Skip to content

Commit

Permalink
test: add test for issue fixed in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leodemoura committed Mar 14, 2022
1 parent 86fc089 commit 7fda1f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/lean/congrThmIssue.lean
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 [*]⟩
10 changes: 10 additions & 0 deletions tests/lean/congrThmIssue.lean.expected.out
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

0 comments on commit 7fda1f4

Please sign in to comment.