def afw_nonuniversality_check(afw: dict) -> bool: """ Checks if the language read by the input AFW is different from Σ∗, returning True/False. The afw is translated into a nfa and then its nonuniversality is checked. :param dict afw: input AFW. :return: *(bool)*, True if input afw is nonuniversal, False otherwise. """ nfa = afw_to_nfa_conversion(afw) return NFA.nfa_nonuniversality_check(nfa)
def test_nfa_nonuniversality_check_side_effects(self): """ Tests that the function doesn't make any side effect on the input""" before = copy.deepcopy(self.nfa_nonuniversality_test_01) NFA.nfa_nonuniversality_check(self.nfa_nonuniversality_test_01) self.assertDictEqual(before, self.nfa_nonuniversality_test_01)
def test_nfa_nonuniversality_check_wrong_input(self): """ Tests the nonemptines of an input different from a dict object. [EXPECTED FAILURE] """ self.assertFalse(NFA.nfa_nonuniversality_check(0))
def test_nfa_nonuniversality_check_wrong_dict(self): """ Tests the nonuniversality of an input dict different from a dict representing a nfa. [EXPECTED FAILURE] """ self.assertFalse(NFA.nfa_nonuniversality_check({}))
def test_nfa_nonuniversality_check_empty(self): """ Tests the nonuniversality of an empty nfa """ self.assertFalse( NFA.nfa_nonuniversality_check(self.nfa_nonuniversality_test_empty))
def test_nfa_nonuniversality_check_false(self): """ Tests a correct nfa nonuniversality check, where the nfa is universal """ self.assertFalse( NFA.nfa_nonuniversality_check(self.nfa_nonuniversality_test_02))
def test_nfa_nonuniversality_check(self): """ Tests a correct nfa nonuniversality check """ self.assertTrue( NFA.nfa_nonuniversality_check(self.nfa_nonuniversality_test_01))