<?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>Dicrete Mathematics can be FUN!!!</title>
	<atom:link href="http://discretemathisfun.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://discretemathisfun.wordpress.com</link>
	<description>Designed by Integer Euler</description>
	<lastBuildDate>Tue, 22 Dec 2009 12:49:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='discretemathisfun.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Dicrete Mathematics can be FUN!!!</title>
		<link>http://discretemathisfun.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://discretemathisfun.wordpress.com/osd.xml" title="Dicrete Mathematics can be FUN!!!" />
	<atom:link rel='hub' href='http://discretemathisfun.wordpress.com/?pushpress=hub'/>
		<item>
		<title>AUTO SCANNING VEHICLE (TESTING)</title>
		<link>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-testing/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-testing/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 15:11:43 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TESTING]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=132</guid>
		<description><![CDATA[This posting is about testing the expert system that we defined earlier. As one of user, we will input some of the database on our own. We’ll declare the data from some of Information System students in ITS, and their vehicle license plate : Dion owns Vehicle with number ‘P 4500 TJ’ declared as ?-plate(‘P [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=132&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This posting is about testing the expert system that we defined earlier.</p>
<p>As one of user, we will input some of the database on our own. We’ll declare the data from some of Information System students in ITS, and their vehicle license plate :</p>
<p><span style="color:#ff0000;"><strong>Dion</strong></span> owns Vehicle with number <span style="color:#ff0000;"><em>‘P 4500 TJ’</em> </span>declared as <span style="color:#ff0000;"><strong>?-plate(‘P 4500 TJ’,Dion).</strong></span></p>
<p><span style="color:#ff0000;"><strong>Dino</strong></span> own Vehicle with number <span style="color:#ff0000;"><em>‘W 5683 XD’</em></span> declared as <span style="color:#ff0000;"><strong>?-plate(‘W 5683 XD’,Dino).</strong></span></p>
<p><span style="color:#ff0000;"><strong>Hendra</strong></span> owns Vehicle with number <span style="color:#ff0000;"><em>‘P 5783 VC’</em></span> declared as <span style="color:#ff0000;"><strong>?-plate(‘P 5783 VC’,Hendra).</strong></span></p>
<p><span style="color:#ff0000;"><strong>Anggoro</strong></span> owns Vehicle with number <span style="color:#ff0000;"><em>‘AE 4088 TG’</em></span> declared as <span style="color:#ff0000;"><strong>?-plate(‘AE 4088 TG’,Anggoro).</strong></span></p>
<p><em> </em></p>
<p>As defined earlier, use create a predicate to run it, to search the database, and to make it looping forever.</p>
<p>The program  would be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/21.jpg"></a><a href="http://discretemathisfun.files.wordpress.com/2009/12/22.jpg"><img class="alignnone size-full wp-image-135" title="2" src="http://discretemathisfun.files.wordpress.com/2009/12/22.jpg?w=460" alt=""   /></a></p>
<p>The output of the program :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/13.jpg"><img class="alignnone size-full wp-image-136" title="1" src="http://discretemathisfun.files.wordpress.com/2009/12/13.jpg?w=460&#038;h=251" alt="" width="460" height="251" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=132&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-testing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/12/13.jpg" medium="image">
			<media:title type="html">1</media:title>
		</media:content>
	</item>
		<item>
		<title>AUTO SCANNING VEHICLE DEVELOPMENT</title>
		<link>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-developtment/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-developtment/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 12:59:16 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=124</guid>
		<description><![CDATA[As we defined before, that this expert-system works  by scanning license plate and scanning the face of the rider. If it match, the door will open, and print to the user : ‘Thank You’.  If it isn’t, the door will closed and print to the user : ‘Show your license number’. We’ll try this system [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=124&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As we defined before, that this expert-system works  by scanning license plate and scanning the face of the rider. If it match, the door will open, and print to the user : ‘Thank You’.  If it isn’t, the door will closed and print to the user : ‘Show your license number’.</p>
<p>We’ll try this system using PROLOG. The system is defined by first inputting the database, both is the license plate and the face (in this program, we defined the ‘face’ as a ‘name’).  The database of this program may be exampled like below :</p>
<p><em> </em></p>
<p><span style="color:#ff0000;"> <strong><em>plat(&#8216;P 1234 PP&#8217;,dion).<br />
</em><em>plat(&#8216;B 1234 ABC&#8217;,dino).</em><em><br />
plat(&#8216;W 1234 WW&#8217;,hendra).<br />
plat(&#8216;N 1234 NN&#8217;,anggoro).<br />
plat(&#8216;K 1234 KK&#8217;,bayu).<br />
plat(&#8216;AB 1234 AB&#8217;,yoga).<br />
</em><em>plat(&#8216;A 1234 AA&#8217;,bunga).<br />
plat(&#8216;DK 1234 DK&#8217;,mawar).<br />
plat(&#8216;D 1234 DD&#8217;,indah).<br />
plat(&#8216;AG 1234 AG&#8217;,harum).</em></strong></span></p>
<p><strong><em> </em></strong>Then we’ll need to defined a predicate to search within the database, as <span style="color:#ff0000;"><strong><em>?-nomerplat. </em></strong></span></p>
<p>We’ll try to make this usefull by making this looping forever.</p>
<p>The program  &#8216;example&#8217; would be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/untitled1.jpg"><img class="alignnone size-full wp-image-126" title="Untitled" src="http://discretemathisfun.files.wordpress.com/2009/12/untitled1.jpg?w=460" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=124&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/12/14/auto-scanning-vehicle-developtment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/12/untitled1.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>LOOPING using PROLOG</title>
		<link>http://discretemathisfun.wordpress.com/2009/12/07/looping-using-prolog/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/12/07/looping-using-prolog/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 06:47:12 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=112</guid>
		<description><![CDATA[Now, we will discuss about Looping in PROLOG. As we know, most of conventional programming languages have a looping facility that enables a set of instructions to b executed for a several times, or until a condition is met. Although, PROLOG has no looping facilities, similar looping effects can be done in some several ways, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=112&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now, we will discuss about Looping in PROLOG. As we know, most of conventional programming languages have a <em>looping</em> facility that enables a set of instructions to b executed for a several times, or until a condition is met. Although, PROLOG has no <em>looping </em>facilities, similar <em>looping</em> effects can be done in some several ways, using backtracking, recursion, built-in predicates, or a combination of them.</p>
<p><strong>1. </strong><strong><span style="text-decoration:underline;">Looping a Fixed Number of Times</span></strong></p>
<p>Unlike java, which has for-loops facilities to enable a set of instructions to be executed a fixed numbers of times, PROLOG is unavailable to do that (directly), but a similar effect can be obtained using recursion, such as :</p>
<p><span style="color:#ff0000;"><strong><em>testloop(0).<br />
testloop(N) :- N&gt;0, write(‘Number : ‘), write(N), nl, M is N-1, testloop(M).</em></strong></span></p>
<p>The testloop predicate is defined as ‘<em>loop from N, write the value of N, then subtract one to give to M, then loop from M</em>’. ‘<em>And by the first clause, is defined as ‘if the argument is zero, do nothing(stop!)</em>’.<br />
test of the program :</p>
<p><span style="color:#ff0000;"><strong><em>?- testloop(3).<br />
</em></strong><strong><em>Number : 3<br />
</em><em>Number :2<br />
</em><em>Number :1<br />
yes</em></strong></span></p>
<p><strong>2. </strong><strong><span style="text-decoration:underline;">Looping until a Condition is Satisfied</span></strong></p>
<p>This example below shows the use of recursion to read terms entered by the user from the keyboard and output them to the screen, until a word <em>end </em>is encountered, using ‘disjunctive goal’(word=end).</p>
<p><span style="color:#ff0000;"><strong><em>test :- write(‘Type the word : ‘), read(word), write(‘Input was ‘), write(word), nl, (word=end; test).</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>?- test.<br />
Type the word : Hello.<br />
Input was Hello<br />
Type the word : ITS.<br />
Input was ITS<br />
Type the word : end.<br />
Input was end.<br />
yes</em></strong></span><strong> </strong></p>
<p><strong>3. </strong><strong><span style="text-decoration:underline;">Backtracking with Failure</span></strong></p>
<p>As the name implies, the predicate fail, always fail, whether on ‘standard’ evaluation left to right or on backtracking. By combining it with PROLOG automatic backtracking, to search through the database to find all the clause with a special property, we can have automated looping.</p>
<p>This example of program below is designed to search database containing clauses representing the name, age, places of residence, and occupation of a number of people.</p>
<p>The database contains these values :</p>
<p><span style="color:#ff0000;"><strong><em>person(john,smith,45,london,doctor).</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>person(martin,williams,33,birmingham,teacher).</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>person(henry,smith,26,manchester,plumber).</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>person(jane,wilson,62,london,teacher).</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>person(mary,smith,29,glasgow,surveyor).</em></strong></span></p>
<p>The predicate <strong><em><span style="color:#ff0000;">somepeople</span> </em></strong>below is to search the person in the database which surname is <em>smith</em></p>
<p><span style="color:#ff0000;"><strong><em>somepeople :- person(Forename, Surname, _, _, _), Surname =smith, write(Forename), write(‘ ‘), write(Surname), nl, fail.</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>somepeople.</em></strong></span></p>
<p>The fail in somepeople predicate is used as a backtracking, which find all the database in the program.</p>
<p>Output of program would be :</p>
<p><span style="color:#ff0000;"><strong><em>?- somepeople.</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>john smith</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>henry smith</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>mary smith</em></strong></span></p>
<p><span style="color:#ff0000;"><strong><em>yes</em></strong></span></p>
<p>This below exercise would help you understand more about Looping in PROLOG.</p>
<p>These are taken from practical exercise 6 form book Logic Programming Using PROLOG.</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/0.jpg"><img class="alignnone size-full wp-image-116" title="0" src="http://discretemathisfun.files.wordpress.com/2009/12/0.jpg?w=460&#038;h=170" alt="" width="460" height="170" /></a></p>
<p>Exercise number 1 :</p>
<p>First, indicate, how many times the program should loop. As <strong><em><span style="color:#ff0000;">X is N2-N1+1</span> </em></strong><em>(as N1 is included)</em></p>
<p>Then for N1, print the squares of N1(Nsquare), as <span style="color:#ff0000;"><strong><em>Nsquare is N1*N1</em></strong></span>, then add N by 1, and subtract X by 1. Defined as <span style="color:#ff0000;"><strong><em>N is N1+1, X1 is X-1</em></strong></span></p>
<p>And last, loop from N and X1 as defined <span style="color:#ff0000;"><strong><em>process(N,X1)</em></strong></span></p>
<p>The program should be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/1.jpg"><img class="alignnone size-full wp-image-117" title="1" src="http://discretemathisfun.files.wordpress.com/2009/12/1.jpg?w=460&#038;h=87" alt="" width="460" height="87" /></a></p>
<p>The output of program should be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/2.jpg"><img class="alignnone size-full wp-image-118" title="2" src="http://discretemathisfun.files.wordpress.com/2009/12/2.jpg?w=460&#038;h=261" alt="" width="460" height="261" /></a></p>
<p>Exercise number 2 :</p>
<p>The program should be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/3.jpg"><img class="alignnone size-full wp-image-119" title="3" src="http://discretemathisfun.files.wordpress.com/2009/12/3.jpg?w=460" alt=""   /></a></p>
<p>The program takes no arguments that all input from user, until the new line (end of record/ASCII number 10) or ? (ASCII number 63).</p>
<p>The looping is shown at predicate process(Y).</p>
<p>The output of program should be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/4.jpg"><img class="alignnone size-full wp-image-120" title="4" src="http://discretemathisfun.files.wordpress.com/2009/12/4.jpg?w=460" alt=""   /></a></p>
<p>Exercise number 3 :</p>
<p>First create the person database like Part 3 from this chapter.</p>
<p>Then create a predicate that takes no argument, <em>age40</em> and have it read the person database on the Age and Profession only. As <span style="color:#ff0000;"><strong><em>person(_,_,Age,_,Profession)</em></strong></span>.<strong><em> </em></strong></p>
<p>It will only takes which age is greater than 40.</p>
<p>The program should be :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/5.jpg"><img class="alignnone size-full wp-image-121" title="5" src="http://discretemathisfun.files.wordpress.com/2009/12/5.jpg?w=460" alt=""   /></a></p>
<p>The output of the program :</p>
<p><a href="http://discretemathisfun.files.wordpress.com/2009/12/6.jpg"><img class="alignnone size-full wp-image-122" title="6" src="http://discretemathisfun.files.wordpress.com/2009/12/6.jpg?w=460&#038;h=201" alt="" width="460" height="201" /></a></p>
<p><span style="color:#ff0000;"><strong><span style="color:#000000;">IE <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </span><em><br />
</em></strong></span></p>
<p><strong><em> </em></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=112&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/12/07/looping-using-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/12/0.jpg" medium="image" />

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

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/12/6.jpg" medium="image">
			<media:title type="html">6</media:title>
		</media:content>
	</item>
		<item>
		<title>Input and Output in PROLOG (Exercise)</title>
		<link>http://discretemathisfun.wordpress.com/2009/11/25/input-and-output-in-prolog-exercise/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/11/25/input-and-output-in-prolog-exercise/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 12:52:45 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=83</guid>
		<description><![CDATA[this exercise will help you more understand about Input and Output in Prolog. These are taken from practical exercise 5 form book Logic Programming Using PROLOG. Exercise 1 Remember that upper case letters ASCII number is 65-90 for A-Z and 97-122 for a-z. First determine the upper case number (X) is 64&#60;X64,Y&#60;91,upper(Y);lower(Y)),makelower. If the ASCII [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=83&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>this exercise will help you more understand about Input and Output in Prolog.<br />
These are taken from practical exercise 5 form book Logic Programming Using PROLOG.<br />
Exercise 1<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/111.jpg"><img class="alignnone size-full wp-image-85" title="11" src="http://discretemathisfun.files.wordpress.com/2009/11/111.jpg?w=460&#038;h=175" alt="" width="460" height="175" /></a><br />
Remember that upper case letters ASCII number is 65-90 for A-Z and 97-122 for a-z.<br />
First determine the upper case number (X) is 64&lt;X64,Y&lt;91,upper(Y);lower(Y)),makelower.<br />
If the ASCII number is between 64-91(A-Z), then add it by 32 to make it between 97-122(a-z).<br />
The PROLOG program would be like :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/12.jpg"><img class="alignnone size-full wp-image-86" title="12" src="http://discretemathisfun.files.wordpress.com/2009/11/12.jpg?w=460" alt=""   /></a><br />
Output of program :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/13.jpg"><img class="alignnone size-full wp-image-87" title="13" src="http://discretemathisfun.files.wordpress.com/2009/11/13.jpg?w=460&#038;h=167" alt="" width="460" height="167" /></a><br />
Exercise 2 :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/21.jpg"><img class="alignnone size-full wp-image-88" title="21" src="http://discretemathisfun.files.wordpress.com/2009/11/21.jpg?w=460&#038;h=338" alt="" width="460" height="338" /></a><br />
First, use predicates to change input and output stream (as define earlier).  The point for this exercise is every terms in the output is separated by dot(.) in every line as end mark. Since the ASCII number for dot(.) is 46, the program would be :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/22.jpg"><img class="alignnone size-full wp-image-89" title="22" src="http://discretemathisfun.files.wordpress.com/2009/11/22.jpg?w=460&#038;h=131" alt="" width="460" height="131" /></a><br />
Now test the program, first make the Input file, name it ‘in copyterms.txt’ :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/23.jpg"><img class="alignnone size-full wp-image-90" title="23" src="http://discretemathisfun.files.wordpress.com/2009/11/23.jpg?w=460" alt=""   /></a><br />
Test your PROLOG program by inputting this :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/24.jpg"><img class="alignnone size-full wp-image-91" title="24" src="http://discretemathisfun.files.wordpress.com/2009/11/24.jpg?w=460" alt=""   /></a><br />
The output file should appear with the name ‘out copyterms.txt’ :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/25.jpg"><img class="alignnone size-full wp-image-92" title="25" src="http://discretemathisfun.files.wordpress.com/2009/11/25.jpg?w=460" alt=""   /></a><br />
Exercise 3 :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/31.jpg"><img class="alignnone size-full wp-image-93" title="31" src="http://discretemathisfun.files.wordpress.com/2009/11/31.jpg?w=460&#038;h=165" alt="" width="460" height="165" /></a><br />
As defined before, you can read END_OF_FILE or END_OF_RECORD with negative ASCII number (-1). Therefore, the program would be :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/32.jpg"><img class="alignnone size-full wp-image-94" title="32" src="http://discretemathisfun.files.wordpress.com/2009/11/32.jpg?w=460&#038;h=88" alt="" width="460" height="88" /></a><br />
First create the input file, name it ‘tesla.txt’ :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/33.jpg"><img class="alignnone size-full wp-image-95" title="33" src="http://discretemathisfun.files.wordpress.com/2009/11/33.jpg?w=460" alt=""   /></a><br />
Test your PROLOG program :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/343.jpg"><img class="alignnone size-full wp-image-99" title="34" src="http://discretemathisfun.files.wordpress.com/2009/11/343.jpg?w=460&#038;h=296" alt="" width="460" height="296" /></a><br />
Exercise 4 :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/411.jpg"><img class="alignnone size-full wp-image-100" title="41" src="http://discretemathisfun.files.wordpress.com/2009/11/411.jpg?w=460&#038;h=116" alt="" width="460" height="116" /></a><br />
The combine predicate takes 2 file to be read, so first make new 2 predicates combine1(for file 1) and combine2(for file2).  And have the program to read it and put seen and told in combine2 only. The PROLOG program should be :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/42.jpg"><img class="alignnone size-full wp-image-101" title="42" src="http://discretemathisfun.files.wordpress.com/2009/11/42.jpg?w=460&#038;h=215" alt="" width="460" height="215" /></a><br />
Now make the input file, ‘in1.txt’ and ‘in2.txt’  :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/43.jpg"><img class="alignnone size-full wp-image-102" title="43" src="http://discretemathisfun.files.wordpress.com/2009/11/43.jpg?w=460" alt=""   /></a><br />
Test your program :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/44.jpg"><img class="alignnone size-full wp-image-103" title="44" src="http://discretemathisfun.files.wordpress.com/2009/11/44.jpg?w=460&#038;h=184" alt="" width="460" height="184" /></a><br />
Output of Program ‘in1+in2.txt’ :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/45.jpg"><img class="alignnone size-full wp-image-104" title="45" src="http://discretemathisfun.files.wordpress.com/2009/11/45.jpg?w=460" alt=""   /></a><br />
Exercise 5 :<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/51.jpg"><img class="alignnone size-full wp-image-105" title="51" src="http://discretemathisfun.files.wordpress.com/2009/11/51.jpg?w=460&#038;h=71" alt="" width="460" height="71" /></a><br />
The last is compare predicates, first read 2 file like the combine predicates in previous number. Read all file and if the ASCII number is the same until the end of file, the both file is the same. If not then it’s not the same.<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/52.jpg"><img class="alignnone size-full wp-image-106" title="52" src="http://discretemathisfun.files.wordpress.com/2009/11/52.jpg?w=460&#038;h=123" alt="" width="460" height="123" /></a><br />
Now make 2 file which is not the same name it ‘compare1.txt’ and ‘compare2.txt’.<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/53.jpg"><img class="alignnone size-full wp-image-107" title="53" src="http://discretemathisfun.files.wordpress.com/2009/11/53.jpg?w=460" alt=""   /></a><br />
Test your PROLOG program, the output should be NOT SAME.<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/54.jpg"><img class="alignnone size-full wp-image-108" title="54" src="http://discretemathisfun.files.wordpress.com/2009/11/54.jpg?w=460&#038;h=220" alt="" width="460" height="220" /></a><br />
Now try to change ‘compare2.txt’ into the same file like ‘compare1.txt’<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/55.jpg"><img class="alignnone size-full wp-image-109" title="55" src="http://discretemathisfun.files.wordpress.com/2009/11/55.jpg?w=460" alt=""   /></a><br />
Test your PROLOG program again, the output should be SAME.<br />
<a href="http://discretemathisfun.files.wordpress.com/2009/11/56.jpg"><img class="alignnone size-full wp-image-110" title="56" src="http://discretemathisfun.files.wordpress.com/2009/11/56.jpg?w=460&#038;h=212" alt="" width="460" height="212" /></a><br />
IE<br />
 <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=83&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/11/25/input-and-output-in-prolog-exercise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

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

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

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

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

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

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

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

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/11/343.jpg" medium="image">
			<media:title type="html">34</media:title>
		</media:content>

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/11/411.jpg" medium="image">
			<media:title type="html">41</media:title>
		</media:content>

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

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

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

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

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

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/11/56.jpg" medium="image">
			<media:title type="html">56</media:title>
		</media:content>
	</item>
		<item>
		<title>Input and Output in PROLOG</title>
		<link>http://discretemathisfun.wordpress.com/2009/11/24/input-and-output-in-prolog/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/11/24/input-and-output-in-prolog/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 15:44:33 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=81</guid>
		<description><![CDATA[Input and Output Prolog has facilities to enable input and output either of terms or of characters. Using terms is simpler and will be described first. Initially, it will be assumed that all output is to the user&#8217;s screen and all input is from the user&#8217;s keyboard. Input and output using external files, e.g. on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=81&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Input and Output</p>
<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } -->Prolog has facilities to enable input and output either of terms or of characters. Using terms is simpler and will be described first. Initially, it will be assumed that all output is to the user&#8217;s screen and all input is from the user&#8217;s keyboard. Input and output using external files, e.g. on a hard disk or CD-ROM. Note that, like many other built-in predicates, those for input and output described in this chapter are all  unresatisfiable, i.e. they always fail when backtracking.</p>
<p>&nbsp;</p>
<p><strong>Outputting Terms</strong></p>
<p>The <strong><em><span style="color:#ff0000;">write</span></em> </strong>predicate takes a single argument, which must be a valid Prolog term. Evaluating the predicate causes the term to be written to the current output stream, which by default is the user&#8217;s screen. The built-in predicate <strong><em><span style="color:#ff0000;">nl</span></em></strong> has also been used many times previously in this book. It takes no arguments. Evaluating a <strong><em><span style="color:#ff0000;">nl</span></em></strong> goal causes a new line to be output to the current output stream.</p>
<p>For example :</p>
<p><span style="color:#ff0000;"><em><strong>?- write(‘Integer’), nl, write(‘Euler’).</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>Integer</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>Euler</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>Yes</strong></em></span></p>
<p>&nbsp;</p>
<p><strong>Inputting Terms</strong></p>
<p>The built-in predicate <strong><em><span style="color:#ff0000;">read</span></em></strong> is provided to input terms. It takes a single argument, which must be a variable. In the input stream, the term must be followed by a dot (&#8216;.&#8217;) and at least one white space character, such as space or newline. The dot and white space characters are read in but are not considered part of the term. When a  <strong><em><span style="color:#ff0000;">read</span></em></strong> goal is evaluated, the input term is  unified with the argument variable. If the variable is unbound (which is usually the case) it is bound to the input value.</p>
<p><span style="color:#ff0000;"><em><strong>?- read(X).</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>| : Dion.</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>X = Dion</strong></em></span></p>
<p>&nbsp;</p>
<p><strong>Input and Output Using Characters</strong></p>
<p>Although input and output of terms is straightforward, the use of quotes and full  stops can be cumbersome and is not always suitable. It would be tedious to define a predicate (using read). A much better approach for problems of this kind is to input a character at a time. To do this it is first necessary to know about the ASCII value of a character.</p>
<p>All printing characters and many non-printing characters (such as space and tab) have a corresponding ASCII (American Standard Code for Information Interchange) value, which is an integer from 0 to 255.</p>
<p>As shown in the table below :</p>
<p>&nbsp;</p>
<p><strong>Outputting Characters</strong></p>
<p>Characters are output using the built-in predicate  <strong><em><span style="color:#ff0000;">put</span></em></strong>. The predicate takes a</p>
<p>single argument, which must be a number from 0 to 255 or an expression that</p>
<p>evaluates to an integer in that range.</p>
<p>Evaluating a  <strong><em><span style="color:#ff0000;">put</span></em></strong> goal causes a single character to be output to the current</p>
<p>output stream. This is the character corresponding to the numerical value (ASCII</p>
<p>value) of its argument.</p>
<p>For example :</p>
<p><span style="color:#ff0000;"><em><strong>?- put(92), nl, put(122).</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>\</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>Z</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>Yes</strong></em></span></p>
<p>&nbsp;</p>
<p><strong>Inputting Characters</strong></p>
<p>Two built-in predicates are provided to input a single character: <strong><em><span style="color:#ff0000;">get0</span></em></strong> and <strong><em><span style="color:#ff0000;">get</span></em>.</strong> The <strong><em><span style="color:#ff0000;">get0</span></em></strong> predicate takes a single argument, which must be a variable. Evaluating a <strong><em><span style="color:#ff0000;">get0</span></em></strong> goal causes a character to be read from the current input stream. The variable is then unified with the ASCII value of this character.</p>
<p>For example :</p>
<p><strong><em><span style="color:#ff0000;">?- get(X).</span></em></strong></p>
<p><span style="color:#ff0000;"><em><strong>|: Z</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>X = 90</strong></em></span></p>
<p><strong><em><span style="color:#ff0000;">?- get0(X).</span></em></strong></p>
<p><span style="color:#ff0000;"><em><strong>|:                           Z</strong></em></span></p>
<p><span style="color:#ff0000;"><em><strong>X = 90</strong></em></span></p>
<p>&nbsp;</p>
<p><strong>File Output: Changing the Current Output Stream</strong></p>
<p>The current output stream can be changed using the <strong><em><span style="color:#ff0000;">tell</span></em> </strong>predicate. This takes a single argument, which is an atom or variable representing a file name, e.g.</p>
<p><strong><em><span style="color:#ff0000;">tell(&#8216;outfile.txt&#8217;)</span></em></strong>.</p>
<p>Evaluating a <strong><em><span style="color:#ff0000;">tell </span></em></strong>goal causes the named file to become the current output stream. If the file is not already open, a file with the specified name is first created(any existing file with the same name is deleted).</p>
<p>The built-in predicate <strong><em><span style="color:#ff0000;">told</span></em> </strong>takes no arguments. Evaluating a <strong><em><span style="color:#ff0000;">told</span></em> </strong>goal causes the current output file to be closed and the current output stream to be reset to <em>user</em>, i.e. the user&#8217;s terminal.</p>
<p>The built-in predicate <strong><em><span style="color:#ff0000;">telling</span></em> </strong>takes one argument, which must be a variable and will normally be unbound. Evaluating a <strong><em><span style="color:#ff0000;">telling</span></em> </strong>goal causes the variable to be bound to the name of the current output stream.</p>
<p>&nbsp;</p>
<p><strong>File Input: Changing the Current Input Stream</strong></p>
<p>The current input stream can be changed using the <strong><em><span style="color:#ff0000;">see</span></em> </strong>predicate. This takes asingle argument, which is an atom or variable representing a file name, e.g.</p>
<p><strong><em><span style="color:#ff0000;">see(&#8216;myfile.txt&#8217;)</span></em></strong>.</p>
<p>Evaluating a <strong><em><span style="color:#ff0000;">see</span></em> </strong>goal causes the named file to become the current input stream. If the file is not already open it is first opened (for read access only). If it is not possible to open a file with the given name, an error will be generated.</p>
<p>The built-in predicate <strong><em><span style="color:#ff0000;">seen</span></em> </strong>takes no arguments. Evaluating a <strong>see </strong>goal causes the current input file to be closed and the current input stream to be reset to <em>user</em>, i.e. the user&#8217;s terminal.</p>
<p>The built-in predicate <strong><em><span style="color:#ff0000;">seeing</span></em> </strong>takes one argument, which must be a variable and will normally be unbound. Evaluating a <strong><em><span style="color:#ff0000;">seeing</span></em> </strong>goal causes the variable to be bound to the name of the current input stream.</p>
<p>IE</p>
<p> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=81&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/11/24/input-and-output-in-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>
	</item>
		<item>
		<title>Auto Scanning Vehicle (ASV)</title>
		<link>http://discretemathisfun.wordpress.com/2009/11/24/auto-scanning-vehicle-asv/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/11/24/auto-scanning-vehicle-asv/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 15:33:21 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[Expert System Design]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/2009/11/24/auto-scanning-vehicle-asv/</guid>
		<description><![CDATA[Vehicle robbery problem has increased from time to time. Even in the State University, for example our beloved ITS. It really worries us as one of the students. The robber, usually change the vehicle number with the new one and they have the exact STNK according to it’s type. The parking system in this time, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=78&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Vehicle robbery problem has increased from time to time. Even in the State University, for example our beloved ITS. It really worries us as one of the students. The robber, usually change the vehicle number with the new one and they have the exact STNK according to it’s type. The parking system in this time, really slow and not safe. Usually some students in University, have to wait a long time to get out from the parking lot. Because of some checking (parking ticket, etc.) that takes some time. Although it may be possible that they have some important matter to do.<br />
We need a new system to develop this situation, and as one of students who need to change the old system, our team manage to develop a new parking system. We call this Auto Scanning Vehicle (ASV). In hope with this system, parking would be more effective and safer.<br />
This system works by scanning the outgoing vehicle by using some sensor to determine the vehicle type and number. The system would have the database to be checked with the vehicle type and number. If it was true (means checked and True) the parking door would be open, if not, the door would close itself and have it the double checked by the officer.<br />
What about the quest? There would be no data in the database system right?<br />
well, for this our team suggest the usage of some ‘special’ parking lot and will be checked manually.<br />
By using the ASV system, it would be  more effective because we can easily and faster for parking check. Because we will no more have to wait before getting out from the parking lot. Aside that, it would be a lot safer because the sensor will also record the face of it’s driver. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=78&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/11/24/auto-scanning-vehicle-asv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>
	</item>
		<item>
		<title>OPERATOR AND ARITHMETIC in Prolog</title>
		<link>http://discretemathisfun.wordpress.com/2009/11/11/operator-and-arithmetic-in-prolog/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/11/11/operator-and-arithmetic-in-prolog/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 18:06:43 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=63</guid>
		<description><![CDATA[Last time, we discussed about FACTS, RULES, PREDICATE and VARIABLE. Our topic now is about OPERATOR AND ARITHMETIC. Up to now, the function we used is still the standard one. As an alternative, we can convert a predicate to be written without parenthesis by using operator by entering a goal using op predicate. for example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=63&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last time, we discussed about <span style="text-decoration:underline;"><strong>FACTS, RULES, PREDICATE and VARIABLE</strong></span>. Our topic now is about OPERATOR AND ARITHMETIC.</p>
<p>Up to now, the function we used is still the standard one. As an alternative, we can convert a predicate to be written without parenthesis by using operator by entering a goal using <strong>op </strong>predicate. for example :</p>
<p lang="id-ID"><span style="color:#ff3366;"><strong>?- op(150,xfy,couple)</strong></span></p>
<p lang="id-ID">first argument (150) means operator precedence. It’s Integer ranged from 0 to 150. The lower the number, the higher the precedence.</p>
<p>second argument (xfy) is one of the following atoms :<strong> </strong></p>
<p><strong>xfy </strong>meaning that the predicate is binary 	(consist of 2 arguments) and is to be converted to an infix 	operator, as exampled below :</p>
<p><span style="color:#ff3366;"><strong>?-op(150,xfy,couple</strong></span><span style="color:#ff3366;"><strong>_with).</strong></span><br />
<span style="color:#ff3366;"><strong>bill couple_with margaret.</strong></span><strong> </strong></p>
<p><strong>fy </strong>meaning that 	the predicate is unary (consist of 1 arguments)  and is to be 	converted to an prefix operator, for example :</p>
<p><span style="color:#ff3366;"><strong>?-op(150,fy,is_male).<br />
is_male bill.</strong></span></p>
<p><span style="color:#ff3366;"><strong> </strong></span><strong>x</strong><strong>f </strong>meaning that 	the predicate is unary (consist of 1 arguments)  and is to be 	converted to an postfix operator, for example :</p>
<p lang="id-ID"><span style="color:#ff3366;"><strong>?-op(150,</strong></span><span style="color:#ff3366;"><strong>fy,is_female).<br />
margaret is_female.</strong></span></p>
<p lang="id-ID">the third argument (couple) is the name of arguments that is to be converted as an operator.</p>
<p>it’s clearly easier using operator like <span style="color:#ff3366;"><strong>bill couple_with margaret</strong></span> rather than predicate <span style="color:#ff3366;"><strong>couple_with(bill,margaret)</strong></span></p>
<p lang="id-ID">Prolog also has arithmatic using a notation similiar as from algebra, as shown from table below :</p>
<p lang="id-ID"><img class="alignnone size-full wp-image-65" title="1" src="http://discretemathisfun.files.wordpress.com/2009/11/11.jpg?w=460&#038;h=201" alt="1" width="460" height="201" /></p>
<p lang="id-ID">For Example :</p>
<p><span style="color:#ff3366;"><strong>?- X is 24,</strong></span><span style="color:#ff3366;"><strong> Y is 6, Z is X*Y+X/Y.</strong></span></p>
<p lang="id-ID"><span style="color:#ff3366;"><strong>X = 24</strong></span></p>
<p lang="id-ID"><span style="color:#ff3366;"><strong>Y = 6</strong></span></p>
<p lang="id-ID"><span style="color:#ff3366;"><strong>Z = 148</strong></span></p>
<p lang="id-ID">
<p>this exercise will help you more understand about Operator an Arithmetics in Prolog.</p>
<p lang="id-ID">These are taken from practical exercise 4 form book Logic Programming Using PROLOG.</p>
<p lang="id-ID"><img class="alignnone size-full wp-image-67" title="2" src="http://discretemathisfun.files.wordpress.com/2009/11/2.jpg?w=460&#038;h=460" alt="2" width="460" height="460" /></p>
<p>let’s convert all the predicates using operator which convert :</p>
<p>dog(fido) <span style="font-family:Wingdings;"></span> fido isa_dog by using <span style="color:#ff3366;"><strong>?- op(150,xf,isa_dog).</strong></span></p>
<p>cat(mary) <span style="font-family:Wingdings;"></span> mary isa_cat by using <span style="color:#ff3366;"><strong>?- op(150,xf,isa_cat).</strong></span></p>
<p>large(mary) <span style="font-family:Wingdings;"></span> mary is_large by using <span style="color:#ff3366;"><strong>?- op(150,xf,is_large).</strong></span></p>
<p>small(rover) <span style="font-family:Wingdings;"></span> rover is_small by using <span style="color:#ff3366;"><strong>?- op(150,xf,is_small)</strong></span><strong>.</strong></p>
<p>large_dog(X) <span style="font-family:Wingdings;"></span> X isa_large_dog by using <span style="color:#ff3366;"><strong>?- op(150,xf,isa_large_dog).</strong></span></p>
<p>small_animal(A) <span style="font-family:Wingdings;"></span> A isa_small_animal by using <span style="color:#ff3366;"><strong>?- op(150,xf,isa_small_animal).</strong></span></p>
<p>chases(X,Y) <span style="font-family:Wingdings;"></span> X chases Y by using <span style="color:#ff3366;"><strong>?- op(150,xfy,chases).</strong></span></p>
<p lang="id-ID"><img class="alignnone size-full wp-image-68" title="3" src="http://discretemathisfun.files.wordpress.com/2009/11/3.jpg?w=460&#038;h=555" alt="3" width="460" height="555" /></p>
<p lang="id-ID">Output of program :</p>
<p lang="id-ID"><img class="alignnone size-full wp-image-73" title="4" src="http://discretemathisfun.files.wordpress.com/2009/11/41.jpg?w=460&#038;h=511" alt="4" width="460" height="511" /></p>
<p lang="id-ID">for the second exercise :</p>
<p lang="id-ID"><img class="alignnone size-full wp-image-70" title="5" src="http://discretemathisfun.files.wordpress.com/2009/11/5.jpg?w=460&#038;h=53" alt="5" width="460" height="53" /></p>
<p lang="id-ID">We’ll need to configure each part:</p>
<p>average, we can define it as <span style="color:#ff3366;"><strong>AVG is (X+Y)/2</strong></span></p>
<p>square root of each product, we can define it as <span style="color:#ff3366;"><strong>SRX is sqrt(X) and SRY is sqrt(Y)</strong></span></p>
<p>larger is defined by <span style="color:#ff3366;"><strong>Z is X,X&gt;=Y,write(Z);write(Y)</strong></span><span style="color:#000000;"> means the greater one would be printed.</span></p>
<p lang="id-ID"><img class="alignnone size-full wp-image-71" title="6" src="http://discretemathisfun.files.wordpress.com/2009/11/6.jpg?w=460&#038;h=102" alt="6" width="460" height="102" /></p>
<p lang="id-ID">Output of program :</p>
<p lang="id-ID"><img class="alignnone size-full wp-image-72" title="7" src="http://discretemathisfun.files.wordpress.com/2009/11/7.jpg?w=460&#038;h=294" alt="7" width="460" height="294" /></p>
<p lang="id-ID">
<p lang="id-ID">IE<br />
 <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=63&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/11/11/operator-and-arithmetic-in-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

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

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

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/11/7.jpg" medium="image">
			<media:title type="html">7</media:title>
		</media:content>
	</item>
		<item>
		<title>FACTS, RULES, PREDICATE and VARIABLE</title>
		<link>http://discretemathisfun.wordpress.com/2009/10/20/facts-rules-predicate-and-variable/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/10/20/facts-rules-predicate-and-variable/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 16:11:42 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=42</guid>
		<description><![CDATA[Allright, back with us, The Integer Euler at the last post, we told you about How to list all possible combination using PROLOG. Here we’ll try to practice about FACTS, RULES, PREDICATE and VARIABLE. We will give an example from the book Logic Programming Using PROLOG by Max Bramer, page 27. Practical Exercises no.1 : [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=42&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Allright, back with us, The Integer Euler <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">at the last post, we told you about How to list all possible combination using PROLOG. Here we’ll try to practice about FACTS, RULES, PREDICATE and VARIABLE. </span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">We will give an example from the book Logic Programming Using PROLOG by Max Bramer, page 27.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Practical Exercises no.1 :</span></span></p>
<p style="margin-bottom:0;"><img class="alignnone size-full wp-image-43" title="40" src="http://discretemathisfun.files.wordpress.com/2009/10/40.jpg?w=460&#038;h=324" alt="40" width="460" height="324" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">We know from the Question, there are 3 kinds of animal (mammal, bird, reptile) 8 different animals ( tiger, hyena, lion, zebra, eagle, sparrow, snake, lizard ) . and different attributes (such as : carnivore,herbivore, scavenger, stripes, etc).</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Then, we’ll have to Devise and test goals to find some problem.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Let’s try to solve this, first enter the facts into <em>Notepad/Wordpad</em>.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-44" title="41" src="http://discretemathisfun.files.wordpress.com/2009/10/411.jpg?w=460&#038;h=190" alt="41" width="460" height="190" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Then save the file and name it animal.pl</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-45" title="42" src="http://discretemathisfun.files.wordpress.com/2009/10/42.jpg?w=460&#038;h=327" alt="42" width="460" height="327" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Now Load the file. Earlier we told you to open it using ProLog program and choose File </span><span style="font-family:Wingdings;"></span><span style="font-family:Times New Roman,serif;">Consult </span><span style="font-family:Wingdings;"></span><span style="font-family:Times New Roman,serif;"> pick the file you saved earlier. Now you can open it by just double click on it, in the Explorer.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><img class="alignnone size-full wp-image-46" title="43" src="http://discretemathisfun.files.wordpress.com/2009/10/43.jpg?w=460" alt="43"   /><br />
</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Pay attention in the first line, if it show “xxxx.pl compiled in xxx sec, xxxx bytes” then your program is correct.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-47" title="44" src="http://discretemathisfun.files.wordpress.com/2009/10/44.jpg?w=460" alt="44"   /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Now, to list all the mammals just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><strong><span style="color:#ff0000;"><span style="font-family:Times-Roman;"><span style="font-size:x-small;">?- animals (mammal,X,_,_).</span></span></span></strong></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-48" title="45" src="http://discretemathisfun.files.wordpress.com/2009/10/45.jpg?w=460" alt="45"   /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">To list all all the carnivores that are mammals just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:x-small;"><span style="font-family:Times-Roman;"><span style="color:#ff0000;">?- animals (mammal,X,carnivore,_).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:x-small;"><span style="font-family:Times-Roman;"><span style="color:#ff0000;"><img class="alignnone size-full wp-image-51" title="46" src="http://discretemathisfun.files.wordpress.com/2009/10/461.jpg?w=460" alt="46"   /><br />
</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">To list all the mammals with stripes just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:x-small;"><span style="font-family:Times-Roman;"><span style="color:#ff0000;">?- animals (mammal,X,_,stripes).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><img class="alignnone size-full wp-image-50" title="47" src="http://discretemathisfun.files.wordpress.com/2009/10/47.jpg?w=460" alt="47"   /><br />
</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">To list whether there is a reptile that has a mane just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:x-small;"><span style="font-family:Times-Roman;"><span style="color:#ff0000;">?- animals (reptile,X,_,mane).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><img class="alignnone size-full wp-image-52" title="48" src="http://discretemathisfun.files.wordpress.com/2009/10/48.jpg?w=460" alt="48"   /><br />
</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">The underscore character ( _ ) denotes a special variable, called the anonymous variable. This is used when the user does not care about the value of the variable.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Practical Exercises no.2 :</span></span></p>
<p style="margin-bottom:0;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><img class="alignnone size-full wp-image-53" title="50" src="http://discretemathisfun.files.wordpress.com/2009/10/50.jpg?w=460&#038;h=238" alt="50" width="460" height="238" /><br />
</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">We know from the Question, there are 6 persons with 3 Male (bill, george, alfred) and 3 Female (carol, margaret, jane). And we need to Extend the program with a rule that defines a predicate couple.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Since Couple means 1 Male and 1 Female, the predicate couple should be :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><em><span style="color:#ff0000;">couple(M,F) :- person(M,male), person(F,female).</span></em></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Now, let’s try to solve this, first enter the facts and the predicates couple into <em>Notepad/Wordpad</em>.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-54" title="51" src="http://discretemathisfun.files.wordpress.com/2009/10/511.jpg?w=460" alt="51"   /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Then save the file and name it person.pl</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-55" title="52" src="http://discretemathisfun.files.wordpress.com/2009/10/521.jpg?w=460&#038;h=327" alt="52" width="460" height="327" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Now Load the file from File Explorer.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-56" title="53" src="http://discretemathisfun.files.wordpress.com/2009/10/53.jpg?w=460&#038;h=204" alt="53" width="460" height="204" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Now, to list all the possible combination couple,  just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="color:#ff0000;"><span style="font-family:Times-Roman;"><span style="font-size:x-small;">?- couple (MALE,FEMALE).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-57" title="55" src="http://discretemathisfun.files.wordpress.com/2009/10/55.jpg?w=460&#038;h=437" alt="55" width="460" height="437" /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">If you want to list all all the possible couple for “ bill ” just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="color:#ff0000;"><span style="font-family:Times-Roman;"><span style="font-size:x-small;">?- couple (bill,FEMALE).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-58" title="56" src="http://discretemathisfun.files.wordpress.com/2009/10/56.jpg?w=460" alt="56"   /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">If you want to list all all the possible couple for “ margaret ” just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="color:#ff0000;"><span style="font-family:Times-Roman;"><span style="font-size:x-small;">?- couple (MALE,margaret).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><img class="alignnone size-full wp-image-59" title="57" src="http://discretemathisfun.files.wordpress.com/2009/10/57.jpg?w=460" alt="57"   /></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">If you want to check whether “ bill ” and “ margaret ” would make a couple just type :</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="color:#ff0000;"><span style="font-family:Times-Roman;"><span style="font-size:x-small;">?- couple (bill,margaret).</span></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><img class="alignnone size-full wp-image-60" title="58" src="http://discretemathisfun.files.wordpress.com/2009/10/58.jpg?w=460" alt="58"   /></span></span></p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p style="margin-bottom:0;">IE</p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=42&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/10/20/facts-rules-predicate-and-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/411.jpg" medium="image">
			<media:title type="html">41</media:title>
		</media:content>

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/461.jpg" medium="image">
			<media:title type="html">46</media:title>
		</media:content>

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/511.jpg" medium="image">
			<media:title type="html">51</media:title>
		</media:content>

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/521.jpg" medium="image">
			<media:title type="html">52</media:title>
		</media:content>

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

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

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

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

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/58.jpg" medium="image">
			<media:title type="html">58</media:title>
		</media:content>
	</item>
		<item>
		<title>Rule – Based Expert System</title>
		<link>http://discretemathisfun.wordpress.com/2009/10/20/rule-%e2%80%93-based-expert-system/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/10/20/rule-%e2%80%93-based-expert-system/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 15:46:55 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[Literature Review]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=40</guid>
		<description><![CDATA[First, we need to know What is an Expert System. An expert system is software that attempts to provide an answer to a problem, or clarify uncertainties where normally one or more human experts would need to be consulted. Expert systems are most common in a specific problem domain, and is a traditional application and/or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=40&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">First, we need to know What is an <strong><span style="text-decoration:underline;">Expert System</span></strong>.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">An expert system is software that attempts to provide an answer to a problem, or clarify uncertainties where normally one or more human experts would need to be consulted. Expert systems are most common in a specific problem domain, and is a traditional application and/or subfield of artificial intelligence. A wide variety of methods can be used to simulate the performance of the expert however common to most or all are 1) the creation of a so-called &#8220;knowledgebase&#8221; which uses some knowledge representation formalism to capture the Subject Matter Expert&#8217;s (SME) knowledge and 2) a process of gathering that knowledge from the SME and codifying it according to the formalism, which is called knowledge engineering. Expert systems may or may not have learning components but a third common element is that once the system is developed it is proven by being placed in the same real world problem solving situation as the human SME, typically as an aid to human workers or a supplement to some information system.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">There are two main methods of reasoning when using inference rules: <em>backward chaining</em> and <em>forward chaining</em>.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><em>Forward chaining</em> starts with the data available and uses the inference rules to conclude more data until a desired goal is reached. An inference engine using forward chaining searches the inference rules until it finds one in which the if clause is known to be true. It then concludes the then clause and adds this information to its data. It would continue to do this until a goal is reached. Because the data available determines which inference rules are used, this method is also called data driven.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><em>Backward chaining</em> starts with a list of goals and works backwards to see if there is data which will allow it to conclude any of these goals. An inference engine using backward chaining would search the inference rules until it finds one which has a then clause that matches a desired goal. If the if clause of that inference rule is not known to be true, then it is added to the list of goals. For example, suppose a rule base contains :</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#ff0000;">If 	Fritz is green then Fritz is a frog</span>.</span></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#ff0000;">If 	Fritz is a frog then Fritz hops</span>.</span></span></p>
</li>
</ol>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Suppose a goal is to conclude that Fritz hops. The rule base would be searched and rule (2) would be selected because its conclusion (the then clause) matches the goal. It is not known that Fritz is a frog, so this &#8220;if&#8221; statement is added to the goal list. The rule base is again searched and this time rule (1) is selected because its then clause matches the new goal just added to the list. This time, the if clause (Fritz is green) is known to be true and the goal that Fritz hops is concluded. Because the list of goals determines which rules are selected and used, this method is called goal driven.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">This <em>Backward Chaining</em> method is called <strong><span style="text-decoration:underline;">Rule-Based Expert System.</span></strong></span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">So, what is <strong><span style="text-decoration:underline;">Rule – Based Expert System</span></strong> ?</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">It is an expert system based on a set of rules that a human expert would follow in diagnosing a problem. Rule – Based Expert System contrast with model-based expert system (An expert system based on fundamental knowledge of the design and function of an object. Such systems are used to diagnose equipment problems, for example).</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">As a premiere application of computing and artificial intelligence, the topic of expert systems has many points of contact with general systems theory, operations research, business process reengineering and various topics in applied mathematics and management science.</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify">
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">( <a href="http://en.wikipedia.org/wiki/Expert_system">http://en.wikipedia.org/wiki/Expert_system</a> )</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><br />
</span></span></p>
<p style="margin-bottom:0;line-height:150%;" align="justify"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">IE</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=40&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/10/20/rule-%e2%80%93-based-expert-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>
	</item>
		<item>
		<title>How to list all possible combination using PROLOG!</title>
		<link>http://discretemathisfun.wordpress.com/2009/10/14/how-to-list-all-possible-combination-using-prolog/</link>
		<comments>http://discretemathisfun.wordpress.com/2009/10/14/how-to-list-all-possible-combination-using-prolog/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 13:26:50 +0000</pubDate>
		<dc:creator>integereuler</dc:creator>
				<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://discretemathisfun.wordpress.com/?p=30</guid>
		<description><![CDATA[Although there are other Logic Programming languages, by far the most widely used is Prolog. The name stands for Programming in Logic. In this blog, we’ll give you some tutorial to use ProLog. For now, we’ll give you some tutorial about How to list all possible combination using PROLOG. First, we’ll have to declare statement. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=30&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;line-height:150%;">Although there are other Logic Programming languages, by far the most widely used is Prolog. The name stands for <span style="text-decoration:underline;">Pro</span>gramming in <span style="text-decoration:underline;">Log</span>ic.</p>
<p style="margin-bottom:0;line-height:150%;">In this blog, we’ll give you some tutorial to use ProLog. For now, we’ll give you some tutorial about How to list all possible combination using PROLOG.</p>
<p style="margin-bottom:0;line-height:150%;">First, we’ll have to declare statement. For example we’ll ilustrated if an instuctor teaches student if they are in the same class :</p>
<p style="margin-bottom:0;line-height:150%;">(To input some facts, use <em>Notepad/Wordpad</em> )</p>
<ol>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>dosen</em></span><span style="color:#ff0000;"><em>(mukhlason,matdis).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>dosen</em></span><span style="color:#ff0000;"><em>(feby,alpro).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>dosen</em></span><span style="color:#ff0000;"><em>(holil,sfb).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(adityo,matdis).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(hendra,matdis).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(hendra,alpro).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(hendra,sfb).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(dino,alpro).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(dino,matdis).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(anggoro,alpro).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>kuliah</em></span><span style="color:#ff0000;"><em>(anggoro,sfb).</em></span></p>
</li>
<li>
<p style="margin-bottom:0;line-height:150%;"><span style="color:#ff0000;"><em>mengajar(D</em></span><span style="color:#ff0000;"><em>,M) 	:- dosen(D,K), kuliah(M,K).</em></span></p>
</li>
</ol>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID"><img class="alignnone size-thumbnail wp-image-31" title="1" src="http://discretemathisfun.files.wordpress.com/2009/10/11.jpg?w=150&#038;h=115" alt="1" width="150" height="115" /></p>
<p style="margin-bottom:0;line-height:150%;">Line 1 – 11 are FACTS that show <em>dosen </em><span style="text-decoration:underline;">mukhlason</span> teaches <span style="text-decoration:underline;">matdis</span> class and so on, while student <span style="text-decoration:underline;">adityo</span><em> kuliah </em><span style="text-decoration:underline;">matdis</span> class and so on. While Line 12 is called RULE saying that instructor D teaches student M if instructor D teaches class K and student M takes class K.</p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID">If done, save the file using the with an extension .pl (for example tes.pl)</p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID"><img class="alignnone size-medium wp-image-32" title="2" src="http://discretemathisfun.files.wordpress.com/2009/10/21.jpg?w=300&#038;h=214" alt="2" width="300" height="214" /></p>
<p style="margin-bottom:0;line-height:150%;">Now, load the file. By opening the ProLog program and choose File <span style="font-family:Wingdings;"></span> Consult <span style="font-family:Wingdings;"></span> pick the file you saved earlier.</p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID"><img class="alignnone size-medium wp-image-33" title="3" src="http://discretemathisfun.files.wordpress.com/2009/10/31.jpg?w=300&#038;h=117" alt="3" width="300" height="117" /></p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID"><img class="alignnone size-medium wp-image-35" title="4" src="http://discretemathisfun.files.wordpress.com/2009/10/41.jpg?w=300&#038;h=235" alt="4" width="300" height="235" /></p>
<p style="margin-bottom:0;line-height:150%;page-break-before:always;">Having loaded the program, the user is then faced with the two character symbol <strong>?-</strong> which is called the <span style="text-decoration:underline;">system prompt</span>. Now to list all the possible combination either instructor D teach student M type the dialog :</p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID"><span style="color:#ff0000;"><em>?- mengajar(D,M).</em></span></p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID">And to see all possible combination keep type semicolon ( ; ) until dialouge No is shown.</p>
<p style="margin-bottom:0;line-height:150%;"><img class="alignnone size-medium wp-image-38" title="5" src="http://discretemathisfun.files.wordpress.com/2009/10/52.jpg?w=300&#038;h=282" alt="5" width="300" height="282" /></p>
<p style="margin-bottom:0;line-height:150%;" lang="id-ID">
<p style="margin-bottom:0;line-height:150%;" lang="id-ID">IE</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/discretemathisfun.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/discretemathisfun.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/discretemathisfun.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=discretemathisfun.wordpress.com&amp;blog=9740875&amp;post=30&amp;subd=discretemathisfun&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://discretemathisfun.wordpress.com/2009/10/14/how-to-list-all-possible-combination-using-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72692b19b820d625b43381e3b4221fce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">integereuler</media:title>
		</media:content>

		<media:content url="http://discretemathisfun.files.wordpress.com/2009/10/11.jpg?w=150" medium="image">
			<media:title type="html">1</media:title>
		</media:content>

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

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

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

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