-
Notifications
You must be signed in to change notification settings - Fork 88
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: getElem!_cons_zero #214
Conversation
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.
Nice! Lean core has List.cons_getElem_zero
and List.cons_getElem_succ
, so following the same convention makes sense here. Also, you might as well add all the companion theorems at the same time:
@[simp] theorem cons_getElem!_zero [Inhabited α] {as : List α} : (a :: as)[0]! = a := by
unfold getElem!; simp [Nat.zero_lt_succ]
@[simp] theorem cons_getElem!_succ [Inhabited α] {as : List α} : (a :: as)[i+1]! = as[i]! := by
unfold getElem!; split
next h => rw [dif_pos (Nat.lt_of_succ_lt_succ h)]; rfl
next h => rw [dif_neg (mt Nat.succ_lt_succ h)]
@[simp] theorem cons_getElem?_zero {as : List α} : (a :: as)[0]? = a := by
unfold getElem?; simp [Nat.zero_lt_succ]
@[simp] theorem cons_getElem?_succ {as : List α} : (a :: as)[i+1]? = as[i]? := by
unfold getElem?; split
next h => rw [dif_pos (Nat.lt_of_succ_lt_succ h)]; rfl
next h => rw [dif_neg (mt Nat.succ_lt_succ h)]
Co-authored-by: François G. Dorais <fgdorais@gmail.com>
Great, I added the lemmas you suggested. |
Without removing the |
I think The simp lint error is interesting: it appears that the simp normal form for lists is to change |
Regarding the simp lint error: If I understand correctly, we should add lemma like |
I think it's fine as-is. |
I don't like these lemmas, because |
ok, let's close this pull request then, I suppose... |
No description provided.