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(data/list/sort): ordered_insert lemmas #1437

Merged
merged 4 commits into from
Sep 17, 2019
Merged

feat(data/list/sort): ordered_insert lemmas #1437

merged 4 commits into from
Sep 17, 2019

Conversation

semorrison
Copy link
Collaborator

Some straightforward lemmas about the ordered_insert operation defined in data/list/sort.lean.

@semorrison semorrison requested a review from a team as a code owner September 14, 2019 10:27
theorem count_tail : Π (l : list α) (a : α) (h : 0 < l.length),
l.tail.count a = l.count a - ite (a = list.nth_le l 0 h) 1 0
| (_ :: _) a h := by { rw [count_cons], split_ifs; simp }

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but maybe this should be l.tail.count a + ite (a = list.nth_le l 0 h) 1 0 = l.count a just to avoid natural number subtraction.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about this, but it's really intended as a simplification lemma, so I wanted the LHS to be the thing being calculated. If I move the ite to the LHS, at least in my use case, and probably others, the user is just going to have to rearrange the lemma by hand before they can use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Relatedly, I wouldn't mind some nice notation for ite P 1 0.

Copy link
Member

Choose a reason for hiding this comment

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

The nice notation is if P then 1 else 0. What would be nicer?

Copy link
Member

Choose a reason for hiding this comment

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

I would be okay with a definition like boole P or similar to mean ite P 1 0. But it doesn't save a lot of space, and I'm not sure how many interesting theorems there are to prove about it.

@ChrisHughes24 ChrisHughes24 added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Sep 16, 2019
@mergify mergify bot merged commit c412527 into master Sep 17, 2019
@mergify mergify bot deleted the ordered_insert branch September 17, 2019 00:59
This was referenced Sep 23, 2019
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
* feat(data/list/sort): ordered_insert lemmas

* add a lemma about L.tail.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants