src/ZF/thy_syntax.ML
author wenzelm
Mon, 13 Mar 2000 13:21:39 +0100
changeset 8434 5e4bba59bfaa
parent 8127 68c6159440f1
child 8813 abc0f3722aed
permissions -rw-r--r--
use HOLogic.Not; export indexify_names;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     1
(*  Title:      ZF/thy_syntax.ML
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     2
    ID:         $Id$
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     3
    Author:     Lawrence C Paulson
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     5
3622
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
     6
Additional theory file sections for ZF.
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     7
*)
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
     8
3622
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
     9
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
    10
local
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
    11
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    12
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    13
open ThyParse;
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    14
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    15
(*ML identifiers for introduction rules.*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    16
fun mk_intr_name suffix s =  
6093
87bf8c03b169 eliminated global/local names;
wenzelm
parents: 6070
diff changeset
    17
    if ThmDatabase.is_ml_identifier s then
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    18
	"op " ^ s ^ suffix  (*the "op" cancels any infix status*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    19
    else "_";               (*bad name, don't try to bind*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    20
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    21
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    22
(*For lists of theorems.  Either a string (an ML list expression) or else
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    23
  a list of identifiers.*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    24
fun optlist s = 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    25
    optional (s $$-- 
6642
732af87c0650 strip_quotes replaced by unenclose;
wenzelm
parents: 6112
diff changeset
    26
	      (string >> unenclose
732af87c0650 strip_quotes replaced by unenclose;
wenzelm
parents: 6112
diff changeset
    27
	       || list1 (name>>unenclose) >> mk_list)) 
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    28
    "[]";
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    29
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    30
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    31
(*(Co)Inductive definitions theory section."*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    32
fun inductive_decl coind =
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    33
  let  
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    34
    fun mk_params ((((((recs, sdom_sum), ipairs), 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1428
diff changeset
    35
                      monos), con_defs), type_intrs), type_elims) =
1428
15a69dd0a145 Reduced indentation; no change in function
paulson
parents: 1418
diff changeset
    36
      let val big_rec_name = space_implode "_" 
6642
732af87c0650 strip_quotes replaced by unenclose;
wenzelm
parents: 6112
diff changeset
    37
                           (map (scan_to_id o unenclose) recs)
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    38
          and srec_tms = mk_list recs
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1428
diff changeset
    39
          and sintrs   = mk_big_list (map snd ipairs)
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    40
          and inames   = mk_list (map (mk_intr_name "" o fst) ipairs)
1428
15a69dd0a145 Reduced indentation; no change in function
paulson
parents: 1418
diff changeset
    41
      in
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    42
	 ";\n\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    43
	 \local\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    44
	 \val (thy, {defs, intrs, elim, mk_cases, \
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    45
		    \bnd_mono, dom_subset, induct, mutual_induct, ...}) =\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    46
	 \  " ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    47
	 (if coind then "Co" else "") ^ 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    48
	 "Ind_Package.add_inductive (" ^  srec_tms ^ ", " ^ sdom_sum ^ ", " ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    49
	  sintrs ^ ", " ^ monos ^ ", " ^ con_defs ^ ", " ^ 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    50
	  type_intrs ^ ", " ^ type_elims ^ ") thy;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    51
	 \in\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    52
	 \structure " ^ big_rec_name ^ " =\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    53
	 \struct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    54
	 \  val defs = defs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    55
	 \  val bnd_mono = bnd_mono\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    56
	 \  val dom_subset = dom_subset\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    57
	 \  val intrs = intrs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    58
	 \  val elim = elim\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    59
	 \  val " ^ (if coind then "co" else "") ^ "induct = induct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    60
	 \  val mutual_induct = mutual_induct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    61
	 \  val mk_cases = mk_cases\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    62
	 \  val " ^ inames ^ " = intrs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    63
	 \end;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    64
	 \val thy = thy;\nend;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    65
	 \val thy = thy\n"
1428
15a69dd0a145 Reduced indentation; no change in function
paulson
parents: 1418
diff changeset
    66
      end
15a69dd0a145 Reduced indentation; no change in function
paulson
parents: 1418
diff changeset
    67
    val domains = "domains" $$-- enum1 "+" string --$$ "<=" -- !! string
15a69dd0a145 Reduced indentation; no change in function
paulson
parents: 1418
diff changeset
    68
    val ipairs  = "intrs"   $$-- repeat1 (ident -- !! string)
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    69
  in domains -- ipairs -- optlist "monos" -- optlist "con_defs"
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    70
             -- optlist "type_intrs" -- optlist "type_elims"
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
    71
     >> mk_params
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
    72
  end;
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
    73
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
    74
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    75
(*Datatype definitions theory section.   co is true for codatatypes*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    76
fun datatype_decl coind =
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    77
  let
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    78
    (*generate strings*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    79
    fun mk_const ((x, y), z) = mk_triple (x, mk_list y, z);
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    80
    val mk_data = mk_list o map mk_const o snd
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    81
    val mk_scons = mk_big_list o map mk_data
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    82
    fun mk_params ((((sdom, rec_pairs), monos), type_intrs), type_elims) =
6642
732af87c0650 strip_quotes replaced by unenclose;
wenzelm
parents: 6112
diff changeset
    83
      let val rec_names = map (scan_to_id o unenclose o fst) rec_pairs
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    84
	  val big_rec_name = space_implode "_" rec_names
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    85
	  and srec_tms = mk_list (map fst rec_pairs)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    86
	  and scons    = mk_scons rec_pairs
6642
732af87c0650 strip_quotes replaced by unenclose;
wenzelm
parents: 6112
diff changeset
    87
	  val con_names = flat (map (map (unenclose o #1 o #1) o snd)
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    88
				rec_pairs)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    89
          val inames = mk_list (map (mk_intr_name "_I") con_names)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    90
      in
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    91
	 ";\n\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    92
	 \local\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    93
	 \val (thy,\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    94
         \     {defs, intrs, elim, mk_cases, \
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    95
		    \bnd_mono, dom_subset, induct, mutual_induct, ...},\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    96
         \     {con_defs, case_eqns, recursor_eqns, free_iffs, free_SEs, mk_free, ...}) =\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    97
	 \  " ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    98
	 (if coind then "Co" else "") ^ 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
    99
	 "Data_Package.add_datatype (" ^  sdom ^ ", " ^ srec_tms ^ ", " ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   100
	  scons ^ ", " ^ monos ^ ", " ^ 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   101
	  type_intrs ^ ", " ^ type_elims ^ ") thy;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   102
	 \in\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   103
	 \structure " ^ big_rec_name ^ " =\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   104
	 \struct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   105
	 \  val defs = defs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   106
	 \  val bnd_mono = bnd_mono\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   107
	 \  val dom_subset = dom_subset\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   108
	 \  val intrs = intrs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   109
	 \  val elim = elim\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   110
	 \  val " ^ (if coind then "co" else "") ^ "induct = induct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   111
	 \  val mutual_induct = mutual_induct\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   112
	 \  val mk_cases = mk_cases\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   113
	 \  val con_defs = con_defs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   114
	 \  val case_eqns = case_eqns\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   115
	 \  val recursor_eqns = recursor_eqns\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   116
	 \  val free_iffs = free_iffs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   117
	 \  val free_SEs = free_SEs\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   118
	 \  val mk_free = mk_free\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   119
	 \  val " ^ inames ^ " = intrs;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   120
	 \end;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   121
	 \val thy = thy;\nend;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   122
	 \val thy = thy\n"
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   123
      end
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   124
    val string_list = "(" $$-- list1 string --$$ ")" || ThyParse.empty;
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   125
    val construct = name -- string_list -- opt_mixfix;
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   126
  in optional ("<=" $$-- string) "\"\"" --
8127
68c6159440f1 new lemmas for Ntree recursor example; more simprules; more lemmas borrowed
paulson
parents: 6642
diff changeset
   127
     enum1 "and" (name --$$ "=" -- enum1 "|" construct) --
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   128
     optlist "monos" -- optlist "type_intrs" -- optlist "type_elims"
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   129
     >> mk_params
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   130
end;
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   131
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   132
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   133
(** rep_datatype **)
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   134
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   135
fun mk_rep_dt_string (((elim, induct), case_eqns), recursor_eqns) =
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   136
  "|> DatatypeTactics.rep_datatype_i " ^ elim ^ " " ^ induct ^ "\n    " ^
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   137
  mk_list case_eqns ^ " " ^ mk_list recursor_eqns;
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   138
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   139
val rep_datatype_decl =
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   140
  (("elim" $$-- ident) -- 
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   141
   ("induct" $$-- ident) --
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   142
   ("case_eqns" $$-- list1 ident) -- 
6112
5e4871c5136b datatype package improvements
paulson
parents: 6093
diff changeset
   143
   optional ("recursor_eqns" $$-- list1 ident) []) >> mk_rep_dt_string;
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   144
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   145
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   146
(** primrec **)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   147
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   148
fun mk_primrec_decl eqns =
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   149
  let val names = map fst eqns
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   150
  in
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   151
    ";\nval (thy, " ^ mk_list names ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   152
    ") = PrimrecPackage.add_primrec " ^
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   153
      mk_list (map mk_pair (map (apfst quote) eqns)) ^ " " ^ " thy;\n\
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   154
    \val thy = thy\n"
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   155
  end;
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   156
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   157
(* either names and axioms or just axioms *)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   158
val primrec_decl = 
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   159
    ((repeat1 ((ident -- string) || (string >> pair "_")))) >> mk_primrec_decl;
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   160
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   161
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 3925
diff changeset
   162
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   163
3622
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   164
(** augment thy syntax **)
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   165
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   166
in
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   167
3622
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   168
val _ = ThySyn.add_syntax
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   169
 ["inductive", "coinductive", "datatype", "codatatype", "and", "|",
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   170
  "<=", "domains", "intrs", "monos", "con_defs", "type_intrs", "type_elims",
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   171
  (*rep_datatype*)
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   172
  "elim", "induct", "case_eqns", "recursor_eqns"]
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   173
 [section "inductive"    "" (inductive_decl false),
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   174
  section "coinductive"  "" (inductive_decl true),
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   175
  section "datatype"     "" (datatype_decl false),
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   176
  section "codatatype"   "" (datatype_decl true),
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   177
  section "rep_datatype" "" rep_datatype_decl,
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6053
diff changeset
   178
  section "primrec"      "" primrec_decl];
3622
85898be702b2 use ThySyn.add_syntax;
wenzelm
parents: 3613
diff changeset
   179
797
713efca1f0aa Defines ZF theory sections (inductive, datatype) at the start/
lcp
parents:
diff changeset
   180
end;