Debian Codegraph @

kernel/uGraph.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 Univ
12 open UVars
13
14 (** {6 Graphs of universes. } *)
15 type t
16
17 val set_type_in_type : bool -> t -> t
18
19 (** When [type_in_type], functions adding constraints do not fail and
20 may instead ignore inconsistent constraints.
21
22 Checking functions such as [check_leq] always return [true].
23 *)
24 val type_in_type : t -> bool
25
26 type 'a check_function = t -> 'a -> 'a -> bool
27
28 val check_leq : Universe.t check_function
29 val check_eq : Universe.t check_function
30 val check_eq_level : Level.t check_function
31
32 (** The initial graph of universes: Prop < Set *)
33 val initial_universes : t
34
35 (** Initial universes, but keeping options such as type in type from the argument. *)
36 val initial_universes_with : t -> t
37
38 (** Check equality of instances w.r.t. a universe graph *)
39 val check_eq_instances : (Sorts.Quality.t -> Sorts.Quality.t -> bool) -> t -> Instance.t -> Instance.t -> bool
40
41 (** {6 ... } *)
42 (** Merge of constraints in a universes graph.
43 The function [merge_constraints] merges a set of constraints in a given
44 universes graph. It raises the exception [UniverseInconsistency] if the
45 constraints are not satisfiable. *)
46
47 type path_explanation
48
49 type explanation =
50 | Path of path_explanation
51 | Other of Pp.t
52
53 type univ_variable_printers = (Sorts.QVar.t -> Pp.t) * (Level.t -> Pp.t)
54 type univ_inconsistency = univ_variable_printers option * (UnivConstraint.kind * Sorts.t * Sorts.t * explanation option)
55
56 exception UniverseInconsistency of univ_inconsistency
57
58 val enforce_constraint : UnivConstraint.t -> t -> t
59
60 val merge_constraints : UnivConstraints.t -> t -> t
61
62 val check_constraint : t -> UnivConstraint.t -> bool
63 val check_constraints : UnivConstraints.t -> t -> bool
64
65 val check_eq_sort : (Sorts.Quality.t -> Sorts.Quality.t -> bool) -> t -> Sorts.t -> Sorts.t -> bool
66 (** Checks whether (i) the first quality is equal to the second and (ii)
67 that the universe of the first one is equal to the universe of the second one.
68 When [type_in_type], only checks relevance. *)
69
70 val check_leq_sort : (Sorts.Quality.t -> Sorts.Quality.t -> bool) -> t -> Sorts.t -> Sorts.t -> bool
71 (** Checks whether (i) the second quality eliminates into the first and (ii)
72 that the universe of the first one is below the universe of the second one.
73 When [type_in_type], only checks relevance. *)
74
75 val enforce_leq_alg : Univ.Universe.t -> Univ.Universe.t -> t -> Univ.UnivConstraints.t * t
76
77 (** Adds a universe to the graph, ensuring it is >= or > Set.
78 @raise AlreadyDeclared if the level is already declared in the graph. *)
79
80 exception AlreadyDeclared
81
82 val add_universe : Level.t -> strict:bool -> t -> t
83
84 (** Check that the universe levels are declared. *)
85 val check_declared_universes : t -> Univ.Level.Set.t -> (unit, Univ.Level.Set.t) result
86
87 (** The empty graph of universes *)
88 val empty_universes : t
89
90 (** [constraints_of_universes g] returns [csts] and [partition] where
91 [csts] are the non-Eq constraints and [partition] is the partition
92 of the universes into equivalence classes. *)
93 val constraints_of_universes : t -> UnivConstraints.t * Level.Set.t list
94
95 val choose : (Level.t -> bool) -> t -> Level.t -> Level.t option
96 (** [choose p g u] picks a universe verifying [p] and equal
97 to [u] in [g]. *)
98
99 (** [constraints_for ~kept g] returns the constraints about the
100 universes [kept] in [g] up to transitivity.
101
102 eg if [g] is [a <= b <= c] then [constraints_for ~kept:{a, c} g] is [a <= c]. *)
103 val constraints_for : kept:Level.Set.t -> t -> UnivConstraints.t
104
105 val domain : t -> Level.Set.t
106 (** Known universes *)
107
108 (** {6 Dumping} *)
109
110 type node =
111 | Alias of Level.t
112 | Node of bool Level.Map.t (** Nodes v s.t. u < v (true) or u <= v (false) *)
113
114 val repr : t -> node Level.Map.t
115
116 (** {6 Pretty-printing of universes. } *)
117
118 val pr_universes : (Level.t -> Pp.t) -> node Level.Map.t -> Pp.t
119
120 val explain_universe_inconsistency : (Sorts.QVar.t -> Pp.t) -> (Level.t -> Pp.t) ->
121 univ_inconsistency -> Pp.t
122
123 (** {6 Debugging} *)
124 val check_universes_invariants : t -> unit
125
126 module Internal : sig
127 (** Makes the qvars treated as above prop.
128 Do not use outside kernel inductive typechecking. *)
129 val add_template_qvars : Sorts.QVar.Set.t -> t -> t
130
131 val is_above_prop : t -> Sorts.QVar.t -> bool
132 end