src/HOL/Library/OptionalSugar.thy
author haftmann
Thu Oct 08 15:16:13 2009 +0200 (2009-10-08)
changeset 32891 d403b99287ff
parent 30663 0b6aff7451b2
child 33384 1b5ba4e6a953
permissions -rw-r--r--
new generalized concept for term styles
nipkow@15469
     1
(*  Title:      HOL/Library/OptionalSugar.thy
nipkow@15469
     2
    Author:     Gerwin Klain, Tobias Nipkow
nipkow@15469
     3
    Copyright   2005 NICTA and TUM
nipkow@15469
     4
*)
nipkow@15476
     5
(*<*)
nipkow@15469
     6
theory OptionalSugar
haftmann@30663
     7
imports Complex_Main LaTeXsugar
nipkow@15469
     8
begin
nipkow@15469
     9
nipkow@30474
    10
(* hiding set *)
nipkow@22835
    11
translations
wenzelm@30404
    12
  "xs" <= "CONST set xs"
nipkow@22835
    13
nipkow@30474
    14
(* hiding numeric conversions - embeddings only *)
nipkow@30474
    15
translations
nipkow@30474
    16
  "n" <= "CONST of_nat n"
nipkow@30474
    17
  "n" <= "CONST int n"
nipkow@30474
    18
  "n" <= "real n"
nipkow@30474
    19
  "n" <= "CONST real_of_nat n"
nipkow@30474
    20
  "n" <= "CONST real_of_int n"
nipkow@30502
    21
  "n" <= "CONST of_real n"
nipkow@30502
    22
  "n" <= "CONST complex_of_real n"
nipkow@30474
    23
nipkow@15469
    24
(* append *)
nipkow@15469
    25
syntax (latex output)
nipkow@15469
    26
  "appendL" :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixl "\<^raw:\isacharat>" 65)
nipkow@15469
    27
translations
nipkow@15469
    28
  "appendL xs ys" <= "xs @ ys" 
nipkow@15469
    29
  "appendL (appendL xs ys) zs" <= "appendL xs (appendL ys zs)"
nipkow@15469
    30
nipkow@15469
    31
haftmann@32891
    32
(* deprecated, use thm with style instead, will be removed *)
nipkow@15469
    33
(* aligning equations *)
wenzelm@21210
    34
notation (tab output)
wenzelm@21404
    35
  "op ="  ("(_) \<^raw:}\putisatab\isa{\ >=\<^raw:}\putisatab\isa{> (_)" [50,49] 50) and
wenzelm@19674
    36
  "=="  ("(_) \<^raw:}\putisatab\isa{\ >\<equiv>\<^raw:}\putisatab\isa{> (_)")
nipkow@15469
    37
nipkow@15469
    38
(* Let *)
nipkow@15469
    39
translations 
wenzelm@30404
    40
  "_bind (p,DUMMY) e" <= "_bind p (CONST fst e)"
wenzelm@30404
    41
  "_bind (DUMMY,p) e" <= "_bind p (CONST snd e)"
nipkow@15469
    42
nipkow@15469
    43
  "_tuple_args x (_tuple_args y z)" ==
nipkow@15469
    44
    "_tuple_args x (_tuple_arg (_tuple y z))"
nipkow@15469
    45
wenzelm@30404
    46
  "_bind (Some p) e" <= "_bind p (CONST the e)"
wenzelm@30404
    47
  "_bind (p#DUMMY) e" <= "_bind p (CONST hd e)"
wenzelm@30404
    48
  "_bind (DUMMY#p) e" <= "_bind p (CONST tl e)"
nipkow@15469
    49
haftmann@29494
    50
(* type constraints with spacing *)
haftmann@29494
    51
setup {*
haftmann@29494
    52
let
haftmann@29494
    53
  val typ = SimpleSyntax.read_typ;
haftmann@29494
    54
  val typeT = Syntax.typeT;
haftmann@29494
    55
  val spropT = Syntax.spropT;
haftmann@29494
    56
in
haftmann@29494
    57
  Sign.del_modesyntax_i (Symbol.xsymbolsN, false) [
haftmann@29494
    58
    ("_constrain", typ "logic => type => logic", Mixfix ("_\<Colon>_", [4, 0], 3)),
haftmann@29494
    59
    ("_constrain", [spropT, typeT] ---> spropT, Mixfix ("_\<Colon>_", [4, 0], 3))]
haftmann@29494
    60
  #> Sign.add_modesyntax_i (Symbol.xsymbolsN, false) [
haftmann@29494
    61
      ("_constrain", typ "logic => type => logic", Mixfix ("_ \<Colon>  _", [4, 0], 3)),
haftmann@29494
    62
      ("_constrain", [spropT, typeT] ---> spropT, Mixfix ("_ \<Colon> _", [4, 0], 3))]
haftmann@29494
    63
end
haftmann@29494
    64
*}
haftmann@29494
    65
haftmann@29494
    66
(* sorts as intersections *)
haftmann@29494
    67
setup {*
haftmann@29494
    68
let
haftmann@29494
    69
  val sortT = Type ("sort", []); (*FIXME*)
haftmann@29494
    70
  val classesT = Type ("classes", []); (*FIXME*)
haftmann@29494
    71
in
haftmann@29494
    72
  Sign.add_modesyntax_i (Symbol.xsymbolsN, false) [
haftmann@29494
    73
    ("_topsort", sortT, Mixfix ("\<top>", [], Syntax.max_pri)),
haftmann@29494
    74
    ("_sort", classesT --> sortT, Mixfix ("'(_')", [], Syntax.max_pri)),
haftmann@29494
    75
    ("_classes", Lexicon.idT --> classesT --> classesT, Mixfix ("_ \<inter> _", [], Syntax.max_pri)),
haftmann@29494
    76
    ("_classes", Lexicon.longidT --> classesT --> classesT, Mixfix ("_ \<inter> _", [], Syntax.max_pri))
haftmann@29494
    77
  ]
haftmann@29494
    78
end
haftmann@29494
    79
*}
nipkow@15469
    80
nipkow@15476
    81
end
nipkow@15476
    82
(*>*)