Nominal/Unused.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 21 May 2010 10:44:07 +0200
changeset 2165 e838f7d90f81
parent 2133 16834a4ca1bb
permissions -rw-r--r--
Function experiments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2115
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
lemma exi: "\<exists>(pi :: perm). P pi \<Longrightarrow> (\<And>(p :: perm). P p \<Longrightarrow> Q (pi \<bullet> p)) \<Longrightarrow> \<exists>pi. Q pi"
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
apply (erule exE)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
apply (rule_tac x="pi \<bullet> pia" in exI)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
by auto
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
ML {*
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
fun alpha_eqvt_tac induct simps ctxt =
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
  rtac induct THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
  simp_tac (HOL_basic_ss addsimps simps) THEN_ALL_NEW split_conj_tac THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  REPEAT o etac @{thm exi[of _ _ "p"]} THEN' split_conj_tac THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  asm_full_simp_tac (HOL_ss addsimps (all_eqvts ctxt @ simps)) THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  asm_full_simp_tac (HOL_ss addsimps
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
    @{thms supp_eqvt[symmetric] inter_eqvt[symmetric] empty_eqvt alphas prod_rel.simps prod_fv.simps}) THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  (split_conj_tac THEN_ALL_NEW TRY o resolve_tac
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
    @{thms fresh_star_permute_iff[of "- p", THEN iffD1] permute_eq_iff[of "- p", THEN iffD1]})
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  THEN_ALL_NEW
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  asm_full_simp_tac (HOL_ss addsimps (@{thms split_conv permute_minus_cancel permute_plus permute_eqvt[symmetric]} @ all_eqvts ctxt @ simps))
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
*}
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
ML {*
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
fun build_alpha_eqvt alpha names =
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
let
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  val pi = Free ("p", @{typ perm});
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  val (tys, _) = strip_type (fastype_of alpha)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  val indnames = Name.variant_list names (Datatype_Prop.make_tnames (map body_type tys));
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  val args = map Free (indnames ~~ tys);
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  val perm_args = map (fn x => mk_perm pi x) args
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
in
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  (HOLogic.mk_imp (list_comb (alpha, args), list_comb (alpha, perm_args)), indnames @ names)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
end
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
*}
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
ML {*
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
fun build_alpha_eqvts funs tac ctxt =
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
let
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
  val (gls, names) = fold_map build_alpha_eqvt funs ["p"]
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj gls)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  val thm = Goal.prove ctxt names [] gl tac
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
in
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  map (fn x => mp OF [x]) (HOLogic.conj_elims thm)
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
end
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
*}
9b109ef7bf47 Move alpha_eqvt to unused.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
2133
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    44
(* Given [fv1, fv2, fv3]
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    45
   produces %(x, y, z). fv1 x u fv2 y u fv3 z *)
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    46
ML {*
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    47
fun mk_compound_fv fvs =
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    48
let
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    49
  val nos = (length fvs - 1) downto 0;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    50
  val fvs_applied = map (fn (fv, no) => fv $ Bound no) (fvs ~~ nos);
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    51
  val fvs_union = mk_union fvs_applied;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    52
  val (tyh :: tys) = rev (map (domain_type o fastype_of) fvs);
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    53
  fun fold_fun ty t = HOLogic.mk_split (Abs ("", ty, t))
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    54
in
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    55
  fold fold_fun tys (Abs ("", tyh, fvs_union))
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    56
end;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    57
*}
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    58
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    59
(* Given [R1, R2, R3]
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    60
   produces %(x,x'). %(y,y'). %(z,z'). R x x' \<and> R y y' \<and> R z z' *)
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    61
ML {*
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    62
fun mk_compound_alpha Rs =
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    63
let
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    64
  val nos = (length Rs - 1) downto 0;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    65
  val nos2 = (2 * length Rs - 1) downto length Rs;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    66
  val Rs_applied = map (fn (R, (no2, no)) => R $ Bound no2 $ Bound no)
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    67
    (Rs ~~ (nos2 ~~ nos));
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    68
  val Rs_conj = foldr1 HOLogic.mk_conj Rs_applied;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    69
  val (tyh :: tys) = rev (map (domain_type o fastype_of) Rs);
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    70
  fun fold_fun ty t = HOLogic.mk_split (Abs ("", ty, t))
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    71
  val abs_rhs = fold fold_fun tys (Abs ("", tyh, Rs_conj))
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    72
in
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    73
  fold fold_fun tys (Abs ("", tyh, abs_rhs))
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    74
end;
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2115
diff changeset
    75
*}