| 1 |
############################################################################### |
| 2 |
# Top contributors (to current version): |
| 3 |
# Aina Niemetz, Yoni Zohar, Alex Ozdemir |
| 4 |
# |
| 5 |
# This file is part of the cvc5 project. |
| 6 |
# |
| 7 |
# Copyright (c) 2009-2025 by the authors listed in the file AUTHORS |
| 8 |
# in the top-level source directory and their institutional affiliations. |
| 9 |
# All rights reserved. See the file COPYING in the top-level source |
| 10 |
# directory for licensing information. |
| 11 |
# ############################################################################# |
| 12 |
# |
| 13 |
# A simple test for SolverEngine::resetAssertions() |
| 14 |
# |
| 15 |
# This program indirectly also tests some corner cases w.r.t. |
| 16 |
# context-dependent datastructures: resetAssertions() pops the contexts to |
| 17 |
# zero but some context-dependent datastructures are created at leevel 1, |
| 18 |
# which the datastructure needs to handle properly problematic. |
| 19 |
## |
| 20 |
|
| 21 |
import cvc5 |
| 22 |
from cvc5 import Kind |
| 23 |
|
| 24 |
tm = cvc5.TermManager() |
| 25 |
slv = cvc5.Solver(tm) |
| 26 |
slv.setOption("incremental", "true") |
| 27 |
|
| 28 |
real = tm.getRealSort() |
| 29 |
x = tm.mkConst(real, "x") |
| 30 |
four = tm.mkReal(4) |
| 31 |
xEqFour = tm.mkTerm(Kind.EQUAL, x, four) |
| 32 |
slv.assertFormula(xEqFour) |
| 33 |
print(slv.checkSat()) |
| 34 |
|
| 35 |
slv.resetAssertions() |
| 36 |
|
| 37 |
elementType = tm.getIntegerSort() |
| 38 |
indexType = tm.getIntegerSort() |
| 39 |
arrayType = tm.mkArraySort(indexType, elementType) |
| 40 |
array = tm.mkConst(arrayType, "array") |
| 41 |
fourInt = tm.mkInteger(4) |
| 42 |
arrayAtFour = tm.mkTerm(Kind.SELECT, array, fourInt) |
| 43 |
ten = tm.mkInteger(10) |
| 44 |
arrayAtFour_eq_ten = tm.mkTerm(Kind.EQUAL, arrayAtFour, ten) |
| 45 |
slv.assertFormula(arrayAtFour_eq_ten) |
| 46 |
print(slv.checkSat()) |