forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simp lemmas for Array.isEqv and beq (leanprover#5786)
- [ ] depends on: leanprover#5785
- Loading branch information
1 parent
258d3fe
commit c8020d4
Showing
9 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/- | ||
Copyright (c) 2024 Lean FRO All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Kim Morrison | ||
-/ | ||
prelude | ||
import Init.Data.Nat.Lemmas | ||
import Init.Data.List.Basic | ||
|
||
namespace List | ||
|
||
/-! ### isEqv-/ | ||
|
||
theorem isEqv_eq_decide (a b : List α) (r) : | ||
isEqv a b r = if h : a.length = b.length then | ||
decide (∀ (i : Nat) (h' : i < a.length), r (a[i]'(h ▸ h')) (b[i]'(h ▸ h'))) else false := by | ||
induction a generalizing b with | ||
| nil => | ||
cases b <;> simp | ||
| cons a as ih => | ||
cases b with | ||
| nil => simp | ||
| cons b bs => | ||
simp only [isEqv, ih, length_cons, Nat.add_right_cancel_iff] | ||
split <;> simp [Nat.forall_lt_succ_left'] | ||
|
||
/-! ### beq -/ | ||
|
||
theorem beq_eq_isEqv [BEq α] (a b : List α) : a.beq b = isEqv a b (· == ·) := by | ||
induction a generalizing b with | ||
| nil => | ||
cases b <;> simp | ||
| cons a as ih => | ||
cases b with | ||
| nil => simp | ||
| cons b bs => | ||
simp only [beq_cons₂, ih, isEqv_eq_decide, length_cons, Nat.add_right_cancel_iff, | ||
Nat.forall_lt_succ_left', getElem_cons_zero, getElem_cons_succ, Bool.decide_and, | ||
Bool.decide_eq_true] | ||
split <;> simp | ||
|
||
theorem beq_eq_decide [BEq α] (a b : List α) : | ||
(a == b) = if h : a.length = b.length then | ||
decide (∀ (i : Nat) (h' : i < a.length), a[i] == b[i]'(h ▸ h')) else false := by | ||
simp [BEq.beq, beq_eq_isEqv, isEqv_eq_decide] | ||
|
||
end List |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters