| 1 |
/****************************************************************************** |
| 2 |
* Top contributors (to current version): |
| 3 |
* Daniel Larraz |
| 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 cvc5.Solver.resetAssertions() |
| 14 |
* |
| 15 |
* This indirectly also tests some corner cases w.r.t. context-dependent |
| 16 |
* datastructures: resetAssertions() pops the contexts to zero but some |
| 17 |
* context-dependent datastructures are created at level 1, which the |
| 18 |
* datastructure needs to handle properly problematic. |
| 19 |
*/ |
| 20 |
|
| 21 |
import io.github.cvc5.*; |
| 22 |
|
| 23 |
public class ResetAssertions |
| 24 |
{ |
| 25 |
public static void main(String[] args) |
| 26 |
{ |
| 27 |
TermManager tm = new TermManager(); |
| 28 |
Solver slv = new Solver(tm); |
| 29 |
slv.setOption("incremental", "true"); |
| 30 |
|
| 31 |
Sort real = tm.getRealSort(); |
| 32 |
Term x = tm.mkConst(real, "x"); |
| 33 |
Term four = tm.mkReal(4); |
| 34 |
Term xEqFour = tm.mkTerm(Kind.EQUAL, x, four); |
| 35 |
slv.assertFormula(xEqFour); |
| 36 |
System.out.println(slv.checkSat()); |
| 37 |
|
| 38 |
slv.resetAssertions(); |
| 39 |
|
| 40 |
Sort elementType = tm.getIntegerSort(); |
| 41 |
Sort indexType = tm.getIntegerSort(); |
| 42 |
Sort arrayType = tm.mkArraySort(indexType, elementType); |
| 43 |
Term array = tm.mkConst(arrayType, "array"); |
| 44 |
Term fourInt = tm.mkInteger(4); |
| 45 |
Term arrayAtFour = tm.mkTerm(Kind.SELECT, array, fourInt); |
| 46 |
Term ten = tm.mkInteger(10); |
| 47 |
Term arrayAtFourEqTen = tm.mkTerm(Kind.EQUAL, arrayAtFour, ten); |
| 48 |
slv.assertFormula(arrayAtFourEqTen); |
| 49 |
System.out.println(slv.checkSat()); |
| 50 |
} |
| 51 |
} |