summaryrefslogtreecommitdiffstats
path: root/z3-solver/src/solving/z3/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'z3-solver/src/solving/z3/mod.rs')
-rw-r--r--z3-solver/src/solving/z3/mod.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/z3-solver/src/solving/z3/mod.rs b/z3-solver/src/solving/z3/mod.rs
new file mode 100644
index 0000000..2f29073
--- /dev/null
+++ b/z3-solver/src/solving/z3/mod.rs
@@ -0,0 +1,44 @@
1use super::{Solver, FloatHandle};
2
3use std::collections::HashMap;
4
5pub struct Z3Solver {
6 ctx: z3::Context,
7}
8
9pub struct Handles<'a> {
10 float: HashMap<u32, z3::ast::Real<'a>>,
11 float_max_id: u32,
12}
13
14impl<'a> Handles<'a> {
15 pub fn new() -> Self {
16 Self {
17 float: HashMap::new(),
18 float_max_id: 0,
19 }
20 }
21}
22
23impl Z3Solver {
24 pub fn new<'a>() -> (Self, Handles<'a>) {
25 let config = z3::Config::new();
26
27 (
28 Self {
29 ctx: z3::Context::new(&config),
30 },
31 Handles::new(),
32 )
33 }
34}
35
36impl Solver for Z3Solver {
37 fn new_float<'a>(&'a mut self, handles: &mut Handles<'a>) -> FloatHandle {
38 let id = handles.float_max_id;
39 let float = z3::ast::Real::new_const(&self.ctx, id);
40 handles.float_max_id += 1;
41 handles.float.insert(id, float);
42 FloatHandle(id)
43 }
44}