Nominal/Ex/LamFun.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 19 May 2014 16:45:46 +0100
changeset 3236 e2da10806a34
parent 2950 0911cb7bf696
permissions -rw-r--r--
changed nominal_primrec to nominal_function and termination to nominal_termination
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2647
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2496
diff changeset
     1
theory LamFun
2496
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
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
nominal_datatype lam =
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
  Var "name"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
| App "lam" "lam"
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2648
diff changeset
    10
| Lam x::"name" l::"lam"  binds x in l
2496
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
thm lam.distinct
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
thm lam.induct
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
thm lam.exhaust
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
thm lam.fv_defs
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
thm lam.bn_defs
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
thm lam.perm_simps
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
thm lam.eq_iff
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
thm lam.fv_bn_eqvt
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
thm lam.size_eqvt
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
thm lam.size
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
thm lam_raw.size
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
thm lam.fresh
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
primrec match_Var_raw where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  "match_Var_raw (Var_raw x) = Some x"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
| "match_Var_raw (App_raw x y) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
| "match_Var_raw (Lam_raw n t) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
quotient_definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  "match_Var :: lam \<Rightarrow> name option"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
is match_Var_raw
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
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
    35
  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
    36
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
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
    38
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
primrec match_App_raw where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  "match_App_raw (Var_raw x) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
| "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
    42
| "match_App_raw (Lam_raw n t) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
quotient_definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  "match_App :: lam \<Rightarrow> (lam \<times> lam) option"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
is match_App_raw
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
lemma [quot_respect]:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  "(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
    50
  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
    51
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
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
    53
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
definition next_name where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
  "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
    56
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
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
    58
  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
    59
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
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
    62
  by (auto simp add: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
definition
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  "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
    66
    (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
    67
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
lemma match_Lam_simps:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  "match_Lam S (Var n) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  "match_Lam S (App l r) = None"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  "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
    72
  apply (simp_all add: match_Lam_def lam.distinct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
  apply (auto simp add: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
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
    77
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
    78
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
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
    81
  apply (induct x rule: lam.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
  apply (simp add: match_Lam_simps)
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 Let_def lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
  apply clarify
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
function subst where
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
"subst v s t = (
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  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
    91
  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
    92
  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
    93
print_theorems
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
thm subst_rel.intros[no_vars]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
by pat_completeness auto
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
termination apply (relation "measure (\<lambda>(_, _, t). size t)")
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  apply auto[1]
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
  apply (frule lam_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
  apply (frule app_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  apply (case_tac a) apply simp
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  apply (frule app_some) apply (simp add: lam.size)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
lemma subst_eqs:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
  "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
   109
  "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
   110
  "subst y s (Lam x t) =
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
    (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
   112
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  apply (simp only: match_Var_simps option.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
  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
   116
  apply (subst subst.simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
  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
   118
  done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
lemma subst_eqvt:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
  "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
   122
  proof (induct v s t rule: subst.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
    case (1 v s t)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
    show ?case proof (cases t rule: lam.exhaust)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
      fix n
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
      assume "t = Var n"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
      then show ?thesis by (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
    next
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
      fix l r
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
      assume "t = App l r"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
      then show ?thesis
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
        apply (simp only: subst_eqs lam.perm_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
        apply (subst 1(2)[of "(l, r)" "l" "r"])
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
        apply (subst 1(3)[of "(l, r)" "l" "r"])
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
        apply (rule refl)
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
        done
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
    next
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
      fix n t'
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
      assume "t = Lam n t'"
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
      then show ?thesis
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
        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
   148
        apply (subst 1(1))
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
        apply (simp add: match_Var_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
        apply (simp add: match_App_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
        apply (simp add: match_Lam_simps Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
        apply (rule refl)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
        (* next_name is not equivariant :( *)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
        apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
        sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
    qed
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
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
lemma subst_eqvt':
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
  "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
   161
  apply (induct t arbitrary: v s rule: lam.induct)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
  apply (simp only: subst_eqs lam.perm_simps eqvts)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  apply (simp only: subst_eqs lam.perm_simps)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  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
   165
  apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
lemma subst_eq3:
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
  "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
   170
  apply (simp only: subst_eqs Let_def)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
  apply (simp only: lam_eq)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
  (* p # y   p # s   subst_eqvt *)
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  (* 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
   174
  sorry
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
end
20ae67cb830a substitution definition with 'next_name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
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