Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 63bc631

Browse files
committed
Move verified algebra interfaces to Control.Algebra
I was running into some weird import issues, and this seems to solve them. Interfaces.Verified as a module probably ought to be abolished, as it really isn't very useful as a grouping.
1 parent 3dfe314 commit 63bc631

File tree

11 files changed

+38
-42
lines changed

11 files changed

+38
-42
lines changed

libs/contrib/Control/Algebra.idr

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,27 @@ mtimes (S k) x = stimes (S k) x
145145
-- Structures where "abs" make sense.
146146
-- Euclidean domains, etc.
147147
-- Where to put fromInteger and fromRational?
148+
149+
-- "Verified" Interfaces -----------------
150+
151+
interface Semigroup a => VerifiedSemigroup a where
152+
semigroupOpIsAssociative : (l, c, r : a) -> l <+> (c <+> r) = (l <+> c) <+> r
153+
154+
interface (VerifiedSemigroup a, Monoid a) => VerifiedMonoid a where
155+
monoidNeutralIsNeutralL : (l : a) -> l <+> Algebra.neutral = l
156+
monoidNeutralIsNeutralR : (r : a) -> Algebra.neutral <+> r = r
157+
158+
interface (VerifiedMonoid a, Group a) => VerifiedGroup a where
159+
groupInverseIsInverseR : (r : a) -> inverse r <+> r = Algebra.neutral
160+
161+
interface (VerifiedGroup a, AbelianGroup a) => VerifiedAbelianGroup a where
162+
abelianGroupOpIsCommutative : (l, r : a) -> l <+> r = r <+> l
163+
164+
interface (VerifiedAbelianGroup a, Ring a) => VerifiedRing a where
165+
ringOpIsAssociative : (l, c, r : a) -> l <.> (c <.> r) = (l <.> c) <.> r
166+
ringOpIsDistributiveL : (l, c, r : a) -> l <.> (c <+> r) = (l <.> c) <+> (l <.> r)
167+
ringOpIsDistributiveR : (l, c, r : a) -> (l <+> c) <.> r = (l <.> r) <+> (c <.> r)
168+
169+
interface (VerifiedRing a, RingWithUnity a) => VerifiedRingWithUnity a where
170+
ringWithUnityIsUnityL : (l : a) -> l <.> Algebra.unity = l
171+
ringWithUnityIsUnityR : (r : a) -> Algebra.unity <.> r = r

libs/contrib/Control/Algebra/ComplexImplementations.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Control.Algebra.ComplexImplementations
22

3-
import Interfaces.Verified
43
import Data.Complex
54
import Control.Algebra
65
import Control.Algebra.Laws

libs/contrib/Control/Algebra/Laws.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Control.Algebra.Laws
22

33
import Prelude.Algebra as A
44
import Control.Algebra as Alg
5-
import Interfaces.Verified
65

76
%access public export
87
%default total

libs/contrib/Control/Algebra/VerifiedImplementations.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Control.VerifiedInterfaces
22

3-
import Interfaces.Verified
43
import Control.Algebra
54
import Control.Algebra.Lattice
65
import Control.Algebra.NumericImplementations

libs/contrib/Control/Isomorphism/Vect.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Control.Isomorphism.Vect
22

33
import Control.Isomorphism
44
import Data.Vect
5-
import Interfaces.Verified
65

76
%default total
87
%access public export

libs/contrib/Data/Bool/Algebra.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Data.Bool.Algebra
22

33
import Control.Algebra
4-
import Interfaces.Verified
54

65
%access public export
76
%default total

libs/contrib/Data/BoundedList.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Data.BoundedList
22

33
import Data.Fin
44
import Data.Vect
5-
import Interfaces.Verified
5+
import Control.Algebra
66

77
%access public export
88
%default total

libs/contrib/Data/Matrix/Algebraic.idr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
||| and `Control.Algebra.VectorSpace`.
44
module Data.Matrix.Algebraic
55

6+
import public Data.Vect
67
import public Control.Algebra
78
import public Control.Algebra.VectorSpace
89
import public Control.Algebra.NumericImplementations
9-
import public Interfaces.Verified
1010

1111
import public Data.Matrix
1212

@@ -44,13 +44,6 @@ implementation Ring a => Ring (Vect n a) where
4444
implementation RingWithUnity a => RingWithUnity (Vect n a) where
4545
unity {n} = replicate n unity
4646

47-
implementation RingWithUnity a => Module a (Vect n a) where
48-
(<#>) r = map (r <.>)
49-
50-
implementation RingWithUnity a => Module a (Vect n (Vect l a)) where
51-
(<#>) r = map (r <#>)
52-
-- should be Module a b => Module a (Vect n b), but results in 'overlapping implementation'
53-
5447
-----------------------------------------------------------------------
5548
-- (Ring) Vector functions
5649
-----------------------------------------------------------------------
@@ -212,3 +205,14 @@ VerifiedRingWithUnity a => VerifiedRingWithUnity (Vect n a) where
212205
rewrite ringWithUnityIsUnityL x in
213206
rewrite ringWithUnityIsUnityL xs in
214207
Refl
208+
209+
-- Vector spaces -----------------------
210+
211+
-- These need to come after the "verified" implementations because ???
212+
213+
implementation RingWithUnity a => Module a (Vect n a) where
214+
(<#>) r = map (r <.>)
215+
216+
implementation RingWithUnity a => Module a (Vect n (Vect l a)) where
217+
(<#>) r = map (r <#>)
218+
-- should be Module a b => Module a (Vect n b), but results in 'overlapping implementation'

libs/contrib/Data/Monoid.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
||| https://hackage.haskell.org/package/base-4.9.0.0/docs/src/Data.Monoid.html
33
module Data.Monoid
44

5-
import Interfaces.Verified
5+
import Control.Algebra
66

77
%access public export
88
%default total

libs/contrib/Data/Sign.idr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Data.Sign
22

33
import Prelude.Algebra
44
import Control.Algebra
5-
import Interfaces.Verified
65

76
%access public export
87

0 commit comments

Comments
 (0)