src/HOL/Library/OptionalSugar.thy
author wenzelm
Wed, 04 Mar 2009 23:05:32 +0100
changeset 30266 970bf4f594c9
parent 29494 a189c6274c7a
child 30404 d03dd6301678
permissions -rw-r--r--
ML antiquotation @{lemma}: allow 'and' list, proper simultaneous type-checking;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15469
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Library/OptionalSugar.thy
nipkow
parents:
diff changeset
     2
    Author:     Gerwin Klain, Tobias Nipkow
nipkow
parents:
diff changeset
     3
    Copyright   2005 NICTA and TUM
nipkow
parents:
diff changeset
     4
*)
15476
b8cb20cc0c0b fixed bugs
nipkow
parents: 15469
diff changeset
     5
(*<*)
15469
nipkow
parents:
diff changeset
     6
theory OptionalSugar
nipkow
parents:
diff changeset
     7
imports LaTeXsugar
nipkow
parents:
diff changeset
     8
begin
nipkow
parents:
diff changeset
     9
22835
37d3a984d730 added "set" supression
nipkow
parents: 21404
diff changeset
    10
(* set *)
37d3a984d730 added "set" supression
nipkow
parents: 21404
diff changeset
    11
translations
37d3a984d730 added "set" supression
nipkow
parents: 21404
diff changeset
    12
  "xs" <= "set xs"
37d3a984d730 added "set" supression
nipkow
parents: 21404
diff changeset
    13
15469
nipkow
parents:
diff changeset
    14
(* append *)
nipkow
parents:
diff changeset
    15
syntax (latex output)
nipkow
parents:
diff changeset
    16
  "appendL" :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixl "\<^raw:\isacharat>" 65)
nipkow
parents:
diff changeset
    17
translations
nipkow
parents:
diff changeset
    18
  "appendL xs ys" <= "xs @ ys" 
nipkow
parents:
diff changeset
    19
  "appendL (appendL xs ys) zs" <= "appendL xs (appendL ys zs)"
nipkow
parents:
diff changeset
    20
nipkow
parents:
diff changeset
    21
nipkow
parents:
diff changeset
    22
(* aligning equations *)
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19674
diff changeset
    23
notation (tab output)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    24
  "op ="  ("(_) \<^raw:}\putisatab\isa{\ >=\<^raw:}\putisatab\isa{> (_)" [50,49] 50) and
19674
22b635240905 const_syntax;
wenzelm
parents: 15476
diff changeset
    25
  "=="  ("(_) \<^raw:}\putisatab\isa{\ >\<equiv>\<^raw:}\putisatab\isa{> (_)")
15469
nipkow
parents:
diff changeset
    26
nipkow
parents:
diff changeset
    27
(* Let *)
nipkow
parents:
diff changeset
    28
translations 
nipkow
parents:
diff changeset
    29
  "_bind (p,DUMMY) e" <= "_bind p (fst e)"
nipkow
parents:
diff changeset
    30
  "_bind (DUMMY,p) e" <= "_bind p (snd e)"
nipkow
parents:
diff changeset
    31
nipkow
parents:
diff changeset
    32
  "_tuple_args x (_tuple_args y z)" ==
nipkow
parents:
diff changeset
    33
    "_tuple_args x (_tuple_arg (_tuple y z))"
nipkow
parents:
diff changeset
    34
nipkow
parents:
diff changeset
    35
  "_bind (Some p) e" <= "_bind p (the e)"
nipkow
parents:
diff changeset
    36
  "_bind (p#DUMMY) e" <= "_bind p (hd e)"
nipkow
parents:
diff changeset
    37
  "_bind (DUMMY#p) e" <= "_bind p (tl e)"
nipkow
parents:
diff changeset
    38
29494
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    39
(* type constraints with spacing *)
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    40
setup {*
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    41
let
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    42
  val typ = SimpleSyntax.read_typ;
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    43
  val typeT = Syntax.typeT;
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    44
  val spropT = Syntax.spropT;
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    45
in
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    46
  Sign.del_modesyntax_i (Symbol.xsymbolsN, false) [
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    47
    ("_constrain", typ "logic => type => logic", Mixfix ("_\<Colon>_", [4, 0], 3)),
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    48
    ("_constrain", [spropT, typeT] ---> spropT, Mixfix ("_\<Colon>_", [4, 0], 3))]
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    49
  #> Sign.add_modesyntax_i (Symbol.xsymbolsN, false) [
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    50
      ("_constrain", typ "logic => type => logic", Mixfix ("_ \<Colon>  _", [4, 0], 3)),
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    51
      ("_constrain", [spropT, typeT] ---> spropT, Mixfix ("_ \<Colon> _", [4, 0], 3))]
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    52
end
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    53
*}
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    54
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    55
(* sorts as intersections *)
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    56
setup {*
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    57
let
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    58
  val sortT = Type ("sort", []); (*FIXME*)
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    59
  val classesT = Type ("classes", []); (*FIXME*)
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    60
in
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    61
  Sign.add_modesyntax_i (Symbol.xsymbolsN, false) [
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    62
    ("_topsort", sortT, Mixfix ("\<top>", [], Syntax.max_pri)),
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    63
    ("_sort", classesT --> sortT, Mixfix ("'(_')", [], Syntax.max_pri)),
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    64
    ("_classes", Lexicon.idT --> classesT --> classesT, Mixfix ("_ \<inter> _", [], Syntax.max_pri)),
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    65
    ("_classes", Lexicon.longidT --> classesT --> classesT, Mixfix ("_ \<inter> _", [], Syntax.max_pri))
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    66
  ]
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    67
end
a189c6274c7a type constraints and sort intersection
haftmann
parents: 22835
diff changeset
    68
*}
15469
nipkow
parents:
diff changeset
    69
15476
b8cb20cc0c0b fixed bugs
nipkow
parents: 15469
diff changeset
    70
end
b8cb20cc0c0b fixed bugs
nipkow
parents: 15469
diff changeset
    71
(*>*)