Documentation

Auto.Embedding.LamChecker

An entry of RTable

Instances For
    Equations
    Instances For

      Table of valid propositions and well-formed formulas Note that Auto.BinTree α is equivalent to NatOption α, which means that .some entries may be interspersed with .none entries

      Instances For
        Equations
        • { entries := le, maxEVarSucc := lmax, lamEVarTy := llam }.beq { entries := re, maxEVarSucc := rmax, lamEVarTy := rlam } = (le == re && lmax == rmax && llam == rlam)
        Instances For
          Equations
          Instances For
            Equations
            Instances For
              structure Auto.Embedding.Lam.CPVal :
              Type (u + 1)

              Checker Partial Valuation (Valuation without lamEVarTy and eVarVal)

              Instances For
                structure Auto.Embedding.Lam.CVal (lamEVarTy : BinTree LamSort) extends Auto.Embedding.Lam.CPVal :
                Type (u_1 + 1)

                Checker Valuation

                Instances For
                  @[reducible, inline]
                  abbrev Auto.Embedding.Lam.eVarTy (tyVal : NatType u) (lamEVarTy : BinTree LamSort) :
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[reducible, inline]
                    abbrev Auto.Embedding.Lam.varSigmaMk (tyVal : NatType u) (fst : LamSort) (snd : LamSort.interp tyVal fst) :

                    Used in checker metacode to construct var

                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev Auto.Embedding.Lam.ilβ (tyVal : NatType u) (s : LamSort) :

                      Used in checker metacode to construct il

                      Equations
                      Instances For
                        @[reducible, inline]
                        abbrev Auto.Embedding.Lam.ilSigmaMk (tyVal : NatType u) (fst : LamSort) (snd : ilβ tyVal fst) :
                        Sigma (ilβ tyVal)

                        Used in checker metacode to construct il

                        Equations
                        Instances For
                          noncomputable def Auto.Embedding.Lam.ilVal.default (lamILTy : NatLamSort) (tyVal : NatType u) (n : Nat) :
                          ILLift (LamSort.interp tyVal (lamILTy n))
                          Equations
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        noncomputable def Auto.Embedding.Lam.CPVal.toLamValuationWithEVar (cpv : CPVal) (letv : NatLamSort) (eVarVal : (n : Nat) → LamSort.interp cpv.tyVal (letv n)) :
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          theorem Auto.Embedding.Lam.REntry.correct_eVarIrrelevance {maxEVarSucc : Nat} {re : REntry} (cpv : CPVal) (levt₁ levt₂ : BinTree LamSort) (val₁ : eVarTy cpv.tyVal levt₁) (val₂ : eVarTy cpv.tyVal levt₂) (hirr : ∀ (n : Nat), n < maxEVarSucc(levt₁.get? n).getD (LamSort.base LamBaseSort.prop) = (levt₂.get? n).getD (LamSort.base LamBaseSort.prop) val₁ n val₂ n) (c₁ : correct { toCPVal := cpv, eVarVal := val₁ } maxEVarSucc re) :
                                          correct { toCPVal := cpv, eVarVal := val₂ } maxEVarSucc re
                                          theorem Auto.Embedding.Lam.REntry.correct_increaseMaxEVarSucc {lamEVarTy✝ : BinTree LamSort} {cv : CVal lamEVarTy✝} {maxEVarSucc₁ : Nat} {re : REntry} {maxEVarSucc₂ : Nat} (c₁ : correct cv maxEVarSucc₁ re) (h : maxEVarSucc₁ maxEVarSucc₂) :
                                          correct cv maxEVarSucc₂ re
                                          theorem Auto.Embedding.Lam.RTable.inv_eVarIrrelevance {maxEVarSucc_ : Nat} {entries_ : BinTree REntry} (cpv : CPVal) (levt₁ levt₂ : BinTree LamSort) (val₁ : eVarTy cpv.tyVal levt₁) (val₂ : eVarTy cpv.tyVal levt₂) (hirr : ∀ (n : Nat), n < maxEVarSucc_(levt₁.get? n).getD (LamSort.base LamBaseSort.prop) = (levt₂.get? n).getD (LamSort.base LamBaseSort.prop) val₁ n val₂ n) (c₁ : { entries := entries_, maxEVarSucc := maxEVarSucc_, lamEVarTy := levt₁ }.inv { toCPVal := cpv, eVarVal := val₁ }) :
                                          { entries := entries_, maxEVarSucc := maxEVarSucc_, lamEVarTy := levt₂ }.inv { toCPVal := cpv, eVarVal := val₂ }
                                          theorem Auto.Embedding.Lam.RTable.inv_increaseMaxEVarSucc {r : RTable} {cv : CVal r.lamEVarTy} {maxEVarSucc_ : Nat} (c₁ : r.inv cv) (h : r.maxEVarSucc maxEVarSucc_) :
                                          { entries := r.entries, maxEVarSucc := maxEVarSucc_, lamEVarTy := r.lamEVarTy }.inv cv
                                          theorem Auto.Embedding.Lam.RTable.wfInv_get {n : Nat} {lctx : List LamSort} {s : LamSort} {t : LamTerm} {r : RTable} {cv : CVal r.lamEVarTy} (inv : r.inv cv) (h : r.get? n = some (REntry.wf lctx s t)) :
                                          theorem Auto.Embedding.Lam.RTable.validInv_get {n : Nat} {lctx : List LamSort} {t : LamTerm} {r : RTable} {cv : CVal r.lamEVarTy} (inv : r.inv cv) (h : r.get? n = some (REntry.valid lctx t)) :
                                          theorem Auto.Embedding.Lam.RTable.nonemptyInv_get {n : Nat} {s : LamSort} {r : RTable} {cv : CVal r.lamEVarTy} (inv : r.inv cv) (h : r.get? n = some (REntry.nonempty s)) :
                                          Equations
                                          Instances For
                                            theorem Auto.Embedding.Lam.RTable.getWF_correct {r : RTable} {cv : CVal r.lamEVarTy} {w : Nat} {lctx : List LamSort} {s : LamSort} {t : LamTerm} (inv : r.inv cv) (heq : r.getWF w = some (lctx, s, t)) :
                                            Equations
                                            Instances For
                                              theorem Auto.Embedding.Lam.RTable.getValid_correct {r : RTable} {cv : CVal r.lamEVarTy} {v : Nat} {lctx : List LamSort} {t : LamTerm} (inv : r.inv cv) (heq : r.getValid v = some (lctx, t)) :
                                              Equations
                                              Instances For
                                                Equations
                                                Instances For
                                                  theorem Auto.Embedding.Lam.RTable.getValidExport_correct {r : RTable} {cpv : CPVal} {v : Nat} {lctx : List LamSort} {t : LamTerm} (inv : (eV : (n : Nat) → LamSort.interp cpv.tyVal ((r.lamEVarTy.get? n).getD (LamSort.base LamBaseSort.prop))), r.inv { toCPVal := cpv, eVarVal := eV }) (heq : r.getValidExport v = some (lctx, t)) :
                                                  Equations
                                                  Instances For
                                                    @[irreducible]
                                                    noncomputable def Auto.Embedding.Lam.RTable.getValidsEnsureLCtx_correct {r : RTable} {cv : CVal r.lamEVarTy} {lctx : List LamSort} {vs : List Nat} {ts : List LamTerm} (inv : r.inv cv) (heq : r.getValidsEnsureLCtx lctx vs = some ts) :
                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      Equations
                                                      Instances For
                                                        theorem Auto.Embedding.Lam.RTable.getNonempty_correct {r : RTable} {cv : CVal r.lamEVarTy} {w : Nat} {s : LamSort} (inv : r.inv cv) (heq : r.getNonempty w = some s) :
                                                        Instances For
                                                          @[reducible, inline]

                                                          The meta code of the checker will prepare this ImportTable

                                                          Equations
                                                          Instances For
                                                            @[reducible, inline]

                                                            Used by the meta code of the checker to build ImportTable

                                                            Equations
                                                            Instances For
                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                theorem Auto.Embedding.Lam.ImportTable.importFacts_correct {cpv : CPVal} {levt : BinTree LamSort} {eVarVal : (n : Nat) → LamSort.interp cpv.tyVal ((levt.get? n).getD (LamSort.base LamBaseSort.prop))} (it : ImportTable cpv) (n : Nat) :
                                                                BinTree.allp (REntry.correct { toCPVal := cpv, eVarVal := eVarVal } n) it.importFacts
                                                                Instances For
                                                                  • validOfEtaExpand1At (pos : Nat) (occ : List Bool) : ConvAtStep
                                                                  • validOfEtaReduce1At (pos : Nat) (occ : List Bool) : ConvAtStep
                                                                  • validOfEtaExpandNAt (pos n : Nat) (occ : List Bool) : ConvAtStep
                                                                  • validOfEtaReduceNAt (pos n : Nat) (occ : List Bool) : ConvAtStep
                                                                  • validOfExtensionalizeEqAt (pos : Nat) (occ : List Bool) : ConvAtStep

                                                                    Turn · f = g into ∀ x₁ x₂ ⋯ xₙ, f x₁ x₂ ⋯ xₙ = g x₁ x₂ ⋯ xₙ · f = into fun g => ∀ x₁ x₂ ⋯ xₙ, f x₁ x₂ ⋯ xₙ = g x₁ x₂ ⋯ xₙ · = into fun f g => ∀ x₁ x₂ ⋯ xₙ, f x₁ x₂ ⋯ xₙ = g x₁ x₂ ⋯ xₙ

                                                                  • validOfExtensionalizeEqFNAt (pos n : Nat) (occ : List Bool) : ConvAtStep

                                                                    Turn f = g into ∀ x₁ x₂ ⋯ xₙ, f x₁ x₂ ⋯ xₙ = g x₁ x₂ ⋯ xₙ, where f and g must be of type s₀ → s₁ → ⋯ → sₙ₋₁ → ?

                                                                  • validOfIntensionalizeEqAt (pos : Nat) (occ : List Bool) : ConvAtStep

                                                                    Turn ∀ x₁ x₂ ⋯ xₙ, f x₁ x₂ ⋯ xₙ = g x₁ x₂ ⋯ xₙ into f = g

                                                                  Instances For
                                                                    Instances For
                                                                      Instances For
                                                                        Instances For
                                                                          Instances For
                                                                            Instances For
                                                                              • validOfPropNeEquivEqNot : PrepConvStep

                                                                                (a ≠ b) ↔ (a = (¬ b))

                                                                              • validOfTrueEqFalseEquivFalse : PrepConvStep

                                                                                (True = False) ↔ False

                                                                              • validOfFalseEqTrueEquivFalse : PrepConvStep

                                                                                (False = True) ↔ False

                                                                              • validOfEqTrueEquiv : PrepConvStep

                                                                                (a = True) ↔ a

                                                                              • validOfEqFalseEquiv : PrepConvStep

                                                                                (a = False) ↔ (¬ a)

                                                                              • validOfNeTrueEquivEqFalse : PrepConvStep

                                                                                (a ≠ True) ↔ (a = False)

                                                                              • validOfNeFalseEquivEqTrue : PrepConvStep

                                                                                (a ≠ False) ↔ (a = True)

                                                                              • validOfNotEqTrueEquivEqFalse : PrepConvStep

                                                                                ((¬ a) = True) ↔ (a = False)

                                                                              • validOfNotEqFalseEquivEqTrue : PrepConvStep

                                                                                ((¬ a) = False) ↔ (a = True)

                                                                              • validOfNotNotEquiv : PrepConvStep

                                                                                (¬¬a) ↔ a

                                                                              • validOfNotEqEquivEqNot : PrepConvStep

                                                                                ((¬ a) = b) ↔ (a = (¬ b))

                                                                              • validOfNotEqNotEquivEq : PrepConvStep

                                                                                ((¬ a) = (¬ b)) ↔ (a = b)

                                                                              • validOfPropext : PrepConvStep

                                                                                (a ↔ b) ↔ (a = b)

                                                                              • validOfNotAndEquivNotOrNot : PrepConvStep

                                                                                (¬ (a ∧ b)) ↔ (¬ a ∨ ¬ b)

                                                                              • validOfNotOrEquivNotAndNot : PrepConvStep

                                                                                (¬ (a ∨ b)) ↔ (¬ a ∧ ¬ b)

                                                                              • validOfImpEquivNotOr : PrepConvStep

                                                                                (a → b) ↔ (¬ a ∨ b)

                                                                              • validOfNotImpEquivAndNot : PrepConvStep

                                                                                (¬ (a → b)) ↔ (a ∧ ¬ b)

                                                                              • validOfPropEq : PrepConvStep

                                                                                (a = b) ↔ (a ∨ ¬ b) ∧ (¬ a ∨ b)

                                                                              • validOfPropNe : PrepConvStep

                                                                                (a = b) ↔ (a ∨ b) ∧ (¬ a ∨ ¬ b)

                                                                              • validOfPushBVCast : PrepConvStep

                                                                                Basic BitVec simplification operations

                                                                              Instances For
                                                                                Instances For
                                                                                  Equations
                                                                                  Instances For
                                                                                    Equations
                                                                                    Instances For
                                                                                      Equations
                                                                                      Instances For

                                                                                        Whether a term is well-formed or not does not depend on assertions. So, the premises of a WFStep is deemed empty (although for some WFSteps they seem to have premise syntactically)

                                                                                        Equations
                                                                                        Instances For
                                                                                          Instances For
                                                                                            theorem Auto.Embedding.Lam.EvalResult.correct_newEtomWithValid_mpLamEVarTy {s : LamSort} {lctx : List LamSort} {t : LamTerm} {r : RTable} {cv : CVal r.lamEVarTy} (levt : NatLamSort) (heq : ∀ (n : Nat), levt n = ((r.lamEVarTy.insert r.maxEVarSucc s).get? n).getD (LamSort.base LamBaseSort.prop)) (H : (eVarVal' : (n : Nat) → LamSort.interp cv.tyVal (levt n)), (∀ (n : Nat), n < r.maxEVarSucceVarVal' n cv.eVarVal n) LamThmValid (cv.toLamValuationWithEVar levt eVarVal') lctx t t.maxEVarSucc r.maxEVarSucc.succ) :
                                                                                            correct r cv (newEtomWithValid s lctx t)
                                                                                            Equations
                                                                                            Instances For
                                                                                              Equations
                                                                                              Instances For
                                                                                                @[reducible]
                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  @[reducible]
                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For
                                                                                                    @[reducible]
                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      @[reducible]
                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For
                                                                                                        @[reducible]
                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For
                                                                                                          @[reducible]
                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            @[reducible]
                                                                                                            Equations
                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                            Instances For
                                                                                                              theorem Auto.Embedding.Lam.InferenceStep.evalValidOfBVarLowers_correct {lctx : List LamSort} {pns : List Nat} {lctx' : List LamSort} {r : RTable} (cv : CVal r.lamEVarTy) (inv : r.inv cv) (heq : evalValidOfBVarLowers r lctx pns = some lctx') :
                                                                                                              (ss : List LamSort), (x : HList (LamNonempty cv.tyVal) ss), ss.length = pns.length lctx = ss ++ lctx'
                                                                                                              Equations
                                                                                                              Instances For
                                                                                                                @[reducible, inline]

                                                                                                                The first ChkStep specifies the checker step The second Nat specifies the position to insert the resulting term Note that

                                                                                                                1. All entries (x : ChkStep × Nat) that insert result into the wf table should have distinct second component
                                                                                                                2. All entries (x : ChkStep × Nat) that insert result into the valid table should have distinct second component Note that we decide where (wf or valid) to insert the resulting term by looking at (c : ChkStep).eval
                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  def Auto.Embedding.Lam.ChkStep.run (lvt lit : NatLamSort) (r : RTable) (c : ChkStep) (n : Nat) :
                                                                                                                  Equations
                                                                                                                  Instances For
                                                                                                                    theorem Auto.Embedding.Lam.ChkStep.run_correct (r : RTable) (cpv : CPVal) (inv : (eV : (n : Nat) → LamSort.interp cpv.tyVal ((r.lamEVarTy.get? n).getD (LamSort.base LamBaseSort.prop))), r.inv { toCPVal := cpv, eVarVal := eV }) (c : ChkStep) (n : Nat) :
                                                                                                                    (eV' : (n_1 : Nat) → LamSort.interp cpv.tyVal (((run cpv.toLamVarTy cpv.toLamILTy r c n).lamEVarTy.get? n_1).getD (LamSort.base LamBaseSort.prop))), (run cpv.toLamVarTy cpv.toLamILTy r c n).inv { toCPVal := cpv, eVarVal := eV' }
                                                                                                                    Equations
                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                    Instances For
                                                                                                                      theorem Auto.Embedding.Lam.ChkSteps.run_correct (r : RTable) (cpv : CPVal) (inv : (eV : (n : Nat) → LamSort.interp cpv.tyVal ((r.lamEVarTy.get? n).getD (LamSort.base LamBaseSort.prop))), r.inv { toCPVal := cpv, eVarVal := eV }) (cs : ChkSteps) :
                                                                                                                      (eV' : (n : Nat) → LamSort.interp cpv.tyVal (((run cpv.toLamVarTy cpv.toLamILTy r cs).lamEVarTy.get? n).getD (LamSort.base LamBaseSort.prop))), (run cpv.toLamVarTy cpv.toLamILTy r cs).inv { toCPVal := cpv, eVarVal := eV' }
                                                                                                                      Equations
                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                      Instances For
                                                                                                                        theorem Auto.Embedding.Lam.CheckerAux (cpv : CPVal) (it : ImportTable cpv) (cs : ChkSteps) :
                                                                                                                        (eV : (n : Nat) → LamSort.interp cpv.tyVal (((ChkSteps.runFromBeginning cpv it cs).lamEVarTy.get? n).getD (LamSort.base LamBaseSort.prop))), (ChkSteps.runFromBeginning cpv it cs).inv { toCPVal := cpv, eVarVal := eV }

                                                                                                                        Note : Using this theorem directly in the checker will cause performance issue, especially when there are a lot of etoms. This is probably caused by the type of eV in ∃ eV being dependent on the result of ChkSteps.runFromBeginning

                                                                                                                        theorem Auto.Embedding.Lam.Checker.getValidExport_indirectReduceAux (cpv : CPVal) (it : ImportTable cpv) (cs : ChkSteps) (v : Nat) (importFacts : BinTree REntry) (hImport : it.importFacts = importFacts) (lvt lit : BinTree LamSort) (hlvt : lvt = BinTree.mapOpt (fun (x : (s : LamSort) × LamSort.interp cpv.tyVal s) => some x.fst) cpv.var) (hlit : lit = BinTree.mapOpt (fun (x : (s : LamSort) × ILLift (LamSort.interp cpv.tyVal s)) => some x.fst) cpv.il) (runResult : RTable) (runEq : ChkSteps.run (fun (n : Nat) => (lvt.get? n).getD (LamSort.base LamBaseSort.prop)) (fun (n : Nat) => (lit.get? n).getD (LamSort.base LamBaseSort.prop)) { entries := importFacts, maxEVarSucc := 0, lamEVarTy := BinTree.leaf } cs = runResult) (lctx : List LamSort) (t : LamTerm) (heq : runResult.getValidExport v = some (lctx, t)) :

                                                                                                                        Note : Do not use the counterpart of this theorem in proof by reflection. Surprisingly, if we use this theorem in proof by reflection, the performance issue will not be the ChkSteps.run in runEq. Instead, it would be caused by compiling the definition of runResult. I'm not sure why it's the case, but Lean sometimes exhibit superlinear (even quadratic) compilation time with respect to the size of runResult.

                                                                                                                        theorem Auto.Embedding.Lam.Checker.getValidExport_indirectReduce (cpv : CPVal) (it : ImportTable cpv) (cs : ChkSteps) (v : Nat) (importFacts : BinTree REntry) (hImport : it.importFacts = importFacts) (lvt lit : BinTree LamSort) (hlvt : lvt = BinTree.mapOpt (fun (x : (s : LamSort) × LamSort.interp cpv.tyVal s) => some x.fst) cpv.var) (hlit : lit = BinTree.mapOpt (fun (x : (s : LamSort) × ILLift (LamSort.interp cpv.tyVal s)) => some x.fst) cpv.il) (lctx : List LamSort) (t : LamTerm) (heq : (ChkSteps.run (fun (n : Nat) => (lvt.get? n).getD (LamSort.base LamBaseSort.prop)) (fun (n : Nat) => (lit.get? n).getD (LamSort.base LamBaseSort.prop)) { entries := importFacts, maxEVarSucc := 0, lamEVarTy := BinTree.leaf } cs).getValidExport v = some (lctx, t)) :
                                                                                                                        Equations
                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                        Instances For
                                                                                                                          theorem Auto.Embedding.Lam.Checker.getValidExport_indirectReduce_reflection (cpv : CPVal) (it : ImportTable cpv) (cs : ChkSteps) (v : Nat) (importFacts : BinTree REntry) (hImport : it.importFacts = importFacts) (lvt lit : BinTree LamSort) (hlvt : lvt = BinTree.mapOpt (fun (x : (s : LamSort) × LamSort.interp cpv.tyVal s) => some x.fst) cpv.var) (hlit : lit = BinTree.mapOpt (fun (x : (s : LamSort) × ILLift (LamSort.interp cpv.tyVal s)) => some x.fst) cpv.il) (lctx : List LamSort) (t : LamTerm) (heq : getValidExport_indirectReduce_reflection_runEq lvt lit importFacts cs v lctx t = true) :

                                                                                                                          Checker utility

                                                                                                                          Instances For
                                                                                                                            Equations
                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                            Equations
                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                            Instances For
                                                                                                                              Equations
                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                              Instances For
                                                                                                                                Equations
                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                Instances For