Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 55534c4

Browse files
feat(data/nat/basic): recursion for set nat (#10273)
Adding a special case of `nat.le_rec_on` where the predicate is membership of a subset.
1 parent 6afda88 commit 55534c4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/data/nat/basic.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,18 @@ begin
741741
{ intros h hP, exact hP }
742742
end
743743

744+
/-- A subset of `ℕ` containing `b : ℕ` and closed under `nat.succ` contains every `n ≥ b`. -/
745+
lemma set_induction_bounded {b : ℕ} {S : set ℕ} (hb : b ∈ S) (h_ind: ∀ k : ℕ, k ∈ S → k + 1 ∈ S)
746+
{n : ℕ} (hbn : b ≤ n) : n ∈ S :=
747+
@le_rec_on (λ n, n ∈ S) b n hbn h_ind hb
748+
749+
/-- A subset of `ℕ` containing zero and closed under `nat.succ` contains all of `ℕ`. -/
750+
lemma set_induction {S : set ℕ} (hb : 0 ∈ S) (h_ind: ∀ k : ℕ, k ∈ S → k + 1 ∈ S) (n : ℕ) : n ∈ S :=
751+
set_induction_bounded hb h_ind (zero_le n)
752+
753+
lemma set_eq_univ {S : set ℕ} : S = set.univ ↔ 0 ∈ S ∧ ∀ k : ℕ, k ∈ S → k + 1 ∈ S :=
754+
by rintro rfl; simp, λ ⟨h0, hs⟩, set.eq_univ_of_forall (set_induction h0 hs)⟩
755+
744756
/-! ### `div` -/
745757

746758
attribute [simp] nat.div_self

0 commit comments

Comments
 (0)