feat: syntax for using while condition in proofs
This commit is contained in:
parent
bd7739d02e
commit
b36b50adb2
2 changed files with 19 additions and 0 deletions
|
|
@ -262,6 +262,11 @@ syntax "repeat " doSeq : doElem
|
|||
macro_rules
|
||||
| `(doElem| repeat $seq) => `(doElem| for _ in Loop.mk do $seq)
|
||||
|
||||
syntax "while " ident " : " termBeforeDo " do " doSeq : doElem
|
||||
|
||||
macro_rules
|
||||
| `(doElem| while $h : $cond do $seq) => `(doElem| repeat if $h : $cond then $seq else break)
|
||||
|
||||
syntax "while " termBeforeDo " do " doSeq : doElem
|
||||
|
||||
macro_rules
|
||||
|
|
|
|||
14
tests/lean/run/1337.lean
Normal file
14
tests/lean/run/1337.lean
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
theorem n_minus_one_le_n {n : Nat} : n > 0 → n - 1 < n := by
|
||||
cases n with
|
||||
| zero => simp []
|
||||
| succ n =>
|
||||
intros
|
||||
rw [Nat.succ_eq_add_one, Nat.add_sub_cancel]
|
||||
apply Nat.le.refl
|
||||
|
||||
partial def foo : Array Int → Int
|
||||
| arr => Id.run do
|
||||
let mut r : Int := 1
|
||||
while h : arr.size > 0 do
|
||||
r := r * arr[arr.size - 1]'(by apply n_minus_one_le_n h)
|
||||
return r
|
||||
Loading…
Add table
Reference in a new issue