src/HOL/ex/Antiquote.thy
author nipkow
Fri, 24 Nov 2000 16:49:27 +0100
changeset 10519 ade64af4c57c
parent 10357 0d0cac129618
child 11586 d8a7f6318457
permissions -rw-r--r--
hide many names from Datatype_Universe.
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
9297
wenzelm
parents: 8559
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     5
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     6
Simple quote / antiquote example.
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     7
*)
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
     8
10357
wenzelm
parents: 9297
diff changeset
     9
header {* Antiquotations *}
wenzelm
parents: 9297
diff changeset
    10
9297
wenzelm
parents: 8559
diff changeset
    11
theory Antiquote = Main:
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    12
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    13
syntax
9297
wenzelm
parents: 8559
diff changeset
    14
  "_Expr" :: "'a => 'a"				("EXPR _" [1000] 999)
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    15
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    16
constdefs
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    17
  var :: "'a => ('a => nat) => nat"		("VAR _" [1000] 999)
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    18
  "var x env == env x"
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    19
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    20
  Expr :: "(('a => nat) => nat) => ('a => nat) => nat"
9297
wenzelm
parents: 8559
diff changeset
    21
  "Expr exp env == exp env"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    22
9297
wenzelm
parents: 8559
diff changeset
    23
parse_translation {* [Syntax.quote_antiquote_tr "_Expr" "var" "Expr"] *}
wenzelm
parents: 8559
diff changeset
    24
print_translation {* [Syntax.quote_antiquote_tr' "_Expr" "var" "Expr"] *}
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    25
9297
wenzelm
parents: 8559
diff changeset
    26
term "EXPR (a + b + c)"
wenzelm
parents: 8559
diff changeset
    27
term "EXPR (a + b + c + VAR x + VAR y + 1)"
wenzelm
parents: 8559
diff changeset
    28
term "EXPR (VAR (f w) + VAR x)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    29
10357
wenzelm
parents: 9297
diff changeset
    30
term "Expr (\<lambda>env. env x)"				(*improper*)
wenzelm
parents: 9297
diff changeset
    31
term "Expr (\<lambda>env. f env)"
wenzelm
parents: 9297
diff changeset
    32
term "Expr (\<lambda>env. f env + env x)"			(*improper*)
wenzelm
parents: 9297
diff changeset
    33
term "Expr (\<lambda>env. f env y z)"
wenzelm
parents: 9297
diff changeset
    34
term "Expr (\<lambda>env. f env + g y env)"
wenzelm
parents: 9297
diff changeset
    35
term "Expr (\<lambda>env. f env + g env y + h a env z)"
5368
7c8d1c7c876d added Antiquote example;
wenzelm
parents:
diff changeset
    36
9297
wenzelm
parents: 8559
diff changeset
    37
end
8559
fd3753188232 ex/Antiquote.thy made new-style theory;
wenzelm
parents: 5368
diff changeset
    38