-
Notifications
You must be signed in to change notification settings - Fork 274
Initial data structures for incremental smt2 solving #6165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thomasspriggs
merged 12 commits into
diffblue:develop
from
thomasspriggs:tas/smt_data_structures
Jul 20, 2021
+1,816
−4
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
596a0bd
Add foundational smt sorts
thomasspriggs 6990a69
Add smt sort downcast visitor
thomasspriggs 5a81e6b
Add operator== to smt_sortt
thomasspriggs 03534cb
Add `smt_sortt::storer` as a way add storage of sorts
thomasspriggs 2e1744f
Add smt_terms data structures
thomasspriggs 416d18a
Rewrite unit test counting in python
thomasspriggs 1b5e426
Include `TEMPLATE_TEST_CASE`s in test count
thomasspriggs fbffc09
Add `smt_termt` visitor
thomasspriggs abff630
Add controlled upcasting of smt_termt for storage implementions
thomasspriggs fabc43a
Add smt commands
thomasspriggs c9a3de1
Add smt_command downcast visitor
thomasspriggs 8bc61d6
Add class diagram for internal SMT AST classes
thomasspriggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
@startuml | ||
' This diagram is written using PlantUML. It can be visualised locally or using | ||
' the PlantUML website - http://www.plantuml.com/plantuml/uml/. | ||
' On Linux the visualisation tool can be installed using - | ||
' `sudo apt-get install plantuml` | ||
' Running the `plantuml` binary from the directory where this file exists will | ||
' give the option to view the file. | ||
|
||
title SMT2 Internal Abstract Syntax Tree Data Structures | ||
legend bottom right | ||
Specification references refer to "The SMT-LIB Standard" Version 2.6 | ||
endlegend | ||
|
||
class irept { | ||
-- | ||
Protected inheritance to be used to prevent direct data access from outside | ||
of the classes inheriting from it. | ||
__ | ||
} | ||
|
||
class smt_commandt { | ||
.. | ||
Note - Protected constructor, so as to only allow construction as part of a | ||
sub-class. Public copy/upcast/assignment to this class still available. | ||
__ | ||
} | ||
irept <|-- smt_commandt | ||
|
||
class smt_set_option_commandt { | ||
""(set-option :produce-models true)"" | ||
-- | ||
Section 4.1.7 page 55 | ||
__ | ||
option : smt_optiont | ||
} | ||
smt_commandt <|-- smt_set_option_commandt | ||
smt_set_option_commandt *-- smt_optiont | ||
|
||
class smt_set_logic_commandt { | ||
(set-logic QF_AUFBV) | ||
-- | ||
__ | ||
logic : smt_logict | ||
} | ||
smt_commandt <|-- smt_set_logic_commandt | ||
smt_set_logic_commandt *-- smt_logict | ||
|
||
class smt_declare_function_commandt { | ||
""(declare-fun |main::1::x!0@1#1| () (_ BitVec 32))"" | ||
-- | ||
Declares the sort (rank?) of a function, introducing the new identifier | ||
""|main::1::x!0@1#1|"" in the above example. | ||
__ | ||
identifier | ||
parameter_sorts : std::vector<smt_sortt> | ||
return_sort : smt_sortt | ||
} | ||
smt_commandt <|-- smt_declare_function_commandt | ||
smt_declare_function_commandt *-- smt_sortt | ||
|
||
class smt_define_function_commandt { | ||
""(define-fun |B0| () Bool (= |main::1::x!0@1#1| |main::1::x!0@1#1|))"" | ||
-- | ||
Defines the implementation of a function. Note that the return_sort could be | ||
stored in the "definition" term because all terms have a sort for our | ||
definition of term. | ||
__ | ||
identifier | ||
parameters : std::vector<smt_identifier_termt> | ||
return_sort : smt_sortt | ||
definition : smt_termt | ||
} | ||
smt_commandt <|-- smt_define_function_commandt | ||
smt_define_function_commandt *-- smt_identifier_termt | ||
smt_define_function_commandt *-- smt_sortt | ||
smt_define_function_commandt *-- smt_termt | ||
|
||
class smt_assert_commandt { | ||
""(assert |B1|)"" | ||
-- | ||
Note condition should be of sort ""smt_bool_sortt"" | ||
__ | ||
condition : smt_termt | ||
} | ||
smt_commandt <|-- smt_assert_commandt | ||
smt_assert_commandt *-- smt_termt | ||
|
||
class smt_check_sat_commandt { | ||
""(check-sat)"" | ||
.. | ||
Section 4.2.5 page 64 | ||
__ | ||
} | ||
smt_commandt <|-- smt_check_sat_commandt | ||
|
||
class smt_get_value_commandt { | ||
""(get-value (|foo|))"" | ||
.. | ||
Section 4.2.6 page 65 | ||
Note: Identifier would usually be a smt_identifier_termt for our use case, but | ||
the syntax allows more flexability than that. | ||
__ | ||
identifier : smt_termt | ||
} | ||
smt_commandt <|-- smt_get_value_commandt | ||
smt_get_value_commandt *-- smt_termt | ||
|
||
class smt_exit_commandt { | ||
""(exit)"" | ||
.. | ||
Section 4.2.1 page 59 | ||
Instructs the solver process to exit. | ||
__ | ||
} | ||
smt_commandt <|-- smt_exit_commandt | ||
|
||
class smt_pop_commandt { | ||
""(pop 1)"" | ||
.. | ||
__ | ||
levels : std::size_t | ||
} | ||
smt_commandt <|-- smt_pop_commandt | ||
|
||
class smt_push_commandt { | ||
""(push 1)"" | ||
.. | ||
__ | ||
levels : std::size_t | ||
} | ||
smt_commandt <|-- smt_push_commandt | ||
|
||
class smt_termt { | ||
.. | ||
Section 3.6 page 26 | ||
Analogous to `exprt`. | ||
Note - Protected constructor, so as to only allow construction as part of a | ||
sub-class. Public copy/upcast/assignment to this class still available. | ||
__ | ||
sort : smt_sortt | ||
} | ||
irept <|-- smt_termt | ||
smt_termt *-- smt_sortt | ||
|
||
class smt_optiont { | ||
.. | ||
Note - Protected constructor, so as to only allow construction as part of a | ||
sub-class. Public copy/upcast/assignment to this class still available. | ||
__ | ||
} | ||
irept <|-- smt_optiont | ||
|
||
class smt_option_produce_modelst { | ||
:produce-models true | ||
.. | ||
Section 4.1.7 page 56 | ||
__ | ||
value : bool | ||
} | ||
smt_optiont <|-- smt_option_produce_modelst | ||
|
||
class smt_logict { | ||
.. | ||
Note - Protected constructor, so as to only allow construction as part of a | ||
sub-class. Public copy/upcast/assignment to this class still available. | ||
__ | ||
} | ||
irept <|-- smt_logict | ||
|
||
class smt_logic_qf_aufbvt { | ||
""QF_AUFBV"" | ||
.. | ||
https://smtlib.cs.uiowa.edu/logics-all.shtml | ||
__ | ||
} | ||
smt_logict <|-- smt_logic_qf_aufbvt | ||
|
||
class smt_bool_literal_termt { | ||
""true"" | ||
""false"" | ||
.. | ||
Sort is set to smt_bool_sortt in constructor. Idea - factory member functions | ||
for true and false. | ||
__ | ||
value : bool | ||
} | ||
smt_termt <-- smt_bool_literal_termt | ||
|
||
class smt_bit_vector_constant_termt { | ||
""(_ bv0 32)"" | ||
.. | ||
http://smtlib.cs.uiowa.edu/logics-all.shtml#QF_BV - See bitvector constants | ||
__ | ||
value : mp_integert | ||
width : std::size_t | ||
} | ||
smt_termt <|-- smt_bit_vector_constant_termt | ||
|
||
class smt_identifier_termt { | ||
""|main::1::x!0@1#1|"" | ||
.. | ||
__ | ||
value : irep_idt | ||
} | ||
smt_termt <|-- smt_identifier_termt | ||
|
||
class smt_not_termt { | ||
(not false) | ||
.. | ||
__ | ||
operand : smt_termt | ||
} | ||
smt_termt <|-- smt_not_termt | ||
smt_not_termt *-- smt_termt | ||
|
||
class smt_function_application_termt { | ||
""(= x y)"" | ||
.. | ||
Section 3.6 page 27. | ||
Sort checking should be carried out somewhere, to confirm that the sorts of | ||
the term arguments match the sorts of the function definition. | ||
__ | ||
function_identifier : irep_idt | ||
arguments : std::vector<smt_termt> | ||
} | ||
smt_termt <|-- smt_function_application_termt | ||
|
||
class smt_sortt { | ||
.. | ||
Section 3.5 page 26 | ||
Analogous to `typet`. | ||
Note - Protected constructor, so as to only allow construction as part of a | ||
sub-class. Public copy/upcast/assignment to this class still available. | ||
__ | ||
} | ||
irept <|-- smt_sortt | ||
|
||
class smt_bool_sortt { | ||
""Bool"" | ||
.. | ||
Section 3.5 page 26 | ||
__ | ||
} | ||
smt_sortt <|-- smt_bool_sortt | ||
|
||
class smt_bit_vector_sortt { | ||
""(_ BitVec 32)"" | ||
.. | ||
http://smtlib.cs.uiowa.edu/theories-FixedSizeBitVectors.shtml | ||
__ | ||
bit_width : std::size_t | ||
} | ||
smt_sortt <|-- smt_bit_vector_sortt | ||
|
||
@enduml |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is great to have (and also to be able to generate). I just have the general concern that this is not generated or linked from the source code? How easy will it be for the two to lose synchronisation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a doxygen plugin which can generate a graph. However I remember these being less than ideal. I suggest we either keep the plantUML and live with the reality that it will likely get out of date, or I remove it entirely and put any useful information from the graph nodes into the doxygen above the corresponding classes.