@@ -4,7 +4,7 @@ Record types
4
4
----------------
5
5
6
6
The :cmd: `Record ` command defines types similar to :gdef: `records `
7
- in programming languages. Those types describes tuples whose
7
+ in programming languages. Those types describe tuples whose
8
8
components, called :gdef: `fields <field> `, can be accessed with
9
9
:gdef: `projections <projection> `. Records can also be used to describe
10
10
mathematical structures, such as groups or rings, hence the
@@ -30,7 +30,7 @@ synonym :cmd:`Structure`.
30
30
31
31
Use the :cmd: `Inductive ` and :cmd: `CoInductive ` commands to define recursive
32
32
(inductive or coinductive) records. These commands also permit defining
33
- mutually inductive or coinductive records, provided all of
33
+ mutually recusrive records provided that all of
34
34
the types in the block are records. These commands automatically generate
35
35
induction schemes. Enable the :flag: `Nonrecursive Elimination Schemes ` flag
36
36
to enable automatic generation of elimination schemes for :cmd: `Record `.
@@ -43,7 +43,7 @@ synonym :cmd:`Structure`.
43
43
satisfied). See :ref: `coercions `.
44
44
45
45
:n: `@ident_decl `
46
- The :n: `@ident ` within is the name of the record.
46
+ The :n: `@ident ` within is the record name .
47
47
48
48
:n: `{* @binder } `
49
49
:n: `@binder `\s may be used to declare the *parameters * of the record.
@@ -67,7 +67,7 @@ synonym :cmd:`Structure`.
67
67
68
68
:n: `@name ` is the field name. Since field names define projections, you can't
69
69
reuse the same field name in two different records in the same scope. This
70
- :ref: `example <reuse_field_name >` shows how to use the reuse the same field
70
+ :ref: `example <reuse_field_name >` shows how to reuse the same field
71
71
name in multiple records.
72
72
73
73
:n: `@field_spec ` can be omitted only when the type of the field can be inferred
@@ -80,13 +80,13 @@ synonym :cmd:`Structure`.
80
80
In :n: `@field_spec `:
81
81
82
82
- :n: `{+ @binder } : @of_type ` is equivalent to
83
- :n: `forall {+ @binder } , @of_type `
83
+ :n: `: forall {+ @binder } , @of_type `
84
84
85
- - :n: `{* @binder } := @term ` is equivalent to
86
- :n: `fun {* @binder } => @term `
85
+ - :n: `{+ @binder } := @term ` is equivalent to
86
+ :n: `:= fun {* @binder } => @term `
87
87
88
- - :n: `{* @binder } @of_type := @term ` is equivalent to
89
- :n: `forall {* @binder } , @type := fun {* @binder } => @term `
88
+ - :n: `{+ @binder } @of_type := @term ` is equivalent to
89
+ :n: `: forall {* @binder } , @type := fun {* @binder } => @term `
90
90
91
91
:n: `:= @term `, if present, gives the value of the field, which may depend
92
92
on the fields that appear before it. Since their values are already defined,
@@ -145,25 +145,26 @@ synonym :cmd:`Structure`.
145
145
Constructing records
146
146
~~~~~~~~~~~~~~~~~~~~
147
147
148
- .. insertprodn term_record field_def
148
+ .. insertprodn term_record field_val
149
149
150
150
.. prodn ::
151
- term_record ::= %{%| {*; @field_def } {? ; } %|%}
152
- field_def ::= @qualid { * @binder } := @term
151
+ term_record ::= %{%| {*; @field_val } {? ; } %|%}
152
+ field_val ::= @qualid { * @binder } := @term
153
153
154
- Instances of record types can be constructed using either *record syntax *
155
- (:n: `@term_record `, shown here) or with *applicative syntax * (see :n: `@term_application `)
156
- using the constructor.
154
+ Instances of record types can be constructed using either *record form *
155
+ (:n: `@term_record `, shown here) or *application form * (see :n: `@term_application `)
156
+ using the constructor. The associated record definition is selected using the
157
+ provided field names or constructor name, both of which are global.
157
158
158
159
In the record form, the fields can be given in any order. Fields that can be
159
160
inferred by unification or by using obligations (see :ref: `programs `) may be omitted.
160
161
161
- In applicative form, all fields of the record must be passed, in order,
162
+ In application form, all fields of the record must be passed, in order,
162
163
as arguments to the constructor.
163
164
164
165
.. example :: Constructing 1/2 as a record
165
166
166
- Constructing the rational :math: `1 /2 ` using either the record or applicative syntax:
167
+ Constructing the rational :math: `1 /2 ` using either the record or application syntax:
167
168
168
169
.. coqtop :: in
169
170
@@ -176,8 +177,8 @@ Constructing records
176
177
Rat_bottom_nonzero := O_S 1;
177
178
Rat_irreducible := one_two_irred |}.
178
179
179
- (* Applicative form: use the constructor and provide values for all the fields
180
- in order. "mkRat" is the Record command *)
180
+ (* Application form: use the constructor and provide values for all the fields
181
+ in order. "mkRat" is defined by the Record command *)
181
182
Definition half' := mkRat true 1 2 (O_S 1) one_two_irred.
182
183
183
184
Accessing fields (projections)
@@ -189,15 +190,15 @@ Accessing fields (projections)
189
190
term_projection ::= @term0 .( @qualid {? @univ_annot } {* @arg } )
190
191
| @term0 .( @ @qualid {? @univ_annot } {* @term1 } )
191
192
192
- The value of a field can be accessed using *projective syntax * (:n: `@term_projection `,
193
- shown here) or with *applicative syntax * (see :n: `@term_application `) using the
193
+ The value of a field can be accessed using *projection form * (:n: `@term_projection `,
194
+ shown here) or with *application form * (see :n: `@term_application `) using the
194
195
projection function associated with the field. Don't forget the parentheses for the
195
- projective form.
196
+ projection form.
196
197
Glossing over some syntactic details, the two forms are:
197
198
198
- - :n: `@qualid__record.( {? @ } @qualid__field {* @arg }) ` (projective ) and
199
+ - :n: `@qualid__record.( {? @ } @qualid__field {* @arg }) ` (projection ) and
199
200
200
- - :n: `{? @ } @qualid__field {* @arg } @qualid__record ` (applicative )
201
+ - :n: `{? @ } @qualid__field {* @arg } @qualid__record ` (application )
201
202
202
203
where the :n: `@arg `\s are the parameters of the inductive type. If :n: `@ ` is
203
204
specified, all implicit arguments must be provided.
@@ -216,22 +217,20 @@ Accessing fields (projections)
216
217
217
218
.. example :: Accessing record fields
218
219
219
- Let us project fields of a record, using either the applicative or projection syntax:
220
-
221
220
.. coqtop :: all
222
221
223
222
(* projection form *)
224
223
Eval compute in half.(top).
225
224
226
- .. coqtop: in
225
+ .. coqtop :: in
227
226
228
227
Goal True.
229
228
230
- .. coqtop: all
229
+ .. coqtop :: all
231
230
232
231
let x := eval compute in half.(top) in idtac x.
233
232
234
- (* applicative form *)
233
+ (* application form *)
235
234
Eval compute in top half.
236
235
Eval compute in bottom half.
237
236
Eval compute in Rat_bottom_nonzero half.
@@ -280,14 +279,15 @@ You can override the display format for specified record types by adding entries
280
279
281
280
.. flag :: Printing Projections
282
281
283
- This :term: ` flag ` activates the dot notation for printing (off by default).
282
+ Activates the projection form ( dot notation) for printing projections (off by default).
284
283
285
284
.. example ::
286
285
287
286
.. coqtop :: all
288
287
288
+ Check top half. (* off: application form *)
289
289
Set Printing Projections.
290
- Check top half.
290
+ Check top half. ( * on: projection form * )
291
291
292
292
.. note :: Records exist in two flavors. In the first
293
293
implementation, a record :n: `@ident ` with parameters :n: `{* @binder } `,
0 commit comments