src/HOL/MicroJava/Comp/LemmasComp.thy
author streckem
Wed, 23 Oct 2002 16:10:02 +0200
changeset 13673 2950128b8206
child 14025 d9b155757dc8
permissions -rw-r--r--
First checkin of compiler
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/LemmasComp.thy
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     2
    ID:         $Id$
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     3
    Author:     Martin Strecker
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     4
    Copyright   GPL 2002
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     5
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     6
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     7
(* Lemmas for compiler correctness proof *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     8
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     9
theory LemmasComp = TranslComp:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    10
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    11
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    12
(* misc lemmas *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    13
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    14
lemma split_pairs: "(\<lambda>(a,b). (F a b)) (ab) = F (fst ab) (snd ab)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    15
proof -
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    16
  have "(\<lambda>(a,b). (F a b)) (fst ab,snd ab) = F (fst ab) (snd ab)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    17
    by (simp add: split_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    18
  then show ?thesis by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    19
qed
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
lemma c_hupd_conv: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    23
  "c_hupd h' (xo, (h,l)) = (xo, (if xo = None then h' else h),l)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    24
by (simp add: c_hupd_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    25
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    26
lemma gl_c_hupd [simp]: "(gl (c_hupd h xs)) = (gl xs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    27
by (simp add: gl_def c_hupd_def split_pairs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    28
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    29
lemma c_hupd_xcpt_invariant [simp]: "gx (c_hupd h' (xo, st)) = xo"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    30
by (case_tac st, simp only: c_hupd_conv gx_conv)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    31
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    32
(* not added to simpset because of interference with c_hupd_conv *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    33
lemma c_hupd_hp_invariant: "gh (c_hupd hp (None, st)) = hp"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    34
by (case_tac st, simp add: c_hupd_conv gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    35
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    36
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    37
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    38
(* invariance of properties under compilation *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    39
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    40
lemma comp_class_imp:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    41
  "(class G C = Some(D, fs, ms)) \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    42
  (class (comp G) C = Some(D, fs, map (compMethod G C) ms))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    43
apply (simp add: class_def comp_def compClass_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    44
apply (rule HOL.trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    45
apply (rule map_of_map2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    46
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    47
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    48
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    49
lemma comp_class_None: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    50
"(class G C = None) = (class (comp G) C = None)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    51
apply (simp add: class_def comp_def compClass_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    52
apply (simp add: map_of_in_set)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    53
apply (simp add: image_compose [THEN sym] o_def split_beta del: image_compose)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    54
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    55
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    56
lemma comp_is_class: "is_class G C = is_class (comp G) C"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    57
by (case_tac "class G C", auto simp: is_class_def comp_class_None dest: comp_class_imp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    58
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    59
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    60
lemma comp_is_type: "is_type G T = is_type (comp G) T"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    61
  by ((cases T),simp,(induct G)) ((simp),(simp only: comp_is_class),(simp add: comp_is_class),(simp only: comp_is_class))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    62
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    63
lemma SIGMA_cong: "\<lbrakk> A = B; !!x. x \<in> B \<Longrightarrow> C x = D x \<rbrakk> \<Longrightarrow> (\<Sigma> x \<in> A. C x) = (\<Sigma> x \<in> B. D x)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    64
by auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    65
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    66
lemma comp_classname: "is_class G C \<Longrightarrow> fst (the (class G C)) = fst (the (class (comp G) C))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    67
by (case_tac "class G C", auto simp: is_class_def dest: comp_class_imp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    68
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    69
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    70
lemma comp_subcls1: "subcls1 G = subcls1 (comp G)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    71
apply (simp add: subcls1_def2 comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    72
apply (rule SIGMA_cong, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    73
apply (simp add: comp_is_class [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    74
apply (simp add: comp_classname)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    75
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    76
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    77
lemma comp_subcls: "(subcls1 G)^* = (subcls1 (comp G))^*"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    78
  by (induct G) (simp_all add: comp_def comp_subcls1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    79
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    80
lemma comp_widen: "((ty1,ty2) \<in> widen G) = ((ty1,ty2) \<in> widen (comp G))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    81
  apply rule
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    82
  apply (cases "(ty1,ty2)" G rule: widen.cases) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    83
  apply (simp_all add: comp_subcls widen.null)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    84
  apply (cases "(ty1,ty2)" "comp G" rule: widen.cases) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    85
  apply (simp_all add: comp_subcls widen.null)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    86
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    87
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    88
lemma comp_cast: "((ty1,ty2) \<in> cast G) = ((ty1,ty2) \<in> cast (comp G))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    89
  apply rule
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    90
  apply (cases "(ty1,ty2)" G rule: cast.cases)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    91
  apply (simp_all add: comp_subcls cast.widen cast.subcls)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    92
  apply (cases "(ty1,ty2)" "comp G" rule: cast.cases) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    93
  apply (simp_all add: comp_subcls cast.widen cast.subcls)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    94
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    95
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    96
lemma comp_cast_ok: "cast_ok G = cast_ok (comp G)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    97
  by (simp add: expand_fun_eq cast_ok_def comp_widen)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    98
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    99
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   100
lemma comp_wf_fdecl: "wf_fdecl G fd  \<Longrightarrow> wf_fdecl (comp G) fd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   101
apply (case_tac fd)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   102
apply (simp add: wf_fdecl_def comp_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   103
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   104
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   105
lemma comp_wf_syscls: "wf_syscls G = wf_syscls (comp G)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   106
apply (simp add: wf_syscls_def comp_def compClass_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   107
apply (simp only: image_compose [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   108
apply (subgoal_tac "(Fun.comp fst (\<lambda>(C, cno::cname, fdls::fdecl list, jmdls). (C, cno, fdls, map (compMethod G C) jmdls))) = fst")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   109
(*
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   110
apply (subgoal_tac "(fst o (\<lambda>(C, cno::cname, fdls::fdecl list, jmdls). (C, cno, fdls, map (compMethod G C) jmdls))) = fst")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   111
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   112
apply (simp del: image_compose)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   113
apply (simp add: expand_fun_eq split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   114
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   115
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   116
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   117
lemma comp_wf_mhead: "wf_mhead G S rT =  wf_mhead (comp G) S rT"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   118
by (simp add: wf_mhead_def split_beta comp_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   119
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   120
lemma comp_wf_mdecl: "\<lbrakk> wf_mdecl wf_mb G C jmdl;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   121
  (wf_mb G C jmdl) \<longrightarrow> (wf_mb_comp (comp G) C (compMethod G C jmdl)) \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   122
 \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   123
  wf_mdecl wf_mb_comp (comp G) C (compMethod G C jmdl)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   124
by (simp add: wf_mdecl_def wf_mhead_def comp_is_type split_beta compMethod_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   125
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   126
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   127
lemma comp_class_rec: " wf ((subcls1 G)^-1) \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   128
class_rec (comp G) C t f = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   129
  class_rec G C t (\<lambda> C' fs' ms' r'. f C' fs' (map (compMethod G C') ms') r')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   130
apply (rule_tac a = C in  wf_induct) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   131
apply (subgoal_tac "wf ((subcls1 (comp G))\<inverse>)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   132
apply (subgoal_tac "(class G x = None) \<or> (\<exists> D fs ms. (class G x = Some (D, fs, ms)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   133
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   134
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   135
  (* case class G x = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   136
apply (simp (no_asm_simp) add: class_rec_def comp_subcls1 wfrec cut_apply)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   137
apply (simp add: comp_class_None)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   138
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   139
  (* case \<exists> D fs ms. (class G x = Some (D, fs, ms)) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   140
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   141
apply (frule comp_class_imp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   142
apply (frule_tac G="comp G" and C=x and t=t and f=f in class_rec_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   143
  apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   144
apply (frule_tac G=G and C=x and t=t 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   145
   and f="(\<lambda>C' fs' ms'. f C' fs' (map (compMethod G C') ms'))" in class_rec_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   146
  apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   147
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   148
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   149
apply (case_tac "x = Object")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   150
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   151
  apply (frule subcls1I, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   152
    apply (drule_tac x=D in spec, drule mp, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   153
    apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   154
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   155
  (* subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   156
apply (case_tac "class G x")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   157
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   158
apply (simp add: comp_subcls1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   159
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   160
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   161
lemma comp_fields: "wf ((subcls1 G)^-1) \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   162
  fields (G,C) = fields (comp G,C)" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   163
by (simp add: fields_def comp_class_rec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   164
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   165
lemma comp_field: "wf ((subcls1 G)^-1) \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   166
  field (G,C) = field (comp G,C)" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   167
by (simp add: field_def comp_fields)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   168
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   169
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   170
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   171
lemma class_rec_relation [rule_format (no_asm)]: "\<lbrakk>  wf_prog wf_mb G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   172
  \<forall> fs ms. R (f1 Object fs ms t1) (f2 Object fs ms t2);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   173
   \<forall> C fs ms r1 r2. (R r1 r2) \<longrightarrow> (R (f1 C fs ms r1) (f2 C fs ms r2)) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   174
  \<Longrightarrow> ((class G C) \<noteq> None) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   175
  R (class_rec G C t1 f1) (class_rec G C t2 f2)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   176
apply (frule wf_subcls1) (* establish wf ((subcls1 G)^-1) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   177
apply (rule_tac a = C in  wf_induct) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   178
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   179
apply (subgoal_tac "(\<exists>D rT mb. class G x = Some (D, rT, mb))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   180
  apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   181
apply (frule_tac C=x and t=t1 and f=f1 in class_rec_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   182
  apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   183
apply (frule_tac C=x and t=t2 and f=f2 in class_rec_lemma)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   184
  apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   185
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   186
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   187
apply (case_tac "x = Object")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   188
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   189
  apply (frule subcls1I, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   190
    apply (drule_tac x=D in spec, drule mp, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   191
    apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   192
    apply (subgoal_tac "(\<exists>D' rT' mb'. class G D = Some (D', rT', mb'))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   193
    apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   194
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   195
  (* subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   196
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   197
apply (frule class_wf) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   198
apply (simp add: wf_cdecl_def is_class_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   199
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   200
apply (simp add: subcls1_def2 is_class_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   201
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   202
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   203
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   204
syntax
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   205
  mtd_mb :: "cname \<times> ty \<times> 'c \<Rightarrow> 'c"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   206
translations
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   207
  "mtd_mb" => "Fun.comp snd snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   208
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   209
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   210
lemma map_of_map_fst: "\<lbrakk> map_of (map f xs) k = Some e; inj f;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   211
  \<forall>x\<in>set xs. fst (f x) = fst x; \<forall>x\<in>set xs. fst (g x) = fst x \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   212
  \<Longrightarrow>  map_of (map g xs) k = Some (snd (g ((inv f) (k, e))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   213
apply (induct xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   214
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   215
apply (simp del: split_paired_All)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   216
apply (case_tac "k = fst a")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   217
apply (simp del: split_paired_All)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   218
apply (subgoal_tac "(fst a, e)  = f a")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   219
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   220
apply (rule_tac s= "(fst (f a), snd (f a))" in trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   221
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   222
apply (rule surjective_pairing [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   223
apply (simp del: split_paired_All)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   224
done
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 comp_method [rule_format (no_asm)]: "\<lbrakk> wf_prog wf_mb G; is_class G C\<rbrakk> \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   228
  (method (G, C) S) = Some (D, rT, mb) \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   229
  (method (comp G, C) S) = Some (D, rT, mtd_mb (compMethod G D (S, rT, mb)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   230
apply (simp add: method_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   231
apply (frule wf_subcls1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   232
apply (simp add: comp_class_rec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   233
apply (simp add: map_compose [THEN sym] split_iter split_compose del: map_compose)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   234
apply (rule_tac R="%x y. (x S) = Some (D, rT, mb) \<longrightarrow> (y S) = Some (D, rT, snd (snd (compMethod G D (S, rT, mb))))" in  class_rec_relation) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   235
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   236
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   237
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   238
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   239
apply (frule_tac f="(\<lambda>(s, m). (s, Object, m))" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   240
  and g="(Fun.comp (\<lambda>(s, m). (s, Object, m)) (compMethod G Object))" in map_of_map_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   241
(*
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   242
apply (frule_tac f="(\<lambda>(s, m). (s, Object, m))" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   243
  and g="((\<lambda>(s, m). (s, Object, m)) \<circ> compMethod G Object)" in map_of_map_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   244
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   245
apply (simp add: inj_on_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   246
apply (simp add: split_beta compMethod_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   247
apply (simp add: split_beta compMethod_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   248
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   249
apply (subgoal_tac "(inv (\<lambda>(s, m). (s, Object, m)) (S, D, rT, mb)) = (S, rT, mb)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   250
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   251
apply (simp add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   252
apply (simp add: map_of_map) apply (erule exE)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   253
apply (simp add: map_of_map) apply (erule exE)+ apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   254
apply (rule inv_f_eq) apply (simp add: inj_on_def) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   255
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   256
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   257
apply (simp add: override_Some_iff map_of_map del: split_paired_Ex)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   258
apply (subgoal_tac "\<forall>x\<in>set ms. fst ((Fun.comp (\<lambda>(s, m). (s, Ca, m)) (compMethod G Ca)) x) = fst x")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   259
(*
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   260
apply (subgoal_tac "\<forall>x\<in>set ms. fst (((\<lambda>(s, m). (s, Ca, m)) \<circ> compMethod G Ca) x) = fst x")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   261
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   262
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   263
apply (rule disjI1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   264
apply (simp add: map_of_map2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   265
apply (simp (no_asm_simp) add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   266
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   267
apply (rule disjI2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   268
apply (simp add: map_of_map2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   269
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   270
  -- "subgoal"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   271
apply (simp (no_asm_simp) add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   272
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   273
apply (simp add: is_class_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   274
done
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
constdefs comp_method_result :: "java_mb prog \<Rightarrow> sig \<Rightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   278
  (cname \<times> ty \<times> java_mb) option \<Rightarrow> (cname \<times> ty \<times> jvm_method) option"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   279
  "comp_method_result G S m ==  case m of 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   280
    None \<Rightarrow> None
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   281
  | Some (D, rT, mb) \<Rightarrow> Some (D, rT, mtd_mb (compMethod G D (S, rT, mb)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   282
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   283
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   284
lemma map_of_map_compMethod: "map_of (map (\<lambda>(s, m). (s, C, m)) (map (compMethod G C) ms)) S =
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   285
          (case map_of (map (\<lambda>(s, m). (s, C, m)) ms) S of None \<Rightarrow> None
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   286
           | Some (D, rT, mb) \<Rightarrow> Some (D, rT, mtd_mb (compMethod G D (S, rT, mb))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   287
apply (induct ms)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   288
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   289
apply (simp only: map_compose [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   290
apply (simp add: o_def split_beta del: map.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   291
apply (simp (no_asm_simp) only: map.simps map_of.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   292
apply (simp add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   293
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   294
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   295
  (* the following is more expressive than comp_method and should replace it *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   296
lemma comp_method_eq [rule_format (no_asm)]: "wf_prog wf_mb G \<Longrightarrow> is_class G C \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   297
method (comp G, C) S = comp_method_result G S (method (G,C) S)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   298
apply (subgoal_tac "wf ((subcls1 G)^-1)") prefer 2 apply (rule wf_subcls1, assumption) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   299
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   300
apply (rule subcls_induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   301
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   302
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   303
apply (subgoal_tac "\<exists> D fs ms. class G C = Some (D, fs, ms)") 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   304
   prefer 2 apply (simp add: is_class_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   305
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   306
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   307
apply (case_tac "C = Object")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   308
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   309
  (* C = Object *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   310
apply (subst method_rec_lemma) apply assumption+ apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   311
apply (subst method_rec_lemma) apply (frule comp_class_imp) apply assumption+ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   312
   apply (simp add: comp_subcls1) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   313
apply (simp add: comp_method_result_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   314
apply (rule map_of_map_compMethod) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   315
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   316
  (* C \<noteq> Object *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   317
apply (subgoal_tac "(C, D) \<in> (subcls1 G)\<^sup>+") 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   318
   prefer 2 apply (frule subcls1I, assumption+) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   319
apply (subgoal_tac "is_class G D")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   320
apply (drule spec, drule mp, assumption, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   321
apply (frule wf_subcls1) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   322
apply (subgoal_tac "wf ((subcls1 (comp G))\<inverse>)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   323
apply (frule_tac G=G in method_rec_lemma, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   324
apply (frule comp_class_imp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   325
apply (frule_tac G="comp G" in method_rec_lemma, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   326
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   327
apply (simp (no_asm_simp) add: comp_method_result_def expand_fun_eq)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   328
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   329
apply (case_tac "(method (G, D) ++  map_of (map (\<lambda>(s, m). (s, C, m)) ms)) S")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   330
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   331
  (* case None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   332
apply (simp (no_asm_simp) add: override_None)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   333
apply (simp add: map_of_map_compMethod comp_method_result_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   334
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   335
  (* case Some *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   336
apply (simp add: override_Some_iff)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   337
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   338
  apply (simp add: split_beta map_of_map_compMethod)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   339
  apply (simp add: override_def comp_method_result_def map_of_map_compMethod)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   340
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   341
  (* show subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   342
apply (simp add: comp_subcls1) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   343
  (* show is_class G D *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   344
apply (simp add: wf_prog_def wf_cdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   345
apply (subgoal_tac "(C, D, fs, ms)\<in>set G")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   346
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   347
apply (simp add: class_def map_of_SomeD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   348
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   349
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   350
  (* ### this proof is horrid and has to be redone *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   351
lemma unique_map_fst [rule_format]: "(\<forall> x \<in> set xs. (fst x = fst (f x) )) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   352
  unique xs = unique (map f xs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   353
apply (induct_tac "xs")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   354
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   355
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   356
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   357
apply (case_tac a, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   358
apply (case_tac "f (aa, b)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   359
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   360
apply (simp only: unique_Cons)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   361
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   362
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   363
apply (subgoal_tac "(\<exists>y. (ab, y) \<in> set list) = (\<exists>y. (ab, y) \<in> f ` set list)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   364
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   365
apply (rule iffI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   366
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   367
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   368
apply (rule_tac x="(snd (f(ab, y)))" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   369
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   370
apply (subgoal_tac "(ab, snd (f (ab, y))) = (fst (f (ab, y)), snd (f (ab, y)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   371
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   372
apply (simp add: surjective_pairing [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   373
apply (subgoal_tac "fst (f (ab, y)) = fst (ab, y)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   374
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   375
apply (drule bspec) apply assumption apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   376
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   377
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   378
apply (drule bspec) apply assumption apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   379
apply (subgoal_tac "ac = ab")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   380
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   381
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   382
apply (drule sym)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   383
apply (drule sym)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   384
apply (drule_tac f=fst in arg_cong)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   385
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   386
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   387
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   388
lemma comp_unique: "unique G = unique (comp G)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   389
apply (simp add: comp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   390
apply (rule unique_map_fst)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   391
apply (simp add: compClass_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   392
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   393
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   394
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   395
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   396
  (* DIVERSE OTHER LEMMAS *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   397
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   398
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   399
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   400
(* already proved less elegantly in CorrComp.thy;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   401
  to be moved into a common super-theory *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   402
lemma max_spec_preserves_length:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   403
  "max_spec G C (mn, pTs) = {((md,rT),pTs')} 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   404
  \<Longrightarrow> length pTs = length pTs'"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   405
apply (frule max_spec2mheads)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   406
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   407
apply (simp add: list_all2_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   408
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   409
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   410
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   411
(* already proved in CorrComp.thy \<longrightarrow> into common supertheory *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   412
lemma ty_exprs_length [simp]: "(E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   413
apply (subgoal_tac "(E\<turnstile>e::T \<longrightarrow> True) \<and> (E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts) \<and> (E\<turnstile>s\<surd> \<longrightarrow> True)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   414
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   415
apply (rule ty_expr_ty_exprs_wt_stmt.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   416
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   417
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   418
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   419
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   420
lemma max_spec_preserves_method_rT [simp]:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   421
  "max_spec G C (mn, pTs) = {((md,rT),pTs')}
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   422
  \<Longrightarrow> method_rT (the (method (G, C) (mn, pTs'))) = rT"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   423
apply (frule max_spec2mheads)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   424
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   425
apply (simp add: method_rT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   426
done
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
end