src/HOL/BNF/Tools/bnf_comp_tactics.ML
author blanchet
Fri, 21 Sep 2012 17:02:23 +0200
changeset 49512 82d99fe04018
parent 49510 ba50d204095e
child 49585 5c4a12550491
permissions -rw-r--r--
clean up lemmas used for composition
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49509
163914705f8d renamed top-level theory from "Codatatype" to "BNF"
blanchet
parents: 49506
diff changeset
     1
(*  Title:      HOL/BNF/Tools/bnf_comp_tactics.ML
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     3
    Author:     Jasmin Blanchette, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     4
    Copyright   2012
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     5
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     6
Tactics for composition of bounded natural functors.
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     7
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     8
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
signature BNF_COMP_TACTICS =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    10
sig
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    11
  val mk_comp_bd_card_order_tac: thm list -> thm -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    12
  val mk_comp_bd_cinfinite_tac: thm -> thm -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    13
  val mk_comp_in_alt_tac: Proof.context -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    14
  val mk_comp_in_bd_tac: thm -> thm list -> thm -> thm list -> thm -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    15
  val mk_comp_map_comp_tac: thm -> thm -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    16
  val mk_comp_map_cong_tac: thm list -> thm -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    17
  val mk_comp_set_alt_tac: Proof.context -> thm -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    18
  val mk_comp_set_bd_tac: Proof.context -> thm -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    19
  val mk_comp_set_natural_tac: thm -> thm -> thm -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    20
  val mk_comp_wit_tac: Proof.context -> thm list -> thm -> thm list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    21
49304
blanchet
parents: 49284
diff changeset
    22
  val mk_kill_bd_card_order_tac: int -> thm -> tactic
blanchet
parents: 49284
diff changeset
    23
  val mk_kill_bd_cinfinite_tac: thm -> tactic
blanchet
parents: 49284
diff changeset
    24
  val kill_in_alt_tac: tactic
blanchet
parents: 49284
diff changeset
    25
  val mk_kill_in_bd_tac: int -> bool -> thm -> thm -> thm -> thm -> thm -> tactic
blanchet
parents: 49284
diff changeset
    26
  val mk_kill_map_cong_tac: Proof.context -> int -> int -> thm -> tactic
blanchet
parents: 49284
diff changeset
    27
  val mk_kill_set_bd_tac: thm -> thm -> tactic
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    28
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    29
  val empty_natural_tac: tactic
49304
blanchet
parents: 49284
diff changeset
    30
  val lift_in_alt_tac: tactic
blanchet
parents: 49284
diff changeset
    31
  val mk_lift_in_bd_tac: int -> thm -> thm -> thm -> tactic
blanchet
parents: 49284
diff changeset
    32
  val mk_lift_set_bd_tac: thm -> tactic
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    33
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    34
  val mk_permute_in_alt_tac: ''a list -> ''a list -> tactic
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    35
  val mk_permute_in_bd_tac: ''a list -> ''a list -> thm -> thm -> thm -> tactic
49284
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
    36
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
    37
  val mk_map_wpull_tac: thm -> thm list -> thm -> tactic
49506
aeb0cc8889f2 renamed "rel" to "srel"
blanchet
parents: 49504
diff changeset
    38
  val mk_simple_srel_O_Gr_tac: Proof.context -> thm -> thm -> thm -> tactic
49284
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
    39
  val mk_simple_wit_tac: thm list -> tactic
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    40
end;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    41
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    42
structure BNF_Comp_Tactics : BNF_COMP_TACTICS =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    43
struct
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    44
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    45
open BNF_Util
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    46
open BNF_Tactics
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    47
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    48
val Card_order_csum = @{thm Card_order_csum};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    49
val Card_order_ctwo = @{thm Card_order_ctwo};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    50
val Cnotzero_UNIV = @{thm Cnotzero_UNIV};
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    51
val arg_cong_Union = @{thm arg_cong[of _ _ Union]};
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    52
val card_of_Card_order = @{thm card_of_Card_order};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    53
val csum_Cnotzero1 = @{thm csum_Cnotzero1};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    54
val csum_Cnotzero2 = @{thm csum_Cnotzero2};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    55
val ctwo_Cnotzero = @{thm ctwo_Cnotzero};
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    56
val o_eq_dest_lhs = @{thm o_eq_dest_lhs};
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    57
val ordIso_transitive = @{thm ordIso_transitive};
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    58
val ordLeq_csum2 = @{thm ordLeq_csum2};
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    59
val trans_image_cong_o_apply = @{thm trans[OF image_cong[OF o_apply refl]]};
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    60
val trans_o_apply = @{thm trans[OF o_apply]};
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    61
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    62
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    63
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    64
(* Composition *)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    65
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    66
fun mk_comp_set_alt_tac ctxt collect_set_natural =
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
    67
  unfold_thms_tac ctxt @{thms sym[OF o_assoc]} THEN
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
    68
  unfold_thms_tac ctxt [collect_set_natural RS sym] THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    69
  rtac refl 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    70
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    71
fun mk_comp_map_comp_tac Gmap_comp Gmap_cong map_comps =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    72
  EVERY' ([rtac ext, rtac sym, rtac trans_o_apply,
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    73
    rtac (Gmap_comp RS sym RS o_eq_dest_lhs RS trans), rtac Gmap_cong] @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    74
    map (fn thm => rtac (thm RS sym RS fun_cong)) map_comps) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    75
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    76
fun mk_comp_set_natural_tac Gmap_comp Gmap_cong Gset_natural set_naturals =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    77
  EVERY' ([rtac ext] @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    78
    replicate 3 (rtac trans_o_apply) @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    79
    [rtac (arg_cong_Union RS trans),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    80
     rtac (@{thm arg_cong2[of _ _ _ _ collect, OF refl]} RS trans),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    81
     rtac (Gmap_comp RS sym RS o_eq_dest_lhs RS trans),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    82
     rtac Gmap_cong] @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    83
     map (fn thm => rtac (thm RS fun_cong)) set_naturals @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    84
     [rtac (Gset_natural RS o_eq_dest_lhs), rtac sym, rtac trans_o_apply,
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    85
     rtac trans_image_cong_o_apply, rtac trans_image_cong_o_apply,
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    86
     rtac (@{thm image_cong} OF [Gset_natural RS o_eq_dest_lhs RS arg_cong_Union, refl] RS trans),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    87
     rtac @{thm trans[OF pointfreeE[OF Union_natural[symmetric]]]}, rtac arg_cong_Union,
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    88
     rtac @{thm trans[OF o_eq_dest_lhs[OF image_o_collect[symmetric]]]},
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    89
     rtac @{thm fun_cong[OF arg_cong[of _ _ collect]]}] @
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    90
     [REPEAT_DETERM_N (length set_naturals) o EVERY' [rtac @{thm trans[OF image_insert]},
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    91
        rtac @{thm arg_cong2[of _ _ _ _ insert]}, rtac ext, rtac trans_o_apply,
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
    92
        rtac trans_image_cong_o_apply, rtac @{thm trans[OF image_image]},
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    93
        rtac @{thm sym[OF trans[OF o_apply]]}, rtac @{thm image_cong[OF refl o_apply]}],
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    94
     rtac @{thm image_empty}]) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    95
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    96
fun mk_comp_map_cong_tac comp_set_alts map_cong map_congs =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    97
  let
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    98
     val n = length comp_set_alts;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    99
  in
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   100
    (if n = 0 then rtac refl 1
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   101
    else rtac map_cong 1 THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   102
      EVERY' (map_index (fn (i, map_cong) =>
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   103
        rtac map_cong THEN' EVERY' (map_index (fn (k, set_alt) =>
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   104
          EVERY' [select_prem_tac n (dtac @{thm meta_spec}) (k + 1), etac @{thm meta_mp},
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   105
            rtac (equalityD2 RS set_mp), rtac (set_alt RS fun_cong RS trans),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   106
            rtac trans_o_apply, rtac (@{thm collect_def} RS arg_cong_Union),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   107
            rtac @{thm UnionI}, rtac @{thm UN_I}, REPEAT_DETERM_N i o rtac @{thm insertI2},
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   108
            rtac @{thm insertI1}, rtac (o_apply RS equalityD2 RS set_mp),
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   109
            etac @{thm imageI}, atac])
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   110
          comp_set_alts))
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   111
      map_congs) 1)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   112
  end;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   113
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   114
fun mk_comp_bd_card_order_tac Fbd_card_orders Gbd_card_order =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   115
  let
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   116
    val (card_orders, last_card_order) = split_last Fbd_card_orders;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   117
    fun gen_before thm = rtac @{thm card_order_csum} THEN' rtac thm;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   118
  in
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   119
    (rtac @{thm card_order_cprod} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   120
    WRAP' gen_before (K (K all_tac)) card_orders (rtac last_card_order) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   121
    rtac Gbd_card_order) 1
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   122
  end;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   123
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   124
fun mk_comp_bd_cinfinite_tac Fbd_cinfinite Gbd_cinfinite =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   125
  (rtac @{thm cinfinite_cprod} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   126
   ((K (TRY ((rtac @{thm cinfinite_csum} THEN' rtac disjI1) 1)) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   127
     ((rtac @{thm cinfinite_csum} THEN' rtac disjI1 THEN' rtac Fbd_cinfinite) ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   128
      rtac Fbd_cinfinite)) ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   129
    rtac Fbd_cinfinite) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   130
   rtac Gbd_cinfinite) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   131
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   132
fun mk_comp_set_bd_tac ctxt comp_set_alt Gset_Fset_bds =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   133
  let
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   134
    val (bds, last_bd) = split_last Gset_Fset_bds;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   135
    fun gen_before bd =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   136
      rtac ctrans THEN' rtac @{thm Un_csum} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   137
      rtac ctrans THEN' rtac @{thm csum_mono} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   138
      rtac bd;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   139
    fun gen_after _ = rtac @{thm ordIso_imp_ordLeq} THEN' rtac @{thm cprod_csum_distrib1};
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   140
  in
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   141
    unfold_thms_tac ctxt [comp_set_alt] THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   142
    rtac @{thm comp_set_bd_Union_o_collect} 1 THEN
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   143
    unfold_thms_tac ctxt @{thms Union_image_insert Union_image_empty Union_Un_distrib o_apply} THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   144
    (rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   145
     WRAP' gen_before gen_after bds (rtac last_bd) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   146
     rtac @{thm ordIso_imp_ordLeq} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   147
     rtac @{thm cprod_com}) 1
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   148
  end;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   149
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   150
val comp_in_alt_thms = @{thms o_apply collect_def SUP_def image_insert image_empty Union_insert
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   151
  Union_empty Un_empty_right Union_Un_distrib Un_subset_iff conj_subset_def UN_image_subset
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   152
  conj_assoc};
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   153
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   154
fun mk_comp_in_alt_tac ctxt comp_set_alts =
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   155
  unfold_thms_tac ctxt (comp_set_alts @ comp_in_alt_thms) THEN
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   156
  unfold_thms_tac ctxt @{thms set_eq_subset} THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   157
  rtac conjI 1 THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   158
  REPEAT_DETERM (
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   159
    rtac @{thm subsetI} 1 THEN
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   160
    unfold_thms_tac ctxt @{thms mem_Collect_eq Ball_def} THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   161
    (REPEAT_DETERM (CHANGED (etac conjE 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   162
     REPEAT_DETERM (CHANGED ((
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   163
       (rtac conjI THEN' (atac ORELSE' rtac subset_UNIV)) ORELSE'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   164
       atac ORELSE'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   165
       (rtac subset_UNIV)) 1)) ORELSE rtac subset_UNIV 1));
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   166
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   167
fun mk_comp_in_bd_tac comp_in_alt Fin_bds Gin_bd Fbd_Cinfs Gbd_Card_order =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   168
  let
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   169
    val (bds, last_bd) = split_last Fin_bds;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   170
    val (Cinfs, _) = split_last Fbd_Cinfs;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   171
    fun gen_before (bd, _) = rtac ctrans THEN' rtac @{thm csum_mono} THEN' rtac bd;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   172
    fun gen_after (_, (bd_Cinf, next_bd_Cinf)) =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   173
      TRY o (rtac @{thm csum_cexp} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   174
        rtac bd_Cinf THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   175
        (TRY o (rtac @{thm Cinfinite_csum} THEN' rtac disjI1) THEN' rtac next_bd_Cinf ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   176
           rtac next_bd_Cinf) THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   177
        ((rtac Card_order_csum THEN' rtac ordLeq_csum2) ORELSE'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   178
          (rtac Card_order_ctwo THEN' rtac @{thm ordLeq_refl})) THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   179
        rtac Card_order_ctwo);
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   180
  in
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   181
    (rtac @{thm ordIso_ordLeq_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   182
     rtac @{thm card_of_ordIso_subst} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   183
     rtac comp_in_alt THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   184
     rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   185
     rtac Gin_bd THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   186
     rtac @{thm ordLeq_ordIso_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   187
     rtac @{thm cexp_mono1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   188
     rtac @{thm ordLeq_ordIso_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   189
     rtac @{thm csum_mono1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   190
     WRAP' gen_before gen_after (bds ~~ (Cinfs ~~ tl Fbd_Cinfs)) (rtac last_bd) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   191
     rtac @{thm csum_absorb1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   192
     rtac @{thm Cinfinite_cexp} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   193
     (rtac ordLeq_csum2 ORELSE' rtac @{thm ordLeq_refl}) THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   194
     rtac Card_order_ctwo THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   195
     (TRY o (rtac @{thm Cinfinite_csum} THEN' rtac disjI1) THEN' rtac (hd Fbd_Cinfs) ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   196
       rtac (hd Fbd_Cinfs)) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   197
     rtac @{thm ctwo_ordLeq_Cinfinite} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   198
     rtac @{thm Cinfinite_cexp} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   199
     (rtac ordLeq_csum2 ORELSE' rtac @{thm ordLeq_refl}) THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   200
     rtac Card_order_ctwo THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   201
     (TRY o (rtac @{thm Cinfinite_csum} THEN' rtac disjI1) THEN' rtac (hd Fbd_Cinfs) ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   202
       rtac (hd Fbd_Cinfs)) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   203
     rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   204
     TRY o rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   205
     rtac ctwo_Cnotzero THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   206
     rtac Gbd_Card_order THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   207
     rtac @{thm cexp_cprod} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   208
     TRY o rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   209
     rtac ctwo_Cnotzero) 1
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   210
  end;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   211
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   212
val comp_wit_thms = @{thms Union_empty_conv o_apply collect_def SUP_def
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   213
  Union_image_insert Union_image_empty};
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   214
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   215
fun mk_comp_wit_tac ctxt Gwit_thms collect_set_natural Fwit_thms =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   216
  ALLGOALS (dtac @{thm in_Union_o_assoc}) THEN
49504
df9b897fb254 renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents: 49490
diff changeset
   217
  unfold_thms_tac ctxt (collect_set_natural :: comp_wit_thms) THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   218
  REPEAT_DETERM (
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   219
    atac 1 ORELSE
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   220
    REPEAT_DETERM (eresolve_tac @{thms UnionE UnE imageE} 1) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   221
    (TRY o dresolve_tac Gwit_thms THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   222
    (etac FalseE ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   223
    hyp_subst_tac THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   224
    dresolve_tac Fwit_thms THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   225
    (etac FalseE ORELSE' atac))) 1);
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   226
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   227
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   228
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   229
(* Kill operation *)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   230
49304
blanchet
parents: 49284
diff changeset
   231
fun mk_kill_map_cong_tac ctxt n m map_cong =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   232
  (rtac map_cong THEN' EVERY' (replicate n (rtac refl)) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   233
    EVERY' (replicate m (Goal.assume_rule_tac ctxt))) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   234
49304
blanchet
parents: 49284
diff changeset
   235
fun mk_kill_bd_card_order_tac n bd_card_order =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   236
  (rtac @{thm card_order_cprod} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   237
  K (REPEAT_DETERM_N (n - 1)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   238
    ((rtac @{thm card_order_csum} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   239
    rtac @{thm card_of_card_order_on}) 1)) THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   240
  rtac @{thm card_of_card_order_on} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   241
  rtac bd_card_order) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   242
49304
blanchet
parents: 49284
diff changeset
   243
fun mk_kill_bd_cinfinite_tac bd_Cinfinite =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   244
  (rtac @{thm cinfinite_cprod2} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   245
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   246
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   247
  rtac bd_Cinfinite) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   248
49304
blanchet
parents: 49284
diff changeset
   249
fun mk_kill_set_bd_tac bd_Card_order set_bd =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   250
  (rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   251
  rtac set_bd THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   252
  rtac @{thm ordLeq_cprod2} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   253
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   254
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   255
  rtac bd_Card_order) 1
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   256
49304
blanchet
parents: 49284
diff changeset
   257
val kill_in_alt_tac =
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   258
  ((rtac @{thm Collect_cong} THEN' rtac iffI) 1 THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   259
  REPEAT_DETERM (CHANGED (etac conjE 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   260
  REPEAT_DETERM (CHANGED ((etac conjI ORELSE'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   261
    rtac conjI THEN' rtac subset_UNIV) 1)) THEN
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   262
  (rtac subset_UNIV ORELSE' atac) 1 THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   263
  REPEAT_DETERM (CHANGED (etac conjE 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   264
  REPEAT_DETERM (CHANGED ((etac conjI ORELSE' atac) 1))) ORELSE
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   265
  ((rtac @{thm UNIV_eq_I} THEN' rtac CollectI) 1 THEN
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   266
    REPEAT_DETERM (TRY (rtac conjI 1) THEN rtac subset_UNIV 1));
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   267
49304
blanchet
parents: 49284
diff changeset
   268
fun mk_kill_in_bd_tac n nontrivial_kill_in in_alt in_bd bd_Card_order bd_Cinfinite bd_Cnotzero =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   269
  (rtac @{thm ordIso_ordLeq_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   270
  rtac @{thm card_of_ordIso_subst} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   271
  rtac in_alt THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   272
  rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   273
  rtac in_bd THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   274
  rtac @{thm ordIso_ordLeq_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   275
  rtac @{thm cexp_cong1}) 1 THEN
49304
blanchet
parents: 49284
diff changeset
   276
  (if nontrivial_kill_in then
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   277
    rtac ordIso_transitive 1 THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   278
    REPEAT_DETERM_N (n - 1)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   279
      ((rtac @{thm csum_cong1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   280
      rtac @{thm ordIso_symmetric} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   281
      rtac @{thm csum_assoc} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   282
      rtac ordIso_transitive) 1) THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   283
    (rtac @{thm ordIso_refl} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   284
    rtac Card_order_csum THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   285
    rtac ordIso_transitive THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   286
    rtac @{thm csum_assoc} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   287
    rtac ordIso_transitive THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   288
    rtac @{thm csum_cong1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   289
    K (mk_flatten_assoc_tac
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   290
      (rtac @{thm ordIso_refl} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   291
        FIRST' [rtac card_of_Card_order, rtac Card_order_csum])
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   292
      ordIso_transitive @{thm csum_assoc} @{thm csum_cong}) THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   293
    rtac @{thm ordIso_refl} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   294
    (rtac card_of_Card_order ORELSE' rtac Card_order_csum)) 1
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   295
  else all_tac) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   296
  (rtac @{thm csum_com} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   297
  rtac bd_Card_order THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   298
  rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   299
  rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   300
  rtac ctwo_Cnotzero THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   301
  rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   302
  rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   303
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   304
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   305
  rtac @{thm ordLeq_ordIso_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   306
  rtac @{thm cexp_mono1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   307
  rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   308
  rtac @{thm csum_mono2} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   309
  rtac @{thm ordLeq_cprod1} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   310
  (rtac card_of_Card_order ORELSE' rtac Card_order_csum) THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   311
  rtac bd_Cnotzero THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   312
  rtac @{thm csum_cexp'} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   313
  rtac @{thm Cinfinite_cprod2} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   314
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   315
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   316
  rtac bd_Cinfinite THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   317
  ((rtac Card_order_ctwo THEN' rtac @{thm ordLeq_refl}) ORELSE'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   318
    (rtac Card_order_csum THEN' rtac ordLeq_csum2)) THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   319
  rtac Card_order_ctwo THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   320
  rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   321
  rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   322
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   323
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   324
  rtac bd_Card_order THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   325
  rtac @{thm cexp_cprod_ordLeq} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   326
  TRY o rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   327
  rtac ctwo_Cnotzero THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   328
  rtac @{thm Cinfinite_cprod2} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   329
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   330
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   331
  rtac bd_Cinfinite THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   332
  rtac bd_Cnotzero THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   333
  rtac @{thm ordLeq_cprod2} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   334
  TRY o rtac csum_Cnotzero1 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   335
  rtac Cnotzero_UNIV THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   336
  rtac bd_Card_order) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   337
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   338
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   339
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   340
(* Lift operation *)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   341
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   342
val empty_natural_tac = rtac @{thm empty_natural} 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   343
49304
blanchet
parents: 49284
diff changeset
   344
fun mk_lift_set_bd_tac bd_Card_order = (rtac @{thm Card_order_empty} THEN' rtac bd_Card_order) 1;
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   345
49304
blanchet
parents: 49284
diff changeset
   346
val lift_in_alt_tac =
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   347
  ((rtac @{thm Collect_cong} THEN' rtac iffI) 1 THEN
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   348
  REPEAT_DETERM (CHANGED (etac conjE 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   349
  REPEAT_DETERM (CHANGED ((etac conjI ORELSE' atac) 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   350
  REPEAT_DETERM (CHANGED (etac conjE 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   351
  REPEAT_DETERM (CHANGED ((etac conjI ORELSE'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   352
    rtac conjI THEN' rtac @{thm empty_subsetI}) 1)) THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   353
  (rtac @{thm empty_subsetI} ORELSE' atac) 1) ORELSE
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   354
  ((rtac sym THEN' rtac @{thm UNIV_eq_I} THEN' rtac CollectI) 1 THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   355
    REPEAT_DETERM (TRY (rtac conjI 1) THEN rtac @{thm empty_subsetI} 1));
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   356
49304
blanchet
parents: 49284
diff changeset
   357
fun mk_lift_in_bd_tac n in_alt in_bd bd_Card_order =
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   358
  (rtac @{thm ordIso_ordLeq_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   359
  rtac @{thm card_of_ordIso_subst} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   360
  rtac in_alt THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   361
  rtac ctrans THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   362
  rtac in_bd THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   363
  rtac @{thm cexp_mono1}) 1 THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   364
  ((rtac @{thm csum_mono1} 1 THEN
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   365
  REPEAT_DETERM_N (n - 1)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   366
    ((rtac ctrans THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   367
    rtac ordLeq_csum2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   368
    (rtac Card_order_csum ORELSE' rtac card_of_Card_order)) 1) THEN
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   369
  (rtac ordLeq_csum2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   370
  (rtac Card_order_csum ORELSE' rtac card_of_Card_order)) 1) ORELSE
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   371
  (rtac ordLeq_csum2 THEN' rtac Card_order_ctwo) 1) THEN
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   372
  (rtac disjI1 THEN' TRY o rtac csum_Cnotzero2 THEN' rtac ctwo_Cnotzero
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   373
   THEN' rtac bd_Card_order) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   374
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   375
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   376
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   377
(* Permute operation *)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   378
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   379
fun mk_permute_in_alt_tac src dest =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   380
  (rtac @{thm Collect_cong} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   381
  mk_rotate_eq_tac (rtac refl) trans @{thm conj_assoc} @{thm conj_commute} @{thm conj_cong}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   382
    dest src) 1;
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   383
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   384
fun mk_permute_in_bd_tac src dest in_alt in_bd bd_Card_order =
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   385
  (rtac @{thm ordIso_ordLeq_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   386
  rtac @{thm card_of_ordIso_subst} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   387
  rtac in_alt THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   388
  rtac @{thm ordLeq_ordIso_trans} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   389
  rtac in_bd THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   390
  rtac @{thm cexp_cong1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   391
  rtac @{thm csum_cong1} THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   392
  mk_rotate_eq_tac
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   393
    (rtac @{thm ordIso_refl} THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   394
      FIRST' [rtac card_of_Card_order, rtac Card_order_csum])
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   395
    ordIso_transitive @{thm csum_assoc} @{thm csum_com} @{thm csum_cong}
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   396
    src dest THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   397
  rtac bd_Card_order THEN'
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   398
  rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   399
  TRY o rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   400
  rtac ctwo_Cnotzero THEN'
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   401
  rtac disjI1 THEN'
49305
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   402
  TRY o rtac csum_Cnotzero2 THEN'
8241f21d104b tuned antiquotations
blanchet
parents: 49304
diff changeset
   403
  rtac ctwo_Cnotzero) 1;
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   404
49284
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   405
fun mk_map_wpull_tac comp_in_alt inner_map_wpulls outer_map_wpull =
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   406
  (rtac (@{thm wpull_cong} OF (replicate 3 comp_in_alt)) THEN' rtac outer_map_wpull) 1 THEN
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   407
  WRAP (fn thm => rtac thm 1 THEN REPEAT_DETERM (atac 1)) (K all_tac) inner_map_wpulls all_tac THEN
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   408
  TRY (REPEAT_DETERM (atac 1 ORELSE rtac @{thm wpull_id} 1));
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   409
49506
aeb0cc8889f2 renamed "rel" to "srel"
blanchet
parents: 49504
diff changeset
   410
fun mk_simple_srel_O_Gr_tac ctxt srel_def srel_O_Gr in_alt_thm =
aeb0cc8889f2 renamed "rel" to "srel"
blanchet
parents: 49504
diff changeset
   411
  rtac (unfold_thms ctxt [srel_def]
49512
82d99fe04018 clean up lemmas used for composition
blanchet
parents: 49510
diff changeset
   412
    (trans OF [srel_O_Gr, in_alt_thm RS @{thm O_Gr_cong} RS sym])) 1;
49463
83ac281bcdc2 provide predicator, define relator
blanchet
parents: 49305
diff changeset
   413
49284
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   414
fun mk_simple_wit_tac wit_thms = ALLGOALS (atac ORELSE' eresolve_tac (@{thm emptyE} :: wit_thms));
5f39b7940b49 spin off "bnf_def_tactics.ML"
blanchet
parents: 48975
diff changeset
   415
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   416
end;