What is negation as failure?

Negation as failure” (also known as “weak negation”) is a concept in logic programming that refers to treating the statement “not P” as true when we are unable to find or derive the statement “P”. This is the approach that RDFox takes when it comes to reasoning. In contrast, “strong negation” is the approach of only treating “not P” as true only if it can be derived directly.

But what does it mean for a knowledge graph?

Suppose we have the following data in our graph:

:jane a :Person .
:jane :hasJob :programmer .

and suppose we work for a company selling photography courses for beginners. If someone is already a professional photographer, they are unlikely to buy our course. So maybe we want to add a rule to our database that says:

“If someone is not a photographer, then they are a potential customer”

In Datalog this would be:

[?person, a, :PotentialCustomer] :-
   [?person, a, :Person],
   NOT [?person, :hasJob, :photographer] .

If our database’s inference system follows the rule of “negation as failure”, it will mark Jane as a potential customer because there is no fact “:jane :hasJob :photographer” in our graph. “Strong negation” would not allow us to mark Jane as a potential customer using a rule like that because we have no proof that Jane does not have a photography business on the side (our data might be incomplete).
This would be done with:

:programmer owl:disjointWith :photographer .

This example illustrates why the “negation as failure” approach is usually more practical – with real-life data, we usually only have “positive” facts available to us, so with “strong negation” we would not be able to infer much.

Another example for negation as failure, where we want to find unemployed people.

:jane a :Person .
:jane :hasJob :programmer .
:anne a :Person .
#:anne has no job.

[?person, a, :UnemployedPerson] :-
   [?person, a, :Person],
   NOT EXISTS ?job IN [?person, :hasJob, ?job] .

Notice the different syntax with NOT EXISTS instead of NOT.
This will infer that :anne is a :UnemployedPerson, but :jane will not be inferred to be unemployed.

See more in the RDFox documentation.

Down arrow icon.