diff --git a/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRuleTest.cs b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRuleTest.cs new file mode 100644 index 00000000..228f8d18 --- /dev/null +++ b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRuleTest.cs @@ -0,0 +1,74 @@ +/* + Copyright 2014-2024 Marco De Salvo + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OWLSharp.Extensions.TIME; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; + +namespace OWLSharp.Test.Extensions.TIME +{ + [TestClass] + public class TIMEEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest + { + #region Tests + [TestMethod] + public async Task ShouldExecuteEqualsEntailment() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTS), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHES), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + List inferences = await TIMEEqualsEntailmentRule.ExecuteRuleAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + + [TestMethod] + public async Task ShouldExecuteEqualsEntailmentViaReasoner() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTS), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHES), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + + TIMEReasoner reasoner = new TIMEReasoner().AddRule(TIMEEnums.TIMEReasonerRules.EqualsEntailment); + List inferences = await reasoner.ApplyToOntologyAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + #endregion + } +} \ No newline at end of file diff --git a/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRuleTest.cs b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRuleTest.cs new file mode 100644 index 00000000..083a6c54 --- /dev/null +++ b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRuleTest.cs @@ -0,0 +1,74 @@ +/* + Copyright 2014-2024 Marco De Salvo + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OWLSharp.Extensions.TIME; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; + +namespace OWLSharp.Test.Extensions.TIME +{ + [TestClass] + public class TIMEEqualsInverseEntailmentRuleTest : TIMEBaseEntailmentRuleTest + { + #region Tests + [TestMethod] + public async Task ShouldExecuteEqualsInverseEntailment() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTED_BY), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHED_BY), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + List inferences = await TIMEEqualsInverseEntailmentRule.ExecuteRuleAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + + [TestMethod] + public async Task ShouldExecuteEqualsInverseEntailmentViaReasoner() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTED_BY), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHED_BY), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + + TIMEReasoner reasoner = new TIMEReasoner().AddRule(TIMEEnums.TIMEReasonerRules.EqualsInverseEntailment); + List inferences = await reasoner.ApplyToOntologyAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + #endregion + } +} \ No newline at end of file diff --git a/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRuleTest.cs b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRuleTest.cs new file mode 100644 index 00000000..8ae2efcf --- /dev/null +++ b/OWLSharp.Test/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRuleTest.cs @@ -0,0 +1,76 @@ +/* + Copyright 2014-2024 Marco De Salvo + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OWLSharp.Extensions.TIME; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; + +namespace OWLSharp.Test.Extensions.TIME +{ + [TestClass] + public class TIMEEqualsTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest + { + #region Tests + [TestMethod] + public async Task ShouldExecuteEqualsTransitiveEntailment() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature3"), new TIMEInterval(new RDFResource("ex:Interval3"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), + new OWLNamedIndividual(new RDFResource("ex:Interval2")), + new OWLNamedIndividual(new RDFResource("ex:Interval3")))); + List inferences = await TIMEEqualsTransitiveEntailmentRule.ExecuteRuleAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + + [TestMethod] + public async Task ShouldExecuteEqualsTransitiveEntailmentViaReasoner() + { + OWLOntology ontology = new OWLOntology(TestOntology); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature1"), new TIMEInterval(new RDFResource("ex:Interval1"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature2"), new TIMEInterval(new RDFResource("ex:Interval2"))); + ontology.DeclareIntervalFeature(new RDFResource("ex:Feature3"), new TIMEInterval(new RDFResource("ex:Interval3"))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), + new OWLNamedIndividual(new RDFResource("ex:Interval1")), + new OWLNamedIndividual(new RDFResource("ex:Interval2")))); + ontology.DeclareAssertionAxiom(new OWLObjectPropertyAssertion( + new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), + new OWLNamedIndividual(new RDFResource("ex:Interval2")), + new OWLNamedIndividual(new RDFResource("ex:Interval3")))); + + TIMEReasoner reasoner = new TIMEReasoner().AddRule(TIMEEnums.TIMEReasonerRules.EqualsTransitiveEntailment); + List inferences = await reasoner.ApplyToOntologyAsync(ontology); + + Assert.IsNotNull(inferences); + Assert.IsTrue(inferences.Count == 2); + } + #endregion + } +} \ No newline at end of file diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterEqualsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterEqualsEntailmentRule.cs index 5d8d3bd9..ff9199cc 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterEqualsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterEqualsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEAfterEqualsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("AFTER(?I1,?I2) ^ EQUALS(?I2,?I3) -> AFTER(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterFinishesEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterFinishesEntailmentRule.cs index 2e36724e..06c1ea71 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterFinishesEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterFinishesEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEAfterFinishesEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("AFTER(?I1,?I2) ^ FINISHES(?I2,?I3) -> AFTER(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterMetByEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterMetByEntailmentRule.cs index da35bcec..395bde40 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterMetByEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterMetByEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEAfterMetByEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("AFTER(?I1,?I2) ^ METBY(?I2,?I3) -> AFTER(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterTransitiveEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterTransitiveEntailmentRule.cs index fd718c8f..7a321720 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterTransitiveEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEAfterTransitiveEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEAfterTransitiveEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("AFTER(?I1,?I2) ^ AFTER(?I3,?I1) -> AFTER(?I3,?I2)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeEqualsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeEqualsEntailmentRule.cs index 3dab4521..058dae7d 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeEqualsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeEqualsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEBeforeEqualsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("BEFORE(?I1,?I2) ^ EQUALS(?I2,?I3) -> BEFORE(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeMeetsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeMeetsEntailmentRule.cs index f2e701e6..0c2b4375 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeMeetsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeMeetsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEBeforeMeetsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("BEFORE(?I1,?I2) ^ MEETS(?I2,?I3) -> BEFORE(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeStartsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeStartsEntailmentRule.cs index 462a7d16..e0500576 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeStartsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeStartsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEBeforeStartsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("BEFORE(?I1,?I2) ^ STARTS(?I2,?I3) -> BEFORE(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeTransitiveEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeTransitiveEntailmentRule.cs index 01fb9b1e..68f82809 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeTransitiveEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEBeforeTransitiveEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEBeforeTransitiveEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("BEFORE(?I1,?I2) ^ BEFORE(?I3,?I1) -> BEFORE(?I3,?I2)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsEqualsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsEqualsEntailmentRule.cs index 59df316f..88e969bc 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsEqualsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsEqualsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEContainsEqualsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("CONTAINS(?I1,?I2) ^ EQUALS(?I2,?I3) -> CONTAINS(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsTransitiveEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsTransitiveEntailmentRule.cs index 4299286e..2a2d03b1 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsTransitiveEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEContainsTransitiveEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEContainsTransitiveEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("CONTAINS(?I1,?I2) ^ CONTAINS(?I2,?I3) -> CONTAINS(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringEqualsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringEqualsEntailmentRule.cs index df78cd72..d560329e 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringEqualsEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringEqualsEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEDuringEqualsEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("DURING(?I1,?I2) ^ EQUALS(?I2,?I3) -> DURING(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringTransitiveEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringTransitiveEntailmentRule.cs index a513bcdf..e765450a 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringTransitiveEntailmentRule.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEDuringTransitiveEntailmentRule.cs @@ -26,7 +26,7 @@ internal static async Task> ExecuteRuleAsync(OWLOntology onto { SWRLRule swrlRule = new SWRLRule( new RDFPlainLiteral(nameof(TIMEDuringTransitiveEntailmentRule)), - new RDFPlainLiteral(""), + new RDFPlainLiteral("DURING(?I1,?I2) ^ DURING(?I2,?I3) -> DURING(?I1,?I3)"), new SWRLAntecedent() { Atoms = new List() diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRule.cs new file mode 100644 index 00000000..b81af9fe --- /dev/null +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsEntailmentRule.cs @@ -0,0 +1,56 @@ +/* + Copyright 2014-2024 Marco De Salvo + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; +using RDFSharp.Query; + +namespace OWLSharp.Extensions.TIME +{ + internal static class TIMEEqualsEntailmentRule + { + internal static async Task> ExecuteRuleAsync(OWLOntology ontology) + { + SWRLRule swrlRule = new SWRLRule( + new RDFPlainLiteral(nameof(TIMEEqualsEntailmentRule)), + new RDFPlainLiteral("STARTS(?I1,?I2) ^ FINISHES(?I1,?I2) -> EQUALS(?I1,?I2)"), + new SWRLAntecedent() + { + Atoms = new List() + { + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I1"))), + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTS), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHES), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))) + }, + BuiltIns = new List() + { + SWRLBuiltIn.NotEqual(new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))) + } + }, + new SWRLConsequent() + { + Atoms = new List() + { + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I2")), new SWRLVariableArgument(new RDFVariable("?I1"))) + } + }); + + return await swrlRule.ApplyToOntologyAsync(ontology); + } + } +} \ No newline at end of file diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRule.cs new file mode 100644 index 00000000..3ca42d3f --- /dev/null +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsInverseEntailmentRule.cs @@ -0,0 +1,56 @@ +/* + Copyright 2014-2024 Marco De Salvo + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; +using RDFSharp.Query; + +namespace OWLSharp.Extensions.TIME +{ + internal static class TIMEEqualsInverseEntailmentRule + { + internal static async Task> ExecuteRuleAsync(OWLOntology ontology) + { + SWRLRule swrlRule = new SWRLRule( + new RDFPlainLiteral(nameof(TIMEEqualsInverseEntailmentRule)), + new RDFPlainLiteral("STARTEDBY(?I1,?I2) ^ FINISHEDBY(?I1,?I2) -> EQUALS(?I1,?I2)"), + new SWRLAntecedent() + { + Atoms = new List() + { + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I1"))), + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTED_BY), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHED_BY), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))) + }, + BuiltIns = new List() + { + SWRLBuiltIn.NotEqual(new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))) + } + }, + new SWRLConsequent() + { + Atoms = new List() + { + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I2")), new SWRLVariableArgument(new RDFVariable("?I1"))) + } + }); + + return await swrlRule.ApplyToOntologyAsync(ontology); + } + } +} \ No newline at end of file diff --git a/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRule.cs b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRule.cs new file mode 100644 index 00000000..c1908fa9 --- /dev/null +++ b/OWLSharp/Extensions/TIME/Reasoner/RuleSet/TIMEEqualsTransitiveEntailmentRule.cs @@ -0,0 +1,59 @@ +/* + Copyright 2014-2024 Marco De Salvo + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; +using System.Threading.Tasks; +using OWLSharp.Ontology; +using OWLSharp.Reasoner; +using RDFSharp.Model; +using RDFSharp.Query; + +namespace OWLSharp.Extensions.TIME +{ + internal static class TIMEEqualsTransitiveEntailmentRule + { + internal static async Task> ExecuteRuleAsync(OWLOntology ontology) + { + SWRLRule swrlRule = new SWRLRule( + new RDFPlainLiteral(nameof(TIMEEqualsTransitiveEntailmentRule)), + new RDFPlainLiteral("EQUALS(?I1,?I2) ^ EQUALS(?I2,?I3) -> EQUALS(?I1,?I3)"), + new SWRLAntecedent() + { + Atoms = new List() + { + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I1"))), + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLClassAtom(new OWLClass(RDFVocabulary.TIME.INTERVAL), new SWRLVariableArgument(new RDFVariable("?I3"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I2")), new SWRLVariableArgument(new RDFVariable("?I3"))) + }, + BuiltIns = new List() + { + SWRLBuiltIn.NotEqual(new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I2"))), + SWRLBuiltIn.NotEqual(new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I3"))), + SWRLBuiltIn.NotEqual(new SWRLVariableArgument(new RDFVariable("?I2")), new SWRLVariableArgument(new RDFVariable("?I3"))) + } + }, + new SWRLConsequent() + { + Atoms = new List() + { + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I1")), new SWRLVariableArgument(new RDFVariable("?I3"))), + new SWRLObjectPropertyAtom(new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS), new SWRLVariableArgument(new RDFVariable("?I3")), new SWRLVariableArgument(new RDFVariable("?I1"))) + } + }); + + return await swrlRule.ApplyToOntologyAsync(ontology); + } + } +} \ No newline at end of file diff --git a/OWLSharp/Extensions/TIME/Reasoner/TIMEReasoner.cs b/OWLSharp/Extensions/TIME/Reasoner/TIMEReasoner.cs index 40467b14..f585ee99 100644 --- a/OWLSharp/Extensions/TIME/Reasoner/TIMEReasoner.cs +++ b/OWLSharp/Extensions/TIME/Reasoner/TIMEReasoner.cs @@ -94,7 +94,7 @@ await Rules.ParallelForEachAsync(async (rule) => case TIMEEnums.TIMEReasonerRules.DuringTransitiveEntailment: inferenceRegistry[TIMEEnums.TIMEReasonerRules.DuringTransitiveEntailment.ToString()] = await TIMEDuringTransitiveEntailmentRule.ExecuteRuleAsync(ontology); break; - /*case TIMEEnums.TIMEReasonerRules.EqualsEntailment: + case TIMEEnums.TIMEReasonerRules.EqualsEntailment: inferenceRegistry[TIMEEnums.TIMEReasonerRules.EqualsEntailment.ToString()] = await TIMEEqualsEntailmentRule.ExecuteRuleAsync(ontology); break; case TIMEEnums.TIMEReasonerRules.EqualsInverseEntailment: @@ -103,7 +103,7 @@ await Rules.ParallelForEachAsync(async (rule) => case TIMEEnums.TIMEReasonerRules.EqualsTransitiveEntailment: inferenceRegistry[TIMEEnums.TIMEReasonerRules.EqualsTransitiveEntailment.ToString()] = await TIMEEqualsTransitiveEntailmentRule.ExecuteRuleAsync(ontology); break; - case TIMEEnums.TIMEReasonerRules.FinishedByEqualsEntailment: + /*case TIMEEnums.TIMEReasonerRules.FinishedByEqualsEntailment: inferenceRegistry[TIMEEnums.TIMEReasonerRules.FinishedByEqualsEntailment.ToString()] = await TIMEFinishedByEqualsEntailmentRule.ExecuteRuleAsync(ontology); break; case TIMEEnums.TIMEReasonerRules.FinishesEqualsEntailment: