module Math.QuantumAlgebra.Tangle where
import Prelude hiding ( (*>) )
import Math.Algebras.VectorSpace
import Math.Algebras.TensorProduct
import Math.Algebras.Structures
import Math.Algebra.Field.Base
import Math.Algebras.LaurentPoly
import Math.QuantumAlgebra.TensorCategory hiding (Vect)
instance Mon [a] where
munit = []
mmult = (++)
instance (Eq k, Num k, Ord a) => Algebra k [a] where
unit 0 = zerov
unit x = V [(munit,x)]
mult = nf . fmap (\(a,b) -> a `mmult` b)
data Tangle
instance MCategory Tangle where
data Ob Tangle = OT Int deriving (Eq,Ord,Show)
data Ar Tangle = IdT Int
| CapT
| CupT
| OverT
| UnderT
| SeqT [Ar Tangle]
| ParT [Ar Tangle]
deriving (Eq,Ord,Show)
id_ (OT n) = IdT n
source (IdT n) = OT n
source CapT = OT 0
source CupT = OT 2
source OverT = OT 2
source UnderT = OT 2
source (ParT as) = OT $ sum [sa | a <- as, let OT sa = source a]
source (SeqT as) = source (head as)
target (IdT n) = OT n
target CapT = OT 2
target CupT = OT 0
target OverT = OT 2
target UnderT = OT 2
target (ParT as) = OT $ sum [ta | a <- as, let OT ta = target a]
target (SeqT as) = target (last as)
a >>> b | target a == source b = SeqT [a,b]
instance Monoidal Tangle where
tunit = OT 0
tob (OT a) (OT b) = OT (a+b)
tar a b = ParT [a,b]
data Oriented = Plus | Minus deriving (Eq,Ord,Show)
type TangleRep b = Vect (LaurentPoly Q) b
cap :: [Oriented] -> TangleRep [Oriented]
cap [] = return [Plus, Minus] <+> (q^2) *> return [Minus, Plus]
cup :: [Oriented] -> TangleRep [Oriented]
cup [Plus, Minus] = (q'^2) *> return []
cup [Minus, Plus] = return []
cup _ = zerov
over :: [Oriented] -> TangleRep [Oriented]
over [u, v] = q *> do {[] <- cup [u, v]; cap []}
<+> q' *> return [u, v]
under :: [Oriented] -> TangleRep [Oriented]
under [u, v] = q' *> do {[] <- cup [u, v]; cap []}
<+> q *> return [u, v]
loop = nf $ do {[i, j] <- cap []; cup [i, j]}
trefoil = nf $ do
[i, j] <- cap []
[k, l] <- cap []
[m, n] <- under [j, k]
[p, q] <- over [i, m]
[r, s] <- over [n, l]
cup [p, s]
cup [q, r]
kauffman :: Ar Tangle -> TangleRep [Oriented] -> TangleRep [Oriented]
kauffman (IdT n) = id
kauffman CapT = linear cap
kauffman CupT = linear cup
kauffman OverT = linear over
kauffman UnderT = linear under
kauffman (SeqT fs) = foldl (>>>) id $ map kauffman fs
where g >>> h = h . g
kauffman (ParT [f]) = kauffman f
kauffman (ParT (f:fs)) = tf m (kauffman f) (kauffman (ParT fs))
where OT m = source f
tf m f' fs' = linear (\xs -> let (ls,rs) = splitAt m xs in f' (return ls) * fs' (return rs) )
loopT = SeqT [CapT, CupT]
trefoilT = SeqT [
ParT [CapT, CapT],
ParT [IdT 1, UnderT, IdT 1],
ParT [OverT, OverT],
ParT [IdT 1, CupT, IdT 1],
CupT]