diff --git a/src/context.rs b/src/context.rs index d36ee82..aca1c0c 100644 --- a/src/context.rs +++ b/src/context.rs @@ -192,6 +192,35 @@ impl Context { ) } + /// Assert `check-sat-assuming` with the given list of assumptions. + pub fn check_assuming( + &mut self, + props: impl IntoIterator, + ) -> io::Result { + let solver = self + .solver + .as_mut() + .expect("check requires a running solver"); + let args = self.arena.list(props.into_iter().collect()); + solver.send( + &self.arena, + self.arena.list(vec![self.atoms.check_sat_assuming, args]), + )?; + let resp = solver.recv(&self.arena)?; + if resp == self.atoms.sat { + Ok(Response::Sat) + } else if resp == self.atoms.unsat { + Ok(Response::Unsat) + } else if resp == self.atoms.unknown { + Ok(Response::Unknown) + } else { + Err(io::Error::new( + io::ErrorKind::Other, + format!("Unexpected result from solver: {}", self.display(resp)), + )) + } + } + /// Assert `check-sat` for the current context. pub fn check(&mut self) -> io::Result { let solver = self diff --git a/src/known_atoms.rs b/src/known_atoms.rs index 1320276..45de1c6 100644 --- a/src/known_atoms.rs +++ b/src/known_atoms.rs @@ -4,6 +4,7 @@ macro_rules! for_each_known_atom { ( $mac:ident ) => { $mac! { check_sat: "check-sat"; + check_sat_assuming: "check-sat-assuming"; unsat: "unsat"; sat: "sat"; unknown: "unknown";