1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! This module defines the diagnostic conditions that the [`theorems`](super)
//! feature reports (see [diagnostics](crate::guide::concepts_overview#diagnostics)).
//!
//! The conditions [`MissingProof`] and [`BadRelationRef`] concern the theorems
//! written in a document. The check stage [`CHECK_PROOFS`](super::CHECK_PROOFS)
//! reports the warning [`MissingProof`] for a theorem that has no proof
//! although its kind expects one, and the error [`BadRelationRef`] for a title
//! of a proof that begins with a star but is not a valid back-reference.
//!
//! The two other conditions indicate an error in the code of a feature, and a
//! document cannot cause them. The lowering rules of the nodes of a theorem
//! heading report [`PointerRefused`] for a node that does not refer to the
//! title of a theorem. The check stage reports [`StageFailed`] when it fails to
//! read a table.
//!
//! The references feature reports two other conditions that concern theorems,
//! as it does for any label and reference: a back-reference to a label that is
//! not defined is reported as `flm.refs.unresolved`, and a `\label` on a proof
//! is reported as `flm.refs.label-type-not-accepted`.
use DiagnosticInfo;
/// The warning that is reported when a theorem has no proof although its kind
/// expects one (id `flm.theorems.missing-proof`).
///
/// A theorem kind expects a proof when its
/// [`expects_proof`](super::TheoremKind::expects_proof) setting is `true`. In
/// the default configuration, these kinds are `theorem`, `proposition`,
/// `lemma` and `corollary`. A theorem has a proof when the title of a proof
/// is a back-reference to a label of the theorem, as in
/// `\begin{proof}[*thm:main]` or `\begin{proof}[**thm:main]`. The warning is
/// not reported for a theorem that carries the field `\noproofref`, as in
/// `\begin{theorem}\label{thm:main}\noproofref`.
///
/// Reported by the check stage [`CHECK_PROOFS`](super::CHECK_PROOFS) at the
/// theorem, under every workflow (see [`check`](super::check)). The output of
/// the document is not affected. The warning is not reported when the registry
/// does not contain the references feature, which resolves back-references.
///
/// The message suggests three fixes: writing a proof whose title refers to the
/// theorem, adding `\noproofref` to the theorem, or setting `expects_proof` to
/// `false` for the kind of the theorem.
/// Writes the message of the warning. The first suggested fix depends on
/// whether the theorem has a label and whether a kind for proofs exists, so
/// the message has four forms.
/// 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`).
///
/// A back-reference consists of one or two stars followed by a label, as in
/// `\begin{proof}[*lem:x]` or `\begin{proof}[**lem:x]`. Back-references are
/// read in the titles of the theorem kinds whose class has
/// [`relation_ref`](super::TheoremClass::relation_ref) set. In the default
/// configuration, `proof` is the only such kind.
///
/// Reported by the check stage [`CHECK_PROOFS`](super::CHECK_PROOFS) at the
/// title, under every workflow. The title is written to the output as it is
/// typed, and the proof does not refer to any theorem.
/// 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`).
///
/// The lowering rule of a theorem writes the heading of the theorem from a
/// template (see [`heading`](super::heading)). In this heading, the title is
/// represented by a synthesized node of the element
/// [`TITLE_POINTER`](super::TITLE_POINTER), or of the element
/// [`RELATION`](super::RELATION) for a back-reference that a proof shows in
/// its heading. This node contains a content pointer
/// ([`ContentPointer`](crate::stdlib::backends::lowering::ContentPointer)),
/// through which the lowering rule of the node reads the title. The content
/// pointer must refer to the title argument of a theorem.
///
/// A document cannot cause this error: it is caused by the faulty code that
/// created the node. Reported by the lowering rules
/// [`TitlePointerRule`](super::TitlePointerRule) and
/// [`RelationRule`](super::RelationRule). The node expands to nothing.
/// Error raised when the check stage of the theorems feature fails to read a
/// table (id `flm.theorems.stage-failed`).
///
/// The check stage [`CHECK_PROOFS`](super::CHECK_PROOFS) reads the element
/// index and, when the registry contains the references feature, the table of
/// resolved references. A table read fails only when the code of a feature is
/// faulty: when a stage reads a table that it did not declare as a read, or
/// when the value type of the table differs from the declared one (see
/// [`AccessError`](crate::core::data::store::AccessError)). A document cannot
/// cause this error.
///
/// Reported with no position in the source. The check stage then stops, and
/// reports no other condition for the document.