Debian Codegraph @

contrib/smarttacs/READ-ME

raw
1
2
3
4 % --------------------------------------------------------------------- %
5 % DIRECTORY: smarttacs %
6 % %
7 % DESCRIPTION: Several general purpose tactics that I have %
8 % found quite useful. %
9 % %
10 % AUTHOR: Donald Syme %
11 % %
12 % ADDRESS: c/o Department of Computer Science %
13 % Australian National University %
14 % GPO Box 4, %
15 % Canberra, Australia, 2601 %
16 % %
17 % email: [email protected] %
18 % Also contact [email protected] (Malcolm Newey) % %
19 % DATE: 25/10/92 %
20 % --------------------------------------------------------------------- %
21
22
23 Tactics:
24
25 ELIMINATE_TACS.ml
26 SSMART_EXISTS_TAC.ml
27 RENAME_TAC.ml
28 - renames variables in a goal so they are all unique
29 SET_PROOFS.ml
30 - function to automatically prove a group of theorems regarding
31 membership or non-membership for a set
32
33 The most original and useful of these tactics are
34 SMART_ELIMINATE_TAC and SSMART_EXISTS_TAC (sic - two x S).
35
36
37 SMART_ELIMINATE_TAC:
38
39 This tactic is just fantastic for eliminating variables with
40 known values from a proof. For instance, with a goal such as:
41
42 "(x = 1) /\ (y = 3)"
43 [ "z = 3" ]
44 [ "p = 1,z" ]
45 [ "x,y = p" ]
46
47 it is quite a natural style of proof to just get rid of all
48 references to z (replacing them by 3), and p (replacing them
49 by (x,y)). This is exactly what SMART_ELIMINATE_TAC does - it
50 searches through the assumptions for assumptions stating that
51 some variable V has value X, and replaces all occurrences of
52 V by X. It does this efficiently, eliminating as many
53 variables as possible at once. It also does not make
54 mistakes, in the sense that it will not eliminate variables
55 in ways that interfere with other eliminations.
56
57 Perhaps the best thing about the tactic is that it eliminates
58 variables on the *right* side of equalities in the
59 assumptions, which ASM_REWRITE_TAC cannot easily do. E.g:
60
61 "P x /\ Q y"
62 [ x = 3 ]
63 [ P 3 ]
64 [ (z + 6) = y ]
65 [ Q (z + 6) ]
66
67 will be reduced by SMART_ELIMINATE_TAC to
68
69 "P 3 /\ Q (z + 6)"
70 [ P 3 ]
71 [ Q (z + 6) ]
72
73 which is easily solved.
74
75
76 Terms more complicate than variables may also be eliminated
77 when it appears safe. To restrict this, use
78 SMART_VAR_ELIMINATE_TAC. To allow it with even less safety
79 checking, use SMART_TERM_ELIMINATE_TAC.
80
81 Examples follow below.
82
83
84 ---------------- SSMART_EXISTS_TAC --------------------
85
86
87 SSMART_EXISTS_TAC:
88
89 This tactic is great for times when you have an existential
90 goal and it is "obvious" what value should be chosen. By
91 obvious it is meant those times when the goal itself demands
92 a particular value for the existential variable, e.g. "?x. x
93 = 1", or when the assumptions give a direct hint. In general,
94 whenever an existential goal appears, it is worth trying
95 SSMART_EXISTS_TAC to see if it does the job (of course
96 knowing what the tactic will and won't choose will make this
97 much more effective).
98
99 For a goal with more than one existential quantifier, such as:
100
101 "?x y. P x /\ (y = 3)"
102
103 SSMART_EXISTS_TAC will try to find values for x and/or y. The
104 tactic firstly looks through the goal for any equality
105 relationships which tell it what to choose. In the above
106 example no value is found for x, and the value 3 is found for
107 y, reducing the goal to
108
109 "?x. P x /\ (3 = 3)
110
111 which can then be simplified by rewriting.
112 The equality search goes through operators too:
113
114 "?x y. (SOME_FUNCTION x y = SOME_FUNCTION 3 4)"
115
116 will find x = 3 and y = 4. If no appropriate values are found
117 in the goal, the tactic will look through the assumptions for
118 a hint:
119
120 "?x y. P x /\ Q y"
121 [ Q (FRANK_SINATRA x) ]
122
123 will result in y = FRANK_SINATRA x being chosen. Choices
124 found in the goal are always preferred to choices found in
125 the assumptions.
126
127
128
129
130
131 --------------------- Examples ------------------------------------
132
133
134 Some examples of the use of SMART_ELIMINATE_TAC (the second taken from
135 part of a monogenicity proof for a programming language):
136
137 Example 1: eliminating paired values
138
139 "(x = 1) /\ (y = 3)"
140 [ "z = 3" ]
141 [ "p = 1,z" ]
142 [ "x,y = p" ]
143
144 () : void
145 Run time: 0.1s
146
147 #e(SMART_ELIMINATE_TAC);;
148 OK..
149 "(x = 1) /\ (y = 3)"
150 [ "x,y = 1,3" ]
151
152 () : void
153 Run time: 0.1s
154 Intermediate theorems generated: 11
155
156
157
158 Example 2: (nb. some special pretty printing is used but is irrelevant to
159 the use of SMART_ELIMINATE_TAC). Note the absolute plethora of variables
160 defined in the assumptions that we would rather just get rid of.
161
162 Current subgoal:
163 "Res_VarEnv(VarEnv(EXTBY VVM{V |-> val''})) =
164 Res_VarEnv(VarEnv(EXTBY VVM'{V |-> val'''}))"
165 [ "!s E val val' s' s''.
166 IS(s,E,Ph_Pat P,val,s') /\ IS(s,E,Ph_Pat P,val',s'') ==>
167 (val = val') /\ (s' = s'')" ]
168 [ "E = Obj_Env_Val E' val''" ]
169 [ "val = Res_VarEnv(VarEnv(EXTBY VVM{V |-> val''}))" ]
170 [ "IS(s,Obj_Env_Val E' val'',Ph_Pat P,Res_VarEnv(VarEnv VVM),s)" ]
171 [ "s' = s" ]
172 [ "E = Obj_Env_Val E'' val'''" ]
173 [ "val' = Res_VarEnv(VarEnv(EXTBY VVM'{V |-> val'''}))" ]
174 [ "IS(s,Obj_Env_Val E'' val''',Ph_Pat P,Res_VarEnv(VarEnv VVM'),s)" ]
175 [ "s'' = s" ]
176
177 () : void
178 Run time: 3.0s
179
180 #e(SMART_ELIMINATE_TAC);;
181 OK..
182 "Res_VarEnv(VarEnv(EXTBY VVM{V |-> val''})) =
183 Res_VarEnv(VarEnv(EXTBY VVM'{V |-> val'''}))"
184 [ "!s''' E val val' s' s''.
185 IS(s''',E,Ph_Pat P,val,s') /\ IS(s''',E,Ph_Pat P,val',s'') ==>
186 (val = val') /\ (s' = s'')" ]
187 [ "Obj_Env_Val E'' val''' = Obj_Env_Val E' val''" ]
188 [ "IS(s,Obj_Env_Val E' val'',Ph_Pat P,Res_VarEnv(VarEnv VVM),s)" ]
189 [ "IS(s,Obj_Env_Val E'' val''',Ph_Pat P,Res_VarEnv(VarEnv VVM'),s)" ]
190
191 () : void
192 Run time: 0.3s
193 Intermediate theorems generated: 28
194
195
196
197
198
199