Quot/Nominal/Terms.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 19 Feb 2010 10:17:35 +0100
changeset 1196 4efbaba9d754
parent 1193 a228acf2907e
child 1197 2f4ce88c2c96
permissions -rw-r--r--
Constructing alpha_inj goal.
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
1196
4efbaba9d754 Constructing alpha_inj goal.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1193
diff changeset
     2
imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "../../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
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
(* 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
    22
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  bv1
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  "bv1 (BUnit) = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
| "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
    28
| "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
    29
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
    30
setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
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
    31
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
local_setup {* 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
    33
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv1}, 0)], [], [(SOME @{term bv1}, 0)]]],
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
   [[], [[]], [[], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
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
    36
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
    37
  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
    38
  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
    39
thm alpha_rtrm1_alpha_bp.intros
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
1196
4efbaba9d754 Constructing alpha_inj goal.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1193
diff changeset
    41
prove {* build_alpha_inj_gl @{thms alpha_rtrm1_alpha_bp.intros} @{context} *}
4efbaba9d754 Constructing alpha_inj goal.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1193
diff changeset
    42
sorry
4efbaba9d754 Constructing alpha_inj goal.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1193
diff changeset
    43
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
lemma alpha1_inj:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
"(rVr1 a \<approx>1 rVr1 b) = (a = b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
"(rAp1 t1 s1 \<approx>1 rAp1 t2 s2) = (t1 \<approx>1 t2 \<and> s1 \<approx>1 s2)"
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
    47
"(rLm1 aa t \<approx>1 rLm1 ab s) = (\<exists>pi. (({atom aa}, t) \<approx>gen alpha_rtrm1 fv_rtrm1 pi ({atom ab}, 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
    48
"(rLt1 bp rtrm11 rtrm12 \<approx>1 rLt1 bpa rtrm11a rtrm12a) =
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
   ((\<exists>pi. (bv1 bp, bp) \<approx>gen alpha_bp fv_bp pi (bv1 bpa, bpa)) \<and> rtrm11 \<approx>1 rtrm11a \<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
    50
   (\<exists>pi. (bv1 bp, rtrm12) \<approx>gen alpha_rtrm1 fv_rtrm1 pi (bv1 bpa, rtrm12a)))"
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
"alpha_bp BUnit BUnit"
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
"(alpha_bp (BVr name) (BVr namea)) = (name = namea)"
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
"(alpha_bp (BPr bp1 bp2) (BPr bp1a bp2a)) = (alpha_bp bp1 bp1a \<and> alpha_bp bp2 bp2a)"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
apply -
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
    55
apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.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
    56
apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.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
    57
apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.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
    58
apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.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
    59
apply rule apply (erule alpha_bp.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.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
    60
apply rule apply (erule alpha_bp.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
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
    63
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
    64
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
    65
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
    66
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
    67
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
    68
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
    69
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
    70
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
    71
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
    72
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
    73
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
    74
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
    75
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
    76
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
    77
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
    78
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
lemma bv1_eqvt[eqvt]:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
  shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
  apply (induct x)
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
    82
apply (simp_all add: empty_eqvt insert_eqvt atom_eqvt eqvts)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
lemma fv_rtrm1_eqvt[eqvt]:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
    "(pi\<bullet>fv_rtrm1 t) = fv_rtrm1 (pi\<bullet>t)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
    "(pi\<bullet>fv_bp b) = fv_bp (pi\<bullet>b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
  apply (induct t and b)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
  apply (simp_all add: insert_eqvt atom_eqvt empty_eqvt union_eqvt Diff_eqvt bv1_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
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
    93
  "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
    94
  "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
    95
  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
    96
  apply (simp_all add:eqvts alpha1_inj)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
  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
    98
  apply (rule_tac x="pi \<bullet> pia" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
  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
   100
  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
   101
  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
   102
  apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  apply(simp add: atom_eqvt Diff_eqvt insert_eqvt empty_eqvt fv_rtrm1_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  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
   105
  apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
  apply(simp add: atom_eqvt Diff_eqvt fv_rtrm1_eqvt insert_eqvt empty_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
  apply(simp add: permute_eqvt[symmetric])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
  apply (erule exE)
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
   109
  apply (erule exE)
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
   110
  apply (rule conjI)
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
  apply (rule_tac x="pi \<bullet> pia" in exI)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
  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
   113
  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
   114
  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
   115
  apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
  apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
  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
   118
  apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
  apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
  apply(simp add: permute_eqvt[symmetric])
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
   121
  apply (rule_tac x="pi \<bullet> piaa" 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
   122
  apply (simp add: alpha_gen)
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
   123
  apply(erule conjE)+
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
   124
  apply(rule conjI)
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
   125
  apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
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
   126
  apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
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
   127
  apply(rule conjI)
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
   128
  apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
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
   129
  apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
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
   130
  apply(simp add: permute_eqvt[symmetric])
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
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
   133
lemma alpha1_equivp: "equivp alpha_rtrm1" 
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
  sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
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
   136
quotient_type trm1 = rtrm1 / alpha_rtrm1
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  by (rule alpha1_equivp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   139
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   140
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   141
 |> 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
   142
 |> 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
   143
 |> 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
   144
 |> 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
   145
 |> 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
   146
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   147
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
   148
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
lemma alpha_rfv1:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
  shows "t \<approx>1 s \<Longrightarrow> fv_rtrm1 t = fv_rtrm1 s"
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
   151
  apply(induct rule: alpha_rtrm1_alpha_bp.inducts(1))
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
  apply(simp_all add: alpha_gen.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
   153
  done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
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
   156
 "(op = ===> alpha_rtrm1) rVr1 rVr1"
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
   157
 "(alpha_rtrm1 ===> alpha_rtrm1 ===> alpha_rtrm1) rAp1 rAp1"
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
   158
 "(op = ===> alpha_rtrm1 ===> alpha_rtrm1) rLm1 rLm1"
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
   159
 "(op = ===> alpha_rtrm1 ===> alpha_rtrm1 ===> alpha_rtrm1) rLt1 rLt1"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
apply (auto 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
   161
apply (rule_tac x="0" in exI)
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 add: fresh_star_def fresh_zero_perm alpha_rfv1 alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
apply (rule_tac x="0" in exI)
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
   164
apply (simp add: alpha_gen fresh_star_def fresh_zero_perm alpha_rfv1 alpha_bp_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
   165
apply (rule_tac x="0" 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
   166
apply (simp add: alpha_gen fresh_star_def fresh_zero_perm alpha_rfv1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
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
   170
  "(op = ===> alpha_rtrm1 ===> alpha_rtrm1) 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
   171
  by (simp add: alpha1_eqvt)
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
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
   174
  "(alpha_rtrm1 ===> op =) fv_rtrm1 fv_rtrm1"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
  by (simp add: alpha_rfv1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
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
   178
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
   179
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
instantiation trm1 and bp :: pt
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  "permute_trm1 :: perm \<Rightarrow> trm1 \<Rightarrow> trm1"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
  "permute :: perm \<Rightarrow> rtrm1 \<Rightarrow> rtrm1"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
lemmas permute_trm1[simp] = permute_rtrm1_permute_bp.simps[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
apply default
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
apply(induct_tac [!] x rule: trm1_bp_inducts(1))
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
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
lemmas fv_trm1 = fv_rtrm1_fv_bp.simps[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
lemmas fv_trm1_eqvt = fv_rtrm1_eqvt[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
lemmas alpha1_INJ = alpha1_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
lemma lm1_supp_pre:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  shows "(supp (atom x, t)) supports (Lm1 x t) "
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
apply(simp add: supports_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
apply(fold fresh_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
apply(simp add: fresh_Pair swap_fresh_fresh)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
apply(subst swap_at_base_simps(3))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
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
   212
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
lemma lt1_supp_pre:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  shows "(supp (x, t, s)) supports (Lt1 t x s) "
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
apply(simp add: supports_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
apply(fold fresh_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
apply(simp add: fresh_Pair swap_fresh_fresh)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
done
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 bp_supp: "finite (supp (bp :: bp))"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  apply (induct bp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
  apply(simp_all add: supp_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
  apply (fold supp_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
  apply (simp add: supp_at_base)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   226
  apply(simp add: Collect_imp_eq)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
  apply(simp add: Collect_neg_eq[symmetric])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
  apply (fold supp_def)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
  apply (simp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
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
   233
apply default
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
apply(induct_tac x rule: trm1_bp_inducts(1))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
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
   236
apply(simp add: supp_def alpha1_INJ eqvts)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
apply(simp add: supp_def[symmetric] supp_at_base)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
apply(simp only: supp_def alpha1_INJ eqvts permute_trm1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
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
   240
apply(rule supports_finite)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
apply(rule lm1_supp_pre)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
apply(simp add: supp_Pair supp_atom)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
apply(rule supports_finite)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
apply(rule lt1_supp_pre)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
apply(simp add: supp_Pair supp_atom bp_supp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   248
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
   249
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
   250
apply(simp_all)
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   251
done
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   252
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
   253
lemma helper: "{b. \<forall>pi. pi \<bullet> (a \<rightleftharpoons> b) \<bullet> bp \<noteq> bp} = {}"
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
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
   255
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
   256
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
   257
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
   258
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
lemma supp_fv:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
  shows "supp t = fv_trm1 t"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
apply(induct t rule: trm1_bp_inducts(1))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
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
   263
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
   264
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
   265
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
   266
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
   267
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
   268
apply(simp add: supp_Abs fv_trm1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
apply(simp (no_asm) add: supp_def permute_set_eq atom_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
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
   271
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
   272
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
   273
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
   274
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
   275
apply(simp add: supp_Abs 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
   276
apply(simp (no_asm) add: supp_def)
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
   277
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
   278
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
   279
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
   280
apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv)
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
   281
apply(simp add: Collect_imp_eq Collect_neg_eq fresh_star_def helper)
1183
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   282
done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   284
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
   285
  "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
   286
  "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
   287
  "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
   288
  "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
   289
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
   290
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
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
   292
  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
   293
  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
   294
  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
   295
  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
   296
  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
   297
sorry
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
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
   300
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
datatype rtrm2 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
  rVr2 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
| 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
   304
| 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
   305
| 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
   306
and rassign =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
  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
   308
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
(* 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
   310
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
  rbv2
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
  "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
   314
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
   315
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
   316
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
   317
local_setup {* snd o define_fv_alpha "Terms.rtrm2"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv2}, 0)], [(SOME @{term rbv2}, 0)]]],
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
   [[[], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
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
   322
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
   323
  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
   324
  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
   325
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
   326
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
lemma alpha2_equivp:
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
   328
  "equivp alpha_rtrm2"
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
   329
  "equivp alpha_rassign"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
  sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
quotient_type
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
  trm2 = rtrm2 / alpha_rtrm2
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
and
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
   335
  assign = rassign / alpha_rassign
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
  by (auto intro: alpha2_equivp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   338
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   339
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   340
 |> 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
   341
 |> 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
   342
 |> 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
   343
 |> 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
   344
 |> 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
   345
 |> 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
   346
 |> 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
   347
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   348
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
   349
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   351
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
   352
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   353
datatype trm3 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
  Vr3 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
| Ap3 "trm3" "trm3"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
| Lm3 "name" "trm3" --"bind (name) in (trm3)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
| Lt3 "assigns" "trm3" --"bind (bv3 assigns) in (trm3)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
and assigns =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
  ANil
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
| ACons "name" "trm3" "assigns"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   362
(* 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
   363
primrec 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
  bv3
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   365
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
  "bv3 ANil = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
| "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
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
   369
setup {* snd o define_raw_perms ["rtrm3", "assigns"] ["Terms.trm3", "Terms.assigns"] *}
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
   370
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
   371
local_setup {* snd o define_fv_alpha "Terms.trm3"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
  [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv3}, 0)], [(SOME @{term bv3}, 0)]]],
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
   [[], [[], [], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
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
   376
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
   377
  alpha_trm3 ("_ \<approx>3 _" [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
   378
  alpha_assigns ("_ \<approx>3a _" [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
   379
thm alpha_trm3_alpha_assigns.intros
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
lemma alpha3_equivp:
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
   382
  "equivp alpha_trm3"
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
  "equivp alpha_assigns"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
  sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   386
quotient_type
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
   387
  qtrm3 = trm3 / alpha_trm3
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   388
and
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
   389
  qassigns = assigns / alpha_assigns
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   390
  by (auto intro: alpha3_equivp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   391
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   392
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   393
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
   394
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   395
datatype trm4 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   396
  Vr4 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   397
| Ap4 "trm4" "trm4 list"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   398
| Lm4 "name" "trm4"  --"bind (name) in (trm)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   400
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   401
thm trm4.recs
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
(* 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
   404
(* permutations are  already defined in Nominal (also functions, options, and so on) *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   405
setup {* snd o define_raw_perms ["trm4"] ["Terms.trm4"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   406
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   407
(* "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
   408
lemma repaired:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
  fixes ts::"trm4 list"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
  shows "permute_trm4_list p ts = p \<bullet> ts"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   411
  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
   412
  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
   413
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
thm permute_trm4_permute_trm4_list.simps
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   416
thm permute_trm4_permute_trm4_list.simps[simplified repaired]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
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
   418
local_setup {* snd o define_fv_alpha "Terms.trm4" [
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
   419
  [[[]], [[], []], [[(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
   420
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
   421
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
   422
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
   423
  alpha_trm4 ("_ \<approx>4 _" [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
   424
  alpha_trm4_list ("_ \<approx>4l _" [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
   425
thm alpha_trm4_alpha_trm4_list.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
   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
lemma alpha4_equivp: "equivp alpha_trm4" sorry
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
   428
lemma alpha4list_equivp: "equivp alpha_trm4_list" sorry
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   429
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
quotient_type 
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
   431
  qtrm4 = trm4 / alpha_trm4 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
   432
  qtrm4list = "trm4 list" / alpha_trm4_list
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   433
  by (simp_all add: alpha4_equivp alpha4list_equivp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   434
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   435
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   436
datatype rtrm5 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   437
  rVr5 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   438
| 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
   439
| 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
   440
and rlts =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   441
  rLnil
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   442
| 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
   443
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   444
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   445
  rbv5
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   446
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   447
  "rbv5 rLnil = {}"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   448
| "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
   449
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
   450
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
   451
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
   452
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
   453
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
   454
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
   455
  [[[]], [[], []], [[(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
   456
print_theorems
1187
3b24f33aedad Changed back to original version of trm5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1186
diff changeset
   457
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
   458
(* 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
   459
(*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
   460
  [[[]], [[], []], [[(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
   461
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
   462
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
   463
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
   464
  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
   465
  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
   466
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
   467
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   468
lemma alpha5_inj:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   469
  "((rVr5 a) \<approx>5 (rVr5 b)) = (a = b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   470
  "(rAp5 t1 s1 \<approx>5 rAp5 t2 s2) = (t1 \<approx>5 t2 \<and> s1 \<approx>5 s2)"
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
   471
  "(rLt5 l1 t1 \<approx>5 rLt5 l2 t2) = ((\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha_rtrm5 fv_rtrm5 pi (rbv5 l2, t2))) \<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
   472
         (\<exists>pi. ((rbv5 l1, l1) \<approx>gen alpha_rlts fv_rlts pi (rbv5 l2, l2))))"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   473
  "rLnil \<approx>l rLnil"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   474
  "(rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2) = (n1 = n2 \<and> ls1 \<approx>l ls2 \<and> t1 \<approx>5 t2)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   475
apply -
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
   476
apply (simp_all add: 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
   477
apply rule
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
   478
apply (erule alpha_rtrm5.cases)
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
   479
apply (simp_all add: 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
   480
apply rule
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
   481
apply (erule alpha_rtrm5.cases)
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
   482
apply (simp_all add: 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
   483
apply rule
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
   484
apply (erule alpha_rtrm5.cases)
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
   485
apply (simp_all add: 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
   486
apply rule
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
   487
apply (erule alpha_rlts.cases)
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
   488
apply (simp_all add: 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
   489
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   490
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   491
lemma alpha5_equivps:
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
   492
  shows "equivp alpha_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
   493
  and   "equivp alpha_rlts"
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   494
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   495
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   496
quotient_type
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
   497
  trm5 = rtrm5 / alpha_rtrm5
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   498
and
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
   499
  lts = rlts / alpha_rlts
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   500
  by (auto intro: alpha5_equivps)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   501
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   502
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   503
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   504
 |> snd o (Quotient_Def.quotient_lift_const ("Vr5", @{term rVr5}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   505
 |> snd o (Quotient_Def.quotient_lift_const ("Ap5", @{term rAp5}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   506
 |> snd o (Quotient_Def.quotient_lift_const ("Lt5", @{term rLt5}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   507
 |> snd o (Quotient_Def.quotient_lift_const ("Lnil", @{term rLnil}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   508
 |> snd o (Quotient_Def.quotient_lift_const ("Lcons", @{term rLcons}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   509
 |> snd o (Quotient_Def.quotient_lift_const ("fv_trm5", @{term fv_rtrm5}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   510
 |> snd o (Quotient_Def.quotient_lift_const ("fv_lts", @{term fv_rlts}))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   511
 |> snd o (Quotient_Def.quotient_lift_const ("bv5", @{term rbv5})))
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   512
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   513
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
   514
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   515
lemma rbv5_eqvt:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   516
  "pi \<bullet> (rbv5 x) = rbv5 (pi \<bullet> x)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   517
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   519
lemma fv_rtrm5_eqvt:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520
  "pi \<bullet> (fv_rtrm5 x) = fv_rtrm5 (pi \<bullet> x)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   521
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   522
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   523
lemma fv_rlts_eqvt:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
  "pi \<bullet> (fv_rlts x) = fv_rlts (pi \<bullet> x)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   525
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   526
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   527
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
   528
  "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
   529
  "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
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
   530
  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
   531
  apply (simp_all add: alpha5_inj)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   532
  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
   533
  apply(unfold alpha_gen)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   534
  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
   535
  apply (rule conjI)
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
   536
  apply (rule_tac x="x \<bullet> pia" 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
   537
  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
   538
  apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   539
  apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   540
  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
   541
  apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   542
  apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   543
  apply (subst permute_eqvt[symmetric])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   544
  apply (simp)
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
   545
  apply (rule_tac x="x \<bullet> pi" 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
   546
  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
   547
  apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   548
  apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   549
  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
   550
  apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   551
  apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   552
  apply (subst permute_eqvt[symmetric])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   553
  apply (simp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   554
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   555
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   556
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
   557
  "(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
   558
  "(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
   559
  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
   560
  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
   561
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   563
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
   564
  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
   565
  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
   566
  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
   567
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   569
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
   570
  "(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
   571
  "(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
   572
  "(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
   573
  "(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
   574
  "(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
   575
  "(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
   576
  "(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
   577
  "(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
   578
  "(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
   579
  "(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
   580
  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
   581
  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
   582
  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
   583
  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
   584
  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
   585
  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
   586
  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
   587
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   588
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   589
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
   590
  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
   591
  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
   592
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   593
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
   594
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   595
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
   596
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   597
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   598
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   599
  "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
   600
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   601
  "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
   602
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   603
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   604
  "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
   605
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   606
  "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
   607
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   608
lemma trm5_lts_zero:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   609
  "0 \<bullet> (x\<Colon>trm5) = x"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   610
  "0 \<bullet> (y\<Colon>lts) = y"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   611
apply(induct x and y rule: trm5_lts_inducts)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   612
apply(simp_all add: permute_rtrm5_permute_rlts.simps[quot_lifted])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   613
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   614
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   615
lemma trm5_lts_plus:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   616
  "(p + q) \<bullet> (x\<Colon>trm5) = p \<bullet> q \<bullet> x"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   617
  "(p + q) \<bullet> (y\<Colon>lts) = p \<bullet> q \<bullet> y"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   618
apply(induct x and y rule: trm5_lts_inducts)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   619
apply(simp_all add: permute_rtrm5_permute_rlts.simps[quot_lifted])
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   620
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   621
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   622
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   623
apply default
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   624
apply (simp_all add: trm5_lts_zero trm5_lts_plus)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   625
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   626
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   627
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   628
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   629
lemmas permute_trm5_lts = permute_rtrm5_permute_rlts.simps[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   630
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   631
lemmas alpha5_INJ = alpha5_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   632
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   633
lemmas bv5[simp] = rbv5.simps[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   634
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   635
lemmas fv_trm5_lts[simp] = fv_rtrm5_fv_rlts.simps[quot_lifted]
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   636
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   637
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
   638
  "(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
   639
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
   640
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
   641
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
   642
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
   643
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
   644
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
   645
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
   646
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
   647
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   648
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   649
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
   650
  "(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
   651
   (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
   652
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
   653
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
   654
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
   655
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
   656
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
   657
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
   658
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
   659
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
   660
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   661
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   662
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   663
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
   664
  "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
   665
             (Lt5 (Lcons y (Vr5 x) (Lcons x (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
   666
apply (subst alpha5_INJ(3))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   667
apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   668
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
   669
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
   670
apply (simp add: alpha5_INJ(5))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   671
apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   672
apply (simp add: alpha5_INJ(2))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   673
apply (simp only: alpha5_INJ(1))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   674
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   675
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   676
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
   677
  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
   678
  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
   679
  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
   680
  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
   681
  done
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 distinct_helper2:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   684
  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
   685
  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
   686
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   687
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
   688
  "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
   689
   (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
   690
   (Lt5 (Lcons y (Vr5 z) (Lcons x (Ap5 (Vr5 z) (Vr5 z)) 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
   691
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
   692
apply (simp only: alpha_gen 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
   693
apply (subst alpha5_INJ(5))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   694
apply (subst alpha5_INJ(5))
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   695
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
   696
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   697
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   698
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   699
(* 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
   700
datatype rtrm6 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   701
  rVr6 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   702
| rLm6 "name" "rtrm6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   703
| 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
   704
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   705
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   706
  rbv6
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   707
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   708
  "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
   709
| "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
   710
| "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
   711
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   712
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
   713
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   714
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
   715
local_setup {* snd o define_fv_alpha "Terms.rtrm6" [
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
   716
  [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv6}, 0)], [(SOME @{term rbv6}, 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
   717
notation alpha_rtrm6 ("_ \<approx>6a _" [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
   718
(* 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
   719
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
   720
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   721
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   722
  alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [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
   723
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   724
  a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   725
| a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha6 fv_rtrm6 pi ({atom b}, s))) \<Longrightarrow> rLm6 a t \<approx>6 rLm6 b s"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   726
| a3: "(\<exists>pi. (((rbv6 t1), s1) \<approx>gen alpha6 fv_rtrm6 pi ((rbv6 t2), s2))) \<Longrightarrow> rLt6 t1 s1 \<approx>6 rLt6 t2 s2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   727
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   728
lemma alpha6_equivps:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   729
  shows "equivp alpha6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   730
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   731
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   732
quotient_type
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   733
  trm6 = rtrm6 / alpha6
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   734
  by (auto intro: alpha6_equivps)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   735
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   736
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   737
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   738
 |> 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
   739
 |> 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
   740
 |> 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
   741
 |> 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
   742
 |> 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
   743
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   744
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
   745
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   746
lemma [quot_respect]:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   747
  "(op = ===> alpha6 ===> alpha6) permute permute"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   748
apply auto (* will work with eqvt *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   749
sorry
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
(* Definitely not true , see lemma below *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   752
lemma [quot_respect]:"(alpha6 ===> op =) rbv6 rbv6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   753
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
   754
apply (erule alpha6.induct)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   755
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   756
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   757
lemma "(a :: name) \<noteq> b \<Longrightarrow> \<not> (alpha6 ===> op =) rbv6 rbv6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   758
apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   759
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
   760
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
   761
apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   762
apply (rule a2)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   763
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
   764
apply (simp 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
   765
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
   766
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
   767
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   768
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   769
lemma [quot_respect]:"(alpha6 ===> op =) fv_rtrm6 fv_rtrm6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   770
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
   771
apply (induct_tac x y rule: alpha6.induct)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   772
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
   773
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
   774
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
   775
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
   776
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
   777
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
   778
apply (simp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   779
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   780
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   781
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   782
lemma [quot_respect]: "(op = ===> alpha6) rVr6 rVr6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   783
by (simp_all add: a1)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   784
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   785
lemma [quot_respect]:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   786
 "(op = ===> alpha6 ===> alpha6) rLm6 rLm6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   787
 "(alpha6 ===> alpha6 ===> alpha6) rLt6 rLt6"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   788
apply simp_all apply (clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   789
apply (rule a2)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   790
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
   791
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
   792
(* needs rfv6_rsp *) defer
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   793
apply clarify
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   794
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
   795
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
   796
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
   797
(* 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
   798
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   799
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   800
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
   801
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   802
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   803
  "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
   804
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   805
  "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
   806
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   807
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   808
apply default
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   809
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   810
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   811
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   812
lemma lifted_induct:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   813
"\<lbrakk>x1 = x2; \<And>a b. a = b \<Longrightarrow> P (Vr6 a) (Vr6 b);
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   814
 \<And>a t b s.
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   815
   \<exists>pi. fv_trm6 t - {atom a} = fv_trm6 s - {atom b} \<and>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   816
        (fv_trm6 t - {atom a}) \<sharp>* pi \<and> pi \<bullet> t = s \<and> P (pi \<bullet> t) s \<Longrightarrow>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   817
   P (Lm6 a t) (Lm6 b s);
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   818
 \<And>t1 s1 t2 s2.
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   819
   \<exists>pi. fv_trm6 s1 - bv6 t1 = fv_trm6 s2 - bv6 t2 \<and>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   820
        (fv_trm6 s1 - bv6 t1) \<sharp>* pi \<and> pi \<bullet> s1 = s2 \<and> P (pi \<bullet> s1) s2 \<Longrightarrow>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   821
   P (Lt6 t1 s1) (Lt6 t2 s2)\<rbrakk>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   822
 \<Longrightarrow> P x1 x2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   823
unfolding alpha_gen
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   824
apply (lifting alpha6.induct[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
   825
apply injection
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   826
(* notice unsolvable goals: (alpha6 ===> op =) rbv6 rbv6 *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   827
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   828
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   829
lemma lifted_inject_a3:
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   830
 "\<exists>pi. fv_trm6 s1 - bv6 t1 = fv_trm6 s2 - bv6 t2 \<and>
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   831
    (fv_trm6 s1 - bv6 t1) \<sharp>* pi \<and> pi \<bullet> s1 = s2 \<Longrightarrow> Lt6 t1 s1 = Lt6 t2 s2"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   832
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
   833
apply injection
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   834
(* notice unsolvable goals: (alpha6 ===> op =) rbv6 rbv6 *)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   835
oops
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   836
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   837
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   838
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   839
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   840
(* 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
   841
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   842
datatype rtrm7 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   843
  rVr7 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   844
| rLm7 "name" "rtrm7"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   845
| 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
   846
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   847
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   848
  rbv7
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   849
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   850
  "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
   851
| "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
   852
| "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
   853
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   854
setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   855
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   856
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
   857
local_setup {* snd o define_fv_alpha "Terms.rtrm7" [
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
   858
  [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv7}, 0)], [(SOME @{term rbv7}, 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
   859
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
   860
  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
   861
(* 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
   862
thm alpha_rtrm7.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
   863
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   864
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   865
  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
   866
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   867
  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
   868
| 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
   869
| 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
   870
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   871
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
   872
  apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   873
  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
   874
  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
   875
  apply simp
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   876
  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
   877
  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
   878
  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
   879
  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
   880
  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
   881
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   882
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   883
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
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   886
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   887
datatype rfoo8 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   888
  Foo0 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   889
| 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
   890
and rbar8 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   891
  Bar0 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   892
| 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
   893
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   894
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   895
  rbv8
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   896
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   897
  "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
   898
| "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
   899
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   900
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
   901
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   902
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
   903
local_setup {* snd o define_fv_alpha "Terms.rfoo8" [
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
   904
  [[[]], [[(SOME @{term rbv8}, 0)], [(SOME @{term rbv8}, 0)]]], [[[]], [[], [(NONE, 1)], [(NONE, 1)]]]] *}
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
   905
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
   906
  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
   907
  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
   908
(* 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
   909
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
   910
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
   911
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   912
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   913
  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
   914
and
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   915
  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
   916
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   917
  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
   918
| 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
   919
| 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
   920
| 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
   921
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   922
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
   923
  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
   924
  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
   925
  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
   926
done
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
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
   929
  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
   930
  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
   931
done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   932
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
   933
  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
   934
done
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
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
   937
  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
   938
  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
   939
  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
   940
  apply clarify
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   941
  apply (erule alpha8f_alpha8b.inducts(2))
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   942
  apply (simp_all)
cb3da5b540f2 Fixed proofs in Terms2 and found a mistake in Terms.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1182
diff changeset
   943
done
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   944
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   945
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   946
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
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   949
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   950
datatype rlam9 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   951
  Var9 "name"
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   952
| 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
   953
and rbla9 =
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   954
  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
   955
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   956
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   957
  rbv9
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   958
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   959
  "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
   960
| "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
   961
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
   962
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
   963
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   964
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
   965
local_setup {* snd o define_fv_alpha "Terms.rlam9" [
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
   966
  [[[]], [[(NONE, 0)], [(NONE, 0)]]], [[[(SOME @{term rbv9}, 0)], [(SOME @{term rbv9}, 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
   967
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
   968
  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
   969
  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
   970
(* 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
   971
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
   972
1182
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   973
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   974
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   975
  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
   976
and
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   977
  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
   978
where
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   979
  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
   980
| 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
   981
| 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
   982
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   983
quotient_type
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   984
  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
   985
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   986
1190
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   987
local_setup {*
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   988
(fn ctxt => ctxt
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   989
 |> 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
   990
 |> 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
   991
 |> 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
   992
 |> 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
   993
 |> 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
   994
 |> 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
   995
*}
d900d19931fa Testing auto constant lifting.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1187
diff changeset
   996
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
   997
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   998
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
   999
begin
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1000
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1001
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1002
  "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
  1003
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1004
  "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
  1005
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1006
quotient_definition
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1007
  "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
  1008
is
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1009
  "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
  1010
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1011
instance
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1012
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1013
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1014
end
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1015
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1016
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
  1017
 \<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
  1018
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
  1019
apply injection
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1020
sorry
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1021
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1022
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1023
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1024
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1025
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1026
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1027
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1028
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1029
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
  1030
datatype ty = 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1031
  Var "name" 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1032
| 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
  1033
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1034
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
  1035
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1036
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1037
datatype tyS = 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1038
  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
  1039
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1040
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
  1041
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1042
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1043
local_setup {* define_raw_fv "Terms.ty" [[[[]], [[], []]]] *}
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1044
print_theorems 
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1045
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1046
(*
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
  1047
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
  1048
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
  1049
print_theorems
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1050
*)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1051
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1052
primrec
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1053
  fv_tyS
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1054
where 
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
  1055
  "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
  1056
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1057
inductive
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1058
  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
  1059
where
1185
7566b899ca6a Code for handling atom sets.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1184
diff changeset
  1060
  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
  1061
        \<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
  1062
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1063
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1064
  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
  1065
  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
  1066
  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
  1067
  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
  1068
  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
  1069
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1070
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1071
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1072
  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
  1073
  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
  1074
  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
  1075
  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
  1076
  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
  1077
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1078
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1079
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1080
  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
  1081
  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
  1082
  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
  1083
  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
  1084
  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
  1085
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1086
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1087
lemma
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1088
  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
  1089
  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
  1090
  using a
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1091
  apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1092
  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
  1093
  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
  1094
  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
  1095
  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
  1096
  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
  1097
  apply(clarify)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1098
  apply(simp)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1099
  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
  1100
  apply(auto)
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1101
  done
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1102
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1103
3c32f91fa771 Terms2 with bindings for binders synchronized with bindings they are used in.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1104
end