Question: DR Racket language ONLY! This DFA has the starting state q0; only one final state q0; and then the transitions. Notice how the DFA is
DR Racket language ONLY!
This DFA has the starting state q0; only one final state q0; and then the transitions.
Notice how the DFA is defined as a list that the first element is the start state, second element is a list of transitions, third element is the list of final states.
Notice that the above DFA recognize only string of even numbers of 0s and/ even number of 1s
The empty string is recognized too, because, the start state is also a final state.
Here it is first draft of a racket program
#lang racket
;;;The final state is "q0"
(define (is-final-state? state) (if (equal? state "q0") #t #f))
;;;transitions
(define (q0-state substring)
(cond
((equal? substring "1") "q1" )
((equal? substring "0") "q2")
(else "not in the alphabet")))
;
(define (q1-state substring)
(cond
((equal? substring "1") "q0" )
((equal? substring "0") "q3")
(else "not in the alphabet")))
;
(define (q2-state substring)
(cond
((equal? substring "0") "q0" )
((equal? substring "1") "q3")
(else "not in the alphabet")))
;
(define (q3-state substring)
(cond
((equal? substring "0") "q1" )
((equal? substring "1") "q2")
(else "not in the alphabet")))
;;; next state
(define (next-state s str ) (cond ((equal? "q0" s) (q0-state str))
((equal? "q1" s) (q1-state str))
((equal? "q2" s) (q2-state str))
((equal? "q3" s) (q3-state str))
(else "error") ))
;;; parse the string
(define (parse str) (if (equal? str "") "it is in the language" (is-in-the-language? "q0" str)))
(define (is-in-the-language? state str)
(cond
((and (= (string-length str) 1) (is-final-state? (next-state state str))) "it is in the language")
((and (= (string-length str) 1) (not (is-final-state? (next-state state str)))) "no in the language")
(else (is-in-the-language? (next-state state (substring str 0 1)) (substring str 1)))
))
PROGRAM THE FOLLOWING CHARTS:

1 point to program the following DFA 0 0 1 points to program the following DFA a,b 1 point to program the following DFA 0 0 1 points to program the following DFA a,b
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
