src/HOLCF/domain/extender.ML
author oheimb
Wed, 18 Dec 1996 15:16:13 +0100
changeset 2445 51993fea433f
parent 1637 b8a8ae2e5de1
child 2446 c2a9bf6c0948
permissions -rw-r--r--
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
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: 1637
diff changeset
     1
(*  Title:      HOLCF/domain/extender.ML
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
     2
    ID:         $Id$
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
     3
    Author : David von Oheimb
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
     4
    Copyright 1995, 1996 TU Muenchen
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
     5
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
     6
theory extender for domain section
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     7
*)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     8
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
     9
structure Domain_Extender =
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    10
struct
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    11
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    12
local
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    13
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    14
open Domain_Library;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    15
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    16
(* ----- general testing and preprocessing of constructor list -------------- *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    17
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    18
  fun check_and_sort_domain (eqs'':((string * typ list) *
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    19
     (string * ThyOps.cmixfix * (bool*string*typ) list) list) list) thy'' = let
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    20
    val dtnvs = map fst eqs'';
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    21
    val cons' = flat (map snd eqs'');
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    22
    val test_dupl_typs = (case duplicates (map fst dtnvs) of 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    23
	[] => false | dups => error ("Duplicate types: " ^ commas_quote dups));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    24
    val test_dupl_cons = (case duplicates (map first cons') of 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    25
	[] => false | dups => error ("Duplicate constructors: " ^ commas_quote dups));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    26
    val test_dupl_sels = (case duplicates(map second (flat(map third cons'))) of
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    27
        [] => false | dups => error("Duplicate selectors: "^commas_quote dups));
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    28
    val test_dupl_tvars = exists(fn s=>case duplicates(map(fst o rep_TFree)s)of
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    29
	[] => false | dups => error("Duplicate type arguments: " 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    30
							   ^commas_quote dups))
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    31
	(map snd dtnvs);
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    32
    val default = ["_default"];
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    33
    (*test for free type variables, Inconsistent sort constraints,
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    34
	       non-pcpo-types and invalid use of recursive type*)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    35
    in map (fn ((dname,typevars),cons') => let
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    36
      val tvars = ref (map rep_TFree typevars) : (string * sort) list ref;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    37
      fun newsort (TFree(v,s)) = TFree(v,case assoc_string (!tvars,v) of
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    38
		None   => Imposs "extender:newsort"
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    39
	      | Some s => if s=default then Type.defaultS(tsig_of thy'') else s)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    40
      |   newsort (Type(s,typl)) = Type(s,map newsort typl)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    41
      |   newsort (TVar _) = Imposs "extender:newsort 2";
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    42
      val analyse_cons = forall (fn con' => let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    43
	  val types = map third (third con');
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    44
	  fun rm_sorts (TFree(s,_)) = TFree(s,[])
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    45
	  |   rm_sorts (Type(s,ts)) = Type(s,remove_sorts ts)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    46
	  |   rm_sorts (TVar(s,_))  = TVar(s,[])
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    47
	  and remove_sorts l = map rm_sorts l;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    48
          fun analyse(TFree(v,s)) = (case assoc_string(!tvars,v) of 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    49
			None =>	error ("Free type variable " ^ v ^ " on rhs.")
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    50
		      | Some sort => s = default orelse
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    51
				     if sort = default 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    52
					then (tvars:= (v,s):: !tvars;true)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    53
					else eq_set_string (s,sort) orelse
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    54
					error ("Inconsistent sort constraints "^
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    55
					       "for type variable "^quote v))
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    56
	    | analyse(Type(s,typl)) = (case assoc_string (dtnvs,s) of 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    57
			None => forall analyse typl
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    58
		      | Some tvs => remove_sorts tvs = remove_sorts typl orelse 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    59
		       		    error ("Recursion of type " ^ s ^ 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    60
					   " with different arguments"))
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    61
	    | analyse(TVar _) = Imposs "extender:analyse";
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    62
	  in forall analyse types end) cons';
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    63
      fun check_pcpo t = (pcpo_type thy'' t orelse 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    64
			  error("Not a pcpo type: "^string_of_typ thy'' t); t);
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    65
      fun check_type (t as Type(s,typl)) = (case assoc_string (dtnvs,s) of 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    66
			None => check_pcpo t | Some _ => t)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    67
      |   check_type t = check_pcpo t;
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    68
      in ((dname,map newsort typevars),
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    69
	  map (upd_third (map (upd_third (check_type o newsort)))) cons')
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    70
      end) eqs''
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    71
    end; (* let *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    72
  fun check_gen_by thy' (typs': string list,cnstrss': string list list) = let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    73
    val test_dupl_typs = (case duplicates typs' of [] => false
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    74
	  | dups => error ("Duplicate types: " ^ commas_quote dups));
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    75
    val test_dupl_cnstrs = map (fn cs => (case duplicates cs of [] => false 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    76
	| ds => error ("Duplicate constructors: " ^ commas_quote ds))) cnstrss';
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    77
    val tycons = map fst (#tycons(Type.rep_tsig (tsig_of thy')));
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    78
    val test_types = forall (fn t => t mem tycons orelse 
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    79
				     error("Unknown type: "^t)) typs';
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    80
    val cnstrss = let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    81
	fun type_of c = case (Sign.const_type(sign_of thy') c) of Some t => t
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    82
				| None => error ("Unknown constructor: "^c);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    83
	fun args_result_type (t as (Type(tn,[arg,rest]))) = 
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    84
		if tn = "->" orelse tn = "=>"
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    85
		then let val (ts,r) = args_result_type rest in (arg::ts,r) end
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    86
		else ([],t)
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    87
	|   args_result_type t = ([],t);
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    88
    in map (map (fn cn => let val (args,res) = args_result_type (type_of cn) in
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    89
	                 (cn,mk_var_names args,(args,res)) end)) cnstrss' 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    90
	: (string * 			(* operator name of constr *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    91
	   string list *		(* argument name list *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    92
	   (typ list *			(* argument types *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    93
	    typ))			(* result type *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    94
	  list list end;
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    95
    fun test_equal_type tn (cn,_,(_,rt)) = fst (rep_Type rt) = tn orelse
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    96
		      error("Inappropriate result type for constructor "^cn);
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    97
    val typs = map (fn (tn, cnstrs) => (map (test_equal_type tn) cnstrs; 
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
    98
				snd(third(hd(cnstrs)))))  (typs'~~cnstrss);
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    99
    val test_typs = map (fn (typ,cnstrs) => 
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   100
			if not (pcpo_type thy' typ)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   101
			then error("Not a pcpo type: "^string_of_typ thy' typ)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   102
			else map (fn (cn,_,(_,rt)) => rt=typ orelse error(
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   103
				"Non-identical result types for constructors "^
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   104
			        first(hd cnstrs)^" and "^ cn ))  cnstrs)
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   105
		    (typs~~cnstrss);
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   106
    val proper_args = let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   107
	fun occurs tn (Type(tn',ts)) = (tn'=tn) orelse exists (occurs tn) ts
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   108
	|   occurs _  _              = false;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   109
	fun proper_arg cn atyp = forall (fn typ => let 
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   110
				   val tn = fst (rep_Type typ) 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   111
				   in atyp=typ orelse not (occurs tn atyp) orelse 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   112
				      error("Illegal use of type "^ tn ^
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   113
					 " as argument of constructor " ^cn)end )typs;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   114
	fun proper_curry (cn,_,(args,_)) = forall (proper_arg cn) args;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   115
    in map (map proper_curry) cnstrss end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   116
  in (typs, flat cnstrss) end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   117
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   118
(* ----- calls for building new thy and thms -------------------------------------- *)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   119
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   120
in
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   121
2445
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   122
  fun add_domain (comp_dname,eqs'') thy'' = let
51993fea433f removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents: 1637
diff changeset
   123
    val eqs' = check_and_sort_domain eqs'' thy'';
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   124
    val thy' = thy'' |> Domain_Syntax.add_syntax (comp_dname,eqs');
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   125
    val dts  = map (Type o fst) eqs';
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   126
    fun cons cons' = (map (fn (con,syn,args) =>
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   127
	(ThyOps.const_name con syn,
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   128
	 map (fn ((lazy,sel,tp),vn) => ((lazy,
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   129
					 find (tp,dts) handle LIST "find" => ~1),
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   130
					sel,vn))
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   131
	     (args~~(mk_var_names(map third args)))
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   132
	 )) cons') : cons list;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   133
    val eqs = map (fn (dtnvs,cons') => (dtnvs,cons cons')) eqs' : eq list;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   134
    val thy         = thy' |> Domain_Axioms.add_axioms (comp_dname,eqs);
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   135
  in (thy,eqs) end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   136
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   137
  fun add_gen_by ((tname,finite),(typs',cnstrss')) thy' = let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   138
   val (typs,cnstrs) = check_gen_by thy' (typs',cnstrss');
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   139
  in
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   140
   Domain_Axioms.add_induct ((tname,finite),(typs,cnstrs)) thy' end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   141
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   142
end (* local *)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   143
end (* struct *)