import Data.List (nub, sortOn)
import Cayley.Group
import Cayley.Symmetric

-- generators of W(B_4), order 384
goodB4Embedding = map read ["(1 3)", "(1 2)(3 4)(5 6)(7 8)", "(1 3)(2 6)(4 5)(7 8)", "(1 3)(2 4)(5 7)(6 8)"] :: [Perm]
goodB4Edges = filter ((>2) . order) [x <> y | x <- goodB4Embedding, y <- goodB4Embedding]
-- generators of H, order 192
badb4Embedding = map read ["(1 2)(3 4)(5 6)(7 8)", "(1 3)(2 5)(4 7)(6 8)", "(1 2)(3 4)(5 7)(6 8)", "(1 2)(3 5)(4 6)(7 8)"] :: [Perm]


-- Order 192 subgroup of only even permutations in W(B_4)
goodB4EvenPermsSubgroup = filter ((==1) . pParity) $ generatingSet $ goodB4Embedding

-- Count the orders in the group xs
-- Should probably be done better in CayleyOps
countOrders xs = sortOn fst $ map ((,) <*> flip numOrder xs) (nub $ map order xs)

commutatorSubgroup xs = nub $ [commutator x y | x <- xs, y <- xs]

printGroupData x = do
  putStr "\tOrder: "
  putStrLn $ show $ length x
  putStr "\tElement order count: "
  putStrLn $ show $ countOrders x
  putStr "\tCommutator subgroup order: "
  putStrLn $ show $ length $ commutatorSubgroup x


main = do
  putStrLn "Bad embedding:"
  printGroupData $ generatingSet badb4Embedding
  putStrLn "Even permutation subgroup of the good embedding:"
  printGroupData goodB4EvenPermsSubgroup
  putStrLn "Edge-generated subgroup of the good embedding:"
  printGroupData $ generatingSet goodB4Edges
