Question: Prolog program Write recursive Prolog predicates to determine if a list of atoms satisfies the following regular expressions or grammar rules. You may write helper

Prolog program  Prolog program Write recursive Prolog predicates to determine if a list

Write recursive Prolog predicates to determine if a list of atoms satisfies the following regular expressions or grammar rules. You may write helper predicates. Do no use any of the "grammar rule capabilities" of Prolog. Write your own rules using predicates we have discussed in class. Note that append(L1,L2,L3) will be a very helpful predicate to use in some cases. a. a listOfa(L) returns true only if L is a list of one or more a's b. b listOfb(L) returns true only if L is a list of one or more b's c. c listOfc(L) returns true only of L is a list of one or more c's d. a'b' listOfab(L) returns true only if L is a list of a's followed by b's e. abc listOfabc (L) returns true only if L matches the pattern a"b c f. bba bbb regExpr1(L) returns true only if L matches the pattern bba"bbb g. (aa lcc) regExpr2(L) returns true only if L matches the pattern (aa | cc) h. a bcregExpr3(L) return true only if L matches pattern a b'c i. aba gRule1(L) returns true only if L is of the form a ba for n-0 Test each of your predicates on good and bad lists. For example listOfabc([a,a,b,c,c,c]) should return true while listOfabc([a,a,c,c,c]) should return false. Note: Mainly need d toi. a is shown below. Thanks! a. listOfa(L):- append ([ a | Y], [al, L). listOfa(Y) listOfa([a]) listOfa([a T]) :- listOfa(T)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!