Add files via upload

This commit is contained in:
Gregory Bednov 2025-01-10 20:50:02 +03:00 committed by GitHub
commit fb6dd81f33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 735 additions and 0 deletions

22
Ternary/Universum.hs Normal file
View file

@ -0,0 +1,22 @@
module Ternary.Universum (Universum(..), universum, aFromStatements) where
import Data.List (nub)
import Ternary.Term (Item (..), Term (..), Vee)
data Universum = Aristotle
| Empty
| Default
universum :: (Eq a) => Universum -> [Vee a] -> [Vee a]
universum Aristotle facts =
[Term True (Item [Term x v])
| v <- aFromStatements facts,
x <- [False, True]]
universum Empty _ = []
universum Default xs = xs
aFromStatements :: (Eq a) => [Vee a] -> [a]
aFromStatements = nub . concatMap (extract . getItem . getVee)
where
getItem (Item x) = x
getVee (Term _ i) = i
extract terms = [v | (Term _ v) <- terms]