src/HOL/MicroJava/Comp/CorrComp.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 46226 e88e980ed735
child 52866 438f578ef1d9
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/Comp/CorrComp.thy
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     2
    Author:     Martin Strecker
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     3
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     4
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     5
(* Compiler correctness statement and proof *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     6
15860
a344c4284972 partial modernising of theory headers
paulson
parents: 15481
diff changeset
     7
theory CorrComp
15866
f011452b2815 sped up a bit
kleing
parents: 15860
diff changeset
     8
imports "../J/JTypeSafe" "LemmasComp"
15860
a344c4284972 partial modernising of theory headers
paulson
parents: 15481
diff changeset
     9
begin
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    10
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
    11
declare wf_prog_ws_prog [simp add]
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    12
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    13
(* If no exception is present after evaluation/execution, 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    14
  none can have been present before *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    15
lemma eval_evals_exec_xcpt:
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    16
 "(G \<turnstile> xs -ex\<succ>val-> xs' \<longrightarrow> gx xs' = None \<longrightarrow> gx xs = None) \<and>
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    17
  (G \<turnstile> xs -exs[\<succ>]vals-> xs' \<longrightarrow> gx xs' = None \<longrightarrow> gx xs = None) \<and>
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    18
  (G \<turnstile> xs -st-> xs' \<longrightarrow> gx xs' = None \<longrightarrow> gx xs = None)"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    19
by (induct rule: eval_evals_exec.induct, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    20
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    21
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    22
(* instance of eval_evals_exec_xcpt for eval *)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    23
lemma eval_xcpt: "G \<turnstile> xs -ex\<succ>val-> xs' \<Longrightarrow> gx xs' = None \<Longrightarrow> gx xs = None"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    24
 (is "?H1 \<Longrightarrow> ?H2 \<Longrightarrow> ?T")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    25
proof-
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    26
  assume h1: ?H1
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    27
  assume h2: ?H2
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    28
  from h1 h2 eval_evals_exec_xcpt show "?T" by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    29
qed
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    30
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    31
(* instance of eval_evals_exec_xcpt for evals *)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    32
lemma evals_xcpt: "G \<turnstile> xs -exs[\<succ>]vals-> xs' \<Longrightarrow> gx xs' = None \<Longrightarrow> gx xs = None"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    33
 (is "?H1 \<Longrightarrow> ?H2 \<Longrightarrow> ?T")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    34
proof-
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    35
  assume h1: ?H1
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    36
  assume h2: ?H2
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    37
  from h1 h2 eval_evals_exec_xcpt show "?T" by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    38
qed
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    39
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    40
(* instance of eval_evals_exec_xcpt for exec *)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
    41
lemma exec_xcpt: "G \<turnstile> xs -st-> xs' \<Longrightarrow> gx xs' = None \<Longrightarrow> gx xs = None"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    42
 (is "?H1 \<Longrightarrow> ?H2 \<Longrightarrow> ?T")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    43
proof-
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    44
  assume h1: ?H1
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    45
  assume h2: ?H2
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    46
  from h1 h2 eval_evals_exec_xcpt show "?T" by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    47
qed
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    48
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    49
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    50
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    51
theorem exec_all_trans: "\<lbrakk>(exec_all G s0 s1); (exec_all G s1 s2)\<rbrakk> \<Longrightarrow> (exec_all G s0 s2)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    52
apply (auto simp: exec_all_def elim: Transitive_Closure.rtrancl_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    53
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    54
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    55
theorem exec_all_refl: "exec_all G s s"
15097
b807858b97bd Modifications for trancl_tac (new solver in simplifier).
ballarin
parents: 15076
diff changeset
    56
by (simp only: exec_all_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    57
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    58
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    59
theorem exec_instr_in_exec_all:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    60
  "\<lbrakk> exec_instr i G hp stk lvars C S pc frs =  (None, hp', frs');
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    61
             gis (gmb G C S) ! pc = i\<rbrakk>  \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    62
       G \<turnstile> (None, hp, (stk, lvars, C, S, pc) # frs) -jvm\<rightarrow> (None, hp', frs')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    63
apply (simp only: exec_all_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    64
apply (rule rtrancl_refl [THEN rtrancl_into_rtrancl])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    65
apply (simp add: gis_def gmb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    66
apply (case_tac frs', simp+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    67
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    68
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    69
theorem exec_all_one_step: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    70
  \<lbrakk> gis (gmb G C S) = pre @ (i # post); pc0 = length pre;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    71
  (exec_instr i G hp0 stk0 lvars0 C S pc0 frs) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    72
  (None, hp1, (stk1,lvars1,C,S, Suc pc0)#frs) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    73
  \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    74
  G \<turnstile> (None, hp0, (stk0,lvars0,C,S, pc0)#frs) -jvm\<rightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    75
  (None, hp1, (stk1,lvars1,C,S, Suc pc0)#frs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    76
apply (unfold exec_all_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    77
apply (rule r_into_rtrancl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    78
apply (simp add: gis_def gmb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    79
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    80
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    81
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    82
(***********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    83
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
    84
definition progression :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    85
                 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    86
                 bytecode \<Rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    87
                 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    88
                 bool"
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
    89
  ("{_,_,_} \<turnstile> {_, _, _} >- _ \<rightarrow> {_, _, _}" [61,61,61,61,61,61,90,61,61,61]60) where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    90
  "{G,C,S} \<turnstile> {hp0, os0, lvars0} >- instrs \<rightarrow> {hp1, os1, lvars1} ==
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    91
  \<forall> pre post frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    92
  (gis (gmb G C S) = pre @ instrs @ post) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    93
   G \<turnstile> (None,hp0,(os0,lvars0,C,S,length pre)#frs) -jvm\<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    94
       (None,hp1,(os1,lvars1,C,S,(length pre) + (length instrs))#frs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    95
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    96
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    97
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    98
lemma progression_call: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    99
  "\<lbrakk> \<forall> pc frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   100
  exec_instr instr G hp0 os0 lvars0 C S pc frs =
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   101
      (None, hp', (os', lvars', C', S', 0) # (fr pc) # frs) \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   102
  gis (gmb G C' S') = instrs' @ [Return] \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   103
  {G, C', S'} \<turnstile> {hp', os', lvars'} >- instrs' \<rightarrow> {hp'', os'', lvars''}  \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   104
  exec_instr Return G hp'' os'' lvars'' C' S' (length instrs') 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   105
                                               ((fr pc) # frs) =
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   106
      (None, hp2, (os2, lvars2, C, S, Suc pc) # frs) \<rbrakk> \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   107
  {G, C, S} \<turnstile> {hp0, os0, lvars0} >-[instr]\<rightarrow> {hp2,os2,lvars2}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   108
apply (simp only: progression_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   109
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   110
apply (drule_tac x="length pre" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   111
apply (drule_tac x="frs" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   112
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   113
apply (rule exec_all_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   114
apply (rule exec_instr_in_exec_all) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   115
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   116
apply (rule exec_all_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   117
apply (simp only: append_Nil)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   118
apply (drule_tac x="[]" in spec)
24699
c6674504103f datatype interpretators for size and datatype_realizer
haftmann
parents: 24074
diff changeset
   119
apply (simp only: list.simps list.size)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   120
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   121
apply (rule exec_instr_in_exec_all)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   122
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   123
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   124
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   125
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   126
lemma progression_transitive: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   127
  "\<lbrakk> instrs_comb = instrs0 @ instrs1; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   128
  {G, C, S} \<turnstile> {hp0, os0, lvars0} >- instrs0 \<rightarrow> {hp1, os1, lvars1};
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   129
  {G, C, S} \<turnstile> {hp1, os1, lvars1} >- instrs1 \<rightarrow> {hp2, os2, lvars2} \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   130
  \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   131
  {G, C, S} \<turnstile> {hp0, os0, lvars0} >- instrs_comb \<rightarrow> {hp2, os2, lvars2}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   132
apply (simp only: progression_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   133
apply (intro strip)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   134
apply (rule_tac ?s1.0 = "Norm (hp1, (os1, lvars1, C, S, 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   135
                          length pre + length instrs0) # frs)"  
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   136
       in exec_all_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   137
apply (simp only: append_assoc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   138
apply (erule thin_rl, erule thin_rl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   139
apply (drule_tac x="pre @ instrs0" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   140
apply (simp add: add_assoc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   141
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   142
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   143
lemma progression_refl: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   144
  "{G, C, S} \<turnstile> {hp0, os0, lvars0} >- [] \<rightarrow> {hp0, os0, lvars0}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   145
apply (simp add: progression_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   146
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   147
apply (rule exec_all_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   148
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   149
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   150
lemma progression_one_step: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   151
  \<forall> pc frs. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   152
  (exec_instr i G hp0 os0 lvars0 C S pc frs) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   153
  (None, hp1, (os1,lvars1,C,S, Suc pc)#frs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   154
  \<Longrightarrow> {G, C, S} \<turnstile> {hp0, os0, lvars0} >- [i] \<rightarrow> {hp1, os1, lvars1}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   155
apply (unfold progression_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   156
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   157
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   158
apply (rule exec_all_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   159
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   160
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   161
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   162
(*****)
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   163
definition jump_fwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   164
                 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> 
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   165
                 instr \<Rightarrow> bytecode \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   166
  "jump_fwd G C S hp lvars os0 os1 instr instrs ==
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   167
  \<forall> pre post frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   168
  (gis (gmb G C S) = pre @ instr # instrs @ post) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   169
   exec_all G (None,hp,(os0,lvars,C,S, length pre)#frs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   170
    (None,hp,(os1,lvars,C,S,(length pre) + (length instrs) + 1)#frs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   171
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   172
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   173
lemma jump_fwd_one_step:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   174
  "\<forall> pc frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   175
  exec_instr instr G hp os0 lvars C S pc frs = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   176
    (None, hp, (os1, lvars, C, S, pc + (length instrs) + 1)#frs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   177
  \<Longrightarrow> jump_fwd G C S hp lvars os0 os1 instr instrs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   178
apply (unfold jump_fwd_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   179
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   180
apply (rule exec_instr_in_exec_all)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   181
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   182
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   183
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   184
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   185
lemma jump_fwd_progression_aux: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   186
  "\<lbrakk> instrs_comb = instr # instrs0 @ instrs1; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   187
     jump_fwd G C S hp lvars os0 os1 instr instrs0;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   188
     {G, C, S} \<turnstile> {hp, os1, lvars} >- instrs1 \<rightarrow> {hp2, os2, lvars2} \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   189
  \<Longrightarrow> {G, C, S} \<turnstile> {hp, os0, lvars} >- instrs_comb \<rightarrow> {hp2, os2, lvars2}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   190
apply (simp only: progression_def jump_fwd_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   191
apply (intro strip)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   192
apply (rule_tac ?s1.0 = "Norm(hp, (os1, lvars, C, S, length pre + length instrs0 + 1) # frs)" in exec_all_trans)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   193
apply (simp only: append_assoc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   194
apply (subgoal_tac "pre @ (instr # instrs0 @ instrs1) @ post = pre @ instr # instrs0 @ (instrs1 @ post)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   195
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   196
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   197
apply (erule thin_rl, erule thin_rl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   198
apply (drule_tac x="pre @ instr # instrs0" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   199
apply (simp add: add_assoc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   200
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   201
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   202
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   203
lemma jump_fwd_progression:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   204
  "\<lbrakk> instrs_comb = instr # instrs0 @ instrs1; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   205
  \<forall> pc frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   206
  exec_instr instr G hp os0 lvars C S pc frs = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   207
    (None, hp, (os1, lvars, C, S, pc + (length instrs0) + 1)#frs);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   208
  {G, C, S} \<turnstile> {hp, os1, lvars} >- instrs1 \<rightarrow> {hp2, os2, lvars2} \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   209
  \<Longrightarrow> {G, C, S}  \<turnstile> {hp, os0, lvars} >- instrs_comb \<rightarrow> {hp2, os2, lvars2}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   210
apply (rule jump_fwd_progression_aux)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   211
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   212
apply (rule jump_fwd_one_step) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   213
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   214
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   215
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   216
(* note: instrs and instr reversed wrt. jump_fwd *)
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   217
definition jump_bwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   218
                 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> 
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   219
                 bytecode \<Rightarrow> instr \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   220
  "jump_bwd G C S hp lvars os0 os1 instrs instr ==
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   221
  \<forall> pre post frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   222
  (gis (gmb G C S) = pre @ instrs @ instr # post) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   223
   exec_all G (None,hp,(os0,lvars,C,S, (length pre) + (length instrs))#frs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   224
    (None,hp,(os1,lvars,C,S, (length pre))#frs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   225
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   226
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   227
lemma jump_bwd_one_step:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   228
  "\<forall> pc frs.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   229
  exec_instr instr G hp os0 lvars C S (pc + (length instrs)) frs = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   230
    (None, hp, (os1, lvars, C, S, pc)#frs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   231
  \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   232
  jump_bwd G C S hp lvars os0 os1 instrs instr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   233
apply (unfold jump_bwd_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   234
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   235
apply (rule exec_instr_in_exec_all)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   236
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   237
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   238
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   239
lemma jump_bwd_progression: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   240
  "\<lbrakk> instrs_comb = instrs @ [instr]; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   241
  {G, C, S} \<turnstile> {hp0, os0, lvars0} >- instrs \<rightarrow> {hp1, os1, lvars1};
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   242
  jump_bwd G C S hp1 lvars1 os1 os2 instrs instr;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   243
  {G, C, S} \<turnstile> {hp1, os2, lvars1} >- instrs_comb \<rightarrow> {hp3, os3, lvars3} \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   244
  \<Longrightarrow> {G, C, S}  \<turnstile> {hp0, os0, lvars0} >- instrs_comb \<rightarrow> {hp3, os3, lvars3}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   245
apply (simp only: progression_def jump_bwd_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   246
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   247
apply (rule exec_all_trans, force)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   248
apply (rule exec_all_trans, force)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   249
apply (rule exec_all_trans, force)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   250
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   251
apply (rule exec_all_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   252
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   253
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   254
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   255
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   256
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   257
(* class C with signature S is defined in program G *)
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   258
definition class_sig_defined :: "'c prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   259
  "class_sig_defined G C S == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   260
  is_class G C \<and> (\<exists> D rT mb. (method (G, C) S = Some (D, rT, mb)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   261
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   262
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   263
(* The environment of a java method body 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   264
  (characterized by class and signature) *)
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   265
definition env_of_jmb :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> java_mb env" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   266
  "env_of_jmb G C S == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   267
  (let (mn,pTs) = S;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   268
       (D,rT,(pns,lvars,blk,res)) = the(method (G, C) S) in
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   269
  (G,map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class C)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   270
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   271
lemma env_of_jmb_fst [simp]: "fst (env_of_jmb G C S) = G"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   272
by (simp add: env_of_jmb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   273
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   274
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   275
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   276
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   277
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   278
lemma method_preserves [rule_format (no_asm)]:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   279
  "\<lbrakk> wf_prog wf_mb G; is_class G C; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   280
  \<forall> S rT mb. \<forall> cn \<in> fst ` set G. wf_mdecl wf_mb G cn (S,rT,mb)  \<longrightarrow> (P cn S (rT,mb))\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   281
 \<Longrightarrow> \<forall> D. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   282
  method (G, C) S = Some (D, rT, mb) \<longrightarrow> (P D S (rT,mb))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   283
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   284
apply (frule wf_prog_ws_prog [THEN wf_subcls1])
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   285
apply (rule subcls1_induct, assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   286
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   287
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   288
apply ((drule spec)+, drule_tac x="Object" in bspec)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   289
apply (simp add: wf_prog_def ws_prog_def wf_syscls_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   290
apply (subgoal_tac "D=Object") apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   291
apply (drule mp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   292
apply (frule_tac C=Object in method_wf_mdecl)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   293
 apply simp
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   294
 apply assumption apply simp apply assumption apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   295
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15236
diff changeset
   296
apply (simplesubst method_rec) apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   297
apply force
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   298
apply simp
14025
d9b155757dc8 *** empty log message ***
nipkow
parents: 13837
diff changeset
   299
apply (simp only: map_add_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   300
apply (split option.split)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   301
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   302
apply force
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   303
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   304
apply (frule_tac
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   305
  ?P1.0 = "wf_mdecl wf_mb G Ca" and
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   306
  ?P2.0 = "%(S, (Da, rT, mb)). P Da S (rT, mb)" in map_of_map_prop)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   307
apply (force simp: wf_cdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   308
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   309
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   310
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   311
apply (simp only: class_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   312
apply (drule map_of_SomeD)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   313
apply (frule_tac A="set G" and f=fst in imageI, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   314
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   315
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   316
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   317
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   318
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   319
lemma method_preserves_length:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   320
  "\<lbrakk> wf_java_prog G; is_class G C; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   321
  method (G, C) (mn,pTs) = Some (D, rT, pns, lvars, blk, res)\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   322
 \<Longrightarrow> length pns = length pTs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   323
apply (frule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   324
  P="%D (mn,pTs) (rT, pns, lvars, blk, res). length pns = length pTs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   325
  in method_preserves)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   326
apply (auto simp: wf_mdecl_def wf_java_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   327
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   328
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   329
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   330
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   331
definition wtpd_expr :: "java_mb env \<Rightarrow> expr \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   332
  "wtpd_expr E e == (\<exists> T. E\<turnstile>e :: T)"
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   333
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   334
definition wtpd_exprs :: "java_mb env \<Rightarrow> (expr list) \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   335
  "wtpd_exprs E e == (\<exists> T. E\<turnstile>e [::] T)"
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   336
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33639
diff changeset
   337
definition wtpd_stmt :: "java_mb env \<Rightarrow> stmt \<Rightarrow> bool" where
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   338
  "wtpd_stmt E c == (E\<turnstile>c \<surd>)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   339
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   340
lemma wtpd_expr_newc: "wtpd_expr E (NewC C) \<Longrightarrow> is_class (prg E) C"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   341
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   342
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   343
lemma wtpd_expr_cast: "wtpd_expr E (Cast cn e) \<Longrightarrow> (wtpd_expr E e)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   344
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   345
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   346
lemma wtpd_expr_lacc: "\<lbrakk> wtpd_expr (env_of_jmb G C S) (LAcc vn);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   347
  class_sig_defined G C S \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   348
  \<Longrightarrow> vn \<in> set (gjmb_plns (gmb G C S)) \<or> vn = This"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   349
apply (simp only: wtpd_expr_def env_of_jmb_def class_sig_defined_def galldefs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   350
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   351
apply (case_tac S)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   352
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   353
apply (erule ty_expr.cases)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   354
apply (auto dest: map_upds_SomeD map_of_SomeD fst_in_set_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   355
apply (drule map_upds_SomeD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   356
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   357
  apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   358
  apply (drule map_of_SomeD) apply (auto dest: fst_in_set_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   359
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   360
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   361
lemma wtpd_expr_lass: "wtpd_expr E (vn::=e)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   362
  \<Longrightarrow> (vn \<noteq> This) & (wtpd_expr E (LAcc vn)) & (wtpd_expr E e)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   363
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   364
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   365
lemma wtpd_expr_facc: "wtpd_expr E ({fd}a..fn) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   366
  \<Longrightarrow> (wtpd_expr E a)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   367
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   368
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   369
lemma wtpd_expr_fass: "wtpd_expr E ({fd}a..fn:=v) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   370
  \<Longrightarrow> (wtpd_expr E ({fd}a..fn)) & (wtpd_expr E v)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   371
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   372
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   373
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   374
lemma wtpd_expr_binop: "wtpd_expr E (BinOp bop e1 e2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   375
  \<Longrightarrow> (wtpd_expr E e1) & (wtpd_expr E e2)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   376
by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   377
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   378
lemma wtpd_exprs_cons: "wtpd_exprs E (e # es)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   379
  \<Longrightarrow> (wtpd_expr E e) & (wtpd_exprs E es)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   380
by (simp only: wtpd_exprs_def wtpd_expr_def, erule exE, erule ty_exprs.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   381
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   382
lemma wtpd_stmt_expr: "wtpd_stmt E (Expr e) \<Longrightarrow> (wtpd_expr E e)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   383
by (simp only: wtpd_stmt_def wtpd_expr_def, erule wt_stmt.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   384
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   385
lemma wtpd_stmt_comp: "wtpd_stmt E (s1;; s2) \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   386
   (wtpd_stmt E s1) &  (wtpd_stmt E s2)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   387
by (simp only: wtpd_stmt_def wtpd_expr_def, erule wt_stmt.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   388
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   389
lemma wtpd_stmt_cond: "wtpd_stmt E (If(e) s1 Else s2) \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   390
   (wtpd_expr E e) & (wtpd_stmt E s1) &  (wtpd_stmt E s2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   391
  & (E\<turnstile>e::PrimT Boolean)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   392
by (simp only: wtpd_stmt_def wtpd_expr_def, erule wt_stmt.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   393
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   394
lemma wtpd_stmt_loop: "wtpd_stmt E (While(e) s) \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   395
   (wtpd_expr E e) & (wtpd_stmt E s) & (E\<turnstile>e::PrimT Boolean)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   396
by (simp only: wtpd_stmt_def wtpd_expr_def, erule wt_stmt.cases, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   397
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   398
lemma wtpd_expr_call: "wtpd_expr E ({C}a..mn({pTs'}ps))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   399
  \<Longrightarrow> (wtpd_expr E a) & (wtpd_exprs E ps) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   400
  & (length ps = length pTs') & (E\<turnstile>a::Class C)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   401
  & (\<exists> pTs md rT. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   402
       E\<turnstile>ps[::]pTs & max_spec (prg E) C (mn, pTs) = {((md,rT),pTs')})"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   403
apply (simp only: wtpd_expr_def wtpd_exprs_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   404
apply (erule exE)
23757
087b0a241557 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   405
apply (ind_cases "E \<turnstile> {C}a..mn( {pTs'}ps) :: T" for T)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   406
apply (auto simp: max_spec_preserves_length)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   407
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   408
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   409
lemma wtpd_blk: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   410
  "\<lbrakk> method (G, D) (md, pTs) = Some (D, rT, (pns, lvars, blk, res)); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   411
  wf_prog wf_java_mdecl G; is_class G D \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   412
 \<Longrightarrow> wtpd_stmt (env_of_jmb G D (md, pTs)) blk"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   413
apply (simp add: wtpd_stmt_def env_of_jmb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   414
apply (frule_tac P="%D (md, pTs) (rT, (pns, lvars, blk, res)). (G, map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class D)) \<turnstile> blk \<surd> " in method_preserves)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   415
apply (auto simp: wf_mdecl_def wf_java_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   416
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   417
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   418
lemma wtpd_res: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   419
  "\<lbrakk> method (G, D) (md, pTs) = Some (D, rT, (pns, lvars, blk, res)); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   420
  wf_prog wf_java_mdecl G; is_class G D \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   421
 \<Longrightarrow> wtpd_expr (env_of_jmb G D (md, pTs)) res"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   422
apply (simp add: wtpd_expr_def env_of_jmb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   423
apply (frule_tac P="%D (md, pTs) (rT, (pns, lvars, blk, res)). \<exists>T. (G, map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class D)) \<turnstile> res :: T " in method_preserves)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   424
apply (auto simp: wf_mdecl_def wf_java_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   425
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   426
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   427
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   428
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   429
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   430
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   431
(* Is there a more elegant proof? *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   432
lemma evals_preserves_length:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   433
  "G\<turnstile> xs -es[\<succ>]vs-> (None, s) \<Longrightarrow> length es = length vs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   434
apply (subgoal_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   435
  "\<forall> xs'. (G \<turnstile> xk -xj\<succ>xi-> xh \<longrightarrow> True) & 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   436
  (G\<turnstile> xs -es[\<succ>]vs-> xs' \<longrightarrow>  (\<exists> s. (xs' = (None, s))) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   437
  length es = length vs) &
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   438
  (G \<turnstile> xc -xb-> xa \<longrightarrow> True)")
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   439
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   440
apply (rule allI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   441
apply (rule Eval.eval_evals_exec.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   442
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   443
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   444
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   445
(***********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   446
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   447
(* required for translation of BinOp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   448
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   449
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   450
lemma progression_Eq : "{G, C, S} \<turnstile>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   451
  {hp, (v2 # v1 # os), lvars} 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   452
  >- [Ifcmpeq 3, LitPush (Bool False), Goto 2, LitPush (Bool True)] \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   453
  {hp, (Bool (v1 = v2) # os), lvars}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   454
apply (case_tac "v1 = v2")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   455
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   456
(* case v1 = v2 *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   457
apply (rule_tac ?instrs1.0 = "[LitPush (Bool True)]" in jump_fwd_progression)
13837
8dd150d36c65 Reorganized, moving many results about the integer dvd relation from IntPrimes
paulson
parents: 13673
diff changeset
   458
apply (auto simp: nat_add_distrib)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   459
apply (rule progression_one_step) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   460
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   461
(* case v1 \<noteq> v2 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   462
apply (rule progression_one_step [THEN HOL.refl [THEN progression_transitive], simplified])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   463
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   464
apply (rule progression_one_step [THEN HOL.refl [THEN progression_transitive], simplified]) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   465
apply auto
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   466
apply (rule_tac ?instrs1.0 = "[]" in jump_fwd_progression)
13837
8dd150d36c65 Reorganized, moving many results about the integer dvd relation from IntPrimes
paulson
parents: 13673
diff changeset
   467
apply (auto simp: nat_add_distrib intro: progression_refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   468
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   469
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   470
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   471
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   472
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   473
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   474
(* to avoid automatic pair splits *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   475
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   476
declare split_paired_All [simp del] split_paired_Ex [simp del]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   477
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   478
lemma distinct_method: "\<lbrakk> wf_java_prog G; is_class G C; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   479
  method (G, C) S = Some (D, rT, pns, lvars, blk, res) \<rbrakk> \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   480
  distinct (gjmb_plns (gmb G C S))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   481
apply (frule method_wf_mdecl [THEN conjunct2],  assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   482
apply (case_tac S)
46226
e88e980ed735 tuned proofs;
wenzelm
parents: 35416
diff changeset
   483
apply (simp add: wf_mdecl_def wf_java_mdecl_def galldefs)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   484
apply (simp add: unique_def map_of_in_set)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   485
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   486
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   487
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   488
lemma distinct_method_if_class_sig_defined : 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   489
  "\<lbrakk> wf_java_prog G; class_sig_defined G C S \<rbrakk> \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   490
  distinct (gjmb_plns (gmb G C S))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   491
by (auto intro: distinct_method simp: class_sig_defined_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   492
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   493
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   494
lemma method_yields_wf_java_mdecl: "\<lbrakk> wf_java_prog G; is_class G C;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   495
  method (G, C) S = Some (D, rT, pns, lvars, blk, res) \<rbrakk>  \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   496
  wf_java_mdecl G D (S,rT,(pns,lvars,blk,res))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   497
apply (frule method_wf_mdecl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   498
apply (auto simp: wf_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   499
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   500
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   501
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   502
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   503
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   504
lemma progression_lvar_init_aux [rule_format (no_asm)]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   505
  \<forall> zs prfx lvals lvars0. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   506
  lvars0 =  (zs @ lvars) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   507
  (disjoint_varnames pns lvars0 \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   508
  (length lvars = length lvals) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   509
  (Suc(length pns + length zs) = length prfx) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   510
   ({cG, D, S} \<turnstile> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   511
    {h, os, (prfx @ lvals)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   512
    >- (concat (map (compInit (pns, lvars0, blk, res)) lvars)) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   513
    {h, os, (prfx @ (map (\<lambda>p. (default_val (snd p))) lvars))}))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   514
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   515
apply (induct lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   516
apply (clarsimp, rule progression_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   517
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   518
apply (case_tac lvals) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   519
apply (simp (no_asm_simp) )
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   520
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 15097
diff changeset
   521
apply (rule_tac ?lvars1.0 = "(prfx @ [default_val (snd a)]) @ list" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   522
apply (case_tac a) apply (simp (no_asm_simp) add: compInit_def)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   523
apply (rule_tac ?instrs0.0 = "[load_default_val b]" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   524
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   525
apply (simp (no_asm_simp) add: load_default_val_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   526
apply (rule conjI, simp)+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   527
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   528
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   529
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   530
apply (rule conjI, simp)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   531
apply (simp add: index_of_var2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   532
apply (drule_tac x="zs @ [a]" in spec) (* instantiate zs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   533
apply (drule mp, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   534
apply (drule_tac x="(prfx @ [default_val (snd a)])" in spec) (* instantiate prfx *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   535
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   536
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   537
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   538
lemma progression_lvar_init [rule_format (no_asm)]: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   539
  "\<lbrakk> wf_java_prog G; is_class G C;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   540
  method (G, C) S = Some (D, rT, pns, lvars, blk, res) \<rbrakk> \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   541
  length pns = length pvs \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   542
  (\<forall> lvals. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   543
  length lvars = length lvals \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   544
   {cG, D, S} \<turnstile>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   545
   {h, os, (a' # pvs @ lvals)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   546
   >- (compInitLvars (pns, lvars, blk, res) lvars) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   547
   {h, os, (locvars_xstate G C S (Norm (h, init_vars lvars(pns[\<mapsto>]pvs)(This\<mapsto>a'))))})"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   548
apply (simp only: compInitLvars_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   549
apply (frule method_yields_wf_java_mdecl, assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   550
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   551
apply (simp only: wf_java_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   552
apply (subgoal_tac "(\<forall>y\<in>set pns. y \<notin> set (map fst lvars))")
33639
603320b93668 New list theorems; added map_map to simpset, this is the prefered direction; allow sorting by a key
hoelzl
parents: 32960
diff changeset
   553
apply (simp add: init_vars_def locvars_xstate_def locvars_locals_def galldefs unique_def split_def map_of_map_as_map_upd del: map_map)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   554
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   555
apply (simp (no_asm_simp) only: append_Cons [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   556
apply (rule progression_lvar_init_aux)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   557
apply (auto simp: unique_def map_of_in_set disjoint_varnames_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   558
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   559
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   560
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   561
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   562
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   563
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   564
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   565
lemma state_ok_eval: "\<lbrakk>xs::\<preceq>E; wf_java_prog (prg E); wtpd_expr E e;
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   566
  (prg E)\<turnstile>xs -e\<succ>v -> xs'\<rbrakk> \<Longrightarrow>  xs'::\<preceq>E"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   567
apply (simp only: wtpd_expr_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   568
apply (erule exE)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   569
apply (case_tac xs', case_tac xs)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   570
apply (auto intro: eval_type_sound [THEN conjunct1])
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   571
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   572
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   573
lemma state_ok_evals: "\<lbrakk>xs::\<preceq>E; wf_java_prog (prg E); wtpd_exprs E es;
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   574
  prg E \<turnstile> xs -es[\<succ>]vs-> xs'\<rbrakk> \<Longrightarrow> xs'::\<preceq>E"
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   575
apply (simp only: wtpd_exprs_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   576
apply (erule exE)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   577
apply (case_tac xs) apply (case_tac xs')
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   578
apply (auto intro: evals_type_sound [THEN conjunct1])
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   579
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   580
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   581
lemma state_ok_exec: "\<lbrakk>xs::\<preceq>E; wf_java_prog (prg E); wtpd_stmt E st;
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   582
  prg E \<turnstile> xs -st-> xs'\<rbrakk> \<Longrightarrow>  xs'::\<preceq>E"
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   583
apply (simp only: wtpd_stmt_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   584
apply (case_tac xs', case_tac xs)
14143
7544966fa07d Modifications after changes in MicroJava/J
streckem
parents: 14045
diff changeset
   585
apply (auto dest: exec_type_sound)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   586
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   587
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   588
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   589
lemma state_ok_init: 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   590
  "\<lbrakk> wf_java_prog G; (x, h, l)::\<preceq>(env_of_jmb G C S); 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   591
  is_class G dynT;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   592
  method (G, dynT) (mn, pTs) = Some (md, rT, pns, lvars, blk, res);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   593
  list_all2 (conf G h) pvs pTs; G,h \<turnstile> a' ::\<preceq> Class md\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   594
\<Longrightarrow>
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   595
(np a' x, h, init_vars lvars(pns[\<mapsto>]pvs)(This\<mapsto>a'))::\<preceq>(env_of_jmb G md (mn, pTs))"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   596
apply (frule wf_prog_ws_prog)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   597
apply (frule method_in_md [THEN conjunct2], assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   598
apply (frule method_yields_wf_java_mdecl, assumption, assumption)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   599
apply (simp add: env_of_jmb_def gs_def conforms_def split_beta)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   600
apply (simp add: wf_java_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   601
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   602
apply (rule lconf_ext)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   603
apply (rule lconf_ext_list)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   604
apply (rule lconf_init_vars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   605
apply (auto dest: Ball_set_table)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   606
apply (simp add: np_def xconf_raise_if)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   607
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   608
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   609
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   610
lemma ty_exprs_list_all2 [rule_format (no_asm)]: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   611
  "(\<forall> Ts. (E \<turnstile> es [::] Ts) = list_all2 (\<lambda>e T. E \<turnstile> e :: T) es Ts)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   612
apply (rule list.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   613
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   614
apply (rule allI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   615
apply (rule iffI)
23757
087b0a241557 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   616
  apply (ind_cases "E \<turnstile> [] [::] Ts" for Ts, assumption)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   617
  apply simp apply (rule WellType.Nil)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   618
apply (simp add: list_all2_Cons1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   619
apply (rule allI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   620
apply (rule iffI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   621
  apply (rename_tac a exs Ts)
23757
087b0a241557 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   622
  apply (ind_cases "E \<turnstile> a # exs  [::] Ts" for a exs Ts) apply blast
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   623
  apply (auto intro: WellType.Cons)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   624
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   625
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   626
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   627
lemma conf_bool: "G,h \<turnstile> v::\<preceq>PrimT Boolean \<Longrightarrow> \<exists> b. v = Bool b"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   628
apply (simp add: conf_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   629
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   630
apply (case_tac v)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   631
apply (auto elim: widen.cases)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   632
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   633
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   634
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   635
lemma class_expr_is_class: "\<lbrakk>E \<turnstile> e :: Class C; ws_prog (prg E)\<rbrakk> 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   636
  \<Longrightarrow> is_class (prg E) C"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   637
by (case_tac E, auto dest: ty_expr_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   638
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   639
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   640
lemma max_spec_widen: "max_spec G C (mn, pTs) = {((md,rT),pTs')} \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   641
  list_all2 (\<lambda> T T'. G \<turnstile> T \<preceq> T') pTs pTs'"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   642
by (blast dest: singleton_in_set max_spec2appl_meths appl_methsD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   643
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   644
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   645
lemma eval_conf: "\<lbrakk>G \<turnstile> s -e\<succ>v-> s'; wf_java_prog G; s::\<preceq>E;
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   646
  E\<turnstile>e::T; gx s' = None; prg E = G \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   647
  \<Longrightarrow> G,gh s'\<turnstile>v::\<preceq>T"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   648
apply (simp add: gh_def)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   649
apply (rule_tac x3="fst s" and s3="snd s"and x'3="fst s'"  
14143
7544966fa07d Modifications after changes in MicroJava/J
streckem
parents: 14045
diff changeset
   650
  in eval_type_sound [THEN conjunct2 [THEN conjunct1 [THEN mp]], simplified])
7544966fa07d Modifications after changes in MicroJava/J
streckem
parents: 14045
diff changeset
   651
apply assumption+
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   652
apply (simp (no_asm_use) add: surjective_pairing [THEN sym])
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   653
apply (simp only: surjective_pairing [THEN sym])
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   654
apply (auto simp add: gs_def gx_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   655
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   656
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   657
lemma evals_preserves_conf:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   658
  "\<lbrakk> G\<turnstile> s -es[\<succ>]vs-> s'; G,gh s \<turnstile> t ::\<preceq> T; E \<turnstile>es[::]Ts;
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   659
  wf_java_prog G; s::\<preceq>E; 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   660
  prg E = G \<rbrakk> \<Longrightarrow> G,gh s' \<turnstile> t ::\<preceq> T"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   661
apply (subgoal_tac "gh s\<le>| gh s'")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   662
apply (frule conf_hext, assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   663
apply (frule eval_evals_exec_type_sound [THEN conjunct2 [THEN conjunct1 [THEN mp]]]) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   664
apply (subgoal_tac "G \<turnstile> (gx s, (gh s, gl s)) -es[\<succ>]vs-> (gx s', (gh s', gl s'))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   665
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   666
apply (simp add: gx_def gh_def gl_def surjective_pairing [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   667
apply (case_tac E)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   668
apply (simp add: gx_def gs_def gh_def gl_def surjective_pairing [THEN sym])
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   669
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   670
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   671
lemma eval_of_class: "\<lbrakk> G \<turnstile> s -e\<succ>a'-> s'; E \<turnstile> e :: Class C; 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   672
  wf_java_prog G; s::\<preceq>E; gx s'=None; a' \<noteq> Null; G=prg E\<rbrakk>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   673
  \<Longrightarrow> (\<exists> lc. a' = Addr lc)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   674
apply (case_tac s, case_tac s', simp)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   675
apply (frule eval_type_sound, (simp add: gs_def)+)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   676
apply (case_tac a')
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   677
apply (auto simp: conf_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   678
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   679
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   680
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   681
lemma dynT_subcls: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   682
  "\<lbrakk> a' \<noteq> Null; G,h\<turnstile>a'::\<preceq> Class C; dynT = fst (the (h (the_Addr a')));
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   683
  is_class G dynT; ws_prog G \<rbrakk> \<Longrightarrow> G\<turnstile>dynT \<preceq>C C"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   684
apply (case_tac "C = Object")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   685
apply (simp, rule subcls_C_Object, assumption+)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   686
apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   687
apply (frule non_np_objD, auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   688
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   689
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   690
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   691
lemma method_defined: "\<lbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   692
  m = the (method (G, dynT) (mn, pTs)); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   693
  dynT = fst (the (h a)); is_class G dynT; wf_java_prog G; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   694
  a' \<noteq> Null; G,h\<turnstile>a'::\<preceq> Class C; a = the_Addr a';
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   695
  \<exists>pTsa md rT. max_spec G C (mn, pTsa) = {((md, rT), pTs)} \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   696
\<Longrightarrow> (method (G, dynT) (mn, pTs)) = Some m"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   697
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   698
apply (drule singleton_in_set, drule max_spec2appl_meths)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   699
apply (simp add: appl_methds_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   700
apply ((erule exE)+, (erule conjE)+, (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   701
apply (drule widen_methd)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   702
apply assumption
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   703
apply (rule dynT_subcls) apply assumption+ apply simp apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   704
apply (erule exE)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   705
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   706
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   707
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   708
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   709
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   710
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   711
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   712
(* 1. any difference between locvars_xstate \<dots> and L ??? *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   713
(* 2. possibly skip env_of_jmb ??? *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   714
theorem compiler_correctness: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   715
  "wf_java_prog G \<Longrightarrow>
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   716
  (G \<turnstile> xs -ex\<succ>val-> xs' \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   717
  gx xs = None \<longrightarrow> gx xs' = None \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   718
  (\<forall> os CL S.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   719
  (class_sig_defined G CL S) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   720
  (wtpd_expr (env_of_jmb G CL S) ex) \<longrightarrow>
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   721
  (xs ::\<preceq> (env_of_jmb G CL S)) \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   722
  ( {TranslComp.comp G, CL, S} \<turnstile>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   723
    {gh xs, os, (locvars_xstate G CL S xs)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   724
    >- (compExpr (gmb G CL S) ex) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   725
    {gh xs', val#os, locvars_xstate G CL S xs'}))) \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   726
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   727
 (G \<turnstile> xs -exs[\<succ>]vals-> xs' \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   728
  gx xs = None \<longrightarrow> gx xs' = None \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   729
  (\<forall> os CL S.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   730
  (class_sig_defined G CL S) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   731
  (wtpd_exprs (env_of_jmb G CL S) exs) \<longrightarrow>
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   732
  (xs::\<preceq>(env_of_jmb G CL S)) \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   733
  ( {TranslComp.comp G, CL, S} \<turnstile>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   734
    {gh xs, os, (locvars_xstate G CL S xs)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   735
    >- (compExprs (gmb G CL S) exs) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   736
    {gh xs', (rev vals)@os, (locvars_xstate G CL S xs')}))) \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   737
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
   738
  (G \<turnstile> xs -st-> xs' \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   739
   gx xs = None \<longrightarrow> gx xs' = None \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   740
  (\<forall> os CL S.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   741
  (class_sig_defined G CL S) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   742
  (wtpd_stmt (env_of_jmb G CL S) st) \<longrightarrow>
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   743
  (xs::\<preceq>(env_of_jmb G CL S)) \<longrightarrow>
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   744
  ( {TranslComp.comp G, CL, S} \<turnstile>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   745
    {gh xs, os, (locvars_xstate G CL S xs)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   746
    >- (compStmt (gmb G CL S) st) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   747
    {gh xs', os, (locvars_xstate G CL S xs')})))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   748
apply (rule Eval.eval_evals_exec.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   749
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   750
(* case XcptE *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   751
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   752
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   753
(* case NewC *) 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   754
apply clarify 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   755
apply (frule wf_prog_ws_prog [THEN wf_subcls1]) (* establish  wf ((subcls1 G)^-1) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   756
apply (simp add: c_hupd_hp_invariant)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   757
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   758
apply (rotate_tac 1, drule sym) (* reverse equation (a, None) = new_Addr (fst s) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   759
apply (simp add: locvars_xstate_def locvars_locals_def comp_fields)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   760
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   761
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   762
(* case Cast *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   763
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   764
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   765
apply (frule raise_if_NoneD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   766
apply (frule wtpd_expr_cast)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   767
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   768
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   769
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   770
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   771
apply (simp add: raise_system_xcpt_def  gh_def comp_cast_ok)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   772
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   773
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   774
(* case Lit *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   775
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   776
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   777
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   778
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   779
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   780
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   781
(* case BinOp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   782
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   783
apply (frule_tac xs=s1 in eval_xcpt, assumption) (* establish (gx s1 = None) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   784
apply (frule wtpd_expr_binop)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   785
(* establish (s1::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   786
apply (frule_tac e=e1 in state_ok_eval) apply (simp (no_asm_simp)) apply simp apply (simp (no_asm_use) only: env_of_jmb_fst) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   787
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   788
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   789
apply (simp (no_asm_use) only: compExpr_compExprs.simps)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   790
apply (rule_tac ?instrs0.0 = "compExpr (gmb G CL S) e1" in progression_transitive, simp) apply blast
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   791
apply (rule_tac ?instrs0.0 = "compExpr (gmb G CL S) e2" in progression_transitive, simp) apply blast
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   792
apply (case_tac bop)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   793
  (*subcase bop = Eq *)  apply simp apply (rule progression_Eq)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   794
  (*subcase bop = Add *) apply simp apply (rule progression_one_step) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   795
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   796
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   797
(* case LAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   798
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   799
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   800
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   801
apply (simp add: locvars_xstate_def locvars_locals_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   802
apply (frule wtpd_expr_lacc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   803
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   804
apply (simp add: gl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   805
apply (erule select_at_index)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   806
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   807
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   808
(* case LAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   809
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   810
apply (frule wtpd_expr_lass, erule conjE, erule conjE)
46226
e88e980ed735 tuned proofs;
wenzelm
parents: 35416
diff changeset
   811
apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   812
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   813
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   814
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   815
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   816
apply (rule_tac ?instrs0.0 = "[Dup]" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   817
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   818
apply (simp add: gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   819
apply (rule conjI, simp)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   820
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   821
apply (simp add: gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   822
(* the following falls out of the general scheme *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   823
apply (frule wtpd_expr_lacc) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   824
apply (rule update_at_index)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   825
apply (rule distinct_method_if_class_sig_defined) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   826
apply assumption apply simp apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   827
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   828
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   829
(* case FAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   830
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   831
   (* establish x1 = None \<and> a' \<noteq> Null *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   832
apply (simp (no_asm_use) only: gx_conv, frule np_NoneD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   833
apply (frule wtpd_expr_facc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   834
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   835
apply (simp (no_asm_use) only: compExpr_compExprs.simps)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   836
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   837
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   838
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   839
apply (simp add: gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   840
apply (case_tac "(the (fst s1 (the_Addr a')))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   841
apply (simp add: raise_system_xcpt_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   842
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   843
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   844
(* case FAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   845
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   846
apply (frule wtpd_expr_fass) apply (erule conjE) apply (frule wtpd_expr_facc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   847
apply (simp only: c_hupd_xcpt_invariant) (* establish x2 = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   848
   (* establish x1 = None  and  a' \<noteq> Null  *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   849
apply (frule_tac xs="(np a' x1, s1)" in eval_xcpt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   850
apply (simp only: gx_conv, simp only: gx_conv, frule np_NoneD, erule conjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   851
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   852
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   853
  (* establish ((Norm s1)::\<preceq> \<dots>) *)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   854
apply (frule_tac e=e1 in state_ok_eval) apply (simp (no_asm_simp) only: env_of_jmb_fst) 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   855
   apply assumption apply (simp (no_asm_use) only: env_of_jmb_fst) 
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   856
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   857
apply (simp only: compExpr_compExprs.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   858
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   859
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e1)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   860
apply fast (* blast does not seem to work - why? *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   861
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e2)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   862
apply fast
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   863
apply (rule_tac ?instrs0.0 = "[Dup_x1]" and ?instrs1.0 = "[Putfield fn T]" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   864
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   865
   (* Dup_x1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   866
   apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   867
   apply (simp add: gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   868
   apply (rule conjI, simp)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   869
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   870
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   871
   (* Putfield \<longrightarrow> still looks nasty*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   872
   apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   873
   apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   874
   apply (case_tac "(the (fst s2 (the_Addr a')))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   875
   apply (simp add: c_hupd_hp_invariant)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   876
   apply (case_tac s2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   877
   apply (simp add: c_hupd_conv raise_system_xcpt_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   878
   apply (rule locvars_xstate_par_dep, rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   879
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   880
defer (* method call *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   881
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   882
(* case XcptEs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   883
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   884
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   885
(* case Nil *)
46226
e88e980ed735 tuned proofs;
wenzelm
parents: 35416
diff changeset
   886
apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   887
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   888
apply (rule progression_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   889
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   890
(* case Cons *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   891
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   892
apply (frule_tac xs=s1 in evals_xcpt, simp only: gx_conv) (* establish gx s1 = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   893
apply (frule wtpd_exprs_cons)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   894
   (* establish ((Norm s0)::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   895
apply (frule_tac e=e in state_ok_eval) apply (simp (no_asm_simp) only: env_of_jmb_fst) apply simp apply (simp (no_asm_use) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   896
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   897
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   898
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   899
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   900
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   901
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   902
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   903
(* case Statement: exception *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   904
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   905
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   906
(* case Skip *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   907
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   908
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   909
apply (rule progression_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   910
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   911
(* case Expr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   912
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   913
apply (frule wtpd_stmt_expr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   914
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   915
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   916
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   917
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   918
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   919
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   920
(* case Comp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   921
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   922
apply (frule_tac xs=s1 in exec_xcpt, assumption) (* establish (gx s1 = None) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   923
apply (frule wtpd_stmt_comp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   924
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   925
  (* establish (s1::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   926
apply (frule_tac st=c1 in state_ok_exec) apply (simp (no_asm_simp) only: env_of_jmb_fst) apply simp apply (simp (no_asm_use) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   927
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   928
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   929
apply (rule_tac ?instrs0.0 = "(compStmt (gmb G CL S) c1)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   930
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   931
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   932
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   933
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   934
(* case Cond *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   935
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   936
apply (frule_tac xs=s1 in exec_xcpt, assumption) (* establish (gx s1 = None) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   937
apply (frule wtpd_stmt_cond, (erule conjE)+)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
   938
(* establish (s1::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   939
apply (frule_tac e=e in state_ok_eval) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   940
apply (simp (no_asm_simp) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   941
apply assumption 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   942
apply (simp (no_asm_use) only: env_of_jmb_fst) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   943
(* establish G,gh s1\<turnstile>v::\<preceq>PrimT Boolean *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   944
apply (frule eval_conf, assumption+, rule env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   945
apply (frule conf_bool) (* establish \<exists>b. v = Bool b *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   946
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   947
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   948
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   949
apply (rule_tac ?instrs0.0 = "[LitPush (Bool False)]" in progression_transitive, simp (no_asm_simp))
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   950
apply (rule progression_one_step,  simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   951
apply (rule conjI, rule HOL.refl)+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   952
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   953
apply (rule_tac ?instrs0.0 = "compExpr (gmb G CL S) e" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   954
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   955
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   956
apply (case_tac b)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   957
 (* case b= True *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   958
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   959
apply (rule_tac ?instrs0.0 = "[Ifcmpeq (2 + int (length (compStmt (gmb G CL S) c1)))]" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   960
apply (rule progression_one_step) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   961
apply (rule conjI, rule HOL.refl)+ apply (rule HOL.refl)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   962
apply (rule_tac ?instrs0.0 = "(compStmt (gmb G CL S) c1)" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   963
apply fast
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   964
apply (rule_tac ?instrs1.0 = "[]" in jump_fwd_progression)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   965
apply (simp, rule conjI, (rule HOL.refl)+)
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20272
diff changeset
   966
apply simp apply (rule conjI, simp) apply (simp add: nat_add_distrib)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   967
apply (rule progression_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   968
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   969
 (* case b= False *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   970
apply simp
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   971
apply (rule_tac ?instrs1.0 = "compStmt (gmb G CL S) c2" in jump_fwd_progression)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   972
apply (simp, rule conjI, (rule HOL.refl)+)
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20272
diff changeset
   973
apply (simp, rule conjI, rule HOL.refl, simp add: nat_add_distrib)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   974
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   975
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   976
(* case exit Loop *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   977
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   978
apply (frule wtpd_stmt_loop, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   979
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   980
(* establish G,gh s1\<turnstile>v::\<preceq>PrimT Boolean *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   981
apply (frule eval_conf, assumption+, rule env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   982
apply (frule conf_bool) (* establish \<exists>b. v = Bool b *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   983
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   984
apply (case_tac b)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   985
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   986
 (* case b= True \<longrightarrow> contradiction *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   987
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   988
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   989
 (* case b= False *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   990
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   991
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   992
apply (rule_tac ?instrs0.0 = "[LitPush (Bool False)]" in progression_transitive, simp (no_asm_simp))
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   993
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   994
   apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   995
   apply (rule conjI, rule HOL.refl)+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   996
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   997
apply (rule_tac ?instrs0.0 = "compExpr (gmb G CL S) e" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   998
apply fast
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
   999
apply (rule_tac ?instrs1.0 = "[]" in jump_fwd_progression)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1000
apply (simp, rule conjI, rule HOL.refl, rule HOL.refl)
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20272
diff changeset
  1001
apply (simp, rule conjI, rule HOL.refl, simp add: nat_add_distrib)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1002
apply (rule progression_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1003
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1004
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1005
(* case continue Loop *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1006
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1007
apply (frule_tac xs=s2 in exec_xcpt, assumption) (* establish (gx s2 = None) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1008
apply (frule_tac xs=s1 in exec_xcpt, assumption) (* establish (gx s1 = None) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1009
apply (frule wtpd_stmt_loop, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1010
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1011
(* establish (s1::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1012
apply (frule_tac e=e in state_ok_eval) apply (simp (no_asm_simp) only: env_of_jmb_fst) apply simp apply (simp (no_asm_use) only: env_of_jmb_fst)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1013
(* establish (s2::\<preceq> \<dots>) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1014
apply (frule_tac xs=s1 and st=c in state_ok_exec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1015
apply (simp (no_asm_simp) only: env_of_jmb_fst) apply assumption apply (simp (no_asm_use) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1016
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1017
(* establish G,gh s1\<turnstile>v::\<preceq>PrimT Boolean *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1018
apply (frule eval_conf, assumption+, rule env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1019
apply (frule conf_bool) (* establish \<exists>b. v = Bool b *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1020
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1021
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1022
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1023
apply (rule jump_bwd_progression) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1024
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1025
apply (rule conjI, (rule HOL.refl)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1026
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1027
apply (rule_tac ?instrs0.0 = "[LitPush (Bool False)]" in progression_transitive, simp (no_asm_simp))
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1028
apply (rule progression_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1029
   apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1030
   apply (rule conjI, simp)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1031
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1032
apply (rule_tac ?instrs0.0 = "compExpr (gmb G CL S) e" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1033
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1034
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1035
apply (case_tac b)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1036
 (* case b= True *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1037
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1038
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1039
apply (rule_tac ?instrs0.0 = "[Ifcmpeq (2 + int (length (compStmt (gmb G CL S) c)))]" in progression_transitive, simp)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1040
apply (rule progression_one_step) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1041
apply (rule conjI, rule HOL.refl)+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1042
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1043
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1044
 (* case b= False \<longrightarrow> contradiction*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1045
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1046
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1047
apply (rule jump_bwd_one_step)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1048
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1049
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1050
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1051
(*****)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1052
(* case method call *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1053
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1054
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1055
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1056
apply (frule_tac xs=s3 in eval_xcpt, simp only: gx_conv) (* establish gx s3 = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1057
apply (frule exec_xcpt, assumption, simp (no_asm_use) only: gx_conv, frule np_NoneD) (* establish x = None \<and> a' \<noteq> Null *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1058
apply (frule evals_xcpt, simp only: gx_conv) (* establish gx s1 = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1059
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1060
apply (frule wtpd_expr_call, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1061
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1062
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1063
(* assumptions about state_ok and is_class *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1064
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1065
(* establish s1::\<preceq> (env_of_jmb G CL S) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1066
apply (frule_tac xs="Norm s0" and e=e in state_ok_eval)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1067
apply (simp (no_asm_simp) only: env_of_jmb_fst, assumption, simp (no_asm_use) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1068
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1069
(* establish (x, h, l)::\<preceq>(env_of_jmb G CL S) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1070
apply (frule_tac xs=s1 and xs'="(x, h, l)" in state_ok_evals)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1071
apply (simp (no_asm_simp) only: env_of_jmb_fst, assumption, simp only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1072
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1073
(* establish \<exists> lc. a' = Addr lc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1074
apply (frule (5) eval_of_class, rule env_of_jmb_fst [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1075
apply (subgoal_tac "G,h \<turnstile> a' ::\<preceq> Class C")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1076
apply (subgoal_tac "is_class G dynT")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1077
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1078
(* establish method (G, dynT) (mn, pTs) = Some(md, rT, pns, lvars, blk, res) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1079
apply (drule method_defined, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1080
apply (simp only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1081
apply ((erule exE)+, erule conjE, (rule exI)+, assumption) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1082
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1083
apply (subgoal_tac "is_class G md")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1084
apply (subgoal_tac "G\<turnstile>Class dynT \<preceq> Class md")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1085
apply (subgoal_tac " method (G, md) (mn, pTs) = Some (md, rT, pns, lvars, blk, res)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1086
apply (subgoal_tac "list_all2 (conf G h) pvs pTs")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1087
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1088
(* establish (np a' x, h, init_vars lvars(pns[\<mapsto>]pvs)(This\<mapsto>a'))::\<preceq>(env_of_jmb G md (mn, pTs)) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1089
apply (subgoal_tac "G,h \<turnstile> a' ::\<preceq> Class dynT")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1090
apply (frule (2) conf_widen)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1091
apply (frule state_ok_init, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1092
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1093
apply (subgoal_tac "class_sig_defined G md (mn, pTs)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1094
apply (frule wtpd_blk, assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1095
apply (frule wtpd_res, assumption, assumption)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1096
apply (subgoal_tac "s3::\<preceq>(env_of_jmb G md (mn, pTs))")
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1097
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1098
apply (subgoal_tac "method (TranslComp.comp G, md) (mn, pTs) =
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1099
          Some (md, rT, snd (snd (compMethod G md ((mn, pTs), rT, pns, lvars, blk, res))))")
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1100
prefer 2 apply (simp add: wf_prog_ws_prog [THEN comp_method])
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1101
apply (subgoal_tac "method (TranslComp.comp G, dynT) (mn, pTs) =
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1102
          Some (md, rT, snd (snd (compMethod G md ((mn, pTs), rT, pns, lvars, blk, res))))")
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1103
prefer 2 apply (simp add: wf_prog_ws_prog [THEN comp_method])
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1104
 apply (simp only: fst_conv snd_conv)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1105
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1106
(* establish length pns = length pTs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1107
apply (frule method_preserves_length, assumption, assumption) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1108
(* establish length pvs = length ps *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1109
apply (frule evals_preserves_length [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1110
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1111
(** start evaluating subexpressions **)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1112
apply (simp (no_asm_use) only: compExpr_compExprs.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1113
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1114
  (* evaluate e *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1115
apply (rule_tac ?instrs0.0 = "(compExpr (gmb G CL S) e)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1116
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1117
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1118
  (* evaluate parameters *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1119
apply (rule_tac ?instrs0.0 = "compExprs (gmb G CL S) ps" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1120
apply fast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1121
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1122
  (* invokation *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1123
apply (rule progression_call)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1124
apply (intro allI impI conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1125
     (* execute Invoke statement *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1126
apply (simp (no_asm_use) only: exec_instr.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1127
apply (erule thin_rl, erule thin_rl, erule thin_rl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1128
apply (simp add: compMethod_def raise_system_xcpt_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1129
apply (rule conjI, simp)+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1130
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1131
     (* get instructions of invoked method *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1132
apply (simp (no_asm_simp) add: gis_def gmb_def compMethod_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1133
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1134
       (* var. initialization *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1135
apply (rule_tac ?instrs0.0 = "(compInitLvars (pns, lvars, blk, res) lvars)" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1136
apply (rule_tac C=md in progression_lvar_init, assumption, assumption, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1137
apply (simp (no_asm_simp)) (* length pns = length pvs *)
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 24699
diff changeset
  1138
apply (simp (no_asm_simp)) (* length lvars = length (replicate (length lvars) undefined) *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1139
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1140
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1141
       (* body statement *)
14174
f3cafd2929d5 Methods rule_tac etc support static (Isar) contexts.
ballarin
parents: 14143
diff changeset
  1142
apply (rule_tac ?instrs0.0 = "compStmt (pns, lvars, blk, res) blk" in progression_transitive, rule HOL.refl)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1143
apply (subgoal_tac "(pns, lvars, blk, res) = gmb G md (mn, pTs)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1144
apply (simp (no_asm_simp))
15866
f011452b2815 sped up a bit
kleing
parents: 15860
diff changeset
  1145
apply (simp only: gh_conv) 
f011452b2815 sped up a bit
kleing
parents: 15860
diff changeset
  1146
apply (drule mp [OF _ TrueI])+
f011452b2815 sped up a bit
kleing
parents: 15860
diff changeset
  1147
apply (erule allE, erule allE, erule allE, erule impE, assumption)+
f011452b2815 sped up a bit
kleing
parents: 15860
diff changeset
  1148
apply ((erule impE, assumption)+, assumption)
15860
a344c4284972 partial modernising of theory headers
paulson
parents: 15481
diff changeset
  1149
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1150
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1151
apply (simp (no_asm_simp) add: gmb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1152
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1153
       (* return expression *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1154
apply (subgoal_tac "(pns, lvars, blk, res) = gmb G md (mn, pTs)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1155
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1156
apply (simp only: gh_conv)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1157
apply ((drule mp, rule TrueI)+, (drule spec)+, (drule mp, assumption)+, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1158
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1159
apply (simp (no_asm_simp) add: gmb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1160
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1161
      (* execute return statement *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1162
apply (simp (no_asm_use) add: gh_def locvars_xstate_def gl_def del: drop_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1163
apply (subgoal_tac "rev pvs @ a' # os = (rev (a' # pvs)) @ os")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1164
apply (simp only: drop_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1165
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1166
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1167
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1168
(* show s3::\<preceq>\<dots> *)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1169
apply (rule_tac xs = "(np a' x, h, init_vars lvars(pns[\<mapsto>]pvs)(This\<mapsto>a'))" and st=blk in state_ok_exec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1170
apply assumption apply (simp (no_asm_simp) only: env_of_jmb_fst) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1171
apply assumption apply (simp (no_asm_use) only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1172
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1173
(* show class_sig_defined G md (mn, pTs) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1174
apply (simp (no_asm_simp) add: class_sig_defined_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1175
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1176
(* show G,h \<turnstile> a' ::\<preceq> Class dynT *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1177
apply (frule non_npD) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1178
apply (erule exE)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1179
apply (rule conf_obj_AddrI) apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1180
apply (rule conjI, (rule HOL.refl)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1181
apply (rule widen_Class_Class [THEN iffD1], rule widen.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1182
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1183
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1184
  (* show list_all2 (conf G h) pvs pTs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1185
apply (erule exE)+ apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1186
apply (rule_tac Ts="pTsa" in conf_list_gext_widen) apply assumption
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
  1187
apply (subgoal_tac "G \<turnstile> (gx s1, gs s1) -ps[\<succ>]pvs-> (x, h, l)")
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1188
apply (frule_tac E="env_of_jmb G CL S" in evals_type_sound)
14143
7544966fa07d Modifications after changes in MicroJava/J
streckem
parents: 14045
diff changeset
  1189
apply assumption+
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1190
apply (simp only: env_of_jmb_fst) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1191
apply (simp add: conforms_def xconf_def gs_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1192
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1193
apply (simp (no_asm_use) only: gx_def gs_def surjective_pairing [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1194
apply (simp (no_asm_use) only: ty_exprs_list_all2) apply simp
14143
7544966fa07d Modifications after changes in MicroJava/J
streckem
parents: 14045
diff changeset
  1195
apply simp
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1196
apply (simp (no_asm_use) only: gx_def gs_def surjective_pairing [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1197
    (* list_all2 (\<lambda>T T'. G \<turnstile> T \<preceq> T') pTsa pTs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1198
    apply (rule max_spec_widen, simp only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1199
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1200
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1201
(* show method (G, md) (mn, pTs) = Some (md, rT, pns, lvars, blk, res) *)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1202
apply (frule wf_prog_ws_prog [THEN method_in_md [THEN conjunct2]], assumption+)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1203
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1204
  (* show G\<turnstile>Class dynT \<preceq> Class md *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1205
apply (simp (no_asm_use) only: widen_Class_Class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1206
apply (rule method_wf_mdecl [THEN conjunct1], assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1207
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1208
  (* is_class G md *)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1209
apply (rule wf_prog_ws_prog [THEN method_in_md [THEN conjunct1]], assumption+)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1210
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1211
  (* show is_class G dynT *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1212
apply (frule non_npD) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1213
apply (erule exE)+ apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1214
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1215
apply (rule subcls_is_class2) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1216
apply (frule class_expr_is_class) apply (simp only: env_of_jmb_fst)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1217
apply (rule wf_prog_ws_prog, assumption)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1218
apply (simp only: env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1219
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1220
 (* show G,h \<turnstile> a' ::\<preceq> Class C *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1221
apply (simp only: wtpd_exprs_def, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1222
apply (frule evals_preserves_conf)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1223
apply (rule eval_conf, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1224
apply (rule env_of_jmb_fst, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1225
apply (rule env_of_jmb_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1226
apply (simp only: gh_conv)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1227
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1228
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1229
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1230
theorem compiler_correctness_eval: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1231
  \<lbrakk> G \<turnstile> (None,hp,loc) -ex \<succ> val-> (None,hp',loc');
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1232
  wf_java_prog G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1233
  class_sig_defined G C S;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1234
  wtpd_expr (env_of_jmb G C S) ex;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1235
  (None,hp,loc) ::\<preceq> (env_of_jmb G C S) \<rbrakk> \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1236
  {(TranslComp.comp G), C, S} \<turnstile> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1237
    {hp, os, (locvars_locals G C S loc)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1238
      >- (compExpr (gmb G C S) ex) \<rightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1239
    {hp', val#os, (locvars_locals G C S loc')}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1240
apply (frule compiler_correctness [THEN conjunct1])
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1241
apply (auto simp: gh_def gx_def gs_def gl_def locvars_xstate_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1242
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1243
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1244
theorem compiler_correctness_exec: "
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 20432
diff changeset
  1245
  \<lbrakk> G \<turnstile> Norm (hp, loc) -st-> Norm (hp', loc');
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1246
  wf_java_prog G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1247
  class_sig_defined G C S;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1248
  wtpd_stmt (env_of_jmb G C S) st;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1249
  (None,hp,loc) ::\<preceq> (env_of_jmb G C S) \<rbrakk> \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1250
  {(TranslComp.comp G), C, S} \<turnstile> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1251
    {hp, os, (locvars_locals G C S loc)}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1252
      >- (compStmt (gmb G C S) st) \<rightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1253
    {hp', os, (locvars_locals G C S loc')}"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1254
apply (frule compiler_correctness [THEN conjunct2 [THEN conjunct2]])
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1255
apply (auto simp: gh_def gx_def gs_def gl_def locvars_xstate_def)
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1256
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1257
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1258
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1259
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1260
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1261
(* reinstall pair splits *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1262
declare split_paired_All [simp] split_paired_Ex [simp]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1263
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1264
declare wf_prog_ws_prog [simp del]
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 14025
diff changeset
  1265
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1266
end