src/HOL/IOA/IOA.thy
author wenzelm
Thu, 26 May 2016 17:51:22 +0200
changeset 63167 0909deb8059b
parent 62145 5b946c81dfbf
child 67613 ce654b0e6d69
permissions -rw-r--r--
isabelle update_cartouches -c -t;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4530
ac1821645636 corrected Title
oheimb
parents: 3842
diff changeset
     1
(*  Title:      HOL/IOA/IOA.thy
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
     2
    Author:     Tobias Nipkow & Konrad Slind
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
     3
    Copyright   1994  TU Muenchen
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
     4
*)
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
     5
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 62145
diff changeset
     6
section \<open>The I/O automata of Lynch and Tuttle\<close>
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
     7
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
     8
theory IOA
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
     9
imports Asig
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
    10
begin
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    11
42174
d0be2722ce9f modernized specifications;
wenzelm
parents: 36862
diff changeset
    12
type_synonym 'a seq = "nat => 'a"
d0be2722ce9f modernized specifications;
wenzelm
parents: 36862
diff changeset
    13
type_synonym 'a oseq = "nat => 'a option"
d0be2722ce9f modernized specifications;
wenzelm
parents: 36862
diff changeset
    14
type_synonym ('a, 'b) execution = "'a oseq * 'b seq"
d0be2722ce9f modernized specifications;
wenzelm
parents: 36862
diff changeset
    15
type_synonym ('a, 's) transition = "('s * 'a * 's)"
d0be2722ce9f modernized specifications;
wenzelm
parents: 36862
diff changeset
    16
type_synonym ('a,'s) ioa = "'a signature * 's set * ('a, 's) transition set"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    17
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    18
(* IO automata *)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    19
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    20
definition state_trans :: "['action signature, ('action,'state)transition set] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    21
  where "state_trans asig R ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    22
     (!triple. triple:R --> fst(snd(triple)):actions(asig)) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    23
     (!a. (a:inputs(asig)) --> (!s1. ? s2. (s1,a,s2):R))"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    24
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    25
definition asig_of :: "('action,'state)ioa => 'action signature"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    26
  where "asig_of == fst"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    27
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    28
definition starts_of :: "('action,'state)ioa => 'state set"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    29
  where "starts_of == (fst o snd)"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    30
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    31
definition trans_of :: "('action,'state)ioa => ('action,'state)transition set"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    32
  where "trans_of == (snd o snd)"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    33
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    34
definition IOA :: "('action,'state)ioa => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    35
  where "IOA(ioa) == (is_asig(asig_of(ioa)) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    36
                (~ starts_of(ioa) = {}) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    37
                state_trans (asig_of ioa) (trans_of ioa))"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    38
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    39
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    40
(* Executions, schedules, and traces *)
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    41
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    42
(* An execution fragment is modelled with a pair of sequences:
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    43
   the first is the action options, the second the state sequence.
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    44
   Finite executions have None actions from some point on. *)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    45
definition is_execution_fragment :: "[('action,'state)ioa, ('action,'state)execution] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    46
  where "is_execution_fragment A ex ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    47
     let act = fst(ex); state = snd(ex)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    48
     in !n a. (act(n)=None --> state(Suc(n)) = state(n)) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    49
              (act(n)=Some(a) --> (state(n),a,state(Suc(n))):trans_of(A))"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    50
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    51
definition executions :: "('action,'state)ioa => ('action,'state)execution set"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    52
  where "executions(ioa) == {e. snd e 0:starts_of(ioa) & is_execution_fragment ioa e}"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    53
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    54
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    55
definition reachable :: "[('action,'state)ioa, 'state] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    56
  where "reachable ioa s == (? ex:executions(ioa). ? n. (snd ex n) = s)"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    57
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    58
definition invariant :: "[('action,'state)ioa, 'state=>bool] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    59
  where "invariant A P == (!s. reachable A s --> P(s))"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    60
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    61
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    62
(* Composition of action signatures and automata *)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    63
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    64
consts
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    65
  compatible_asigs ::"('a => 'action signature) => bool"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    66
  asig_composition ::"('a => 'action signature) => 'action signature"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    67
  compatible_ioas  ::"('a => ('action,'state)ioa) => bool"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    68
  ioa_composition  ::"('a => ('action, 'state)ioa) =>('action,'a => 'state)ioa"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    69
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    70
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    71
(* binary composition of action signatures and automata *)
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    72
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    73
definition compat_asigs ::"['action signature, 'action signature] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    74
  where "compat_asigs a1 a2 ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    75
   (((outputs(a1) Int outputs(a2)) = {}) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    76
    ((internals(a1) Int actions(a2)) = {}) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    77
    ((internals(a2) Int actions(a1)) = {}))"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    78
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    79
definition compat_ioas  ::"[('action,'s)ioa, ('action,'t)ioa] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    80
  where "compat_ioas ioa1 ioa2 == compat_asigs (asig_of(ioa1)) (asig_of(ioa2))"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    81
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    82
definition asig_comp :: "['action signature, 'action signature] => 'action signature"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    83
  where "asig_comp a1 a2 ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    84
      (((inputs(a1) Un inputs(a2)) - (outputs(a1) Un outputs(a2)),
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    85
        (outputs(a1) Un outputs(a2)),
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    86
        (internals(a1) Un internals(a2))))"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
    87
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    88
definition par :: "[('a,'s)ioa, ('a,'t)ioa] => ('a,'s*'t)ioa"  (infixr "||" 10)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    89
  where "(ioa1 || ioa2) ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    90
     (asig_comp (asig_of ioa1) (asig_of ioa2),
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    91
      {pr. fst(pr):starts_of(ioa1) & snd(pr):starts_of(ioa2)},
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    92
      {tr. let s = fst(tr); a = fst(snd(tr)); t = snd(snd(tr))
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    93
           in (a:actions(asig_of(ioa1)) | a:actions(asig_of(ioa2))) &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    94
              (if a:actions(asig_of(ioa1)) then
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    95
                 (fst(s),a,fst(t)):trans_of(ioa1)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    96
               else fst(t) = fst(s))
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    97
              &
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    98
              (if a:actions(asig_of(ioa2)) then
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
    99
                 (snd(s),a,snd(t)):trans_of(ioa2)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   100
               else snd(t) = snd(s))})"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   101
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   102
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   103
(* Filtering and hiding *)
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   104
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   105
(* Restrict the trace to those members of the set s *)
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   106
definition filter_oseq :: "('a => bool) => 'a oseq => 'a oseq"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   107
  where "filter_oseq p s ==
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   108
   (%i. case s(i)
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   109
         of None => None
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   110
          | Some(x) => if p x then Some x else None)"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   111
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   112
definition mk_trace :: "[('action,'state)ioa, 'action oseq] => 'action oseq"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   113
  where "mk_trace(ioa) == filter_oseq(%a. a:externals(asig_of(ioa)))"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   114
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   115
(* Does an ioa have an execution with the given trace *)
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   116
definition has_trace :: "[('action,'state)ioa, 'action oseq] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   117
  where "has_trace ioa b == (? ex:executions(ioa). b = mk_trace ioa (fst ex))"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   118
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   119
definition NF :: "'a oseq => 'a oseq"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   120
  where "NF(tr) == @nf. ? f. mono(f) & (!i. nf(i)=tr(f(i))) &
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   121
                    (!j. j ~: range(f) --> nf(j)= None) &
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   122
                    (!i. nf(i)=None --> (nf (Suc i)) = None)"
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   123
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   124
(* All the traces of an ioa *)
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   125
definition traces :: "('action,'state)ioa => 'action oseq set"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   126
  where "traces(ioa) == {trace. ? tr. trace=NF(tr) & has_trace ioa tr}"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   127
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   128
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   129
definition restrict_asig :: "['a signature, 'a set] => 'a signature"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   130
  where "restrict_asig asig actns ==
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   131
    (inputs(asig) Int actns, outputs(asig) Int actns,
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   132
     internals(asig) Un (externals(asig) - actns))"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   133
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   134
definition restrict :: "[('a,'s)ioa, 'a set] => ('a,'s)ioa"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   135
  where "restrict ioa actns ==
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   136
    (restrict_asig (asig_of ioa) actns, starts_of(ioa), trans_of(ioa))"
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   137
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   138
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   139
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   140
(* Notions of correctness *)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   141
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   142
definition ioa_implements :: "[('action,'state1)ioa, ('action,'state2)ioa] => bool"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   143
  where "ioa_implements ioa1 ioa2 ==
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   144
  ((inputs(asig_of(ioa1)) = inputs(asig_of(ioa2))) &
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   145
     (outputs(asig_of(ioa1)) = outputs(asig_of(ioa2))) &
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   146
      traces(ioa1) <= traces(ioa2))"
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   147
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   148
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   149
(* Instantiation of abstract IOA by concrete actions *)
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   150
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   151
definition rename :: "('a, 'b)ioa => ('c => 'a option) => ('c,'b)ioa"
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   152
  where "rename ioa ren ==
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   153
    (({b. ? x. Some(x)= ren(b) & x : inputs(asig_of(ioa))},
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   154
      {b. ? x. Some(x)= ren(b) & x : outputs(asig_of(ioa))},
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   155
      {b. ? x. Some(x)= ren(b) & x : internals(asig_of(ioa))}),
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   156
                starts_of(ioa)   ,
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   157
     {tr. let s = fst(tr); a = fst(snd(tr));  t = snd(snd(tr))
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   158
          in
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   159
          ? x. Some(x) = ren(a) & (s,x,t):trans_of(ioa)})"
3078
984866a8f905 old IOA meta theory (see also new version in HOLCF/IOA/meta_theory);
mueller
parents:
diff changeset
   160
19801
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   161
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   162
declare Let_def [simp]
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   163
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   164
lemmas ioa_projections = asig_of_def starts_of_def trans_of_def
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   165
  and exec_rws = executions_def is_execution_fragment_def
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   166
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   167
lemma ioa_triple_proj:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   168
    "asig_of(x,y,z) = x & starts_of(x,y,z) = y & trans_of(x,y,z) = z"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   169
  apply (simp add: ioa_projections)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   170
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   171
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   172
lemma trans_in_actions:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   173
  "[| IOA(A); (s1,a,s2):trans_of(A) |] ==> a:actions(asig_of(A))"
62145
5b946c81dfbf eliminated old defs;
wenzelm
parents: 58889
diff changeset
   174
  apply (unfold IOA_def state_trans_def actions_def is_asig_def)
19801
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   175
  apply (erule conjE)+
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   176
  apply (erule allE, erule impE, assumption)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   177
  apply simp
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   178
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   179
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   180
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   181
lemma filter_oseq_idemp: "filter_oseq p (filter_oseq p s) = filter_oseq p s"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   182
  apply (simp add: filter_oseq_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   183
  apply (rule ext)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   184
  apply (case_tac "s i")
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   185
  apply simp_all
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   186
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   187
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   188
lemma mk_trace_thm:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   189
"(mk_trace A s n = None) =
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   190
   (s(n)=None | (? a. s(n)=Some(a) & a ~: externals(asig_of(A))))
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   191
   &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   192
   (mk_trace A s n = Some(a)) =
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   193
    (s(n)=Some(a) & a : externals(asig_of(A)))"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   194
  apply (unfold mk_trace_def filter_oseq_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   195
  apply (case_tac "s n")
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   196
  apply auto
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   197
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   198
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   199
lemma reachable_0: "s:starts_of(A) ==> reachable A s"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   200
  apply (unfold reachable_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   201
  apply (rule_tac x = "(%i. None, %i. s)" in bexI)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   202
  apply simp
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   203
  apply (simp add: exec_rws)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   204
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   205
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   206
lemma reachable_n:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   207
  "!!A. [| reachable A s; (s,a,t) : trans_of(A) |] ==> reachable A t"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   208
  apply (unfold reachable_def exec_rws)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   209
  apply (simp del: bex_simps)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   210
  apply (simp (no_asm_simp) only: split_tupled_all)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   211
  apply safe
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   212
  apply (rename_tac ex1 ex2 n)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   213
  apply (rule_tac x = "(%i. if i<n then ex1 i else (if i=n then Some a else None) , %i. if i<Suc n then ex2 i else t)" in bexI)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   214
   apply (rule_tac x = "Suc n" in exI)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   215
   apply (simp (no_asm))
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   216
  apply simp
24742
73b8b42a36b6 removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents: 19801
diff changeset
   217
  apply (metis ioa_triple_proj less_antisym)
19801
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   218
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   219
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   220
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   221
lemma invariantI:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   222
  assumes p1: "!!s. s:starts_of(A) ==> P(s)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   223
    and p2: "!!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   224
  shows "invariant A P"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   225
  apply (unfold invariant_def reachable_def Let_def exec_rws)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   226
  apply safe
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   227
  apply (rename_tac ex1 ex2 n)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   228
  apply (rule_tac Q = "reachable A (ex2 n) " in conjunct1)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   229
  apply simp
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   230
  apply (induct_tac n)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   231
   apply (fast intro: p1 reachable_0)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   232
  apply (erule_tac x = na in allE)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   233
  apply (case_tac "ex1 na", simp_all)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   234
  apply safe
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   235
   apply (erule p2 [THEN mp])
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   236
    apply (fast dest: reachable_n)+
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   237
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   238
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   239
lemma invariantI1:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   240
 "[| !!s. s : starts_of(A) ==> P(s);
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   241
     !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   242
  |] ==> invariant A P"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   243
  apply (blast intro!: invariantI)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   244
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   245
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   246
lemma invariantE:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   247
  "[| invariant A P; reachable A s |] ==> P(s)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   248
  apply (unfold invariant_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   249
  apply blast
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   250
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   251
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   252
lemma actions_asig_comp:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   253
  "actions(asig_comp a b) = actions(a) Un actions(b)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   254
  apply (auto simp add: actions_def asig_comp_def asig_projections)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   255
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   256
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   257
lemma starts_of_par:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   258
  "starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   259
  apply (simp add: par_def ioa_projections)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   260
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   261
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   262
(* Every state in an execution is reachable *)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   263
lemma states_of_exec_reachable:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   264
  "ex:executions(A) ==> !n. reachable A (snd ex n)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   265
  apply (unfold reachable_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   266
  apply fast
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   267
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   268
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   269
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   270
lemma trans_of_par4:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   271
"(s,a,t) : trans_of(A || B || C || D) =
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   272
  ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) |
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   273
    a:actions(asig_of(D))) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   274
   (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   275
    else fst t=fst s) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   276
   (if a:actions(asig_of(B)) then (fst(snd(s)),a,fst(snd(t))):trans_of(B)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   277
    else fst(snd(t))=fst(snd(s))) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   278
   (if a:actions(asig_of(C)) then
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   279
      (fst(snd(snd(s))),a,fst(snd(snd(t)))):trans_of(C)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   280
    else fst(snd(snd(t)))=fst(snd(snd(s)))) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   281
   (if a:actions(asig_of(D)) then
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   282
      (snd(snd(snd(s))),a,snd(snd(snd(t)))):trans_of(D)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   283
    else snd(snd(snd(t)))=snd(snd(snd(s)))))"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   284
  (*SLOW*)
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 42174
diff changeset
   285
  apply (simp (no_asm) add: par_def actions_asig_comp prod_eq_iff ioa_projections)
19801
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   286
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   287
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   288
lemma cancel_restrict: "starts_of(restrict ioa acts) = starts_of(ioa) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   289
              trans_of(restrict ioa acts) = trans_of(ioa) &
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   290
              reachable (restrict ioa acts) s = reachable ioa s"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   291
  apply (simp add: is_execution_fragment_def executions_def
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   292
    reachable_def restrict_def ioa_projections)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   293
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   294
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   295
lemma asig_of_par: "asig_of(A || B) = asig_comp (asig_of A) (asig_of B)"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   296
  apply (simp add: par_def ioa_projections)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   297
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   298
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   299
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   300
lemma externals_of_par: "externals(asig_of(A1||A2)) =
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   301
   (externals(asig_of(A1)) Un externals(asig_of(A2)))"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   302
  apply (simp add: externals_def asig_of_par asig_comp_def
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 24742
diff changeset
   303
    asig_inputs_def asig_outputs_def Un_def set_diff_eq)
19801
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   304
  apply blast
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   305
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   306
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   307
lemma ext1_is_not_int2:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   308
  "[| compat_ioas A1 A2; a:externals(asig_of(A1))|] ==> a~:internals(asig_of(A2))"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   309
  apply (unfold externals_def actions_def compat_ioas_def compat_asigs_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   310
  apply auto
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   311
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   312
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   313
lemma ext2_is_not_int1:
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   314
 "[| compat_ioas A2 A1 ; a:externals(asig_of(A1))|] ==> a~:internals(asig_of(A2))"
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   315
  apply (unfold externals_def actions_def compat_ioas_def compat_asigs_def)
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   316
  apply auto
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   317
  done
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   318
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   319
lemmas ext1_ext2_is_not_act2 = ext1_is_not_int2 [THEN int_and_ext_is_act]
b2af2549efd1 removed obsolete ML files;
wenzelm
parents: 17288
diff changeset
   320
  and ext1_ext2_is_not_act1 = ext2_is_not_int1 [THEN int_and_ext_is_act]
17288
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   321
aa3833fb7bee converted to Isar theory format;
wenzelm
parents: 11482
diff changeset
   322
end