Debian Codegraph @

theories/Ltac2/Ind.v

raw
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 From Ltac2 Require Import Init.
12
13 Ltac2 Type t := inductive.
14 (** An [inductive] is a name of a mutually inductive type and the index of an
15 inductive block within that type. *)
16
17 Ltac2 @ external equal : t -> t -> bool := "rocq-runtime.plugins.ltac2" "ind_equal".
18 (** Equality test. *)
19
20 Ltac2 Type data.
21 (** The actual data specified by a concrete declaration of an inductive type,
22 containing, e.g., its constructors and its parameters. A value of type
23 [data] corresponds to one inductive type within a larger mutually inductive
24 block. *)
25
26 Ltac2 @ external data : t -> data := "rocq-runtime.plugins.ltac2" "ind_data".
27 (** Get the value named by [t] in the current environment. Panics if [t] is not
28 in the current environment. *)
29
30 Ltac2 @ external repr : data -> t := "rocq-runtime.plugins.ltac2" "ind_repr".
31 (** Returns the name of the inductive type corresponding to the block. Inverse
32 of [data]. *)
33
34 Ltac2 @ external index : t -> int := "rocq-runtime.plugins.ltac2" "ind_index".
35 (** Returns the index of the inductive type inside its mutual block. Guaranteed
36 to range between [0] and [nblocks data - 1] where [data] was retrieved using
37 the above function. *)
38
39 Ltac2 @ external nblocks : data -> int := "rocq-runtime.plugins.ltac2" "ind_nblocks".
40 (** Returns the number of inductive types appearing in a mutual block. *)
41
42 Ltac2 @ external nconstructors : data -> int := "rocq-runtime.plugins.ltac2" "ind_nconstructors".
43 (** Returns the number of constructors appearing in the current block. *)
44
45 Ltac2 @ external get_block : data -> int -> data := "rocq-runtime.plugins.ltac2" "ind_get_block".
46 (** [get_block data n] is the block corresponding to the nth inductive type in
47 [data]'s parent mutually inductive type. Index must range between [0] and
48 [nblocks data - 1], otherwise the function panics. *)
49
50 Ltac2 @ external get_constructor : data -> int -> constructor := "rocq-runtime.plugins.ltac2" "ind_get_constructor".
51 (** Returns the nth constructor of the inductive type. Index must range between
52 [0] and [nconstructors data - 1], otherwise the function panics. *)
53
54 Ltac2 @ external nparams : data -> int := "rocq-runtime.plugins.ltac2" "ind_get_nparams".
55 (** The number of parameters of the inductive type, including both uniform and
56 non-uniform parameters. Does not count local let-ins. *)
57
58 Ltac2 @ external nparams_uniform : data -> int := "rocq-runtime.plugins.ltac2" "ind_get_nparams_rec".
59 (** The number of recursively uniform (i.e., ordinary) parameters of the
60 inductive type. *)
61
62 Ltac2 @ external get_projections : data -> projection array option
63 := "rocq-runtime.plugins.ltac2" "ind_get_projections".
64 (** Returns the list of projections for a primitive record,
65 or [None] if the inductive is not a primitive record. *)
66
67 Ltac2 @ external constructor_nargs : data -> int array := "rocq-runtime.plugins.ltac2" "constructor_nargs".
68 (** [Array.get (constructor_nargs data) n] is the number of non-parameter
69 arguments accepted by the [n]th constructor of this inductive type. Add
70 [Array.get (constructor_nargs data) n] to [Ind.nparams_data] to get the total
71 number of arguments of the constructor. *)
72
73 Ltac2 @ external constructor_ndecls : data -> int array := "rocq-runtime.plugins.ltac2" "constructor_ndecls".
74 (** [Array.get (constructor_ndecls data) n] is the number of variables bound in
75 a pattern match expression by the [n]th constructor of this inductive type.
76 Can be greater than [constructor_nargs] if the constructors have local
77 let-bindings, e.g., applied to [Inductive Ind (A : Type) (f : A -> A) : Set
78 := Constr (x : A) (y := f x)] it would return [[|2|]], because in [match t
79 with Constr _ _ x y => e end], [x] and [y] are bound in [e]. *)
80
81 Ltac2 @external print : t -> message
82 := "rocq-runtime.plugins.ltac2" "ind_print".
83 (** Print the inductive using the shortest qualified identifier which refers to it.
84 Does not avoid variable names in the current or global environment. *)