src/HOLCF/domain/interface.ML
author wenzelm
Tue, 27 May 1997 15:45:07 +0200
changeset 3362 0b268cff9344
parent 2446 c2a9bf6c0948
child 3622 85898be702b2
permissions -rw-r--r--
NJ 1.09.2x as factory default!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     1
(*  Title:      HOLCF/domain/interface.ML
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     2
    ID:         $Id$
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     3
    Author : David von Oheimb
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     4
    Copyright 1995, 1996 TU Muenchen
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     5
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
     6
parser for domain section
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     7
*)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     8
2446
c2a9bf6c0948 The previous log message was wrong. The correct one is:
oheimb
parents: 2445
diff changeset
     9
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    10
structure ThySynData: THY_SYN_DATA = (* overwrites old version of ThySynData !!!!!! *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    11
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    12
struct
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    13
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    14
local 
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    15
  open ThyParse;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    16
  open Domain_Library;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    17
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    18
(* --- generation of bindings for axioms and theorems in trailer of .thy.ML - *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    19
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    20
  fun gt_ax         name   = "get_axiom thy " ^ quote name;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    21
  fun gen_val dname name   = "val "^name^" = "^ gt_ax (dname^"_"^name)^";";
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    22
  fun gen_vall      name l = "val "^name^" = "^ mk_list l^";";
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    23
  val rews1 = "iso_rews @ when_rews @\n\
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    24
 	      \con_rews @ sel_rews @ dis_rews @ dists_le @ dists_eq @\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    25
	      \copy_rews";
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    26
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    27
  fun gen_domain eqname num ((dname,_), cons') = let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    28
    val axioms1 = ["abs_iso", "rep_iso", "when_def"];
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    29
		   (* con_defs , sel_defs, dis_defs *) 
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    30
    val axioms2 = ["copy_def"];
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    31
    val theorems = 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    32
	"iso_rews, exhaust, cases, when_rews, con_rews, sel_rews, dis_rews,\n    \
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    33
	\dists_le, dists_eq, inverts, injects, copy_rews";
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    34
    in
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    35
      "structure "^dname^" = struct\n"^
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    36
      cat_lines(map (gen_val dname) axioms1)^"\n"^
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    37
      gen_vall"con_defs"(map(fn (con,_,_) => gt_ax(strip_esc con^"_def")) cons')^"\n"^
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    38
      gen_vall"sel_defs"(flat(map (fn (_,_,args) => map (fn (_,sel,_) => 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    39
					     gt_ax(sel^"_def")) args)    cons'))^"\n"^
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    40
      gen_vall"dis_defs"(map(fn (con,_,_) => gt_ax(dis_name_ con^"_def")) 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    41
								          cons')^"\n"^
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    42
      cat_lines(map (gen_val dname) axioms2)^"\n"^
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    43
      "val ("^ theorems ^") =\n\
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    44
      \Domain_Theorems.theorems thy "^eqname^";\n" ^
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    45
      (if num > 1 then "val rews = " ^rews1 ^";\n" else "")
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    46
    end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    47
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    48
  fun mk_domain (eqs'') = let
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
    49
    val dtnvs  = map (rep_Type o fst) eqs'';
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    50
    val dnames = map fst dtnvs;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    51
    val num = length dnames;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    52
    val comp_dname = implode (separate "_" dnames);
2267
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    53
    val conss' = ListPair.map 
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    54
	(fn (dname,cons'') =>
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    55
	  let fun sel n m = upd_second 
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    56
			      (fn None   => dname^"_sel_"^(string_of_int n)^
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    57
						 "_"^(string_of_int m)
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    58
				| Some s => s)
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    59
	      fun fill_sels n con = upd_third (mapn (sel n) 1) con;
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    60
	  in mapn fill_sels 1 cons'' end)
b2326aefecbc Replaced map...~~ by ListPair.map
paulson
parents: 2240
diff changeset
    61
	(dnames, map #2 eqs'');
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    62
    val eqs' = dtnvs~~conss';
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    63
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    64
(* ----- string for calling add_domain -------------------------------------- *)
1284
e5b95ee2616b removed incompatibility with sml
regensbu
parents: 1274
diff changeset
    65
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    66
    val thy_ext_string = let
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
    67
      fun mk_tnv (n,v) = mk_pair (quote n, mk_list (map mk_typ v))
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
    68
      and mk_typ (TFree(name,sort))= "TFree" ^ 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
    69
			 mk_pair (quote name, mk_list (map quote sort))
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    70
      |   mk_typ (Type (name,args))= "Type" ^mk_tnv(name,args)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    71
      |   mk_typ _                 = Imposs "interface:mk_typ";
2240
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    72
      fun mk_conslist cons' = 
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    73
	  mk_list (map 
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    74
		   (fn (c,syn,ts)=>
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    75
		    mk_triple(quote c, syn, 
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    76
			      mk_list
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    77
			      (map (fn (b,s ,tp) =>
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    78
				    mk_triple(Bool.toString b, quote s,
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
    79
					      mk_typ tp)) ts))) cons');
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    80
    in "val (thy, "^comp_dname^"_equations) = thy |> Domain_Extender.add_domain \n"
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    81
       ^ mk_pair(quote comp_dname,
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    82
		 mk_list(map (fn (t,cs)=> mk_pair (mk_tnv t,mk_conslist cs)) eqs'))
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    83
       ^ ";\nval thy = thy"
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    84
    end;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    85
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    86
(* ----- string for calling (comp_)theorems and producing the structures ---------- *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    87
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    88
    val val_gen_string =  let
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    89
      fun plural s = if num > 1 then s^"s" else "["^s^"]";
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    90
      val comp_axioms   = [(* copy, *) "reach", "take_def", "finite_def"
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    91
			   (*, "bisim_def" *)];
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    92
      val comp_theorems = "take_rews, " ^ implode (separate ", " (map plural
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    93
			       ["take_lemma","finite"]))^", finite_ind, ind, coind";
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    94
      fun eqname n = "(hd(funpow "^string_of_int n^" tl "^comp_dname^"_equations), "
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    95
							 ^comp_dname^"_equations)";
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    96
      fun collect sep name = if num = 1 then name else
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    97
			     implode (separate sep (map (fn s => s^"."^name) dnames));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    98
    in
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    99
      implode (separate "end; (* struct *)\n\n" 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   100
        	 (mapn (fn n => gen_domain (eqname n) num) 0 eqs'))^(if num > 1 then
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   101
      "end; (* struct *)\n\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   102
      \structure "^comp_dname^" = struct\n" else "") ^
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   103
	(if num > 1 then gen_val comp_dname "copy_def" ^"\n" else "") ^
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   104
	implode ((map (fn s => gen_vall (plural s)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   105
	           (map (fn dn => gt_ax(dn ^ "_" ^ s)) dnames) ^"\n") comp_axioms)) ^
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   106
	 gen_val comp_dname "bisim_def" ^"\n\
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   107
        \val ("^ comp_theorems ^") =\n\
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   108
	\Domain_Theorems.comp_theorems thy \
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   109
	\(" ^ quote comp_dname   ^ ","^ comp_dname ^"_equations,\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   110
	\ ["^collect "    ," "cases"    ^"],\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   111
	\  "^collect "@"     "con_rews " ^",\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   112
	\  "^collect " @"    "copy_rews" ^");\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   113
	\val rews = "^(if num>1 then collect" @ " "rews"else rews1)^ " @ take_rews;\n\
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   114
      \end; (* struct *)"
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   115
    end;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   116
  in (thy_ext_string, val_gen_string) end;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   117
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   118
(* ----- strings for calling add_gen_by and producing the value binding ----------- *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   119
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   120
  fun mk_gen_by (finite,eqs) = let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   121
      val typs    = map fst eqs;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   122
      val cnstrss = map snd eqs;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   123
      val tname = implode (separate "_" typs) in
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   124
      ("|> Domain_Extender.add_gen_by "
2240
a8c074224e11 Replaced obsolete "makestring" by Bool.toString
paulson
parents: 1637
diff changeset
   125
       ^ mk_pair(mk_pair(quote tname, Bool.toString finite),
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   126
		 mk_pair(mk_list(map quote typs), 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   127
			 mk_list (map (fn cns => mk_list(map quote cns)) cnstrss))),
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   128
       "val "^tname^"_induct = " ^gt_ax (tname^"_induct")^";") end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   129
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   130
(* ----- parser for domain declaration equation ----------------------------------- *)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   131
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   132
  val name' = name >> strip_quotes;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   133
  val type_var' = type_var >> strip_quotes;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   134
  val sort = name' >> (fn s => [s])
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   135
	  || "{" $$-- !! (list name' --$$ "}");
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   136
  val tvar = (type_var' --(optional("::" $$-- !! sort)["_default"])) >>TFree;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   137
(*val tvar = type_var >> (fn tv => TFree(strip_quotes tv,["pcpo"]));*)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   138
  fun type_args l = ("(" $$-- !! (list1 typ --$$ ")")
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   139
	         || tvar  >> (fn x => [x])
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   140
	         || empty >> K []) l
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   141
  and con_typ l   = (type_args -- name' >> (fn (x,y) => Type(y,x))) l
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   142
			(* here ident may be used instead of name' 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   143
			   to avoid ambiguity with standard mixfix option *)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   144
  and typ l       = (con_typ 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   145
		   || tvar) l;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   146
  val domain_arg  = "(" $$-- (optional ($$ "lazy" >> K true) false)
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   147
			  -- (optional ((name' >> Some) --$$ "::") None)
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   148
			  -- typ --$$ ")" >> (fn ((lazy,sel),tp) => (lazy,sel,tp))
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   149
		 || name' >> (fn x => (false,None,Type(x,[]))) 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   150
		 || tvar  >> (fn x => (false,None,x));
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   151
  val domain_cons = name' -- !! (repeat domain_arg) 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   152
		    -- ThyOps.opt_cmixfix
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   153
		    >> (fn ((con,args),syn) => (con,syn,args));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   154
in
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   155
  val domain_decl = (enum1 "," (con_typ --$$ "="  -- !! 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   156
			       (enum1 "|" domain_cons))) 	    >> mk_domain;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   157
  val gen_by_decl = (optional ($$ "finite" >> K true) false) -- 
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   158
		    (enum1 "," (name'   --$$ "by" -- !!
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 2267
diff changeset
   159
			       (enum1 "|" name'))) >> mk_gen_by;
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   160
end; (* local *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   161
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   162
val user_keywords = "lazy"::"by"::"finite"::
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   163
		(**)filter_out (fn s=>s="lazy" orelse s="by" orelse s="finite")(**)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   164
		    ThySynData.user_keywords;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   165
val user_sections = ("domain", domain_decl)::("generated", gen_by_decl)::
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   166
		(**)filter_out (fn (s,_)=>s="domain" orelse s="generated")(**)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   167
		    ThySynData.user_sections;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   168
end; (* struct *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   169
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   170
structure ThySyn = ThySynFun(ThySynData); (* overwrites old version of ThySyn!!!!!! *)