2021-04-12 12:31:43 -07:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Top contributors (to current version):
|
2024-03-12 09:35:09 -07:00
|
|
|
* Aina Niemetz, Andres Noetzli, Mathias Preiner
|
2021-04-12 12:31:43 -07:00
|
|
|
*
|
|
|
|
|
* This file is part of the cvc5 project.
|
|
|
|
|
*
|
2025-01-23 09:54:20 -08:00
|
|
|
* Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
|
2021-04-12 12:31:43 -07:00
|
|
|
* in the top-level source directory and their institutional affiliations.
|
|
|
|
|
* All rights reserved. See the file COPYING in the top-level source
|
|
|
|
|
* directory for licensing information.
|
|
|
|
|
* ****************************************************************************
|
|
|
|
|
*
|
2024-07-31 00:01:09 -07:00
|
|
|
* A simple test for cvc5::Solver::resetAssertions()
|
2021-04-12 12:31:43 -07:00
|
|
|
*
|
2024-07-31 00:01:09 -07:00
|
|
|
* This indirectly also tests some corner cases w.r.t. context-dependent
|
|
|
|
|
* datastructures: resetAssertions() pops the contexts to zero but some
|
2025-10-28 06:29:03 -05:00
|
|
|
* context-dependent datastructures are created at level 1, which the
|
2024-07-31 00:01:09 -07:00
|
|
|
* datastructure needs to handle properly problematic.
|
2021-04-12 12:31:43 -07:00
|
|
|
*/
|
2017-12-06 04:45:06 -08:00
|
|
|
|
2023-03-07 15:39:29 -08:00
|
|
|
#include <cvc5/cvc5.h>
|
|
|
|
|
|
2017-12-06 04:45:06 -08:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2022-03-29 16:23:01 -07:00
|
|
|
using namespace cvc5;
|
2017-12-06 04:45:06 -08:00
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2024-03-08 11:39:13 -08:00
|
|
|
TermManager tm;
|
|
|
|
|
Solver slv(tm);
|
2020-06-29 15:35:44 -07:00
|
|
|
slv.setOption("incremental", "true");
|
2017-12-06 04:45:06 -08:00
|
|
|
|
2024-03-08 11:39:13 -08:00
|
|
|
Sort real = tm.getRealSort();
|
|
|
|
|
Term x = tm.mkConst(real, "x");
|
|
|
|
|
Term four = tm.mkReal(4);
|
|
|
|
|
Term xEqFour = tm.mkTerm(Kind::EQUAL, {x, four});
|
2020-06-29 15:35:44 -07:00
|
|
|
slv.assertFormula(xEqFour);
|
|
|
|
|
std::cout << slv.checkSat() << std::endl;
|
2017-12-06 04:45:06 -08:00
|
|
|
|
2020-06-29 15:35:44 -07:00
|
|
|
slv.resetAssertions();
|
2017-12-06 04:45:06 -08:00
|
|
|
|
2024-03-08 11:39:13 -08:00
|
|
|
Sort elementType = tm.getIntegerSort();
|
|
|
|
|
Sort indexType = tm.getIntegerSort();
|
|
|
|
|
Sort arrayType = tm.mkArraySort(indexType, elementType);
|
|
|
|
|
Term array = tm.mkConst(arrayType, "array");
|
|
|
|
|
Term fourInt = tm.mkInteger(4);
|
|
|
|
|
Term arrayAtFour = tm.mkTerm(Kind::SELECT, {array, fourInt});
|
|
|
|
|
Term ten = tm.mkInteger(10);
|
|
|
|
|
Term arrayAtFour_eq_ten = tm.mkTerm(Kind::EQUAL, {arrayAtFour, ten});
|
2020-06-29 15:35:44 -07:00
|
|
|
slv.assertFormula(arrayAtFour_eq_ten);
|
|
|
|
|
std::cout << slv.checkSat() << std::endl;
|
2017-12-06 04:45:06 -08:00
|
|
|
}
|