I want to write this rule: if there isn't any individual that Alice has relation HasParent with it, then Alice has relation HasParent with individual Bob. something like this:
notExist(HasParent(Alice,?p)) -> HasParent(Alice,Bob)
how should i write the swrl rule for this?
In OWL or its rule extension SWRL, the only rules you can model are the ones that say "if I know X (where X is set of formula in OWL) then I can deduce Y (with Y a formula in OWL). What you seem to be asking is if we can say "if I don't know X, then I can deduce that Y".
But in fact, your question is a little vague. It is not completely clear what you mean by your rule syntax. Let us explore several interpretations, and in passing, show that the problem is unrelated to Open World Assumption.
The pure OWL interpretation
It is possible to interpret your rule as "if I it is the case that there is no ?p in the universe such that
HasParent(Alice,?p), then I can deduceHasParent(Alice,Bob). Using FOL notation, it could be written like:(∀x¬HasParent(Alice,x)) ⟶ HasParent(Alice,Bob). In this case, this rule is useless: if the premise is true, then Alice does not have any parent, so the conclusion contradicts that. If the premise is false, we don't need the rule. You probably don't want such a rule.The epistemic interpretation
One way of interpreting this is to say that if it is not known (from the point of view of an agent or of the system) that
HasParent(Alice,x)is true for somex, then it is true (from the point of view of an omniscient agent) thatHasParent(Alice,Bob). In epistemic modal logic, this can be written:(∀x¬K.HasParent(Alice,x)) ⟶ HasParent(Alice,Bob). This is a valid and potentially useful rule, but since it requires a modal operator, it cannot be written in OWL or SWRL, which are not modal logics. The problem is unrelated to Open World Assumption in this case.The meta assumption interpretation
Maybe this rule can be interpreted as an assumption that, like the Closed World Assumption or the Unique Name Assumption, is assumed to hold but cannot be modelled directly in the language. CWA and UNA are assumptions that can only be implemented by hard coding them in reasoning, rather than by adding custom rules. Similarly, this rule could be an assumption that affects reasoning beyond the possibilities of OWL. In this case, obviously, OWL is not suitable to represent the assumption.
Note, in passing that adding CWA would not help. With CWA, if we cannot infer that
HasParent(Alice,?p)hold for some?p, then for any constant?p(includingBob) we assume thatHasParent(Alice,?p)is false. But then, because of the rule, we would conclude thatHasParent(Alice,Bob)is true and false at the same time. So OWL with CWA is as useless as the pure OWL interpretation. The problem is not related with OWA/CWA.The knowledge revision interpretation
One way to interpret the rule is by assuming that it is a knowledge revision operator. When we cannot infer (or we don't have explicitly in the knowledge base) that
HasParent(Alice,?p)for some?p, then we revise the knowledge base by addingHasParent(Alice,Bob). This means that we update our knowledge rather than merely inferring truth. This cannot be expressed in OWL simply because OWL is not made to express knowledge revision operations. Again, it under this interpretation, there is nothing related to Open World Assumption.