Skip to content

Commit 03213c1

Browse files
Merge pull request #6165 from thomasspriggs/tas/smt_data_structures
Initial data structures for incremental smt2 solving
2 parents a7bfc10 + 8bc61d6 commit 03213c1

23 files changed

+1816
-4
lines changed

src/solvers/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ SRC = $(BOOLEFORCE_SRC) \
192192
smt2/smt2_parser.cpp \
193193
smt2/smt2_tokenizer.cpp \
194194
smt2/smt2irep.cpp \
195+
smt2_incremental/smt_commands.cpp \
196+
smt2_incremental/smt_logics.cpp \
197+
smt2_incremental/smt_options.cpp \
198+
smt2_incremental/smt_sorts.cpp \
199+
smt2_incremental/smt_terms.cpp \
195200
smt2_incremental/smt2_incremental_decision_procedure.cpp \
196201
# Empty last line
197202

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
@startuml
2+
' This diagram is written using PlantUML. It can be visualised locally or using
3+
' the PlantUML website - http://www.plantuml.com/plantuml/uml/.
4+
' On Linux the visualisation tool can be installed using -
5+
' `sudo apt-get install plantuml`
6+
' Running the `plantuml` binary from the directory where this file exists will
7+
' give the option to view the file.
8+
9+
title SMT2 Internal Abstract Syntax Tree Data Structures
10+
legend bottom right
11+
Specification references refer to "The SMT-LIB Standard" Version 2.6
12+
endlegend
13+
14+
class irept {
15+
--
16+
Protected inheritance to be used to prevent direct data access from outside
17+
of the classes inheriting from it.
18+
__
19+
}
20+
21+
class smt_commandt {
22+
..
23+
Note - Protected constructor, so as to only allow construction as part of a
24+
sub-class. Public copy/upcast/assignment to this class still available.
25+
__
26+
}
27+
irept <|-- smt_commandt
28+
29+
class smt_set_option_commandt {
30+
""(set-option :produce-models true)""
31+
--
32+
Section 4.1.7 page 55
33+
__
34+
option : smt_optiont
35+
}
36+
smt_commandt <|-- smt_set_option_commandt
37+
smt_set_option_commandt *-- smt_optiont
38+
39+
class smt_set_logic_commandt {
40+
(set-logic QF_AUFBV)
41+
--
42+
__
43+
logic : smt_logict
44+
}
45+
smt_commandt <|-- smt_set_logic_commandt
46+
smt_set_logic_commandt *-- smt_logict
47+
48+
class smt_declare_function_commandt {
49+
""(declare-fun |main::1::x!0@1#1| () (_ BitVec 32))""
50+
--
51+
Declares the sort (rank?) of a function, introducing the new identifier
52+
""|main::1::x!0@1#1|"" in the above example.
53+
__
54+
identifier
55+
parameter_sorts : std::vector<smt_sortt>
56+
return_sort : smt_sortt
57+
}
58+
smt_commandt <|-- smt_declare_function_commandt
59+
smt_declare_function_commandt *-- smt_sortt
60+
61+
class smt_define_function_commandt {
62+
""(define-fun |B0| () Bool (= |main::1::x!0@1#1| |main::1::x!0@1#1|))""
63+
--
64+
Defines the implementation of a function. Note that the return_sort could be
65+
stored in the "definition" term because all terms have a sort for our
66+
definition of term.
67+
__
68+
identifier
69+
parameters : std::vector<smt_identifier_termt>
70+
return_sort : smt_sortt
71+
definition : smt_termt
72+
}
73+
smt_commandt <|-- smt_define_function_commandt
74+
smt_define_function_commandt *-- smt_identifier_termt
75+
smt_define_function_commandt *-- smt_sortt
76+
smt_define_function_commandt *-- smt_termt
77+
78+
class smt_assert_commandt {
79+
""(assert |B1|)""
80+
--
81+
Note condition should be of sort ""smt_bool_sortt""
82+
__
83+
condition : smt_termt
84+
}
85+
smt_commandt <|-- smt_assert_commandt
86+
smt_assert_commandt *-- smt_termt
87+
88+
class smt_check_sat_commandt {
89+
""(check-sat)""
90+
..
91+
Section 4.2.5 page 64
92+
__
93+
}
94+
smt_commandt <|-- smt_check_sat_commandt
95+
96+
class smt_get_value_commandt {
97+
""(get-value (|foo|))""
98+
..
99+
Section 4.2.6 page 65
100+
Note: Identifier would usually be a smt_identifier_termt for our use case, but
101+
the syntax allows more flexability than that.
102+
__
103+
identifier : smt_termt
104+
}
105+
smt_commandt <|-- smt_get_value_commandt
106+
smt_get_value_commandt *-- smt_termt
107+
108+
class smt_exit_commandt {
109+
""(exit)""
110+
..
111+
Section 4.2.1 page 59
112+
Instructs the solver process to exit.
113+
__
114+
}
115+
smt_commandt <|-- smt_exit_commandt
116+
117+
class smt_pop_commandt {
118+
""(pop 1)""
119+
..
120+
__
121+
levels : std::size_t
122+
}
123+
smt_commandt <|-- smt_pop_commandt
124+
125+
class smt_push_commandt {
126+
""(push 1)""
127+
..
128+
__
129+
levels : std::size_t
130+
}
131+
smt_commandt <|-- smt_push_commandt
132+
133+
class smt_termt {
134+
..
135+
Section 3.6 page 26
136+
Analogous to `exprt`.
137+
Note - Protected constructor, so as to only allow construction as part of a
138+
sub-class. Public copy/upcast/assignment to this class still available.
139+
__
140+
sort : smt_sortt
141+
}
142+
irept <|-- smt_termt
143+
smt_termt *-- smt_sortt
144+
145+
class smt_optiont {
146+
..
147+
Note - Protected constructor, so as to only allow construction as part of a
148+
sub-class. Public copy/upcast/assignment to this class still available.
149+
__
150+
}
151+
irept <|-- smt_optiont
152+
153+
class smt_option_produce_modelst {
154+
:produce-models true
155+
..
156+
Section 4.1.7 page 56
157+
__
158+
value : bool
159+
}
160+
smt_optiont <|-- smt_option_produce_modelst
161+
162+
class smt_logict {
163+
..
164+
Note - Protected constructor, so as to only allow construction as part of a
165+
sub-class. Public copy/upcast/assignment to this class still available.
166+
__
167+
}
168+
irept <|-- smt_logict
169+
170+
class smt_logic_qf_aufbvt {
171+
""QF_AUFBV""
172+
..
173+
https://smtlib.cs.uiowa.edu/logics-all.shtml
174+
__
175+
}
176+
smt_logict <|-- smt_logic_qf_aufbvt
177+
178+
class smt_bool_literal_termt {
179+
""true""
180+
""false""
181+
..
182+
Sort is set to smt_bool_sortt in constructor. Idea - factory member functions
183+
for true and false.
184+
__
185+
value : bool
186+
}
187+
smt_termt <-- smt_bool_literal_termt
188+
189+
class smt_bit_vector_constant_termt {
190+
""(_ bv0 32)""
191+
..
192+
http://smtlib.cs.uiowa.edu/logics-all.shtml#QF_BV - See bitvector constants
193+
__
194+
value : mp_integert
195+
width : std::size_t
196+
}
197+
smt_termt <|-- smt_bit_vector_constant_termt
198+
199+
class smt_identifier_termt {
200+
""|main::1::x!0@1#1|""
201+
..
202+
__
203+
value : irep_idt
204+
}
205+
smt_termt <|-- smt_identifier_termt
206+
207+
class smt_not_termt {
208+
(not false)
209+
..
210+
__
211+
operand : smt_termt
212+
}
213+
smt_termt <|-- smt_not_termt
214+
smt_not_termt *-- smt_termt
215+
216+
class smt_function_application_termt {
217+
""(= x y)""
218+
..
219+
Section 3.6 page 27.
220+
Sort checking should be carried out somewhere, to confirm that the sorts of
221+
the term arguments match the sorts of the function definition.
222+
__
223+
function_identifier : irep_idt
224+
arguments : std::vector<smt_termt>
225+
}
226+
smt_termt <|-- smt_function_application_termt
227+
228+
class smt_sortt {
229+
..
230+
Section 3.5 page 26
231+
Analogous to `typet`.
232+
Note - Protected constructor, so as to only allow construction as part of a
233+
sub-class. Public copy/upcast/assignment to this class still available.
234+
__
235+
}
236+
irept <|-- smt_sortt
237+
238+
class smt_bool_sortt {
239+
""Bool""
240+
..
241+
Section 3.5 page 26
242+
__
243+
}
244+
smt_sortt <|-- smt_bool_sortt
245+
246+
class smt_bit_vector_sortt {
247+
""(_ BitVec 32)""
248+
..
249+
http://smtlib.cs.uiowa.edu/theories-FixedSizeBitVectors.shtml
250+
__
251+
bit_width : std::size_t
252+
}
253+
smt_sortt <|-- smt_bit_vector_sortt
254+
255+
@enduml

0 commit comments

Comments
 (0)