In class, we implemented FSA by making state, initial, final, and arc basic facts in the database. Let's do an implementation now where these are
In class, we implemented FSA by making state, initial, final, and arc basic facts in the database. Let's do an implementation now where these are structures. We will ultimately write a function go/3 that takes three arguments: a specification of an FSA (as described below), a state, and a string. The function returns true or false depending on whether the string is accepted from that state.
Here's an example:
go( fsa( initial(1), final([3]), arcs([ arc(1,a,2), arc(2,b,3), arc(2,b,2) ]) ), 1, "abbb").The logic of the approach is that go/3 will look at that first argument, rather than facts in the database.
The first step, however, is to write a function that will extract the initial state from such an FSA representation getinitial/2. The first argument is an FSA representation like above and the second is the output.
In [ ]:
%%CONSULT%Your code hereIn [ ]:
getinitial(fsa(initial(33),final([]),arcs([])),33).In [ ]:
getinitial(fsa(initial(7),final([]),arcs([])),7).Step by Step Solution
There are 3 Steps involved in it
Step: 1
The detailed answer for the above question is provided below To implement the getin...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started