-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
91 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# Revision history for hsym | ||
# Revision history for hegg | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
## Unreleased | ||
|
||
* Make e-graph abstract. The internal structure can still be modified to some | ||
extent using Data.Equality.Graph.Lens | ||
|
||
## 0.1.0.0 -- 2022-08-25 | ||
|
||
* First version. Released on an unsuspecting world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE UndecidableInstances #-} -- tmp show | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# OPTIONS_HADDOCK hide #-} | ||
{-| | ||
Non-abstract definition of e-graphs | ||
-} | ||
module Data.Equality.Graph.Internal where | ||
|
||
import Data.Functor.Classes | ||
|
||
import Data.Equality.Graph.ReprUnionFind | ||
import Data.Equality.Graph.Classes | ||
import Data.Equality.Graph.Nodes | ||
import Data.Equality.Analysis | ||
|
||
-- | E-graph representing terms of language @l@. | ||
-- | ||
-- Intuitively, an e-graph is a set of equivalence classes (e-classes). Each e-class is a | ||
-- set of e-nodes representing equivalent terms from a given language, and an e-node is a function | ||
-- symbol paired with a list of children e-classes. | ||
data EGraph l = EGraph | ||
{ unionFind :: !ReprUnionFind -- ^ Union find like structure to find canonical representation of an e-class id | ||
, classes :: !(ClassIdMap (EClass l)) -- ^ Map canonical e-class ids to their e-classes | ||
, memo :: !(Memo l) -- ^ Hashcons maps all canonical e-nodes to their e-class ids | ||
, worklist :: !(Worklist l) -- ^ Worklist of e-class ids that need to be upward merged | ||
, analysisWorklist :: !(Worklist l) -- ^ Like 'worklist' but for analysis repairing | ||
} | ||
|
||
-- | The hashcons π» is a map from e-nodes to e-class ids | ||
type Memo l = NodeMap l ClassId | ||
|
||
-- | Maintained worklist of e-class ids that need to be βupward mergedβ | ||
type Worklist l = NodeMap l ClassId | ||
|
||
instance (Show (Domain l), Show1 l) => Show (EGraph l) where | ||
show (EGraph a b c d e) = | ||
"UnionFind: " <> show a <> | ||
"\n\nE-Classes: " <> show b <> | ||
"\n\nHashcons: " <> show c <> | ||
"\n\nWorklist: " <> show d <> | ||
"\n\nAnalWorklist: " <> show e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE RoleAnnotations #-} | ||
{-# LANGUAGE StandaloneKindSignatures #-} | ||
module Data.Equality.Graph.Internal where | ||
|
||
import Data.Kind | ||
|
||
type EGraph :: (Type -> Type) -> Type | ||
type role EGraph nominal | ||
data EGraph l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters