2022-04-05 13:38:57 -07:00
|
|
|
###############################################################################
|
2021-12-01 03:38:45 +02:00
|
|
|
# Top contributors (to current version):
|
2025-01-23 09:54:20 -08:00
|
|
|
# Aina Niemetz, Yoni Zohar, Alex Ozdemir
|
2021-12-01 03:38:45 +02: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-12-01 03:38:45 +02: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.
|
2022-04-05 13:38:57 -07:00
|
|
|
# #############################################################################
|
2021-12-01 03:38:45 +02:00
|
|
|
#
|
|
|
|
|
# A simple test for SolverEngine::resetAssertions()
|
|
|
|
|
#
|
|
|
|
|
# This program indirectly also tests some corner cases w.r.t.
|
|
|
|
|
# context-dependent datastructures: resetAssertions() pops the contexts to
|
|
|
|
|
# zero but some context-dependent datastructures are created at leevel 1,
|
|
|
|
|
# which the datastructure needs to handle properly problematic.
|
|
|
|
|
##
|
|
|
|
|
|
2022-02-02 15:45:42 -08:00
|
|
|
import cvc5
|
|
|
|
|
from cvc5 import Kind
|
2021-12-01 03:38:45 +02:00
|
|
|
|
2024-03-14 14:34:58 -07:00
|
|
|
tm = cvc5.TermManager()
|
|
|
|
|
slv = cvc5.Solver(tm)
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.setOption("incremental", "true")
|
|
|
|
|
|
2024-03-14 14:34:58 -07:00
|
|
|
real = tm.getRealSort()
|
|
|
|
|
x = tm.mkConst(real, "x")
|
|
|
|
|
four = tm.mkReal(4)
|
|
|
|
|
xEqFour = tm.mkTerm(Kind.EQUAL, x, four)
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.assertFormula(xEqFour)
|
|
|
|
|
print(slv.checkSat())
|
|
|
|
|
|
|
|
|
|
slv.resetAssertions()
|
|
|
|
|
|
2024-03-14 14:34:58 -07:00
|
|
|
elementType = tm.getIntegerSort()
|
|
|
|
|
indexType = tm.getIntegerSort()
|
|
|
|
|
arrayType = tm.mkArraySort(indexType, elementType)
|
|
|
|
|
array = tm.mkConst(arrayType, "array")
|
|
|
|
|
fourInt = tm.mkInteger(4)
|
|
|
|
|
arrayAtFour = tm.mkTerm(Kind.SELECT, array, fourInt)
|
|
|
|
|
ten = tm.mkInteger(10)
|
|
|
|
|
arrayAtFour_eq_ten = tm.mkTerm(Kind.EQUAL, arrayAtFour, ten)
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.assertFormula(arrayAtFour_eq_ten)
|
|
|
|
|
print(slv.checkSat())
|