refining the tuple calculations
This commit is contained in:
parent
6848663caf
commit
591a24d755
@ -18,6 +18,9 @@ import Datalog.DatalogParser
|
||||
import Control.Exception
|
||||
import Data.Maybe
|
||||
import Utility.Utility
|
||||
import Control.Monad(guard)
|
||||
import Data.Set (Set)
|
||||
import Data.Set qualified as Set
|
||||
|
||||
data (DatalogDB db) => NaiveQE db = NaiveQE
|
||||
{
|
||||
@ -64,7 +67,13 @@ computeHerbrand db =
|
||||
amalgamateRelationSub newFacts relation =
|
||||
foldr amalgamateRule newFacts (_rules relation) where
|
||||
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
||||
amalgamateRule (RelationRule headVars body) newFacts =
|
||||
-- allMaps headVars (allConstants db)
|
||||
newFacts
|
||||
amalgamateRule (RelationRule headVars body) newFacts =
|
||||
newFacts where
|
||||
(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