def test_check_membership(self): my_dfa = ExampleDFA.three() self.assertEqual(my_dfa.check_membership(""), False) self.assertEqual(my_dfa.check_membership("1111"), False) self.assertEqual(my_dfa.check_membership("0000"), False) self.assertEqual(my_dfa.check_membership("010101010"), True) self.assertEqual(my_dfa.check_membership("110011"), False)
def test_check_membership_minimised(self): my_dfa = ExampleDFA.three() my_dfa.state_minimisation() self.assertEqual(my_dfa.check_membership(""), False) self.assertEqual(my_dfa.check_membership("1111"), False) self.assertEqual(my_dfa.check_membership("0000"), False) self.assertEqual(my_dfa.check_membership("010101010"), True) self.assertEqual(my_dfa.check_membership("110011"), False)
def test_random_states_and_transitions_initialisation(self): my_dfa = ExampleDFA.three() self.assertEqual( ''.join(str(my_dfa.table_df).split()), "01S0S7S13S1S1S22S2S6S6S4S9S23S5S2S0S6S24S0S7S19S11→S8S8S15S9S7S25*S10S2S5S11S16S9S12S24S0S13S1S15S14S13S10S15S6S5S16S18S12S17S15S20S18S10S8S19S14S26S20S8S25S21S8S26S22S17S2S23S8S25*S24S17S20*S25S4S21S26S19S26" )
def test_unequivalence_simple_two(self): my_dfa_a = ExampleDFA.three() my_dfa_b = ExampleDFA.nine() self.assertEqual(my_dfa_a.equivalence_test(my_dfa_b), False)
def test_equivalence_minimised_two(self): my_dfa_a = ExampleDFA.three() my_dfa_b = copy.deepcopy(my_dfa_a) my_dfa_b.state_minimisation() self.assertEqual(my_dfa_a.equivalence_test(my_dfa_b), True)
def test_equivalence_simple_two(self): my_dfa_a = ExampleDFA.three() my_dfa_b = copy.deepcopy(my_dfa_a) self.assertEqual(my_dfa_a.equivalence_test(my_dfa_b), True)
def test_check_membership_minimised_brute_force(self): my_dfa = ExampleDFA.three() my_dfa.state_minimisation() minimum_acceptable_string = BruteForcer.bruteforce_dfa_check_string_membership( my_dfa, ['0', '1']) self.assertEqual(minimum_acceptable_string, "100")