src/HOL/MicroJava/J/WellForm.thy
author kleing
Sat, 16 Nov 2002 22:54:39 +0100
changeset 13717 78f91fcdf560
parent 13672 b95d12325b51
child 14025 d9b155757dc8
permissions -rw-r--r--
beautified "match"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/J/WellForm.thy
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     David von Oheimb
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1999 Technische Universitaet Muenchen
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
     5
*)
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     6
12911
704713ca07ea new document
kleing
parents: 12566
diff changeset
     7
header {* \isaheader{Well-formedness of Java programs} *}
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     8
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
     9
theory WellForm = TypeRel + SystemClasses:
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    10
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    11
text {*
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    12
for static checks on expressions and statements, see WellType.
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    13
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    14
\begin{description}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    15
\item[improvements over Java Specification 1.0 (cf. 8.4.6.3, 8.4.6.4, 9.4.1):]\ \\
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    16
\begin{itemize}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    17
\item a method implementing or overwriting another method may have a result type
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    18
that widens to the result type of the other method (instead of identical type)
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    19
\end{itemize}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    20
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    21
\item[simplifications:]\ \\
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    22
\begin{itemize}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    23
\item for uniformity, Object is assumed to be declared like any other class
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    24
\end{itemize}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    25
\end{description}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    26
*}
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    27
types 'c wf_mb = "'c prog => cname => 'c mdecl => bool"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    28
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    29
constdefs
10069
c7226e6f9625 untabified for HTML
kleing
parents: 10061
diff changeset
    30
 wf_fdecl :: "'c prog => fdecl => bool"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    31
"wf_fdecl G == \<lambda>(fn,ft). is_type G ft"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    32
10069
c7226e6f9625 untabified for HTML
kleing
parents: 10061
diff changeset
    33
 wf_mhead :: "'c prog => sig => ty => bool"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    34
"wf_mhead G == \<lambda>(mn,pTs) rT. (\<forall>T\<in>set pTs. is_type G T) \<and> is_type G rT"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    35
10061
fe82134773dc added HTML syntax; added spaces in normal syntax for better documents
kleing
parents: 10042
diff changeset
    36
 wf_mdecl :: "'c wf_mb => 'c wf_mb"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    37
"wf_mdecl wf_mb G C == \<lambda>(sig,rT,mb). wf_mhead G sig rT \<and> wf_mb G C (sig,rT,mb)"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    38
10061
fe82134773dc added HTML syntax; added spaces in normal syntax for better documents
kleing
parents: 10042
diff changeset
    39
 wf_cdecl :: "'c wf_mb => 'c prog => 'c cdecl => bool"
10042
7164dc0d24d8 unsymbolized
kleing
parents: 8106
diff changeset
    40
"wf_cdecl wf_mb G ==
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    41
   \<lambda>(C,(D,fs,ms)).
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    42
  (\<forall>f\<in>set fs. wf_fdecl G         f) \<and>  unique fs \<and>
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    43
  (\<forall>m\<in>set ms. wf_mdecl wf_mb G C m) \<and>  unique ms \<and>
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    44
  (C \<noteq> Object \<longrightarrow> is_class G D \<and>  \<not>G\<turnstile>D\<preceq>C C \<and>
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    45
                   (\<forall>(sig,rT,b)\<in>set ms. \<forall>D' rT' b'.
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    46
                      method(G,D) sig = Some(D',rT',b') --> G\<turnstile>rT\<preceq>rT'))"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    47
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    48
 wf_syscls :: "'c prog => bool"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    49
"wf_syscls G == let cs = set G in Object \<in> fst ` cs \<and> (\<forall>x. Xcpt x \<in> fst ` cs)"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    50
10061
fe82134773dc added HTML syntax; added spaces in normal syntax for better documents
kleing
parents: 10042
diff changeset
    51
 wf_prog :: "'c wf_mb => 'c prog => bool"
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    52
"wf_prog wf_mb G == 
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    53
   let cs = set G in wf_syscls G \<and> (\<forall>c\<in>cs. wf_cdecl wf_mb G c) \<and> unique G"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    54
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    55
lemma class_wf: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    56
 "[|class G C = Some c; wf_prog wf_mb G|] ==> wf_cdecl wf_mb G (C,c)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    57
apply (unfold wf_prog_def class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    58
apply (simp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    59
apply (fast dest: map_of_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    60
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    61
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    62
lemma class_Object [simp]: 
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    63
  "wf_prog wf_mb G ==> \<exists>X fs ms. class G Object = Some (X,fs,ms)"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    64
apply (unfold wf_prog_def wf_syscls_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    65
apply (auto simp: map_of_SomeI)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    66
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    67
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    68
lemma is_class_Object [simp]: "wf_prog wf_mb G ==> is_class G Object"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    69
apply (unfold is_class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    70
apply (simp (no_asm_simp))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    71
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    72
13051
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    73
lemma is_class_xcpt [simp]: "wf_prog wf_mb G \<Longrightarrow> is_class G (Xcpt x)"
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    74
  apply (simp add: wf_prog_def wf_syscls_def)
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    75
  apply (simp add: is_class_def class_def)
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    76
  apply clarify
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    77
  apply (erule_tac x = x in allE)
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    78
  apply clarify
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    79
  apply (auto intro!: map_of_SomeI)
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    80
  done
8efb5d92cf55 in wellformed programs, exceptions are classes
kleing
parents: 12951
diff changeset
    81
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    82
lemma subcls1_wfD: "[|G\<turnstile>C\<prec>C1D; wf_prog wf_mb G|] ==> D \<noteq> C \<and> \<not>(D,C)\<in>(subcls1 G)^+"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    83
apply( frule r_into_trancl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    84
apply( drule subcls1D)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    85
apply(clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    86
apply( drule (1) class_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    87
apply( unfold wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    88
apply(force simp add: reflcl_trancl [THEN sym] simp del: reflcl_trancl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    89
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    90
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    91
lemma wf_cdecl_supD: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    92
"!!r. \<lbrakk>wf_cdecl wf_mb G (C,D,r); C \<noteq> Object\<rbrakk> \<Longrightarrow> is_class G D"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    93
apply (unfold wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    94
apply (auto split add: option.split_asm)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    95
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    96
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    97
lemma subcls_asym: "[|wf_prog wf_mb G; (C,D)\<in>(subcls1 G)^+|] ==> \<not>(D,C)\<in>(subcls1 G)^+"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    98
apply(erule tranclE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
    99
apply(fast dest!: subcls1_wfD )
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   100
apply(fast dest!: subcls1_wfD intro: trancl_trans)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   101
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   102
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   103
lemma subcls_irrefl: "[|wf_prog wf_mb G; (C,D)\<in>(subcls1 G)^+|] ==> C \<noteq> D"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   104
apply (erule trancl_trans_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   105
apply  (auto dest: subcls1_wfD subcls_asym)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   106
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   107
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   108
lemma acyclic_subcls1: "wf_prog wf_mb G ==> acyclic (subcls1 G)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   109
apply (unfold acyclic_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   110
apply (fast dest: subcls_irrefl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   111
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   112
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   113
lemma wf_subcls1: "wf_prog wf_mb G ==> wf ((subcls1 G)^-1)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   114
apply (rule finite_acyclic_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   115
apply ( subst finite_converse)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   116
apply ( rule finite_subcls1)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   117
apply (subst acyclic_converse)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   118
apply (erule acyclic_subcls1)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   119
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   120
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   121
lemma subcls_induct: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   122
"[|wf_prog wf_mb G; !!C. \<forall>D. (C,D)\<in>(subcls1 G)^+ --> P D ==> P C|] ==> P C"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   123
(is "?A \<Longrightarrow> PROP ?P \<Longrightarrow> _")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   124
proof -
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   125
  assume p: "PROP ?P"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   126
  assume ?A thus ?thesis apply -
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   127
apply(drule wf_subcls1)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   128
apply(drule wf_trancl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   129
apply(simp only: trancl_converse)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   130
apply(erule_tac a = C in wf_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   131
apply(rule p)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   132
apply(auto)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   133
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   134
qed
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   135
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   136
lemma subcls1_induct:
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   137
"[|is_class G C; wf_prog wf_mb G; P Object;  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   138
   !!C D fs ms. [|C \<noteq> Object; is_class G C; class G C = Some (D,fs,ms) \<and>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   139
    wf_cdecl wf_mb G (C,D,fs,ms) \<and> G\<turnstile>C\<prec>C1D \<and> is_class G D \<and> P D|] ==> P C 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   140
 |] ==> P C"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   141
(is "?A \<Longrightarrow> ?B \<Longrightarrow> ?C \<Longrightarrow> PROP ?P \<Longrightarrow> _")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   142
proof -
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   143
  assume p: "PROP ?P"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   144
  assume ?A ?B ?C thus ?thesis apply -
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   145
apply(unfold is_class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   146
apply( rule impE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   147
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   148
apply(   assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   149
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   150
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   151
apply( erule thin_rl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   152
apply( rule subcls_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   153
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   154
apply( rule impI)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   155
apply( case_tac "C = Object")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   156
apply(  fast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   157
apply safe
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   158
apply( frule (1) class_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   159
apply( frule (1) wf_cdecl_supD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   160
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   161
apply( subgoal_tac "G\<turnstile>C\<prec>C1a")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   162
apply( erule_tac [2] subcls1I)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   163
apply(  rule p)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   164
apply (unfold is_class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   165
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   166
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   167
qed
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   168
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   169
lemmas method_rec = wf_subcls1 [THEN [2] method_rec_lemma];
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   170
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   171
lemmas fields_rec = wf_subcls1 [THEN [2] fields_rec_lemma];
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   172
13672
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   173
lemma field_rec: "\<lbrakk>class G C = Some (D, fs, ms); wf_prog wf_mb G\<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   174
\<Longrightarrow> field (G, C) =
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   175
   (if C = Object then empty else field (G, D)) ++
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   176
   map_of (map (\<lambda>(s, f). (s, C, f)) fs)"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   177
apply (simp only: field_def)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   178
apply (frule fields_rec, assumption)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   179
apply (rule HOL.trans)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   180
apply (simp add: o_def)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   181
apply (simp (no_asm_use) 
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   182
  add: split_beta split_def o_def map_compose [THEN sym] del: map_compose)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   183
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   184
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   185
lemma method_Object [simp]:
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   186
  "method (G, Object) sig = Some (D, mh, code) \<Longrightarrow> wf_prog wf_mb G \<Longrightarrow> D = Object"  
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   187
  apply (frule class_Object, clarify)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   188
  apply (drule method_rec, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   189
  apply (auto dest: map_of_SomeD)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   190
  done
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   191
13672
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   192
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   193
lemma fields_Object [simp]: "\<lbrakk> ((vn, C), T) \<in> set (fields (G, Object)); wf_prog wf_mb G \<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   194
  \<Longrightarrow> C = Object"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   195
apply (frule class_Object)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   196
apply clarify
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   197
apply (subgoal_tac "fields (G, Object) = map (\<lambda>(fn,ft). ((fn,Object),ft)) fs")
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   198
apply (simp add: image_iff split_beta)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   199
apply auto
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   200
apply (rule trans)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   201
apply (rule fields_rec, assumption+)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   202
apply simp
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   203
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   204
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   205
lemma subcls_C_Object: "[|is_class G C; wf_prog wf_mb G|] ==> G\<turnstile>C\<preceq>C Object"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   206
apply(erule subcls1_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   207
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   208
apply( fast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   209
apply(auto dest!: wf_cdecl_supD)
12566
fe20540bcf93 renamed rtrancl_into_rtrancl2 to converse_rtrancl_into_rtrancl
nipkow
parents: 12517
diff changeset
   210
apply(erule (1) converse_rtrancl_into_rtrancl)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   211
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   212
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   213
lemma is_type_rTI: "wf_mhead G sig rT ==> is_type G rT"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   214
apply (unfold wf_mhead_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   215
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   216
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   217
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   218
lemma widen_fields_defpl': "[|is_class G C; wf_prog wf_mb G|] ==>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   219
  \<forall>((fn,fd),fT)\<in>set (fields (G,C)). G\<turnstile>C\<preceq>C fd"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   220
apply( erule subcls1_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   221
apply(   assumption)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   222
apply(  frule class_Object)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   223
apply(  clarify)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   224
apply(  frule fields_rec, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   225
apply(  fastsimp)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   226
apply( tactic "safe_tac HOL_cs")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   227
apply( subst fields_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   228
apply(   assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   229
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   230
apply( simp (no_asm) split del: split_if)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   231
apply( rule ballI)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   232
apply( simp (no_asm_simp) only: split_tupled_all)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   233
apply( simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   234
apply( erule UnE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   235
apply(  force)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   236
apply( erule r_into_rtrancl [THEN rtrancl_trans])
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   237
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   238
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   239
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   240
lemma widen_fields_defpl: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   241
  "[|((fn,fd),fT) \<in> set (fields (G,C)); wf_prog wf_mb G; is_class G C|] ==>  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   242
  G\<turnstile>C\<preceq>C fd"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   243
apply( drule (1) widen_fields_defpl')
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   244
apply (fast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   245
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   246
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   247
lemma unique_fields: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   248
  "[|is_class G C; wf_prog wf_mb G|] ==> unique (fields (G,C))"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   249
apply( erule subcls1_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   250
apply(   assumption)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   251
apply(  frule class_Object)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   252
apply(  clarify)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   253
apply(  frule fields_rec, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   254
apply(  drule class_wf, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   255
apply(  simp add: wf_cdecl_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   256
apply(  rule unique_map_inj)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   257
apply(   simp)
13585
db4005b40cc6 Converted Fun to Isar style.
paulson
parents: 13051
diff changeset
   258
apply(  rule inj_onI)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   259
apply(  simp)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   260
apply( safe dest!: wf_cdecl_supD)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   261
apply( drule subcls1_wfD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   262
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   263
apply( subst fields_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   264
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   265
apply( rotate_tac -1)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   266
apply( frule class_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   267
apply  auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   268
apply( simp add: wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   269
apply( erule unique_append)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   270
apply(  rule unique_map_inj)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   271
apply(   clarsimp)
13585
db4005b40cc6 Converted Fun to Isar style.
paulson
parents: 13051
diff changeset
   272
apply  (rule inj_onI)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   273
apply(  simp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   274
apply(auto dest!: widen_fields_defpl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   275
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   276
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   277
lemma fields_mono_lemma [rule_format (no_asm)]: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   278
  "[|wf_prog wf_mb G; (C',C)\<in>(subcls1 G)^*|] ==>  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   279
  x \<in> set (fields (G,C)) --> x \<in> set (fields (G,C'))"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   280
apply(erule converse_rtrancl_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   281
apply( safe dest!: subcls1D)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   282
apply(subst fields_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   283
apply(  auto)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   284
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   285
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   286
lemma fields_mono: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   287
"\<lbrakk>map_of (fields (G,C)) fn = Some f; G\<turnstile>D\<preceq>C C; is_class G D; wf_prog wf_mb G\<rbrakk> 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   288
  \<Longrightarrow> map_of (fields (G,D)) fn = Some f"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   289
apply (rule map_of_SomeI)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   290
apply  (erule (1) unique_fields)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   291
apply (erule (1) fields_mono_lemma)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   292
apply (erule map_of_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   293
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   294
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   295
lemma widen_cfs_fields: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   296
"[|field (G,C) fn = Some (fd, fT); G\<turnstile>D\<preceq>C C; wf_prog wf_mb G|]==>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   297
  map_of (fields (G,D)) (fn, fd) = Some fT"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   298
apply (drule field_fields)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   299
apply (drule rtranclD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   300
apply safe
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   301
apply (frule subcls_is_class)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   302
apply (drule trancl_into_rtrancl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   303
apply (fast dest: fields_mono)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   304
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   305
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   306
lemma method_wf_mdecl [rule_format (no_asm)]: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   307
  "wf_prog wf_mb G ==> is_class G C \<Longrightarrow>   
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   308
     method (G,C) sig = Some (md,mh,m) 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   309
   --> G\<turnstile>C\<preceq>C md \<and> wf_mdecl wf_mb G md (sig,(mh,m))"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   310
apply( erule subcls1_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   311
apply(   assumption)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   312
apply(  clarify) 
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   313
apply(  frule class_Object)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   314
apply(  clarify)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   315
apply(  frule method_rec, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   316
apply(  drule class_wf, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   317
apply(  simp add: wf_cdecl_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   318
apply(  drule map_of_SomeD)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   319
apply(  subgoal_tac "md = Object")
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   320
apply(   fastsimp)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   321
apply(  fastsimp)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   322
apply( clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   323
apply( frule_tac C = C in method_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   324
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   325
apply( rotate_tac -1)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   326
apply( simp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   327
apply( drule override_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   328
apply( erule disjE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   329
apply(  erule_tac V = "?P --> ?Q" in thin_rl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   330
apply (frule map_of_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   331
apply (clarsimp simp add: wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   332
apply( clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   333
apply( rule rtrancl_trans)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   334
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   335
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   336
apply( rule r_into_rtrancl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   337
apply( fast intro: subcls1I)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   338
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   339
13672
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   340
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   341
lemma wf_prog_wf_mhead: "\<lbrakk> wf_prog wf_mb G; (C, D, fds, mths) \<in> set G;
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   342
  ((mn, pTs), rT, jmb) \<in> set mths \<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   343
  \<Longrightarrow> wf_mhead G (mn, pTs) rT"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   344
apply (simp add: wf_prog_def wf_cdecl_def)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   345
apply (erule conjE)+
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   346
apply (drule bspec, assumption)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   347
apply simp
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   348
apply (erule conjE)+
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   349
apply (drule bspec, assumption)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   350
apply (simp add: wf_mdecl_def)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   351
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   352
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   353
lemma subcls_widen_methd [rule_format (no_asm)]: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   354
  "[|G\<turnstile>T\<preceq>C T'; wf_prog wf_mb G|] ==>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   355
   \<forall>D rT b. method (G,T') sig = Some (D,rT ,b) --> 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   356
  (\<exists>D' rT' b'. method (G,T) sig = Some (D',rT',b') \<and> G\<turnstile>rT'\<preceq>rT)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   357
apply( drule rtranclD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   358
apply( erule disjE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   359
apply(  fast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   360
apply( erule conjE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   361
apply( erule trancl_trans_induct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   362
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   363
apply(  clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   364
apply(  drule spec, drule spec, drule spec, erule (1) impE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   365
apply(  fast elim: widen_trans)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   366
apply( clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   367
apply( drule subcls1D)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   368
apply( clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   369
apply( subst method_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   370
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   371
apply( unfold override_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   372
apply( simp (no_asm_simp) del: split_paired_Ex)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   373
apply( case_tac "\<exists>z. map_of(map (\<lambda>(s,m). (s, ?C, m)) ms) sig = Some z")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   374
apply(  erule exE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   375
apply(  rotate_tac -1, frule ssubst, erule_tac [2] asm_rl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   376
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   377
apply(  rotate_tac -1, frule ssubst, erule_tac [2] asm_rl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   378
apply(  tactic "asm_full_simp_tac (HOL_ss addsimps [not_None_eq RS sym]) 1")
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   379
apply(  simp_all (no_asm_simp) del: split_paired_Ex)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   380
apply( drule (1) class_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   381
apply( simp (no_asm_simp) only: split_tupled_all)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   382
apply( unfold wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   383
apply( drule map_of_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   384
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   385
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   386
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   387
lemma subtype_widen_methd: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   388
 "[| G\<turnstile> C\<preceq>C D; wf_prog wf_mb G;  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   389
     method (G,D) sig = Some (md, rT, b) |]  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   390
  ==> \<exists>mD' rT' b'. method (G,C) sig= Some(mD',rT',b') \<and> G\<turnstile>rT'\<preceq>rT"
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   391
apply(auto dest: subcls_widen_methd method_wf_mdecl 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   392
           simp add: wf_mdecl_def wf_mhead_def split_def)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   393
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   394
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   395
lemma method_in_md [rule_format (no_asm)]: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   396
  "wf_prog wf_mb G ==> is_class G C \<Longrightarrow> \<forall>D. method (G,C) sig = Some(D,mh,code) 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   397
  --> is_class G D \<and> method (G,D) sig = Some(D,mh,code)"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   398
apply (erule (1) subcls1_induct)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   399
 apply clarify
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   400
 apply (frule method_Object, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   401
 apply hypsubst
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   402
 apply simp
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   403
apply (erule conjE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   404
apply (subst method_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   405
  apply (assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   406
 apply (assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   407
apply (clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   408
apply (erule_tac "x" = "Da" in allE)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   409
apply (clarsimp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   410
 apply (simp add: map_of_map)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   411
 apply (clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   412
 apply (subst method_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   413
   apply (assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   414
  apply (assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   415
 apply (simp add: override_def map_of_map split add: option.split)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   416
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   417
13672
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   418
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   419
lemma fields_in_fd [rule_format (no_asm)]: "\<lbrakk> wf_prog wf_mb G; is_class G C\<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   420
  \<Longrightarrow> \<forall> vn D T. (((vn,D),T) \<in> set (fields (G,C))
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   421
  \<longrightarrow> (is_class G D \<and> ((vn,D),T) \<in> set (fields (G,D))))"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   422
apply (erule (1) subcls1_induct)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   423
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   424
apply clarify
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   425
apply (frule fields_Object, assumption+)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   426
apply (simp only: is_class_Object) apply simp
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   427
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   428
apply clarify
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   429
apply (frule fields_rec)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   430
apply assumption
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   431
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   432
apply (case_tac "Da=C")
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   433
apply blast			(* case Da=C *)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   434
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   435
apply (subgoal_tac "((vn, Da), T) \<in> set (fields (G, D))") apply blast
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   436
apply (erule thin_rl)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   437
apply (rotate_tac 1)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   438
apply (erule thin_rl, erule thin_rl, erule thin_rl, 
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   439
      erule thin_rl, erule thin_rl, erule thin_rl)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   440
apply auto
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   441
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   442
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   443
lemma field_in_fd [rule_format (no_asm)]: "\<lbrakk> wf_prog wf_mb G; is_class G C\<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   444
  \<Longrightarrow> \<forall> vn D T. (field (G,C) vn = Some(D,T) 
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   445
  \<longrightarrow> is_class G D \<and> field (G,D) vn = Some(D,T))"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   446
apply (erule (1) subcls1_induct)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   447
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   448
apply clarify
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   449
apply (frule field_fields)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   450
apply (drule map_of_SomeD)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   451
apply (drule fields_Object, assumption+)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   452
apply simp
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   453
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   454
apply clarify
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   455
apply (subgoal_tac "((field (G, D)) ++ map_of (map (\<lambda>(s, f). (s, C, f)) fs)) vn = Some (Da, T)")
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   456
apply (simp (no_asm_use) only:  override_Some_iff)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   457
apply (erule disjE)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   458
apply (simp (no_asm_use) add: map_of_map) apply blast
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   459
apply blast
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   460
apply (rule trans [THEN sym], rule sym, assumption)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   461
apply (rule_tac x=vn in fun_cong)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   462
apply (rule trans, rule field_rec, assumption+)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   463
apply (simp (no_asm_use)) apply blast
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   464
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   465
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   466
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   467
lemma widen_methd: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   468
"[| method (G,C) sig = Some (md,rT,b); wf_prog wf_mb G; G\<turnstile>T''\<preceq>C C|] 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   469
  ==> \<exists>md' rT' b'. method (G,T'') sig = Some (md',rT',b') \<and> G\<turnstile>rT'\<preceq>rT"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   470
apply( drule subcls_widen_methd)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   471
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   472
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   473
13672
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   474
lemma widen_field: "\<lbrakk> (field (G,C) fn) = Some (fd, fT); wf_prog wf_mb G; is_class G C \<rbrakk>
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   475
  \<Longrightarrow> G\<turnstile>C\<preceq>C fd"
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   476
apply (rule widen_fields_defpl)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   477
apply (simp add: field_def)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   478
apply (rule map_of_SomeD)
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   479
apply (rule table_of_remap_SomeD) 
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   480
apply assumption+
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   481
done
b95d12325b51 Added compiler
streckem
parents: 13585
diff changeset
   482
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   483
lemma Call_lemma: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   484
"[|method (G,C) sig = Some (md,rT,b); G\<turnstile>T''\<preceq>C C; wf_prog wf_mb G;  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   485
  class G C = Some y|] ==> \<exists>T' rT' b. method (G,T'') sig = Some (T',rT',b) \<and>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   486
  G\<turnstile>rT'\<preceq>rT \<and> G\<turnstile>T''\<preceq>C T' \<and> wf_mhead G sig rT' \<and> wf_mb G T' (sig,rT',b)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   487
apply( drule (2) widen_methd)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   488
apply( clarify)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   489
apply( frule subcls_is_class2)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   490
apply (unfold is_class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   491
apply (simp (no_asm_simp))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   492
apply( drule method_wf_mdecl)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   493
apply( unfold wf_mdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   494
apply( unfold is_class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   495
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   496
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   497
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   498
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   499
lemma fields_is_type_lemma [rule_format (no_asm)]: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   500
  "[|is_class G C; wf_prog wf_mb G|] ==>  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   501
  \<forall>f\<in>set (fields (G,C)). is_type G (snd f)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   502
apply( erule (1) subcls1_induct)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   503
apply(  frule class_Object)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   504
apply(  clarify)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   505
apply(  frule fields_rec, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   506
apply(  drule class_wf, assumption)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   507
apply(  simp add: wf_cdecl_def wf_fdecl_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   508
apply(  fastsimp)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   509
apply( subst fields_rec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   510
apply(   fast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   511
apply(  assumption)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   512
apply( clarsimp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   513
apply( safe)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   514
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   515
apply(  force)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   516
apply( drule (1) class_wf)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   517
apply( unfold wf_cdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   518
apply( clarsimp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   519
apply( drule (1) bspec)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   520
apply( unfold wf_fdecl_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   521
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   522
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   523
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   524
lemma fields_is_type: 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   525
  "[|map_of (fields (G,C)) fn = Some f; wf_prog wf_mb G; is_class G C|] ==>  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   526
  is_type G f"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   527
apply(drule map_of_SomeD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   528
apply(drule (2) fields_is_type_lemma)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   529
apply(auto)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   530
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   531
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   532
lemma methd:
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   533
  "[| wf_prog wf_mb G; (C,S,fs,mdecls) \<in> set G; (sig,rT,code) \<in> set mdecls |]
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   534
  ==> method (G,C) sig = Some(C,rT,code) \<and> is_class G C"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   535
proof -
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   536
  assume wf: "wf_prog wf_mb G" and C:  "(C,S,fs,mdecls) \<in> set G" and
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   537
         m: "(sig,rT,code) \<in> set mdecls"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   538
  moreover
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   539
  from wf C have "class G C = Some (S,fs,mdecls)"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   540
    by (auto simp add: wf_prog_def class_def is_class_def intro: map_of_SomeI)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   541
  moreover
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   542
  from wf C 
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   543
  have "unique mdecls" by (unfold wf_prog_def wf_cdecl_def) auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   544
  hence "unique (map (\<lambda>(s,m). (s,C,m)) mdecls)" by (induct mdecls, auto)  
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   545
  with m 
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   546
  have "map_of (map (\<lambda>(s,m). (s,C,m)) mdecls) sig = Some (C,rT,code)"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   547
    by (force intro: map_of_SomeI)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   548
  ultimately
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11070
diff changeset
   549
  show ?thesis by (auto simp add: is_class_def dest: method_rec)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10613
diff changeset
   550
qed
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
   551
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   552
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   553
lemma wf_mb'E:
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   554
  "\<lbrakk> wf_prog wf_mb G; \<And>C S fs ms m.\<lbrakk>(C,S,fs,ms) \<in> set G; m \<in> set ms\<rbrakk> \<Longrightarrow> wf_mb' G C m \<rbrakk>
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   555
  \<Longrightarrow> wf_prog wf_mb' G"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   556
  apply (simp add: wf_prog_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   557
  apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   558
  apply (simp add: wf_cdecl_def wf_mdecl_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   559
  apply safe
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   560
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   561
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   562
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   563
  apply clarify apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   564
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   565
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   566
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   567
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   568
  apply (drule bspec, assumption) apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   569
  apply clarify apply (drule bspec, assumption)+ apply simp
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   570
  done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   571
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   572
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   573
lemma fst_mono: "A \<subseteq> B \<Longrightarrow> fst ` A \<subseteq> fst ` B" by fast
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   574
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   575
lemma wf_syscls:
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   576
  "set SystemClasses \<subseteq> set G \<Longrightarrow> wf_syscls G"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   577
  apply (drule fst_mono)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   578
  apply (simp add: SystemClasses_def wf_syscls_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   579
  apply (simp add: ObjectC_def) 
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   580
  apply (rule allI, case_tac x)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   581
  apply (auto simp add: NullPointerC_def ClassCastC_def OutOfMemoryC_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   582
  done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   583
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
   584
end