src/HOL/MicroJava/BV/Kildall.thy
author nipkow
Thu, 10 May 2001 17:28:40 +0200
changeset 11295 66925f23ac7f
parent 11229 f417841385b7
child 11298 acd83fa66e92
permissions -rw-r--r--
improved tracing of permutative rules.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     1
(*  Title:      HOL/BCV/Kildall.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
Kildall's algorithm
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     7
*)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     8
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     9
header "Kildall's Algorithm"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    10
11229
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
    11
theory Kildall = Typing_Framework + While_Combinator:
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    12
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    13
constdefs
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    14
 pres_type :: "(nat => 's => 's) => nat => 's set => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    15
"pres_type step n A == !s:A. !p<n. step p s : A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    16
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    17
 mono :: "'s ord => (nat => 's => 's) => nat => 's set => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    18
"mono r step n A ==
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    19
 !s p t. s : A & p < n & s <=_r t --> step p s <=_r step p t"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    20
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    21
consts
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
    22
 iter :: "'s binop \<Rightarrow> (nat \<Rightarrow> 's \<Rightarrow> 's) \<Rightarrow> (nat \<Rightarrow> nat list) \<Rightarrow>
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
    23
          's list \<Rightarrow> nat set \<Rightarrow> 's list"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    24
 propa :: "'s binop => nat list => 's => 's list => nat set => 's list * nat set"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    25
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    26
primrec
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    27
"propa f []     t ss w = (ss,w)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    28
"propa f (q#qs) t ss w = (let u = t +_f ss!q;
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    29
                              w' = (if u = ss!q then w else insert q w)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    30
                          in propa f qs t (ss[q := u]) w')"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    31
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
    32
defs iter_def:
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
    33
"iter f step succs ss w ==
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
    34
 fst(while (%(ss,w). w \<noteq> {})
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
    35
           (%(ss,w). let p = SOME p. p : w
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
    36
                     in propa f (succs p) (step p (ss!p)) ss (w-{p}))
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
    37
           (ss,w))"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    38
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    39
constdefs
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    40
 unstables ::
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    41
 "'s binop => (nat => 's => 's) => (nat => nat list) => 's list => nat set"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    42
"unstables f step succs ss ==
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    43
 {p. p < size ss & (? q:set(succs p). step p (ss!p) +_f ss!q ~= ss!q)}"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    44
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
    45
 kildall :: "'s binop => (nat => 's => 's) => (nat => nat list)
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    46
             => 's list => 's list"
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
    47
"kildall f step succs ss == iter f step succs ss (unstables f step succs ss)"
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    48
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    49
consts merges :: "'s binop => 's => nat list => 's list => 's list"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    50
primrec
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    51
"merges f s []     ss = ss"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    52
"merges f s (p#ps) ss = merges f s ps (ss[p := s +_f ss!p])"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    53
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    54
10774
4de3a0d3ae28 recdef_tc;
wenzelm
parents: 10661
diff changeset
    55
lemmas [simp] = Let_def le_iff_plus_unchanged [symmetric]
10496
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 pres_typeD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    59
  "[| pres_type step n A; s:A; p<n |] ==> step p s : A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    60
  by (unfold pres_type_def, blast)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    61
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    62
lemma boundedD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    63
  "[| bounded succs n; p < n; q : set(succs p) |] ==> q < n"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    64
  by (unfold bounded_def, blast)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    65
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    66
lemma monoD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    67
  "[| mono r step n A; p < n; s:A; s <=_r t |] ==> step p s <=_r step p t"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    68
  by (unfold mono_def, blast)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    69
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    70
(** merges **)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    71
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    72
lemma length_merges [rule_format, simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    73
  "!ss. size(merges f t ps ss) = size ss"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    74
  by (induct_tac ps, auto)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    75
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    76
lemma merges_preserves_type [rule_format, simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    77
  "[| semilat(A,r,f) |] ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    78
     !xs. xs : list n A --> x : A --> (!p : set ps. p<n) 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    79
          --> merges f x ps xs : list n A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    80
  apply (frule semilatDclosedI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    81
  apply (unfold closed_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    82
  apply (induct_tac ps)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    83
  apply auto
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    84
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    85
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    86
lemma merges_incr [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    87
  "[| semilat(A,r,f) |] ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    88
     !xs. xs : list n A --> x : A --> (!p:set ps. p<size xs) --> xs <=[r] merges f x ps xs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    89
  apply (induct_tac ps)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    90
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    91
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    92
  apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    93
  apply (rule order_trans)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    94
    apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    95
   apply (erule list_update_incr)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    96
     apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    97
    apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    98
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    99
  apply (blast intro!: listE_set intro: closedD listE_length [THEN nth_in])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   100
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   101
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   102
lemma merges_same_conv [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   103
  "[| semilat(A,r,f) |] ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   104
     (!xs. xs : list n A --> x:A --> (!p:set ps. p<size xs) --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   105
     (merges f x ps xs = xs) = (!p:set ps. x <=_r xs!p))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   106
  apply (induct_tac ps)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   107
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   108
  apply clarsimp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   109
  apply (rename_tac p ps xs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   110
  apply (rule iffI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   111
   apply (rule context_conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   112
    apply (subgoal_tac "xs[p := x +_f xs!p] <=[r] xs")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   113
     apply (force dest!: le_listD simp add: nth_list_update)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   114
    apply (erule subst, rule merges_incr)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   115
        apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   116
       apply (blast intro!: listE_set intro: closedD listE_length [THEN nth_in])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   117
     apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   118
    apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   119
   apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   120
   apply (rotate_tac -2)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   121
   apply (erule allE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   122
   apply (erule impE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   123
    apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   124
   apply (erule impE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   125
    apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   126
   apply (drule bspec)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   127
    apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   128
   apply (simp add: le_iff_plus_unchanged [THEN iffD1] list_update_same_conv [THEN iffD2])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   129
  apply clarify 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   130
  apply (simp add: le_iff_plus_unchanged [THEN iffD1] list_update_same_conv [THEN iffD2])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   131
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   132
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   133
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   134
lemma list_update_le_listI [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   135
  "set xs <= A --> set ys <= A --> xs <=[r] ys --> p < size xs -->  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   136
   x <=_r ys!p --> semilat(A,r,f) --> x:A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   137
   xs[p := x +_f xs!p] <=[r] ys"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   138
  apply (unfold Listn.le_def lesub_def semilat_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   139
  apply (simp add: list_all2_conv_all_nth nth_list_update)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   140
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   141
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   142
lemma merges_pres_le_ub:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   143
  "[| semilat(A,r,f); t:A; set ts <= A; set ss <= A; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   144
     !p. p:set ps --> t <=_r ts!p; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   145
     !p. p:set ps --> p<size ts; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   146
     ss <=[r] ts |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   147
  ==> merges f t ps ss <=[r] ts"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   148
proof -
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   149
  { fix A r f t ts ps
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   150
    have
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   151
    "!!qs. [| semilat(A,r,f); set ts <= A; t:A; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   152
       !p. p:set ps --> t <=_r ts!p; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   153
       !p. p:set ps --> p<size ts |] ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   154
    set qs <= set ps  --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   155
    (!ss. set ss <= A --> ss <=[r] ts --> merges f t qs ss <=[r] ts)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   156
    apply (induct_tac qs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   157
     apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   158
    apply (simp (no_asm_simp))
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   159
    apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   160
    apply (rotate_tac -2)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   161
    apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   162
    apply (erule allE, erule impE, erule_tac [2] mp)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   163
     apply (simp (no_asm_simp) add: closedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   164
    apply (simp add: list_update_le_listI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   165
    done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   166
  } note this [dest]
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   167
  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   168
  case antecedent
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   169
  thus ?thesis by blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   170
qed
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   171
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   172
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   173
lemma nth_merges [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   174
  "[| semilat (A, r, f); t:A; p < n |] ==> !ss. ss : list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   175
     (!p:set ps. p<n) --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   176
     (merges f t ps ss)!p = (if p : set ps then t +_f ss!p else ss!p)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   177
  apply (induct_tac "ps")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   178
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   179
  apply (simp add: nth_list_update closedD listE_nth_in) 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   180
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   181
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   182
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   183
(** propa **)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   184
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   185
lemma decomp_propa [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   186
  "!ss w. (!q:set qs. q < size ss) --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   187
   propa f qs t ss w = 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   188
   (merges f t qs ss, {q. q:set qs & t +_f ss!q ~= ss!q} Un w)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   189
  apply (induct_tac qs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   190
   apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   191
  apply (simp (no_asm))
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   192
  apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   193
  apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   194
   apply (simp add: nth_list_update)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   195
   apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   196
  apply (simp add: nth_list_update)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   197
  apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   198
  done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   199
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   200
(** iter **)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   201
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   202
lemma stable_pres_lemma:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   203
  "[| semilat (A,r,f); pres_type step n A; bounded succs n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   204
     ss : list n A; p : w; ! q:w. q < n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   205
     ! q. q < n --> q ~: w --> stable r step succs ss q; q < n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   206
     q : set (succs p) --> step p (ss ! p) +_f ss ! q = ss ! q; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   207
     q ~: w | q = p  |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   208
  ==> stable r step succs (merges f (step p (ss!p)) (succs p) ss) q"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   209
  apply (unfold stable_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   210
  apply (subgoal_tac "step p (ss!p) : A")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   211
   defer
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   212
   apply (blast intro: listE_nth_in pres_typeD)     
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   213
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   214
  apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   215
  apply (subst nth_merges)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   216
       apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   217
      apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   218
     prefer 2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   219
     apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   220
    apply (blast dest: boundedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   221
   apply (blast dest: boundedD)  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   222
  apply (subst nth_merges)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   223
       apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   224
      apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   225
     prefer 2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   226
     apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   227
    apply (blast dest: boundedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   228
   apply (blast dest: boundedD)  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   229
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   230
  apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   231
   apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   232
   apply (blast intro!: semilat_ub1 semilat_ub2 listE_nth_in
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   233
                intro: order_trans dest: boundedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   234
  apply (blast intro!: semilat_ub1 semilat_ub2 listE_nth_in
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   235
               intro: order_trans dest: boundedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   236
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   237
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   238
lemma merges_bounded_lemma [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   239
  "[| semilat (A,r,f); mono r step n A; bounded succs n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   240
     step p (ss!p) : A; ss : list n A; ts : list n A; p < n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   241
     ss <=[r] ts; ! p. p < n --> stable r step succs ts p |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   242
  ==> merges f (step p (ss!p)) (succs p) ss <=[r] ts"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   243
  apply (unfold stable_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   244
  apply (blast intro!: listE_set monoD listE_nth_in le_listD less_lengthI
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   245
               intro: merges_pres_le_ub order_trans
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   246
               dest: pres_typeD boundedD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   247
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   248
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   249
lemma termination_lemma:  
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   250
  "[| semilat(A,r,f); ss : list n A; t:A; ! q:set qs. q < n; p:w |] ==> 
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   251
      ss <[r] merges f t qs ss | 
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   252
  merges f t qs ss = ss & {q. q:set qs & t +_f ss!q ~= ss!q} Un (w-{p}) < w"
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   253
  apply (unfold lesssub_def)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   254
  apply (simp (no_asm_simp) add: merges_incr)
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   255
  apply (rule impI)
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   256
  apply (rule merges_same_conv [THEN iffD1, elim_format]) 
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   257
  apply assumption+
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   258
    defer
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   259
    apply (rule sym, assumption)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   260
   apply (simp cong add: conj_cong add: le_iff_plus_unchanged [symmetric])
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   261
   apply (blast intro!: psubsetI elim: equalityE)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   262
  apply simp
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   263
  done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   264
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   265
lemma while_properties:
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   266
  "\<lbrakk> semilat(A,r,f); acc r ; pres_type step n A; mono r step n A;
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   267
     bounded succs n; \<forall>p\<in>w0. p < n; ss0 \<in> list n A;
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   268
     \<forall>p<n. p \<notin> w0 \<longrightarrow> stable r step succs ss0 p \<rbrakk> \<Longrightarrow>
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   269
   ss' = fst(while (%(ss,w). w \<noteq> {})
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   270
         (%(ss,w). let p = SOME p. p \<in> w
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   271
                   in propa f (succs p) (step p (ss!p)) ss (w-{p})) (ss0,w0))
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   272
   \<longrightarrow>
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   273
   ss' \<in> list n A \<and> stables r step succs ss' \<and> ss0 <=[r] ss' \<and>
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   274
   (\<forall>ts\<in>list n A. ss0 <=[r] ts \<and> stables r step succs ts \<longrightarrow> ss' <=[r] ts)"
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   275
apply (unfold stables_def)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   276
apply (rule_tac P = "%(ss,w).
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   277
 ss \<in> list n A \<and> (\<forall>p<n. p \<notin> w \<longrightarrow> stable r step succs ss p) \<and> ss0 <=[r] ss \<and>
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   278
 (\<forall>ts\<in>list n A. ss0 <=[r] ts \<and> stables r step succs ts \<longrightarrow> ss <=[r] ts) \<and>
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   279
 (\<forall>p\<in>w. p < n)" and
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   280
 r = "{(ss',ss) . ss <[r] ss'} <*lex*> finite_psubset"
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   281
       in while_rule)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   282
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   283
(* Invariant holds initially: *)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   284
apply (simp add:stables_def)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   285
(* Invariant is preserved: *)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   286
apply(simp add: stables_def split_paired_all)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   287
apply(rename_tac ss w)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   288
apply(subgoal_tac "(SOME p. p \<in> w) \<in> w")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   289
 prefer 2; apply (fast intro: someI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   290
apply(subgoal_tac "step (SOME p. p \<in> w) (ss ! (SOME p. p \<in> w)) \<in> A")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   291
 prefer 2; apply (blast intro: pres_typeD listE_nth_in dest: boundedD);
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   292
  apply (subgoal_tac "\<forall>q\<in>set(succs (SOME p. p \<in> w)). q < size ss")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   293
 prefer 2;  apply(clarsimp, blast dest!: boundedD)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   294
apply (subst decomp_propa)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   295
 apply blast
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   296
apply simp
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   297
apply (rule conjI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   298
 apply (blast intro: merges_preserves_type dest: boundedD);
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   299
apply (rule conjI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   300
 apply (blast intro!: stable_pres_lemma)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   301
apply (rule conjI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   302
 apply (blast intro!: merges_incr intro: le_list_trans)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   303
apply (rule conjI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   304
 apply clarsimp
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   305
 apply (best intro!: merges_bounded_lemma)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   306
apply (blast dest!: boundedD)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   307
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   308
(* Postcondition holds upon termination: *)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   309
apply(clarsimp simp add: stables_def split_paired_all)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   310
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   311
(* Well-foundedness of the termination relation: *)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   312
apply (rule wf_lex_prod)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   313
 apply (drule (1) semilatDorderI [THEN acc_le_listI])
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   314
 apply (simp only: acc_def lesssub_def)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   315
apply (rule wf_finite_psubset)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   316
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   317
(* Loop decreases along termination relation: *)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   318
apply(simp add: stables_def split_paired_all)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   319
apply(rename_tac ss w)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   320
apply(subgoal_tac "(SOME p. p \<in> w) \<in> w")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   321
 prefer 2; apply (fast intro: someI)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   322
apply(subgoal_tac "step (SOME p. p \<in> w) (ss ! (SOME p. p \<in> w)) \<in> A")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   323
 prefer 2; apply (blast intro: pres_typeD listE_nth_in dest: boundedD);
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   324
  apply (subgoal_tac "\<forall>q\<in>set(succs (SOME p. p \<in> w)). q < n")
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   325
 prefer 2;  apply(clarsimp, blast dest!: boundedD)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   326
apply (subst decomp_propa)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   327
 apply clarsimp
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   328
apply clarify
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   329
apply (simp del: listE_length
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   330
    add: lex_prod_def finite_psubset_def decomp_propa termination_lemma
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   331
         bounded_nat_set_is_finite)
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   332
done
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   333
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   334
lemma iter_properties:
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   335
  "\<lbrakk> semilat(A,r,f); acc r ; pres_type step n A; mono r step n A;
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   336
     bounded succs n; \<forall>p\<in>w0. p < n; ss0 \<in> list n A;
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   337
     \<forall>p<n. p \<notin> w0 \<longrightarrow> stable r step succs ss0 p \<rbrakk> \<Longrightarrow>
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   338
  iter f step succs ss0 w0 : list n A \<and>
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   339
  stables r step succs (iter f step succs ss0 w0) \<and>
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   340
  ss0 <=[r] iter f step succs ss0 w0 \<and>
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   341
  (\<forall>ts\<in>list n A. ss0 <=[r] ts \<and> stables r step succs ts \<longrightarrow>
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   342
                 iter f step succs ss0 w0 <=[r] ts)"
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   343
apply(simp add:iter_def del:Let_def)
11175
56ab6a5ba351 recoded function iter with the help of the while-combinator.
nipkow
parents: 10774
diff changeset
   344
by(rule while_properties[THEN mp,OF _ _ _ _ _ _ _ _ refl])
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   345
11229
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   346
lemma kildall_properties:
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   347
  "\<lbrakk> semilat(A,r,f); acc r; pres_type step n A; mono r step n A;
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   348
     bounded succs n; ss0 \<in> list n A \<rbrakk> \<Longrightarrow>
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   349
  kildall f step succs ss0 : list n A \<and>
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   350
  stables r step succs (kildall f step succs ss0) \<and>
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   351
  ss0 <=[r] kildall f step succs ss0 \<and>
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   352
  (\<forall>ts\<in>list n A. ss0 <=[r] ts \<and> stables r step succs ts \<longrightarrow>
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   353
                 kildall f step succs ss0 <=[r] ts)";
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   354
apply (unfold kildall_def)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   355
apply (rule iter_properties)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   356
apply (simp_all add: unstables_def stable_def)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   357
apply (blast intro!: le_iff_plus_unchanged [THEN iffD2] listE_nth_in
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   358
             dest: boundedD pres_typeD)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   359
done
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   360
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   361
lemma is_bcv_kildall:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   362
  "[| semilat(A,r,f); acc r; top r T; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   363
      pres_type step n A; bounded succs n; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   364
      mono r step n A |]
11184
10a307328d2c kildall now via while and therefore executable!
nipkow
parents: 11175
diff changeset
   365
  ==> is_bcv r T step succs n A (kildall f step succs)"
11229
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   366
apply(unfold is_bcv_def welltyping_def)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   367
apply(insert kildall_properties[of A])
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   368
apply(simp add:stables_def)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   369
apply clarify
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   370
apply(subgoal_tac "kildall f step succs ss : list n A")
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   371
 prefer 2 apply (simp(no_asm_simp))
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   372
apply (rule iffI)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   373
 apply (rule_tac x = "kildall f step succs ss" in bexI)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   374
  apply (rule conjI)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   375
   apply blast
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   376
  apply (simp  (no_asm_simp))
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   377
 apply assumption
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   378
apply clarify
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   379
apply(subgoal_tac "kildall f step succs ss!p <=_r ts!p")
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   380
 apply simp
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   381
apply (blast intro!: le_listD less_lengthI)
f417841385b7 Got rid of is_dfa
nipkow
parents: 11184
diff changeset
   382
done
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   383
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   384
end