src/HOL/MicroJava/BV/Kildall_Lift.thy
author kleing
Sun, 24 Mar 2002 19:16:51 +0100
changeset 13067 a59af3a83c61
parent 13066 b57d926d1de2
permissions -rw-r--r--
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/Kildall_Lift.thy
d09d0f160888 exceptions
kleing
parents:
diff changeset
     2
    ID:         $Id$
d09d0f160888 exceptions
kleing
parents:
diff changeset
     3
    Author:     Gerwin Klein
d09d0f160888 exceptions
kleing
parents:
diff changeset
     4
    Copyright   2001 TUM
d09d0f160888 exceptions
kleing
parents:
diff changeset
     5
*)
d09d0f160888 exceptions
kleing
parents:
diff changeset
     6
d09d0f160888 exceptions
kleing
parents:
diff changeset
     7
theory Kildall_Lift = Kildall + Typing_Framework_err:
d09d0f160888 exceptions
kleing
parents:
diff changeset
     8
d09d0f160888 exceptions
kleing
parents:
diff changeset
     9
constdefs
d09d0f160888 exceptions
kleing
parents:
diff changeset
    10
 app_mono :: "'s ord \<Rightarrow> (nat \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 's set \<Rightarrow> bool"
d09d0f160888 exceptions
kleing
parents:
diff changeset
    11
"app_mono r app n A ==
d09d0f160888 exceptions
kleing
parents:
diff changeset
    12
 \<forall>s p t. s \<in> A \<and> p < n \<and> s <=_r t \<longrightarrow> app p t \<longrightarrow> app p s"
d09d0f160888 exceptions
kleing
parents:
diff changeset
    13
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    14
lemma bounded_lift:
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    15
  "bounded step n \<Longrightarrow> bounded (err_step n app step) n"
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    16
  apply (unfold bounded_def err_step_def error_def)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    17
  apply clarify
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    18
  apply (erule allE, erule impE, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    19
  apply (case_tac s)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    20
  apply (auto simp add: map_snd_def split: split_if_asm)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    21
  done
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    22
d09d0f160888 exceptions
kleing
parents:
diff changeset
    23
lemma le_list_map_OK [simp]:
d09d0f160888 exceptions
kleing
parents:
diff changeset
    24
  "\<And>b. map OK a <=[Err.le r] map OK b = (a <=[r] b)"
d09d0f160888 exceptions
kleing
parents:
diff changeset
    25
  apply (induct a)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    26
   apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    27
  apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    28
  apply (case_tac b)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    29
   apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    30
  apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    31
  done
d09d0f160888 exceptions
kleing
parents:
diff changeset
    32
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    33
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    34
lemma map_snd_lessI:
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    35
  "x <=|r| y \<Longrightarrow> map_snd OK x <=|Err.le r| map_snd OK y"
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    36
  apply (induct x)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    37
  apply (unfold lesubstep_type_def map_snd_def)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    38
  apply auto
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    39
  done
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    40
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    41
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    42
lemma mono_lift:
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    43
  "order r \<Longrightarrow> app_mono r app n A \<Longrightarrow> bounded (err_step n app step) n \<Longrightarrow>
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    44
  \<forall>s p t. s \<in> A \<and> p < n \<and> s <=_r t \<longrightarrow> app p t \<longrightarrow> step p s <=|r| step p t \<Longrightarrow>
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    45
  mono (Err.le r) (err_step n app step) n (err A)"
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    46
apply (unfold app_mono_def mono_def err_step_def)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    47
apply clarify
d09d0f160888 exceptions
kleing
parents:
diff changeset
    48
apply (case_tac s)
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    49
 apply simp 
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    50
apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    51
apply (case_tac t)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    52
 apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    53
 apply clarify
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    54
 apply (simp add: lesubstep_type_def error_def)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    55
 apply clarify
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    56
 apply (drule in_map_sndD)
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    57
 apply clarify
13067
kleing
parents: 13066
diff changeset
    58
 apply (drule bounded_err_stepD, assumption+)
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    59
 apply (rule exI [of _ Err])
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    60
 apply simp
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    61
apply simp
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    62
apply (erule allE, erule allE, erule allE, erule impE)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    63
 apply (rule conjI, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    64
 apply (rule conjI, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    65
 apply assumption
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    66
apply (rule conjI)
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    67
apply clarify
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    68
apply (erule allE, erule allE, erule allE, erule impE)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    69
 apply (rule conjI, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    70
 apply (rule conjI, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    71
 apply assumption
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    72
apply (erule impE, assumption)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    73
apply (rule map_snd_lessI, assumption)
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    74
apply clarify
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    75
apply (simp add: lesubstep_type_def error_def)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    76
apply clarify
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    77
apply (drule in_map_sndD)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    78
apply clarify
13067
kleing
parents: 13066
diff changeset
    79
apply (drule bounded_err_stepD, assumption+)
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    80
apply (rule exI [of _ Err])
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    81
apply simp
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    82
done
d09d0f160888 exceptions
kleing
parents:
diff changeset
    83
 
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    84
lemma in_errorD:
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    85
  "(x,y) \<in> set (error n) \<Longrightarrow> y = Err"
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    86
  by (auto simp add: error_def)
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    87
d09d0f160888 exceptions
kleing
parents:
diff changeset
    88
lemma pres_type_lift:
d09d0f160888 exceptions
kleing
parents:
diff changeset
    89
  "\<forall>s\<in>A. \<forall>p. p < n \<longrightarrow> app p s \<longrightarrow> (\<forall>(q, s')\<in>set (step p s). s' \<in> A) 
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    90
  \<Longrightarrow> pres_type (err_step n app step) n (err A)"  
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    91
apply (unfold pres_type_def err_step_def)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    92
apply clarify
d09d0f160888 exceptions
kleing
parents:
diff changeset
    93
apply (case_tac b)
d09d0f160888 exceptions
kleing
parents:
diff changeset
    94
 apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
    95
apply (case_tac s)
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    96
 apply simp
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    97
 apply (drule in_errorD)
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
    98
 apply simp
13066
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
    99
apply (simp add: map_snd_def split: split_if_asm)
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
   100
 apply fast
b57d926d1de2 cleanup + simpler monotonicity
kleing
parents: 12516
diff changeset
   101
apply (drule in_errorD)
12516
d09d0f160888 exceptions
kleing
parents:
diff changeset
   102
apply simp
d09d0f160888 exceptions
kleing
parents:
diff changeset
   103
done
d09d0f160888 exceptions
kleing
parents:
diff changeset
   104
d09d0f160888 exceptions
kleing
parents:
diff changeset
   105
end