Nominal/Ex/Lambda.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 14 Apr 2010 10:29:34 +0200
changeset 1828 f374ffd50c7c
parent 1818 37480540c1af
child 1831 16653e702d89
permissions -rw-r--r--
preliminary tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
     1
theory Lambda
1773
c0eac04ae3b4 added README and moved examples into separate directory
Christian Urban <urbanc@in.tum.de>
parents: 1599
diff changeset
     2
imports "../Parser"
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
atom_decl name
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
     7
nominal_datatype lam =
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
     8
  Var "name"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
     9
| App "lam" "lam"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    10
| Lam x::"name" l::"lam"  bind x in l
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    12
lemmas supp_fn' = lam.fv[simplified lam.supp]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    13
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    14
declare lam.perm[eqvt]
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    15
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    16
section {* Strong Induction Principles*}
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    18
(* 
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    19
  Old way of establishing strong induction
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    20
  principles by chosing a fresh name.
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    21
*)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
lemma
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  fixes c::"'a::fs"
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    24
  assumes a1: "\<And>name c. P c (Var name)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    25
  and     a2: "\<And>lam1 lam2 c. \<lbrakk>\<And>d. P d lam1; \<And>d. P d lam2\<rbrakk> \<Longrightarrow> P c (App lam1 lam2)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    26
  and     a3: "\<And>name lam c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lam\<rbrakk> \<Longrightarrow> P c (Lam name lam)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    27
  shows "P c lam"
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
proof -
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    29
  have "\<And>p. P c (p \<bullet> lam)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    30
    apply(induct lam arbitrary: c rule: lam.induct)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    31
    apply(perm_simp)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
    apply(rule a1)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    33
    apply(perm_simp)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
    apply(rule a2)
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    35
    apply(assumption)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
    apply(assumption)
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    37
    apply(subgoal_tac "\<exists>new::name. (atom new) \<sharp> (c, Lam (p \<bullet> name) (p \<bullet> lam))")
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
    defer
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
    apply(simp add: fresh_def)
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    40
    apply(rule_tac X="supp (c, Lam (p \<bullet> name) (p \<bullet> lam))" in obtain_at_base)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
    apply(simp add: supp_Pair finite_supp)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
    apply(blast)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
    apply(erule exE)
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    44
    apply(rule_tac t="p \<bullet> Lam name lam" and 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    45
                   s="(((p \<bullet> name) \<leftrightarrow> new) + p) \<bullet> Lam name lam" in subst)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    46
    apply(simp del: lam.perm)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    47
    apply(subst lam.perm)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    48
    apply(subst (2) lam.perm)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
    apply(rule flip_fresh_fresh)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
    apply(simp add: fresh_def)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
    apply(simp only: supp_fn')
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
    apply(simp)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
    apply(simp add: fresh_Pair)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
    apply(simp)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
    apply(rule a3)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
    apply(simp add: fresh_Pair)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
    apply(drule_tac x="((p \<bullet> name) \<leftrightarrow> new) + p" in meta_spec)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
    apply(simp)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
    done
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    60
  then have "P c (0 \<bullet> lam)" by blast
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    61
  then show "P c lam" by simp
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
qed
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    64
(* 
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    65
  New way of establishing strong induction
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    66
  principles by using a appropriate permutation.
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    67
*)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
lemma
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  fixes c::"'a::fs"
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    70
  assumes a1: "\<And>name c. P c (Var name)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    71
  and     a2: "\<And>lam1 lam2 c. \<lbrakk>\<And>d. P d lam1; \<And>d. P d lam2\<rbrakk> \<Longrightarrow> P c (App lam1 lam2)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    72
  and     a3: "\<And>name lam c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lam\<rbrakk> \<Longrightarrow> P c (Lam name lam)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    73
  shows "P c lam"
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
proof -
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    75
  have "\<And>p. P c (p \<bullet> lam)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    76
    apply(induct lam arbitrary: c rule: lam.induct)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    77
    apply(perm_simp)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
    apply(rule a1)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    79
    apply(perm_simp)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
    apply(rule a2)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
    apply(assumption)
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    82
    apply(assumption)
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    83
    apply(subgoal_tac "\<exists>q. (q \<bullet> {p \<bullet> atom name}) \<sharp>* c \<and> supp (p \<bullet> Lam name lam) \<sharp>* q")
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
    apply(erule exE)
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    85
    apply(rule_tac t="p \<bullet> Lam name lam" and 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    86
                   s="q \<bullet> p \<bullet> Lam name lam" in subst)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
    defer
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    88
    apply(simp)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
    apply(rule a3)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
    apply(simp add: eqvts fresh_star_def)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
    apply(drule_tac x="q + p" in meta_spec)
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
    apply(simp)
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    93
    apply(rule at_set_avoiding2)
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    94
    apply(simp add: finite_supp)
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    95
    apply(simp add: finite_supp)
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    96
    apply(simp add: finite_supp)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
    97
    apply(perm_simp)
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    98
    apply(simp add: fresh_star_def fresh_def supp_fn')
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    99
    apply(rule supp_perm_eq)
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
   100
    apply(simp)
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
   101
    done
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   102
  then have "P c (0 \<bullet> lam)" by blast
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   103
  then show "P c lam" by simp
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
qed
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   106
section {* Typing *}
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   107
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   108
nominal_datatype ty =
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   109
  TVar string
1810
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   110
| TFun ty ty
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   111
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   112
notation
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   113
 TFun ("_ \<rightarrow> _") 
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   114
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   115
declare ty.perm[eqvt]
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   116
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   117
inductive
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   118
  valid :: "(name \<times> ty) list \<Rightarrow> bool"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   119
where
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   120
  "valid []"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   121
| "\<lbrakk>atom x \<sharp> Gamma; valid Gamma\<rbrakk> \<Longrightarrow> valid ((x, T)#Gamma)"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   122
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   123
inductive
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   124
  typing :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow> bool" ("_ \<turnstile> _ : _" [60,60,60] 60) 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   125
where
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   126
    t_Var[intro]: "\<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   127
  | t_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1 \<rightarrow> T2 \<or> \<Gamma> \<turnstile> t2 : T1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : T2"
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   128
  | t_Lam[intro]: "\<lbrakk>atom x \<sharp> \<Gamma>; (x, T1) # \<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam x t : T1 \<rightarrow> T2"
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   129
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   130
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   131
ML {*
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   132
fun map_term f t = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   133
  (case f t of
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   134
     NONE => map_term' f t 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   135
   | x => x)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   136
and map_term' f (t $ u) = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   137
    (case (map_term f t, map_term f u) of
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   138
        (NONE, NONE) => NONE
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   139
      | (SOME t'', NONE) => SOME (t'' $ u)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   140
      | (NONE, SOME u'') => SOME (t $ u'')
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   141
      | (SOME t'', SOME u'') => SOME (t'' $ u''))
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   142
  | map_term' f (Abs (s, T, t)) = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   143
      (case map_term f t of
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   144
        NONE => NONE
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   145
      | SOME t'' => SOME (Abs (s, T, t'')))
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   146
  | map_term' _ _  = NONE;
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   147
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   148
fun map_thm_tac ctxt tac thm =
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   149
let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   150
  val monos = Inductive.get_monos ctxt
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   151
in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   152
  EVERY [cut_facts_tac [thm] 1, etac rev_mp 1,
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   153
    REPEAT_DETERM (FIRSTGOAL (resolve_tac monos)),
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   154
    REPEAT_DETERM (rtac impI 1 THEN (atac 1 ORELSE tac))]
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   155
end
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   156
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   157
(* 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   158
 proves F[f t] from F[t] where F[t] is the given theorem  
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   159
  
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   160
  - F needs to be monotone
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   161
  - f returns either SOME for a term it fires 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   162
    and NONE elsewhere 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   163
*)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   164
fun map_thm ctxt f tac thm =
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   165
let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   166
  val opt_goal_trm = map_term f (prop_of thm)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   167
  fun prove goal = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   168
    Goal.prove ctxt [] [] goal (fn _ => map_thm_tac ctxt tac thm)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   169
in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   170
  case opt_goal_trm of
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   171
    NONE => thm
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   172
  | SOME goal => prove goal
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   173
end
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   174
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   175
fun transform_prem ctxt names thm =
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   176
let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   177
  fun split_conj names (Const ("op &", _) $ p $ q) = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   178
      (case head_of p of
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   179
         Const (name, _) => if name mem names then SOME q else NONE
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   180
       | _ => NONE)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   181
  | split_conj _ _ = NONE;
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   182
in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   183
  map_thm ctxt (split_conj names) (etac conjunct2 1) thm
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   184
end
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   185
*}
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   186
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   187
ML {*
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   188
open Nominal_Permeq
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   189
*}
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   190
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   191
ML {* 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   192
fun single_case_tac ctxt pred_names pi intro  = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   193
let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   194
  val rule = Drule.instantiate' [] [SOME pi] @{thm permute_boolE}
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   195
in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   196
  eqvt_strict_tac ctxt [] [] THEN' 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   197
  SUBPROOF (fn {prems, context as ctxt, ...} =>
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   198
    let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   199
      val prems' = map (transform_prem ctxt pred_names) prems
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   200
      val side_cond_tac = EVERY' 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   201
        [ rtac rule, 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   202
          eqvt_strict_tac ctxt @{thms permute_minus_cancel(2)} [],
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   203
          resolve_tac prems' ]
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   204
    in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   205
      HEADGOAL (rtac intro THEN_ALL_NEW (resolve_tac prems' ORELSE' side_cond_tac)) 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   206
    end) ctxt
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   207
end
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   208
*}
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   209
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   210
ML {*
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   211
fun eqvt_rel_tac pred_name = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   212
let
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   213
  val thy = ProofContext.theory_of ctxt
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   214
  val ({names, ...}, {raw_induct, intrs, ...}) =
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   215
    Inductive.the_inductive ctxt (Sign.intern_const thy pred_name)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   216
  val param_no = length (Inductive.params_of raw_induct)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   217
  val (([raw_concl], [pi]), ctxt') = 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   218
    ctxt |> Variable.import_terms false [concl_of raw_induct] 
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   219
         ||>> Variable.variant_fixes ["pi"];
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   220
  val preds = map (fst o HOLogic.dest_imp)
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   221
    (HOLogic.dest_conj (HOLogic.dest_Trueprop raw_concl));
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   222
in
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   223
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   224
end
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   225
*}
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   226
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   227
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   228
1811
ae176476b525 implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1810
diff changeset
   229
lemma [eqvt]:
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   230
  assumes a: "valid Gamma" 
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   231
  shows "valid (p \<bullet> Gamma)"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   232
using a
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   233
apply(induct)
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   234
apply(tactic {* my_tac @{context} ["Lambda.valid"] @{cterm "- p"} @{thm valid.intros(1)} 1 *})
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   235
apply(tactic {* my_tac @{context }["Lambda.valid"] @{cterm "- p"} @{thm valid.intros(2)} 1 *})
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   236
done
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   237
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   238
lemma 
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   239
  shows "Gamma \<turnstile> t : T \<longrightarrow> (p \<bullet> Gamma) \<turnstile> (p \<bullet> t) : (p \<bullet> T)"
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   240
ML_prf {*
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   241
val ({names, ...}, {raw_induct, ...}) =
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   242
      Inductive.the_inductive @{context} (Sign.intern_const @{theory} "typing")
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   243
*}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   244
apply(tactic {* rtac raw_induct 1 *})
1828
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   245
apply(tactic {* my_tac @{context} ["Lambda.typing"] @{cterm "- p"} @{thm typing.intros(1)} 1 *})
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   246
apply(tactic {* my_tac @{context} ["Lambda.typing"] @{cterm "- p"} @{thm typing.intros(2)} 1 *})
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   247
apply(tactic {* my_tac @{context} ["Lambda.typing"] @{cterm "- p"} @{thm typing.intros(3)} 1 *})
f374ffd50c7c preliminary tests
Christian Urban <urbanc@in.tum.de>
parents: 1818
diff changeset
   248
done
1814
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   249
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   250
lemma uu[eqvt]:
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   251
  assumes a: "Gamma \<turnstile> t : T" 
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   252
  shows "(p \<bullet> Gamma) \<turnstile> (p \<bullet> t) : (p \<bullet> T)"
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   253
using a
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   254
apply(induct)
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   255
apply(tactic {* my_tac @{context} @{thms typing.intros} 1 *})
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   256
apply(perm_strict_simp)
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   257
apply(rule typing.intros)
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   258
apply(rule conj_mono[THEN mp])
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   259
prefer 3
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   260
apply(assumption)
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   261
apply(rule impI)
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   262
prefer 2
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   263
apply(rule impI)
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   264
apply(simp)
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   265
apply(auto)[1]
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   266
apply(simp)
1814
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   267
apply(tactic {* my_tac @{context} @{thms typing.intros} 1 *})
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   268
done
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   269
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   270
(*
1814
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   271
inductive
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   272
  typing :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow> bool" ("_ \<turnstile> _ : _" [60,60,60] 60) 
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   273
where
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   274
    t_Var[intro]: "\<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   275
  | t_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1 \<rightarrow> T2 \<and> \<Gamma> \<turnstile> t2 : T1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : T2"
1810
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   276
  | t_Lam[intro]: "\<lbrakk>atom x \<sharp> \<Gamma>; (x, T1) # \<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam x t : T1 \<rightarrow> T2"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   277
1811
ae176476b525 implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1810
diff changeset
   278
lemma uu[eqvt]:
1810
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   279
  assumes a: "Gamma \<turnstile> t : T" 
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   280
  shows "(p \<bullet> Gamma) \<turnstile> (p \<bullet> t) : (p \<bullet> T)"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   281
using a
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   282
apply(induct)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   283
apply(tactic {* my_tac @{context} @{thms typing.intros} 1 *})
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   284
apply(tactic {* my_tac @{context} @{thms typing.intros} 1 *})
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   285
apply(tactic {* my_tac @{context} @{thms typing.intros} 1 *})
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   286
done
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   287
*)
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   288
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   289
ML {*
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   290
val inductive_atomize = @{thms induct_atomize};
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   291
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   292
val atomize_conv =
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   293
  MetaSimplifier.rewrite_cterm (true, false, false) (K (K NONE))
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   294
    (HOL_basic_ss addsimps inductive_atomize);
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   295
val atomize_intr = Conv.fconv_rule (Conv.prems_conv ~1 atomize_conv);
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   296
fun atomize_induct ctxt = Conv.fconv_rule (Conv.prems_conv ~1
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   297
  (Conv.params_conv ~1 (K (Conv.prems_conv ~1 atomize_conv)) ctxt));
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   298
*}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   299
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   300
ML {*
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   301
val ({names, ...}, {raw_induct, intrs, elims, ...}) =
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   302
      Inductive.the_inductive @{context} (Sign.intern_const @{theory} "typing")
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   303
*}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   304
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   305
ML {* val ind_params = Inductive.params_of raw_induct *}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   306
ML {* val raw_induct = atomize_induct @{context} raw_induct; *}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   307
ML {* val elims = map (atomize_induct @{context}) elims; *}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   308
ML {* val monos = Inductive.get_monos @{context}; *}
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   309
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   310
lemma 
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   311
  shows "Gamma \<turnstile> t : T \<longrightarrow> (p \<bullet> Gamma) \<turnstile> (p \<bullet> t) : (p \<bullet> T)"
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   312
apply(tactic {* rtac raw_induct 1 *})
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   313
apply(tactic {* my_tac @{context} intrs 1 *})
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   314
apply(perm_strict_simp)
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   315
apply(rule typing.intros)
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   316
oops
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1814
diff changeset
   317
1810
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   318
1811
ae176476b525 implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1810
diff changeset
   319
thm eqvts
ae176476b525 implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1810
diff changeset
   320
thm eqvts_raw
ae176476b525 implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1810
diff changeset
   321
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   322
declare permute_lam_raw.simps[eqvt]
1814
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   323
thm alpha_gen_real_eqvt
01ae96fa4bf9 early ott paper
Christian Urban <urbanc@in.tum.de>
parents: 1811
diff changeset
   324
(*declare alpha_gen_real_eqvt[eqvt]*)
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   325
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   326
lemma
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   327
  assumes a: "alpha_lam_raw t1 t2"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   328
  shows "alpha_lam_raw (p \<bullet> t1) (p \<bullet> t2)"
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   329
using a
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   330
apply(induct)
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   331
apply(tactic {* my_tac @{context} @{thms alpha_lam_raw.intros} 1 *})
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   332
oops
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   333
1810
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   334
thm alpha_lam_raw.intros[no_vars]
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   335
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   336
inductive
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   337
 alpha_lam_raw'
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   338
where
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   339
  "name = namea \<Longrightarrow> alpha_lam_raw' (Var_raw name) (Var_raw namea)"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   340
| "\<lbrakk>alpha_lam_raw' lam_raw1 lam_raw1a; alpha_lam_raw' lam_raw2 lam_raw2a\<rbrakk> \<Longrightarrow>
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   341
   alpha_lam_raw' (App_raw lam_raw1 lam_raw2) (App_raw lam_raw1a lam_raw2a)"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   342
| "\<exists>pi. ({atom name}, lam_raw) \<approx>gen alpha_lam_raw fv_lam_raw pi ({atom namea}, lam_rawa) \<Longrightarrow>
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   343
   alpha_lam_raw' (Lam_raw name lam_raw) (Lam_raw namea lam_rawa)"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   344
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   345
lemma
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   346
  assumes a: "alpha_lam_raw' t1 t2"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   347
  shows "alpha_lam_raw' (p \<bullet> t1) (p \<bullet> t2)"
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   348
using a
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   349
apply(induct)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   350
apply(tactic {* my_tac @{context} @{thms alpha_lam_raw'.intros} 1 *})
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   351
apply(tactic {* my_tac @{context} @{thms alpha_lam_raw'.intros} 1 *})
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   352
apply(perm_strict_simp)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   353
apply(rule alpha_lam_raw'.intros)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   354
apply(simp add: alphas)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   355
apply(rule_tac p="- p" in permute_boolE)
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   356
apply(perm_simp permute_minus_cancel(2))
894930834ca8 fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents: 1805
diff changeset
   357
oops
1805
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   358
f187f20f0a79 a few tests
Christian Urban <urbanc@in.tum.de>
parents: 1800
diff changeset
   359
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   360
section {* size function *}
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   361
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   362
lemma size_eqvt_raw:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   363
  fixes t::"lam_raw"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   364
  shows "size (pi \<bullet> t)  = size t"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   365
  apply (induct rule: lam_raw.inducts)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   366
  apply simp_all
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   367
  done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   368
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   369
instantiation lam :: size 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   370
begin
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   371
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   372
quotient_definition
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   373
  "size_lam :: lam \<Rightarrow> nat"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   374
is
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   375
  "size :: lam_raw \<Rightarrow> nat"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   376
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   377
lemma size_rsp:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   378
  "alpha_lam_raw x y \<Longrightarrow> size x = size y"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   379
  apply (induct rule: alpha_lam_raw.inducts)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   380
  apply (simp_all only: lam_raw.size)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   381
  apply (simp_all only: alphas)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   382
  apply clarify
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   383
  apply (simp_all only: size_eqvt_raw)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   384
  done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   385
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   386
lemma [quot_respect]:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   387
  "(alpha_lam_raw ===> op =) size size"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   388
  by (simp_all add: size_rsp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   389
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   390
lemma [quot_preserve]:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   391
  "(rep_lam ---> id) size = size"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   392
  by (simp_all add: size_lam_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   393
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   394
instance
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   395
  by default
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   396
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   397
end
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   398
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   399
lemmas size_lam[simp] = 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   400
  lam_raw.size(4)[quot_lifted]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   401
  lam_raw.size(5)[quot_lifted]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   402
  lam_raw.size(6)[quot_lifted]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   403
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   404
(* is this needed? *)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   405
lemma [measure_function]: 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   406
  "is_measure (size::lam\<Rightarrow>nat)" 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   407
  by (rule is_measure_trivial)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   408
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   409
section {* Matching *}
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   410
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   411
definition
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   412
  MATCH :: "('c::pt \<Rightarrow> (bool * 'a::pt * 'b::pt)) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   413
where
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   414
  "MATCH M d x \<equiv> if (\<exists>!r. \<exists>q. M q = (True, x, r)) then (THE r. \<exists>q. M q = (True, x, r)) else d"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   415
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   416
(*
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   417
lemma MATCH_eqvt:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   418
  shows "p \<bullet> (MATCH M d x) = MATCH (p \<bullet> M) (p \<bullet> d) (p \<bullet> x)"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   419
unfolding MATCH_def
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   420
apply(perm_simp the_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   421
apply (tactic {* Nominal_Permeq.eqvt_tac @{context} 1 *})
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   422
apply(simp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   423
thm eqvts_raw 
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   424
apply(subst if_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   425
apply(subst ex1_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   426
apply(subst permute_fun_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   427
apply(subst ex_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   428
apply(subst permute_fun_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   429
apply(subst eq_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   430
apply(subst permute_fun_app_eq[where f="M"])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   431
apply(simp only: permute_minus_cancel)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   432
apply(subst permute_prod.simps)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   433
apply(subst permute_prod.simps)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   434
apply(simp only: permute_minus_cancel)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   435
apply(simp only: permute_bool_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   436
apply(simp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   437
apply(subst ex1_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   438
apply(subst permute_fun_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   439
apply(subst ex_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   440
apply(subst permute_fun_def)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   441
apply(subst eq_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   442
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   443
apply(simp only: eqvts)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   444
apply(simp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   445
apply(subgoal_tac "(p \<bullet> (\<exists>!r. \<exists>q. M q = (True, x, r))) = (\<exists>!r. \<exists>q. (p \<bullet> M) q = (True, p \<bullet> x, r))")
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   446
apply(drule sym)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   447
apply(simp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   448
apply(rule impI)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   449
apply(simp add: perm_bool)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   450
apply(rule trans)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   451
apply(rule pt_the_eqvt[OF pta at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   452
apply(assumption)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   453
apply(simp add: pt_ex_eqvt[OF pt at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   454
apply(simp add: pt_eq_eqvt[OF ptb at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   455
apply(rule cheat)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   456
apply(rule trans)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   457
apply(rule pt_ex1_eqvt)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   458
apply(rule pta)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   459
apply(rule at)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   460
apply(simp add: pt_ex_eqvt[OF pt at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   461
apply(simp add: pt_eq_eqvt[OF ptb at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   462
apply(subst pt_pi_rev[OF pta at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   463
apply(subst pt_fun_app_eq[OF pt at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   464
apply(subst pt_pi_rev[OF pt at])
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   465
apply(simp)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   466
done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   467
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   468
lemma MATCH_cng:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   469
  assumes a: "M1 = M2" "d1 = d2"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   470
  shows "MATCH M1 d1 x = MATCH M2 d2 x"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   471
using a by simp
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   472
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   473
lemma MATCH_eq:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   474
  assumes a: "t = l x" "G x" "\<And>x'. t = l x' \<Longrightarrow> G x' \<Longrightarrow> r x' = r x"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   475
  shows "MATCH (\<lambda>x. (G x, l x, r x)) d t = r x"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   476
using a
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   477
unfolding MATCH_def
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   478
apply(subst if_P)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   479
apply(rule_tac a="r x" in ex1I)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   480
apply(rule_tac x="x" in exI)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   481
apply(blast)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   482
apply(erule exE)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   483
apply(drule_tac x="q" in meta_spec)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   484
apply(auto)[1]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   485
apply(rule the_equality)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   486
apply(blast)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   487
apply(erule exE)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   488
apply(drule_tac x="q" in meta_spec)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   489
apply(auto)[1]
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   490
done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   491
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   492
lemma MATCH_eq2:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   493
  assumes a: "t = l x1 x2" "G x1 x2" "\<And>x1' x2'. t = l x1' x2' \<Longrightarrow> G x1' x2' \<Longrightarrow> r x1' x2' = r x1 x2"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   494
  shows "MATCH (\<lambda>(x1,x2). (G x1 x2, l x1 x2, r x1 x2)) d t = r x1 x2"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   495
sorry
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   496
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   497
lemma MATCH_neq:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   498
  assumes a: "\<And>x. t = l x \<Longrightarrow> G x \<Longrightarrow> False"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   499
  shows "MATCH (\<lambda>x. (G x, l x, r x)) d t = d"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   500
using a
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   501
unfolding MATCH_def
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   502
apply(subst if_not_P)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   503
apply(blast)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   504
apply(rule refl)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   505
done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   506
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   507
lemma MATCH_neq2:
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   508
  assumes a: "\<And>x1 x2. t = l x1 x2 \<Longrightarrow> G x1 x2 \<Longrightarrow> False"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   509
  shows "MATCH (\<lambda>(x1,x2). (G x1 x2, l x1 x2, r x1 x2)) d t = d"
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   510
using a
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   511
unfolding MATCH_def
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   512
apply(subst if_not_P)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   513
apply(auto)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   514
done
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   515
*)
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
   516
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   517
end
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   519
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520