@@ -32,6 +32,7 @@ pub enum CommandError {
3232 ProcessError ( #[ from] io:: Error ) ,
3333}
3434
35+ #[ derive( Debug ) ]
3536pub enum SolverType {
3637 Z3 ,
3738 SWINE ,
@@ -127,15 +128,17 @@ pub struct Prover<'ctx> {
127128 level : usize ,
128129 /// The minimum level where an assertion was added to the solver.
129130 min_level_with_provables : Option < usize > ,
131+ smt_solver : SolverType
130132}
131133
132134impl < ' ctx > Prover < ' ctx > {
133135 /// Create a new prover with the given [`Context`].
134- pub fn new ( ctx : & ' ctx Context ) -> Self {
136+ pub fn new ( ctx : & ' ctx Context , solver_type : SolverType ) -> Self {
135137 Prover {
136138 solver : Solver :: new ( ctx) ,
137139 level : 0 ,
138140 min_level_with_provables : None ,
141+ smt_solver : solver_type,
139142 }
140143 }
141144
@@ -159,23 +162,22 @@ impl<'ctx> Prover<'ctx> {
159162 }
160163
161164 pub fn check_proof ( & mut self ) -> ProveResult < ' ctx > {
162- self . check_proof_assuming ( & [ ] , SolverType :: SWINE )
165+ self . check_proof_assuming ( & [ ] )
163166 }
164167
165168 /// Do the SAT check, but consider a check with no provables to be a
166169 /// [`ProveResult::Proof`].
167170 pub fn check_proof_assuming (
168171 & mut self ,
169172 assumptions : & [ Bool < ' ctx > ] ,
170- solver_type : SolverType ,
171173 ) -> ProveResult < ' ctx > {
172174 if self . min_level_with_provables . is_none ( ) {
173175 return ProveResult :: Proof ;
174176 }
175177
176178 let res;
177179
178- match solver_type {
180+ match self . smt_solver {
179181 SolverType :: SWINE => {
180182 let mut smtlib = self . get_smtlib ( ) ;
181183 smtlib. add_check_sat ( ) ;
@@ -198,7 +200,6 @@ impl<'ctx> Prover<'ctx> {
198200 }
199201 SatResult :: Sat => {
200202 // TODO: Get the model from the output of SWINE
201- println ! ( "The Result of SWINE: sat" ) ;
202203 process:: exit ( 1 )
203204 }
204205 }
@@ -291,7 +292,7 @@ impl<'ctx> Prover<'ctx> {
291292 universal. iter ( ) . map ( |v| v as & dyn Ast < ' ctx > ) . collect ( ) ;
292293 let assertions = self . solver . get_assertions ( ) ;
293294 let theorem = forall_const ( ctx, & universal, & [ ] , & Bool :: and ( ctx, & assertions) . not ( ) ) ;
294- let mut res = Prover :: new ( ctx) ;
295+ let mut res = Prover :: new ( ctx, SolverType :: Z3 ) ;
295296 res. add_assumption ( & theorem) ;
296297 res
297298 }
@@ -306,12 +307,14 @@ impl<'ctx> Prover<'ctx> {
306307mod test {
307308 use z3:: { ast:: Bool , Config , Context , SatResult } ;
308309
310+ use crate :: prover:: SolverType ;
311+
309312 use super :: { ProveResult , Prover } ;
310313
311314 #[ test]
312315 fn test_prover ( ) {
313316 let ctx = Context :: new ( & Config :: default ( ) ) ;
314- let mut prover = Prover :: new ( & ctx) ;
317+ let mut prover = Prover :: new ( & ctx, SolverType :: Z3 ) ;
315318 assert ! ( matches!( prover. check_proof( ) , ProveResult :: Proof ) ) ;
316319 assert_eq ! ( prover. check_sat( ) , SatResult :: Sat ) ;
317320
0 commit comments