src/HOL/IMP/Compiler.thy
changeset 61147 263a354329e9
parent 60542 c5953e3a1e4f
child 67406 23307fd33906
equal deleted inserted replaced
61146:6fced6d926be 61147:263a354329e9
    79 abbreviation 
    79 abbreviation 
    80   exec :: "instr list \<Rightarrow> config \<Rightarrow> config \<Rightarrow> bool" ("(_/ \<turnstile> (_ \<rightarrow>*/ _))" 50)
    80   exec :: "instr list \<Rightarrow> config \<Rightarrow> config \<Rightarrow> bool" ("(_/ \<turnstile> (_ \<rightarrow>*/ _))" 50)
    81 where
    81 where
    82   "exec P \<equiv> star (exec1 P)"
    82   "exec P \<equiv> star (exec1 P)"
    83 
    83 
    84 declare star.step[intro]
       
    85 
       
    86 lemmas exec_induct = star.induct [of "exec1 P", split_format(complete)]
    84 lemmas exec_induct = star.induct [of "exec1 P", split_format(complete)]
    87 
    85 
    88 code_pred exec1 by (metis exec1_def)
    86 code_pred exec1 by (metis exec1_def)
    89 
    87 
    90 values
    88 values
   105 
   103 
   106 lemma exec1_appendR: "P \<turnstile> c \<rightarrow> c' \<Longrightarrow> P@P' \<turnstile> c \<rightarrow> c'"
   104 lemma exec1_appendR: "P \<turnstile> c \<rightarrow> c' \<Longrightarrow> P@P' \<turnstile> c \<rightarrow> c'"
   107 by (auto simp: exec1_def)
   105 by (auto simp: exec1_def)
   108 
   106 
   109 lemma exec_appendR: "P \<turnstile> c \<rightarrow>* c' \<Longrightarrow> P@P' \<turnstile> c \<rightarrow>* c'"
   107 lemma exec_appendR: "P \<turnstile> c \<rightarrow>* c' \<Longrightarrow> P@P' \<turnstile> c \<rightarrow>* c'"
   110 by (induction rule: star.induct) (fastforce intro: exec1_appendR)+
   108 by (induction rule: star.induct) (fastforce intro: star.step exec1_appendR)+
   111 
   109 
   112 lemma exec1_appendL:
   110 lemma exec1_appendL:
   113   fixes i i' :: int 
   111   fixes i i' :: int 
   114   shows
   112   shows
   115   "P \<turnstile> (i,s,stk) \<rightarrow> (i',s',stk') \<Longrightarrow>
   113   "P \<turnstile> (i,s,stk) \<rightarrow> (i',s',stk') \<Longrightarrow>
   120 lemma exec_appendL:
   118 lemma exec_appendL:
   121   fixes i i' :: int 
   119   fixes i i' :: int 
   122   shows
   120   shows
   123  "P \<turnstile> (i,s,stk) \<rightarrow>* (i',s',stk')  \<Longrightarrow>
   121  "P \<turnstile> (i,s,stk) \<rightarrow>* (i',s',stk')  \<Longrightarrow>
   124   P' @ P \<turnstile> (size(P')+i,s,stk) \<rightarrow>* (size(P')+i',s',stk')"
   122   P' @ P \<turnstile> (size(P')+i,s,stk) \<rightarrow>* (size(P')+i',s',stk')"
   125   by (induction rule: exec_induct) (blast intro!: exec1_appendL)+
   123   by (induction rule: exec_induct) (blast intro: star.step exec1_appendL)+
   126 
   124 
   127 text{* Now we specialise the above lemmas to enable automatic proofs of
   125 text{* Now we specialise the above lemmas to enable automatic proofs of
   128 @{prop "P \<turnstile> c \<rightarrow>* c'"} where @{text P} is a mixture of concrete instructions and
   126 @{prop "P \<turnstile> c \<rightarrow>* c'"} where @{text P} is a mixture of concrete instructions and
   129 pieces of code that we already know how they execute (by induction), combined
   127 pieces of code that we already know how they execute (by induction), combined
   130 by @{text "@"} and @{text "#"}. Backward jumps are not supported.
   128 by @{text "@"} and @{text "#"}. Backward jumps are not supported.