Nominal/Ex/LamFun.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 24 Nov 2010 02:36:21 +0000
changeset 2581 3696659358c8
parent 2496 20ae67cb830a
child 2647 5e95387bef45
permissions -rw-r--r--
added example from the F-ing paper by Rossberg, Russo and Dreyer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2496
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory Lambda
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports "../Nominal2" Quotient_Option
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
atom_decl name
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
declare [[STEPS = 100]]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
nominal_datatype lam =
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
  Var "name"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
| App "lam" "lam"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
| Lam x::"name" l::"lam"  bind x in l
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
thm lam.distinct
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
thm lam.induct
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
thm lam.exhaust
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
thm lam.fv_defs
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
thm lam.bn_defs
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
thm lam.perm_simps
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
thm lam.eq_iff
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
thm lam.fv_bn_eqvt
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
thm lam.size_eqvt
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
thm lam.size
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
thm lam_raw.size
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
thm lam.fresh
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
primrec match_Var_raw where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  "match_Var_raw (Var_raw x) = Some x"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
| "match_Var_raw (App_raw x y) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
| "match_Var_raw (Lam_raw n t) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
quotient_definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
  "match_Var :: lam \<Rightarrow> name option"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
is match_Var_raw
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
lemma [quot_respect]: "(alpha_lam_raw ===> op =) match_Var_raw match_Var_raw"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
  by (rule, induct_tac a b rule: alpha_lam_raw.induct, simp_all)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
lemmas match_Var_simps = match_Var_raw.simps[quot_lifted]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
primrec match_App_raw where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  "match_App_raw (Var_raw x) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
| "match_App_raw (App_raw x y) = Some (x, y)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
| "match_App_raw (Lam_raw n t) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
quotient_definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  "match_App :: lam \<Rightarrow> (lam \<times> lam) option"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
is match_App_raw
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
lemma [quot_respect]:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
  "(alpha_lam_raw ===> option_rel (prod_rel alpha_lam_raw alpha_lam_raw)) match_App_raw match_App_raw"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  by (intro fun_relI, induct_tac a b rule: alpha_lam_raw.induct, simp_all)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
lemmas match_App_simps = match_App_raw.simps[quot_lifted]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
definition next_name where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  "next_name (s :: 'a :: fs) = (THE x. \<forall>a \<in> supp s. atom x \<noteq> a)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
lemma lam_eq: "Lam a t = Lam b s \<longleftrightarrow> (a \<leftrightarrow> b) \<bullet> t = s"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
  apply (simp add: lam.eq_iff Abs_eq_iff alphas)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
lemma lam_half_inj: "(Lam z s = Lam z sa) = (s = sa)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
  by (auto simp add: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  "match_Lam (S :: 'a :: fs) t = (if (\<exists>n s. (t = Lam n s)) then
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
    (let z = next_name (S, t) in Some (z, THE s. t = Lam z s)) else None)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
lemma match_Lam_simps:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  "match_Lam S (Var n) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  "match_Lam S (App l r) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
  "match_Lam S (Lam z s) = (let n = next_name (S, (Lam z s)) in Some (n, (z \<leftrightarrow> n) \<bullet> s))"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
  apply (simp_all add: match_Lam_def lam.distinct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  apply (auto simp add: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
lemma app_some: "match_App x = Some (a, b) \<Longrightarrow> x = App a b"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
by (induct x rule: lam.induct) (simp_all add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
lemma lam_some: "match_Lam S x = Some (n, t) \<Longrightarrow> x = Lam n t"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
  apply (induct x rule: lam.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
  apply (simp add: match_Lam_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
  apply (simp add: match_Lam_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
  apply (simp add: match_Lam_simps Let_def lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  apply clarify
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
function subst where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
"subst v s t = (
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
  case match_Var t of Some n \<Rightarrow> if n = v then s else Var n | None \<Rightarrow>
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
  case match_App t of Some (l, r) \<Rightarrow> App (subst v s l) (subst v s r) | None \<Rightarrow>
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
  case match_Lam (v, s) t of Some (n, s') \<Rightarrow> Lam n (subst v s s') | None \<Rightarrow> undefined)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
print_theorems
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
thm subst_rel.intros[no_vars]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
by pat_completeness auto
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
termination apply (relation "measure (\<lambda>(_, _, t). size t)")
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
  apply auto[1]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  apply (frule lam_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  apply (frule app_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
  apply (frule app_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
lemma subst_eqs:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  "subst y s (Var x) = (if x = y then s else (Var x))"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
  "subst y s (App l r) = App (subst y s l) (subst y s r)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
  "subst y s (Lam x t) =
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
    (let n = next_name ((y, s), Lam x t) in Lam n (subst y s ((x \<leftrightarrow> n) \<bullet> t)))"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
  apply (simp only: match_Var_simps option.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
  apply (simp only: match_App_simps option.simps prod.simps match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
  apply (simp only: match_App_simps option.simps prod.simps match_Var_simps match_Lam_simps Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
lemma subst_eqvt:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
  "p \<bullet> (subst v s t) = subst (p \<bullet> v) (p \<bullet> s) (p \<bullet> t)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
  proof (induct v s t rule: subst.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
    case (1 v s t)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
    show ?case proof (cases t rule: lam.exhaust)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
      fix n
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
      assume "t = Var n"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
      then show ?thesis by (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
    next
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
      fix l r
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
      assume "t = App l r"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
      then show ?thesis
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
        apply (simp only: subst_eqs lam.perm_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
        apply (subst 1(2)[of "(l, r)" "l" "r"])
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
        apply (subst 1(3)[of "(l, r)" "l" "r"])
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
        done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
    next
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
      fix n t'
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
      assume "t = Lam n t'"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
      then show ?thesis
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
        apply (simp only: subst_eqs lam.perm_simps Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
        apply (subst 1(1))
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
        apply (simp add: match_Lam_simps Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
        (* next_name is not equivariant :( *)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
        apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
        sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
    qed
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
  qed
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
lemma subst_eqvt':
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
  "p \<bullet> (subst v s t) = subst (p \<bullet> v) (p \<bullet> s) (p \<bullet> t)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
  apply (induct t arbitrary: v s rule: lam.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  apply (simp only: subst_eqs lam.perm_simps eqvts)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  apply (simp only: subst_eqs lam.perm_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
  apply (simp only: subst_eqs lam.perm_simps Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
  apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
lemma subst_eq3:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
  "atom x \<sharp> (y, s) \<Longrightarrow> subst y s (Lam x t) = Lam x (subst y s t)"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
  apply (simp only: subst_eqs Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
  apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  (* p # y   p # s   subst_eqvt *)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
  (* p \<bullet> -p \<bullet> (subst y s t) = subst y s t *)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
end
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180