<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>MAD.....Math_C</title>
	<atom:link href="http://madmathc.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://madmathc.wordpress.com</link>
	<description>We are NOT MAD! but we are Member At Discrete Math C....</description>
	<lastBuildDate>Tue, 22 Dec 2009 13:16:00 +0000</lastBuildDate>
	<language>id</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='madmathc.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>MAD.....Math_C</title>
		<link>http://madmathc.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://madmathc.wordpress.com/osd.xml" title="MAD.....Math_C" />
	<atom:link rel='hub' href='http://madmathc.wordpress.com/?pushpress=hub'/>
		<item>
		<title>INPUT and OUTPUT in Prolog ch.3</title>
		<link>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-3/</link>
		<comments>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-3/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 13:16:00 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=183</guid>
		<description><![CDATA[This is the last post of this session&#8230;. (4) Example I make this file.. And the second file &#8230; Next, type this rule&#8230; and save it in .pl Consult it in Prolog. Then type this.. ?-combine(&#8216;in1.txt&#8217;,'in2.txt&#8217;,'out1.txt&#8217;). The result is.. Just it? No, look at your computer. You will find file with name out1.txt. Open it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=183&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the last post of this session&#8230;.</p>
<p>(4) Example I make this file..</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/in1a.jpg"><img class="aligncenter size-full wp-image-184" title="in1a" src="http://madmathc.files.wordpress.com/2009/12/in1a.jpg" alt="" width="490" height="273" /></a>And the second file &#8230;</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/in2a.jpg"><img class="aligncenter size-full wp-image-185" title="in2a" src="http://madmathc.files.wordpress.com/2009/12/in2a.jpg" alt="" width="360" height="240" /></a>Next, type this rule&#8230; and save it in .pl</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/combinea.jpg"><img class="aligncenter size-full wp-image-186" title="combinea" src="http://madmathc.files.wordpress.com/2009/12/combinea.jpg" alt="" width="439" height="219" /></a>Consult it in Prolog. Then type this..</p>
<p><strong>?-combine(&#8216;in1.txt&#8217;,'in2.txt&#8217;,'out1.txt&#8217;).</strong></p>
<p>The result is..</p>
<p style="text-align:left;"><a href="http://madmathc.files.wordpress.com/2009/12/combinepl.jpg"><img class="aligncenter size-full wp-image-187" title="combinepl" src="http://madmathc.files.wordpress.com/2009/12/combinepl.jpg" alt="" width="494" height="364" /></a>Just it? No, look at your computer. You will find file with name out1.txt. Open it and look&#8230;</p>
<p style="text-align:left;"><a href="http://madmathc.files.wordpress.com/2009/12/out1a.jpg"><img class="aligncenter size-full wp-image-188" title="out1a" src="http://madmathc.files.wordpress.com/2009/12/out1a.jpg" alt="" width="360" height="240" /></a>(5) You can try to type this. Save it in test1.txt</p>
<p style="text-align:left;"><a href="http://madmathc.files.wordpress.com/2009/12/test1a.jpg"><img class="aligncenter size-full wp-image-189" title="test1a" src="http://madmathc.files.wordpress.com/2009/12/test1a.jpg" alt="" width="360" height="240" /></a>Next type this and save in test2.txt</p>
<p style="text-align:left;"><a href="http://madmathc.files.wordpress.com/2009/12/test2a.jpg"><img class="aligncenter size-full wp-image-190" title="test2a" src="http://madmathc.files.wordpress.com/2009/12/test2a.jpg" alt="" width="360" height="240" /></a>Type this rule and save it in compare.pl<a href="http://madmathc.files.wordpress.com/2009/12/comparea.jpg"><img class="aligncenter size-full wp-image-191" title="comparea" src="http://madmathc.files.wordpress.com/2009/12/comparea.jpg" alt="" width="490" height="273" /></a>Then, consult it in PROLOG. Next type this&#8230;</p>
<p style="text-align:left;"><strong>?-compare(&#8216;test1.txt&#8217;,'test2.txt&#8217;).</strong></p>
<p style="text-align:left;">Then the result is&#8230;.</p>
<p style="text-align:left;"><a href="http://madmathc.files.wordpress.com/2009/12/comparepl.jpg"><img class="aligncenter size-full wp-image-192" title="comparepl" src="http://madmathc.files.wordpress.com/2009/12/comparepl.jpg" alt="" width="494" height="364" /></a>Finally, this chapter have finished. Thanx for coming&#8230; Don&#8217;t forget to give a comment.:-)</p>
<p style="text-align:left;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=183&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/in1a.jpg" medium="image">
			<media:title type="html">in1a</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/in2a.jpg" medium="image">
			<media:title type="html">in2a</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/combinea.jpg" medium="image">
			<media:title type="html">combinea</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/combinepl.jpg" medium="image">
			<media:title type="html">combinepl</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/out1a.jpg" medium="image">
			<media:title type="html">out1a</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/test1a.jpg" medium="image">
			<media:title type="html">test1a</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/test2a.jpg" medium="image">
			<media:title type="html">test2a</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/comparea.jpg" medium="image">
			<media:title type="html">comparea</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/comparepl.jpg" medium="image">
			<media:title type="html">comparepl</media:title>
		</media:content>
	</item>
		<item>
		<title>INPUT and OUTPUT in Prolog ch.2</title>
		<link>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-2/</link>
		<comments>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-2/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 12:48:27 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=170</guid>
		<description><![CDATA[Now we continue to explain other numbers in Practical Exercise INPUT and OUTPUT in Prolog (2) First, type this in notepadand save it. Then type this to make rule for Prolog. Save it ang don&#8217;t forget to add .pl at the end of your filename. Next consult it. After that, type this&#8230; ?-copyterms(&#8216;in.txt&#8217;,'out.txt&#8217;). and press [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=170&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now we continue to explain other numbers in Practical Exercise INPUT and OUTPUT in Prolog</p>
<p>(2) First, type this in notepadand save it.</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/ina.jpg"><img class="aligncenter size-full wp-image-171" title="ina" src="http://madmathc.files.wordpress.com/2009/12/ina.jpg" alt="" width="439" height="219" /></a>Then type this to make rule for Prolog. Save it ang don&#8217;t forget to add .pl at the end of your filename.</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/copytermsa.jpg"><img class="aligncenter size-full wp-image-173" title="copytermsa" src="http://madmathc.files.wordpress.com/2009/12/copytermsa.jpg" alt="" width="439" height="219" /></a>Next consult it. After that, type this&#8230;</p>
<p><strong>?-copyterms(&#8216;in.txt&#8217;,'out.txt&#8217;).</strong></p>
<p>and press Enter</p>
<p style="text-align:center;"><a href="http://madmathc.files.wordpress.com/2009/12/copytermspl.jpg"><img class="aligncenter size-full wp-image-174" title="copytermspl" src="http://madmathc.files.wordpress.com/2009/12/copytermspl.jpg" alt="" width="494" height="364" /></a>Then automatically out.txt appears&#8230; Open it. This is the layout&#8230;</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/outa.jpg"><img class="aligncenter size-full wp-image-175" title="outa" src="http://madmathc.files.wordpress.com/2009/12/outa.jpg" alt="" width="439" height="219" /></a>(3) Type it in testa.txt</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/testaa.jpg"><img class="aligncenter size-full wp-image-178" title="testaa" src="http://madmathc.files.wordpress.com/2009/12/testaa.jpg" alt="" width="360" height="240" /></a>Type this rule. Save it and give name readfile.pl</p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/readfilea.jpg"><img class="aligncenter size-full wp-image-179" title="readfilea" src="http://madmathc.files.wordpress.com/2009/12/readfilea.jpg" alt="" width="439" height="219" /></a>After that, consult it. Next type this&#8230;</p>
<p><strong>?-readfile(&#8216;testa.txt&#8217;).</strong></p>
<p>Then the output is</p>
<p style="text-align:center;"><a href="http://madmathc.files.wordpress.com/2009/12/readfilepl2.jpg"><img class="aligncenter size-full wp-image-180" title="readfilepl2" src="http://madmathc.files.wordpress.com/2009/12/readfilepl2.jpg" alt="" width="494" height="364" /></a>This session will be continued at next post. thank for coming&#8230;:-)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=170&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/ina.jpg" medium="image">
			<media:title type="html">ina</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/copytermsa.jpg" medium="image">
			<media:title type="html">copytermsa</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/copytermspl.jpg" medium="image">
			<media:title type="html">copytermspl</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/outa.jpg" medium="image">
			<media:title type="html">outa</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/testaa.jpg" medium="image">
			<media:title type="html">testaa</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/readfilea.jpg" medium="image">
			<media:title type="html">readfilea</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/readfilepl2.jpg" medium="image">
			<media:title type="html">readfilepl2</media:title>
		</media:content>
	</item>
		<item>
		<title>INPUT and OUTPUT in PROLOG ch.1</title>
		<link>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-1/</link>
		<comments>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-1/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 11:37:20 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=160</guid>
		<description><![CDATA[Huff&#8230; so long I didn&#8217;t write at this blog because many assignments must be done and because these two weeks is the final week of 1st semester, projects and final test are coming to me. T.T&#8230;.But now it is time for me to show u how to finish Practical Exercise in chapter INPUT &#38; OUTPUT. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=160&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Huff&#8230; so long I didn&#8217;t write at this blog because many assignments must be done and because these two weeks is the final week of 1st semester, projects and final test are coming to me. T.T&#8230;.But now it is time for me to show u how to finish Practical Exercise in chapter INPUT &amp; OUTPUT. These are the question :</p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(1) Define a predicate </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>makelower/0</strong></span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"> which reads in a line of characters from the keyboard and outputs it again as a single line with any upper case letters converted to lower case. (The ASCII values of the characters a, z, A and Z are 97, 122, 65 and 90, respectively.) </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Thus the following would be a typical use of </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>makelower:</strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>?- makelower. </strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>: This is an Example 123 inCLUDing numbers and symbols +-*/@[] XYz </strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>this is an example 123 including numbers and symbols +-*/@[] xyz </strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>yes </strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(2) Define a predicate </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>copyterms</strong></span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"> which reads all the terms in a text file and outputs them as terms to another text file one by one on separate lines. The output file should be in a format suitable for use as the input file in a subsequent call of </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>copyterms</strong></span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">. Thus for example if the input file contained </span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">&#8216;first term&#8217;. &#8216;second term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">&#8216;third term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">fourth. &#8216;fifth term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">sixth. </span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">The output file would contain </span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">first term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">&#8216;second term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">&#8216;third term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">fourth. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">&#8216;fifth term&#8217;. </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">sixth. </span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(3) Create a text file testa.txt containing two lines, each of five characters followed by a new line, e.g. </span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">abcde </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">fghij</span></span></p>
<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Define a predicate readfile that will read  fifteen characters from this file one by one and output the ASCII value of each character. Use this to establish whether the representations of &#8216;end of file&#8217; and &#8216;end of record&#8217; for your version of Prolog are as suggested in Sections 5.9.1 and 5.9.2, respectively.</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(4) Using a text editor, create two text files in1.txt and in2.txt, each comprising a number of terms</span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"> </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">terminated by end.</span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"> </span></span><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Define and test a predicate combine that takes the names of two input files as its first two arguments and the name of an output file as its third argument. The output file should contain the terms in the first input file followed by the terms in the second, one per line and terminated by end.</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(5) Define and test a predicate compare that reads in two text files term by term and for each pair of corresponding terms outputs a message either saying that they are the same or that they are different. Assume that both files contain the same number of terms and that the final term in each is end.</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">And now the solution of those problem are&#8230;..</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">(1) Type this in notepad and save. Don&#8217;t forget to add .pl at the end of your filename.</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><a href="http://madmathc.files.wordpress.com/2009/12/makelowernotepad1.jpg"><img class="aligncenter size-full wp-image-168" title="makelowernotepad" src="http://madmathc.files.wordpress.com/2009/12/makelowernotepad1.jpg" alt="makelower" width="500" height="328" /></a><br />
</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Then consult on Prolog.</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><a href="http://madmathc.files.wordpress.com/2009/12/makelower_edit.jpg"><img class="aligncenter size-full wp-image-164" title="makelower_edit" src="http://madmathc.files.wordpress.com/2009/12/makelower_edit.jpg" alt="makelower2" width="500" height="273" /></a>After that, type </span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>This is an Example 123 inCLUDing numbers and symbols +-*/@[] XYz</strong></span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">then press Enter. The output shoud be here</span></span></p>
<p><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><a href="http://madmathc.files.wordpress.com/2009/12/makelower1_edit.jpg"><img class="aligncenter size-full wp-image-166" title="makelower1_edit" src="http://madmathc.files.wordpress.com/2009/12/makelower1_edit.jpg" alt="makelower2" width="500" height="273" /></a>For next number, they will be posted soon. Thank u.<br />
</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=160&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/12/22/input-and-output-in-prolog-ch-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/makelowernotepad1.jpg" medium="image">
			<media:title type="html">makelowernotepad</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/makelower_edit.jpg" medium="image">
			<media:title type="html">makelower_edit</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/makelower1_edit.jpg" medium="image">
			<media:title type="html">makelower1_edit</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Expert System on Prolog &#8220;Rubik&#8217;s Cube Puzzle&#8221;</title>
		<link>http://madmathc.wordpress.com/2009/12/10/simple-expert-system-on-prolog-rubiks-cube-puzzle/</link>
		<comments>http://madmathc.wordpress.com/2009/12/10/simple-expert-system-on-prolog-rubiks-cube-puzzle/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 17:47:45 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Discrete Math]]></category>
		<category><![CDATA[Literature Review]]></category>
		<category><![CDATA[SWI - Prolog]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=139</guid>
		<description><![CDATA[@Mo2nCha&#8217;09 et all 1. What is a Rubik&#8217;s cube and what&#8217;s the problem? ( Apa sih kubus Rubik dan apa yang menjadi masalahnya?) Rubik&#8217;s cube is a simple looking puzzle. It is a cube with nine tiles on each face. In its solved state each of the sides is made up of tiles of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=139&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>@Mo2nCha&#8217;09 et all</p>
<p style="text-align:center;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>1. What is a Rubik&#8217;s   cube and what&#8217;s the problem? ( Apa sih kubus Rubik dan apa yang menjadi masalahnya?)</strong><br />
</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> Rubik&#8217;s cube is a simple looking puzzle. It is a cube with nine tiles on each face.   In its solved state each of the sides is made up of tiles of the same color,   with a different color for each side. Each of the tiles is actually part of  a small cube, or cubie. Each face of the cube (made up of nine cubies) can be   rotated. The mechanical genius of the puzzle is that the same cubie can be rotated   from multiple sides. A corner cubie can move with three sides, and edge cubie   moves with two sides. Figure below shows a cube in the initial solved state,   and after the right side was rotated 90 degrees clockwise.</span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> Then the   problem is to take a cube whose sides have been randomly rotated and figure   out how to get it back to the initial solved state. The scrambled cube might   look like that of figure below.</span></p>
<p><img src="/Users/DELL/Pictures/rubikscube12-1a.gif" alt="" /></p>
<p><a href="http://madmathc.files.wordpress.com/2009/12/rubikcube21.jpg"><img class="aligncenter size-full wp-image-141" title="rubikcube2" src="http://madmathc.files.wordpress.com/2009/12/rubikcube21.jpg" alt="" width="547" height="141" /></a></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> The   problem is, there are an astronomical number of possible ways to try to unscramble   the cube, not very many of which lead to the solved state. To reach a solution   using a blind search algorithm is not feasible, even on the largest machines.   A human expert can unscramble the cube in well less than a minute. The   difficulty with solving the cube revolves around the fact that if you move one   cubie, you have to move seven other cubies as well (the center one doesn&#8217;t really   go anywhere). This is not a big problem in the early stages of unscrambling   the cube, but once a number of tiles are positioned correctly, new rotations   tend to destroy the solved parts of the cube. The   experienced cube solver knows of complex sequences of moves which can be used   to manipulate a small portion of the cube without disturbing the other portions   of the cube. For example a 14 move sequence can be used to twist two corner   pieces without disturbing any other pieces.It   is important to realize there are actually two different senses of solving the   cube. One assumes the problem solver has no previous knowledge of the cube.   The other assumes the individual is an expert familiar with all of the intricacies   of the cube. In   the first case, the person solving the cube must be able to discover the need   for complex sequences of moves and then discover the actual sequences. The program   does not have anywhere near the level of &#8220;intelligence&#8221; necessary to solve the   cube in this sense.In   the second case the person is armed with full knowledge of many complex sequences   of moves which can be brought to bear on rearranging various parts of the cube.   The problem here is to be able to quickly determine which sequences to apply   given a particular scrambled cube. This is the type of &#8220;expertise&#8221; which is   contained in the Rubik&#8217;s cube program. In   the following sections we will look at how the cube is represented, what is   done by searching, what is done with heuristics, how the heuristics are coded,   how the cube is manipulated, and how it is displayed.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> As we could say in Bahasa, permasalahan yang ada pada kubus rubik adalah bagaimana mengacak sebuah rubik kubus yang teratur dengan memutar 90 derajat searah jarum jam menjadi sebuah susunan kubus yang acak, kemudian dari posisi dan susunan yang acak tersebut dikembalikan kepada susunan semula (teratur), seorang ahli puzzle kubus bisa saja memecahkan masalah tersebut hanya dalam hitungan menit, tapi buat orang awam mencari susunan yang tepat untuk satu sisi kubus bisa memecah formasi sisi lainnya, dalam asumsi penyelesaiannya ada dua tipe asumsi orang yang dapat menyelesaikan, satu adalah seorang yang awam tentang puzzle kubus yang kedua memang seorang tersebut sudah ahli didalamnya. Sekarang bagaimana menggunakan aplikasi Prolog agar urutan penyelesaiannya bisa cepat, meskipun sebuah program tidak memiliki indera tertentu untuk menyelesaikan puzzle ini.</span></p>
<p style="text-align:center;"><strong><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">2.</span> Modelling Rubik&#8217;s Cube</strong></p>
<p>The Standard cube has 5.7 cm ribs, Puzzle has 26 miniature cubes on the surface. Center of each cube surface is the main box position has remained a central mechanism. With structure, the small cubes can be played. The remaining 21 pieces of the cube that can be changed its position while the other 6 as The main axis is fixed but still can rotated. Normal Rubik&#8217;s cube (3x3x3) has (8! × 38-1) × (12! × 212-1) / 2 = 43.252.003.274.489.856.000 different positions (permutations). Based on the size of the position all cubes can be solved with 27 steps or less. If every permutation attempted 1 by one it will take 261 years light. And if the surface of the cube of each permutasinya spread will be proportional with 256 times the size of the earth In fact there are (8! × 38) × (12! × 212) = 519.024.039.293.878.272.000 possibilities compilation of each piece to build this cube, but 1 in 12 that can be achieved. This is because there are no steps to do sequence so as to exchange a pair of or rotate pieces contained in the corner. Rubik&#8217;s cube can be represented as a finite state machine and receive language like any other machine. Language accepted composed of strings of each step. Even so, many of the assumptions the status of this machine enormous. This causes the process status of the search space is very difficult to do except that most likely removed at the time of checking. This machine can be modeled with a focus to the small boxes that build koyal big. Small boxes are also a finite state machines that accept languages certain. All slices of the language accepted by setipa small box is the language accepted by a large box.</p>
<p>Or in Bahasa we could say that : Kubus standar memiliki ukuran rusuk 5.7cm. Puzzle memiliki 26 miniatur kubus padapermukaannya. Kubus pusat dari setiap permukaannya adalah kotak utama yang posisinya sudah tetap sebagai mekanisme pusat. Dengan struktur tersebut, kubus-kubus kecil lainnya dapat diputar. Tersisa 21 potongan kubus yang dapat diubah posisinya sedangkan 6 lainnya sebagaisumbu utama yang tetap tetapi tetap dapat dirotasikan. Rubik&#8217;s cube normal (3x3x3) memiliki (8! × 38−1) × (12! × 212−1)/2 = 43.252.003.274.489.856.000 posisi berbeda(permutasi). Berdasarkan besarnya jmlah posisi tersebut, semua kubus dapat dipecahkan dengan 27 langkah atau kurang. Jika setiap permutasi dicoba 1 per satu maka akan membutuhkan waktu 261 tahun cahaya (aji gilee&#8230;selama itukah?!) Dan apabila permukaan kubus dari setiap permutasinya dibentangkan maka akan sebanding dengan 256 kali luas bumi Faktanya terdapat (8! × 38) × (12! × 212) = 519.024.039.293.878.272.000 kemungkinan penyusunan dari setiap potongan untuk membangun kubus ini, tapi 1 diantara 12 yang dapat dicapai. Hal ini dikarenakan tidak ada langkah yang dilakukan secara berurutan sehingga dapat menukar sepasang atau merotasikan potongan yang terdapat di pojok. Rubik&#8217;s cube dapat direpresentasikan sebagai mesin status terhingga dan menerima bahasa seperti mesin lainnya. Bahasa yang diterima tersusun atas string setiap langkah. Walau begitu, banyaknya status yang menjadi asumsi mesin ini sangatlah besar. Hal ini menyebabkan proses pencarian ruang statusnya sangat sulit dilakukan kecuali jika sebagian besar kemungkinan dihilangkan pada saat pengecekan.<br />
Mesin ini dapat dimodelkan dengan fokus kepada kotak-kotak kecil yang membangun koyal besar. Kotak-kotak kecil tersebut juga merupakan mesin status berhingga yang menerima bahasa tertentu. Semua irisan dari bahasa yang diterima oleh setiap kotak kecil adalah bahasa yang diterima oleh kotak besar</p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> The   core of the program has to be the knowledge representation of the cube and its   fundamental rotations. The   cube lends itself to two obvious representation strategies. It can either be   viewed simply as 54 tiles, or as 20 cubies (or pieces) each with either two   or three tiles. Since much of the intelligence in the program is based on locating   pieces and their positions on the cube, a representation which preserves the   piece identity is preferred. However there are also brute force search predicates   which need a representation which can be manipulated fast. For these predicates   a simple flat structure of tiles is best. The   next decision is whether to use flat Prolog data structures (terms) with each   tile represented as an argument of the term, or lists with each element a tile.   Lists are much better for any predicates which might want to search for specific   pieces, but they are slower to manipulate as a single entity. Data structures   are more difficult to tear apart argument by argument, but are much more efficient   to handle as a whole. By using fixed length records, some Prologs use lists internally thus changing the performance trade-offs mentioned. </span></p>
<p><img src="/Users/DELL/Pictures/kubik%20tabel.jpg" alt="" /></p>
<p style="text-align:center;"><img src="/Users/DELL/Pictures/kubik%20tabel.jpg" alt="" /><a href="http://madmathc.files.wordpress.com/2009/12/kubik-tabel.jpg"><img class="aligncenter size-full wp-image-149" title="kubik tabel" src="http://madmathc.files.wordpress.com/2009/12/kubik-tabel.jpg" alt="" width="418" height="141" /></a>*the phrase  &#8220;hidden&#8221;  is the part that cant be viewed when we look the cube from the front</p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> The tabel above mentioning about </span>4 basic types of pieces cube different. Corner cube, cube ribs, the middle cube (on each surface), and the center cube is not visible from the outside. As a convention, the middle cube hasa fixed position (though can be rotated). This meant that every other piece of the cube still can be moved without having to go move the cube center. In fact, the cube center always the same when direlasikan with others. Consider each cube was fixed can be symbolized as the direction. Each piece of the cube has 6 sides. If we move the pieces of the available cube<br />
of the whole cube (), we can find 6 side of the cube and identify colors indicates the direction of what. This information can be used to define the status of a cube pieces with the following examples:</p>
<p style="text-align:center;"><strong>mc(Front,Top,Left,Hidden,Bot,Right)</strong> atau <strong>mc(F,T,L,H,B,R)</strong></p>
<p style="text-align:left;">Where each argument has a meaning: green (g), white (w),  orange (o), yellow (Y), blue (b), red (r), none (n). Suppose Instantiation of the cube pieces first as mc (n, n, o, y, b, n). This means under the front-facing surfaces are considered no color (or &#8220;none&#8221;), the top also &#8220;None&#8221;, the left side of orange, part &#8220;Hidden&#8221; is yellow, bottom color blue, the right is &#8220;none&#8221;. (This initiation produce the first piece of the cube as position found). The result of all this is that we do not need to describe the status of the color on every surface: we can solve cube pieces as small cubes for later recorded orientation. For example, the first piece of cube can be positioned with the color orange as front. But we also need to know orientation to know their status. At side in front of orange, yellow sides will facing up, right, bottom or left. Within other words cut the cube has a total of 24 pieces status .</p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>cube(X1, X2,       X3, X4, &#8230;&#8230;&#8230;., X53, X54).%this representing the cube structure</strong></span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>[p(X1), p(X2),       ...p(X7, X8, X9), ...p(X31, X32), p(X33, X34), ...]. %</strong></span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">where   each <strong>X</strong> represents a tile, or by the list, </span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">where   each <strong>p(..)</strong> represents a piece. A piece might have one, two, or three   arguments depending on whether or not it is a center piece, edge piece, or corner   piece.</span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>goalstate(       cube(&#8216;F&#8217;, &#8216;R&#8217;, &#8216;U&#8217;, &#8216;B&#8217;, &#8230;&#8230;&#8230;&#8230;)). % </strong></span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   tiles are each represented by an uppercase letter representing the side of the   cube the tile should reside on. These are front, back, top, bottom, right, and   left. (The display routine maps the sides to colors.) Quotes are used to indicate   the tiles are constants, not variables. Using the constants, the solved state   (or goal state of the program) is stored as the Prolog fact <strong>goalstate/1</strong></span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Having   decided on two representations, it is necessary to quickly change from one to   the other. Unification has exactly the power we need to easily transform between   one notation of the cube and the other. A predicate <strong>pieces</strong> takes the   flat structure and converts it to a list.</span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>pieces( cube(X1,       X2, &#8230;&#8230;. X54), [p(X1), ......p(X7, X8, X9), .....]).</strong></span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">If   <strong>Z</strong> is a variable containing a cube in structure notation, then the query: </span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>?- pieces(Z,       Y). %</strong></span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Will   bind the variable <strong>Y</strong> to the same cube in list notation. It can also be   used the other way.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   following query can be used to get the goal state in list notation in the variable   <strong>PieceState</strong>:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"> <strong>?- goalstate(FlatState),       pieces(FlatState, PieceState).<br />
</strong>FlatState = cube(&#8216;F&#8217;, &#8216;R&#8217;, &#8216;U&#8217;, &#8216;B&#8217;, &#8230;&#8230;).<br />
PieceState = [p('F'), p('R'), ....p('R', 'U'),....p('B', 'R', 'F'), ....]. % </span><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   first goal unifies <strong>FlatState</strong> with the initial cube we saw earlier. <strong>pieces/2</strong> is then used to generate <strong>PieceState</strong> from <strong>FlatState</strong>.</span></p>
<p style="text-align:center;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>3. Rotation (Perputaran)</strong></span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Unification   also gives us the most efficient way to rotate a cube. Each rotation is represented   by a predicate which maps one arrangement of tiles, to another. The first argument   is the name of the rotation, while the second and third arguments represent   a clockwise turn of the side. For example, the rotation of the upper side is   represented by:</span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>mov(u, cube(X1,       &#8230;X6, X7, X8, X9, &#8230;),<br />
cube(X1, &#8230;X6, X20, X19, X21, &#8230;))</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">We   can apply this rotation to the top of the goal cube:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>?- goalstate(State),       mov(u, State, NewState).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   variable <strong>NewState</strong> would now have a solved cube with the upper side rotated   clockwise.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Since   these can be used in either direction, we can write a higher level predicate   that will make either type of move based on a sign attached to the move.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>move(+M, OldState,       NewState):-<br />
mov(M, OldState, NewState).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>move(-M, OldState,       NewState):-<br />
mov(M, NewState, OldState).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Having   now built the basic rotations, it is necessary to represent the complex sequences   of moves necessary to unscramble the cube. In this case the list notation is   the best way to go. For example, a sequence which rotates three corner pieces   is represented by:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>seq(tc3, [+r,       -u, -l, +u, -r, -u, +l, +u]).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   sequence can be applied to a cube using a recursive list predicate, <strong>move_list/3</strong>:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>move_list([],       X, X).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>move_list(       [Move|T], X, Z):-<br />
move(Move, X, Y),<br />
move_list(T, Y, Z).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">At   this point we have a very efficient representation of the cube and a means of   rotating it. We next need to apply some expertise to the search for a solution.</span></p>
<p style="text-align:center;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>4. Advanced Rules</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   most obvious rule for solving Rubik&#8217;s cube is to attack it one piece at a time.   The placing of pieces in the solved cube is done in stages. In Black &amp; Taylor&#8217;s   book they recognize six different stages which build the cube up from the left   side to the right. Some examples of stages are: put the left side edge pieces   in place, and put the right side corner pieces in place. Each   stage has from one to four pieces that need placement. One of the advantages   of writing expert systems directly in a programming language such as Prolog,   is that it is possible to structure the heuristics in an efficient, customized   fashion. That is what is done in this program.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   particular knowledge necessary to solve each stage is stored in predicates,   which are then used by another predicate, <strong>stage/1</strong>, to set up and solve   each stage. Each stage has a plan of pieces it tries to solve for. These are   stored in the predicate <strong>pln/2</strong>. It contains the stage number and a list   of pieces. For example, stage 5 looks for the four edge pieces on the right   side:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>pln(5, [p('R',       'U'), p('F', 'R'), p('R', 'D'), p('B', 'R')]).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">Each   stage will also use a search routine which tries various combinations of rotations   to position a particular target piece. Different rotations are useful for different   stages, and these too are stored in predicates similar to <strong>pln/2</strong>. The   predicate is <strong>cnd/2</strong> which contains the candidate rotations for the stage.</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">For   example, the first stage (left edge pieces) can be solved using just the simple   rotations of the right, upper, and front faces. The last stage (right corner   pieces) requires the use of powerful sequences which exchange and twist corner   pieces without disturbing the rest of the cube. These have names such as corner-twister   3 and tri-corner 1. They are selected from Black and Taylor&#8217;s book. These two   examples are represented:</span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>cnd(1, [r,       u, f]).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong>cnd(6, [u,       tc1, tc3, ct1, ct3]).</strong></span></p>
<p><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;">The   <strong>stage/1</strong> predicate drives each of the stages. It basically initializes   the stage, and then calls a general purpose routine to improve the cube&#8217;s state.   The initialization of the stage includes setting up the data structures that   hold the plan for the stage and the candidate moves. Stage also reorients the   cube for the stage to take advantage of symmetries and/or make for better displays.</span></p>
<p style="text-align:left;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong><br />
</strong></span></p>
<p style="text-align:center;"><span style="font-family:New Century Schlbk,Century Schoolbook;font-size:small;"><strong><br />
</strong></span></p>
<p style="text-align:left;"><strong><br />
</strong></p>
<p style="text-align:left;"><strong><br />
</strong></p>
<p style="text-align:left;"><strong><br />
</strong></p>
<p><img src="/Users/DELL/AppData/Local/Temp/moz-screenshot-1.jpg" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=139&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/12/10/simple-expert-system-on-prolog-rubiks-cube-puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/rubikcube21.jpg" medium="image">
			<media:title type="html">rubikcube2</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/12/kubik-tabel.jpg" medium="image">
			<media:title type="html">kubik tabel</media:title>
		</media:content>
	</item>
		<item>
		<title>Prolog Simple Expert System  (Step Of Six Counters)</title>
		<link>http://madmathc.wordpress.com/2009/11/24/prolog-simple-expert-system-step-of-three-dots/</link>
		<comments>http://madmathc.wordpress.com/2009/11/24/prolog-simple-expert-system-step-of-three-dots/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 17:45:27 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Discrete Math]]></category>
		<category><![CDATA[SWI - Prolog]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=121</guid>
		<description><![CDATA[MAD-Math-C (MEMBER AT DISCRETE MATHEMATIC CLASS C) Final Project Simple Expert System Using Prolog @author Mo2ncha&#8217;09 Assalamualaikum Wbr. Kali ini kami memberikan contoh sebuah permasalahan sederhana, yaitu ada sebuah papan dengan 3 titik hitam dan 3 titik putih saling berhadapan dan di tengah-tengahnya diberikan ruang/spasi, seperti gambar dibawah ini: Dari gambar diatas diketahui bahwa tujuannya [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=121&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>MAD-Math-C (MEMBER AT DISCRETE MATHEMATIC CLASS C)</strong></p>
<p><strong>Final Project </strong></p>
<p>Simple Expert System Using Prolog</p>
<p>@author Mo2ncha&#8217;09</p>
<p>Assalamualaikum Wbr.</p>
<p>Kali ini kami memberikan contoh sebuah permasalahan sederhana, yaitu ada sebuah papan dengan 3 titik hitam dan 3 titik putih saling berhadapan dan di tengah-tengahnya diberikan ruang/spasi, seperti gambar dibawah ini:</p>
<p><img src="/Users/DELL/AppData/Local/Temp/moz-screenshot.jpg" alt="" /><a href="http://madmathc.files.wordpress.com/2009/11/prolog-dots.jpg"><img class="aligncenter size-full wp-image-122" title="prolog dots" src="http://madmathc.files.wordpress.com/2009/11/prolog-dots.jpg" alt="" width="330" height="260" /></a><!--[if gte mso 9]&gt;    &lt;![endif]--><!--[if gte mso 9]&gt;  Normal 0     false false false  IN X-NONE X-NONE                         &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-margin-top-alt:auto; 	margin-right:0cm; 	mso-margin-bottom-alt:auto; 	margin-left:0cm; 	text-align:justify; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} a:link, span.MsoHyperlink 	{mso-style-noshow:yes; 	mso-style-priority:99; 	color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{mso-style-noshow:yes; 	mso-style-priority:99; 	color:purple; 	mso-themecolor:followedhyperlink; 	text-decoration:underline; 	text-underline:single;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoPapDefault 	{mso-style-type:export-only; 	mso-margin-top-alt:auto; 	mso-margin-bottom-alt:auto; 	text-align:justify;} @page Section1 	{size:595.3pt 841.9pt; 	margin:72.0pt 72.0pt 72.0pt 72.0pt; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:&quot;Table Normal&quot;; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-parent:&quot;&quot;; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:auto; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:auto; 	mso-para-margin-left:0cm; 	text-align:justify; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-fareast-language:EN-US;} --> <!--[endif]--></p>
<p class="MsoNormal" style="text-align:left;"><span class="medium_text"><span style="background-color:#ffffff;" title="The rules for moving are as follows:">Dari gambar diatas diketahui bahwa tujuannya adalah membuat urutan langkah yang tepat untuk menukarkan hitam dan putih saling berlawanan, dengan aturan yang berlaku adalah sebagai berikut:</span></span></p>
<ol>
<li><span class="medium_text"><span style="background-color:#ffffff;" title="The rules for moving are as follows:">Hitam dan putih harus bergerak bergantian dan saling berlawanan arah</span></span></li>
<li><span class="medium_text"><span style="background-color:#ffffff;" title="The rules for moving are as follows:">Setiap biji hitam maupun putih dapat bergerak secara horizontal maupun vertikal</span></span></li>
<li><span class="medium_text"><span style="background-color:#ffffff;" title="The rules for moving are as follows:">setiap biji hitam maupun putih dapat melompati satu biji lainnya kedalam sebuah ruang kosong</span></span></li>
</ol>
<p>Bagaimana cara  menulis program Prolognya untuk mencari semua kemingkinan cara untuk melakukan hal tersebut tanpa perulangan?  Sebagai contoh, input query yang kita masukkan adalah:</p>
<p><strong>?-play (w,s(w,w,w,e,b,b,b),s(b,b,b,e,w,w,w),S,R).<br />
</strong></p>
<p>maka Prolog harus menjawab seperti ini :</p>
<p><strong>S=[s(w,w,w,e,b,b,b),s(w,e,w,b,b,b,b),...,s(b,b,b,e,w,w,w)].</strong></p>
<p><strong>R=[[w,2,4],[b,6,2],[w,4,6],&#8230;,[w,4,6]].</strong></p>
<p><span id="result_box" class="long_text"><span style="background-color:#ffffff;" title="e,w ,w,w)]"> </span><span style="background-color:#ffffff;" title="R=[[w,2,4],[b,6,2],[w,4,6],...,[w,4,6]].">Penjelasannya adalah [w,2,4] menunjukkan biji putih akan bergerak dari posisi 2 sampai dengan posisi 4, bukan dari output &#8220;,&#8230;,&#8221;. Tetapi setiap biji yang ada harus mengandung histori dari tiap-tiap tempat yang telah di tempati (setelah lompatan/jalan), jumlah maksimal gerakan yang ada mungkin berbeda konfigurasinya.</span></span></p>
<p><span id="result_box" class="long_text"><span style="background-color:#ffffff;" title="of “,...,” the output should contain pertinent history of visited states.">Cek query dari Prolognya: </span><span style="background-color:#ffffff;" title="Check the query:"><br />
</span><span style="background-color:#ffffff;" title="?-play(_,s(w,w,w,e,b,b,b),s(b,b,e,w,w,b,w),_,_)."><strong>?-play (_, s (w, w, w, e, b, b, b), s (b, b, e, w, w, b, w ),_,_).</strong><br />
</span></span></p>
<ul>
<li><span id="result_box" class="long_text"><span style="background-color:#ffffff;" title="What does this answer mean?">Apa artinya jawaban ini? </span><span style="background-color:#ffffff;" title="Hint: first solve the problem for play/4 with no R">Petunjuk: pertama adalah memecahkan masalah untuk bermain / 4 tanpa R</span> variabel.</span></li>
<li><span class="long_text">Bagaimana cara mencari pergerakan alternatifnya (<em>alternate movement</em>?)</span></li>
</ul>
<p>Solusinya (mudah-mudahan kalau saya tidak salah):<br />
%pergerakan tepi pinggir/corner edge movement<br />
<strong>move(C, 1, 2, s(C, e, X3, X4, X5, X6, X7), s(e, C, X3, X4, X5, X6, X7)).<br />
move(C, 1, 3, s(C, X2, e, X4, X5, X6, X7), s(e, X2, C, X4, X5, X6, X7)).<br />
move(C, 7, 5, s(X1, X2, X3, X4, e, X6, C), s(X1, X2, X3, X4, C, X6, e)).<br />
move(C, 7, 6, s(X1, X2, X3, X4, X5, e, C), s(X1, X2, X3, X4, X5, C, e)).</strong></p>
<p>% pergerakan arah tengah/center edge movement<br />
<strong>move(C, 4, 2, s(X1, e, X3, C, X5, X6, X7), s(X1, C, X3, e, X5, X6, X7)).<br />
move(C, 4, 3, s(X1, X2, e, C, X5, X6, X7), s(X1, X2, C, e, X5, X6, X7)).<br />
move(C, 4, 5, s(X1, X2, X3, C, e, X6, X7), s(X1, X2, X3, e, C, X6, X7)).<br />
move(C, 4, 6, s(X1, X2, X3, C, X5, e, X7), s(X1, X2, X3, e, X5, C, X7)).</strong></p>
<p>% gerak melompat/jump movement<br />
<strong>move(C, 2, 6, s(X1, C, X3, X4, X5, e, X7), s(X1, e, X3, X4, X5, C, X7)).<br />
move(C, 3, 5, s(X1, X2, C, X4, e, X6, X7), s(X1, X2, e, X4, C, X6, X7)).</strong></p>
<p>% menjelaskan semua kemungkinan gerakan &#8212; 20 gerakan dari segala arah<br />
% define all the required movement &#8212; 20 movements from all directions<br />
<strong>make_movement(C, N1, N2, List1, List2) :- move(C, N1, N2, List1, List2).<br />
make_movement(C, N1, N2, List1, List2) :- move(C, N2, N1, List2, List1).</strong></p>
<p>% Pergerakan alternatif dari biji hitam dan biji putih<br />
% alternate moving a black counter and a white counter<br />
<strong>nextPlayer(b, w).<br />
nextPlayer(w, b).<br />
alternate(Present, Next) :- nextPlayer(Present, Next).</strong></p>
<p><strong>play_move(C, X, X, A, [X], []).<br />
play_move(C, X, Y, A, [X|P], [[C, N1, N2]|B]) :- 	make_movement(C, N1, N2, X, Z),<br />
alternate(C, Next),<br />
not(member(Z, [X|A])),<br />
play_move(Next, Z, Y, [X|A], P, B).<br />
play(C, X, Y, S, R):- play_move(C, X, Y, [], S, R).</strong></p>
<p>Mohon saran dan kritiknya jika terdapat kesalahan dalam posting ini.</p>
<p>Wassalamualaikum Wbr.</p>
<p>Mo2ncha dkk</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=121&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/11/24/prolog-simple-expert-system-step-of-three-dots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/prolog-dots.jpg" medium="image">
			<media:title type="html">prolog dots</media:title>
		</media:content>
	</item>
		<item>
		<title>INPUT AND OUTPUT IN PROLOG</title>
		<link>http://madmathc.wordpress.com/2009/11/24/input-and-output-in-prolog/</link>
		<comments>http://madmathc.wordpress.com/2009/11/24/input-and-output-in-prolog/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 17:10:44 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Discrete Math]]></category>
		<category><![CDATA[SWI - Prolog]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=119</guid>
		<description><![CDATA[Berikut adalah resume dari Input dan Output pada Prolog. Tujuannya:  adalah agar user mampu Menggunakan predikat built-in  baik untuk terminal (keyboard dan layar) atau file, dan mampu menggunakan nilai ASCII untuk memanipulasi string karakter. Fungsi masukan dan keluaran (I/O atau Input/Output) dalam Prolog yaitu WRITE dan READ. Fungsi WRITE digunakan untuk menulis nilai atau ekspresi, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=119&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;">Berikut adalah resume dari Input dan Output pada Prolog.</p>
<p style="text-align:left;"><strong>Tujuannya</strong>:  adalah agar user mampu Menggunakan predikat built-in  baik untuk terminal (keyboard dan layar) atau file, dan mampu menggunakan nilai ASCII untuk memanipulasi string karakter.</p>
<p style="text-align:left;">Fungsi masukan dan keluaran (I/O atau Input/Output) dalam Prolog yaitu WRITE dan READ. Fungsi WRITE digunakan untuk menulis nilai atau ekspresi, sedangkan fungsi READ digunakan untuk menerima masukan dari keyboard.<br />
Contoh :<br />
(save as program dibawah ini dengan nama latihan.pro)<br />
predicates<br />
eksekusi<br />
clauses<br />
eksekusi:‐<br />
write(&#8220;tuliskan sebuah kata : &#8220;),readln(X),<br />
write(&#8220;kata yang saya ketik tadi adalah &#8220;),<br />
write(X),nl.<br />
goal<br />
eksekusi.<br />
penjelasan:<br />
• ‘eksekusi’ merupakan deklarasi predikat.<br />
• Karena goal menjalankan ‘eksekusi’, maka program akan menjalankan urutan eksekusi yang ada pada clauses.<br />
• Saat Test goal, perintah write akan memunculkan “tuliskan sebuah kata : “ pada layar.<br />
• Setelah user menginputkan suatu kata (dan tekan Enter), maka kata tersebut akan dimasukkan ke dalam variable ‘X’.<br />
• Kemudian pada layar muncul “kata yang saya ketik tadi adalah “<br />
lalu perintah write(X) akan menampilkan isi dari variable ‘X’ tersebut.<br />
NB: syntax nl adalah untuk ganti baris.</p>
<p style="text-align:left;">bersambung&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=119&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/11/24/input-and-output-in-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>
	</item>
		<item>
		<title>Operators and Arithmetics ch.2</title>
		<link>http://madmathc.wordpress.com/2009/11/13/prolog-summary-chapter-4-operator-and-arithmetic/</link>
		<comments>http://madmathc.wordpress.com/2009/11/13/prolog-summary-chapter-4-operator-and-arithmetic/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 13:31:56 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Discrete Math]]></category>
		<category><![CDATA[SWI - Prolog]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=93</guid>
		<description><![CDATA[Bismillahirrahmanirrahim.. 4.1 Operator-Operator Penggunaan notasi untuk predikat secara standar menggunakan sebuah fungsi yang diikuti oleh sebuah angka dari argumen dalam tanda kurung, misalnya cinta(momon,nida). Cara lain menetapkan predikat dengan dua argumen dari sebuah predikat kembar dapat di konversi menjadi sebuah infix operator (Operator sisipan). Cara demikian akan mempermudah functor atau nama dari predikat untuk dituliskan [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=93&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;">
<p><strong><img class="aligncenter size-full wp-image-117" title="setujugan" src="http://madmathc.files.wordpress.com/2009/11/setujugan.gif" alt="setujugan" width="63" height="63" /></strong></p>
<h4>Bismillahirrahmanirrahim..</h4>
<h3><strong>4.1 Operator-Operator</strong></h3>
<p><strong> </strong></p>
<p>Penggunaan notasi untuk predikat secara standar menggunakan sebuah fungsi yang diikuti oleh sebuah angka dari argumen dalam tanda kurung, misalnya <strong>cinta(momon,nida). </strong>Cara lain menetapkan predikat dengan dua argumen dari sebuah predikat kembar dapat di konversi menjadi sebuah <em>infix operator</em> (Operator sisipan). Cara demikian akan mempermudah <em>functor</em> atau nama dari predikat untuk dituliskan diantara dua argumen tanpa tanda kurung, misalnya: <strong>momon cinta nida</strong>. Dengan demikian cara tersebut lebih memudahkan functor dibaca sebelum argumen tanpa tanda kurung, misal <strong>heli_anjing momon </strong>ketimbang menggunakan <strong>heli_anjing(momon). </strong>Cara lain, sebuah predikat dengan satu argumen (<em>unary predicate</em>) dapat di konversikan menjadi sebuah <em>postfix operator </em>(Operator dibelakang operand). Ini memungkinkan <em>functor</em> untuk ditulis setelah argumen, misal <strong>momon heli_anjing </strong>.</p>
<p>Notasi operator dapat pula digunakan dengan <em>rules </em>untuk mempermudah pembacaan. Sebagai contoh rule adalah <strong>cinta(momon,X):-is_wanita(X),memiliki(X,Y),isa_kucing(Y)</strong>. Lebih mudah dimengerti jika <em>rules</em> ditulis sebagai <strong>momon cinta X:- X is_wanita, X memiliki Y, Y isa_kucing</strong>. Notasi tanda kurung  <em>functor </em>dan argumen  misal: <strong>cinta(momon,X) </strong>maka<strong> </strong>masih dapat digunakan dengan operator-operator jika lebih memilih hal tersebut.Notasi &#8216;Mixed&#8217; atau campuran juga diperbolehkan, misal: <strong>cinta/2</strong>, <strong>is_wanita/1</strong>, <strong>memiliki/2 </strong>and <strong>isa_kucing/1 </strong>adalah semua operator yang sama dengan <strong>(momon,X):-is_wanita(X),X memiliki Y,isa_kucing(Y).</strong> Ada pula yang menetapkan predikat dengan satu atau dua dapat di konversikan menjadi sebuah operator dengan memasukkan hasil dengan predikat <strong><em>op</em> </strong>pada sistem prompt. Predikat tersebut memakai tiga argumen, sebagai contoh  <strong>?-op(150,xfy,cinta).</strong></p>
<p>Argumen pertama adalah &#8216;<em>operator precedence&#8217;</em>, atau operator yang lebih didahulukan yang merupakanbilangan integer positif. Jarak dari angka-angka digunakan tergantung  dari implementasi khusus. Angka yang lebih kecil akan didahulukan. Nilai dari <em>Operator precedence</em> digunakan untuk  menentukan operator manakah yang akan digunakan pada saat tertentu akan digunakan lebih dari satu kali.</p>
<p>Sebuah predikat juga dapat di konversikan kedalam sebuah operator dengan menempatkan baris seperti <strong> </strong></p>
<p><strong>?-op(150,xfy,cinta). </strong></p>
<p>Dalam aplikasi Prolog <em>file</em> akan dimasukkan menggunakan <em>consult</em><strong> </strong>atau <em>reconsult</em>.  Sebagai catatan bahwa <em>prompt </em>(dua karakter ?-)<em> </em>harus dimasukkan<em>. </em>Ketika sebuah hasil digunakan  dengan cara tersebut, keseluruhan baris dikenal sebagai <em>directive</em> atau instruksi. Dalam kasus ini <em>directive</em> harus ditempatkan pada <em>file </em>sebelum klausa pertama yang menggunakan operator <strong>cinta</strong>. Termasuk didalamnya <em>relational operators</em> untuk membandingkan nilai numerik, termasuk  menunjukkan <strong>kurang dari</strong> dan menunjukkan <strong>lebih besar dari</strong>. Sebagai contoh term yang benar:</p>
<p><strong>X&gt;4</strong></p>
<p><strong>Y&lt;Z</strong></p>
<p><strong>A=B</strong></p>
<p>Notasi tanda kurung dapat pula digunakan dengan predikat pembangun ditetapkan sebagai operator contoh <strong>&gt;(X,4) </strong>daripada <strong>X&gt;4</strong>.</p>
<h3><strong>4.2. Arithmetic (Aritmatika)</strong></h3>
<p>Disamping penggunaan non-angka (hewan atau nama), Prolog juga menyediakan fasilitas untuk melakukan perhitungan aritmatika dengan menggunakan notasi yang mirip dengannya, yang tentu saja cukup akrap dengan aljabar dasar. Dapat digunakan dengan predikat <em>built-in </em><strong>is/2 </strong>yang dikenal sebagai operator <em>infix</em> (sisipan) dan demikian ditulis diantara dua argumen. Mengevaluasi hasil <strong>X is -6.5</strong> akan menyebabkan <strong>X</strong> terbatas pada angka <strong>-6.5</strong> sehingga hasil tercapai. Argumen kedua dapat pula sebagai angka atau atau perhitungan aritmatika, contoh: <strong>X is 6*Y+Z-3.2+P-Q/4 </strong>(* menunjukkan perkalian). variabel-variabel yang muncul dalam operasi aritmatika harus telah dibatasi sebagai hasil dari evaluasi hasil sebelumnya dan nilai-nilainya haruslah berwujud angka.  Jika disajikan demikian, hasil akan selalu berhasil dan wujud variabel argumen pertama akan terbatas dari nilai operasi aritmatika. Jika tidak sebuah pesan error akan muncul. Contoh:</p>
<p><strong>?- X is 10.5+4.7*2.</strong></p>
<p><strong>X = 19.9</strong></p>
<p><strong>?- Y is 10,Z is Y+1.</strong></p>
<p><strong>Y = 10 ,</strong></p>
<p><strong>Z = 11</strong></p>
<p>Simbol-simbol seperti <strong> + &#8211; * / </strong>dalam operasi aritmatika adalah tipe spesial dari operator sisipan (  <em>infix</em><em> </em><em>operator</em> ) yang dikenal sebagai <em>arithmetic operators </em>atau operator-operator aritmatika. Tidak seperti operator lain yang digunakan pada Prolog, mereka bukanlah predikat melainkan fungsi-fungsi,yang menghasilkan nilai numerik. Sama halnya dengan angka, variabel dan operator, operasi aritmatik dapat mencakup fungsi aritmatik, tertulis dengan argumen-argumen dalam tanda kurung.Misal operasi aritmatika untuk menghitung akar kuadrat dari <strong>36 :<br />
</strong></p>
<p><strong>?- X is sqrt(36).</strong></p>
<p><strong>X = 6</strong></p>
<p>Operator Aritmatika dapat pula digunakan tidak sebagai operator sisipan biner untuk menunjukkan perbedaan antara dua nilai numerik, contoh <strong>X-6</strong>, tapi juga sebagai operator awalan <em>unary</em> digunakan untuk menunjukkan numerik bernilai negatif, contoh:</p>
<p><strong>?- X is 10,Y is -X-2.</strong></p>
<p><strong>X = 10 ,</strong></p>
<p><strong>Y = -12</strong></p>
<p>Tabel dibawah  (dalam bahasa Inggris) menunjukkan beberapa operator aritmatika dan fungsi aritmatika yang tersedia dalam Prolog:</p>
<p><img class="aligncenter size-medium wp-image-103" title="tabel aritmatik" src="http://madmathc.files.wordpress.com/2009/11/tabel-aritmatik1.jpg?w=736&#038;h=457" alt="tabel aritmatik" width="736" height="457" /></p>
<p>Sebagai contoh:</p>
<p><strong>?- X is 30,Y is 5,Z is X+Y+X*Y+sin(X).</strong></p>
<p><strong>X = 30 ,</strong></p>
<p><strong>Y = 5 ,</strong></p>
<p><strong>Z = 185.5</strong></p>
<p>Meskipun predikat <strong>is </strong>umumnya digunakan untuk menguraikan, argumen pertama dapat pula sebagai variabel angka atau batasan dengan nilai numerik. Pada kasus tersebut jika nilai numerik dari dua argumen di kalkulasikan. Hasil tercapai jika hasil sama dengan, jika tidak maka gagal, contoh:</p>
<p><strong>?- X is 7,X is 6+1.</strong></p>
<p><strong>X = 7</strong></p>
<p><strong>?- 10 is 7+13-11+9.</strong></p>
<p><strong>no</strong></p>
<p><strong>?- 18 is 7+13-11+9.</strong></p>
<p><strong>yes</strong></p>
<p>Catatan bahwa hasil dari <strong>X is X+1 </strong>akan selalu gagal, apakah X dibatasi atau tidak, contoh:</p>
<p><strong>?- X is 10,X is X+1.</strong></p>
<p><strong>no</strong></p>
<p>Catatan bahwa hasil dari <strong>X is X+1 </strong>akan selalu gagal, apakah X dibatasi atau tidak, contoh:</p>
<p><strong>?- X is 10,X is X+1.</strong></p>
<p><strong>no</strong></p>
<p>Untuk menaikkan (increase) nilai sebanyak satu membutuhkan pendekatan yang berbeda, misal:</p>
<p>Versi yang salah : increase(N):-N is N+1. Maka hasilnya:</p>
<p><strong>?- increase(4).</strong></p>
<p><strong>no</strong></p>
<p>Versi yang benar : increase(N,M):-M is N+1., maka hasilnya:</p>
<p><strong>?- increase(4,X).</strong></p>
<p><strong>X = 5</strong></p>
<p><strong><br />
</strong></p>
<p><strong>4.2.1.  Operator Precedence (Operator yang lebih dahulu/Presedensi)</strong> <strong>pada Operasi Aritmatika</strong></p>
<p>Ketika terdapat lebih dari satu operator pada operasi misal :<strong>A+B*C-D</strong>, Prolog membutuhkan sebuah pengertian untuk memutuskan perintah yang mana yang akan digunakan. Untuk operator dasar seperti <strong>+ &#8211; * /</strong> ,perhitungan <strong>A+B*C-D </strong>harus ditafsirkan sebagai “perhitungan hasil dari B dan C, ditambahkan ke A kemudian dikurangi D”, tidak seperti “menambahkan A dan B, kemudian mengalikan C dan dikurangi D”. Prolog mampu mencapai hal demikian dengan memberikan masing-masing operator sebuah nilai numerik yang didahulukan (<em>numerical</em> <em>precedence value), </em>operator dengan tingkat didahulukan lebih tinggi seperti * dan / , digunakan sebelum operator dengan tingkat pendahuluan lebih rendah (<em>lower precedence</em>) seperti +dan -. Operator dengan  tingkat presedensi/pendahuluan yang sama misal + dan -, * dan / digunakan dari kiri ke kanan.  Efek dari memberikan operasi seperti <strong>A+B*C-D </strong>bagi yang memahami aljabar akan memandang dengan: <strong>A+(B*C)-D</strong>. Jika perintah berbeda dari dibutuhkan evaluasi, maka dapat diproses dengan tanda kurung, misal:  <strong>X is (A+B)*(C-D)</strong>. Ekspresi dengan tanda kurung akan didahulukan.</p>
<p><strong>4.2.2. Relational Operators (Operator-operator Hubungan)</strong></p>
<p><strong> </strong></p>
<p>Operator sisipan  (<em>infix operators</em>) <strong>=:= =\= &gt; &gt;= &lt; =&lt; </strong>adalah sebuah tipe istimewa yang dikenal sebagai <em>relational operators</em> atau operasi hubungan. Digunakan untuk membandingkan nilai dari dua buah ekspresi aritmatika. Hasil tercapai jika nilai dari ekspresi pertama adalah sama dengan, tidak sama dengan, lebih besar daripada, lebih besar atau sama dengan, kurang dari, atau kurang dari sama dengan nilai dari ekspresi kedua, berturut-turut. Kedua argumen harus berupa angka, dibatasi variabel atau ekspresi aritmatik. Contoh:</p>
<p><strong>?- 88+15-3=:=110-5*2.</strong></p>
<p><strong>yes</strong></p>
<p><strong>?- 100=\=99.</strong></p>
<p><strong>yes</strong></p>
<p><strong><br />
</strong></p>
<h3><strong>4.3 Equality Operators (Operator Persamaan)</strong></h3>
<p><strong> </strong></p>
<p>Terdapat tiga tipe dari operator persamaan untuk mengetes persamaan dan pertidakpersamaan yang tersedia pada Prolog. Tipe pertama digunakan untuk membandingkan nilai dari ekspresi aritmatika, sedangkan yang kedua digunakan untuk membandingkan syarat (<em>terms</em>).</p>
<p><strong>4.3.1. Ekspresi Aritmatika persamaan </strong><strong>=:=</strong><strong> </strong></p>
<p><strong>E1=:=E2 </strong>akan sukses jika ekspresi aritmatika dari E1 dan E2 mengevaluasi nilai yang sama, contoh:</p>
<p><strong>?- 6+4=:=6*3-8.</strong></p>
<p><strong>yes</strong></p>
<p><strong>?- sqrt(36)+4=:=5*11-45.</strong></p>
<p><strong>yes</strong></p>
<p>untuk mengecek apakah sebuah integer (bilangan bulat) genap atau ganjil, kita dapat menggunakan predikat <strong>checkeven/1 </strong>seperti dibawah ini:<strong> </strong></p>
<p><strong>checkeven(N):-M is N//2,N=:=2*M. </strong>,<strong> </strong>maka hasilnya:</p>
<p><strong>?- checkeven(12).</strong></p>
<p><strong>yes</strong></p>
<p><strong>?- checkeven(23).</strong></p>
<p><strong>no</strong></p>
<p><strong>?- checkeven(-11).</strong></p>
<p><strong>no</strong></p>
<p><strong>?- checkeven(-30).</strong></p>
<p><strong>yes</strong></p>
<p>Operator pembagian bilangan bulat // membagi argumen pertama dengan yang kedua dan mengkerucutkan hasilnya kepada bilangan bulat yang terdekat diantara bilangan tersebut dan nol. Jadi <strong>12//2 </strong>adalah 6, <strong>23//2 </strong>adalah 11, <strong>-11//2 </strong>adalah -5 and <strong>-30//2 </strong>adalah -15. Pembagian sebuah bilangan bulat dengan 2 menggunakan //dan mengalikannya lagi dengan 2 akan menghasilkan bilangan bulat tersebut sebagai genap, tetapi tidak sebaliknya.</p>
<p><strong>4.3.2. Arithmetic Expression Inequality (Pertidaksamaan Ekspresi Aritmatika)</strong> <strong>=\=</strong></p>
<p><strong> </strong></p>
<p><strong>E1=\=E2 </strong>dinilai berhasil jika ekspresi aritmatik E1 dan E2 tidak mengevaluasi nilai yang sama, contoh:</p>
<p><strong>?- 10=\=8+3.</strong></p>
<p><strong>yes</strong></p>
<p><strong><br />
</strong></p>
<p><strong>4.3.3. Terms Identical (Hubungan identikal) </strong><strong>==</strong></p>
<p><strong> </strong></p>
<p>Kedua argumen dari operator sisipan (<em>infix operators</em>) == harus saling berhubungan, hasil dari <em>Term1</em>==<em>Term2 </em>akan tercapai jika dan hanya jika (<em>iff</em>) <em>Term1 </em>adalah identik dengan <em>Term2</em>. Apapun variabel yang digunakan pada <em>terms</em> mungkin atau belum terbatas, tetapi tidak ada variabel yang terbatas sebagai hasil dari  evaluasi hasil (<em>goal evaluation</em>), contoh:</p>
<p><strong>?- likes(X,prolog)==likes(X,prolog).</strong></p>
<p><strong>X = _</strong></p>
<p><strong>?- likes(X,prolog)==likes(Y,prolog).</strong></p>
<p><strong>no</strong></p>
<p>(dengan X dan Y adalah variabel yang berbeda)</p>
<p><strong>?- X is 10,pred1(X)==pred1(10).</strong></p>
<p><strong>X = 10</strong></p>
<p><strong>?- X==0.</strong></p>
<p><strong>no</strong></p>
<p><strong>?- 6+4==3+7.</strong></p>
<p><strong>no</strong></p>
<p>Nilai dari ekspresi aritmatik hanya dievaluasi jika digunakan dengan operator <strong>is/2</strong>. Terdapat <strong>6+4 </strong>contoh sederhana hubungan dengan <em>functor</em> <strong>+ </strong>dan argumen <strong>6 </strong>dan <strong>4</strong>. Sangat berbeda dengan hubungan<strong> 3+7</strong>.</p>
<p><strong>4.3.4. Terms Not Identical (Hubungan tidak identik) \==</strong></p>
<p><strong> </strong></p>
<p><em>Term1\==Term2 </em>akan mengetes apakah <em>Term1 </em>adalah tidak identik dengan <em>Term2</em>. Hasil akan tercapai jika <em>Term1==Term2 </em>tidak tercapai. Selain dari itu akan gagal.contoh:</p>
<p><strong>?- pred1(X)\==pred1(Y).</strong></p>
<p><strong>X = _ ,</strong></p>
<p><strong>Y = _</strong></p>
<p>(Keluaran menandakan bahwa antara X dan Y tidak dibatasi dan merupakan variabel yang berbeda.)</p>
<p><strong>4.3.5. Terms Identical With Unification (Hubungan Identik Dengan Penggabungan) </strong><strong>=</strong></p>
<p><strong> </strong></p>
<p>Operator hubungan persamaan <strong>= </strong>mirip dengan <strong>== </strong>dengan sebuah perbedaan yang vital dan terkadang sangat berguna. Hasil dari <em>Term1</em>=<em>Term2 </em>akan tercapai jika hubungan <em>Term1 </em>and <em>Term2 </em>menyatu, contoh:</p>
<p><strong>?- pred1(X)=pred1(10).</strong></p>
<p><strong>X = 10</strong></p>
<p>(Dimana variabel X terikat pada 10, yang membuat dua hubungan identikal)</p>
<p><strong>?- suka(X,prolog)=suka(momon,Y).</strong></p>
<p><strong>X = john ,</strong></p>
<p><strong>Y = prolog</strong></p>
<p>(Mengikat <em>X </em>ke atom <em>momon </em>and <em>Y </em>to the atom <em>prolog</em> sehingga membuat dua hubungan identikal.)<em> </em></p>
<p><strong>?- X=0,X=:=0.</strong></p>
<p><strong>X = 0</strong></p>
<p>(<em>X</em>=0 menyebabkan <em>X </em>terikat pada 0. hasil <strong>X=:=0 </strong>tercapai, yang memberitahukan bahwa <em>X </em>sekarang bernilai nol.)</p>
<p><strong>?- 6+4=3+7.</strong></p>
<p><strong>no</strong></p>
<p><strong>?- 6+X=6+3.</strong></p>
<p><strong>X = 3</strong></p>
<p>(Mengikat <em>X </em>pada 3 membuat dua hubungan identikal. Keduanga 6+3, tapi bukan angka 9.)</p>
<p><strong>?- suka(X,prolog)=suka(</strong></p>
<p><strong>X = Y = _</strong></p>
<p>(Mengikat <em>X </em>dan <em>Y </em>membuat hubungan identikal.)</p>
<p><strong>?- suka(X,prolog)=likes(Y,ada).</strong></p>
<p><strong>no</strong></p>
<p>(Tidak ada penyatuan membuat atom <em>prolog </em>dan <em>ada </em>identikal.)</p>
<p><strong>4.3.6. Non-Unification Between Two Terms (Non-Penggabungan Antara Dua Hubungan) </strong><strong>\=</strong></p>
<p>Hasil dari <em>Term1\=Term2 </em>tercapai jika  <em>Term1=Term2 </em>gagal, diluar itu maka akan gagal, contoh:</p>
<p><strong>?- 6+4\=3+7.</strong></p>
<p><strong>yes</strong></p>
<p><strong>?- suka(X,prolog)\=suka(momon,Y).</strong></p>
<p><strong>no</strong></p>
<p>(Karena mengikat <em>X </em>pada <em>momon </em>dan <em>Y </em>pada <em>prolog </em>akan membuat hubungan identikal.)</p>
<p><strong>?- likes(X,prolog)\=likes(X,ada).</strong></p>
<p><strong>X = _</strong></p>
<p><strong><br />
</strong></p>
<h3><strong>4.4.  Logical Operators (Operator Logika) </strong></h3>
<p><strong> </strong></p>
<p>Membahas tentang penjelasan dari dua operator yang mengambil argumen yang disebut <em>terms</em>atau hubungan, dimana <em>terms</em> dapat diangap sebagai hasil.</p>
<p><strong>4.4.1. The not Operator (Operator “Not”)</strong></p>
<p>Operator awalan (prefix operator) not/1 dapat ditempatkan sebelum hasil apapun utnuk memberikan negasi  terhadapnya. Hasil negasi akan tercapai jika hasil awal gagal dan akan gagal jika hasil awal tercapai. Contoh dibawah menggunakan not/1. Dengan mengasumsikan menggunakan satu klausa<br />
anjing(helli).<br />
?- not anjing(helli).<br />
no<br />
?- helli(burik).<br />
no<br />
?- not anjing(burik).<br />
yes<br />
?- X=0,X is 0.<br />
X = 0<br />
?- X=0,not X is 0.<br />
No</p>
<p><strong>4.4.2. The Disjunction Operator (Operator Pemisahan)</strong></p>
<p>Operator pemisahan <strong>;/2 </strong>(ditulis dengan karakter titik koma) digunakan untuk mewakili &#8216;or&#8217;. Sebuah operator sisipan (<em>Infix Operator</em>) yang menggunakan dua argumen, keduanya adalah hasil (<em>goals</em>). <strong><em>Goal1;Goal2 </em></strong>tercapai jika salah satu dari <strong><em>Goal1 </em></strong>atau <strong><em>Goal2 </em></strong>tercapai.Contoh:</p>
<p><strong>?- 6&lt;3;7 is 5+2.</strong></p>
<p><strong>Yes</strong></p>
<p><strong>?- 6*6=:=36;10=8+3.</strong></p>
<p><strong>yes</strong></p>
<p>Sekian resume Tutorial Prolog Bab 4 : Operator And Arithmetic<strong>, </strong>mudah-mudahan dari apa yang kami kerjakan ini bermanfaat sehingga mengantar pada tujuan, khususnya bagi kami dan pada umumnya untuk pembaca sekalian.Amin  @MoMoNcha&#8217;09</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=93&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/11/13/prolog-summary-chapter-4-operator-and-arithmetic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/setujugan.gif" medium="image">
			<media:title type="html">setujugan</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/tabel-aritmatik1.jpg?w=300" medium="image">
			<media:title type="html">tabel aritmatik</media:title>
		</media:content>
	</item>
		<item>
		<title>Operator and Arithmetic ch.1</title>
		<link>http://madmathc.wordpress.com/2009/11/13/operator-and-arithmetic-ch-1/</link>
		<comments>http://madmathc.wordpress.com/2009/11/13/operator-and-arithmetic-ch-1/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 10:00:44 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=77</guid>
		<description><![CDATA[Hello bloggers&#8230;. Now I will show u how to solve Practical Exercise about Operator and Arithmetic in Prolog.  These are the question  : (1) This program is based on Animals Program 3, given in Chapter 2. dog(fido). large(fido). cat(mary). large(mary). dog(rover). small(rover). cat(jane). small(jane). dog(tom). small(tom). cat(harry). dog(fred). large(fred). cat(henry). large(henry). cat(bill). cat(steve). large(steve). large(jim). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=77&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello bloggers&#8230;.</p>
<p>Now I will show u how to solve Practical Exercise about Operator and Arithmetic in Prolog.  These are the question  :</p>
<p>(1) This program is based on Animals Program 3, given in Chapter 2.</p>
<p>dog(fido). large(fido).<br />
cat(mary). large(mary).<br />
dog(rover). small(rover).<br />
cat(jane). small(jane).<br />
dog(tom). small(tom).<br />
cat(harry).<br />
dog(fred). large(fred).<br />
cat(henry). large(henry).<br />
cat(bill).<br />
cat(steve). large(steve).<br />
large(jim).<br />
large(mike).<br />
large_dog(X):- dog(X),large(X).<br />
small_animal(A):- dog(A),small(A).<br />
small_animal(B):- cat(B),small(B).<br />
chases(X,Y):-<br />
large_dog(X),small_animal(Y),<br />
write(X),write(&#8216; chases &#8216;),write(Y),nl.</p>
<p>Convert the seven predicates used to operator form and test your revised program. The output should be the same as the output from the program above. Include directives to define the operators in your program.</p>
<p>(2) Define and test a predicate which takes two arguments, both numbers, and calculates and outputs the following values: (a) their average, (b) the square root of their product and (c) the larger of (a) and (b).</p>
<p>Now, this is the answer&#8230;.<br />
1)<br />
Step 1 : Make your new rule in Notepad like this one&#8230;<br />
<img class="aligncenter size-full wp-image-80" title="step_1" src="http://madmathc.files.wordpress.com/2009/11/untitled.jpg" alt="step_1" width="432" height="403" /><br />
Save it and don&#8217;t forget to type .pl at the end of your file name.</p>
<p>2.  Next, consult your file in Prolog. After that, type<br />
<strong>?- X chases Y.</strong><br />
Then press Enter. After 1st answer, type <strong>;</strong> to show another answer. This is the result&#8230;</p>
<p><img class="aligncenter size-full wp-image-81" title="gambar 4" src="http://madmathc.files.wordpress.com/2009/11/gambar-4.jpg" alt="gambar 4" width="320" height="230" /></p>
<p>Compare the result from the question above&#8230;</p>
<p><img class="aligncenter size-full wp-image-84" title="step3" src="http://madmathc.files.wordpress.com/2009/11/gambar-2-21.jpg" alt="step3" width="320" height="270" /></p>
<p>Same things, right&#8230;. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>2)</p>
<p>step1 : You must make rule like this&#8230;</p>
<p><img class="aligncenter size-full wp-image-85" title="untitled" src="http://madmathc.files.wordpress.com/2009/11/untitled1.jpg" alt="untitled" width="444" height="129" /></p>
<p>Save it and don&#8217;t forget to type .pl at the end of your file name.</p>
<p>2.  Next, consult your file in Prolog. After that, try to type this&#8230;</p>
<p><strong>?- pred(9,19). </strong></p>
<p>Then press Enter. This is the result&#8230;</p>
<p><img class="aligncenter size-full wp-image-86" title="nomor 2" src="http://madmathc.files.wordpress.com/2009/11/nomor-2.jpg" alt="nomor 2" width="320" height="192" /></p>
<p>Those are the solution for this problem. For more explanation about this chapter, read Arithmetic n Operators ch. 2. This writing will be posted soon. Thank u and don&#8217;t forget to give a comment. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=77&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/11/13/operator-and-arithmetic-ch-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/untitled.jpg" medium="image">
			<media:title type="html">step_1</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/gambar-4.jpg" medium="image">
			<media:title type="html">gambar 4</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/gambar-2-21.jpg" medium="image">
			<media:title type="html">step3</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/untitled1.jpg" medium="image">
			<media:title type="html">untitled</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/11/nomor-2.jpg" medium="image">
			<media:title type="html">nomor 2</media:title>
		</media:content>
	</item>
		<item>
		<title>Rule-Based/Expert Systems</title>
		<link>http://madmathc.wordpress.com/2009/10/21/rule-basedexpert-systems/</link>
		<comments>http://madmathc.wordpress.com/2009/10/21/rule-basedexpert-systems/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:11:46 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Literature Review]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=72</guid>
		<description><![CDATA[Definition of Expert systems are: - Knowledge based systems - Part of the Artificial Intelligence field - Computer programs that contain some subject-specific knowledge of one or more human experts - Made up of a set of rules that analyze user supplied information about a specific class of problems. - Systems that utilize reasoning capabilities [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=72&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Definition of Expert systems are:</p>
<p>- Knowledge based systems<br />
- Part of the Artificial Intelligence field<br />
- Computer programs that contain some subject-specific knowledge of one or more human experts<br />
- Made up of a set of rules that analyze user supplied information about a specific class of problems.<br />
- Systems that utilize reasoning capabilities and draw conclusions.</p>
<p>Terms Associated with Expert Systems<br />
+ Knowledge Engineering – building an expert system<br />
+ Knowledge Engineers – the people who build the system<br />
+ Knowledge Representation – the symbols used to represent the knowledge<br />
+ Factual Knowledge – knowledge of a particular task domain that is widely shared<br />
+ Heuristic Knowledge – more judgmental knowledge of performance in a task domain.</p>
<p>Uses of Expert Systems<br />
- Very useful to companies with a high-level  of experience and expertise that cannot easily be transferred to other members.<br />
- Solves problems that would normally be tackled by a medical or other professional.<br />
- Currently used in fields such as accounting, medicine, process control, financial service, production, and human resources</p>
<p>Prominent Expert Systems<br />
&gt; MYCIN – used to diagnose infectious blood diseases and recommend antibiotics.<br />
&gt; DENDRAL – embedded a chemist’s knowledge of mass spectrometry rules to use in analysis.<br />
&gt; CADUCEUS – used to analyze blood-borne infectious bacteria<br />
&gt; CLIPS and Prolog programming languages are both used in expert systems<br />
- The Age of Empire game uses CLIPS to control its AI</p>
<p>Building an Expert System<br />
+ Can be built from scratch – using lots of if-then-else statements.<br />
+ There are many products being sold to make programming these systems easier.<br />
A few that I’m aware of:<br />
- Exsys – www.exsys.com – provides an easy to use user interface to develop traditional applications or web-based solutions.<br />
- Barisoft – www.barisoft.com – developed by a PSU professor and finely tuned by his students<br />
- CLIPS  &#8211; provides a complete environment for the construction of rules and/or object based expert systems<br />
- Jess – the Rule Engine, built</p>
<p>Components of an Expert System<br />
&gt; Set of Rules – derived from the knowledge base and used by the interpreter to evaluate the inputted data<br />
&gt; Knowledge Engineer – decides how to represent the experts knowledge and how to build the inference engine appropriately for the domain<br />
&gt; Interpreter – interprets the inputted data and draws a conclusion based on the users responses.</p>
<p>Problem-solving Models<br />
+ Forward-chaining – starts from a set of conditions and moves towards some conclusion<br />
+ Backward-chaining – starts with a list of goals and the works backwards to see if there is any data that will allow it to conclude any of these goals.<br />
+ Both problem-solving methods are built into inference engines or inference procedures<br />
Knowledge Objects<br />
- Classes – questions the user is asked<br />
- Parameters – place holder for a character string which can be variable and used to decide if/when a question is asked<br />
- Procedures – definitions of calls to external procedures<br />
- Rule Nodes – inferencing is done by a tree structure (decision trees!) and the nodes are called rule nodes.</p>
<p>Advantages of Expert Systems<br />
+ Provide consistent answers for repetitive decisions, processes and tasks.<br />
+ Hold and maintain significant levels of information.<br />
+ Reduce employee training costs<br />
+ Centralize the decision making process.<br />
+ Create efficiencies and reduce the time needed to solve problems.<br />
+  Combine multiple human expert intelligences<br />
+ Reduce the amount of human errors.<br />
+ Give strategic and comparative advantages creating entry barriers to competitors<br />
+ Review transactions that human experts may overlook.</p>
<p>Disadvantages of Expert Systems<br />
&gt; Lack human common sense needed in some decision making.<br />
&gt; Will not be able to give the creative responses that human experts can give in unusual circumstances.<br />
&gt; Domain experts cannot always clearly explain their logic and reasoning.<br />
&gt; Challenges of automating complex processes.<br />
&gt; Lack of flexibility and ability to adapt to changing environments.<br />
&gt; Not being able to recognize when no answer is available.</p>
<p>References :<br />
- “Expert Systems and Artificial Intelligence”. Engelmore, R., Feigenbaum, E., Chapter 1. http://www.wtec.org/loyola/kb/c1_s1.htm<br />
- “The Origin of Rule-Based Systems in AI”, Davis, R., King, J.<br />
- “Expert System – Wikipedia”, http://en.wikipedia.org/wiki/Expert_system</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=72&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/10/21/rule-basedexpert-systems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>
	</item>
		<item>
		<title>Facts, Rules, Predicates, and Variables in PROLOG</title>
		<link>http://madmathc.wordpress.com/2009/10/21/facts-rules-predicates-and-variables-in-prolog/</link>
		<comments>http://madmathc.wordpress.com/2009/10/21/facts-rules-predicates-and-variables-in-prolog/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:03:17 +0000</pubDate>
		<dc:creator>madmathc</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://madmathc.wordpress.com/?p=61</guid>
		<description><![CDATA[(1) Type the following program into a file and load it into Prolog. /* Animals Database */ animal(mammal,tiger,carnivore,stripes). animal(mammal,hyena,carnivore,ugly). animal(mammal,lion,carnivore,mane). animal(mammal,zebra,herbivore,stripes). animal(bird,eagle,carnivore,large). animal(bird,sparrow,scavenger,small). animal(reptile,snake,carnivore,long). animal(reptile,lizard,scavenger,small). Devise and test goals to find (a) all the mammals, (b) all the carnivores that are mammals, (c) all the mammals with stripes, (d) whether there is a reptile that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=61&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>(1) Type the following program into a file and load it into Prolog.</p>
<p>/* Animals Database */<br />
animal(mammal,tiger,carnivore,stripes).<br />
animal(mammal,hyena,carnivore,ugly).<br />
animal(mammal,lion,carnivore,mane).<br />
animal(mammal,zebra,herbivore,stripes).<br />
animal(bird,eagle,carnivore,large).<br />
animal(bird,sparrow,scavenger,small).<br />
animal(reptile,snake,carnivore,long).<br />
animal(reptile,lizard,scavenger,small).</p>
<p>Devise and test goals to find (a) all the mammals, (b) all the carnivores that are mammals, (c) all the mammals with stripes, (d) whether there is a reptile that has a mane.</p>
<p>(2) Type the following program into a file</p>
<p>/* Dating Agency Database */<br />
person(bill,male).<br />
person(george,male).<br />
person(alfred,male).<br />
person(carol,female).<br />
person(margaret,female).<br />
person(jane,female).</p>
<p>Extend the program with a rule that defines a predicate couple with two arguments, the first being the name of a man and the second the name of a woman.<br />
Load your revised program into Prolog and test it.</p>
<p>Okay, guys! This is our homework for this time. So, how can we find the answer? Now, this is the solution&#8230;.<br />
Question Number 1<br />
1. Type all words in the box in Notepad, save it and don’t forget to insert .pl at the end of your name.</p>
<p><img class="aligncenter size-full wp-image-62" title="Clip_5" src="http://madmathc.files.wordpress.com/2009/10/clip_5.jpg" alt="Clip_5" width="439" height="275" /></p>
<p>2. Consult your saved file in PROLOG.<br />
3. To find the answer of number 1.a, you must type this.<br />
<strong>?- animal(mammal,X,_,_).</strong><br />
Then press Enter.<br />
4. To find another answers, type ; then another answers can appear until word No appears. It means there is no answer again.</p>
<p><img class="aligncenter size-medium wp-image-63" title="Clip_6" src="http://madmathc.files.wordpress.com/2009/10/clip_6.jpg?w=300&#038;h=199" alt="Clip_6" width="300" height="199" /></p>
<p>5. To find the answer of number 1.b, you must type this.<br />
<strong> ?- animal(mammal,Y,carnivore,_).</strong><br />
Then press Enter.<br />
6. To find another answer, follow the instruction number  4.</p>
<p><img class="aligncenter size-medium wp-image-65" title="Clip_7" src="http://madmathc.files.wordpress.com/2009/10/clip_71.jpg?w=300&#038;h=199" alt="Clip_7" width="300" height="199" /></p>
<p>7. To find the answer of number 1.c, you must type this.<br />
<strong> ?- animal(mammal,Z,_,stripes).</strong><br />
Then press Enter.<br />
8. To find another answer, follow the instruction number  4.</p>
<p><img class="aligncenter size-medium wp-image-66" title="Clip_8" src="http://madmathc.files.wordpress.com/2009/10/clip_8.jpg?w=300&#038;h=199" alt="Clip_8" width="300" height="199" /></p>
<p>9. To find the answer of number 1.d, you must type this.<br />
<strong>?- animal(reptile,R,_,mane).</strong><br />
Then press Enter.<br />
10. The answer must be No, because there is no reptile has mane in that program.</p>
<p><img class="aligncenter size-medium wp-image-67" title="Clip_9" src="http://madmathc.files.wordpress.com/2009/10/clip_9.jpg?w=300&#038;h=199" alt="Clip_9" width="300" height="199" /></p>
<p>Question Number 2</p>
<p>1. Type all words in the box in Notepad.<br />
2. We must make a rule to find all possible couples. The couple must a man and a woman, not both of them are men or women. So the correct rule for this problem is :<br />
couple(X,Y) :- person(X,male),person(Y,female).<br />
3. Type it and save but don’t forget to insert .pl at the end of your name.</p>
<p><img class="aligncenter size-full wp-image-68" title="Clip_10" src="http://madmathc.files.wordpress.com/2009/10/clip_10.jpg" alt="Clip_10" width="439" height="277" />4. Consult your saved file in PROLOG.<br />
5. To find the answer, type this<br />
<strong>?- couple(X,Y).</strong><br />
Then press Enter.<br />
4. To find another answers, type ; then another answers can appear until word No appears. It means there is no answer again.</p>
<p><img class="aligncenter size-medium wp-image-69" title="Clip_11" src="http://madmathc.files.wordpress.com/2009/10/clip_11.jpg?w=300&#038;h=247" alt="Clip_11" width="300" height="247" /><br />
This is the end of this section. Don’t forget to give comment for our blog. Thank u.  (^_^)!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/madmathc.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/madmathc.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/madmathc.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=madmathc.wordpress.com&amp;blog=9718847&amp;post=61&amp;subd=madmathc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://madmathc.wordpress.com/2009/10/21/facts-rules-predicates-and-variables-in-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e30f6616b2b3e2ca2c01f92e024f697f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">madmathc</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_5.jpg" medium="image">
			<media:title type="html">Clip_5</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_6.jpg?w=300" medium="image">
			<media:title type="html">Clip_6</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_71.jpg?w=300" medium="image">
			<media:title type="html">Clip_7</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_8.jpg?w=300" medium="image">
			<media:title type="html">Clip_8</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_9.jpg?w=300" medium="image">
			<media:title type="html">Clip_9</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_10.jpg" medium="image">
			<media:title type="html">Clip_10</media:title>
		</media:content>

		<media:content url="http://madmathc.files.wordpress.com/2009/10/clip_11.jpg?w=300" medium="image">
			<media:title type="html">Clip_11</media:title>
		</media:content>
	</item>
	</channel>
</rss>
