src/HOL/Lambda/ParRed.thy
author haftmann
Mon Aug 14 13:46:06 2006 +0200 (2006-08-14)
changeset 20380 14f9f2a1caa6
parent 19363 667b5ea637dd
child 20503 503ac4c5ef91
permissions -rw-r--r--
simplified code generator setup
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@19363
    20
abbreviation
wenzelm@19086
    21
  par_beta_red :: "[dB, dB] => bool"  (infixl "=>" 50)
wenzelm@19363
    22
  "s => t == (s, t) \<in> par_beta"
nipkow@1120
    23
paulson@1789
    24
inductive par_beta
wenzelm@11638
    25
  intros
wenzelm@11638
    26
    var [simp, intro!]: "Var n => Var n"
wenzelm@11638
    27
    abs [simp, intro!]: "s => t ==> Abs s => Abs t"
wenzelm@12011
    28
    app [simp, intro!]: "[| s => s'; t => t' |] ==> s \<degree> t => s' \<degree> t'"
wenzelm@12011
    29
    beta [simp, intro!]: "[| s => s'; t => t' |] ==> (Abs s) \<degree> t => s'[t'/0]"
wenzelm@9811
    30
wenzelm@9811
    31
inductive_cases par_beta_cases [elim!]:
wenzelm@9811
    32
  "Var n => t"
wenzelm@9811
    33
  "Abs s => Abs t"
wenzelm@12011
    34
  "(Abs s) \<degree> t => u"
wenzelm@12011
    35
  "s \<degree> t => u"
wenzelm@9811
    36
  "Abs s => t"
wenzelm@9811
    37
wenzelm@9811
    38
wenzelm@9811
    39
subsection {* Inclusions *}
wenzelm@9811
    40
wenzelm@9811
    41
text {* @{text "beta \<subseteq> par_beta \<subseteq> beta^*"} \medskip *}
wenzelm@9811
    42
wenzelm@9811
    43
lemma par_beta_varL [simp]:
wenzelm@9811
    44
    "(Var n => t) = (t = Var n)"
wenzelm@18241
    45
  by blast
wenzelm@9811
    46
wenzelm@9811
    47
lemma par_beta_refl [simp]: "t => t"  (* par_beta_refl [intro!] causes search to blow up *)
wenzelm@18241
    48
  by (induct t) simp_all
wenzelm@9811
    49
wenzelm@9811
    50
lemma beta_subset_par_beta: "beta <= par_beta"
wenzelm@9811
    51
  apply (rule subsetI)
wenzelm@9811
    52
  apply clarify
wenzelm@9811
    53
  apply (erule beta.induct)
wenzelm@9811
    54
     apply (blast intro!: par_beta_refl)+
wenzelm@9811
    55
  done
wenzelm@9811
    56
wenzelm@9811
    57
lemma par_beta_subset_beta: "par_beta <= beta^*"
wenzelm@9811
    58
  apply (rule subsetI)
wenzelm@9811
    59
  apply clarify
wenzelm@9811
    60
  apply (erule par_beta.induct)
wenzelm@9811
    61
     apply blast
wenzelm@9811
    62
    apply (blast del: rtrancl_refl intro: rtrancl_into_rtrancl)+
wenzelm@9811
    63
      -- {* @{thm[source] rtrancl_refl} complicates the proof by increasing the branching factor *}
wenzelm@9811
    64
  done
wenzelm@9811
    65
wenzelm@9811
    66
wenzelm@9811
    67
subsection {* Misc properties of par-beta *}
wenzelm@9811
    68
wenzelm@18241
    69
lemma par_beta_lift [simp]:
wenzelm@18241
    70
    "t => t' \<Longrightarrow> lift t n => lift t' n"
wenzelm@18241
    71
  by (induct t fixing: t' n) fastsimp+
wenzelm@9811
    72
wenzelm@18241
    73
lemma par_beta_subst:
wenzelm@18241
    74
    "s => s' \<Longrightarrow> t => t' \<Longrightarrow> t[s/n] => t'[s'/n]"
wenzelm@18241
    75
  apply (induct t fixing: s s' t' n)
wenzelm@9811
    76
    apply (simp add: subst_Var)
wenzelm@9811
    77
   apply (erule par_beta_cases)
wenzelm@9811
    78
    apply simp
wenzelm@9811
    79
   apply (simp add: subst_subst [symmetric])
wenzelm@9811
    80
   apply (fastsimp intro!: par_beta_lift)
wenzelm@9811
    81
  apply fastsimp
wenzelm@9811
    82
  done
wenzelm@9811
    83
wenzelm@9811
    84
wenzelm@9811
    85
subsection {* Confluence (directly) *}
wenzelm@9811
    86
wenzelm@9811
    87
lemma diamond_par_beta: "diamond par_beta"
wenzelm@9811
    88
  apply (unfold diamond_def commute_def square_def)
wenzelm@9811
    89
  apply (rule impI [THEN allI [THEN allI]])
wenzelm@9811
    90
  apply (erule par_beta.induct)
wenzelm@9811
    91
     apply (blast intro!: par_beta_subst)+
wenzelm@9811
    92
  done
wenzelm@9811
    93
wenzelm@9811
    94
wenzelm@9811
    95
subsection {* Complete developments *}
nipkow@1120
    96
nipkow@1120
    97
consts
wenzelm@9811
    98
  "cd" :: "dB => dB"
wenzelm@9811
    99
recdef "cd" "measure size"
wenzelm@9811
   100
  "cd (Var n) = Var n"
wenzelm@12011
   101
  "cd (Var n \<degree> t) = Var n \<degree> cd t"
wenzelm@12011
   102
  "cd ((s1 \<degree> s2) \<degree> t) = cd (s1 \<degree> s2) \<degree> cd t"
wenzelm@12011
   103
  "cd (Abs u \<degree> t) = (cd u)[cd t/0]"
wenzelm@9811
   104
  "cd (Abs s) = Abs (cd s)"
wenzelm@9811
   105
wenzelm@18241
   106
lemma par_beta_cd: "s => t \<Longrightarrow> t => cd s"
wenzelm@18241
   107
  apply (induct s fixing: t rule: cd.induct)
wenzelm@9811
   108
      apply auto
wenzelm@9811
   109
  apply (fast intro!: par_beta_subst)
wenzelm@9811
   110
  done
nipkow@1120
   111
wenzelm@9811
   112
wenzelm@9811
   113
subsection {* Confluence (via complete developments) *}
wenzelm@9811
   114
wenzelm@9811
   115
lemma diamond_par_beta2: "diamond par_beta"
wenzelm@9811
   116
  apply (unfold diamond_def commute_def square_def)
wenzelm@9811
   117
  apply (blast intro: par_beta_cd)
wenzelm@9811
   118
  done
wenzelm@9811
   119
wenzelm@9811
   120
theorem beta_confluent: "confluent beta"
wenzelm@9811
   121
  apply (rule diamond_par_beta2 diamond_to_confluence
wenzelm@9811
   122
    par_beta_subset_beta beta_subset_par_beta)+
wenzelm@9811
   123
  done
wenzelm@9811
   124
wenzelm@11638
   125
end