Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 22 additions & 59 deletions src/v2/std/algebra.dag
Original file line number Diff line number Diff line change
@@ -1,48 +1,28 @@
module v2.std.algebra

import v2.std.node { Atom, Arrow, Conj, Disj, Edge, Named, Node, Positional, Symbol, TypeNode, SyntheticOccurrence }
import std.algebra { FreeMonoid, Empty, Cons }
type Magma<T> {
op: fn(T, T) -> T
}
type Semigroup<T> {
magma: Magma<T>
}
type Monoid<T> {
semigroup: Semigroup<T>
identity: T
}
type CommutativeMonoid<T> {
monoid: Monoid<T>
}
type Group<T> {
monoid: Monoid<T>
inverse: fn(T) -> T
}
type AbelianGroup<T> {
group: Group<T>
}
type Semiring<T> {
add: CommutativeMonoid<T>
mul: Monoid<T>
}
type CommutativeSemiring<T> {
semiring: Semiring<T>
}
type Ring<T> {
add: AbelianGroup<T>
mul: Monoid<T>
}
type CommutativeRing<T> {
ring: Ring<T>
}
type OrderedRing<T> {
ring: Ring<T>
compare: fn(T, T) -> Ordering
}
type Field<T> {
commutative_ring: CommutativeRing<T>
reciprocal: fn(T) -> T
import std.algebra {
AbelianGroup,
BooleanAlgebra,
BoundedLattice,
CommutativeMonoid,
CommutativeSemiring,
Cons,
Empty,
Equal,
Field,
FreeMonoid,
Greater,
Group,
Lattice,
Less,
Magma,
Monoid,
OrderedRing,
Ordering,
Ring,
Semigroup,
Semiring,
}

type ApproximateField<T> {
Expand All @@ -53,19 +33,6 @@ type ApproximateField<T> {
one: T
compare: fn(T, T) -> Ordering
}
type Lattice<T> {
meet: fn(T, T) -> T
join: fn(T, T) -> T
}
type BoundedLattice<T> {
lattice: Lattice<T>
top: T
bottom: T
}
type BooleanAlgebra<T> {
bounded_lattice: BoundedLattice<T>
complement: fn(T) -> T
}

type Equivalence<T> {
eq: fn(T, T) -> Bool
Expand Down Expand Up @@ -812,10 +779,6 @@ type PointwisePower<T> {
member: fn(T) -> Bool
}

type Ordering
= Less
| Equal
| Greater
type Homomorphism<C, Source, Target> {
source: C<Source>
target: C<Target>
Expand Down
Loading