@@ -668,31 +668,40 @@ theorem finite_option {s : Set (Option α)} : s.Finite ↔ { x : α | some x ∈
668
668
((h.image some).insert none).subset fun x =>
669
669
x.casesOn (fun _ => Or.inl rfl) fun _ hx => Or.inr <| mem_image_of_mem _ hx⟩
670
670
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`. -/
671
676
@[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`. -/
681
692
@[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
685
699
intro a s has _ hCs haS
686
700
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 )
688
702
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
696
705
697
706
section
698
707
@@ -908,9 +917,9 @@ theorem finite_range_findGreatest {P : α → ℕ → Prop} [∀ x, DecidablePre
908
917
909
918
theorem Finite.exists_maximal_wrt [PartialOrder β] (f : α → β) (s : Set α) (h : s.Finite)
910
919
(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 =>
914
923
rcases s.eq_empty_or_nonempty with h | h
915
924
· use a
916
925
simp [h]
0 commit comments