src/HOL/MicroJava/BV/DFA_Framework.thy
author kleing
Fri, 09 Feb 2001 16:01:58 +0100
changeset 11085 b830bf10bf71
parent 10592 fc0b575a2cf7
permissions -rw-r--r--
tuned for 99-2 release
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     1
(*  Title:      HOL/BCV/DFA_Framework.thy
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     2
    ID:         $Id$
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     3
    Author:     Tobias Nipkow
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     4
    Copyright   2000 TUM
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     5
*)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     6
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     7
header "Dataflow Analysis Framework"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     8
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     9
theory DFA_Framework = Listn:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    10
11085
b830bf10bf71 tuned for 99-2 release
kleing
parents: 10592
diff changeset
    11
text {* 
b830bf10bf71 tuned for 99-2 release
kleing
parents: 10592
diff changeset
    12
  The relationship between dataflow analysis and a welltyped-insruction predicate. 
b830bf10bf71 tuned for 99-2 release
kleing
parents: 10592
diff changeset
    13
*}
b830bf10bf71 tuned for 99-2 release
kleing
parents: 10592
diff changeset
    14
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    15
constdefs
10592
fc0b575a2cf7 BCV Integration
kleing
parents: 10496
diff changeset
    16
 bounded :: "(nat => nat list) => nat => bool"
fc0b575a2cf7 BCV Integration
kleing
parents: 10496
diff changeset
    17
"bounded succs n == !p<n. !q:set(succs p). q<n"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    18
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    19
 stable :: "'s ord =>
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    20
           (nat => 's => 's)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    21
           => (nat => nat list) => 's list => nat => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    22
"stable r step succs ss p == !q:set(succs p). step p (ss!p) <=_r ss!q"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    23
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    24
 stables :: "'s ord => (nat => 's => 's)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    25
            => (nat => nat list) => 's list => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    26
"stables r step succs ss == !p<size ss. stable r step succs ss p"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    27
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    28
 is_dfa :: "'s ord
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    29
           => ('s list => 's list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    30
           => (nat => 's => 's)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    31
           => (nat => nat list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    32
           => nat => 's set => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    33
"is_dfa r dfa step succs n A == !ss : list n A.
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    34
   dfa ss : list n A & stables r step succs (dfa ss) & ss <=[r] dfa ss &
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    35
   (!ts: list n A. ss <=[r] ts & stables r step succs ts
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    36
                     --> dfa ss <=[r] ts)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    37
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    38
 is_bcv :: "'s ord => 's => (nat => 's => 's) => (nat => nat list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    39
           => nat => 's set => ('s list => 's list) => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    40
"is_bcv r T step succs n A bcv == !ss : list n A.
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    41
   (!p<n. (bcv ss)!p ~= T) =
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    42
   (? ts: list n A. ss <=[r] ts & welltyping r T step succs ts)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    43
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    44
 welltyping ::
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    45
"'s ord => 's => (nat => 's => 's) => (nat => nat list) => 's list => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    46
"welltyping r T step succs ts ==
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    47
 !p<size(ts). ts!p ~= T & stable r step succs ts p"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    48
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    49
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    50
lemma is_dfaD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    51
 "[| is_dfa r dfa step succs n A; ss : list n A |] ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    52
  dfa ss:list n A & stables r step succs (dfa ss) & ss <=[r] dfa ss & 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    53
  (!ts: list n A. stables r step succs ts & ss <=[r] ts 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    54
  --> dfa ss <=[r] ts)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    55
  by (simp add: is_dfa_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    56
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    57
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    58
lemma is_bcv_dfa:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    59
  "[| order r; top r T; is_dfa r dfa step succs n A |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    60
  ==> is_bcv r T step succs n A dfa"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    61
apply (unfold is_bcv_def welltyping_def stables_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    62
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    63
apply (drule is_dfaD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    64
apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    65
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    66
apply (rule iffI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    67
 apply (rule bexI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    68
  apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    69
   apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    70
  apply (simp add: stables_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    71
 apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    72
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    73
apply (simp add: imp_conjR all_conj_distrib stables_def 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    74
            cong: conj_cong)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    75
apply (drule_tac x = ts in bspec)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    76
 apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    77
apply (force dest: le_listD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    78
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    79
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    80
end