-
Notifications
You must be signed in to change notification settings - Fork 299
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
Conversation
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 } | ||
|
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.
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.
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.
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.
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.
Relatedly, I wouldn't mind some nice notation for ite P 1 0
.
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.
The nice notation is if P then 1 else 0
. What would be nicer?
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.
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.
* feat(data/list/sort): ordered_insert lemmas * add a lemma about L.tail.count
Some straightforward lemmas about the
ordered_insert
operation defined in data/list/sort.lean.