src/HOL/MicroJava/Comp/DefsComp.thy
author bulwahn
Thu, 12 Nov 2009 20:38:57 +0100
changeset 33649 854173fcd21c
parent 15481 fc075ae929e4
child 35416 d8d7d1b785af
permissions -rw-r--r--
added a tabled implementation of the reflexive transitive closure
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/DefsComp.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
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     5
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     6
(* Definitions for accessing parts of methods, states etc. *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     7
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14981
diff changeset
     8
theory DefsComp
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14981
diff changeset
     9
imports "../JVM/JVMExec"
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14981
diff changeset
    10
begin
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    11
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    12
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    13
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    14
  method_rT :: "cname \<times> ty \<times> 'c \<Rightarrow> ty"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    15
  "method_rT mtd == (fst (snd mtd))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    16
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    17
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    18
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    19
(* g = get *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    20
  gx :: "xstate \<Rightarrow> val option"  "gx \<equiv> fst"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    21
  gs :: "xstate \<Rightarrow> state"  "gs \<equiv> snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    22
  gh :: "xstate \<Rightarrow> aheap"        "gh \<equiv> fst\<circ>snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    23
  gl :: "xstate \<Rightarrow> State.locals" "gl \<equiv> snd\<circ>snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    24
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    25
  gmb :: "'a prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> 'a"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    26
    "gmb G cn si \<equiv> snd(snd(the(method (G,cn) si)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    27
  gis :: "jvm_method \<Rightarrow> bytecode"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    28
    "gis \<equiv> fst \<circ> snd \<circ> snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    29
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    30
(* jmb = aus einem JavaMaethodBody *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    31
  gjmb_pns  :: "java_mb \<Rightarrow> vname list"     "gjmb_pns \<equiv> fst"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    32
  gjmb_lvs  :: "java_mb \<Rightarrow> (vname\<times>ty)list" "gjmb_lvs \<equiv> fst\<circ>snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    33
  gjmb_blk  :: "java_mb \<Rightarrow> stmt"           "gjmb_blk \<equiv> fst\<circ>snd\<circ>snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    34
  gjmb_res  :: "java_mb \<Rightarrow> expr"           "gjmb_res \<equiv> snd\<circ>snd\<circ>snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    35
  gjmb_plns :: "java_mb \<Rightarrow> vname list"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    36
    "gjmb_plns \<equiv> \<lambda>jmb. gjmb_pns jmb @ map fst (gjmb_lvs jmb)"
14653
0848ab6fe5fc constdefs: proper order;
wenzelm
parents: 13673
diff changeset
    37
0848ab6fe5fc constdefs: proper order;
wenzelm
parents: 13673
diff changeset
    38
  glvs :: "java_mb \<Rightarrow> State.locals \<Rightarrow> locvars"
0848ab6fe5fc constdefs: proper order;
wenzelm
parents: 13673
diff changeset
    39
    "glvs jmb loc \<equiv> map (the\<circ>loc) (gjmb_plns jmb)"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    40
  
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    41
lemmas gdefs = gx_def gh_def gl_def gmb_def gis_def glvs_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    42
lemmas gjmbdefs = gjmb_pns_def gjmb_lvs_def gjmb_blk_def gjmb_res_def gjmb_plns_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    43
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    44
lemmas galldefs = gdefs gjmbdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    45
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    46
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    47
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    48
constdefs 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    49
  locvars_locals :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> State.locals \<Rightarrow> locvars"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    50
  "locvars_locals G C S lvs == the (lvs This) # glvs (gmb G C S) lvs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    51
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    52
  locals_locvars :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> locvars \<Rightarrow> State.locals"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    53
  "locals_locvars G C S lvs == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    54
  empty ((gjmb_plns (gmb G C S))[\<mapsto>](tl lvs)) (This\<mapsto>(hd lvs))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    55
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    56
  locvars_xstate :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> xstate \<Rightarrow> locvars"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    57
  "locvars_xstate G C S xs == locvars_locals G C S (gl xs)"
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 locvars_xstate_par_dep: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    61
  "lv1 = lv2 \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    62
  locvars_xstate G C S (xcpt1, hp1, lv1) = locvars_xstate G C S (xcpt2, hp2, lv2)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    63
by (simp add: locvars_xstate_def gl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    64
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    65
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    66
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    67
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    68
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    69
(* Conversions *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    70
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    71
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    72
lemma gx_conv [simp]: "gx (xcpt, s) = xcpt" by (simp add: gx_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    73
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    74
lemma gh_conv [simp]: "gh (xcpt, h, l) = h" by (simp add: gh_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    75
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    76
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    77
end