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

[Merged by Bors] - feat: add reverse induction principle for Vector #5400

Closed
wants to merge 10 commits into from

Conversation

alexkeizer
Copy link
Collaborator

@alexkeizer alexkeizer commented Jun 22, 2023

Add a snoc pseudo-constructor, lemmas to reason about snoc, and a reverse induction principle for Vectors.


Vector.snoc xs x is just a short-hand for xs ++ [x].
The reverse induction principle uses xs.snoc x for it's recursive step, which makes it easier to reason about algorithms that work on a Vector right-to-left, such as foldr or mapAccumr.
The PR also add some simplification rules for snoc which help with such backwards proofs.

Open in Gitpod

@alexkeizer alexkeizer added blocked-by-other-PR This PR depends on another PR which is still in the queue. awaiting-CI new-feature Add features not present in Mathlib 3 labels Jun 22, 2023
@semorrison semorrison added merge-conflict The PR has a merge conflict with master, and needs manual merging. and removed blocked-by-other-PR This PR depends on another PR which is still in the queue. labels Jun 27, 2023
@alexkeizer alexkeizer added the awaiting-review The author would like community review of the PR label Jun 27, 2023
@semorrison semorrison removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jun 27, 2023
@alexkeizer alexkeizer marked this pull request as ready for review June 27, 2023 15:32
Copy link
Member

@ChrisHughes24 ChrisHughes24 left a comment

Choose a reason for hiding this comment

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

I think my main comments here are just style comments about indentation.

Mathlib/Data/Vector/Basic.lean Outdated Show resolved Hide resolved
Comment on lines 84 to 86
(nil : C nil)
(snoc : ∀ {n : ℕ} (xs : Vector α n) (x : α), C xs → C (xs.snoc x))
: C v :=
Copy link
Member

Choose a reason for hiding this comment

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

This indentation style is not usual. We just indent the theorem statement with four spaces usually, with occasional extra two space indentations for readability.

@alexkeizer
Copy link
Collaborator Author

I think my main comments here are just style comments about indentation.

These should now be addressed

Copy link
Member

@ChrisHughes24 ChrisHughes24 left a comment

Choose a reason for hiding this comment

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

You can merge after the small fixes

bors d+

Mathlib/Data/Vector/Snoc.lean Outdated Show resolved Hide resolved

@[simp]
theorem mapAccumr_cons : mapAccumr f (x ::ᵥ xs) s
= let r := mapAccumr f xs s
Copy link
Member

Choose a reason for hiding this comment

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

I think this indentation is somewhat not in mathlib style as well.

Mathlib/Data/Vector/Snoc.lean Outdated Show resolved Hide resolved
Mathlib/Data/Vector/Snoc.lean Outdated Show resolved Hide resolved
Mathlib/Data/Vector/Snoc.lean Show resolved Hide resolved
Mathlib/Data/Vector/Snoc.lean Outdated Show resolved Hide resolved
@bors
Copy link

bors bot commented Jun 28, 2023

✌️ alexkeizer can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@semorrison semorrison added delegated and removed awaiting-review The author would like community review of the PR labels Jun 28, 2023
alexkeizer and others added 3 commits June 28, 2023 14:55
Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com>
@alexkeizer
Copy link
Collaborator Author

bors merge

bors bot pushed a commit that referenced this pull request Jun 28, 2023
Add a snoc pseudo-constructor, lemmas to reason about snoc, and a reverse induction principle for Vectors.
@bors
Copy link

bors bot commented Jun 28, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title feat: add reverse induction principle for Vector [Merged by Bors] - feat: add reverse induction principle for Vector Jun 28, 2023
@bors bors bot closed this Jun 28, 2023
@bors bors bot deleted the vector-snoc branch June 28, 2023 16:07
semorrison pushed a commit that referenced this pull request Jun 29, 2023
Add a snoc pseudo-constructor, lemmas to reason about snoc, and a reverse induction principle for Vectors.
kbuzzard pushed a commit that referenced this pull request Jul 6, 2023
Add a snoc pseudo-constructor, lemmas to reason about snoc, and a reverse induction principle for Vectors.
semorrison pushed a commit that referenced this pull request Aug 14, 2023
Add a snoc pseudo-constructor, lemmas to reason about snoc, and a reverse induction principle for Vectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated new-feature Add features not present in Mathlib 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants