3 תשובות
מה צריך?
שואל השאלה:
זה השאלה
נתונה שפה l מעל הא"ב {0,1,2}
l = {0^i 1 2^n|i>0,n=i mod 3}
בנה אוטומטי סופי דטרמיניסטי לא מלא המכיל את השפה l
אנונימי
class incompletedfa:
def __init__(self):
self.states = {"q0", "q1", "q2", "q3"}
self.start_state = "q0"
self.accept_states = {"q1", "q2", "q3"}
self.transitions = {
"q0": {"0": "q0", "1": "q1", "2": "q0"},
"q1": {"0": "q2"},
"q2": {"0": "q3"}
}

def is_valid_string(self, string):
current_state = self.start_state
for char in string:
if char not in self.transitions[current_state]:
return false
current_state = self.transitions[current_state][char]
return current_state in self.accept_states