filename
stringlengths
3
67
data
stringlengths
0
58.3M
license
stringlengths
0
19.5k
extBytes.ml
#if OCAML >= 402 || defined WITH_BYTES module Bytes = Bytes #else module Bytes = struct include String let empty = "" let of_string = copy let to_string = copy let sub_string = sub let blit_string = blit let unsafe_to_string : t -> string = fun s -> s let unsafe_of_string : string -> t = fun s -> s end #endif
Neural_network.ml
let () = Wrap_utils.init ();; let __wrap_namespace = Py.import "sklearn.neural_network" let get_py name = Py.Module.get __wrap_namespace name module BernoulliRBM = struct type tag = [`BernoulliRBM] type t = [`BaseEstimator | `BernoulliRBM | `Object | `TransformerMixin] Obj.t let of_pyobject x = ((Obj.of_pyobject x) : t) let to_pyobject x = Obj.to_pyobject x let as_transformer x = (x :> [`TransformerMixin] Obj.t) let as_estimator x = (x :> [`BaseEstimator] Obj.t) let create ?n_components ?learning_rate ?batch_size ?n_iter ?verbose ?random_state () = Py.Module.get_function_with_keywords __wrap_namespace "BernoulliRBM" [||] (Wrap_utils.keyword_args [("n_components", Wrap_utils.Option.map n_components Py.Int.of_int); ("learning_rate", Wrap_utils.Option.map learning_rate Py.Float.of_float); ("batch_size", Wrap_utils.Option.map batch_size Py.Int.of_int); ("n_iter", Wrap_utils.Option.map n_iter Py.Int.of_int); ("verbose", Wrap_utils.Option.map verbose Py.Int.of_int); ("random_state", Wrap_utils.Option.map random_state Py.Int.of_int)]) |> of_pyobject let fit ?y ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "fit" [||] (Wrap_utils.keyword_args [("y", y); ("X", Some(x |> Np.Obj.to_pyobject))]) |> of_pyobject let fit_transform ?y ?fit_params ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "fit_transform" [||] (List.rev_append (Wrap_utils.keyword_args [("y", Wrap_utils.Option.map y Np.Obj.to_pyobject); ("X", Some(x |> Np.Obj.to_pyobject))]) (match fit_params with None -> [] | Some x -> x)) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let get_params ?deep self = Py.Module.get_function_with_keywords (to_pyobject self) "get_params" [||] (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)]) |> Dict.of_pyobject let gibbs ~v self = Py.Module.get_function_with_keywords (to_pyobject self) "gibbs" [||] (Wrap_utils.keyword_args [("v", Some(v |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let partial_fit ?y ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "partial_fit" [||] (Wrap_utils.keyword_args [("y", y); ("X", Some(x |> Np.Obj.to_pyobject))]) |> of_pyobject let score_samples ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "score_samples" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let set_params ?params self = Py.Module.get_function_with_keywords (to_pyobject self) "set_params" [||] (match params with None -> [] | Some x -> x) |> of_pyobject let transform ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "transform" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let intercept_hidden_opt self = match Py.Object.get_attr_string (to_pyobject self) "intercept_hidden_" with | None -> failwith "attribute intercept_hidden_ not found" | Some x -> if Py.is_none x then None else Some ((fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) x) let intercept_hidden_ self = match intercept_hidden_opt self with | None -> raise Not_found | Some x -> x let intercept_visible_opt self = match Py.Object.get_attr_string (to_pyobject self) "intercept_visible_" with | None -> failwith "attribute intercept_visible_ not found" | Some x -> if Py.is_none x then None else Some ((fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) x) let intercept_visible_ self = match intercept_visible_opt self with | None -> raise Not_found | Some x -> x let components_opt self = match Py.Object.get_attr_string (to_pyobject self) "components_" with | None -> failwith "attribute components_ not found" | Some x -> if Py.is_none x then None else Some ((fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) x) let components_ self = match components_opt self with | None -> raise Not_found | Some x -> x let h_samples_opt self = match Py.Object.get_attr_string (to_pyobject self) "h_samples_" with | None -> failwith "attribute h_samples_ not found" | Some x -> if Py.is_none x then None else Some ((fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) x) let h_samples_ self = match h_samples_opt self with | None -> raise Not_found | Some x -> x let to_string self = Py.Object.to_string (to_pyobject self) let show self = to_string self let pp formatter self = Format.fprintf formatter "%s" (show self) end module MLPClassifier = struct type tag = [`MLPClassifier] type t = [`BaseEstimator | `BaseMultilayerPerceptron | `ClassifierMixin | `MLPClassifier | `Object] Obj.t let of_pyobject x = ((Obj.of_pyobject x) : t) let to_pyobject x = Obj.to_pyobject x let as_classifier x = (x :> [`ClassifierMixin] Obj.t) let as_multilayer_perceptron x = (x :> [`BaseMultilayerPerceptron] Obj.t) let as_estimator x = (x :> [`BaseEstimator] Obj.t) let create ?hidden_layer_sizes ?activation ?solver ?alpha ?batch_size ?learning_rate ?learning_rate_init ?power_t ?max_iter ?shuffle ?random_state ?tol ?verbose ?warm_start ?momentum ?nesterovs_momentum ?early_stopping ?validation_fraction ?beta_1 ?beta_2 ?epsilon ?n_iter_no_change ?max_fun () = Py.Module.get_function_with_keywords __wrap_namespace "MLPClassifier" [||] (Wrap_utils.keyword_args [("hidden_layer_sizes", hidden_layer_sizes); ("activation", Wrap_utils.Option.map activation (function | `Identity -> Py.String.of_string "identity" | `Logistic -> Py.String.of_string "logistic" | `Tanh -> Py.String.of_string "tanh" | `Relu -> Py.String.of_string "relu" )); ("solver", Wrap_utils.Option.map solver (function | `Lbfgs -> Py.String.of_string "lbfgs" | `Sgd -> Py.String.of_string "sgd" | `Adam -> Py.String.of_string "adam" )); ("alpha", Wrap_utils.Option.map alpha Py.Float.of_float); ("batch_size", Wrap_utils.Option.map batch_size Py.Int.of_int); ("learning_rate", Wrap_utils.Option.map learning_rate (function | `Constant -> Py.String.of_string "constant" | `Invscaling -> Py.String.of_string "invscaling" | `Adaptive -> Py.String.of_string "adaptive" )); ("learning_rate_init", Wrap_utils.Option.map learning_rate_init Py.Float.of_float); ("power_t", Wrap_utils.Option.map power_t Py.Float.of_float); ("max_iter", Wrap_utils.Option.map max_iter Py.Int.of_int); ("shuffle", Wrap_utils.Option.map shuffle Py.Bool.of_bool); ("random_state", Wrap_utils.Option.map random_state Py.Int.of_int); ("tol", Wrap_utils.Option.map tol Py.Float.of_float); ("verbose", Wrap_utils.Option.map verbose Py.Int.of_int); ("warm_start", Wrap_utils.Option.map warm_start Py.Bool.of_bool); ("momentum", Wrap_utils.Option.map momentum Py.Float.of_float); ("nesterovs_momentum", Wrap_utils.Option.map nesterovs_momentum Py.Bool.of_bool); ("early_stopping", Wrap_utils.Option.map early_stopping Py.Bool.of_bool); ("validation_fraction", Wrap_utils.Option.map validation_fraction Py.Float.of_float); ("beta_1", Wrap_utils.Option.map beta_1 Py.Float.of_float); ("beta_2", Wrap_utils.Option.map beta_2 Py.Float.of_float); ("epsilon", Wrap_utils.Option.map epsilon Py.Float.of_float); ("n_iter_no_change", Wrap_utils.Option.map n_iter_no_change Py.Int.of_int); ("max_fun", Wrap_utils.Option.map max_fun Py.Int.of_int)]) |> of_pyobject let fit ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "fit" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject)); ("y", Some(y |> Np.Obj.to_pyobject))]) |> of_pyobject let get_params ?deep self = Py.Module.get_function_with_keywords (to_pyobject self) "get_params" [||] (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)]) |> Dict.of_pyobject let partial_fit ?classes ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "partial_fit" [||] (Wrap_utils.keyword_args [("classes", classes); ("X", Some(x )); ("y", Some(y ))]) |> of_pyobject let predict ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "predict" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let predict_log_proba ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "predict_log_proba" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let predict_proba ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "predict_proba" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let score ?sample_weight ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "score" [||] (Wrap_utils.keyword_args [("sample_weight", Wrap_utils.Option.map sample_weight Np.Obj.to_pyobject); ("X", Some(x |> Np.Obj.to_pyobject)); ("y", Some(y |> Np.Obj.to_pyobject))]) |> Py.Float.to_float let set_params ?params self = Py.Module.get_function_with_keywords (to_pyobject self) "set_params" [||] (match params with None -> [] | Some x -> x) |> of_pyobject let classes_opt self = match Py.Object.get_attr_string (to_pyobject self) "classes_" with | None -> failwith "attribute classes_ not found" | Some x -> if Py.is_none x then None else Some ((fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) x) let classes_ self = match classes_opt self with | None -> raise Not_found | Some x -> x let loss_opt self = match Py.Object.get_attr_string (to_pyobject self) "loss_" with | None -> failwith "attribute loss_ not found" | Some x -> if Py.is_none x then None else Some (Py.Float.to_float x) let loss_ self = match loss_opt self with | None -> raise Not_found | Some x -> x let coefs_opt self = match Py.Object.get_attr_string (to_pyobject self) "coefs_" with | None -> failwith "attribute coefs_ not found" | Some x -> if Py.is_none x then None else Some (Wrap_utils.id x) let coefs_ self = match coefs_opt self with | None -> raise Not_found | Some x -> x let intercepts_opt self = match Py.Object.get_attr_string (to_pyobject self) "intercepts_" with | None -> failwith "attribute intercepts_ not found" | Some x -> if Py.is_none x then None else Some (Wrap_utils.id x) let intercepts_ self = match intercepts_opt self with | None -> raise Not_found | Some x -> x let n_iter_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_iter_" with | None -> failwith "attribute n_iter_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_iter_ self = match n_iter_opt self with | None -> raise Not_found | Some x -> x let n_layers_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_layers_" with | None -> failwith "attribute n_layers_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_layers_ self = match n_layers_opt self with | None -> raise Not_found | Some x -> x let n_outputs_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_outputs_" with | None -> failwith "attribute n_outputs_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_outputs_ self = match n_outputs_opt self with | None -> raise Not_found | Some x -> x let out_activation_opt self = match Py.Object.get_attr_string (to_pyobject self) "out_activation_" with | None -> failwith "attribute out_activation_ not found" | Some x -> if Py.is_none x then None else Some (Py.String.to_string x) let out_activation_ self = match out_activation_opt self with | None -> raise Not_found | Some x -> x let to_string self = Py.Object.to_string (to_pyobject self) let show self = to_string self let pp formatter self = Format.fprintf formatter "%s" (show self) end module MLPRegressor = struct type tag = [`MLPRegressor] type t = [`BaseEstimator | `BaseMultilayerPerceptron | `MLPRegressor | `Object | `RegressorMixin] Obj.t let of_pyobject x = ((Obj.of_pyobject x) : t) let to_pyobject x = Obj.to_pyobject x let as_estimator x = (x :> [`BaseEstimator] Obj.t) let as_multilayer_perceptron x = (x :> [`BaseMultilayerPerceptron] Obj.t) let as_regressor x = (x :> [`RegressorMixin] Obj.t) let create ?hidden_layer_sizes ?activation ?solver ?alpha ?batch_size ?learning_rate ?learning_rate_init ?power_t ?max_iter ?shuffle ?random_state ?tol ?verbose ?warm_start ?momentum ?nesterovs_momentum ?early_stopping ?validation_fraction ?beta_1 ?beta_2 ?epsilon ?n_iter_no_change ?max_fun () = Py.Module.get_function_with_keywords __wrap_namespace "MLPRegressor" [||] (Wrap_utils.keyword_args [("hidden_layer_sizes", hidden_layer_sizes); ("activation", Wrap_utils.Option.map activation (function | `Identity -> Py.String.of_string "identity" | `Logistic -> Py.String.of_string "logistic" | `Tanh -> Py.String.of_string "tanh" | `Relu -> Py.String.of_string "relu" )); ("solver", Wrap_utils.Option.map solver (function | `Lbfgs -> Py.String.of_string "lbfgs" | `Sgd -> Py.String.of_string "sgd" | `Adam -> Py.String.of_string "adam" )); ("alpha", Wrap_utils.Option.map alpha Py.Float.of_float); ("batch_size", Wrap_utils.Option.map batch_size Py.Int.of_int); ("learning_rate", Wrap_utils.Option.map learning_rate (function | `Constant -> Py.String.of_string "constant" | `Invscaling -> Py.String.of_string "invscaling" | `Adaptive -> Py.String.of_string "adaptive" )); ("learning_rate_init", Wrap_utils.Option.map learning_rate_init Py.Float.of_float); ("power_t", Wrap_utils.Option.map power_t Py.Float.of_float); ("max_iter", Wrap_utils.Option.map max_iter Py.Int.of_int); ("shuffle", Wrap_utils.Option.map shuffle Py.Bool.of_bool); ("random_state", Wrap_utils.Option.map random_state Py.Int.of_int); ("tol", Wrap_utils.Option.map tol Py.Float.of_float); ("verbose", Wrap_utils.Option.map verbose Py.Int.of_int); ("warm_start", Wrap_utils.Option.map warm_start Py.Bool.of_bool); ("momentum", Wrap_utils.Option.map momentum Py.Float.of_float); ("nesterovs_momentum", Wrap_utils.Option.map nesterovs_momentum Py.Bool.of_bool); ("early_stopping", Wrap_utils.Option.map early_stopping Py.Bool.of_bool); ("validation_fraction", Wrap_utils.Option.map validation_fraction Py.Float.of_float); ("beta_1", Wrap_utils.Option.map beta_1 Py.Float.of_float); ("beta_2", Wrap_utils.Option.map beta_2 Py.Float.of_float); ("epsilon", Wrap_utils.Option.map epsilon Py.Float.of_float); ("n_iter_no_change", Wrap_utils.Option.map n_iter_no_change Py.Int.of_int); ("max_fun", Wrap_utils.Option.map max_fun Py.Int.of_int)]) |> of_pyobject let fit ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "fit" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject)); ("y", Some(y |> Np.Obj.to_pyobject))]) |> of_pyobject let get_params ?deep self = Py.Module.get_function_with_keywords (to_pyobject self) "get_params" [||] (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)]) |> Dict.of_pyobject let partial_fit ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "partial_fit" [||] (Wrap_utils.keyword_args [("X", Some(x )); ("y", Some(y ))]) |> of_pyobject let predict ~x self = Py.Module.get_function_with_keywords (to_pyobject self) "predict" [||] (Wrap_utils.keyword_args [("X", Some(x |> Np.Obj.to_pyobject))]) |> (fun py -> (Np.Obj.of_pyobject py : [>`ArrayLike] Np.Obj.t)) let score ?sample_weight ~x ~y self = Py.Module.get_function_with_keywords (to_pyobject self) "score" [||] (Wrap_utils.keyword_args [("sample_weight", Wrap_utils.Option.map sample_weight Np.Obj.to_pyobject); ("X", Some(x |> Np.Obj.to_pyobject)); ("y", Some(y |> Np.Obj.to_pyobject))]) |> Py.Float.to_float let set_params ?params self = Py.Module.get_function_with_keywords (to_pyobject self) "set_params" [||] (match params with None -> [] | Some x -> x) |> of_pyobject let loss_opt self = match Py.Object.get_attr_string (to_pyobject self) "loss_" with | None -> failwith "attribute loss_ not found" | Some x -> if Py.is_none x then None else Some (Py.Float.to_float x) let loss_ self = match loss_opt self with | None -> raise Not_found | Some x -> x let coefs_opt self = match Py.Object.get_attr_string (to_pyobject self) "coefs_" with | None -> failwith "attribute coefs_ not found" | Some x -> if Py.is_none x then None else Some (Wrap_utils.id x) let coefs_ self = match coefs_opt self with | None -> raise Not_found | Some x -> x let intercepts_opt self = match Py.Object.get_attr_string (to_pyobject self) "intercepts_" with | None -> failwith "attribute intercepts_ not found" | Some x -> if Py.is_none x then None else Some (Wrap_utils.id x) let intercepts_ self = match intercepts_opt self with | None -> raise Not_found | Some x -> x let n_iter_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_iter_" with | None -> failwith "attribute n_iter_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_iter_ self = match n_iter_opt self with | None -> raise Not_found | Some x -> x let n_layers_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_layers_" with | None -> failwith "attribute n_layers_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_layers_ self = match n_layers_opt self with | None -> raise Not_found | Some x -> x let n_outputs_opt self = match Py.Object.get_attr_string (to_pyobject self) "n_outputs_" with | None -> failwith "attribute n_outputs_ not found" | Some x -> if Py.is_none x then None else Some (Py.Int.to_int x) let n_outputs_ self = match n_outputs_opt self with | None -> raise Not_found | Some x -> x let out_activation_opt self = match Py.Object.get_attr_string (to_pyobject self) "out_activation_" with | None -> failwith "attribute out_activation_ not found" | Some x -> if Py.is_none x then None else Some (Py.String.to_string x) let out_activation_ self = match out_activation_opt self with | None -> raise Not_found | Some x -> x let to_string self = Py.Object.to_string (to_pyobject self) let show self = to_string self let pp formatter self = Format.fprintf formatter "%s" (show self) end
dune
(cram (deps (glob_files bin/*.exe)))
path_intf.ml
module type S = sig type t val hash : t -> int val to_string : t -> string val of_string : string -> t val parse_string_exn : loc:Loc0.t -> string -> t (** a directory is smaller than its descendants *) include Comparator.S with type t := t include Comparator.OPS with type t := t val to_dyn : t -> Dyn.t val extension : t -> string (** [set_extension path ~ext] replaces extension of [path] by [ext] *) val set_extension : t -> ext:string -> t (** [map_extension path ~f] replaces extension of [path] by [f extension]*) val map_extension : t -> f:(string -> string) -> t val split_extension : t -> t * string val basename : t -> string val basename_opt : t -> string option val extend_basename : t -> suffix:string -> t module Map : Map.S with type key = t module Set : sig include Set.S with type elt = t and type 'a map = 'a Map.t val to_dyn : t Dyn.builder val of_listing : dir:elt -> filenames:string list -> t end module Table : Hashtbl.S with type key = t val relative : ?error_loc:Loc0.t -> t -> string -> t val to_string_maybe_quoted : t -> string val is_descendant : t -> of_:t -> bool val is_root : t -> bool val parent_exn : t -> t val parent : t -> t option val unlink_no_err : t -> unit end (** [Unspecified.w] is a type-level placeholder of an unspecified path. (see [Local_gen] for how it's used) *) module Unspecified = struct type w end (** ['w Local_gen.t] is the type of local paths that live under ['w]. If [x : w Local_gen.t] and [w] is a type-level witness corresponding to a (real or hypothetical) filesystem location [base], then we think of [x] as referring to the location [to_string base ^/ to_string x]. *) module type Local_gen = sig type 'w t val hash : 'w t -> int (* it's not clear that these should be polymorphic over 'w, maybe they should additionally ask for an object that fixes 'w *) val to_string : 'w t -> string val of_string : string -> 'w t val parse_string_exn : loc:Loc0.t -> string -> 'w t (** a directory is smaller than its descendants *) val compare : 'w t -> 'w t -> Ordering.t val to_dyn : 'w t -> Dyn.t val extension : 'w t -> string (** [set_extension path ~ext] replaces extension of [path] by [ext] *) val set_extension : 'w t -> ext:string -> 'w t (** [map_extension path ~f] replaces extension of [path] by [f extension]*) val map_extension : 'W t -> f:(string -> string) -> 'W t val split_extension : 'w t -> 'w t * string val basename : 'w t -> string val extend_basename : 'w t -> suffix:string -> 'w t module Fix_root (Root : sig type w end) : sig module Map : Map.S with type key = Root.w t module Set : sig include Set.S with type elt = Root.w t and type 'a map = 'a Map.t val to_dyn : t Dyn.builder val of_listing : dir:elt -> filenames:string list -> t end module Table : Hashtbl.S with type key = Root.w t end val relative : ?error_loc:Loc0.t -> 'w t -> string -> 'w t val to_string_maybe_quoted : 'w t -> string val is_descendant : 'w t -> of_:'w t -> bool val is_root : 'w t -> bool val parent_exn : 'w t -> 'w t val parent : 'w t -> 'w t option val explode : 'w t -> string list val root : 'w t val append : 'w t -> Unspecified.w t -> 'w t val descendant : 'w t -> of_:'w t -> Unspecified.w t option val reach : 'w t -> from:'w t -> string val split_first_component : 'w t -> (string * Unspecified.w t) option module L : sig val relative : ?error_loc:Loc0.t -> 'w t -> string list -> 'w t val relative_result : 'w t -> string list -> ('w t, [ `Outside_the_workspace ]) Result.t end val unlink_no_err : 'w t -> unit end
from.c
void main() { if(x) goto lab1; else y(); lab1: ; while(x) goto lab2; lab2: ; for(i = 0; i < 5; i++) goto lab3; lab3: ; { int a; goto lab4; x++; y++; } lab4: ; }
testInfo.mli
(* Extract information from test, at the moment name + fname + hash *) (* Type of information *) module T : sig type t = { tname : string ; fname : string ; hash : string ; } val compare : t -> t -> int end (* Extract information out of parsed test *) module Make(A:ArchBase.S)(Pte:PteVal.S) : sig val zyva : Name.t -> A.pseudo MiscParser.t -> T.t end (* Parser an extract *) module Z : sig val from_file : string -> T.t end
(****************************************************************************) (* the diy toolsuite *) (* *) (* Jade Alglave, University College London, UK. *) (* Luc Maranget, INRIA Paris-Rocquencourt, France. *) (* *) (* Copyright 2016-present Institut National de Recherche en Informatique et *) (* en Automatique and the authors. All rights reserved. *) (* *) (* This software is governed by the CeCILL-B license under French law and *) (* abiding by the rules of distribution of free software. You can use, *) (* modify and/ or redistribute the software under the terms of the CeCILL-B *) (* license as circulated by CEA, CNRS and INRIA at the following URL *) (* "http://www.cecill.info". We also give a copy in LICENSE.txt. *) (****************************************************************************)
dune
(mdx (files README.md) (packages pkg))
doubly_linked_test.ml
open OUnit open Core open Poly module type S = sig val name : string module Elt : sig type 'a t val value : 'a t -> 'a val equal : 'a t -> 'a t -> bool val sexp_of_t : ('a -> Sexp.t) -> 'a t -> Sexp.t end type 'a t include Container.S1 with type 'a t := 'a t include Invariant.S1 with type 'a t := 'a t include Sexpable.S1 with type 'a t := 'a t val create : unit -> 'a t val of_list : 'a list -> 'a t val equal : 'a t -> 'a t -> bool val is_first : 'a t -> 'a Elt.t -> bool val is_last : 'a t -> 'a Elt.t -> bool val first_elt : 'a t -> 'a Elt.t option val last_elt : 'a t -> 'a Elt.t option val first : 'a t -> 'a option val last : 'a t -> 'a option val next : 'a t -> 'a Elt.t -> 'a Elt.t option val prev : 'a t -> 'a Elt.t -> 'a Elt.t option val insert_before : 'a t -> 'a Elt.t -> 'a -> 'a Elt.t val insert_after : 'a t -> 'a Elt.t -> 'a -> 'a Elt.t val insert_first : 'a t -> 'a -> 'a Elt.t val insert_last : 'a t -> 'a -> 'a Elt.t val remove : 'a t -> 'a Elt.t -> unit val remove_first : 'a t -> 'a option val remove_last : 'a t -> 'a option val find_elt : 'a t -> f:('a -> bool) -> 'a Elt.t option val clear : 'a t -> unit val copy : 'a t -> 'a t val transfer : src:'a t -> dst:'a t -> unit val filter_inplace : 'a t -> f:('a -> bool) -> unit end module Hero : S = struct let name = "hero" include Doubly_linked end module Foil : S = struct let name = "foil" type 'a t = { mutable elts : 'a elt list ; mutable num_readers : int } and 'a elt = { value : 'a ; mutable root : 'a t } module Elt = struct type 'a t = 'a elt let equal (t1 : _ t) t2 = phys_equal t1 t2 let value t = t.value let sexp_of_t sexp_of_a t = sexp_of_a t.value end let to_list t = List.map ~f:Elt.value t.elts let of_list xs = let t = { elts = []; num_readers = 0 } in t.elts <- List.map xs ~f:(fun x -> { value = x; root = t }); t ;; let length t = List.length (to_list t) let is_empty t = List.is_empty (to_list t) let to_array t = List.to_array (to_list t) let read_wrap t f = t.num_readers <- t.num_readers + 1; Exn.protect ~f ~finally:(fun () -> t.num_readers <- t.num_readers - 1) ;; let for_all t ~f = read_wrap t (fun () -> List.for_all (to_list t) ~f) let exists t ~f = read_wrap t (fun () -> List.exists (to_list t) ~f) let find t ~f = read_wrap t (fun () -> List.find (to_list t) ~f) let find_map t ~f = read_wrap t (fun () -> List.find_map (to_list t) ~f) let iter t ~f = read_wrap t (fun () -> List.iter (to_list t) ~f) let fold t ~init ~f = read_wrap t (fun () -> List.fold (to_list t) ~init ~f) let count t ~f = read_wrap t (fun () -> List.count (to_list t) ~f) let sum m t ~f = read_wrap t (fun () -> List.sum m (to_list t) ~f) let mem t a ~equal = read_wrap t (fun () -> List.mem (to_list t) a ~equal) let min_elt t ~compare = read_wrap t (fun () -> List.min_elt ~compare (to_list t)) let max_elt t ~compare = read_wrap t (fun () -> List.max_elt ~compare (to_list t)) let fold_result t ~init ~f = read_wrap t (fun () -> List.fold_result (to_list t) ~init ~f) ;; let fold_until t ~init ~f = read_wrap t (fun () -> List.fold_until (to_list t) ~init ~f) let sexp_of_t sexp_of_a t = List.sexp_of_t sexp_of_a (to_list t) let t_of_sexp a_of_sexp s = of_list (List.t_of_sexp a_of_sexp s) let invariant _ _ = () let equal t1 t2 = phys_equal t1 t2 let create () = of_list [] let assert_no_pending_readers t = assert (t.num_readers = 0) let filter_inplace t ~f = assert_no_pending_readers t; t.elts <- List.filter t.elts ~f:(fun e -> f e.value) ;; let copy t = of_list (to_list t) let clear t = assert_no_pending_readers t; let dummy = create () in List.iter t.elts ~f:(fun e -> e.root <- dummy); t.elts <- [] ;; let find_elt t ~f = List.find t.elts ~f:(fun elt -> f elt.value) let first_elt t = List.hd t.elts let last_elt t = List.last t.elts let is_last t e = assert (equal t e.root); match last_elt t with | None -> assert false | Some e' -> Elt.equal e e' ;; let is_first t e = assert (equal t e.root); match first_elt t with | None -> assert false | Some e' -> Elt.equal e e' ;; let first t = Option.map ~f:Elt.value (first_elt t) let last t = Option.map ~f:Elt.value (last_elt t) type 'a zipper = { before : 'a elt list ; cursor : 'a elt ; after : 'a elt list } let elts_to_zipper = function | [] -> None | hd :: tl -> Some { before = []; cursor = hd; after = tl } ;; let elts_of_zipper z = List.rev_append z.before (z.cursor :: z.after) let search z e = let rec loop ({ before; cursor = this; after } as z) = if Elt.equal e this then Some z else ( match after with | [] -> None | next :: rest -> loop { before = this :: before; cursor = next; after = rest }) in loop z ;; let search_to t e = assert (equal t e.root); match elts_to_zipper t.elts with | None -> failwith "wrong list" | Some z -> (match search z e with | None -> failwith "wrong list" | Some z -> z) ;; let neighbor before_or_after t e = let z = search_to t e in let side = match before_or_after with | `Before -> z.before | `After -> z.after in List.hd side ;; let next t e = neighbor `After t e let prev t e = neighbor `Before t e let insert_neighbor before_or_after t e x = let z = search_to t e in let new_elt = { value = x; root = t } in let z = match before_or_after with | `Before -> { z with before = new_elt :: z.before } | `After -> { z with after = new_elt :: z.after } in assert_no_pending_readers t; t.elts <- elts_of_zipper z; new_elt ;; let insert_before t elt x = insert_neighbor `Before t elt x let insert_after t elt x = insert_neighbor `After t elt x let insert_first t x = assert_no_pending_readers t; let new_elt = { value = x; root = t } in t.elts <- new_elt :: t.elts; new_elt ;; let insert_last t x = assert_no_pending_readers t; let new_elt = { value = x; root = t } in t.elts <- t.elts @ [ new_elt ]; new_elt ;; let remove t e = let z = search_to t e in assert_no_pending_readers t; e.root <- create (); t.elts <- (match z.before with | [] -> z.after | hd :: tl -> elts_of_zipper { z with before = tl; cursor = hd }) ;; let remove_first t = Option.map (first_elt t) ~f:(fun elt -> remove t elt; Elt.value elt) ;; let remove_last t = Option.map (last_elt t) ~f:(fun elt -> remove t elt; Elt.value elt) ;; let transfer ~src ~dst = assert (not (equal src dst)); List.iter src.elts ~f:(fun e -> e.root <- dst); dst.elts <- dst.elts @ src.elts; src.elts <- [] ;; end exception Both_raised module Both : S = struct module M : sig type ('a1, 'a2) m val ( *@ ) : ('a1 -> 'b1, 'a2 -> 'b2) m -> ('a1, 'a2) m -> ('b1, 'b2) m val pure : 'a -> ('a, 'a) m val pair : 'a -> 'b -> ('a, 'b) m val opt_obs : ('a option, 'b option) m -> ('a, 'b) m option (* observe option *) val obs : ('a, 'a) m -> 'a (* observe *) end = struct type ('a, 'b) m = ('a, exn) Result.t * ('b, exn) Result.t let app f x = match f with | Error e -> Error e | Ok f -> (match x with | Error e -> Error e | Ok x -> (try Ok (f x) with | e -> Error e)) ;; let ( *@ ) (f, g) (x, y) = app f x, app g y let pair x y = Ok x, Ok y let pure x = pair x x let force = function | Ok x, Ok y -> x, y | Error _, Error _ -> raise Both_raised | Error _, Ok _ -> failwith "hero failure =/= foil success" | Ok _, Error _ -> failwith "hero success =/= foil failure" ;; let obs t = let x, y = force t in assert (x = y); x ;; let opt_obs t = match force t with | Some x, Some y -> Some (Ok x, Ok y) | None, None -> None | Some _, None -> failwith "hero some =/= foil none" | None, Some _ -> failwith "hero none =/= foil some" ;; end open M let name = "both" type 'a t = ('a Hero.t, 'a Foil.t) m module Elt = struct type 'a t = ('a Hero.Elt.t, 'a Foil.Elt.t) m let value t = obs (pair Hero.Elt.value Foil.Elt.value *@ t) let sexp_of_t sexp_of_a t = obs (pair Hero.Elt.sexp_of_t Foil.Elt.sexp_of_t *@ pure sexp_of_a *@ t) ;; let equal t1 t2 = obs (pair Hero.Elt.equal Foil.Elt.equal *@ t1 *@ t2) end let sexp_of_t sexp_of_a t = obs (pair Hero.sexp_of_t Foil.sexp_of_t *@ pure sexp_of_a *@ t) ;; let t_of_sexp a_of_sexp s = pair Hero.t_of_sexp Foil.t_of_sexp *@ pure a_of_sexp *@ pure s ;; let exists t ~f = obs (pair (Hero.exists ~f) (Foil.exists ~f) *@ t) let mem t a ~equal = obs (pair (fun h -> Hero.mem h a ~equal) (fun f -> Foil.mem f a ~equal) *@ t) ;; let find_map t ~f = obs (pair (Hero.find_map ~f) (Foil.find_map ~f) *@ t) let find t ~f = obs (pair (Hero.find ~f) (Foil.find ~f) *@ t) let for_all t ~f = obs (pair (Hero.for_all ~f) (Foil.for_all ~f) *@ t) let is_empty t = obs (pair Hero.is_empty Foil.is_empty *@ t) let length t = obs (pair Hero.length Foil.length *@ t) let of_list xs = pair Hero.of_list Foil.of_list *@ pure xs let to_list t = obs (pair Hero.to_list Foil.to_list *@ t) let to_array t = obs (pair Hero.to_array Foil.to_array *@ t) let min_elt t ~compare = obs (pair (Hero.min_elt ~compare) (Foil.min_elt ~compare) *@ t) let max_elt t ~compare = obs (pair (Hero.max_elt ~compare) (Foil.max_elt ~compare) *@ t) (* punt: so as not to duplicate any effects in passed-in functions *) let fold _ = failwith "unimplemented" let fold_result _ = failwith "unimplemented" let fold_until _ = failwith "unimplemented" let iter _ = failwith "unimplemented" let count _ = failwith "unimplemented" let sum _ = failwith "unimplemented" let invariant f t = obs (pair (Hero.invariant f) (Foil.invariant f) *@ t) let create () = pair Hero.create Foil.create *@ pure () let equal t1 t2 = obs (pair Hero.equal Foil.equal *@ t1 *@ t2) let is_first t elt = obs (pair Hero.is_first Foil.is_first *@ t *@ elt) let is_last t elt = obs (pair Hero.is_last Foil.is_last *@ t *@ elt) let first_elt t = opt_obs (pair Hero.first_elt Foil.first_elt *@ t) let last_elt t = opt_obs (pair Hero.last_elt Foil.last_elt *@ t) let first t = obs (pair Hero.first Foil.first *@ t) let last t = obs (pair Hero.last Foil.last *@ t) let next t elt = opt_obs (pair Hero.next Foil.next *@ t *@ elt) let prev t elt = opt_obs (pair Hero.prev Foil.prev *@ t *@ elt) let insert_before t elt v = pair Hero.insert_before Foil.insert_before *@ t *@ elt *@ pure v ;; let insert_after t elt v = pair Hero.insert_after Foil.insert_after *@ t *@ elt *@ pure v ;; let insert_first t v = pair Hero.insert_first Foil.insert_first *@ t *@ pure v let insert_last t v = pair Hero.insert_last Foil.insert_last *@ t *@ pure v let remove t elt = obs (pair Hero.remove Foil.remove *@ t *@ elt) let remove_first t = obs (pair Hero.remove_first Foil.remove_first *@ t) let remove_last t = obs (pair Hero.remove_last Foil.remove_last *@ t) let clear t = obs (pair Hero.clear Foil.clear *@ t) let copy t = pair Hero.copy Foil.copy *@ t let find_elt t ~f = opt_obs (pair (Hero.find_elt ~f) (Foil.find_elt ~f) *@ t) let filter_inplace t ~f = obs (pair (Hero.filter_inplace ~f) (Foil.filter_inplace ~f) *@ t) ;; let transfer ~src ~dst = obs (pair (fun src dst -> Hero.transfer ~src ~dst) (fun src dst -> Foil.transfer ~src ~dst) *@ src *@ dst) ;; end module Make_test (X : S) = struct open X exception Finished let assert_raises f = try f (); raise Finished with | Finished -> assert false | _ -> () ;; module Help = struct let of_sexp s = t_of_sexp Int.t_of_sexp (Sexp.of_string s) let even n = n mod 2 = 0 end let test = X.name >::: [ ("empty" >:: fun () -> let t = create () in assert (length t = 0); assert (is_empty t); assert (first_elt t = None); assert (last_elt t = None); assert (first t = None); assert (last t = None); assert (remove_first t = None); assert (remove_last t = None); assert (to_list t = [])) ; ("single" >:: fun () -> let t = create () in let elt = insert_first t 13 in assert (length t = 1); assert (not (is_empty t)); assert (first t = Some 13); assert (last t = Some 13); assert (to_list t = [ 13 ]); assert (is_first t elt); assert (is_last t elt)) ; ("pair" >:: fun () -> let t = create () in let elt2 = insert_first t 14 in let elt1 = insert_first t 13 in assert (length t = 2); assert (not (is_empty t)); assert true; assert (first t = Some 13); assert (last t = Some 14); assert (to_list t = [ 13; 14 ]); assert (is_first t elt1); assert (is_last t elt2)) ; ("container" >:: fun () -> let module T = Container_test.Test_S1 (X) in T.test ()) ; ("of_list" >:: fun () -> for i = 0 to 5 do let l = List.init i ~f:Fn.id in let t = of_list l in assert (l = to_list t) done) ; ("clear" >:: fun () -> for i = 0 to 5 do let t = of_list (List.init i ~f:Fn.id) in clear t; assert (is_empty t) done) ; ("transfer" >:: fun () -> for i1 = 0 to 3 do let l1 = List.init i1 ~f:Fn.id in for i2 = 0 to 3 do let l2 = List.init i2 ~f:Fn.id in let t1 = of_list l1 in let t2 = of_list l2 in transfer ~src:t1 ~dst:t2; assert (is_empty t1); assert (to_list t2 = l2 @ l1) done done) ; ("transfer2" >:: fun () -> let l1 = create () in let e = insert_first l1 9 in let l2 = create () in transfer ~src:l1 ~dst:l2; remove l2 e; assert (is_empty l1); assert (is_empty l2)) ; ("insert-remove" >:: fun () -> let t = create () in let is_elts elts = assert (to_list t = List.map elts ~f:Elt.value); let rec loop elt elts = match elt, elts with | None, [] -> () | Some elt, elt' :: elts -> assert (Elt.equal elt elt'); loop (next t elt) elts | _ -> assert false in loop (first_elt t) elts; (match elts with | [] -> () | elt :: elts -> assert (prev t elt = None); assert (is_first t elt); assert (Option.equal Elt.equal (first_elt t) (Some elt)); List.iter elts ~f:(fun elt -> assert (not (is_first t elt))); ignore (List.fold elts ~init:elt ~f:(fun prev elt -> assert (Option.equal Elt.equal (X.prev t elt) (Some prev)); elt) : _ Elt.t)); match List.rev elts with | [] -> () | elt :: elts -> assert (next t elt = None); assert (is_last t elt); assert (Option.equal Elt.equal (last_elt t) (Some elt)); List.iter elts ~f:(fun elt -> assert (not (is_last t elt))); ignore (List.fold elts ~init:elt ~f:(fun next elt -> assert (Option.equal Elt.equal (X.next t elt) (Some next)); elt) : _ Elt.t) in let elt1 = insert_first t () in is_elts [ elt1 ]; let elt2 = insert_first t () in is_elts [ elt2; elt1 ]; let elt3 = insert_last t () in is_elts [ elt2; elt1; elt3 ]; remove t elt1; is_elts [ elt2; elt3 ]; let elt4 = insert_after t elt2 () in is_elts [ elt2; elt4; elt3 ]; let elt5 = insert_before t elt2 () in is_elts [ elt5; elt2; elt4; elt3 ]; ignore (remove_last t : _ option); is_elts [ elt5; elt2; elt4 ]; ignore (remove_first t : _ option); is_elts [ elt2; elt4 ]; ignore (remove_first t : _ option); is_elts [ elt4 ]; ignore (remove_first t : _ option); is_elts []) ; ("filter-inplace" >:: fun () -> let t = create () in let r1 = ref 0 in let r2 = ref 1 in let r3 = ref 2 in let i x = ignore (insert_first t x : _ Elt.t) in i r1; i r2; i r3; assert (length t = 3); filter_inplace t ~f:(fun r -> not (phys_equal r r2)); assert (length t = 2); let len = fold t ~init:0 ~f:(fun acc x -> assert (not (phys_equal x r2)); acc + 1) in assert (len = length t)) ; ("wrong-list-1" >:: fun () -> let t1 = create () in let t2 = create () in let e1 = insert_first t1 0 in try remove t2 e1; assert false with | _ -> ()) ; ("wrong-list-2" >:: fun () -> let t4 = create () in let t5 = t_of_sexp Int.t_of_sexp (Sexp.of_string "(1 2)") in match last_elt t5 with | None -> assert false | Some e6 -> (try ignore (prev t4 e6 : _ Elt.t option); raise Exit with | Exit -> assert false | _ -> ())) ; ("transfer-self" >:: fun () -> let l2 = of_list [] in try transfer ~src:l2 ~dst:l2; raise Exit with | Exit -> assert false | _ -> ()) ; "write-lock" >::: [ ("remove" >:: fun () -> let xs = [ 1; 2; 3 ] in let t = of_list xs in let e = Option.value_exn (first_elt t) in iter t ~f:(fun _ -> assert_raises (fun () -> ignore (remove_first t : _ option))); assert (to_list t = xs); iter t ~f:(fun _ -> assert_raises (fun () -> ignore (remove_last t : _ option))); assert (to_list t = xs); iter t ~f:(fun _ -> assert_raises (fun () -> remove t e)); assert (to_list t = xs)) ; ("insert" >:: fun () -> let xs = [ 1; 2; 3 ] in let t = of_list xs in let e = Option.value_exn (first_elt t) in iter t ~f:(fun _ -> assert_raises (fun () -> ignore (insert_first t 4 : _ Elt.t))); assert (to_list t = xs); iter t ~f:(fun _ -> assert_raises (fun () -> ignore (insert_last t 5 : _ Elt.t))); assert (to_list t = xs); iter t ~f:(fun _ -> assert_raises (fun () -> ignore (insert_before t e 6 : _ Elt.t))); assert (to_list t = xs); iter t ~f:(fun _ -> assert_raises (fun () -> ignore (insert_after t e 7 : _ Elt.t))); assert (to_list t = xs)) ] ; ("transfer2" >:: fun () -> let open Help in let src = of_sexp "(1)" in ignore src; let elt = insert_last src 4 in ignore elt; let dst = of_sexp "(1 2 3 4)" in ignore dst; transfer ~src ~dst; ignore (next dst elt : _ Elt.t option); ()) ; ("counterexample1" >:: fun () -> let open Help in let l = of_sexp "(1)" in let e = insert_first l 2 in invariant ignore l; assert (Option.is_some (remove_first l)); assert_raises (fun () -> ignore (is_last l e : bool)); ()) ; ("counterexample2" >:: fun () -> let l = of_list [ 1 ] in let e = insert_first l 3 in invariant ignore l; remove l e; invariant ignore l; assert (Option.is_some (first_elt l))) ; ("counterexample3" >:: fun () -> let open Help in let l1 = of_sexp "(1 2 3)" in let l2 = copy l1 in transfer ~src:l2 ~dst:l1; invariant ignore l1) ; ("counterexample4" >:: fun () -> let open Help in let l1 = of_sexp "(1 2 3 4)" in assert (length l1 = 4); ignore (insert_last l1 4 : _ Elt.t); assert (length l1 = 5); let l2 = of_list [ 1; 2; 3 ] in assert (length l2 = 3); transfer ~src:l1 ~dst:l2; match length l1, length l2 with | 0, 8 -> () | len1, len2 -> failwithf "%s: len1 = %d =/= 0; len2 = %d =/= 8" X.name len1 len2 ()) ] ;; end module Bisimulation = struct module Random = struct let prng = Random.State.make [| 3 ; 1 ; 4 ; 1 ; 5 ; 9 ; 2 ; 6 ; 5 ; 3 ; 5 ; 8 ; 9 ; 7 ; 9 ; 3 ; 2 ; 3 ; 8 ; 4 ; 6 ; 2 ; 6 ; 4 ; 3 ; 3 ; 8 ; 3 ; 2 ; 7 ; 9 ; 5 ; 0 ; 2 ; 8 ; 8 ; 4 ; 1 ; 9 ; 7 ; 1 ; 6 ; 9 ; 3 ; 9 ; 9 ; 3 ; 7 ; 5 ; 1 ; 0 ; 5 ; 8 ; 2 ; 0 ; 9 ; 7 ; 4 ; 9 ; 4 ; 4 ; 5 ; 9 ; 2 ; 3 ; 0 ; 7 ; 8 ; 1 ; 6 ; 4 ; 0 ; 6 ; 2 ; 8 ; 6 ; 2 ; 0 ; 8 ; 9 ; 9 ; 8 ; 6 ; 2 ; 8 ; 0 ; 3 ; 4 ; 8 ; 2 ; 5 ; 3 ; 4 ; 2 ; 1 ; 1 ; 7 ; 0 ; 6 ; 7 ; 9 ; 8 ; 2 ; 1 ; 4 ; 8 ; 0 ; 8 ; 6 ; 5 ; 1 ; 3 ; 2 ; 8 ; 2 ; 3 ; 0 ; 6 ; 6 ; 4 ; 7 ; 0 ; 9 ; 3 ; 8 ; 4 ; 4 ; 6 ; 0 ; 9 ; 5 ; 5 ; 0 ; 5 ; 8 ; 2 ; 2 ; 3 ; 1 ; 7 ; 2 ; 5 ; 3 ; 5 ; 9 ; 4 ; 0 ; 8 ; 1 ; 2 ; 8 ; 4 ; 8 ; 1 ; 1 ; 1 ; 7 ; 4 ; 5 ; 0 ; 2 ; 8 ; 4 ; 1 ; 0 ; 2 ; 7 ; 0 ; 1 ; 9 ; 3 ; 8 ; 5 ; 2 ; 1 ; 1 ; 0 ; 5 ; 5 ; 5 ; 9 ; 6 ; 4 ; 4 ; 6 ; 2 ; 2 ; 9 ; 4 ; 8 ; 9 ; 5 ; 4 ; 9 ; 3 ; 0 ; 3 ; 8 ; 1 ; 9 ; 6 ; 4 ; 4 ; 2 ; 8 ; 8 ; 1 ; 0 ; 9 ; 7 ; 5 ; 6 ; 6 ; 5 ; 9 ; 3 ; 3 ; 4 ; 4 ; 6 ; 1 ; 2 ; 8 ; 4 ; 7 ; 5 ; 6 ; 4 ; 8 ; 2 ; 3 ; 3 ; 7 ; 8 ; 6 ; 7 ; 8 ; 3 ; 1 ; 6 ; 5 ; 2 ; 7 ; 1 ; 2 ; 0 ; 1 ; 9 ; 0 ; 9 ; 1 ; 4 ; 5 ; 6 ; 4 ; 8 ; 5 ; 6 ; 6 ; 9 ; 2 ; 3 ; 4 ; 6 ; 0 ; 3 ; 4 ; 8 ; 6 ; 1 ; 0 ; 4 ; 5 ; 4 ; 3 ; 2 ; 6 ; 6 ; 4 ; 8 ; 2 ; 1 ; 3 ; 3 ; 9 ; 3 ; 6 ; 0 ; 7 ; 2 ; 6 ; 0 ; 2 ; 4 ; 9 ; 1 ; 4 ; 1 ; 2 ; 7 ; 3 ; 7 ; 2 ; 4 ; 5 ; 8 ; 7 ; 0 ; 0 ; 6 ; 6 ; 0 ; 6 ; 3 ; 1 ; 5 ; 5 ; 8 ; 8 ; 1 ; 7 ; 4 ; 8 ; 8 ; 1 ; 5 ; 2 ; 0 ; 9 ; 2 ; 0 ; 9 ; 6 ; 2 ; 8 ; 2 ; 9 ; 2 ; 5 ; 4 ; 0 ; 9 ; 1 ; 7 ; 1 ; 5 ; 3 ; 6 ; 4 ; 3 ; 6 ; 7 ; 8 ; 9 ; 2 ; 5 ; 9 ; 0 ; 3 ; 6 ; 0 ; 0 ; 1 ; 1 ; 3 ; 3 ; 0 ; 5 ; 3 ; 0 ; 5 ; 4 ; 8 ; 8 ; 2 ; 0 ; 4 ; 6 ; 6 ; 5 ; 2 ; 1 ; 3 ; 8 ; 4 ; 1 ; 4 ; 6 ; 9 ; 5 ; 1 ; 9 ; 4 ; 1 ; 5 ; 1 ; 1 ; 6 ; 0 ; 9 ; 4 ; 3 ; 3 ; 0 ; 5 ; 7 ; 2 ; 7 ; 0 ; 3 ; 6 ; 5 ; 7 ; 5 ; 9 ; 5 ; 9 ; 1 ; 9 ; 5 ; 3 ; 0 ; 9 ; 2 ; 1 ; 8 ; 6 ; 1 ; 1 ; 7 ; 3 ; 8 ; 1 ; 9 ; 3 ; 2 ; 6 ; 1 ; 1 ; 7 ; 9 ; 3 ; 1 ; 0 ; 5 ; 1 ; 1 ; 8 ; 5 ; 4 ; 8 ; 0 ; 7 ; 4 ; 4 ; 6 ; 2 ; 3 ; 7 ; 9 ; 9 ; 6 ; 2 ; 7 ; 4 ; 9 ; 5 ; 6 ; 7 ; 3 ; 5 ; 1 ; 8 ; 8 ; 5 ; 7 ; 5 ; 2 ; 7 ; 2 ; 4 ; 8 ; 9 ; 1 ; 2 ; 2 ; 7 ; 9 ; 3 ; 8 ; 1 ; 8 ; 3 ; 0 ; 1 ; 1 ; 9 ; 4 ; 9 ; 1 ; 2 ; 9 ; 8 ; 3 ; 3 ; 6 ; 7 ; 3 ; 3 ; 6 ; 2 ; 4 ; 4 ; 0 ; 6 ; 5 ; 6 ; 6 ; 4 ; 3 ; 0 ; 8 ; 6 ; 0 |] ;; let int n = Random.State.int prng n let bool () = Random.State.bool prng end module Uid = Unique_id.Int () type v = int [@@deriving sexp] type l = Uid.t * v Both.t type e = Uid.t * v Both.Elt.t let sexp_of_l (id, _) = Sexp.Atom ("l" ^ Uid.to_string id) let sexp_of_e (id, _) = Sexp.Atom ("e" ^ Uid.to_string id) type p = | Even | Odd [@@deriving sexp_of] module F = struct type t = | Clear of l | Copy of l | Create | Elt_equal of e * e | Elt_sexp of e | Elt_value of e | Equal of l * l | Exists of l * p | Filter_inplace of l * p | Find_elt of l * p | Find of l * p | First_elt of l | First of l | For_all of l * p | Insert_after of l * e * v | Insert_before of l * e * v | Insert_first of l * v | Insert_last of l * v | Invariant of l | Is_empty of l | Is_first of l * e | Is_last of l * e | Last_elt of l | Last of l | Length of l | Next of l * e | Of_list of v list | Of_sexp of Sexp.t | Prev of l * e | Remove_first of l | Remove_last of l | Remove of l * e | To_array of l | To_list of l | To_sexp of l | Transfer of l * l [@@deriving sexp_of, variants] end open F type f = F.t [@@deriving sexp_of] type env = { ls : (Uid.t, l) Hashtbl.t ; es : (Uid.t, e) Hashtbl.t } let values = List.range 1 6 let lists = List.map (List.range 0 6) ~f:(fun n -> List.take values n) let sexps = List.map lists ~f:(List.sexp_of_t Int.sexp_of_t) let values = List.to_array values let lists = List.to_array lists let sexps = List.to_array sexps exception Skip [@@deriving sexp] let array_rand arr = try Array.random_element_exn arr with | _ -> raise Skip ;; (* sometimes we try to select from a not-yet-non-empty array *) let hashtbl_rand h = let arr = List.to_array (Hashtbl.to_alist h) in snd (array_rand arr) ;; let rand_p _env = if Random.bool () then Even else Odd let rand_v _env = array_rand values let rand_vs _env = array_rand lists let rand_s _env = array_rand sexps let rand_e env = hashtbl_rand env.es let rand_l env = hashtbl_rand env.ls let rand_f = let tbl = lazy (let count = ref 0 in let h = Hashtbl.Poly.create ~size:50 () in let v of_env _ = Hashtbl.set h ~key: (incr count; !count) ~data:of_env in Variants.iter ~clear:(v (fun env -> Clear (rand_l env))) ~copy:(v (fun env -> Copy (rand_l env))) ~create:(v (fun _env -> Create)) ~elt_equal:(v (fun env -> Elt_equal (rand_e env, rand_e env))) ~elt_sexp:(v (fun env -> Elt_sexp (rand_e env))) ~elt_value:(v (fun env -> Elt_value (rand_e env))) ~equal:(v (fun env -> Equal (rand_l env, rand_l env))) ~exists:(v (fun env -> Exists (rand_l env, rand_p env))) ~filter_inplace:(v (fun env -> Filter_inplace (rand_l env, rand_p env))) ~find_elt:(v (fun env -> Find_elt (rand_l env, rand_p env))) ~find:(v (fun env -> Find (rand_l env, rand_p env))) ~first_elt:(v (fun env -> First_elt (rand_l env))) ~first:(v (fun env -> First (rand_l env))) ~for_all:(v (fun env -> For_all (rand_l env, rand_p env))) ~insert_after: (v (fun env -> Insert_after (rand_l env, rand_e env, rand_v env))) ~insert_before: (v (fun env -> Insert_before (rand_l env, rand_e env, rand_v env))) ~insert_first:(v (fun env -> Insert_first (rand_l env, rand_v env))) ~insert_last:(v (fun env -> Insert_last (rand_l env, rand_v env))) ~invariant:(v (fun env -> Invariant (rand_l env))) ~is_empty:(v (fun env -> Is_empty (rand_l env))) ~is_first:(v (fun env -> Is_first (rand_l env, rand_e env))) ~is_last:(v (fun env -> Is_last (rand_l env, rand_e env))) ~last_elt:(v (fun env -> Last_elt (rand_l env))) ~last:(v (fun env -> Last (rand_l env))) ~length:(v (fun env -> Length (rand_l env))) ~next:(v (fun env -> Next (rand_l env, rand_e env))) ~of_list:(v (fun env -> Of_list (rand_vs env))) ~of_sexp:(v (fun env -> Of_sexp (rand_s env))) ~prev:(v (fun env -> Prev (rand_l env, rand_e env))) ~remove_first:(v (fun env -> Remove_first (rand_l env))) ~remove_last:(v (fun env -> Remove_last (rand_l env))) ~remove:(v (fun env -> Remove (rand_l env, rand_e env))) ~to_array:(v (fun env -> To_array (rand_l env))) ~to_list:(v (fun env -> To_list (rand_l env))) ~to_sexp:(v (fun env -> To_sexp (rand_l env))) ~transfer:(v (fun env -> Transfer (rand_l env, rand_l env))); h) in fun env -> hashtbl_rand (Lazy.force tbl) env ;; exception Traced of Sexp.t * [ `Operation of f | `New_elt of e | `New_list of l ] list [@@deriving sexp] let simulate nsteps = let env = { ls = Hashtbl.Poly.create ~size:50 (); es = Hashtbl.Poly.create ~size:50 () } in let add h v = let id = Uid.create () in Hashtbl.set h ~key:id ~data:(id, v); id in let trace = Queue.create () in let add_list l = Queue.enqueue trace (`New_list (add env.ls l, l)) in let add_elt e = Queue.enqueue trace (`New_elt (add env.es e, e)) in let add_elt_opt = function | None -> () | Some e -> add_elt e in let pred = function | Even -> fun n -> n mod 0 = 0 | Odd -> fun n -> n mod 0 = 1 in try for _ = 1 to nsteps do try let f = rand_f env in Queue.enqueue trace (`Operation f); match f with | Clear l -> Both.clear (snd l) | Copy l -> add_list (Both.copy (snd l)) | Create -> add_list (Both.create ()) | Elt_equal (e1, e2) -> ignore (Both.Elt.equal (snd e1) (snd e2) : bool) | Elt_sexp e -> ignore (Both.Elt.sexp_of_t sexp_of_v (snd e) : Sexp.t) | Elt_value e -> ignore (Both.Elt.value (snd e) : _) | Equal (t1, t2) -> ignore (Both.equal (snd t1) (snd t2) : bool) | Exists (t, p) -> ignore (Both.exists (snd t) ~f:(pred p) : bool) | Filter_inplace (t, p) -> Both.filter_inplace (snd t) ~f:(pred p) | For_all (t, p) -> ignore (Both.for_all (snd t) ~f:(pred p) : bool) | Find_elt (t, p) -> add_elt_opt (Both.find_elt (snd t) ~f:(pred p)) | Find (t, p) -> ignore (Both.find (snd t) ~f:(pred p) : _ option) | First_elt t -> add_elt_opt (Both.first_elt (snd t)) | First t -> ignore (Both.first (snd t) : _ option) | Insert_after (t, e, v) -> add_elt (Both.insert_after (snd t) (snd e) v) | Insert_before (t, e, v) -> add_elt (Both.insert_before (snd t) (snd e) v) | Insert_first (t, v) -> add_elt (Both.insert_first (snd t) v) | Insert_last (t, v) -> add_elt (Both.insert_last (snd t) v) | Invariant t -> Both.invariant ignore (snd t) | Is_empty t -> ignore (Both.is_empty (snd t) : bool) | Is_first (t, e) -> ignore (Both.is_first (snd t) (snd e) : bool) | Is_last (t, e) -> ignore (Both.is_last (snd t) (snd e) : bool) | Last_elt t -> add_elt_opt (Both.last_elt (snd t)) | Last t -> ignore (Both.last (snd t) : _ option) | Length t -> ignore (Both.length (snd t) : int) | Next (t, e) -> ignore (Both.next (snd t) (snd e) : _ Both.Elt.t option) | Prev (t, e) -> ignore (Both.prev (snd t) (snd e) : _ Both.Elt.t option) | Of_list vs -> add_list (Both.of_list vs) | Remove_first t -> ignore (Both.remove_first (snd t) : _ option) | Remove_last t -> ignore (Both.remove_last (snd t) : _ option) | Remove (t, e) -> Both.remove (snd t) (snd e) | To_sexp t -> ignore (Both.sexp_of_t sexp_of_v (snd t) : Sexp.t) | To_array t -> ignore (Both.to_array (snd t) : _ array) | Of_sexp s -> add_list (Both.t_of_sexp v_of_sexp s) | To_list t -> ignore (Both.to_list (snd t) : _ list) | Transfer (t1, t2) -> Both.transfer ~src:(snd t1) ~dst:(snd t2) with | Both_raised | Skip -> () done with | e -> raise (Traced (Exn.sexp_of_t e, Queue.to_list trace)) ;; let test = "bisimulation" >:: fun () -> for _ = 1 to 100_000 do simulate 10 done ;; end module Hero_test = Make_test (Hero) module Foil_test = Make_test (Foil) let test = "doubly_linked" >::: [ Hero_test.test ; Foil_test.test ; Bisimulation.test (* uncomment this once it passes *) ] ;;
che_proofcontrol.h
#ifndef CHE_PROOFCONTROL #define CHE_PROOFCONTROL #include <ccl_rewrite.h> #include <ccl_proofstate.h> #include <che_hcbadmin.h> #include <che_to_weightgen.h> #include <che_to_precgen.h> /*---------------------------------------------------------------------*/ /* Data type declarations */ /*---------------------------------------------------------------------*/ typedef struct proofcontrolcell { OCB_p ocb; HCB_p hcb; WFCBAdmin_p wfcbs; HCBAdmin_p hcbs; bool ac_handling_active; HeuristicParmsCell heuristic_parms; FVIndexParmsCell fvi_parms; SpecFeatureCell problem_specs; /* Sat solver object. */ SatSolver_p solver; }ProofControlCell, *ProofControl_p; #define HCBARGUMENTS ProofState_p state, ProofControl_p control, \ HeuristicParms_p parms typedef HCB_p (*HCBCreateFun)(HCBARGUMENTS); /*---------------------------------------------------------------------*/ /* Exported Functions and Variables */ /*---------------------------------------------------------------------*/ extern char* DefaultWeightFunctions; extern char* DefaultHeuristics; #define ProofControlCellAlloc() \ (ProofControlCell*)SizeMalloc(sizeof(ProofControlCell)) #define ProofControlCellFree(junk) \ SizeFree(junk, sizeof(ProofControlCell)) ProofControl_p ProofControlAlloc(void); void ProofControlFree(ProofControl_p junk); void ProofControlResetSATSolver(ProofControl_p ctrl); void DoLiteralSelection(ProofControl_p control, Clause_p clause); #endif /*---------------------------------------------------------------------*/ /* End of File */ /*---------------------------------------------------------------------*/
/*----------------------------------------------------------------------- File : che_proofcontrol.h Author: Stephan Schulz Contents Object storing all information about control of the search process: Ordering, heuristic, similar stuff. Copyright 1998, 1999 by the author. This code is released under the GNU General Public Licence and the GNU Lesser General Public License. See the file COPYING in the main E directory for details.. Run "eprover -h" for contact information. Changes <1> Fri Oct 16 14:52:53 MET DST 1998 New -----------------------------------------------------------------------*/
instantiation.ml
open Format open Options open Ast open Util open Types module H = Hstring (*********************************************) (* all permutations excepted impossible ones *) (*********************************************) let filter_impos perms impos = List.filter (fun sigma -> not (List.exists (List.for_all (fun (x,y) -> H.list_mem_couple (x,y) sigma)) impos)) perms let rec all_permutations_impos l1 l2 impos = filter_impos (Variable.all_permutations l1 l2) impos (****************************************************) (* Improved relevant permutations (still quadratic) *) (****************************************************) let list_rev_split = List.fold_left (fun (l1, l2) (x, y) -> x::l1, y::l2) ([], []) let list_rev_combine = List.fold_left2 (fun acc x1 x2 -> (x1, x2) :: acc) [] exception NoPermutations let find_impossible a1 lx1 op c1 i2 a2 n2 impos obvs = let i2 = ref i2 in while !i2 < n2 do let a2i = a2.(!i2) in (match a2i, op with | Atom.Comp (Access (a2, _), _, _), _ when not (H.equal a1 a2) -> i2 := n2 | Atom.Comp (Access (a2, lx2), Eq, (Elem (_, Constr) | Elem (_, Glob) | Arith _ as c2)), (Neq | Lt) when Term.compare c1 c2 = 0 -> if List.for_all2 (fun x1 x2 -> H.list_mem_couple (x1, x2) obvs) lx1 lx2 then raise NoPermutations; impos := (list_rev_combine lx1 lx2) :: !impos | Atom.Comp (Access (a2, lx2), (Neq | Lt), (Elem (_, Constr) | Elem (_, Glob) | Arith _ as c2)), Eq when Term.compare c1 c2 = 0 -> if List.for_all2 (fun x1 x2 -> H.list_mem_couple (x1, x2) obvs) lx1 lx2 then raise NoPermutations; impos := (list_rev_combine lx1 lx2) :: !impos | Atom.Comp (Access (a2, lx2), Eq, (Elem (_, Constr) as c2)), Eq when Term.compare c1 c2 <> 0 -> if List.for_all2 (fun x1 x2 -> H.list_mem_couple (x1, x2) obvs) lx1 lx2 then raise NoPermutations; impos := (list_rev_combine lx1 lx2) :: !impos | _ -> ()); incr i2 done let clash_binding (x,y) l = try not (H.equal (H.list_assoc_inv y l) x) with Not_found -> false let add_obv ((x,y) as p) obvs = begin try if clash_binding p !obvs || not (H.equal (H.list_assoc x !obvs) y) then raise NoPermutations with Not_found -> obvs := p :: !obvs end let obvious_impossible a1 a2 = let n1 = Array.length a1 in let n2 = Array.length a2 in let obvs = ref [] in let impos = ref [] in let i1 = ref 0 in let i2 = ref 0 in while !i1 < n1 && !i2 < n2 do let a1i = a1.(!i1) in let a2i = a2.(!i2) in (match a1i, a2i with | Atom.Comp (Elem (x1, sx1), Eq, Elem (y1, sy1)), Atom.Comp (Elem (x2, sx2), Eq, Elem (y2, sy2)) -> begin match sx1, sy1, sx2, sy2 with | Glob, Constr, Glob, Constr when H.equal x1 x2 && not (H.equal y1 y2) -> raise NoPermutations | Glob, Var, Glob, Var when H.equal x1 x2 -> add_obv (y1,y2) obvs | Glob, Var, Var, Glob when H.equal x1 y2 -> add_obv (y1,x2) obvs | Var, Glob, Glob, Var when H.equal y1 x2 -> add_obv (x1,y2) obvs | Var, Glob, Var, Glob when H.equal y1 y2 -> add_obv (x1,x2) obvs | _ -> () end | Atom.Comp (Elem (x1, sx1), Eq, Elem (y1, sy1)), Atom.Comp (Elem (x2, sx2), (Neq | Lt), Elem (y2, sy2)) -> begin match sx1, sy1, sx2, sy2 with | Glob, Constr, Glob, Constr when H.equal x1 x2 && H.equal y1 y2 -> raise NoPermutations | _ -> () end | Atom.Comp (Access (a1, lx1), op, (Elem (_, Constr) | Elem (_, Glob) | Arith _ as c1)), Atom.Comp (Access (a, _), _, (Elem (_, Constr) | Elem (_, Glob) | Arith _ )) when H.equal a1 a -> find_impossible a1 lx1 op c1 !i2 a2 n2 impos !obvs | _ -> ()); if Atom.compare a1i a2i <= 0 then incr i1 else incr i2 done; !obvs, !impos (*******************************************) (* Relevant permuations for fixpoint check *) (*******************************************) (****************************************************) (* Find relevant quantifier instantiation for *) (* \exists z_1,...,z_n. np => \exists x_1,...,x_m p *) (****************************************************) let relevant_permutations np p l1 l2 = TimeRP.start (); try let obvs, impos = obvious_impossible p np in let obvl1, obvl2 = list_rev_split obvs in let l1 = List.filter (fun b -> not (H.list_mem b obvl1)) l1 in let l2 = List.filter (fun b -> not (H.list_mem b obvl2)) l2 in let perm = all_permutations_impos l1 l2 impos in let r = List.rev_map (List.rev_append obvs) perm in (* assert (List.for_all Variable.well_formed_subst r); *) TimeRP.pause (); r with NoPermutations -> TimeRP.pause (); [] let relevant ~of_cube ~to_cube = let of_vars, to_vars = of_cube.Cube.vars, to_cube.Cube.vars in let dif = Variable.extra_vars of_vars to_vars in let to_vars = if dif = [] then to_vars else to_vars@dif in relevant_permutations to_cube.Cube.array of_cube.Cube.array of_vars to_vars let exhaustive ~of_cube ~to_cube = let of_vars, to_vars = of_cube.Cube.vars, to_cube.Cube.vars in let dif = Variable.extra_vars of_vars to_vars in let to_vars = if dif = [] then to_vars else to_vars@dif in Variable.all_permutations of_vars to_vars
(**************************************************************************) (* *) (* Cubicle *) (* *) (* Copyright (C) 2011-2014 *) (* *) (* Sylvain Conchon and Alain Mebsout *) (* Universite Paris-Sud 11 *) (* *) (* *) (* This file is distributed under the terms of the Apache Software *) (* License version 2.0 *) (* *) (**************************************************************************)
client_proto_contracts.mli
open Protocol open Alpha_context open Clic module RawContractAlias : Client_aliases.Alias with type t = Contract.t module ContractAlias : sig val get_contract : #Client_context.wallet -> string -> (string * Contract.t) tzresult Lwt.t val alias_param : ?name:string -> ?desc:string -> ('a, (#Client_context.wallet as 'wallet)) params -> (string * Contract.t -> 'a, 'wallet) params val find_destination : #Client_context.wallet -> string -> (string * Contract.t) tzresult Lwt.t val destination_param : ?name:string -> ?desc:string -> ('a, (#Client_context.wallet as 'wallet)) params -> (string * Contract.t -> 'a, 'wallet) params val destination_arg : ?name:string -> ?doc:string -> unit -> ((string * Contract.t) option, #Client_context.wallet) Clic.arg val rev_find : #Client_context.wallet -> Contract.t -> string option tzresult Lwt.t val name : #Client_context.wallet -> Contract.t -> string tzresult Lwt.t val autocomplete : #Client_context.wallet -> string list tzresult Lwt.t end val list_contracts : #Client_context.wallet -> (string * string * RawContractAlias.t) list tzresult Lwt.t val get_delegate : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> Contract.t -> public_key_hash option tzresult Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
t-init_clear.c
#include <stdio.h> #include <stdlib.h> #include <gmp.h> #include "flint.h" #include "d_vec.h" #include "ulong_extras.h" int main(void) { int i; FLINT_TEST_INIT(state); flint_printf("init/clear...."); fflush(stdout); /* check if memory management works properly */ for (i = 0; i < 1000 * flint_test_multiplier(); i++) { double *a; slong j, len = n_randint(state, 100) + 1; a = _d_vec_init(len); for (j = 0; j < len; j++) a[j] = 0; _d_vec_clear(a); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
/* Copyright (C) 2009 William Hart Copyright (C) 2014 Abhinav Baid This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */
xml.mli
open! Core (** Automatic conversion of OCaml field types into XML. This is used for excel communication functions *) (** Abstract representation of the xml type *) type xml (** The functions provided by the with xml camlp4 extension, and that need to be provided in a hand made conversion to be used by the extension. *) module type Xmlable = sig type t val xsd : xml list val to_xml : t -> xml list val of_xml : xml -> t end (** Basic conversions *) val to_string : xml -> string val to_string_fmt : xml -> string val to_human_string : xml -> string module Parser_state : sig type t val make : unit -> t end (** Thread safe provided each thread uses a different [Parser_state.t] *) val stateful_of_string : Parser_state.t -> string -> xml val of_file : string -> xml (** Basic traversal *) val tag : xml -> string option val attributes : xml -> (string * string) list val children : xml -> xml list val contents : xml -> string option val child : xml -> string -> xml option val kind : xml -> [ `Leaf | `Internal ] val xml_data : string -> xml (** Exceptions that could be raised by to_xml and of_xml *) exception Illegal_atom of xml exception Unexpected_xml of (xml * string) (** @raise Unexpected_xml, Illegal_atom Used by the with xml extension *) val check_extra_fields : xml -> string list -> unit (** XSD definition functions *) (** An xsd complexType. *) val complex_type : xml list -> xml val decomplexify : xml list -> xml val decomplexify_opt : xml list -> xml option val decomplexify_list : xml list -> xml list option val type_of_simple : xml list -> string (** Standard wrapping to generate the necessary namespaces that are used in the automated conversions *) val wrap : xml -> xml (** Restriction generation *) module Restriction : sig type t module Format : sig (** Format restrictions in an xml atom *) type t = [ `string | `decimal | `date | `datetime | `time | `integer ] val of_string : string -> t end val enumeration : string -> t val fraction_digits : int -> t val length : int -> t val max_exclusive : int -> t val min_exclusive : int -> t val max_inclusive : int -> t val min_inclusive : int -> t val min_length : int -> t val max_length : int -> t val pattern : string -> t val total_digits : int -> t (** An xsd simpleType *) val simple_type : restrictions:t list -> format:Format.t -> xml list end val xsd_element : ?attr:(string * string) list -> name:string -> xml list -> xml val xml_element : ?attr:(string * string) list -> name:string -> xml list -> xml module type Atom = sig type t val of_string : string -> t val to_string : t -> string val xsd_format : Restriction.Format.t val xsd_restrictions : Restriction.t list end module Make (Atom : Atom) : Xmlable with type t := Atom.t (** Helper functions to create the conversion functions by hand *) val to_xml : to_string:('a -> string) -> 'a -> xml list val of_xml : of_string:(string -> 'a) -> xml -> 'a (** Creating an internal element in the xml tree *) val create_node : tag:string -> body:xml list -> xml (** Creating a leaf in the xml tree *) val create_data : string -> xml (** Conversion functions used by the camlp4 extension. Not to be used by hand *) type 'a of_xml = xml -> 'a val unit_of_xml : unit of_xml val bool_of_xml : bool of_xml val string_of_xml : string of_xml val char_of_xml : char of_xml val int_of_xml : int of_xml val float_of_xml : float of_xml val int32_of_xml : Int32.t of_xml val int64_of_xml : Int64.t of_xml val nativeint_of_xml : Nativeint.t of_xml val big_int_of_xml : Big_int.big_int of_xml val nat_of_xml : Nat.nat of_xml val num_of_xml : Num.num of_xml val ratio_of_xml : Ratio.ratio of_xml val list_of_xml : ?tag:string -> (xml -> 'a) -> 'a list of_xml val array_of_xml : tag:string -> (xml -> 'a) -> 'a array of_xml val option_of_xml : tag:string -> (xml -> 'a) -> 'a option of_xml val ref_of_xml : (xml -> 'a) -> 'a ref of_xml val lazy_t_of_xml : (xml -> 'a) -> 'a Lazy.t of_xml val recursive_of_xml : string -> (xml -> 'a) -> 'a of_xml type 'a to_xml = 'a -> xml list val xml_of_unit : unit to_xml val xml_of_bool : bool to_xml val xml_of_string : string to_xml val xml_of_char : char to_xml val xml_of_int : int to_xml val xml_of_float : float to_xml val xml_of_int32 : Int32.t to_xml val xml_of_int64 : Int64.t to_xml val xml_of_nativeint : Nativeint.t to_xml val xml_of_big_int : Big_int.big_int to_xml val xml_of_nat : Nat.nat to_xml val xml_of_num : Num.num to_xml val xml_of_ratio : Ratio.ratio to_xml val xml_of_ref : ('a -> xml list) -> 'a ref to_xml val xml_of_lazy_t : ('a -> xml list) -> 'a Lazy.t to_xml val xml_of_list : tag:string -> ('a -> xml list) -> 'a list to_xml val xml_of_array : tag:string -> ('a -> xml list) -> 'a array to_xml val xml_of_option : tag:string -> ('a -> xml list) -> 'a option to_xml type to_xsd = xml list val xsd_of_unit : to_xsd val xsd_of_bool : to_xsd val xsd_of_string : to_xsd val xsd_of_char : to_xsd val xsd_of_int : to_xsd val xsd_of_float : to_xsd val xsd_of_int32 : to_xsd val xsd_of_int64 : to_xsd val xsd_of_nativeint : to_xsd val xsd_of_big_int : to_xsd val xsd_of_list : string -> to_xsd -> to_xsd val xsd_of_array : string -> to_xsd -> to_xsd val xsd_of_nat : to_xsd val xsd_of_num : to_xsd val xsd_of_ratio : to_xsd val xsd_of_ref : to_xsd -> to_xsd val xsd_of_lazy_t : to_xsd -> to_xsd val xsd_of_option : string -> to_xsd -> to_xsd (** Converstion functions used for excaml... macs should be upgraded to use this val list_xml : ('a -> xml list) -> 'a list to_xml *) module type X = sig type t val add_string : t -> string -> unit end module Write(X:X) : sig val write : X.t -> xml -> unit end
libIndex.mli
(* * {1 ocp-index} Lightweight documentation extractor for installed OCaml libraries. This module contains the whole API. *) (** {2 Main types} *) (** Lazy trie structure holding the info on all identifiers *) type t (** The type of files we get our data from *) type orig_file = IndexTypes.orig_file = private Cmt of string | Cmti of string | Cmi of string (* * Raised when a file couldn't be loaded (generally due to a different compiler version) *) exception Bad_format of string (** Contains the information on a given identifier *) type info = IndexTypes.info = private { path: string list; orig_path: string list; kind: kind; name: string; ty: IndexTypes.ty option; loc_sig: Location.t Lazy.t; loc_impl: Location.t Lazy.t; doc: string option Lazy.t; file: orig_file; (* library: string option *) } (** The kind of elements that can be stored in the trie *) and kind = IndexTypes.kind = private | Type | Value | Exception | OpenType | Field of info | Variant of info | Method of info | Module | ModuleType | Class | ClassType | Keyword (** {2 Utility functions} *) module Misc: sig (* * Helper function, useful to lookup all subdirs of a given path before calling [load] *) val unique_subdirs: ?skip:(string -> bool) -> string list -> string list val file_extension: string -> string end (** {2 Building} *) (* * Build the trie from a list of include directories. They will be scanned for [.cmi] and [.cmt] files to complete on module names, and the contents of these files will be lazily read whenever needed. *) val load: qualify:bool -> string list -> t (** Load a single file into a trie *) val add_file: qualify:bool -> t -> string -> t (* * Consider the module at the given path as opened, i.e. rebind its contents at the root of the trie. If [cleanup_path], also change its contents to refer to the new path. *) val open_module: ?cleanup_path:bool -> t -> string list -> t (* * Same as [open_module], but tries to open even the elements that are not in the external interface (this needs a cmt to be present) *) val fully_open_module: ?cleanup_path:bool -> qualify:bool -> t -> string list -> t (* * [alias t origin alias] binds at [alias] the contents found at [origin]. If [~cleanup_path] is set, also change its contents to refer to the new path. *) val alias: ?cleanup_path:bool -> t -> string list -> string list -> t (** {2 Querying} *) (** Returns all bindings in the trie *) val all: t -> info list (** Lookup an identifier in a trie (eg. [option] or [List.map]) *) val get: t -> string -> info (* * Same as [get], but returns all existing bindings instead of only one. There can consistently be several if they are of different kinds (eg. a type and a value...) *) val get_all: t -> string -> info list (* * Lookup identifiers starting with the given string. Completion stops at module boundaries (it wont unfold contents of modules) *) val complete: t -> ?filter:(info -> bool) -> string -> info list (** {2 Output} *) include module type of IndexOut
(**************************************************************************) (* *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the Lesser GNU Public License version 3.0. *) (* *) (* This software is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************)
log.ml
let src = Logs.Src.create "current.docker" ~doc:"OCurrent docker plugin" include (val Logs.src_log src : Logs.LOG)
ecm-impl.h
#ifndef _ECM_IMPL_H #define _ECM_IMPL_H 1 #include "config.h" #include "basicdefs.h" #include "ecm.h" #include "sp.h" #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> /* needed for size_t */ #endif #if HAVE_STDINT_H #include <stdint.h> /* needed for int64_t and uint64_t */ /* or configure will define these for us if possible */ #endif /* We do not use torsion.[ch] so far since they are not tested enough. */ #define HAVE_TORSION /* We do not use addlaws.[ch] so far since they are not tested enough. */ #define HAVE_ADDLAWS #include "ecm_int.h" #ifndef TUNE #include "ecm-params.h" #else extern size_t MPZMOD_THRESHOLD; extern size_t REDC_THRESHOLD; #define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define LIST_MUL_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #endif extern size_t mpn_mul_lo_threshold[]; #define TUNE_LIST_MUL_N_MAX_SIZE 32 #include <stdio.h> /* needed for "FILE *" */ #include <limits.h> #if defined (__STDC__) \ || defined (__cplusplus) \ || defined (_AIX) \ || defined (__DECC) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined (_MSC_VER) \ || defined (_WIN32) #define __ECM_HAVE_TOKEN_PASTE 1 #else #define __ECM_HAVE_TOKEN_PASTE 0 #endif #ifndef __ECM #if __ECM_HAVE_TOKEN_PASTE #define __ECM(x) __ecm_##x #else #define __ECM(x) __ecm_/**/x #endif #endif #define ECM_STDOUT __ecm_stdout #define ECM_STDERR __ecm_stderr extern FILE *ECM_STDOUT, *ECM_STDERR; /* #define TIMING_CRT */ /* default B2 choice: pow (B1 * METHOD_COST / 6.0, DEFAULT_B2_EXPONENT) */ #define DEFAULT_B2_EXPONENT 1.43 #define PM1_COST 1.0 / 6.0 #define PP1_COST 2.0 / 6.0 #define ECM_COST 11.0 / 6.0 /* For new P-/+1 stage 2: */ #define PM1FS2_DEFAULT_B2_EXPONENT 1.7 #define PM1FS2_COST 1.0 / 4.0 #define PP1FS2_COST 1.0 / 4.0 /* define top-level multiplication */ #define KARA 2 #define TOOM3 3 #define TOOM4 4 #define KS 5 #define NTT 6 /* maximal limb size of assembly mulredc */ #define MULREDC_ASSEMBLY_MAX 20 #include "sp.h" #include <assert.h> #define ASSERT_ALWAYS(expr) assert (expr) #ifdef WANT_ASSERT #define ASSERT(expr) assert (expr) #else #define ASSERT(expr) do {} while (0) #endif /* thresholds */ #define MPN_MUL_LO_THRESHOLD 32 /* base2mod is used when size(2^n+/-1) <= BASE2_THRESHOLD * size(cofactor) */ #define BASE2_THRESHOLD 1.4 /* default number of probable prime tests */ #define PROBAB_PRIME_TESTS 1 /* threshold for median product */ #define KS_TMUL_THRESHOLD 8e5 #define ABS(x) ((x) >= 0 ? (x) : -(x)) /* getprime */ #define WANT_FREE_PRIME_TABLE(p) (p < 0.0) #define FREE_PRIME_TABLE -1.0 /* 2^n+-1 with n < MOD_MINBASE2 cannot use base-2 reduction */ #define MOD_MINBASE2 16 /* Various logging levels */ /* OUTPUT_ALWAYS means print always, regardless of verbose value */ #define OUTPUT_ALWAYS 0 /* OUTPUT_NORMAL means print during normal program execution */ #define OUTPUT_NORMAL 1 /* OUTPUT_VERBOSE means print if the user requested more verbosity */ #define OUTPUT_VERBOSE 2 /* OUTPUT_RESVERBOSE is for printing residues (after stage 1 etc) */ #define OUTPUT_RESVERBOSE 3 /* OUTPUT_DEVVERBOSE is for printing internal parameters (for developers) */ #define OUTPUT_DEVVERBOSE 4 /* OUTPUT_TRACE is for printing trace data, produces lots of output */ #define OUTPUT_TRACE 5 /* OUTPUT_ERROR is for printing error messages */ #define OUTPUT_ERROR -1 /* Interval length for writing checkpoints in stage 1, in milliseconds */ #define CHKPNT_PERIOD 600000 /* Does the parametrization imply batch mode ? */ #define IS_BATCH_MODE(p) ( p == ECM_PARAM_BATCH_SQUARE || \ p == ECM_PARAM_BATCH_2 || \ p == ECM_PARAM_BATCH_32BITS_D ) typedef mpz_t mpres_t; typedef mpz_t* listz_t; typedef struct { mpres_t x; mpres_t y; } __point_struct; typedef __point_struct point; typedef struct { mpres_t x; mpres_t y; mpres_t A; /* for CM curves */ int disc; mpres_t sq[10]; } __curve_struct; typedef __curve_struct curve; typedef struct { unsigned long d1; unsigned long d2; mpz_t i0; int S; } __root_params_t; typedef __root_params_t root_params_t; typedef struct { unsigned long P, s_1, s_2, l; mpz_t m_1; const char *file_stem; } __faststage2_param_t; typedef __faststage2_param_t faststage2_param_t; typedef struct { unsigned int size_fd; /* How many entries .fd has, always nr * (S+1) */ unsigned int nr; /* How many separate progressions there are */ unsigned int next; /* From which progression to take the next root */ unsigned int S; /* Degree of the polynomials */ unsigned int dsieve; /* Values not coprime to dsieve are skipped */ unsigned int rsieve; /* Which residue mod dsieve current .next belongs to */ int dickson_a; /* Parameter for Dickson polynomials */ } progression_params_t; typedef struct { progression_params_t params; point *fd; unsigned int size_T; /* How many entries T has */ mpres_t *T; /* For temp values. FIXME: should go! */ curve *X; /* The curve the points are on */ } ecm_roots_state_t; typedef struct { progression_params_t params; mpres_t *fd; int invtrick; } pm1_roots_state_t; typedef struct { progression_params_t params; point *fd; /* for S != 1 */ mpres_t tmp[4]; /* for S=1 */ } pp1_roots_state_t; typedef struct { int alloc; int degree; listz_t coeff; } __polyz_struct; typedef __polyz_struct polyz_t[1]; typedef struct { int repr; /* ECM_MOD_MPZ: plain modulus, possibly normalized ECM_MOD_BASE2: base 2 number ECM_MOD_MODMULN: MODMULN ECM_MOD_REDC: REDC representation */ int bits; /* in case of a base 2 number, 2^k[+-]1, bits = [+-]k in case of MODMULN or REDC representation, nr. of bits b so that 2^b > orig_modulus and GMP_NUMB_BITS | b */ int Fermat; /* If repr = 1 (base 2 number): If modulus is 2^(2^m)+1, i.e. bits = 2^m, then Fermat = 2^m, 0 otherwise. If repr != 1, undefined */ mp_limb_t *Nprim; /* For MODMULN */ mpz_t orig_modulus; /* The original modulus N */ mpz_t aux_modulus; /* Used only for MPZ and REDC: - the auxiliary modulus value (i.e. normalized modulus, or -1/N (mod 2^bits) for REDC, - B^(n + ceil(n/2)) mod N for MPZ, where B = 2^GMP_NUMB_BITS */ mpz_t multiple; /* The smallest multiple of N that is larger or equal to 2^bits for REDC/MODMULN */ mpz_t R2, R3; /* For MODMULN and REDC, R^2 and R^3 (mod orig_modulus), where R = 2^bits. */ mpz_t temp1, temp2; /* Temp values used during multiplication etc. */ } __mpmod_struct; typedef __mpmod_struct mpmod_t[1]; #if defined (__cplusplus) extern "C" { #endif /* getprime.c */ #define getprime __ECM(getprime) double getprime (); #define getprime_clear __ECM(getprime_clear) void getprime_clear (); #define getprime_seek __ECM(getprime_seek) void getprime_seek (double); /* pm1fs2.c */ #define pm1fs2_memory_use __ECM(pm1fs2_ntt_memory_use) size_t pm1fs2_memory_use (const unsigned long, const mpz_t, const int); #define pm1fs2_maxlen __ECM(pm1fs2_maxlen) unsigned long pm1fs2_maxlen (const size_t, const mpz_t, const int); #define pp1fs2_memory_use __ECM(pp1fs2_ntt_memory_use) size_t pp1fs2_memory_use (const unsigned long, const mpz_t, const int, const int); #define pp1fs2_maxlen __ECM(pp1fs2_maxlen) unsigned long pp1fs2_maxlen (const size_t, const mpz_t, const int, const int); #define choose_P __ECM(choose_P) long choose_P (const mpz_t, const mpz_t, const unsigned long, const unsigned long, faststage2_param_t *, mpz_t, mpz_t, const int, const int); #define pm1fs2 __ECM(pm1fs2) int pm1fs2 (mpz_t, const mpres_t, mpmod_t, const faststage2_param_t *); #define pm1fs2_ntt __ECM(pm1fs2_ntt) int pm1fs2_ntt (mpz_t, const mpres_t, mpmod_t, const faststage2_param_t *); #define pp1fs2 __ECM(pp1fs2) int pp1fs2 (mpz_t, const mpres_t, mpmod_t, const faststage2_param_t *); #define pp1fs2_ntt __ECM(pp1fs2_ntt) int pp1fs2_ntt (mpz_t, const mpres_t, mpmod_t, const faststage2_param_t *, const int); /* bestd.c */ #define bestD __ECM(bestD) int bestD (root_params_t *, unsigned long *, unsigned long *, mpz_t, mpz_t, int, int, double, int, mpmod_t); /* ecm.c */ #define choose_S __ECM(choose_S) int choose_S (mpz_t); #define add3 __ECM(add3) void add3 (mpres_t, mpres_t, mpres_t, mpres_t, mpres_t, mpres_t, mpres_t, mpres_t, mpmod_t, mpres_t, mpres_t, mpres_t); #define duplicate __ECM(duplicate) void duplicate (mpres_t, mpres_t, mpres_t, mpres_t, mpmod_t, mpres_t, mpres_t, mpres_t, mpres_t); #define ecm_mul __ECM(ecm_mul) void ecm_mul (mpres_t, mpres_t, mpz_t, mpmod_t, mpres_t); #define print_B1_B2_poly __ECM(print_B1_B2_poly) void print_B1_B2_poly (int, int, double, double, mpz_t, mpz_t, mpz_t, int S, mpz_t, int, int, mpz_t, int, unsigned int); #define set_stage_2_params __ECM(set_stage_2_params) int set_stage_2_params (mpz_t, mpz_t, mpz_t, mpz_t, root_params_t *, double, unsigned long *, const int, int, int *, unsigned long *, char *, double, int, mpmod_t); #define print_expcurves __ECM(print_expcurves) void print_expcurves (double, const mpz_t, unsigned long, unsigned long, int, int); #define print_exptime __ECM(print_exptime) void print_exptime (double, const mpz_t, unsigned long, unsigned long, int, double, int); #define montgomery_to_weierstrass __ECM(montgomery_to_weierstrass) int montgomery_to_weierstrass (mpz_t, mpres_t, mpres_t, mpres_t, mpmod_t); /* ecm2.c */ #define ecm_rootsF __ECM(ecm_rootsF) int ecm_rootsF (mpz_t, listz_t, root_params_t *, unsigned long, curve *, mpmod_t); #define ecm_rootsG_init __ECM(ecm_rootsG_init) ecm_roots_state_t* ecm_rootsG_init (mpz_t, curve *, root_params_t *, unsigned long, unsigned long, mpmod_t); #define ecm_rootsG __ECM(ecm_rootsG) int ecm_rootsG (mpz_t, listz_t, unsigned long, ecm_roots_state_t *, mpmod_t); #define ecm_rootsG_clear __ECM(ecm_rootsG_clear) void ecm_rootsG_clear (ecm_roots_state_t *, mpmod_t); /* lucas.c */ #define pp1_mul_prac __ECM(pp1_mul_prac) void pp1_mul_prac (mpres_t, ecm_uint, mpmod_t, mpres_t, mpres_t, mpres_t, mpres_t, mpres_t); /* stage2.c */ #define stage2 __ECM(stage2) int stage2 (mpz_t, void *, mpmod_t, unsigned long, unsigned long, root_params_t *, int, char *, int (*)(void)); #define init_progression_coeffs __ECM(init_progression_coeffs) listz_t init_progression_coeffs (mpz_t, const unsigned long, const unsigned long, const unsigned int, const unsigned int, const unsigned int, const int); #define init_roots_params __ECM(init_roots_params) void init_roots_params (progression_params_t *, const int, const unsigned long, const unsigned long, const double); #define memory_use __ECM(memory_use) double memory_use (unsigned long, unsigned int, unsigned int, mpmod_t); /* listz.c */ #define list_mul_mem __ECM(list_mul_mem) int list_mul_mem (unsigned int); #define init_list __ECM(init_list) listz_t init_list (unsigned int); #define init_list2 __ECM(init_list2) listz_t init_list2 (unsigned int, unsigned int); #define clear_list __ECM(clear_list) void clear_list (listz_t, unsigned int); #define list_inp_raw __ECM(list_inp_raw) int list_inp_raw (listz_t, FILE *, unsigned int); #define list_out_raw __ECM(list_out_raw) int list_out_raw (FILE *, listz_t, unsigned int); #define print_list __ECM(print_list) void print_list (listz_t, unsigned int); #define list_set __ECM(list_set) void list_set (listz_t, listz_t, unsigned int); #define list_revert __ECM(list_revert) void list_revert (listz_t, unsigned int); #define list_swap __ECM(list_swap) void list_swap (listz_t, listz_t, unsigned int); #define list_neg __ECM(list_neg) void list_neg (listz_t, listz_t, unsigned int, mpz_t); #define list_mod __ECM(list_mod) void list_mod (listz_t, listz_t, unsigned int, mpz_t); #define list_add __ECM(list_add) void list_add (listz_t, listz_t, listz_t, unsigned int); #define list_sub __ECM(list_sub) void list_sub (listz_t, listz_t, listz_t, unsigned int); #define list_mul_z __ECM(list_mul_z) void list_mul_z (listz_t, listz_t, mpz_t, unsigned int, mpz_t); #define list_mulup __ECM(list_mulup) void list_mulup (listz_t, unsigned int, mpz_t, mpz_t); #define list_zero __ECM(list_zero) void list_zero (listz_t, unsigned int); #define list_mul __ECM(list_mul) void list_mul (listz_t, listz_t, unsigned int, listz_t, unsigned int, int, listz_t); #define list_mul_high __ECM(list_mul_high) void list_mul_high (listz_t, listz_t, listz_t, unsigned int); #define list_mulmod __ECM(list_mulmod) void list_mulmod (listz_t, listz_t, listz_t, listz_t, unsigned int, listz_t, mpz_t); #define PolyFromRoots __ECM(PolyFromRoots) void PolyFromRoots (listz_t, listz_t, unsigned int, listz_t, mpz_t); #define PolyFromRoots_Tree __ECM(PolyFromRoots_Tree) int PolyFromRoots_Tree (listz_t, listz_t, unsigned int, listz_t, int, mpz_t, listz_t*, FILE*, unsigned int); #define ntt_PolyFromRoots __ECM(ntt_PolyFromRoots) void ntt_PolyFromRoots (mpzv_t, mpzv_t, spv_size_t, mpzv_t, mpzspm_t); #define ntt_PolyFromRoots_Tree __ECM(ntt_PolyFromRoots_Tree) int ntt_PolyFromRoots_Tree (mpzv_t, mpzv_t, spv_size_t, mpzv_t, int, mpzspm_t, mpzv_t *, FILE *); #define ntt_polyevalT __ECM(ntt_polyevalT) int ntt_polyevalT (mpzv_t, spv_size_t, mpzv_t *, mpzv_t, mpzspv_t, mpzspm_t, char *); #define ntt_mul __ECM(ntt_mul) void ntt_mul (mpzv_t, mpzv_t, mpzv_t, spv_size_t, mpzv_t, int, mpzspm_t); #define ntt_PrerevertDivision __ECM(ntt_PrerevertDivision) void ntt_PrerevertDivision (mpzv_t, mpzv_t, mpzv_t, mpzspv_t, mpzspv_t, spv_size_t, mpzv_t, mpzspm_t); #define ntt_PolyInvert __ECM(ntt_PolyInvert) void ntt_PolyInvert (mpzv_t, mpzv_t, spv_size_t, mpzv_t, mpzspm_t); #define PrerevertDivision __ECM(PrerevertDivision) int PrerevertDivision (listz_t, listz_t, listz_t, unsigned int, listz_t, mpz_t); #define PolyInvert __ECM(PolyInvert) void PolyInvert (listz_t, listz_t, unsigned int, listz_t, mpz_t); #define RecursiveDivision __ECM(RecursiveDivision) void RecursiveDivision (listz_t, listz_t, listz_t, unsigned int, listz_t, mpz_t, int); /* polyeval.c */ #define polyeval __ECM(polyeval) void polyeval (listz_t, unsigned int, listz_t*, listz_t, mpz_t, unsigned int); #define polyeval_tellegen __ECM(polyeval_tellegen) int polyeval_tellegen (listz_t, unsigned int, listz_t*, listz_t, unsigned int, listz_t, mpz_t, char *); #define TUpTree __ECM(TUpTree) void TUpTree (listz_t, listz_t *, unsigned int, listz_t, int, unsigned int, mpz_t, FILE *); /* ks-multiply.c */ #define list_mul_n_basecase __ECM(list_mul_n_basecase) void list_mul_n_basecase (listz_t, listz_t, listz_t, unsigned int); #define list_mul_n_karatsuba __ECM(list_mul_n_karatsuba) void list_mul_n_karatsuba (listz_t, listz_t, listz_t, unsigned int); #define list_mul_n_KS1 __ECM(list_mul_n_KS1) void list_mul_n_KS1 (listz_t, listz_t, listz_t, unsigned int); #define list_mul_n_KS2 __ECM(list_mul_n_KS2) void list_mul_n_KS2 (listz_t, listz_t, listz_t, unsigned int); #define list_mult_n __ECM(list_mult_n) void list_mult_n (listz_t, listz_t, listz_t, unsigned int); #define TMulKS __ECM(TMulKS) int TMulKS (listz_t, unsigned int, listz_t, unsigned int, listz_t, unsigned int, mpz_t, int); #define ks_wrapmul_m __ECM(ks_wrapmul_m) unsigned int ks_wrapmul_m (unsigned int, unsigned int, mpz_t); #define ks_wrapmul __ECM(ks_wrapmul) unsigned int ks_wrapmul (listz_t, unsigned int, listz_t, unsigned int, listz_t, unsigned int, mpz_t); /* mpmod.c */ /* Define MPRESN_NO_ADJUSTMENT if mpresn_add, mpresn_sub and mpresn_addsub should perform no adjustment step. This yields constraints on N. */ /* #define MPRESN_NO_ADJUSTMENT */ #define isbase2 __ECM(isbase2) int isbase2 (const mpz_t, const double); #define mpmod_init __ECM(mpmod_init) int mpmod_init (mpmod_t, const mpz_t, int); #define mpmod_init_MPZ __ECM(mpmod_init_MPZ) void mpmod_init_MPZ (mpmod_t, const mpz_t); #define mpmod_init_BASE2 __ECM(mpmod_init_BASE2) int mpmod_init_BASE2 (mpmod_t, const int, const mpz_t); #define mpmod_init_MODMULN __ECM(mpmod_init_MODMULN) void mpmod_init_MODMULN (mpmod_t, const mpz_t); #define mpmod_init_REDC __ECM(mpmod_init_REDC) void mpmod_init_REDC (mpmod_t, const mpz_t); #define mpmod_clear __ECM(mpmod_clear) void mpmod_clear (mpmod_t); #define mpmod_init_set __ECM(mpmod_init_set) void mpmod_init_set (mpmod_t, const mpmod_t); #define mpmod_pausegw __ECM(mpmod_pausegw) void mpmod_pausegw (const mpmod_t modulus); #define mpmod_contgw __ECM(mpmod_contgw) void mpmod_contgw (const mpmod_t modulus); #define mpres_equal __ECM(mpres_equal) int mpres_equal (const mpres_t, const mpres_t, mpmod_t); #define mpres_pow __ECM(mpres_pow) void mpres_pow (mpres_t, const mpres_t, const mpz_t, mpmod_t); #define mpres_ui_pow __ECM(mpres_ui_pow) void mpres_ui_pow (mpres_t, const unsigned long, const mpres_t, mpmod_t); #define mpres_mul __ECM(mpres_mul) void mpres_mul (mpres_t, const mpres_t, const mpres_t, mpmod_t) ATTRIBUTE_HOT; #define mpres_sqr __ECM(mpres_sqr) void mpres_sqr (mpres_t, const mpres_t, mpmod_t) ATTRIBUTE_HOT; #define mpres_mul_z_to_z __ECM(mpres_mul_z_to_z) void mpres_mul_z_to_z (mpz_t, const mpres_t, const mpz_t, mpmod_t); #define mpres_set_z_for_gcd __ECM(mpres_set_z_for_gcd) void mpres_set_z_for_gcd (mpres_t, const mpz_t, mpmod_t); #define mpres_set_z_for_gcd_fix __ECM(mpres_set_z_for_gcd_fix) void mpres_set_z_for_gcd_fix (mpres_t, const mpres_t, const mpz_t, mpmod_t); #define mpres_div_2exp __ECM(mpres_div_2exp) void mpres_div_2exp (mpres_t, const mpres_t, const unsigned int, mpmod_t); #define mpres_add_ui __ECM(mpres_add_ui) void mpres_add_ui (mpres_t, const mpres_t, const unsigned long, mpmod_t); #define mpres_add __ECM(mpres_add) void mpres_add (mpres_t, const mpres_t, const mpres_t, mpmod_t) ATTRIBUTE_HOT; #define mpres_sub_ui __ECM(mpres_sub_ui) void mpres_sub_ui (mpres_t, const mpres_t, const unsigned long, mpmod_t); #define mpres_ui_sub __ECM(mpres_ui_sub) void mpres_ui_sub (mpres_t, const unsigned long, const mpres_t, mpmod_t); #define mpres_sub __ECM(mpres_sub) void mpres_sub (mpres_t, const mpres_t, const mpres_t, mpmod_t) ATTRIBUTE_HOT; #define mpres_set_z __ECM(mpres_set_z) void mpres_set_z (mpres_t, const mpz_t, mpmod_t); #define mpres_get_z __ECM(mpres_get_z) void mpres_get_z (mpz_t, const mpres_t, mpmod_t); #define mpres_set_ui __ECM(mpres_set_ui) void mpres_set_ui (mpres_t, const unsigned long, mpmod_t); #define mpres_set_si __ECM(mpres_set_si) void mpres_set_si (mpres_t, const long, mpmod_t); #define mpres_init __ECM(mpres_init) void mpres_init (mpres_t, const mpmod_t); #define mpres_clear __ECM(mpres_clear) void mpres_clear (mpres_t, const mpmod_t); #define mpres_realloc __ECM(mpres_realloc) void mpres_realloc (mpres_t, const mpmod_t); #define mpres_mul_ui __ECM(mpres_mul_ui) void mpres_mul_ui (mpres_t, const mpres_t, const unsigned long, mpmod_t); #define mpres_mul_2exp __ECM(mpres_mul_2exp) void mpres_mul_2exp (mpres_t, const mpres_t, const unsigned long, mpmod_t); #define mpres_muldivbysomething_si __ECM(mpres_muldivbysomething_si) void mpres_muldivbysomething_si (mpres_t, const mpres_t, const long, mpmod_t); #define mpres_neg __ECM(mpres_neg) void mpres_neg (mpres_t, const mpres_t, mpmod_t); #define mpres_invert __ECM(mpres_invert) int mpres_invert (mpres_t, const mpres_t, mpmod_t); #define mpres_gcd __ECM(mpres_gcd) void mpres_gcd (mpz_t, const mpres_t, const mpmod_t); #define mpres_out_str __ECM(mpres_out_str) void mpres_out_str (FILE *, const unsigned int, const mpres_t, mpmod_t); #define mpres_is_zero __ECM(mpres_is_zero) int mpres_is_zero (const mpres_t, mpmod_t); #define mpres_set(a,b,n) mpz_set (a, b) #define mpres_swap(a,b,n) mpz_swap (a, b) #define mpresn_mul __ECM(mpresn_mul) void mpresn_mul (mpres_t, const mpres_t, const mpres_t, mpmod_t); #define mpresn_addsub __ECM(mpresn_addsub) void mpresn_addsub (mpres_t, mpres_t, const mpres_t, const mpres_t, mpmod_t); #define mpresn_pad __ECM(mpresn_pad) void mpresn_pad (mpres_t R, mpmod_t N); #define mpresn_unpad __ECM(mpresn_unpad) void mpresn_unpad (mpres_t R); #define mpresn_sqr __ECM(mpresn_sqr) void mpresn_sqr (mpres_t, const mpres_t, mpmod_t); #define mpresn_add __ECM(mpresn_add) void mpresn_add (mpres_t, const mpres_t, const mpres_t, mpmod_t); #define mpresn_sub __ECM(mpresn_sub) void mpresn_sub (mpres_t, const mpres_t, const mpres_t, mpmod_t); #define mpresn_mul_1 __ECM(mpresn_mul_ui) void mpresn_mul_1 (mpres_t, const mpres_t, const mp_limb_t, mpmod_t); /* mul_lo.c */ #define ecm_mul_lo_n __ECM(ecm_mul_lo_n) void ecm_mul_lo_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define ecm_mul_lo_basecase __ECM(ecm_mul_lo_basecase) void ecm_mul_lo_basecase (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); /* median.c */ #define TMulGen __ECM(TMulGen) int TMulGen (listz_t, unsigned int, listz_t, unsigned int, listz_t, unsigned int, listz_t, mpz_t); #define TMulGen_space __ECM(TMulGen_space) unsigned int TMulGen_space (unsigned int, unsigned int, unsigned int); /* schoen_strass.c */ #define DEFAULT 0 #define MONIC 1 #define NOPAD 2 #define F_mul __ECM(F_mul) unsigned int F_mul (mpz_t *, mpz_t *, mpz_t *, unsigned int, int, unsigned int, mpz_t *); #define F_mul_trans __ECM(F_mul_trans) unsigned int F_mul_trans (mpz_t *, mpz_t *, mpz_t *, unsigned int, unsigned int, unsigned int, mpz_t *); #define F_clear __ECM(F_clear) void F_clear (); /* rho.c */ #define rhoinit __ECM(rhoinit) void rhoinit (int, int); #define ecmprob __ECM(ecmprob) double ecmprob (double, double, double, double, int); double pm1prob (double, double, double, double, int, const mpz_t); /* pm1.c */ void print_prob (double, const mpz_t, unsigned long, unsigned long, int, const mpz_t); /* auxlib.c */ #define mpz_add_si __ECM(mpz_add_si) void mpz_add_si (mpz_t, mpz_t, long); #define mpz_sub_si __ECM(mpz_sub_si) void mpz_sub_si (mpz_t, mpz_t, long); #define mpz_divby3_1op __ECM(mpz_divby3_1op) void mpz_divby3_1op (mpz_t); #define double_to_size __ECM(double_to_size) size_t double_to_size (double d); #define cputime __ECM(cputime) long cputime (void); #define realtime __ECM(realtime) long realtime (void); #define elltime __ECM(elltime) long elltime (long, long); #define test_verbose __ECM(test_verbose) int test_verbose (int); #define set_verbose __ECM(set_verbose) void set_verbose (int); #define outputf __ECM(outputf) int outputf (int, const char *, ...); #define writechkfile __ECM(writechkfile) void writechkfile (char *, int, double, mpmod_t, mpres_t, mpres_t, mpres_t, mpres_t); #define aux_fseek64 __ECM(aux_fseek64) int aux_fseek64(FILE *, const int64_t, const int); #define ecm_tstbit __ECM(ecm_tstbit) int ecm_tstbit (mpz_srcptr, ecm_uint); /* Due to GMP (6.x and prior) using long as input to mpz_tstbit, factors would be missed on computers with 32-bit longs in batch mode when using B1 > 2977044736UL. So, we need to use our own function when long is not 64-bits wide */ #if ULONG_MAX == 0xffffffffUL #undef mpz_tstbit #define mpz_tstbit ecm_tstbit #endif /* auxarith.c */ #define gcd __ECM(gcd) unsigned long gcd (unsigned long, unsigned long); #define eulerphi __ECM(eulerphi) unsigned long eulerphi (unsigned long); #define ceil_log2 __ECM(ceil_log2) unsigned int ceil_log2 (unsigned long); #define find_factor __ECM(find_factor) unsigned long find_factor (const unsigned long); /* random.c */ #define init_randstate __ECM(init_randstate) void init_randstate (gmp_randstate_t); #define pp1_random_seed __ECM(pp1_random_seed) void pp1_random_seed (mpz_t, mpz_t, gmp_randstate_t); #define pm1_random_seed __ECM(pm1_random_seed) void pm1_random_seed (mpz_t, mpz_t, gmp_randstate_t); #define get_random_ul __ECM(get_random_ul) unsigned long get_random_ul (void); /* Fgw.c */ #ifdef HAVE_GWNUM int gw_ecm_stage1 (mpz_t, curve *, mpmod_t, double, double *, mpz_t, double, unsigned long, unsigned long, signed long); #endif /* batch.c */ #define compute_s __ECM(compute_s ) void compute_s (mpz_t, ecm_uint, int *); #define ecm_stage1_batch __ECM(ecm_stage1_batch) int ecm_stage1_batch (mpz_t, mpres_t, mpres_t, mpmod_t, double, double *, int, mpz_t); /* parametrizations.c */ #define get_curve_from_random_parameter __ECM(get_curve_from_random_parameter) int get_curve_from_random_parameter (mpz_t, mpres_t, mpres_t, mpz_t, int, mpmod_t, gmp_randstate_t); #define get_curve_from_param0 __ECM(get_curve_from_param0) int get_curve_from_param0 (mpz_t, mpres_t, mpres_t, mpz_t, mpmod_t); #define get_curve_from_param1 __ECM(get_curve_from_param1) int get_curve_from_param1 (mpres_t, mpres_t, mpz_t, mpmod_t); #define get_curve_from_param2 __ECM(get_curve_from_param2) int get_curve_from_param2 (mpz_t, mpres_t, mpres_t, mpz_t, mpmod_t); #define get_curve_from_param3 __ECM(get_curve_from_param3) int get_curve_from_param3 (mpres_t, mpres_t, mpz_t, mpmod_t); #define get_default_param __ECM(get_default_param) int get_default_param (int, double, int); /* sets_long.c */ /* A set of long ints */ typedef struct { unsigned long card; long elem[1]; } set_long_t; /* A set of sets of long ints */ typedef struct { unsigned long nr; set_long_t sets[1]; } sets_long_t; #define quicksort_long __ECM(quicksort_long) void quicksort_long (long *, unsigned long); #define sets_print __ECM(sets_print) void sets_print (const int, sets_long_t *); #define sets_max __ECM(sets_max) void sets_max (mpz_t, const unsigned long); #define sets_sumset __ECM(sets_sumset) void sets_sumset (set_long_t *, const sets_long_t *); #define sets_sumset_minmax __ECM(sets_sumset_minmax) void sets_sumset_minmax (mpz_t, const sets_long_t *, const int); #define sets_extract __ECM(sets_extract) void sets_extract (sets_long_t *, size_t *, sets_long_t *, const unsigned long); #define sets_get_factored_sorted __ECM(sets_get_factored_sorted) sets_long_t * sets_get_factored_sorted (const unsigned long); /* Return the size in bytes of a set of cardinality c */ #define set_sizeof __ECM(set_sizeof) ATTRIBUTE_UNUSED static size_t set_sizeof (const unsigned long c) { return sizeof (long) + (size_t) c * sizeof (unsigned long); } /* Return pointer to the next set in "*sets" */ ATTRIBUTE_UNUSED static set_long_t * sets_nextset (const set_long_t *sets) { return (set_long_t *) ((char *)sets + sizeof(unsigned long) + sets->card * sizeof(long)); } #if defined (__cplusplus) } #endif /* a <- b * c where a and b are mpz, c is a double, and t an auxiliary mpz */ /* Not sure how the preprocessor handles shifts by more than the integer width on 32 bit machines, so do the shift by 53 in two pieces */ #if (((ULONG_MAX >> 27) >> 26) >= 1) #define mpz_mul_d(a, b, c, t) \ mpz_mul_ui (a, b, (unsigned long int) c); #else #define mpz_mul_d(a, b, c, t) \ if (c < (double) ULONG_MAX) \ mpz_mul_ui (a, b, (unsigned long int) c); \ else { \ mpz_set_d (t, c); \ mpz_mul (a, b, t); } #endif #endif /* _ECM_IMPL_H */
/* ecm-impl.h - header file for libecm Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Paul Zimmermann, Alexander Kruppa and Cyril Bouvier. This file is part of the ECM Library. The ECM Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The ECM Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the ECM Library; see the file COPYING.LIB. If not, see http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
test.ml
module I = struct type t = int let compare = Stdlib.compare end module B = Bag.Make(I) let () = let a = B.add 1 ~mult:1 (B.add 2 ~mult:2 (B.add 3 ~mult:3 B.empty)) in let b = B.add 1 ~mult:4 (B.add 2 ~mult:5 (B.add 3 ~mult:6 B.empty)) in assert (B.cardinal a = 6); assert (B.cardinal (B.sum a b) = 21); assert (B.cardinal (B.union a b) = 15); assert (B.is_empty (B.diff a b)); assert (B.cardinal (B.diff b a) = 9); assert (B.equal (B.inter a b) a); assert (B.included a b); assert (not (B.included b a)); assert (not (B.disjoint b a)); assert (B.elements a = [1,1; 2,2; 3,3]); assert (B.min_elt a = (1,1)); assert (B.max_elt a = (3,3)); let f _ = 1 in assert (B.cardinal (B.map f a) = 3); assert (B.cardinal (B.map f b) = 3); let e = B.filter (fun x _ -> x mod 2 = 0) a in assert (B.min_elt e = (2,2)); assert (B.max_elt e = (2,2)); assert (B.choose e = (2,2)); assert (B.cardinal e = 2); let o = B.filter (fun x _ -> x mod 2 = 1) b in assert (B.min_elt o = (1,4)); assert (B.max_elt o = (3,6)); assert (B.cardinal o = 10); () let test n = let b1 = ref B.empty in let b2 = ref B.empty in for x = 0 to n do b1 := B.add x ~mult:2 !b1; assert (B.cardinal !b1 = 2*(x+1)); b2 := B.add (n-x) !b2; assert (B.cardinal !b2 = 2*x+1); b2 := B.add (n-x) !b2; if x < n/2 then assert (B.disjoint !b1 !b2) done; assert (B.mem n !b1); assert (B.occ n !b1 = 2); assert (B.cardinal !b1 = 2*(n+1)); assert (B.cardinal !b2 = 2*(n+1)); assert (B.equal !b1 !b2); assert (B.for_all (fun x _ -> x <= n) !b1); assert (not (B.for_all (fun x _ -> x < n) !b1)); assert (B.exists (fun x m -> x = 0 && m = 2) !b2); for x = 0 to n do b1 := B.remove_all x !b1; b2 := B.remove (n-x) ~mult:2 !b2; done; assert (B.is_empty !b1); assert (B.is_empty !b2); () let () = for n = 0 to 10 do test (10 * n) done
ast.ml
(* This file is free software, part of dolmen. See file "LICENSE" for more information. *) (** AST requirements for the iCNF format. iCNF is a very simple format intended to express CNFs (conjunctive normal forms) in the simplest format possible. Compared to dimacs, iCNF allows local assumptions, and does not require to declare the number of clauses and formulas. *) module type Term = sig type t (** The type of terms. *) type location (** The type of locations. *) val atom : ?loc:location -> int -> t (** Make an atom from an non-zero integer. Positive integers denotes variables, and negative integers denote the negation of the variable corresponding to their absolute value. *) end (** Requirements for implementations of Dimacs terms. *) module type Statement = sig type t (** The type of statements for iCNF. *) type term (** The type of iCNF terms. *) type location (** The type of locations. *) val p_inccnf : ?loc:location -> unit -> t (** header of an iCNF file. *) val clause : ?loc:location -> term list -> t (** Make a clause from a list of literals. *) val assumption : ?loc:location -> term list -> t (** Generate a solve instruction with the given list of assumptions. *) end (** Requirements for implementations of iCNF statements. *)
Header.ml
open Utils type t = { alg : Jwa.alg; jwk : Jwk.public Jwk.t option; kid : string option; x5t : string option; x5t256 : string option; typ : string option; cty : string option; enc : Jwa.enc option; extra : (string * Yojson.Safe.t) list; } (* TODO: This is probably very slow *) let remove_supported (l : (string * Yojson.Safe.t) list) = l |> List.remove_assoc "alg" |> List.remove_assoc "jwk" |> List.remove_assoc "kid" |> List.remove_assoc "x5t" |> List.remove_assoc "x5t#256" |> List.remove_assoc "typ" |> List.remove_assoc "cty" |> List.remove_assoc "enc" let make_header ?typ ?alg ?enc ?(extra = []) ?(jwk_header = false) (jwk : Jwk.priv Jwk.t) = let alg = match alg with | Some alg -> alg | None -> ( match jwk with | Jwk.Rsa_priv _ -> `RS256 | Jwk.Oct _ -> `HS256 | Jwk.Es256_priv _ -> `ES256 | Jwk.Es384_priv _ -> `ES384 | Jwk.Es512_priv _ -> `ES512 | Jwk.Ed25519_priv _ -> `EdDSA) in let kid = match List.assoc_opt "kid" extra with | Some kid -> Some (Yojson.Safe.Util.to_string kid) | None -> Jwk.get_kid jwk in let extra = remove_supported extra in { alg; jwk = (if jwk_header then Some (Jwk.pub_of_priv jwk) else None); kid; x5t = None; x5t256 = None; typ; cty = None; enc; extra; } module Json = Yojson.Safe.Util let get_extra_headers (json : Yojson.Safe.t) = match json with | `Assoc vals -> ( let extra = remove_supported vals in match extra with [] -> [] | extra -> extra) | _ -> [] (* TODO: raise here? *) let of_json json = try Ok { alg = json |> Json.member "alg" |> Jwa.alg_of_json; jwk = json |> Json.member "jwk" |> Json.to_option (fun jwk_json -> Jwk.of_pub_json jwk_json |> U_Result.to_opt) |> U_Opt.flatten; kid = json |> Json.member "kid" |> Json.to_string_option; x5t = json |> Json.member "x5t" |> Json.to_string_option; x5t256 = json |> Json.member "x5t#256" |> Json.to_string_option; typ = json |> Json.member "typ" |> Json.to_string_option; cty = json |> Json.member "cty" |> Json.to_string_option; enc = json |> Json.member "enc" |> Json.to_string_option |> U_Opt.map Jwa.enc_of_string; extra = get_extra_headers json; } with Json.Type_error (s, _) -> Error (`Msg s) let to_json t = let values = [ RJson.to_json_string_opt "typ" t.typ; Some ("alg", Jwa.alg_to_json t.alg); RJson.to_json_string_opt "kid" t.kid; U_Opt.map Jwk.to_pub_json t.jwk |> U_Opt.map (fun jwk -> ("jwk", jwk)); RJson.to_json_string_opt "x5t" t.x5t; RJson.to_json_string_opt "x5t#256" t.x5t256; RJson.to_json_string_opt "cty" t.cty; t.enc |> U_Opt.map Jwa.enc_to_string |> U_Opt.map (fun enc -> ("enc", `String enc)); ] in `Assoc (U_List.filter_map (fun x -> x) values @ t.extra) let of_string header_str = U_Base64.url_decode header_str |> U_Result.flat_map (fun decoded_header -> Yojson.Safe.from_string decoded_header |> of_json) let to_string header = to_json header |> Yojson.Safe.to_string |> U_Base64.url_encode_string
global_litmus.mli
(** Global locations for litmus *) type t = Addr of string | Pte of string | Phy of string val pp_old : t -> string val pp : t -> string val compare : t -> t -> int val as_addr : t -> string (* assert false if not an addr *) val tr_symbol : Constant.symbol -> t module Set : MySet.S with type elt = t module Map : MyMap.S with type key = t type displayed = string ConstrGen.rloc val dump_displayed : displayed -> string module DisplayedSet : MySet.S with type elt = displayed
(****************************************************************************) (* the diy toolsuite *) (* *) (* Jade Alglave, University College London, UK. *) (* Luc Maranget, INRIA Paris-Rocquencourt, France. *) (* *) (* Copyright 2020-present Institut National de Recherche en Informatique et *) (* en Automatique and the authors. All rights reserved. *) (* *) (* This software is governed by the CeCILL-B license under French law and *) (* abiding by the rules of distribution of free software. You can use, *) (* modify and/ or redistribute the software under the terms of the CeCILL-B *) (* license as circulated by CEA, CNRS and INRIA at the following URL *) (* "http://www.cecill.info". We also give a copy in LICENSE.txt. *) (****************************************************************************)
test_mysql.ml
(** *) open Rdf open Graph let string_of_triple (sub, pred, obj) = Printf.sprintf "%s %s %s." (Term.string_of_term sub) (Iri.to_string pred) (Term.string_of_term obj) ;; let main () = let options = [ "storage", "mysql" ; "database", "testrdf"; "user", Sys.getenv "USER"; ] in let g = Graph.open_graph ~options (Iri.of_string "http://hello.fr") in let pred = Iri.of_string "http://dis-bonjour.org" in let obj = Term.term_of_literal_string "youpi" in let sub = Term.term_of_iri_string "http://coucou0.net" in for i = 0 to 10 do g.add_triple ~sub: (Term.term_of_iri_string (Printf.sprintf "http://coucou%d.net" i)) ~pred ~obj done; g.rem_triple ~sub: (Term.term_of_iri_string "http://coucou3.net") ~pred ~obj; let subjects = g.subjects_of ~pred ~obj in List.iter (fun term -> print_endline (Term.string_of_term term)) subjects; let b = g.exists_t (sub, pred, obj) in assert b; let b = g.exists ~sub ~obj () in assert b; let b = not (g.exists ~obj: (Term.term_of_iri_string "http://") ()) in assert b; let triples = g.find () in List.iter (fun t -> print_endline (string_of_triple t)) triples; let subjects = g.subjects () in List.iter (fun term -> print_endline (Term.string_of_term term)) subjects; let sub4 = Term.term_of_iri_string "http://coucou4.net" in g.transaction_start (); g.rem_triple ~sub: sub4 ~pred ~obj; assert (not (g.exists_t (sub4, pred, obj))); g.transaction_rollback (); assert (g.exists_t (sub4, pred, obj)); g.add_namespace (Iri.of_string "http://dis-bonjour.org") "bonjour" ; g.add_namespace (Iri.of_string "http://coucou1.net") "coucou1" ; print_endline (Ttl.to_string g); g.rem_namespace "coucou1"; g.rem_namespace "coucou2"; g.set_namespaces [ (Iri.of_string "http://coucou3.net", "coucou3"); (Iri.of_string "http://coucou4.net", "coucou4"); ]; print_endline (Ttl.to_string g); ;; let () = main();;
(*********************************************************************************) (* OCaml-RDF *) (* *) (* Copyright (C) 2012-2021 Institut National de Recherche en Informatique *) (* et en Automatique. All rights reserved. *) (* *) (* This program is free software; you can redistribute it and/or modify *) (* it under the terms of the GNU Lesser General Public License version *) (* 3 as published by the Free Software Foundation. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU General Public License *) (* along with this program; if not, write to the Free Software *) (* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *) (* 02111-1307 USA *) (* *) (* Contact: Maxence.Guesdon@inria.fr *) (* *) (*********************************************************************************)
bar.ml
int64.mli
(** 64-bit integers. *) open! Import include Int_intf.S with type t = int64 module O : sig (*_ Declared as externals so that the compiler skips the caml_apply_X wrapping even when compiling without cross library inlining. *) external ( + ) : t -> t -> t = "%int64_add" external ( - ) : t -> t -> t = "%int64_sub" external ( * ) : t -> t -> t = "%int64_mul" external ( / ) : t -> t -> t = "%int64_div" external ( ~- ) : t -> t = "%int64_neg" val ( ** ) : t -> t -> t external ( = ) : t -> t -> bool = "%equal" external ( <> ) : t -> t -> bool = "%notequal" external ( < ) : t -> t -> bool = "%lessthan" external ( > ) : t -> t -> bool = "%greaterthan" external ( <= ) : t -> t -> bool = "%lessequal" external ( >= ) : t -> t -> bool = "%greaterequal" external ( land ) : t -> t -> t = "%int64_and" external ( lor ) : t -> t -> t = "%int64_or" external ( lxor ) : t -> t -> t = "%int64_xor" val lnot : t -> t val abs : t -> t external neg : t -> t = "%int64_neg" val zero : t val ( % ) : t -> t -> t val ( /% ) : t -> t -> t val ( // ) : t -> t -> float external ( lsl ) : t -> int -> t = "%int64_lsl" external ( asr ) : t -> int -> t = "%int64_asr" external ( lsr ) : t -> int -> t = "%int64_lsr" end include module type of O (** {2 Conversion functions} *) (*_ Declared as externals so that the compiler skips the caml_apply_X wrapping even when compiling without cross library inlining. *) external of_int : int -> t = "%int64_of_int" external of_int32 : int32 -> t = "%int64_of_int32" external of_int64 : t -> t = "%identity" val to_int : t -> int option val to_int32 : t -> int32 option val of_nativeint : nativeint -> t val to_nativeint : t -> nativeint option (** {3 Truncating conversions} These functions return the least-significant bits of the input. In cases where optional conversions return [Some x], truncating conversions return [x]. *) (*_ Declared as externals so that the compiler skips the caml_apply_X wrapping even when compiling without cross library inlining. *) external to_int_trunc : t -> int = "%int64_to_int" external to_int32_trunc : int64 -> int32 = "%int64_to_int32" external to_nativeint_trunc : int64 -> nativeint = "%int64_to_nativeint" (** {3 Low-level float conversions} *) val bits_of_float : float -> t val float_of_bits : t -> float (** {2 Byte swap operations} See {{!modtype:Int.Int_without_module_types}[Int]'s byte swap section} for a description of Base's approach to exposing byte swap primitives. As of writing, these operations do not sign extend unnecessarily on 64 bit machines, unlike their int32 counterparts, and hence, are more performant. See the {!Int32} module for more details of the overhead entailed by the int32 byteswap functions. *) val bswap16 : t -> t val bswap32 : t -> t val bswap48 : t -> t (*_ Declared as an external so that the compiler skips the caml_apply_X wrapping even when compiling without cross library inlining. *) external bswap64 : t -> t = "%bswap_int64"
(** 64-bit integers. *)
intersectionObserver.mli
(** The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API *) class type intersectionObserverEntry = object method target : Dom.node Js.t Js.readonly_prop method boundingClientRect : Dom_html.clientRect Js.t Js.readonly_prop method rootBounds : Dom_html.clientRect Js.t Js.opt Js.readonly_prop method intersectionRect : Dom_html.clientRect Js.t Js.readonly_prop method intersectionRatio : float Js.readonly_prop method isIntersecting : bool Js.t Js.readonly_prop method time : float Js.readonly_prop end class type intersectionObserverOptions = object method root : Dom.node Js.t Js.writeonly_prop method rootMargin : Js.js_string Js.t Js.writeonly_prop method threshold : float Js.js_array Js.t Js.writeonly_prop end class type intersectionObserver = object method root : Dom.node Js.t Js.opt Js.readonly_prop method rootMargin : Js.js_string Js.t Js.readonly_prop method thresholds : float Js.js_array Js.t Js.readonly_prop method observe : #Dom.node Js.t -> unit Js.meth method unobserve : #Dom.node Js.t -> unit Js.meth method disconnect : unit Js.meth method takeRecords : intersectionObserverEntry Js.t Js.js_array Js.meth end val empty_intersection_observer_options : unit -> intersectionObserverOptions Js.t val is_supported : unit -> bool val intersectionObserver : ( ( intersectionObserverEntry Js.t Js.js_array Js.t -> intersectionObserver Js.t -> unit) Js.callback -> intersectionObserverOptions Js.t -> intersectionObserver Js.t) Js.constr
(** The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API *)
test_paid_storage_increase.ml
(** Testing ------- Component: Protocol (increase_paid_storage) Invocation: dune exec \ src/proto_alpha/lib_protocol/test/integration/operations/main.exe \ -- test "^paid storage increase$" Subject: On increasing a paid amount of contract storage. *) open Protocol open Alpha_context let ten_tez = Test_tez.of_int 10 let dummy_script = "{parameter unit; storage unit; code { CAR ; NIL operation ; PAIR }}" let contract_originate block ?(script = dummy_script) ?(storage = Expr.from_string "Unit") account = let open Lwt_result_syntax in let code = Expr.from_string script in let script = Alpha_context.Script.{code = lazy_expr code; storage = lazy_expr storage} in let source_contract = account in let baker = Context.Contract.pkh account in let* op, dst = Op.contract_origination_hash (B block) source_contract ~fee:Tez.zero ~script in let* inc = Incremental.begin_construction ~policy:Block.(By_account baker) block in let* inc = Incremental.add_operation inc op in let+ b = Incremental.finalize_block inc in (b, dst) (** [test_balances] runs a simple [increase_paid_storage] and verifies that the source contract balance is correct and that the storage of the destination contract has been increased by the right amount. *) let test_balances ~amount = let open Lwt_result_syntax in let* b, source = Context.init1 () in let* b, destination = contract_originate b source in let* inc = Incremental.begin_construction b in let* balance_before_op = Context.Contract.balance (I inc) source in let contract_dst = Contract.Originated destination in let*! storage_before_op = Contract.Internal_for_tests.paid_storage_space (Incremental.alpha_ctxt inc) contract_dst in let* storage_before_op = Lwt.return (Environment.wrap_tzresult storage_before_op) in let* op = Op.increase_paid_storage ~fee:Tez.zero (I inc) ~source ~destination amount in let* inc = Incremental.add_operation inc op in (* check that after the block has been baked, the source was debited of all the burned tez *) let* {parametric = {cost_per_byte; _}; _} = Context.get_constants (I inc) in let burned_tez = Tez.mul_exn cost_per_byte (Z.to_int amount) in let* () = Assert.balance_was_debited ~loc:__LOC__ (I inc) source balance_before_op burned_tez in (* check that the storage has been increased by the right amount *) let*! storage = Contract.Internal_for_tests.paid_storage_space (Incremental.alpha_ctxt inc) contract_dst in let* storage = Lwt.return (Environment.wrap_tzresult storage) in let storage_minus_amount = Z.sub storage amount in Assert.equal_int ~loc:__LOC__ (Z.to_int storage_before_op) (Z.to_int storage_minus_amount) (******************************************************) (* Tests *) (******************************************************) (** Basic test. We test balances in simple cases. *) let test_balances_simple () = test_balances ~amount:(Z.of_int 100) (******************************************************) (* Errors *) (******************************************************) (** We test the operation when the amount given is null. *) let test_null_amount () = let open Lwt_result_syntax in let*! result = test_balances ~amount:Z.zero in Assert.proto_error ~loc:__LOC__ result (function | Fees_storage.Negative_storage_input -> true | _ -> false) (** We test the operation when the amount given is negative. *) let test_negative_amount () = let open Lwt_result_syntax in let amount = Z.of_int (-10) in let*! result = test_balances ~amount in Assert.proto_error ~loc:__LOC__ result (function | Fees_storage.Negative_storage_input -> true | _ -> false) (** We create an implicit account with not enough tez to pay for the storage increase. *) let test_no_tez_to_pay () = let open Lwt_result_syntax in let* b, (source, baker, receiver) = Context.init3 ~consensus_threshold:0 () in let* b, destination = contract_originate b source in let pkh_for_bake = Context.Contract.pkh baker in let* inc = Incremental.begin_construction ~policy:Block.(By_account pkh_for_bake) b in let* {parametric = {cost_per_byte; _}; _} = Context.get_constants (I inc) in let increase_amount = Z.div (Z.of_int 2_000_000) (Z.of_int64 (Tez.to_mutez cost_per_byte)) in let* balance = Context.Contract.balance (I inc) source in let*? tez_to_substract = Test_tez.(balance -? Tez.one) in let* op = Op.transaction (I inc) ~fee:Tez.zero source receiver tez_to_substract in let* inc = Incremental.add_operation inc op in let* b = Incremental.finalize_block inc in let* inc = Incremental.begin_construction ~policy:Block.(By_account pkh_for_bake) b in let* op = Op.increase_paid_storage (I inc) ~source ~destination increase_amount in let*! inc = Incremental.add_operation inc op in Assert.proto_error ~loc:__LOC__ inc (function | Fees_storage.Cannot_pay_storage_fee -> true | _ -> false) (** To test when there is no smart contract at the address given. *) let test_no_contract () = let open Lwt_result_syntax in let* b, source = Context.init1 () in let* inc = Incremental.begin_construction b in let destination = Contract_helpers.fake_KT1 in let* op = Op.increase_paid_storage (I inc) ~source ~destination Z.zero in let*! inc = Incremental.add_operation inc op in Assert.proto_error ~loc:__LOC__ inc (function | Raw_context.Storage_error (Missing_key (_, Raw_context.Get)) -> true | _ -> false) (** To test if the increase in storage is effective. *) let test_effectiveness () = let open Lwt_result_syntax in let* b, (source, _contract_source) = Context.init2 ~consensus_threshold:0 () in let script = "{parameter unit; storage int; code { CDR ; PUSH int 65536 ; MUL ; NIL \ operation ; PAIR }}" in let storage = Tezos_micheline.Micheline.strip_locations (Expr_common.int Z.one) in let* b, destination = contract_originate ~script ~storage b source in let* inc = Incremental.begin_construction b in (* We ensure that the transaction can't be made with a 0 burn cap. *) let contract_dst = Contract.Originated destination in let* op = Op.transaction ~storage_limit:Z.zero ~fee:Tez.zero (I inc) source contract_dst Tez.zero in let*! inc_test = Incremental.add_operation inc op in let* () = Assert.proto_error ~loc:__LOC__ inc_test (function | Fees.Operation_quota_exceeded -> true | _ -> false) in let* b = Incremental.finalize_block inc in let* inc = Incremental.begin_construction b in let* op = Op.increase_paid_storage (I inc) ~fee:Tez.zero ~source ~destination (Z.of_int 10) in let* inc = Incremental.add_operation inc op in let* b = Incremental.finalize_block inc in let* inc = Incremental.begin_construction b in (* We test the same transaction to see if increase_paid_storage worked. *) let* op = Op.transaction ~storage_limit:Z.zero ~fee:Tez.zero (I inc) source contract_dst Tez.zero in let+ _inc = Incremental.add_operation inc op in () let tests = [ Tztest.tztest "balances simple" `Quick test_balances_simple; Tztest.tztest "null amount" `Quick test_null_amount; Tztest.tztest "negative amount" `Quick test_negative_amount; Tztest.tztest "not enough tez to pay" `Quick test_no_tez_to_pay; Tztest.tztest "no contract to bump its paid storage" `Quick test_no_contract; Tztest.tztest "effectiveness" `Quick test_effectiveness; ]
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
dune
pg_ts_config.h
#ifndef PG_TS_CONFIG_H #define PG_TS_CONFIG_H #include "catalog/genbki.h" #include "catalog/pg_ts_config_d.h" /* ---------------- * pg_ts_config definition. cpp turns this into * typedef struct FormData_pg_ts_config * ---------------- */ CATALOG(pg_ts_config,3602,TSConfigRelationId) { /* oid */ Oid oid; /* name of configuration */ NameData cfgname; /* name space */ Oid cfgnamespace BKI_DEFAULT(PGNSP); /* owner */ Oid cfgowner BKI_DEFAULT(PGUID); /* OID of parser */ Oid cfgparser BKI_LOOKUP(pg_ts_parser); } FormData_pg_ts_config; typedef FormData_pg_ts_config *Form_pg_ts_config; #endif /* PG_TS_CONFIG_H */
/*------------------------------------------------------------------------- * * pg_ts_config.h * definition of the "text search configuration" system catalog * (pg_ts_config) * * * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/catalog/pg_ts_config.h * * NOTES * The Catalog.pm module reads this file and derives schema * information. * *------------------------------------------------------------------------- */
queue.mli
include Queue_intf.Queue (** @inline *)
include Queue_intf.Queue (** @inline *)
equality_witness.mli
(** This module provides support for type equalities and runtime type identifiers. For two types [a] and [b], [(a, b) eq] is a witness that [a = b]. This is a standard generalized algebraic datatype on top of which type-level programming techniques can be implemented. Given a type [a], an inhabitant of [a t] is a dynamic identifier for [a]. Identifiers can be compared for equality. They are also equipped with a hash function. WARNING: the hash function changes at every run. Therefore, the result of the hash function should never be stored. Notice that dynamic identifiers are not unique: two identifiers for [a] can have distinct hash and can be physically distinct. Hence, only [eq] can decide if two type identifiers correspond to the same type. *) (** A proof witness that two types are equal. *) type (_, _) eq = Refl : ('a, 'a) eq (** A dynamic representation for ['a]. *) type 'a t (** [make ()] is a dynamic representation for ['a]. A fresh identifier is returned each time [make ()] is evaluated. *) val make : unit -> 'a t (** [eq ida idb] returns a proof that [a = b] if [ida] and [idb] identify the same type. *) val eq : 'a t -> 'b t -> ('a, 'b) eq option (** [hash id] returns a hash for [id]. *) val hash : 'a t -> int
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2021 Nomadic Labs. <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
irTransform.mli
type state = { context: Context.t; primitive_vars: Utility.IntSet.t; datatype: Types.datatype } type result = Result of { state: state; program: Ir.program } val context : state -> Context.t val return : state -> Ir.program -> result val with_type : Types.datatype -> state -> state module type S = sig val name : string val program : state -> Ir.program -> result end class virtual ir_transformer: object('self) method virtual program : Ir.program -> Ir.program * Types.datatype * 'self end module Make(T : sig val name : string val obj : Types.typing_environment -> ir_transformer end) : S
voting_period_storage.mli
val init : Raw_context.t -> Voting_period_repr.t -> Raw_context.t tzresult Lwt.t (** Sets the initial period to [{voting_period = root; kind = Proposal; start_position}]. *) val init_first_period : Raw_context.t -> start_position:Int32.t -> Raw_context.t tzresult Lwt.t (** Increment the index by one and set the kind to Proposal. *) val reset : Raw_context.t -> Raw_context.t tzresult Lwt.t (** Increment the index by one and set the kind to its successor. *) val succ : Raw_context.t -> Raw_context.t tzresult Lwt.t val get_current : Raw_context.t -> Voting_period_repr.t tzresult Lwt.t val get_current_kind : Raw_context.t -> Voting_period_repr.kind tzresult Lwt.t (** Returns true if the context level is the last of current voting period. *) val is_last_block : Raw_context.t -> bool tzresult Lwt.t (* Given the issue explained in voting_period_storage.ml this function behaves currectly during the validation of a block but returns inconsistent info if called after the finalization of the block. For this reason when used by the RPC `votes/current_period_kind` gives an unintuitive result: after the validation of the last block of a voting period (e.g. proposal), it returns the kind of the next period (e.g. exploration). To fix this, at least part of the current vote finalization should be moved at the beginning of the block validation. For retro-compatibility, we keep this function but we provide two new fixed functions to reply correctly to RPCs [get_rpc_fixed_current_info] and [get_rpc_fixed_succ_info]. *) val get_current_info : Raw_context.t -> Voting_period_repr.info tzresult Lwt.t (* In order to avoid the problem of `get_current_info` explained above, this function provides the corrent behavior for the new RPC `votes/current_period`. *) val get_rpc_fixed_current_info : Raw_context.t -> Voting_period_repr.info tzresult Lwt.t (* In order to avoid the problem of `get_current_info` explained above, this function provides the corrent behavior for the new RPC `votes/successor_period`. *) val get_rpc_fixed_succ_info : Raw_context.t -> Voting_period_repr.info tzresult Lwt.t
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
dune
(test (name test) (package progress) (libraries progress alcotest astring fmt mtime))
theory_dense_diff_logic.h
#pragma once #include "smt/theory_arith.h" #include "smt/params/theory_arith_params.h" #include "ast/arith_decl_plugin.h" #include "smt/arith_eq_adapter.h" #include "smt/theory_opt.h" namespace smt { struct theory_dense_diff_logic_statistics { unsigned m_num_assertions; unsigned m_num_propagations; void reset() { m_num_assertions = 0; m_num_propagations = 0; } theory_dense_diff_logic_statistics() { reset(); } }; template<typename Ext> class theory_dense_diff_logic : public theory, public theory_opt, private Ext { public: theory_dense_diff_logic_statistics m_stats; private: typedef typename Ext::inf_numeral numeral; class atom { typedef typename Ext::inf_numeral numeral; bool_var m_bvar; theory_var m_source; theory_var m_target; numeral m_offset; public: atom(bool_var bv, theory_var source, theory_var target, numeral const & offset): m_bvar(bv), m_source(source), m_target(target), m_offset(offset) { } bool_var get_bool_var() const { return m_bvar; } theory_var get_source() const { return m_source; } theory_var get_target() const { return m_target; } numeral const & get_offset() const { return m_offset; } }; typedef ptr_vector<atom> atoms; typedef ptr_vector<atom> bool_var2atom; struct edge { theory_var m_source; theory_var m_target; numeral m_offset; literal m_justification; edge():m_source(null_theory_var), m_target(null_theory_var), m_justification(null_literal) {} edge(theory_var s, theory_var t, numeral const & offset, literal js): m_source(s), m_target(t), m_offset(offset), m_justification(js) { } }; typedef int edge_id; typedef vector<edge> edges; static const edge_id null_edge_id = -1; static const edge_id self_edge_id = 0; struct cell { edge_id m_edge_id; numeral m_distance; atoms m_occs; cell(): m_edge_id(null_edge_id) { } }; struct cell_trail { unsigned short m_source; unsigned short m_target; edge_id m_old_edge_id; numeral m_old_distance; cell_trail(unsigned short s, unsigned short t, edge_id old_edge_id, numeral const & old_distance): m_source(s), m_target(t), m_old_edge_id(old_edge_id), m_old_distance(old_distance) {} }; typedef vector<cell> row; typedef vector<row> matrix; struct scope { unsigned m_atoms_lim; unsigned m_edges_lim; unsigned m_cell_trail_lim; }; theory_arith_params & m_params; arith_util m_autil; arith_eq_adapter m_arith_eq_adapter; atoms m_atoms; atoms m_bv2atoms; edges m_edges; // list of asserted edges matrix m_matrix; bool_vector m_is_int; vector<cell_trail> m_cell_trail; svector<scope> m_scopes; bool m_non_diff_logic_exprs; // For optimization purpose typedef vector <std::pair<theory_var, rational> > objective_term; vector<objective_term> m_objectives; vector<rational> m_objective_consts; vector<expr_ref_vector> m_objective_assignments; struct f_target { theory_var m_target; numeral m_new_distance; }; typedef std::pair<theory_var, theory_var> var_pair; typedef vector<f_target> f_targets; literal_vector m_tmp_literals; svector<var_pair> m_tmp_pairs; f_targets m_f_targets; vector<numeral> m_assignment; struct var_value_hash; friend struct var_value_hash; struct var_value_hash { theory_dense_diff_logic & m_th; var_value_hash(theory_dense_diff_logic & th):m_th(th) {} unsigned operator()(theory_var v) const { return m_th.m_assignment[v].hash(); } }; struct var_value_eq; friend struct var_value_eq; struct var_value_eq { theory_dense_diff_logic & m_th; var_value_eq(theory_dense_diff_logic & th):m_th(th) {} bool operator()(theory_var v1, theory_var v2) const { return m_th.m_assignment[v1] == m_th.m_assignment[v2]; } }; typedef int_hashtable<var_value_hash, var_value_eq> var_value_table; var_value_table m_var_value_table; // ----------------------------------- // // Auxiliary // // ----------------------------------- bool is_int(theory_var v) const { return m_is_int[v]; } bool is_real(theory_var v) const { return !is_int(v); } numeral const & get_epsilon(theory_var v) const { return is_real(v) ? this->m_real_epsilon : this->m_int_epsilon; } bool is_times_minus_one(expr * n, app * & r) const { expr * _r; if (m_autil.is_times_minus_one(n, _r)) { r = to_app(_r); return true; } return false; } app * mk_zero_for(expr * n); theory_var mk_var(enode * n) override; theory_var internalize_term_core(app * n); void found_non_diff_logic_expr(expr * n); bool is_connected(theory_var source, theory_var target) const { return m_matrix[source][target].m_edge_id != null_edge_id; } void mk_clause(literal l1, literal l2); void mk_clause(literal l1, literal l2, literal l3); void add_edge(theory_var source, theory_var target, numeral const & offset, literal l); void update_cells(); void propagate_using_cell(theory_var source, theory_var target); void get_antecedents(theory_var source, theory_var target, literal_vector & result); void assign_literal(literal l, theory_var source, theory_var target); void restore_cells(unsigned old_size); void del_atoms(unsigned old_size); void del_vars(unsigned old_num_vars); void init_model(); bool internalize_objective(expr * n, rational const& m, rational& r, objective_term & objective); expr_ref mk_ineq(theory_var v, inf_eps const& val, bool is_strict); #ifdef Z3DEBUG bool check_vector_sizes() const; bool check_matrix() const; #endif public: numeral const & get_distance(theory_var source, theory_var target) const { SASSERT(is_connected(source, target)); return m_matrix[source][target].m_distance; } // ----------------------------------- // // Internalization // // ----------------------------------- bool internalize_atom(app * n, bool gate_ctx) override; bool internalize_term(app * term) override; void internalize_eq_eh(app * atom, bool_var v) override; void apply_sort_cnstr(enode * n, sort * s) override; void assign_eh(bool_var v, bool is_true) override; void new_eq_eh(theory_var v1, theory_var v2) override; bool use_diseqs() const override; void new_diseq_eh(theory_var v1, theory_var v2) override; void conflict_resolution_eh(app * atom, bool_var v) override; void push_scope_eh() override; void pop_scope_eh(unsigned num_scopes) override; void restart_eh() override; void init_search_eh() override; final_check_status final_check_eh() override; bool can_propagate() override; void propagate() override; void flush_eh() override; void reset_eh() override; void display(std::ostream & out) const override; virtual void display_atom(std::ostream & out, atom * a) const; void collect_statistics(::statistics & st) const override; // ----------------------------------- // // Model generation // // ----------------------------------- arith_factory * m_factory; rational m_epsilon; // void update_epsilon(const inf_numeral & l, const inf_numeral & u); void compute_epsilon(); void fix_zero(); void init_model(model_generator & m) override; model_value_proc * mk_value(enode * n, model_generator & mg) override; // ----------------------------------- // // Optimization // // ----------------------------------- inf_eps_rational<inf_rational> maximize(theory_var v, expr_ref& blocker, bool& has_shared) override; inf_eps_rational<inf_rational> value(theory_var v) override; theory_var add_objective(app* term) override; virtual expr_ref mk_gt(theory_var v, inf_eps const& val); expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val); // ----------------------------------- // // Main // // ----------------------------------- public: theory_dense_diff_logic(context& ctx); ~theory_dense_diff_logic() override { reset_eh(); } theory * mk_fresh(context * new_ctx) override; char const * get_name() const override { return "difference-logic"; } /** \brief See comment in theory::mk_eq_atom */ app * mk_eq_atom(expr * lhs, expr * rhs) override { return m_autil.mk_eq(lhs, rhs); } }; typedef theory_dense_diff_logic<mi_ext> theory_dense_mi; typedef theory_dense_diff_logic<i_ext> theory_dense_i; typedef theory_dense_diff_logic<smi_ext> theory_dense_smi; typedef theory_dense_diff_logic<si_ext> theory_dense_si; };
/*++ Copyright (c) 2006 Microsoft Corporation Module Name: theory_dense_diff_logic.h Abstract: <abstract> Author: Leonardo de Moura (leonardo) 2008-05-16. Revision History: TODO: eager equality propagation --*/
pg_query_internal.h
#ifndef PG_QUERY_INTERNAL_H #define PG_QUERY_INTERNAL_H #include "postgres.h" #include "utils/memutils.h" #include "nodes/pg_list.h" #define STDERR_BUFFER_LEN 4096 #define DEBUG typedef struct { List *tree; char* stderr_buffer; PgQueryError* error; } PgQueryInternalParsetreeAndError; PgQueryInternalParsetreeAndError pg_query_raw_parse(const char* input); void pg_query_free_error(PgQueryError *error); MemoryContext pg_query_enter_memory_context(); void pg_query_exit_memory_context(MemoryContext ctx); #endif
identifiable.mli
(** Uniform interface for common data structures over various things. {b Warning:} this module is unstable and part of {{!Compiler_libs}compiler-libs}. *) module type Thing = sig type t include Hashtbl.HashedType with type t := t include Map.OrderedType with type t := t val output : out_channel -> t -> unit val print : Format.formatter -> t -> unit end module Pair : functor (A : Thing) (B : Thing) -> Thing with type t = A.t * B.t module type Set = sig module T : Set.OrderedType include Set.S with type elt = T.t and type t = Set.Make (T).t val output : out_channel -> t -> unit val print : Format.formatter -> t -> unit val to_string : t -> string val of_list : elt list -> t val map : (elt -> elt) -> t -> t end module type Map = sig module T : Map.OrderedType include Map.S with type key = T.t and type 'a t = 'a Map.Make (T).t val of_list : (key * 'a) list -> 'a t (** [disjoint_union m1 m2] contains all bindings from [m1] and [m2]. If some binding is present in both and the associated value is not equal, a Fatal_error is raised *) val disjoint_union : ?eq:('a -> 'a -> bool) -> ?print:(Format.formatter -> 'a -> unit) -> 'a t -> 'a t -> 'a t (** [union_right m1 m2] contains all bindings from [m1] and [m2]. If some binding is present in both, the one from [m2] is taken *) val union_right : 'a t -> 'a t -> 'a t (** [union_left m1 m2 = union_right m2 m1] *) val union_left : 'a t -> 'a t -> 'a t val union_merge : ('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t val rename : key t -> key -> key val map_keys : (key -> key) -> 'a t -> 'a t val keys : 'a t -> Set.Make(T).t val data : 'a t -> 'a list val of_set : (key -> 'a) -> Set.Make(T).t -> 'a t val transpose_keys_and_data : key t -> key t val transpose_keys_and_data_set : key t -> Set.Make(T).t t val print : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit end module type Tbl = sig module T : sig type t include Map.OrderedType with type t := t include Hashtbl.HashedType with type t := t end include Hashtbl.S with type key = T.t and type 'a t = 'a Hashtbl.Make (T).t val to_list : 'a t -> (T.t * 'a) list val of_list : (T.t * 'a) list -> 'a t val to_map : 'a t -> 'a Map.Make(T).t val of_map : 'a Map.Make(T).t -> 'a t val memoize : 'a t -> (key -> 'a) -> key -> 'a val map : 'a t -> ('a -> 'b) -> 'b t end module type S = sig type t module T : Thing with type t = t include Thing with type t := T.t module Set : Set with module T := T module Map : Map with module T := T module Tbl : Tbl with module T := T end module Make (T : Thing) : S with type t := T.t
(**************************************************************************) (* *) (* OCaml *) (* *) (* Pierre Chambart, OCamlPro *) (* Mark Shinwell and Leo White, Jane Street Europe *) (* *) (* Copyright 2013--2016 OCamlPro SAS *) (* Copyright 2014--2016 Jane Street Group LLC *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) (* special exception on linking described in the file LICENSE. *) (* *) (**************************************************************************)
script_repr.mli
type location = Micheline.canonical_location type annot = Micheline.annot type expr = Michelson_v1_primitives.prim Micheline.canonical type error += Lazy_script_decode (* `Permanent *) type lazy_expr = expr Data_encoding.lazy_t type node = (location, Michelson_v1_primitives.prim) Micheline.node val location_encoding : location Data_encoding.t val expr_encoding : expr Data_encoding.t val lazy_expr_encoding : lazy_expr Data_encoding.t val lazy_expr : expr -> lazy_expr type t = {code : lazy_expr; storage : lazy_expr} val encoding : t Data_encoding.encoding val deserialized_cost : expr -> Gas_limit_repr.cost val serialized_cost : bytes -> Gas_limit_repr.cost val traversal_cost : node -> Gas_limit_repr.cost val int_node_cost : Z.t -> Gas_limit_repr.cost val int_node_cost_of_numbits : int -> Gas_limit_repr.cost val string_node_cost : string -> Gas_limit_repr.cost val string_node_cost_of_length : int -> Gas_limit_repr.cost val bytes_node_cost : bytes -> Gas_limit_repr.cost val bytes_node_cost_of_length : int -> Gas_limit_repr.cost val prim_node_cost_nonrec : expr list -> annot -> Gas_limit_repr.cost val seq_node_cost_nonrec : expr list -> Gas_limit_repr.cost val seq_node_cost_nonrec_of_length : int -> Gas_limit_repr.cost val force_decode : lazy_expr -> (expr * Gas_limit_repr.cost) tzresult val force_bytes : lazy_expr -> (bytes * Gas_limit_repr.cost) tzresult val minimal_deserialize_cost : lazy_expr -> Gas_limit_repr.cost val unit_parameter : lazy_expr val is_unit_parameter : lazy_expr -> bool val strip_annotations : node -> node val micheline_nodes : node -> int val strip_locations_cost : node -> Gas_limit_repr.cost
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
execution_parameters.mli
(** Parameters that influence rule execution *) (** Such as: - should targets be set read-only? - should aliases be expanded when sandboxing rules? These often depend on the version of the Dune language used, which is written in the [dune-project] file. Depending on the execution parameters rather than the whole [dune-project] file means that when some part of the [dune-project] file changes and this part does not have an effect on rule execution, we can skip a bunch of work by not trying to re-execute all the rules. *) type t val equal : t -> t -> bool val hash : t -> int val to_dyn : t -> Dyn.t module Action_output_on_success : sig (** How to deal with the output (stdout/stderr) of actions when they succeed. *) type t = | Print (** Print it to the terminal. *) | Swallow (** Completely ignore it. There is no way for the user to access it but the output of Dune is clean. *) | Must_be_empty (** Require it to be empty. Treat the action as failed if it is not. *) val all : (string * t) list val equal : t -> t -> bool val hash : t -> int val to_dyn : t -> Dyn.t end (** {1 Constructors} *) val builtin_default : t val set_dune_version : Dune_lang.Syntax.Version.t -> t -> t val set_action_stdout_on_success : Action_output_on_success.t -> t -> t val set_action_stderr_on_success : Action_output_on_success.t -> t -> t val set_expand_aliases_in_sandbox : bool -> t -> t val add_workspace_root_to_build_path_prefix_map : t -> bool (** As configured by [init] *) val default : t Memo.t (** {1 Accessors} *) val dune_version : t -> Dune_lang.Syntax.Version.t val should_remove_write_permissions_on_generated_files : t -> bool val expand_aliases_in_sandbox : t -> bool val action_stdout_on_success : t -> Action_output_on_success.t val action_stderr_on_success : t -> Action_output_on_success.t (** {1 Initialisation} *) val init : t Memo.t -> unit
(** Parameters that influence rule execution *)
test_helpers.mli
val fixture : string -> Cstruct.t (** Reads a file in [tests/keys] *)
resource_types.mli
(** resource.proto Types *) (** {2 Types} *) type resource = { attributes : Common_types.key_value list; dropped_attributes_count : int32; } (** {2 Default values} *) val default_resource : ?attributes:Common_types.key_value list -> ?dropped_attributes_count:int32 -> unit -> resource (** [default_resource ()] is the default value for type [resource] *)
(** resource.proto Types *)
dynlink_platform_intf.ml
#2 "otherlibs/dynlink/dynlink_platform_intf.ml" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* Mark Shinwell and Leo White, Jane Street Europe *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* Copyright 2017--2018 Jane Street Group LLC *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) (* special exception on linking described in the file LICENSE. *) (* *) (**************************************************************************) (** Interface for platform-specific dynlink providers. Note that this file needs to be a valid .mli file. *) [@@@ocaml.warning "+a-4-30-40-41-42"] module type S = sig type handle module Unit_header : sig type t val name : t -> string val crc : t -> Digest.t option val interface_imports : t -> (string * Digest.t option) list val implementation_imports : t -> (string * Digest.t option) list val defined_symbols : t -> string list val unsafe_module : t -> bool end val init : unit -> unit val is_native : bool val adapt_filename : Dynlink_types.filename -> Dynlink_types.filename val num_globals_inited : unit -> int val fold_initial_units : init:'a -> f:('a -> comp_unit:string -> interface:Digest.t option -> implementation:(Digest.t option * Dynlink_types.implem_state) option -> defined_symbols:string list -> 'a) -> 'a val load : filename:Dynlink_types.filename -> priv:bool -> handle * (Unit_header.t list) val run_shared_startup : handle -> unit val run : handle -> unit_header:Unit_header.t -> priv:bool -> unit val finish : handle -> unit end
raw_level_repr.mli
(** The shell's notion of a level: an integer indicating the number of blocks since genesis: genesis is 0, all other blocks have increasing levels from there. *) type t type raw_level = t val encoding : raw_level Data_encoding.t val rpc_arg : raw_level RPC_arg.arg val pp : Format.formatter -> raw_level -> unit include Compare.S with type t := raw_level val to_int32 : raw_level -> int32 val of_int32_exn : int32 -> raw_level val of_int32 : int32 -> raw_level tzresult val diff : raw_level -> raw_level -> int32 val root : raw_level val succ : raw_level -> raw_level val pred : raw_level -> raw_level option module Index : Storage_description.INDEX with type t = raw_level
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************)
pp.ml
Ppxlib.Driver.standalone ()
lib_relocated.ml
module Elsewhere : sig module Foo : module type of Repr type t [@@deriving repr { lib = Some "Foo" }] end = struct module Foo = Repr module Irmin = struct end type t = unit * unit [@@deriving repr { lib = Some "Foo" }] end module Locally_avaliable : sig type 'a ty type t [@@deriving repr { lib = None }] end = struct let pair, unit = Repr.(pair, unit) type 'a ty = 'a Repr.ty module Irmin = struct end type t = unit * unit [@@deriving repr { lib = None }] end
recursive_module_evaluation_errors.ml
(* TEST * expect *) module rec A: sig val x: int end = struct let x = B.x end and B:sig val x: int end = struct let x = E.y end and C:sig val x: int end = struct let x = B.x end and D:sig val x: int end = struct let x = C.x end and E:sig val x: int val y:int end = struct let x = D.x let y = 0 end [%%expect {| Line 2, characters 27-49: 2 | and B:sig val x: int end = struct let x = E.y end ^^^^^^^^^^^^^^^^^^^^^^ Error: Cannot safely evaluate the definition of the following cycle of recursively-defined modules: B -> E -> D -> C -> B. There are no safe modules in this cycle (see manual section 8.2). Line 2, characters 10-20: 2 | and B:sig val x: int end = struct let x = E.y end ^^^^^^^^^^ Module B defines an unsafe value, x . Line 5, characters 10-20: 5 | and E:sig val x: int val y:int end = struct let x = D.x let y = 0 end ^^^^^^^^^^ Module E defines an unsafe value, x . Line 4, characters 10-20: 4 | and D:sig val x: int end = struct let x = C.x end ^^^^^^^^^^ Module D defines an unsafe value, x . Line 3, characters 10-20: 3 | and C:sig val x: int end = struct let x = B.x end ^^^^^^^^^^ Module C defines an unsafe value, x . |}] type t = .. module rec A: sig type t += A end = struct type t += A = B.A end and B:sig type t += A end = struct type t += A = A.A end [%%expect {| type t = .. Line 2, characters 36-64: 2 | module rec A: sig type t += A end = struct type t += A = B.A end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error: Cannot safely evaluate the definition of the following cycle of recursively-defined modules: A -> B -> A. There are no safe modules in this cycle (see manual section 8.2). Line 2, characters 28-29: 2 | module rec A: sig type t += A end = struct type t += A = B.A end ^ Module A defines an unsafe extension constructor, A . Line 3, characters 20-21: 3 | and B:sig type t += A end = struct type t += A = A.A end ^ Module B defines an unsafe extension constructor, A . |}] module rec A: sig module F: functor(X:sig end) -> sig end val f: unit -> unit end = struct module F(X:sig end) = struct end let f () = B.value end and B: sig val value: unit end = struct let value = A.f () end [%%expect {| Line 4, characters 6-72: 4 | ......struct 5 | module F(X:sig end) = struct end 6 | let f () = B.value 7 | end Error: Cannot safely evaluate the definition of the following cycle of recursively-defined modules: A -> B -> A. There are no safe modules in this cycle (see manual section 8.2). Line 2, characters 2-41: 2 | module F: functor(X:sig end) -> sig end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Module A defines an unsafe functor, F . Line 8, characters 11-26: 8 | and B: sig val value: unit end = struct let value = A.f () end ^^^^^^^^^^^^^^^ Module B defines an unsafe value, value . |}] module F(X: sig module type t module M: t end) = struct module rec A: sig module M: X.t val f: unit -> unit end = struct module M = X.M let f () = B.value end and B: sig val value: unit end = struct let value = A.f () end end [%%expect {| Line 5, characters 8-62: 5 | ........struct 6 | module M = X.M 7 | let f () = B.value 8 | end Error: Cannot safely evaluate the definition of the following cycle of recursively-defined modules: A -> B -> A. There are no safe modules in this cycle (see manual section 8.2). Line 3, characters 4-17: 3 | module M: X.t ^^^^^^^^^^^^^ Module A defines an unsafe module, M . Line 9, characters 13-28: 9 | and B: sig val value: unit end = struct let value = A.f () end ^^^^^^^^^^^^^^^ Module B defines an unsafe value, value . |}] module rec M: sig val f: unit -> int end = struct let f () = N.x end and N:sig val x: int end = struct let x = M.f () end;; [%%expect {| Exception: Undefined_recursive_module ("", 1, 43). |}]
(* TEST * expect *)
native_io.mli
open Fmlib module IO: Io.SIG
mul_KS.c
#include "fq_poly.h" #ifdef T #undef T #endif #define T fq #define CAP_T FQ #include "fq_poly_templates/mul_KS.c" #undef CAP_T #undef T
/* Copyright (C) 2008, 2009 William Hart Copyright (C) 2010, 2012 Sebastian Pancratz Copyright (C) 2013 Mike Hansen This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */

Dataset Card for "opam-source"

More Information needed

Downloads last month
124
Edit dataset card

Models trained or fine-tuned on sadiqj/opam-source