1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 00:24:22 +03:00
inform7/docs/assertions-module/P-wtmd.html

234 lines
16 KiB
HTML
Raw Normal View History

2020-08-26 00:27:06 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>What This Module Does</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-08-26 12:52:50 +03:00
<script src="http://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script src="../docs-assets/Bigfoot.js"></script>
<link href="../docs-assets/Bigfoot.css" rel="stylesheet" rev="stylesheet" type="text/css">
2021-02-05 02:15:21 +02:00
<script>
MathJax = {
tex: {
inlineMath: '$', '$'], ['\\(', '\\)'
},
svg: {
fontCache: 'global'
}
};
</script>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>
2020-08-26 00:27:06 +03:00
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body class="commentary-font">
<nav role="navigation">
<h1><a href="../index.html">
<img src="../docs-assets/Inform.png" height=72">
</a></h1>
<ul><li><a href="../compiler.html">compiler tools</a></li>
<li><a href="../other.html">other tools</a></li>
<li><a href="../extensions.html">extensions and kits</a></li>
<li><a href="../units.html">unit test tools</a></li>
</ul><h2>Compiler Webs</h2><ul>
<li><a href="../inbuild/index.html">inbuild</a></li>
<li><a href="../inform7/index.html">inform7</a></li>
<li><a href="../inter/index.html">inter</a></li>
</ul><h2>Inbuild Modules</h2><ul>
<li><a href="../supervisor-module/index.html">supervisor</a></li>
</ul><h2>Inform7 Modules</h2><ul>
<li><a href="../core-module/index.html">core</a></li>
<li><a href="index.html"><span class="selectedlink">assertions</span></a></li>
<li><a href="../values-module/index.html">values</a></li>
<li><a href="../knowledge-module/index.html">knowledge</a></li>
<li><a href="../imperative-module/index.html">imperative</a></li>
<li><a href="../runtime-module/index.html">runtime</a></li>
<li><a href="../if-module/index.html">if</a></li>
<li><a href="../multimedia-module/index.html">multimedia</a></li>
<li><a href="../index-module/index.html">index</a></li>
</ul><h2>Inter Modules</h2><ul>
<li><a href="../bytecode-module/index.html">bytecode</a></li>
<li><a href="../building-module/index.html">building</a></li>
<li><a href="../codegen-module/index.html">codegen</a></li>
</ul><h2>Services</h2><ul>
<li><a href="../arch-module/index.html">arch</a></li>
<li><a href="../calculus-module/index.html">calculus</a></li>
<li><a href="../html-module/index.html">html</a></li>
<li><a href="../inflections-module/index.html">inflections</a></li>
<li><a href="../kinds-module/index.html">kinds</a></li>
<li><a href="../linguistics-module/index.html">linguistics</a></li>
<li><a href="../problems-module/index.html">problems</a></li>
<li><a href="../syntax-module/index.html">syntax</a></li>
<li><a href="../words-module/index.html">words</a></li>
<li><a href="../../../inweb/docs/foundation-module/index.html">foundation</a></li>
</ul>
</nav>
<main role="main">
<!--Weave of 'What This Module Does' generated by Inweb-->
<div class="breadcrumbs">
2021-02-05 02:15:21 +02:00
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../compiler.html">Inform7</a></li><li><a href="index.html">assertions</a></li><li><a href="index.html#P">Preliminaries</a></li><li><b>What This Module Does</b></li></ul></div>
2020-08-26 00:27:06 +03:00
<p class="purpose">An overview of the assertions module's role and abilities.</p>
2021-02-05 02:15:21 +02:00
<ul class="toc"><li><a href="P-wtmd.html#SP1">&#167;1. Prerequisites</a></li><li><a href="P-wtmd.html#SP2">&#167;2. Assertions</a></li><li><a href="P-wtmd.html#SP4">&#167;4. Special meanings</a></li><li><a href="P-wtmd.html#SP5">&#167;5. Regular meanings</a></li><li><a href="P-wtmd.html#SP6">&#167;6. Making use of the calculus module</a></li></ul><hr class="tocbar">
2020-08-26 00:27:06 +03:00
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Prerequisites. </b>The assertions module is a part of the Inform compiler toolset. It is
presented as a literate program or "web". Before diving in:
</p>
<ul class="items"><li>(a) It helps to have some experience of reading webs: see <a href="../../../inweb/docs/index.html" class="internal">inweb</a> for more.
</li><li>(b) The module is written in C, in fact ANSI C99, but this is disguised by the
fact that it uses some extension syntaxes provided by the <a href="../../../inweb/docs/index.html" class="internal">inweb</a> literate
programming tool, making it a dialect of C called InC. See <a href="../../../inweb/docs/index.html" class="internal">inweb</a> for
full details, but essentially: it's C without predeclarations or header files,
and where functions have names like <span class="extract"><span class="extract-syntax">Tags::add_by_name</span></span> rather than just <span class="extract"><span class="extract-syntax">add_by_name</span></span>.
</li><li>(c) This module uses other modules drawn from the <a href="../compiler.html" class="internal">compiler</a>, and also
uses a module of utility functions called <a href="../../../inweb/docs/foundation-module/index.html" class="internal">foundation</a>.
For more, see <a href="../../../inweb/docs/foundation-module/P-abgtf.html" class="internal">A Brief Guide to Foundation (in foundation)</a>.
</li></ul>
2021-02-05 02:15:21 +02:00
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Assertions. </b>This module's task is to read the declarative sentences in the source text,
such as "Mrs Jones is wearing a trilby hat" or "Brightness is a kind of value",
which assert that something is true. These are converted into propositions
in predicate calculus, which are sent in a stream to the <a href="../knowledge-module/index.html" class="internal">knowledge</a> module.
Those propositions may be mutually inconsistent, or not even be self-consistent
or meaningful: but that is for <a href="../knowledge-module/index.html" class="internal">knowledge</a> to worry about. Our task is just
to provide a list of supposedly true statements.
</p>
<p class="commentary">Between the <a href="../linguistics-module/index.html" class="internal">linguistics</a> and <a href="../calculus-module/index.html" class="internal">calculus</a> modules we have extensive
equipment for parsing regular sentences already, so it would seem simple
to act on a sentence like "Mr Herries knows Howarth." And so it would be if
people called "Mr Herries" and "Howarth" were already known to exist.
Unfortunately, this may be the first mention of them, and that makes things
much more complicated.
</p>
<p class="commentary">Even if they do exist, they may be referred to ambiguously. If there are
two different people both called Kassava, who is meant by "Carter knows
Kassava"? This depends on context: see <a href="4-nr.html" class="internal">Name Resolution</a>.
</p>
<p class="commentary">Though it is rather under-developed at present, Inform also has minimal
support for "anaphora", that is, for cross-references between sentences using
pronouns such as "it". See <a href="2-ar.html" class="internal">Anaphoric References</a>, but don't expect much.
</p>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>So, then, top-level declarations are dealt with like so:
2020-08-26 12:52:50 +03:00
</p>
2020-08-27 01:12:58 +03:00
<ul class="items"><li>&#9679; The tree is subdivided into <a href="../runtime-module/2-cu.html" class="internal">Compilation Units (in runtime)</a>. The project's own
2020-08-26 12:52:50 +03:00
source text is one unit, as is each extension used.
</li><li>&#9679; A minimal set of kinds, such as "number", verbs, such as "to mean", relations,
such as "meaning", and so on, is created. See in particular <a href="2-bv.html" class="internal">Booting Verbs (in assertions)</a>.
</li><li>&#9679; Three passes are made through the "major nodes" of the parse tree, meaning,
assertion sentences and top-level declarations of structures such as tables,
equations and rules. See <a href="2-ptmn.html" class="internal">Passes through Major Nodes</a>.
<ul class="items"><li>(0) During the "pre-pass" names of tables and other top-level structures are
recorded, and sentences are classified by <a href="2-cs.html#SP3" class="internal">Classifying::sentence</a>. This is
done by asking the <a href="../linguistics-module/index.html" class="internal">linguistics</a> module to diagram them and determine whether
the meaning is "regular" &mdash; a typical sentence asserting some relationship,
such as "the ball is on the table" &mdash; or "special" &mdash; a sentence with some
other purpose, such as "Test ... with ...", often but not always written in
the imperative.
</li><li>(1) During "pass 1", noun phrases in these assertion sentences are understood,
which may involve creating new instances or other values. For example, the
sentence "The fedora hat is on the can of Ubuntu cola" may cause new instances
"fedora hat" and "can of Ubuntu cola" to be created. This process is called
"refinement": see <a href="4-rpt.html" class="internal">Refine Parse Tree</a>, which calls <a href="4-tc.html" class="internal">The Creator</a> to bring
things into being.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> The function <a href="4-ass.html#SP6" class="internal">Assertions::make_coupling</a> is then
called to draw out information from this pairing of values.
</li><li>(2) During "pass 2", <a href="4-ass.html#SP6" class="internal">Assertions::make_coupling</a> is again called, and this
time is able to draw out relationships between values: for example, that the
hat is indeed spatially on top of the can.
</li></ul>
</li></ul>
<pre class="undisplayed-code all-displayed-code code-font">
<span class="plain-syntax">Classification:</span>
<span class="plain-syntax">SENTENCE_NT'jane is a woman' {classified}</span>
2020-08-26 12:52:50 +03:00
<span class="plain-syntax"> VERB_NT'is' {verb 'be' 3p s act IS_TENSE +ve}</span>
<span class="plain-syntax"> UNPARSED_NOUN_NT'jane'</span>
<span class="plain-syntax"> UNPARSED_NOUN_NT'woman' {indefinite 'a' n/m/f nom/acc s}</span>
<span class="plain-syntax">Refined:</span>
<span class="plain-syntax"> CREATED_NT'jane' {refined}</span>
<span class="plain-syntax"> COMMON_NOUN_NT'woman' {indefinite 'a' n/m/f nom/acc s} {refined} {refers: infs'woman'} {creation: &lt;&lt; woman(x) &gt;&gt;} {eval: TEST_VALUE_NT}</span>
2020-08-26 12:52:50 +03:00
<span class="plain-syntax">After creation:</span>
<span class="plain-syntax">SENTENCE_NT'jane is a woman' {classified}</span>
2020-08-26 12:52:50 +03:00
<span class="plain-syntax"> VERB_NT'is' {verb 'be' 3p s act IS_TENSE +ve}</span>
<span class="plain-syntax"> PROPER_NOUN_NT'jane' {refined} {refers: infs'jane'} {eval: CONSTANT_NT'jane' {kind: object} {instance: 'jane'} {enumeration: 0}} {created here}</span>
<span class="plain-syntax"> COMMON_NOUN_NT'woman' {indefinite 'a' n/m/f nom/acc s} {refined} {refers: infs'woman'} {creation: &lt;&lt; woman(x) &gt;&gt;} {eval: TEST_VALUE_NT}</span>
2020-08-26 12:52:50 +03:00
</pre>
<ul class="footnotetexts"><li class="footnote" id="fn:1"><p class="inwebfootnote"><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> There really is an Ubuntu cola; it's a fair-trade product which it amuses my
more Linux-aware students to drink.
<a href="#fnref:1" title="return to text"> &#x21A9;</a></p></li></ul>
2021-02-05 02:15:21 +02:00
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Special meanings. </b>In the same way that programming languages have a few "reserved words" which
cue up built-in language features, even though they may look like user-defined
functions or variables, Inform has a few verbs with "special meanings", which
make requests directly to the compiler. These occupy <a href="3-dlr.html" class="internal">Chapter 3: Requests</a>, which is
really just a catalogue of ways to ask for things.
</p>
<p class="commentary">All that we do is parse such sentences and then make a call to some
appropriate function, usually in one of the other modules. For example, the
section <a href="3-nar.html" class="internal">New Activity Requests</a> dismantles sentences like "Counting is an
2021-02-06 20:00:34 +02:00
activity on numbers", but calls the <a href="../knowledge-module/index.html" class="internal">knowledge</a> module to do the actual
making of the new activity.
2021-02-05 02:15:21 +02:00
</p>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Regular meanings. </b>As noted above, <a href="4-ass.html#SP6" class="internal">Assertions::make_coupling</a> is called on each regular
assertion: coupling being a lingistic term for placing subject and object into
a relationship with each other. What it does is to split into cases according to
the subject and object phrases of a sentence. These can take 12 different forms,
so there are \(12\times 12 = 144\) possible combinations of subject with object,
and a \(12\times 12\) matrix is used to determine which of 42 cases the sentence
falls into.
</p>
<p class="commentary">Each case then leads either to a proposition being formed, or to
a problem message being issued. Most of the easier cases are dealt with in
the (admittedly quite long) <a href="index.html" class="internal">assertions</a> section, but harder ones are
delegated to the remaining sections in <a href="4-nr.html" class="internal">Chapter 4: Assertions</a>.
</p>
<p class="commentary">The brief story above implied that each sentence is turned into a single
proposition, as if this part of Inform can act as a sort of pipeline: text
in, proposition out. But it is not quite so simple, and for the hardest
sentences we must store notes on what to add later. For example, in
<a href="4-ass2.html" class="internal">Assemblies</a>, a sentence like "In every container is a coin" cannot
take immediate effect. It clearly creates a whole lot of coin instances,
but we don't yet know what is a container and what is not. That will
depend on conclusions to be drawn by the <a href="../knowledge-module/index.html" class="internal">knowledge</a> module later on.
Similarly, though a little easier, <a href="4-imp.html" class="internal">Implications</a> like "Something worn is
usually wearable" do not immediately lead to propositions being drawn up.
</p>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Making use of the calculus module. </b><a href="5-kpr.html" class="internal">Chapter 5: Predicates</a> simply stocks up our predicate calculus system with some
basic unary and binary predicates, and provides a few shorthand functions
to make commonly-needed propositions (see <a href="5-cu.html" class="internal">Calculus Utilities</a>).
</p>
<p class="commentary">More specialised predicates will also be added by other modules, so the
roster here is not complete, but these are the essentials.
</p>
2020-08-26 00:27:06 +03:00
<nav role="progress"><div class="progresscontainer">
2021-02-05 02:15:21 +02:00
<ul class="progressbar"><li class="progressprevoff">&#10094;</li><li class="progresscurrentchapter">P</li><li class="progresscurrent">wtmd</li><li class="progresschapter"><a href="1-am.html">1</a></li><li class="progresschapter"><a href="2-bv.html">2</a></li><li class="progresschapter"><a href="3-dlr.html">3</a></li><li class="progresschapter"><a href="4-nr.html">4</a></li><li class="progresschapter"><a href="5-kpr.html">5</a></li><li class="progressnext"><a href="1-am.html">&#10095;</a></li></ul></div>
2020-08-26 00:27:06 +03:00
</nav><!--End of weave-->
</main>
</body>
</html>