在以下示例中(用 OWLready2 编写):
class A(Thing): pass
class p(ObjectProperty, FunctionalProperty): pass
class B(Thing): pass
class B1(B): equivalent_to = [B & p.some(A)]
class B2(B): equivalent_to = [B & Not(p.some(A))]
b1 = B(p=A())
b2 = B()
对象 b1 重新设置为 B1 的父级,而 b2 则不设置为 B2 的父级。这是什么原因呢?我使用了错误的设计模式吗?
由于开放世界原则,定义的个体 b2 是否实际上具有 p=A() 被认为是未知的。 OWLready2 有能力为个人使用封闭世界方法:
close_world(b2)
这将为 b2 添加 p.only(Nothing) 限制,这足以推断 b2 属于 B2 类。