src/HOL/Proofs/Lambda/Standardization.thy
changeset 61986 2461779da2b8
parent 58889 5b7a9633cfa8
child 67399 eab6ce8368fa
equal deleted inserted replaced
61985:a63a11b09335 61986:2461779da2b8
     1 (*  Title:      HOL/Proofs/Lambda/Standardization.thy
     1 (*  Title:      HOL/Proofs/Lambda/Standardization.thy
     2     Author:     Stefan Berghofer
     2     Author:     Stefan Berghofer
     3     Copyright   2005 TU Muenchen
     3     Copyright   2005 TU Muenchen
     4 *)
     4 *)
     5 
     5 
     6 section {* Standardization *}
     6 section \<open>Standardization\<close>
     7 
     7 
     8 theory Standardization
     8 theory Standardization
     9 imports NormalForm
     9 imports NormalForm
    10 begin
    10 begin
    11 
    11 
    12 text {*
    12 text \<open>
    13 Based on lecture notes by Ralph Matthes @{cite "Matthes-ESSLLI2000"},
    13 Based on lecture notes by Ralph Matthes @{cite "Matthes-ESSLLI2000"},
    14 original proof idea due to Ralph Loader @{cite Loader1998}.
    14 original proof idea due to Ralph Loader @{cite Loader1998}.
    15 *}
    15 \<close>
    16 
    16 
    17 
    17 
    18 subsection {* Standard reduction relation *}
    18 subsection \<open>Standard reduction relation\<close>
    19 
    19 
    20 declare listrel_mono [mono_set]
    20 declare listrel_mono [mono_set]
    21 
    21 
    22 inductive
    22 inductive
    23   sred :: "dB \<Rightarrow> dB \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>s" 50)
    23   sred :: "dB \<Rightarrow> dB \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>s" 50)
    61 next
    61 next
    62   case (Abs r r' ss ss')
    62   case (Abs r r' ss ss')
    63   from Abs(3) have "ss [\<rightarrow>\<^sub>s] ss'" by (rule listrelp_conj1)
    63   from Abs(3) have "ss [\<rightarrow>\<^sub>s] ss'" by (rule listrelp_conj1)
    64   moreover have "[s] [\<rightarrow>\<^sub>s] [s']" by (iprover intro: s listrelp.intros)
    64   moreover have "[s] [\<rightarrow>\<^sub>s] [s']" by (iprover intro: s listrelp.intros)
    65   ultimately have "ss @ [s] [\<rightarrow>\<^sub>s] ss' @ [s']" by (rule listrelp_app)
    65   ultimately have "ss @ [s] [\<rightarrow>\<^sub>s] ss' @ [s']" by (rule listrelp_app)
    66   with `r \<rightarrow>\<^sub>s r'` have "Abs r \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> (ss' @ [s'])"
    66   with \<open>r \<rightarrow>\<^sub>s r'\<close> have "Abs r \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> (ss' @ [s'])"
    67     by (rule sred.Abs)
    67     by (rule sred.Abs)
    68   thus ?case by (simp only: app_last)
    68   thus ?case by (simp only: app_last)
    69 next
    69 next
    70   case (Beta r u ss t)
    70   case (Beta r u ss t)
    71   hence "r[u/0] \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s t \<degree> s'" by (simp only: app_last)
    71   hence "r[u/0] \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s t \<degree> s'" by (simp only: app_last)
   197   from Var(1) rs have "rs [\<rightarrow>\<^sub>s] ss" by (rule lemma4_aux)
   197   from Var(1) rs have "rs [\<rightarrow>\<^sub>s] ss" by (rule lemma4_aux)
   198   hence "Var x \<degree>\<degree> rs \<rightarrow>\<^sub>s Var x \<degree>\<degree> ss" by (rule sred.Var)
   198   hence "Var x \<degree>\<degree> rs \<rightarrow>\<^sub>s Var x \<degree>\<degree> ss" by (rule sred.Var)
   199   with r'' show ?case by simp
   199   with r'' show ?case by simp
   200 next
   200 next
   201   case (Abs r r' ss ss')
   201   case (Abs r r' ss ss')
   202   from `Abs r' \<degree>\<degree> ss' \<rightarrow>\<^sub>\<beta> r''` show ?case
   202   from \<open>Abs r' \<degree>\<degree> ss' \<rightarrow>\<^sub>\<beta> r''\<close> show ?case
   203   proof
   203   proof
   204     fix s
   204     fix s
   205     assume r'': "r'' = s \<degree>\<degree> ss'"
   205     assume r'': "r'' = s \<degree>\<degree> ss'"
   206     assume "Abs r' \<rightarrow>\<^sub>\<beta> s"
   206     assume "Abs r' \<rightarrow>\<^sub>\<beta> s"
   207     then obtain r''' where s: "s = Abs r'''" and r''': "r' \<rightarrow>\<^sub>\<beta> r'''" by cases auto
   207     then obtain r''' where s: "s = Abs r'''" and r''': "r' \<rightarrow>\<^sub>\<beta> r'''" by cases auto
   211     with r'' s show "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
   211     with r'' s show "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
   212   next
   212   next
   213     fix rs'
   213     fix rs'
   214     assume "ss' => rs'"
   214     assume "ss' => rs'"
   215     with Abs(3) have "ss [\<rightarrow>\<^sub>s] rs'" by (rule lemma4_aux)
   215     with Abs(3) have "ss [\<rightarrow>\<^sub>s] rs'" by (rule lemma4_aux)
   216     with `r \<rightarrow>\<^sub>s r'` have "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> rs'" by (rule sred.Abs)
   216     with \<open>r \<rightarrow>\<^sub>s r'\<close> have "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> rs'" by (rule sred.Abs)
   217     moreover assume "r'' = Abs r' \<degree>\<degree> rs'"
   217     moreover assume "r'' = Abs r' \<degree>\<degree> rs'"
   218     ultimately show "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
   218     ultimately show "Abs r \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
   219   next
   219   next
   220     fix t u' us'
   220     fix t u' us'
   221     assume "ss' = u' # us'"
   221     assume "ss' = u' # us'"
   238   assumes r: "r \<rightarrow>\<^sub>\<beta>\<^sup>* r'"
   238   assumes r: "r \<rightarrow>\<^sub>\<beta>\<^sup>* r'"
   239   shows "r \<rightarrow>\<^sub>s r'" using r
   239   shows "r \<rightarrow>\<^sub>s r'" using r
   240   by induct (iprover intro: refl_sred lemma4)+
   240   by induct (iprover intro: refl_sred lemma4)+
   241 
   241 
   242 
   242 
   243 subsection {* Leftmost reduction and weakly normalizing terms *}
   243 subsection \<open>Leftmost reduction and weakly normalizing terms\<close>
   244 
   244 
   245 inductive
   245 inductive
   246   lred :: "dB \<Rightarrow> dB \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>l" 50)
   246   lred :: "dB \<Rightarrow> dB \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>l" 50)
   247   and lredlist :: "dB list \<Rightarrow> dB list \<Rightarrow> bool"  (infixl "[\<rightarrow>\<^sub>l]" 50)
   247   and lredlist :: "dB list \<Rightarrow> dB list \<Rightarrow> bool"  (infixl "[\<rightarrow>\<^sub>l]" 50)
   248 where
   248 where
   259   then have "rs [\<rightarrow>\<^sub>s] rs'"
   259   then have "rs [\<rightarrow>\<^sub>s] rs'"
   260     by induct (iprover intro: listrelp.intros)+
   260     by induct (iprover intro: listrelp.intros)+
   261   then show ?case by (rule sred.Var)
   261   then show ?case by (rule sred.Var)
   262 next
   262 next
   263   case (Abs r r')
   263   case (Abs r r')
   264   from `r \<rightarrow>\<^sub>s r'`
   264   from \<open>r \<rightarrow>\<^sub>s r'\<close>
   265   have "Abs r \<degree>\<degree> [] \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> []" using listrelp.Nil
   265   have "Abs r \<degree>\<degree> [] \<rightarrow>\<^sub>s Abs r' \<degree>\<degree> []" using listrelp.Nil
   266     by (rule sred.Abs)
   266     by (rule sred.Abs)
   267   then show ?case by simp
   267   then show ?case by simp
   268 next
   268 next
   269   case (Beta r s ss t)
   269   case (Beta r s ss t)
   270   from `r[s/0] \<degree>\<degree> ss \<rightarrow>\<^sub>s t`
   270   from \<open>r[s/0] \<degree>\<degree> ss \<rightarrow>\<^sub>s t\<close>
   271   show ?case by (rule sred.Beta)
   271   show ?case by (rule sred.Beta)
   272 qed
   272 qed
   273 
   273 
   274 inductive WN :: "dB => bool"
   274 inductive WN :: "dB => bool"
   275   where
   275   where
   308 lemma lemma7:
   308 lemma lemma7:
   309   assumes r: "r \<rightarrow>\<^sub>s r'"
   309   assumes r: "r \<rightarrow>\<^sub>s r'"
   310   shows "NF r' \<Longrightarrow> r \<rightarrow>\<^sub>l r'" using r
   310   shows "NF r' \<Longrightarrow> r \<rightarrow>\<^sub>l r'" using r
   311 proof induct
   311 proof induct
   312   case (Var rs rs' x)
   312   case (Var rs rs' x)
   313   from `NF (Var x \<degree>\<degree> rs')` have "listall NF rs'"
   313   from \<open>NF (Var x \<degree>\<degree> rs')\<close> have "listall NF rs'"
   314     by cases simp_all
   314     by cases simp_all
   315   with Var(1) have "rs [\<rightarrow>\<^sub>l] rs'"
   315   with Var(1) have "rs [\<rightarrow>\<^sub>l] rs'"
   316   proof induct
   316   proof induct
   317     case Nil
   317     case Nil
   318     show ?case by (rule listrelp.Nil)
   318     show ?case by (rule listrelp.Nil)
   322     thus ?case by (rule listrelp.Cons)
   322     thus ?case by (rule listrelp.Cons)
   323   qed
   323   qed
   324   thus ?case by (rule lred.Var)
   324   thus ?case by (rule lred.Var)
   325 next
   325 next
   326   case (Abs r r' ss ss')
   326   case (Abs r r' ss ss')
   327   from `NF (Abs r' \<degree>\<degree> ss')`
   327   from \<open>NF (Abs r' \<degree>\<degree> ss')\<close>
   328   have ss': "ss' = []" by (rule Abs_NF)
   328   have ss': "ss' = []" by (rule Abs_NF)
   329   from Abs(3) have ss: "ss = []" using ss'
   329   from Abs(3) have ss: "ss = []" using ss'
   330     by cases simp_all
   330     by cases simp_all
   331   from ss' Abs have "NF (Abs r')" by simp
   331   from ss' Abs have "NF (Abs r')" by simp
   332   hence "NF r'" by cases simp_all
   332   hence "NF r'" by cases simp_all