You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: SMT Verificaiton Module: Data Structures (#13658)
This pr adds new Symbolic objects: Tuple, Array and Set
# Data Structures
- Added `STuple`, `SymArray`, `SymSet` classes to ease up lookup tables
and ROM/RAM arrays symbolic translation
- Reflected new symbolic objects in `UltraCircuit`, `STerm` and `Solver`
- Added tests for all of the new structures
- Added pretty print for these structures
# Bool
added tests for symbolic bool class
# Solver
- Added a few more default solver configurations to use.
- Added `ff_bitsum` option to solver config. It allows solver to
understand bitsums (namely constraints of the form `b0 + 2 * b1 + 4 * b2
+ ... == X`)
- Added few more debug solver options
- Added few options to handle arrays and sets
- Fixed a bug: `lookup_enabled` was not handled properly
Copy file name to clipboardExpand all lines: barretenberg/cpp/src/barretenberg/smt_verification/README.md
+90-2Lines changed: 90 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,8 @@ To store it on the disk just do the following
134
134
135
135
4. Terms creation
136
136
137
+
### Arithmetic Variables
138
+
137
139
You can initialize symbolic variable via `STerm::Var(str name, &solver, TermType type)` or `STerm::Const(str val, &solver, TermType type, u32 base=16)`
138
140
139
141
But also you can use `FFVar(str name, &Solver)` or equivalently via `FFIVar` and `BVVar` so you don't have to mess with types.
@@ -162,10 +164,12 @@ To store it on the disk just do the following
162
164
- `STerm::in(cvc5::Term table&)` - simple set inclusion.
You can `|, &, ==, !=, !` these variables and also `batch_or`, `batch_and` them.
171
175
To create a constraint you should call `Bool::assert_term()` method.
@@ -175,6 +179,84 @@ To store it on the disk just do the following
175
179
**!Note that constraint like `(Bool(STerm a) == Bool(STerm b)).assert_term()`, where a has `FFTerm` type and b has `FFITerm` type, won't work, since their types differ.**
176
180
**!Note `Bool(a == b)` won't work since `a==b` will create an equality constraint as I mentioned earlier and the return type of this operation is `void`.**
177
181
182
+
---
183
+
184
+
### Data Structures
185
+
186
+
There're three extra data structures:
187
+
188
+
#### STuple
189
+
190
+
Symbolic Tuple type.
191
+
You can group several items in one term.
192
+
**!Note Only compatible with `STerm` class**
193
+
194
+
`STuple STuple(vec<STerm>, Solver* slv)`
195
+
196
+
**!Note that you can not access the element of the tuple by its index after creation**
197
+
198
+
#### SymArray
199
+
200
+
Symbolic Array type.
201
+
You can store symbolic values. And access them by symbolic index.
202
+
203
+
Both index and entry can be any of the symbolic types: `STerm`, `Bool`, `STuple`, `SymArray`, `SymSet`
***!Note passing cvc5 native types directly is a little bit advanced compared to the ordinary usage of this module. See the tests***
209
+
210
+
Create an array from indicies and entrys:
211
+
`SymArray SymArray<sym_index, sym_entry>(vector<sym_index> indicies, vec<sym_entry> entries, str name = "")`
212
+
213
+
Create an integer indexed array from entries:
214
+
`SymArray SymArray<sym_index, sym_entry>(vec<sym_entry> entries, STerm index_base, str name = "")`
215
+
216
+
**!Note you need to provide an example for the integer like index entry. Most of the time you'll be fine using: `index_base` = `FFConst(1, &slv)`| `FFIConst(1, &slv)`| `IConst(1, &slv)`| `BVConst(1, &slv)`**
217
+
218
+
After you've created an array you can put/overwrite elements in it by:
219
+
220
+
`arr.put(sym_idx, sym_entry)`
221
+
222
+
And access them:
223
+
224
+
`arr.get(sym_idx)`
225
+
`arr[sym_idx]`
226
+
227
+
228
+
For debugging purposes there's a `print_trace` method, that will print all the `put` operations
229
+
230
+
#### SymSet
231
+
232
+
Symbolic Set type.
233
+
You can store symbolic values. You can check wheter an element belong to the set or not.
234
+
235
+
Entries can be any of the symbolic types: `STerm`, `Bool`, `STuple`, `SymArray`, `SymSet`
0 commit comments