| 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 | |
| 13 | type t |
| 14 | (** Flexible universe data. |
| 15 | A level is flexible if [UnivFlex.mem] returns [true] on it. |
| 16 | Flexible levels may have a definition, this induces a universe substitution. |
| 17 | |
| 18 | Only some flexible levels may be defined as algebraic universes. *) |
| 19 | |
| 20 | val empty : t |
| 21 | |
| 22 | val is_empty : t -> bool |
| 23 | |
| 24 | val domain : t -> Level.Set.t |
| 25 | (** Contains both defined and undefined flexible levels. *) |
| 26 | |
| 27 | val fold : (Level.t -> is_defined:bool -> 'a -> 'a) -> t -> 'a -> 'a |
| 28 | (** For universe minimization. *) |
| 29 | |
| 30 | val mem : Level.t -> t -> bool |
| 31 | (** Returns [true] for both defined and undefined flexible levels. *) |
| 32 | |
| 33 | val is_algebraic : Level.t -> t -> bool |
| 34 | (** Is the level allowed to be defined by an algebraic universe? *) |
| 35 | |
| 36 | val make_nonalgebraic_variable : t -> Level.t -> t |
| 37 | (** Make the level non algebraic. Undefined behaviour on |
| 38 | already-defined algebraics. *) |
| 39 | |
| 40 | val make_all_undefined_nonalgebraic : t -> t |
| 41 | (** Turn all undefined flexible algebraic variables into simply flexible |
| 42 | ones. Can be used in case the variables might appear in universe instances |
| 43 | (typically for polymorphic program obligations). *) |
| 44 | |
| 45 | val fix_undefined_variables : t -> t |
| 46 | (** Make all undefined flexible levels into rigid levels, ie remove them. *) |
| 47 | |
| 48 | val add : Level.t -> algebraic:bool -> t -> t |
| 49 | (** Makes a level flexible with no definition. |
| 50 | It must not already be flexible. *) |
| 51 | |
| 52 | val remove : Level.t -> t -> t |
| 53 | |
| 54 | val add_levels : Level.Set.t -> algebraic:bool -> t -> t |
| 55 | (** Make the levels flexible with no definitions. |
| 56 | They must not already be flexible. *) |
| 57 | |
| 58 | val define : Level.t -> Universe.t -> t -> t |
| 59 | (** Define the level to the given universe. The level must already |
| 60 | be flexible and must be undefined. *) |
| 61 | |
| 62 | val constrain_variables : Level.Set.t -> t -> Univ.ContextSet.t -> Univ.ContextSet.t * t |
| 63 | (** [constrain_variables diff subst ctx] removes bindings [l := l'] |
| 64 | from the substitution where [l] is in [diff] and [l'] is a |
| 65 | level, and adds [l, l = l'] to [ctx]. *) |
| 66 | |
| 67 | val biased_union : t -> t -> t |
| 68 | (** [biased_union x y] favors the bindings of the first map that are defined, |
| 69 | otherwise takes the second's bindings. *) |
| 70 | |
| 71 | val normalize : t -> t |
| 72 | (** Return an optimized representation of the input *) |
| 73 | |
| 74 | val normalize_univ_variables : t -> t * Level.Set.t * UnivSubst.universe_subst_fn |
| 75 | (** As [normalize] and also returns the set of defined variables |
| 76 | and a function which is equivalent to calling [normalize_univ_variable] |
| 77 | on the substitution but may be faster. *) |
| 78 | |
| 79 | val normalize_univ_variable : t -> UnivSubst.universe_subst_fn |
| 80 | (** Apply the substitution to a variable. *) |
| 81 | |
| 82 | val normalize_universe : t -> Universe.t -> Universe.t |
| 83 | (** Apply the substitution to an algebraic universe. *) |
| 84 | |
| 85 | val pr : (Level.t -> Pp.t) -> t -> Pp.t |
| 86 | (** "Show Universes"-style printing. *) |