Skip to content

Commit d465284

Browse files
committed
chore: add cases_eliminator and induction_eliminator to some simple types (#14205)
Namely: * `AList` * `Cycle` * `ConjAct` * `Projectivization` * `Lex` * `NatOrdinal` * `WithLawson` * `WithLower` * `WithUpper` * `WithScott` * `WithUpperSet` * `WithLowerSet` * `Speicalization` (which had an incorrectly-stated induction principle) These are just for the cases which have docstrings of the form "Use as `induction .* using .*`". Inspired by #12605.
1 parent 7d9b08c commit d465284

File tree

11 files changed

+35
-25
lines changed

11 files changed

+35
-25
lines changed

Mathlib/Data/List/AList.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ theorem mk_cons_eq_insert (c : Sigma β) (l : List (Sigma β)) (h : (c :: l).Nod
362362
simpa [insert] using (kerase_of_not_mem_keys <| not_mem_keys_of_nodupKeys_cons h).symm
363363
#align alist.mk_cons_eq_insert AList.mk_cons_eq_insert
364364

365-
/-- Recursion on an `AList`, using `insert`. Use as `induction l using AList.insertRec`. -/
366-
@[elab_as_elim]
365+
/-- Recursion on an `AList`, using `insert`. Use as `induction l`. -/
366+
@[elab_as_elim, induction_eliminator]
367367
def insertRec {C : AList β → Sort*} (H0 : C ∅)
368368
(IH : ∀ (a : α) (b : β a) (l : AList β), a ∉ l → C l → C (l.insert a b)) :
369369
∀ l : AList β, C l
@@ -374,8 +374,8 @@ def insertRec {C : AList β → Sort*} (H0 : C ∅)
374374
exact not_mem_keys_of_nodupKeys_cons h
375375
#align alist.insert_rec AList.insertRec
376376

377-
-- Test that the `induction` tactic works on `insert_rec`.
378-
example (l : AList β) : True := by induction l using AList.insertRec <;> trivial
377+
-- Test that the `induction` tactic works on `insertRec`.
378+
example (l : AList β) : True := by induction l <;> trivial
379379

380380
@[simp]
381381
theorem insertRec_empty {C : AList β → Sort*} (H0 : C ∅)

Mathlib/Data/List/Cycle.lean

+6-6
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ theorem empty_eq : ∅ = @nil α :=
505505
instance : Inhabited (Cycle α) :=
506506
⟨nil⟩
507507

508-
/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/
509-
@[elab_as_elim]
508+
/-- An induction principle for `Cycle`. Use as `induction s`. -/
509+
@[elab_as_elim, induction_eliminator]
510510
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
511511
(HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
512512
Quotient.inductionOn' s fun l => by
@@ -964,7 +964,7 @@ variable {r : α → α → Prop} {s : Cycle α}
964964

965965
theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : Chain r₁ s) :
966966
Chain r₂ s := by
967-
induction s using Cycle.induction_on
967+
induction s
968968
· trivial
969969
· rw [chain_coe_cons] at p ⊢
970970
exact p.imp H
@@ -976,7 +976,7 @@ theorem chain_mono : Monotone (Chain : (α → α → Prop) → Cycle α → Pro
976976
#align cycle.chain_mono Cycle.chain_mono
977977

978978
theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s := by
979-
induction' s using Cycle.induction_on with a l _
979+
induction' s with a l _
980980
· exact fun _ => Cycle.Chain.nil r
981981
intro hs
982982
have Ha : a ∈ (a :: l : Cycle α) := by simp
@@ -1002,7 +1002,7 @@ theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s := b
10021002

10031003
theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈ s, r a b :=
10041004
by
1005-
induction' s using Cycle.induction_on with a l _
1005+
induction' s with a l _
10061006
· exact fun _ b hb => (not_mem_nil _ hb).elim
10071007
intro hs b hb c hc
10081008
rw [Cycle.chain_coe_cons, List.chain_iff_pairwise] at hs
@@ -1017,7 +1017,7 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
10171017
#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise
10181018

10191019
theorem Chain.eq_nil_of_irrefl [IsTrans α r] [IsIrrefl α r] (h : Chain r s) : s = Cycle.nil := by
1020-
induction' s using Cycle.induction_on with a l _ h
1020+
induction' s with a l _ h
10211021
· rfl
10221022
· have ha := mem_cons_self a l
10231023
exact (irrefl_of r a <| chain_iff_pairwise.1 h a ha a ha).elim

Mathlib/GroupTheory/GroupAction/ConjAct.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def toConjAct : G ≃* ConjAct G :=
8181
ofConjAct.symm
8282
#align conj_act.to_conj_act ConjAct.toConjAct
8383

84-
/-- A recursor for `ConjAct`, for use as `induction x using ConjAct.rec` when `x : ConjAct G`. -/
84+
/-- A recursor for `ConjAct`, for use as `induction x` when `x : ConjAct G`. -/
85+
@[elab_as_elim, cases_eliminator, induction_eliminator]
8586
protected def rec {C : ConjAct G → Sort*} (h : ∀ g, C (toConjAct g)) : ∀ g, C g :=
8687
h
8788
#align conj_act.rec ConjAct.rec

Mathlib/LinearAlgebra/Projectivization/Basic.lean

+2-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ theorem exists_smul_eq_mk_rep (v : V) (hv : v ≠ 0) : ∃ a : Kˣ, a • v = (m
122122

123123
variable {K}
124124

125-
/-- An induction principle for `Projectivization`.
126-
Use as `induction v using Projectivization.ind`. -/
127-
@[elab_as_elim]
125+
/-- An induction principle for `Projectivization`. Use as `induction v`. -/
126+
@[elab_as_elim, cases_eliminator, induction_eliminator]
128127
theorem ind {P : ℙ K V → Prop} (h : ∀ (v : V) (h : v ≠ 0), P (mk K v h)) : ∀ p, P p :=
129128
Quotient.ind' <| Subtype.rec <| h
130129
#align projectivization.ind Projectivization.ind

Mathlib/Order/Synonym.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ theorem ofLex_inj {a b : Lex α} : ofLex a = ofLex b ↔ a = b :=
202202
Iff.rfl
203203
#align of_lex_inj ofLex_inj
204204

205-
/-- A recursor for `Lex`. Use as `induction x using Lex.rec`. -/
205+
/-- A recursor for `Lex`. Use as `induction x`. -/
206+
@[elab_as_elim, induction_eliminator, cases_eliminator]
206207
protected def Lex.rec {β : Lex α → Sort*} (h : ∀ a, β (toLex a)) : ∀ a, β a := fun a => h (ofLex a)
207208
#align lex.rec Lex.rec
208209

Mathlib/SetTheory/Ordinal/NaturalOps.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ theorem succ_def (a : NatOrdinal) : succ a = toNatOrdinal (toOrdinal a + 1) :=
133133
rfl
134134
#align nat_ordinal.succ_def NatOrdinal.succ_def
135135

136-
/-- A recursor for `NatOrdinal`. Use as `induction x using NatOrdinal.rec`. -/
136+
/-- A recursor for `NatOrdinal`. Use as `induction x`. -/
137+
@[elab_as_elim, cases_eliminator, induction_eliminator]
137138
protected def rec {β : NatOrdinal → Sort*} (h : ∀ a, β (toNatOrdinal a)) : ∀ a, β a := fun a =>
138139
h (toOrdinal a)
139140
#align nat_ordinal.rec NatOrdinal.rec

Mathlib/Topology/Order/LawsonTopology.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ lemma toLawson_inj {a b : α} : toLawson a = toLawson b ↔ a = b := Iff.rfl
127127
@[simp, nolint simpNF]
128128
lemma ofLawson_inj {a b : WithLawson α} : ofLawson a = ofLawson b ↔ a = b := Iff.rfl
129129

130-
/-- A recursor for `WithLawson`. Use as `induction' x using WithLawson.rec`. -/
130+
/-- A recursor for `WithLawson`. Use as `induction' x`. -/
131+
@[elab_as_elim, cases_eliminator, induction_eliminator]
131132
protected def rec {β : WithLawson α → Sort*}
132133
(h : ∀ a, β (toLawson a)) : ∀ a, β a := fun a => h (ofLawson a)
133134

Mathlib/Topology/Order/LowerUpperTopology.lean

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ theorem ofLower_inj {a b : WithLower α} : ofLower a = ofLower b ↔ a = b :=
103103
Iff.rfl
104104
#align with_lower_topology.of_lower_inj Topology.WithLower.ofLower_inj
105105

106-
/-- A recursor for `WithLower`. Use as `induction x using WithLower.rec`. -/
106+
/-- A recursor for `WithLower`. Use as `induction x`. -/
107+
@[elab_as_elim, cases_eliminator, induction_eliminator]
107108
protected def rec {β : WithLower α → Sort*} (h : ∀ a, β (toLower a)) : ∀ a, β a := fun a =>
108109
h (ofLower a)
109110
#align with_lower_topology.rec Topology.WithLower.rec
@@ -142,7 +143,8 @@ namespace WithUpper
142143
lemma toUpper_inj {a b : α} : toUpper a = toUpper b ↔ a = b := Iff.rfl
143144
lemma ofUpper_inj {a b : WithUpper α} : ofUpper a = ofUpper b ↔ a = b := Iff.rfl
144145

145-
/-- A recursor for `WithUpper`. Use as `induction x using WithUpper.rec`. -/
146+
/-- A recursor for `WithUpper`. Use as `induction x`. -/
147+
@[elab_as_elim, cases_eliminator, induction_eliminator]
146148
protected def rec {β : WithUpper α → Sort*} (h : ∀ a, β (toUpper a)) : ∀ a, β a := fun a =>
147149
h (ofUpper a)
148150

Mathlib/Topology/Order/ScottTopology.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ lemma toScott_inj {a b : α} : toScott a = toScott b ↔ a = b := Iff.rfl
317317
@[simp, nolint simpNF]
318318
lemma ofScott_inj {a b : WithScott α} : ofScott a = ofScott b ↔ a = b := Iff.rfl
319319

320-
/-- A recursor for `WithScott`. Use as `induction x using WithScott.rec`. -/
320+
/-- A recursor for `WithScott`. Use as `induction x`. -/
321+
@[elab_as_elim, cases_eliminator, induction_eliminator]
321322
protected def rec {β : WithScott α → Sort _}
322323
(h : ∀ a, β (toScott a)) : ∀ a, β a := fun a ↦ h (ofScott a)
323324

Mathlib/Topology/Order/UpperLowerSetTopology.lean

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ namespace WithUpperSet
8787
lemma toUpperSet_inj {a b : α} : toUpperSet a = toUpperSet b ↔ a = b := Iff.rfl
8888
lemma ofUpperSet_inj {a b : WithUpperSet α} : ofUpperSet a = ofUpperSet b ↔ a = b := Iff.rfl
8989

90-
/-- A recursor for `WithUpperSet`. Use as `induction x using WithUpperSet.rec`. -/
90+
/-- A recursor for `WithUpperSet`. Use as `induction x`. -/
91+
@[elab_as_elim, cases_eliminator, induction_eliminator]
9192
protected def rec {β : WithUpperSet α → Sort*} (h : ∀ a, β (toUpperSet a)) : ∀ a, β a :=
9293
fun a => h (ofUpperSet a)
9394

@@ -132,7 +133,8 @@ namespace WithLowerSet
132133
lemma toLowerSet_inj {a b : α} : toLowerSet a = toLowerSet b ↔ a = b := Iff.rfl
133134
lemma ofLowerSet_inj {a b : WithLowerSet α} : ofLowerSet a = ofLowerSet b ↔ a = b := Iff.rfl
134135

135-
/-- A recursor for `WithLowerSet`. Use as `induction x using WithLowerSet.rec`. -/
136+
/-- A recursor for `WithLowerSet`. Use as `induction x`. -/
137+
@[elab_as_elim, cases_eliminator, induction_eliminator]
136138
protected def rec {β : WithLowerSet α → Sort*} (h : ∀ a, β (toLowerSet a)) : ∀ a, β a :=
137139
fun a => h (ofLowerSet a)
138140

Mathlib/Topology/Specialization.lean

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ variable {α β γ : Type*}
3838
@[simp, nolint simpNF] lemma ofEquiv_inj {a b : Specialization α} : ofEquiv a = ofEquiv b ↔ a = b :=
3939
Iff.rfl
4040

41-
/-- A recursor for `Specialization`. Use as `induction x using Specialization.rec`. -/
42-
protected def rec {β : Specialization α → Sort*} (h : ∀ a, β (toEquiv a)) (a : α) : β a :=
43-
h (ofEquiv a)
41+
/-- A recursor for `Specialization`. Use as `induction x`. -/
42+
@[elab_as_elim, cases_eliminator, induction_eliminator]
43+
protected def rec {β : Specialization α → Sort*} (h : ∀ a, β (toEquiv a)) (a : Specialization α) :
44+
β a :=
45+
h (ofEquiv a)
4446

4547
variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
4648

0 commit comments

Comments
 (0)