Besides introducing a way to construct an if statement in an AIG, this module also demonstrates
a style of writing Lean code that minimizes the risk of linearity issues on the AIG.
The idea is to always keep one aig variable around that contains the AIG and continuously
shadow it. However, applying multiple operations to the AIG does often require Ref.cast to use
other inputs or Refs created by previous operations in later ones. Applying a Ref.cast would
usually require keeping around the old AIG to state the theorem statement. Luckily in this
situation Lean is usually always able to infer the theorem statement on it's own. For this
reason the style goes as follows:
let res := someLawfulOperator aig input
let aig := res.aig
let ref := res.ref
have := LawfulOperator.le_size (f := mkIfCached) ..
let input1 := input1.cast this
let input2 := input2.cast this
-- ...
-- Next `LawfulOperator` application
This style also generalizes to applications of LawfulVecOperators.
def Std.Sat.AIG.mkIfCached {α : Type} [Hashable α] [DecidableEq α] (aig : AIG α) (input : aig.TernaryInput) :
Equations
- One or more equations did not get rendered due to their size.
Instances For
instance Std.Sat.AIG.instLawfulOperatorTernaryInputMkIfCached {α : Type} [Hashable α] [DecidableEq α] :
@[simp]
theorem Std.Sat.AIG.denote_mkIfCached {α : Type} [Hashable α] [DecidableEq α] {assign : α → Bool} {aig : AIG α} {input : aig.TernaryInput} :
def Std.Sat.AIG.RefVec.ite {α : Type} [Hashable α] [DecidableEq α] {w : Nat} (aig : AIG α) (input : IfInput aig w) :
RefVecEntry α w
Equations
- Std.Sat.AIG.RefVec.ite aig { discr := discr, lhs := lhs, rhs := rhs } = Std.Sat.AIG.RefVec.ite.go aig 0 ⋯ discr lhs rhs (Std.Sat.AIG.RefVec.emptyWithCapacity w)
Instances For
@[irreducible]
def Std.Sat.AIG.RefVec.ite.go {α : Type} [Hashable α] [DecidableEq α] {w : Nat} (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (discr : aig.Ref) (lhs rhs : aig.RefVec w) (s : aig.RefVec curr) :
RefVecEntry α w
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem Std.Sat.AIG.RefVec.ite.go_decl_eq {α : Type} [Hashable α] [DecidableEq α] {w : Nat} (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (discr : aig.Ref) (lhs rhs : aig.RefVec w) (s : aig.RefVec curr) (idx : Nat) (h1 : idx < aig.decls.size) (h2 : idx < (go aig curr hcurr discr lhs rhs s).aig.decls.size) :
instance Std.Sat.AIG.RefVec.instLawfulVecOperatorIfInputIte {α : Type} [Hashable α] [DecidableEq α] :
LawfulVecOperator α IfInput fun {len : Nat} => ite
theorem Std.Sat.AIG.RefVec.ite.go_get_aux {α : Type} [Hashable α] [DecidableEq α] {w : Nat} (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (discr : aig.Ref) (lhs rhs : aig.RefVec w) (s : aig.RefVec curr) (idx : Nat) (hidx : idx < curr) (hfoo : aig.decls.size ≤ (go aig curr hcurr discr lhs rhs s).aig.decls.size) :
@[simp]
theorem Std.Sat.AIG.RefVec.denote_ite {α : Type} [Hashable α] [DecidableEq α] {w : Nat} {assign : α → Bool} {aig : AIG α} {input : IfInput aig w} (idx : Nat) (hidx : idx < w) :