Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
use HSat for BoolExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Jul 15, 2024
1 parent b12b4ce commit eecd726
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 10 additions & 6 deletions LeanSAT/BitBlast/BoolExpr/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Copyright (c) 2024 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import LeanSAT.Sat.Basic

set_option linter.missingDocs false

open Lean Meta
Expand Down Expand Up @@ -68,14 +70,16 @@ def eval (f : α → Bool) : BoolExpr α → Bool
@[simp] theorem eval_not : eval f (.not x) = !eval f x := rfl
@[simp] theorem eval_gate : eval f (.gate g x y) = g.eval (eval f x) (eval f y) := rfl

def sat (x : BoolExpr α) (f : α → Bool) : Prop := eval f x = true
def sat (f : α → Bool) (x : BoolExpr α) : Prop := eval f x = true

theorem sat_and {x y : BoolExpr α} {f} (hx : sat x f) (hy : sat y f) : sat (.gate .and x y) f := by
simp only [sat] at *
simp [hx, hy, Gate.eval]
instance : HSat α (BoolExpr α) where
eval := sat

theorem sat_true : sat (.const true) f := rfl
theorem sat_and {x y : BoolExpr α} {f : α → Bool} (hx : f ⊨ x) (hy : f ⊨ y)
: f ⊨ (BoolExpr.gate .and x y) := by
simp only [(· ⊨ ·), sat] at *
simp [hx, hy, Gate.eval]

def unsat (x : BoolExpr α) : Prop := ∀ f, eval f x = false
theorem sat_true {f : α → Bool} : f ⊨ (BoolExpr.const true : BoolExpr α) := rfl

end BoolExpr
4 changes: 3 additions & 1 deletion LeanSAT/BitBlast/BoolExpr/BitBlast.lean
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ theorem ofBoolExprCachedDirect_eval_eq_eval (expr : BoolExpr α) (assign) :
⟦ofBoolExprCachedDirect expr, assign⟧ = expr.eval assign := by
apply ofBoolExprCached.go_eval_eq_eval

theorem ofBoolExprCachedDirect_unsat_iff {expr : BoolExpr α} : (ofBoolExprCachedDirect expr).unsat ↔ expr.unsat := by
theorem ofBoolExprCachedDirect_unsat_iff {expr : BoolExpr α}
: (ofBoolExprCachedDirect expr).unsat ↔ unsatisfiable α expr := by
simp [unsatisfiable, (· ⊨ ·), BoolExpr.sat]
constructor
all_goals
intro h assign
Expand Down

0 comments on commit eecd726

Please sign in to comment.