src/HOL/ex/Antiquote.thy
author krauss
Tue, 28 Sep 2010 09:54:07 +0200
changeset 39754 150f831ce4a3
parent 35113 1a0c129bb2e0
child 42284 326f57825e1a
permissions -rw-r--r--
no longer declare .psimps rules as [simp]. This regularly caused confusion (e.g., they show up in simp traces when the regular simp rules are disabled). In the few places where the rules are used, explicitly mentioning them actually clarifies the proof text.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/ex/Antiquote.thy
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     2
    Author:     Markus Wenzel, TU Muenchen
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     3
*)
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     4
10357
wenzelm
parents: 9297
diff changeset
     5
header {* Antiquotations *}
wenzelm
parents: 9297
diff changeset
     6
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
     7
theory Antiquote
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
     8
imports Main
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
     9
begin
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    10
11586
wenzelm
parents: 10357
diff changeset
    11
text {*
wenzelm
parents: 10357
diff changeset
    12
  A simple example on quote / antiquote in higher-order abstract
wenzelm
parents: 10357
diff changeset
    13
  syntax.
wenzelm
parents: 10357
diff changeset
    14
*}
wenzelm
parents: 10357
diff changeset
    15
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    16
syntax
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    17
  "_Expr" :: "'a => 'a"    ("EXPR _" [1000] 999)
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    18
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    19
definition
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    20
  var :: "'a => ('a => nat) => nat"    ("VAR _" [1000] 999)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    21
  where "var x env = env x"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    22
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    23
definition
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    24
  Expr :: "(('a => nat) => nat) => ('a => nat) => nat"
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    25
  where "Expr exp env = exp env"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    26
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    27
parse_translation {*
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    28
  [Syntax.quote_antiquote_tr @{syntax_const "_Expr"} @{const_syntax var} @{const_syntax Expr}]
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    29
*}
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    30
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    31
print_translation {*
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    32
  [Syntax.quote_antiquote_tr' @{syntax_const "_Expr"} @{const_syntax var} @{const_syntax Expr}]
1a0c129bb2e0 modernized translations;
wenzelm
parents: 32960
diff changeset
    33
*}
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    34
9297
wenzelm
parents: 8559
diff changeset
    35
term "EXPR (a + b + c)"
wenzelm
parents: 8559
diff changeset
    36
term "EXPR (a + b + c + VAR x + VAR y + 1)"
wenzelm
parents: 8559
diff changeset
    37
term "EXPR (VAR (f w) + VAR x)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    38
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 16417
diff changeset
    39
term "Expr (\<lambda>env. env x)"    -- {* improper *}
10357
wenzelm
parents: 9297
diff changeset
    40
term "Expr (\<lambda>env. f env)"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 16417
diff changeset
    41
term "Expr (\<lambda>env. f env + env x)"    -- {* improper *}
10357
wenzelm
parents: 9297
diff changeset
    42
term "Expr (\<lambda>env. f env y z)"
wenzelm
parents: 9297
diff changeset
    43
term "Expr (\<lambda>env. f env + g y env)"
wenzelm
parents: 9297
diff changeset
    44
term "Expr (\<lambda>env. f env + g env y + h a env z)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    45
9297
wenzelm
parents: 8559
diff changeset
    46
end