Beispiel #1
0
 def is_empty(self):
     if self.special_attr == 'true':
         return False
     elif self.special_attr == 'false':
         return True
     else:
         return not NFA.nfa_nonemptiness_check(self.aut)
Beispiel #2
0
def afw_nonemptiness_check(afw: dict) -> bool:
    """ Checks if the input AFW reads any language other than the
    empty one, returning True/False.

    The afw is translated into a nfa and then its nonemptiness is
    checked.

    :param dict afw: input AFW.
    :return: *(bool)*, True if input afw is nonempty, False otherwise.
    """
    nfa = afw_to_nfa_conversion(afw)
    return NFA.nfa_nonemptiness_check(nfa)
Beispiel #3
0
 def test_nfa_nonemptiness_check_side_effects(self):
     """ Tests that the function doesn't make any side effect
     on the input"""
     before = copy.deepcopy(self.nfa_nonemptiness_test_01)
     NFA.nfa_nonemptiness_check(self.nfa_nonemptiness_test_01)
     self.assertDictEqual(before, self.nfa_nonemptiness_test_01)
Beispiel #4
0
 def test_nfa_nonemptiness_check_wrong_input(self):
     """ Tests the nonemptines of an input different from a
     dict object. [EXPECTED FAILURE] """
     self.assertFalse(NFA.nfa_nonemptiness_check(0))
Beispiel #5
0
 def test_nfa_nonemptiness_check_wrong_dict(self):
     """ Tests the nonemptiness of an input dict different
     from a dict representing a nfa. [EXPECTED FAILURE] """
     self.assertFalse(NFA.nfa_nonemptiness_check({}))
Beispiel #6
0
 def test_nfa_nonemptiness_check_empty(self):
     """ Tests the nonemptiness of an empty nfa"""
     self.assertFalse(
         NFA.nfa_nonemptiness_check(self.nfa_nonemptiness_test_empty))
Beispiel #7
0
 def test_nfa_nonemptiness_check_false(self):
     """ Tests a correct nfa nonemptiness check, where the nfa
     is empty"""
     self.assertFalse(
         NFA.nfa_nonemptiness_check(self.nfa_nonemptiness_test_02))
Beispiel #8
0
 def test_nfa_nonemptiness_check(self):
     """ Tests a correct nfa nonemptiness check"""
     self.assertTrue(
         NFA.nfa_nonemptiness_check(self.nfa_nonemptiness_test_01))