Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROLOG Here is a DFA and its transitions: startnode(s1). finalnode(s4). transition(s1, a, s2). transition(s2, a, s2). transition(s3, a, s1). transition(s2, b, s1). transition(s3, b, s4).

PROLOG

Here is a DFA and its transitions:

image text in transcribed

startnode(s1). finalnode(s4). transition(s1, a, s2). transition(s2, a, s2). transition(s3, a, s1). transition(s2, b, s1). transition(s3, b, s4). transition(s2, c, s4). transition(s4, d, s3).

Create a predicate in Prolog, states(X), where X is a list of symbols, that shows the states it traverses from. Before that it should be checked that we have the correct input symbols (only a, b, c, d). That's why I provide you the following predicate parse(L):

parse(L) :- startnode(S), trans(S,L). trans(X,[A|B]) :- transition(X,A,Y), trans(Y,B). trans(X,[]) :- finalnode(X).

I am giving some examples:

?-states([a,a,c]).

S1

S2

S2

S4

true

?-states([a,c,c]).

false

I hope it is clear. The answer should be as above and not just check if the list with the input symbols are accepted by the dfa. Be careful!!

a a Si S2 b a b S3 S4 d

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions