@@ -156,9 +156,34 @@ Zero {d} = replicate d zero
156-- Matrix Algebra Properties
156-- Matrix Algebra Properties
157-----------------------------------------------------------------------
157-----------------------------------------------------------------------
159+instance Semigroup a => Semigroup (Vect n a) where
160+ (<+>) v w = zipWith (<+>) v w
160−-- TODO: Prove properties of matrix algebra for 'Verified' algebraic classes
162+instance Monoid a => Monoid (Vect n a) where
163+ neutral {n} = replicate n neutral
165+instance Group a => Group (Vect n a) where
166+ inverse = map inverse
168+instance AbelianGroup a => AbelianGroup (Vect n a) where {}
170+instance Ring a => Ring (Vect n a) where
171+ (<*>) v w = zipWith (<*>) v w
173+instance RingWithUnity a => RingWithUnity (Vect n a) where
174+ unity {n} = replicate n unity
176+instance Field a => Field (Vect n a) where
177+ inverseM = map inverseM
179+instance (Field a, AbelianGroup a) => VectorSpace a (Vect n a) where
180+ (<#>) s v = map (s <*>) v
182+instance (Field a, AbelianGroup a) => VectorSpace a (Vect n (Vect n a)) where
183+ (<#>) s m = map (s <#>) m
186+-- TODO: Prove properties of matrix algebra for 'Verified' algebraic classes
163-----------------------------------------------------------------------
188-----------------------------------------------------------------------
164-- Numberic data types as rings
189-- Numberic data types as rings
@@ -217,6 +242,9 @@ instance Ring Float where
217instance RingWithUnity Float where
242instance RingWithUnity Float where
218 unity = 1
243 unity = 1
245+instance Field Float where
221instance Semigroup Nat where
249instance Semigroup Nat where
222 (<+>) = (+)
250 (<+>) = (+)