author | wenzelm |
Wed, 24 Oct 2007 20:17:50 +0200 | |
changeset 25179 | b84f3c3c27f2 |
parent 24824 | b7866aea0815 |
child 26806 | 40b411ec05aa |
permissions | -rw-r--r-- |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
1 |
(* Title: HOL/Induct/Com |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
2 |
ID: $Id$ |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
4 |
Copyright 1997 University of Cambridge |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
5 |
|
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
6 |
Example of Mutual Induction via Iteratived Inductive Definitions: Commands |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
7 |
*) |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
8 |
|
14527 | 9 |
header{*Mutual Induction via Iteratived Inductive Definitions*} |
10 |
||
16417 | 11 |
theory Com imports Main begin |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
12 |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
13 |
typedecl loc |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
14 |
types state = "loc => nat" |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
15 |
|
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
16 |
datatype |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
17 |
exp = N nat |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
18 |
| X loc |
24824 | 19 |
| Op "nat => nat => nat" exp exp |
10759 | 20 |
| valOf com exp ("VALOF _ RESULTIS _" 60) |
21 |
and |
|
22 |
com = SKIP |
|
24824 | 23 |
| Assign loc exp (infixl ":=" 60) |
24 |
| Semi com com ("_;;_" [60, 60] 60) |
|
25 |
| Cond exp com com ("IF _ THEN _ ELSE _" 60) |
|
10759 | 26 |
| While exp com ("WHILE _ DO _" 60) |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
27 |
|
14527 | 28 |
|
29 |
subsection {* Commands *} |
|
30 |
||
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
31 |
text{* Execution of commands *} |
4264 | 32 |
|
19736 | 33 |
abbreviation (input) |
23746 | 34 |
generic_rel ("_/ -|[_]-> _" [50,0,50] 50) where |
19736 | 35 |
"esig -|[eval]-> ns == (esig,ns) \<in> eval" |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
36 |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
37 |
text{*Command execution. Natural numbers represent Booleans: 0=True, 1=False*} |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
38 |
|
23746 | 39 |
inductive_set |
40 |
exec :: "((exp*state) * (nat*state)) set => ((com*state)*state)set" |
|
41 |
and exec_rel :: "com * state => ((exp*state) * (nat*state)) set => state => bool" |
|
42 |
("_/ -[_]-> _" [50,0,50] 50) |
|
43 |
for eval :: "((exp*state) * (nat*state)) set" |
|
44 |
where |
|
45 |
"csig -[eval]-> s == (csig,s) \<in> exec eval" |
|
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
46 |
|
23746 | 47 |
| Skip: "(SKIP,s) -[eval]-> s" |
48 |
||
49 |
| Assign: "(e,s) -|[eval]-> (v,s') ==> (x := e, s) -[eval]-> s'(x:=v)" |
|
50 |
||
51 |
| Semi: "[| (c0,s) -[eval]-> s2; (c1,s2) -[eval]-> s1 |] |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
52 |
==> (c0 ;; c1, s) -[eval]-> s1" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
53 |
|
23746 | 54 |
| IfTrue: "[| (e,s) -|[eval]-> (0,s'); (c0,s') -[eval]-> s1 |] |
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
55 |
==> (IF e THEN c0 ELSE c1, s) -[eval]-> s1" |
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
56 |
|
23746 | 57 |
| IfFalse: "[| (e,s) -|[eval]-> (Suc 0, s'); (c1,s') -[eval]-> s1 |] |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
58 |
==> (IF e THEN c0 ELSE c1, s) -[eval]-> s1" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
59 |
|
23746 | 60 |
| WhileFalse: "(e,s) -|[eval]-> (Suc 0, s1) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
61 |
==> (WHILE e DO c, s) -[eval]-> s1" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
62 |
|
23746 | 63 |
| WhileTrue: "[| (e,s) -|[eval]-> (0,s1); |
18260 | 64 |
(c,s1) -[eval]-> s2; (WHILE e DO c, s2) -[eval]-> s3 |] |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
65 |
==> (WHILE e DO c, s) -[eval]-> s3" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
66 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
67 |
declare exec.intros [intro] |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
68 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
69 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
70 |
inductive_cases |
18260 | 71 |
[elim!]: "(SKIP,s) -[eval]-> t" |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
72 |
and [elim!]: "(x:=a,s) -[eval]-> t" |
18260 | 73 |
and [elim!]: "(c1;;c2, s) -[eval]-> t" |
74 |
and [elim!]: "(IF e THEN c1 ELSE c2, s) -[eval]-> t" |
|
75 |
and exec_WHILE_case: "(WHILE b DO c,s) -[eval]-> t" |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
76 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
77 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
78 |
text{*Justifies using "exec" in the inductive definition of "eval"*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
79 |
lemma exec_mono: "A<=B ==> exec(A) <= exec(B)" |
23746 | 80 |
apply (rule subsetI) |
81 |
apply (simp add: split_paired_all) |
|
82 |
apply (erule exec.induct) |
|
83 |
apply blast+ |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
84 |
done |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
85 |
|
23746 | 86 |
lemma [pred_set_conv]: |
87 |
"((\<lambda>x x' y y'. ((x, x'), (y, y')) \<in> R) <= (\<lambda>x x' y y'. ((x, x'), (y, y')) \<in> S)) = (R <= S)" |
|
88 |
by (auto simp add: le_fun_def le_bool_def) |
|
89 |
||
90 |
lemma [pred_set_conv]: |
|
91 |
"((\<lambda>x x' y. ((x, x'), y) \<in> R) <= (\<lambda>x x' y. ((x, x'), y) \<in> S)) = (R <= S)" |
|
92 |
by (auto simp add: le_fun_def le_bool_def) |
|
93 |
||
24178
4ff1dc2aa18d
turned Unify flags into configuration options (global only);
wenzelm
parents:
23746
diff
changeset
|
94 |
declare [[unify_trace_bound = 30, unify_search_bound = 60]] |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
95 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
96 |
text{*Command execution is functional (deterministic) provided evaluation is*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
97 |
theorem single_valued_exec: "single_valued ev ==> single_valued(exec ev)" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
98 |
apply (simp add: single_valued_def) |
18260 | 99 |
apply (intro allI) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
100 |
apply (rule impI) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
101 |
apply (erule exec.induct) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
102 |
apply (blast elim: exec_WHILE_case)+ |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
103 |
done |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
104 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
105 |
|
14527 | 106 |
subsection {* Expressions *} |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
107 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
108 |
text{* Evaluation of arithmetic expressions *} |
18260 | 109 |
|
23746 | 110 |
inductive_set |
111 |
eval :: "((exp*state) * (nat*state)) set" |
|
112 |
and eval_rel :: "[exp*state,nat*state] => bool" (infixl "-|->" 50) |
|
113 |
where |
|
114 |
"esig -|-> ns == (esig, ns) \<in> eval" |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
115 |
|
23746 | 116 |
| N [intro!]: "(N(n),s) -|-> (n,s)" |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
117 |
|
23746 | 118 |
| X [intro!]: "(X(x),s) -|-> (s(x),s)" |
119 |
||
120 |
| Op [intro]: "[| (e0,s) -|-> (n0,s0); (e1,s0) -|-> (n1,s1) |] |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
121 |
==> (Op f e0 e1, s) -|-> (f n0 n1, s1)" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
122 |
|
23746 | 123 |
| valOf [intro]: "[| (c,s) -[eval]-> s0; (e,s0) -|-> (n,s1) |] |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
124 |
==> (VALOF c RESULTIS e, s) -|-> (n, s1)" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
125 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
126 |
monos exec_mono |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
127 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
128 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
129 |
inductive_cases |
18260 | 130 |
[elim!]: "(N(n),sigma) -|-> (n',s')" |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
131 |
and [elim!]: "(X(x),sigma) -|-> (n,s')" |
18260 | 132 |
and [elim!]: "(Op f a1 a2,sigma) -|-> (n,s')" |
133 |
and [elim!]: "(VALOF c RESULTIS e, s) -|-> (n, s1)" |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
134 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
135 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
136 |
lemma var_assign_eval [intro!]: "(X x, s(x:=n)) -|-> (n, s(x:=n))" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
137 |
by (rule fun_upd_same [THEN subst], fast) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
138 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
139 |
|
23746 | 140 |
text{* Make the induction rule look nicer -- though @{text eta_contract} makes the new |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
141 |
version look worse than it is...*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
142 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
143 |
lemma split_lemma: |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
144 |
"{((e,s),(n,s')). P e s n s'} = Collect (split (%v. split (split P v)))" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
145 |
by auto |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
146 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
147 |
text{*New induction rule. Note the form of the VALOF induction hypothesis*} |
18260 | 148 |
lemma eval_induct |
149 |
[case_names N X Op valOf, consumes 1, induct set: eval]: |
|
150 |
"[| (e,s) -|-> (n,s'); |
|
151 |
!!n s. P (N n) s n s; |
|
152 |
!!s x. P (X x) s (s x) s; |
|
153 |
!!e0 e1 f n0 n1 s s0 s1. |
|
154 |
[| (e0,s) -|-> (n0,s0); P e0 s n0 s0; |
|
155 |
(e1,s0) -|-> (n1,s1); P e1 s0 n1 s1 |
|
156 |
|] ==> P (Op f e0 e1) s (f n0 n1) s1; |
|
157 |
!!c e n s s0 s1. |
|
158 |
[| (c,s) -[eval Int {((e,s),(n,s')). P e s n s'}]-> s0; |
|
159 |
(c,s) -[eval]-> s0; |
|
160 |
(e,s0) -|-> (n,s1); P e s0 n s1 |] |
|
161 |
==> P (VALOF c RESULTIS e) s n s1 |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
162 |
|] ==> P e s n s'" |
18260 | 163 |
apply (induct set: eval) |
164 |
apply blast |
|
165 |
apply blast |
|
166 |
apply blast |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
167 |
apply (frule Int_lower1 [THEN exec_mono, THEN subsetD]) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
168 |
apply (auto simp add: split_lemma) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
169 |
done |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
170 |
|
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
171 |
|
23746 | 172 |
text{*Lemma for @{text Function_eval}. The major premise is that @{text "(c,s)"} executes to @{text "s1"} |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
173 |
using eval restricted to its functional part. Note that the execution |
23746 | 174 |
@{text "(c,s) -[eval]-> s2"} can use unrestricted @{text eval}! The reason is that |
175 |
the execution @{text "(c,s) -[eval Int {...}]-> s1"} assures us that execution is |
|
176 |
functional on the argument @{text "(c,s)"}. |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
177 |
*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
178 |
lemma com_Unique: |
18260 | 179 |
"(c,s) -[eval Int {((e,s),(n,t)). \<forall>nt'. (e,s) -|-> nt' --> (n,t)=nt'}]-> s1 |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
180 |
==> \<forall>s2. (c,s) -[eval]-> s2 --> s2=s1" |
18260 | 181 |
apply (induct set: exec) |
182 |
apply simp_all |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
183 |
apply blast |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
184 |
apply force |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
185 |
apply blast |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
186 |
apply blast |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
187 |
apply blast |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
188 |
apply (blast elim: exec_WHILE_case) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
189 |
apply (erule_tac V = "(?c,s2) -[?ev]-> s3" in thin_rl) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
190 |
apply clarify |
18260 | 191 |
apply (erule exec_WHILE_case, blast+) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
192 |
done |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
193 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
194 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
195 |
text{*Expression evaluation is functional, or deterministic*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
196 |
theorem single_valued_eval: "single_valued eval" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
197 |
apply (unfold single_valued_def) |
18260 | 198 |
apply (intro allI, rule impI) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
199 |
apply (simp (no_asm_simp) only: split_tupled_all) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
200 |
apply (erule eval_induct) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
201 |
apply (drule_tac [4] com_Unique) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
202 |
apply (simp_all (no_asm_use)) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
203 |
apply blast+ |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
204 |
done |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
205 |
|
18260 | 206 |
lemma eval_N_E [dest!]: "(N n, s) -|-> (v, s') ==> (v = n & s' = s)" |
207 |
by (induct e == "N n" s v s' set: eval) simp_all |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
208 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
209 |
text{*This theorem says that "WHILE TRUE DO c" cannot terminate*} |
18260 | 210 |
lemma while_true_E: |
211 |
"(c', s) -[eval]-> t ==> c' = WHILE (N 0) DO c ==> False" |
|
212 |
by (induct set: exec) auto |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
213 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
214 |
|
18260 | 215 |
subsection{* Equivalence of IF e THEN c;;(WHILE e DO c) ELSE SKIP and |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
216 |
WHILE e DO c *} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
217 |
|
18260 | 218 |
lemma while_if1: |
219 |
"(c',s) -[eval]-> t |
|
220 |
==> c' = WHILE e DO c ==> |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
221 |
(IF e THEN c;;c' ELSE SKIP, s) -[eval]-> t" |
18260 | 222 |
by (induct set: exec) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
223 |
|
18260 | 224 |
lemma while_if2: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
225 |
"(c',s) -[eval]-> t |
18260 | 226 |
==> c' = IF e THEN c;;(WHILE e DO c) ELSE SKIP ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
227 |
(WHILE e DO c, s) -[eval]-> t" |
18260 | 228 |
by (induct set: exec) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
229 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
230 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
231 |
theorem while_if: |
18260 | 232 |
"((IF e THEN c;;(WHILE e DO c) ELSE SKIP, s) -[eval]-> t) = |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
233 |
((WHILE e DO c, s) -[eval]-> t)" |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
234 |
by (blast intro: while_if1 while_if2) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
235 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
236 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
237 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
238 |
subsection{* Equivalence of (IF e THEN c1 ELSE c2);;c |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
239 |
and IF e THEN (c1;;c) ELSE (c2;;c) *} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
240 |
|
18260 | 241 |
lemma if_semi1: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
242 |
"(c',s) -[eval]-> t |
18260 | 243 |
==> c' = (IF e THEN c1 ELSE c2);;c ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
244 |
(IF e THEN (c1;;c) ELSE (c2;;c), s) -[eval]-> t" |
18260 | 245 |
by (induct set: exec) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
246 |
|
18260 | 247 |
lemma if_semi2: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
248 |
"(c',s) -[eval]-> t |
18260 | 249 |
==> c' = IF e THEN (c1;;c) ELSE (c2;;c) ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
250 |
((IF e THEN c1 ELSE c2);;c, s) -[eval]-> t" |
18260 | 251 |
by (induct set: exec) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
252 |
|
18260 | 253 |
theorem if_semi: "(((IF e THEN c1 ELSE c2);;c, s) -[eval]-> t) = |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
254 |
((IF e THEN (c1;;c) ELSE (c2;;c), s) -[eval]-> t)" |
18260 | 255 |
by (blast intro: if_semi1 if_semi2) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
256 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
257 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
258 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
259 |
subsection{* Equivalence of VALOF c1 RESULTIS (VALOF c2 RESULTIS e) |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
260 |
and VALOF c1;;c2 RESULTIS e |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
261 |
*} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
262 |
|
18260 | 263 |
lemma valof_valof1: |
264 |
"(e',s) -|-> (v,s') |
|
265 |
==> e' = VALOF c1 RESULTIS (VALOF c2 RESULTIS e) ==> |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
266 |
(VALOF c1;;c2 RESULTIS e, s) -|-> (v,s')" |
18260 | 267 |
by (induct set: eval) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
268 |
|
18260 | 269 |
lemma valof_valof2: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
270 |
"(e',s) -|-> (v,s') |
18260 | 271 |
==> e' = VALOF c1;;c2 RESULTIS e ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
272 |
(VALOF c1 RESULTIS (VALOF c2 RESULTIS e), s) -|-> (v,s')" |
18260 | 273 |
by (induct set: eval) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
274 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
275 |
theorem valof_valof: |
18260 | 276 |
"((VALOF c1 RESULTIS (VALOF c2 RESULTIS e), s) -|-> (v,s')) = |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
277 |
((VALOF c1;;c2 RESULTIS e, s) -|-> (v,s'))" |
18260 | 278 |
by (blast intro: valof_valof1 valof_valof2) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
279 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
280 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
281 |
subsection{* Equivalence of VALOF SKIP RESULTIS e and e *} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
282 |
|
18260 | 283 |
lemma valof_skip1: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
284 |
"(e',s) -|-> (v,s') |
18260 | 285 |
==> e' = VALOF SKIP RESULTIS e ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
286 |
(e, s) -|-> (v,s')" |
18260 | 287 |
by (induct set: eval) auto |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
288 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
289 |
lemma valof_skip2: |
18260 | 290 |
"(e,s) -|-> (v,s') ==> (VALOF SKIP RESULTIS e, s) -|-> (v,s')" |
291 |
by blast |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
292 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
293 |
theorem valof_skip: |
18260 | 294 |
"((VALOF SKIP RESULTIS e, s) -|-> (v,s')) = ((e, s) -|-> (v,s'))" |
295 |
by (blast intro: valof_skip1 valof_skip2) |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
296 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
297 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
298 |
subsection{* Equivalence of VALOF x:=e RESULTIS x and e *} |
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
299 |
|
18260 | 300 |
lemma valof_assign1: |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
301 |
"(e',s) -|-> (v,s'') |
18260 | 302 |
==> e' = VALOF x:=e RESULTIS X x ==> |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
303 |
(\<exists>s'. (e, s) -|-> (v,s') & (s'' = s'(x:=v)))" |
18260 | 304 |
by (induct set: eval) (simp_all del: fun_upd_apply, clarify, auto) |
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
305 |
|
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
306 |
lemma valof_assign2: |
18260 | 307 |
"(e,s) -|-> (v,s') ==> (VALOF x:=e RESULTIS X x, s) -|-> (v,s'(x:=v))" |
308 |
by blast |
|
13075
d3e1d554cd6d
conversion of some HOL/Induct proof scripts to Isar
paulson
parents:
12338
diff
changeset
|
309 |
|
3120
c58423c20740
New directory to contain examples of (co)inductive definitions
paulson
parents:
diff
changeset
|
310 |
end |