Skip to content

Commit

Permalink
simplifying complements of complements
Browse files Browse the repository at this point in the history
  • Loading branch information
LckyLke committed Nov 22, 2024
1 parent 7bc6445 commit dc39fd5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions owlapy/class_expression/class_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def is_owl_thing(self) -> bool:

def get_object_complement_of(self) -> 'OWLObjectComplementOf':
# documented in parent
if isinstance(self, OWLObjectComplementOf):
return self.get_operand()
return OWLObjectComplementOf(self)

def get_nnf(self) -> 'OWLClassExpression':
Expand All @@ -86,6 +84,15 @@ class OWLObjectComplementOf(OWLBooleanClassExpression, HasOperands[OWLClassExpre

_operand: OWLClassExpression

def __new__(cls, op: OWLClassExpression):
"""
Creates a new instance or returns the operand if op is already a complement.
"""
if isinstance(op, OWLObjectComplementOf):
return op.get_operand()
else:
return super(OWLObjectComplementOf, cls).__new__(cls)

def __init__(self, op: OWLClassExpression):
"""
Args:
Expand Down

0 comments on commit dc39fd5

Please sign in to comment.