diff --git a/CoAlgLogics.ml b/CoAlgLogics.ml index 1cd832469d93921fc08b6902a3664c3ea66439c0..14d8d64bec674332da6ba830ecd977ade9fc31cf 100644 --- a/CoAlgLogics.ml +++ b/CoAlgLogics.ml @@ -155,7 +155,6 @@ let mkRule_MultiModalKD sort bs sl = / \i=1 a_i /\ b / \j=1 c_j *) - let mkRule_CL sort bs sl = assert (List.length sl = 1); (* TODO: Why? *) let s1 = List.hd sl in (* [s1] = List.hd sl *) diff --git a/playground.hs b/playground.hs new file mode 100644 index 0000000000000000000000000000000000000000..0f394ffca236e975950339f6584b41f2ed28a3b6 --- /dev/null +++ b/playground.hs @@ -0,0 +1,29 @@ + +import Control.Monad +import Data.List +import System.IO + +-- some example functions which will be adapted to ocaml + +-- mutliset -> disjoint subset +-- of sets / / .... all those maximal ones +-- | | | | / +maxdisj :: Eq a => [[a]] -> [[[a]]] +maxdisj = maxdisj' [] + +-- test it with: +-- flip (>>=) (return . length) $ mapM putStrLn $ map show $ maxdisj [[1,2],[2,3],[3,4]] + +-- only keep subsets if they intersect with pool -- does not work yet... TODO +maxdisj' :: Eq a => [[a]] -> [[a]] -> [[[a]]] +maxdisj' pool (x:xs) = (map (x:) oth') ++ maximal + where oth = maxdisj' (x:pool) xs ++ [[]] + oth' = filter (compatible x) oth + maximal = filter (\s -> all (not . flip compatible s) pool) oth + expandable = filter (\s -> any (flip compatible s) pool) oth + compatible set setset = all (disjoint set) setset +maxdisj' _ [] = [[]] + +disjoint :: Eq a => [a] -> [a] -> Bool +disjoint x = all (not . flip elem x) +