src/HOLCF/domain/axioms.ML
author oheimb
Thu, 19 Dec 1996 17:02:27 +0100
changeset 2453 2d416226b27d
parent 1637 b8a8ae2e5de1
child 2641 533a84b3bedd
permissions -rw-r--r--
corrected headers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2453
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     1
(*  Title:      HOLCF/domain/axioms.ML
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     2
    ID:         $Id$
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     3
    Author : David von Oheimb
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     4
    Copyright 1995, 1996 TU Muenchen
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     5
2d416226b27d corrected headers
oheimb
parents: 1637
diff changeset
     6
syntax generator for domain section
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     7
*)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     8
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
     9
structure Domain_Axioms = struct
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    10
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    11
local
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    12
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    13
open Domain_Library;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    14
infixr 0 ===>;infixr 0 ==>;infix 0 == ; 
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    15
infix 1 ===; infix 1 ~= ; infix 1 <<; infix 1 ~<<;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    16
infix 9 `   ; infix 9 `% ; infix 9 `%%; infixr 9 oo;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    17
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    18
fun infer_types thy' = map (inferT_axm (sign_of thy'));
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    19
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    20
fun calc_axioms comp_dname (eqs : eq list) n (((dname,_),cons) : eq)=
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    21
let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    22
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    23
(* ----- axioms and definitions concerning the isomorphism ------------------ *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    24
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    25
  val dc_abs = %%(dname^"_abs");
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    26
  val dc_rep = %%(dname^"_rep");
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    27
  val x_name'= "x";
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    28
  val x_name = idx_name eqs x_name' (n+1);
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    29
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    30
 val ax_abs_iso=(dname^"_abs_iso",mk_trp(dc_rep`(dc_abs`%x_name')=== %x_name'));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    31
 val ax_rep_iso=(dname^"_rep_iso",mk_trp(dc_abs`(dc_rep`%x_name')=== %x_name'));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    32
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    33
  val ax_when_def = (dname^"_when_def",%%(dname^"_when") == 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    34
     foldr (uncurry /\ ) (when_funs cons, /\x_name'((when_body cons (fn (x,y) =>
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    35
				Bound(1+length cons+x-y)))`(dc_rep`Bound 0))));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    36
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    37
  fun con_def outer recu m n (_,args) = let
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    38
     fun idxs z x arg = (if is_lazy arg then fn t => %%"up"`t else Id)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    39
			(if recu andalso is_rec arg then (cproj (Bound z) 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    40
			(length eqs) (rec_of arg))`Bound(z-x) else Bound(z-x));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    41
     fun parms [] = %%"one"
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    42
     |   parms vs = foldr'(fn(x,t)=> %%"spair"`x`t)(mapn (idxs(length vs))1 vs);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    43
     fun inj y 1 _ = y
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    44
     |   inj y _ 0 = %%"sinl"`y
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    45
     |   inj y i j = %%"sinr"`(inj y (i-1) (j-1));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    46
  in foldr /\# (args, outer (inj (parms args) m n)) end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    47
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    48
  val ax_copy_def = (dname^"_copy_def", %%(dname^"_copy") == /\"f" (dc_abs oo 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    49
	foldl (op `) (%%(dname^"_when") , 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    50
	              mapn (con_def Id true (length cons)) 0 cons)));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    51
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    52
(* -- definitions concerning the constructors, discriminators and selectors - *)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    53
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    54
  val axs_con_def = mapn (fn n => fn (con,args) => (extern_name con ^"_def",  
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    55
  %%con == con_def (fn t => dc_abs`t) false (length cons) n (con,args))) 0 cons;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    56
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    57
  val axs_dis_def = let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    58
	fun ddef (con,_) = (dis_name con ^"_def",%%(dis_name con) == 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    59
		 mk_cfapp(%%(dname^"_when"),map 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    60
			(fn (con',args) => (foldr /\#
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    61
			   (args,if con'=con then %%"TT" else %%"FF"))) cons))
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    62
	in map ddef cons end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    63
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    64
  val axs_sel_def = let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    65
	fun sdef con n arg = (sel_of arg^"_def",%%(sel_of arg) == 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    66
		 mk_cfapp(%%(dname^"_when"),map 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    67
			(fn (con',args) => if con'<>con then %%"UU" else
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    68
			 foldr /\# (args,Bound (length args - n))) cons));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    69
	in flat(map (fn (con,args) => mapn (sdef con) 1 args) cons) end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    70
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    71
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    72
(* ----- axiom and definitions concerning induction ------------------------- *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    73
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    74
  fun cproj' T = cproj T (length eqs) n;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    75
  val ax_reach = (dname^"_reach", mk_trp(cproj'(%%"fix"`%%(comp_dname^"_copy"))
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    76
					`%x_name === %x_name));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    77
  val ax_take_def = (dname^"_take_def",%%(dname^"_take") == mk_lam("n",cproj'
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    78
		    (%%"iterate" $ Bound 0 $ %%(comp_dname^"_copy") $ %%"UU")));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    79
  val ax_finite_def = (dname^"_finite_def",%%(dname^"_finite") == mk_lam(x_name,
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    80
	mk_ex("n",(%%(dname^"_take") $ Bound 0)`Bound 1 === Bound 1)));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    81
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    82
in [ax_abs_iso, ax_rep_iso, ax_when_def, ax_copy_def] @
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    83
    axs_con_def @ axs_dis_def @ axs_sel_def @
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    84
   [ax_reach, ax_take_def, ax_finite_def] 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    85
end; (* let *)
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    86
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    87
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    88
in (* local *)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    89
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    90
fun add_axioms (comp_dname, eqs : eq list) thy' = let
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    91
  val dnames = map (fst o fst) eqs;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    92
  val x_name = idx_name dnames "x"; 
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    93
  fun copy_app dname = %%(dname^"_copy")`Bound 0;
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    94
  val ax_copy_def =(comp_dname^"_copy_def" , %%(comp_dname^"_copy") ==
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    95
				    /\"f"(foldr' cpair (map copy_app dnames)));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    96
  val ax_bisim_def=(comp_dname^"_bisim_def",%%(comp_dname^"_bisim")==mk_lam("R",
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    97
    let
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
    98
      fun one_con (con,args) = let
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
    99
	val nonrec_args = filter_out is_rec args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   100
	val    rec_args = filter     is_rec args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   101
	val    recs_cnt = length rec_args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   102
	val allargs     = nonrec_args @ rec_args
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   103
				      @ map (upd_vname (fn s=> s^"'")) rec_args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   104
	val allvns      = map vname allargs;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   105
	fun vname_arg s arg = if is_rec arg then vname arg^s else vname arg;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   106
	val vns1        = map (vname_arg "" ) args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   107
	val vns2        = map (vname_arg "'") args;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   108
	val allargs_cnt = length nonrec_args + 2*recs_cnt;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   109
	val rec_idxs    = (recs_cnt-1) downto 0;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   110
	val nonlazy_idxs = map snd (filter_out (fn (arg,_) => is_lazy arg)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   111
					 (allargs~~((allargs_cnt-1) downto 0)));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   112
	fun rel_app i ra = proj (Bound(allargs_cnt+2)) (length eqs) (rec_of ra) $ 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   113
			   Bound (2*recs_cnt-i) $ Bound (recs_cnt-i);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   114
	val capps = foldr mk_conj (mapn rel_app 1 rec_args, mk_conj(
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   115
	   Bound(allargs_cnt+1)===mk_cfapp(%%con,map (bound_arg allvns) vns1),
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   116
	   Bound(allargs_cnt+0)===mk_cfapp(%%con,map (bound_arg allvns) vns2)));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   117
        in foldr mk_ex (allvns, foldr mk_conj 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   118
			      (map (defined o Bound) nonlazy_idxs,capps)) end;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   119
      fun one_comp n (_,cons) =mk_all(x_name(n+1),mk_all(x_name(n+1)^"'",mk_imp(
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   120
	 		proj (Bound 2) (length eqs) n $ Bound 1 $ Bound 0,
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   121
         		foldr' mk_disj (mk_conj(Bound 1 === UU,Bound 0 === UU)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   122
					::map one_con cons))));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   123
    in foldr' mk_conj (mapn one_comp 0 eqs)end ));
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   124
  val thy_axs = flat (mapn (calc_axioms comp_dname eqs) 0 eqs) @
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   125
		(if length eqs>1 then [ax_copy_def] else []) @ [ax_bisim_def];
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   126
in thy' |> add_axioms_i (infer_types thy' thy_axs) end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   127
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   128
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   129
fun add_induct ((tname,finite),(typs,cnstrs)) thy' = let
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   130
  fun P_name typ = "P"^(if typs = [typ] then "" 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   131
			else string_of_int(1 + find(typ,typs)));
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   132
  fun lift_adm t = lift (fn typ => %%"adm" $ %(P_name typ)) 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   133
			(if finite then [] else typs,t);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   134
  fun lift_pred_UU t = lift (fn typ => %(P_name typ) $ UU) (typs,t);
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   135
  fun one_cnstr (cnstr,vns,(args,res)) = let 
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   136
		val rec_args = filter (fn (_,typ) => typ mem typs)(vns~~args);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   137
		val app = mk_cfapp(%%cnstr,map (bound_arg vns) vns);
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   138
	     in foldr mk_All (vns,
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   139
			 lift (fn (vn,typ) => %(P_name typ) $ bound_arg vns vn)
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   140
			      (rec_args,defined app ==> %(P_name res)$app)) end;
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   141
  fun one_conc typ = let val pn = P_name typ 
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   142
		     in %pn $ %("x"^implode(tl(explode pn))) end;
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   143
  val concl = mk_trp(foldr' mk_conj (map one_conc typs));
1637
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   144
  val induct = (tname^"_induct",lift_adm(lift_pred_UU(
b8a8ae2e5de1 Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents: 1461
diff changeset
   145
			foldr (op ===>) (map one_cnstr cnstrs,concl))));
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   146
in thy' |> add_axioms_i (infer_types thy' [induct]) end;
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   147
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   148
end; (* local *)
ea0668a1c0ba added 8bit pragmas
regensbu
parents:
diff changeset
   149
end; (* struct *)