The areas / V34. The tactics of Mathlib
Mathlib.Tactic.ProdAssoc
25 declarations. Mathlib docs · Source
Associativity of products
This file constructs a term elaborator for "obvious" equivalences between iterated products. For example,
(prod_assoc% : (α × β) × (γ × δ) ≃ α × (β × γ) × δ)
gives the "obvious" equivalence between (α × β) × (γ × δ) and α × (β × γ) × δ.
theorem Lean.Expr.ProdTree.prod.injEq E0 #
∀ (fst snd : Lean.Expr.ProdTree) (lfst lsnd : Lean.Level) (fst_1 snd_1 : Lean.Expr.ProdTree)
(lfst_1 lsnd_1 : Lean.Level),
(fst.prod snd lfst lsnd = fst_1.prod snd_1 lfst_1 lsnd_1) =
(fst = fst_1 ∧ snd = snd_1 ∧ lfst = lfst_1 ∧ lsnd = lsnd_1)
theorem Lean.Expr.ProdTree.brecOn.eq E1 #
∀ {motive : Lean.Expr.ProdTree → Sort u} (t : Lean.Expr.ProdTree)
(F_1 : (t : Lean.Expr.ProdTree) → Lean.Expr.ProdTree.below t → motive t),
Lean.Expr.ProdTree.brecOn t F_1 = F_1 t (Lean.Expr.ProdTree.brecOn.go t F_1).2
abbrev Lean.Expr.ProdTree.ctorElimType E1 #
{motive : Lean.Expr.ProdTree → Sort u} → ℕ → Sort (max 1 u)
theorem Lean.Expr.ProdTree.type.inj E1 #
∀ {tp : Lean.Expr} {l : Lean.Level} {tp_1 : Lean.Expr} {l_1 : Lean.Level},
Lean.Expr.ProdTree.type tp l = Lean.Expr.ProdTree.type tp_1 l_1 → tp = tp_1 ∧ l = l_1
theorem Lean.Expr.ProdTree.prod.inj E1 #
∀ {fst snd : Lean.Expr.ProdTree} {lfst lsnd : Lean.Level} {fst_1 snd_1 : Lean.Expr.ProdTree}
{lfst_1 lsnd_1 : Lean.Level},
fst.prod snd lfst lsnd = fst_1.prod snd_1 lfst_1 lsnd_1 → fst = fst_1 ∧ snd = snd_1 ∧ lfst = lfst_1 ∧ lsnd = lsnd_1
def Lean.Expr.ProdTree.ctorIdx E1 #
Lean.Expr.ProdTree → ℕ
abbrev Lean.Expr.ProdTree.brecOn.go E1 #
{motive : Lean.Expr.ProdTree → Sort u} →
(t : Lean.Expr.ProdTree) →
((t : Lean.Expr.ProdTree) → Lean.Expr.ProdTree.below t → motive t) → motive t ×' Lean.Expr.ProdTree.below t
theorem Lean.Expr.ProdTree.type.injEq E0 #
∀ (tp : Lean.Expr) (l : Lean.Level) (tp_1 : Lean.Expr) (l_1 : Lean.Level),
(Lean.Expr.ProdTree.type tp l = Lean.Expr.ProdTree.type tp_1 l_1) = (tp = tp_1 ∧ l = l_1)
inductive Lean.Expr.ProdTree E1 #
Type
A helper type to keep track of universe levels and types in iterated products.
ctor Lean.Expr.ProdTree.type E0 #
Lean.Expr → Lean.Level → Lean.Expr.ProdTree
ctor Lean.Expr.ProdTree.prod E0 #
Lean.Expr.ProdTree → Lean.Expr.ProdTree → Lean.Level → Lean.Level → Lean.Expr.ProdTree
instance Lean.Expr.instReprProdTree E0 #
Repr Lean.Expr.ProdTree
def Lean.Expr.instReprProdTree.repr E1 #
Lean.Expr.ProdTree → ℕ → Std.Format
def Lean.Expr.ProdTree.getType E1 #
Lean.Expr.ProdTree → Lean.Expr
The iterated product corresponding to a ProdTree.
def Lean.Expr.ProdTree.size E1 #
Lean.Expr.ProdTree → ℕ
The number of types appearing in an iterated product encoded as a ProdTree.
def Lean.Expr.ProdTree.components E1 #
Lean.Expr.ProdTree → List Lean.Expr
The components of an iterated product, presented as a ProdTree.
opaque Lean.Expr.mkProdTree E1 #
Lean.Expr → Lean.MetaM Lean.Expr.ProdTree
Make a ProdTree out of an Expr.
def Lean.Expr.ProdTree.unpack E1 #
Lean.Expr → Lean.Expr.ProdTree → Lean.MetaM (List Lean.Expr)
Given P : ProdTree representing an iterated product and e : Expr which
should correspond to a term of the iterated product, this will return
a list, whose items correspond to the leaves of P (i.e. the types appearing in the product),
where each item is the appropriate composition of Prod.fst and Prod.snd applied to e
resulting in an element of the type corresponding to the leaf.
For example, if P corresponds to (X × Y) × Z and t : (X × Y) × Z, then this
should return [t.fst.fst, t.fst.snd, t.snd].
def Lean.Expr.ProdTree.pack E1 #
List Lean.Expr → Lean.Expr.ProdTree → Lean.MetaM Lean.Expr
This function should act as the "reverse" of ProdTree.unpack, constructing
a term of the iterated product out of a list of terms of the types appearing in the product.
def Lean.Expr.ProdTree.convertTo E1 #
Lean.Expr.ProdTree → Lean.Expr.ProdTree → Lean.Expr → Lean.MetaM Lean.Expr
Converts a term e in an iterated product P1 into a term of an iterated product P2.
Here e is an Expr representing the term, and the iterated products are represented
by terms of ProdTree.
def Lean.Expr.mkProdFun E1 #
Lean.Expr → Lean.Expr → Lean.MetaM Lean.Expr
Given two expressions corresponding to iterated products of the same types, associated in possibly different ways, this constructs the "obvious" function from one to the other.
def Lean.Expr.mkProdEquiv E1 #
Lean.Expr → Lean.Expr → Lean.MetaM Lean.Expr
Construct the equivalence between iterated products of the same type, associated in possibly different ways.
def Lean.Expr.prodAssocStx E1 #
Lean.ParserDescr
IMPLEMENTATION: Syntax used in the implementation of prod_assoc%.
This elaborator postpones if there are metavariables in the expected type,
and to propagate the fact that this elaborator produces an Equiv,
the prod_assoc% macro sets things up with a type ascription.
This enables using prod_assoc% with, for example Equiv.trans dot notation.
def Lean.Expr.elabProdAssoc E1 #
Lean.Elab.Term.TermElab
Elaborator for prod_assoc%.
def Lean.Expr.«termProd_assoc%» E1 #
Lean.ParserDescr
prod_assoc% elaborates to the "obvious" equivalence between iterated products of types,
regardless of how the products are parenthesized.
The prod_assoc% term uses the expected type when elaborating.
For example, (prod_assoc% : (α × β) × (γ × δ) ≃ α × (β × γ) × δ).
The elaborator can handle holes in the expected type, so long as they eventually get filled by unification.
example : (α × β) × (γ × δ) ≃ α × (β × γ) × δ :=
(prod_assoc% : _ ≃ α × β × γ × δ).trans prod_assoc%