From 974f10616c5f3b9e2251f0d3350e705adbc32f72 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Wed, 28 Oct 2020 17:49:50 +0100 Subject: Adapt test to new `cycle` method --- src/main/scala/rsacomb/RSAOntology.scala | 8 ++++-- src/test/scala/rsacomb/CanonicalModelSpec.scala | 38 ++++++++++++++++--------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index 6d39bae..b81a8f5 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala @@ -346,10 +346,12 @@ trait RSAOntology { tripleARB = Seq(classA, roleR, classB).hashCode tripleDSC = Seq(classD, roleS, classC).hashCode individual = - if (tripleARB < tripleDSC) { - RSA.internal("v0_" ++ tripleDSC.hashCode.toString()) - } else { + if (tripleARB > tripleDSC) { RSA.internal("v1_" ++ tripleDSC.hashCode.toString()) + } else { + // Note that this is also the case for + // `tripleARB == tripleDSC` + RSA.internal("v0_" ++ tripleDSC.hashCode.toString()) } } yield individual } diff --git a/src/test/scala/rsacomb/CanonicalModelSpec.scala b/src/test/scala/rsacomb/CanonicalModelSpec.scala index 5d633cc..39801bf 100644 --- a/src/test/scala/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/rsacomb/CanonicalModelSpec.scala @@ -158,38 +158,48 @@ class Ontology1_CanonicalModelSpec renderer.render( DsomeValuesFromRB - ) should "have a sigleton 'cycle' set" in { - // Using `hashCode` we are assuming (B,S,D) < (D,R,B) - val ind = RSA.internal("v1_" ++ BsomeValuesFromSD.hashCode.toString()) - ontology.cycle(DsomeValuesFromRB).loneElement shouldBe ind + ) should "have a 'cycle' set of 48 elements" in { + // Cycle introduces a new constant for each possible triple (the + // order among triples is total). In this example there are 4 + // concept names and R has 3 safe roles in its conflict set (S, T, + // Inv(R)). Triples are + // (concept, role, concept) + // and hence we have 4*3*4=48 new constants introduced. + ontology.cycle(DsomeValuesFromRB) should have size 48 } it should "produce 5 rules" in { - // Rule 1 provides 1 rule (split in 2) + 1 fact + // Rule 1 provides 1 rule (split in 2) + 48 fact // Rule 2 provides 0 rules - // Rule 3 provides 1 rule (split in 2) + // Rule 3 provides 48 rule (split in 2) + // Then (1*2 + 48) + (0) + (48*2) = 146 val varX = Variable.create("X") val visitor = ProgramGenerator(ontology, varX) val rules = DsomeValuesFromRB.accept(visitor) - rules should have length 5 + rules should have length 146 } renderer.render( BsomeValuesFromSD ) should "have a sigleton 'cycle' set" in { - // Using `hashCode` we are assuming (B,S,D) < (D,R,B) - val ind = RSA.internal("v0_" ++ DsomeValuesFromRB.hashCode.toString()) - ontology.cycle(BsomeValuesFromSD).loneElement shouldBe ind + // Cycle introduces a new constant for each possible triple (the + // order among triples is total). In this example there are 4 + // concept names and S has 2 safe roles in its conflict set (R, + // Inv(T)). Triples are + // (concept, role, concept) + // and hence we have 4*2*4=32 new constants introduced. + ontology.cycle(BsomeValuesFromSD) should have size 32 } it should "produce 5 rules" in { - // Rule 1 provides 1 rule (split in 2) + 1 fact + // Rule 1 provides 1 rule (split in 2) + 32 fact // Rule 2 provides 0 rules - // Rule 3 provides 1 rule (split in 2) + // Rule 3 provides 32 rule (split in 2) + // Then (1*2 + 32) + (0) + (32*2) = 98 val varX = Variable.create("X") val visitor = ProgramGenerator(ontology, varX) - val rules = BsomeValuesFromSD.accept(visitor) - rules should have length 5 + val rules = DsomeValuesFromRB.accept(visitor) + rules should have length 146 } renderer.render( -- cgit v1.2.3