diff options
| author | Enrico Tassi | 2014-02-21 18:24:10 +0100 |
|---|---|---|
| committer | Enrico Tassi | 2014-02-26 14:53:08 +0100 |
| commit | f7338257584ba69e7e815c7ef9ac0d24f0dec36c (patch) | |
| tree | 84de35428de2923e297c73bdd66ec65c2f42aa3b /kernel/declareops.ml | |
| parent | 9232c8618eebdcd223fe8eddaa5f46fab0bce95e (diff) | |
New compilation mode -vi2vo
To obtain a.vo one can now:
1) coqtop -quick -compile a
2) coqtop -vi2vo a.vi
To make that possible the .vo structure has been complicated. It is now
made of 5 segments.
| vo | vi | vi2vo | contents
--------------+------+-----+-------+------------------------------------
lib | Yes | Yes | Yes | libstack (modules, notations,...)
opauqe_univs | No | Yes | Yes | constraints coming from opaque proofs
discharge | No | Yes | No | data needed to close sections
tasks | No | Yes | No | STM tasks to produce proof terms
opaque_proofs | Yes | Yes | Yes | proof terms
--------------+------+-----+-------+------------------------------------
This means one can load only the strictly necessay parts. Usually one
does not load the tasks segment of a .vi nor the opaque_proof segment of
a .vo, unless one is turning a .vi into a .vo, in which case he load
all the segments.
Optional segments are marshalled as None. But for lib, all segments
are Array.t of:
| type
--------------+---------------------------------------------------------
lib | a list of Libobject.obj (n'importe quoi)
opauqe_univs | Univ.consraints Future.computation
discharge | what Cooking.cook_constr needs
tasks | Stm.tasks (a task is system_state * vernacexpr list)
opaque_proofs | Term.constr Future.computation
--------------+------+-----+-------+------------------------------------
Invariant: all Future.computation in a vo file (obtained by a vi2vo
compilation or not) have been terminated with Future.join (or
Future.sink). This means they are values (inside a box).
This invariant does not hold for vi files. E.g. opauqe_proofs can be
dangling Future.computation (i.e. NotHere exception). The vi2vo
compilation step will replace them by true values.
Rationale for opaque_univs: in the vi2vo transformation we want to reuse
the lib segment. Hence the missing pieces have to be put on the side,
not inside. Opaque proof terms are already in a separte segment.
Universe constraints are not, hence the new opauqe_univs segment. Such
segment, if present in a .vo file, is always loaded, and
Declare.open_constant will add to the environment the constraints stored
there. For regular constants this is not necessay since the constraints
are already in their enclosing module (and also in the constant_body).
With vi2vo the constraints coming from the proof are not in the
constant_body (hence not in the enclosing module) but there and are
added to the environment explicitly by Declare.open_constant.
Rationale for discharge: vi2vo produces a proof term in its original
context (in the middle of a section). Then it has to discharge the
object. This segment contains the data that is needed in order to do
so. It is morally the input that Lib.close_section passes to Cooking
(via the insane rewinding of libstack, GlobalRecipe, etc chain).
Checksums: the checksum of .vi and a .vo obtain from it is the same.
This means that if if b.vo has been compiled using a.vi, and then
a.vi is compiled into a.vo, Require Import b works (and recursively
loads a.vo).
Diffstat (limited to 'kernel/declareops.ml')
| -rw-r--r-- | kernel/declareops.ml | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/kernel/declareops.ml b/kernel/declareops.ml index e40441d74c..21a961fc3e 100644 --- a/kernel/declareops.ml +++ b/kernel/declareops.ml @@ -19,7 +19,13 @@ open Util let body_of_constant cb = match cb.const_body with | Undef _ -> None | Def c -> Some (Lazyconstr.force c) - | OpaqueDef lc -> Some (Lazyconstr.force_opaque (Future.force lc)) + | OpaqueDef lc -> Some (Lazyconstr.force_opaque lc) + +let constraints_of_constant cb = Univ.union_constraints cb.const_constraints + (match cb.const_body with + | Undef _ -> Univ.empty_constraint + | Def c -> Univ.empty_constraint + | OpaqueDef lc -> snd (Lazyconstr.force_opaque_w_constraints lc)) let constant_has_body cb = match cb.const_body with | Undef _ -> false @@ -52,8 +58,7 @@ let subst_const_type sub arity = match arity with let subst_const_def sub def = match def with | Undef _ -> def | Def c -> Def (subst_constr_subst sub c) - | OpaqueDef lc -> - OpaqueDef (Future.chain ~pure:true lc (subst_lazy_constr sub)) + | OpaqueDef lc -> OpaqueDef (subst_lazy_constr sub lc) let subst_const_body sub cb = assert (List.is_empty cb.const_hyps); (* we're outside sections *) @@ -101,20 +106,13 @@ let hcons_const_def = function | Def l_constr -> let constr = force l_constr in Def (from_val (Term.hcons_constr constr)) - | OpaqueDef lc -> - OpaqueDef - (Future.chain ~greedy:true ~pure:true lc - (fun lc -> opaque_from_val (Term.hcons_constr (force_opaque lc)))) + | OpaqueDef _ as x -> x (* hashconsed when turned indirect *) let hcons_const_body cb = { cb with const_body = hcons_const_def cb.const_body; const_type = hcons_const_type cb.const_type; - const_constraints = - if Future.is_val cb.const_constraints then - Future.from_val - (Univ.hcons_constraints (Future.force cb.const_constraints)) - else cb.const_constraints } + const_constraints = Univ.hcons_constraints cb.const_constraints; } (** {6 Inductive types } *) @@ -239,9 +237,8 @@ let hcons_mind mib = (** {6 Stm machinery } *) let join_constant_body cb = - ignore(Future.join cb.const_constraints); match cb.const_body with - | OpaqueDef d -> ignore(Future.join d) + | OpaqueDef d -> Lazyconstr.join_lazy_constr d | _ -> () let string_of_side_effect = function |
