Skip to content

Commit dabfbed

Browse files
committed
Review #2
1 parent fadb397 commit dabfbed

File tree

4 files changed

+37
-36
lines changed

4 files changed

+37
-36
lines changed

doc/sphinx/addendum/type-classes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ Summary of the commands
339339

340340
This command has no effect when used on a typeclass.
341341

342-
.. cmd:: Instance {? @ident_decl {* @binder } } : @type {? @hint_info } {? {| := %{ {* @field_def } %} | := @term } }
342+
.. cmd:: Instance {? @ident_decl {* @binder } } : @type {? @hint_info } {? {| := %{ {* @field_val } %} | := @term } }
343343

344344
Declares a typeclass instance named
345345
:token:`ident_decl` of the class :n:`@type` with the specified parameters and with
346-
fields defined by :token:`field_def`, where each field must be a declared field of
346+
fields defined by :token:`field_val`, where each field must be a declared field of
347347
the class.
348348

349349
Adds one or more :token:`binder`\s to declare a parameterized instance. :token:`hint_info`

doc/sphinx/language/core/records.rst

+31-31
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Record types
44
----------------
55

66
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
88
components, called :gdef:`fields <field>`, can be accessed with
99
:gdef:`projections <projection>`. Records can also be used to describe
1010
mathematical structures, such as groups or rings, hence the
@@ -30,7 +30,7 @@ synonym :cmd:`Structure`.
3030

3131
Use the :cmd:`Inductive` and :cmd:`CoInductive` commands to define recursive
3232
(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
3434
the types in the block are records. These commands automatically generate
3535
induction schemes. Enable the :flag:`Nonrecursive Elimination Schemes` flag
3636
to enable automatic generation of elimination schemes for :cmd:`Record`.
@@ -43,7 +43,7 @@ synonym :cmd:`Structure`.
4343
satisfied). See :ref:`coercions`.
4444

4545
:n:`@ident_decl`
46-
The :n:`@ident` within is the name of the record.
46+
The :n:`@ident` within is the record name.
4747

4848
:n:`{* @binder }`
4949
:n:`@binder`\s may be used to declare the *parameters* of the record.
@@ -67,7 +67,7 @@ synonym :cmd:`Structure`.
6767

6868
:n:`@name` is the field name. Since field names define projections, you can't
6969
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
7171
name in multiple records.
7272

7373
:n:`@field_spec` can be omitted only when the type of the field can be inferred
@@ -80,13 +80,13 @@ synonym :cmd:`Structure`.
8080
In :n:`@field_spec`:
8181

8282
- :n:`{+ @binder } : @of_type` is equivalent to
83-
:n:`forall {+ @binder } , @of_type`
83+
:n:`: forall {+ @binder } , @of_type`
8484

85-
- :n:`{* @binder } := @term` is equivalent to
86-
:n:`fun {* @binder } => @term`
85+
- :n:`{+ @binder } := @term` is equivalent to
86+
:n:`:= fun {* @binder } => @term`
8787

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`
9090

9191
:n:`:= @term`, if present, gives the value of the field, which may depend
9292
on the fields that appear before it. Since their values are already defined,
@@ -145,25 +145,26 @@ synonym :cmd:`Structure`.
145145
Constructing records
146146
~~~~~~~~~~~~~~~~~~~~
147147

148-
.. insertprodn term_record field_def
148+
.. insertprodn term_record field_val
149149
150150
.. prodn::
151-
term_record ::= %{%| {*; @field_def } {? ; } %|%}
152-
field_def ::= @qualid {* @binder } := @term
151+
term_record ::= %{%| {*; @field_val } {? ; } %|%}
152+
field_val ::= @qualid {* @binder } := @term
153153

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.
157158

158159
In the record form, the fields can be given in any order. Fields that can be
159160
inferred by unification or by using obligations (see :ref:`programs`) may be omitted.
160161

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,
162163
as arguments to the constructor.
163164

164165
.. example:: Constructing 1/2 as a record
165166

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:
167168

168169
.. coqtop:: in
169170

@@ -176,8 +177,8 @@ Constructing records
176177
Rat_bottom_nonzero := O_S 1;
177178
Rat_irreducible := one_two_irred |}.
178179
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 *)
181182
Definition half' := mkRat true 1 2 (O_S 1) one_two_irred.
182183
183184
Accessing fields (projections)
@@ -189,15 +190,15 @@ Accessing fields (projections)
189190
term_projection ::= @term0 .( @qualid {? @univ_annot } {* @arg } )
190191
| @term0 .( @ @qualid {? @univ_annot } {* @term1 } )
191192
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
194195
projection function associated with the field. Don't forget the parentheses for the
195-
projective form.
196+
projection form.
196197
Glossing over some syntactic details, the two forms are:
197198

198-
- :n:`@qualid__record.( {? @ } @qualid__field {* @arg })` (projective) and
199+
- :n:`@qualid__record.( {? @ } @qualid__field {* @arg })` (projection) and
199200

200-
- :n:`{? @ } @qualid__field {* @arg } @qualid__record` (applicative)
201+
- :n:`{? @ } @qualid__field {* @arg } @qualid__record` (application)
201202

202203
where the :n:`@arg`\s are the parameters of the inductive type. If :n:`@` is
203204
specified, all implicit arguments must be provided.
@@ -216,22 +217,20 @@ Accessing fields (projections)
216217

217218
.. example:: Accessing record fields
218219

219-
Let us project fields of a record, using either the applicative or projection syntax:
220-
221220
.. coqtop:: all
222221

223222
(* projection form *)
224223
Eval compute in half.(top).
225224
226-
.. coqtop: in
225+
.. coqtop:: in
227226

228227
Goal True.
229228

230-
.. coqtop: all
229+
.. coqtop:: all
231230

232231
let x := eval compute in half.(top) in idtac x.
233232

234-
(* applicative form *)
233+
(* application form *)
235234
Eval compute in top half.
236235
Eval compute in bottom half.
237236
Eval compute in Rat_bottom_nonzero half.
@@ -280,14 +279,15 @@ You can override the display format for specified record types by adding entries
280279

281280
.. flag:: Printing Projections
282281

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).
284283

285284
.. example::
286285

287286
.. coqtop:: all
288287

288+
Check top half. (* off: application form *)
289289
Set Printing Projections.
290-
Check top half.
290+
Check top half. (* on: projection form *)
291291
292292
.. note:: Records exist in two flavors. In the first
293293
implementation, a record :n:`@ident` with parameters :n:`{* @binder }`,

doc/tools/docgram/common.edit_mlg

+1
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,7 @@ RENAME: [
28312831
| q_strategy_flag q_reductions
28322832
| destruction_arg induction_arg
28332833
| field_body field_spec
2834+
| field_def field_val
28342835
]
28352836

28362837
simple_tactic: [

doc/tools/docgram/orderedGrammar

+3-3
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ field_spec: [
692692
]
693693

694694
term_record: [
695-
| "{|" LIST0 field_def SEP ";" OPT ";" "|}"
695+
| "{|" LIST0 field_val SEP ";" OPT ";" "|}"
696696
]
697697

698-
field_def: [
698+
field_val: [
699699
| qualid LIST0 binder ":=" term
700700
]
701701

@@ -1077,7 +1077,7 @@ command: [
10771077
| "Identity" "Coercion" ident ":" class ">->" class
10781078
| "Coercion" reference ":" class ">->" class
10791079
| "Context" LIST1 binder
1080-
| "Instance" OPT ( ident_decl LIST0 binder ) ":" type OPT hint_info OPT [ ":=" "{" LIST0 field_def "}" | ":=" term ]
1080+
| "Instance" OPT ( ident_decl LIST0 binder ) ":" type OPT hint_info OPT [ ":=" "{" LIST0 field_val "}" | ":=" term ]
10811081
| "Existing" "Instance" qualid OPT hint_info
10821082
| "Existing" "Instances" LIST1 qualid OPT [ "|" natural ]
10831083
| "Existing" "Class" qualid

0 commit comments

Comments
 (0)