src/HOL/IMP/Small_Step.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 45415 bf39b07a7a8e
child 47818 151d137f1095
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     1
header "Small-Step Semantics of Commands"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     2
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     3
theory Small_Step imports Star Big_Step begin
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     4
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     5
subsection "The transition relation"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     6
45415
bf39b07a7a8e more fragments to export, removed the one from Com
kleing
parents: 45265
diff changeset
     7
text_raw{*\begin{isaverbatimwrite}\newcommand{\SmallStepDef}{% *}
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     8
inductive
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
     9
  small_step :: "com * state \<Rightarrow> com * state \<Rightarrow> bool" (infix "\<rightarrow>" 55)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    10
where
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    11
Assign:  "(x ::= a, s) \<rightarrow> (SKIP, s(x := aval a s))" |
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    12
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    13
Semi1:   "(SKIP;c\<^isub>2,s) \<rightarrow> (c\<^isub>2,s)" |
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    14
Semi2:   "(c\<^isub>1,s) \<rightarrow> (c\<^isub>1',s') \<Longrightarrow> (c\<^isub>1;c\<^isub>2,s) \<rightarrow> (c\<^isub>1';c\<^isub>2,s')" |
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    15
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    16
IfTrue:  "bval b s \<Longrightarrow> (IF b THEN c\<^isub>1 ELSE c\<^isub>2,s) \<rightarrow> (c\<^isub>1,s)" |
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    17
IfFalse: "\<not>bval b s \<Longrightarrow> (IF b THEN c\<^isub>1 ELSE c\<^isub>2,s) \<rightarrow> (c\<^isub>2,s)" |
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    18
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    19
While:   "(WHILE b DO c,s) \<rightarrow> (IF b THEN c; WHILE b DO c ELSE SKIP,s)"
45415
bf39b07a7a8e more fragments to export, removed the one from Com
kleing
parents: 45265
diff changeset
    20
text_raw{*}\end{isaverbatimwrite}*}
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    21
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    22
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    23
abbreviation small_steps :: "com * state \<Rightarrow> com * state \<Rightarrow> bool" (infix "\<rightarrow>*" 55)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    24
where "x \<rightarrow>* y == star small_step x y"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    25
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    26
subsection{* Executability *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    27
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    28
code_pred small_step .
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    29
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    30
values "{(c',map t [''x'',''y'',''z'']) |c' t.
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    31
   (''x'' ::= V ''z''; ''y'' ::= V ''x'',
44036
d03f9f28d01d new state syntax with less conflicts
kleing
parents: 43158
diff changeset
    32
    <''x'' := 3, ''y'' := 7, ''z'' := 5>) \<rightarrow>* (c',t)}"
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    33
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    34
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    35
subsection{* Proof infrastructure *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    36
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    37
subsubsection{* Induction rules *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    38
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    39
text{* The default induction rule @{thm[source] small_step.induct} only works
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    40
for lemmas of the form @{text"a \<rightarrow> b \<Longrightarrow> \<dots>"} where @{text a} and @{text b} are
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    41
not already pairs @{text"(DUMMY,DUMMY)"}. We can generate a suitable variant
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    42
of @{thm[source] small_step.induct} for pairs by ``splitting'' the arguments
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    43
@{text"\<rightarrow>"} into pairs: *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    44
lemmas small_step_induct = small_step.induct[split_format(complete)]
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    45
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    46
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    47
subsubsection{* Proof automation *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    48
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    49
declare small_step.intros[simp,intro]
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    50
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    51
text{* Rule inversion: *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    52
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    53
inductive_cases SkipE[elim!]: "(SKIP,s) \<rightarrow> ct"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    54
thm SkipE
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    55
inductive_cases AssignE[elim!]: "(x::=a,s) \<rightarrow> ct"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    56
thm AssignE
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    57
inductive_cases SemiE[elim]: "(c1;c2,s) \<rightarrow> ct"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    58
thm SemiE
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    59
inductive_cases IfE[elim!]: "(IF b THEN c1 ELSE c2,s) \<rightarrow> ct"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    60
inductive_cases WhileE[elim]: "(WHILE b DO c, s) \<rightarrow> ct"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    61
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    62
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    63
text{* A simple property: *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    64
lemma deterministic:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    65
  "cs \<rightarrow> cs' \<Longrightarrow> cs \<rightarrow> cs'' \<Longrightarrow> cs'' = cs'"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
    66
apply(induction arbitrary: cs'' rule: small_step.induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    67
apply blast+
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    68
done
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    69
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    70
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    71
subsection "Equivalence with big-step semantics"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    72
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    73
lemma star_semi2: "(c1,s) \<rightarrow>* (c1',s') \<Longrightarrow> (c1;c2,s) \<rightarrow>* (c1';c2,s')"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
    74
proof(induction rule: star_induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    75
  case refl thus ?case by simp
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    76
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    77
  case step
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    78
  thus ?case by (metis Semi2 star.step)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    79
qed
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    80
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    81
lemma semi_comp:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    82
  "\<lbrakk> (c1,s1) \<rightarrow>* (SKIP,s2); (c2,s2) \<rightarrow>* (SKIP,s3) \<rbrakk>
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    83
   \<Longrightarrow> (c1;c2, s1) \<rightarrow>* (SKIP,s3)"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    84
by(blast intro: star.step star_semi2 star_trans)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    85
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    86
text{* The following proof corresponds to one on the board where one would
45218
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
    87
show chains of @{text "\<rightarrow>"} and @{text "\<rightarrow>*"} steps. *}
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    88
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    89
lemma big_to_small:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    90
  "cs \<Rightarrow> t \<Longrightarrow> cs \<rightarrow>* (SKIP,t)"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
    91
proof (induction rule: big_step.induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    92
  fix s show "(SKIP,s) \<rightarrow>* (SKIP,s)" by simp
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    93
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    94
  fix x a s show "(x ::= a,s) \<rightarrow>* (SKIP, s(x := aval a s))" by auto
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    95
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    96
  fix c1 c2 s1 s2 s3
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    97
  assume "(c1,s1) \<rightarrow>* (SKIP,s2)" and "(c2,s2) \<rightarrow>* (SKIP,s3)"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    98
  thus "(c1;c2, s1) \<rightarrow>* (SKIP,s3)" by (rule semi_comp)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
    99
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   100
  fix s::state and b c0 c1 t
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   101
  assume "bval b s"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   102
  hence "(IF b THEN c0 ELSE c1,s) \<rightarrow> (c0,s)" by simp
45218
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   103
  moreover assume "(c0,s) \<rightarrow>* (SKIP,t)"
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   104
  ultimately 
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   105
  show "(IF b THEN c0 ELSE c1,s) \<rightarrow>* (SKIP,t)" by (metis star.simps)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   106
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   107
  fix s::state and b c0 c1 t
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   108
  assume "\<not>bval b s"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   109
  hence "(IF b THEN c0 ELSE c1,s) \<rightarrow> (c1,s)" by simp
45218
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   110
  moreover assume "(c1,s) \<rightarrow>* (SKIP,t)"
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   111
  ultimately 
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   112
  show "(IF b THEN c0 ELSE c1,s) \<rightarrow>* (SKIP,t)" by (metis star.simps)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   113
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   114
  fix b c and s::state
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   115
  assume b: "\<not>bval b s"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   116
  let ?if = "IF b THEN c; WHILE b DO c ELSE SKIP"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   117
  have "(WHILE b DO c,s) \<rightarrow> (?if, s)" by blast
45218
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   118
  moreover have "(?if,s) \<rightarrow> (SKIP, s)" by (simp add: b)
45265
521508e85c0d tuned names to avoid shadowing
nipkow
parents: 45218
diff changeset
   119
  ultimately show "(WHILE b DO c,s) \<rightarrow>* (SKIP,s)" by(metis star.refl star.step)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   120
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   121
  fix b c s s' t
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   122
  let ?w  = "WHILE b DO c"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   123
  let ?if = "IF b THEN c; ?w ELSE SKIP"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   124
  assume w: "(?w,s') \<rightarrow>* (SKIP,t)"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   125
  assume c: "(c,s) \<rightarrow>* (SKIP,s')"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   126
  assume b: "bval b s"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   127
  have "(?w,s) \<rightarrow> (?if, s)" by blast
45218
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   128
  moreover have "(?if, s) \<rightarrow> (c; ?w, s)" by (simp add: b)
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   129
  moreover have "(c; ?w,s) \<rightarrow>* (SKIP,t)" by(rule semi_comp[OF c w])
f115540543d8 removed [trans] concept from basic material
kleing
parents: 45114
diff changeset
   130
  ultimately show "(WHILE b DO c,s) \<rightarrow>* (SKIP,t)" by (metis star.simps)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   131
qed
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   132
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   133
text{* Each case of the induction can be proved automatically: *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   134
lemma  "cs \<Rightarrow> t \<Longrightarrow> cs \<rightarrow>* (SKIP,t)"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
   135
proof (induction rule: big_step.induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   136
  case Skip show ?case by blast
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   137
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   138
  case Assign show ?case by blast
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   139
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   140
  case Semi thus ?case by (blast intro: semi_comp)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   141
next
45265
521508e85c0d tuned names to avoid shadowing
nipkow
parents: 45218
diff changeset
   142
  case IfTrue thus ?case by (blast intro: star.step)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   143
next
45265
521508e85c0d tuned names to avoid shadowing
nipkow
parents: 45218
diff changeset
   144
  case IfFalse thus ?case by (blast intro: star.step)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   145
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   146
  case WhileFalse thus ?case
45265
521508e85c0d tuned names to avoid shadowing
nipkow
parents: 45218
diff changeset
   147
    by (metis star.step star_step1 small_step.IfFalse small_step.While)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   148
next
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   149
  case WhileTrue
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   150
  thus ?case
45265
521508e85c0d tuned names to avoid shadowing
nipkow
parents: 45218
diff changeset
   151
    by(metis While semi_comp small_step.IfTrue star.step[of small_step])
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   152
qed
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   153
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   154
lemma small1_big_continue:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   155
  "cs \<rightarrow> cs' \<Longrightarrow> cs' \<Rightarrow> t \<Longrightarrow> cs \<Rightarrow> t"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
   156
apply (induction arbitrary: t rule: small_step.induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   157
apply auto
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   158
done
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   159
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   160
lemma small_big_continue:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   161
  "cs \<rightarrow>* cs' \<Longrightarrow> cs' \<Rightarrow> t \<Longrightarrow> cs \<Rightarrow> t"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
   162
apply (induction rule: star.induct)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   163
apply (auto intro: small1_big_continue)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   164
done
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   165
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   166
lemma small_to_big: "cs \<rightarrow>* (SKIP,t) \<Longrightarrow> cs \<Rightarrow> t"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   167
by (metis small_big_continue Skip)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   168
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   169
text {*
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   170
  Finally, the equivalence theorem:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   171
*}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   172
theorem big_iff_small:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   173
  "cs \<Rightarrow> t = cs \<rightarrow>* (SKIP,t)"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   174
by(metis big_to_small small_to_big)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   175
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   176
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   177
subsection "Final configurations and infinite reductions"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   178
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   179
definition "final cs \<longleftrightarrow> \<not>(EX cs'. cs \<rightarrow> cs')"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   180
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   181
lemma finalD: "final (c,s) \<Longrightarrow> c = SKIP"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   182
apply(simp add: final_def)
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44036
diff changeset
   183
apply(induction c)
43141
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   184
apply blast+
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   185
done
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   186
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   187
lemma final_iff_SKIP: "final (c,s) = (c = SKIP)"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   188
by (metis SkipE finalD final_def)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   189
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   190
text{* Now we can show that @{text"\<Rightarrow>"} yields a final state iff @{text"\<rightarrow>"}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   191
terminates: *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   192
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   193
lemma big_iff_small_termination:
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   194
  "(EX t. cs \<Rightarrow> t) \<longleftrightarrow> (EX cs'. cs \<rightarrow>* cs' \<and> final cs')"
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   195
by(simp add: big_iff_small final_iff_SKIP)
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   196
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   197
text{* This is the same as saying that the absence of a big step result is
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   198
equivalent with absence of a terminating small step sequence, i.e.\ with
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   199
nontermination.  Since @{text"\<rightarrow>"} is determininistic, there is no difference
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   200
between may and must terminate. *}
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   201
11fce8564415 Replacing old IMP with new Semantics material
nipkow
parents:
diff changeset
   202
end