Skip to content

Commit

Permalink
remove subsumedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Dec 17, 2024
1 parent a32d2eb commit 2614e71
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class KeyValueReplica(val uid: Uid, val votingReplicas: Set[Uid]) {
}
if old != changed then {
val upkept = changed.upkeep()
if upkept `subsumedBy` currentState
if currentState.subsumes(upkept)
then log(s"no changes")
else log(s"upkeep")
assert(changed == currentState)
Expand Down
4 changes: 1 addition & 3 deletions Modules/RDTs/src/main/scala/rdts/base/Lattice.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ trait Lattice[A] {
/* It would be conceivable to only have the extensions, but the two parameter lists of merge make it not work well with SAM.
* IntelliJ also does not like to implement or override extension methods. */
extension (left: A) {
final inline def subsumedBy(right: A): Boolean = Lattice.this.subsumption(left, right)

/** Merging `right` into `left` has no effect */
final inline def subsumes(right: A): Boolean = Lattice.this.subsumption(right, left)

Expand Down Expand Up @@ -126,7 +124,7 @@ object Lattice {

override def subsumption(left: Mp[K, V], right: Mp[K, V]): Boolean =
left.forall { (k, l) =>
right.get(k).exists(r => l `subsumedBy` r)
right.get(k).exists(r => r `subsumes` l )
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ abstract class LatticePropertyChecks[A](

assertEquals(left `merge` merged, merged, "naive lteq")
assertEquals(right `merge` merged, merged, "naive lteq")
assert(left `subsumedBy` merged, s"merged:\n ${merged}\n ${left `merge` merged}")
assert(right `subsumedBy` merged, s"merged:\n ${merged}\n ${right `merge` merged}")
assert(merged.subsumes(left), s"merged:\n ${merged}\n ${left `merge` merged}")
assert(merged.subsumes(right), s"merged:\n ${merged}\n ${right `merge` merged}")
assert(merged.inflates(left) || merged == Lattice.normalize(left), s"merged:\n ${merged}")
assert(merged.inflates(right) || merged == Lattice.normalize(right), s"merged:\n ${merged}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DotFunTest extends munit.ScalaCheckSuite {
val ccB = dfB.dots `union` deletedB

assert(
Dotted(dfA, ccA) `subsumedBy` Dotted(dfA, ccA),
Dotted(dfA, ccA).subsumes(Dotted(dfA, ccA)),
s"DotFun.leq should be reflexive, but returns false when applied to ($dfA, $ccA, $dfA, $ccA)"
)

Expand All @@ -100,11 +100,11 @@ class DotFunTest extends munit.ScalaCheckSuite {
)

assert(
Dotted(dfA, (ccA)) `subsumedBy` Dotted(dfMerged, ccMerged),
Dotted(dfMerged, ccMerged) `subsumes` Dotted(dfA, (ccA)),
s"The result of DotFun.merge should be larger than its lhs, but DotFun.leq returns false when applied to ($dfA, $ccA, $dfMerged, $ccMerged)"
)
assert(
Dotted(dfB, ccB) `subsumedBy` Dotted(dfMerged, ccMerged),
Dotted(dfMerged, ccMerged) `subsumes` Dotted(dfB, ccB),
s"The result of DotFun.merge should be larger than its rhs, but DotFun.leq returns false when applied to ($dfB, $ccB, $dfMerged, $ccMerged)"
)
}
Expand All @@ -117,7 +117,7 @@ class DotFunTest extends munit.ScalaCheckSuite {
val left = Dotted(Map(someDot -> 10), Dots.single(someDot))
val right = Dotted(Map.empty[Dot, Int], Dots.single(someDot))

assert(left `subsumedBy` right)
assert(right.subsumes(left))

}

Expand All @@ -144,7 +144,7 @@ class DotFunTest extends munit.ScalaCheckSuite {
val decomposed: Iterable[Dotted[Map[Dot, Int]]] = Decompose.decompose(withContext)

decomposed.foreach { dec =>
assert(dec `subsumedBy` withContext)
assert(withContext.subsumes(dec))
}

val Dotted(dfMerged, ccMerged) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class DotMapTest extends munit.ScalaCheckSuite {
val dottedB = Dotted(dmB, ccB)

assert(
dottedA `subsumedBy` Dotted(dmA, (ccA)),
Dotted(dmA, (ccA)).subsumes(dottedA),
s"DotMap.leq should be reflexive, but returns false when applied to ($dmA, $ccA)"
)

Expand All @@ -110,11 +110,11 @@ class DotMapTest extends munit.ScalaCheckSuite {
)

assert(
dottedA `subsumedBy` merged,
merged.subsumes(dottedA),
s"The result of DotMap.merge should be larger than its lhs, but DotMap.leq returns false when applied to:\n $dottedA\n $merged"
)
assert(
dottedB `subsumedBy` merged,
merged.subsumes(dottedB),
s"The result of DotMap.merge should be larger than its rhs, but DotMap.leq returns false when applied to\n $dottedB\n $merged"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ class DotSetTest extends munit.ScalaCheckSuite {
val dottedSetB = Dotted(dsB, ccB)

assert(
dottedSetA `subsumedBy` dottedSetA,
dottedSetA.subsumes(dottedSetA),
s"DotSet.leq should be reflexive, but returns false when applied to ($dsA, $ccA, $dsA, $ccA)"
)

val dottedMerged @ Dotted(dsMerged, ccMerged) = dottedSetA `merge` dottedSetB

assert(
dottedSetA `subsumedBy` dottedMerged,
dottedMerged.subsumes(dottedSetA),
s"The result of DotSet.merge should be larger than its lhs, but DotSet.leq returns false when applied to ($dsA, $ccA, $dsMerged, $ccMerged)"
)
assert(
dottedSetB `subsumedBy` dottedMerged,
dottedMerged.subsumes(dottedSetB),
s"The result of DotSet.merge should be larger than its rhs, but DotSet.leq returns false when applied to ($dsB, $ccB, $dsMerged, $ccMerged)"
)
}
Expand Down

0 comments on commit 2614e71

Please sign in to comment.