Skip to content

Commit 0466ef7

Browse files
author
This Name
committed
refactor(SetTheory): change recursion to use functions instead of function-like relations
1 parent 67e0cc7 commit 0466ef7

4 files changed

Lines changed: 1668 additions & 1287 deletions

File tree

Foundation/FirstOrder/SetTheory/Function.lean

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module
22

3-
public import Foundation.FirstOrder.SetTheory.Z
3+
public import Foundation.FirstOrder.SetTheory.ZF
44

55
@[expose] public section
66
/-!
@@ -402,6 +402,25 @@ lemma value_mem_range {f x : V} {X Y : V} (hf : f ∈ Y ^ X) (hx : x ∈ X) : f
402402
constructor <;> intro h <;> grind
403403
grind
404404

405+
namespace IsFunction
406+
407+
lemma value_eq_of_kpair_mem (f x y : V) [IsFunction f] (hxy : ⟨x, y⟩ₖ ∈ f) :
408+
f ‘ x = y := by
409+
ext z
410+
constructor
411+
· intro hz
412+
rcases show z ∈ ⋃ˢ range f ∧ ∃ y', z ∈ y' ∧ ⟨x, y'⟩ₖ ∈ f by
413+
simpa [value, mem_sep_iff] using hz with
414+
⟨-, y', hzy', hxy'⟩
415+
have : y' = y := IsFunction.unique hxy' hxy
416+
simpa [this] using hzy'
417+
· intro hzy
418+
have hyR : y ∈ range f := mem_range_of_kpair_mem hxy
419+
have hzU : z ∈ ⋃ˢ range f := mem_sUnion_iff.mpr ⟨y, hyR, hzy⟩
420+
exact mem_sep_iff.mpr ⟨hzU, y, hzy, hxy⟩
421+
422+
end IsFunction
423+
405424
/-- Restricting the domain of a relation -/
406425
noncomputable def restrict (R A : V) : V := R ∩ (A ×ˢ range R)
407426

@@ -472,15 +491,37 @@ lemma domain_restrict_eq (R A : V) : domain (R ↾ A) = domain R ∩ A := by
472491
⟨x, y⟩ₖ ∈ (R ↾ A) ↔ ⟨x, y⟩ₖ ∈ R ∧ x ∈ A := by
473492
simp [mem_restrict_iff]
474493

475-
lemma restrict_restrict_of_subset {R A B : V} (h : B ⊆ A) : (R ↾ A) ↾ B = R ↾ B := by
494+
lemma restrict_restrict_eq_restrict_inter (R A B : V) : (R ↾ A) ↾ B = R ↾ (A ∩ B) := by
476495
ext p
477-
simp only [mem_restrict_iff]
496+
simp only [mem_restrict_iff, mem_inter_iff]
478497
constructor
479-
· rintro ⟨⟨hpR, x, _, y, rfl⟩, x', hx'B, y', hxy⟩
498+
· rintro ⟨⟨hpR, x, hxA, y, rfl⟩, x', hx'B, y', hxy⟩
480499
rcases kpair_inj hxy with ⟨rfl, rfl⟩
481-
exact ⟨hpR, x, hx'B, y, rfl⟩
482-
· rintro ⟨hpR, x, hxB, y, rfl⟩
483-
exact ⟨⟨hpR, x, h x hxB, y, rfl⟩, x, hxB, y, rfl⟩
500+
exact ⟨hpR, x, ⟨hxA, hx'B⟩, y, rfl⟩
501+
· rintro ⟨hpR, x, hxAB, y, rfl⟩
502+
exact ⟨⟨hpR, x, hxAB.1, y, rfl⟩, x, hxAB.2, y, rfl⟩
503+
504+
lemma restrict_restrict_of_subset {R A B : V} (h : B ⊆ A) : (R ↾ A) ↾ B = R ↾ B := by
505+
simpa [inter_eq_right_of_subset h] using restrict_restrict_eq_restrict_inter R A B
506+
507+
/--
508+
Restricting an inserted relation to a set that does not contain the inserted first coordinate
509+
recovers the original restriction.
510+
-/
511+
lemma restrict_insert_kpair_eq_restrict_of_not_mem
512+
{f x y A : V} (hxA : x ∉ A) :
513+
(insert ⟨x, y⟩ₖ f) ↾ A = f ↾ A := by
514+
ext p
515+
constructor
516+
· intro hp
517+
rcases mem_restrict_iff.mp hp with ⟨hp', a, haA, b, rfl⟩
518+
rcases show ⟨a, b⟩ₖ = ⟨x, y⟩ₖ ∨ ⟨a, b⟩ₖ ∈ f by simpa using hp' with (hxy | hf)
519+
· rcases kpair_inj hxy with ⟨rfl, rfl⟩
520+
exact (hxA haA).elim
521+
· exact mem_restrict_iff.mpr ⟨hf, a, haA, b, rfl⟩
522+
· intro hp
523+
rcases mem_restrict_iff.mp hp with ⟨hf, a, haA, b, rfl⟩
524+
exact mem_restrict_iff.mpr ⟨by simp [hf], a, haA, b, rfl⟩
484525

485526
/-- Image of a set under a relation -/
486527
noncomputable def image (R A : V) : V := range (restrict R A)
@@ -563,6 +604,26 @@ lemma replacement_graph_exists_on [V ⊧ₘ* 𝗭𝗙] (X : V) (R : V → V →
563604
exact (hfun x hxX).unique hR₁ hR₀
564605
refine ⟨f, IsFunction.of_mem hfunc_mem, hdomain, hgraph⟩
565606

607+
/--
608+
Graph construction from a definable unary function on a fixed set `X`.
609+
-/
610+
lemma replacement_graph_exists_on_of_definableFunction [V ⊧ₘ* 𝗭𝗙]
611+
(X : V) (F : V → V) (hFdef : ℒₛₑₜ-function₁[V] F) :
612+
∃ f : V, IsFunction f ∧ domain f = X ∧
613+
∀ x ∈ X, ∀ y, ⟨x, y⟩ₖ ∈ f ↔ y = F x := by
614+
let R : V → V → Prop := fun x y ↦ Function.Graph F y x
615+
have hR : ℒₛₑₜ-relation[V] R := by
616+
letI : ℒₛₑₜ-function₁[V] F := hFdef
617+
change ℒₛₑₜ-relation[V] (fun x y ↦ Function.Graph F y x)
618+
definability
619+
have hfun : ∀ x : V, x ∈ X → ∃! y : V, R x y := by
620+
intro x _
621+
simpa [R] using functionGraph_functionLike F x
622+
rcases replacement_graph_exists_on (X := X) R hR hfun with ⟨f, hf, hdf, hgraph⟩
623+
refine ⟨f, hf, hdf, ?_⟩
624+
intro x hx y
625+
simpa [R, Function.Graph] using hgraph x hx y
626+
566627
/-! ### Cardinality comparison -/
567628

568629
@[simp] lemma kpair_mem_sUnion_iff {C x y : V} :

0 commit comments

Comments
 (0)