src/HOL/IMP/Machines.thy
author huffman
Wed, 18 Feb 2009 15:01:53 -0800
changeset 29981 7d0ed261b712
parent 23746 a455e69c31cc
child 30952 7ab2716dd93b
permissions -rw-r--r--
generalize int_dvd_cancel_factor simproc to idom class
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
     1
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
     2
(* $Id$ *)
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
     3
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14565
diff changeset
     4
theory Machines imports Natural begin
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
     5
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
     6
lemma rtrancl_eq: "R^* = Id \<union> (R O R^*)"
22267
ea31e6ea0e2e Adapted to changes in Transitive_Closure theory.
berghofe
parents: 20503
diff changeset
     7
  by (fast intro: rtrancl_into_rtrancl elim: rtranclE)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
     8
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
     9
lemma converse_rtrancl_eq: "R^* = Id \<union> (R^* O R)"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    10
  by (subst r_comp_rtrancl_eq[symmetric], rule rtrancl_eq)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    11
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    12
lemmas converse_rel_powE = rel_pow_E2
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    13
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    14
lemma R_O_Rn_commute: "R O R^n = R^n O R"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    15
  by (induct n) (simp, simp add: O_assoc [symmetric])
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    16
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    17
lemma converse_in_rel_pow_eq:
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    18
  "((x,z) \<in> R^n) = (n=0 \<and> z=x \<or> (\<exists>m y. n = Suc m \<and> (x,y) \<in> R \<and> (y,z) \<in> R^m))"
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    19
apply(rule iffI)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    20
 apply(blast elim:converse_rel_powE)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    21
apply (fastsimp simp add:gr0_conv_Suc R_O_Rn_commute)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    22
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    23
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    24
lemma rel_pow_plus: "R^(m+n) = R^n O R^m"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    25
  by (induct n) (simp, simp add: O_assoc)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    26
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    27
lemma rel_pow_plusI: "\<lbrakk> (x,y) \<in> R^m; (y,z) \<in> R^n \<rbrakk> \<Longrightarrow> (x,z) \<in> R^(m+n)"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    28
  by (simp add: rel_pow_plus rel_compI)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    29
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    30
subsection "Instructions"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    31
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    32
text {* There are only three instructions: *}
13675
01fc1fc61384 ASIN -> SET
nipkow
parents: 13612
diff changeset
    33
datatype instr = SET loc aexp | JMPF bexp nat | JMPB nat
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    34
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    35
types instrs = "instr list"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    36
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    37
subsection "M0 with PC"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    38
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    39
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    40
  exec01 :: "instr list \<Rightarrow> ((nat\<times>state) \<times> (nat\<times>state))set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    41
  and exec01' :: "[instrs, nat,state, nat,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    42
    ("(_/ \<turnstile> (1\<langle>_,/_\<rangle>)/ -1\<rightarrow> (1\<langle>_,/_\<rangle>))" [50,0,0,0,0] 50)
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    43
  for P :: "instr list"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    44
where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    45
  "p \<turnstile> \<langle>i,s\<rangle> -1\<rightarrow> \<langle>j,t\<rangle> == ((i,s),j,t) : (exec01 p)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    46
| SET: "\<lbrakk> n<size P; P!n = SET x a \<rbrakk> \<Longrightarrow> P \<turnstile> \<langle>n,s\<rangle> -1\<rightarrow> \<langle>Suc n,s[x\<mapsto> a s]\<rangle>"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    47
| JMPFT: "\<lbrakk> n<size P; P!n = JMPF b i;  b s \<rbrakk> \<Longrightarrow> P \<turnstile> \<langle>n,s\<rangle> -1\<rightarrow> \<langle>Suc n,s\<rangle>"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    48
| JMPFF: "\<lbrakk> n<size P; P!n = JMPF b i; \<not>b s; m=n+i+1; m \<le> size P \<rbrakk>
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    49
        \<Longrightarrow> P \<turnstile> \<langle>n,s\<rangle> -1\<rightarrow> \<langle>m,s\<rangle>"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    50
| JMPB:  "\<lbrakk> n<size P; P!n = JMPB i; i \<le> n; j = n-i \<rbrakk> \<Longrightarrow> P \<turnstile> \<langle>n,s\<rangle> -1\<rightarrow> \<langle>j,s\<rangle>"
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    51
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    52
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    53
  exec0s :: "[instrs, nat,state, nat,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    54
    ("(_/ \<turnstile> (1\<langle>_,/_\<rangle>)/ -*\<rightarrow> (1\<langle>_,/_\<rangle>))" [50,0,0,0,0] 50)  where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    55
  "p \<turnstile> \<langle>i,s\<rangle> -*\<rightarrow> \<langle>j,t\<rangle> == ((i,s),j,t) : (exec01 p)^*"
14565
c6dc17aab88a use more symbols in HTML output
kleing
parents: 13675
diff changeset
    56
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    57
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    58
  exec0n :: "[instrs, nat,state, nat, nat,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    59
    ("(_/ \<turnstile> (1\<langle>_,/_\<rangle>)/ -_\<rightarrow> (1\<langle>_,/_\<rangle>))" [50,0,0,0,0] 50)  where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    60
  "p \<turnstile> \<langle>i,s\<rangle> -n\<rightarrow> \<langle>j,t\<rangle> == ((i,s),j,t) : (exec01 p)^n"
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    61
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    62
subsection "M0 with lists"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    63
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    64
text {* We describe execution of programs in the machine by
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    65
  an operational (small step) semantics:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    66
*}
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    67
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    68
types config = "instrs \<times> instrs \<times> state"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    69
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    70
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    71
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    72
  stepa1 :: "(config \<times> config)set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    73
  and stepa1' :: "[instrs,instrs,state, instrs,instrs,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    74
    ("((1\<langle>_,/_,/_\<rangle>)/ -1\<rightarrow> (1\<langle>_,/_,/_\<rangle>))" 50)
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    75
where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    76
  "\<langle>p,q,s\<rangle> -1\<rightarrow> \<langle>p',q',t\<rangle> == ((p,q,s),p',q',t) : stepa1"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    77
| "\<langle>SET x a#p,q,s\<rangle> -1\<rightarrow> \<langle>p,SET x a#q,s[x\<mapsto> a s]\<rangle>"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    78
| "b s \<Longrightarrow> \<langle>JMPF b i#p,q,s\<rangle> -1\<rightarrow> \<langle>p,JMPF b i#q,s\<rangle>"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    79
| "\<lbrakk> \<not> b s; i \<le> size p \<rbrakk>
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    80
   \<Longrightarrow> \<langle>JMPF b i # p, q, s\<rangle> -1\<rightarrow> \<langle>drop i p, rev(take i p) @ JMPF b i # q, s\<rangle>"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    81
| "i \<le> size q
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    82
   \<Longrightarrow> \<langle>JMPB i # p, q, s\<rangle> -1\<rightarrow> \<langle>rev(take i q) @ JMPB i # p, drop i q, s\<rangle>"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    83
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    84
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    85
  stepa :: "[instrs,instrs,state, instrs,instrs,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    86
    ("((1\<langle>_,/_,/_\<rangle>)/ -*\<rightarrow> (1\<langle>_,/_,/_\<rangle>))" 50)  where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    87
  "\<langle>p,q,s\<rangle> -*\<rightarrow> \<langle>p',q',t\<rangle> == ((p,q,s),p',q',t) : (stepa1^*)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    88
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    89
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    90
  stepan :: "[instrs,instrs,state, nat, instrs,instrs,state] \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    91
    ("((1\<langle>_,/_,/_\<rangle>)/ -_\<rightarrow> (1\<langle>_,/_,/_\<rangle>))" 50) where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    92
  "\<langle>p,q,s\<rangle> -i\<rightarrow> \<langle>p',q',t\<rangle> == ((p,q,s),p',q',t) : (stepa1^i)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    93
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22267
diff changeset
    94
inductive_cases execE: "((i#is,p,s), (is',p',s')) : stepa1"
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    95
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    96
lemma exec_simp[simp]:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    97
 "(\<langle>i#p,q,s\<rangle> -1\<rightarrow> \<langle>p',q',t\<rangle>) = (case i of
13675
01fc1fc61384 ASIN -> SET
nipkow
parents: 13612
diff changeset
    98
 SET x a \<Rightarrow> t = s[x\<mapsto> a s] \<and> p' = p \<and> q' = i#q |
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
    99
 JMPF b n \<Rightarrow> t=s \<and> (if b s then p' = p \<and> q' = i#q
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   100
            else n \<le> size p \<and> p' = drop n p \<and> q' = rev(take n p) @ i # q) |
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   101
 JMPB n \<Rightarrow> n \<le> size q \<and> t=s \<and> p' = rev(take n q) @ i # p \<and> q' = drop n q)"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   102
apply(rule iffI)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   103
defer
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   104
apply(clarsimp simp add: stepa1.intros split: instr.split_asm split_if_asm)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   105
apply(erule execE)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   106
apply(simp_all)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   107
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   108
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   109
lemma execn_simp[simp]:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   110
"(\<langle>i#p,q,s\<rangle> -n\<rightarrow> \<langle>p'',q'',u\<rangle>) =
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   111
 (n=0 \<and> p'' = i#p \<and> q'' = q \<and> u = s \<or>
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   112
  ((\<exists>m p' q' t. n = Suc m \<and>
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   113
                \<langle>i#p,q,s\<rangle> -1\<rightarrow> \<langle>p',q',t\<rangle> \<and> \<langle>p',q',t\<rangle> -m\<rightarrow> \<langle>p'',q'',u\<rangle>)))"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   114
by(subst converse_in_rel_pow_eq, simp)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   115
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   116
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   117
lemma exec_star_simp[simp]: "(\<langle>i#p,q,s\<rangle> -*\<rightarrow> \<langle>p'',q'',u\<rangle>) =
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   118
 (p'' = i#p & q''=q & u=s |
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   119
 (\<exists>p' q' t. \<langle>i#p,q,s\<rangle> -1\<rightarrow> \<langle>p',q',t\<rangle> \<and> \<langle>p',q',t\<rangle> -*\<rightarrow> \<langle>p'',q'',u\<rangle>))"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   120
apply(simp add: rtrancl_is_UN_rel_pow del:exec_simp)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   121
apply(blast)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   122
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   123
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   124
declare nth_append[simp]
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   125
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   126
lemma rev_revD: "rev xs = rev ys \<Longrightarrow> xs = ys"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   127
by simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   128
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   129
lemma [simp]: "(rev xs @ rev ys = rev zs) = (ys @ xs = zs)"
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   130
apply(rule iffI)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   131
 apply(rule rev_revD, simp)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   132
apply fastsimp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   133
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   134
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   135
lemma direction1:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   136
 "\<langle>q,p,s\<rangle> -1\<rightarrow> \<langle>q',p',t\<rangle> \<Longrightarrow>
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   137
  rev p' @ q' = rev p @ q \<and> rev p @ q \<turnstile> \<langle>size p,s\<rangle> -1\<rightarrow> \<langle>size p',t\<rangle>"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
   138
apply(induct set: stepa1)
13675
01fc1fc61384 ASIN -> SET
nipkow
parents: 13612
diff changeset
   139
   apply(simp add:exec01.SET)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   140
  apply(fastsimp intro:exec01.JMPFT)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   141
 apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   142
 apply(rule exec01.JMPFF)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   143
     apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   144
    apply fastsimp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   145
   apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   146
  apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   147
 apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   148
apply(fastsimp simp add:exec01.JMPB)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   149
done
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 18372
diff changeset
   150
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   151
(*
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   152
lemma rev_take: "\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)"
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   153
apply(induct xs)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   154
 apply simp_all
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   155
apply(case_tac i)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   156
apply simp_all
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   157
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   158
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   159
lemma rev_drop: "\<And>i. rev (drop i xs) = take (length xs - i) (rev xs)"
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   160
apply(induct xs)
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   161
 apply simp_all
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   162
apply(case_tac i)
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   163
apply simp_all
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   164
done
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   165
*)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 18372
diff changeset
   166
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   167
lemma direction2:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   168
 "rpq \<turnstile> \<langle>sp,s\<rangle> -1\<rightarrow> \<langle>sp',t\<rangle> \<Longrightarrow>
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
   169
  rpq = rev p @ q & sp = size p & sp' = size p' \<longrightarrow>
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   170
          rev p' @ q' = rev p @ q \<longrightarrow> \<langle>q,p,s\<rangle> -1\<rightarrow> \<langle>q',p',t\<rangle>"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20217
diff changeset
   171
apply(induct arbitrary: p q p' q' set: exec01)
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   172
   apply(clarsimp simp add: neq_Nil_conv append_eq_conv_conj)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   173
   apply(drule sym)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   174
   apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   175
   apply(rule rev_revD)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   176
   apply simp
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   177
  apply(clarsimp simp add: neq_Nil_conv append_eq_conv_conj)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   178
  apply(drule sym)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   179
  apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   180
  apply(rule rev_revD)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   181
  apply simp
13612
55d32e76ef4e Adapted to new simplifier.
berghofe
parents: 13098
diff changeset
   182
 apply(simp (no_asm_use) add: neq_Nil_conv append_eq_conv_conj, clarify)+
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   183
 apply(drule sym)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   184
 apply simp
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   185
 apply(rule rev_revD)
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   186
 apply simp
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   187
apply(clarsimp simp add: neq_Nil_conv append_eq_conv_conj)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   188
apply(drule sym)
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   189
apply(simp add:rev_take)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   190
apply(rule rev_revD)
13098
e0644528e21e Better compiler proof
nipkow
parents: 13095
diff changeset
   191
apply(simp add:rev_drop)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   192
done
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   193
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   194
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   195
theorem M_eqiv:
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   196
"(\<langle>q,p,s\<rangle> -1\<rightarrow> \<langle>q',p',t\<rangle>) =
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   197
 (rev p' @ q' = rev p @ q \<and> rev p @ q \<turnstile> \<langle>size p,s\<rangle> -1\<rightarrow> \<langle>size p',t\<rangle>)"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
   198
  by (blast dest: direction1 direction2)
13095
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   199
8ed413a57bdc New machine architecture and other direction of compiler proof.
nipkow
parents:
diff changeset
   200
end