State for an encoding.
We need to parameterize by literal type L (and variable ν),
because otherwise we need to prove everywhere that clauses are "within range"
Instances For
Equations
Instances For
@[simp]
theorem
Trestle.Encode.EncCNF.State.toPropFun_addComment
{ν : Type u_1}
(comment : String)
(s : State ν)
:
structure
Trestle.Encode.EncCNF.LawfulState
(ν : Type u_1)
extends Trestle.Encode.EncCNF.State ν :
Type u_1
Lawfulness conditions on encoding state.
- vMapInj : Function.Injective self.vMap
Instances For
instance
Trestle.Encode.EncCNF.LawfulState.instCoeState
{ν : Type u_1}
:
Coe (LawfulState ν) (State ν)
theorem
Trestle.Encode.EncCNF.LawfulState.semVars_toPropFun_cnf_lt
{ν : Type u_1}
(s : LawfulState ν)
(v : IVar)
:
The interpretation of an EncCNF state is the
formula's interpretation, but with all temporaries
existentially quantified away.
Equations
- s.interp τ = ∃ (σ : Trestle.Model.PropAssignment Trestle.IVar), τ = Trestle.Model.PropAssignment.map s.vMap σ ∧ σ ⊨ s.toPropFun
Instances For
def
Trestle.Encode.EncCNF.LawfulState.new
{ν : Type u_1}
(nextVar : IVar)
(f : ν ↪ IVar)
(h : ∀ (v : ν), f v < nextVar)
(names : List (ν × String))
:
Equations
- Trestle.Encode.EncCNF.LawfulState.new nextVar f h names = { toState := Trestle.Encode.EncCNF.State.new nextVar (⇑f) names, cnfVarsLt := ⋯, vMapLt := h, vMapInj := ⋯ }
Instances For
def
Trestle.Encode.EncCNF.LawfulState.addClause
{ν : Type u_1}
(C : Clause (Literal ν))
:
LawfulState ν → LawfulState ν
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.interp_addClause
{ν : Type u_1}
(C : Clause (Literal ν))
(s : LawfulState ν)
:
def
Trestle.Encode.EncCNF.LawfulState.addComment
{ν : Type u_1}
(comm : String)
:
LawfulState ν → LawfulState ν
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.interp_addComment
{ν : Type u_1}
(comm : String)
(s : LawfulState ν)
:
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.vMap_addComment
{ν : Type u_1}
(comm : String)
(s : LawfulState ν)
:
Encoding monad.
This requires quite a few invariants to be held.
It receives and produces lawful states, and
nextVar is nondecreasing.
Equations
- Trestle.Encode.EncCNF ν α = { sa : StateM (Trestle.Encode.EncCNF.LawfulState ν) α // ∀ (s : Trestle.Encode.EncCNF.LawfulState ν), s.nextVar ≤ (sa s).2.nextVar }
Instances For
Equations
- One or more equations did not get rendered due to their size.
def
Trestle.Encode.EncCNF.run
{ν α : Type u_1}
[IndexType ν]
[LawfulIndexType ν]
(e : EncCNF ν α)
(names : List (ν × String) := [])
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- Trestle.Encode.EncCNF.addComment comm = ⟨fun (s : Trestle.Encode.EncCNF.LawfulState ν) => ((), Trestle.Encode.EncCNF.LawfulState.addComment comm s), ⋯⟩
Instances For
Instances For
Equations
- Trestle.Encode.EncCNF.blockAssn a = Trestle.Encode.EncCNF.addClause (Array.map (fun (x : Trestle.Literal ν) => -x) a.toLitArray)
Instances For
Temporaries #
def
Trestle.Encode.EncCNF.State.withTemps.vMap
{ν : Type u_1}
{ι : Type u_2}
[IndexType ι]
(vMap : ν → IVar)
(nextVar : IVar)
(x : ν ⊕ ι)
:
Equations
- Trestle.Encode.EncCNF.State.withTemps.vMap vMap nextVar (Sum.inl v) = vMap v
- Trestle.Encode.EncCNF.State.withTemps.vMap vMap nextVar (Sum.inr i) = nextVar + ↑(Trestle.IndexType.toFin i)
Instances For
def
Trestle.Encode.EncCNF.LawfulState.withTemps
{ν : Type u_1}
{ι : Type u_2}
[IndexType ι]
[LawfulIndexType ι]
(s : LawfulState ν)
(names : Option (ι → String))
:
LawfulState (ν ⊕ ι)
Equations
Instances For
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.vMap_withTemps
{ν : Type u_2}
{ι : Type u_1}
{names : Option (ι → String)}
[IndexType ι]
[LawfulIndexType ι]
(s : LawfulState ν)
:
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.interp_withTemps
{ν : Type u_2}
{ι : Type u_1}
{names : Option (ι → String)}
[IndexType ι]
[LawfulIndexType ι]
(s : LawfulState ν)
:
(s.withTemps names).interp = fun (τ : Model.PropAssignment (ν ⊕ ι)) => s.interp (Model.PropAssignment.map Sum.inl τ)
def
Trestle.Encode.EncCNF.LawfulState.withoutTemps
{ν : Type u_1}
{ι : Type u_2}
(s : LawfulState (ν ⊕ ι))
(vMap : ν → IVar)
(vMapLt : ∀ (v : ν), vMap v < s.nextVar)
(vMapInj : Function.Injective vMap)
:
Equations
- s.withoutTemps vMap vMapLt vMapInj = { toState := Trestle.Encode.EncCNF.State.withoutTemps vMap s.toState, cnfVarsLt := ⋯, vMapLt := ⋯, vMapInj := ⋯ }
Instances For
@[simp]
theorem
Trestle.Encode.EncCNF.LawfulState.vMap_withoutTemps
{ν : Type u_2}
{ι : Type u_1}
(s : LawfulState (ν ⊕ ι))
{vMap : ν → IVar}
{vMapLt : ∀ (v : ν), vMap v < s.nextVar}
{vMapInj : Function.Injective vMap}
:
theorem
Trestle.Encode.EncCNF.LawfulState.interp_withoutTemps
{ν : Type u_2}
{ι : Type u_1}
(s : LawfulState (ν ⊕ ι))
{vMap : ν → IVar}
{vMapLt : ∀ (v : ν), vMap v < s.nextVar}
{vMapInj : Function.Injective vMap}
(h : vMap = s.vMap ∘ Sum.inl)
:
(s.withoutTemps vMap vMapLt vMapInj).interp = fun (τ : Model.PropAssignment ν) =>
∃ (σ : Model.PropAssignment (ν ⊕ ι)), τ = Model.PropAssignment.map Sum.inl σ ∧ s.interp σ
def
Trestle.Encode.EncCNF.nextVar_mono_of_eq
{ν α : Type u_1}
{s : LawfulState ν}
{a : α}
{s' : LawfulState ν}
{e : EncCNF ν α}
(h : ↑e s = (a, s'))
:
Equations
- ⋯ = ⋯