Copyright | (c) Fabricio Olivetti 2021 - 2024 |
---|---|
License | BSD3 |
Maintainer | fabricio.olivetti@gmail.com |
Stability | experimental |
Portability | |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Equality Graph data structure Heavily based on hegg (https:/github.comalt-romes/hegg by alt-romes)
Synopsis
- type EClassId = Int
- type ClassIdMap = IntMap
- type ENode = SRTree EClassId
- type EData = ()
- type EGraphST a = State EGraph a
- type Cost = Int
- type CostFun = SRTree Cost -> Cost
- data EGraph = EGraph {
- _canonicalMap :: ClassIdMap EClassId
- _eNodeToEClass :: Map ENode EClassId
- _eClass :: ClassIdMap EClass
- _worklist :: [(EClassId, ENode)]
- _analysis :: [(EClassId, ENode)]
- _nextId :: Int
- data EClass = EClass {}
- data Consts
- data Property
- data EClassData = EData {}
- worklist :: Lens' EGraph [(EClassId, ENode)]
- nextId :: Lens' EGraph Int
- eNodeToEClass :: Lens' EGraph (Map ENode EClassId)
- eClass :: Lens' EGraph (ClassIdMap EClass)
- canonicalMap :: Lens' EGraph (ClassIdMap EClassId)
- analysis :: Lens' EGraph [(EClassId, ENode)]
- parents :: Lens' EClass [(EClassId, ENode)]
- info :: Lens' EClass EClassData
- height :: Lens' EClass Int
- eNodes :: Lens' EClass (Set ENode)
- eClassId :: Lens' EClass Int
- cost :: Lens' EClassData Cost
- consts :: Lens' EClassData Consts
- best :: Lens' EClassData ENode
- add :: CostFun -> ENode -> EGraphST EClassId
- rebuild :: CostFun -> EGraphST ()
- repair :: CostFun -> EClassId -> ENode -> EGraphST ()
- repairAnalysis :: CostFun -> EClassId -> ENode -> EGraphST ()
- merge :: CostFun -> EClassId -> EClassId -> EGraphST EClassId
- modifyEClass :: CostFun -> EClassId -> EGraphST EClassId
- joinData :: EClassData -> EClassData -> EClassData
- makeAnalysis :: CostFun -> ENode -> EGraphST EClassData
- fromTree :: CostFun -> Fix SRTree -> (EClassId, EGraph)
- fromTrees :: CostFun -> [Fix SRTree] -> ([EClassId], EGraph)
- fromTreeWith :: CostFun -> EGraph -> Fix SRTree -> (EClassId, EGraph)
- findRootClasses :: EGraph -> [EClassId]
- getExpressionFrom :: EGraph -> EClassId -> Fix SRTree
- getAllExpressionsFrom :: EGraph -> EClassId -> [Fix SRTree]
- getRndExpressionFrom :: EGraph -> EClassId -> State StdGen (Fix SRTree)
- calculateHeights :: EGraphST ()
- canonical :: EClassId -> EGraphST EClassId
- canonical' :: EClassId -> EGraph -> EClassId
- canonize :: ENode -> EGraphST ENode
- sequence' :: Applicative f => SRTree (f a) -> f (SRTree a)
- children :: SRTree a -> [a]
- replaceChildren :: [a] -> SRTree b -> SRTree a
- getOperator :: SRTree a -> SRTree ()
- getEClass :: EClassId -> EGraphST EClass
- emptyGraph :: EGraph
- calculateCost :: CostFun -> SRTree EClassId -> EGraphST Cost
- calculateConsts :: SRTree EClassId -> EGraphST Consts
- combineConsts :: SRTree Consts -> Consts
Documentation
type ClassIdMap = IntMap #
EGraph | |
|
data EClassData #
Instances
Show EClassData # | |
Defined in Algorithm.EqSat.Egraph showsPrec :: Int -> EClassData -> ShowS # show :: EClassData -> String # showList :: [EClassData] -> ShowS # | |
Eq EClassData # | |
Defined in Algorithm.EqSat.Egraph (==) :: EClassData -> EClassData -> Bool # (/=) :: EClassData -> EClassData -> Bool # |
info :: Lens' EClass EClassData #
cost :: Lens' EClassData Cost #
consts :: Lens' EClassData Consts #
best :: Lens' EClassData ENode #
repair :: CostFun -> EClassId -> ENode -> EGraphST () #
repairs e-node by canonizing its children if the canonized e-node already exists in e-graph, merge the e-classes
repairAnalysis :: CostFun -> EClassId -> ENode -> EGraphST () #
repair the analysis of the e-class considering the new added e-node
joinData :: EClassData -> EClassData -> EClassData #
makeAnalysis :: CostFun -> ENode -> EGraphST EClassData #
Calculate e-node data (constant values and cost)
fromTrees :: CostFun -> [Fix SRTree] -> ([EClassId], EGraph) #
Builds an e-graph from multiple independent trees
fromTreeWith :: CostFun -> EGraph -> Fix SRTree -> (EClassId, EGraph) #
insert new tree into an existing e-graph
findRootClasses :: EGraph -> [EClassId] #
returns all the root e-classes (e-class without parents)
getAllExpressionsFrom :: EGraph -> EClassId -> [Fix SRTree] #
returns all expressions rooted at e-class eId
getRndExpressionFrom :: EGraph -> EClassId -> State StdGen (Fix SRTree) #
returns a random expression rooted at e-class eId
calculateHeights :: EGraphST () #
update the heights of each e-class won't work if there's no root
canonical' :: EClassId -> EGraph -> EClassId #
sequence' :: Applicative f => SRTree (f a) -> f (SRTree a) #
replaceChildren :: [a] -> SRTree b -> SRTree a #
getOperator :: SRTree a -> SRTree () #
emptyGraph :: EGraph #
returns an empty e-graph
combineConsts :: SRTree Consts -> Consts #