Nominal/Terms.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Thu, 25 Feb 2010 09:41:14 +0100
changeset 1263 a6eeca90fd4e
parent 1262 2f020819ada9
child 1264 1dedc0b76f32
permissions -rw-r--r--
Use eqvt infrastructure.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory Terms
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
     2
imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "Rsp" "../Attic/Prove"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
atom_decl name
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
text {* primrec seems to be genarally faster than fun *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
section {*** lets with binding patterns ***}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
datatype rtrm1 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  rVr1 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
| rAp1 "rtrm1" "rtrm1"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
| rLm1 "name" "rtrm1"        --"name is bound in trm1"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
| rLt1 "bp" "rtrm1" "rtrm1"   --"all variables in bp are bound in the 2nd trm1"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
and bp =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  BUnit
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
| BVr "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
| BPr "bp" "bp"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
1198
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
    21
print_theorems
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
    22
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
(* to be given by the user *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  bv1
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  "bv1 (BUnit) = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
| "bv1 (BVr x) = {atom x}"
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
    30
| "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp2)"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    32
setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
    33
thm permute_rtrm1_permute_bp.simps
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    34
1225
28aaf6d01e10 Progress towards automatic rsp of constants and fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1222
diff changeset
    35
local_setup {*
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
    36
  snd o define_fv_alpha "Terms.rtrm1"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv1}, 0)], [], [(SOME @{term bv1}, 0)]]],
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
    38
  [[], [[]], [[], []]]] *}
1198
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
    39
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    40
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    41
  alpha_rtrm1 ("_ \<approx>1 _" [100, 100] 100) and
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    42
  alpha_bp ("_ \<approx>1b _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    43
thm alpha_rtrm1_alpha_bp.intros
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
    44
thm fv_rtrm1_fv_bp.simps
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
    46
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha1_inj}, []), (build_alpha_inj @{thms alpha_rtrm1_alpha_bp.intros} @{thms rtrm1.distinct rtrm1.inject bp.distinct bp.inject} @{thms alpha_rtrm1.cases alpha_bp.cases} ctxt)) ctxt)) *}
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
    47
thm alpha1_inj
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    49
lemma alpha_bp_refl: "alpha_bp a a"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    50
apply induct
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    51
apply (simp_all  add: alpha1_inj)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    52
done
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    53
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    54
lemma alpha_bp_eq_eq: "alpha_bp a b = (a = b)"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    55
apply rule
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    56
apply (induct a b rule: alpha_rtrm1_alpha_bp.inducts(2))
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    57
apply (simp_all add: alpha_bp_refl)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    58
done
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    59
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    60
lemma alpha_bp_eq: "alpha_bp = (op =)"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    61
apply (rule ext)+
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    62
apply (rule alpha_bp_eq_eq)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    63
done
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    64
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    65
ML {*
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    66
fun build_eqvts funs perms simps induct ctxt =
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    67
let
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    68
  val pi = Free ("p", @{typ perm});
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    69
  val types = map (domain_type o fastype_of) funs;
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    70
  val fv_indnames = Datatype_Prop.make_tnames (map body_type types);
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    71
  val args = map Free (fv_indnames ~~ types);
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    72
  val perm_at = Const (@{const_name permute}, @{typ "perm \<Rightarrow> atom set \<Rightarrow> atom set"})
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    73
  fun eqvtc (fv, (arg, perm)) =
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    74
    HOLogic.mk_eq ((perm_at $ pi $ (fv $ arg)), (fv $ (perm $ pi $ arg)))
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    75
  val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map eqvtc (funs ~~ (args ~~ perms))))
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    76
  fun tac _ = (indtac induct fv_indnames THEN_ALL_NEW
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    77
    (asm_full_simp_tac (HOL_ss addsimps 
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    78
      (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ simps)))) 1
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    79
  val thm = Goal.prove ctxt ("p" :: fv_indnames) [] gl tac
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    80
  val thms = HOLogic.conj_elims thm
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    81
in
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    82
  Local_Theory.note ((Binding.empty, [Attrib.internal (fn _ => Nominal_ThmDecls.eqvt_add)]), thms) ctxt
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    83
end
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    84
*}
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    85
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    86
local_setup {*
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    87
snd o (build_eqvts [@{term bv1}] [@{term "permute :: perm \<Rightarrow> bp \<Rightarrow> bp"}] (@{thms bv1.simps permute_rtrm1_permute_bp.simps}) @{thm rtrm1_bp.inducts(2)})
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    88
*}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    90
local_setup {*
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    91
snd o build_eqvts [@{term fv_rtrm1}, @{term fv_bp}] [@{term "permute :: perm \<Rightarrow> rtrm1 \<Rightarrow> rtrm1"},@{term "permute :: perm \<Rightarrow> bp \<Rightarrow> bp"}] (@{thms fv_rtrm1_fv_bp.simps permute_rtrm1_permute_bp.simps}) @{thm rtrm1_bp.induct}
1262
2f020819ada9 Simple function eqvt code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1259
diff changeset
    92
*}
1263
a6eeca90fd4e Use eqvt infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1262
diff changeset
    93
thm eqvts
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
lemma alpha1_eqvt:
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    95
  "t \<approx>1 s \<Longrightarrow> (pi \<bullet> t) \<approx>1 (pi \<bullet> s)"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    96
  "alpha_bp a b \<Longrightarrow> alpha_bp (pi \<bullet> a) (pi \<bullet> b)"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
    97
  apply (induct t s and a b rule: alpha_rtrm1_alpha_bp.inducts)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  apply (simp_all add:eqvts alpha1_inj)
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
    99
  apply (tactic {* 
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   100
    ALLGOALS (
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   101
      TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI) THEN_ALL_NEW
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   102
      (etac @{thm alpha_gen_compose_eqvt})
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   103
    ) *})
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   104
  apply (simp_all only: eqvts atom_eqvt)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   107
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha1_equivp}, []),
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   108
  (build_equivps [@{term alpha_rtrm1}, @{term alpha_bp}] @{thm rtrm1_bp.induct} @{thm alpha_rtrm1_alpha_bp.induct} @{thms rtrm1.inject bp.inject} @{thms alpha1_inj} @{thms rtrm1.distinct bp.distinct} @{thms alpha_rtrm1.cases alpha_bp.cases} @{thms alpha1_eqvt} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   109
thm alpha1_equivp
1211
05e5fcf9840b export the reflp and symp tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1210
diff changeset
   110
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   111
local_setup  {* define_quotient_type [(([], @{binding trm1}, NoSyn), (@{typ rtrm1}, @{term alpha_rtrm1}))]
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   112
  (rtac @{thm alpha1_equivp(1)} 1) *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   114
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   115
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   116
 |> snd o (Quotient_Def.quotient_lift_const ("Vr1", @{term rVr1}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   117
 |> snd o (Quotient_Def.quotient_lift_const ("Ap1", @{term rAp1}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   118
 |> snd o (Quotient_Def.quotient_lift_const ("Lm1", @{term rLm1}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   119
 |> snd o (Quotient_Def.quotient_lift_const ("Lt1", @{term rLt1}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   120
 |> snd o (Quotient_Def.quotient_lift_const ("fv_trm1", @{term fv_rtrm1})))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   121
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   122
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
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
   124
thm alpha_rtrm1_alpha_bp.induct
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
local_setup {* prove_const_rsp @{binding fv_rtrm1_rsp} [@{term fv_rtrm1}]
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
   126
  (fn _ => fvbv_rsp_tac @{thm alpha_rtrm1_alpha_bp.inducts(1)} @{thms fv_rtrm1_fv_bp.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
   127
local_setup {* prove_const_rsp @{binding rVr1_rsp} [@{term rVr1}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   128
  (fn _ => constr_rsp_tac @{thms alpha1_inj} @{thms fv_rtrm1_rsp} @{thms alpha1_equivp} 1) *}
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
   129
local_setup {* prove_const_rsp @{binding rAp1_rsp} [@{term rAp1}]
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
   130
  (fn _ => constr_rsp_tac @{thms alpha1_inj} @{thms fv_rtrm1_rsp} @{thms alpha1_equivp} 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
   131
local_setup {* prove_const_rsp @{binding rLm1_rsp} [@{term rLm1}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   132
  (fn _ => constr_rsp_tac @{thms alpha1_inj} @{thms fv_rtrm1_rsp} @{thms alpha1_equivp} 1) *}
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
   133
local_setup {* prove_const_rsp @{binding rLt1_rsp} [@{term rLt1}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   134
  (fn _ => constr_rsp_tac @{thms alpha1_inj} @{thms fv_rtrm1_rsp} @{thms alpha1_equivp} 1) *}
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
   135
local_setup {* prove_const_rsp @{binding permute_rtrm1_rsp} [@{term "permute :: perm \<Rightarrow> rtrm1 \<Rightarrow> rtrm1"}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   136
  (fn _ => asm_simp_tac (HOL_ss addsimps @{thms alpha1_eqvt}) 1) *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
lemmas trm1_bp_induct = rtrm1_bp.induct[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
lemmas trm1_bp_inducts = rtrm1_bp.inducts[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
1253
cff8a67691d2 Define lifted perms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1250
diff changeset
   141
setup {* define_lifted_perms ["Terms.trm1"] [("permute_trm1", @{term "permute :: perm \<Rightarrow> rtrm1 \<Rightarrow> rtrm1"})]
cff8a67691d2 Define lifted perms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1250
diff changeset
   142
  @{thms permute_rtrm1_permute_bp_zero permute_rtrm1_permute_bp_append} *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   144
lemmas
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   145
    permute_trm1 = permute_rtrm1_permute_bp.simps[quot_lifted]
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   146
and fv_trm1 = fv_rtrm1_fv_bp.simps[quot_lifted]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   147
and fv_trm1_eqvt = fv_rtrm1_eqvt[quot_lifted]
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   148
and alpha1_INJ = alpha1_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
1246
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   150
lemma supports:
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   151
  "(supp (atom x)) supports (Vr1 x)"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   152
  "(supp t \<union> supp s) supports (Ap1 t s)"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   153
  "(supp (atom x) \<union> supp t) supports (Lm1 x t)"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   154
  "(supp b \<union> supp t \<union> supp s) supports (Lt1 b t s)"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   155
  "{} supports BUnit"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   156
  "(supp (atom x)) supports (BVr x)"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   157
  "(supp a \<union> supp b) supports (BPr a b)"
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   158
apply(simp_all add: supports_def fresh_def[symmetric] swap_fresh_fresh permute_trm1)
1246
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   159
apply(rule_tac [!] allI)+
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   160
apply(rule_tac [!] impI)
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   161
apply(tactic {* ALLGOALS (REPEAT o etac conjE) *})
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
apply(simp_all add: fresh_atom)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
1246
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   165
lemma rtrm1_bp_fs:
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   166
  "finite (supp (x :: trm1))"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   167
  "finite (supp (b :: bp))"
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   168
  apply (induct x and b rule: trm1_bp_inducts)
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   169
  apply(tactic {* ALLGOALS (rtac @{thm supports_finite} THEN' resolve_tac @{thms supports}) *})
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   170
  apply(simp_all add: supp_atom)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
instance trm1 :: fs
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
apply default
1246
845bf16eee18 Regularize finite support proof for trm1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1230
diff changeset
   175
apply (rule rtrm1_bp_fs(1))
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   178
lemma fv_eq_bv: "fv_bp bp = bv1 bp"
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   179
apply(induct bp rule: trm1_bp_inducts(2))
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   180
apply(simp_all)
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   181
done
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   182
1209
7b1a3df239cd Some progress about transp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1208
diff changeset
   183
lemma helper2: "{b. \<forall>pi. pi \<bullet> (a \<rightleftharpoons> b) \<bullet> bp \<noteq> bp} = {}"
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   184
apply auto
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   185
apply (rule_tac x="(x \<rightleftharpoons> a)" in exI)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   186
apply auto
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   187
done
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   188
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
lemma supp_fv:
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   190
  "supp t = fv_trm1 t"
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   191
  "supp b = fv_bp b"
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   192
apply(induct t and b rule: trm1_bp_inducts)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
apply(simp_all)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
apply(simp add: supp_def permute_trm1 alpha1_INJ fv_trm1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
apply(simp only: supp_at_base[simplified supp_def])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
apply(simp add: supp_def permute_trm1 alpha1_INJ fv_trm1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
apply(simp add: Collect_imp_eq Collect_neg_eq)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
apply(subgoal_tac "supp (Lm1 name rtrm1) = supp (Abs {atom name} rtrm1)")
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
apply(simp add: supp_Abs fv_trm1)
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   200
apply(simp (no_asm) add: supp_def permute_set_eq atom_eqvt permute_trm1)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
apply(simp add: alpha1_INJ)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
apply(simp add: Abs_eq_iff)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
apply(simp add: alpha_gen.simps)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric])
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   205
apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp(rtrm11) \<union> supp (Abs (bv1 bp) rtrm12)")
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   206
apply(simp add: supp_Abs fv_trm1 fv_eq_bv)
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   207
apply(simp (no_asm) add: supp_def permute_trm1)
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   208
apply(simp add: alpha1_INJ alpha_bp_eq)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
apply(simp add: Abs_eq_iff)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
apply(simp add: alpha_gen)
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   211
apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv)
1209
7b1a3df239cd Some progress about transp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1208
diff changeset
   212
apply(simp add: Collect_imp_eq Collect_neg_eq fresh_star_def helper2)
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   213
apply(simp (no_asm) add: supp_def permute_set_eq atom_eqvt)
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   214
apply(simp (no_asm) add: supp_def eqvts)
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   215
apply(fold supp_def)
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   216
apply(simp add: supp_at_base)
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   217
apply(simp (no_asm) add: supp_def Collect_imp_eq Collect_neg_eq)
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   218
apply(simp add: Collect_imp_eq[symmetric] Collect_neg_eq[symmetric] supp_def[symmetric])
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   219
done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
lemma trm1_supp:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  "supp (Vr1 x) = {atom x}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
  "supp (Ap1 t1 t2) = supp t1 \<union> supp t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
  "supp (Lm1 x t) = (supp t) - {atom x}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
  "supp (Lt1 b t s) = supp t \<union> (supp s - bv1 b)"
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   226
by (simp_all add: supp_fv fv_trm1 fv_eq_bv)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
lemma trm1_induct_strong:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
  assumes "\<And>name b. P b (Vr1 name)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
  and     "\<And>rtrm11 rtrm12 b. \<lbrakk>\<And>c. P c rtrm11; \<And>c. P c rtrm12\<rbrakk> \<Longrightarrow> P b (Ap1 rtrm11 rtrm12)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
  and     "\<And>name rtrm1 b. \<lbrakk>\<And>c. P c rtrm1; (atom name) \<sharp> b\<rbrakk> \<Longrightarrow> P b (Lm1 name rtrm1)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
  and     "\<And>bp rtrm11 rtrm12 b. \<lbrakk>\<And>c. P c rtrm11; \<And>c. P c rtrm12; bv1 bp \<sharp>* b\<rbrakk> \<Longrightarrow> P b (Lt1 bp rtrm11 rtrm12)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
  shows   "P a rtrma"
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   234
sorry
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
section {*** lets with single assignments ***}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
datatype rtrm2 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
  rVr2 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
| rAp2 "rtrm2" "rtrm2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
| rLm2 "name" "rtrm2" --"bind (name) in (rtrm2)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
| rLt2 "rassign" "rtrm2" --"bind (bv2 rassign) in (rtrm2)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
and rassign =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
  rAs "name" "rtrm2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
(* to be given by the user *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
  rbv2
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
  "rbv2 (rAs x t) = {atom x}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   252
setup {* snd o define_raw_perms ["rtrm2", "rassign"] ["Terms.rtrm2", "Terms.rassign"] *}
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   253
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   254
local_setup {* snd o define_fv_alpha "Terms.rtrm2"
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   255
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv2}, 0)]]],
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
   [[[], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   258
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   259
  alpha_rtrm2 ("_ \<approx>2 _" [100, 100] 100) and
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   260
  alpha_rassign ("_ \<approx>2b _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   261
thm alpha_rtrm2_alpha_rassign.intros
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   263
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha2_inj}, []), (build_alpha_inj @{thms alpha_rtrm2_alpha_rassign.intros} @{thms rtrm2.distinct rtrm2.inject rassign.distinct rassign.inject} @{thms alpha_rtrm2.cases alpha_rassign.cases} ctxt)) ctxt)) *}
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   264
thm alpha2_inj
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   265
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   266
lemma alpha2_eqvt:
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   267
  "t \<approx>2 s \<Longrightarrow> (pi \<bullet> t) \<approx>2 (pi \<bullet> s)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   268
  "a \<approx>2b b \<Longrightarrow> (pi \<bullet> a) \<approx>2b (pi \<bullet> b)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   269
sorry
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   270
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   271
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha2_equivp}, []),
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   272
  (build_equivps [@{term alpha_rtrm2}, @{term alpha_rassign}] @{thm rtrm2_rassign.induct} @{thm alpha_rtrm2_alpha_rassign.induct} @{thms rtrm2.inject rassign.inject} @{thms alpha2_inj} @{thms rtrm2.distinct rassign.distinct} @{thms alpha_rtrm2.cases alpha_rassign.cases} @{thms alpha2_eqvt} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   273
thm alpha2_equivp
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   274
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   275
local_setup  {* define_quotient_type 
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   276
  [(([], @{binding trm2}, NoSyn), (@{typ rtrm2}, @{term alpha_rtrm2})),
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   277
   (([], @{binding assign}, NoSyn), (@{typ rassign}, @{term alpha_rassign}))]
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   278
  ((rtac @{thm alpha2_equivp(1)} 1) THEN (rtac @{thm alpha2_equivp(2)}) 1) *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   280
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   281
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   282
 |> snd o (Quotient_Def.quotient_lift_const ("Vr2", @{term rVr2}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   283
 |> snd o (Quotient_Def.quotient_lift_const ("Ap2", @{term rAp2}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   284
 |> snd o (Quotient_Def.quotient_lift_const ("Lm2", @{term rLm2}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   285
 |> snd o (Quotient_Def.quotient_lift_const ("Lt2", @{term rLt2}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   286
 |> snd o (Quotient_Def.quotient_lift_const ("As", @{term rAs}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   287
 |> snd o (Quotient_Def.quotient_lift_const ("fv_trm2", @{term fv_rtrm2}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   288
 |> snd o (Quotient_Def.quotient_lift_const ("bv2", @{term rbv2})))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   289
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   290
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
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
   292
local_setup {* prove_const_rsp @{binding fv_rtrm2_rsp} [@{term fv_rtrm2}, @{term fv_rassign}]
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
   293
  (fn _ => fvbv_rsp_tac @{thm alpha_rtrm2_alpha_rassign.induct} @{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
   294
local_setup {* prove_const_rsp @{binding rbv2_rsp} [@{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
   295
  (fn _ => fvbv_rsp_tac @{thm alpha_rtrm2_alpha_rassign.inducts(2)} @{thms rbv2.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
   296
local_setup {* prove_const_rsp @{binding rVr2_rsp} [@{term rVr2}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   297
  (fn _ => constr_rsp_tac @{thms alpha2_inj} @{thms fv_rtrm2_rsp} @{thms alpha2_equivp} 1) *}
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
   298
local_setup {* prove_const_rsp @{binding rAp2_rsp} [@{term rAp2}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   299
  (fn _ => constr_rsp_tac @{thms alpha2_inj} @{thms fv_rtrm2_rsp} @{thms alpha2_equivp} 1) *}
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
   300
local_setup {* prove_const_rsp @{binding rLm2_rsp} [@{term rLm2}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   301
  (fn _ => constr_rsp_tac @{thms alpha2_inj} @{thms fv_rtrm2_rsp} @{thms alpha2_equivp} 1) *}
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
   302
local_setup {* prove_const_rsp @{binding rLt2_rsp} [@{term rLt2}]
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
   303
  (fn _ => constr_rsp_tac @{thms alpha2_inj} @{thms fv_rtrm2_rsp rbv2_rsp} @{thms alpha2_equivp} 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
   304
local_setup {* prove_const_rsp @{binding permute_rtrm2_rsp} [@{term "permute :: perm \<Rightarrow> rtrm2 \<Rightarrow> rtrm2"}]
1227
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   305
  (fn _ => asm_simp_tac (HOL_ss addsimps @{thms alpha2_eqvt}) 1) *}
ec2e0116779e rsp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1225
diff changeset
   306
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
section {*** lets with many assignments ***}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   310
datatype rtrm3 =
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   311
  rVr3 "name"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   312
| rAp3 "rtrm3" "rtrm3"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   313
| rLm3 "name" "rtrm3" --"bind (name) in (trm3)"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   314
| rLt3 "rassigns" "rtrm3" --"bind (bv3 assigns) in (trm3)"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   315
and rassigns =
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   316
  rANil
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   317
| rACons "name" "rtrm3" "rassigns"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
(* to be given by the user *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
  bv3
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
where
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   323
  "bv3 rANil = {}"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   324
| "bv3 (rACons x t as) = {atom x} \<union> (bv3 as)"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   326
setup {* snd o define_raw_perms ["rtrm3", "rassigns"] ["Terms.rtrm3", "Terms.rassigns"] *}
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   327
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   328
local_setup {* snd o define_fv_alpha "Terms.rtrm3"
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   329
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term bv3}, 0)]]],
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
   [[], [[], [], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   333
notation
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   334
  alpha_rtrm3 ("_ \<approx>3 _" [100, 100] 100) and
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   335
  alpha_rassigns ("_ \<approx>3a _" [100, 100] 100)
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   336
thm alpha_rtrm3_alpha_rassigns.intros
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   338
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha3_inj}, []), (build_alpha_inj @{thms alpha_rtrm3_alpha_rassigns.intros} @{thms rtrm3.distinct rtrm3.inject rassigns.distinct rassigns.inject} @{thms alpha_rtrm3.cases alpha_rassigns.cases} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   339
thm alpha3_inj
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   340
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   341
lemma alpha3_eqvt:
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   342
  "t \<approx>3 s \<Longrightarrow> (pi \<bullet> t) \<approx>3 (pi \<bullet> s)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   343
  "a \<approx>3a b \<Longrightarrow> (pi \<bullet> a) \<approx>3a (pi \<bullet> b)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   344
sorry
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   345
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   346
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha3_equivp}, []),
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   347
  (build_equivps [@{term alpha_rtrm3}, @{term alpha_rassigns}] @{thm rtrm3_rassigns.induct} @{thm alpha_rtrm3_alpha_rassigns.induct} @{thms rtrm3.inject rassigns.inject} @{thms alpha3_inj} @{thms rtrm3.distinct rassigns.distinct} @{thms alpha_rtrm3.cases alpha_rassigns.cases} @{thms alpha3_eqvt} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   348
thm alpha3_equivp
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
quotient_type
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   351
  trm3 = rtrm3 / alpha_rtrm3
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
and
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   353
  assigns = rassigns / alpha_rassigns
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   354
  by (rule alpha3_equivp(1)) (rule alpha3_equivp(2))
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
section {*** lam with indirect list recursion ***}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   359
datatype rtrm4 =
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   360
  rVr4 "name"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   361
| rAp4 "rtrm4" "rtrm4 list"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   362
| rLm4 "name" "rtrm4"  --"bind (name) in (trm)"
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   363
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   365
thm rtrm4.recs
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
(* there cannot be a clause for lists, as *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
(* permutations are  already defined in Nominal (also functions, options, and so on) *)
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   369
setup {* snd o define_raw_perms ["rtrm4"] ["Terms.rtrm4"] *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   370
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   371
(* "repairing" of the permute function *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
lemma repaired:
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   373
  fixes ts::"rtrm4 list"
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   374
  shows "permute_rtrm4_list p ts = p \<bullet> ts"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
  apply(induct ts)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   376
  apply(simp_all)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   379
thm permute_rtrm4_permute_rtrm4_list.simps
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   380
thm permute_rtrm4_permute_rtrm4_list.simps[simplified repaired]
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   382
local_setup {* snd o define_fv_alpha "Terms.rtrm4" [
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   383
  [[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]]], [[], [[], []]]  ] *}
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   384
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   386
notation
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   387
  alpha_rtrm4 ("_ \<approx>4 _" [100, 100] 100) and
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   388
  alpha_rtrm4_list ("_ \<approx>4l _" [100, 100] 100)
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   389
thm alpha_rtrm4_alpha_rtrm4_list.intros
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   390
1216
06ace3a1eedd Fixed pseudo_injectivity for trm4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1215
diff changeset
   391
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_inj}, []), (build_alpha_inj @{thms alpha_rtrm4_alpha_rtrm4_list.intros} @{thms rtrm4.distinct rtrm4.inject list.distinct list.inject} @{thms alpha_rtrm4.cases alpha_rtrm4_list.cases} ctxt)) ctxt)) *}
06ace3a1eedd Fixed pseudo_injectivity for trm4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1215
diff changeset
   392
thm alpha4_inj
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   393
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   394
lemma alpha4_eqvt:
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   395
  "t \<approx>4 s \<Longrightarrow> (pi \<bullet> t) \<approx>4 (pi \<bullet> s)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   396
  "a \<approx>4l b \<Longrightarrow> (pi \<bullet> a) \<approx>4l (pi \<bullet> b)"
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   397
sorry
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   398
1216
06ace3a1eedd Fixed pseudo_injectivity for trm4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1215
diff changeset
   399
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha4_equivp}, []),
1217
74e2b9b95add Fixes for auxiliary datatypes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1216
diff changeset
   400
  (build_equivps [@{term alpha_rtrm4}, @{term alpha_rtrm4_list}] @{thm rtrm4.induct} @{thm alpha_rtrm4_alpha_rtrm4_list.induct} @{thms rtrm4.inject list.inject} @{thms alpha4_inj} @{thms rtrm4.distinct list.distinct} @{thms alpha_rtrm4_list.cases alpha_rtrm4.cases} @{thms alpha4_eqvt} ctxt)) ctxt)) *}
74e2b9b95add Fixes for auxiliary datatypes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1216
diff changeset
   401
thm alpha4_equivp
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   402
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
quotient_type 
1206
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   404
  qrtrm4 = rtrm4 / alpha_rtrm4 and
9c968284553c Renaming.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1205
diff changeset
   405
  qrtrm4list = "rtrm4 list" / alpha_rtrm4_list
1217
74e2b9b95add Fixes for auxiliary datatypes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1216
diff changeset
   406
  by (simp_all add: alpha4_equivp)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   407
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   408
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
datatype rtrm5 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
  rVr5 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   411
| rAp5 "rtrm5" "rtrm5"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   412
| rLt5 "rlts" "rtrm5" --"bind (bv5 lts) in (rtrm5)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   413
and rlts =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
  rLnil
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
| rLcons "name" "rtrm5" "rlts"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   416
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   418
  rbv5
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   420
  "rbv5 rLnil = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   421
| "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   422
1186
166cc41091b9 The alternate version of trm5 with additional binding. All proofs work the same.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1185
diff changeset
   423
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   424
setup {* snd o define_raw_perms ["rtrm5", "rlts"] ["Terms.rtrm5", "Terms.rlts"] *}
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   425
print_theorems
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   426
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   427
local_setup {* snd o define_fv_alpha "Terms.rtrm5" [
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   428
  [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[], [], []]]  ] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   429
print_theorems
1187
3b24f33aedad Changed back to original version of trm5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1186
diff changeset
   430
1186
166cc41091b9 The alternate version of trm5 with additional binding. All proofs work the same.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1185
diff changeset
   431
(* Alternate version with additional binding of name in rlts in rLcons *)
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   432
(*local_setup {* snd o define_fv_alpha "Terms.rtrm5" [
1186
166cc41091b9 The alternate version of trm5 with additional binding. All proofs work the same.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1185
diff changeset
   433
  [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[(NONE,0)], [], [(NONE,0)]]]  ] *}
1187
3b24f33aedad Changed back to original version of trm5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1186
diff changeset
   434
print_theorems*)
1186
166cc41091b9 The alternate version of trm5 with additional binding. All proofs work the same.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1185
diff changeset
   435
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   436
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   437
  alpha_rtrm5 ("_ \<approx>5 _" [100, 100] 100) and
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   438
  alpha_rlts ("_ \<approx>l _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   439
thm alpha_rtrm5_alpha_rlts.intros
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   440
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   441
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha5_inj}, []), (build_alpha_inj @{thms alpha_rtrm5_alpha_rlts.intros} @{thms rtrm5.distinct rtrm5.inject rlts.distinct rlts.inject} @{thms alpha_rtrm5.cases alpha_rlts.cases} ctxt)) ctxt)) *}
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   442
thm alpha5_inj
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   444
lemma rbv5_eqvt[eqvt]:
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   445
  "pi \<bullet> (rbv5 x) = rbv5 (pi \<bullet> x)"
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   446
  apply (induct x)
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   447
  apply (simp_all add: eqvts atom_eqvt)
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   448
  done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   449
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   450
lemma fv_rtrm5_rlts_eqvt[eqvt]:
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   451
  "pi \<bullet> (fv_rtrm5 x) = fv_rtrm5 (pi \<bullet> x)"
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   452
  "pi \<bullet> (fv_rlts l) = fv_rlts (pi \<bullet> l)"
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   453
  apply (induct x and l)
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   454
  apply (simp_all add: eqvts atom_eqvt)
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   455
  done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   456
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   457
lemma alpha5_eqvt:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   458
  "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   459
  "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   460
  apply (induct rule: alpha_rtrm5_alpha_rlts.inducts)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   461
  apply (simp_all add: alpha5_inj)
1255
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   462
  apply (tactic {* 
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   463
    ALLGOALS (
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   464
      TRY o REPEAT_ALL_NEW (CHANGED o rtac conjI) THEN_ALL_NEW
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   465
      (etac @{thm alpha_gen_compose_eqvt})
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   466
    ) *})
ab8ed83d0188 Simplified and finised eqvt proofs for t1 and t5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1253
diff changeset
   467
  apply (simp_all only: eqvts atom_eqvt)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   468
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   469
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   470
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha5_equivp}, []),
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   471
  (build_equivps [@{term alpha_rtrm5}, @{term alpha_rlts}] @{thm rtrm5_rlts.induct} @{thm alpha_rtrm5_alpha_rlts.induct} @{thms rtrm5.inject rlts.inject} @{thms alpha5_inj} @{thms rtrm5.distinct rlts.distinct} @{thms alpha_rtrm5.cases alpha_rlts.cases} @{thms alpha5_eqvt} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   472
thm alpha5_equivp
1213
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   473
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   474
quotient_type
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   475
  trm5 = rtrm5 / alpha_rtrm5
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   476
and
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   477
  lts = rlts / alpha_rlts
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   478
  by (auto intro: alpha5_equivp)
1213
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   479
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   480
local_setup {*
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   481
(fn ctxt => ctxt
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   482
 |> snd o (Quotient_Def.quotient_lift_const ("Vr5", @{term rVr5}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   483
 |> snd o (Quotient_Def.quotient_lift_const ("Ap5", @{term rAp5}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   484
 |> snd o (Quotient_Def.quotient_lift_const ("Lt5", @{term rLt5}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   485
 |> snd o (Quotient_Def.quotient_lift_const ("Lnil", @{term rLnil}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   486
 |> snd o (Quotient_Def.quotient_lift_const ("Lcons", @{term rLcons}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   487
 |> snd o (Quotient_Def.quotient_lift_const ("fv_trm5", @{term fv_rtrm5}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   488
 |> snd o (Quotient_Def.quotient_lift_const ("fv_lts", @{term fv_rlts}))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   489
 |> snd o (Quotient_Def.quotient_lift_const ("bv5", @{term rbv5})))
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   490
*}
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   491
print_theorems
43bd70786f9f More equivp infrastructure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1212
diff changeset
   492
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   493
lemma alpha5_rfv:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   494
  "(t \<approx>5 s \<Longrightarrow> fv_rtrm5 t = fv_rtrm5 s)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   495
  "(l \<approx>l m \<Longrightarrow> fv_rlts l = fv_rlts m)"
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   496
  apply(induct rule: alpha_rtrm5_alpha_rlts.inducts)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   497
  apply(simp_all add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   498
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   499
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   500
lemma bv_list_rsp:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   501
  shows "x \<approx>l y \<Longrightarrow> rbv5 x = rbv5 y"
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   502
  apply(induct rule: alpha_rtrm5_alpha_rlts.inducts(2))
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   503
  apply(simp_all)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   504
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   505
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   506
lemma [quot_respect]:
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   507
  "(alpha_rlts ===> op =) fv_rlts fv_rlts"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   508
  "(alpha_rtrm5 ===> op =) fv_rtrm5 fv_rtrm5"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   509
  "(alpha_rlts ===> op =) rbv5 rbv5"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   510
  "(op = ===> alpha_rtrm5) rVr5 rVr5"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   511
  "(alpha_rtrm5 ===> alpha_rtrm5 ===> alpha_rtrm5) rAp5 rAp5"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   512
  "(alpha_rlts ===> alpha_rtrm5 ===> alpha_rtrm5) rLt5 rLt5"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   513
  "(op = ===> alpha_rtrm5 ===> alpha_rlts ===> alpha_rlts) rLcons rLcons"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   514
  "(op = ===> alpha_rtrm5 ===> alpha_rtrm5) permute permute"
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   515
  "(op = ===> alpha_rlts ===> alpha_rlts) permute permute"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   516
  apply (simp_all add: alpha5_inj alpha5_rfv alpha5_eqvt bv_list_rsp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   517
  apply (clarify) apply (rule conjI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
  apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   519
  apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   521
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   522
lemma
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   523
  shows "(alpha_rlts ===> op =) rbv5 rbv5"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
  by (simp add: bv_list_rsp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   525
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   526
lemmas trm5_lts_inducts = rtrm5_rlts.inducts[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   527
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   528
instantiation trm5 and lts :: pt
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   529
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   530
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   531
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   532
  "permute_trm5 :: perm \<Rightarrow> trm5 \<Rightarrow> trm5"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   533
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   534
  "permute :: perm \<Rightarrow> rtrm5 \<Rightarrow> rtrm5"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   535
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   536
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   537
  "permute_lts :: perm \<Rightarrow> lts \<Rightarrow> lts"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   538
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   539
  "permute :: perm \<Rightarrow> rlts \<Rightarrow> rlts"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   540
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   541
instance by default
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   542
  (simp_all add: permute_rtrm5_permute_rlts_zero[quot_lifted] permute_rtrm5_permute_rlts_append[quot_lifted])
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   543
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   544
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   545
1250
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   546
lemmas
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   547
    permute_trm5_lts = permute_rtrm5_permute_rlts.simps[quot_lifted]
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   548
and alpha5_INJ = alpha5_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   549
and bv5[simp] = rbv5.simps[quot_lifted]
d1ab27c10049 With permute_rsp we can lift the instance proofs :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1246
diff changeset
   550
and fv_trm5_lts[simp] = fv_rtrm5_fv_rlts.simps[quot_lifted]
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   551
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   552
lemma lets_ok:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   553
  "(Lt5 (Lcons x (Vr5 x) Lnil) (Vr5 x)) = (Lt5 (Lcons y (Vr5 y) Lnil) (Vr5 y))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   554
apply (subst alpha5_INJ)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   555
apply (rule conjI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   556
apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   557
apply (simp only: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   558
apply (simp add: permute_trm5_lts fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   559
apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   560
apply (simp only: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   561
apply (simp add: permute_trm5_lts fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   563
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   564
lemma lets_ok2:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   565
  "(Lt5 (Lcons x (Vr5 x) (Lcons y (Vr5 y) Lnil)) (Ap5 (Vr5 x) (Vr5 y))) =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   566
   (Lt5 (Lcons y (Vr5 y) (Lcons x (Vr5 x) Lnil)) (Ap5 (Vr5 x) (Vr5 y)))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   567
apply (subst alpha5_INJ)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
apply (rule conjI)
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   569
apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   570
apply (simp only: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   571
apply (simp add: permute_trm5_lts fresh_star_def)
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   572
apply (rule_tac x="0 :: perm" in exI)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   573
apply (simp only: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   574
apply (simp add: permute_trm5_lts fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   575
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   576
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   577
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   578
lemma lets_not_ok1:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   579
  "x \<noteq> y \<Longrightarrow> (Lt5 (Lcons x (Vr5 x) (Lcons y (Vr5 y) Lnil)) (Ap5 (Vr5 x) (Vr5 y))) \<noteq>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
             (Lt5 (Lcons y (Vr5 x) (Lcons x (Vr5 y) Lnil)) (Ap5 (Vr5 x) (Vr5 y)))"
1200
a94c04c4a720 proof cleaning and standardizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1199
diff changeset
   581
apply (simp add: alpha5_INJ(3) alpha_gen)
a94c04c4a720 proof cleaning and standardizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1199
diff changeset
   582
apply (simp add: permute_trm5_lts fresh_star_def alpha5_INJ(5) alpha5_INJ(2) alpha5_INJ(1))
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   583
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   584
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   585
lemma distinct_helper:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   586
  shows "\<not>(rVr5 x \<approx>5 rAp5 y z)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   587
  apply auto
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   588
  apply (erule alpha_rtrm5.cases)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   589
  apply (simp_all only: rtrm5.distinct)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   590
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   591
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   592
lemma distinct_helper2:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   593
  shows "(Vr5 x) \<noteq> (Ap5 y z)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   594
  by (lifting distinct_helper)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   595
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   596
lemma lets_nok:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   597
  "x \<noteq> y \<Longrightarrow> x \<noteq> z \<Longrightarrow> z \<noteq> y \<Longrightarrow>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   598
   (Lt5 (Lcons x (Ap5 (Vr5 z) (Vr5 z)) (Lcons y (Vr5 z) Lnil)) (Ap5 (Vr5 x) (Vr5 y))) \<noteq>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   599
   (Lt5 (Lcons y (Vr5 z) (Lcons x (Ap5 (Vr5 z) (Vr5 z)) Lnil)) (Ap5 (Vr5 x) (Vr5 y)))"
1200
a94c04c4a720 proof cleaning and standardizing.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1199
diff changeset
   600
apply (simp only: alpha5_INJ(3) alpha5_INJ(5) alpha_gen permute_trm5_lts fresh_star_def)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   601
apply (simp add: distinct_helper2)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   602
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   603
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   604
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   605
(* example with a bn function defined over the type itself *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   606
datatype rtrm6 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   607
  rVr6 "name"
1205
acbf50e8eac2 Added missing description.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1202
diff changeset
   608
| rLm6 "name" "rtrm6" --"bind name in rtrm6"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   609
| rLt6 "rtrm6" "rtrm6" --"bind (bv6 left) in (right)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   610
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   611
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   612
  rbv6
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   613
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   614
  "rbv6 (rVr6 n) = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   615
| "rbv6 (rLm6 n t) = {atom n} \<union> rbv6 t"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   616
| "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   617
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   618
setup {* snd o define_raw_perms ["rtrm6"] ["Terms.rtrm6"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   619
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   620
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   621
local_setup {* snd o define_fv_alpha "Terms.rtrm6" [
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   622
  [[[]], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv6}, 0)]]]] *}
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   623
notation alpha_rtrm6 ("_ \<approx>6 _" [100, 100] 100)
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   624
(* HERE THE RULES DIFFER *)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   625
thm alpha_rtrm6.intros
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   626
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   627
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha6_inj}, []), (build_alpha_inj @{thms alpha_rtrm6.intros} @{thms rtrm6.distinct rtrm6.inject} @{thms alpha_rtrm6.cases} ctxt)) ctxt)) *}
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   628
thm alpha6_inj
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   629
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   630
lemma alpha6_eqvt:
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   631
  "xa \<approx>6 y \<Longrightarrow> (x \<bullet> xa) \<approx>6 (x \<bullet> y)"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   632
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   633
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   634
local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding alpha6_equivp}, []),
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   635
  (build_equivps [@{term alpha_rtrm6}] @{thm rtrm6.induct} @{thm alpha_rtrm6.induct} @{thms rtrm6.inject} @{thms alpha6_inj} @{thms rtrm6.distinct} @{thms alpha_rtrm6.cases} @{thms alpha6_eqvt} ctxt)) ctxt)) *}
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   636
thm alpha6_equivp
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   637
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   638
quotient_type
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   639
  trm6 = rtrm6 / alpha_rtrm6
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   640
  by (auto intro: alpha6_equivp)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   641
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   642
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   643
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   644
 |> snd o (Quotient_Def.quotient_lift_const ("Vr6", @{term rVr6}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   645
 |> snd o (Quotient_Def.quotient_lift_const ("Lm6", @{term rLm6}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   646
 |> snd o (Quotient_Def.quotient_lift_const ("Lt6", @{term rLt6}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   647
 |> snd o (Quotient_Def.quotient_lift_const ("fv_trm6", @{term fv_rtrm6}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   648
 |> snd o (Quotient_Def.quotient_lift_const ("bv6", @{term rbv6})))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   649
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   650
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   651
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   652
lemma [quot_respect]:
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   653
  "(op = ===> alpha_rtrm6 ===> alpha_rtrm6) permute permute"
1215
aec9576b3950 Testing auto equivp code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1214
diff changeset
   654
by (auto simp add: alpha6_eqvt)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   655
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   656
(* Definitely not true , see lemma below *)
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   657
lemma [quot_respect]:"(alpha_rtrm6 ===> op =) rbv6 rbv6"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   658
apply simp apply clarify
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   659
apply (erule alpha_rtrm6.induct)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   660
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   661
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   662
lemma "(a :: name) \<noteq> b \<Longrightarrow> \<not> (alpha_rtrm6 ===> op =) rbv6 rbv6"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   663
apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   664
apply (rule_tac x="rLm6 (a::name) (rVr6 (a :: name))" in  exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   665
apply (rule_tac x="rLm6 (b::name) (rVr6 (b :: name))" in  exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   666
apply simp
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   667
apply (simp add: alpha6_inj)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   668
apply (rule_tac x="(a \<leftrightarrow> b)" in  exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   669
apply (simp add: alpha_gen fresh_star_def)
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   670
apply (simp add: alpha6_inj)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   671
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   672
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   673
lemma fv6_rsp: "x \<approx>6 y \<Longrightarrow> fv_rtrm6 x = fv_rtrm6 y"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   674
apply (induct_tac x y rule: alpha_rtrm6.induct)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   675
apply simp_all
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   676
apply (erule exE)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   677
apply (simp_all add: alpha_gen)
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   678
done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   679
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   680
lemma [quot_respect]:"(alpha_rtrm6 ===> op =) fv_rtrm6 fv_rtrm6"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   681
by (simp add: fv6_rsp)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   682
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   683
lemma [quot_respect]:
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   684
 "(op = ===> alpha_rtrm6) rVr6 rVr6"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   685
 "(op = ===> alpha_rtrm6 ===> alpha_rtrm6) rLm6 rLm6"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   686
apply auto
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   687
apply (simp_all add: alpha6_inj)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   688
apply (rule_tac x="0::perm" in exI)
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   689
apply (simp add: alpha_gen fv6_rsp fresh_star_def fresh_zero_perm)
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   690
done
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   691
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   692
lemma [quot_respect]:
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   693
 "(alpha_rtrm6 ===> alpha_rtrm6 ===> alpha_rtrm6) rLt6 rLt6"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   694
apply auto
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   695
apply (simp_all add: alpha6_inj)
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   696
apply (rule_tac [!] x="0::perm" in exI)
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   697
apply (simp_all add: alpha_gen fresh_star_def fresh_zero_perm)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   698
(* needs rbv6_rsp *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   699
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   700
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   701
instantiation trm6 :: pt begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   702
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   703
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   704
  "permute_trm6 :: perm \<Rightarrow> trm6 \<Rightarrow> trm6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   705
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   706
  "permute :: perm \<Rightarrow> rtrm6 \<Rightarrow> rtrm6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   707
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   708
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   709
apply default
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   710
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   711
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   712
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   713
lemma lifted_induct:
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   714
"\<lbrakk>x1 = x2; \<And>name namea. name = namea \<Longrightarrow> P (Vr6 name) (Vr6 namea);
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   715
 \<And>name rtrm6 namea rtrm6a.
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   716
    \<lbrakk>True;
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   717
     \<exists>pi. fv_trm6 rtrm6 - {atom name} = fv_trm6 rtrm6a - {atom namea} \<and>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   718
          (fv_trm6 rtrm6 - {atom name}) \<sharp>* pi \<and> pi \<bullet> rtrm6 = rtrm6a \<and> P (pi \<bullet> rtrm6) rtrm6a\<rbrakk>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   719
    \<Longrightarrow> P (Lm6 name rtrm6) (Lm6 namea rtrm6a);
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   720
 \<And>rtrm61 rtrm61a rtrm62 rtrm62a.
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   721
    \<lbrakk>rtrm61 = rtrm61a; P rtrm61 rtrm61a;
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   722
     \<exists>pi. fv_trm6 rtrm62 - bv6 rtrm61 = fv_trm6 rtrm62a - bv6 rtrm61a \<and>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   723
          (fv_trm6 rtrm62 - bv6 rtrm61) \<sharp>* pi \<and> pi \<bullet> rtrm62 = rtrm62a \<and> P (pi \<bullet> rtrm62) rtrm62a\<rbrakk>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   724
    \<Longrightarrow> P (Lt6 rtrm61 rtrm62) (Lt6 rtrm61a rtrm62a)\<rbrakk>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   725
\<Longrightarrow> P x1 x2"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   726
apply (lifting alpha_rtrm6.induct[unfolded alpha_gen])
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   727
apply injection
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   728
(* notice unsolvable goals: (alpha_rtrm6 ===> op =) rbv6 rbv6 *)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   729
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   730
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   731
lemma lifted_inject_a3:
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   732
"(Lt6 rtrm61 rtrm62 = Lt6 rtrm61a rtrm62a) =
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   733
(rtrm61 = rtrm61a \<and>
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   734
 (\<exists>pi. fv_trm6 rtrm62 - bv6 rtrm61 = fv_trm6 rtrm62a - bv6 rtrm61a \<and>
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   735
       (fv_trm6 rtrm62 - bv6 rtrm61) \<sharp>* pi \<and> pi \<bullet> rtrm62 = rtrm62a))"
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   736
apply(lifting alpha6_inj(3)[unfolded alpha_gen])
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   737
apply injection
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   738
(* notice unsolvable goals: (alpha_rtrm6 ===> op =) rbv6 rbv6 *)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   739
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   740
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   741
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   742
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   743
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   744
(* example with a respectful bn function defined over the type itself *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   745
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   746
datatype rtrm7 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   747
  rVr7 "name"
1198
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
   748
| rLm7 "name" "rtrm7" --"bind left in right"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   749
| rLt7 "rtrm7" "rtrm7" --"bind (bv7 left) in (right)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   750
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   751
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   752
  rbv7
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   753
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   754
  "rbv7 (rVr7 n) = {atom n}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   755
| "rbv7 (rLm7 n t) = rbv7 t - {atom n}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   756
| "rbv7 (rLt7 l r) = rbv7 l \<union> rbv7 r"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   757
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   758
setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
1201
6d2200603585 Some adaptation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1200
diff changeset
   759
thm permute_rtrm7.simps
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   760
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   761
local_setup {* snd o define_fv_alpha "Terms.rtrm7" [
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   762
  [[[]], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv7}, 0)]]]] *}
1198
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
   763
print_theorems
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   764
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   765
  alpha_rtrm7 ("_ \<approx>7a _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   766
(* HERE THE RULES DIFFER *)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   767
thm alpha_rtrm7.intros
1198
5523d5713a65 Experiments for the pseudo-injectivity tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1197
diff changeset
   768
thm fv_rtrm7.simps
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   769
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   770
  alpha7 :: "rtrm7 \<Rightarrow> rtrm7 \<Rightarrow> bool" ("_ \<approx>7 _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   771
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   772
  a1: "a = b \<Longrightarrow> (rVr7 a) \<approx>7 (rVr7 b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   773
| a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha7 fv_rtrm7 pi ({atom b}, s))) \<Longrightarrow> rLm7 a t \<approx>7 rLm7 b s"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   774
| a3: "(\<exists>pi. (((rbv7 t1), s1) \<approx>gen alpha7 fv_rtrm7 pi ((rbv7 t2), s2))) \<Longrightarrow> rLt7 t1 s1 \<approx>7 rLt7 t2 s2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   775
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   776
lemma "(x::name) \<noteq> y \<Longrightarrow> \<not> (alpha7 ===> op =) rbv7 rbv7"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   777
  apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   778
  apply (rule_tac x="rLt7 (rVr7 x) (rVr7 x)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   779
  apply (rule_tac x="rLt7 (rVr7 y) (rVr7 y)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   780
  apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   781
  apply (rule a3)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   782
  apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   783
  apply (simp_all add: alpha_gen fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   784
  apply (rule a1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   785
  apply (rule refl)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   786
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   787
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   788
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   789
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   790
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   791
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   792
datatype rfoo8 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   793
  Foo0 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   794
| Foo1 "rbar8" "rfoo8" --"bind bv(bar) in foo"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   795
and rbar8 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   796
  Bar0 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   797
| Bar1 "name" "name" "rbar8" --"bind second name in b"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   798
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   799
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   800
  rbv8
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   801
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   802
  "rbv8 (Bar0 x) = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   803
| "rbv8 (Bar1 v x b) = {atom v}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   804
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   805
setup {* snd o define_raw_perms ["rfoo8", "rbar8"] ["Terms.rfoo8", "Terms.rbar8"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   806
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   807
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   808
local_setup {* snd o define_fv_alpha "Terms.rfoo8" [
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   809
  [[[]], [[], [(SOME @{term rbv8}, 0)]]], [[[]], [[], [(NONE, 1)], [(NONE, 1)]]]] *}
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   810
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   811
  alpha_rfoo8 ("_ \<approx>f' _" [100, 100] 100) and
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   812
  alpha_rbar8 ("_ \<approx>b' _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   813
(* HERE THE RULE DIFFERS *)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   814
thm alpha_rfoo8_alpha_rbar8.intros
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   815
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   816
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   817
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   818
  alpha8f :: "rfoo8 \<Rightarrow> rfoo8 \<Rightarrow> bool" ("_ \<approx>f _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   819
and
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   820
  alpha8b :: "rbar8 \<Rightarrow> rbar8 \<Rightarrow> bool" ("_ \<approx>b _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   821
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   822
  a1: "a = b \<Longrightarrow> (Foo0 a) \<approx>f (Foo0 b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   823
| a2: "a = b \<Longrightarrow> (Bar0 a) \<approx>b (Bar0 b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   824
| a3: "b1 \<approx>b b2 \<Longrightarrow> (\<exists>pi. (((rbv8 b1), t1) \<approx>gen alpha8f fv_rfoo8 pi ((rbv8 b2), t2))) \<Longrightarrow> Foo1 b1 t1 \<approx>f Foo1 b2 t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   825
| a4: "v1 = v2 \<Longrightarrow> (\<exists>pi. (({atom x1}, t1) \<approx>gen alpha8b fv_rbar8 pi ({atom x2}, t2))) \<Longrightarrow> Bar1 v1 x1 t1 \<approx>b Bar1 v2 x2 t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   826
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   827
lemma "(alpha8b ===> op =) rbv8 rbv8"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   828
  apply simp apply clarify
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   829
  apply (erule alpha8f_alpha8b.inducts(2))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   830
  apply (simp_all)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   831
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   832
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   833
lemma fv_rbar8_rsp_hlp: "x \<approx>b y \<Longrightarrow> fv_rbar8 x = fv_rbar8 y"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   834
  apply (erule alpha8f_alpha8b.inducts(2))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   835
  apply (simp_all add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   836
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   837
lemma "(alpha8b ===> op =) fv_rbar8 fv_rbar8"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   838
  apply simp apply clarify apply (simp add: fv_rbar8_rsp_hlp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   839
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   840
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   841
lemma "(alpha8f ===> op =) fv_rfoo8 fv_rfoo8"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   842
  apply simp apply clarify
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   843
  apply (erule alpha8f_alpha8b.inducts(1))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   844
  apply (simp_all add: alpha_gen fv_rbar8_rsp_hlp)
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   845
done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   846
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   847
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   848
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   849
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   850
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   851
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   852
datatype rlam9 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   853
  Var9 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   854
| Lam9 "name" "rlam9" --"bind name in rlam"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   855
and rbla9 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   856
  Bla9 "rlam9" "rlam9" --"bind bv(first) in second"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   857
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   858
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   859
  rbv9
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   860
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   861
  "rbv9 (Var9 x) = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   862
| "rbv9 (Lam9 x b) = {atom x}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   863
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   864
setup {* snd o define_raw_perms ["rlam9", "rbla9"] ["Terms.rlam9", "Terms.rbla9"] *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   865
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   866
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   867
local_setup {* snd o define_fv_alpha "Terms.rlam9" [
1202
ab942ba2d243 Removed bindings 'in itself' where possible.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1201
diff changeset
   868
  [[[]], [[(NONE, 0)], [(NONE, 0)]]], [[[], [(SOME @{term rbv9}, 0)]]]] *}
1193
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   869
notation
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   870
  alpha_rlam9 ("_ \<approx>9l' _" [100, 100] 100) and
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   871
  alpha_rbla9 ("_ \<approx>9b' _" [100, 100] 100)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   872
(* HERE THE RULES DIFFER *)
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   873
thm alpha_rlam9_alpha_rbla9.intros
a228acf2907e Full alpha equivalence + testing in terms. Some differ but it seems the generated version is more correct.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1190
diff changeset
   874
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   875
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   876
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   877
  alpha9l :: "rlam9 \<Rightarrow> rlam9 \<Rightarrow> bool" ("_ \<approx>9l _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   878
and
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   879
  alpha9b :: "rbla9 \<Rightarrow> rbla9 \<Rightarrow> bool" ("_ \<approx>9b _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   880
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   881
  a1: "a = b \<Longrightarrow> (Var9 a) \<approx>9l (Var9 b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   882
| a4: "(\<exists>pi. (({atom x1}, t1) \<approx>gen alpha9l fv_rlam9 pi ({atom x2}, t2))) \<Longrightarrow> Lam9 x1 t1 \<approx>9l Lam9 x2 t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   883
| a3: "b1 \<approx>9l b2 \<Longrightarrow> (\<exists>pi. (((rbv9 b1), t1) \<approx>gen alpha9l fv_rlam9 pi ((rbv9 b2), t2))) \<Longrightarrow> Bla9 b1 t1 \<approx>9b Bla9 b2 t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   884
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   885
quotient_type
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   886
  lam9 = rlam9 / alpha9l and bla9 = rbla9 / alpha9b
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   887
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   888
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   889
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   890
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   891
 |> snd o (Quotient_Def.quotient_lift_const ("qVar9", @{term Var9}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   892
 |> snd o (Quotient_Def.quotient_lift_const ("qLam9", @{term Lam9}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   893
 |> snd o (Quotient_Def.quotient_lift_const ("qBla9", @{term Bla9}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   894
 |> snd o (Quotient_Def.quotient_lift_const ("fv_lam9", @{term fv_rlam9}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   895
 |> snd o (Quotient_Def.quotient_lift_const ("fv_bla9", @{term fv_rbla9}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   896
 |> snd o (Quotient_Def.quotient_lift_const ("bv9", @{term rbv9})))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   897
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   898
print_theorems
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   899
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   900
instantiation lam9 and bla9 :: pt
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   901
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   902
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   903
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   904
  "permute_lam9 :: perm \<Rightarrow> lam9 \<Rightarrow> lam9"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   905
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   906
  "permute :: perm \<Rightarrow> rlam9 \<Rightarrow> rlam9"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   907
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   908
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   909
  "permute_bla9 :: perm \<Rightarrow> bla9 \<Rightarrow> bla9"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   910
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   911
  "permute :: perm \<Rightarrow> rbla9 \<Rightarrow> rbla9"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   912
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   913
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   914
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   915
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   916
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   917
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   918
lemma "\<lbrakk>b1 = b2; \<exists>pi. fv_lam9 t1 - bv9 b1 = fv_lam9 t2 - bv9 b2 \<and> (fv_lam9 t1 - bv9 b1) \<sharp>* pi \<and> pi \<bullet> t1 = t2\<rbrakk>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   919
 \<Longrightarrow> qBla9 b1 t1 = qBla9 b2 t2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   920
apply (lifting a3[unfolded alpha_gen])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   921
apply injection
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   922
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   923
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   924
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   925
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   926
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   927
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   928
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   929
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   930
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   931
text {* type schemes *} 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   932
datatype ty = 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   933
  Var "name" 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   934
| Fun "ty" "ty"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   935
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   936
setup {* snd o define_raw_perms ["ty"] ["Terms.ty"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   937
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   938
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   939
datatype tyS = 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   940
  All "name set" "ty" 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   941
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   942
setup {* snd o define_raw_perms ["tyS"] ["Terms.tyS"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   943
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   944
1199
5770c73f2415 Automatic production and proving of pseudo-injectivity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1198
diff changeset
   945
local_setup {* snd o define_fv_alpha "Terms.ty" [[[[]], [[], []]]] *}
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   946
print_theorems 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   947
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   948
(*
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
   949
Doesnot work yet since we do not refer to fv_ty
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   950
local_setup {* define_raw_fv "Terms.tyS" [[[[], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   951
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   952
*)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   953
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   954
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   955
  fv_tyS
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   956
where 
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
   957
  "fv_tyS (All xs T) = (fv_ty T - atom ` xs)"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   958
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   959
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   960
  alpha_tyS :: "tyS \<Rightarrow> tyS \<Rightarrow> bool" ("_ \<approx>tyS _" [100, 100] 100)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   961
where
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
   962
  a1: "\<exists>pi. ((atom ` xs1, T1) \<approx>gen (op =) fv_ty pi (atom ` xs2, T2)) 
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   963
        \<Longrightarrow> All xs1 T1 \<approx>tyS All xs2 T2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   964
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   965
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   966
  shows "All {a, b} (Fun (Var a) (Var b)) \<approx>tyS All {b, a} (Fun (Var a) (Var b))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   967
  apply(rule a1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   968
  apply(simp add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   969
  apply(rule_tac x="0::perm" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   970
  apply(simp add: fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   971
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   972
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   973
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   974
  shows "All {a, b} (Fun (Var a) (Var b)) \<approx>tyS All {a, b} (Fun (Var b) (Var a))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   975
  apply(rule a1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   976
  apply(simp add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   977
  apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   978
  apply(simp add: fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   979
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   980
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   981
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   982
  shows "All {a, b, c} (Fun (Var a) (Var b)) \<approx>tyS All {a, b} (Fun (Var a) (Var b))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   983
  apply(rule a1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   984
  apply(simp add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   985
  apply(rule_tac x="0::perm" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   986
  apply(simp add: fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   987
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   988
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   989
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   990
  assumes a: "a \<noteq> b"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   991
  shows "\<not>(All {a, b} (Fun (Var a) (Var b)) \<approx>tyS All {c} (Fun (Var c) (Var c)))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   992
  using a
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   993
  apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   994
  apply(erule alpha_tyS.cases)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   995
  apply(simp add: alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   996
  apply(erule conjE)+
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   997
  apply(erule exE)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   998
  apply(erule conjE)+
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   999
  apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1000
  apply(simp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1001
  apply(simp add: fresh_star_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1002
  apply(auto)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1003
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1004
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1005
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1006
end