src/HOL/Library/LaTeXsugar.thy
author wenzelm
Sat Mar 05 20:47:31 2016 +0100 (2016-03-05)
changeset 62522 d32c23d29968
parent 60500 903bb1495239
child 63120 629a4c5e953e
permissions -rw-r--r--
abbreviations for \<nexists>;
nipkow@15469
     1
(*  Title:      HOL/Library/LaTeXsugar.thy
blanchet@55077
     2
    Author:     Gerwin Klein, Tobias Nipkow, Norbert Schirmer
nipkow@15469
     3
    Copyright   2005 NICTA and TUM
nipkow@15469
     4
*)
nipkow@15469
     5
nipkow@15469
     6
(*<*)
nipkow@15469
     7
theory LaTeXsugar
haftmann@30663
     8
imports Main
nipkow@15469
     9
begin
nipkow@15469
    10
nipkow@15469
    11
(* LOGIC *)
wenzelm@21210
    12
notation (latex output)
wenzelm@19674
    13
  If  ("(\<^raw:\textsf{>if\<^raw:}> (_)/ \<^raw:\textsf{>then\<^raw:}> (_)/ \<^raw:\textsf{>else\<^raw:}> (_))" 10)
wenzelm@19674
    14
nipkow@15469
    15
syntax (latex output)
nipkow@15469
    16
nipkow@15469
    17
  "_Let"        :: "[letbinds, 'a] => 'a"
nipkow@15469
    18
  ("(\<^raw:\textsf{>let\<^raw:}> (_)/ \<^raw:\textsf{>in\<^raw:}> (_))" 10)
nipkow@15469
    19
nipkow@15469
    20
  "_case_syntax":: "['a, cases_syn] => 'b"
nipkow@15469
    21
  ("(\<^raw:\textsf{>case\<^raw:}> _ \<^raw:\textsf{>of\<^raw:}>/ _)" 10)
nipkow@15469
    22
nipkow@16110
    23
nipkow@15469
    24
(* SETS *)
nipkow@15469
    25
nipkow@15469
    26
(* empty set *)
nipkow@27688
    27
notation (latex)
haftmann@30304
    28
  "Set.empty" ("\<emptyset>")
nipkow@15469
    29
nipkow@15469
    30
(* insert *)
nipkow@15469
    31
translations 
haftmann@31462
    32
  "{x} \<union> A" <= "CONST insert x A"
nipkow@15690
    33
  "{x,y}" <= "{x} \<union> {y}"
nipkow@15469
    34
  "{x,y} \<union> A" <= "{x} \<union> ({y} \<union> A)"
nipkow@27688
    35
  "{x}" <= "{x} \<union> \<emptyset>"
nipkow@15469
    36
nipkow@15469
    37
(* set comprehension *)
nipkow@15469
    38
syntax (latex output)
nipkow@15469
    39
  "_Collect" :: "pttrn => bool => 'a set"              ("(1{_ | _})")
nipkow@41757
    40
  "_CollectIn" :: "pttrn => 'a set => bool => 'a set"   ("(1{_ \<in> _ | _})")
nipkow@15469
    41
translations
nipkow@15469
    42
  "_Collect p P"      <= "{p. P}"
nipkow@15690
    43
  "_Collect p P"      <= "{p|xs. P}"
nipkow@41757
    44
  "_CollectIn p A P"  <= "{p : A. P}"
nipkow@15469
    45
nipkow@56977
    46
(* card *)
nipkow@56977
    47
notation (latex output)
nipkow@56977
    48
  card  ("|_|")
nipkow@56977
    49
nipkow@15469
    50
(* LISTS *)
nipkow@15469
    51
nipkow@15469
    52
(* Cons *)
wenzelm@21210
    53
notation (latex)
nipkow@56977
    54
  Cons  ("_ \<cdot>/ _" [66,65] 65)
nipkow@15469
    55
nipkow@15469
    56
(* length *)
wenzelm@21210
    57
notation (latex output)
wenzelm@19674
    58
  length  ("|_|")
nipkow@15469
    59
nipkow@15469
    60
(* nth *)
wenzelm@21210
    61
notation (latex output)
wenzelm@19674
    62
  nth  ("_\<^raw:\ensuremath{_{[\mathit{>_\<^raw:}]}}>" [1000,0] 1000)
nipkow@15469
    63
nipkow@15469
    64
(* DUMMY *)
nipkow@15469
    65
consts DUMMY :: 'a ("\<^raw:\_>")
nipkow@15469
    66
nipkow@15469
    67
(* THEOREMS *)
wenzelm@35251
    68
notation (Rule output)
wenzelm@56245
    69
  Pure.imp  ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>")
wenzelm@35251
    70
nipkow@15469
    71
syntax (Rule output)
nipkow@15469
    72
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
nipkow@15469
    73
  ("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>")
nipkow@15469
    74
nipkow@15469
    75
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" 
nipkow@15469
    76
  ("\<^raw:\mbox{>_\<^raw:}\\>/ _")
nipkow@15469
    77
nipkow@15469
    78
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
nipkow@15469
    79
wenzelm@35251
    80
notation (Axiom output)
wenzelm@35251
    81
  "Trueprop"  ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>")
schirmer@22328
    82
wenzelm@35251
    83
notation (IfThen output)
wenzelm@56245
    84
  Pure.imp  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
nipkow@15469
    85
syntax (IfThen output)
nipkow@15469
    86
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
nipkow@25467
    87
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
nipkow@25467
    88
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
nipkow@15469
    89
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
nipkow@15469
    90
wenzelm@35251
    91
notation (IfThenNoBox output)
wenzelm@56245
    92
  Pure.imp  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
nipkow@15469
    93
syntax (IfThenNoBox output)
nipkow@15469
    94
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
nipkow@25467
    95
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
nipkow@25467
    96
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
nipkow@15469
    97
  "_asm" :: "prop \<Rightarrow> asms" ("_")
nipkow@15469
    98
wenzelm@60500
    99
setup\<open>
nipkow@49628
   100
  let
nipkow@49628
   101
    fun pretty ctxt c =
wenzelm@56002
   102
      let val tc = Proof_Context.read_const {proper = true, strict = false} ctxt c
nipkow@49628
   103
      in Pretty.block [Thy_Output.pretty_term ctxt tc, Pretty.str " ::",
nipkow@49628
   104
            Pretty.brk 1, Syntax.pretty_typ ctxt (fastype_of tc)]
nipkow@49628
   105
      end
nipkow@49628
   106
  in
nipkow@49628
   107
    Thy_Output.antiquotation @{binding "const_typ"}
wenzelm@55111
   108
     (Scan.lift Args.name_inner_syntax)
nipkow@49628
   109
       (fn {source = src, context = ctxt, ...} => fn arg =>
nipkow@49628
   110
          Thy_Output.output ctxt
nipkow@49628
   111
            (Thy_Output.maybe_pretty_source pretty ctxt src [arg]))
nipkow@49628
   112
  end;
wenzelm@60500
   113
\<close>
nipkow@49628
   114
nipkow@15469
   115
end
blanchet@55077
   116
(*>*)