refining the tuple calculations
This commit is contained in:
parent
6848663caf
commit
591a24d755
@ -18,6 +18,9 @@ import Datalog.DatalogParser
|
|||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Utility.Utility
|
import Utility.Utility
|
||||||
|
import Control.Monad(guard)
|
||||||
|
import Data.Set (Set)
|
||||||
|
import Data.Set qualified as Set
|
||||||
|
|
||||||
data (DatalogDB db) => NaiveQE db = NaiveQE
|
data (DatalogDB db) => NaiveQE db = NaiveQE
|
||||||
{
|
{
|
||||||
@ -65,6 +68,12 @@ computeHerbrand db =
|
|||||||
foldr amalgamateRule newFacts (_rules relation) where
|
foldr amalgamateRule newFacts (_rules relation) where
|
||||||
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
||||||
amalgamateRule (RelationRule headVars body) newFacts =
|
amalgamateRule (RelationRule headVars body) newFacts =
|
||||||
-- allMaps headVars (allConstants db)
|
newFacts where
|
||||||
newFacts
|
(facts, changed) = newFacts
|
||||||
|
knownTuples :: Set [Constant] = _tuples $ facts Map.! (_name relation)
|
||||||
|
extraTuples = do
|
||||||
|
varmap <- allMaps headVars (Set.toList $ allConstants db)
|
||||||
|
let tuple = (\name -> varmap Map.! name) <$> headVars
|
||||||
|
guard $ not $ Set.member tuple knownTuples
|
||||||
|
return varmap
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user