| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | open Names |
| 12 | open Constr |
| 13 | open Environ |
| 14 | |
| 15 | (** {6 Typing functions (not yet tagged as safe) } |
| 16 | |
| 17 | They return unsafe judgments that are "in context" of a set of |
| 18 | (local) universe variables (the ones that appear in the term) and |
| 19 | associated constraints. In case of polymorphic definitions, these |
| 20 | variables and constraints will be generalized. |
| 21 | |
| 22 | When typechecking a term it may be updated to fix relevance marks. |
| 23 | Do not discard the result. *) |
| 24 | |
| 25 | val infer : env -> constr -> unsafe_judgment |
| 26 | val infer_hconstr : env -> HConstr.t -> unsafe_judgment |
| 27 | val infer_type : env -> types -> unsafe_type_judgment |
| 28 | |
| 29 | val check_context : |
| 30 | env -> Constr.rel_context -> env * Constr.rel_context |
| 31 | |
| 32 | (** {6 Basic operations of the typing machine. } *) |
| 33 | |
| 34 | (** If [j] is the judgement {% $ %}c:t{% $ %}, then [assumption_of_judgement env j] |
| 35 | returns the type {% $ %}c{% $ %}, checking that {% $ %}t{% $ %} is a sort. *) |
| 36 | |
| 37 | val assumption_of_judgment : env -> unsafe_judgment -> Sorts.relevance |
| 38 | |
| 39 | (** {6 Type of sorts. } *) |
| 40 | val type1 : types |
| 41 | val type_of_sort : Sorts.t -> types |
| 42 | |
| 43 | (** {6 Type of a bound variable. } *) |
| 44 | val type_of_relative : env -> int -> types |
| 45 | |
| 46 | (** {6 Type of variables } *) |
| 47 | val type_of_variable : env -> variable -> types |
| 48 | |
| 49 | (** {6 type of a constant } *) |
| 50 | val type_of_constant_in : env -> pconstant -> types |
| 51 | |
| 52 | (** {6 type of an applied projection } *) |
| 53 | val type_of_projection : env -> Projection.t -> constr -> types -> Sorts.relevance * types |
| 54 | |
| 55 | (** {6 Type of a product. } *) |
| 56 | val sort_of_product : env -> Sorts.t -> Sorts.t -> Sorts.t |
| 57 | |
| 58 | (** {6 Type of a cast. } *) |
| 59 | val check_cast : |
| 60 | env -> unsafe_judgment -> cast_kind -> unsafe_type_judgment -> unit |
| 61 | |
| 62 | (** {6 Type of global references. } *) |
| 63 | |
| 64 | val type_of_global_in_context : env -> GlobRef.t -> types * UVars.AbstractContext.t |
| 65 | (** Returns the type of the global reference, by creating a fresh |
| 66 | instance of polymorphic references and computing their |
| 67 | instantiated universe context. The type should not be used |
| 68 | without pushing it's universe context in the environmnent of |
| 69 | usage. For non-universe-polymorphic constants, it does not |
| 70 | matter. *) |
| 71 | |
| 72 | (** {6 Miscellaneous. } *) |
| 73 | |
| 74 | (** Check that hyps are included in env and fails with error otherwise *) |
| 75 | val check_hyps_inclusion : env -> ?evars:CClosure.evar_handler -> |
| 76 | GlobRef.t -> Constr.named_context -> unit |
| 77 | |
| 78 | (** Types for primitives *) |
| 79 | |
| 80 | val type_of_int : env -> types |
| 81 | val type_of_float : env -> types |
| 82 | val type_of_string : env -> types |
| 83 | val type_of_array : env -> UVars.Instance.t -> types |
| 84 | val type_of_prim_type : env -> UVars.Instance.t -> 'a CPrimitives.prim_type -> types |
| 85 | val type_of_prim : env -> UVars.Instance.t -> CPrimitives.t -> types |
| 86 | val type_of_prim_or_type : env -> UVars.Instance.t -> CPrimitives.op_or_type -> types |
| 87 | |
| 88 | val should_invert_case : env -> Sorts.relevance -> case_info -> bool |
| 89 | (** Matches must be annotated with the indices when going from SProp to non SProp |
| 90 | (implies 1 or 0 constructors). *) |