-
Notifications
You must be signed in to change notification settings - Fork 316
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
refactor: migrate to dependent induction lemmas #17543
Open
j-loreaux
wants to merge
2
commits into
master
Choose a base branch
from
j-loreaux/induction-prime
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.
+52
−48
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
|
@@ -294,30 +294,31 @@ is preserved under multiplication, then `p` holds for all elements of the closur | |
@[to_additive (attr := elab_as_elim) "An induction principle for additive closure membership. If `p` | ||
holds for all elements of `s`, and is preserved under addition, then `p` holds for all | ||
elements of the additive closure of `s`."] | ||
theorem closure_induction {p : M → Prop} {x} (h : x ∈ closure s) (mem : ∀ x ∈ s, p x) | ||
(mul : ∀ x y, p x → p y → p (x * y)) : p x := | ||
(@closure_le _ _ _ ⟨p, mul _ _⟩).2 mem h | ||
|
||
/-- A dependent version of `Subsemigroup.closure_induction`. -/ | ||
@[to_additive (attr := elab_as_elim) "A dependent version of `AddSubsemigroup.closure_induction`. "] | ||
theorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop} | ||
theorem closure_induction {p : ∀ x, x ∈ closure s → Prop} | ||
(mem : ∀ (x) (h : x ∈ s), p x (subset_closure h)) | ||
(mul : ∀ x hx y hy, p x hx → p y hy → p (x * y) (mul_mem hx hy)) {x} (hx : x ∈ closure s) : | ||
p x hx := by | ||
refine Exists.elim ?_ fun (hx : x ∈ closure s) (hc : p x hx) => hc | ||
exact | ||
closure_induction hx (fun x hx => ⟨_, mem x hx⟩) fun x y ⟨hx', hx⟩ ⟨hy', hy⟩ => | ||
⟨_, mul _ _ _ _ hx hy⟩ | ||
p x hx := | ||
let S : Subsemigroup M := | ||
{ carrier := { x | ∃ hx, p x hx } | ||
mul_mem' := fun ⟨hx, hpx⟩ ⟨hy, hpy⟩ ↦ ⟨mul_mem hx hy, mul _ hx _ hy hpx hpy⟩ } | ||
closure_le (S := S) |>.mpr (fun y hy ↦ ⟨subset_closure hy, mem y hy⟩) hx |>.elim fun _ ↦ id | ||
|
||
/-- An induction principle for closure membership for predicates with two arguments. -/ | ||
@[to_additive (attr := elab_as_elim) "An induction principle for additive closure membership for | ||
predicates with two arguments."] | ||
theorem closure_induction₂ {p : M → M → Prop} {x} {y : M} (hx : x ∈ closure s) (hy : y ∈ closure s) | ||
(Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (Hmul_left : ∀ x y z, p x z → p y z → p (x * y) z) | ||
(Hmul_right : ∀ x y z, p z x → p z y → p z (x * y)) : p x y := | ||
closure_induction hx | ||
(fun x xs => closure_induction hy (Hs x xs) fun z _ h₁ h₂ => Hmul_right z _ _ h₁ h₂) | ||
fun _ _ h₁ h₂ => Hmul_left _ _ _ h₁ h₂ | ||
theorem closure_induction₂ {p : ∀ x y, x ∈ closure s → y ∈ closure s → Prop} | ||
(mem : ∀ (x) (hx : x ∈ s) (y) (hy : y ∈ s), p x y (subset_closure hx) (subset_closure hy)) | ||
(mul_left : ∀ x hx y hy z hz , p x z hx hz → p y z hy hz → p (x * y) z (mul_mem hx hy) hz) | ||
(mul_right : ∀ x hx y hy z hz , p z x hz hx → p z y hz hy → p z (x * y) hz (mul_mem hx hy)) | ||
{x y : M} (hx : x ∈ closure s) (hy : y ∈ closure s) : p x y hx hy := by | ||
refine closure_induction (closure_induction mem ?_ hx) (mul_right · · · · _ hx · ·) hy | ||
exact fun _ _ _ _ h₁ h₂ z hz ↦ mul_left _ _ _ _ _ (subset_closure hz) (h₁ _ hz) (h₂ _ hz) | ||
-- which version do we prefer? | ||
--induction hx using closure_induction with | ||
--| mem z hz => induction hy using closure_induction with | ||
--| mem _ h => exact mem _ hz _ h | ||
--| mul _ _ _ _ h₁ h₂ => exact mul_right _ _ _ _ _ (subset_closure hz) h₁ h₂ | ||
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. I'm curious if you can drop the |
||
--| mul _ _ _ _ h₁ h₂ => exact mul_left _ _ _ _ _ hy h₁ h₂ | ||
|
||
/-- If `s` is a dense set in a magma `M`, `Subsemigroup.closure s = ⊤`, then in order to prove that | ||
some predicate `p` holds for all `x : M` it suffices to verify `p x` for `x ∈ s`, | ||
|
@@ -326,11 +327,11 @@ and verify that `p x` and `p y` imply `p (x * y)`. -/ | |
`AddSubsemigroup.closure s = ⊤`, then in order to prove that some predicate `p` holds | ||
for all `x : M` it suffices to verify `p x` for `x ∈ s`, and verify that `p x` and `p y` imply | ||
`p (x + y)`."] | ||
theorem dense_induction {p : M → Prop} (x : M) {s : Set M} (hs : closure s = ⊤) | ||
theorem dense_induction {p : M → Prop} {s : Set M} (hs : closure s = ⊤) | ||
(mem : ∀ x ∈ s, p x) | ||
(mul : ∀ x y, p x → p y → p (x * y)) : p x := by | ||
have : ∀ x ∈ closure s, p x := fun x hx => closure_induction hx mem mul | ||
simpa [hs] using this x | ||
(mul : ∀ x y, p x → p y → p (x * y)) | ||
(x : M) : p x := | ||
closure_induction (p := fun x _ ↦ p x) mem (fun x _ y _ ↦ mul x y) (hs.symm ▸ mem_top x) | ||
|
||
variable (M) | ||
|
||
|
@@ -426,8 +427,8 @@ def ofDense {M N} [Semigroup M] [Semigroup N] {s : Set M} (f : M → N) (hs : cl | |
M →ₙ* N where | ||
toFun := f | ||
map_mul' x y := | ||
dense_induction y hs (fun y hy x => hmul x y hy) | ||
(fun y₁ y₂ h₁ h₂ x => by simp only [← mul_assoc, h₁, h₂]) x | ||
dense_induction hs (fun y hy x => hmul x y hy) | ||
(fun y₁ y₂ h₁ h₂ x => by simp only [← mul_assoc, h₁, h₂]) y x | ||
|
||
/-- Let `s` be a subset of an additive semigroup `M` such that the closure of `s` is the whole | ||
semigroup. Then `AddHom.ofDense` defines an additive homomorphism from `M` asking for a proof | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.