src/HOL/TLA/Buffer/Buffer.thy
author huffman
Thu, 04 Dec 2008 16:28:09 -0800
changeset 28988 13d6f120992b
parent 21624 6f79647cf536
child 41589 bbd861837ebc
permissions -rw-r--r--
revert to using eq_number_of_eq for simplification (Groebner_Examples.thy was broken)
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:        Buffer.thy
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
     3
    ID:          $Id$
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     4
    Author:      Stephan Merz
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     5
    Copyright:   1997 University of Munich
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     6
*)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     7
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
     8
header {* A simple FIFO buffer (synchronous communication, interleaving) *}
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
     9
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    10
theory Buffer
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    11
imports TLA
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    12
begin
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    13
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    14
consts
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    15
  (* actions *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    16
  BInit     :: "'a stfun => 'a list stfun => 'a stfun => stpred"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    17
  Enq       :: "'a stfun => 'a list stfun => 'a stfun => action"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    18
  Deq       :: "'a stfun => 'a list stfun => 'a stfun => action"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    19
  Next      :: "'a stfun => 'a list stfun => 'a stfun => action"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    20
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    21
  (* temporal formulas *)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    22
  IBuffer   :: "'a stfun => 'a list stfun => 'a stfun => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    23
  Buffer    :: "'a stfun => 'a stfun => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    24
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    25
defs
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    26
  BInit_def:   "BInit ic q oc    == PRED q = #[]"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    27
  Enq_def:     "Enq ic q oc      == ACT (ic$ ~= $ic)
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    28
                                     & (q$ = $q @ [ ic$ ])
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    29
                                     & (oc$ = $oc)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    30
  Deq_def:     "Deq ic q oc      == ACT ($q ~= #[])
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    31
                                     & (oc$ = hd< $q >)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    32
                                     & (q$ = tl< $q >)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    33
                                     & (ic$ = $ic)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    34
  Next_def:    "Next ic q oc     == ACT (Enq ic q oc | Deq ic q oc)"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    35
  IBuffer_def: "IBuffer ic q oc  == TEMP Init (BInit ic q oc)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    36
                                      & [][Next ic q oc]_(ic,q,oc)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    37
                                      & WF(Deq ic q oc)_(ic,q,oc)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    38
  Buffer_def:  "Buffer ic oc     == TEMP (EEX q. IBuffer ic q oc)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    39
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    40
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    41
(* ---------------------------- Data lemmas ---------------------------- *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    42
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    43
(*FIXME: move to theory List? Maybe as (tl xs = xs) = (xs = [])"?*)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    44
lemma tl_not_self [simp]: "xs ~= [] ==> tl xs ~= xs"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    45
  by (auto simp: neq_Nil_conv)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    46
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    47
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    48
(* ---------------------------- Action lemmas ---------------------------- *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    49
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    50
(* Dequeue is visible *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    51
lemma Deq_visible: "|- <Deq ic q oc>_(ic,q,oc) = Deq ic q oc"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    52
  apply (unfold angle_def Deq_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    53
  apply (safe, simp (asm_lr))+
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    54
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    55
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    56
(* Enabling condition for dequeue -- NOT NEEDED *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    57
lemma Deq_enabled: 
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    58
    "!!q. basevars (ic,q,oc) ==> |- Enabled (<Deq ic q oc>_(ic,q,oc)) = (q ~= #[])"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    59
  apply (unfold Deq_visible [temp_rewrite])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    60
  apply (force elim!: base_enabled [temp_use] enabledE [temp_use] simp: Deq_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    61
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    62
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    63
(* For the left-to-right implication, we don't need the base variable stuff *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    64
lemma Deq_enabledE: 
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    65
    "|- Enabled (<Deq ic q oc>_(ic,q,oc)) --> (q ~= #[])"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    66
  apply (unfold Deq_visible [temp_rewrite])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    67
  apply (auto elim!: enabledE simp add: Deq_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    68
  done
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    69
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 6255
diff changeset
    70
end