src/HOL/Lambda/ParRed.thy
author wenzelm
Wed Nov 23 22:26:13 2005 +0100 (2005-11-23)
changeset 18241 afdba6b3e383
parent 16417 9bc16273c2d4
child 19086 1b3780be6cc2
permissions -rw-r--r--
tuned induction proofs;
nipkow@1120
     1
(*  Title:      HOL/Lambda/ParRed.thy
nipkow@1120
     2
    ID:         $Id$
nipkow@1120
     3
    Author:     Tobias Nipkow
nipkow@1120
     4
    Copyright   1995 TU Muenchen
nipkow@1120
     5
wenzelm@9811
     6
Properties of => and "cd", in particular the diamond property of => and
wenzelm@9811
     7
confluence of beta.
nipkow@1120
     8
*)
nipkow@1120
     9
wenzelm@9811
    10
header {* Parallel reduction and a complete developments *}
nipkow@1120
    11
haftmann@16417
    12
theory ParRed imports Lambda Commutation begin
wenzelm@9811
    13
wenzelm@9811
    14
wenzelm@9811
    15
subsection {* Parallel reduction *}
nipkow@1120
    16
wenzelm@9811
    17
consts
wenzelm@9811
    18
  par_beta :: "(dB \<times> dB) set"
nipkow@1120
    19
wenzelm@9811
    20
syntax
wenzelm@9811
    21
  par_beta :: "[dB, dB] => bool"  (infixl "=>" 50)
nipkow@1120
    22
translations
wenzelm@9811
    23
  "s => t" == "(s, t) \<in> par_beta"
nipkow@1120
    24
paulson@1789
    25
inductive par_beta
wenzelm@11638
    26
  intros
wenzelm@11638
    27
    var [simp, intro!]: "Var n => Var n"
wenzelm@11638
    28
    abs [simp, intro!]: "s => t ==> Abs s => Abs t"
wenzelm@12011
    29
    app [simp, intro!]: "[| s => s'; t => t' |] ==> s \<degree> t => s' \<degree> t'"
wenzelm@12011
    30
    beta [simp, intro!]: "[| s => s'; t => t' |] ==> (Abs s) \<degree> t => s'[t'/0]"
wenzelm@9811
    31
wenzelm@9811
    32
inductive_cases par_beta_cases [elim!]:
wenzelm@9811
    33
  "Var n => t"
wenzelm@9811
    34
  "Abs s => Abs t"
wenzelm@12011
    35
  "(Abs s) \<degree> t => u"
wenzelm@12011
    36
  "s \<degree> t => u"
wenzelm@9811
    37
  "Abs s => t"
wenzelm@9811
    38
wenzelm@9811
    39
wenzelm@9811
    40
subsection {* Inclusions *}
wenzelm@9811
    41
wenzelm@9811
    42
text {* @{text "beta \<subseteq> par_beta \<subseteq> beta^*"} \medskip *}
wenzelm@9811
    43
wenzelm@9811
    44
lemma par_beta_varL [simp]:
wenzelm@9811
    45
    "(Var n => t) = (t = Var n)"
wenzelm@18241
    46
  by blast
wenzelm@9811
    47
wenzelm@9811
    48
lemma par_beta_refl [simp]: "t => t"  (* par_beta_refl [intro!] causes search to blow up *)
wenzelm@18241
    49
  by (induct t) simp_all
wenzelm@9811
    50
wenzelm@9811
    51
lemma beta_subset_par_beta: "beta <= par_beta"
wenzelm@9811
    52
  apply (rule subsetI)
wenzelm@9811
    53
  apply clarify
wenzelm@9811
    54
  apply (erule beta.induct)
wenzelm@9811
    55
     apply (blast intro!: par_beta_refl)+
wenzelm@9811
    56
  done
wenzelm@9811
    57
wenzelm@9811
    58
lemma par_beta_subset_beta: "par_beta <= beta^*"
wenzelm@9811
    59
  apply (rule subsetI)
wenzelm@9811
    60
  apply clarify
wenzelm@9811
    61
  apply (erule par_beta.induct)
wenzelm@9811
    62
     apply blast
wenzelm@9811
    63
    apply (blast del: rtrancl_refl intro: rtrancl_into_rtrancl)+
wenzelm@9811
    64
      -- {* @{thm[source] rtrancl_refl} complicates the proof by increasing the branching factor *}
wenzelm@9811
    65
  done
wenzelm@9811
    66
wenzelm@9811
    67
wenzelm@9811
    68
subsection {* Misc properties of par-beta *}
wenzelm@9811
    69
wenzelm@18241
    70
lemma par_beta_lift [simp]:
wenzelm@18241
    71
    "t => t' \<Longrightarrow> lift t n => lift t' n"
wenzelm@18241
    72
  by (induct t fixing: t' n) fastsimp+
wenzelm@9811
    73
wenzelm@18241
    74
lemma par_beta_subst:
wenzelm@18241
    75
    "s => s' \<Longrightarrow> t => t' \<Longrightarrow> t[s/n] => t'[s'/n]"
wenzelm@18241
    76
  apply (induct t fixing: s s' t' n)
wenzelm@9811
    77
    apply (simp add: subst_Var)
wenzelm@9811
    78
   apply (erule par_beta_cases)
wenzelm@9811
    79
    apply simp
wenzelm@9811
    80
   apply (simp add: subst_subst [symmetric])
wenzelm@9811
    81
   apply (fastsimp intro!: par_beta_lift)
wenzelm@9811
    82
  apply fastsimp
wenzelm@9811
    83
  done
wenzelm@9811
    84
wenzelm@9811
    85
wenzelm@9811
    86
subsection {* Confluence (directly) *}
wenzelm@9811
    87
wenzelm@9811
    88
lemma diamond_par_beta: "diamond par_beta"
wenzelm@9811
    89
  apply (unfold diamond_def commute_def square_def)
wenzelm@9811
    90
  apply (rule impI [THEN allI [THEN allI]])
wenzelm@9811
    91
  apply (erule par_beta.induct)
wenzelm@9811
    92
     apply (blast intro!: par_beta_subst)+
wenzelm@9811
    93
  done
wenzelm@9811
    94
wenzelm@9811
    95
wenzelm@9811
    96
subsection {* Complete developments *}
nipkow@1120
    97
nipkow@1120
    98
consts
wenzelm@9811
    99
  "cd" :: "dB => dB"
wenzelm@9811
   100
recdef "cd" "measure size"
wenzelm@9811
   101
  "cd (Var n) = Var n"
wenzelm@12011
   102
  "cd (Var n \<degree> t) = Var n \<degree> cd t"
wenzelm@12011
   103
  "cd ((s1 \<degree> s2) \<degree> t) = cd (s1 \<degree> s2) \<degree> cd t"
wenzelm@12011
   104
  "cd (Abs u \<degree> t) = (cd u)[cd t/0]"
wenzelm@9811
   105
  "cd (Abs s) = Abs (cd s)"
wenzelm@9811
   106
wenzelm@18241
   107
lemma par_beta_cd: "s => t \<Longrightarrow> t => cd s"
wenzelm@18241
   108
  apply (induct s fixing: t rule: cd.induct)
wenzelm@9811
   109
      apply auto
wenzelm@9811
   110
  apply (fast intro!: par_beta_subst)
wenzelm@9811
   111
  done
nipkow@1120
   112
wenzelm@9811
   113
wenzelm@9811
   114
subsection {* Confluence (via complete developments) *}
wenzelm@9811
   115
wenzelm@9811
   116
lemma diamond_par_beta2: "diamond par_beta"
wenzelm@9811
   117
  apply (unfold diamond_def commute_def square_def)
wenzelm@9811
   118
  apply (blast intro: par_beta_cd)
wenzelm@9811
   119
  done
wenzelm@9811
   120
wenzelm@9811
   121
theorem beta_confluent: "confluent beta"
wenzelm@9811
   122
  apply (rule diamond_par_beta2 diamond_to_confluence
wenzelm@9811
   123
    par_beta_subset_beta beta_subset_par_beta)+
wenzelm@9811
   124
  done
wenzelm@9811
   125
wenzelm@11638
   126
end