feat: expand show-by and have-by macros
This commit is contained in:
parent
8586ec1759
commit
a6b19cd4af
2 changed files with 27 additions and 7 deletions
|
|
@ -55,16 +55,19 @@ fun stx expectedType? => match_syntax stx with
|
|||
|
||||
@[builtinMacro Lean.Parser.Term.show] def expandShow : Macro :=
|
||||
fun stx => match_syntax stx with
|
||||
| `(show $type from $val) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $thisId)
|
||||
| _ => Macro.throwUnsupported
|
||||
| `(show $type from $val) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $thisId)
|
||||
| `(show $type by $tac:tacticSeq) => `(show $type from by $tac:tacticSeq)
|
||||
| _ => Macro.throwUnsupported
|
||||
|
||||
@[builtinMacro Lean.Parser.Term.have] def expandHave : Macro :=
|
||||
fun stx => match_syntax stx with
|
||||
| `(have $type from $val; $body) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $body)
|
||||
| `(have $type := $val; $body) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $body)
|
||||
| `(have $x : $type from $val; $body) => `(let! $x:ident : $type := $val; $body)
|
||||
| `(have $x : $type := $val; $body) => `(let! $x:ident : $type := $val; $body)
|
||||
| _ => Macro.throwUnsupported
|
||||
| `(have $type from $val; $body) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $body)
|
||||
| `(have $type by $tac:tacticSeq; $body) => `(have $type from by $tac:tacticSeq; $body)
|
||||
| `(have $type := $val; $body) => let thisId := mkIdentFrom stx `this; `(let! $thisId : $type := $val; $body)
|
||||
| `(have $x : $type from $val; $body) => `(let! $x:ident : $type := $val; $body)
|
||||
| `(have $x : $type by $tac:tacticSeq; $body) => `(have $x : $type from by $tac:tacticSeq; $body)
|
||||
| `(have $x : $type := $val; $body) => `(let! $x:ident : $type := $val; $body)
|
||||
| _ => Macro.throwUnsupported
|
||||
|
||||
@[builtinMacro Lean.Parser.Term.where] def expandWhere : Macro :=
|
||||
fun stx => match_syntax stx with
|
||||
|
|
|
|||
|
|
@ -349,3 +349,20 @@ theorem simple21 (x y z : Nat) : y = z → x = x → y = x → x = z :=
|
|||
fun h1 _ h3 =>
|
||||
have x = y from by apply Eq.symm; assumption;
|
||||
Eq.trans this (by assumption)
|
||||
|
||||
theorem simple22 (x y z : Nat) : y = z → y = x → id (x = z + 0) :=
|
||||
fun h1 h2 => show x = z + 0 by
|
||||
apply Eq.trans;
|
||||
exact h2.symm;
|
||||
assumption;
|
||||
skip
|
||||
|
||||
theorem simple23 (x y z : Nat) : y = z → x = x → y = x → x = z :=
|
||||
fun h1 _ h3 =>
|
||||
have x = y by apply Eq.symm; assumption;
|
||||
Eq.trans this (by assumption)
|
||||
|
||||
theorem simple24 (x y z : Nat) : y = z → x = x → y = x → x = z :=
|
||||
fun h1 _ h3 =>
|
||||
have h : x = y by apply Eq.symm; assumption;
|
||||
Eq.trans h (by assumption)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue