| 1 |
\chapter{ML Functions in the wordn Library} |
| 2 |
\label{entries} |
| 3 |
\input{entries-intro} |
| 4 |
\DOC{define\_wordn\_bit\_ops} |
| 5 |
|
| 6 |
\TYPE {\small\verb%define_wordn_bit_ops : thm -> int -> (thm) list%}\egroup |
| 7 |
|
| 8 |
\SYNOPSIS |
| 9 |
Defines a set of bitwise logical operators for the given word length. |
| 10 |
|
| 11 |
\DESCRIBE |
| 12 |
{\small\verb%define_wordn_bit_ops wordn n%}, where {\small\verb%wordn%} is the theorem returned |
| 13 |
by {\small\verb%define_wordn_type%} and {\small\verb%n%} is the word length, defines four |
| 14 |
commonly used bitwise logical operators: {\small\verb%NOTn%}, {\small\verb%ANDn%}, {\small\verb%ORn%}, and |
| 15 |
{\small\verb%XORn%}. The definitions are stored in the current theory under the |
| 16 |
names: {\small\verb%NOTn_DEF%}, {\small\verb%ANDn_DEF%}, {\small\verb%ORn_DEF%} and {\small\verb%XORn_DEF%} and are |
| 17 |
returned in a list as the value of this function. |
| 18 |
|
| 19 |
\FAILURE |
| 20 |
Fails if either it is not in draft mode, or the input theorem is not |
| 21 |
in the expected form or the type {\small\verb%:wordn%} has not been defined. |
| 22 |
|
| 23 |
\EXAMPLE |
| 24 |
{\small\verb%define_wordn_bit_ops word3 3%} returns the following list of |
| 25 |
definitons: |
| 26 |
{\par\samepage\setseps\small\begin{verbatim} |
| 27 |
[ |- !b0 b1 b2. NOT3(WORD3[b0;b1;b2]) = WORD3(B_NOT[b0;b1;b2]); |
| 28 |
|- !b0 b1 b2 w. |
| 29 |
(WORD3[b0;b1;b2]) AND3 w = WORD3(B_AND[b0;b1;b2](BITS3 w)); |
| 30 |
|- !b0 b1 b2 w. |
| 31 |
(WORD3[b0;b1;b2]) OR3 w = WORD3(B_OR[b0;b1;b2](BITS3 w)); |
| 32 |
|- !b0 b1 b2 w. |
| 33 |
(WORD3[b0;b1;b2]) XOR3 w = WORD3(B_XOR[b0;b1;b2](BITS3 w)) ] |
| 34 |
\end{verbatim}} |
| 35 |
\noindent and they are stored in the current theory under the names |
| 36 |
{\small\verb%NOT3_DEF%}, {\small\verb%AND3_DEF%}, {\small\verb%OR3_DEF%} and {\small\verb%XOR3_DEF%}, repectively. |
| 37 |
|
| 38 |
\SEEALSO |
| 39 |
{\small\verb%prove_bit_opthms%}, {\small\verb%wordn_bit_ops%}. |
| 40 |
|
| 41 |
\ENDDOC |
| 42 |
\DOC{define\_wordn\_type} |
| 43 |
|
| 44 |
\TYPE {\small\verb%define_wordn_type : string -> int -> thm%}\egroup |
| 45 |
|
| 46 |
\SYNOPSIS |
| 47 |
|
| 48 |
|
| 49 |
\DESCRIBE |
| 50 |
|
| 51 |
|
| 52 |
\FAILURE |
| 53 |
|
| 54 |
|
| 55 |
\EXAMPLE |
| 56 |
|
| 57 |
|
| 58 |
\USES |
| 59 |
|
| 60 |
|
| 61 |
\COMMENTS |
| 62 |
|
| 63 |
|
| 64 |
\SEEALSO |
| 65 |
|
| 66 |
|
| 67 |
\ENDDOC |
| 68 |
\DOC{define\_word\_val} |
| 69 |
|
| 70 |
\TYPE {\small\verb%define_word_val : int -> thm list%}\egroup |
| 71 |
|
| 72 |
\SYNOPSIS |
| 73 |
Defines two constants for converting between the type {\small\verb%:wordn%} and {\small\verb%:num%}. |
| 74 |
|
| 75 |
\DESCRIBE |
| 76 |
{\small\verb%define_word_val%} takes a single argument, a positive integer {\small\verb%n%}. It |
| 77 |
defines two logical constants for converting between the types |
| 78 |
{\small\verb%:wordn%} and {\small\verb%:num%}. The constants are named {\small\verb%NVALn%} and {\small\verb%NWORDn%}, and |
| 79 |
they have the types {\small\verb%:wordn -> num%} and {\small\verb%:num -> wordn%}, respectively. |
| 80 |
Natural numbers are represented by an n-bit word in a big-endian |
| 81 |
format, for example, {\small\verb%#001%} denotes 1 as a 3-bit word, and the |
| 82 |
following expressions are true: |
| 83 |
{\par\samepage\setseps\small\begin{verbatim} |
| 84 |
NVAL3 #001 = 1 |
| 85 |
NWORD3 1 = #001 |
| 86 |
\end{verbatim}} |
| 87 |
|
| 88 |
These constants are defined in terms of {\small\verb%VAL%} and {\small\verb%WORDN%}, which are |
| 89 |
the generic conversion |
| 90 |
functions between the represention type of the n-bit words, namely |
| 91 |
{\small\verb%:(bool)list%}, and the type {\small\verb%:num%}. The definitions of these generic |
| 92 |
conversion functions are as follows: |
| 93 |
{\par\samepage\setseps\small\begin{verbatim} |
| 94 |
|- (VAL[] = 0) /\ |
| 95 |
(!b bs. VAL(CONS b bs) = ((BV b) * (2 EXP (LENGTH bs))) + (VAL bs)) |
| 96 |
|- !n m. (LENGTH(WORDN n m) = n) /\ (VAL(WORDN n m) = m MOD (2 EXP n)) |
| 97 |
\end{verbatim}} |
| 98 |
|
| 99 |
For a particular word length {\small\verb%n%}, the conversion from {\small\verb%:wordn%} to |
| 100 |
{\small\verb%:num%} is defined to be |
| 101 |
{\par\samepage\setseps\small\begin{verbatim} |
| 102 |
!w. NVALn w = VAL(BITSn w) |
| 103 |
\end{verbatim}} |
| 104 |
and the conversion from {\small\verb%:num%} to {\small\verb%:wordn%} is defined to be |
| 105 |
{\par\samepage\setseps\small\begin{verbatim} |
| 106 |
!m. NWORDn m = WORDn(WORDN n m) |
| 107 |
\end{verbatim}} |
| 108 |
|
| 109 |
The functions {\small\verb%NVALn%} converting words to natural numbers are one-one |
| 110 |
and onto, but the functions {\small\verb%NWORDn%} are not one-one due to the finite |
| 111 |
length of a word. From the definition of {\small\verb%WORDN%}, the theorem |
| 112 |
{\par\samepage\setseps\small\begin{verbatim} |
| 113 |
|- !m. NWORDn m = NWORDn (m MOD (2 EXP n)) |
| 114 |
\end{verbatim}} |
| 115 |
can be deduced. The conversions can be better characterized by the |
| 116 |
theorem |
| 117 |
{\par\samepage\setseps\small\begin{verbatim} |
| 118 |
|- (!w. NWORDn(NVALn w) = w) /\ |
| 119 |
(!m. m < (2 EXP m) ==> (NVALn(NWORDn m) = m)) |
| 120 |
\end{verbatim}} |
| 121 |
which can be obtained by calling the function {\small\verb%prove_word_val%}. |
| 122 |
|
| 123 |
\FAILURE |
| 124 |
Fails if the type {\small\verb%:wordn%} of the specified word length {\small\verb%n%} has not |
| 125 |
been defined. |
| 126 |
|
| 127 |
\EXAMPLE |
| 128 |
The following HOL session illustrates the use of this function: |
| 129 |
{\par\samepage\setseps\small\begin{verbatim} |
| 130 |
# let [NVAL3_DEF; NWORD3_DEF] = define_word_val 3;; |
| 131 |
|
| 132 |
NVAL3_DEF = |- !w. NVAL3 w = VAL(BITS3 w) |
| 133 |
NWORD3_DEF = |- !n. NWORD3 n = WORD3(WORDN 3 n) |
| 134 |
\end{verbatim}} |
| 135 |
|
| 136 |
\SEEALSO |
| 137 |
{\small\verb%define_wordn_type%}, {\small\verb%prove_word_val%}. |
| 138 |
|
| 139 |
\ENDDOC |
| 140 |
\DOC{define\_word\_partition} |
| 141 |
|
| 142 |
\TYPE {\small\verb%define_word_partition : int -> int -> thm%}\egroup |
| 143 |
|
| 144 |
\SYNOPSIS |
| 145 |
Defines operators for splitting and joining words. |
| 146 |
|
| 147 |
\DESCRIBE |
| 148 |
{\small\verb%define_word_partition m n%} defines the following two constants: |
| 149 |
{\small\verb%JOIN_m_n%} which has type {\small\verb%:(wordm # wordn) -> wordl%} and |
| 150 |
{\small\verb%SPLIT_m_n%} which has type {\small\verb%:wordl -> (wordm # wordn)%} where {\small\verb%l = m + n%}. |
| 151 |
They are specified by the following theorem: |
| 152 |
{\par\samepage\setseps\small\begin{verbatim} |
| 153 |
|- (!wm wn. SPLIT_m_n(JOIN_m_n(wm,wn)) = wm,wn) /\ |
| 154 |
(!w. JOIN_m_n(SPLIT_m_n w) = w) |
| 155 |
\end{verbatim}} |
| 156 |
\noindent which is stored in the current theory as a definition under the name |
| 157 |
{\small\verb%PARTITION_m_n%} and is returned as the value of this function. |
| 158 |
|
| 159 |
\FAILURE |
| 160 |
Fails if either it is not in draft mode or any of the word types |
| 161 |
involved has not been defined. |
| 162 |
|
| 163 |
\EXAMPLE |
| 164 |
{\small\verb%define_word_partition 3 5%} returns the following definition: |
| 165 |
{\par\samepage\setseps\small\begin{verbatim} |
| 166 |
|- (!wm wn. SPLIT_3_5(JOIN_3_5 (wm,wn)) = wm,wn) /\ |
| 167 |
(!w. JOIN_3_5(SPLIT_3_5 w) = w) |
| 168 |
\end{verbatim}} |
| 169 |
where {\small\verb%wm%} is of type {\small\verb%:word3%}, {\small\verb%wn%} is of type {\small\verb%:word5%} and {\small\verb%w%} is |
| 170 |
{\small\verb%:word8%}. |
| 171 |
|
| 172 |
\ENDDOC |
| 173 |
\DOC{new\_wordn\_definition} |
| 174 |
|
| 175 |
\TYPE {\small\verb%new_wordn_definition : (bool -> thm -> string -> conv)%}\egroup |
| 176 |
|
| 177 |
\SYNOPSIS |
| 178 |
Defines a function over the types of n-bit words. |
| 179 |
|
| 180 |
\DESCRIBE |
| 181 |
The function {\small\verb%new_wordn_definition%} provides a facility for defining |
| 182 |
functions on the types of n-bit words. It takes four arguments. The |
| 183 |
first is a boolean flag which indicates if the function being |
| 184 |
defined will be an infix or not. The second is a theorem stating the |
| 185 |
existence of functions on the type of n-bit words; this must be a |
| 186 |
theorem returned by {\small\verb%prove_function_defn_thm%}. The third argument is a |
| 187 |
name under which the resulting definition will be saved in the current |
| 188 |
theory segment. And the fourth argument is a term giving the desired |
| 189 |
function definition. The value returned by {\small\verb%new_wordn_definiton%} is a |
| 190 |
theorem stating the definition requested by the user. This theorem is |
| 191 |
derived by formal proof from an instance of the theorem given as the |
| 192 |
second argument. |
| 193 |
|
| 194 |
\FAILURE |
| 195 |
Failure occurs if HOL cannot prove there is a function satisfying the |
| 196 |
specification supplied as the last argument, or if any other condition |
| 197 |
for making constant specification (ie, the failure conditions of |
| 198 |
{\small\verb%new_specification%}) is violated. |
| 199 |
|
| 200 |
\EXAMPLE |
| 201 |
Suppose that the type of 3-bit word has been defined by calling |
| 202 |
{\small\verb%define_wordn_type 3%}, and the theorem returned by this type |
| 203 |
definition is bound to the name {\small\verb%word3%}. Then, a call to the function |
| 204 |
{\small\verb%prove_function_defn_thm%} with the theorem {\small\verb%word3%} |
| 205 |
will result in the following theorem: |
| 206 |
{\par\samepage\setseps\small\begin{verbatim} |
| 207 |
word3_FNDEF |- !f. ?! fn. !b0 b1 b2. fn(WORD3[b0;b1;b2]) = f b0 b1 b2 |
| 208 |
\end{verbatim}} |
| 209 |
\noindent which is in the form expected by the function {\small\verb%new_wordn_definition%}. |
| 210 |
The following definition will define a new constant on the type |
| 211 |
{\small\verb%:word3%}: |
| 212 |
{\par\samepage\setseps\small\begin{verbatim} |
| 213 |
#let BIT1 = new_wordn_definition false word3_FNDEF `BIT1` |
| 214 |
# "BIT1(WORD3[b0;b1;b2]) = b1";; |
| 215 |
BIT1 = |
| 216 |
|- !b0 b1 b2. BIT1(WORD3[b0;b1;b2]) = b1 |
| 217 |
\end{verbatim}} |
| 218 |
|
| 219 |
|
| 220 |
\SEEALSO |
| 221 |
{\small\verb%define_wordn_type%}, {\small\verb%new_specification%}, {\small\verb%new_recursive_definition%}, |
| 222 |
{\small\verb%prove_function_defn_thm%}, {\small\verb%use_wordn%}. |
| 223 |
|
| 224 |
\ENDDOC |
| 225 |
\DOC{prove\_BITS\_one\_one} |
| 226 |
|
| 227 |
\TYPE {\small\verb%prove_BITS_one_one : thm -> thm%}\egroup |
| 228 |
|
| 229 |
\SYNOPSIS |
| 230 |
|
| 231 |
|
| 232 |
\DESCRIBE |
| 233 |
|
| 234 |
|
| 235 |
\FAILURE |
| 236 |
|
| 237 |
|
| 238 |
\EXAMPLE |
| 239 |
|
| 240 |
|
| 241 |
\USES |
| 242 |
|
| 243 |
|
| 244 |
\COMMENTS |
| 245 |
|
| 246 |
|
| 247 |
\SEEALSO |
| 248 |
|
| 249 |
|
| 250 |
\ENDDOC |
| 251 |
\DOC{prove\_BITS\_onto} |
| 252 |
|
| 253 |
\TYPE {\small\verb%prove_BITS_onto : thm -> thm%}\egroup |
| 254 |
|
| 255 |
\SYNOPSIS |
| 256 |
|
| 257 |
|
| 258 |
\DESCRIBE |
| 259 |
|
| 260 |
|
| 261 |
\FAILURE |
| 262 |
|
| 263 |
|
| 264 |
\EXAMPLE |
| 265 |
|
| 266 |
|
| 267 |
\USES |
| 268 |
|
| 269 |
|
| 270 |
\COMMENTS |
| 271 |
|
| 272 |
|
| 273 |
\SEEALSO |
| 274 |
|
| 275 |
|
| 276 |
\ENDDOC |
| 277 |
\DOC{prove\_BITS\_WORD} |
| 278 |
|
| 279 |
\TYPE {\small\verb%prove_BITS_WORD : thm -> thm%}\egroup |
| 280 |
|
| 281 |
\SYNOPSIS |
| 282 |
Proves a theorem for reducing {\small\verb%BITSn(WORDn [...])%} to {\small\verb%[...]%}. |
| 283 |
|
| 284 |
\DESCRIBE |
| 285 |
{\small\verb%prove_BITS_WORDS%} takes a theorem returned by {\small\verb%define_wordn_type%} and |
| 286 |
deduces a theorem which is an instance of the second conjunct of the |
| 287 |
type definition theorem. This theorem is usually used in rewriting to |
| 288 |
simplify terms containing the expression {\small\verb%BITSn(WORDn [...]%}. |
| 289 |
|
| 290 |
\FAILURE |
| 291 |
Fails if the input theorem is not in the expected form. |
| 292 |
|
| 293 |
\EXAMPLE |
| 294 |
{\small\verb%prove_BITS_WORD word3%} where {\small\verb%word3%} is the theorem |
| 295 |
{\par\samepage\setseps\small\begin{verbatim} |
| 296 |
|- (!w. WORD3(BITS3 w) = w) /\ |
| 297 |
(!l. (LENGTH l = 3) = (BITS3(WORD3 l) = l)) |
| 298 |
\end{verbatim}} |
| 299 |
\noindent returns the following theorem: |
| 300 |
{\par\samepage\setseps\small\begin{verbatim} |
| 301 |
|- !b0 b1 b2. BITS3(WORD3[b0; b1; b2]) = [b0; b1; b2] |
| 302 |
\end{verbatim}} |
| 303 |
|
| 304 |
\ENDDOC |
| 305 |
\DOC{prove\_bit\_op\_thms} |
| 306 |
|
| 307 |
\TYPE {\small\verb%prove_bit_op_thms : (int -> thm list)%}\egroup |
| 308 |
|
| 309 |
\SYNOPSIS |
| 310 |
Proves some basic theorems about the bitwise logical operators. |
| 311 |
|
| 312 |
\DESCRIBE |
| 313 |
{\small\verb%prove_bit_op_thms%} takes a single integer as its argument and returns |
| 314 |
a list of theorems about the basic properties of the bitwise logical |
| 315 |
operators. These theorems are the self-inversion of the {\small\verb%NOTn%} |
| 316 |
operator, the symmetry and associativity of the {\small\verb%ANDn%}, {\small\verb%ORn%} and |
| 317 |
{\small\verb%XORn%} operators. They are also stored in the current theory under the |
| 318 |
names {\small\verb%NOTn%}, {\small\verb%ANDn_SYM%}, {\small\verb%ORn_SYM%}, {\small\verb%XORn_SYM%}, {\small\verb%ANDn_ASSOC%}, |
| 319 |
{\small\verb%ORn_ASSOC%} and {\small\verb%XORn_ASSOC%}. |
| 320 |
|
| 321 |
\FAILURE |
| 322 |
Fails if either it is not in draft mode, or any of the operators has |
| 323 |
not been defined. |
| 324 |
|
| 325 |
\EXAMPLE |
| 326 |
{\small\verb%prove_bit_op_thms 3%} returns the following list of theorems and |
| 327 |
stores them in the current theory under the names {\small\verb%NOT3%}, |
| 328 |
{\small\verb%AND3_SYM%}, {\small\verb%OR3_SYM%}, {\small\verb%XOR3_SYM%}, {\small\verb%AND3_ASSOC%}, {\small\verb%OR3_ASSOC%} and |
| 329 |
{\small\verb%XOR3_ASSOC%}, respectively. |
| 330 |
{\par\samepage\setseps\small\begin{verbatim} |
| 331 |
[ |- !w. NOT3(NOT3 w) = w; |
| 332 |
|- !w1 w2. w1 AND3 w2 = w2 AND3 w1; |
| 333 |
|- !w1 w2. w1 OR3 w2 = w2 OR3 w1; |
| 334 |
|- !w1 w2. w1 XOR3 w2 = w2 XOR3 w1; |
| 335 |
|- !w1 w2 w3. w1 AND3 (w2 AND3 w3) = (w1 AND3 w2) AND3 w3; |
| 336 |
|- !w1 w2 w3. w1 OR3 (w2 OR3 w3) = (w1 OR3 w2) OR3 w3; |
| 337 |
|- !w1 w2 w3. w1 XOR3 (w2 XOR3 w3) = (w1 XOR3 w2) XOR3 w3] |
| 338 |
\end{verbatim}} |
| 339 |
|
| 340 |
\SEEALSO |
| 341 |
{\small\verb%define_wordn_bit_ops%}, {\small\verb%wordn_bit_ops%}. |
| 342 |
|
| 343 |
\ENDDOC |
| 344 |
\DOC{prove\_function\_defn\_thm} |
| 345 |
|
| 346 |
\TYPE {\small\verb%prove_function_defn_thm : thm -> thm%}\egroup |
| 347 |
|
| 348 |
\SYNOPSIS |
| 349 |
|
| 350 |
|
| 351 |
\DESCRIBE |
| 352 |
|
| 353 |
|
| 354 |
\FAILURE |
| 355 |
|
| 356 |
|
| 357 |
\EXAMPLE |
| 358 |
|
| 359 |
|
| 360 |
\USES |
| 361 |
|
| 362 |
|
| 363 |
\COMMENTS |
| 364 |
|
| 365 |
|
| 366 |
\SEEALSO |
| 367 |
|
| 368 |
|
| 369 |
\ENDDOC |
| 370 |
\DOC{prove\_LENGTH\_BITS\_thm} |
| 371 |
|
| 372 |
\TYPE {\small\verb%prove_LENGTH_BITS_thm : thm -> thm%}\egroup |
| 373 |
|
| 374 |
\SYNOPSIS |
| 375 |
|
| 376 |
|
| 377 |
\DESCRIBE |
| 378 |
|
| 379 |
|
| 380 |
\FAILURE |
| 381 |
|
| 382 |
|
| 383 |
\EXAMPLE |
| 384 |
|
| 385 |
|
| 386 |
\USES |
| 387 |
|
| 388 |
|
| 389 |
\COMMENTS |
| 390 |
|
| 391 |
|
| 392 |
\SEEALSO |
| 393 |
|
| 394 |
|
| 395 |
\ENDDOC |
| 396 |
\DOC{prove\_NWORD\_MOD} |
| 397 |
|
| 398 |
\TYPE {\small\verb%prove_NWORD_MOD : int -> thm%}\egroup |
| 399 |
|
| 400 |
\SYNOPSIS |
| 401 |
Proves a theorem stating the periodicity of the function {\small\verb%NWORDn%}. |
| 402 |
|
| 403 |
\DESCRIBE |
| 404 |
{\small\verb%prove_NWORD_MOD n%} proves a theorem about the num-to-word conversion |
| 405 |
{\small\verb%NWORDn%} which takes the following form: |
| 406 |
{\par\samepage\setseps\small\begin{verbatim} |
| 407 |
|- !m. NWORDn m = NWORDn (m MOD e) |
| 408 |
\end{verbatim}} |
| 409 |
\noindent where {\small\verb%e%} is a constant number whose value equals to {\small\verb%2 EXP n%}. |
| 410 |
|
| 411 |
\FAILURE |
| 412 |
Fails if the type {\small\verb%:wordn%} or the conversion function {\small\verb%NWORDn%} |
| 413 |
has not been defined. |
| 414 |
|
| 415 |
\EXAMPLE |
| 416 |
The following HOL session illustrates the use of this function: |
| 417 |
{\par\samepage\setseps\small\begin{verbatim} |
| 418 |
# let word3_NWORD_MOD = prove_NWORD_MOD 3;; |
| 419 |
word3_NWORD_MOD = |- !m. NWORD3 m = NWORD3(m MOD 8) |
| 420 |
\end{verbatim}} |
| 421 |
|
| 422 |
\SEEALSO |
| 423 |
{\small\verb%define_wordn_type%}, {\small\verb%define_word_val%}, {\small\verb%prove_word_val%}. |
| 424 |
|
| 425 |
\ENDDOC |
| 426 |
\DOC{prove\_wordn\_cases\_thm} |
| 427 |
|
| 428 |
\TYPE {\small\verb%prove_wordn_cases_thm : thm -> thm%}\egroup |
| 429 |
|
| 430 |
\SYNOPSIS |
| 431 |
|
| 432 |
|
| 433 |
\DESCRIBE |
| 434 |
|
| 435 |
|
| 436 |
\FAILURE |
| 437 |
|
| 438 |
|
| 439 |
\EXAMPLE |
| 440 |
|
| 441 |
|
| 442 |
\USES |
| 443 |
|
| 444 |
|
| 445 |
\COMMENTS |
| 446 |
|
| 447 |
|
| 448 |
\SEEALSO |
| 449 |
|
| 450 |
|
| 451 |
\ENDDOC |
| 452 |
\DOC{prove\_wordn\_const\_cases} |
| 453 |
|
| 454 |
\TYPE {\small\verb%prove_wordn_const_cases : thm -> thm%}\egroup |
| 455 |
|
| 456 |
\SYNOPSIS |
| 457 |
Exhaustive cases theorem for wordn constants. |
| 458 |
|
| 459 |
\DESCRIBE |
| 460 |
{\small\verb%prove_wordn_const_cases%} derives an exhaustive cases theorem for |
| 461 |
constants of type {\small\verb%:wordn%}. Use only for small n. |
| 462 |
The input is a theorem of the form returned by {\small\verb%prove_word_cases_thm%}: |
| 463 |
{\par\samepage\setseps\small\begin{verbatim} |
| 464 |
|- !w. ?b0...bn-1. w = WORDn [b0;...;bn-1] |
| 465 |
\end{verbatim}} |
| 466 |
\noindent The corresponding output has the form: |
| 467 |
{\par\samepage\setseps\small\begin{verbatim} |
| 468 |
|- !w. ((w = #0...0) \/ ...) \/ (... \/ w = #1...1) |
| 469 |
\end{verbatim}} |
| 470 |
|
| 471 |
\FAILURE |
| 472 |
|
| 473 |
|
| 474 |
\EXAMPLE |
| 475 |
{\small\verb%prove_wordn_const_cases word3_CASES%} returns the following theorem: |
| 476 |
{\par\samepage\setseps\small\begin{verbatim} |
| 477 |
|- !w. |
| 478 |
(((w = #000) \/ (w = #001)) \/ (w = #010) \/ (w = #011)) \/ |
| 479 |
((w = #100) \/ (w = #101)) \/ |
| 480 |
(w = #110) \/ |
| 481 |
(w = #111) |
| 482 |
\end{verbatim}} |
| 483 |
|
| 484 |
\SEEALSO |
| 485 |
{\small\verb%prove_wordn_cases_thm%} |
| 486 |
|
| 487 |
\ENDDOC |
| 488 |
\DOC{prove\_wordn\_induction\_thm} |
| 489 |
|
| 490 |
\TYPE {\small\verb%prove_wordn_induction_thm : thm -> thm%}\egroup |
| 491 |
|
| 492 |
\SYNOPSIS |
| 493 |
|
| 494 |
|
| 495 |
\DESCRIBE |
| 496 |
|
| 497 |
|
| 498 |
\FAILURE |
| 499 |
|
| 500 |
|
| 501 |
\EXAMPLE |
| 502 |
|
| 503 |
|
| 504 |
\USES |
| 505 |
|
| 506 |
|
| 507 |
\COMMENTS |
| 508 |
|
| 509 |
|
| 510 |
\SEEALSO |
| 511 |
|
| 512 |
|
| 513 |
\ENDDOC |
| 514 |
\DOC{prove\_WORD\_one\_one} |
| 515 |
|
| 516 |
\TYPE {\small\verb%prove_WORD_one_one : thm -> thm%}\egroup |
| 517 |
|
| 518 |
\SYNOPSIS |
| 519 |
|
| 520 |
|
| 521 |
\DESCRIBE |
| 522 |
|
| 523 |
|
| 524 |
\FAILURE |
| 525 |
|
| 526 |
|
| 527 |
\EXAMPLE |
| 528 |
|
| 529 |
|
| 530 |
\USES |
| 531 |
|
| 532 |
|
| 533 |
\COMMENTS |
| 534 |
|
| 535 |
|
| 536 |
\SEEALSO |
| 537 |
|
| 538 |
|
| 539 |
\ENDDOC |
| 540 |
\DOC{prove\_WORD\_onto} |
| 541 |
|
| 542 |
\TYPE {\small\verb%prove_WORD_onto : thm -> thm%}\egroup |
| 543 |
|
| 544 |
\SYNOPSIS |
| 545 |
|
| 546 |
|
| 547 |
\DESCRIBE |
| 548 |
|
| 549 |
|
| 550 |
\FAILURE |
| 551 |
|
| 552 |
|
| 553 |
\EXAMPLE |
| 554 |
|
| 555 |
|
| 556 |
\USES |
| 557 |
|
| 558 |
|
| 559 |
\COMMENTS |
| 560 |
|
| 561 |
|
| 562 |
\SEEALSO |
| 563 |
|
| 564 |
|
| 565 |
\ENDDOC |
| 566 |
\DOC{prove\_word\_val} |
| 567 |
|
| 568 |
\TYPE {\small\verb%prove_word_val : int -> thm%}\egroup |
| 569 |
|
| 570 |
\SYNOPSIS |
| 571 |
Proves the theorem characterizing the conversion functions between the |
| 572 |
types {\small\verb%:wordn%} and {\small\verb%:num%}. |
| 573 |
|
| 574 |
\DESCRIBE |
| 575 |
{\small\verb%prove_word_val%} takes a natural number as its single argument. It |
| 576 |
proves a theorem which characterizes the conversion functions {\small\verb%NVALn%} |
| 577 |
and {\small\verb%NWORDn%}. The theorem is returned as the function value, and it |
| 578 |
takes the following form: |
| 579 |
{\par\samepage\setseps\small\begin{verbatim} |
| 580 |
|- (!w. NWORDn(NVALn w) = w) /\ |
| 581 |
(!m. m < (2 EXP n) ==> (NVALn(NWORDn m) = m)) |
| 582 |
\end{verbatim}} |
| 583 |
|
| 584 |
\FAILURE |
| 585 |
Fails if the type {\small\verb%:wordn%} or the conversion functions {\small\verb%:NVALn%} and |
| 586 |
{\small\verb%:NWORDn%} have not been defined. |
| 587 |
|
| 588 |
\EXAMPLE |
| 589 |
The following HOL session illustrates the use of this function: |
| 590 |
{\par\samepage\setseps\small\begin{verbatim} |
| 591 |
# let WORD_VAL_3 = save_thm(`WORD_VAL_3`, prove_word_val 3);; |
| 592 |
WORD_VAL_3 = |
| 593 |
|- (!w. NWORD3(NVAL3 w) = w) /\ |
| 594 |
(!n. n < (2 EXP 3) ==> (NVAL3(NWORD3 n) = n)) |
| 595 |
\end{verbatim}} |
| 596 |
|
| 597 |
\SEEALSO |
| 598 |
{\small\verb%define_wordn_type%}, {\small\verb%define_word_val%}. |
| 599 |
|
| 600 |
\ENDDOC |
| 601 |
\DOC{use\_wordn} |
| 602 |
|
| 603 |
\TYPE {\small\verb%use_wordn : int -> (thm)list%}\egroup |
| 604 |
|
| 605 |
\SYNOPSIS |
| 606 |
Defines the type of n-bit words and proves some basic theorems. |
| 607 |
|
| 608 |
\DESCRIBE |
| 609 |
The function {\small\verb%use_wordn%} is one of the top level user functions of the |
| 610 |
wordn library. It provides a facility to define the type of n-bit |
| 611 |
words and to prove some basic theorems on this type. When the user |
| 612 |
needs to use n-bit words in an application, he/she can simply make |
| 613 |
a call to {\small\verb%use_wordn%} with a single argument {\small\verb%n%}. This will define the |
| 614 |
type {\small\verb%:wordn%}, and a list of basic theorems about the type are returned. |
| 615 |
{\small\verb%use_wordn%} combines the function {\small\verb%define_wordn_type%} and the following |
| 616 |
functions for proving theorems about the type of n-bit words: |
| 617 |
{\small\verb%prove_function_defn_thm%},\ {\small\verb%prove_wordn_induction_thm%},\ |
| 618 |
{\small\verb%prove_wordn_cases_thm%},\ {\small\verb%prove_BITS_one_one%},\ |
| 619 |
{\small\verb%prove_BITS_onto%},\ {\small\verb%prove_WORD_one_one%},\ |
| 620 |
{\small\verb%prove_WORD_onto%},\ {\small\verb%prove_LENGTH_BITS_thm%}. |
| 621 |
|
| 622 |
\FAILURE |
| 623 |
Failure occurs if any of the functions invoked fails. |
| 624 |
|
| 625 |
|
| 626 |
\EXAMPLE |
| 627 |
The HOL session below illustrates the use of the function {\small\verb%use_wordn%}: |
| 628 |
{\par\samepage\setseps\small\begin{verbatim} |
| 629 |
# let [word3; word3_BITS_11; word3_BITS_onto; |
| 630 |
# word3_WORD_11; word3_WORD_onto; word3_LENGTH_BITS; |
| 631 |
# word3_FNDEF; word3_INDUCT; word3_CASES] = |
| 632 |
# use_wordn 3;; |
| 633 |
word3 = |
| 634 |
|- (!w. WORD3(BITS3 w) = w) /\ |
| 635 |
(!l. (LENGTH l = 3) = (BITS3(WORD3 l) = l)) |
| 636 |
word3_BITS_11 = |- !w' w. (BITS3 w = BITS3 w') ==> (w = w') |
| 637 |
word3_BITS_onto = |- !l. (LENGTH l = 3) ==> (?w. BITS3 w = l) |
| 638 |
word3_WORD_11 = |
| 639 |
|- !l l'. |
| 640 |
(LENGTH l = 3) /\ (LENGTH l' = 3) ==> |
| 641 |
(WORD3 l = WORD3 l') ==> |
| 642 |
(l = l') |
| 643 |
word3_WORD_onto = |- !w. ?l. (LENGTH l = 3) /\ (WORD3 l = w) |
| 644 |
word3_LENGTH_BITS = |- !w. LENGTH(BITS3 w) = 3 |
| 645 |
word3_FNDEF = |- !f. ?! fn. !b0 b1 b2. fn(WORD3[b0;b1;b2]) = f b0 b1 b2 |
| 646 |
word3_INDUCT = |- !P. (!b0 b1 b2. P(WORD3[b0;b1;b2])) ==> (!w. P w) |
| 647 |
word3_CASES = |- !w. ?b0 b1 b2. w = WORD3[b0;b1;b2] |
| 648 |
\end{verbatim}} |
| 649 |
|
| 650 |
\SEEALSO |
| 651 |
{\small\verb%define_wordn_type%}, {\small\verb%prove_function_defn_thm%}, {\small\verb%prove_wordn_induction_thm%}, |
| 652 |
{\small\verb%prove_wordn_cases_thm%}, {\small\verb%prove_BITS_one_one%}, |
| 653 |
{\small\verb%prove_BITS_onto%}, {\small\verb%prove_WORD_one_one%}, |
| 654 |
{\small\verb%prove_WORD_onto%}, {\small\verb%prove_LENGTH_BITS_thm%}. |
| 655 |
|
| 656 |
|
| 657 |
\ENDDOC |
| 658 |
\DOC{wordn\_bit\_ops} |
| 659 |
|
| 660 |
\TYPE {\small\verb%wordn_bit_ops : thm -> int -> (thm)list%}\egroup |
| 661 |
|
| 662 |
\SYNOPSIS |
| 663 |
Defines bitwise operators and proves some basic theorems about them. |
| 664 |
|
| 665 |
\DESCRIBE |
| 666 |
{\small\verb%wordn_bit_ops wordn n%}, where {\small\verb%wordn%} is the theorem returned by |
| 667 |
{\small\verb%define_wordn_type%} and {\small\verb%n%} is the word length, defines a set of |
| 668 |
commonly used bitwise logical operators and proves some basic theorems |
| 669 |
about these operators. It combines the functions of |
| 670 |
{\small\verb%define_wordn_bit_ops%}, and {\small\verb%prove_bit_op_thms%}. |
| 671 |
|
| 672 |
\FAILURE |
| 673 |
Fails if either it is not in draft mode, or the input theorem is not |
| 674 |
in the expected form or the type {\small\verb%:wordn%} has not been defined. |
| 675 |
|
| 676 |
\EXAMPLE |
| 677 |
{\small\verb%wordn_bit_ops word3 3%} returns the following list of definitions and |
| 678 |
theorems: |
| 679 |
{\par\samepage\setseps\small\begin{verbatim} |
| 680 |
[ |- !b0 b1 b2. NOT3(WORD3[b0;b1;b2]) = WORD3(B_NOT[b0;b1;b2]); |
| 681 |
|- !b0 b1 b2 w. |
| 682 |
(WORD3[b0;b1;b2]) AND3 w = WORD3(B_AND[b0;b1;b2](BITS3 w)); |
| 683 |
|- !b0 b1 b2 w. |
| 684 |
(WORD3[b0;b1;b2]) OR3 w = WORD3(B_OR[b0;b1;b2](BITS3 w)); |
| 685 |
|- !b0 b1 b2 w. |
| 686 |
(WORD3[b0;b1;b2]) XOR3 w = WORD3(B_XOR[b0;b1;b2](BITS3 w)); |
| 687 |
|- !w. NOT3(NOT3 w) = w; |
| 688 |
|- !w1 w2. w1 AND3 w2 = w2 AND3 w1; |
| 689 |
|- !w1 w2. w1 OR3 w2 = w2 OR3 w1; |
| 690 |
|- !w1 w2. w1 XOR3 w2 = w2 XOR3 w1; |
| 691 |
|- !w1 w2 w3. w1 AND3 (w2 AND3 w3) = (w1 AND3 w2) AND3 w3; |
| 692 |
|- !w1 w2 w3. w1 OR3 (w2 OR3 w3) = (w1 OR3 w2) OR3 w3; |
| 693 |
|- !w1 w2 w3. w1 XOR3 (w2 XOR3 w3) = (w1 XOR3 w2) XOR3 w3 ] |
| 694 |
\end{verbatim}} |
| 695 |
|
| 696 |
\SEEALSO |
| 697 |
{\small\verb%define_wordn_bit_ops%}, {\small\verb%prove_bit_op_thms%}. |
| 698 |
|
| 699 |
\ENDDOC |
| 700 |
\DOC{wordn\_CASES\_TAC} |
| 701 |
|
| 702 |
\TYPE {\small\verb%wordn_CASES_TAC : term -> thm_tactic%}\egroup |
| 703 |
|
| 704 |
\SYNOPSIS |
| 705 |
Instantiates variables of type {\small\verb%:wordn%} with a list of bits. |
| 706 |
|
| 707 |
\DESCRIBE |
| 708 |
The tactic {\small\verb%wordn_CASES_TAC%} instantiates occurrences of a variable of |
| 709 |
type {\small\verb%:wordn%} in the goal with a list of bits. It takes, as its |
| 710 |
arguments, a term which indicates which variable is to be instantiated |
| 711 |
and a theorem which should in the form returned by |
| 712 |
{\small\verb%prove_wordn_cases%}. The specification of {\small\verb%wordn_CASES_TAC%} is: |
| 713 |
{\par\samepage\setseps\small\begin{verbatim} |
| 714 |
A ?- t[w] |
| 715 |
=============================== wordn_CASES_TAC "w" wordn_CASES |
| 716 |
A ?- t[WORDn[b0';...;bn-1']/w] |
| 717 |
\end{verbatim}} |
| 718 |
where {\small\verb%wordn_CASES%} is the following theorem: |
| 719 |
{\par\samepage\setseps\small\begin{verbatim} |
| 720 |
|- !w. ?b0...bn-1. w = WORDn[b0;...bn-1] |
| 721 |
\end{verbatim}} |
| 722 |
|
| 723 |
This function specializes the universally quantified variable in the |
| 724 |
theorem {\small\verb%wordn_CASES%} with the given term which should match the |
| 725 |
variable required to be instantiated in the goal. It then eliminaates |
| 726 |
the existentially quantified vairables {\small\verb%b0%},...,{\small\verb%bn-1%} by choosing some |
| 727 |
variants which are not free in the assumptions; normally these are |
| 728 |
just {\small\verb%b0%},...,{\small\verb%bn-1%}. It then substitutes the right-hand side of the |
| 729 |
equation for the occurrences of the variable {\small\verb%w%} in the goal. |
| 730 |
|
| 731 |
\FAILURE |
| 732 |
Fails if the substitution cannot be performed due to no matching |
| 733 |
variable of the correct type is found or other reasons as given in the |
| 734 |
failure conditions of {\small\verb%CHOOSE_TAC%} and {\small\verb%SUBST1_TAC%}. |
| 735 |
|
| 736 |
\EXAMPLE |
| 737 |
Suppose that one wants to solve the following goal: |
| 738 |
{\par\samepage\setseps\small\begin{verbatim} |
| 739 |
"!w. LENGTH(BITS3 w) = 3" |
| 740 |
\end{verbatim}} |
| 741 |
The tactic {\small\verb%GEN_TAC THEN wordn_CASES_TAC "w" word3_CASES%} |
| 742 |
may be used to transform it to |
| 743 |
{\par\samepage\setseps\small\begin{verbatim} |
| 744 |
"LENGTH(BITS3(WORD3[b0;b1;b2])) = 3" |
| 745 |
\end{verbatim}} |
| 746 |
|
| 747 |
\SEEALSO |
| 748 |
{\small\verb%wordn_X_CASES_TAC%}, {\small\verb%prove_wordn_cases_thm%}, |
| 749 |
{\small\verb%CHOOSE_TAC%}, {\small\verb%SUBST1_TAC%}. |
| 750 |
|
| 751 |
\ENDDOC |
| 752 |
\DOC{wordn\_CONV} |
| 753 |
|
| 754 |
\TYPE {\small\verb%wordn_CONV : conv%}\egroup |
| 755 |
|
| 756 |
\SYNOPSIS |
| 757 |
Definition scheme for wordn constants. |
| 758 |
|
| 759 |
\DESCRIBE |
| 760 |
{\small\verb%wordn_CONV "#b1...bn"%} returns |
| 761 |
{\par\samepage\setseps\small\begin{verbatim} |
| 762 |
|- #b1...bn = WORDn [b1;...;bn] |
| 763 |
\end{verbatim}} |
| 764 |
|
| 765 |
\FAILURE |
| 766 |
|
| 767 |
|
| 768 |
\EXAMPLE |
| 769 |
{\small\verb%wordn_CONV "#110"%} returns the following theorem: |
| 770 |
{\par\samepage\setseps\small\begin{verbatim} |
| 771 |
|- #110 = WORD3 [T; T; F] |
| 772 |
\end{verbatim}} |
| 773 |
|
| 774 |
\SEEALSO |
| 775 |
{\small\verb%define_wordn_type%}, {\small\verb%wordn_NVAL_CONV%}, {\small\verb%wordn_NWORD_CONV%}. |
| 776 |
|
| 777 |
\ENDDOC |
| 778 |
\DOC{wordn\_EQ\_CONV} |
| 779 |
|
| 780 |
\TYPE {\small\verb%wordn_EQ_CONV : thm -> conv%}\egroup |
| 781 |
|
| 782 |
\SYNOPSIS |
| 783 |
Derives a theorem stating the equality of two words. |
| 784 |
|
| 785 |
\DESCRIBE |
| 786 |
{\small\verb%wordn_EQ_CONV wordn "w1 = w2"%} returns a theorem |
| 787 |
{\par\samepage\setseps\small\begin{verbatim} |
| 788 |
|- (w1 = w2) = T |
| 789 |
\end{verbatim}} |
| 790 |
if and only if {\small\verb%w1%} is equal to {\small\verb%w2%}, otherwise, it returns |
| 791 |
{\par\samepage\setseps\small\begin{verbatim} |
| 792 |
|- (w1 = w2) = F |
| 793 |
\end{verbatim}} |
| 794 |
{\small\verb%wordn%} is the type definition theorem returned by {\small\verb%define_wordn_type%}. |
| 795 |
|
| 796 |
\FAILURE |
| 797 |
|
| 798 |
|
| 799 |
\EXAMPLE |
| 800 |
{\small\verb%wordn_EQ_CONV word3 "#010 = #110";;%} return the following theorem: |
| 801 |
{\par\samepage\setseps\small\begin{verbatim} |
| 802 |
|- (#010 = #110) = F |
| 803 |
\end{verbatim}} |
| 804 |
|
| 805 |
\SEEALSO |
| 806 |
{\small\verb%define_wordn_type%}, {\small\verb%wordn_CONV%}. |
| 807 |
|
| 808 |
\ENDDOC |
| 809 |
\DOC{wordn\_NVAL\_CONV} |
| 810 |
|
| 811 |
\TYPE {\small\verb%wordn_NVAL_CONV : conv%}\egroup |
| 812 |
|
| 813 |
\SYNOPSIS |
| 814 |
Derives a theorem stating the value of a word. |
| 815 |
|
| 816 |
\DESCRIBE |
| 817 |
{\small\verb%wordn_NVAL_CONV%} takes a term in the form {\small\verb%"NVALn #..."%} and derives |
| 818 |
a theorem stating the value of the given word when interpreted as |
| 819 |
natural number in a big-endian format. The length of the string |
| 820 |
following the hash {\small\verb%#%} should be {\small\verb%n%}, and it should consist of only |
| 821 |
the digits {\small\verb%0%} and {\small\verb%1%}. |
| 822 |
|
| 823 |
\FAILURE |
| 824 |
Fails if the type {\small\verb%:wordn%} or the constant {\small\verb%NVALn%} has not been |
| 825 |
defined, or the string is not in the form specified above. |
| 826 |
|
| 827 |
\EXAMPLE |
| 828 |
The HOL session below illustrates the use of this conversion: |
| 829 |
{\par\samepage\setseps\small\begin{verbatim} |
| 830 |
# let word3_val_6 = wordn_NVAL_CONV "NVAL3 #110";; |
| 831 |
word3_val_6 = |- NVAL3 #110 = 6 |
| 832 |
\end{verbatim}} |
| 833 |
|
| 834 |
\SEEALSO |
| 835 |
{\small\verb%define_wordn_type%}, {\small\verb%define_word_val%}, {\small\verb%wordn_NWORD_CONV%}. |
| 836 |
|
| 837 |
\ENDDOC |
| 838 |
\DOC{wordn\_NWORD\_CONV} |
| 839 |
|
| 840 |
\TYPE {\small\verb%wordn_NWORD_CONV : conv%}\egroup |
| 841 |
|
| 842 |
\SYNOPSIS |
| 843 |
Derives a theorem stating the representation of a natural number in |
| 844 |
an n-bit word. |
| 845 |
|
| 846 |
\DESCRIBE |
| 847 |
{\small\verb%wordn_NWORD_CONV%} takes a term in the form {\small\verb%"NWORDn m"%} and derives a |
| 848 |
theorem stating the n-bit word representing the natural number {\small\verb%m%} as |
| 849 |
below: |
| 850 |
{\par\samepage\setseps\small\begin{verbatim} |
| 851 |
|- NWORDn m = #... |
| 852 |
\end{verbatim}} |
| 853 |
If {\small\verb%m%} is greater than the maximium that an n-bit word can represent, |
| 854 |
{\small\verb%m MOD (2 EXP n)%} will be used to work out the n-bit word instead. By |
| 855 |
virtue of the theorem returned by {\small\verb%prove_NWORD_MOD%}, the above theorem |
| 856 |
is still valid. |
| 857 |
|
| 858 |
\FAILURE |
| 859 |
Fails if the type {\small\verb%:wordn%} or the function {\small\verb%NWORDn%} has not been defined. |
| 860 |
|
| 861 |
\EXAMPLE |
| 862 |
The HOL session below illustrates the use of this conversion: |
| 863 |
{\par\samepage\setseps\small\begin{verbatim} |
| 864 |
# wordn_NWORD_CONV "NWORD3 6";; |
| 865 |
|- NWORD3 6 = #110 |
| 866 |
|
| 867 |
# wordn_NWORD_CONV "NWORD3 16";; |
| 868 |
|- NWORD3 16 = #000 |
| 869 |
\end{verbatim}} |
| 870 |
|
| 871 |
\SEEALSO |
| 872 |
{\small\verb%define_wordn_type%}, {\small\verb%define_word_val%}, {\small\verb%prove_NWORD_MOD%}, {\small\verb%wordn_NVAL_CONV%}. |
| 873 |
|
| 874 |
\ENDDOC |
| 875 |
\DOC{wordn\_X\_CASES\_TAC} |
| 876 |
|
| 877 |
\TYPE {\small\verb%wordn_X_CASES_TAC : term -> thm -> (term list) -> tactic%}\egroup |
| 878 |
|
| 879 |
\SYNOPSIS |
| 880 |
Instantiates variables of type {\small\verb%:wordn%} with a list of bits. |
| 881 |
|
| 882 |
\DESCRIBE |
| 883 |
The tactic {\small\verb%wordn_X_CASES_TAC%} instantiates occurrences of a variable of |
| 884 |
type {\small\verb%:wordn%} in the goal with a list of bits. It takes, as its |
| 885 |
arguments, a term which indicates which variable is to be |
| 886 |
instantiated, a theorem which should in the form returned by |
| 887 |
{\small\verb%prove_wordn_cases%} and a list of terms which is used as the bits in |
| 888 |
the instantiation. The specification of {\small\verb%wordn_X_CASES_TAC%} is: |
| 889 |
{\par\samepage\setseps\small\begin{verbatim} |
| 890 |
A ?- t[w] |
| 891 |
=============================== wordn_X_CASES_TAC "w" wordn_CASES |
| 892 |
A ?- t[WORDn[c0;...;cn-1]/w] ["c0";..."cn-1"] |
| 893 |
\end{verbatim}} |
| 894 |
\noindent where {\small\verb%wordn_CASES%} has the following theorem: |
| 895 |
{\par\samepage\setseps\small\begin{verbatim} |
| 896 |
|- !w. ?b0...bn. w = WORDn[b0;...bn] |
| 897 |
\end{verbatim}} |
| 898 |
|
| 899 |
This function specializes the universally quantified variable in the |
| 900 |
theorem {\small\verb%wordn_CASES%} with the given term which should match the |
| 901 |
variable required to be instantiated in the goal. It then eliminates |
| 902 |
the existentially quantified vairables {\small\verb%b0%},...,{\small\verb%bn-1%} using the terms |
| 903 |
given in the last argument as specific witness. |
| 904 |
It then substitutes the right-hand side of the |
| 905 |
equation for the occurrences of the variable {\small\verb%w%} in the goal. |
| 906 |
|
| 907 |
\FAILURE |
| 908 |
Fails if the substitution cannot be performed due to no matching |
| 909 |
variable of the correct type is found, or the supplied |
| 910 |
terms involve variables which are free in the assumption or other reasons |
| 911 |
as given in the failure conditions of {\small\verb%X_CHOOSE_TAC%} and {\small\verb%SUBST1_TAC%}. |
| 912 |
|
| 913 |
\EXAMPLE |
| 914 |
Suppose that one wants to solve the following goal: |
| 915 |
{\par\samepage\setseps\small\begin{verbatim} |
| 916 |
"!w. LENGTH(BITS3 w) = 3" |
| 917 |
\end{verbatim}} |
| 918 |
\noindent The tactic {\small\verb%GEN_TAC THEN wordn_X_CASES_TAC "w" word3_CASES ["c1";"c2";"c3"]%} |
| 919 |
may be used to transform it to |
| 920 |
{\par\samepage\setseps\small\begin{verbatim} |
| 921 |
"LENGTH(BITS3(WORD3[c1;c2;c3])) = 3" |
| 922 |
\end{verbatim}} |
| 923 |
|
| 924 |
\SEEALSO |
| 925 |
{\small\verb%wordn_CASES_TAC%}, {\small\verb%prove_wordn_cases_thm%}, |
| 926 |
{\small\verb%X_CHOOSE_TAC%}, {\small\verb%SUBST1_TAC%}. |
| 927 |
|
| 928 |
\ENDDOC |