示例#1
0
 def test_nnf_or(self):
     axiom1 = Or(Concept("A"), Concept("B"))
     axiom2 = Or(Concept("A"), Not(Concept("B")))
     axiom3 = Or(Not(Not(Concept("A"))), Not(Not(Concept("B"))))
     self.assertEqual(axiom1, NNF(axiom1))
     self.assertEqual(axiom1, NNF(axiom3))
     self.assertNotEqual(axiom1, NNF(axiom2))
示例#2
0
 def setUp(self):
     self.KB = NodeSet()
     self.axioms = [
         And(Concept("Man"), All("hasChild", Concept("Human"))),
         And(Concept("Woman"), All("hasChild", Concept("Human"))),
         Concept("Human"),
         Not(Concept("Robot"))
     ]
     self.KB.add_axioms(self.axioms)
示例#3
0
import sys

sys.path.append("/home/adityas/Projects/ALC-reasoner/")

from reasoner.knowledgebase.axioms import And, Or, Not, ClassAssertion, ABoxAxiom, RoleAssertion, TBoxAxiom, Subsumption
from reasoner.common.constructors import Concept, All, Some, Instance

simple_or = Or(Concept("Man"), Concept("Machine"))
complex_or = Or(Or(Concept("Man"), Concept("Machine")), Concept("Robot"))
kinda_complicated_axiom = And(
    Or(And(Concept("Man"), Not(Concept("Machine"))),
       And(Concept("Machine"), Not(Concept("Man")))), Concept("Physical"))
kinda_complicated_abox = ABoxAxiom(
    ClassAssertion(kinda_complicated_axiom, Instance("Aditya")))

kinda_complicated_unsat_axiom = And(
    Or(And(Concept("Man"), Not(Concept("Machine"))),
       And(Concept("Machine"), Not(Concept("Man")))),
    And(Concept("Man"), Concept("Machine")))

kinda_complicated_unsat_abox = ABoxAxiom(
    ClassAssertion(kinda_complicated_unsat_axiom, Instance("Aditya")))

simple_and_abox = ABoxAxiom(
    ClassAssertion(And(Concept("Man"), Concept("Machine")),
                   Instance("Aditya")))

simple_or_abox = ABoxAxiom(ClassAssertion(simple_or, Instance("Aditya")))

consistent_complex_abox = [
    ABoxAxiom(
示例#4
0
little_kb = [
    ABoxAxiom(ClassAssertion(Concept("Man"), Instance("Aditya"))),
    TBoxAxiom(Subsumption(Concept("Man"), Concept("Biological")))
]

small_kb = [
    ABoxAxiom(ClassAssertion(Concept("Man"), Instance("Aditya"))),
    ABoxAxiom(ClassAssertion(Concept("Machine"), Instance("Icarus"))),
    TBoxAxiom(Subsumption(Concept("Man"), Concept("Biological")))
]

simple_kb = [
    ABoxAxiom(ClassAssertion(Concept("Man"), Instance("Aditya"))),
    ABoxAxiom(ClassAssertion(Concept("Machine"), Instance("Icarus"))),
    TBoxAxiom(Subsumption(Concept("Man"), Concept("Biological"))),
    TBoxAxiom(Subsumption(Concept("Machine"), Not(Concept("Man")))),
    TBoxAxiom(Subsumption(Concept("Biological"), Concept("Man")))
]

inconsistent_test_kb = [
    ABoxAxiom(ClassAssertion(Concept("Man"), Instance("Aditya"))),
    ABoxAxiom(
        ClassAssertion(And(Concept("Machine"), Concept("Man")),
                       Instance("Adam"))),
    TBoxAxiom(Subsumption(Concept("Man"), Concept("Biological"))),
    TBoxAxiom(Subsumption(Concept("Machine"), Not(Concept("Man")))),
    TBoxAxiom(Subsumption(Concept("Biological"), Concept("Man")))
]

yet_another_kb = [
    ABoxAxiom(ClassAssertion(Concept("Man"), Instance("Aditya"))),
示例#5
0
 def test_complex_and_or(self):
     axiom=Or(And(Concept("Man"),Not(Concept("Man"))),And(Concept("Machine"),Or(Not(Concept("Machine")),Concept("Machine"))))
     models=get_models({},axiom,"Aditya")
     self.assertTrue(is_model_consistent(models))
示例#6
0
 def test_unsat_and(self):
     axiom=And(And(Concept("Man"),Concept("Living")),And(Not(Concept("Man")),Concept("Terminator")))
     models=get_models({},axiom,"Aditya")
     self.assertFalse(is_model_consistent(models))
示例#7
0
 def test_nnf_subsumption(self):
     axiom1 = Concept("Man")
     axiom2 = Concept("Human")
     axiom = Subsumption(axiom1, axiom2)
     self.assertEqual(NNF(axiom), Or(Not(Concept("Man")), Concept("Human")))
示例#8
0
 def test_nnf_complex_statement(self):
     axiom1 = Not(And(Some("A", Concept("B")), Not(Concept("C"))))
     axiom2 = Or(All("A", Not(Concept("B"))), Concept("C"))
     self.assertEqual(axiom2, NNF(axiom1))
示例#9
0
 def test_nnf_not_all(self):
     axiom1 = Not(All("A", Concept("B")))
     axiom2 = Some("A", Not(Concept("B")))
     self.assertEqual(NNF(axiom1), axiom2)
示例#10
0
 def test_nnf_not_and(self):
     axiom1 = Not(And(Concept("A"), Concept("B")))
     axiom2 = Or(Not(Concept("A")), Not(Concept("B")))
     self.assertEqual(axiom2, NNF(axiom1))
示例#11
0
 def test_nnf_and(self):
     axiom1 = And(Concept("A"), Concept("B"))
     axiom2 = And(Not(Not(Concept("A"))), Not(Not(Concept("B"))))
     self.assertEqual(axiom1, NNF(axiom2))
示例#12
0
 def test_nnf_not_not_not_concept(self):
     self.assertEqual(NNF(Not(Not(Not(Concept("A"))))), Not(Concept("A")))
     self.assertNotEqual(Not(Not(Concept("A"))), Not(Concept("A")))
示例#13
0
 def test_not_inequality(self):
     axiom1 = Not(Concept("Man"))
     axiom2 = Not(Concept("Woman"))
     self.assertNotEqual(axiom1, axiom2)
示例#14
0
 def test_not_equality(self):
     axiom1 = Not(Concept("Man"))
     axiom2 = Not(Concept("Man"))
     self.assertEqual(axiom2, axiom1)
示例#15
0
 def test_not_constructor(self):
     axiom = Not(Concept("Human"))
     self.assertIsInstance(axiom, Not)