Skip to content

Commit c485bfa

Browse files
committed
chore: review induction principles for Set.Finite (#20444)
Rename `Set.Finite.dinduction_on` to `Set.Finite.induction_on` as this is the more useful induction principle (it works with `induction`). Rename `Set.Finite.induction_on'` to `Set.Finite.induction_on_subset` and make it dependent. Give the assumptions meaningful names.
1 parent 2b47f63 commit c485bfa

File tree

18 files changed

+60
-54
lines changed

18 files changed

+60
-54
lines changed

Mathlib/Data/Set/Card.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ theorem encard_insert_of_not_mem {a : α} (has : a ∉ s) : (insert a s).encard
112112
rw [← union_singleton, encard_union_eq (by simpa), encard_singleton]
113113

114114
theorem Finite.encard_lt_top (h : s.Finite) : s.encard < ⊤ := by
115-
refine h.induction_on (by simp) ?_
115+
refine h.induction_on _ (by simp) ?_
116116
rintro a t hat _ ht'
117117
rw [encard_insert_of_not_mem hat]
118118
exact lt_tsub_iff_right.1 ht'

Mathlib/Data/Set/Finite/Basic.lean

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -668,31 +668,40 @@ theorem finite_option {s : Set (Option α)} : s.Finite ↔ { x : α | some x ∈
668668
((h.image some).insert none).subset fun x =>
669669
x.casesOn (fun _ => Or.inl rfl) fun _ hx => Or.inr <| mem_image_of_mem _ hx⟩
670670

671+
/-- Induction principle for finite sets: To prove a property `motive` of a finite set `s`, it's
672+
enough to prove for the empty set and to prove that `motive t → motive ({a} ∪ t)` for all `t`.
673+
674+
See also `Set.Finite.induction_on` for the version requiring to check `motive t → motive ({a} ∪ t)`
675+
only for `t ⊆ s`. -/
671676
@[elab_as_elim]
672-
theorem Finite.induction_on {C : Set α → Prop} {s : Set α} (h : s.Finite) (H0 : C ∅)
673-
(H1 : ∀ {a s}, a ∉ s → Set.Finite s → C s → C (insert a s)) : C s := by
674-
lift s to Finset α using h
675-
induction' s using Finset.cons_induction_on with a s ha hs
676-
· rwa [Finset.coe_empty]
677-
· rw [Finset.coe_cons]
678-
exact @H1 a s ha (Set.toFinite _) hs
679-
680-
/-- Analogous to `Finset.induction_on'`. -/
677+
theorem Finite.induction_on {motive : ∀ s : Set α, s.Finite → Prop} (s : Set α) (hs : s.Finite)
678+
(empty : motive ∅ finite_empty)
679+
(insert : ∀ {a s}, a ∉ s →
680+
∀ hs : Set.Finite s, motive s hs → motive (insert a s) (hs.insert a)) :
681+
motive s hs := by
682+
lift s to Finset α using id hs
683+
induction' s using Finset.cons_induction_on with a s ha ih
684+
· simpa
685+
· simpa using @insert a s ha (Set.toFinite _) (ih _)
686+
687+
/-- Induction principle for finite sets: To prove a property `C` of a finite set `s`, it's enough
688+
to prove for the empty set and to prove that `C t → C ({a} ∪ t)` for all `t ⊆ s`.
689+
690+
This is analogous to `Finset.induction_on'`. See also `Set.Finite.induction_on` for the version
691+
requiring `C t → C ({a} ∪ t)` for all `t`. -/
681692
@[elab_as_elim]
682-
theorem Finite.induction_on' {C : Set α → Prop} {S : Set α} (h : S.Finite) (H0 : C ∅)
683-
(H1 : ∀ {a s}, a ∈ S → s ⊆ S → a ∉ s → C s → C (insert a s)) : C S := by
684-
refine @Set.Finite.induction_on α (fun s => s ⊆ S → C s) S h (fun _ => H0) ?_ Subset.rfl
693+
theorem Finite.induction_on_subset {motive : ∀ s : Set α, s.Finite → Prop} (s : Set α)
694+
(hs : s.Finite) (empty : motive ∅ finite_empty)
695+
(insert : ∀ {a t}, a ∈ s → ∀ hts : t ⊆ s, a ∉ t → motive t (hs.subset hts) →
696+
motive (insert a t) ((hs.subset hts).insert a)) : motive s hs := by
697+
refine Set.Finite.induction_on (motive := fun t _ => ∀ hts : t ⊆ s, motive t (hs.subset hts)) s hs
698+
(fun _ => empty) ?_ .rfl
685699
intro a s has _ hCs haS
686700
rw [insert_subset_iff] at haS
687-
exact H1 haS.1 haS.2 has (hCs haS.2)
701+
exact insert haS.1 haS.2 has (hCs haS.2)
688702

689-
@[elab_as_elim]
690-
theorem Finite.dinduction_on {C : ∀ s : Set α, s.Finite → Prop} (s : Set α) (h : s.Finite)
691-
(H0 : C ∅ finite_empty)
692-
(H1 : ∀ {a s}, a ∉ s → ∀ h : Set.Finite s, C s h → C (insert a s) (h.insert a)) : C s h :=
693-
have : ∀ h : s.Finite, C s h :=
694-
Finite.induction_on h (fun _ => H0) fun has hs ih _ => H1 has hs (ih _)
695-
this h
703+
@[deprecated (since := "2025-01-03")] alias Finite.induction_on' := Finite.induction_on_subset
704+
@[deprecated (since := "2025-01-03")] alias Finite.dinduction_on := Finite.induction_on
696705

697706
section
698707

@@ -908,9 +917,9 @@ theorem finite_range_findGreatest {P : α → ℕ → Prop} [∀ x, DecidablePre
908917

909918
theorem Finite.exists_maximal_wrt [PartialOrder β] (f : α → β) (s : Set α) (h : s.Finite)
910919
(hs : s.Nonempty) : ∃ a ∈ s, ∀ a' ∈ s, f a ≤ f a' → f a = f a' := by
911-
induction s, h using Set.Finite.dinduction_on with
912-
| H0 => exact absurd hs not_nonempty_empty
913-
| @H1 a s his _ ih =>
920+
induction s, h using Set.Finite.induction_on with
921+
| empty => exact absurd hs not_nonempty_empty
922+
| @insert a s his _ ih =>
914923
rcases s.eq_empty_or_nonempty with h | h
915924
· use a
916925
simp [h]

Mathlib/Data/Set/Finite/Lattice.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ lemma map_finite_iInf {F ι : Type*} [CompleteLattice α] [CompleteLattice β] [
276276
theorem Finite.iSup_biInf_of_monotone {ι ι' α : Type*} [Preorder ι'] [Nonempty ι']
277277
[IsDirected ι' (· ≤ ·)] [Order.Frame α] {s : Set ι} (hs : s.Finite) {f : ι → ι' → α}
278278
(hf : ∀ i ∈ s, Monotone (f i)) : ⨆ j, ⨅ i ∈ s, f i j = ⨅ i ∈ s, ⨆ j, f i j := by
279-
induction s, hs using Set.Finite.dinduction_on with
280-
| H0 => simp [iSup_const]
281-
| H1 _ _ ihs =>
279+
induction s, hs using Set.Finite.induction_on with
280+
| empty => simp [iSup_const]
281+
| insert _ _ ihs =>
282282
rw [forall_mem_insert] at hf
283283
simp only [iInf_insert, ← ihs hf.2]
284284
exact iSup_inf_of_monotone hf.1 fun j₁ j₂ hj => iInf₂_mono fun i hi => hf.2 i hi hj
@@ -361,12 +361,12 @@ variable [Preorder α] [IsDirected α (· ≤ ·)] [Nonempty α] {s : Set α}
361361

362362
/-- A finite set is bounded above. -/
363363
protected theorem Finite.bddAbove (hs : s.Finite) : BddAbove s :=
364-
Finite.induction_on hs bddAbove_empty fun _ _ h => h.insert _
364+
Finite.induction_on _ hs bddAbove_empty fun _ _ h => h.insert _
365365

366366
/-- A finite union of sets which are all bounded above is still bounded above. -/
367367
theorem Finite.bddAbove_biUnion {I : Set β} {S : β → Set α} (H : I.Finite) :
368368
BddAbove (⋃ i ∈ I, S i) ↔ ∀ i ∈ I, BddAbove (S i) :=
369-
Finite.induction_on H (by simp only [biUnion_empty, bddAbove_empty, forall_mem_empty])
369+
Finite.induction_on _ H (by simp only [biUnion_empty, bddAbove_empty, forall_mem_empty])
370370
fun _ _ hs => by simp only [biUnion_insert, forall_mem_insert, bddAbove_union, hs]
371371

372372
theorem infinite_of_not_bddAbove : ¬BddAbove s → s.Infinite :=

Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,10 @@ theorem toSubalgebra_iSup_of_directed (dir : Directed (· ≤ ·) t) :
110110
instance finiteDimensional_iSup_of_finite [h : Finite ι] [∀ i, FiniteDimensional K (t i)] :
111111
FiniteDimensional K (⨆ i, t i : IntermediateField K L) := by
112112
rw [← iSup_univ]
113-
let P : Set ι → Prop := fun s => FiniteDimensional K (⨆ i ∈ s, t i : IntermediateField K L)
114-
change P Set.univ
115-
apply Set.Finite.induction_on
116-
all_goals dsimp only [P]
117-
· exact Set.finite_univ
113+
refine Set.Finite.induction_on
114+
(motive := fun s _ => FiniteDimensional K (⨆ i ∈ s, t i : IntermediateField K L))
115+
_ Set.finite_univ ?_ ?_
116+
all_goals dsimp
118117
· rw [iSup_emptyset]
119118
exact (botEquiv K L).symm.toLinearEquiv.finiteDimensional
120119
· intro _ s _ _ hs

Mathlib/LinearAlgebra/TensorProduct/Finiteness.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ theorem exists_finite_submodule_of_finite (s : Set (M ⊗[R] N)) (hs : s.Finite)
100100
∃ (M' : Submodule R M) (N' : Submodule R N), Module.Finite R M' ∧ Module.Finite R N' ∧
101101
s ⊆ LinearMap.range (mapIncl M' N') := by
102102
simp_rw [Module.Finite.iff_fg]
103-
refine hs.induction_on ⟨_, _, fg_bot, fg_bot, Set.empty_subset _⟩ ?_
103+
refine hs.induction_on _ ⟨_, _, fg_bot, fg_bot, Set.empty_subset _⟩ ?_
104104
rintro a s - - ⟨M', N', hM', hN', h⟩
105105
refine TensorProduct.induction_on a ?_ (fun x y ↦ ?_) fun x y hx hy ↦ ?_
106106
· exact ⟨M', N', hM', hN', Set.insert_subset (zero_mem _) h⟩

Mathlib/MeasureTheory/Integral/IntegrableOn.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,8 @@ theorem integrableOn_singleton_iff {x : α} [MeasurableSingletonClass α] :
171171

172172
@[simp]
173173
theorem integrableOn_finite_biUnion {s : Set β} (hs : s.Finite) {t : β → Set α} :
174-
IntegrableOn f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, IntegrableOn f (t i) μ := by
175-
refine hs.induction_on ?_ ?_
176-
· simp
177-
· intro a s _ _ hf; simp [hf, or_imp, forall_and]
174+
IntegrableOn f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, IntegrableOn f (t i) μ :=
175+
hs.induction_on _ (by simp) <| by intro a s _ _ hf; simp [hf, or_imp, forall_and]
178176

179177
@[simp]
180178
theorem integrableOn_finset_iUnion {s : Finset β} {t : β → Set α} :

Mathlib/MeasureTheory/MeasurableSpace/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ theorem Set.Subsingleton.measurableSet {s : Set α} (hs : s.Subsingleton) : Meas
264264
hs.induction_on .empty .singleton
265265

266266
theorem Set.Finite.measurableSet {s : Set α} (hs : s.Finite) : MeasurableSet s :=
267-
Finite.induction_on hs MeasurableSet.empty fun _ _ hsm => hsm.insert _
267+
Finite.induction_on _ hs .empty fun _ _ hsm => hsm.insert _
268268

269269
@[measurability]
270270
protected theorem Finset.measurableSet (s : Finset α) : MeasurableSet (↑s : Set α) :=

Mathlib/NumberTheory/Cyclotomic/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ protected theorem finite [IsDomain B] [h₁ : Finite S] [h₂ : IsCyclotomicExte
301301
Module.Finite A B := by
302302
cases' nonempty_fintype S with h
303303
revert h₂ A B
304-
refine Set.Finite.induction_on h₁ (fun A B => ?_) @fun n S _ _ H A B => ?_
304+
refine Set.Finite.induction_on _ h₁ (fun A B => ?_) @fun n S _ _ H A B => ?_
305305
· intro _ _ _ _ _
306306
refine Module.finite_def.2 ⟨({1} : Finset B), ?_⟩
307307
simp [← top_toSubmodule, ← empty, toSubmodule_bot, Submodule.one_eq_span]

Mathlib/Order/Filter/Finite.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ variable {α : Type u} {f g : Filter α} {s t : Set α}
2525
@[simp]
2626
theorem biInter_mem {β : Type v} {s : β → Set α} {is : Set β} (hf : is.Finite) :
2727
(⋂ i ∈ is, s i) ∈ f ↔ ∀ i ∈ is, s i ∈ f :=
28-
Finite.induction_on hf (by simp) fun _ _ hs => by simp [hs]
28+
Finite.induction_on _ hf (by simp) fun _ _ hs => by simp [hs]
2929

3030
@[simp]
3131
theorem biInter_finset_mem {β : Type v} {s : β → Set α} (is : Finset β) :

Mathlib/Order/Filter/Ultrafilter.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ theorem eventually_imp : (∀ᶠ x in f, p x → q x) ↔ (∀ᶠ x in f, p x)
161161
simp only [imp_iff_not_or, eventually_or, eventually_not]
162162

163163
theorem finite_sUnion_mem_iff {s : Set (Set α)} (hs : s.Finite) : ⋃₀ s ∈ f ↔ ∃ t ∈ s, t ∈ f :=
164-
Finite.induction_on hs (by simp) fun _ _ his => by
164+
Finite.induction_on _ hs (by simp) fun _ _ his => by
165165
simp [union_mem_iff, his, or_and_right, exists_or]
166166

167167
theorem finite_biUnion_mem_iff {is : Set β} {s : β → Set α} (his : is.Finite) :

0 commit comments

Comments
 (0)