-
-
Notifications
You must be signed in to change notification settings - Fork 27
add(SetTheory): Recursion, ordinal addition and multiplication #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tosiaki
wants to merge
26
commits into
FormalizedFormalLogic:master
Choose a base branch
from
tosiaki:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ee89a25
Adding recursion, definitions of addition and multiplication
e1d63e1
add(FirstOrder/SetTheory): Add definability (#791)
Convindix d97d9d2
add(SecondOrder): second-order LK (#792)
iehality 55f13b6
fix: Change `Inhabited` to `Nonempty` in `ForcingRelation` (#796)
Copilot 147aeb0
refactor(Incompleteness): Provability Abstraction Pt.3 (#797)
SnO2WMaN 67e0cc7
Merging changes
0466ef7
refactor(SetTheory): change recursion to use functions instead of fun…
1ebfac8
Merge branch 'master' into master
tosiaki 1bb7590
Merge branch 'master' into master
tosiaki 925ceff
refactor(SetTheory): changing usages of relations to functions, delet…
005eaf0
Merge branch 'master' of https://github.com/tosiaki/Foundation-SetTheory
2320e36
Merge branch 'master' into master
tosiaki 29cc764
My first commit to recursion, changed some names
Convindix 902e41d
Update Recursion.lean
Convindix b53353a
merging changes
b6b6794
Merge branch 'Convindix-recursion'
75d8538
Merge branch 'master' of https://github.com/tosiaki/Foundation-SetTheory
1178406
Simplify two proofs
Convindix dce7052
Simplify two proofs
Convindix a2b3927
Add some section headers, move lemmas around
Convindix 3413408
Add some section headers, move lemmas around
Convindix 034e200
Update recursion branch, no sorries
Convindix 161f540
Merge branch 'master' into graphless
Convindix 463b41f
Try to fix my merge attempt
Convindix 8eb042c
Merge branch 'master' into graphless
Convindix 086e272
Merge pull request #2 from Convindix/graphless
Convindix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module | ||
|
|
||
| public import Foundation.FirstOrder.SetTheory.Z | ||
| public import Foundation.FirstOrder.SetTheory.ZF | ||
|
|
||
| @[expose] public section | ||
| /-! | ||
|
|
@@ -402,6 +402,25 @@ lemma value_mem_range {f x : V} {X Y : V} (hf : f ∈ Y ^ X) (hx : x ∈ X) : f | |
| constructor <;> intro h <;> grind | ||
| grind | ||
|
|
||
| namespace IsFunction | ||
|
|
||
| lemma value_eq_of_kpair_mem (f x y : V) [IsFunction f] (hxy : ⟨x, y⟩ₖ ∈ f) : | ||
| f ‘ x = y := by | ||
| ext z | ||
| constructor | ||
| · intro hz | ||
| rcases show z ∈ ⋃ˢ range f ∧ ∃ y', z ∈ y' ∧ ⟨x, y'⟩ₖ ∈ f by | ||
| simpa [value, mem_sep_iff] using hz with | ||
| ⟨-, y', hzy', hxy'⟩ | ||
| have : y' = y := IsFunction.unique hxy' hxy | ||
| simpa [this] using hzy' | ||
| · intro hzy | ||
| have hyR : y ∈ range f := mem_range_of_kpair_mem hxy | ||
| have hzU : z ∈ ⋃ˢ range f := mem_sUnion_iff.mpr ⟨y, hyR, hzy⟩ | ||
| exact mem_sep_iff.mpr ⟨hzU, y, hzy, hxy⟩ | ||
|
|
||
| end IsFunction | ||
|
|
||
| /-- Restricting the domain of a relation -/ | ||
| noncomputable def restrict (R A : V) : V := R ∩ (A ×ˢ range R) | ||
|
|
||
|
|
@@ -415,6 +434,48 @@ instance restrict.defined : ℒₛₑₜ-function₂[V] restrict via restrict.df | |
|
|
||
| instance restrict.definable : ℒₛₑₜ-function₂[V] restrict := restrict.defined.to_definable | ||
|
|
||
| lemma mem_restrict_iff {R A p : V} : | ||
| p ∈ (R ↾ A) ↔ p ∈ R ∧ ∃ x ∈ A, ∃ y, p = ⟨x, y⟩ₖ := by | ||
| constructor | ||
| · intro hp | ||
| rcases show p ∈ R ∧ p ∈ A ×ˢ range R by simpa [restrict] using hp with ⟨hpR, hpP⟩ | ||
| rcases show ∃ x ∈ A, ∃ y ∈ range R, p = ⟨x, y⟩ₖ by simpa [mem_prod_iff] using hpP with | ||
| ⟨x, hxA, y, -, rfl⟩ | ||
| exact ⟨hpR, x, hxA, y, rfl⟩ | ||
| · rintro ⟨hpR, x, hxA, y, rfl⟩ | ||
| have hyR : y ∈ range R := mem_range_of_kpair_mem hpR | ||
| have hpP : ⟨x, y⟩ₖ ∈ A ×ˢ range R := by simpa [mem_prod_iff] using ⟨hxA, hyR⟩ | ||
| simpa [restrict] using And.intro hpR hpP | ||
|
|
||
| lemma IsFunction.restrict (f A : V) [hf : IsFunction f] : IsFunction (f ↾ A) := by | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This statement should be proved by a general proposition: @[grind ->] lemma IsFunction.odSubset (f g : V) [hf : IsFunction f] : g ⊆ f → IsFunction gand @[simp] lemma restrict_subset (f A : V) : f ↾ A ⊆ f |
||
| have hff : f ∈ range f ^ domain f := hf.mem_function | ||
| have : f ↾ A ∈ range f ^ (domain f ∩ A) := by | ||
| apply mem_function.intro | ||
| · intro p hp | ||
| rcases mem_restrict_iff.mp hp with ⟨hpf, x, hxA, y, rfl⟩ | ||
| have hxd : x ∈ domain f := mem_domain_of_kpair_mem hpf | ||
| have hyr : y ∈ range f := mem_range_of_kpair_mem hpf | ||
| simpa [mem_prod_iff] using ⟨⟨hxd, hxA⟩, hyr⟩ | ||
| · intro x hx | ||
| have ⟨hxd, hxA⟩ := show x ∈ domain f ∧ x ∈ A by simpa using hx | ||
| rcases exists_unique_of_mem_function hff x hxd with ⟨y, hy, hyu⟩ | ||
| refine ExistsUnique.intro y ?_ ?_ | ||
| · exact mem_restrict_iff.mpr ⟨hy, x, hxA, y, rfl⟩ | ||
| · intro y' hy' | ||
| have ⟨hy'f, _⟩ := mem_restrict_iff.mp hy' | ||
| exact hyu y' hy'f | ||
| exact IsFunction.of_mem this | ||
|
|
||
| lemma IsFunction.restrict_eq_self (f A : V) [hf : IsFunction f] (hA : domain f ⊆ A) : f ↾ A = f := by | ||
| apply subset_antisymm | ||
| · intro p hp | ||
| exact (mem_restrict_iff.mp hp).1 | ||
| · intro p hp | ||
| rcases show ∃ x ∈ domain f, ∃ y ∈ range f, p = ⟨x, y⟩ₖ from by | ||
| simpa [mem_prod_iff] using subset_prod_of_mem_function hf.mem_function p hp with | ||
| ⟨x, hxd, y, -, rfl⟩ | ||
| exact mem_restrict_iff.mpr ⟨hp, x, hA x hxd, y, rfl⟩ | ||
|
|
||
| lemma domain_restrict_eq (R A : V) : domain (R ↾ A) = domain R ∩ A := by | ||
| ext z | ||
| apply Iff.intro <;> intro h | ||
|
|
@@ -426,6 +487,42 @@ lemma domain_restrict_eq (R A : V) : domain (R ↾ A) = domain R ∩ A := by | |
| simp_all only [kpair_mem_iff, true_and, mem_range_iff] | ||
| use z | ||
|
|
||
| @[simp] lemma kpair_mem_restrict_iff {R A x y : V} : | ||
| ⟨x, y⟩ₖ ∈ (R ↾ A) ↔ ⟨x, y⟩ₖ ∈ R ∧ x ∈ A := by | ||
| simp [mem_restrict_iff] | ||
|
|
||
| lemma restrict_restrict_eq_restrict_inter (R A B : V) : (R ↾ A) ↾ B = R ↾ (A ∩ B) := by | ||
| ext p | ||
| simp only [mem_restrict_iff, mem_inter_iff] | ||
| constructor | ||
| · rintro ⟨⟨hpR, x, hxA, y, rfl⟩, x', hx'B, y', hxy⟩ | ||
| rcases kpair_inj hxy with ⟨rfl, rfl⟩ | ||
| exact ⟨hpR, x, ⟨hxA, hx'B⟩, y, rfl⟩ | ||
| · rintro ⟨hpR, x, hxAB, y, rfl⟩ | ||
| exact ⟨⟨hpR, x, hxAB.1, y, rfl⟩, x, hxAB.2, y, rfl⟩ | ||
|
|
||
| lemma restrict_restrict_of_subset {R A B : V} (h : B ⊆ A) : (R ↾ A) ↾ B = R ↾ B := by | ||
| simpa [inter_eq_right_of_subset h] using restrict_restrict_eq_restrict_inter R A B | ||
|
|
||
| /-- | ||
| Restricting an inserted relation to a set that does not contain the inserted first coordinate | ||
| recovers the original restriction. | ||
| -/ | ||
| lemma restrict_insert_kpair_eq_restrict_of_not_mem | ||
| {f x y A : V} (hxA : x ∉ A) : | ||
| (insert ⟨x, y⟩ₖ f) ↾ A = f ↾ A := by | ||
| ext p | ||
| constructor | ||
| · intro hp | ||
| rcases mem_restrict_iff.mp hp with ⟨hp', a, haA, b, rfl⟩ | ||
| rcases show ⟨a, b⟩ₖ = ⟨x, y⟩ₖ ∨ ⟨a, b⟩ₖ ∈ f by simpa using hp' with (hxy | hf) | ||
| · rcases kpair_inj hxy with ⟨rfl, rfl⟩ | ||
| exact (hxA haA).elim | ||
| · exact mem_restrict_iff.mpr ⟨hf, a, haA, b, rfl⟩ | ||
| · intro hp | ||
| rcases mem_restrict_iff.mp hp with ⟨hf, a, haA, b, rfl⟩ | ||
| exact mem_restrict_iff.mpr ⟨by simp [hf], a, haA, b, rfl⟩ | ||
|
|
||
| /-- Image of a set under a relation -/ | ||
| noncomputable def image (R A : V) : V := range (restrict R A) | ||
|
|
||
|
|
@@ -439,8 +536,127 @@ instance image.defined : ℒₛₑₜ-function₂[V] image via image.dfn := | |
|
|
||
| instance image.definable : ℒₛₑₜ-function₂[V] image := image.defined.to_definable | ||
|
|
||
| /-- | ||
| Graph construction from a function-like relation on a fixed set `X`. | ||
| -/ | ||
| lemma replacement_graph_exists_on [V ⊧ₘ* 𝗭𝗙] (X : V) (R : V → V → Prop) (hR : ℒₛₑₜ-relation[V] R) | ||
| (hfun : ∀ x : V, x ∈ X → ∃! y : V, R x y) : | ||
|
iehality marked this conversation as resolved.
Outdated
|
||
| ∃ f : V, IsFunction f ∧ domain f = X ∧ | ||
| ∀ x ∈ X, ∀ y, ⟨x, y⟩ₖ ∈ f ↔ R x y := by | ||
| let S : V → V → Prop := fun x p ↦ ∃ y : V, R x y ∧ p = ⟨x, y⟩ₖ | ||
| have hS : ℒₛₑₜ-relation[V] S := by | ||
| letI : ℒₛₑₜ-relation[V] R := hR | ||
| change ℒₛₑₜ-relation[V] (fun x p ↦ ∃ y : V, R x y ∧ p = ⟨x, y⟩ₖ) | ||
| definability | ||
| have hfunS : ∀ x : V, x ∈ X → ∃! p : V, S x p := by | ||
| intro x hx | ||
| rcases hfun x hx with ⟨y, hy, hyu⟩ | ||
| refine ⟨⟨x, y⟩ₖ, ⟨y, hy, rfl⟩, ?_⟩ | ||
| intro p hp | ||
| rcases hp with ⟨y', hy', hp⟩ | ||
| have : y' = y := hyu y' hy' | ||
| rcases this | ||
| simp [hp] | ||
| rcases replacement_exists_on (X := X) S hS hfunS with ⟨f, hf⟩ | ||
| have hmem : ∀ p : V, p ∈ f ↔ ∃ x ∈ X, ∃ y, R x y ∧ p = ⟨x, y⟩ₖ := by | ||
| intro p | ||
| constructor | ||
| · intro hp | ||
| rcases (hf p).1 hp with ⟨x, hxX, hpS⟩ | ||
| rcases hpS with ⟨y, hy, rfl⟩ | ||
| exact ⟨x, hxX, y, hy, rfl⟩ | ||
| · rintro ⟨x, hxX, y, hy, rfl⟩ | ||
| exact (hf _).2 ⟨x, hxX, ⟨y, hy, rfl⟩⟩ | ||
| have hgraph : ∀ x ∈ X, ∀ y, ⟨x, y⟩ₖ ∈ f ↔ R x y := by | ||
| intro x hxX y | ||
| constructor | ||
| · intro hxy | ||
| rcases (hmem _).1 hxy with ⟨x', hx'X, y', hy', hxy'⟩ | ||
| rcases kpair_inj hxy' with ⟨rfl, rfl⟩ | ||
| exact hy' | ||
| · intro hxy | ||
| exact (hmem _).2 ⟨x, hxX, y, hxy, rfl⟩ | ||
| have hdomain : domain f = X := by | ||
| apply subset_antisymm | ||
| · intro x hx | ||
| rcases mem_domain_iff.mp hx with ⟨y, hxy⟩ | ||
| rcases (hmem _).1 hxy with ⟨x', hx'X, y', -, hxy'⟩ | ||
| rcases kpair_inj hxy' with ⟨rfl, -⟩ | ||
| exact hx'X | ||
| · intro x hxX | ||
| rcases hfun x hxX with ⟨y, hy, -⟩ | ||
| exact mem_domain_iff.mpr ⟨y, (hgraph x hxX y).2 hy⟩ | ||
| have hfunc_mem : f ∈ range f ^ domain f := by | ||
| apply mem_function.intro | ||
| · intro p hp | ||
| rcases (hmem _).1 hp with ⟨x, hxX, y, hy, rfl⟩ | ||
| have hxyf : ⟨x, y⟩ₖ ∈ f := (hgraph x hxX y).2 hy | ||
| have hxd : x ∈ domain f := mem_domain_of_kpair_mem hxyf | ||
| have hyr : y ∈ range f := mem_range_of_kpair_mem hxyf | ||
| simpa [mem_prod_iff] using ⟨hxd, hyr⟩ | ||
| · intro x hx | ||
| rcases mem_domain_iff.mp hx with ⟨y₀, hxy₀⟩ | ||
| refine ExistsUnique.intro y₀ hxy₀ ?_ | ||
| intro y₁ hxy₁ | ||
| have hxX : x ∈ X := by simpa [hdomain] using hx | ||
| have hR₀ : R x y₀ := (hgraph x hxX y₀).1 hxy₀ | ||
| have hR₁ : R x y₁ := (hgraph x hxX y₁).1 hxy₁ | ||
| exact (hfun x hxX).unique hR₁ hR₀ | ||
| refine ⟨f, IsFunction.of_mem hfunc_mem, hdomain, hgraph⟩ | ||
|
|
||
| /-- | ||
| Graph construction from a definable unary function on a fixed set `X`. | ||
| -/ | ||
| lemma replacement_graph_exists_on_of_definableFunction [V ⊧ₘ* 𝗭𝗙] | ||
| (X : V) (F : V → V) (hFdef : ℒₛₑₜ-function₁[V] F) : | ||
| ∃ f : V, IsFunction f ∧ domain f = X ∧ | ||
| ∀ x ∈ X, ∀ y, ⟨x, y⟩ₖ ∈ f ↔ y = F x := by | ||
| let R : V → V → Prop := fun x y ↦ Function.Graph F y x | ||
| have hR : ℒₛₑₜ-relation[V] R := by | ||
| letI : ℒₛₑₜ-function₁[V] F := hFdef | ||
| change ℒₛₑₜ-relation[V] (fun x y ↦ Function.Graph F y x) | ||
| definability | ||
| have hfun : ∀ x : V, x ∈ X → ∃! y : V, R x y := by | ||
| intro x _ | ||
| simpa [R] using functionGraph_functionLike F x | ||
| rcases replacement_graph_exists_on (X := X) R hR hfun with ⟨f, hf, hdf, hgraph⟩ | ||
| refine ⟨f, hf, hdf, ?_⟩ | ||
| intro x hx y | ||
| simpa [R, Function.Graph] using hgraph x hx y | ||
|
|
||
| /-! ### Cardinality comparison -/ | ||
|
|
||
| @[simp] lemma kpair_mem_sUnion_iff {C x y : V} : | ||
| ⟨x, y⟩ₖ ∈ ⋃ˢ C ↔ ∃ f ∈ C, ⟨x, y⟩ₖ ∈ f := by | ||
| simp [mem_sUnion_iff] | ||
|
|
||
| lemma IsFunction.sUnion_of_coherent {C : V} | ||
| (hfunc : ∀ f ∈ C, IsFunction f) | ||
| (hcoh : ∀ f ∈ C, ∀ g ∈ C, ∀ x y₁ y₂, | ||
| ⟨x, y₁⟩ₖ ∈ f → ⟨x, y₂⟩ₖ ∈ g → y₁ = y₂) : | ||
| IsFunction (⋃ˢ C) := by | ||
| have hmem : ⋃ˢ C ∈ range (⋃ˢ C) ^ domain (⋃ˢ C) := by | ||
| apply mem_function.intro | ||
| · intro p hp | ||
| rcases mem_sUnion_iff.mp hp with ⟨f, hfC, hpf⟩ | ||
| have hff : IsFunction f := hfunc f hfC | ||
| have hmem : f ∈ range f ^ domain f := IsFunction.mem_function f | ||
| rcases show ∃ x ∈ domain f, ∃ y ∈ range f, p = ⟨x, y⟩ₖ from by | ||
| simpa [mem_prod_iff] using subset_prod_of_mem_function hmem p hpf with | ||
| ⟨x, hxd, y, hyd, rfl⟩ | ||
| have hxyU : ⟨x, y⟩ₖ ∈ ⋃ˢ C := mem_sUnion_iff.mpr ⟨f, hfC, by simpa⟩ | ||
| have hxU : x ∈ domain (⋃ˢ C) := mem_domain_of_kpair_mem hxyU | ||
| have hyU : y ∈ range (⋃ˢ C) := mem_range_of_kpair_mem hxyU | ||
| simpa [mem_prod_iff] using And.intro hxU hyU | ||
| · intro x hx | ||
| rcases mem_domain_iff.mp hx with ⟨y, hxyU⟩ | ||
| refine ExistsUnique.intro y hxyU ?_ | ||
| intro y' hxy'U | ||
| rcases mem_sUnion_iff.mp hxyU with ⟨f, hfC, hxyf⟩ | ||
| rcases mem_sUnion_iff.mp hxy'U with ⟨g, hgC, hxyg⟩ | ||
| exact (hcoh f hfC g hgC x y y' hxyf hxyg).symm | ||
| exact IsFunction.of_mem hmem | ||
|
|
||
| def CardLE (X Y : V) : Prop := ∃ f ∈ Y ^ X, Injective f | ||
|
|
||
| infix:50 " ≤# " => CardLE | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.