2 <!-- =========== Terms, declarations and definitions ============ -->
4 <chapter id="sec_terms">
6 <para>To describe syntax in this manual we use the following conventions:</para>
8 <listitem>Non terminal symbols are emphasized and have a link to their definition. E.g.: &term;</listitem>
9 <listitem>Terminal symbols are in bold. E.g.: <emphasis role="bold">theorem</emphasis></listitem>
10 <listitem>Optional sequences of elements are put in square brackets.
11 E.g.: [<emphasis role="bold">in</emphasis> &term;]</listitem>
12 <listitem>Alternatives are put in square brakets and they are separated
13 by vertical bars. E.g.: [<emphasis role="bold"><</emphasis>|<emphasis role="bold">></emphasis>]</listitem>
14 <listitem>Repetition of sequences of elements are given by putting the
15 first sequence in square brackets, that are followed by three dots.
16 E.g.: [<emphasis role="bold">and</emphasis> &term;]…</listitem>
18 <sect1 id="terms_and_co">
19 <title>Terms & co.</title>
21 <title>Lexical conventions</title>
27 <entry id="id">&id;</entry>
29 <entry><emphasis>〈〈&TODO;〉〉</emphasis></entry>
39 <entry id="nat">&nat;</entry>
41 <entry><emphasis>〈〈&TODO;〉〉</emphasis></entry>
51 <entry id="uri">&uri;</entry>
53 <entry><emphasis>〈〈&TODO;〉〉</emphasis></entry>
66 <entry id="term">&term;</entry>
68 <entry>&sterm;</entry>
69 <entry>simple or delimited term</entry>
74 <entry>&term; &term;</entry>
75 <entry>application</entry>
80 <entry><emphasis role="bold">λ</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
81 <entry>λ-abstraction</entry>
86 <entry><emphasis role="bold">Π</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
87 <entry>dependent product meant to define a datatype</entry>
92 <entry><emphasis role="bold">∀</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
93 <entry>dependent product meant to define a proposition</entry>
98 <entry>&term; <emphasis role="bold">→</emphasis> &term;</entry>
99 <entry>non-dependent product (logical implication or function space)</entry>
104 <entry><emphasis role="bold">let</emphasis> [&id;|(&id;<emphasis role="bold">:</emphasis> &term;)] <emphasis role="bold">≝</emphasis> &term; <emphasis role="bold">in</emphasis> &term;</entry>
105 <entry>local definition</entry>
110 <entry><emphasis role="bold">let</emphasis>
111 [<emphasis role="bold">co</emphasis>]<emphasis role="bold">rec</emphasis>
112 &id; [&id;|<emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&term;]… <emphasis role="bold">:</emphasis>&term;<emphasis role="bold">)</emphasis>]… [<emphasis role="bold">on</emphasis> &nat;]
113 [<emphasis role="bold">:</emphasis> &term;]
114 <emphasis role="bold">≝</emphasis> &term;
116 <entry>(co)recursive definitions</entry>
122 [<emphasis role="bold">and</emphasis>
123 [&id;|<emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&term;]… <emphasis role="bold">:</emphasis>&term;<emphasis role="bold">)</emphasis>]… [<emphasis role="bold">on</emphasis> &nat;]
124 [<emphasis role="bold">:</emphasis> &term;]
125 <emphasis role="bold">≝</emphasis> &term;]…
133 <emphasis role="bold">in</emphasis> &term;
141 <entry>user provided notation</entry>
152 <entry id="sterm">&sterm;</entry>
154 <entry><emphasis role="bold">(</emphasis>&term;<emphasis role="bold">)</emphasis></entry>
160 <entry>&id;[<emphasis role="bold">\subst[</emphasis>
161 &id;<emphasis role="bold">≔</emphasis>&term;
162 [<emphasis role="bold">;</emphasis>&id;<emphasis role="bold">≔</emphasis>&term;]…
163 <emphasis role="bold">]</emphasis>]
165 <entry>identifier with optional explicit named substitution</entry>
171 <entry>a qualified reference</entry>
176 <entry><emphasis role="bold">Prop</emphasis></entry>
177 <entry>the impredicative sort of propositions</entry>
182 <entry><emphasis role="bold">Set</emphasis></entry>
183 <entry>the impredicate sort of datatypes</entry>
188 <entry><emphasis role="bold">Type</emphasis></entry>
189 <entry>one predicative sort of datatypes</entry>
194 <entry><emphasis role="bold">?</emphasis></entry>
195 <entry>implicit argument</entry>
200 <entry><emphasis role="bold">?n</emphasis>
201 [<emphasis role="bold">[</emphasis>
202 [<emphasis role="bold">_</emphasis>|&term;]…
203 <emphasis role="bold">]</emphasis>]</entry>
204 <entry>metavariable</entry>
209 <entry><emphasis role="bold">match</emphasis> &term;
210 [ <emphasis role="bold">in</emphasis> &term; ]
211 [ <emphasis role="bold">return</emphasis> &term; ]
212 <emphasis role="bold">with</emphasis>
214 <entry>case analysis</entry>
220 <emphasis role="bold">[</emphasis>
221 &match_pattern; <emphasis role="bold"> ⇒ </emphasis> &term;
223 <emphasis role="bold">|</emphasis>
224 &match_pattern; <emphasis role="bold"> ⇒ </emphasis> &term;
225 ]…<emphasis role="bold">]</emphasis> </entry>
231 <entry><emphasis role="bold">(</emphasis>&term;<emphasis role="bold">:</emphasis>&term;<emphasis role="bold">)</emphasis></entry>
238 <entry>user provided notation at precedence 90</entry>
249 <entry id="args">&args;</entry>
252 <emphasis role="bold">_</emphasis>[<emphasis role="bold">:</emphasis> &term;]
254 <entry>ignored argument</entry>
260 <emphasis role="bold">(</emphasis><emphasis role="bold">_</emphasis>[<emphasis role="bold">:</emphasis> &term;]<emphasis role="bold">)</emphasis>
262 <entry>ignored argument</entry>
267 <entry>&id;[<emphasis role="bold">,</emphasis>&id;]…[<emphasis role="bold">:</emphasis> &term;]</entry>
273 <entry><emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&id;]…[<emphasis role="bold">:</emphasis> &term;]<emphasis role="bold">)</emphasis></entry>
285 <entry id="args2">&args2;</entry>
293 <entry><emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&id;]…<emphasis role="bold">:</emphasis> &term;<emphasis role="bold">)</emphasis></entry>
305 <entry id="match_pattern">&match_pattern;</entry>
308 <entry>0-ary constructor</entry>
313 <entry><emphasis role="bold">(</emphasis>&id; &id; [&id;]…<emphasis role="bold">)</emphasis></entry>
314 <entry>n-ary constructor (binds the n arguments)</entry>
323 <sect1 id="axiom_definition_declaration">
324 <title>Definitions and declarations</title>
326 <title><emphasis role="bold">axiom</emphasis> &id;<emphasis role="bold">:</emphasis> &term;</title>
327 <titleabbrev>axiom</titleabbrev>
328 <para><userinput>axiom H: P</userinput></para>
329 <para><command>H</command> is declared as an axiom that states <command>P</command></para>
331 <sect2 id="definition">
332 <title><emphasis role="bold">definition</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
333 <titleabbrev>definition</titleabbrev>
334 <para><userinput>definition f: T ≝ t</userinput></para>
335 <para><command>f</command> is defined as <command>t</command>;
336 <command>T</command> is its type. An error is raised if the type of
337 <command>t</command> is not convertible to <command>T</command>.</para>
338 <para><command>T</command> is inferred from <command>t</command> if
340 <para><command>t</command> can be omitted only if <command>T</command> is
341 given. In this case Matita enters in interactive mode and
342 <command>f</command> must be defined by means of tactics.</para>
343 <para>Notice that the command is equivalent to <command>theorem f: T ≝ t</command>.</para>
345 <sect2 id="inductive">
346 <title>[<emphasis role="bold">inductive</emphasis>|<emphasis role="bold">coinductive</emphasis>] &id; [&args2;]… <emphasis role="bold">:</emphasis> &term; <emphasis role="bold">≝</emphasis> [<emphasis role="bold">|</emphasis>] [&id;<emphasis role="bold">:</emphasis>&term;] [<emphasis role="bold">|</emphasis> &id;<emphasis role="bold">:</emphasis>&term;]…
347 [<emphasis role="bold">with</emphasis> &id; <emphasis role="bold">:</emphasis> &term; <emphasis role="bold">≝</emphasis> [<emphasis role="bold">|</emphasis>] [&id;<emphasis role="bold">:</emphasis>&term;] [<emphasis role="bold">|</emphasis> &id;<emphasis role="bold">:</emphasis>&term;]…]
349 <titleabbrev>(co)inductive types declaration</titleabbrev>
350 <para><userinput>inductive i x y z: S ≝ k1:T1 | … | kn:Tn with i' : S' ≝ k1':T1' | … | km':Tm'</userinput></para>
351 <para>Declares a family of two mutually inductive types
352 <command>i</command> and <command>i'</command> whose types are
353 <command>S</command> and <command>S'</command>, which must be convertible
355 <para>The constructors <command>ki</command> of type <command>Ti</command>
356 and <command>ki'</command> of type <command>Ti'</command> are also
357 simultaneously declared. The declared types <command>i</command> and
358 <command>i'</command> may occur in the types of the constructors, but
359 only in strongly positive positions according to the rules of the
361 <para>The whole family is parameterized over the arguments <command>x,y,z</command>.</para>
362 <para>If the keyword <command>coinductive</command> is used, the declared
363 types are considered mutually coinductive.</para>
364 <para>Elimination principles for the record are automatically generated
365 by Matita, if allowed by the typing rules of the calculus according to
366 the sort <command>S</command>. If generated,
367 they are named <command>i_ind</command>, <command>i_rec</command> and
368 <command>i_rect</command> according to the sort of their induction
372 <title><emphasis role="bold">record</emphasis> &id; [&args2;]… <emphasis role="bold">:</emphasis> &term; <emphasis role="bold">≝</emphasis><emphasis role="bold">{</emphasis>[&id; [<emphasis role="bold">:</emphasis>|<emphasis role="bold">:></emphasis>] &term;] [<emphasis role="bold">;</emphasis>&id; [<emphasis role="bold">:</emphasis>|<emphasis role="bold">:></emphasis>] &term;]…<emphasis role="bold">}</emphasis></title>
373 <titleabbrev>record</titleabbrev>
374 <para><userinput>record id x y z: S ≝ { f1: T1; …; fn:Tn }</userinput></para>
375 <para>Declares a new record family <command>id</command> parameterized over
376 <command>x,y,z</command>.</para>
377 <para><command>S</command> is the type of the record
378 and it must be convertible to a sort.</para>
379 <para>Each field <command>fi</command> is declared by giving its type
380 <command>Ti</command>. A record without any field is admitted.</para>
381 <para>Elimination principles for the record are automatically generated
382 by Matita, if allowed by the typing rules of the calculus according to
383 the sort <command>S</command>. If generated,
384 they are named <command>i_ind</command>, <command>i_rec</command> and
385 <command>i_rect</command> according to the sort of their induction
387 <para>For each field <command>fi</command> a record projection
388 <command>fi</command> is also automatically generated if projection
389 is allowed by the typing rules of the calculus according to the
390 sort <command>S</command>, the type <command>T1</command> and
391 the definability of depending record projections.</para>
392 <para>If the type of a field is declared with <command>:></command>,
393 the corresponding record projection becomes an implicit coercion.
394 This is just syntactic sugar and it has the same effect of declaring the
395 record projection as a coercion later on.</para>
400 <title>Proofs</title>
402 <title><emphasis role="bold">theorem</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
403 <titleabbrev>theorem</titleabbrev>
404 <para><userinput>theorem f: P ≝ p</userinput></para>
405 <para>Proves a new theorem <command>f</command> whose thesis is
406 <command>P</command>.</para>
407 <para>If <command>p</command> is provided, it must be a proof term for
408 <command>P</command>. Otherwise an interactive proof is started.</para>
409 <para><command>P</command> can be omitted only if the proof is not
411 <para>Proving a theorem already proved in the library is an error.
412 To provide an alternative name and proof for the same theorem, use
413 <command>variant f: P ≝ p</command>.</para>
414 <para>A warning is raised if the name of the theorem cannot be obtained
415 by mangling the name of the constants in its thesis.</para>
416 <para>Notice that the command is equivalent to <command>definition f: T ≝ t</command>.</para>
419 <title><emphasis role="bold">variant</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
420 <titleabbrev>variant</titleabbrev>
421 <para><userinput>variant f: T ≝ t</userinput></para>
422 <para>Same as <command>theorem f: T ≝ t</command>, but it does not
423 complain if the theorem has already been proved. To be used to give
424 an alternative name or proof to a theorem.</para>
427 <title><emphasis role="bold">lemma</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
428 <titleabbrev>lemma</titleabbrev>
429 <para><userinput>lemma f: T ≝ t</userinput></para>
430 <para>Same as <command>theorem f: T ≝ t</command></para>
433 <title><emphasis role="bold">fact</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
434 <titleabbrev>fact</titleabbrev>
435 <para><userinput>fact f: T ≝ t</userinput></para>
436 <para>Same as <command>theorem f: T ≝ t</command></para>
439 <title><emphasis role="bold">remark</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
440 <titleabbrev>remark</titleabbrev>
441 <para><userinput>remark f: T ≝ t</userinput></para>
442 <para>Same as <command>theorem f: T ≝ t</command></para>