Hi,
The problem is caused by the following part of the ontology:
<owl:NamedIndividual rdf:about="
http://www.example.com/#B"> <rdf:type rdf:resource="
http://www.example.com/#B"/> </owl:NamedIndividual>
This means that B is an instance of itself. In OWL, whether the class B is the same entity as the individual B is not clear -- most tools and reasoners consider that it is not, but when using punning, it is.
In Owlready, I chosed to identify an entity by its IRI. This means that two distinct entities cannot share the same IRI. This is consistent with the typeless nature of Python.
A consequence is that you should avoid having different entities with the same IRI. Owlready tries its best to merge such entities, but in this case, they cannot be merged without causing an infinite cycle of "instance-of" relation.
Hope this help,
Jiba