A function that determines if the empty list is part of a clause set

77 views Asked by At

Theoretically my function should be able to return True or False if a set of clauses has the empty list ([]), I actually defined the next data type:

data Literal = V String | NotV String deriving Eq
type Clause = [Literal]
type Interpretacion = [( String , Bool ) ]
type State = ( Interpretation , [ Clause ])

And for the function i did this:

conflict :: State -> Bool
    | [] `elem` xs = True
    | otherwise = False

But i really think that this is not going to be enough, my next work is do another function that determines if the model search has been successful, (this happens when the clause set is empty), I think that I have to use the above function using the same (State -> Bool) but if the first function is not working the second can't work either.

My big question is: What do you think I need to do?. Any comment will be of great help to me, I'm a little lost. My work is about the transition rules from DPLL algorithm, once i have i'm going to share in Github to new programmers.

1

There are 1 answers

1
Filbert B Brand On

I think I've seen the same problem on another site when implementing the DPLL algorithm, maybe you could try using a function like this:

isEmptyState :: State -> Bool
isEmptyState = null . assignments

And for the next function you could implement a helper function that checks the first function and another that returns the result of it, like this:

unassigned :: State -> [Var]
unassigned (State(_,us)) = us

complete :: State -> Bool
complete = null . unassigned

I think the point you're trying to get to with the first function is that when you compile you can have something like this:

ghci >success ([( p , True ) , (q , False ) ] , []) ▷ True