src/HOL/BCV/DFAimpl.thy
author nipkow
Tue, 28 Sep 1999 16:36:12 +0200
changeset 7626 5997f35954d7
child 9279 fb4186e20148
permissions -rw-r--r--
A new theory: a model of bytecode verification.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/BCV/DFAimpl.thy
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     4
    Copyright   1999 TUM
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     5
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     6
Implementations of data-flow analysis.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     7
*)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     8
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     9
DFAimpl = DFAandWTI + Fixpoint +
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    10
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    11
consts merges :: "('s::plus) => nat list => 's os => 's os"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    12
primrec
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    13
"merges a []     s = s"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    14
"merges a (p#ps) s = merges a ps (s[p := Some(a) + s!p])"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    15
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    16
constdefs
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    17
 succs_bounded :: "(nat => nat list) => nat => bool"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    18
"succs_bounded succs n == !p<n. !q:set(succs p). q<n"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    19
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    20
 is_next :: "((nat => 's => ('s::plus)option) => (nat => nat list)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    21
              => 's os => 's os option)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    22
             => bool"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    23
"is_next next == !step succs sos sos'.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    24
   succs_bounded succs (size sos) -->
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    25
   (next step succs sos = None -->
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    26
      (? p<size sos. ? s. sos!p = Some s & step p s = None))  &
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    27
   (next step succs sos = Some sos -->
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    28
      (!p<size sos. !s. sos!p = Some s --> (? t.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    29
          step p s = Some(t) & merges t (succs p) sos = sos))) &
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    30
   (next step succs sos = Some sos' & sos' ~= sos -->
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    31
      (? p<size sos. ? s. sos!p = Some s & (? t.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    32
          step p s = Some(t) & merges t (succs p) sos = sos')))"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    33
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    34
 step_pres_type :: "(nat => 's => 's option) => nat => 's set => bool"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    35
"step_pres_type step n L == !s:L. !p<n. !t. step p s = Some(t) --> t:L"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    36
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    37
 step_mono_None :: "(nat => 's => 's option) => nat => 's set => bool"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    38
"step_mono_None step n L == !s p t.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    39
   s : L & p < n & s <= t & step p s = None --> step p t = None"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    40
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    41
 step_mono :: "(nat => 's => 's option) => nat => 's set => bool"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    42
"step_mono step n L == !s p t u.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    43
   s : L & p < n & s <= t & step p s = Some(u)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    44
   --> (!v. step p t = Some(v) --> u <= v)"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    45
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    46
consts
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    47
itnext :: nat => (nat => 's => 's option) => (nat => nat list)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    48
          => 's os => ('s::plus) os option
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    49
primrec
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    50
"itnext 0       step succs sos = Some sos"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    51
"itnext (Suc p) step succs sos =
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    52
   (case sos!p of
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    53
      None => itnext p step succs sos
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    54
    | Some s => (case step p s of None => None
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    55
                 | Some t => let sos' = merges t (succs p) sos
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    56
                             in if sos' = sos
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    57
                                then itnext p step succs sos
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    58
                                else Some sos'))"
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    59
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    60
end