Nominal/Ex/SingleLetFoo.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 14 May 2010 15:37:23 +0200
changeset 2133 16834a4ca1bb
parent 2132 d74e08799b63
child 2136 2fc55508a6d0
permissions -rw-r--r--
Proper fv/alpha for multiple compound binders
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2130
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory SingleLetFoo
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports "../NewParser"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
2132
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
     6
declare [[STEPS = 5]]
2130
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
atom_decl name
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
nominal_datatype trm =
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  Var "name"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
| App "trm" "trm"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
| Lam x::"name" t::"trm"  bind_set x in t
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
| Let a::"assg" t::"trm"  bind_set "bn a" in t
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
| Foo1 a1::"assg" a2::"assg" t::"trm" bind_set "bn a1" "bn a2" in t
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
| Foo2 x::name a::"assg" t::"trm" bind_set x "bn a" in t
2133
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2132
diff changeset
    17
2130
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
and assg =
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  As "name" "trm"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
binder
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  bn::"assg \<Rightarrow> atom set"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
where
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  "bn (As x t) = {atom x}"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
2132
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
    25
thm trm_assg.distinct
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
    26
thm trm_assg.eq_iff
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
    27
thm trm_assg.supp
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
    28
thm trm_assg.perm
2133
16834a4ca1bb Proper fv/alpha for multiple compound binders
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2132
diff changeset
    29
thm trm_assg.fv[simplified trm_assg.supp(1-2),no_vars]
2132
d74e08799b63 SingleLetFoo with everything.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2130
diff changeset
    30
2130
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
thm permute_trm_raw_permute_assg_raw.simps
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
thm fv_trm_raw.simps fv_assg_raw.simps fv_bn_raw.simps[no_vars]
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
(* there is something wrong with the free variables *)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
text {*
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
thm alpha_trm_raw_alpha_assg_raw_alpha_bn_raw.intros[no_vars]
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
*}
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
inductive 
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  alpha_trm_raw and alpha_assg_raw and alpha_bn_raw
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
where
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  "name = namea \<Longrightarrow> alpha_trm_raw (Var_raw name) (Var_raw namea)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
| "\<lbrakk>alpha_trm_raw trm_raw1 trm_raw1a; alpha_trm_raw trm_raw2 trm_raw2a\<rbrakk>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  \<Longrightarrow> alpha_trm_raw (App_raw trm_raw1 trm_raw2) (App_raw trm_raw1a trm_raw2a)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
| "\<exists>p. ({atom name}, trm_raw) \<approx>gen alpha_trm_raw fv_trm_raw p ({atom namea}, trm_rawa) \<Longrightarrow>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
   alpha_trm_raw (Lam_raw name trm_raw) (Lam_raw namea trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
| "\<lbrakk>\<exists>p. (bn_raw assg_raw, trm_raw) \<approx>gen alpha_trm_raw fv_trm_raw p (bn_raw assg_rawa, trm_rawa);
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
    alpha_bn_raw assg_raw assg_rawa\<rbrakk>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
    \<Longrightarrow> alpha_trm_raw (Let_raw assg_raw trm_raw) (Let_raw assg_rawa trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
| "\<lbrakk>\<exists>p. (bn_raw assg_raw1 \<union> bn_raw ass_raw2, trm_raw) \<approx>gen alpha_trm_raw fv_trm_raw p 
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
        (bn_raw assg_raw1a \<union> bn_raw ass_raw2a, trm_rawa);
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
   alpha_bn_raw assg_raw1 assg_raw1a; alpha_bn_raw assg_raw2 assg_raw2a\<rbrakk>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
   \<Longrightarrow> alpha_trm_raw (Foo1_raw assg_raw1 assg_raw2 trm_raw) (Foo1_raw assg_raw1a assg_raw2a trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
| "\<lbrakk>\<exists>p. ({atom name} \<union> bn_raw assg_raw, trm_raw) \<approx>gen alpha_trm_raw fv_trm_raw p 
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
        ({atom namea} \<union> bn_raw assg_rawa, trm_rawa);
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
   alpha_bn_raw assg_raw assg_rawa\<rbrakk>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
   \<Longrightarrow> alpha_trm_raw (Foo2_raw name assg_raw trm_raw) (Foo2_raw namea assg_rawa trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
| "\<lbrakk>name = namea; alpha_trm_raw trm_raw trm_rawa\<rbrakk>
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  \<Longrightarrow> alpha_assg_raw (As_raw name trm_raw) (As_raw namea trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
| "alpha_trm_raw trm_raw trm_rawa \<Longrightarrow> alpha_bn_raw (As_raw name trm_raw) (As_raw namea trm_rawa)"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
lemmas all = alpha_trm_raw_alpha_assg_raw_alpha_bn_raw.intros
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
lemma test: "p \<bullet> bn_raw \<equiv> bn_raw" sorry
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
lemma
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  assumes "distinct [x,y, z, u]"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  shows "alpha_trm_raw (Foo2_raw z (As_raw x (Var_raw z)) (Var_raw z))
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
                       (Foo2_raw u (As_raw y (Var_raw z)) (Var_raw u))"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
using assms
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
apply(rule_tac all)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
apply(rule_tac x="(z \<leftrightarrow> u) + (x \<leftrightarrow> y)" in exI)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
apply(simp only: alphas)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
apply(rule conjI)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
apply(simp add: supp_at_base fresh_star_def)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
apply(rule conjI)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
apply(simp add: supp_at_base fresh_star_def)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
apply(rule conjI)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
apply(rule all)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
unfolding flip_def
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
apply(perm_simp add: test)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
unfolding flip_def[symmetric]
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
apply(subst flip_at_base_simps(3))
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
apply(auto)[2]
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
apply(rule all)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
apply(rule all)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
apply(simp)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
done
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
lemma
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  assumes "distinct [x,y,z,u]"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  shows "fv_trm_raw (Foo2_raw z (As_raw x (Var_raw z)) (Var_raw z)) = {atom z}"
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
using assms
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
apply(simp add: supp_at_base)
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
end
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
5111dadd1162 added a more instructive example - has some problems with fv though
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107