Debian Codegraph @

kernel/type_errors.mli

raw symbols SCIP
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 open Univ
15 open UVars
16
17 (** Type errors. {% \label{typeerrors} %} *)
18
19 (*i Rem: NotEnoughAbstractionInFixBody should only occur with "/i" Fix
20 notation i*)
21 type 'constr pfix_guard_error =
22 (* Fixpoints *)
23 | NotEnoughAbstractionInFixBody of int
24 | RecursionNotOnInductiveType of 'constr
25 | RecursionOnIllegalTerm of int * (env * 'constr) * (int list * int list) Lazy.t
26 | NotEnoughArgumentsForFixCall of int
27 | FixpointOnNonEliminable of Sorts.t * Sorts.t
28
29 type 'constr pcofix_guard_error =
30 (* CoFixpoints *)
31 | CodomainNotInductiveType of 'constr
32 | NestedRecursiveOccurrences
33 | UnguardedRecursiveCall of 'constr
34 | RecCallInTypeOfAbstraction of 'constr
35 | RecCallInNonRecArgOfConstructor of 'constr
36 | RecCallInTypeOfDef of 'constr
37 | RecCallInCaseFun of 'constr
38 | RecCallInCaseArg of 'constr
39 | RecCallInCasePred of 'constr
40 | NotGuardedForm of 'constr
41 | ReturnPredicateNotCoInductive of 'constr
42
43 type 'constr pguard_error =
44 | FixGuardError of 'constr pfix_guard_error
45 | CoFixGuardError of 'constr pcofix_guard_error
46
47 type fix_guard_error = constr pfix_guard_error
48 type cofix_guard_error = constr pcofix_guard_error
49 type guard_error = constr pguard_error
50
51 type ('constr, 'types) pcant_apply_bad_type =
52 (int * 'constr * 'constr) * ('constr, 'types) punsafe_judgment * ('constr, 'types) punsafe_judgment array
53
54 type ('constr, 'types, 'r) ptype_error =
55 | UnboundRel of int
56 | UnboundVar of variable
57 | NotAType of ('constr, 'types) punsafe_judgment
58 | BadAssumption of ('constr, 'types) punsafe_judgment
59 | ReferenceVariables of Id.t * GlobRef.t
60 | ElimArity of pinductive * 'constr * Sorts.t option
61 | CaseNotInductive of ('constr, 'types) punsafe_judgment
62 | CaseOnPrivateInd of inductive
63 | WrongCaseInfo of pinductive * case_info
64 | NumberBranches of ('constr, 'types) punsafe_judgment * int
65 | IllFormedCaseParams
66 | IllFormedBranch of 'constr * pconstructor * 'constr * 'constr
67 | BadProjType of ('constr, 'types) punsafe_judgment * Projection.t
68 | Generalization of (Name.t * 'types) * ('constr, 'types) punsafe_judgment
69 | ActualType of ('constr, 'types) punsafe_judgment * 'types
70 | IncorrectPrimitive of (CPrimitives.op_or_type,'types) punsafe_judgment * 'types
71 | CantApplyBadType of ('constr, 'types) pcant_apply_bad_type
72 | CantApplyNonFunctional of ('constr, 'types) punsafe_judgment * ('constr, 'types) punsafe_judgment array
73 | IllFormedRecBody of 'constr pguard_error * (Name.t,'r) Context.pbinder_annot array * int * env * ('constr, 'types) punsafe_judgment array
74 | IllTypedRecBody of
75 int * (Name.t,'r) Context.pbinder_annot array * ('constr, 'types) punsafe_judgment array * 'types array
76 | UnsatisfiedUnivConstraints of UnivConstraints.t
77 | UnsatisfiedPConstraints of PConstraints.t
78 | UndeclaredQualities of Sorts.QVar.Set.t
79 | UndeclaredUniverses of Level.Set.t
80 | NotAllowedSProp
81 | BadBinderRelevance of 'r * ('constr, 'types, 'r) Context.Rel.Declaration.pt
82 | BadCaseRelevance of 'r * 'constr
83 | BadInvert
84 | BadVariance of { lev : Level.t; expected : Variance.t; actual : Variance.t }
85 | UndeclaredUsedVariables of { declared_vars : Id.Set.t; inferred_vars : Id.Set.t }
86 | IllFormedConstant of Constant.t * KerName.t
87 | IllFormedInductive of MutInd.t * KerName.t
88
89 type type_error = (constr, types, Sorts.relevance) ptype_error
90
91 exception TypeError of env * type_error
92
93 (** The different kinds of errors that may result of a malformed inductive
94 definition. *)
95 type inductive_error =
96 | NonPos of constr * constr
97 | NotEnoughArgs of constr * constr
98 | NotConstructor of Id.t * constr * constr * int * int
99 | NonPar of constr * int * constr * constr
100 | SameNamesTypes of Id.t
101 | SameNamesConstructors of Id.t
102 | SameNamesOverlap of Id.t list
103 | NotAnArity of constr
104 | BadEntry
105 | LargeNonPropInductiveNotInType
106 | MissingUnivConstraints of (Sorts.t list * Sorts.t)
107 (* each universe in the set should have been <= the other one *)
108
109 exception InductiveError of env * inductive_error
110
111 (** Raising functions *)
112
113 val error_unbound_rel : env -> int -> 'a
114
115 val error_unbound_var : env -> variable -> 'a
116
117 val error_not_type : env -> unsafe_judgment -> 'a
118
119 val error_assumption : env -> unsafe_judgment -> 'a
120
121 val error_reference_variables : env -> Id.t -> GlobRef.t -> 'a
122
123 val error_elim_arity :
124 env -> pinductive -> constr -> Sorts.t option -> 'a
125
126 val error_case_not_inductive : env -> unsafe_judgment -> 'a
127
128 val error_case_on_private_ind : env -> inductive -> 'a
129
130 val error_number_branches : env -> unsafe_judgment -> int -> 'a
131
132 val error_ill_formed_branch : env -> constr -> pconstructor -> constr -> constr -> 'a
133
134 val error_generalization : env -> Name.t * types -> unsafe_judgment -> 'a
135
136 val error_bad_proj_type : env -> unsafe_judgment -> Projection.t -> 'a
137
138 val error_actual_type : env -> unsafe_judgment -> types -> 'a
139
140 val error_incorrect_primitive : env -> (CPrimitives.op_or_type,types) punsafe_judgment -> types -> 'a
141
142 val error_cant_apply_not_functional :
143 env -> unsafe_judgment -> unsafe_judgment array -> 'a
144
145 val error_cant_apply_bad_type :
146 env -> int * constr * constr ->
147 unsafe_judgment -> unsafe_judgment array -> 'a
148
149 val error_ill_formed_rec_body :
150 env -> guard_error -> Name.t binder_annot array -> int -> env -> unsafe_judgment array -> 'a
151
152 val error_ill_typed_rec_body :
153 env -> int -> Name.t binder_annot array -> unsafe_judgment array -> types array -> 'a
154
155 val error_unsatisfied_univ_constraints : env -> Univ.UnivConstraints.t -> 'a
156
157 val error_unsatisfied_poly_constraints : env -> PConstraints.t -> 'a
158
159 val error_undeclared_qualities : env -> Sorts.QVar.Set.t -> 'a
160
161 val error_undeclared_universes : env -> Level.Set.t -> 'a
162
163 val error_not_allowed_sprop : env -> 'a
164
165 val error_bad_binder_relevance : env -> Sorts.relevance -> rel_declaration -> 'a
166
167 val error_bad_case_relevance : env -> Sorts.relevance -> Constr.case -> 'a
168
169 val error_bad_invert : env -> 'a
170
171 val error_bad_variance : env -> lev:Level.t -> expected:Variance.t -> actual:Variance.t -> 'a
172
173 val error_undeclared_used_variables : env -> declared_vars:Id.Set.t -> inferred_vars:Id.Set.t -> 'a
174
175 val error_ill_formed_constant : env -> Constant.t -> KerName.t -> 'a
176
177 val error_ill_formed_inductive : env -> MutInd.t -> KerName.t -> 'a
178
179 val map_pguard_error : ('c -> 'd) -> 'c pguard_error -> 'd pguard_error
180 val map_ptype_error : ('r1 -> 'r2) -> ('c -> 'd) -> ('c, 'c, 'r1) ptype_error -> ('d, 'd, 'r2) ptype_error