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><para>Non terminal symbols are emphasized and have a link to their
9 definition. E.g.: &term;</para></listitem>
10 <listitem><para>Terminal symbols are in bold. E.g.:
11 <emphasis role="bold">theorem</emphasis></para></listitem>
12 <listitem><para>Optional sequences of elements are put in square brackets.
13 E.g.: [<emphasis role="bold">in</emphasis> &term;]</para></listitem>
14 <listitem><para>Alternatives are put in square brakets and they are
15 separated by vertical bars. E.g.: [<emphasis role="bold"><</emphasis>|<emphasis role="bold">></emphasis>]</para></listitem>
16 <listitem><para>Repetitions of a sequence of elements are given by putting the
17 sequence in square brackets, that are followed by three dots. The empty
18 sequence is a valid repetition.
19 E.g.: [<emphasis role="bold">and</emphasis> &term;]…</para></listitem>
20 <listitem><para>Characters belonging to a set of characters are given
21 by listing the set elements in square brackets. Hyphens are used to
22 specify ranges of characters in the set.
23 E.g.: [<emphasis role="bold">a</emphasis>-<emphasis role="bold">zA</emphasis>-<emphasis role="bold">Z0</emphasis>-<emphasis role="bold">9_-</emphasis>]</para></listitem>
25 <sect1 id="terms_and_co">
26 <title>Terms & co.</title>
28 <title>Lexical conventions</title>
29 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
34 <entry id="grammar.id">&id;</entry>
36 <entry><emphasis>〈〈any sequence of letters, underscores or valid <ulink type="http" url="http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Digit">XML digits</ulink> prefixed by a latin letter ([a-zA-Z]) and post-fixed by a possible empty sequence of decorators ([?'`])〉〉</emphasis></entry>
41 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
46 <entry id="grammar.nat">&nat;</entry>
48 <entry><emphasis>〈〈any sequence of valid <ulink type="http" url="http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Digit">XML digits</ulink>〉〉</emphasis></entry>
53 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
58 <entry id="grammar.char">&char;</entry>
60 <entry>[<emphasis role="bold">a</emphasis>-<emphasis role="bold">zA</emphasis>-<emphasis role="bold">Z0</emphasis>-<emphasis role="bold">9_-</emphasis>]</entry>
65 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
66 <title>uri-step</title>
70 <entry id="grammar.uri-step">&uri-step;</entry>
72 <entry>&char;[&char;]…</entry>
77 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
82 <entry id="grammar.uri">&uri;</entry>
84 <entry>[<emphasis role="bold">cic:/</emphasis>|<emphasis role="bold">theory:/</emphasis>]&uri-step;[<emphasis role="bold">/</emphasis>&uri-step;]…<emphasis role="bold">.</emphasis>&id;[<emphasis role="bold">.</emphasis>&id;]…[<emphasis role="bold">#xpointer(</emphasis>&nat;<emphasis role="bold">/</emphasis>&nat;[<emphasis role="bold">/</emphasis>&nat;]…<emphasis role="bold">)</emphasis>]</entry>
93 <!-- ZACK: Sample EBNF snippet, see:
94 http://www.docbook.org/tdg/en/html/productionset.html -->
98 <production id="grammar.term">
101 <lineannotation></lineannotation>
107 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
112 <entry id="grammar.term">&term;</entry>
114 <entry>&sterm;</entry>
115 <entry>simple or delimited term</entry>
120 <entry>&term; &term;</entry>
121 <entry>application</entry>
126 <entry><emphasis role="bold">λ</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
127 <entry>λ-abstraction</entry>
132 <entry><emphasis role="bold">Π</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
133 <entry>dependent product meant to define a datatype</entry>
138 <entry><emphasis role="bold">∀</emphasis>&args;<emphasis role="bold">.</emphasis>&term;</entry>
139 <entry>dependent product meant to define a proposition</entry>
144 <entry>&term; <emphasis role="bold">→</emphasis> &term;</entry>
145 <entry>non-dependent product (logical implication or function space)</entry>
150 <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>
151 <entry>local definition</entry>
157 <emphasis role="bold">let</emphasis>
158 [<emphasis role="bold">co</emphasis>]<emphasis role="bold">rec</emphasis>
161 <entry>(co)recursive definitions</entry>
167 [<emphasis role="bold">and</emphasis> &rec_def;]…
175 <emphasis role="bold">in</emphasis> &term;
183 <entry>user provided notation</entry>
186 <entry id="grammar.rec_def">&rec_def;</entry>
189 &id; [&id;|<emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&term;]… <emphasis role="bold">:</emphasis>&term;<emphasis role="bold">)</emphasis>]…
196 [<emphasis role="bold">on</emphasis> &nat;]
197 [<emphasis role="bold">:</emphasis> &term;]
198 <emphasis role="bold">≝</emphasis> &term;]
205 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
206 <title>Simple terms</title>
210 <entry id="grammar.sterm">&sterm;</entry>
212 <entry><emphasis role="bold">(</emphasis>&term;<emphasis role="bold">)</emphasis></entry>
218 <entry>&id;[<emphasis role="bold">\subst[</emphasis>
219 &id;<emphasis role="bold">≔</emphasis>&term;
220 [<emphasis role="bold">;</emphasis>&id;<emphasis role="bold">≔</emphasis>&term;]…
221 <emphasis role="bold">]</emphasis>]
223 <entry>identifier with optional explicit named substitution</entry>
229 <entry>a qualified reference</entry>
234 <entry><emphasis role="bold">Prop</emphasis></entry>
235 <entry>the impredicative sort of propositions</entry>
240 <entry><emphasis role="bold">Set</emphasis></entry>
241 <entry>the impredicate sort of datatypes</entry>
246 <entry><emphasis role="bold">Type</emphasis></entry>
247 <entry>one predicative sort of datatypes</entry>
252 <entry><emphasis role="bold">?</emphasis></entry>
253 <entry>implicit argument</entry>
258 <entry><emphasis role="bold">?n</emphasis>
259 [<emphasis role="bold">[</emphasis>
260 [<emphasis role="bold">_</emphasis>|&term;]…
261 <emphasis role="bold">]</emphasis>]</entry>
262 <entry>metavariable</entry>
267 <entry><emphasis role="bold">match</emphasis> &term;
268 [ <emphasis role="bold">in</emphasis> &term; ]
269 [ <emphasis role="bold">return</emphasis> &term; ]
270 <emphasis role="bold">with</emphasis>
272 <entry>case analysis</entry>
278 <emphasis role="bold">[</emphasis>
279 &match_branch;[<emphasis role="bold">|</emphasis>&match_branch;]…
280 <emphasis role="bold">]</emphasis>
287 <entry><emphasis role="bold">(</emphasis>&term;<emphasis role="bold">:</emphasis>&term;<emphasis role="bold">)</emphasis></entry>
294 <entry>user provided notation at precedence 90</entry>
300 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
301 <title>Arguments</title>
305 <entry id="grammar.args">&args;</entry>
308 <emphasis role="bold">_</emphasis>[<emphasis role="bold">:</emphasis> &term;]
310 <entry>ignored argument</entry>
316 <emphasis role="bold">(</emphasis><emphasis role="bold">_</emphasis>[<emphasis role="bold">:</emphasis> &term;]<emphasis role="bold">)</emphasis>
318 <entry>ignored argument</entry>
323 <entry>&id;[<emphasis role="bold">,</emphasis>&id;]…[<emphasis role="bold">:</emphasis> &term;]</entry>
329 <entry><emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&id;]…[<emphasis role="bold">:</emphasis> &term;]<emphasis role="bold">)</emphasis></entry>
333 <entry id="grammar.args2">&args2;</entry>
341 <entry><emphasis role="bold">(</emphasis>&id;[<emphasis role="bold">,</emphasis>&id;]…<emphasis role="bold">:</emphasis> &term;<emphasis role="bold">)</emphasis></entry>
348 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
349 <title>Pattern matching</title>
353 <entry id="grammar.match_branch">&match_branch;</entry>
355 <entry>&match_pattern; <emphasis role="bold">⇒</emphasis> &term;</entry>
358 <entry id="grammar.match_pattern">&match_pattern;</entry>
361 <entry>0-ary constructor</entry>
366 <entry><emphasis role="bold">(</emphasis>&id; &id; [&id;]…<emphasis role="bold">)</emphasis></entry>
367 <entry>n-ary constructor (binds the n arguments)</entry>
377 <sect1 id="axiom_definition_declaration">
378 <title>Definitions and declarations</title>
380 <title><emphasis role="bold">axiom</emphasis> &id;<emphasis role="bold">:</emphasis> &term;</title>
381 <titleabbrev>axiom</titleabbrev>
382 <para><userinput>axiom H: P</userinput></para>
383 <para><command>H</command> is declared as an axiom that states <command>P</command></para>
385 <sect2 id="definition">
386 <title><emphasis role="bold">definition</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
387 <titleabbrev>definition</titleabbrev>
388 <para><userinput>definition f: T ≝ t</userinput></para>
389 <para><command>f</command> is defined as <command>t</command>;
390 <command>T</command> is its type. An error is raised if the type of
391 <command>t</command> is not convertible to <command>T</command>.</para>
392 <para><command>T</command> is inferred from <command>t</command> if
394 <para><command>t</command> can be omitted only if <command>T</command> is
395 given. In this case Matita enters in interactive mode and
396 <command>f</command> must be defined by means of tactics.</para>
397 <para>Notice that the command is equivalent to <command>theorem f: T ≝ t</command>.</para>
399 <sect2 id="inductive">
400 <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;]…
401 [<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;]…]…
403 <titleabbrev>(co)inductive types declaration</titleabbrev>
404 <para><userinput>inductive i x y z: S ≝ k1:T1 | … | kn:Tn with i' : S' ≝ k1':T1' | … | km':Tm'</userinput></para>
405 <para>Declares a family of two mutually inductive types
406 <command>i</command> and <command>i'</command> whose types are
407 <command>S</command> and <command>S'</command>, which must be convertible
409 <para>The constructors <command>ki</command> of type <command>Ti</command>
410 and <command>ki'</command> of type <command>Ti'</command> are also
411 simultaneously declared. The declared types <command>i</command> and
412 <command>i'</command> may occur in the types of the constructors, but
413 only in strongly positive positions according to the rules of the
415 <para>The whole family is parameterized over the arguments <command>x,y,z</command>.</para>
416 <para>If the keyword <command>coinductive</command> is used, the declared
417 types are considered mutually coinductive.</para>
418 <para>Elimination principles for the record are automatically generated
419 by Matita, if allowed by the typing rules of the calculus according to
420 the sort <command>S</command>. If generated,
421 they are named <command>i_ind</command>, <command>i_rec</command> and
422 <command>i_rect</command> according to the sort of their induction
426 <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>
427 <titleabbrev>record</titleabbrev>
428 <para><userinput>record id x y z: S ≝ { f1: T1; …; fn:Tn }</userinput></para>
429 <para>Declares a new record family <command>id</command> parameterized over
430 <command>x,y,z</command>.</para>
431 <para><command>S</command> is the type of the record
432 and it must be convertible to a sort.</para>
433 <para>Each field <command>fi</command> is declared by giving its type
434 <command>Ti</command>. A record without any field is admitted.</para>
435 <para>Elimination principles for the record are automatically generated
436 by Matita, if allowed by the typing rules of the calculus according to
437 the sort <command>S</command>. If generated,
438 they are named <command>i_ind</command>, <command>i_rec</command> and
439 <command>i_rect</command> according to the sort of their induction
441 <para>For each field <command>fi</command> a record projection
442 <command>fi</command> is also automatically generated if projection
443 is allowed by the typing rules of the calculus according to the
444 sort <command>S</command>, the type <command>T1</command> and
445 the definability of depending record projections.</para>
446 <para>If the type of a field is declared with <command>:></command>,
447 the corresponding record projection becomes an implicit coercion.
448 This is just syntactic sugar and it has the same effect of declaring the
449 record projection as a coercion later on.</para>
454 <title>Proofs</title>
456 <title><emphasis role="bold">theorem</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
457 <titleabbrev>theorem</titleabbrev>
458 <para><userinput>theorem f: P ≝ p</userinput></para>
459 <para>Proves a new theorem <command>f</command> whose thesis is
460 <command>P</command>.</para>
461 <para>If <command>p</command> is provided, it must be a proof term for
462 <command>P</command>. Otherwise an interactive proof is started.</para>
463 <para><command>P</command> can be omitted only if the proof is not
465 <para>Proving a theorem already proved in the library is an error.
466 To provide an alternative name and proof for the same theorem, use
467 <command>variant f: P ≝ p</command>.</para>
468 <para>A warning is raised if the name of the theorem cannot be obtained
469 by mangling the name of the constants in its thesis.</para>
470 <para>Notice that the command is equivalent to <command>definition f: T ≝ t</command>.</para>
473 <title><emphasis role="bold">variant</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
474 <titleabbrev>variant</titleabbrev>
475 <para><userinput>variant f: T ≝ t</userinput></para>
476 <para>Same as <command>theorem f: T ≝ t</command>, but it does not
477 complain if the theorem has already been proved. To be used to give
478 an alternative name or proof to a theorem.</para>
481 <title><emphasis role="bold">lemma</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
482 <titleabbrev>lemma</titleabbrev>
483 <para><userinput>lemma f: T ≝ t</userinput></para>
484 <para>Same as <command>theorem f: T ≝ t</command></para>
487 <title><emphasis role="bold">fact</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
488 <titleabbrev>fact</titleabbrev>
489 <para><userinput>fact f: T ≝ t</userinput></para>
490 <para>Same as <command>theorem f: T ≝ t</command></para>
493 <title><emphasis role="bold">remark</emphasis> &id;[<emphasis role="bold">:</emphasis> &term;] [<emphasis role="bold">≝</emphasis> &term;]</title>
494 <titleabbrev>remark</titleabbrev>
495 <para><userinput>remark f: T ≝ t</userinput></para>
496 <para>Same as <command>theorem f: T ≝ t</command></para>
500 <sect1 id="tacticargs">
501 <title>Tactic arguments</title>
502 <para>This section documents the syntax of some recurring arguments for
505 <sect2 id="introsspec">
506 <title>intros-spec</title>
507 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
508 <title>intros-spec</title>
512 <entry id="grammar.intros-spec">&intros-spec;</entry>
514 <entry>[&nat;] [<emphasis role="bold">(</emphasis>[&id;]…<emphasis role="bold">)</emphasis>]</entry>
519 <para>The natural number is the number of new hypotheses to be introduced. The list of identifiers gives the name for the first hypotheses.</para>
523 <title>pattern</title>
524 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
525 <title>pattern</title>
529 <entry id="grammar.pattern">&pattern;</entry>
531 <entry>&TODO;</entry>
539 <sect2 id="reduction-kind">
540 <title>reduction-kind</title>
541 <para>Reduction kinds are normalization functions that transform a term
542 to a convertible but simpler one. Each reduction kind can be used both
543 as a tactic argument and as a stand-alone tactic.</para>
544 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
545 <title>reduction-kind</title>
549 <entry id="grammar.reduction-kind">&reduction-kind;</entry>
551 <entry><emphasis role="bold">demodulate</emphasis></entry>
556 <entry><emphasis role="bold">normalize</emphasis></entry>
557 <entry>Computes the βδιζ-normal form</entry>
562 <entry><emphasis role="bold">reduce</emphasis></entry>
563 <entry>Computes the βδιζ-normal form</entry>
568 <entry><emphasis role="bold">simplify</emphasis></entry>
569 <entry>Computes a form supposed to be simpler</entry>
574 <entry><emphasis role="bold">unfold</emphasis> [&sterm;]</entry>
575 <entry>δ-reduces the constant or variable if specified, or that
576 in head position</entry>
581 <entry><emphasis role="bold">whd</emphasis></entry>
582 <entry>Computes the βδιζ-weak-head normal form</entry>