Skip to content
This repository has been archived by the owner on Oct 9, 2022. It is now read-only.

Commit

Permalink
fix 'to_nnf' of LDLfNot
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofavorito committed Oct 9, 2019
1 parent 23a4f1b commit b11df30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions flloat/ldlf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from functools import lru_cache
from typing import Set

from flloat.base.convertible import ConvertibleFormula
from flloat.base.convertible import ConvertibleFormula, BaseConvertibleFormula
from flloat.base.delta import (
Delta,
DeltaConvertibleFormula,
Expand Down Expand Up @@ -220,12 +220,13 @@ def _delta(self, i: PLInterpretation, epsilon=False):


class LDLfNot(NotTruth, LDLfFormula, NotNNF):

def _to_nnf(self):
neg = self.f.negate()
return neg.to_nnf()
if isinstance(self.f, AtomicNNF) and not isinstance(self.f, BaseConvertibleFormula):
return self.f.negate()
else:
return self.f.negate().to_nnf()

def negate(self):
return self.f

def _delta(self, i: PLInterpretation, epsilon=False):
# should never called, since it is called from NNF formulas
Expand Down Expand Up @@ -347,6 +348,10 @@ def __str__(self):
def _to_nnf(self):
return RegExpTest(self.f.to_nnf())

def negate(self):
return self.Dual(self.Not(self.f))


def delta_diamond(self, f: LDLfFormula, i: PLInterpretation, epsilon=False):
return PLAnd([self.f._delta(i, epsilon), f._delta(i, epsilon)])

Expand Down Expand Up @@ -483,7 +488,7 @@ def convert(self):
return LDLfBox(RegExpPropositional(PLTrue()), LDLfLogicalFalse())


class LDLfLast(DeltaConvertibleFormula, LDLfAtomic):
class LDLfLast(DeltaConvertibleFormula, LDLfAtomic, ):
def __init__(self):
super().__init__(Symbols.LAST.value)

Expand Down
4 changes: 3 additions & 1 deletion tests/test_ldlf.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ def test_delta():
assert parser("[B]ff").delta(i_b) == PLAtomic(ff)
assert parser("[B]ff").delta(i_ab) == PLAtomic(ff)

f = parser("!(<!(A<->B)+(B;A)*+(!last)?>[(true)*]end)")
f = parser("!(<(!last)?>end)")
a = f.delta(i_)
b = f.to_nnf().delta(i_)
assert f.delta(i_) == f.to_nnf().delta(i_)
assert f.delta(i_ab) == f.to_nnf().delta(i_ab)

Expand Down

0 comments on commit b11df30

Please sign in to comment.