package ego
Library
Module
Module type
Parameter
Class
Class type
This module defines the main interface to the EGraph provided by Ego.Basic
.
pp ?pp_id fmt graph
prints an internal representation of the graph
.
Note: This is primarily intended for debugging, and the output format is not guaranteed to remain consistent over versions.
val pp_dot : Stdlib.Format.formatter -> t -> unit
pp_dot fmt graph
pretty prints graph
in a Graphviz format.
val init : unit -> t
init ()
creates a new EGraph.
add_sexp graph sexp
adds sexp
to graph
and returns the equivalence class associated with term.
val to_dot : t -> Odot.graph
to_dot graph
converts graph
into a Graphviz representation.
val rebuild : t -> unit
extract cost_fn graph
computes an extraction function Id.t
-> Sexplib0.Sexp.t
to extract terms (specified by Id.t
) from the EGraph.
cost_fn f (sym,children)
should assign costs to the node with tag sym
and children children
- it can use f
to determine the cost of a child.
apply_rules graph rules
runs each of the rewrites in rules
exactly once over the egraph graph
and then returns.
run_until_saturation ?fuel graph rules
repeatedly each one of the rewrites in rules
until no further changes occur (i.e equality saturation), or until it runs out of fuel
.
It returns a boolean indicating whether it reached equality saturation or had to terminate early.