2022-04-05 13:38:57 -07:00
|
|
|
###############################################################################
|
2021-12-01 03:38:45 +02:00
|
|
|
# Top contributors (to current version):
|
2022-04-05 13:38:57 -07:00
|
|
|
# Yoni Zohar, Alex Ozdemir, Aina Niemetz
|
2021-12-01 03:38:45 +02:00
|
|
|
#
|
|
|
|
|
# This file is part of the cvc5 project.
|
|
|
|
|
#
|
2022-04-05 13:38:57 -07:00
|
|
|
# Copyright (c) 2009-2022 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
|
|
|
|
2022-02-02 15:45:42 -08:00
|
|
|
slv = cvc5.Solver()
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.setOption("incremental", "true")
|
|
|
|
|
|
|
|
|
|
real = slv.getRealSort()
|
|
|
|
|
x = slv.mkConst(real, "x")
|
2022-05-06 21:22:12 -05:00
|
|
|
four = slv.mkReal(4)
|
2022-04-01 12:45:36 -07:00
|
|
|
xEqFour = slv.mkTerm(Kind.EQUAL, x, four)
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.assertFormula(xEqFour)
|
|
|
|
|
print(slv.checkSat())
|
|
|
|
|
|
|
|
|
|
slv.resetAssertions()
|
|
|
|
|
|
|
|
|
|
elementType = slv.getIntegerSort()
|
|
|
|
|
indexType = slv.getIntegerSort()
|
|
|
|
|
arrayType = slv.mkArraySort(indexType, elementType)
|
|
|
|
|
array = slv.mkConst(arrayType, "array")
|
2022-05-06 21:22:12 -05:00
|
|
|
fourInt = slv.mkInteger(4)
|
|
|
|
|
arrayAtFour = slv.mkTerm(Kind.SELECT, array, fourInt)
|
2021-12-01 03:38:45 +02:00
|
|
|
ten = slv.mkInteger(10)
|
2022-04-01 12:45:36 -07:00
|
|
|
arrayAtFour_eq_ten = slv.mkTerm(Kind.EQUAL, arrayAtFour, ten)
|
2021-12-01 03:38:45 +02:00
|
|
|
slv.assertFormula(arrayAtFour_eq_ten)
|
|
|
|
|
print(slv.checkSat())
|