File: OK-IF.html

package info (click to toggle)
acl2 3.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 36,712 kB
  • ctags: 38,396
  • sloc: lisp: 464,023; makefile: 5,470; sh: 86; csh: 47; cpp: 25; ansic: 22
file content (48 lines) | stat: -rw-r--r-- 2,469 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<html>
<head><title>OK-IF.html  --  ACL2 Version 3.1</title></head>
<body text=#000000 bgcolor="#FFFFFF">
<h2>OK-IF</h2>conditional exit from <code>break-rewrite</code>
<pre>Major Section:  <a href="BREAK-REWRITE.html">BREAK-REWRITE</a>
</pre><p>


<pre>
Example Form:
:ok-if (null (brr@ :wonp))
<p>
General Form:
:ok-if expr
</pre>

where <code>expr</code> is a term involving no free variables other than <code>state</code>
and returning one non-<code>state</code> result which is treated as Boolean.
This form is intended to be executed from within <code>break-rewrite</code>
(see <a href="BREAK-REWRITE.html">break-rewrite</a>).<p>

Consider first the simple situation that the <code>(ok-if term)</code> is a
command read by <code>break-rewrite</code>.  Then, if the term is non-<code>nil</code>,
<code>break-rewrite</code> exits and otherwise it does not.<p>

More generally, <code>ok-if</code> returns an ACL2 error triple
<code>(mv erp val state)</code>.  (See <a href="LD.html">ld</a> for more on error triples.)  If
any form being evaluated as a command by <code>break-rewrite</code> returns
the triple returned by <code>(ok-if term)</code> then the effect of that form
is to exit <a href="BREAK-REWRITE.html">break-rewrite</a> if term is non-<code>nil</code>.  Thus, one
might define a function or macro that returns the value of <code>ok-if</code>
expressions on all outputs and thus create a convenient new way to
exit <code>break-rewrite</code>.<p>

The exit test, <code>term</code>, generally uses <code>brr@</code> to access context sensitive
information about the attempted rule application.  See <a href="BRR_at_.html">brr@</a>.
<code>Ok-if</code> is useful inside of command sequences produced by break
conditions.  See <a href="MONITOR.html">monitor</a>.  <code>:ok-if</code> is most useful after an <code>:eval</code>
command has caused <code>break-rewrite</code> to try to apply the rule because in
the resulting break environment <code>expr</code> can access such things as
whether the rule succeeded, if so, what term it produced, and if
not, why.  There is no need to use <code>:ok-if</code> before <code>:eval</code>ing the rule
since the same effects could be achieved with the break condition on
the rule itself.  Perhaps we should replace this concept with
<code>:eval-and-break-if</code>?  Time will tell.
<br><br><br><a href="acl2-doc.html"><img src="llogo.gif"></a> <a href="acl2-doc-index.html"><img src="index.gif"></a>
</body>
</html>