(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
(* Note: don't forget to update v_primitive in checker/values.ml if the *) (* number of primitives is changed. *)
let const_to_string = function
| Arraymaxlength -> "arraymaxlength"
| Stringmaxlength -> "stringmaxlength"
let const_of_string = function
| "array_max_length" -> Arraymaxlength
| "string_max_length" -> Stringmaxlength
| _ -> raise Not_found
let const_univs = function
| Arraymaxlength
| Stringmaxlength -> AbstractContext.empty
type'a prim_type =
| PT_int63 : unit prim_type
| PT_float64 : unit prim_type
| PT_string : unit prim_type
| PT_array : (Instance.t * ind_or_type) prim_type
and'a prim_ind =
| PIT_bool : unit prim_ind
| PIT_carry : ind_or_type prim_ind
| PIT_pair : (ind_or_type * ind_or_type) prim_ind
| PIT_cmp : unit prim_ind
| PIT_f_cmp : unit prim_ind
| PIT_f_class : unit prim_ind
and ind_or_type =
| PITT_ind : 'a prim_ind * 'a -> ind_or_type
| PITT_type : 'a prim_type * 'a -> ind_or_type
| PITT_param : int -> ind_or_type (* DeBruijn index referring to prenex type quantifiers *)
let one_univ =
AbstractContext.make { quals = [||]; univs = Names.[|Name (Id.of_string "u")|]} Constraints.empty
let typ_univs (type a) (t : a prim_type) = match t with
| PT_int63 -> AbstractContext.empty
| PT_float64 -> AbstractContext.empty
| PT_string -> AbstractContext.empty
| PT_array -> one_univ
type prim_type_ex = PTE : 'a prim_type -> prim_type_ex
type prim_ind_ex = PIE : 'a prim_ind -> prim_ind_ex
let one_param = (* currently if there's a parameter it's always this *) let a_annot = Context.nameR (Names.Id.of_string "A") in let ty = Constr.mkType (Universe.make (Level.var 0)) in
Context.Rel.Declaration.[LocalAssum (a_annot, ty)]
type arg_kind =
| Kparam (* not needed for the evaluation of the primitive when it reduces *)
| Kwhnf (* need to be reduced in whnf before reducing the primitive *)
| Karg (* no need to be reduced in whnf. example: [v] in [Array.set t i v] *)
type args_red = arg_kind list
(* Invariant only argument of type int63, float or an inductive can
have kind Kwhnf *)
let arity t =
nparams t + List.length (fst (types t))
let kind t = let rec params n = if n <= 0 then [] else Kparam :: params (n - 1) in let args = function PITT_type _ | PITT_ind _ -> Kwhnf | PITT_param _ -> Karg in
params (nparams t) @ List.map args (fst (types t))
let types t = let args_ty, ret_ty = types t in
params t, args_ty, ret_ty
(** Special Entries for Register **)
type op_or_type =
| OT_op of t
| OT_type : 'a prim_type -> op_or_type
| OT_const ofconst
let prim_ind_to_string (type a) (p : a prim_ind) = match p with
| PIT_bool -> "bool"
| PIT_carry -> "carry"
| PIT_pair -> "pair"
| PIT_cmp -> "cmp"
| PIT_f_cmp -> "f_cmp"
| PIT_f_class -> "f_class"
let prim_type_to_string (type a) (ty : a prim_type) = match ty with
| PT_int63 -> "int63_type"
| PT_float64 -> "float64_type"
| PT_string -> "string_type"
| PT_array -> "array_type"
let op_or_type_to_string = function
| OT_op op -> to_string op
| OT_type t -> prim_type_to_string t
| OT_const c -> const_to_string c
let op_or_type_of_string s = match prim_type_of_string s with
| PTE ty -> OT_type ty
| exception Not_found -> begintry OT_op (parse s) with Not_found -> OT_const (const_of_string s) end
let parse_op_or_type ?loc s = try op_or_type_of_string s with Not_found ->
CErrors.user_err ?loc Pp.(str ("Built-in #"^s^" does not exist."))
let op_or_type_univs = function
| OT_op t -> univs t
| OT_type t -> typ_univs t
| OT_const c -> const_univs c
let body_of_prim_const = function
| Arraymaxlength ->
Constr.mkInt (Parray.max_length)
| Stringmaxlength ->
Constr.mkInt (Pstring.max_length)
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.