fix: use show .. from .. to implement calc
Recall that `show .. from ..` ensures that proof has exactly the type provided by the user. In the new test, `rw [ih]` without this change because the goal would be ``` ... |- 0 + succ n = succ n ```
This commit is contained in:
parent
1f37cc7b41
commit
34d8ecc066
2 changed files with 17 additions and 2 deletions
|
|
@ -98,8 +98,8 @@ syntax calcStep := colGe term " := " withPosition(term)
|
|||
syntax "calc " withPosition(calcStep+) : term
|
||||
|
||||
macro_rules
|
||||
| `(calc $p:term := $h:term) => `(($h : $p))
|
||||
| `(calc $p:term := $h:term $rest:calcStep*) => ``(trans ($h : $p) (calc $rest:calcStep*))
|
||||
| `(calc $p:term := $h:term) => `(show $p from $h)
|
||||
| `(calc $p:term := $h:term $rest:calcStep*) => ``(trans (show $p from $h) (calc $rest:calcStep*))
|
||||
|
||||
@[appUnexpander Unit.unit] def unexpandUnit : Lean.PrettyPrinter.Unexpander
|
||||
| `($(_)) => `(())
|
||||
|
|
|
|||
15
tests/lean/run/calcBug.lean
Normal file
15
tests/lean/run/calcBug.lean
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
namespace Hidden
|
||||
|
||||
open Nat
|
||||
|
||||
theorem zero_add (n : Nat) : 0 + n = n :=
|
||||
Nat.recOn (motive := fun x => 0 + x = x)
|
||||
n
|
||||
(show 0 + 0 = 0 from rfl)
|
||||
(fun (n : Nat) (ih : 0 + n = n) =>
|
||||
show 0 + succ n = succ n from
|
||||
calc
|
||||
0 + succ n = succ (0 + n) := rfl
|
||||
_ = succ n := by rw [ih])
|
||||
|
||||
end Hidden
|
||||
Loading…
Add table
Reference in a new issue