src/HOLCF/FOCUS/Buffer.ML
author wenzelm
Wed, 14 Sep 2005 22:04:34 +0200
changeset 17383 3eb21fb8c2ec
parent 17293 ecf182ccc3ca
permissions -rw-r--r--
no longer prefer xemacs, which fails more often than GNU emacs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
     1
(*  Title:      HOLCF/FOCUS/Buffer.ML
11355
wenzelm
parents: 11350
diff changeset
     2
    ID:         $Id$
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
     3
    Author:     David von Oheimb, TU Muenchen
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
     4
*)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
     5
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
     6
val set_cong = prove_goal (theory "Set") "!!X. A = B ==> (x:A) = (x:B)" (K [
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
     7
        etac subst 1, rtac refl 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
     8
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
     9
fun B_prover s tac eqs = prove_goal (the_context ()) s (fn prems => [cut_facts_tac prems 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    10
        tac 1, auto_tac (claset(), simpset() addsimps eqs)]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    11
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    12
fun prove_forw  s thm     = B_prover s (dtac (thm RS iffD1)) [];
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    13
fun prove_backw s thm eqs = B_prover s (rtac (thm RS iffD2)) eqs;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    14
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    15
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    16
(**** BufEq *******************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    17
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    18
val mono_BufEq_F = prove_goalw (the_context ()) [mono_def, BufEq_F_def]
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    19
                "mono BufEq_F" (K [Fast_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    20
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    21
val BufEq_fix = mono_BufEq_F RS (BufEq_def RS def_gfp_unfold);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    22
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    23
val BufEq_unfold = prove_goal (the_context ()) "(f:BufEq) = (!d. f\\<cdot>(Md d\\<leadsto><>) = <> & \
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    24
                \(!x. ? ff:BufEq. f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x) = d\\<leadsto>(ff\\<cdot>x)))" (K [
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    25
        stac (BufEq_fix RS set_cong) 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    26
        rewtac BufEq_F_def,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    27
        Asm_full_simp_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    28
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    29
val Buf_f_empty = prove_forw "f:BufEq \\<Longrightarrow> f\\<cdot><> = <>" BufEq_unfold;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    30
val Buf_f_d     = prove_forw "f:BufEq \\<Longrightarrow> f\\<cdot>(Md d\\<leadsto><>) = <>" BufEq_unfold;
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    31
val Buf_f_d_req = prove_forw
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    32
        "f:BufEq \\<Longrightarrow> \\<exists>ff. ff:BufEq \\<and> f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x) = d\\<leadsto>ff\\<cdot>x" BufEq_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    33
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    34
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    35
(**** BufAC_Asm ***************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    36
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    37
val mono_BufAC_Asm_F = prove_goalw (the_context ()) [mono_def, BufAC_Asm_F_def]
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    38
                "mono BufAC_Asm_F" (K [Fast_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    39
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    40
val BufAC_Asm_fix = mono_BufAC_Asm_F RS (BufAC_Asm_def RS def_gfp_unfold);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    41
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    42
val BufAC_Asm_unfold = prove_goal (the_context ()) "(s:BufAC_Asm) = (s = <> | (? d x. \
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    43
\       s = Md d\\<leadsto>x & (x = <> | (ft\\<cdot>x = Def \\<bullet> & (rt\\<cdot>x):BufAC_Asm))))" (K [
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    44
                                stac (BufAC_Asm_fix RS set_cong) 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    45
                                rewtac BufAC_Asm_F_def,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    46
                                Asm_full_simp_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    47
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    48
val BufAC_Asm_empty = prove_backw "<>     :BufAC_Asm" BufAC_Asm_unfold [];
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    49
val BufAC_Asm_d     = prove_backw "Md d\\<leadsto><>:BufAC_Asm" BufAC_Asm_unfold [];
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    50
val BufAC_Asm_d_req = prove_backw "x:BufAC_Asm ==> Md d\\<leadsto>\\<bullet>\\<leadsto>x:BufAC_Asm"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    51
                                                           BufAC_Asm_unfold [];
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    52
val BufAC_Asm_prefix2 = prove_forw "a\\<leadsto>b\\<leadsto>s:BufAC_Asm ==> s:BufAC_Asm"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    53
                                                         BufAC_Asm_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    54
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    55
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    56
(**** BBufAC_Cmt **************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    57
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    58
val mono_BufAC_Cmt_F = prove_goalw (the_context ()) [mono_def, BufAC_Cmt_F_def]
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    59
                "mono BufAC_Cmt_F" (K [Fast_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    60
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    61
val BufAC_Cmt_fix = mono_BufAC_Cmt_F RS (BufAC_Cmt_def RS def_gfp_unfold);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    62
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    63
val BufAC_Cmt_unfold = prove_goal (the_context ()) "((s,t):BufAC_Cmt) = (!d x. \
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    64
    \(s = <>       -->      t = <>) & \
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    65
    \(s = Md d\\<leadsto><>  -->      t = <>) & \
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    66
    \(s = Md d\\<leadsto>\\<bullet>\\<leadsto>x --> ft\\<cdot>t = Def d & (x, rt\\<cdot>t):BufAC_Cmt))" (K [
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    67
        stac (BufAC_Cmt_fix RS set_cong) 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    68
        rewtac BufAC_Cmt_F_def,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    69
        Asm_full_simp_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    70
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    71
val BufAC_Cmt_empty = prove_backw "f:BufEq ==> (<>, f\\<cdot><>):BufAC_Cmt"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    72
                                BufAC_Cmt_unfold [Buf_f_empty];
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    73
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    74
val BufAC_Cmt_d = prove_backw "f:BufEq ==> (a\\<leadsto>\\<bottom>, f\\<cdot>(a\\<leadsto>\\<bottom>)):BufAC_Cmt"
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    75
                                BufAC_Cmt_unfold [Buf_f_d];
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    76
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    77
val BufAC_Cmt_d2 = prove_forw
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    78
 "(Md d\\<leadsto>\\<bottom>, f\\<cdot>(Md d\\<leadsto>\\<bottom>)):BufAC_Cmt ==> f\\<cdot>(Md d\\<leadsto>\\<bottom>) = \\<bottom>" BufAC_Cmt_unfold;
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    79
val BufAC_Cmt_d3 = prove_forw
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    80
"(Md d\\<leadsto>\\<bullet>\\<leadsto>x, f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x)):BufAC_Cmt ==> (x, rt\\<cdot>(f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x))):BufAC_Cmt"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    81
                                                        BufAC_Cmt_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    82
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    83
val BufAC_Cmt_d32 = prove_forw
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    84
"(Md d\\<leadsto>\\<bullet>\\<leadsto>x, f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x)):BufAC_Cmt ==> ft\\<cdot>(f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x)) = Def d"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
    85
                                                        BufAC_Cmt_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    86
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    87
(**** BufAC *******************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    88
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    89
Goalw [BufAC_def] "f \\<in> BufAC \\<Longrightarrow> f\\<cdot>(Md d\\<leadsto>\\<bottom>) = \\<bottom>";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    90
by (fast_tac (claset() addIs [BufAC_Cmt_d2, BufAC_Asm_d]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    91
qed "BufAC_f_d";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    92
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    93
Goal "(? ff:B. (!x. f\\<cdot>(a\\<leadsto>b\\<leadsto>x) = d\\<leadsto>ff\\<cdot>x)) = \
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    94
   \((!x. ft\\<cdot>(f\\<cdot>(a\\<leadsto>b\\<leadsto>x)) = Def d) & (LAM x. rt\\<cdot>(f\\<cdot>(a\\<leadsto>b\\<leadsto>x))):B)";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    95
(*  this is an instance (though unification cannot handle this) of
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    96
Goal "(? ff:B. (!x. f\\<cdot>x = d\\<leadsto>ff\\<cdot>x)) = \
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    97
   \((!x. ft\\<cdot>(f\\<cdot>x) = Def d) & (LAM x. rt\\<cdot>(f\\<cdot>x)):B)";*)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    98
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
    99
by (  res_inst_tac [("P","(%x. x:B)")] ssubst 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   100
by (   atac 3);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   101
by (  rtac ext_cfun 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   102
by (  dtac spec 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   103
by (  dres_inst_tac [("f","rt")] cfun_arg_cong 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   104
by (  Asm_full_simp_tac 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   105
by ( Full_simp_tac 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   106
by (rtac bexI 2);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   107
by Auto_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   108
by (dtac spec 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   109
by (etac exE 1);;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   110
by (etac ssubst 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   111
by (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   112
qed "ex_elim_lemma";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   113
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   114
Goalw [BufAC_def] "f\\<in>BufAC \\<Longrightarrow> \\<exists>ff\\<in>BufAC. \\<forall>x. f\\<cdot>(Md d\\<leadsto>\\<bullet>\\<leadsto>x) = d\\<leadsto>ff\\<cdot>x";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   115
by (rtac (ex_elim_lemma RS iffD2) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   116
by Safe_tac;
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   117
by  (fast_tac (claset() addIs [BufAC_Cmt_d32 RS Def_maximal,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   118
             monofun_cfun_arg,  BufAC_Asm_empty RS BufAC_Asm_d_req]) 1);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   119
by (auto_tac (claset() addIs [BufAC_Cmt_d3, BufAC_Asm_d_req],simpset()));
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   120
qed "BufAC_f_d_req";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   121
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   122
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   123
(**** BufSt *******************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   124
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   125
val mono_BufSt_F = prove_goalw (the_context ()) [mono_def, BufSt_F_def]
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   126
                "mono BufSt_F" (K [Fast_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   127
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   128
val BufSt_P_fix = mono_BufSt_F RS (BufSt_P_def RS def_gfp_unfold);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   129
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   130
val BufSt_P_unfold = prove_goal (the_context ()) "(h:BufSt_P) = (!s. h s\\<cdot><> = <> & \
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   131
         \ (!d x. h \\<currency>     \\<cdot>(Md d\\<leadsto>x)   =    h (Sd d)\\<cdot>x & \
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   132
  \   (? hh:BufSt_P. h (Sd d)\\<cdot>(\\<bullet>\\<leadsto>x)   = d\\<leadsto>(hh \\<currency>    \\<cdot>x))))" (K [
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   133
        stac (BufSt_P_fix RS set_cong) 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   134
        rewtac BufSt_F_def,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   135
        Asm_full_simp_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   136
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   137
val BufSt_P_empty = prove_forw "h:BufSt_P ==> h s     \\<cdot> <>       = <>"
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   138
                        BufSt_P_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   139
val BufSt_P_d     = prove_forw "h:BufSt_P ==> h  \\<currency>    \\<cdot>(Md d\\<leadsto>x) = h (Sd d)\\<cdot>x"
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   140
                        BufSt_P_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   141
val BufSt_P_d_req = prove_forw "h:BufSt_P ==> \\<exists>hh\\<in>BufSt_P. \
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   142
                                         \ h (Sd d)\\<cdot>(\\<bullet>   \\<leadsto>x) = d\\<leadsto>(hh \\<currency>    \\<cdot>x)"
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   143
                        BufSt_P_unfold;
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   144
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   145
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   146
(**** Buf_AC_imp_Eq ***********************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   147
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   148
Goalw [BufEq_def] "BufAC \\<subseteq> BufEq";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   149
by (rtac gfp_upperbound 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   150
by (rewtac BufEq_F_def);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   151
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   152
by  (etac BufAC_f_d 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   153
by (dtac BufAC_f_d_req 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   154
by (Fast_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   155
qed "Buf_AC_imp_Eq";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   156
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   157
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   158
(**** Buf_Eq_imp_AC by coinduction ********************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   159
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   160
Goal "\\<forall>s f ff. f\\<in>BufEq \\<longrightarrow> ff\\<in>BufEq \\<longrightarrow> \
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   161
\ s\\<in>BufAC_Asm \\<longrightarrow> stream_take n\\<cdot>(f\\<cdot>s) = stream_take n\\<cdot>(ff\\<cdot>s)";
13454
01e2496dee05 Replaced nat_ind_tac by induct_tac.
berghofe
parents: 11655
diff changeset
   162
by (induct_tac "n" 1);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   163
by  (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   164
by (strip_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   165
by (dtac (BufAC_Asm_unfold RS iffD1) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   166
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   167
by   (asm_simp_tac (simpset() addsimps [Buf_f_empty]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   168
by  (asm_simp_tac (simpset() addsimps [Buf_f_d]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   169
by (dtac (ft_eq RS iffD1) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   170
by (Clarsimp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   171
by (REPEAT(dtac Buf_f_d_req 1));
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   172
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   173
by (REPEAT(etac ssubst 1));
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   174
by (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   175
by (Fast_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   176
qed_spec_mp "BufAC_Asm_cong_lemma";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   177
Goal "\\<lbrakk>f \\<in> BufEq; ff \\<in> BufEq; s \\<in> BufAC_Asm\\<rbrakk> \\<Longrightarrow> f\\<cdot>s = ff\\<cdot>s";
15188
9d57263faf9e integrated Streams with ex/Stream.*; added FOCUS/Fstreams.thy
oheimb
parents: 14981
diff changeset
   178
by (resolve_tac (thms "stream.take_lemmas") 1);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   179
by (eatac BufAC_Asm_cong_lemma 2 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   180
qed "BufAC_Asm_cong";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   181
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   182
Goalw [BufAC_Cmt_def] "\\<lbrakk>f \\<in> BufEq; x \\<in> BufAC_Asm\\<rbrakk> \\<Longrightarrow> (x, f\\<cdot>x) \\<in> BufAC_Cmt";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   183
by (rotate_tac ~1 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   184
by (etac weak_coinduct_image 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   185
by (rewtac BufAC_Cmt_F_def);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   186
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   187
by    (etac Buf_f_empty 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   188
by   (etac Buf_f_d 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   189
by  (dtac Buf_f_d_req 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   190
by  (Clarsimp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   191
by  (etac exI 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   192
by (dtac BufAC_Asm_prefix2 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   193
by (ftac Buf_f_d_req 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   194
by (Clarsimp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   195
by (etac ssubst 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   196
by (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   197
by (datac BufAC_Asm_cong 2 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   198
by (etac subst 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   199
by (etac imageI 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   200
qed "Buf_Eq_imp_AC_lemma";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   201
Goalw [BufAC_def] "BufEq \\<subseteq> BufAC";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   202
by (Clarify_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   203
by (eatac Buf_Eq_imp_AC_lemma 1 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   204
qed "Buf_Eq_imp_AC";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   205
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   206
(**** Buf_Eq_eq_AC ************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   207
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   208
val Buf_Eq_eq_AC = Buf_AC_imp_Eq RS (Buf_Eq_imp_AC RS subset_antisym);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   209
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   210
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   211
(**** alternative (not strictly) stronger version of Buf_Eq *******************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   212
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   213
val Buf_Eq_alt_imp_Eq = prove_goalw (the_context ()) [BufEq_def,BufEq_alt_def]
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   214
        "BufEq_alt \\<subseteq> BufEq" (K [
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   215
        rtac gfp_mono 1,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   216
        rewtac BufEq_F_def,
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   217
        Fast_tac 1]);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   218
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   219
(* direct proof of "BufEq \\<subseteq> BufEq_alt" seems impossible *)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   220
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   221
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   222
Goalw [BufEq_alt_def] "BufAC <= BufEq_alt";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   223
by (rtac gfp_upperbound 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   224
by (fast_tac (claset() addEs [BufAC_f_d, BufAC_f_d_req]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   225
qed "Buf_AC_imp_Eq_alt";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   226
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   227
bind_thm ("Buf_Eq_imp_Eq_alt",
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   228
  subset_trans OF [Buf_Eq_imp_AC, Buf_AC_imp_Eq_alt]);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   229
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   230
bind_thm ("Buf_Eq_alt_eq",
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   231
 subset_antisym OF [Buf_Eq_alt_imp_Eq, Buf_Eq_imp_Eq_alt]);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   232
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   233
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   234
(**** Buf_Eq_eq_St ************************************************************)
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   235
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   236
Goalw [BufSt_def, BufEq_def] "BufSt <= BufEq";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   237
by (rtac gfp_upperbound 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   238
by (rewtac BufEq_F_def);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   239
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   240
by ( asm_simp_tac (simpset() addsimps [BufSt_P_d, BufSt_P_empty]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   241
by (asm_simp_tac (simpset() addsimps [BufSt_P_d]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   242
by (dtac BufSt_P_d_req 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   243
by (Force_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   244
qed "Buf_St_imp_Eq";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   245
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   246
Goalw [BufSt_def, BufSt_P_def] "BufEq <= BufSt";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   247
by Safe_tac;
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   248
by (EVERY'[rename_tac "f", res_inst_tac
14171
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents: 13454
diff changeset
   249
        [("x","\\<lambda>s. case s of Sd d => \\<Lambda> x. f\\<cdot>(Md d\\<leadsto>x)| \\<currency> => f")] bexI] 1);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   250
by ( Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   251
by (etac weak_coinduct_image 1);
17293
ecf182ccc3ca converted to Isar theory format;
wenzelm
parents: 15188
diff changeset
   252
by (rewtac BufSt_F_def);
11350
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   253
by (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   254
by Safe_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   255
by (  EVERY'[rename_tac "s", induct_tac "s"] 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   256
by (   asm_simp_tac (simpset() addsimps [Buf_f_d]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   257
by (  asm_simp_tac (simpset() addsimps [Buf_f_empty]) 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   258
by ( Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   259
by (Simp_tac 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   260
by (EVERY'[rename_tac"f d x",dres_inst_tac[("d","d"),("x","x")] Buf_f_d_req] 1);
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   261
by Auto_tac;
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   262
qed "Buf_Eq_imp_St";
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   263
4c55b020d6ee added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff changeset
   264
bind_thm ("Buf_Eq_eq_St", Buf_St_imp_Eq RS (Buf_Eq_imp_St RS subset_antisym));