| 
2570
 | 
     1  | 
open Focus_ex;
  | 
| 
 | 
     2  | 
  | 
| 
 | 
     3  | 
(* first some logical trading *)
  | 
| 
 | 
     4  | 
  | 
| 
 | 
     5  | 
val prems = goal Focus_ex.thy
  | 
| 
 | 
     6  | 
"is_g(g) = \ 
  | 
| 
 | 
     7  | 
\ (? f. is_f(f) &  (!x.(? z. <g`x,z> = f`<x,z> &  \
  | 
| 
 | 
     8  | 
\                  (! w y. <y,w> = f`<x,w>  --> z << w))))";
  | 
| 
 | 
     9  | 
by (simp_tac (HOL_ss addsimps [is_g,is_net_g]) 1);
  | 
| 
 | 
    10  | 
by (fast_tac HOL_cs 1);
  | 
| 
 | 
    11  | 
val lemma1 = result();
  | 
| 
 | 
    12  | 
  | 
| 
 | 
    13  | 
val prems = goal Focus_ex.thy
  | 
| 
 | 
    14  | 
"(? f. is_f(f) &  (!x. (? z. <g`x,z> = f`<x,z> &  \
  | 
| 
 | 
    15  | 
\                 (!w y. <y,w> = f`<x,w>  --> z << w)))) \
  | 
| 
 | 
    16  | 
\ = \ 
  | 
| 
 | 
    17  | 
\ (? f. is_f(f) &  (!x. ? z.\
  | 
| 
 | 
    18  | 
\       g`x = cfst`(f`<x,z>) &  \
  | 
| 
 | 
    19  | 
\         z = csnd`(f`<x,z>) &  \
  | 
| 
 | 
    20  | 
\       (! w y.  <y,w> = f`<x,w> --> z << w)))";
  | 
| 
 | 
    21  | 
by (rtac iffI 1);
  | 
| 
 | 
    22  | 
by (etac exE 1);
  | 
| 
 | 
    23  | 
by (res_inst_tac [("x","f")] exI 1);
 | 
| 
 | 
    24  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    25  | 
by (etac conjI 1);
  | 
| 
 | 
    26  | 
by (strip_tac 1);
  | 
| 
 | 
    27  | 
by (etac allE 1);
  | 
| 
 | 
    28  | 
by (etac exE 1);
  | 
| 
 | 
    29  | 
by (res_inst_tac [("x","z")] exI 1);
 | 
| 
 | 
    30  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    31  | 
by (rtac conjI 1);
  | 
| 
 | 
    32  | 
by (rtac conjI 2);
  | 
| 
 | 
    33  | 
by (atac 3);
  | 
| 
 | 
    34  | 
by (dtac sym 1);
  | 
| 
 | 
    35  | 
by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
    36  | 
by (dtac sym 1);
  | 
| 
 | 
    37  | 
by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
    38  | 
by (etac exE 1);
  | 
| 
 | 
    39  | 
by (res_inst_tac [("x","f")] exI 1);
 | 
| 
 | 
    40  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    41  | 
by (etac conjI 1);
  | 
| 
 | 
    42  | 
by (strip_tac 1);
  | 
| 
 | 
    43  | 
by (etac allE 1);
  | 
| 
 | 
    44  | 
by (etac exE 1);
  | 
| 
 | 
    45  | 
by (res_inst_tac [("x","z")] exI 1);
 | 
| 
 | 
    46  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    47  | 
by (rtac conjI 1);
  | 
| 
 | 
    48  | 
by (atac 2);
  | 
| 
 | 
    49  | 
by (rtac trans 1);
  | 
| 
 | 
    50  | 
by (rtac (surjective_pairing_Cprod2) 2);
  | 
| 
 | 
    51  | 
by (etac subst 1);
  | 
| 
 | 
    52  | 
by (etac subst 1);
  | 
| 
 | 
    53  | 
by (rtac refl 1);
  | 
| 
 | 
    54  | 
val lemma2 = result();
  | 
| 
 | 
    55  | 
  | 
| 
 | 
    56  | 
(* direction def_g(g) --> is_g(g) *)
  | 
| 
 | 
    57  | 
  | 
| 
 | 
    58  | 
val prems = goal Focus_ex.thy "def_g(g) --> is_g(g)";
  | 
| 
 | 
    59  | 
by (simp_tac (HOL_ss addsimps [def_g,lemma1, lemma2]) 1);
  | 
| 
 | 
    60  | 
by (rtac impI 1);
  | 
| 
 | 
    61  | 
by (etac exE 1);
  | 
| 
 | 
    62  | 
by (res_inst_tac [("x","f")] exI 1);
 | 
| 
 | 
    63  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    64  | 
by (etac conjI 1);
  | 
| 
 | 
    65  | 
by (strip_tac 1);
  | 
| 
3842
 | 
    66  | 
by (res_inst_tac [("x","fix`(LAM k. csnd`(f`<x,k>))")] exI 1);
 | 
| 
2570
 | 
    67  | 
by (rtac conjI 1);
  | 
| 
 | 
    68  | 
 by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
    69  | 
 by (rtac trans 1);
  | 
| 
 | 
    70  | 
  by (rtac surjective_pairing_Cprod2 2);
  | 
| 
 | 
    71  | 
 by (rtac cfun_arg_cong 1);
  | 
| 
 | 
    72  | 
 by (rtac trans 1);
  | 
| 
 | 
    73  | 
  by (rtac fix_eq 1);
  | 
| 
 | 
    74  | 
 by (Simp_tac 1);
  | 
| 
 | 
    75  | 
by (strip_tac 1);
  | 
| 
 | 
    76  | 
by (rtac fix_least 1);
  | 
| 
 | 
    77  | 
by (Simp_tac 1);
  | 
| 
3018
 | 
    78  | 
by (etac exE 1);
  | 
| 
2570
 | 
    79  | 
by (dtac sym 1);
  | 
| 
 | 
    80  | 
back();
  | 
| 
 | 
    81  | 
by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
    82  | 
val lemma3 = result();
  | 
| 
 | 
    83  | 
  | 
| 
 | 
    84  | 
(* direction is_g(g) --> def_g(g) *)
  | 
| 
 | 
    85  | 
val prems = goal Focus_ex.thy "is_g(g) --> def_g(g)";
  | 
| 
 | 
    86  | 
by (simp_tac (HOL_ss delsimps (ex_simps @ all_simps)
  | 
| 
3018
 | 
    87  | 
                     addsimps [lemma1,lemma2,def_g]) 1);
  | 
| 
2570
 | 
    88  | 
by (rtac impI 1);
  | 
| 
 | 
    89  | 
by (etac exE 1);
  | 
| 
 | 
    90  | 
by (res_inst_tac [("x","f")] exI 1);
 | 
| 
 | 
    91  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    92  | 
by (etac conjI 1);
  | 
| 
 | 
    93  | 
by (rtac ext_cfun 1);
  | 
| 
 | 
    94  | 
by (eres_inst_tac [("x","x")] allE 1);
 | 
| 
 | 
    95  | 
by (etac exE 1);
  | 
| 
 | 
    96  | 
by (REPEAT (etac conjE 1));
  | 
| 
 | 
    97  | 
by (subgoal_tac "fix`(LAM k. csnd`(f`<x, k>)) = z" 1);
  | 
| 
 | 
    98  | 
 by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
    99  | 
by (subgoal_tac "! w y. f`<x, w> = <y, w>  --> z << w" 1);
  | 
| 
 | 
   100  | 
by (rtac sym 1);
  | 
| 
 | 
   101  | 
by (rtac fix_eqI 1);
  | 
| 
 | 
   102  | 
by (asm_simp_tac HOLCF_ss 1);
  | 
| 
 | 
   103  | 
by (rtac allI 1);
  | 
| 
 | 
   104  | 
by (simp_tac HOLCF_ss 1);
  | 
| 
 | 
   105  | 
by (strip_tac 1);
  | 
| 
 | 
   106  | 
by (subgoal_tac "f`<x, za> = <cfst`(f`<x,za>),za>" 1);
  | 
| 
 | 
   107  | 
by (fast_tac HOL_cs 1);
  | 
| 
 | 
   108  | 
by (rtac trans 1);
  | 
| 
 | 
   109  | 
by (rtac (surjective_pairing_Cprod2 RS sym) 1);
  | 
| 
 | 
   110  | 
by (etac cfun_arg_cong 1);
  | 
| 
 | 
   111  | 
by (strip_tac 1);
  | 
| 
 | 
   112  | 
by (REPEAT (etac allE 1));
  | 
| 
 | 
   113  | 
by (etac mp 1);
  | 
| 
 | 
   114  | 
by (etac sym 1);
  | 
| 
 | 
   115  | 
val lemma4 = result();
  | 
| 
 | 
   116  | 
  | 
| 
 | 
   117  | 
(* now we assemble the result *)
  | 
| 
 | 
   118  | 
  | 
| 
 | 
   119  | 
val prems = goal Focus_ex.thy "def_g = is_g";
  | 
| 
 | 
   120  | 
by (rtac ext 1);
  | 
| 
 | 
   121  | 
by (rtac iffI 1);
  | 
| 
 | 
   122  | 
by (etac (lemma3 RS mp) 1);
  | 
| 
 | 
   123  | 
by (etac (lemma4 RS mp) 1);
  | 
| 
 | 
   124  | 
val loopback_eq = result();
  | 
| 
 | 
   125  | 
  | 
| 
 | 
   126  | 
val prems = goal Focus_ex.thy 
  | 
| 
 | 
   127  | 
"(? f.\
  | 
| 
 | 
   128  | 
\ is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))\
 | 
| 
 | 
   129  | 
\ -->\
  | 
| 
 | 
   130  | 
\ (? g. def_g(g::'b stream -> 'c stream ))";
  | 
| 
 | 
   131  | 
by (simp_tac (HOL_ss addsimps [def_g]) 1);
  | 
| 
 | 
   132  | 
by (strip_tac 1);
  | 
| 
 | 
   133  | 
by (etac exE 1);
  | 
| 
 | 
   134  | 
by (rtac exI 1);
  | 
| 
 | 
   135  | 
by (rtac exI 1);
  | 
| 
 | 
   136  | 
by (etac conjI 1);
  | 
| 
 | 
   137  | 
by (rtac refl 1);
  | 
| 
 | 
   138  | 
val L2 = result();
  | 
| 
 | 
   139  | 
  | 
| 
 | 
   140  | 
val prems = goal Focus_ex.thy 
  | 
| 
 | 
   141  | 
"(? f.\
  | 
| 
 | 
   142  | 
\ is_f(f::'b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream))\
 | 
| 
 | 
   143  | 
\ -->\
  | 
| 
 | 
   144  | 
\ (? g. is_g(g::'b stream -> 'c stream ))";
  | 
| 
 | 
   145  | 
by (rtac (loopback_eq RS subst) 1);
  | 
| 
 | 
   146  | 
by (rtac L2 1);
  | 
| 
 | 
   147  | 
val conservative_loopback = result();
  |