-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for issue fixed in previous commit
- Loading branch information
1 parent
86fc089
commit 7fda1f4
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
theorem Nat.lt_of_lt_le {x y z : Nat} : x < y → y ≤ z → x < z := by | ||
intro h h' | ||
induction h' | ||
assumption | ||
apply Nat.le_step | ||
assumption | ||
|
||
structure ArrayBuffer (α) where | ||
cap : Nat | ||
backing : Fin cap → Option α | ||
size : Nat | ||
h_size : size ≤ cap | ||
h_full : ∀ i, (h:i < size) → (backing ⟨i, Nat.lt_of_lt_le h h_size⟩).isSome | ||
|
||
namespace ArrayBuffer | ||
|
||
def grow : ArrayBuffer α → ArrayBuffer α := | ||
λ ⟨cap, backing, size, h_size, h_full⟩ => | ||
⟨cap + cap, | ||
λ i => if h:i < cap then backing ⟨i,h⟩ else none, | ||
size, | ||
Nat.le_trans h_size (Nat.le_add_left _ _), | ||
by intro i h | ||
simp | ||
trace_state | ||
have : i < cap := Nat.lt_of_lt_le h h_size | ||
simp [*]⟩ |
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,10 @@ | ||
α : Type ?u | ||
x✝ : ArrayBuffer α | ||
cap : Nat | ||
backing : Fin cap → Option α | ||
size : Nat | ||
h_size : size ≤ cap | ||
h_full : ∀ (i : Nat), i < size → Option.isSome (backing { val := i, isLt := (_ : i < cap) }) = true | ||
i : Nat | ||
h : i < size | ||
⊢ Option.isSome (if h : i < cap then backing { val := i, isLt := h } else none) = true |