srtree
Copyright(c) Fabricio Olivetti 2021 - 2024
LicenseBSD3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
Portability
Safe HaskellNone
LanguageHaskell2010

Algorithm.EqSat.Egraph

Description

Equality Graph data structure Heavily based on hegg (https:/github.comalt-romes/hegg by alt-romes)

Synopsis

Documentation

type EGraphST (m :: Type -> Type) a = StateT EGraph m a Source #

type Cost = Int Source #

type RangeTree a = Seq (a, EClassId) Source #

encodeEnode :: ENode -> ENodeEnc Source #

this assumes up to 999 variables and params

insertRange :: (Ord a, Show a) => EClassId -> a -> RangeTree a -> RangeTree a Source #

removeRange :: (Ord a, Show a) => EClassId -> a -> RangeTree a -> RangeTree a Source #

getWithinRange :: Ord a => a -> a -> RangeTree a -> [EClassId] Source #

data EGraph Source #

Instances

Instances details
Binary EGraph Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: EGraph -> Put #

get :: Get EGraph #

putList :: [EGraph] -> Put #

Generic EGraph Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Associated Types

type Rep EGraph 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

from :: EGraph -> Rep EGraph x #

to :: Rep EGraph x -> EGraph #

Show EGraph Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep EGraph Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

data EGraphDB Source #

Instances

Instances details
Binary EGraphDB Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: EGraphDB -> Put #

get :: Get EGraphDB #

putList :: [EGraphDB] -> Put #

Generic EGraphDB Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Associated Types

type Rep EGraphDB 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

from :: EGraphDB -> Rep EGraphDB x #

to :: Rep EGraphDB x -> EGraphDB #

Show EGraphDB Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep EGraphDB Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

data EClass Source #

Instances

Instances details
Binary EClass Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: EClass -> Put #

get :: Get EClass #

putList :: [EClass] -> Put #

Generic EClass Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

from :: EClass -> Rep EClass x #

to :: Rep EClass x -> EClass #

Show EClass Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Eq EClass Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

(==) :: EClass -> EClass -> Bool #

(/=) :: EClass -> EClass -> Bool #

type Rep EClass Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

data Consts Source #

Instances

Instances details
Binary Consts Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: Consts -> Put #

get :: Get Consts #

putList :: [Consts] -> Put #

Generic Consts Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Associated Types

type Rep Consts 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep Consts = D1 ('MetaData "Consts" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) (C1 ('MetaCons "NotConst" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ParamIx" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "ConstVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Double))))

Methods

from :: Consts -> Rep Consts x #

to :: Rep Consts x -> Consts #

Show Consts Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Eq Consts Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

(==) :: Consts -> Consts -> Bool #

(/=) :: Consts -> Consts -> Bool #

type Rep Consts Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep Consts = D1 ('MetaData "Consts" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) (C1 ('MetaCons "NotConst" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ParamIx" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "ConstVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Double))))

data Property Source #

Constructors

Positive 
Negative 
NonZero 
Real 

Instances

Instances details
Binary Property Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: Property -> Put #

get :: Get Property #

putList :: [Property] -> Put #

Generic Property Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Associated Types

type Rep Property 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep Property = D1 ('MetaData "Property" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) ((C1 ('MetaCons "Positive" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Negative" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NonZero" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Real" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Property -> Rep Property x #

to :: Rep Property x -> Property #

Show Property Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Eq Property Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep Property Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep Property = D1 ('MetaData "Property" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) ((C1 ('MetaCons "Positive" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Negative" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NonZero" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Real" 'PrefixI 'False) (U1 :: Type -> Type)))

data EClassData Source #

Constructors

EData 

Instances

Instances details
Binary EClassData Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Generic EClassData Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Show EClassData Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Eq EClassData Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep EClassData Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Serialization

type DB = Map (SRTree ()) IntTrie Source #

data IntTrie Source #

Constructors

IntTrie 

Instances

Instances details
Binary IntTrie Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Methods

put :: IntTrie -> Put #

get :: Get IntTrie #

putList :: [IntTrie] -> Put #

Generic IntTrie Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

Associated Types

type Rep IntTrie 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep IntTrie = D1 ('MetaData "IntTrie" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) (C1 ('MetaCons "IntTrie" 'PrefixI 'True) (S1 ('MetaSel ('Just "_keys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashSet EClassId)) :*: S1 ('MetaSel ('Just "_trie") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (IntMap IntTrie))))

Methods

from :: IntTrie -> Rep IntTrie x #

to :: Rep IntTrie x -> IntTrie #

Show IntTrie Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep IntTrie Source # 
Instance details

Defined in Algorithm.EqSat.Egraph

type Rep IntTrie = D1 ('MetaData "IntTrie" "Algorithm.EqSat.Egraph" "srtree-2.0.0.4-inplace" 'False) (C1 ('MetaCons "IntTrie" 'PrefixI 'True) (S1 ('MetaSel ('Just "_keys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashSet EClassId)) :*: S1 ('MetaSel ('Just "_trie") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (IntMap IntTrie))))

E-Graph basic supporting functions

emptyGraph :: EGraph Source #

returns an empty e-graph

emptyDB :: EGraphDB Source #

returns an empty e-graph DB

createEClass :: EClassId -> ENode -> EClassData -> Int -> EClass Source #

Creates a new e-class from an e-class id, a new e-node, and the info of this e-class

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

gets the canonical id of an e-class

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

canonize the e-node children

getEClass :: forall (m :: Type -> Type). Monad m => EClassId -> EGraphST m EClass Source #

gets an e-class with id c

trie :: EClassId -> IntMap IntTrie -> IntTrie Source #

Creates a singleton trie from an e-class id

isConst :: forall (m :: Type -> Type). Monad m => EClassId -> EGraphST m Bool Source #

Check whether an e-class is a constant value

Orphan instances

Binary PVector Source # 
Instance details

Methods

put :: PVector -> Put #

get :: Get PVector #

putList :: [PVector] -> Put #

Hashable ENode Source # 
Instance details

Methods

hashWithSalt :: Int -> ENode -> Int #

hash :: ENode -> Int #

Binary (SRTree EClassId) Source # 
Instance details

Binary (SRTree ()) Source # 
Instance details

Methods

put :: SRTree () -> Put #

get :: Get (SRTree ()) #

putList :: [SRTree ()] -> Put #

(Binary a, Hashable a) => Binary (HashSet a) Source # 
Instance details

Methods

put :: HashSet a -> Put #

get :: Get (HashSet a) #

putList :: [HashSet a] -> Put #

Generic (EClassId, ENode) Source # 
Instance details

Associated Types

type Rep (a, b)

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Generics

Methods

from :: (EClassId, ENode) -> Rep (EClassId, ENode) x #

to :: Rep (EClassId, ENode) x -> (EClassId, ENode) #