Skip to content
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

feat(logic/hydra): induction on an unordered pair #15286

Closed
wants to merge 5 commits into from
Closed

Conversation

vihdzp
Copy link
Collaborator

@vihdzp vihdzp commented Jul 12, 2022

We define the relation game_add_swap r a b = game_add r r a b ∨ game_add r r a.swap b and prove its well-foundedness. This formalizes induction on an unordered pair, where either entry decreases.

To facilitate using these relations, we also add custom induction/recursion lemmas for game_add and game_add_swap.


Open in Gitpod

@vihdzp vihdzp added the awaiting-review The author would like community review of the PR label Jul 12, 2022
@vihdzp vihdzp requested a review from alreadydone July 12, 2022 21:28
Copy link
Collaborator

@alreadydone alreadydone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to duplicate the fix, fix_eq and induction lemmas for every well-founded relation. Did you see such pattern elsewhere in mathlib?

I'm now a bit regretful that I didn't include the condition a ∈ s in cut_expand; if I did so then you should be able to use the map α × α → multiset α, show that game_add_swap is contained in the inv_image of cut_expand, then prove game_add_swap_aux (aside: shouldn't it be called acc.game_add_swap?) using acc_of_singleton and acc.cut_expand (which shouldn't need the is_irrefl hypothesis if cut_expand required a ∈ s).

src/logic/hydra.lean Outdated Show resolved Hide resolved
@vihdzp
Copy link
Collaborator Author

vihdzp commented Jul 13, 2022

The reason I'm specializing fix and fix_eq specifically for these two relations is so that they can be comfortably be used as lemmas on two variables, rather than lemmas on a single pair.

Also, every well founded relation is irreflexive, so maybe what you're saying can still be done? I would still like to have the fix and fix_eq theorems close to their current form if we did this: it's easier to prove a relation between four elements than it is to prove a relation between two multisets.

Co-authored-by: Junyan Xu <junyanxumath@gmail.com>
@vihdzp
Copy link
Collaborator Author

vihdzp commented Jul 13, 2022

Regarding game_add_swap_aux: this is just the conjunction of two applications of acc.game_add_swap, so I don't think it deserves any role beyond being an auxiliary result.

Copy link
Collaborator

@alreadydone alreadydone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding game_add_swap_aux: this is just the conjunction of two applications of acc.game_add_swap, so I don't think it deserves any role beyond being an auxiliary result.

OK, I missed that game_add_swap_aux is a conjunction,and acc.game_add_swap already exists and is what I expect.

The reason I'm specializing fix and fix_eq specifically for these two relations is so that they can be comfortably be used as lemmas on two variables, rather than lemmas on a single pair.

OK, I missed that they take C : α → α → Sort* instead of the uncurried form.

Also, every well founded relation is irreflexive, so maybe what you're saying can still be done? I would still like to have the fix and fix_eq theorems close to their current form if we did this: it's easier to prove a relation between four elements than it is to prove a relation between two multisets.

You can prove well_founded.game_add_swap this way but not acc.game_add_swap, and I think we should have the acc result for completeness. The form of the fix and fix_eq theorems looks good.

@vihdzp vihdzp changed the title feat(logic/hydra): game_add_swap feat(logic/hydra): induction on an unordered pair Jul 15, 2022
@vihdzp
Copy link
Collaborator Author

vihdzp commented Aug 5, 2022

I just learned about sym2, and I think it will be better to implement this new relation in terms of it.

@vihdzp vihdzp marked this pull request as draft August 5, 2022 22:02
@vihdzp
Copy link
Collaborator Author

vihdzp commented Aug 7, 2022

I'll redo this in terms of sym2 in a future PR.

@vihdzp vihdzp closed this Aug 7, 2022
@alreadydone
Copy link
Collaborator

I just came up with another proof of well-foundedness of game_add_swap using relation.fibration, as shown in this branch. It's only slightly shorter though.

I'm not sure sym2 makes things any easier; is your idea to define game_add_swap as the inv_image of the relation.map of game_add under the quotient map? That seems too convoluted.

@YaelDillies YaelDillies deleted the game_add_swap branch February 27, 2023 08:15
@YaelDillies YaelDillies removed the awaiting-review The author would like community review of the PR label Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants