Nominal/Rsp.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Thu, 25 Mar 2010 17:30:46 +0100
changeset 1650 4b949985cf57
parent 1623 b63e85d36715
child 1653 a2142526bb01
permissions -rw-r--r--
Gathering things to prove by induction together; removed cheat_bn_eqvt.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory Rsp
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports Abs
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
ML {*
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
fun define_quotient_type args tac ctxt =
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
let
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
  val mthd = Method.SIMPLE_METHOD tac
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
  val mthdt = Method.Basic (fn _ => mthd)
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  val bymt = Proof.global_terminal_proof (mthdt, NONE)
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
in
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  bymt (Quotient_Type.quotient_type args ctxt)
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
end
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
ML {*
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    17
fun const_rsp lthy const =
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
let
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  val nty = fastype_of (Quotient_Term.quotient_lift_const ("", const) lthy)
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  val rel = Quotient_Term.equiv_relation_chk lthy (fastype_of const, nty);
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
in
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  HOLogic.mk_Trueprop (rel $ const $ const)
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
end
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    26
(* Replaces bounds by frees and meta implications by implications *)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
ML {*
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    28
fun prepare_goal trm =
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
let
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  val vars = strip_all_vars trm
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  val fs = rev (map Free vars)
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    32
  val (fixes, no_alls) = ((map fst vars), subst_bounds (fs, (strip_all_body trm)))
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    33
  val prems = map HOLogic.dest_Trueprop (Logic.strip_imp_prems no_alls)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    34
  val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl no_alls)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
in
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    36
  (fixes, fold (curry HOLogic.mk_imp) prems concl)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
end
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
ML {*
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
fun get_rsp_goal thy trm =
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
let
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  val goalstate = Goal.init (cterm_of thy trm);
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  val tac = REPEAT o rtac @{thm fun_rel_id};
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
in
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  case (SINGLE (tac 1) goalstate) of
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
    NONE => error "rsp_goal failed"
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    48
  | SOME th => prepare_goal (term_of (cprem_of th 1))
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
end
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
ML {*
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    53
fun repeat_mp thm = repeat_mp (mp OF [thm]) handle THM _ => thm
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    54
*}
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    55
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    56
ML {*
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    57
fun prove_const_rsp bind consts tac ctxt =
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
let
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    59
  val rsp_goals = map (const_rsp ctxt) consts
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  val thy = ProofContext.theory_of ctxt
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    61
  val (fixed, user_goals) = split_list (map (get_rsp_goal thy) rsp_goals)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    62
  val fixed' = distinct (op =) (flat fixed)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    63
  val user_goal = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj user_goals)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    64
  val user_thm = Goal.prove ctxt fixed' [] user_goal tac
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    65
  val user_thms = map repeat_mp (HOLogic.conj_elims user_thm)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    66
  fun tac _ = (REPEAT o rtac @{thm fun_rel_id} THEN' resolve_tac user_thms THEN_ALL_NEW atac) 1
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    67
  val rsp_thms = map (fn gl => Goal.prove ctxt [] [] gl tac) rsp_goals
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
in
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
   ctxt
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
|> snd o Local_Theory.note 
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    71
  ((Binding.empty, [Attrib.internal (fn _ => Quotient_Info.rsp_rules_add)]), rsp_thms)
1278
8814494fe4da Change in signature of prove_const_rsp for general lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1268
diff changeset
    72
|> Local_Theory.note ((bind, []), user_thms)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
end
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
1573
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    76
ML {*
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    77
fun ind_tac induct = (rtac impI THEN' etac induct) ORELSE' rtac induct
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    78
*}
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
    79
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
ML {*
1573
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    81
fun fvbv_rsp_tac induct fvbv_simps ctxt =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    82
  ind_tac induct THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    83
  (TRY o rtac @{thm TrueI}) THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    84
  asm_full_simp_tac (HOL_basic_ss addsimps @{thms alpha_gen2}) THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    85
  asm_full_simp_tac (HOL_ss addsimps (@{thm alpha_gen} :: fvbv_simps)) THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    86
  REPEAT o eresolve_tac [conjE, exE] THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    87
  asm_full_simp_tac (HOL_ss addsimps fvbv_simps) THEN_ALL_NEW
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
    88
  TRY o blast_tac (claset_of ctxt)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
ML {*
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1494
diff changeset
    92
fun sym_eqvts ctxt = map (fn x => sym OF [x]) (Nominal_ThmDecls.get_eqvts_thms ctxt)
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1494
diff changeset
    93
fun all_eqvts ctxt =
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1494
diff changeset
    94
  Nominal_ThmDecls.get_eqvts_thms ctxt @ Nominal_ThmDecls.get_eqvts_raw_thms ctxt
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1494
diff changeset
    95
val split_conjs = REPEAT o etac conjE THEN' TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI)
1416
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1410
diff changeset
    96
*}
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1410
diff changeset
    97
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1410
diff changeset
    98
ML {*
1561
c3dca6e600c8 Use 'alpha_bn_refl' to get rid of one of the sorrys.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
    99
fun constr_rsp_tac inj rsp =
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   100
  REPEAT o rtac impI THEN'
1416
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1410
diff changeset
   101
  simp_tac (HOL_ss addsimps inj) THEN' split_conjs THEN_ALL_NEW
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
  (asm_simp_tac HOL_ss THEN_ALL_NEW (
1561
c3dca6e600c8 Use 'alpha_bn_refl' to get rid of one of the sorrys.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
   103
   REPEAT o rtac @{thm exI[of _ "0 :: perm"]} THEN_ALL_NEW
c3dca6e600c8 Use 'alpha_bn_refl' to get rid of one of the sorrys.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
   104
   simp_tac (HOL_basic_ss addsimps @{thms alpha_gen2}) THEN_ALL_NEW
c3dca6e600c8 Use 'alpha_bn_refl' to get rid of one of the sorrys.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
   105
   asm_full_simp_tac (HOL_ss addsimps (rsp @
c3dca6e600c8 Use 'alpha_bn_refl' to get rid of one of the sorrys.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
   106
     @{thms alpha_gen fresh_star_def fresh_zero_perm permute_zero ball_triv add_0_left}))
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
  ))
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
*}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   110
(* Testing code
1278
8814494fe4da Change in signature of prove_const_rsp for general lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1268
diff changeset
   111
local_setup {* snd o prove_const_rsp @{binding fv_rtrm2_rsp} [@{term rbv2}]
1230
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   112
  (fn _ => fv_rsp_tac @{thm alpha_rtrm2_alpha_rassign.inducts(2)} @{thms fv_rtrm2_fv_rassign.simps} 1) *}*)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   113
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   114
(*ML {*
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   115
  val rsp_goals = map (const_rsp @{context}) [@{term rbv2}]
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   116
  val (fixed, user_goals) = split_list (map (get_rsp_goal @{theory}) rsp_goals)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   117
  val fixed' = distinct (op =) (flat fixed)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   118
  val user_goal = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj user_goals)
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   119
*}
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   120
prove ug: {* user_goal *}
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   121
ML_prf {*
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   122
val induct = @{thm alpha_rtrm2_alpha_rassign.inducts(2)}
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   123
val fv_simps = @{thms rbv2.simps}
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   124
*} 
a41c3a105104 rsp for bv; the only issue is that it requires an appropriate induction principle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1227
diff changeset
   125
*)
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   127
ML {*
1445
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   128
fun perm_arg arg =
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   129
let
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   130
  val ty = fastype_of arg
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   131
in
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   132
  Const (@{const_name permute}, @{typ perm} --> ty --> ty)
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   133
end
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   134
1650
4b949985cf57 Gathering things to prove by induction together; removed cheat_bn_eqvt.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1623
diff changeset
   135
val perm_at = @{term "permute :: perm \<Rightarrow> atom set \<Rightarrow> atom set"}
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   136
*}
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   137
1300
22a084c9316b Fixed eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1278
diff changeset
   138
lemma exi: "\<exists>(pi :: perm). P pi \<Longrightarrow> (\<And>(p :: perm). P p \<Longrightarrow> Q (pi \<bullet> p)) \<Longrightarrow> \<exists>pi. Q pi"
22a084c9316b Fixed eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1278
diff changeset
   139
apply (erule exE)
22a084c9316b Fixed eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1278
diff changeset
   140
apply (rule_tac x="pi \<bullet> pia" in exI)
22a084c9316b Fixed eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1278
diff changeset
   141
by auto
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   142
1331
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   143
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   144
ML {*
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   145
fun mk_minimal_ss ctxt =
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   146
  Simplifier.context ctxt empty_ss
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   147
    setsubgoaler asm_simp_tac
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   148
    setmksimps (mksimps [])
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   149
*}
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   150
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   151
ML {*
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   152
fun alpha_eqvt_tac induct simps ctxt =
1334
80441e27dfd6 Code for solving symp goals with multiple existentials.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1331
diff changeset
   153
  ind_tac induct THEN_ALL_NEW
1331
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   154
  simp_tac ((mk_minimal_ss ctxt) addsimps simps) THEN_ALL_NEW
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   155
  REPEAT o etac @{thm exi[of _ _ "p"]} THEN' split_conjs THEN_ALL_NEW
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   156
  asm_full_simp_tac (HOL_ss addsimps (all_eqvts ctxt @ simps)) THEN_ALL_NEW
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   157
  asm_full_simp_tac (HOL_ss addsimps 
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   158
    @{thms supp_eqvt[symmetric] inter_eqvt[symmetric] empty_eqvt alpha_gen}) THEN_ALL_NEW
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   159
  (split_conjs THEN_ALL_NEW TRY o resolve_tac
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   160
    @{thms fresh_star_permute_iff[of "- p", THEN iffD1] permute_eq_iff[of "- p", THEN iffD1]})
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   161
  THEN_ALL_NEW
1494
923413256cbb Clean 'Lift', start working only on exported things in Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1474
diff changeset
   162
  asm_full_simp_tac (HOL_ss addsimps (@{thms split_conv permute_minus_cancel permute_plus permute_eqvt[symmetric]} @ all_eqvts ctxt @ simps))
1331
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   163
*}
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   164
0f329449e304 Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1314
diff changeset
   165
ML {*
1445
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   166
fun build_alpha_eqvt alpha names =
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   167
let
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   168
  val pi = Free ("p", @{typ perm});
1445
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   169
  val (tys, _) = strip_type (fastype_of alpha)
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   170
  val indnames = Name.variant_list names (Datatype_Prop.make_tnames (map body_type tys));
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   171
  val args = map Free (indnames ~~ tys);
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   172
  val perm_args = map (fn x => perm_arg x $ pi $ x) args
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   173
in
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   174
  (HOLogic.mk_imp (list_comb (alpha, args), list_comb (alpha, perm_args)), indnames @ names)
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   175
end
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   176
*}
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   177
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   178
ML {* fold_map build_alpha_eqvt *}
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   179
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   180
ML {*
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   181
fun build_alpha_eqvts funs tac ctxt =
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   182
let
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   183
  val (gls, names) = fold_map build_alpha_eqvt funs ["p"]
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   184
  val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj gls)
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   185
  val thm = Goal.prove ctxt names [] gl tac
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   186
in
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   187
  map (fn x => mp OF [x]) (HOLogic.conj_elims thm)
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   188
end
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   189
*}
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   190
1308
80dabcaafc38 Moving wrappers out of Lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1303
diff changeset
   191
ML {*
1573
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   192
fun prove_fv_rsp fv_alphas_lst all_alphas tac ctxt =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   193
let
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   194
  val (fvs_alphas, ls) = split_list fv_alphas_lst;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   195
  val (fv_ts, alpha_ts) = split_list fvs_alphas;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   196
  val tys = map (domain_type o fastype_of) alpha_ts;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   197
  val names = Datatype_Prop.make_tnames tys;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   198
  val names2 = Name.variant_list names names;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   199
  val args = map Free (names ~~ tys);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   200
  val args2 = map Free (names2 ~~ tys);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   201
  fun mk_fv_rsp arg arg2 (fv, alpha) = HOLogic.mk_eq ((fv $ arg), (fv $ arg2));
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   202
  fun fv_rsp_arg (((fv, alpha), (arg, arg2)), l) =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   203
    HOLogic.mk_imp (
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   204
     (alpha $ arg $ arg2),
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   205
     (foldr1 HOLogic.mk_conj
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   206
       (HOLogic.mk_eq (fv $ arg, fv $ arg2) ::
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   207
       (map (mk_fv_rsp arg arg2) l))));
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   208
  val nobn_eqs = map fv_rsp_arg (((fv_ts ~~ alpha_ts) ~~ (args ~~ args2)) ~~ ls);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   209
  fun mk_fv_rsp_bn arg arg2 (fv, alpha) =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   210
    HOLogic.mk_imp (
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   211
      (alpha $ arg $ arg2),
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   212
      HOLogic.mk_eq ((fv $ arg), (fv $ arg2)));
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   213
  fun fv_rsp_arg_bn ((arg, arg2), l) =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   214
    map (mk_fv_rsp_bn arg arg2) l;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   215
  val bn_eqs = flat (map fv_rsp_arg_bn ((args ~~ args2) ~~ ls));
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   216
  val (_, add_alphas) = chop (length (nobn_eqs @ bn_eqs)) all_alphas;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   217
  val atys = map (domain_type o fastype_of) add_alphas;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   218
  val anames = Name.variant_list (names @ names2) (Datatype_Prop.make_tnames atys);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   219
  val aargs = map Free (anames ~~ atys);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   220
  val aeqs = map2 (fn alpha => fn arg => HOLogic.mk_imp (alpha $ arg $ arg, @{term True}))
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   221
    add_alphas aargs;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   222
  val eq = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (nobn_eqs @ bn_eqs @ aeqs));
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   223
  val th = Goal.prove ctxt (names @ names2) [] eq tac;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   224
  val ths = HOLogic.conj_elims th;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   225
  val (ths_nobn, ths_bn) = chop (length ls) ths;
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   226
  fun project (th, l) =
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   227
    Project_Rule.projects ctxt (1 upto (length l + 1)) (hd (Project_Rule.projections ctxt th))
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   228
  val ths_nobn_pr = map project (ths_nobn ~~ ls);
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   229
in
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   230
  (flat ths_nobn_pr @ ths_bn)
1268
d1999540d23a Move the eqvt code out of Terms and fixed induction for single-rule examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1258
diff changeset
   231
end
1573
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   232
*}
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   233
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   234
lemma equivp_rspl:
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   235
  "equivp r \<Longrightarrow> r a b \<Longrightarrow> r a c = r b c"
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   236
  unfolding equivp_reflp_symp_transp symp_def transp_def 
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   237
  by blast
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   238
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   239
lemma equivp_rspr:
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   240
  "equivp r \<Longrightarrow> r a b \<Longrightarrow> r c a = r c b"
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   241
  unfolding equivp_reflp_symp_transp symp_def transp_def 
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   242
  by blast
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   243
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   244
ML {*
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   245
fun prove_alpha_bn_rsp alphas inducts exhausts inj_dis equivps ctxt (alpha_bn, n) =
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   246
let
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   247
  val alpha = nth alphas n;
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   248
  val ty = domain_type (fastype_of alpha);
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   249
  val ([x, y, a], ctxt') = Variable.variant_fixes ["x","y","a"] ctxt;
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   250
  val [l, r] = map (fn x => (Free (x, ty))) [x, y]
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   251
  val lhs = HOLogic.mk_Trueprop (alpha $ l $ r)
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   252
  val g1 =
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   253
    Logic.mk_implies (lhs,
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   254
      HOLogic.mk_Trueprop (HOLogic.mk_all (a, ty,
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   255
        HOLogic.mk_eq (alpha_bn $ l $ Bound 0, alpha_bn $ r $ Bound 0))));
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   256
  val g2 =
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   257
    Logic.mk_implies (lhs,
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   258
      HOLogic.mk_Trueprop (HOLogic.mk_all (a, ty,
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   259
        HOLogic.mk_eq (alpha_bn $ Bound 0 $ l, alpha_bn $ Bound 0 $ r))));
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   260
  val resl = map (fn x => @{thm equivp_rspl} OF [x]) equivps;
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   261
  val resr = map (fn x => @{thm equivp_rspr} OF [x]) equivps;
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   262
  fun tac {context, ...} = (
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   263
    etac (nth inducts n) THEN_ALL_NEW
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   264
    (TRY o rtac @{thm TrueI}) THEN_ALL_NEW rtac allI THEN_ALL_NEW
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   265
    split_conjs THEN_ALL_NEW
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   266
    InductTacs.case_rule_tac context a (nth exhausts n) THEN_ALL_NEW
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   267
    asm_full_simp_tac (HOL_ss addsimps inj_dis) THEN_ALL_NEW
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   268
    TRY o REPEAT_ALL_NEW (rtac @{thm arg_cong2[of _ _ _ _ "op \<and>"]}) THEN_ALL_NEW
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   269
    TRY o eresolve_tac (resl @ resr) THEN_ALL_NEW
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   270
    asm_full_simp_tac (HOL_ss addsimps inj_dis)
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   271
  ) 1;
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   272
  val t1 = Goal.prove ctxt [] [] g1 tac;
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   273
  val t2 = Goal.prove ctxt [] [] g2 tac;
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   274
in
1576
7b8f570b2450 Got rid of alpha_bn_rsp_cheat.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1575
diff changeset
   275
  Variable.export ctxt' ctxt [t1, t2]
1575
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   276
end
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   277
*}
2c37f5a8c747 alpha_bn_rsp_pre automatized.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1573
diff changeset
   278
1573
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   279
b39108f42638 fv_rsp proved automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1561
diff changeset
   280
end