src/HOL/ex/Antiquote.thy
author haftmann
Tue, 20 Mar 2007 08:27:15 +0100
changeset 22473 753123c89d72
parent 16417 9bc16273c2d4
child 32960 69916a850301
permissions -rw-r--r--
explizit "type" superclass
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
    ID:         $Id$
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     4
*)
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     5
10357
wenzelm
parents: 9297
diff changeset
     6
header {* Antiquotations *}
wenzelm
parents: 9297
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14981
diff changeset
     8
theory Antiquote imports Main begin
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     9
11586
wenzelm
parents: 10357
diff changeset
    10
text {*
wenzelm
parents: 10357
diff changeset
    11
  A simple example on quote / antiquote in higher-order abstract
wenzelm
parents: 10357
diff changeset
    12
  syntax.
wenzelm
parents: 10357
diff changeset
    13
*}
wenzelm
parents: 10357
diff changeset
    14
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    15
syntax
9297
wenzelm
parents: 8559
diff changeset
    16
  "_Expr" :: "'a => 'a"				("EXPR _" [1000] 999)
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    17
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    18
constdefs
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    19
  var :: "'a => ('a => nat) => nat"		("VAR _" [1000] 999)
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    20
  "var x env == env x"
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    21
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    22
  Expr :: "(('a => nat) => nat) => ('a => nat) => nat"
9297
wenzelm
parents: 8559
diff changeset
    23
  "Expr exp env == exp env"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    24
9297
wenzelm
parents: 8559
diff changeset
    25
parse_translation {* [Syntax.quote_antiquote_tr "_Expr" "var" "Expr"] *}
wenzelm
parents: 8559
diff changeset
    26
print_translation {* [Syntax.quote_antiquote_tr' "_Expr" "var" "Expr"] *}
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    27
9297
wenzelm
parents: 8559
diff changeset
    28
term "EXPR (a + b + c)"
wenzelm
parents: 8559
diff changeset
    29
term "EXPR (a + b + c + VAR x + VAR y + 1)"
wenzelm
parents: 8559
diff changeset
    30
term "EXPR (VAR (f w) + VAR x)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    31
10357
wenzelm
parents: 9297
diff changeset
    32
term "Expr (\<lambda>env. env x)"				(*improper*)
wenzelm
parents: 9297
diff changeset
    33
term "Expr (\<lambda>env. f env)"
wenzelm
parents: 9297
diff changeset
    34
term "Expr (\<lambda>env. f env + env x)"			(*improper*)
wenzelm
parents: 9297
diff changeset
    35
term "Expr (\<lambda>env. f env y z)"
wenzelm
parents: 9297
diff changeset
    36
term "Expr (\<lambda>env. f env + g y env)"
wenzelm
parents: 9297
diff changeset
    37
term "Expr (\<lambda>env. f env + g env y + h a env z)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    38
9297
wenzelm
parents: 8559
diff changeset
    39
end