/usr/share/doc/racket/racklog/set-of.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>9 Set Predicates</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Racklog:<span class="mywbr"> </span> Prolog-<wbr></wbr>Style Logic Programming</a></td></tr></table></div><div class="tocviewsublistonly" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="simple.html" class="tocviewlink" data-pltdoc="x">Simple Goals and Queries</a></td></tr><tr><td align="right">2 </td><td><a href="predicates.html" class="tocviewlink" data-pltdoc="x">Predicates</a></td></tr><tr><td align="right">3 </td><td><a href="racket-w-logic.html" class="tocviewlink" data-pltdoc="x">Using Conventional Racket Expressions in Racklog</a></td></tr><tr><td align="right">4 </td><td><a href="backtracking.html" class="tocviewlink" data-pltdoc="x">Backtracking</a></td></tr><tr><td align="right">5 </td><td><a href="unification.html" class="tocviewlink" data-pltdoc="x">Unification</a></td></tr><tr><td align="right">6 </td><td><a href="and-or.html" class="tocviewlink" data-pltdoc="x">Conjuctions and Disjunctions</a></td></tr><tr><td align="right">7 </td><td><a href="lv-manip.html" class="tocviewlink" data-pltdoc="x">Manipulating Racklog Variables</a></td></tr><tr><td align="right">8 </td><td><a href="cut.html" class="tocviewlink" data-pltdoc="x">The Cut (<span class="RktSym"><span class="RktStxLink">!</span></span>)</a></td></tr><tr><td align="right">9 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Set Predicates</a></td></tr><tr><td align="right">10 </td><td><a href="Racklog_Module_Language.html" class="tocviewlink" data-pltdoc="x">Racklog Module Language</a></td></tr><tr><td align="right">11 </td><td><a href="glossary.html" class="tocviewlink" data-pltdoc="x">Glossary of Racklog Primitives</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr></table></div></div></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="cut.html" title="backward to "8 The Cut (!)"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Racklog: Prolog-Style Logic Programming"" data-pltdoc="x">up</a> <a href="Racklog_Module_Language.html" title="forward to "10 Racklog Module Language"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "racklog/racklog.scrbl")" x-part-tag=""set-of"">9<tt> </tt><a name="(part._set-of)"></a>Set Predicates</h3><p>The goal</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span><span class="hspace"> </span><span class="RktVar">X</span><span class="hspace"> </span><span class="RktVar">G</span><span class="hspace"> </span><span class="RktVar">Bag</span><span class="RktPn">)</span></p></blockquote><p>unifies with <span class="RktVar">Bag</span> the list of all instantiations of
<span class="RktVar">X</span> for which <span class="RktVar">G</span> succeeds. Thus, the following query
asks for all the things known —<wbr></wbr> ie, the collection of things
such that someone knows them:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25which%29%29" class="RktStxLink" data-pltdoc="x">%which</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">things-known</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25let%29%29" class="RktStxLink" data-pltdoc="x">%let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">%knows</span><span class="hspace"> </span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">things-known</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'((things-known</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">TeX</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">Racket</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">Prolog</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">Penelope</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">TeX</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">Prolog</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">Odysseus</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">TeX</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">calculus</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">archery))</span></p></td></tr></table></td></tr></table></blockquote><p>This is the only solution for this goal:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25more%29%29" class="RktValLink" data-pltdoc="x">%more</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote><p>Note that some things —<wbr></wbr> eg, TeX —<wbr></wbr> are enumerated
more than once. This is because more than one person knows
TeX. To remove duplicates, use the predicate
<span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25set-of%29%29" class="RktValLink" data-pltdoc="x">%set-of</a></span>
instead of <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25which%29%29" class="RktStxLink" data-pltdoc="x">%which</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">things-known</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25let%29%29" class="RktStxLink" data-pltdoc="x">%let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25set-of%29%29" class="RktValLink" data-pltdoc="x">%set-of</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">%knows</span><span class="hspace"> </span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">things-known</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((things-known TeX Racket Prolog Penelope Odysseus calculus archery))</span></p></td></tr></table></blockquote><p>In the above, the free variable <span class="RktVar">someone</span> in the
<span class="RktSym">%knows</span>-goal is used as if it
were existentially quantified. In contrast, Prolog’s
versions of
<span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span> and <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25set-of%29%29" class="RktValLink" data-pltdoc="x">%set-of</a></span> fix it for each solution of the
set-predicate goal. We can do it too with some additional
syntax that identifies the free variable.
Eg,</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25which%29%29" class="RktStxLink" data-pltdoc="x">%which</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">things-known</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25let%29%29" class="RktStxLink" data-pltdoc="x">%let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span><span class="hspace"> </span><span class="RktSym">x</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28form._%28%28lib._racklog%2Fmain..rkt%29._~25free-vars%29%29" class="RktStxLink" data-pltdoc="x">%free-vars</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">someone</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">%knows</span><span class="hspace"> </span><span class="RktSym">someone</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">things-known</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((someone . Odysseus) (things-known TeX Racket Prolog Penelope))</span></p></td></tr></table></blockquote><p>The bag of things known by <span style="font-style: italic">one</span> someone is
returned. That someone is Odysseus. The query can be
retried for more solutions, each listing the things known by
a different someone:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25more%29%29" class="RktValLink" data-pltdoc="x">%more</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((someone . Penelope) (things-known TeX Prolog Odysseus))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25more%29%29" class="RktValLink" data-pltdoc="x">%more</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((someone . Telemachus) (things-known TeX calculus))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25more%29%29" class="RktValLink" data-pltdoc="x">%more</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((someone . Odysseus) (things-known archery))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25more%29%29" class="RktValLink" data-pltdoc="x">%more</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote><p>Racklog also provides two variants of these set predicates,
viz., <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of-1%29%29" class="RktValLink" data-pltdoc="x">%bag-of-1</a></span> and <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25set-of-1%29%29" class="RktValLink" data-pltdoc="x">%set-of-1</a></span>. These act like <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25bag-of%29%29" class="RktValLink" data-pltdoc="x">%bag-of</a></span>
and <span class="RktSym"><a href="glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25set-of%29%29" class="RktValLink" data-pltdoc="x">%set-of</a></span> but fail if the resulting bag or set is empty.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="cut.html" title="backward to "8 The Cut (!)"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Racklog: Prolog-Style Logic Programming"" data-pltdoc="x">up</a> <a href="Racklog_Module_Language.html" title="forward to "10 Racklog Module Language"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|