@@ -5,7 +5,7 @@ import Test.Hspec
5
5
import Data.Set (Set )
6
6
import Autotool.DAO (toValue )
7
7
import qualified Autotool.DAO.Set as DAO
8
- import Autotool.Data.RelOp ( (&) , (+) , (-) , (*) )
8
+ import Autotool.Data.RelOp ( (&) , (+) , (-) , (*) , inverse , transitiveClosure , reflexiveClosure )
9
9
import Autotool.Data.LazyTree ( Tree (Node ), mkOp0 )
10
10
import Autotool.TreeSearch (SearchMode (.. ))
11
11
import Autotool.Solver.Relations (solve )
@@ -85,6 +85,24 @@ spec = do
85
85
]
86
86
]
87
87
in solve (Parallel 10000 ) ops u t `shouldBe` result
88
+ it " finds term w/ a target value from a set of relations and operations (including inverse, transitive_cl, reflexive_cl)" $
89
+ let
90
+ r = mkOp0 " r" $ readSet " {(1 , 2) , (4 , 3)}"
91
+ s = mkOp0 " s" $ readSet " {(1 , 3) , (2 , 4)}"
92
+ t = readSet " {(3 , 1)}"
93
+ u = [1 ,2 ,3 ,4 ] :: [Int ]
94
+ ops = [ r, s, (+) , (&) , (-) , (*) , inverse, transitiveClosure, reflexiveClosure ]
95
+ result =
96
+ Node inverse [
97
+ Node (*) [
98
+ Node r [] ,
99
+ Node (*) [
100
+ Node s [] ,
101
+ Node r []
102
+ ]
103
+ ]
104
+ ]
105
+ in solve (Parallel 10000 ) ops u t `shouldBe` result
88
106
89
107
readSet :: String -> Set (Int ,Int )
90
108
readSet s = let dao = read s :: DAO. Set (Int ,Int ) in toValue dao
0 commit comments