Fixed the implication

This commit is contained in:
VegOwOtenks 2024-10-22 13:53:46 +02:00
parent 903ae349b2
commit ca9165a861

View file

@ -70,10 +70,10 @@ table = [
Prefix (m_reservedOp "~" >> return (Unary LogicalNot)) Prefix (m_reservedOp "~" >> return (Unary LogicalNot))
], ],
[ [
Infix (m_reservedOp "&" >> return (Binary LogicalAnd)) AssocLeft Infix (m_reservedOp "|" >> return (Binary LogicalOr)) AssocLeft
], ],
[ [
Infix (m_reservedOp "|" >> return (Binary LogicalOr)) AssocLeft Infix (m_reservedOp "&" >> return (Binary LogicalAnd)) AssocLeft
], ],
[ [
Infix (m_reservedOp "->" >> return (Binary LogicalImplication)) AssocLeft Infix (m_reservedOp "->" >> return (Binary LogicalImplication)) AssocLeft
@ -109,6 +109,6 @@ evaluate vs (Binary LogicalEquality l r) = evaluate vs l == evaluate vs r
evaluate vs (Binary LogicalImplication l r) = implication (evaluate vs l) (evaluate vs r) evaluate vs (Binary LogicalImplication l r) = implication (evaluate vs l) (evaluate vs r)
where where
implication :: Bool -> Bool -> Bool implication :: Bool -> Bool -> Bool
implication False True = False implication True False = False
implication _ _ = True implication _ _ = True
evaluate vs (Variable name) = maybe False id (Map.lookup name vs) evaluate vs (Variable name) = maybe False id (Map.lookup name vs)