summaryrefslogtreecommitdiffstats
path: root/z3-solver/src/lib.rs
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2022-12-25 15:46:31 +0100
committerMinijackson <minijackson@riseup.net>2022-12-25 15:46:31 +0100
commit30f7d39ca2ed4590b5d356b1a4c024d11156a383 (patch)
tree115d8af6f02ec6d42e0a794ac57c391f3d10d6f7 /z3-solver/src/lib.rs
parent92a02c34628343153b33602eae00cef46e28d191 (diff)
downloaddiaphragm-30f7d39ca2ed4590b5d356b1a4c024d11156a383.tar.gz
diaphragm-30f7d39ca2ed4590b5d356b1a4c024d11156a383.zip
WIP before core rewrite
Diffstat (limited to 'z3-solver/src/lib.rs')
-rw-r--r--z3-solver/src/lib.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/z3-solver/src/lib.rs b/z3-solver/src/lib.rs
index 04d77eb..35a17a8 100644
--- a/z3-solver/src/lib.rs
+++ b/z3-solver/src/lib.rs
@@ -45,7 +45,7 @@ impl<'z3> Z3Context<'z3> {
45 pub fn new(ctx: &'z3 z3::Context) -> Self { 45 pub fn new(ctx: &'z3 z3::Context) -> Self {
46 Self { 46 Self {
47 ctx, 47 ctx,
48 solver: z3::Solver::new(&ctx), 48 solver: z3::Solver::new(ctx),
49 floats: HashMap::new(), 49 floats: HashMap::new(),
50 max_float_id: 0, 50 max_float_id: 0,
51 bools: HashMap::new(), 51 bools: HashMap::new(),
@@ -85,7 +85,7 @@ impl<'z3> Z3Context<'z3> {
85 let handle = match f { 85 let handle = match f {
86 Float::Fixed(value) => { 86 Float::Fixed(value) => {
87 let (num, den) = value_to_num_den(value); 87 let (num, den) = value_to_num_den(value);
88 return z3::ast::Real::from_real(&self.ctx, num, den); 88 return z3::ast::Real::from_real(self.ctx, num, den);
89 } 89 }
90 Float::Variable(handle) => handle, 90 Float::Variable(handle) => handle,
91 }; 91 };
@@ -128,7 +128,7 @@ impl<'z3> SolverContext for Z3Context<'z3> {
128 let id = self.max_float_id; 128 let id = self.max_float_id;
129 let handle = VariableHandle::new(id as usize); 129 let handle = VariableHandle::new(id as usize);
130 self.floats 130 self.floats
131 .insert(handle, z3::ast::Real::new_const(&self.ctx, id)); 131 .insert(handle, z3::ast::Real::new_const(self.ctx, id));
132 Float::from_handle(handle) 132 Float::from_handle(handle)
133 } 133 }
134 134
@@ -140,7 +140,7 @@ impl<'z3> SolverContext for Z3Context<'z3> {
140 let (num, den) = value_to_num_den(value); 140 let (num, den) = value_to_num_den(value);
141 141
142 self.floats 142 self.floats
143 .insert(handle, z3::ast::Real::from_real(&self.ctx, num, den)); 143 .insert(handle, z3::ast::Real::from_real(self.ctx, num, den));
144 Float::from_handle(handle) 144 Float::from_handle(handle)
145 } 145 }
146 146
@@ -236,7 +236,7 @@ impl<'z3> SolverContext for Z3Context<'z3> {
236 let id = self.max_bool_id; 236 let id = self.max_bool_id;
237 let handle = VariableHandle::new(id as usize); 237 let handle = VariableHandle::new(id as usize);
238 self.bools 238 self.bools
239 .insert(handle, z3::ast::Bool::new_const(&self.ctx, id)); 239 .insert(handle, z3::ast::Bool::new_const(self.ctx, id));
240 Bool::new(handle) 240 Bool::new(handle)
241 } 241 }
242 242
@@ -246,21 +246,21 @@ impl<'z3> SolverContext for Z3Context<'z3> {
246 let handle = VariableHandle::new(id as usize); 246 let handle = VariableHandle::new(id as usize);
247 247
248 self.bools 248 self.bools
249 .insert(handle, z3::ast::Bool::from_bool(&self.ctx, value)); 249 .insert(handle, z3::ast::Bool::from_bool(self.ctx, value));
250 Bool::new(handle) 250 Bool::new(handle)
251 } 251 }
252 252
253 fn bool_eq(&mut self, lhs: Bool, rhs: Bool) -> Bool { 253 fn bool_eq(&mut self, lhs: Bool, rhs: Bool) -> Bool {
254 let lhs = self.bool(lhs); 254 let lhs = self.bool(lhs);
255 let rhs = self.bool(rhs); 255 let rhs = self.bool(rhs);
256 let result = lhs._eq(&rhs); 256 let result = lhs._eq(rhs);
257 self.anon_bool(result) 257 self.anon_bool(result)
258 } 258 }
259 259
260 fn bool_ne(&mut self, lhs: Bool, rhs: Bool) -> Bool { 260 fn bool_ne(&mut self, lhs: Bool, rhs: Bool) -> Bool {
261 let lhs = self.bool(lhs); 261 let lhs = self.bool(lhs);
262 let rhs = self.bool(rhs); 262 let rhs = self.bool(rhs);
263 let result = lhs._eq(&rhs).not(); 263 let result = lhs._eq(rhs).not();
264 self.anon_bool(result) 264 self.anon_bool(result)
265 } 265 }
266 266
@@ -308,7 +308,7 @@ impl SolverModel for Z3Model<'_> {
308 308
309 let (num, den) = self 309 let (num, den) = self
310 .model 310 .model
311 .eval::<z3::ast::Real>(self.ctx.floats.get(&handle).expect("Couldn't find float")) 311 .eval::<z3::ast::Real>(self.ctx.floats.get(&handle).expect("Couldn't find float"), true)
312 .unwrap() 312 .unwrap()
313 .as_real() 313 .as_real()
314 .unwrap(); 314 .unwrap();
@@ -319,7 +319,7 @@ impl SolverModel for Z3Model<'_> {
319 fn eval_bool(&self, f: Bool) -> Option<bool> { 319 fn eval_bool(&self, f: Bool) -> Option<bool> {
320 Some( 320 Some(
321 self.model 321 self.model
322 .eval::<z3::ast::Bool>(&self.ctx.bool(f)) 322 .eval::<z3::ast::Bool>(self.ctx.bool(f), true)
323 .unwrap() 323 .unwrap()
324 .as_bool() 324 .as_bool()
325 .unwrap(), 325 .unwrap(),