vicramgon/logicus/8.0.2

NOTE: the latest version is 10.1.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/vicramgon/logicus is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 8.0.2 found (12 same-name repos checked); no cached copy. Use another version.

Details

LogicUS.PL.NormalForms

The module provides the tools for express formulas in their NN, CNF, DNF.

Normal Forms

It checks if the formula contains any equivalence as a part of it.


f1 = Neg (Equi (Atom "p") (Impl (Atom "q") (Atom "r")))
fplContainsEquiv f1 == True


f2 = Disj (Neg (Conj (Atom "p") (Conj (Atom "q") (Atom "r")))) (Disj (Conj (Atom "p") (Atom "q")) (Atom "r"))
fplContainsEquiv f2 == False
It checks if the formula contains any disjunction as a part of the formula


fplContainsDisj f1 == False


fplContainsDisj f2 == True

It checks if the formula contains any conjunction as a part of the formula

fplContainsConj f1 == False


fplContainsConj f2 == True
It eliminates all equivalences of a formula by replacing it with the conjunction of the corresponding implications.


f3 = fplRemoveAllEquiv f1
f3 == Neg (Conj (Impl (Atom "p") (Impl (Atom "q") (Atom "r"))) (Impl (Impl (Atom "q") (Atom "r")) (Atom "p")))
It checks if the formula contains any implication as a part of the formula


fplContainsImpl f1 == True


fplContainsImpl f2 == False
It eliminates all implications of a formula by replacing it with the conjunction of the corresponding implications.


f4 = fplRemoveAllImpl f3
f4 == Neg (Conj (Disj (Neg (Atom "p")) (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Neg (Disj (Neg (Atom "q")) (Atom "r"))) (Atom "p")))
It interiorizes the disjunctions by applying the AND Distributive law where appropriate.


f7 = fplInteriorizeAllDisj f6
f7 == Conj (Conj (Disj (Atom "p") (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Atom "p") (Neg (Atom "p")))) (Conj (Conj (Disj (Atom "q") (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Atom "q") (Neg (Atom "p")))) (Conj (Disj (Neg (Atom "r")) (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Neg (Atom "r")) (Neg (Atom "p")))))
It interiorizes the conjunctions by applying the OR Distributive law where appropriate.


f8 = fplInteriorizeAllConj f6
f8 == Disj (Conj (Atom "p") (Conj (Atom "q") (Neg (Atom "r")))) (Disj (Conj (Neg (Atom "q")) (Neg (Atom "p"))) (Conj (Atom "r") (Neg (Atom "p"))))
It interiorizes the negations by applying De Morgan's laws where appropriate


f5 = fplInteriorizeAllNeg f2
f5 == Disj (Disj (Neg (Atom "p")) (Disj (Neg (Atom "q")) (Neg (Atom "r")))) (Disj (Conj (Atom "p") (Atom "q")) (Atom "r"))


f6 = fplInteriorizeAllNeg f4
f6 == Disj (Conj (Atom "p") (Conj (Atom "q") (Neg (Atom "r")))) (Conj (Disj (Neg (Atom "q")) (Atom "r")) (Neg (Atom "p")))
Express a formula in its Conjuction Normal Form (CNF) that is formed as a conjuction of disjuntive formulas.


 -- Check if f1 is in CNF
(f1 == fplToCNF f1) == False


-- Check if f7 is in CNF
(f7 == fplToCNF f7) == True


-- Calculate CNF for f1
f10 = fplToCNF f1
f10 == Conj (Conj (Disj (Atom "p") (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Atom "p") (Neg (Atom "p")))) (Conj (Conj (Disj (Atom "q") (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Atom "q") (Neg (Atom "p")))) (Conj (Disj (Neg (Atom "r")) (Disj (Neg (Atom "q")) (Atom "r"))) (Disj (Neg (Atom "r")) (Neg (Atom "p")))))


-- It is equal to f7
(f10 == f7) == True
Express a formula in its Disjunction Normal Form (CNF) that is formed as a conjuction of disjuntive formulas.


-- Check if f1 is in DNF
(f1 == fplToDNF f1) == False


-- Check if f8 is in DNF
(f8 == fplToCNF f8) == True


-- Calculate CNF for f1
f11 = fplToDNF f1
f11 == Disj (Conj (Atom "p") (Conj (Atom "q") (Neg (Atom "r")))) (Disj (Conj (Neg (Atom "q")) (Neg (Atom "p"))) (Conj (Atom "r") (Neg (Atom "p"))))


-- It is equal to f8
(f11 == f8) == True
dnfAsLiteralSets : FormulaPL -> Maybe (List SetPL)

It gives a formula in DNF as a list of literal sets. If the formula given is not in DNF it returns Nothing.

cnfAsLiteralSets : FormulaPL -> Maybe (List SetPL)

It gives a formula in CNF as a list of literal sets. If the formula given is not in CNF it returns Nothing.

It solves the satisfiability of a formula by its DNF

fplModelsDNF : FormulaPL -> List Interpretation

It gets the models by DNF of a formula

It solves the validity of a formula by its CNF.