5368
|
1 |
(* Title: HOL/ex/Antiquote.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Muenchen
|
9297
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
5368
|
5 |
*)
|
|
6 |
|
10357
|
7 |
header {* Antiquotations *}
|
|
8 |
|
9297
|
9 |
theory Antiquote = Main:
|
5368
|
10 |
|
11586
|
11 |
text {*
|
|
12 |
A simple example on quote / antiquote in higher-order abstract
|
|
13 |
syntax.
|
|
14 |
*}
|
|
15 |
|
5368
|
16 |
syntax
|
9297
|
17 |
"_Expr" :: "'a => 'a" ("EXPR _" [1000] 999)
|
5368
|
18 |
|
|
19 |
constdefs
|
|
20 |
var :: "'a => ('a => nat) => nat" ("VAR _" [1000] 999)
|
|
21 |
"var x env == env x"
|
|
22 |
|
8559
|
23 |
Expr :: "(('a => nat) => nat) => ('a => nat) => nat"
|
9297
|
24 |
"Expr exp env == exp env"
|
5368
|
25 |
|
9297
|
26 |
parse_translation {* [Syntax.quote_antiquote_tr "_Expr" "var" "Expr"] *}
|
|
27 |
print_translation {* [Syntax.quote_antiquote_tr' "_Expr" "var" "Expr"] *}
|
8559
|
28 |
|
9297
|
29 |
term "EXPR (a + b + c)"
|
|
30 |
term "EXPR (a + b + c + VAR x + VAR y + 1)"
|
|
31 |
term "EXPR (VAR (f w) + VAR x)"
|
5368
|
32 |
|
10357
|
33 |
term "Expr (\<lambda>env. env x)" (*improper*)
|
|
34 |
term "Expr (\<lambda>env. f env)"
|
|
35 |
term "Expr (\<lambda>env. f env + env x)" (*improper*)
|
|
36 |
term "Expr (\<lambda>env. f env y z)"
|
|
37 |
term "Expr (\<lambda>env. f env + g y env)"
|
|
38 |
term "Expr (\<lambda>env. f env + g env y + h a env z)"
|
5368
|
39 |
|
9297
|
40 |
end
|