Skip to content

Commit

Permalink
Define models of SAT
Browse files Browse the repository at this point in the history
  • Loading branch information
xldenis committed Jul 12, 2022
1 parent 3ac3efc commit c5ba213
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion CreuSAT/src/logic/logic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
extern crate creusot_contracts;
use creusot_contracts::std::*;
use creusot_contracts::*;

use crate::{assignments::*, clause::*, formula::*, lit::*, trail::*};

use crate::logic::{logic_assignments::*, logic_clause::*, logic_formula::*, logic_trail::*};

#[cfg(feature = "contracts")]
mod inner {
struct Model(Mapping<Int, bool>);

impl Model {
#[predicate]
fn satisfies_clause(self, cl: Seq<Lit>) -> bool {
pearlite! {
forall<i : _> 0 <= i && i < cl.len() ==> self.get(@cl[i].idx) == cl[i].polarity
}
}

#[predicate]
fn satisfies(self, fml: Seq<Seq<Lit>>) -> bool {
pearlite! {
forall<c : _> 0 <= i && i < fml.len() ==> self.satisfies_clause(fml[c])
}
}
}

impl Formula {
#[predicate]
fn unsat(self) -> bool {
pearlite! { forall<m : Model> m.satisfies(@self) ==> false }
}

#[predicate]
fn sat(self) -> bool {
pearlite! { exists<m : Model> m.satisfies(@self) }
}
}
}

#[cfg(feature = "contracts")]
pub use inner::*;

#[logic]
fn pos() -> AssignedState {
1u8
Expand Down

0 comments on commit c5ba213

Please sign in to comment.