-- | This module represents group presentation and its sub-types.
module GRType where

import Data.Set (Set)
import SMType

-- |This is a data type of 'GR' generators.
--
-- 'A_Y' is a generators witch obtain from alphabet letters 'SMType.Y' of S-machine.
--
-- 'A_K' is a generators witch forms the 'SM2GR.hubRelation'.
--
-- 'A_R' is a generators witch obtain from rules 'SMType.SRule' of S-machine.
--
-- 'A_Q' is a generators witch obtain from states 'SMType.State' of S-machine.
data A = A_Y Y| A_K Int | A_R SRule | A_Q State
   deriving (Int -> A -> ShowS
[A] -> ShowS
A -> String
(Int -> A -> ShowS) -> (A -> String) -> ([A] -> ShowS) -> Show A
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [A] -> ShowS
$cshowList :: [A] -> ShowS
show :: A -> String
$cshow :: A -> String
showsPrec :: Int -> A -> ShowS
$cshowsPrec :: Int -> A -> ShowS
Show, A -> A -> Bool
(A -> A -> Bool) -> (A -> A -> Bool) -> Eq A
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: A -> A -> Bool
$c/= :: A -> A -> Bool
== :: A -> A -> Bool
$c== :: A -> A -> Bool
Eq, Eq A
Eq A
-> (A -> A -> Ordering)
-> (A -> A -> Bool)
-> (A -> A -> Bool)
-> (A -> A -> Bool)
-> (A -> A -> Bool)
-> (A -> A -> A)
-> (A -> A -> A)
-> Ord A
A -> A -> Bool
A -> A -> Ordering
A -> A -> A
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: A -> A -> A
$cmin :: A -> A -> A
max :: A -> A -> A
$cmax :: A -> A -> A
>= :: A -> A -> Bool
$c>= :: A -> A -> Bool
> :: A -> A -> Bool
$c> :: A -> A -> Bool
<= :: A -> A -> Bool
$c<= :: A -> A -> Bool
< :: A -> A -> Bool
$c< :: A -> A -> Bool
compare :: A -> A -> Ordering
$ccompare :: A -> A -> Ordering
$cp1Ord :: Eq A
Ord)

-- |This is a data type of symbols in 'GrRelation'.
--
-- Symbols can represent generators 'A' and its invertions.
--
-- 'SmbA' represents generators.
--
-- 'SmbA'' represents invertions of generators.
data SmbR = SmbA A | SmbA' A
   deriving (Int -> SmbR -> ShowS
[SmbR] -> ShowS
SmbR -> String
(Int -> SmbR -> ShowS)
-> (SmbR -> String) -> ([SmbR] -> ShowS) -> Show SmbR
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SmbR] -> ShowS
$cshowList :: [SmbR] -> ShowS
show :: SmbR -> String
$cshow :: SmbR -> String
showsPrec :: Int -> SmbR -> ShowS
$cshowsPrec :: Int -> SmbR -> ShowS
Show, SmbR -> SmbR -> Bool
(SmbR -> SmbR -> Bool) -> (SmbR -> SmbR -> Bool) -> Eq SmbR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SmbR -> SmbR -> Bool
$c/= :: SmbR -> SmbR -> Bool
== :: SmbR -> SmbR -> Bool
$c== :: SmbR -> SmbR -> Bool
Eq, Eq SmbR
Eq SmbR
-> (SmbR -> SmbR -> Ordering)
-> (SmbR -> SmbR -> Bool)
-> (SmbR -> SmbR -> Bool)
-> (SmbR -> SmbR -> Bool)
-> (SmbR -> SmbR -> Bool)
-> (SmbR -> SmbR -> SmbR)
-> (SmbR -> SmbR -> SmbR)
-> Ord SmbR
SmbR -> SmbR -> Bool
SmbR -> SmbR -> Ordering
SmbR -> SmbR -> SmbR
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SmbR -> SmbR -> SmbR
$cmin :: SmbR -> SmbR -> SmbR
max :: SmbR -> SmbR -> SmbR
$cmax :: SmbR -> SmbR -> SmbR
>= :: SmbR -> SmbR -> Bool
$c>= :: SmbR -> SmbR -> Bool
> :: SmbR -> SmbR -> Bool
$c> :: SmbR -> SmbR -> Bool
<= :: SmbR -> SmbR -> Bool
$c<= :: SmbR -> SmbR -> Bool
< :: SmbR -> SmbR -> Bool
$c< :: SmbR -> SmbR -> Bool
compare :: SmbR -> SmbR -> Ordering
$ccompare :: SmbR -> SmbR -> Ordering
$cp1Ord :: Eq SmbR
Ord)
   
-- |This is a data type of 'GR' relations.
-- 
-- 'Relation' represents relation beetwen right and left symbols 'SmbR'. 
--
-- For example, relation ab=ba will coded like
--
-- >>> Relation ([a, b], [b, a])
-- 
-- where a, b are 'SmbR'
--
-- 'Relator' is relation in witch one part is identity. 
--
-- For example, ab=1 is
--
-- >>> Relator [a,b]
data GrRelation = Relation ([SmbR], [SmbR]) | Relator [SmbR]
   deriving (Int -> GrRelation -> ShowS
[GrRelation] -> ShowS
GrRelation -> String
(Int -> GrRelation -> ShowS)
-> (GrRelation -> String)
-> ([GrRelation] -> ShowS)
-> Show GrRelation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrRelation] -> ShowS
$cshowList :: [GrRelation] -> ShowS
show :: GrRelation -> String
$cshow :: GrRelation -> String
showsPrec :: Int -> GrRelation -> ShowS
$cshowsPrec :: Int -> GrRelation -> ShowS
Show, GrRelation -> GrRelation -> Bool
(GrRelation -> GrRelation -> Bool)
-> (GrRelation -> GrRelation -> Bool) -> Eq GrRelation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrRelation -> GrRelation -> Bool
$c/= :: GrRelation -> GrRelation -> Bool
== :: GrRelation -> GrRelation -> Bool
$c== :: GrRelation -> GrRelation -> Bool
Eq, Eq GrRelation
Eq GrRelation
-> (GrRelation -> GrRelation -> Ordering)
-> (GrRelation -> GrRelation -> Bool)
-> (GrRelation -> GrRelation -> Bool)
-> (GrRelation -> GrRelation -> Bool)
-> (GrRelation -> GrRelation -> Bool)
-> (GrRelation -> GrRelation -> GrRelation)
-> (GrRelation -> GrRelation -> GrRelation)
-> Ord GrRelation
GrRelation -> GrRelation -> Bool
GrRelation -> GrRelation -> Ordering
GrRelation -> GrRelation -> GrRelation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GrRelation -> GrRelation -> GrRelation
$cmin :: GrRelation -> GrRelation -> GrRelation
max :: GrRelation -> GrRelation -> GrRelation
$cmax :: GrRelation -> GrRelation -> GrRelation
>= :: GrRelation -> GrRelation -> Bool
$c>= :: GrRelation -> GrRelation -> Bool
> :: GrRelation -> GrRelation -> Bool
$c> :: GrRelation -> GrRelation -> Bool
<= :: GrRelation -> GrRelation -> Bool
$c<= :: GrRelation -> GrRelation -> Bool
< :: GrRelation -> GrRelation -> Bool
$c< :: GrRelation -> GrRelation -> Bool
compare :: GrRelation -> GrRelation -> Ordering
$ccompare :: GrRelation -> GrRelation -> Ordering
$cp1Ord :: Eq GrRelation
Ord)

-- |'GR' is a group presentation type. 
-- 
-- It consists of set of generators 'A' and set of relations 'GrRelation'.
newtype GR =  GR (Set A, Set GrRelation)
   deriving (GR -> GR -> Bool
(GR -> GR -> Bool) -> (GR -> GR -> Bool) -> Eq GR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GR -> GR -> Bool
$c/= :: GR -> GR -> Bool
== :: GR -> GR -> Bool
$c== :: GR -> GR -> Bool
Eq, Eq GR
Eq GR
-> (GR -> GR -> Ordering)
-> (GR -> GR -> Bool)
-> (GR -> GR -> Bool)
-> (GR -> GR -> Bool)
-> (GR -> GR -> Bool)
-> (GR -> GR -> GR)
-> (GR -> GR -> GR)
-> Ord GR
GR -> GR -> Bool
GR -> GR -> Ordering
GR -> GR -> GR
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GR -> GR -> GR
$cmin :: GR -> GR -> GR
max :: GR -> GR -> GR
$cmax :: GR -> GR -> GR
>= :: GR -> GR -> Bool
$c>= :: GR -> GR -> Bool
> :: GR -> GR -> Bool
$c> :: GR -> GR -> Bool
<= :: GR -> GR -> Bool
$c<= :: GR -> GR -> Bool
< :: GR -> GR -> Bool
$c< :: GR -> GR -> Bool
compare :: GR -> GR -> Ordering
$ccompare :: GR -> GR -> Ordering
$cp1Ord :: Eq GR
Ord)
instance Show GR where
   show :: GR -> String
show (GR (Set A
a, Set GrRelation
r)) = String
"A {" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Set A -> String
forall a. Show a => a -> String
show Set A
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"}" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"R {" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Set GrRelation -> String
forall a. Show a => a -> String
show Set GrRelation
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"}"