The areas / V34. The tactics of Mathlib
Mathlib.Tactic.NormNum.BigOperators
55 declarations. Mathlib docs · Source
norm_num plugin for big operators
This file adds norm_num plugins for Finset.prod and Finset.sum.
The driving part of this plugin is Mathlib.Meta.NormNum.evalFinsetBigop.
We repeatedly use Finset.proveEmptyOrCons to try to find a proof that the given set is empty,
or that it consists of one element inserted into a strict subset, and evaluate the big operator
on that subset until the set is completely exhausted.
See also
- The
fin_casestactic has similar scope: splitting out a finite collection into its elements.
Porting notes
This plugin is noticeably less powerful than the equivalent version in Mathlib 3: the design of
norm_num means plugins have to return numerals, rather than a generic expression.
In particular, we can't use the plugin on sums containing variables.
(See also the TODO note "To support variables".)
TODO
- Support intervals:
Finset.Ico,Finset.Icc, ... - To support variables, like in Mathlib 3, turn this into a standalone tactic that unfolds
the sum/prod, without computing its numeric value (using the
ringtactic to do some normalization?)
theorem Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Finset «$α»)} {a : Q(«$α»)} {s' : Q(Finset «$α»)} {h : Q(«$a» ∉ «$s'»)}
{pf : Q(«$s» = Finset.cons «$a» «$s'» «$h»)} {a_1 : Q(«$α»)} {s'_1 : Q(Finset «$α»)} {h_1 : Q(«$a_1» ∉ «$s'_1»)}
{pf_1 : Q(«$s» = Finset.cons «$a_1» «$s'_1» «$h_1»)},
Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons a s' h pf =
Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons a_1 s'_1 h_1 pf_1 →
a = a_1 ∧ s' = s'_1 ∧ h = h_1 ∧ pf = pf_1
theorem Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ.injEq E0 #
∀ {n : Q(ℕ)} (n' : Q(ℕ)) (pf : «$n» =Q «$n'».succ) (n'_1 : Q(ℕ)) (pf_1 : «$n» =Q «$n'_1».succ),
(Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ n' pf = Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ n'_1 pf_1) =
(n' = n'_1)
theorem Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ.inj E1 #
∀ {n n' : Q(ℕ)} {pf : «$n» =Q «$n'».succ} {n'_1 : Q(ℕ)} {pf_1 : «$n» =Q «$n'_1».succ},
Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ n' pf = Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ n'_1 pf_1 → n' = n'_1
theorem Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Finset «$α»)} (a : Q(«$α»)) (s' : Q(Finset «$α»)) (h : Q(«$a» ∉ «$s'»))
(pf : Q(«$s» = Finset.cons «$a» «$s'» «$h»)) (a_1 : Q(«$α»)) (s'_1 : Q(Finset «$α»)) (h_1 : Q(«$a_1» ∉ «$s'_1»))
(pf_1 : Q(«$s» = Finset.cons «$a_1» «$s'_1» «$h_1»)),
(Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons a s' h pf =
Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons a_1 s'_1 h_1 pf_1) =
(a = a_1 ∧ s' = s'_1 ∧ h = h_1 ∧ pf = pf_1)
def Mathlib.Meta.Finset.ProveEmptyOrConsResult.ctorIdx E1 #
{u : Lean.Level} → {α : Q(Type u)} → {s : Q(Finset «$α»)} → Mathlib.Meta.Finset.ProveEmptyOrConsResult s → ℕ
abbrev Mathlib.Meta.Finset.ProveEmptyOrConsResult.ctorElimType E1 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(Finset «$α»)} → {motive : Mathlib.Meta.Finset.ProveEmptyOrConsResult s → Sort u} → ℕ → Sort (max 1 u)
theorem Mathlib.Meta.List.ProveNilOrConsResult.nil.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(List «$α»)} (pf pf_1 : Q(«$s» = [])),
(Mathlib.Meta.List.ProveNilOrConsResult.nil pf = Mathlib.Meta.List.ProveNilOrConsResult.nil pf_1) = (pf = pf_1)
def Mathlib.Meta.List.ProveNilOrConsResult.ctorIdx E1 #
{u : Lean.Level} → {α : Q(Type u)} → {s : Q(List «$α»)} → Mathlib.Meta.List.ProveNilOrConsResult s → ℕ
theorem Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Multiset «$α»)} {a : Q(«$α»)} {s' : Q(Multiset «$α»)}
{pf : Q(«$s» = «$a» ::ₘ «$s'»)} {a_1 : Q(«$α»)} {s'_1 : Q(Multiset «$α»)} {pf_1 : Q(«$s» = «$a_1» ::ₘ «$s'_1»)},
Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons a s' pf =
Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons a_1 s'_1 pf_1 →
a = a_1 ∧ s' = s'_1 ∧ pf = pf_1
def Mathlib.Meta.Nat.UnifyZeroOrSuccResult.ctorIdx E1 #
{n : Q(ℕ)} → Mathlib.Meta.Nat.UnifyZeroOrSuccResult n → ℕ
abbrev Mathlib.Meta.Multiset.ProveZeroOrConsResult.ctorElimType E1 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(Multiset «$α»)} → {motive : Mathlib.Meta.Multiset.ProveZeroOrConsResult s → Sort u} → ℕ → Sort (max 1 u)
theorem Mathlib.Meta.List.ProveNilOrConsResult.cons.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(List «$α»)} (a : Q(«$α»)) (s' : Q(List «$α»)) (pf : Q(«$s» = «$a» :: «$s'»))
(a_1 : Q(«$α»)) (s'_1 : Q(List «$α»)) (pf_1 : Q(«$s» = «$a_1» :: «$s'_1»)),
(Mathlib.Meta.List.ProveNilOrConsResult.cons a s' pf = Mathlib.Meta.List.ProveNilOrConsResult.cons a_1 s'_1 pf_1) =
(a = a_1 ∧ s' = s'_1 ∧ pf = pf_1)
theorem Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Multiset «$α»)} {pf pf_1 : Q(«$s» = 0)},
Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero pf = Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero pf_1 →
pf = pf_1
theorem Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Multiset «$α»)} (a : Q(«$α»)) (s' : Q(Multiset «$α»))
(pf : Q(«$s» = «$a» ::ₘ «$s'»)) (a_1 : Q(«$α»)) (s'_1 : Q(Multiset «$α»)) (pf_1 : Q(«$s» = «$a_1» ::ₘ «$s'_1»)),
(Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons a s' pf =
Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons a_1 s'_1 pf_1) =
(a = a_1 ∧ s' = s'_1 ∧ pf = pf_1)
abbrev Mathlib.Meta.Nat.UnifyZeroOrSuccResult.ctorElimType E1 #
{n : Q(ℕ)} → {motive : Mathlib.Meta.Nat.UnifyZeroOrSuccResult n → Sort u} → ℕ → Sort (max 1 u)
def Mathlib.Meta.Multiset.ProveZeroOrConsResult.ctorIdx E1 #
{u : Lean.Level} → {α : Q(Type u)} → {s : Q(Multiset «$α»)} → Mathlib.Meta.Multiset.ProveZeroOrConsResult s → ℕ
theorem Mathlib.Meta.List.ProveNilOrConsResult.cons.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(List «$α»)} {a : Q(«$α»)} {s' : Q(List «$α»)} {pf : Q(«$s» = «$a» :: «$s'»)}
{a_1 : Q(«$α»)} {s'_1 : Q(List «$α»)} {pf_1 : Q(«$s» = «$a_1» :: «$s'_1»)},
Mathlib.Meta.List.ProveNilOrConsResult.cons a s' pf = Mathlib.Meta.List.ProveNilOrConsResult.cons a_1 s'_1 pf_1 →
a = a_1 ∧ s' = s'_1 ∧ pf = pf_1
theorem Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Finset «$α»)} (pf pf_1 : Q(«$s» = ∅)),
(Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty pf = Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty pf_1) =
(pf = pf_1)
abbrev Mathlib.Meta.List.ProveNilOrConsResult.ctorElimType E1 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(List «$α»)} → {motive : Mathlib.Meta.List.ProveNilOrConsResult s → Sort u} → ℕ → Sort (max 1 u)
theorem Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero.injEq E0 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Multiset «$α»)} (pf pf_1 : Q(«$s» = 0)),
(Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero pf = Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero pf_1) =
(pf = pf_1)
theorem Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(Finset «$α»)} {pf pf_1 : Q(«$s» = ∅)},
Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty pf = Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty pf_1 →
pf = pf_1
theorem Mathlib.Meta.List.ProveNilOrConsResult.nil.inj E1 #
∀ {u : Lean.Level} {α : Q(Type u)} {s : Q(List «$α»)} {pf pf_1 : Q(«$s» = [])},
Mathlib.Meta.List.ProveNilOrConsResult.nil pf = Mathlib.Meta.List.ProveNilOrConsResult.nil pf_1 → pf = pf_1
inductive Mathlib.Meta.Nat.UnifyZeroOrSuccResult E1 #
Q(ℕ) → Type
This represents the result of trying to determine whether the given expression n : Q(ℕ)
is either zero or succ.
ctor Mathlib.Meta.Nat.UnifyZeroOrSuccResult.zero E0 #
{n : Q(ℕ)} → «$n» =Q 0 → Mathlib.Meta.Nat.UnifyZeroOrSuccResult n
n unifies with 0
ctor Mathlib.Meta.Nat.UnifyZeroOrSuccResult.succ E0 #
{n : Q(ℕ)} → (n' : Q(ℕ)) → «$n» =Q «$n'».succ → Mathlib.Meta.Nat.UnifyZeroOrSuccResult n
n unifies with succ n' for this specific n'
def Mathlib.Meta.Nat.unifyZeroOrSucc E1 #
(n : Q(ℕ)) → Lean.MetaM (Mathlib.Meta.Nat.UnifyZeroOrSuccResult n)
Determine whether the expression n : Q(ℕ) unifies with 0 or Nat.succ n'.
We do not use norm_num functionality because we want definitional equality,
not propositional equality, for use in dependent types.
Fails if neither of the options succeed.
inductive Mathlib.Meta.List.ProveNilOrConsResult E1 #
{u : Lean.Level} → {α : Q(Type u)} → Q(List «$α») → Type
This represents the result of trying to determine whether the given expression
s : Q(List $α) is either empty or consists of an element inserted into a strict subset.
ctor Mathlib.Meta.List.ProveNilOrConsResult.nil E0 #
{u : Lean.Level} → {α : Q(Type u)} → {s : Q(List «$α»)} → Q(«$s» = []) → Mathlib.Meta.List.ProveNilOrConsResult s
The set is Nil.
ctor Mathlib.Meta.List.ProveNilOrConsResult.cons E0 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(List «$α»)} →
(a : Q(«$α»)) → (s' : Q(List «$α»)) → Q(«$s» = «$a» :: «$s'») → Mathlib.Meta.List.ProveNilOrConsResult s
The set equals a inserted into the strict subset s'.
def Mathlib.Meta.List.ProveNilOrConsResult.uncheckedCast E1 #
{u v : Lean.Level} →
{α : Q(Type u)} →
{β : Q(Type v)} →
(s : Q(List «$α»)) →
(t : Q(List «$β»)) → Mathlib.Meta.List.ProveNilOrConsResult s → Mathlib.Meta.List.ProveNilOrConsResult t
If s unifies with t, convert a result for s to a result for t.
If s does not unify with t, this results in a type-incorrect proof.
theorem Mathlib.Meta.List.range_zero' E1 #
∀ {n : ℕ}, Mathlib.Meta.NormNum.IsNat n 0 → List.range n = []
theorem Mathlib.Meta.List.range_succ_eq_map' E1 #
∀ {n nn n' : ℕ}, Mathlib.Meta.NormNum.IsNat n nn → nn = n'.succ → List.range n = 0 :: List.map Nat.succ (List.range n')
opaque Mathlib.Meta.List.proveNilOrCons E1 #
{u : Lean.Level} → {α : Q(Type u)} → (s : Q(List «$α»)) → Lean.MetaM (Mathlib.Meta.List.ProveNilOrConsResult s)
Either show the expression s : Q(List α) is Nil, or remove one element from it.
Fails if we cannot determine which of the alternatives apply to the expression.
inductive Mathlib.Meta.Multiset.ProveZeroOrConsResult E1 #
{u : Lean.Level} → {α : Q(Type u)} → Q(Multiset «$α») → Type
This represents the result of trying to determine whether the given expression
s : Q(Multiset $α) is either empty or consists of an element inserted into a strict subset.
ctor Mathlib.Meta.Multiset.ProveZeroOrConsResult.zero E0 #
{u : Lean.Level} →
{α : Q(Type u)} → {s : Q(Multiset «$α»)} → Q(«$s» = 0) → Mathlib.Meta.Multiset.ProveZeroOrConsResult s
The set is zero.
ctor Mathlib.Meta.Multiset.ProveZeroOrConsResult.cons E0 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(Multiset «$α»)} →
(a : Q(«$α»)) → (s' : Q(Multiset «$α»)) → Q(«$s» = «$a» ::ₘ «$s'») → Mathlib.Meta.Multiset.ProveZeroOrConsResult s
The set equals a inserted into the strict subset s'.
def Mathlib.Meta.Multiset.ProveZeroOrConsResult.uncheckedCast E1 #
{u v : Lean.Level} →
{α : Q(Type u)} →
{β : Q(Type v)} →
(s : Q(Multiset «$α»)) →
(t : Q(Multiset «$β»)) →
Mathlib.Meta.Multiset.ProveZeroOrConsResult s → Mathlib.Meta.Multiset.ProveZeroOrConsResult t
If s unifies with t, convert a result for s to a result for t.
If s does not unify with t, this results in a type-incorrect proof.
theorem Mathlib.Meta.Multiset.insert_eq_cons E1 #
∀ {α : Type u_1} (a : α) (s : Multiset α), insert a s = a ::ₘ s
theorem Mathlib.Meta.Multiset.range_zero' E1 #
∀ {n : ℕ}, Mathlib.Meta.NormNum.IsNat n 0 → Multiset.range n = 0
theorem Mathlib.Meta.Multiset.range_succ' E1 #
∀ {n nn n' : ℕ}, Mathlib.Meta.NormNum.IsNat n nn → nn = n'.succ → Multiset.range n = n' ::ₘ Multiset.range n'
def Mathlib.Meta.Multiset.proveZeroOrCons E1 #
{u : Lean.Level} → {α : Q(Type u)} → (s : Q(Multiset «$α»)) → Lean.MetaM (Mathlib.Meta.Multiset.ProveZeroOrConsResult s)
Either show the expression s : Q(Multiset α) is Zero, or remove one element from it.
Fails if we cannot determine which of the alternatives apply to the expression.
inductive Mathlib.Meta.Finset.ProveEmptyOrConsResult E1 #
{u : Lean.Level} → {α : Q(Type u)} → Q(Finset «$α») → Type
This represents the result of trying to determine whether the given expression
s : Q(Finset $α) is either empty or consists of an element inserted into a strict subset.
ctor Mathlib.Meta.Finset.ProveEmptyOrConsResult.empty E0 #
{u : Lean.Level} → {α : Q(Type u)} → {s : Q(Finset «$α»)} → Q(«$s» = ∅) → Mathlib.Meta.Finset.ProveEmptyOrConsResult s
The set is empty.
ctor Mathlib.Meta.Finset.ProveEmptyOrConsResult.cons E0 #
{u : Lean.Level} →
{α : Q(Type u)} →
{s : Q(Finset «$α»)} →
(a : Q(«$α»)) →
(s' : Q(Finset «$α»)) →
(h : Q(«$a» ∉ «$s'»)) → Q(«$s» = Finset.cons «$a» «$s'» «$h») → Mathlib.Meta.Finset.ProveEmptyOrConsResult s
The set equals a inserted into the strict subset s'.
def Mathlib.Meta.Finset.ProveEmptyOrConsResult.uncheckedCast E1 #
{u v : Lean.Level} →
{α : Q(Type u)} →
{β : Q(Type v)} →
(s : Q(Finset «$α»)) →
(t : Q(Finset «$β»)) →
Mathlib.Meta.Finset.ProveEmptyOrConsResult s → Mathlib.Meta.Finset.ProveEmptyOrConsResult t
If s unifies with t, convert a result for s to a result for t.
If s does not unify with t, this results in a type-incorrect proof.
theorem Mathlib.Meta.Finset.insert_eq_cons E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s : Finset α) (h : a ∉ s), insert a s = Finset.cons a s h
theorem Mathlib.Meta.Finset.range_zero' E1 #
∀ {n : ℕ}, Mathlib.Meta.NormNum.IsNat n 0 → Finset.range n = ∅
theorem Mathlib.Meta.Finset.range_succ' E1 #
∀ {n nn n' : ℕ}, Mathlib.Meta.NormNum.IsNat n nn → nn = n'.succ → Finset.range n = Finset.cons n' (Finset.range n') ⋯
theorem Mathlib.Meta.Finset.univ_eq_elems E1 #
∀ {α : Type u_1} [inst : Fintype α] (elems : Finset α), (∀ (x : α), x ∈ elems) → Finset.univ = elems
opaque Mathlib.Meta.Finset.proveEmptyOrCons E1 #
{u : Lean.Level} → {α : Q(Type u)} → (s : Q(Finset «$α»)) → Lean.MetaM (Mathlib.Meta.Finset.ProveEmptyOrConsResult s)
Either show the expression s : Q(Finset α) is empty, or remove one element from it.
Fails if we cannot determine which of the alternatives apply to the expression.
theorem Mathlib.Meta.NormNum.Finset.sum_empty E1 #
∀ {β : Type u_1} {α : Type u_2} [inst : CommSemiring β] (f : α → β), Mathlib.Meta.NormNum.IsNat (∅.sum f) 0
theorem Mathlib.Meta.NormNum.Finset.prod_empty E1 #
∀ {β : Type u_1} {α : Type u_2} [inst : CommSemiring β] (f : α → β), Mathlib.Meta.NormNum.IsNat (∅.prod f) 1
opaque Mathlib.Meta.NormNum.evalFinsetBigop E1 #
{u v : Lean.Level} →
{α : Q(Type u)} →
{β : Q(Type v)} →
(op : Q(Finset «$α» → («$α» → «$β») → «$β»)) →
(f : Q(«$α» → «$β»)) →
Mathlib.Meta.NormNum.Result q(«$op» Finset.empty «$f») →
({a : Q(«$α»)} →
{s' : Q(Finset «$α»)} →
{h : Q(«$a» ∉ «$s'»)} →
Mathlib.Meta.NormNum.Result q(«$f» «$a») →
Mathlib.Meta.NormNum.Result q(«$op» «$s'» «$f») →
Lean.MetaM (Mathlib.Meta.NormNum.Result q(«$op» (Finset.cons «$a» «$s'» «$h») «$f»))) →
(s : Q(Finset «$α»)) → Lean.MetaM (Mathlib.Meta.NormNum.Result q(«$op» «$s» «$f»))
Evaluate a big operator applied to a finset by repeating proveEmptyOrCons until
we exhaust all elements of the set.
def Mathlib.Meta.NormNum.evalFinsetProd E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num plugin for evaluating products of finsets.
If your finset is not supported, you can add it to the match in Finset.proveEmptyOrCons.
def Mathlib.Meta.NormNum.evalFinsetSum E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num plugin for evaluating sums of finsets.
If your finset is not supported, you can add it to the match in Finset.proveEmptyOrCons.