Copyright | (c) Fabricio Olivetti 2021 - 2024 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | |
Safe Haskell | None |
Language | Haskell2010 |
Algorithm.EqSat.DB
Description
Pattern matching and rule application functions Heavily based on hegg (https:/github.comalt-romes/hegg by alt-romes)
Synopsis
- data Pattern
- data Rule
- type Query = [Atom]
- type Condition = Map ClassOrVar ClassOrVar -> EGraph -> Bool
- type ClassOrVar = Either EClassId Int
- data Atom = Atom ClassOrVar (SRTree ClassOrVar)
- unFixPat :: Pattern -> SRTree Pattern
- target :: Rule -> Pattern
- source :: Rule -> Pattern
- getConditions :: Rule -> [Condition]
- cleanDB :: forall (m :: Type -> Type). Monad m => EGraphST m ()
- match :: forall (m :: Type -> Type). Monad m => Pattern -> EGraphST m [(Map ClassOrVar ClassOrVar, ClassOrVar)]
- compileToQuery :: Pattern -> (Query, ClassOrVar)
- getInt :: ClassOrVar -> Int
- getElems :: SRTree a -> [a]
- genericJoin :: forall (m :: Type -> Type). Monad m => Query -> ClassOrVar -> EGraphST m [Map ClassOrVar ClassOrVar]
- domainX :: forall (m :: Type -> Type). Monad m => ClassOrVar -> Query -> ClassOrVar -> EGraphST m [ClassOrVar]
- intersectAtoms :: forall (m :: Type -> Type). Monad m => ClassOrVar -> Query -> ClassOrVar -> EGraphST m [EClassId]
- intersectTries :: ClassOrVar -> Map ClassOrVar EClassId -> IntTrie -> [ClassOrVar] -> Maybe (HashSet EClassId)
- updateVar :: ClassOrVar -> ClassOrVar -> Query -> Query
- isDiffFrom :: Int -> ClassOrVar -> Bool
- elemOfAtom :: ClassOrVar -> Atom -> Bool
- orderedVars :: Query -> [ClassOrVar]
Documentation
Instances
IsString Pattern Source # | |
Defined in Algorithm.EqSat.DB Methods fromString :: String -> Pattern # | |
Floating Pattern Source # | |
Num Pattern Source # | |
Fractional Pattern Source # | |
Show Pattern Source # | |
type Condition = Map ClassOrVar ClassOrVar -> EGraph -> Bool Source #
Constructors
Atom ClassOrVar (SRTree ClassOrVar) |
getConditions :: Rule -> [Condition] Source #
match :: forall (m :: Type -> Type). Monad m => Pattern -> EGraphST m [(Map ClassOrVar ClassOrVar, ClassOrVar)] Source #
Returns the substitution rules
for every match of the pattern source
inside the e-graph.
compileToQuery :: Pattern -> (Query, ClassOrVar) Source #
Returns a Query (list of atoms) of a pattern
getInt :: ClassOrVar -> Int Source #
genericJoin :: forall (m :: Type -> Type). Monad m => Query -> ClassOrVar -> EGraphST m [Map ClassOrVar ClassOrVar] Source #
Creates the substituion map for the pattern variables for each one of the matched subgraph
domainX :: forall (m :: Type -> Type). Monad m => ClassOrVar -> Query -> ClassOrVar -> EGraphST m [ClassOrVar] Source #
returns the e-class id for a certain variable that matches the pattern described by the atoms
intersectAtoms :: forall (m :: Type -> Type). Monad m => ClassOrVar -> Query -> ClassOrVar -> EGraphST m [EClassId] Source #
returns all e-class id that can matches this sequence of atoms
intersectTries :: ClassOrVar -> Map ClassOrVar EClassId -> IntTrie -> [ClassOrVar] -> Maybe (HashSet EClassId) Source #
searches for the intersection of e-class ids that matches each part of the query. Returns Nothing if the intersection is empty.
var is the current variable being investigated xs is the map of ids being investigated and their corresponding e-class id trie is the current trie of the pattern (i:ids) sequence of root : children of the atom to investigate NOTE: it must be Maybe Set to differentiate between empty set and no answer
updateVar :: ClassOrVar -> ClassOrVar -> Query -> Query Source #
updates all occurrence of var with the new id x
isDiffFrom :: Int -> ClassOrVar -> Bool Source #
checks whether two ClassOrVar are different only check if it is a pattern variable, else returns true
elemOfAtom :: ClassOrVar -> Atom -> Bool Source #
checks if v is an element of an atom
orderedVars :: Query -> [ClassOrVar] Source #
sorts the variables in a query by the most frequently occurring