%META:TOPICINFO{author="AndreaSterbini" date="1006849030" format="1.0" version="1.3"}%
*Prolog examples Plugin*

This plugin nicely formats a Prolog piece of code, together with its query results.

His brother is the PerlSamplePlugin.

*TODO:*
	* Apply a timeout to the Prolog execution (spawn a delayed killer process)

*Usage example*
<table border=1><tr><th> You type: </th><th> You get: </th><th> If correctly installed: </th></tr>
<tr valign=top>

<td>
<pre>
%<nop>PROLOGSAMPLE{"
knows(andrea,automi).
knows(annalisa,karnaugh).
prerequisiteof(automi,karnaugh).
prerequisiteof(karnaugh,boole).
mayknow(X,U) :- knows(U,Y),
	prerequisiteof(Y,X).
mayknow(X,U) :- knows(U,X)." 
query="?- mayknow(TOPIC,USER)." 
vars="TOPIC,USER"}% 
</pre>
</td>


<td>
<table border=0>
	<tr>
		<th bgcolor = #aaaaaa>Initial KB</th>
	</tr>
	<tr valign="top" bgcolor = #eeeeff>
		<td bgcolor="#eeeeee"><font color="#ff0000"><pre>
knows(andrea,automi).
knows(annalisa,karnaugh).
prerequisiteof(automi,karnaugh).
prerequisiteof(karnaugh,boole).
mayknow(X,U) :- knows(U,Y),
	prerequisiteof(Y,X).
mayknow(X,U) :- knows(U,X).</pre></font></td>
	</tr>
	<tr>
		<th bgcolor = #aaffaa>Query:</th>
	</tr>
	<tr>
		<td bgcolor = #eeffee><pre>?- mayknow(TOPIC,USER).</pre></td>
	</tr>
	<tr valign="top" bgcolor = #eeeeff>
		<th bgcolor = #ffaaff>Result:</th>
	</tr>
	<tr valign="top" bgcolor = #eeeeff>
		<td bgcolor = #ffeeff><pre>found solutions:
	<b>TOPIC</b> = karnaugh
	<b>USER</b> = andrea
found solutions:
	<b>TOPIC</b> = boole
	<b>USER</b> = annalisa
no more solutions

</pre></td>
	</tr>
</table>
</td>

<td>
%PROLOGSAMPLE{"
knows(andrea,automi).
knows(annalisa,karnaugh).
prerequisiteof(automi,karnaugh).
prerequisiteof(karnaugh,boole).
mayknow(X,U) :- knows(U,Y),
	prerequisiteof(Y,X).
mayknow(X,U) :- knows(U,X)." 
query="?- mayknow(TOPIC,USER)." 
vars="TOPIC,USER"}% 
</td></tr>
</table>

*Installation*

	* Unzip the *%TOPIC%<nop>.zip* file in your TWiki installation directory.
	* Install the *Language::Prolog* Perl module attached to it in your Perl @LIB path.
	  (use this one, it complains less respect to the
 [[http://www.cpan.org][CPAN]]  version.) 

If the installation is correct you will see a nice table showing the code, its value and stdout/stderr near the example.

-- %TWIKIWEB%.AndreaSterbini - 27 Nov 2001 <br>

%META:FILEATTACHMENT{name="Language-Prolog.zip" attr="" comment="Updated Prolog module (look for #AS comments)" date="981248520" path="Language-Prolog.zip" size="12347" user="AndreaSterbini" version=""}%
%META:TOPICMOVED{by="AndreaSterbini" date="1006844949" from="Plugins.PrologsamplePlugin" to="Plugins.PrologSamplePlugin"}%
