Quot/Nominal/Perm.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 24 Feb 2010 15:36:07 +0100
changeset 1249 ea6a52a4f5bf
parent 1248 705afaaf6fb4
child 1253 cff8a67691d2
permissions -rw-r--r--
Note the instance proofs, since they can be easily lifted.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory Perm
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     2
imports "Nominal2_Atoms"
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     5
ML {*
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     6
  open Datatype_Aux; (* typ_of_dtyp, DtRec, ... *)
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     7
  fun permute ty = Const (@{const_name permute}, @{typ perm} --> ty --> ty);
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     8
  val minus_perm = Const (@{const_name minus}, @{typ perm} --> @{typ perm});
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
     9
*}
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
ML {*
1248
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    12
fun prove_perm_empty lthy induct perm_def perm_frees =
1247
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    13
let
1248
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    14
  val perm_types = map fastype_of perm_frees;
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    15
  val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types);
1247
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    16
  val gl =
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    17
    HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    18
      (map (fn ((perm, T), x) => HOLogic.mk_eq
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    19
          (perm $ @{term "0 :: perm"} $ Free (x, T),
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    20
           Free (x, T)))
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    21
       (perm_frees ~~
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    22
        map body_type perm_types ~~ perm_indnames)));
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    23
  fun tac _ =
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    24
    EVERY [
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    25
      indtac induct perm_indnames 1,
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    26
      ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_zero} :: perm_def)))
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    27
    ];
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    28
in
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    29
  split_conj_thm (Goal.prove lthy perm_indnames [] gl tac)
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    30
end;
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    31
*}
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    32
1248
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    33
ML {*
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    34
fun prove_perm_append lthy induct perm_def perm_frees =
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    35
let
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    36
  val add_perm = @{term "op + :: (perm \<Rightarrow> perm \<Rightarrow> perm)"}
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    37
  val pi1 = Free ("pi1", @{typ perm});
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    38
  val pi2 = Free ("pi2", @{typ perm});
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    39
  val perm_types = map fastype_of perm_frees
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    40
  val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types);
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    41
  val gl =
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    42
    (HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    43
      (map (fn ((perm, T), x) =>
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    44
          let
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    45
            val lhs = perm $ (add_perm $ pi1 $ pi2) $ Free (x, T)
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    46
            val rhs = perm $ pi1 $ (perm $ pi2 $ Free (x, T))
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    47
          in HOLogic.mk_eq (lhs, rhs)
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    48
          end)
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    49
        (perm_frees ~~ map body_type perm_types ~~ perm_indnames))))
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    50
  fun tac _ =
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    51
    EVERY [
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    52
      indtac induct perm_indnames 1,
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    53
      ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_plus} :: perm_def)))
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    54
    ]
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    55
in
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    56
  split_conj_thm (Goal.prove lthy ("pi1" :: "pi2" :: perm_indnames) [] gl tac)
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    57
end;
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
    58
*}
1247
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    59
a728e199851d Factor-out 'prove_perm_empty'; I plan to use it in defining permutations on the lifted type.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1189
diff changeset
    60
ML {*
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
    61
(* TODO: full_name can be obtained from new_type_names with Datatype *)
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
    62
fun define_raw_perms new_type_names full_tnames thy =
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
    63
let
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
    64
  val {descr, induct, ...} = Datatype.the_info thy (hd full_tnames);
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  (* TODO: [] should be the sorts that we'll take from the specification *)
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  val sorts = [];
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  fun nth_dtyp i = typ_of_dtyp descr sorts (DtRec i);
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  val perm_names' = Datatype_Prop.indexify_names (map (fn (i, _) =>
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
    "permute_" ^ name_of_typ (nth_dtyp i)) descr);
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  val perm_types = map (fn (i, _) =>
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
    let val T = nth_dtyp i
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
    in @{typ perm} --> T --> T end) descr;
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
  val perm_names_types' = perm_names' ~~ perm_types;
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  val pi = Free ("pi", @{typ perm});
1164
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    75
  fun perm_eq_constr i (cname, dts) =
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    76
    let
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    77
      val Ts = map (typ_of_dtyp descr sorts) dts;
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    78
      val names = Name.variant_list ["pi"] (Datatype_Prop.make_tnames Ts);
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    79
      val args = map Free (names ~~ Ts);
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    80
      val c = Const (cname, Ts ---> (nth_dtyp i));
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    81
      fun perm_arg (dt, x) =
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    82
        let val T = type_of x
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    83
        in
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    84
          if is_rec_type dt then
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    85
            let val (Us, _) = strip_type T
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    86
            in list_abs (map (pair "x") Us,
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    87
              Free (nth perm_names_types' (body_index dt)) $ pi $
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    88
                list_comb (x, map (fn (i, U) =>
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    89
                  (permute U) $ (minus_perm $ pi) $ Bound i)
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    90
                  ((length Us - 1 downto 0) ~~ Us)))
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    91
            end
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    92
          else (permute T) $ pi $ x
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    93
        end;
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    94
    in
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    95
      (Attrib.empty_binding, HOLogic.mk_Trueprop (HOLogic.mk_eq
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    96
        (Free (nth perm_names_types' i) $
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    97
           Free ("pi", @{typ perm}) $ list_comb (c, args),
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    98
         list_comb (c, map perm_arg (dts ~~ args)))))
fe0a31cf30a0 Simplifying perm_eq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1161
diff changeset
    99
    end;
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   100
    fun perm_eq (i, (_, _, constrs)) = map (perm_eq_constr i) constrs;
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   101
    val perm_eqs = maps perm_eq descr;
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   102
    val lthy =
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   103
      Theory_Target.instantiation (full_tnames, [], @{sort pt}) thy;
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   104
    (* TODO: Use the version of prmrec that gives the names explicitely. *)
1189
bd40c5cb803d Fix for new Isabelle (primrec)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1170
diff changeset
   105
    val ((_, perm_ldef), lthy') =
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   106
      Primrec.add_primrec
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   107
        (map (fn s => (Binding.name s, NONE, NoSyn)) perm_names') perm_eqs lthy;
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   108
    val perm_frees =
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   109
      (distinct (op =)) (map (fst o strip_comb o fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) perm_ldef);
1248
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
   110
    val perm_empty_thms = List.take (prove_perm_empty lthy' induct perm_ldef perm_frees, length new_type_names);
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
   111
    val perm_append_thms = List.take (prove_perm_append lthy' induct perm_ldef perm_frees, length new_type_names)
1249
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   112
    val perms_name = space_implode "_" perm_names'
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   113
    val perms_zero_bind = Binding.name (perms_name ^ "_zero")
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   114
    val perms_append_bind = Binding.name (perms_name ^ "_append")
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   115
    fun tac _ perm_thms =
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   116
      (Class.intro_classes_tac []) THEN (ALLGOALS (
1248
705afaaf6fb4 More refactoring and removed references to the global simpset in Perm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1247
diff changeset
   117
        simp_tac (HOL_ss addsimps perm_thms
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   118
      )));
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   119
    fun morphism phi = map (Morphism.thm phi);
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   120
  in
1249
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   121
  lthy'
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   122
  |> snd o (Local_Theory.note ((perms_zero_bind, []), perm_empty_thms))
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   123
  |> snd o (Local_Theory.note ((perms_append_bind, []), perm_append_thms))
ea6a52a4f5bf Note the instance proofs, since they can be easily lifted.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1248
diff changeset
   124
  |> Class_Target.prove_instantiation_exit_result morphism tac (perm_empty_thms @ perm_append_thms)
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   125
  end
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
*}
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   129
(* Test
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   130
atom_decl name
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   132
datatype rtrm1 =
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   133
  rVr1 "name"
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   134
| rAp1 "rtrm1" "rtrm1 list"
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   135
| rLm1 "name" "rtrm1"
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   136
| rLt1 "bp" "rtrm1" "rtrm1"
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   137
and bp =
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   138
  BUnit
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   139
| BVr "name"
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   140
| BPr "bp" "bp"
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
1170
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   142
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   143
setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Perm.rtrm1", "Perm.bp"] *}
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   144
print_theorems
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   145
*)
a7b4160ef463 Wrapped the permutation code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1164
diff changeset
   146
1159
3c6bee89d826 Ported Stefan's permutation code, still needs some localizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
end