| 
5111
 | 
     1  | 
(*  Title:      HOL/UNITY/Traces
  | 
| 
 | 
     2  | 
    ID:         $Id$
  | 
| 
 | 
     3  | 
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
  | 
| 
 | 
     4  | 
    Copyright   1998  University of Cambridge
  | 
| 
 | 
     5  | 
  | 
| 
 | 
     6  | 
Definitions of
  | 
| 
 | 
     7  | 
  * traces: the possible execution traces
  | 
| 
 | 
     8  | 
  * reachable: the set of reachable states
  | 
| 
 | 
     9  | 
  | 
| 
 | 
    10  | 
*)
  | 
| 
 | 
    11  | 
  | 
| 
4776
 | 
    12  | 
open Traces;
  | 
| 
 | 
    13  | 
  | 
| 
5111
 | 
    14  | 
  | 
| 
 | 
    15  | 
(****
  | 
| 
 | 
    16  | 
Now simulate the inductive definition (illegal due to paired arguments)
  | 
| 
 | 
    17  | 
  | 
| 
 | 
    18  | 
inductive "reachable(Init,Acts)"
  | 
| 
 | 
    19  | 
  intrs 
  | 
| 
 | 
    20  | 
    Init  "s: Init ==> s : reachable(Init,Acts)"
  | 
| 
 | 
    21  | 
  | 
| 
 | 
    22  | 
    Acts  "[| act: Acts;  s : reachable(Init,Acts);  (s,s'): act |]
  | 
| 
 | 
    23  | 
	   ==> s' : reachable(Init,Acts)"
  | 
| 
4776
 | 
    24  | 
  | 
| 
5111
 | 
    25  | 
This amounts to an equivalence proof for the definition actually used, 
  | 
| 
 | 
    26  | 
****)
  | 
| 
 | 
    27  | 
  | 
| 
4776
 | 
    28  | 
  | 
| 
5111
 | 
    29  | 
(** reachable: Deriving the Introduction rules **)
  | 
| 
4776
 | 
    30  | 
  | 
| 
5111
 | 
    31  | 
Goal "s: Init ==> s : reachable(Init,Acts)";
  | 
| 
 | 
    32  | 
by (simp_tac (simpset() addsimps [reachable_def]) 1);
  | 
| 
 | 
    33  | 
by (blast_tac (claset() addIs traces.intrs) 1);
  | 
| 
 | 
    34  | 
qed "reachable_Init";
  | 
| 
4776
 | 
    35  | 
  | 
| 
 | 
    36  | 
  | 
| 
5111
 | 
    37  | 
Goal "[| act: Acts;  s : reachable(Init,Acts) |] \
  | 
| 
 | 
    38  | 
\     ==> (s,s'): act --> s' : reachable(Init,Acts)";
  | 
| 
 | 
    39  | 
by (asm_full_simp_tac (simpset() addsimps [reachable_def]) 1);
  | 
| 
 | 
    40  | 
by (etac exE 1);
  | 
| 
 | 
    41  | 
be traces.induct 1;
  | 
| 
 | 
    42  | 
by (ALLGOALS Asm_simp_tac);
  | 
| 
 | 
    43  | 
by (ALLGOALS (blast_tac (claset() addIs traces.intrs)));
  | 
| 
 | 
    44  | 
qed_spec_mp "reachable_Acts";
  | 
| 
 | 
    45  | 
  | 
| 
 | 
    46  | 
  | 
| 
 | 
    47  | 
val major::prems = 
  | 
| 
 | 
    48  | 
Goalw [reachable_def] 
  | 
| 
 | 
    49  | 
  "[| za : reachable(Init,Acts);  \
  | 
| 
 | 
    50  | 
\     !!s. s : Init ==> P s;      \
  | 
| 
 | 
    51  | 
\     !!act s s'.  \
  | 
| 
 | 
    52  | 
\        [| act : Acts; s : reachable(Init,Acts); P s; (s, s') : act |]  \
  | 
| 
 | 
    53  | 
\        ==> P s' |] \
  | 
| 
 | 
    54  | 
\  ==> P za";
  | 
| 
 | 
    55  | 
by (cut_facts_tac [major] 1);
  | 
| 
5132
 | 
    56  | 
by Auto_tac;
  | 
| 
5111
 | 
    57  | 
be traces.induct 1;
  | 
| 
 | 
    58  | 
by (ALLGOALS (blast_tac (claset() addIs prems)));
  | 
| 
 | 
    59  | 
qed "reachable_induct";
  | 
| 
 | 
    60  | 
  | 
| 
 | 
    61  | 
structure reachable = 
  | 
| 
 | 
    62  | 
  struct 
  | 
| 
 | 
    63  | 
  val Init = reachable_Init
  | 
| 
 | 
    64  | 
  val Acts = reachable_Acts
  | 
| 
 | 
    65  | 
  val intrs = [reachable_Init, reachable_Acts]
  | 
| 
 | 
    66  | 
  val induct = reachable_induct
  | 
| 
 | 
    67  | 
  end;
  | 
| 
4776
 | 
    68  | 
  | 
| 
 | 
    69  | 
  | 
| 
 | 
    70  | 
(*The strongest invariant is the set of all reachable states!*)
  | 
| 
5069
 | 
    71  | 
Goalw [stable_def, constrains_def]
  | 
| 
5111
 | 
    72  | 
    "[| Init<=A;  stable Acts A |] ==> reachable(Init,Acts) <= A";
  | 
| 
4776
 | 
    73  | 
by (rtac subsetI 1);
  | 
| 
 | 
    74  | 
be reachable.induct 1;
  | 
| 
 | 
    75  | 
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
  | 
| 
 | 
    76  | 
qed "strongest_invariant";
  | 
| 
 | 
    77  | 
  | 
| 
5111
 | 
    78  | 
Goal "stable Acts (reachable(Init,Acts))";
  | 
| 
4776
 | 
    79  | 
by (REPEAT (blast_tac (claset() addIs [stableI, constrainsI]
  | 
| 
 | 
    80  | 
				addIs reachable.intrs) 1));
  | 
| 
 | 
    81  | 
qed "stable_reachable";
  |