Expand description
The theorems feature: the theorem-like environments of mathematical
writing. These are numbered, titled block environments such as theorem,
lemma and definition, and the proof environment, whose title can refer
back to the statement it proves. Every environment is declared from the
feature’s configuration (TheoremsConfig), so a host can add environments
of its own (an exercise) or remove shipped ones.
§What an author writes
\begin{lemma}[Key lemma]\label{lem:key}
Every bounded monotone sequence converges.
\end{lemma}
\begin{proof}[*lem:key]
By completeness.
\end{proof}prints, on the text backend,
Lemma 1 (Key lemma). Every bounded monotone sequence converges.
Proof (Lemma 1). By completeness. □Each environment is one theorem kind (lemma above). It takes an
optional title in brackets, then two fields in any order, \label{…}
(repeatable) and \noproofref (which says that no proof of the statement
is coming), and a body laid out as blocks (elements). A proof’s title
written [*lem:key] is a back-reference: it refers to the statement
labeled lem:key and shows that statement’s word and number in the proof’s
heading; [**lem:key] refers to the same statement and shows nothing in
the heading. The
language guide describes these environments for authors under
Theorems.
§Theorem kinds and theorem classes
Every theorem kind belongs to one theorem class (TheoremClass),
which holds what a family of kinds shares: whether its kinds are numbered
and in which counter, the heading template, the closing mark, and whether a
title beginning with * is read as a back-reference. A kind
(TheoremKind) adds its words (Lemma, Lemmas, and variants such as
the abbreviation Lem.) and whether each of its statements expects a
proof. The default configuration (TheoremsConfig::new) declares:
theorem,proposition,lemma,corollaryandconjecturein the classtheoremlike, anddefinitionandremarkin the classdefinitionlike, all numbered in one shared counter;proofin the classprooflike: unnumbered, closed by the mark□, its title read as a back-reference.
The feature’s code refers to no kind and no class by name: a host’s
exercise is an environment in its own right, declared in the
configuration. The configuration is fixed when the registry is built
(see settings, options and
configuration).
§Numbers, labels and back-references
Every theorem is one reference point of
the reference kind theorem (see reference points, labels and
anchors).
A theorem of a numbered kind is numbered by the
numbering feature in its class’s
counter and shown in a
counter style of
its kind, whose words are the kind’s (numbers): \ref{lem:key} reads
Lemma~1; in a document that numbers theorems within sections it reads
Lemma~2.3 on every output except the recomposed LaTeX, where LaTeX
numbers the theorems (see the
limitation). Its anchor is the
environment’s name and its number, lemma-1. A theorem of an unnumbered
kind accepts no label and has no anchor.
A back-reference is a reference site,
which the references feature resolves as
it resolves \ref. title_reading is the function that decides whether
a title is a back-reference. On a class that reads back-references, a title
that begins with a star is kept as typed: its reader places it under an
opaque wrapper, so that its label meets the label of a \label as written,
and [*lem:a--b] refers to \label{lem:a--b}. Every other title is content
(see a starred title is kept as
typed).
§The check of proofs
A statement of a kind that expects a proof
(by default theorem, proposition, lemma and corollary) should have
a proof whose back-reference refers to it, unless it carries \noproofref.
The feature’s check stage (check) reports a statement that has neither
as the Warning flm.theorems.missing-proof, and a title that begins with a
star but is not a well-formed back-reference as the Error
flm.theorems.bad-relation-ref. The stage is a member of the
flm.validated collection, which every
standard workflow demands, so it runs, with the same reports, under the
check workflow and under every render. It reads the document tree: a
theorem inside a user definition that the plan keeps unexpanded is not
checked (see check).
§What the feature provides to the pipeline
- Elements.
THEOREM(flm.theorems.theorem), with one element value per configured kind, available in text mode. Three synthesized elements,NAME_ELEMENT,TITLE_POINTERandRELATION, hold the parts of a theorem’s heading (heading); no document can write them. - The general lowering rules, each the default on every backend:
THEOREM_RULEand the rules of the three heading elements,NAME_RULE,TITLE_POINTER_RULEandRELATION_RULE. A theorem becomes aflm.pres.blockof roleflm.theorems.theoremwhose kind tokens are the class’s name and the kind’s (theoremlike lemma), with its heading as a run-in decoration at the head of its first paragraph and, for a class with a closing mark, the mark as a final decoration at the end of its last paragraph (rules; see decorations and roles and kinds). The heading is the class’s heading template, with the kind’s word and number in a span of roleflm.theorems.nameand the title in a span of roleflm.theorems.title; the title is lowered where the heading shows it, never copied (heading). The text and html backends write a stop after the heading (their render optionrun_in_stop, a period by default; seeTextRenderOptions::run_in_stopandHtmlRenderOptions::run_in_stop) unless the heading already ends in punctuation; the text backend writes a non-breaking space before the closing mark. At every theorem the general rule requires the feature’s style identifierflm.theorems.style(html::STYLE). - On the
htmlbackend, the stylesheetflm.theorems.style(html), which the requirement brings into a page holding a theorem and which sets the kind’s word and number apart from the title. - On the
latex-renderedbackend, the definition pieceflm.latex.def.flmx.theorems(latex_rendered), which the same requirement brings into the style file and which registers the look of each class of theorem. - On the
latex-recomposedbackend, rules of their own (latex): a theorem is written back as the environment the author wrote, and the style file declares each kind the document uses. A proof’s back-reference is written in one of two forms, which the backend’s render optionresolved_proof_refschooses: as the author wrote it, for thephfthmLaTeX package to read (the default), or resolved into the proof’s title, over theamsthmpackage alone. The rendering guide describes this output under Theorems in the recomposed LaTeX. - Counters and counter styles (
numbers), contributed to the numbering feature’s service slots. - A check stage,
CHECK_PROOFS(flm.theorems.check-proofs), providing the capability of the same name, a member of theflm.validatedcollection (check). - A configuration,
TheoremsConfig, whose fields are the feature’s settings keys. A build hook (LateInit) compiles the heading templates, the closing marks and the kinds’ words once the language is built; a text that does not compile fails the registry build.
§Interactions with other features
- The numbering feature. Without it, no theorem is numbered: a heading
shows the kind’s word alone (
Theorem), and a theorem’s anchor comes from its first label. - The references feature. It resolves labels and back-references and computes anchors. Without it, no label resolves, a theorem has no anchor, a back-reference shows its label’s text, and the check reports no missing proof.
- The feature reads the tables of these two features optionally, and
declares them through peer declarations
(
PeerName); it declares the same way the argument role that the references feature gives the argument of a theorem’s\labelfield (DEFINED_LABEL_ARG_ROLE). It therefore builds and renders in a registry that holds neither. The rules of thelatex-recomposedbackend are registered under peer declarations of their backend and of the LaTeX family’s elements; in a registry without them, those rules are set aside (excluded from rule selection; seePeerName). - User definitions. A theorem written in a user definition’s template is
checked and numbered where the template is expanded in the tree. The
title’s reader sees a star written in the template (
[*#1]), and keeps that title as typed. It does not see a star that arrives through a placeholder (a template[#1]used as\pf{*lem:a--b}): that title is laid out as content, and a label holding--, quotes, an apostrophe or...does not resolve through it. A theorem in the template of a kept definition (a user definition whose use sites the plan leaves in the tree; see kept definitions) whose title holds a placeholder where a back-reference’s star could be is expanded at each use site instead (TitleReading::Unknown).
§Map of the items
- The feature:
Theorems,feature,FEATURE. - The configuration:
TheoremsConfig,TheoremClass,TheoremKindand their constants (DEFAULT_HEADING,DEFAULT_CLOSING_MARK,DEFAULT_LABEL_TYPES,LOWERCASE_VARIANT,CAPITAL_VARIANT,ABBREVIATED_VARIANT). - The element and its reading:
elements(THEOREM,TheoremElement,title_reading,TitleReading,has_noproofref,theorem_args). - The heading:
heading. The general rule of a theorem:rules. - The counters and counter styles:
numbers. - The check of proofs:
check(CHECK_PROOFS). - The conditions:
MissingProof,BadRelationRef,PointerRefused,StageFailed. - The stylesheet:
html. Thelatex-recomposedbackend’s own rules:latex.
Re-exports§
pub use check::CHECK_PROOFS;pub use elements::NOPROOFREF_FIELD;pub use elements::POINT_KIND;pub use elements::THEOREM;pub use elements::TITLE_ARG;pub use elements::TheoremElement;pub use elements::TitleReading;pub use elements::has_noproofref;pub use elements::theorem_args;pub use elements::title_reading;pub use heading::NAME_ELEMENT;pub use heading::NAME_PLACEHOLDER;pub use heading::NAME_ROLE;pub use heading::NAME_RULE;pub use heading::NameRule;pub use heading::RELATION;pub use heading::RELATION_RULE;pub use heading::RelationRule;pub use heading::TITLE_PLACEHOLDER;pub use heading::TITLE_POINTER;pub use heading::TITLE_POINTER_RULE;pub use heading::TITLE_ROLE;pub use heading::TitlePointerRule;pub use rules::THEOREM_RULE;pub use rules::TheoremRule;
Modules§
- check
- This module defines the check stage
CHECK_PROOFS(flm.theorems.check-proofs) of thetheoremsfeature. The stage checks that each theorem whose kind expects a proof has a proof, and that the back-references in the titles of proofs are valid. In this module, a theorem is an environment of any theorem kind, such aslemmaorproof. - elements
- The element of the
theoremsfeature,THEOREM(flm.theorems.theorem), with one element value per configured theorem kind: its arguments and fields, the reference point every theorem declares, and the back-reference a proof’s title declares (title_reading). - heading
- The heading and the closing mark of a theorem: the compilation of every class’s heading template, every class’s closing mark and every kind’s word when the registry is built; the instantiation of a heading at a theorem; and the three synthesized elements that an instantiated heading holds, with their general lowering rules.
- html
- The stylesheet of the
theoremsfeature on thehtmlbackend,flm.theorems.style(stylesheet), and the markup it selects on. - latex
- The lowering rules of the
theoremsfeature for thelatex-recomposedbackend, and the definition pieces they require. The rendering guide describes this output for users under Theorems in the recomposed LaTeX. - latex_
rendered - The definition piece of the
theoremsfeature on thelatex-renderedbackend,flm.latex.def.flmx.theorems(piece). - numbers
- The numbers of theorems: the counters and the counter styles that the
theoremsfeature declares. A counter is a dotted name under which things are counted in document order, and a counter style says how a counter value is shown. - rules
- The general lowering rule of a theorem,
TheoremRule(THEOREM_RULE), the default on every backend that has no rule of its own for theorems: a block that opens with the theorem’s heading and, for a class with a closing mark, closes with the mark.
Structs§
- BadRelation
Ref - The error that is reported when the title of a proof begins with a star but
is not a valid back-reference (id
flm.theorems.bad-relation-ref). - Missing
Proof - The warning that is reported when a theorem has no proof although its kind
expects one (id
flm.theorems.missing-proof). - Pointer
Refused - Error representing a node of a theorem heading whose content pointer does
not refer to the title of a theorem (id
flm.theorems.pointer-refused). - Stage
Failed - Error raised when the check stage of the theorems feature fails to read a
table (id
flm.theorems.stage-failed). - Theorem
Class - One theorem class: what a family of theorem kinds shares. A class
says whether its kinds are numbered and in which counter, how their
heading is written, whether a closing mark ends them, and whether a title
beginning with
*is read as a back-reference to the statement a theorem proves. - Theorem
Kind - One theorem kind: one environment an author writes, such as
theorem,lemma,proofor a host’sexercise. Its key inTheoremsConfig::kindsis the environment’s name. - Theorems
- The
theoremsfeature (FlmFeature): it registers one element value ofTHEOREMper kind of itsTheoremsConfig, each written as the environment of the kind’s name, together with the heading elements, the lowering rules, the check stage, and the counters and counter styles of the numbered kinds (contributed to the numbering feature). See the module documentation. - Theorems
Config - The configuration of the
Theoremsfeature: the theorem classes and the theorem kinds, the number format of every kind, and the label types every numbered kind accepts.
Constants§
- ABBREVIATED_
VARIANT - The name of the variant of a theorem kind’s words written abbreviated,
abbreviated:\ref[abbreviated]{lem:x}readsLem.~4where the kind declares that variant. The references feature defines the name. - CAPITAL_
VARIANT - The name of the variant of a theorem kind’s words written with a capital
initial,
capital: the variant that\ref[S]{…}and\ref[capital]{…}ask for. The references feature defines the name. - DEFAULT_
CLOSING_ MARK - The closing mark of the shipped theorem class
prooflike,□(TheoremClass::closing_mark). - DEFAULT_
HEADING - The heading template of every shipped theorem class,
#{name}\IfValueT{#{title}}{ (#{title})}: the kind’s word and number, then the title between parentheses where the theorem has one, as inLemma 4 (Key lemma), orLemma 4alone (TheoremClass::headingdescribes the placeholders). - DEFAULT_
LABEL_ TYPES - The label types a numbered theorem kind accepts by default
(
TheoremsConfig::label_types):thm,prop,cor,lem,rem,def,dfn,xandtopic. Every numbered kind accepts every one of them:\label{lem:x}on atheoremis accepted. - FEATURE
- The feature’s registered name,
theorems. - LOWERCASE_
VARIANT - The name of the variant of a theorem kind’s words written all in
lowercase,
lowercase:\ref[lowercase]{lem:x}readslemma~4. The references feature defines the name.
Functions§
- feature
- The
Theoremsfeature under the default configuration (the eight kinds ofTheoremsConfig::new), ready to be listed in a package entry (PackageEntry).