src/HOLCF/Fix.thy
changeset 27185 0407630909ef
parent 25927 9c544dac6269
child 27270 6a353260735e
equal deleted inserted replaced
27184:b1483d423512 27185:0407630909ef
   104 done
   104 done
   105 
   105 
   106 lemma fix_least: "F\<cdot>x = x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
   106 lemma fix_least: "F\<cdot>x = x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
   107 by (rule fix_least_less, simp)
   107 by (rule fix_least_less, simp)
   108 
   108 
   109 lemma fix_eqI: "\<lbrakk>F\<cdot>x = x; \<forall>z. F\<cdot>z = z \<longrightarrow> x \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x = fix\<cdot>F"
   109 lemma fix_eqI:
       
   110   assumes fixed: "F\<cdot>x = x" and least: "\<And>z. F\<cdot>z = z \<Longrightarrow> x \<sqsubseteq> z"
       
   111   shows "fix\<cdot>F = x"
   110 apply (rule antisym_less)
   112 apply (rule antisym_less)
   111 apply (simp add: fix_eq [symmetric])
   113 apply (rule fix_least [OF fixed])
   112 apply (erule fix_least)
   114 apply (rule least [OF fix_eq [symmetric]])
   113 done
   115 done
   114 
   116 
   115 lemma fix_eq2: "f \<equiv> fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
   117 lemma fix_eq2: "f \<equiv> fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
   116 by (simp add: fix_eq [symmetric])
   118 by (simp add: fix_eq [symmetric])
   117 
   119 
   150 by (subst fix_eq, simp)
   152 by (subst fix_eq, simp)
   151 
   153 
   152 subsection {* Fixed point induction *}
   154 subsection {* Fixed point induction *}
   153 
   155 
   154 lemma fix_ind: "\<lbrakk>adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P (fix\<cdot>F)"
   156 lemma fix_ind: "\<lbrakk>adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P (fix\<cdot>F)"
   155 apply (subst fix_def2)
   157 unfolding fix_def2
   156 apply (erule admD)
   158 apply (erule admD)
   157 apply (rule chain_iterate)
   159 apply (rule chain_iterate)
   158 apply (induct_tac "i", simp_all)
   160 apply (rule nat_induct, simp_all)
   159 done
   161 done
   160 
   162 
   161 lemma def_fix_ind:
   163 lemma def_fix_ind:
   162   "\<lbrakk>f \<equiv> fix\<cdot>F; adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P f"
   164   "\<lbrakk>f \<equiv> fix\<cdot>F; adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P f"
   163 by (simp add: fix_ind)
   165 by (simp add: fix_ind)
       
   166 
       
   167 lemma fix_ind2:
       
   168   assumes adm: "adm P"
       
   169   assumes 0: "P \<bottom>" and 1: "P (F\<cdot>\<bottom>)"
       
   170   assumes step: "\<And>x. \<lbrakk>P x; P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P (F\<cdot>(F\<cdot>x))"
       
   171   shows "P (fix\<cdot>F)"
       
   172 unfolding fix_def2
       
   173 apply (rule admD [OF adm chain_iterate])
       
   174 apply (rule nat_less_induct)
       
   175 apply (case_tac n)
       
   176 apply (simp add: 0)
       
   177 apply (case_tac nat)
       
   178 apply (simp add: 1)
       
   179 apply (frule_tac x=nat in spec)
       
   180 apply (simp add: step)
       
   181 done
   164 
   182 
   165 subsection {* Recursive let bindings *}
   183 subsection {* Recursive let bindings *}
   166 
   184 
   167 definition
   185 definition
   168   CLetrec :: "('a \<rightarrow> 'a \<times> 'b) \<rightarrow> 'b" where
   186   CLetrec :: "('a \<rightarrow> 'a \<times> 'b) \<rightarrow> 'b" where
   196 lemma fix_cprod:
   214 lemma fix_cprod:
   197   "fix\<cdot>(F::'a \<times> 'b \<rightarrow> 'a \<times> 'b) =
   215   "fix\<cdot>(F::'a \<times> 'b \<rightarrow> 'a \<times> 'b) =
   198    \<langle>\<mu> x. cfst\<cdot>(F\<cdot>\<langle>x, \<mu> y. csnd\<cdot>(F\<cdot>\<langle>x, y\<rangle>)\<rangle>),
   216    \<langle>\<mu> x. cfst\<cdot>(F\<cdot>\<langle>x, \<mu> y. csnd\<cdot>(F\<cdot>\<langle>x, y\<rangle>)\<rangle>),
   199     \<mu> y. csnd\<cdot>(F\<cdot>\<langle>\<mu> x. cfst\<cdot>(F\<cdot>\<langle>x, \<mu> y. csnd\<cdot>(F\<cdot>\<langle>x, y\<rangle>)\<rangle>), y\<rangle>)\<rangle>"
   217     \<mu> y. csnd\<cdot>(F\<cdot>\<langle>\<mu> x. cfst\<cdot>(F\<cdot>\<langle>x, \<mu> y. csnd\<cdot>(F\<cdot>\<langle>x, y\<rangle>)\<rangle>), y\<rangle>)\<rangle>"
   200   (is "fix\<cdot>F = \<langle>?x, ?y\<rangle>")
   218   (is "fix\<cdot>F = \<langle>?x, ?y\<rangle>")
   201 proof (rule fix_eqI [rule_format, symmetric])
   219 proof (rule fix_eqI)
   202   have 1: "cfst\<cdot>(F\<cdot>\<langle>?x, ?y\<rangle>) = ?x"
   220   have 1: "cfst\<cdot>(F\<cdot>\<langle>?x, ?y\<rangle>) = ?x"
   203     by (rule trans [symmetric, OF fix_eq], simp)
   221     by (rule trans [symmetric, OF fix_eq], simp)
   204   have 2: "csnd\<cdot>(F\<cdot>\<langle>?x, ?y\<rangle>) = ?y"
   222   have 2: "csnd\<cdot>(F\<cdot>\<langle>?x, ?y\<rangle>) = ?y"
   205     by (rule trans [symmetric, OF fix_eq], simp)
   223     by (rule trans [symmetric, OF fix_eq], simp)
   206   from 1 2 show "F\<cdot>\<langle>?x, ?y\<rangle> = \<langle>?x, ?y\<rangle>" by (simp add: eq_cprod)
   224   from 1 2 show "F\<cdot>\<langle>?x, ?y\<rangle> = \<langle>?x, ?y\<rangle>" by (simp add: eq_cprod)