srtree-2.0.0.2: A general library to work with Symbolic Regression expression trees.
Copyright(c) Fabricio Olivetti 2021 - 2024
LicenseBSD3
Maintainer[email protected]
Stabilityexperimental
Portability
Safe HaskellNone
LanguageHaskell2010

Algorithm.EqSat.Build

Description

Functions related to building and maintaining e-graphs Heavily based on hegg (https:/github.comalt-romes/hegg by alt-romes)

Synopsis

Documentation

add :: forall (m :: Type -> Type). Monad m => CostFun -> ENode -> EGraphST m EClassId Source #

adds a new or existing e-node (merging if necessary)

rebuild :: forall (m :: Type -> Type). Monad m => CostFun -> EGraphST m () Source #

rebuilds the e-graph after inserting or merging e-classes

repair :: forall (m :: Type -> Type). Monad m => CostFun -> EClassId -> ENode -> EGraphST m () Source #

repairs e-node by canonizing its children if the canonized e-node already exists in e-graph, merge the e-classes

repairAnalysis :: forall (m :: Type -> Type). Monad m => CostFun -> EClassId -> ENode -> EGraphST m () Source #

repair the analysis of the e-class considering the new added e-node

merge :: forall (m :: Type -> Type). Monad m => CostFun -> EClassId -> EClassId -> EGraphST m EClassId Source #

merge to equivalent e-classes

modifyEClass :: forall (m :: Type -> Type). Monad m => CostFun -> EClassId -> EGraphST m EClassId Source #

modify an e-class, e.g., add constant e-node and prune non-leaves

DB

createDB :: forall (m :: Type -> Type). Monad m => EGraphST m DB Source #

createDB creates a database of patterns from an e-graph it simply calls addToDB for every pair (e-node, e-class id) from the e-graph.

addToDB :: forall (m :: Type -> Type). Monad m => ENode -> EClassId -> EGraphST m () Source #

addToDB adds an e-node and e-class id to the database

populate :: Maybe IntTrie -> [EClassId] -> Maybe IntTrie Source #

Populates an IntTrie with a sequence of e-class ids

applyMatch :: forall (m :: Type -> Type). Monad m => CostFun -> Rule -> (Map ClassOrVar ClassOrVar, ClassOrVar) -> EGraphST m () Source #

classOfENode :: forall (m :: Type -> Type). Monad m => CostFun -> Map ClassOrVar ClassOrVar -> Pattern -> EGraphST m (Maybe EClassId) Source #

gets the e-node of the target of the rule TODO: add consts and modify

reprPrat :: forall (m :: Type -> Type). Monad m => CostFun -> Map ClassOrVar ClassOrVar -> Pattern -> EGraphST m EClassId Source #

adds the target of the rule into the e-graph

isValidConditions :: forall (m :: Type -> Type). Monad m => Condition -> (Map ClassOrVar ClassOrVar, ClassOrVar) -> EGraphST m Bool Source #

returns True if the condition of a rule is valid for that match

Tree to e-graph conversion and utility functions

fromTree :: forall (m :: Type -> Type). Monad m => CostFun -> Fix SRTree -> EGraphST m EClassId Source #

Creates an e-graph from an expression tree

fromTrees :: forall (m :: Type -> Type). Monad m => CostFun -> [Fix SRTree] -> EGraphST m [EClassId] Source #

Builds an e-graph from multiple independent trees

getBest :: forall (m :: Type -> Type). Monad m => EClassId -> EGraphST m (Fix SRTree) Source #

gets the best expression given the default cost function

getExpressionFrom :: forall (m :: Type -> Type). Monad m => EClassId -> EGraphST m (Fix SRTree) Source #

returns one expression rooted at e-class eId TODO: avoid loopings

getAllExpressionsFrom :: forall (m :: Type -> Type). Monad m => EClassId -> EGraphST m [Fix SRTree] Source #

returns all expressions rooted at e-class eId TODO: check for infinite list

getRndExpressionFrom :: EClassId -> EGraphST (State StdGen) (Fix SRTree) Source #

returns a random expression rooted at e-class eId

cleanMaps :: forall (m :: Type -> Type). Monad m => EGraphST m () Source #

forceState :: forall (m :: Type -> Type) s. Monad m => StateT s m () Source #