Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge authored and pikinier20 committed Oct 25, 2021
1 parent 8cee6f1 commit e46e446
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions algebra-core/src/main/scala/algebra/lattice/Bool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait Bool[@sp(Int, Long) A] extends Any with Heyting[A] with GenBool[A] { self
* Note that the ring returned by this method is not an extension of
* the `Rig` returned from `BoundedDistributiveLattice.asCommutativeRig`.
*/
override def asBoolRing: BoolRing[A] = new BoolRingFromBool(self)
override private[algebra] def asBoolRing: BoolRing[A] = new BoolRingFromBool(self)
}

class DualBool[@sp(Int, Long) A](orig: Bool[A]) extends Bool[A] {
Expand All @@ -62,7 +62,7 @@ class DualBool[@sp(Int, Long) A](orig: Bool[A]) extends Bool[A] {
override def dual: Bool[A] = orig
}

private[lattice] class BoolRingFromBool[A](orig: Bool[A]) extends BoolRngFromGenBool(orig) with BoolRing[A] {
class BoolRingFromBool[A](orig: Bool[A]) extends BoolRngFromGenBool(orig) with BoolRing[A] {
def one: A = orig.one
}

Expand All @@ -78,7 +78,7 @@ class BoolFromBoolRing[A](orig: BoolRing[A]) extends GenBoolFromBoolRng(orig) wi
def one: A = orig.one
def complement(a: A): A = orig.plus(orig.one, a)
override def without(a: A, b: A): A = super[GenBoolFromBoolRng].without(a, b)
override def asBoolRing: BoolRing[A] = orig
override private[algebra] def asBoolRing: BoolRing[A] = orig

override def meet(a: A, b: A): A = super[GenBoolFromBoolRng].meet(a, b)
override def join(a: A, b: A): A = super[GenBoolFromBoolRng].join(a, b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait BoundedDistributiveLattice[@sp(Int, Long, Float, Double) A]
* Return a CommutativeRig using join and meet. Note this must obey the commutative rig laws since
* meet(a, one) = a, and meet and join are associative, commutative and distributive.
*/
def asCommutativeRig: CommutativeRig[A] =
private[algebra] def asCommutativeRig: CommutativeRig[A] =
new CommutativeRig[A] {
def zero: A = self.zero
def one: A = self.one
Expand Down
6 changes: 3 additions & 3 deletions algebra-core/src/main/scala/algebra/lattice/GenBool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait GenBool[@sp(Int, Long) A] extends Any with DistributiveLattice[A] with Bou
* Every generalized Boolean algebra is also a `BoolRng`, with
* multiplication defined as `and` and addition defined as `xor`.
*/
def asBoolRing: BoolRng[A] = new BoolRngFromGenBool(self)
private[algebra] def asBoolRing: BoolRng[A] = new BoolRngFromGenBool(self)
}

/**
Expand All @@ -54,10 +54,10 @@ class GenBoolFromBoolRng[A](orig: BoolRng[A]) extends GenBool[A] {
def and(a: A, b: A): A = orig.times(a, b)
def or(a: A, b: A): A = orig.plus(orig.plus(a, b), orig.times(a, b))
def without(a: A, b: A): A = orig.plus(a, orig.times(a, b))
override def asBoolRing: BoolRng[A] = orig
override private[algebra] def asBoolRing: BoolRng[A] = orig
}

private[lattice] class BoolRngFromGenBool[@sp(Int, Long) A](orig: GenBool[A]) extends BoolRng[A] {
class BoolRngFromGenBool[@sp(Int, Long) A](orig: GenBool[A]) extends BoolRng[A] {
def zero: A = orig.zero
def plus(x: A, y: A): A = orig.xor(x, y)
def times(x: A, y: A): A = orig.and(x, y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LawTests extends munit.DisciplineSuite {
checkAll("Boolean", RingLaws[Boolean].boolRing(booleanRing))

// ensure that Bool[A].asBoolRing is a valid BoolRing
checkAll("Boolean-ring-from-bool", RingLaws[Boolean].boolRing(Bool[Boolean].asBoolRing))
checkAll("Boolean-ring-from-bool", RingLaws[Boolean].boolRing(new BoolRingFromBool[Boolean](Bool[Boolean])))

// ensure that BoolRing[A].asBool is a valid Bool
checkAll("Boolean- bool-from-ring", LogicLaws[Boolean].bool(new BoolFromBoolRing(booleanRing)))
Expand Down Expand Up @@ -91,7 +91,7 @@ class LawTests extends munit.DisciplineSuite {
checkAll("Set[Byte]", LogicLaws[Set[Byte]].generalizedBool)
checkAll("Set[Byte]", RingLaws[Set[Byte]].boolRng(setBoolRng[Byte]))
checkAll("Set[Byte]-bool-from-rng", LogicLaws[Set[Byte]].generalizedBool(new GenBoolFromBoolRng(setBoolRng)))
checkAll("Set[Byte]-rng-from-bool", RingLaws[Set[Byte]].boolRng(GenBool[Set[Byte]].asBoolRing))
checkAll("Set[Byte]-rng-from-bool", RingLaws[Set[Byte]].boolRng(new BoolRngFromGenBool(GenBool[Set[Byte]])))
checkAll("Set[Int]", OrderLaws[Set[Int]].partialOrder)
checkAll("Set[Int]", RingLaws[Set[Int]].semiring)
checkAll("Set[String]", RingLaws[Set[String]].semiring)
Expand Down

0 comments on commit e46e446

Please sign in to comment.