1 /********************* */
4 ** Original author: cconway
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
14 ** \brief Definitions of SMT2 constants.
16 ** Definitions of SMT2 constants.
19 #include "expr/type.h"
20 #include "expr/command.h"
21 #include "parser/parser.h"
22 #include "parser/smt/smt.h"
23 #include "parser/smt2/smt2.h"
28 Smt2::Smt2(ExprManager
* exprManager
, Input
* input
, bool strictMode
, bool parseOnly
) :
29 Parser(exprManager
,input
,strictMode
,parseOnly
),
31 if( !strictModeEnabled() ) {
32 addTheory(Smt2::THEORY_CORE
);
36 void Smt2::addArithmeticOperators() {
37 addOperator(kind::PLUS
);
38 addOperator(kind::MINUS
);
39 addOperator(kind::UMINUS
);
40 addOperator(kind::MULT
);
41 addOperator(kind::DIVISION
);
42 addOperator(kind::LT
);
43 addOperator(kind::LEQ
);
44 addOperator(kind::GT
);
45 addOperator(kind::GEQ
);
48 void Smt2::addTheory(Theory theory
) {
51 defineType("Bool", getExprManager()->booleanType());
52 defineVar("true", getExprManager()->mkConst(true));
53 defineVar("false", getExprManager()->mkConst(false));
54 addOperator(kind::AND
);
55 addOperator(kind::EQUAL
);
56 addOperator(kind::IFF
);
57 addOperator(kind::IMPLIES
);
58 addOperator(kind::ITE
);
59 addOperator(kind::NOT
);
60 addOperator(kind::OR
);
61 addOperator(kind::XOR
);
65 // FIXME: should define a paramterized type 'Array' with 2 arguments
68 addOperator(kind::SELECT
);
69 addOperator(kind::STORE
);
72 case THEORY_REALS_INTS
:
73 defineType("Real", getExprManager()->realType());
74 // falling-through on purpose, to add Ints part of RealsInts
77 defineType("Int", getExprManager()->integerType());
78 addArithmeticOperators();
82 defineType("Real", getExprManager()->realType());
83 addArithmeticOperators();
86 case THEORY_BITVECTORS
:
94 bool Smt2::logicIsSet() {
98 void Smt2::setLogic(const std::string
& name
) {
100 d_logic
= Smt::toLogic(name
);
102 // Core theory belongs to every logic
103 addTheory(THEORY_CORE
);
107 /* No extra symbols necessary */
111 addTheory(THEORY_ARRAYS
);
117 addTheory(THEORY_INTS
);
123 addTheory(THEORY_REALS
);
127 addOperator(kind::APPLY_UF
);
132 case Smt::QF_UFNIA
:// nonstandard logic
133 addTheory(THEORY_INTS
);
134 addOperator(kind::APPLY_UF
);
139 addTheory(THEORY_REALS
);
140 addOperator(kind::APPLY_UF
);
143 case Smt::QF_UFLIRA
:// nonstandard logic
144 case Smt::QF_UFNIRA
:// nonstandard logic
145 addOperator(kind::APPLY_UF
);
146 addTheory(THEORY_INTS
);
147 addTheory(THEORY_REALS
);
151 addTheory(THEORY_BITVECTORS
);
155 addTheory(THEORY_ARRAYS
);
156 addTheory(THEORY_BITVECTORS
);
160 addOperator(kind::APPLY_UF
);
161 addTheory(THEORY_BITVECTORS
);
165 addOperator(kind::APPLY_UF
);
166 addTheory(THEORY_ARRAYS
);
167 addTheory(THEORY_BITVECTORS
);
170 case Smt::QF_AUFBVLIA
:
171 addOperator(kind::APPLY_UF
);
172 addTheory(THEORY_ARRAYS
);
173 addTheory(THEORY_BITVECTORS
);
174 addTheory(THEORY_INTS
);
177 case Smt::QF_AUFBVLRA
:
178 addOperator(kind::APPLY_UF
);
179 addTheory(THEORY_ARRAYS
);
180 addTheory(THEORY_BITVECTORS
);
181 addTheory(THEORY_REALS
);
185 addTheory(THEORY_ARRAYS
);
186 addOperator(kind::APPLY_UF
);
187 addTheory(THEORY_INTS
);
190 case Smt::QF_AUFLIRA
:
191 addTheory(THEORY_ARRAYS
);
192 addOperator(kind::APPLY_UF
);
193 addTheory(THEORY_INTS
);
194 addTheory(THEORY_REALS
);
197 case Smt::ALL_SUPPORTED
:
199 case Smt::QF_ALL_SUPPORTED
:
200 addTheory(THEORY_ARRAYS
);
201 addOperator(kind::APPLY_UF
);
202 addTheory(THEORY_INTS
);
203 addTheory(THEORY_REALS
);
204 addTheory(THEORY_BITVECTORS
);
217 void Smt2::setInfo(const std::string
& flag
, const SExpr
& sexpr
) {
221 void Smt2::setOption(const std::string
& flag
, const SExpr
& sexpr
) {
225 void Smt2::checkThatLogicIsSet() {
226 if( ! logicIsSet() ) {
227 if( strictModeEnabled() ) {
228 parseError("set-logic must appear before this point.");
230 warning("No set-logic command was given before this point.");
231 warning("CVC4 will assume the non-standard ALL_SUPPORTED logic.");
232 warning("Consider setting a stricter logic for (likely) better performance.");
233 warning("To suppress this warning in the future use (set-logic ALL_SUPPORTED).");
235 setLogic("ALL_SUPPORTED");
237 preemptCommand(new SetBenchmarkLogicCommand("ALL_SUPPORTED"));
242 }/* CVC4::parser namespace */
243 }/* CVC4 namespace */