src/HOL/Library/LaTeXsugar.thy
author blanchet
Wed, 24 Sep 2014 15:45:55 +0200
changeset 58425 246985c6b20b
parent 56977 a33fe940a557
child 60500 903bb1495239
permissions -rw-r--r--
simpler proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15469
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Library/LaTeXsugar.thy
55077
4cf280104b85 fixed typo
blanchet
parents: 49628
diff changeset
     2
    Author:     Gerwin Klein, Tobias Nipkow, Norbert Schirmer
15469
nipkow
parents:
diff changeset
     3
    Copyright   2005 NICTA and TUM
nipkow
parents:
diff changeset
     4
*)
nipkow
parents:
diff changeset
     5
nipkow
parents:
diff changeset
     6
(*<*)
nipkow
parents:
diff changeset
     7
theory LaTeXsugar
30663
0b6aff7451b2 Main is (Complex_Main) base entry point in library theories
haftmann
parents: 30304
diff changeset
     8
imports Main
15469
nipkow
parents:
diff changeset
     9
begin
nipkow
parents:
diff changeset
    10
nipkow
parents:
diff changeset
    11
(* LOGIC *)
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19674
diff changeset
    12
notation (latex output)
19674
22b635240905 const_syntax;
wenzelm
parents: 16110
diff changeset
    13
  If  ("(\<^raw:\textsf{>if\<^raw:}> (_)/ \<^raw:\textsf{>then\<^raw:}> (_)/ \<^raw:\textsf{>else\<^raw:}> (_))" 10)
22b635240905 const_syntax;
wenzelm
parents: 16110
diff changeset
    14
15469
nipkow
parents:
diff changeset
    15
syntax (latex output)
nipkow
parents:
diff changeset
    16
nipkow
parents:
diff changeset
    17
  "_Let"        :: "[letbinds, 'a] => 'a"
nipkow
parents:
diff changeset
    18
  ("(\<^raw:\textsf{>let\<^raw:}> (_)/ \<^raw:\textsf{>in\<^raw:}> (_))" 10)
nipkow
parents:
diff changeset
    19
nipkow
parents:
diff changeset
    20
  "_case_syntax":: "['a, cases_syn] => 'b"
nipkow
parents:
diff changeset
    21
  ("(\<^raw:\textsf{>case\<^raw:}> _ \<^raw:\textsf{>of\<^raw:}>/ _)" 10)
nipkow
parents:
diff changeset
    22
16110
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    23
(* should become standard syntax once x-symbols supports it *)
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    24
syntax (latex)
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    25
  nexists :: "('a => bool) => bool"           (binder "\<nexists>" 10)
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    26
translations
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    27
  "\<nexists>x. P" <= "\<not>(\<exists>x. P)"
c423bb89186d added \nexists
nipkow
parents: 15690
diff changeset
    28
15469
nipkow
parents:
diff changeset
    29
(* SETS *)
nipkow
parents:
diff changeset
    30
nipkow
parents:
diff changeset
    31
(* empty set *)
27688
397de75836a1 *** empty log message ***
nipkow
parents: 27487
diff changeset
    32
notation (latex)
30304
d8e4cd2ac2a1 set operations Int, Un, INTER, UNION, Inter, Union, empty, UNIV are now proper qualified constants with authentic syntax
haftmann
parents: 29493
diff changeset
    33
  "Set.empty" ("\<emptyset>")
15469
nipkow
parents:
diff changeset
    34
nipkow
parents:
diff changeset
    35
(* insert *)
nipkow
parents:
diff changeset
    36
translations 
31462
4fcbf17b5a98 Set.insert with authentic syntax
haftmann
parents: 30663
diff changeset
    37
  "{x} \<union> A" <= "CONST insert x A"
15690
nipkow
parents: 15476
diff changeset
    38
  "{x,y}" <= "{x} \<union> {y}"
15469
nipkow
parents:
diff changeset
    39
  "{x,y} \<union> A" <= "{x} \<union> ({y} \<union> A)"
27688
397de75836a1 *** empty log message ***
nipkow
parents: 27487
diff changeset
    40
  "{x}" <= "{x} \<union> \<emptyset>"
15469
nipkow
parents:
diff changeset
    41
nipkow
parents:
diff changeset
    42
(* set comprehension *)
nipkow
parents:
diff changeset
    43
syntax (latex output)
nipkow
parents:
diff changeset
    44
  "_Collect" :: "pttrn => bool => 'a set"              ("(1{_ | _})")
41757
7bbd11360bd3 more pretty set comprehension sugar
nipkow
parents: 35251
diff changeset
    45
  "_CollectIn" :: "pttrn => 'a set => bool => 'a set"   ("(1{_ \<in> _ | _})")
15469
nipkow
parents:
diff changeset
    46
translations
nipkow
parents:
diff changeset
    47
  "_Collect p P"      <= "{p. P}"
15690
nipkow
parents: 15476
diff changeset
    48
  "_Collect p P"      <= "{p|xs. P}"
41757
7bbd11360bd3 more pretty set comprehension sugar
nipkow
parents: 35251
diff changeset
    49
  "_CollectIn p A P"  <= "{p : A. P}"
15469
nipkow
parents:
diff changeset
    50
56977
a33fe940a557 new syntax for card, normalized spacing for #
nipkow
parents: 56245
diff changeset
    51
(* card *)
a33fe940a557 new syntax for card, normalized spacing for #
nipkow
parents: 56245
diff changeset
    52
notation (latex output)
a33fe940a557 new syntax for card, normalized spacing for #
nipkow
parents: 56245
diff changeset
    53
  card  ("|_|")
a33fe940a557 new syntax for card, normalized spacing for #
nipkow
parents: 56245
diff changeset
    54
15469
nipkow
parents:
diff changeset
    55
(* LISTS *)
nipkow
parents:
diff changeset
    56
nipkow
parents:
diff changeset
    57
(* Cons *)
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19674
diff changeset
    58
notation (latex)
56977
a33fe940a557 new syntax for card, normalized spacing for #
nipkow
parents: 56245
diff changeset
    59
  Cons  ("_ \<cdot>/ _" [66,65] 65)
15469
nipkow
parents:
diff changeset
    60
nipkow
parents:
diff changeset
    61
(* length *)
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19674
diff changeset
    62
notation (latex output)
19674
22b635240905 const_syntax;
wenzelm
parents: 16110
diff changeset
    63
  length  ("|_|")
15469
nipkow
parents:
diff changeset
    64
nipkow
parents:
diff changeset
    65
(* nth *)
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19674
diff changeset
    66
notation (latex output)
19674
22b635240905 const_syntax;
wenzelm
parents: 16110
diff changeset
    67
  nth  ("_\<^raw:\ensuremath{_{[\mathit{>_\<^raw:}]}}>" [1000,0] 1000)
15469
nipkow
parents:
diff changeset
    68
nipkow
parents:
diff changeset
    69
(* DUMMY *)
nipkow
parents:
diff changeset
    70
consts DUMMY :: 'a ("\<^raw:\_>")
nipkow
parents:
diff changeset
    71
nipkow
parents:
diff changeset
    72
(* THEOREMS *)
35251
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    73
notation (Rule output)
56245
84fc7dfa3cd4 more qualified names;
wenzelm
parents: 56002
diff changeset
    74
  Pure.imp  ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>")
35251
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    75
15469
nipkow
parents:
diff changeset
    76
syntax (Rule output)
nipkow
parents:
diff changeset
    77
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
nipkow
parents:
diff changeset
    78
  ("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>")
nipkow
parents:
diff changeset
    79
nipkow
parents:
diff changeset
    80
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" 
nipkow
parents:
diff changeset
    81
  ("\<^raw:\mbox{>_\<^raw:}\\>/ _")
nipkow
parents:
diff changeset
    82
nipkow
parents:
diff changeset
    83
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
nipkow
parents:
diff changeset
    84
35251
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    85
notation (Axiom output)
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    86
  "Trueprop"  ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>")
22328
cc403d881873 added print-mode Axiom to print theorems without premises with a rule on top.
schirmer
parents: 21210
diff changeset
    87
35251
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    88
notation (IfThen output)
56245
84fc7dfa3cd4 more qualified names;
wenzelm
parents: 56002
diff changeset
    89
  Pure.imp  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
15469
nipkow
parents:
diff changeset
    90
syntax (IfThen output)
nipkow
parents:
diff changeset
    91
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
25467
bba589a88022 Removed forced roman font in mode=IfThen.
nipkow
parents: 22328
diff changeset
    92
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
bba589a88022 Removed forced roman font in mode=IfThen.
nipkow
parents: 22328
diff changeset
    93
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
15469
nipkow
parents:
diff changeset
    94
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
nipkow
parents:
diff changeset
    95
35251
e244adbbc28f modernized notation -- to make it work for authentic syntax;
wenzelm
parents: 31462
diff changeset
    96
notation (IfThenNoBox output)
56245
84fc7dfa3cd4 more qualified names;
wenzelm
parents: 56002
diff changeset
    97
  Pure.imp  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
15469
nipkow
parents:
diff changeset
    98
syntax (IfThenNoBox output)
nipkow
parents:
diff changeset
    99
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
25467
bba589a88022 Removed forced roman font in mode=IfThen.
nipkow
parents: 22328
diff changeset
   100
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
bba589a88022 Removed forced roman font in mode=IfThen.
nipkow
parents: 22328
diff changeset
   101
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
15469
nipkow
parents:
diff changeset
   102
  "_asm" :: "prop \<Rightarrow> asms" ("_")
nipkow
parents:
diff changeset
   103
49628
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   104
setup{*
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   105
  let
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   106
    fun pretty ctxt c =
56002
2028467b4df4 tuned signature;
wenzelm
parents: 55955
diff changeset
   107
      let val tc = Proof_Context.read_const {proper = true, strict = false} ctxt c
49628
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   108
      in Pretty.block [Thy_Output.pretty_term ctxt tc, Pretty.str " ::",
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   109
            Pretty.brk 1, Syntax.pretty_typ ctxt (fastype_of tc)]
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   110
      end
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   111
  in
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   112
    Thy_Output.antiquotation @{binding "const_typ"}
55111
5792f5106c40 tuned signature;
wenzelm
parents: 49628
diff changeset
   113
     (Scan.lift Args.name_inner_syntax)
49628
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   114
       (fn {source = src, context = ctxt, ...} => fn arg =>
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   115
          Thy_Output.output ctxt
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   116
            (Thy_Output.maybe_pretty_source pretty ctxt src [arg]))
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   117
  end;
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   118
*}
8262d35eff20 new antiquotation const_typ
nipkow
parents: 41757
diff changeset
   119
15469
nipkow
parents:
diff changeset
   120
end
55077
4cf280104b85 fixed typo
blanchet
parents: 49628
diff changeset
   121
(*>*)