src/HOLCF/ex/Focus_ex.thy
changeset 19763 ec18656a2c10
parent 19742 86f21beabafc
child 21404 eb85850d3eb7
equal deleted inserted replaced
19762:957bcf55c98f 19763:ec18656a2c10
   106 
   106 
   107 typedecl ('a, 'b) tc
   107 typedecl ('a, 'b) tc
   108 arities tc:: (pcpo, pcpo) pcpo
   108 arities tc:: (pcpo, pcpo) pcpo
   109 
   109 
   110 consts
   110 consts
   111 
   111   Rf :: "('b stream * ('b,'c) tc stream * 'c stream * ('b,'c) tc stream) => bool"
   112 is_f     ::
   112 
   113  "('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) => bool"
   113 definition
   114 is_net_g :: "('b stream *('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) =>
   114   is_f :: "('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) => bool"
   115             'b stream => 'c stream => bool"
   115   "is_f f = (!i1 i2 o1 o2. f$<i1,i2> = <o1,o2> --> Rf(i1,i2,o1,o2))"
   116 is_g     :: "('b stream -> 'c stream) => bool"
   116 
   117 def_g    :: "('b stream -> 'c stream) => bool"
   117   is_net_g :: "('b stream *('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) =>
   118 Rf       ::
   118     'b stream => 'c stream => bool"
   119 "('b stream * ('b,'c) tc stream * 'c stream * ('b,'c) tc stream) => bool"
   119   "is_net_g f x y == (? z.
   120 
       
   121 defs
       
   122 
       
   123 is_f:           "is_f f == (!i1 i2 o1 o2.
       
   124                         f$<i1,i2> = <o1,o2> --> Rf(i1,i2,o1,o2))"
       
   125 
       
   126 is_net_g:       "is_net_g f x y == (? z.
       
   127                         <y,z> = f$<x,z> &
   120                         <y,z> = f$<x,z> &
   128                         (!oy hz. <oy,hz> = f$<x,hz> --> z << hz))"
   121                         (!oy hz. <oy,hz> = f$<x,hz> --> z << hz))"
   129 
   122 
   130 is_g:           "is_g g  == (? f.
   123   is_g :: "('b stream -> 'c stream) => bool"
   131                         is_f f  &
   124   "is_g g  == (? f. is_f f  & (!x y. g$x = y --> is_net_g f x y))"
   132                         (!x y. g$x = y --> is_net_g f x y))"
   125 
   133 
   126   def_g :: "('b stream -> 'c stream) => bool"
   134 
   127   "def_g g == (? f. is_f f  & g = (LAM x. cfst$(f$<x,fix$(LAM  k. csnd$(f$<x,k>))>)))"
   135 def_g:          "def_g g == (? f.
       
   136                         is_f f  &
       
   137                         g = (LAM x. cfst$(f$<x,fix$(LAM  k. csnd$(f$<x,k>))>)))"
       
   138 
   128 
   139 
   129 
   140 (* first some logical trading *)
   130 (* first some logical trading *)
   141 
   131 
   142 lemma lemma1:
   132 lemma lemma1:
   143 "is_g(g) =
   133 "is_g(g) =
   144   (? f. is_f(f) &  (!x.(? z. <g$x,z> = f$<x,z> &
   134   (? f. is_f(f) &  (!x.(? z. <g$x,z> = f$<x,z> &
   145                    (! w y. <y,w> = f$<x,w>  --> z << w))))"
   135                    (! w y. <y,w> = f$<x,w>  --> z << w))))"
   146 apply (simp add: is_g is_net_g)
   136 apply (simp add: is_g_def is_net_g_def)
   147 apply fast
   137 apply fast
   148 done
   138 done
   149 
   139 
   150 lemma lemma2:
   140 lemma lemma2:
   151 "(? f. is_f(f) &  (!x. (? z. <g$x,z> = f$<x,z> &
   141 "(? f. is_f(f) &  (!x. (? z. <g$x,z> = f$<x,z> &
   189 apply (erule subst)
   179 apply (erule subst)
   190 apply (rule refl)
   180 apply (rule refl)
   191 done
   181 done
   192 
   182 
   193 lemma lemma3: "def_g(g) --> is_g(g)"
   183 lemma lemma3: "def_g(g) --> is_g(g)"
   194 apply (tactic {* simp_tac (HOL_ss addsimps [thm "def_g", thm "lemma1", thm "lemma2"]) 1 *})
   184 apply (tactic {* simp_tac (HOL_ss addsimps [thm "def_g_def", thm "lemma1", thm "lemma2"]) 1 *})
   195 apply (rule impI)
   185 apply (rule impI)
   196 apply (erule exE)
   186 apply (erule exE)
   197 apply (rule_tac x = "f" in exI)
   187 apply (rule_tac x = "f" in exI)
   198 apply (erule conjE)+
   188 apply (erule conjE)+
   199 apply (erule conjI)
   189 apply (erule conjI)
   216 apply simp
   206 apply simp
   217 done
   207 done
   218 
   208 
   219 lemma lemma4: "is_g(g) --> def_g(g)"
   209 lemma lemma4: "is_g(g) --> def_g(g)"
   220 apply (tactic {* simp_tac (HOL_ss delsimps (thms "ex_simps" @ thms "all_simps")
   210 apply (tactic {* simp_tac (HOL_ss delsimps (thms "ex_simps" @ thms "all_simps")
   221   addsimps [thm "lemma1", thm "lemma2", thm "def_g"]) 1 *})
   211   addsimps [thm "lemma1", thm "lemma2", thm "def_g_def"]) 1 *})
   222 apply (rule impI)
   212 apply (rule impI)
   223 apply (erule exE)
   213 apply (erule exE)
   224 apply (rule_tac x = "f" in exI)
   214 apply (rule_tac x = "f" in exI)
   225 apply (erule conjE)+
   215 apply (erule conjE)+
   226 apply (erule conjI)
   216 apply (erule conjI)
   260 lemma L2:
   250 lemma L2:
   261 "(? f.
   251 "(? f.
   262   is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))
   252   is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))
   263   -->
   253   -->
   264   (? g. def_g(g::'b stream -> 'c stream ))"
   254   (? g. def_g(g::'b stream -> 'c stream ))"
   265 apply (simp add: def_g)
   255 apply (simp add: def_g_def)
   266 done
   256 done
   267 
   257 
   268 theorem conservative_loopback:
   258 theorem conservative_loopback:
   269 "(? f.
   259 "(? f.
   270   is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))
   260   is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))