<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. </b>Implications are structures are used to store the information in sentences
like "Something worn is usually wearable and initially carried." The
"something worn" part must turn out to be a description of a category of
objects; the "usually" part translates into a level of certainty. We regard
these as implications in the sense of IF condition A, THEN condition B, but
note that A is quite restricted in what it can be: it must be a simple-to-test
description only, whereas B could be any subtree of an assertion.
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">pcalc_prop</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">if_spec</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> which objects are affected</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">parse_node</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">then_pn</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> what assertion is implied about them</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">int</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">implied_likelihood</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> with what certainty level</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="reserved-syntax">implication</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">next_implication</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> in list of implications</span>
<ulclass="endnotetexts"><li>The structure implication is private to this section.</li></ul>
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. </b>We also need a little piece of storage attached to each property name:
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">int</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">possessed</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> temporary use when checking implications about objects</span>
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. </b>Implications are gathered during the main parse tree traverses, but all we do
<spanclass="reserved-syntax">void</span><spanclass="plain-syntax"></span><spanclass="function-syntax">Assertions::Implications::new</span><buttonclass="popup"onclick="togglePopup('usagePopup1')"><spanclass="comment-syntax">?</span><spanclass="popuptext"id="usagePopup1">Usage of <spanclass="code-font"><spanclass="function-syntax">Assertions::Implications::new</span></span>:<br/>Assertions - <ahref="4-ass.html#SP6_3_2">§6.3.2</a>, <ahref="4-ass.html#SP6_3_22">§6.3.22</a></span></button><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">parse_node</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">px</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">parse_node</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">py</span><spanclass="plain-syntax">) {</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">if</span><spanclass="plain-syntax"> (</span><spanclass="identifier-syntax">prevailing_mood</span><spanclass="plain-syntax"> == </span><spanclass="identifier-syntax">CERTAIN_CE</span><spanclass="plain-syntax">) </span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP3_1"class="named-paragraph-link"><spanclass="named-paragraph">Reject implications given with certainty</span><spanclass="named-paragraph-number">3.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP3_2"class="named-paragraph-link"><spanclass="named-paragraph">Actually create a single implication</span><spanclass="named-paragraph-number">3.2</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax">}</span>
</pre>
<pclass="commentary firstcommentary"><aid="SP3_1"class="paragraph-anchor"></a><b>§3.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Reject implications given with certainty</span><spanclass="named-paragraph-number">3.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"that's an implication which is too certain for me"</span><spanclass="plain-syntax">,</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"since a sentence like this talks about a generality of things in terms of "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"one either/or property implying another, and I can only handle those as "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"likelihoods. You should probably add 'usually' somewhere: e.g., 'An open "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"door is usually openable'. (But implications can have unpredictable "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"consequences: best to avoid them altogether where possible.)"</span><spanclass="plain-syntax">);</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2"class="paragraph-anchor"></a><b>§3.2. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Actually create a single implication</span><spanclass="named-paragraph-number">3.2</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP3_2_1"class="named-paragraph-link"><spanclass="named-paragraph">Find the premiss kind and specification</span><spanclass="named-paragraph-number">3.2.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP3_2_2"class="named-paragraph-link"><spanclass="named-paragraph">Check that the premiss involves only either/or properties and/or a kind</span><spanclass="named-paragraph-number">3.2.2</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP3_2_3"class="named-paragraph-link"><spanclass="named-paragraph">Check that the conclusion involves only a single either/or property</span><spanclass="named-paragraph-number">3.2.3</span></a></span><spanclass="plain-syntax">;</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_1"class="paragraph-anchor"></a><b>§3.2.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Find the premiss kind and specification</span><spanclass="named-paragraph-number">3.2.1</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP3_2">§3.2</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_2"class="paragraph-anchor"></a><b>§3.2.2. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Check that the premiss involves only either/or properties and/or a kind</span><spanclass="named-paragraph-number">3.2.2</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"that's an implication where the condition to qualify is not "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"one that I can determine in advance of the start of play"</span><spanclass="plain-syntax">,</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"since it involves more than simple either/or properties "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"plus a kind. (For example, adjectives like 'adjacent' or "</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"'visible' here are too difficult to determine.)"</span><spanclass="plain-syntax">);</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP3_2">§3.2</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_3"class="paragraph-anchor"></a><b>§3.2.3. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Check that the conclusion involves only a single either/or property</span><spanclass="named-paragraph-number">3.2.3</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"which is the only form of implication I can handle."</span><spanclass="plain-syntax">);</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP3_2">§3.2</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. Implication checking. </b>The checking of implications happens all at once, during model completion,
so that all inferences arising directly from the source text have already
been drawn.
</p>
<pclass="commentary">For instance, if there is an inference asserting that object X is worn, and
there is an implication that what is worn is usually also wearable, then we
must generate an inference that X is wearable: in effect, this is a deduction
from a syllogism. We should however not generate such an inference if we
already have definite knowledge that X is not wearable. We do this for each
object X individually.
</p>
<pclass="commentary">We begin by checking implications associated with X and applying to X,
but in fact because <spanclass="extract"><spanclass="extract-syntax">Assertions::Implications::check_implications_of</span></span> recurses depth-first through
the kinds, a typical object X — a container, say — will first have
implications associated with "thing" applied to it, then with
those associated with "container", and only then its own implications.
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP4_1"class="named-paragraph-link"><spanclass="named-paragraph">Erase all of the possession markers</span><spanclass="named-paragraph-number">4.1</span></a></span><spanclass="plain-syntax">;</span>
<pclass="commentary firstcommentary"><aid="SP4_1"class="paragraph-anchor"></a><b>§4.1. </b>We are going to need to examine which either/or properties are held by X.
We don't want to store all of the properties of everything in memory at once,
so we keep just a single set of "possession markers", one for each property.
Here we erase these markers ready for use with X.
</p>
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Erase all of the possession markers</span><spanclass="named-paragraph-number">4.1</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP4">§4</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP5"class="paragraph-anchor"></a><b>§5. </b>This is the recursive routine which sets the possession markers for X on the
<spanclass="reserved-syntax">void</span><spanclass="plain-syntax"></span><spanclass="function-syntax">Assertions::Implications::set_possessed_flags</span><buttonclass="popup"onclick="togglePopup('usagePopup2')"><spanclass="comment-syntax">?</span><spanclass="popuptext"id="usagePopup2">Usage of <spanclass="code-font"><spanclass="function-syntax">Assertions::Implications::set_possessed_flags</span></span>:<br/><ahref="4-imp.html#SP4">§4</a></span></button><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">inference_subject</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">infs</span><spanclass="plain-syntax">) {</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP5_1"class="named-paragraph-link"><spanclass="named-paragraph">See what we can get out of this inference</span><spanclass="named-paragraph-number">5.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"> }</span>
<spanclass="plain-syntax">}</span>
</pre>
<pclass="commentary firstcommentary"><aid="SP5_1"class="paragraph-anchor"></a><b>§5.1. </b>Note that where there are antonyms such as open/closed, we have to mark
both of them, because an inference of being closed is as good as an inference
of not being open, and vice versa.
</p>
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">See what we can get out of this inference</span><spanclass="named-paragraph-number">5.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP5_1_1"class="named-paragraph-link"><spanclass="named-paragraph">Mark this property if its possession is not already equally certainly known</span><spanclass="named-paragraph-number">5.1.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP5_1_1"class="named-paragraph-link"><spanclass="named-paragraph">Mark this property if its possession is not already equally certainly known</span><spanclass="named-paragraph-number">5.1.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"> }</span>
</pre>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP5">§5</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP5_1_1"class="paragraph-anchor"></a><b>§5.1.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Mark this property if its possession is not already equally certainly known</span><spanclass="named-paragraph-number">5.1.1</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP5_1">§5.1</a> (twice).</li></ul>
<pclass="commentary firstcommentary"><aid="SP6"class="paragraph-anchor"></a><b>§6. </b>Lastly, then, the routine actually checking and applying implications.
Our aim is to find and act upon the first implication which makes a difference,
and return <spanclass="extract"><spanclass="extract-syntax">TRUE</span></span>; but if no implication can be acted on, to return <spanclass="extract"><spanclass="extract-syntax">FALSE</span></span>.
</p>
<pclass="commentary">This cannot act twice on the same candidate with the same implication, since
the act results in creating inferences about the property. An attempt at
repetition results in redundancy, since the inferences it would make have
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">IMPLICATIONS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"Considering implications about $j as they apply to $j:\n"</span><spanclass="plain-syntax">,</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP6_1"class="named-paragraph-link"><spanclass="named-paragraph">Consider this individual implication as it applies to the candidate</span><spanclass="named-paragraph-number">6.1</span></a></span><spanclass="plain-syntax">;</span>
<pclass="commentary firstcommentary"><aid="SP6_1"class="paragraph-anchor"></a><b>§6.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Consider this individual implication as it applies to the candidate</span><spanclass="named-paragraph-number">6.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP6_1_1"class="named-paragraph-link"><spanclass="named-paragraph">Check that the conclusion is not impossible</span><spanclass="named-paragraph-number">6.1.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP6_1_2"class="named-paragraph-link"><spanclass="named-paragraph">Check that the conclusion is not redundant or irrelevant</span><spanclass="named-paragraph-number">6.1.2</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">IMPLICATIONS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"PASS: changing property $Y of $j\n"</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">conclusion_prop</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">candidate</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-imp.html#SP6_1_3"class="named-paragraph-link"><spanclass="named-paragraph">Apply the conclusion to the candidate</span><spanclass="named-paragraph-number">6.1.3</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">IMPLICATIONS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"FAIL: take no action\n"</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"> }</span>
</pre>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP6">§6</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP6_1_1"class="paragraph-anchor"></a><b>§6.1.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Check that the conclusion is not impossible</span><spanclass="named-paragraph-number">6.1.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">IMPLICATIONS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"IMPOSSIBLE: property not provided\n"</span><spanclass="plain-syntax">);</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP6_1">§6.1</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP6_1_2"class="paragraph-anchor"></a><b>§6.1.2. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Check that the conclusion is not redundant or irrelevant</span><spanclass="named-paragraph-number">6.1.2</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">IMPLICATIONS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"Possession marker has (certainty %d; possessed state %d)\n"</span><spanclass="plain-syntax">,</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-imp.html#SP6_1">§6.1</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP6_1_3"class="paragraph-anchor"></a><b>§6.1.3. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Apply the conclusion to the candidate</span><spanclass="named-paragraph-number">6.1.3</span></span><spanclass="comment-syntax"> =</span>