package ego

  1. Overview
  2. Docs

This module Rule defines the rewrite interface for the EGraph, allowing users to express relatively complex transformations of expressions of the Language L.

type t

Represents rewrite rules over the language of the EGraph.

val make_constant : from:L.op Query.t -> into:L.op Query.t -> t

make_constant ~from ~into creates a rewrite rule from a pattern from into a schema into that applies a purely syntactic transformation.

val make_conditional : from:L.op Query.t -> into:L.op Query.t -> cond: ((Id.t L.shape, A.t, A.data, rw) egraph -> Id.t -> Id.t StringMap.t -> bool) -> t

make_conditional ~from ~into ~cond creates a syntactic rewrite rule from from to into that is conditionally applied based on some property cond of the EGraph, the root eclass of the sub-expression being transformed and the eclasses of all bound variables.

val make_dynamic : from:L.op Query.t -> generator: ((Id.t L.shape, A.t, A.data, rw) egraph -> Id.t -> Id.t StringMap.t -> L.op Query.t option) -> t

make_dynamic ~from ~generator creates a dynamic rewrite rule from a pattern from into a schema that is conditionally generated based on properties of the EGraph, the root eclass of the sub-expression being transformed and the eclasses of all bound variables

OCaml

Innovation. Community. Security.