Documentation

Lean.Meta.Sym.Simp.Forall

Given xs containing free variables (x₁ : α₁) (x₂ : α₂[x₁]) ... (xₙ : αₙ[x₁, ..., x_{n-1}]), creates the custom forall congruence theorem

∀ (p q : (x₁ : α₁) → (x₂ : α₂[x₁]) → ... → (xₙ : αₙ[x₁, ..., x_{n-1}]) → Prop)
  (h : ∀ x₁ ... xₙ, p x₁ ... xₙ = q x₁ ... xₙ),
  (∀ x₁ ... xₙ, p x₁ ... xₙ) = (∀ x₁ ... xₙ, q x₁ ... xₙ)

The theorem has three arguments p, q, and h. This auxiliary theorem is used by the simplifier when visiting forall expressions. The proof uses the approach used in mkFunextFor followed by an Eq.ndrec.

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

    Simplifies a telescope of non-dependent arrows p₁ → p₂ → ... → pₙ → q by:

    1. Converting to Arrow p₁ (Arrow p₂ (... (Arrow pₙ q))) (see toArrow)
    2. Simplifying each pᵢ and q (see simpArrows)
    3. Converting back to → form (see toForall)

    Using Arrow (a definitional wrapper around →) avoids the quadratic proof growth that occurs with Expr.forallE. With forallE, each nesting level bumps de Bruijn indices in subterms, destroying sharing. For example, if each pᵢ contains a free variable x, the de Bruijn representation of x differs at each depth, preventing hash-consing from recognizing them as identical.

    With Arrow, both arguments are explicit (not under binders), so subterms remain identical across nesting levels and can be shared, yielding linear-sized proofs.

    Tradeoff: This function simplifies each pᵢ and q individually, but misses simplifications that depend on the arrow structure itself. For example, q → p → p won't be simplified to True (when p : Prop) because the simplifier does not have a chance to apply post methods to the intermediate arrow p → p.

    Thus, this is a simproc that is meant to be used as a pre-method and marks the result as fully simplified to prevent simpArrow from being applied.

    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
        def Lean.Meta.Sym.Simp.simpForall' (simpArrow simpBody : Simproc) (e : Expr) :
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Simplifies the domain of ∃ a : p₁, q a when p₁ : Prop. If simp p₁ produces p₂ with proof h : p₁ = p₂, the result is ∃ a : p₂, q (h.substr a) (see exists_prop_congr_dom). The body is not simplified here: the result is not marked as done, so the simplifier visits it afterwards under a : p₂. Intended as a pre-method.

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