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)
def setUp(self): self.KB = KnowledgeBase() self.axioms = [ ClassAssertion(And(Concept("Man"), Concept("Human")), Instance("Aditya")), ClassAssertion(Some("owns", Concept("Conputer")), 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"))), ABoxAxiom( ClassAssertion(And(Concept("Machine"), Concept("Man")), Instance("Adam"))), TBoxAxiom(Subsumption(Concept("Man"), Concept("Biological"))), TBoxAxiom(Subsumption(Concept("Biological"), Concept("Man"))), TBoxAxiom( Subsumption(And(Concept("Machine"), Concept("Man")),
def test_simple_all(self): axiom=All("hasParent",And(Concept("Engineer"),Concept("Graduate"))) models=get_models(self.pre_graph,axiom,"Aditya")
def test_simple_some(self): axiom=Some("hasParent",And(Concept("Man"),Concept("Human"))) models=get_models({},axiom,"Aditya") self.assertTrue(is_model_consistent(models))
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))
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))
def test_and_equality(self): axiom1 = And(Concept("Man"), Concept("Woman")) axiom2 = And(Concept("Man"), Concept("Woman")) axiom3 = And(Concept("Woman"), Concept("Man")) self.assertEqual(axiom1, axiom2) self.assertEqual(axiom3, axiom1)
def setUp(self): _axiom=Some("hasParent",And(Concept("Man"),Concept("Human"))) self.pre_graph=get_models({},_axiom,"Aditya")[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))
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))
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))
def test_tbox_wrapper(self): axiom = And(Concept("Man"), Concept("Machine")) wrapper = TBoxAxiom(axiom) self.assertEqual(axiom, wrapper.axiom)
def test_and_inequality(self): axiom1 = And(Concept("Man"), Concept("Human")) axiom2 = And(Concept("Woman"), Concept("Human")) self.assertNotEqual(axiom1, axiom2)
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(
def test_simple_and(self): axiom=And(And(Concept("Man"),Concept("Living")),And(Concept("Machine"),Concept("Terminator"))) models=get_models({},axiom,"Aditya") self.assertTrue(is_model_consistent(models))
def test_and_constructor(self): axiom = And(Concept("Man"), Some("hasChild", Concept("Human"))) self.assertIsInstance(axiom, And)