<html>

<head><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- MyFirstUnitAd -->
<ins class="adsbygoogle"
     style="display:inline-block;width:970px;height:250px"
     data-ad-client="ca-pub-5778386704669218"
     data-ad-slot="1503492166"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Population</title>
</head>

<body>



<p align="center"><span lang="en-ca"><font size="6" color="#FF0000"><b>Who Am I?</b></font></span></p>

<div align="left">
  <pre><b><font color="#ff0000" size="5">A.<span lang="en-ca">First</span> Edition</font></b></pre>
</div>
<div align="left">
  <pre><b>This is the <span lang="en-ca"> first </span>edition of <span lang="en-ca">another deduction example. It is really a boring routine to do this kind of </span></b></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>repeating job. But for me, it is a kind of fun.</b></span></pre>
</div>
<div align="left">
  <pre><b><font color="#ff0000" size="5"><span lang="en-ca">B</span>.</font></b><span lang="en-ca"><font size="5" color="#FF0000"><b>Idea of program</b></font></span></pre>
</div>
<div align="left">
  <pre><b>1¡£ Basic idea: </b></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>Same as old silly game: a set of propositions, a set of rules and a set of facts. Then using the analysing</b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>method to verify the truth value of each propositions according to rules.</b></span></pre>
</div>
<div align="left">
  <pre><b>2¡£ Program design: </b></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>I found a need for &quot;Exclusive Or&quot; and try to overload operators for it. But soon give up as it will this </b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>new operator involves a lot of job of my &quot;Logic Library&quot; and I would rather not risk to change it since I</b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>almost forgot all what it is doing after a couple of months. Also a noticeable events is that my Logic class </b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>fail to deduct &quot;Exclusive Or&quot; in form of [&quot;A ==&gt; not B&quot; and &quot;B==&gt; not A&quot;]. Similar form of [&quot;A and B&quot; or &quot;not A </b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>and not B&quot;] is also not working. The only form is [&quot;A or B&quot; and &quot;not (A and B)&quot;]. It is quite interesting and </b></span></pre>
</div>
<div align="left">
  <pre><span lang="en-ca"><b>implies some omission in my class. </b></span></pre>
</div>
<div align="left">
  <blockquote>
    <blockquote>
  <pre><b> </b></pre>
    </blockquote>
  </blockquote>
  <pre><b>4¡£ Further improvement£º</b></pre>
  <pre><span lang="en-ca"><b>To add a function of &quot;Exclusive Or&quot; in LogicLib.lib in near future. And check out why equivalent proposition of</b></span></pre>
  <pre><span lang="en-ca"><b>&quot;Exclusive Or&quot; does not work.</b></span><b>	</b></pre>
  <pre><font color="#FF0000" size="5"><span lang="en-ca"><b>C. What is the problem?</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>x is an animal and following is some facts and rules:</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>1. Any long-nosed mammal is either an ant-eater or elephant.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>2. Elephant is huge.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>3. Ant-eaters are small.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>4. Indian elephants are small-eared.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>5, Nairobi is in Africa.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>6. Any non-Indian elephant is African.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>7. X has a long nose.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>8. x lives in Nairobi.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>9. x is a mammal.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>10. x is huge.</b></span></font></pre>
  <pre><font color="#FF0000"><span lang="en-ca"><b>11. x has large ears.</b></span></font></pre>
  <pre><span lang="en-ca"><font color="#0000FF" size="5"><b>Then Who am I?</b></font></span></pre>
  <pre><span lang="en-ca"><b>There is some underlined proposition that we, human, assume without explicitly mention it. They are </b></span></pre>
  <pre><span lang="en-ca"><font color="#00FF00"><b>1. If it is in Africa, then it cannot be in India. verse visa.</b></font></span></pre>
  <pre><span lang="en-ca"><font color="#00FF00"><b>2. If it is huge, it cannot be small. verse visa.</b></font></span></pre>
  <pre><span lang="en-ca"><font color="#00FF00"><b>3. If it is ant-eater, it cannot be elephant. verse visa.</b></font></span></pre>
  <pre><span lang="en-ca"><font color="#00FF00"><b>4. If it is large-eared, it cannot be small-eared. verse visa.</b></font></span></pre>
  <pre>¡¡</pre>
  <pre><span lang="en-ca"><b>	</b></span></pre>
</div>
<pre>#include &lt;iostream&gt;
#include &quot;LogicLib.h&quot;

using namespace std;


Logic logic[11];
enum Proposition
	{Long_nosed, Mammal, Ant_eater, Elephant, Huge, Small,
	Indian, African, Nairobi, Large_ear, Small_ear};

char* logicName[11] = {&quot;Long_nosed&quot;, &quot;Mammal&quot;, &quot;Ant_Eater&quot;, &quot;Elephant&quot;, &quot;Huge&quot;, &quot;Small&quot;,
	&quot;Indian&quot;, &quot;African&quot;, &quot;Nairobi&quot;, &quot;Large_ear&quot;, &quot;Small_ear&quot;};

Logic&amp; rules1()
{
	return logic[Long_nosed] &gt;&gt;(logic[Ant_eater]||logic[Elephant]);
}

Logic&amp; rules2()
{
	return logic[Elephant]&gt;&gt;logic[Huge];
}

Logic&amp; rules3()
{
	return logic[Ant_eater]&gt;&gt;logic[Small];
}

Logic&amp; rules4()
{
	return (logic[Indian]&amp;&amp;logic[Elephant])&gt;&gt;logic[Small_ear];
}

Logic&amp; rules5()
{
	return logic[Nairobi]&gt;&gt;logic[African];
}

Logic&amp; rules6()
{
	return (!(logic[Indian]&amp;&amp;logic[Elephant]))&gt;&gt;logic[African];
}

Logic&amp; extraRules1()
{
	return (logic[Huge]||logic[Small])&amp;&amp;(!(logic[Huge]&amp;&amp;logic[Small]));
}

Logic&amp; extraRules2()
{
	return (logic[Large_ear]||logic[Small_ear])&amp;&amp;(!(logic[Large_ear]&amp;&amp;logic[Small_ear]));
}

Logic&amp; extraRules3()
{
	return (logic[Ant_eater]||logic[Elephant])&amp;&amp;((!(logic[Ant_eater])&amp;&amp;logic[Elephant]));
}

void initialize()
{
	for (int i=0; i&lt; 11; i++)
	{
		logic[i].setExpress(logicName[i]);
	}
	logic[Long_nosed].setState(Positive);
	logic[Nairobi].setState(Positive);
	logic[Mammal].setState(Positive);
	logic[Huge].setState(Positive);
	logic[Large_ear].setState(Positive);
}

void display()
{
	for (int i =0; i&lt; 11; i++)
	{
		cout&lt;&lt;logic[i].getExpress()&lt;&lt;&quot; is &quot;;
		switch (logic[i].getState())
		{
		case Positive:
			cout&lt;&lt;&quot;True&quot;;
			break;
		case Negative:
			cout&lt;&lt;&quot;False&quot;;
			break;
		default:
			cout&lt;&lt;&quot;Unknown&quot;;
			break;
		}
		cout&lt;&lt;endl;
	}
}

Logic&amp; (*ruleArray[9])() = {rules1, rules2, rules3, rules4, rules5, rules6,
		extraRules1, extraRules2, extraRules3};

int main()
{
	int j=0;
	initialize();
	do 
	{
		for (int i=0; i&lt;9; i++)
		{
			ruleArray[i]().doAnalysing();
		}
		j++;
	}
	while (j==3);
	display();



	return 0;
}

</pre>
<pre>
</pre>
<pre></pre>
<pre></pre>
<pre></pre>

<p>¡¡          


</p>

<p><b><font color="#0000FF"><span lang="en-ca">This is what my program found 
out:</span></font></b></p>

<p>Long_nosed is True<br>
Mammal is True<br>
Ant_Eater is False<br>
Elephant is True<br>
Huge is True<br>
Small is False<br>
Indian is False<br>
African is True<br>
Nairobi is True<br>
Large_ear is True<br>
Small_ear is False</p>
<p><font color="#0000FF"><span lang="en-ca">Or in English it is said:&quot; I am a 
long-nosed mammal and I live in Nairobi in Africa. I am a large-eared elephant. 
Obviously I am not an ant-eater, not small, not small-eared and not in India. 
Can you imagine what I am?&quot; </span></font></p>

<p><span lang="en-ca"> <br>
¡¡</span></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                   
&nbsp;&nbsp;&nbsp; <a href="Monopoly.htm">                  







                       <img src="picture/back.gif" style="border: medium none" alt="back.gif (341 bytes)" width="32" height="35"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<a href="index.htm"><img src="picture/up.gif" style="border: medium none" alt="up.gif (335 bytes)" width="35" height="32"></a>       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                         
<img src="picture/next.gif" style="border: medium none" alt="next.gif (337 bytes)" width="32" height="35">          


</p>

</body>

</html>