-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger CI for leanprover/lean4#3940
- Loading branch information
Showing
26 changed files
with
662 additions
and
322 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,11 @@ | ||
/- | ||
Copyright (c) 2021 Mario Carneiro. All rights reserved. | ||
Copyright (c) 2024 Kim Morrison. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Mario Carneiro, Gabriel Ebner | ||
Authors: Kim Morrison | ||
-/ | ||
|
||
/-! # Bootstrapping properties of Arrays -/ | ||
|
||
namespace Array | ||
|
||
@[simp] theorem size_ofFn_go {n} (f : Fin n → α) (i acc) : | ||
(ofFn.go f i acc).size = acc.size + (n - i) := by | ||
if hin : i < n then | ||
unfold ofFn.go | ||
have : 1 + (n - (i + 1)) = n - i := | ||
Nat.sub_sub .. ▸ Nat.add_sub_cancel' (Nat.le_sub_of_add_le (Nat.add_comm .. ▸ hin)) | ||
rw [dif_pos hin, size_ofFn_go f (i+1), size_push, Nat.add_assoc, this] | ||
else | ||
have : n - i = 0 := Nat.sub_eq_zero_of_le (Nat.le_of_not_lt hin) | ||
unfold ofFn.go | ||
simp [hin, this] | ||
termination_by n - i | ||
|
||
@[simp] theorem size_ofFn (f : Fin n → α) : (ofFn f).size = n := by simp [ofFn] | ||
|
||
theorem getElem_ofFn_go (f : Fin n → α) (i) {acc k} | ||
(hki : k < n) (hin : i ≤ n) (hi : i = acc.size) | ||
(hacc : ∀ j, ∀ hj : j < acc.size, acc[j] = f ⟨j, Nat.lt_of_lt_of_le hj (hi ▸ hin)⟩) : | ||
haveI : acc.size + (n - acc.size) = n := Nat.add_sub_cancel' (hi ▸ hin) | ||
(ofFn.go f i acc)[k]'(by simp [*]) = f ⟨k, hki⟩ := by | ||
unfold ofFn.go | ||
if hin : i < n then | ||
have : 1 + (n - (i + 1)) = n - i := | ||
Nat.sub_sub .. ▸ Nat.add_sub_cancel' (Nat.le_sub_of_add_le (Nat.add_comm .. ▸ hin)) | ||
simp only [dif_pos hin] | ||
rw [getElem_ofFn_go f (i+1) _ hin (by simp [*]) (fun j hj => ?hacc)] | ||
cases (Nat.lt_or_eq_of_le <| Nat.le_of_lt_succ (by simpa using hj)) with | ||
| inl hj => simp [get_push, hj, hacc j hj] | ||
| inr hj => simp [get_push, *] | ||
else | ||
simp [hin, hacc k (Nat.lt_of_lt_of_le hki (Nat.le_of_not_lt (hi ▸ hin)))] | ||
termination_by n - i | ||
|
||
@[simp] theorem getElem_ofFn (f : Fin n → α) (i : Nat) (h) : | ||
(ofFn f)[i] = f ⟨i, size_ofFn f ▸ h⟩ := | ||
getElem_ofFn_go _ _ _ (by simp) (by simp) nofun | ||
/-! | ||
While this file is currently empty, it is intended as a home for any lemmas which are required for | ||
definitions in `Std.Data.Array.Basic`, but which are not provided by Lean. | ||
-/ |
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
Oops, something went wrong.