src/HOL/TLA/Buffer/DBuffer.ML
author berghofe
Mon, 30 Sep 2002 16:14:02 +0200
changeset 13601 fd3e3d6b37b2
parent 6255 db63752140c7
child 17309 c43ed29bd197
permissions -rw-r--r--
Adapted to new simplifier.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     1
(* 
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     2
    File:        DBuffer.ML
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     3
    Author:      Stephan Merz
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     4
    Copyright:   1997 University of Munich
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     5
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     6
    Double FIFO buffer implements simple FIFO buffer.
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     7
*)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     8
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
     9
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3807
diff changeset
    10
val db_css = (claset(), simpset() addsimps [qc_def]);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    11
Addsimps [qc_def];
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    12
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    13
val db_defs = [BInit_def, Enq_def, Deq_def, Next_def, IBuffer_def, Buffer_def,
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    14
               DBInit_def,DBEnq_def,DBDeq_def,DBPass_def,DBNext_def,DBuffer_def];
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    15
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    16
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    17
(*** Proper initialization ***)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    18
Goal "|- Init DBInit --> Init (BInit inp qc out)";
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    19
by (auto_tac (db_css addsimps2 [Init_def,DBInit_def,BInit_def]));
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    20
qed "DBInit";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    21
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    22
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    23
(*** Step simulation ***)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    24
Goal "|- [DBNext]_(inp,mid,out,q1,q2) --> [Next inp qc out]_(inp,qc,out)";
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    25
by (rtac square_simulation 1);
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    26
by (Clarsimp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3807
diff changeset
    27
by (action_simp_tac (simpset() addsimps hd_append::db_defs) [] [] 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    28
qed "DB_step_simulation";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    29
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    30
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    31
(*** Simulation of fairness ***)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    32
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    33
(* Compute enabledness predicates for DBDeq and DBPass actions *)
13601
fd3e3d6b37b2 Adapted to new simplifier.
berghofe
parents: 6255
diff changeset
    34
Goalw [angle_def,DBDeq_def,Deq_def] "|- <DBDeq>_(inp,mid,out,q1,q2) = DBDeq";
fd3e3d6b37b2 Adapted to new simplifier.
berghofe
parents: 6255
diff changeset
    35
by (REPEAT (Safe_tac THEN Asm_lr_simp_tac 1));
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    36
qed "DBDeq_visible";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    37
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    38
Goalw [action_rewrite DBDeq_visible]
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    39
  "|- Enabled (<DBDeq>_(inp,mid,out,q1,q2)) = (q2 ~= #[])";
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    40
by (force_tac (db_css addSIs2 [DB_base RS base_enabled] addSEs2 [enabledE] 
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    41
                     addsimps2 [angle_def,DBDeq_def,Deq_def]) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    42
qed "DBDeq_enabled";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    43
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    44
Goal "|- <DBPass>_(inp,mid,out,q1,q2) = DBPass";
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    45
by (auto_tac (db_css addsimps2 [angle_def,DBPass_def,Deq_def]));
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    46
qed "DBPass_visible";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    47
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    48
Goalw [action_rewrite DBPass_visible]
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    49
   "|- Enabled (<DBPass>_(inp,mid,out,q1,q2)) = (q1 ~= #[])";
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    50
by (force_tac (db_css addSIs2 [DB_base RS base_enabled] addSEs2 [enabledE] 
5525
896f8234b864 improved addbefore and addSbefore
oheimb
parents: 5069
diff changeset
    51
                     addsimps2 [angle_def,DBPass_def,Deq_def]) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    52
qed "DBPass_enabled";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    53
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    54
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    55
(* The plan for proving weak fairness at the higher level is to prove
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    56
   (0)  DBuffer => (Enabled (Deq inp qc out) ~> (Deq inp qc out))
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    57
   which is in turn reduced to the two leadsto conditions
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    58
   (1)  DBuffer => (Enabled (Deq inp qc out) ~> q2 ~= [])
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    59
   (2)  DBuffer => (q2 ~= [] ~> DBDeq)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    60
   and the fact that DBDeq implies <Deq inp qc out>_(inp,qc,out)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    61
   (and therefore DBDeq ~> <Deq inp qc out>_(inp,qc,out) trivially holds).
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    62
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    63
   Condition (1) is reduced to
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    64
   (1a) DBuffer => (qc ~= [] /\ q2 = [] ~> q2 ~= [])
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    65
   by standard leadsto rules (leadsto_classical) and rule Deq_enabledE.
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    66
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    67
   Both (1a) and (2) are proved from DBuffer's WF conditions by standard
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    68
   WF reasoning (Lamport's WF1 and WF_leadsto).
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    69
   The condition WF(Deq inp qc out) follows from (0) by rule leadsto_WF.
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    70
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    71
   One could use Lamport's WF2 instead.
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    72
*)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    73
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    74
(* Condition (1a) *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    75
Goal "|- [][DBNext]_(inp,mid,out,q1,q2) & WF(DBPass)_(inp,mid,out,q1,q2) \
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    76
\        --> (qc ~= #[] & q2 = #[] ~> q2 ~= #[])";
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    77
by (rtac WF1 1);
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    78
by (force_tac (db_css addsimps2 db_defs) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    79
by (force_tac (db_css addsimps2 [angle_def,DBPass_def]) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    80
by (force_tac (db_css addsimps2 [DBPass_enabled]) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    81
qed "DBFair_1a";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    82
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    83
(* Condition (1) *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    84
Goal "|- [][DBNext]_(inp,mid,out,q1,q2) & WF(DBPass)_(inp,mid,out,q1,q2) \
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    85
\        --> (Enabled (<Deq inp qc out>_(inp,qc,out)) ~> q2 ~= #[])";
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    86
by (Clarsimp_tac 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    87
by (rtac (temp_use leadsto_classical) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    88
by (rtac ((temp_use DBFair_1a) RS (temp_use LatticeTransitivity)) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    89
by (TRYALL atac);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    90
by (rtac (temp_use ImplLeadsto_gen) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    91
by (force_tac (db_css addSIs2 [necT] addSDs2 [STL2_gen, Deq_enabledE]
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    92
                      addsimps2 Init_defs) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    93
qed "DBFair_1";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    94
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    95
(* Condition (2) *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    96
Goal "|- [][DBNext]_(inp,mid,out,q1,q2) & WF(DBDeq)_(inp,mid,out,q1,q2) \
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    97
\        --> (q2 ~= #[] ~> DBDeq)";
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    98
by (rtac WF_leadsto 1);
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
    99
by (force_tac (db_css addsimps2 [DBDeq_enabled]) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   100
by (force_tac (db_css addsimps2 [angle_def]) 1);
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   101
by (force_tac (db_css addsimps2 db_defs addSEs2 [Stable]) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   102
qed "DBFair_2";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   103
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   104
(* High-level fairness *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   105
Goal "|- [][DBNext]_(inp,mid,out,q1,q2) & WF(DBPass)_(inp,mid,out,q1,q2) \
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   106
\                                       & WF(DBDeq)_(inp,mid,out,q1,q2)  \ 
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   107
\        --> WF(Deq inp qc out)_(inp,qc,out)";
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   108
by (auto_tac (temp_css addSIs2 [leadsto_WF,
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   109
                                (temp_use DBFair_1) RSN(2,(temp_use LatticeTransitivity)),
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   110
                                (temp_use DBFair_2) RSN(2,(temp_use LatticeTransitivity))]));
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   111
by (auto_tac (db_css addSIs2 [ImplLeadsto_simple]
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   112
                     addsimps2 [angle_def,DBDeq_def,Deq_def,hd_append]));
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   113
qed "DBFair";
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   114
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   115
(*** Main theorem ***)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   116
Goalw [DBuffer_def,Buffer_def,IBuffer_def] "|- DBuffer --> Buffer inp out";
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 5755
diff changeset
   117
by (force_tac (temp_css addSIs2 [eexI,DBInit,DB_step_simulation RS STL4,DBFair]) 1);
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   118
qed "DBuffer_impl_Buffer";