-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogic.hs
25 lines (21 loc) · 815 Bytes
/
Logic.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# OPTIONS_GHC -Wall -Wno-name-shadowing -fwarn-tabs #-}
module Logic where
import Formula
import DPLL
--------------------------------------------------------------------------
-- Methods of checking the model
-- Brute force model checking approach
modelCheck :: Formula -> Formula -> Bool
modelCheck knowledge query
= all modelCheck' (sequence allModels)
where
symbols = vars (And knowledge query)
allModels = [[(symbol, b) | b <- [True, False]] | symbol <- symbols]
modelCheck' :: [(Id, Bool)] -> Bool
modelCheck' model
| evaluate model knowledge = evaluate model query
| otherwise = True
-- Checking with DPLL algorithm
checkWithUnSAT :: Formula -> Formula -> Bool
checkWithUnSAT knowledge query
= allSat (knowledge `And` Not query) == []