author | paulson |
Mon, 01 Mar 1999 18:38:43 +0100 | |
changeset 6295 | 351b3c2b0d83 |
parent 6012 | 1894bfc4aee9 |
permissions | -rw-r--r-- |
5111 | 1 |
(* Title: HOL/UNITY/Traces |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
6 |
Definitions of |
|
7 |
* traces: the possible execution traces |
|
8 |
* reachable: the set of reachable states |
|
9 |
||
10 |
*) |
|
11 |
||
5596 | 12 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
13 |
|
5596 | 14 |
(*** The abstract type of programs ***) |
15 |
||
16 |
val rep_ss = simpset() addsimps |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
17 |
[Init_def, Acts_def, mk_program_def, Program_def, Rep_Program, |
5596 | 18 |
Rep_Program_inverse, Abs_Program_inverse]; |
19 |
||
20 |
||
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
21 |
Goal "Id : Acts F"; |
5620 | 22 |
by (cut_inst_tac [("x", "F")] Rep_Program 1); |
5596 | 23 |
by (auto_tac (claset(), rep_ss)); |
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
24 |
qed "Id_in_Acts"; |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
25 |
AddIffs [Id_in_Acts]; |
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
26 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
27 |
Goal "insert Id (Acts F) = Acts F"; |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
28 |
by (simp_tac (simpset() addsimps [insert_absorb, Id_in_Acts]) 1); |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
29 |
qed "insert_Id_Acts"; |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
30 |
AddIffs [insert_Id_Acts]; |
5584 | 31 |
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
32 |
(** Inspectors for type "program" **) |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
33 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
34 |
Goal "Init (mk_program (init,acts)) = init"; |
5596 | 35 |
by (auto_tac (claset(), rep_ss)); |
36 |
qed "Init_eq"; |
|
4776 | 37 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
38 |
Goal "Acts (mk_program (init,acts)) = insert Id acts"; |
5596 | 39 |
by (auto_tac (claset(), rep_ss)); |
5423 | 40 |
qed "Acts_eq"; |
41 |
||
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
42 |
Addsimps [Acts_eq, Init_eq]; |
5596 | 43 |
|
5423 | 44 |
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
45 |
(** The notation of equality for type "program" **) |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
46 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
47 |
Goal "[| Init F = Init G; Acts F = Acts G |] ==> F = G"; |
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
48 |
by (subgoals_tac ["EX x. Rep_Program F = x", |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
49 |
"EX x. Rep_Program G = x"] 1); |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
50 |
by (REPEAT (Blast_tac 2)); |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
51 |
by (Clarify_tac 1); |
5596 | 52 |
by (auto_tac (claset(), rep_ss)); |
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
53 |
by (REPEAT (dres_inst_tac [("f", "Abs_Program")] arg_cong 1)); |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
54 |
by (asm_full_simp_tac rep_ss 1); |
5596 | 55 |
qed "program_equalityI"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
56 |
|
5969 | 57 |
val [major,minor] = |
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
58 |
Goal "[| F = G; [| Init F = Init G; Acts F = Acts G |] ==> P |] ==> P"; |
5969 | 59 |
by (rtac minor 1); |
60 |
by (auto_tac (claset(), simpset() addsimps [major])); |
|
61 |
qed "program_equalityE"; |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
62 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
63 |
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
64 |
(*** These rules allow "lazy" definition expansion |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
65 |
They avoid expanding the full program, which is a large expression |
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
66 |
***) |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
67 |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
68 |
Goal "F == mk_program (init,acts) ==> Init F = init"; |
5648 | 69 |
by Auto_tac; |
70 |
qed "def_prg_Init"; |
|
71 |
||
72 |
(*The program is not expanded, but its Init and Acts are*) |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
73 |
val [rew] = goal thy |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
74 |
"[| F == mk_program (init,acts) |] \ |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
75 |
\ ==> Init F = init & Acts F = insert Id acts"; |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
76 |
by (rewtac rew); |
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
77 |
by Auto_tac; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
78 |
qed "def_prg_simps"; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
79 |
|
5648 | 80 |
(*An action is expanded only if a pair of states is being tested against it*) |
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
81 |
Goal "[| act == {(s,s'). P s s'} |] ==> ((s,s') : act) = P s s'"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
82 |
by Auto_tac; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
83 |
qed "def_act_simp"; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
84 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
85 |
fun simp_of_act def = def RS def_act_simp; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
86 |
|
5648 | 87 |
(*A set is expanded only if an element is being tested against it*) |
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5969
diff
changeset
|
88 |
Goal "A == B ==> (x : A) = (x : B)"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
89 |
by Auto_tac; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
90 |
qed "def_set_simp"; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
91 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
92 |
fun simp_of_set def = def RS def_set_simp; |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5423
diff
changeset
|
93 |
|
5596 | 94 |
|
95 |
(*** traces and reachable ***) |
|
96 |
||
5620 | 97 |
Goal "reachable F = {s. EX evs. (s,evs): traces (Init F) (Acts F)}"; |
5596 | 98 |
by Safe_tac; |
99 |
by (etac traces.induct 2); |
|
100 |
by (etac reachable.induct 1); |
|
5620 | 101 |
by (ALLGOALS (blast_tac (claset() addIs reachable.intrs @ traces.intrs))); |
5596 | 102 |
qed "reachable_equiv_traces"; |