lean4-htt/tests/lean/run/macro.lean
2020-01-15 20:53:23 -08:00

36 lines
868 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

abbrev Set (α : Type) := α → Prop
axiom setOf {α : Type} : (α → Prop) → Set α
axiom mem {α : Type} : α → Set α → Prop
axiom univ {α : Type} : Set α
axiom Union {α : Type} : Set (Set α) → Set α
new_frontend
syntax term " ∈ ":100 term:99 : term
macro
| `($x ∈ $s) => `(mem $x $s)
syntax "{" term " | " term "}" : term
-- set_option trace.Elab true
-- set_option syntaxMaxDepth 6
macro
| `({$x ∈ $s | $p}) => `(setOf (fun $x => $x ∈ $s ∧ $p))
| `({$x ≤ $e | $p}) => `(setOf (fun $x => $x ≤ $e ∧ $p))
| `({$b | $r}) => `(setOf (fun $b => $r))
syntax " " term ", " term : term
macro | `( $b, $r) => `(Union {$b | $r})
#check x, x = x
#check (x : Set Unit), x = x
#check x ∈ univ, x = x
syntax "#check2" term : command
macro | `(#check2 $e) => `(#check $e #check $e)
#check2 1