@@ -10,18 +10,16 @@ synopsis: >-
10
10
11
11
description : |-
12
12
This library provides `ring`, `field`, `lra`, `nra`, and `psatz` tactics for
13
- algebraic structures of the Mathematical Components library. The `ring` tactic
14
- works with any `comRingType` (commutative ring) or `comSemiRingType`
15
- (commutative semiring). The `field` tactic works with any `fieldType` (field).
16
- The other (Micromega) tactics work with any `realDomainType` (totally ordered
17
- integral domain) or `realFieldType` (totally ordered field). Algebra Tactics
18
- do not provide a way to declare instances, like the `Add Ring` and `Add Field`
19
- commands, but use canonical structure inference instead. Therefore, each of
20
- these tactics works with any canonical (or abstract) instance of the
21
- respective structure declared through Hierarchy Builder. Another key feature
22
- of Algebra Tactics is that they automatically push down ring morphisms and
23
- additive functions to leaves of ring/field expressions before applying the
24
- proof procedures.
13
+ the Mathematical Components library. These tactics use the algebraic
14
+ structures defined in the MathComp library and their canonical instances for
15
+ the instance resolution, and do not require any special instance declaration,
16
+ like the `add Ring` and `Add Field` commands. Therefore, each of these tactics
17
+ works with any instance of the respective structure, including concrete
18
+ instances declared through Hierarchy Builder, abstract instances, and mixed
19
+ concrete and abstract instances, e.g., `int * R` where `R` is an abstract
20
+ commutative ring. Another key feature of Algebra Tactics is that they
21
+ automatically push down ring morphisms and additive functions to leaves of
22
+ ring/field expressions before applying the proof procedures.
25
23
26
24
publications :
27
25
- pub_url : https://drops.dagstuhl.de/opus/volltexte/2022/16738/
@@ -87,10 +85,139 @@ dependencies:
87
85
namespace : mathcomp.algebra_tactics
88
86
89
87
documentation : |-
90
- ## Caveat
91
88
92
- The `lra`, `nra`, and `psatz` tactics are considered experimental features and
93
- subject to change.
89
+ ## Documentation
90
+
91
+ **Caveat: the `lra`, `nra`, and `psatz` tactics are considered experimental
92
+ features and subject to change.**
93
+
94
+ This Coq library provides an adaptation of the
95
+ [`ring`, `field`](https://coq.inria.fr/refman/addendum/ring),
96
+ [`lra`, `nra`, and `psatz`](https://coq.inria.fr/refman/addendum/micromega)
97
+ tactics to the MathComp library.
98
+ See the Coq reference manual for the basic functionalities of these tactics.
99
+ The descriptions of these tactics below mainly focus on the differences
100
+ between ones provided by Coq and ones provided by this library, including the
101
+ additional features introduced by this library.
102
+
103
+ ### The `ring` tactic
104
+
105
+ The `ring` tactic solves a goal of the form `p = q :> R` representing a
106
+ polynomial equation. The type `R` must have a canonical `comRingType`
107
+ (commutative ring) or at least `comSemiRingType` (commutative semiring)
108
+ instance.
109
+ The `ring` tactic solves the equation by normalizing each side as a
110
+ polynomial, whose coefficients are either integers `Z` (if `R` is a
111
+ `comRingType`) or natural numbers `N`.
112
+
113
+ The `ring` tactic can decide the given polynomial equation modulo given
114
+ monomial equations. The syntax to use this feature is `ring: t_1 .. t_n` where
115
+ each `t_i` is a proof of equality `m_i = p_i`, `m_i` is a monomial, and `p_i`
116
+ is a polynomial.
117
+ Although the `ring` tactic supports ring homomorphisms (explained below), all
118
+ the monomials and polynomials `m_1, .., m_n, p_1, .., p_n, p, q` must have the
119
+ same type `R` for the moment.
120
+
121
+ Each tactic provided by this library has a preprocessor and supports
122
+ applications of (semi)ring homomorphisms and additive functions (N-module or
123
+ Z-module homomorphisms).
124
+ For example, suppose `f : S -> T` and `g : R -> S` are ring homomorphisms. The
125
+ preprocessor turns a ring sub-expression of the form `f (x + g (y * z))` into
126
+ `f x + f (g y) * f (g z)`.
127
+ A composition of homomorphisms from the initial objects `nat`, `N`, `int`, and
128
+ `Z` is automatically normalized to the canonical one. For example, if `R` in
129
+ the above example is `int`, the result of the preprocessing should be
130
+ `f x + y%:~R * z%:~R` where `f \o g : int -> T` is replaced with `intr`
131
+ (`_%:~R`).
132
+ Thanks to the preprocessor, the `ring` tactic supports the following
133
+ constructs apart from homomorphism applications:
134
+ - `GRing.zero` (`0%R`),
135
+ - `GRing.add` (`+%R`),
136
+ - `addn`,
137
+ - `N.add`,
138
+ - `Z.add`,
139
+ - `GRing.natmul`,
140
+ - `GRing.opp` (`-%R`),
141
+ - `Z.opp`,
142
+ - `Z.sub`,
143
+ - `intmul`,
144
+ - `GRing.one` (`1%R`),
145
+ - `GRing.mul` (`*%R`),
146
+ - `muln`,
147
+ - `N.mul`,
148
+ - `Z.mul`,
149
+ - `GRing.exp`,[^constant_exponent]
150
+ - `exprz`,[^constant_exponent]
151
+ - `expn`,[^constant_exponent]
152
+ - `N.pow`,[^constant_exponent]
153
+ - `Z.pow`,[^constant_exponent]
154
+ - `S`,
155
+ - `Posz`,
156
+ - `Negz`, and
157
+ - constants of type `nat`, `N`, or `Z`.
158
+
159
+ [^constant_exponent]: The exponent must be a constant value. In addition, it
160
+ must be non-negative for `exprz`.
161
+
162
+ ### The `field` tactic
163
+
164
+ The `field` tactic solves a goal of the form `p = q :> F` representing a
165
+ rational equation. The type `F` must have a canonical `fieldType` (field)
166
+ instance.
167
+ The `field` tactic solves the equation by normalizing each side to a pair of
168
+ two polynomials representing a fraction, whose coefficients are integers `Z`.
169
+ As is the case for the `ring` tactic, the `field` tactic can decide the given
170
+ rational equation modulo given monomial equations. The syntax to use this
171
+ feature is the same as the `ring` tactic: `field: t_1 .. t_n`.
172
+
173
+ The `field` tactic generates proof obligations that all the denominators in
174
+ the equation are not zero.
175
+ A proof obligation of the form `p * q != 0 :> F` is always automatically
176
+ reduced to `p != 0 /\ q != 0`.
177
+ If the field `F` is a `numFieldType` (partially ordered field), a proof
178
+ obligation of the form `c%:~R != 0 :> F` where `c` is a non-zero integer
179
+ constant is automatically resolved.
180
+
181
+ The `field` tactic has a preprocessor similar to the `ring` tactic.
182
+ In addition ot the constructs supported by the `ring` tactic, the `field`
183
+ tactic supports `GRing.inv` and `exprz` with a negative exponent.
184
+
185
+ ### The `lra`, `nra`, and `psatz` tactics
186
+
187
+ The `lra` tactic is a decision procedure for linear real arithmetic. The `nra`
188
+ and `psatz` tactics are incomplete proof procedures for non-linear real
189
+ arithmetic.
190
+ The carrier type must have a canonical `realDomainType` (totally ordered
191
+ integral domain) or `realFieldType` (totally ordered field) instance.
192
+ The multiplicative inverse is supported only if the carrier type is a
193
+ `realFieldType`.
194
+
195
+ If the carrier type is not a `realFieldType` but a `realDomainType`, these
196
+ three tactics use the same preprocessor as the `ring` tactic.
197
+ If the carrier type is a `realFieldType`, these tactics support `GRing.inv`
198
+ and `exprz` with a negative exponent.
199
+ In contrast to the `field` tactic, these tactics push down the multiplicative
200
+ inverse through multiplication and exponentiation, e.g., turning `(x * y)^-1`
201
+ into `x^-1 * y^-1`.
202
+
203
+ ## Files
204
+
205
+ - `theories/`
206
+ - `common.v`: provides the reflexive preprocessors (syntax, interpretation
207
+ function, and normalization functions),
208
+ - `common.elpi`: provides the reification procedure for (semi)ring and
209
+ module expressions, except for the case that the carrier type is a
210
+ `realFieldType` in the `lra`, `nra`, and `psatz` tactics,
211
+ - `ring.v`: provides the Coq code specific to the `ring` and `field`
212
+ tactics, including the reflection lemmas,
213
+ - `ring.elpi`: provides the Elpi code specific to the `ring` and `field`
214
+ tactics,
215
+ - `ring_tac.elpi`: provides the entry point for the `ring` tactic,
216
+ - `field_tac.elpi`: provides the entry point for the `field` tactic,
217
+ - `lra.v`: provides the Coq code specific to the `lra`, `nra`, and `psatz`
218
+ tactics, including the reflection lemmas,
219
+ - `lra.elpi`: provides the Elpi code specific to the `lra`, `nra`, and
220
+ `psatz` tactics, including the reification procedure and the entry point.
94
221
95
222
## Credits
96
223
0 commit comments