Debian Codegraph @

dev/doc/primproj.md

raw symbols SCIP
1 Primitive Projections
2 ---------------------
3
4 | Proj of Projection.t * constr
5
6 Projections are always applied to a term, which must be of a record
7 type (i.e. reducible to an inductive type `I params`). Type-checking,
8 reduction and conversion are fast (not as fast as they could be yet)
9 because we don't keep parameters around. As you can see, it's
10 currently a `constant` that is used here to refer to the projection,
11 that will change to an abstract `projection` type in the future.
12 Basically a projection constant records which inductive it is a
13 projection for, the number of params and the actual position in the
14 constructor that must be projected. For compatibility reason, we also
15 define an eta-expanded form (accessible from user syntax `@f`). The
16 constant_entry of a projection has both informations. Declaring a
17 record (under `Set Primitive Projections`) will generate such
18 definitions. The API to declare them is not stable at the moment, but
19 the inductive type declaration also knows about the projections, i.e.
20 a record inductive type decl contains an array of terms representing
21 the projections. This is used to implement eta-conversion for record
22 types (with at least one field and having all projections definable).
23 The canonical value being `Build_R (pn x) ... (pn x)`. Unification and
24 conversion work up to this eta rule. The records can also be universe
25 polymorphic of course, and we don't need to keep track of the universe
26 instance for the projections either. Projections are reduced _eagerly_
27 everywhere, and introduce a new `Zproj` constructor in the abstract
28 machines that obeys both the delta (for the constant opacity) and iota
29 laws (for the actual reduction). Refolding works as well (afaict), but
30 there is a slight hack there related to universes (not projections).
31
32 For the ML programmer, the biggest change is that pattern-matchings on
33 kind_of_term require an additional case, that is handled usually
34 exactly like an `App (Const p) arg`.
35
36 There are slight hacks related to hints is well, to use the primitive
37 projection form of f when one does `Hint Resolve f`. Usually hint
38 resolve will typecheck the term, resulting in a partially applied
39 projection (disallowed), so we allow it to take
40 `constr_or_global_reference` arguments instead and special-case on
41 projections. Other tactic extensions might need similar treatment.