From 38ddfa5f4848f47071450cfd7c58e09576decb43 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Fri, 18 Jan 2019 16:25:39 +0100 Subject: [PATCH] Small things --- app/LStar.hs | 5 ++--- app/Minimise.hs | 2 +- src/EquivariantMap.hs | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/LStar.hs b/app/LStar.hs index d24a8ec..1c818fa 100644 --- a/app/LStar.hs +++ b/app/LStar.hs @@ -124,12 +124,11 @@ learn mq eq = do learn mq eq True -> do -- Also consistent! Let's build a minimal automaton! - let equiv = Set.fromOrbitList . filter (\(s, t) -> equalRows s t suffs table) $ product prefs prefs - (f, s) = quotient equiv prefs + let (f, st, _) = quotientf 0 (\s t -> s == t || equalRows s t suffs table) prefs trans = Map.fromList . toList . map (\(s, t) -> (s, f ! t)) . filter (\(s, t) -> equalRows s t suffs table) $ product prefsExt prefs trans2 pa = if pa `elem` prefsExt then trans ! pa else f ! pa hypothesis = Automaton - { states = s + { states = map fst st , initialState = f ! [] , acceptance = Map.fromList . toList . map (\p -> (f ! p, table ! p)) $ prefs , transition = Map.fromList . toList . map (\(p, a) -> ((f ! p, a), trans2 (ext p a))) $ product prefs alph diff --git a/app/Minimise.hs b/app/Minimise.hs index 4cb8138..3e7dc24 100644 --- a/app/Minimise.hs +++ b/app/Minimise.hs @@ -76,8 +76,8 @@ minimiseB Automaton{..} alph = Automaton main :: IO () main = do - -- putStrLn . toStr $ (doubleWordAut 4) putStrLn . toStr $ (minimiseB (doubleWordAut 4) rationals) + -- putStrLn . toStr $ (minimiseB (fifoAut 4) fifoAlph) -- All example automata follow below diff --git a/src/EquivariantMap.hs b/src/EquivariantMap.hs index 9f6a1d5..50229cd 100644 --- a/src/EquivariantMap.hs +++ b/src/EquivariantMap.hs @@ -59,6 +59,9 @@ lookup x (EqMap m) = mapelInv x <$> Map.lookup (toOrbit x) m (!) :: (Nominal k, Ord (Orbit k), Nominal v) => EquivariantMap k v -> k -> v (!) m k = fromMaybe undefined (EquivariantMap.lookup k m) +(?) :: (Nominal k, Ord (Orbit k), Nominal v) => EquivariantMap k v -> k -> Maybe v +(?) m k = EquivariantMap.lookup k m + -- Construction empty :: EquivariantMap k v