package orgeat

  1. Overview
  2. Docs

Parameters

module K : Scalar.S

Signature

module Boltzmann : sig ... end

Tree representation of the definition of a combinatorial class

Note: the functions in Map should be bijections whenever possible. Not doing so is not a problem in itself, but we can predict what will happen:

  • without injectivity, some elements will have a greater probability of occurence;
  • without surjectivity, the sampling will not be exhaustive. Please keep this notion in mind when manually creating class_trees.
type sequence_kind = {
  1. min : int;
  2. max : int option;
}
val unbounded_seq : sequence_kind
val bounded_seq : int -> int option -> sequence_kind
type _ class_tree =
  1. | One : unit class_tree
  2. | Scalar : K.t -> unit class_tree
  3. | Z : unit class_tree
  4. | Empty : 'a class_tree
  5. | Sampler : 'a Sampler.t -> 'a class_tree
  6. | Class : 'a combi_class -> 'a class_tree
  7. | Union : 'a class_tree list -> 'a class_tree
  8. | Product : 'a class_tree * 'b class_tree -> ('a * 'b) class_tree
  9. | Sequence : sequence_kind * 'a class_tree -> 'a list class_tree
  10. | Map : 'a class_tree * ('a -> 'b) -> 'b class_tree
and 'a solved_tree =
  1. | T : (K.t * 'a stub) -> 'a solved_tree
and 'a stub =
  1. | S_One : unit stub
  2. | S_Z : unit stub
  3. | S_Sampler : 'a Sampler.t -> 'a stub
  4. | S_Empty : 'a stub
  5. | S_Class : 'a combi_class -> 'a stub
  6. | S_Union : 'a solved_tree list -> 'a stub
  7. | S_Product : 'a solved_tree * 'b solved_tree -> ('a * 'b) stub
  8. | S_Sequence : sequence_kind * 'a solved_tree -> 'a list stub
  9. | S_Map : 'a solved_tree * ('a -> 'b) -> 'b stub
and 'a combi_class = {
  1. name : Literal.Class.t;
  2. mutable class_tree : 'a class_tree option;
  3. mutable solved_tree : 'a solved_tree option;
}

Reference to a class_tree with a name. Allows for mutual recursion.

val get_name : 'a combi_class -> Literal.Class.t
val get_class : 'a combi_class -> 'a class_tree option
val get_solved : 'a combi_class -> 'a solved_tree option
val new_class : Literal.Class.t -> 'a combi_class
val new_class_of_str : string -> 'a combi_class
val reset_class : 'a combi_class -> unit
val update_class : 'a combi_class -> 'a class_tree -> unit
val reset_solved : 'a combi_class -> unit
val update_solved : 'a combi_class -> 'a solved_tree -> unit
val tup2 : 'a class_tree -> 'b class_tree -> ('a * 'b) class_tree

tupn generates a t class_tree where t is a tuple of size n Useful before a Map to build records.

val tup3 : 'a class_tree -> 'b class_tree -> 'c class_tree -> ('d * 'e * 'f) class_tree
val tup4 : 'a class_tree -> 'b class_tree -> 'c class_tree -> 'd class_tree -> ('e * 'f * 'g * 'h) class_tree
val tup5 : 'a class_tree -> 'b class_tree -> 'c class_tree -> 'd class_tree -> 'e class_tree -> ('f * 'g * 'h * 'i * 'j) class_tree
val mul_scalar : K.t -> 'a class_tree -> 'b class_tree

mul_scalar k t multiplies the given tree t with a weight k. Used to skew the distribution without changing the generated objects.

val (+) : 'a class_tree -> 'a class_tree -> 'b class_tree
val (*) : 'a class_tree -> 'b class_tree -> ('a * 'b) class_tree
val z : 'a class_tree -> 'b class_tree
val seq : 'a class_tree -> 'a list class_tree
val seq_bounded : min:int -> ?max:int -> 'a class_tree -> 'a list class_tree
val option : 'a class_tree -> 'b option class_tree
val stub_node_to_string : 'a. 'a stub -> string
val solved_node_to_string : 'a. 'a solved_tree -> string
val solved_to_strings : 'a. 'a solved_tree -> string list
val pp_solved_tree : Stdlib.Format.formatter -> 'a solved_tree -> unit