Modify the Scheme program of Figure 11.1 or the OCaml program of Figure 11.3 to simulate an
Question:
Modify the Scheme program of Figure 11.1 or the OCaml program of Figure 11.3 to simulate an NFA (nondeterministic finite automaton), rather than a DFA. (The distinction between these automata is described in Section 2.2.1.) Since you cannot “guess” correctly in the face of a multivalued transition function, you will need either to use explicitly coded backtracking to search for an accepting series ofmoves (if there is one), or keep track of all possible states that the machine could be in at a given point in time.
Figure 11.1
Figure 11.3
Transcribed Image Text:
(define simulate (lambda (dfa input) (letrec ((helper ; note that helper is tail recursive, ; but builds the list of moves in reverse order (lambda (moves d2 i) (let ((c (current-state d2))) (if (null? i) (cons c moves) (helper (cons c moves) (move d2 (car i)) (cdr i))))))) (let ((moves (helper '() dfa input))) (reverse (cons (if (is-final? (car moves) dfa) 'accept 'reject) moves)))))) ;; access functions for machine description: (define current-state car) (define transition-function cadr) (define final-states caddr) (define is-final? (lambda (s dfa) (memą s (final-states dfa)))) (define move (lambda (dfa symbol) (let ((cs (current-state dfa)) (trans (transition-function dfa))) (list (if (eq? cs 'error) 'error (let ((pair (assoc (list cs symbol) trans))) (if pair (cadr pair) 'error))); new start state trans ; same transition function (final-states dfa))))) same final states
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (16 reviews)
ANSWER define simulate lambda nfa input letrec helper note that helper is tail recursive but builds ...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
A five-year follow-up study was carried out in a certain metropolitan area to assess the relationship of diet and weight to the incidence of stomach cancer. Data were obtained on n = 2,000 subjects....
-
The Company Lalo Company, headquartered in Vaduz, is a company listed in Amsterdam, Paris and Zurich. It is the third largest small home appliance manufacturer in Europe. The company was founded in...
-
The design of a new multinational personnel selection system at MobilCom. Louisa is a senior HR manager at MobilCom, currently residing and working in the Kuala Lumpur (KL) office. She had completed...
-
The Assembly Department of Zip Surge Protectors began September with no work in process inventory. During the month, production that cost $39,860 (direct materials, $9,900, and conversion costs,...
-
Monitoring data an Oregon catchment produce the following record of annual precipitation and runoff: a) Determine a linear relationship between runoff and precipitation using linear regression...
-
- = 1 = 2 = 3 4 Frank's credit card statement shows a balance of $ 1 1 8 9 . 5 6 on the first day of the billing cycle. If he makes a payment of $ 4 9 2 . 7 8 and charges $ 3 7 0 . 5 4 during this...
-
Glass as a waste encapsulant. The encapsulation of waste in glass is considered to be a promising solution to the problem of low-level nuclear waste. A study was undertaken jointly by the Department...
-
The following selected transactions were taken from the records of Aprilla Company for the first year of its operations ending December 31, 2012: Jan. 27. Wrote off account of C. Knoll, $6,000. Feb....
-
Question 5 Carla Vista Corporation, which uses ASPE, enters into a 6-year lease of equipment on September 1, 2020, that requires 6 annual payments of $17,000 each, beginning September 1, 2020. In...
-
Given a database of the results of an election, find the number of seats won by each party. There are some rules to going about this: There are many constituencies in a state and many candidates who...
-
Consider the problem of determining whether two trees have the same fringe: the same set of leaves in the same order, regardless of internal structure. An obvious way to solve this problem is to...
-
Write a purely functional Scheme function that returns a list of all permutations of a given list. For example, given (a b c), it should return ((a b c) (b a c) (b c a) (a c b) (c a b) (c b a)) (in...
-
A producer of machine parts claimed that the diameters of the connector rods produced by his plant had a variance of at most .03 inch2. A random sample of 15 connector rods from his plant produced a...
-
Use as many directional terms as possible to describe therelationshipbetween: a. the antecubital region and the poplitealregion b. the acromial region and the mentalregion c. the gluteal region and...
-
Average rate of return-cost savings Maui Fabricators Inc. is considering an investment in equipment that will replace direct labor. The equipment has a cost of $114,000 with a $10,000 residual value...
-
Alan was rated as excellent on his individual work performance evaluation, earning him $2,000, provided as a merit pay increase. His annual salary this year is $48,000. He works in a team of 3...
-
Josie spends $60 at the end of each month on cigarettes. If shestops smoking and invests the same amount in an investment planpaying 6% compounded monthly, how much will she have after fiveyears? 2...
-
Say we have a Boeing 747 whose longitudinal flight dynamics for a given flight condition may be approximated using the following state equation (uncontrolled motion; thus no need to consider the...
-
In Problems, solve each equation. Give answers correct to three decimal places in Problems 112. ln x - ln 5 = 10
-
Suppose you are comparing just two means. Among the possible statistics you could use is the difference in means, the MAD, or the max min (the difference between the largest mean and the smallest...
-
Write a program that consists of three classes, A, B, and C, such that B extends A and that C extends B. Each class should define an instance variable named x (that is, each has its own variable...
-
Explain the changes that would have to be made to the program of Code Fragment 3.8 so that it could perform the Caesar cipher for messages that are written in an alphabet-based language other than...
-
The removeFirst method of the SinglyLinkedList class includes a special case to reset the tail field to null when deleting the last node of a list (see lines 51 and 52 of Code Fragment 3.15). What...
-
How to solve general ledger cash balance chapter 9 assignment 5
-
On 31 July 2018, Sipho bought 1 000 ordinary shares in ABC Ltd at a cost of R2 750. On 31 December 2018 the company made a 1 for 10 bonus issue. On 31 March 2019, Sipho sold 300 shares for R800. What...
-
If you purchase a $1000 par value bond for $1065 that has a 6 3/8% coupon rate and 15 years until maturity, what will be your annual return? 5.5% 5.9% 5.7% 6.1%
Study smarter with the SolutionInn App