src/HOL/HOLCF/Tools/Domain/domain_isomorphism.ML
author huffman
Sat, 27 Nov 2010 16:08:10 -0800
changeset 40774 0437dbc127b3
parent 40771 src/HOLCF/Tools/Domain/domain_isomorphism.ML@1c6f7d4b110e
child 40832 4352ca878c41
permissions -rw-r--r--
moved directory src/HOLCF to src/HOL/HOLCF; added HOLCF theories to src/HOL/IsaMakefile;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37744
3daaf23b9ab4 tuned titles
haftmann
parents: 37078
diff changeset
     1
(*  Title:      HOLCF/Tools/Domain/domain_isomorphism.ML
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     3
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     4
Defines new types satisfying the given domain equations.
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     5
*)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     6
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     7
signature DOMAIN_ISOMORPHISM =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
     8
sig
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
     9
  val domain_isomorphism :
35657
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    10
      (string list * binding * mixfix * typ
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    11
       * (binding * binding) option) list ->
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    12
      theory ->
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    13
      (Domain_Take_Proofs.iso_info list
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    14
       * Domain_Take_Proofs.take_induct_info) * theory
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
    15
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    16
  val define_map_functions :
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    17
      (binding * Domain_Take_Proofs.iso_info) list ->
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    18
      theory ->
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    19
      {
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    20
        map_consts : term list,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    21
        map_apply_thms : thm list,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    22
        map_unfold_thms : thm list,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    23
        deflation_map_thms : thm list
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    24
      }
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    25
      * theory
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
    26
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
    27
  val domain_isomorphism_cmd :
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
    28
    (string list * binding * mixfix * string * (binding * binding) option) list
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
    29
      -> theory -> theory
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
    30
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    31
  val setup : theory -> theory
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    32
end;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    33
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
    34
structure Domain_Isomorphism : DOMAIN_ISOMORPHISM =
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    35
struct
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    36
37078
a1656804fcad domain package internal proofs use fixed set of continuity rules, rather than taking cont2cont rules from context
huffman
parents: 36960
diff changeset
    37
val beta_rules =
40326
73d45866dbda renamed lemma cont2cont_Rep_CFun to cont2cont_APP
huffman
parents: 40218
diff changeset
    38
  @{thms beta_cfun cont_id cont_const cont2cont_APP cont2cont_LAM'} @
39808
1410c84013b9 rename cont2cont_split to cont2cont_prod_case; add lemmas prod_contI, prod_cont_iff; simplify some proofs
huffman
parents: 39557
diff changeset
    39
  @{thms cont2cont_fst cont2cont_snd cont2cont_Pair cont2cont_prod_case'};
37078
a1656804fcad domain package internal proofs use fixed set of continuity rules, rather than taking cont2cont rules from context
huffman
parents: 36960
diff changeset
    40
a1656804fcad domain package internal proofs use fixed set of continuity rules, rather than taking cont2cont rules from context
huffman
parents: 36960
diff changeset
    41
val beta_ss = HOL_basic_ss addsimps (simp_thms @ beta_rules);
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
    42
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
    43
val beta_tac = simp_tac beta_ss;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
    44
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
    45
fun is_cpo thy T = Sign.of_sort thy (T, @{sort cpo});
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
    46
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    47
(******************************************************************************)
33791
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    48
(******************************** theory data *********************************)
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    49
(******************************************************************************)
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    50
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    51
structure RepData = Named_Thms
33791
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    52
(
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    53
  val name = "domain_defl_simps"
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    54
  val description = "theorems like DEFL('a t) = t_defl$DEFL('a)"
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    55
)
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    56
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    57
structure IsodeflData = Named_Thms
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
    58
(
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    59
  val name = "domain_isodefl"
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
    60
  val description = "theorems like isodefl d t ==> isodefl (foo_map$d) (foo_defl$t)"
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
    61
);
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
    62
40489
0f37a553bc1a implement map_of_typ using Pattern.rewrite_term
huffman
parents: 40487
diff changeset
    63
val setup = RepData.setup #> IsodeflData.setup
33801
e8535acd302c copy_of_dtyp uses map table from theory data
huffman
parents: 33797
diff changeset
    64
33791
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    65
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
    66
(******************************************************************************)
35475
979019ab92eb move common functions into new file holcf_library.ML
huffman
parents: 35474
diff changeset
    67
(************************** building types and terms **************************)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    68
(******************************************************************************)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    69
35475
979019ab92eb move common functions into new file holcf_library.ML
huffman
parents: 35474
diff changeset
    70
open HOLCF_Library;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    71
35475
979019ab92eb move common functions into new file holcf_library.ML
huffman
parents: 35474
diff changeset
    72
infixr 6 ->>;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
    73
infixr -->>;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    74
40037
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
    75
val udomT = @{typ udom};
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
    76
val deflT = @{typ "defl"};
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    77
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
    78
fun mk_DEFL T =
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
    79
  Const (@{const_name defl}, Term.itselfT T --> deflT) $ Logic.mk_type T;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
    80
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
    81
fun dest_DEFL (Const (@{const_name defl}, _) $ t) = Logic.dest_type t
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
    82
  | dest_DEFL t = raise TERM ("dest_DEFL", [t]);
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
    83
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    84
fun mk_LIFTDEFL T =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    85
  Const (@{const_name liftdefl}, Term.itselfT T --> deflT) $ Logic.mk_type T;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    86
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    87
fun dest_LIFTDEFL (Const (@{const_name liftdefl}, _) $ t) = Logic.dest_type t
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    88
  | dest_LIFTDEFL t = raise TERM ("dest_LIFTDEFL", [t]);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    89
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    90
fun mk_u_defl t = mk_capply (@{const "u_defl"}, t);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    91
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    92
fun mk_u_map t =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    93
  let
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    94
    val (T, U) = dest_cfunT (fastype_of t);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    95
    val u_map_type = (T ->> U) ->> (mk_upT T ->> mk_upT U);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    96
    val u_map_const = Const (@{const_name u_map}, u_map_type);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    97
  in
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    98
    mk_capply (u_map_const, t)
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
    99
  end;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   100
40037
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
   101
fun emb_const T = Const (@{const_name emb}, T ->> udomT);
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
   102
fun prj_const T = Const (@{const_name prj}, udomT ->> T);
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
   103
fun coerce_const (T, U) = mk_cfcomp (prj_const U, emb_const T);
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   104
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   105
fun isodefl_const T =
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   106
  Const (@{const_name isodefl}, (T ->> T) --> deflT --> HOLogic.boolT);
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   107
35480
7a1f285cad25 domain_isomorphism package proves deflation rules for map functions
huffman
parents: 35479
diff changeset
   108
fun mk_deflation t =
7a1f285cad25 domain_isomorphism package proves deflation rules for map functions
huffman
parents: 35479
diff changeset
   109
  Const (@{const_name deflation}, Term.fastype_of t --> boolT) $ t;
7a1f285cad25 domain_isomorphism package proves deflation rules for map functions
huffman
parents: 35479
diff changeset
   110
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   111
(* splits a cterm into the right and lefthand sides of equality *)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   112
fun dest_eqs t = HOLogic.dest_eq (HOLogic.dest_Trueprop t);
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   113
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   114
fun mk_eqs (t, u) = HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u));
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   115
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   116
(******************************************************************************)
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   117
(****************************** isomorphism info ******************************)
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   118
(******************************************************************************)
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   119
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
   120
fun deflation_abs_rep (info : Domain_Take_Proofs.iso_info) : thm =
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   121
  let
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   122
    val abs_iso = #abs_inverse info;
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   123
    val rep_iso = #rep_inverse info;
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   124
    val thm = @{thm deflation_abs_rep} OF [abs_iso, rep_iso];
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   125
  in
36241
2a4cec6bcae2 replace many uses of Drule.export_without_context with Drule.zero_var_indexes
huffman
parents: 35842
diff changeset
   126
    Drule.zero_var_indexes thm
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   127
  end
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   128
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   129
(******************************************************************************)
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   130
(*************** fixed-point definitions and unfolding theorems ***************)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   131
(******************************************************************************)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   132
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   133
fun mk_projs []      t = []
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   134
  | mk_projs (x::[]) t = [(x, t)]
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   135
  | mk_projs (x::xs) t = (x, mk_fst t) :: mk_projs xs (mk_snd t);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   136
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   137
fun add_fixdefs
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   138
    (spec : (binding * term) list)
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   139
    (thy : theory) : (thm list * thm list) * theory =
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   140
  let
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   141
    val binds = map fst spec;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   142
    val (lhss, rhss) = ListPair.unzip (map (dest_eqs o snd) spec);
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   143
    val functional = lambda_tuple lhss (mk_tuple rhss);
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   144
    val fixpoint = mk_fix (mk_cabs functional);
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   145
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   146
    (* project components of fixpoint *)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   147
    val projs = mk_projs lhss fixpoint;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   148
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   149
    (* convert parameters to lambda abstractions *)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   150
    fun mk_eqn (lhs, rhs) =
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   151
        case lhs of
40327
1dfdbd66093a renamed {Rep,Abs}_CFun to {Rep,Abs}_cfun
huffman
parents: 40326
diff changeset
   152
          Const (@{const_name Rep_cfun}, _) $ f $ (x as Free _) =>
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   153
            mk_eqn (f, big_lambda x rhs)
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   154
        | f $ Const (@{const_name TYPE}, T) =>
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   155
            mk_eqn (f, Abs ("t", T, rhs))
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   156
        | Const _ => Logic.mk_equals (lhs, rhs)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   157
        | _ => raise TERM ("lhs not of correct form", [lhs, rhs]);
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   158
    val eqns = map mk_eqn projs;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   159
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   160
    (* register constant definitions *)
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   161
    val (fixdef_thms, thy) =
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   162
      (Global_Theory.add_defs false o map Thm.no_attributes)
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   163
        (map (Binding.suffix_name "_def") binds ~~ eqns) thy;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   164
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   165
    (* prove applied version of definitions *)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   166
    fun prove_proj (lhs, rhs) =
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   167
      let
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   168
        val tac = rewrite_goals_tac fixdef_thms THEN beta_tac 1;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   169
        val goal = Logic.mk_equals (lhs, rhs);
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   170
      in Goal.prove_global thy [] [] goal (K tac) end;
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   171
    val proj_thms = map prove_proj projs;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   172
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   173
    (* mk_tuple lhss == fixpoint *)
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   174
    fun pair_equalI (thm1, thm2) = @{thm Pair_equalI} OF [thm1, thm2];
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   175
    val tuple_fixdef_thm = foldr1 pair_equalI proj_thms;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   176
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   177
    val cont_thm =
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   178
      Goal.prove_global thy [] [] (mk_trp (mk_cont functional))
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   179
        (K (beta_tac 1));
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   180
    val tuple_unfold_thm =
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   181
      (@{thm def_cont_fix_eq} OF [tuple_fixdef_thm, cont_thm])
36610
bafd82950e24 renamed ProofContext.init to ProofContext.init_global to emphasize that this is not the real thing;
wenzelm
parents: 36241
diff changeset
   182
      |> Local_Defs.unfold (ProofContext.init_global thy) @{thms split_conv};
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   183
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   184
    fun mk_unfold_thms [] thm = []
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   185
      | mk_unfold_thms (n::[]) thm = [(n, thm)]
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   186
      | mk_unfold_thms (n::ns) thm = let
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   187
          val thmL = thm RS @{thm Pair_eqD1};
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   188
          val thmR = thm RS @{thm Pair_eqD2};
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   189
        in (n, thmL) :: mk_unfold_thms ns thmR end;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   190
    val unfold_binds = map (Binding.suffix_name "_unfold") binds;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   191
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   192
    (* register unfold theorems *)
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   193
    val (unfold_thms, thy) =
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   194
      (Global_Theory.add_thms o map (Thm.no_attributes o apsnd Drule.zero_var_indexes))
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   195
        (mk_unfold_thms unfold_binds tuple_unfold_thm) thy;
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   196
  in
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   197
    ((proj_thms, unfold_thms), thy)
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   198
  end;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   199
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   200
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   201
(******************************************************************************)
33790
b2ff505e30f8 replace defl_tab and map_tab with theory data
huffman
parents: 33789
diff changeset
   202
(****************** deflation combinators and map functions *******************)
b2ff505e30f8 replace defl_tab and map_tab with theory data
huffman
parents: 33789
diff changeset
   203
(******************************************************************************)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   204
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   205
fun defl_of_typ
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   206
    (thy : theory)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   207
    (tab1 : (typ * term) list)
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   208
    (tab2 : (typ * term) list)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   209
    (T : typ) : term =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   210
  let
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   211
    val defl_simps = RepData.get (ProofContext.init_global thy);
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   212
    val rules = map (Thm.concl_of #> HOLogic.dest_Trueprop #> HOLogic.dest_eq) defl_simps;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   213
    val rules' = map (apfst mk_DEFL) tab1 @ map (apfst mk_LIFTDEFL) tab2;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   214
    fun proc1 t =
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   215
      (case dest_DEFL t of
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   216
        TFree (a, _) => SOME (Free ("d" ^ Library.unprefix "'" a, deflT))
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   217
      | _ => NONE) handle TERM _ => NONE;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   218
    fun proc2 t =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   219
      (case dest_LIFTDEFL t of
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   220
        TFree (a, _) => SOME (Free ("p" ^ Library.unprefix "'" a, deflT))
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   221
      | _ => NONE) handle TERM _ => NONE;
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   222
  in
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   223
    Pattern.rewrite_term thy (rules @ rules') [proc1, proc2] (mk_DEFL T)
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   224
  end;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   225
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   226
(******************************************************************************)
35477
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   227
(********************* declaring definitions and theorems *********************)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   228
(******************************************************************************)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   229
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   230
fun define_const
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   231
    (bind : binding, rhs : term)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   232
    (thy : theory)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   233
    : (term * thm) * theory =
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   234
  let
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   235
    val typ = Term.fastype_of rhs;
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   236
    val (const, thy) = Sign.declare_const ((bind, typ), NoSyn) thy;
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   237
    val eqn = Logic.mk_equals (const, rhs);
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   238
    val def = Thm.no_attributes (Binding.suffix_name "_def" bind, eqn);
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   239
    val (def_thm, thy) = yield_singleton (Global_Theory.add_defs false) def thy;
35477
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   240
  in
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   241
    ((const, def_thm), thy)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   242
  end;
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   243
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   244
fun add_qualified_thm name (dbind, thm) =
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   245
    yield_singleton Global_Theory.add_thms
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   246
      ((Binding.qualified true name dbind, thm), []);
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   247
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   248
(******************************************************************************)
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   249
(*************************** defining map functions ***************************)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   250
(******************************************************************************)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   251
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   252
fun define_map_functions
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   253
    (spec : (binding * Domain_Take_Proofs.iso_info) list)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   254
    (thy : theory) =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   255
  let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   256
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   257
    (* retrieve components of spec *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   258
    val dbinds = map fst spec;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   259
    val iso_infos = map snd spec;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   260
    val dom_eqns = map (fn x => (#absT x, #repT x)) iso_infos;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   261
    val rep_abs_consts = map (fn x => (#rep_const x, #abs_const x)) iso_infos;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   262
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   263
    fun mapT (T as Type (_, Ts)) =
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   264
        (map (fn T => T ->> T) (filter (is_cpo thy) Ts)) -->> (T ->> T)
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   265
      | mapT T = T ->> T;
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   266
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   267
    (* declare map functions *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   268
    fun declare_map_const (tbind, (lhsT, rhsT)) thy =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   269
      let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   270
        val map_type = mapT lhsT;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   271
        val map_bind = Binding.suffix_name "_map" tbind;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   272
      in
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   273
        Sign.declare_const ((map_bind, map_type), NoSyn) thy
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   274
      end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   275
    val (map_consts, thy) = thy |>
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   276
      fold_map declare_map_const (dbinds ~~ dom_eqns);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   277
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   278
    (* defining equations for map functions *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   279
    local
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   280
      fun unprime a = Library.unprefix "'" a;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   281
      fun mapvar T = Free (unprime (fst (dest_TFree T)), T ->> T);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   282
      fun map_lhs (map_const, lhsT) =
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   283
          (lhsT, list_ccomb (map_const, map mapvar (filter (is_cpo thy) (snd (dest_Type lhsT)))));
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   284
      val tab1 = map map_lhs (map_consts ~~ map fst dom_eqns);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   285
      val Ts = (snd o dest_Type o fst o hd) dom_eqns;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   286
      val tab = (Ts ~~ map mapvar Ts) @ tab1;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   287
      fun mk_map_spec (((rep_const, abs_const), map_const), (lhsT, rhsT)) =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   288
        let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   289
          val lhs = Domain_Take_Proofs.map_of_typ thy tab lhsT;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   290
          val body = Domain_Take_Proofs.map_of_typ thy tab rhsT;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   291
          val rhs = mk_cfcomp (abs_const, mk_cfcomp (body, rep_const));
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   292
        in mk_eqs (lhs, rhs) end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   293
    in
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   294
      val map_specs =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   295
          map mk_map_spec (rep_abs_consts ~~ map_consts ~~ dom_eqns);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   296
    end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   297
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   298
    (* register recursive definition of map functions *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   299
    val map_binds = map (Binding.suffix_name "_map") dbinds;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   300
    val ((map_apply_thms, map_unfold_thms), thy) =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   301
      add_fixdefs (map_binds ~~ map_specs) thy;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   302
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   303
    (* prove deflation theorems for map functions *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   304
    val deflation_abs_rep_thms = map deflation_abs_rep iso_infos;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   305
    val deflation_map_thm =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   306
      let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   307
        fun unprime a = Library.unprefix "'" a;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   308
        fun mk_f T = Free (unprime (fst (dest_TFree T)), T ->> T);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   309
        fun mk_assm T = mk_trp (mk_deflation (mk_f T));
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   310
        fun mk_goal (map_const, (lhsT, rhsT)) =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   311
          let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   312
            val (_, Ts) = dest_Type lhsT;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   313
            val map_term = list_ccomb (map_const, map mk_f (filter (is_cpo thy) Ts));
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   314
          in mk_deflation map_term end;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   315
        val assms = (map mk_assm o filter (is_cpo thy) o snd o dest_Type o fst o hd) dom_eqns;
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   316
        val goals = map mk_goal (map_consts ~~ dom_eqns);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   317
        val goal = mk_trp (foldr1 HOLogic.mk_conj goals);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   318
        val start_thms =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   319
          @{thm split_def} :: map_apply_thms;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   320
        val adm_rules =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   321
          @{thms adm_conj adm_subst [OF _ adm_deflation]
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   322
                 cont2cont_fst cont2cont_snd cont_id};
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   323
        val bottom_rules =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   324
          @{thms fst_strict snd_strict deflation_UU simp_thms};
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   325
        val deflation_rules =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   326
          @{thms conjI deflation_ID}
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   327
          @ deflation_abs_rep_thms
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   328
          @ Domain_Take_Proofs.get_deflation_thms thy;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   329
      in
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   330
        Goal.prove_global thy [] assms goal (fn {prems, ...} =>
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   331
         EVERY
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   332
          [simp_tac (HOL_basic_ss addsimps start_thms) 1,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   333
           rtac @{thm fix_ind} 1,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   334
           REPEAT (resolve_tac adm_rules 1),
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   335
           simp_tac (HOL_basic_ss addsimps bottom_rules) 1,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   336
           simp_tac beta_ss 1,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   337
           simp_tac (HOL_basic_ss addsimps @{thms fst_conv snd_conv}) 1,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   338
           REPEAT (etac @{thm conjE} 1),
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   339
           REPEAT (resolve_tac (deflation_rules @ prems) 1 ORELSE atac 1)])
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   340
      end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   341
    fun conjuncts [] thm = []
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   342
      | conjuncts (n::[]) thm = [(n, thm)]
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   343
      | conjuncts (n::ns) thm = let
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   344
          val thmL = thm RS @{thm conjunct1};
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   345
          val thmR = thm RS @{thm conjunct2};
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   346
        in (n, thmL):: conjuncts ns thmR end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   347
    val deflation_map_binds = dbinds |>
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   348
        map (Binding.prefix_name "deflation_" o Binding.suffix_name "_map");
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   349
    val (deflation_map_thms, thy) = thy |>
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   350
      (Global_Theory.add_thms o map (Thm.no_attributes o apsnd Drule.zero_var_indexes))
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   351
        (conjuncts deflation_map_binds deflation_map_thm);
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   352
40737
2037021f034f remove map function names from domain package theory data
huffman
parents: 40575
diff changeset
   353
    (* register indirect recursion in theory data *)
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   354
    local
40737
2037021f034f remove map function names from domain package theory data
huffman
parents: 40575
diff changeset
   355
      fun register_map (dname, args) =
2037021f034f remove map function names from domain package theory data
huffman
parents: 40575
diff changeset
   356
        Domain_Take_Proofs.add_rec_type (dname, args);
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   357
      val dnames = map (fst o dest_Type o fst) dom_eqns;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   358
      val map_names = map (fst o dest_Const) map_consts;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   359
      fun args (T, _) = case T of Type (_, Ts) => map (is_cpo thy) Ts | _ => [];
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   360
      val argss = map args dom_eqns;
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   361
    in
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   362
      val thy =
40737
2037021f034f remove map function names from domain package theory data
huffman
parents: 40575
diff changeset
   363
          fold register_map (dnames ~~ argss) thy;
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   364
    end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   365
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   366
    (* register deflation theorems *)
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   367
    val thy = fold Domain_Take_Proofs.add_deflation_thm deflation_map_thms thy;
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   368
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   369
    val result =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   370
      {
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   371
        map_consts = map_consts,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   372
        map_apply_thms = map_apply_thms,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   373
        map_unfold_thms = map_unfold_thms,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   374
        deflation_map_thms = deflation_map_thms
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   375
      }
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   376
  in
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   377
    (result, thy)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   378
  end;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   379
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   380
(******************************************************************************)
35477
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   381
(******************************* main function ********************************)
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   382
(******************************************************************************)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   383
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   384
fun read_typ thy str sorts =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   385
  let
36610
bafd82950e24 renamed ProofContext.init to ProofContext.init_global to emphasize that this is not the real thing;
wenzelm
parents: 36241
diff changeset
   386
    val ctxt = ProofContext.init_global thy
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   387
      |> fold (Variable.declare_typ o TFree) sorts;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   388
    val T = Syntax.read_typ ctxt str;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   389
  in (T, Term.add_tfreesT T sorts) end;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   390
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   391
fun cert_typ sign raw_T sorts =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   392
  let
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   393
    val T = Type.no_tvars (Sign.certify_typ sign raw_T)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   394
      handle TYPE (msg, _, _) => error msg;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   395
    val sorts' = Term.add_tfreesT T sorts;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   396
    val _ =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   397
      case duplicates (op =) (map fst sorts') of
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   398
        [] => ()
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   399
      | dups => error ("Inconsistent sort constraints for " ^ commas dups)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   400
  in (T, sorts') end;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   401
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   402
fun gen_domain_isomorphism
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   403
    (prep_typ: theory -> 'a -> (string * sort) list -> typ * (string * sort) list)
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   404
    (doms_raw: (string list * binding * mixfix * 'a * (binding * binding) option) list)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   405
    (thy: theory)
35657
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
   406
    : (Domain_Take_Proofs.iso_info list
0537c34c6067 pass take_induct_info as an argument to comp_theorems
huffman
parents: 35654
diff changeset
   407
       * Domain_Take_Proofs.take_induct_info) * theory =
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   408
  let
40510
638943ad5bdc update Theory.requires with new theory name
huffman
parents: 40497
diff changeset
   409
    val _ = Theory.requires thy "Domain" "domain isomorphisms";
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   410
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   411
    (* this theory is used just for parsing *)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   412
    val tmp_thy = thy |>
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   413
      Theory.copy |>
40486
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   414
      Sign.add_types (map (fn (tvs, tbind, mx, _, morphs) =>
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   415
        (tbind, length tvs, mx)) doms_raw);
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   416
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   417
    fun prep_dom thy (vs, t, mx, typ_raw, morphs) sorts =
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   418
      let val (typ, sorts') = prep_typ thy typ_raw sorts
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   419
      in ((vs, t, mx, typ, morphs), sorts') end;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   420
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   421
    val (doms : (string list * binding * mixfix * typ * (binding * binding) option) list,
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   422
         sorts : (string * sort) list) =
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   423
      fold_map (prep_dom tmp_thy) doms_raw [];
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   424
40486
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   425
    (* lookup function for sorts of type variables *)
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   426
    fun the_sort v = the (AList.lookup (op =) sorts v);
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   427
40490
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   428
    (* declare arities in temporary theory *)
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   429
    val tmp_thy =
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   430
      let
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   431
        fun arity (vs, tbind, mx, _, _) =
40497
d2e876d6da8c rename class 'bifinite' to 'domain'
huffman
parents: 40494
diff changeset
   432
          (Sign.full_name thy tbind, map the_sort vs, @{sort "domain"});
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   433
      in
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   434
        fold AxClass.axiomatize_arity (map arity doms) tmp_thy
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   435
      end;
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   436
40490
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   437
    (* check bifiniteness of right-hand sides *)
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   438
    fun check_rhs (vs, tbind, mx, rhs, morphs) =
40497
d2e876d6da8c rename class 'bifinite' to 'domain'
huffman
parents: 40494
diff changeset
   439
      if Sign.of_sort tmp_thy (rhs, @{sort "domain"}) then ()
d2e876d6da8c rename class 'bifinite' to 'domain'
huffman
parents: 40494
diff changeset
   440
      else error ("Type not of sort domain: " ^
40490
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   441
        quote (Syntax.string_of_typ_global tmp_thy rhs));
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   442
    val _ = map check_rhs doms;
05be0c37db1d add bifiniteness check for domain_isomorphism command
huffman
parents: 40489
diff changeset
   443
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   444
    (* domain equations *)
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   445
    fun mk_dom_eqn (vs, tbind, mx, rhs, morphs) =
40486
0f2ae76c2e1d add function the_sort
huffman
parents: 40327
diff changeset
   446
      let fun arg v = TFree (v, the_sort v);
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   447
      in (Type (Sign.full_name tmp_thy tbind, map arg vs), rhs) end;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   448
    val dom_eqns = map mk_dom_eqn doms;
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   449
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   450
    (* check for valid type parameters *)
35474
7675a41e755a get rid of incomplete pattern match warnings
huffman
parents: 35467
diff changeset
   451
    val (tyvars, _, _, _, _) = hd doms;
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   452
    val new_doms = map (fn (tvs, tname, mx, _, _) =>
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   453
      let val full_tname = Sign.full_name tmp_thy tname
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   454
      in
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   455
        (case duplicates (op =) tvs of
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   456
          [] =>
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   457
            if eq_set (op =) (tyvars, tvs) then (full_tname, tvs)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   458
            else error ("Mutually recursive domains must have same type parameters")
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   459
        | dups => error ("Duplicate parameter(s) for domain " ^ quote (Binding.str_of tname) ^
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   460
            " : " ^ commas dups))
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   461
      end) doms;
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   462
    val dbinds = map (fn (_, dbind, _, _, _) => dbind) doms;
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   463
    val morphs = map (fn (_, _, _, _, morphs) => morphs) doms;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   464
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   465
    (* determine deflation combinator arguments *)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   466
    val lhsTs : typ list = map fst dom_eqns;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   467
    val defl_rec = Free ("t", mk_tupleT (map (K deflT) lhsTs));
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   468
    val defl_recs = mk_projs lhsTs defl_rec;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   469
    val defl_recs' = map (apsnd mk_u_defl) defl_recs;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   470
    fun defl_body (_, _, _, rhsT, _) =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   471
      defl_of_typ tmp_thy defl_recs defl_recs' rhsT;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   472
    val functional = Term.lambda defl_rec (mk_tuple (map defl_body doms));
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   473
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   474
    val tfrees = map fst (Term.add_tfrees functional []);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   475
    val frees = map fst (Term.add_frees functional []);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   476
    fun get_defl_flags (vs, _, _, _, _) =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   477
      let
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   478
        fun argT v = TFree (v, the_sort v);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   479
        fun mk_d v = "d" ^ Library.unprefix "'" v;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   480
        fun mk_p v = "p" ^ Library.unprefix "'" v;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   481
        val args = maps (fn v => [(mk_d v, mk_DEFL (argT v)), (mk_p v, mk_LIFTDEFL (argT v))]) vs;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   482
        val typeTs = map argT (filter (member (op =) tfrees) vs);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   483
        val defl_args = map snd (filter (member (op =) frees o fst) args);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   484
      in
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   485
        (typeTs, defl_args)
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   486
      end;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   487
    val defl_flagss = map get_defl_flags doms;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   488
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33782
diff changeset
   489
    (* declare deflation combinator constants *)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   490
    fun declare_defl_const ((typeTs, defl_args), (_, tbind, _, _, _)) thy =
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   491
      let
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33782
diff changeset
   492
        val defl_bind = Binding.suffix_name "_defl" tbind;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   493
        val defl_type =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   494
          map Term.itselfT typeTs ---> map (K deflT) defl_args -->> deflT;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   495
      in
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33782
diff changeset
   496
        Sign.declare_const ((defl_bind, defl_type), NoSyn) thy
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   497
      end;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   498
    val (defl_consts, thy) =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   499
      fold_map declare_defl_const (defl_flagss ~~ doms) thy;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   500
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   501
    (* defining equations for type combinators *)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   502
    fun mk_defl_term (defl_const, (typeTs, defl_args)) =
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   503
      let
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   504
        val type_args = map Logic.mk_type typeTs;
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   505
      in
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   506
        list_ccomb (list_comb (defl_const, type_args), defl_args)
40487
1320a0747974 implement defl_of_typ using Pattern.rewrite_term instead of DeflData theory data
huffman
parents: 40486
diff changeset
   507
      end;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   508
    val defl_terms = map mk_defl_term (defl_consts ~~ defl_flagss);
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   509
    val defl_tab = map fst dom_eqns ~~ defl_terms;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   510
    val defl_tab' = map fst dom_eqns ~~ map mk_u_defl defl_terms;
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   511
    fun mk_defl_spec (lhsT, rhsT) =
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   512
      mk_eqs (defl_of_typ tmp_thy defl_tab defl_tab' lhsT,
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   513
              defl_of_typ tmp_thy defl_tab defl_tab' rhsT);
33775
7a1518c42c56 cleaned up; factored out fixed-point definition code
huffman
parents: 33774
diff changeset
   514
    val defl_specs = map mk_defl_spec dom_eqns;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   515
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33782
diff changeset
   516
    (* register recursive definition of deflation combinators *)
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   517
    val defl_binds = map (Binding.suffix_name "_defl") dbinds;
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   518
    val ((defl_apply_thms, defl_unfold_thms), thy) =
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   519
      add_fixdefs (defl_binds ~~ defl_specs) thy;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   520
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   521
    (* define types using deflation combinators *)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   522
    fun make_repdef ((vs, tbind, mx, _, _), defl) thy =
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   523
      let
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   524
        val spec = (tbind, map (rpair dummyS) vs, mx);
40494
db8a09daba7b add class liftdomain, for bifinite domains where DEFL('a u) = u_defl('a)
huffman
parents: 40492
diff changeset
   525
        val ((_, _, _, {DEFL, liftemb_def, liftprj_def, ...}), thy) =
40575
b9a86f15e763 rename 'repdef' to 'domaindef'
huffman
parents: 40510
diff changeset
   526
          Domaindef.add_domaindef false NONE spec defl NONE thy;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   527
        (* declare domain_defl_simps rules *)
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   528
        val thy = Context.theory_map (RepData.add_thm DEFL) thy;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   529
      in
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   530
        (DEFL, thy)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   531
      end;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   532
    val (DEFL_thms, thy) = fold_map make_repdef (doms ~~ defl_terms) thy;
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   533
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   534
    (* prove DEFL equations *)
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   535
    fun mk_DEFL_eq_thm (lhsT, rhsT) =
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   536
      let
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   537
        val goal = mk_eqs (mk_DEFL lhsT, mk_DEFL rhsT);
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   538
        val DEFL_simps = RepData.get (ProofContext.init_global thy);
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   539
        val tac =
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   540
          rewrite_goals_tac (map mk_meta_eq DEFL_simps)
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   541
          THEN TRY (resolve_tac defl_unfold_thms 1);
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   542
      in
33777
69eae9bca167 get rid of numbers on thy variables
huffman
parents: 33776
diff changeset
   543
        Goal.prove_global thy [] [] goal (K tac)
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   544
      end;
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   545
    val DEFL_eq_thms = map mk_DEFL_eq_thm dom_eqns;
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   546
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   547
    (* register DEFL equations *)
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   548
    val DEFL_eq_binds = map (Binding.prefix_name "DEFL_eq_") dbinds;
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   549
    val (_, thy) = thy |>
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   550
      (Global_Theory.add_thms o map Thm.no_attributes)
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   551
        (DEFL_eq_binds ~~ DEFL_eq_thms);
33776
5048b02c2bbb automate proofs of REP equations
huffman
parents: 33775
diff changeset
   552
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   553
    (* define rep/abs functions *)
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   554
    fun mk_rep_abs ((tbind, morphs), (lhsT, rhsT)) thy =
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   555
      let
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   556
        val rep_bind = Binding.suffix_name "_rep" tbind;
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   557
        val abs_bind = Binding.suffix_name "_abs" tbind;
35477
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   558
        val ((rep_const, rep_def), thy) =
40037
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
   559
            define_const (rep_bind, coerce_const (lhsT, rhsT)) thy;
35477
b972233773dd add function define_const
huffman
parents: 35475
diff changeset
   560
        val ((abs_const, abs_def), thy) =
40037
81e6b89d8f58 eliminate constant 'coerce'; use 'prj oo emb' instead
huffman
parents: 40015
diff changeset
   561
            define_const (abs_bind, coerce_const (rhsT, lhsT)) thy;
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   562
      in
33785
2f2d9eb37084 automate definition of map functions; remove unused code
huffman
parents: 33784
diff changeset
   563
        (((rep_const, abs_const), (rep_def, abs_def)), thy)
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   564
      end;
33785
2f2d9eb37084 automate definition of map functions; remove unused code
huffman
parents: 33784
diff changeset
   565
    val ((rep_abs_consts, rep_abs_defs), thy) = thy
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   566
      |> fold_map mk_rep_abs (dbinds ~~ morphs ~~ dom_eqns)
33785
2f2d9eb37084 automate definition of map functions; remove unused code
huffman
parents: 33784
diff changeset
   567
      |>> ListPair.unzip;
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   568
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   569
    (* prove isomorphism and isodefl rules *)
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   570
    fun mk_iso_thms ((tbind, DEFL_eq), (rep_def, abs_def)) thy =
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   571
      let
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   572
        fun make thm =
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   573
            Drule.zero_var_indexes (thm OF [DEFL_eq, abs_def, rep_def]);
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   574
        val rep_iso_thm = make @{thm domain_rep_iso};
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   575
        val abs_iso_thm = make @{thm domain_abs_iso};
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   576
        val isodefl_thm = make @{thm isodefl_abs_rep};
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   577
        val thy = thy
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   578
          |> snd o add_qualified_thm "rep_iso" (tbind, rep_iso_thm)
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   579
          |> snd o add_qualified_thm "abs_iso" (tbind, abs_iso_thm)
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   580
          |> snd o add_qualified_thm "isodefl_abs_rep" (tbind, isodefl_thm);
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   581
      in
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   582
        (((rep_iso_thm, abs_iso_thm), isodefl_thm), thy)
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   583
      end;
35489
dd02201d95b6 add function define_take_functions
huffman
parents: 35480
diff changeset
   584
    val ((iso_thms, isodefl_abs_rep_thms), thy) =
35480
7a1f285cad25 domain_isomorphism package proves deflation rules for map functions
huffman
parents: 35479
diff changeset
   585
      thy
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   586
      |> fold_map mk_iso_thms (dbinds ~~ DEFL_eq_thms ~~ rep_abs_defs)
33782
cdb3ca1a765d prove isomorphism and isodefl rules
huffman
parents: 33778
diff changeset
   587
      |>> ListPair.unzip;
33778
9121ea165a40 automate definition of rep/abs functions
huffman
parents: 33777
diff changeset
   588
35467
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   589
    (* collect info about rep/abs *)
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
   590
    val iso_infos : Domain_Take_Proofs.iso_info list =
35467
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   591
      let
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   592
        fun mk_info (((lhsT, rhsT), (repC, absC)), (rep_iso, abs_iso)) =
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   593
          {
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   594
            repT = rhsT,
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   595
            absT = lhsT,
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   596
            rep_const = repC,
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   597
            abs_const = absC,
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   598
            rep_inverse = rep_iso,
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   599
            abs_inverse = abs_iso
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   600
          };
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   601
      in
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   602
        map mk_info (dom_eqns ~~ rep_abs_consts ~~ iso_thms)
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   603
      end
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   604
35791
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   605
    (* definitions and proofs related to map functions *)
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   606
    val (map_info, thy) =
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   607
        define_map_functions (dbinds ~~ iso_infos) thy;
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   608
    val { map_consts, map_apply_thms, map_unfold_thms,
dc175fe29326 separate map-related code into new function define_map_functions
huffman
parents: 35773
diff changeset
   609
          deflation_map_thms } = map_info;
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   610
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   611
    (* prove isodefl rules for map functions *)
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   612
    val isodefl_thm =
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   613
      let
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   614
        fun unprime a = Library.unprefix "'" a;
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   615
        fun mk_d T = Free ("d" ^ unprime (fst (dest_TFree T)), deflT);
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   616
        fun mk_p T = Free ("p" ^ unprime (fst (dest_TFree T)), deflT);
35474
7675a41e755a get rid of incomplete pattern match warnings
huffman
parents: 35467
diff changeset
   617
        fun mk_f T = Free ("f" ^ unprime (fst (dest_TFree T)), T ->> T);
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   618
        fun mk_assm t =
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   619
          case try dest_LIFTDEFL t of
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   620
            SOME T => mk_trp (isodefl_const (mk_upT T) $ mk_u_map (mk_f T) $ mk_p T)
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   621
          | NONE =>
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   622
            let val T = dest_DEFL t
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   623
            in mk_trp (isodefl_const T $ mk_f T $ mk_d T) end;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   624
        fun mk_goal (map_const, (T, rhsT)) =
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   625
          let
35474
7675a41e755a get rid of incomplete pattern match warnings
huffman
parents: 35467
diff changeset
   626
            val (_, Ts) = dest_Type T;
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   627
            val map_term = list_ccomb (map_const, map mk_f (filter (is_cpo thy) Ts));
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   628
            val defl_term = defl_of_typ thy (Ts ~~ map mk_d Ts) (Ts ~~ map mk_p Ts) T;
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   629
          in isodefl_const T $ map_term $ defl_term end;
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   630
        val assms = (map mk_assm o snd o hd) defl_flagss;
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   631
        val goals = map mk_goal (map_consts ~~ dom_eqns);
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   632
        val goal = mk_trp (foldr1 HOLogic.mk_conj goals);
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   633
        val start_thms =
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   634
          @{thm split_def} :: defl_apply_thms @ map_apply_thms;
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   635
        val adm_rules =
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   636
          @{thms adm_conj adm_isodefl cont2cont_fst cont2cont_snd cont_id};
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   637
        val bottom_rules =
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   638
          @{thms fst_strict snd_strict isodefl_bottom simp_thms};
40492
e380754e8a09 adapt isodefl proof script to unpointed types
huffman
parents: 40491
diff changeset
   639
        val map_ID_thms = Domain_Take_Proofs.get_map_ID_thms thy;
e380754e8a09 adapt isodefl proof script to unpointed types
huffman
parents: 40491
diff changeset
   640
        val map_ID_simps = map (fn th => th RS sym) map_ID_thms;
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   641
        val isodefl_rules =
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   642
          @{thms conjI isodefl_ID_DEFL isodefl_LIFTDEFL}
33791
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
   643
          @ isodefl_abs_rep_thms
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   644
          @ IsodeflData.get (ProofContext.init_global thy);
33845
91f3fc0364cf made SML/NJ happy;
wenzelm
parents: 33809
diff changeset
   645
      in
91f3fc0364cf made SML/NJ happy;
wenzelm
parents: 33809
diff changeset
   646
        Goal.prove_global thy [] assms goal (fn {prems, ...} =>
91f3fc0364cf made SML/NJ happy;
wenzelm
parents: 33809
diff changeset
   647
         EVERY
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   648
          [simp_tac (HOL_basic_ss addsimps start_thms) 1,
33791
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
   649
           (* FIXME: how reliable is unification here? *)
fef59343b4b3 use theory data for REP_simps and isodefl_rules
huffman
parents: 33790
diff changeset
   650
           (* Maybe I should instantiate the rule. *)
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   651
           rtac @{thm parallel_fix_ind} 1,
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   652
           REPEAT (resolve_tac adm_rules 1),
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   653
           simp_tac (HOL_basic_ss addsimps bottom_rules) 1,
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   654
           simp_tac beta_ss 1,
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   655
           simp_tac (HOL_basic_ss addsimps @{thms fst_conv snd_conv}) 1,
40492
e380754e8a09 adapt isodefl proof script to unpointed types
huffman
parents: 40491
diff changeset
   656
           simp_tac (HOL_basic_ss addsimps map_ID_simps) 1,
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   657
           REPEAT (etac @{thm conjE} 1),
33845
91f3fc0364cf made SML/NJ happy;
wenzelm
parents: 33809
diff changeset
   658
           REPEAT (resolve_tac (isodefl_rules @ prems) 1 ORELSE atac 1)])
33788
481bc899febf automate isodefl proof
huffman
parents: 33785
diff changeset
   659
      end;
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   660
    val isodefl_binds = map (Binding.prefix_name "isodefl_") dbinds;
33789
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   661
    fun conjuncts [] thm = []
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   662
      | conjuncts (n::[]) thm = [(n, thm)]
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   663
      | conjuncts (n::ns) thm = let
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   664
          val thmL = thm RS @{thm conjunct1};
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   665
          val thmR = thm RS @{thm conjunct2};
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   666
        in (n, thmL):: conjuncts ns thmR end;
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   667
    val (isodefl_thms, thy) = thy |>
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 37744
diff changeset
   668
      (Global_Theory.add_thms o map (Thm.no_attributes o apsnd Drule.zero_var_indexes))
33789
c3fbdff7aed0 separate conjuncts of isodefl theorem
huffman
parents: 33788
diff changeset
   669
        (conjuncts isodefl_binds isodefl_thm);
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   670
    val thy = fold (Context.theory_map o IsodeflData.add_thm) isodefl_thms thy;
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   671
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   672
    (* prove map_ID theorems *)
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   673
    fun prove_map_ID_thm
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   674
        (((map_const, (lhsT, _)), DEFL_thm), isodefl_thm) =
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   675
      let
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   676
        val Ts = snd (dest_Type lhsT);
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   677
        fun is_cpo T = Sign.of_sort thy (T, @{sort cpo});
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   678
        val lhs = list_ccomb (map_const, map mk_ID (filter is_cpo Ts));
35475
979019ab92eb move common functions into new file holcf_library.ML
huffman
parents: 35474
diff changeset
   679
        val goal = mk_eqs (lhs, mk_ID lhsT);
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   680
        val tac = EVERY
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   681
          [rtac @{thm isodefl_DEFL_imp_ID} 1,
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   682
           stac DEFL_thm 1,
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   683
           rtac isodefl_thm 1,
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40490
diff changeset
   684
           REPEAT (resolve_tac @{thms isodefl_ID_DEFL isodefl_LIFTDEFL} 1)];
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   685
      in
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   686
        Goal.prove_global thy [] [] goal (K tac)
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   687
      end;
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   688
    val map_ID_binds = map (Binding.suffix_name "_map_ID") dbinds;
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   689
    val map_ID_thms =
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   690
      map prove_map_ID_thm
39989
ad60d7311f43 renamed type and constant 'sfp' to 'defl'; replaced syntax SFP('a) with DEFL('a)
huffman
parents: 39974
diff changeset
   691
        (map_consts ~~ dom_eqns ~~ DEFL_thms ~~ isodefl_thms);
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   692
    val (_, thy) = thy |>
40489
0f37a553bc1a implement map_of_typ using Pattern.rewrite_term
huffman
parents: 40487
diff changeset
   693
      (Global_Theory.add_thms o map (rpair [Domain_Take_Proofs.map_ID_add]))
33793
5beafabffa07 automate proofs of map_ID theorems
huffman
parents: 33792
diff changeset
   694
        (map_ID_binds ~~ map_ID_thms);
33802
48ce3a1063f2 domain_isomorphism package defines copy functions
huffman
parents: 33801
diff changeset
   695
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   696
    (* definitions and proofs related to take functions *)
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   697
    val (take_info, thy) =
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35498
diff changeset
   698
        Domain_Take_Proofs.define_take_functions
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   699
          (dbinds ~~ iso_infos) thy;
40015
2fda96749081 add take_strict_thms field to take_info type
huffman
parents: 39989
diff changeset
   700
    val { take_consts, chain_take_thms, take_0_thms, take_Suc_thms, ...} =
2fda96749081 add take_strict_thms field to take_info type
huffman
parents: 39989
diff changeset
   701
        take_info;
33807
ce8d2e8bca21 domain_isomorphism package defines combined copy function
huffman
parents: 33802
diff changeset
   702
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   703
    (* least-upper-bound lemma for take functions *)
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   704
    val lub_take_lemma =
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   705
      let
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   706
        val lhs = mk_tuple (map mk_lub take_consts);
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   707
        fun is_cpo T = Sign.of_sort thy (T, @{sort cpo});
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   708
        fun mk_map_ID (map_const, (lhsT, rhsT)) =
40218
f7d4d023a899 make domain package work with non-cpo argument types
huffman
parents: 40216
diff changeset
   709
          list_ccomb (map_const, map mk_ID (filter is_cpo (snd (dest_Type lhsT))));
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   710
        val rhs = mk_tuple (map mk_map_ID (map_consts ~~ dom_eqns));
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   711
        val goal = mk_trp (mk_eq (lhs, rhs));
40489
0f37a553bc1a implement map_of_typ using Pattern.rewrite_term
huffman
parents: 40487
diff changeset
   712
        val map_ID_thms = Domain_Take_Proofs.get_map_ID_thms thy;
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   713
        val start_rules =
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40737
diff changeset
   714
            @{thms lub_Pair [symmetric] ch2ch_Pair} @ chain_take_thms
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   715
            @ @{thms pair_collapse split_def}
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 40037
diff changeset
   716
            @ map_apply_thms @ map_ID_thms;
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   717
        val rules0 =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   718
            @{thms iterate_0 Pair_strict} @ take_0_thms;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   719
        val rules1 =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   720
            @{thms iterate_Suc Pair_fst_snd_eq fst_conv snd_conv}
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   721
            @ take_Suc_thms;
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   722
        val tac =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   723
            EVERY
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   724
            [simp_tac (HOL_basic_ss addsimps start_rules) 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   725
             simp_tac (HOL_basic_ss addsimps @{thms fix_def2}) 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   726
             rtac @{thm lub_eq} 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   727
             rtac @{thm nat.induct} 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   728
             simp_tac (HOL_basic_ss addsimps rules0) 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   729
             asm_full_simp_tac (beta_ss addsimps rules1) 1];
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   730
      in
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   731
        Goal.prove_global thy [] [] goal (K tac)
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   732
      end;
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   733
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   734
    (* prove lub of take equals ID *)
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   735
    fun prove_lub_take (((dbind, take_const), map_ID_thm), (lhsT, rhsT)) thy =
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   736
      let
35557
5da670d57118 uniformly use variable names m and n in take-related lemmas; use export_without_context where appropriate
huffman
parents: 35555
diff changeset
   737
        val n = Free ("n", natT);
5da670d57118 uniformly use variable names m and n in take-related lemmas; use export_without_context where appropriate
huffman
parents: 35555
diff changeset
   738
        val goal = mk_eqs (mk_lub (lambda n (take_const $ n)), mk_ID lhsT);
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   739
        val tac =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   740
            EVERY
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   741
            [rtac @{thm trans} 1, rtac map_ID_thm 2,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   742
             cut_facts_tac [lub_take_lemma] 1,
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   743
             REPEAT (etac @{thm Pair_inject} 1), atac 1];
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   744
        val lub_take_thm = Goal.prove_global thy [] [] goal (K tac);
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   745
      in
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   746
        add_qualified_thm "lub_take" (dbind, lub_take_thm) thy
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   747
      end;
35494
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   748
    val (lub_take_thms, thy) =
45c9a8278faf domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents: 35490
diff changeset
   749
        fold_map prove_lub_take
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   750
          (dbinds ~~ take_consts ~~ map_ID_thms ~~ dom_eqns) thy;
33809
033831fd9ef3 store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents: 33807
diff changeset
   751
35654
7a15e181bf3b move proofs of reach and take lemmas to domain_take_proofs.ML
huffman
parents: 35640
diff changeset
   752
    (* prove additional take theorems *)
7a15e181bf3b move proofs of reach and take lemmas to domain_take_proofs.ML
huffman
parents: 35640
diff changeset
   753
    val (take_info2, thy) =
7a15e181bf3b move proofs of reach and take lemmas to domain_take_proofs.ML
huffman
parents: 35640
diff changeset
   754
        Domain_Take_Proofs.add_lub_take_theorems
35773
cae4f840d15d more consistent use of qualified bindings
huffman
parents: 35659
diff changeset
   755
          (dbinds ~~ iso_infos) take_info lub_take_thms thy;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   756
  in
35659
a78bc1930a7a include take_info within take_induct_info type
huffman
parents: 35658
diff changeset
   757
    ((iso_infos, take_info2), thy)
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   758
  end;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   759
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   760
val domain_isomorphism = gen_domain_isomorphism cert_typ;
35467
561d8e98d9d3 domain_isomorphism function returns iso_info record
huffman
parents: 35021
diff changeset
   761
val domain_isomorphism_cmd = snd oo gen_domain_isomorphism read_typ;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   762
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   763
(******************************************************************************)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   764
(******************************** outer syntax ********************************)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   765
(******************************************************************************)
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   766
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   767
local
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   768
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   769
val parse_domain_iso :
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   770
    (string list * binding * mixfix * string * (binding * binding) option)
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   771
      parser =
36960
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36610
diff changeset
   772
  (Parse.type_args -- Parse.binding -- Parse.opt_mixfix -- (Parse.$$$ "=" |-- Parse.typ) --
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36610
diff changeset
   773
    Scan.option (Parse.$$$ "morphisms" |-- Parse.!!! (Parse.binding -- Parse.binding)))
34149
a0efb4754cb7 add 'morphisms' option to domain_isomorphism command
huffman
parents: 33971
diff changeset
   774
    >> (fn ((((vs, t), mx), rhs), morphs) => (vs, t, mx, rhs, morphs));
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   775
36960
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36610
diff changeset
   776
val parse_domain_isos = Parse.and_list1 parse_domain_iso;
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   777
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   778
in
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   779
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   780
val _ =
36960
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36610
diff changeset
   781
  Outer_Syntax.command "domain_isomorphism" "define domain isomorphisms (HOLCF)"
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36610
diff changeset
   782
    Keyword.thy_decl
33774
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   783
    (parse_domain_isos >> (Toplevel.theory o domain_isomorphism_cmd));
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   784
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   785
end;
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   786
e11e05b32548 automate solution of domain equations
huffman
parents:
diff changeset
   787
end;