src/HOLCF/Tools/Domain/domain_axioms.ML
author huffman
Tue, 02 Mar 2010 02:28:45 -0800
changeset 35495 dc59e781669f
parent 35494 45c9a8278faf
child 35497 979706bd5c16
permissions -rw-r--r--
remove dead code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32126
a5042f260440 obey captialized directory names convention
haftmann
parents: 31738
diff changeset
     1
(*  Title:      HOLCF/Tools/Domain/domain_axioms.ML
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
     2
    Author:     David von Oheimb
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
     3
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
     4
Syntax generator for domain command.
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
     5
*)
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
     6
30919
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
     7
signature DOMAIN_AXIOMS =
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
     8
sig
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
     9
  val copy_of_dtyp :
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    10
      string Symtab.table -> (int -> term) -> Datatype.dtyp -> term
31232
689aa7da48cc define copy functions using combinators; add checking for failed proofs of induction rules
huffman
parents: 31227
diff changeset
    11
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    12
  val calc_axioms :
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    13
      bool -> string Symtab.table ->
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    14
      string -> Domain_Library.eq list -> int -> Domain_Library.eq ->
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    15
      string * (string * term) list * (string * term) list
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    16
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    17
  val add_axioms :
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    18
      bool ->
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
    19
      ((string * typ list) *
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
    20
       (binding * (bool * binding option * typ) list * mixfix) list) list ->
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    21
      bstring -> Domain_Library.eq list -> theory -> theory
30919
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
    22
end;
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
    23
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
    24
33245
65232054ffd0 eliminated some old folds;
wenzelm
parents: 32952
diff changeset
    25
structure Domain_Axioms : DOMAIN_AXIOMS =
30919
dcf8a7a66bd1 make domain package ML interface more consistent with datatype package; use binding instead of bstring
huffman
parents: 30912
diff changeset
    26
struct
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    27
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    28
open Domain_Library;
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    29
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    30
infixr 0 ===>;infixr 0 ==>;infix 0 == ; 
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    31
infix 1 ===; infix 1 ~= ; infix 1 <<; infix 1 ~<<;
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    32
infix 9 `   ; infix 9 `% ; infix 9 `%%; infixr 9 oo;
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    33
31232
689aa7da48cc define copy functions using combinators; add checking for failed proofs of induction rules
huffman
parents: 31227
diff changeset
    34
(* FIXME: use theory data for this *)
689aa7da48cc define copy functions using combinators; add checking for failed proofs of induction rules
huffman
parents: 31227
diff changeset
    35
val copy_tab : string Symtab.table =
33504
b4210cc3ac97 map functions for various types, with ep_pair/deflation/finite_deflation lemmas
huffman
parents: 33396
diff changeset
    36
    Symtab.make [(@{type_name "->"}, @{const_name "cfun_map"}),
b4210cc3ac97 map functions for various types, with ep_pair/deflation/finite_deflation lemmas
huffman
parents: 33396
diff changeset
    37
                 (@{type_name "++"}, @{const_name "ssum_map"}),
b4210cc3ac97 map functions for various types, with ep_pair/deflation/finite_deflation lemmas
huffman
parents: 33396
diff changeset
    38
                 (@{type_name "**"}, @{const_name "sprod_map"}),
b4210cc3ac97 map functions for various types, with ep_pair/deflation/finite_deflation lemmas
huffman
parents: 33396
diff changeset
    39
                 (@{type_name "*"}, @{const_name "cprod_map"}),
b4210cc3ac97 map functions for various types, with ep_pair/deflation/finite_deflation lemmas
huffman
parents: 33396
diff changeset
    40
                 (@{type_name "u"}, @{const_name "u_map"})];
31232
689aa7da48cc define copy functions using combinators; add checking for failed proofs of induction rules
huffman
parents: 31227
diff changeset
    41
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    42
fun copy_of_dtyp tab r dt =
33971
9c7fa7f76950 modernized structure Datatype_Aux
haftmann
parents: 33809
diff changeset
    43
    if Datatype_Aux.is_rec_type dt then copy tab r dt else ID
9c7fa7f76950 modernized structure Datatype_Aux
haftmann
parents: 33809
diff changeset
    44
and copy tab r (Datatype_Aux.DtRec i) = r i
9c7fa7f76950 modernized structure Datatype_Aux
haftmann
parents: 33809
diff changeset
    45
  | copy tab r (Datatype_Aux.DtTFree a) = ID
9c7fa7f76950 modernized structure Datatype_Aux
haftmann
parents: 33809
diff changeset
    46
  | copy tab r (Datatype_Aux.DtType (c, ds)) =
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    47
    case Symtab.lookup tab c of
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    48
      SOME f => list_ccomb (%%:f, map (copy_of_dtyp tab r) ds)
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
    49
    | NONE => (warning ("copy_of_dtyp: unknown type constructor " ^ c); ID);
31232
689aa7da48cc define copy functions using combinators; add checking for failed proofs of induction rules
huffman
parents: 31227
diff changeset
    50
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    51
fun calc_axioms
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    52
    (definitional : bool)
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
    53
    (map_tab : string Symtab.table)
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    54
    (comp_dname : string)
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    55
    (eqs : eq list)
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    56
    (n : int)
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    57
    (eqn as ((dname,_),cons) : eq)
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    58
    : string * (string * term) list * (string * term) list =
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    59
  let
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    60
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    61
(* ----- axioms and definitions concerning the isomorphism ------------------ *)
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    62
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    63
    val dc_abs = %%:(dname^"_abs");
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    64
    val dc_rep = %%:(dname^"_rep");
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    65
    val x_name'= "x";
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    66
    val x_name = idx_name eqs x_name' (n+1);
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    67
    val dnam = Long_Name.base_name dname;
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    68
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    69
    val abs_iso_ax = ("abs_iso", mk_trp(dc_rep`(dc_abs`%x_name') === %:x_name'));
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    70
    val rep_iso_ax = ("rep_iso", mk_trp(dc_abs`(dc_rep`%x_name') === %:x_name'));
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    71
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    72
(* ----- axiom and definitions concerning induction ------------------------- *)
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    73
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    74
    val finite_def =
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    75
        ("finite_def",
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    76
         %%:(dname^"_finite") ==
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    77
            mk_lam(x_name,
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    78
                   mk_ex("n",(%%:(dname^"_take") $ Bound 0)`Bound 1 === Bound 1)));
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    79
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    80
  in (dnam,
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
    81
      (if definitional then [] else [abs_iso_ax, rep_iso_ax]),
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
    82
      [finite_def])
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
    83
  end; (* let (calc_axioms) *)
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    84
30483
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    85
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    86
(* legacy type inference *)
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    87
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    88
fun legacy_infer_term thy t =
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
    89
    singleton (Syntax.check_terms (ProofContext.init thy)) (Sign.intern_term thy t);
30483
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    90
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    91
fun legacy_infer_prop thy t = legacy_infer_term thy (TypeInfer.constrain propT t);
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    92
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    93
fun infer_props thy = map (apsnd (legacy_infer_prop thy));
0c398040969c added legacy type inference (from fixrec_package.ML);
wenzelm
parents: 30364
diff changeset
    94
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    95
29585
c23295521af5 binding replaces bstring
haftmann
parents: 28965
diff changeset
    96
fun add_axioms_i x = snd o PureThy.add_axioms (map (Thm.no_attributes o apfst Binding.name) x);
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    97
fun add_axioms_infer axms thy = add_axioms_i (infer_props thy axms) thy;
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
    98
29585
c23295521af5 binding replaces bstring
haftmann
parents: 28965
diff changeset
    99
fun add_defs_i x = snd o (PureThy.add_defs false) (map (Thm.no_attributes o apfst Binding.name) x);
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
   100
fun add_defs_infer defs thy = add_defs_i (infer_props thy defs) thy;
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
   101
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   102
fun add_axioms definitional eqs' comp_dnam (eqs : eq list) thy' =
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   103
  let
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   104
    val comp_dname = Sign.full_bname thy' comp_dnam;
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   105
    val dnames = map (fst o fst) eqs;
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   106
    val x_name = idx_name dnames "x"; 
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
   107
35288
aa7da51ae1ef add mixfix field to type Domain_Library.cons
huffman
parents: 33971
diff changeset
   108
    fun one_con (con, _, args) =
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   109
      let
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   110
        val nonrec_args = filter_out is_rec args;
33317
b4534348b8fd standardized filter/filter_out;
wenzelm
parents: 33245
diff changeset
   111
        val    rec_args = filter is_rec args;
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   112
        val    recs_cnt = length rec_args;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   113
        val allargs     = nonrec_args @ rec_args
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   114
                          @ map (upd_vname (fn s=> s^"'")) rec_args;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   115
        val allvns      = map vname allargs;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   116
        fun vname_arg s arg = if is_rec arg then vname arg^s else vname arg;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   117
        val vns1        = map (vname_arg "" ) args;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   118
        val vns2        = map (vname_arg "'") args;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   119
        val allargs_cnt = length nonrec_args + 2*recs_cnt;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   120
        val rec_idxs    = (recs_cnt-1) downto 0;
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   121
        val nonlazy_idxs = map snd (filter_out (fn (arg,_) => is_lazy arg)
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   122
                                               (allargs~~((allargs_cnt-1) downto 0)));
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   123
        fun rel_app i ra = proj (Bound(allargs_cnt+2)) eqs (rec_of ra) $ 
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   124
                                Bound (2*recs_cnt-i) $ Bound (recs_cnt-i);
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   125
        val capps =
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   126
          List.foldr
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   127
            mk_conj
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   128
            (mk_conj(
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   129
             Bound(allargs_cnt+1)===list_ccomb(%%:con,map (bound_arg allvns) vns1),
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   130
             Bound(allargs_cnt+0)===list_ccomb(%%:con,map (bound_arg allvns) vns2)))
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   131
            (mapn rel_app 1 rec_args);
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   132
      in
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   133
        List.foldr
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   134
          mk_ex
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   135
          (Library.foldr mk_conj
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   136
                         (map (defined o Bound) nonlazy_idxs,capps)) allvns
31288
67dff9c5b2bd remove hard tabs, fix indentation
huffman
parents: 31232
diff changeset
   137
      end;
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   138
    fun one_comp n (_,cons) =
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   139
        mk_all (x_name(n+1),
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   140
        mk_all (x_name(n+1)^"'",
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   141
        mk_imp (proj (Bound 2) eqs n $ Bound 1 $ Bound 0,
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   142
        foldr1 mk_disj (mk_conj(Bound 1 === UU,Bound 0 === UU)
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   143
                        ::map one_con cons))));
35444
73f645fdd4ff reorganizing domain package code (in progress)
huffman
parents: 35288
diff changeset
   144
(* TEMPORARILY DISABLED
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   145
    val bisim_def =
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   146
        ("bisim_def", %%:(comp_dname^"_bisim") ==
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   147
                         mk_lam("R", foldr1 mk_conj (mapn one_comp 0 eqs)));
35444
73f645fdd4ff reorganizing domain package code (in progress)
huffman
parents: 35288
diff changeset
   148
TEMPORARILY DISABLED *)
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   149
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   150
    fun add_one (dnam, axs, dfs) =
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   151
        Sign.add_path dnam
33245
65232054ffd0 eliminated some old folds;
wenzelm
parents: 32952
diff changeset
   152
          #> add_axioms_infer axs
65232054ffd0 eliminated some old folds;
wenzelm
parents: 32952
diff changeset
   153
          #> Sign.parent_path;
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
   154
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
   155
    val map_tab = Domain_Isomorphism.get_map_tab thy';
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   156
    val axs = mapn (calc_axioms definitional map_tab comp_dname eqs) 0 eqs;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   157
    val thy = thy' |> fold add_one axs;
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33798
diff changeset
   158
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   159
    fun get_iso_info ((dname, tyvars), cons') =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   160
      let
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   161
        fun opt_lazy (lazy,_,t) = if lazy then mk_uT t else t
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   162
        fun prod     (_,args,_) =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   163
            case args of [] => oneT
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   164
                       | _ => foldr1 mk_sprodT (map opt_lazy args);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   165
        val ax_abs_iso = PureThy.get_thm thy (dname ^ ".abs_iso");
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   166
        val ax_rep_iso = PureThy.get_thm thy (dname ^ ".rep_iso");
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   167
        val lhsT = Type(dname,tyvars);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   168
        val rhsT = foldr1 mk_ssumT (map prod cons');
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   169
        val rep_const = Const(dname^"_rep", lhsT ->> rhsT);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   170
        val abs_const = Const(dname^"_abs", rhsT ->> lhsT);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   171
      in
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   172
        {
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   173
          absT = lhsT,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   174
          repT = rhsT,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   175
          abs_const = abs_const,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   176
          rep_const = rep_const,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   177
          abs_inverse = ax_abs_iso,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   178
          rep_inverse = ax_rep_iso
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   179
        }
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   180
      end;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   181
    val dom_binds = map (Binding.name o Long_Name.base_name) dnames;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   182
    val thy =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   183
        if definitional then thy
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   184
        else snd (Domain_Isomorphism.define_take_functions
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   185
                    (dom_binds ~~ map get_iso_info eqs') thy);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   186
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   187
    fun add_one' (dnam, axs, dfs) =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   188
        Sign.add_path dnam
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   189
          #> add_defs_infer dfs
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   190
          #> Sign.parent_path;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   191
    val thy = fold add_one' axs thy;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   192
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   193
    (* declare lub_take axioms *)
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   194
    local
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   195
      fun ax_lub_take dname =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   196
        let
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   197
          val dnam : string = Long_Name.base_name dname;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   198
          val take_const = %%:(dname^"_take");
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   199
          val lub = %%: @{const_name lub};
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   200
          val image = %%: @{const_name image};
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   201
          val UNIV = %%: @{const_name UNIV};
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   202
          val lhs = lub $ (image $ take_const $ UNIV);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   203
          val ax = mk_trp (lhs === ID);
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   204
        in
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   205
          add_one (dnam, [("lub_take", ax)], [])
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   206
        end
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   207
    in
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   208
      val thy =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   209
          if definitional then thy
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   210
          else fold ax_lub_take dnames thy
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   211
    end;
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   212
  in
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   213
    thy
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   214
    |> Sign.add_path comp_dnam
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   215
(*
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   216
    |> add_defs_infer [bisim_def]
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35486
diff changeset
   217
*)
33798
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   218
    |> Sign.parent_path
46cbbcbd4e68 clean up indentation; add 'definitional' option flag
huffman
parents: 33504
diff changeset
   219
  end; (* let (add_axioms) *)
31227
0aa6afd229d3 indentation; export Domain_Axioms.calc_axioms
huffman
parents: 31023
diff changeset
   220
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents:
diff changeset
   221
end; (* struct *)