Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Programming Languages Assignment

Write the following as Prolog rules: 

1. Implement a rule "dogEnthusiast". Someone is a "dogEnthusiast" if they own AT LEAST TWO dogs. Assume that the only types of facts available are:

"owner" facts of the form owner(p,n), meaning that person p owns animal named n.

"breed" facts of the form breed(a,b), meaning that animal named a is of type b.  

For example: 

owner(fred,fido) means that a person named "fred" owns an animal named "fido". 

breed(fido,dog) means that the animal named "fido" is a dog. 

breed(leo,cat) means that the animal named "leo" is a cat. 

dogEnthusiast(sam) would be true if sam owned two different animals that were dogs.

2. Implement "listPicker" from Homework #2 as a Prolog rule.

For example, the query:listPicker([42,3,99,7],[4,3,3],M) should result in Prolog's response:M = [7,99,99]. You only need to handle lists that contain integers.

3. Implement a rule "crypto" that solves the following cryptarithmetic multiplication problem:

TOCK * TOCK = GRIPTOCK

Each of the 4 letters (T,O,C,K) stands for a different digit. The 4 letters (G,R,I,P) can each be matched by any digit. The aim is to find a substitution of digits for the letters such that the above stated product is arithmetically correct. Your program should find all answers. It should be possible to query your solution in this manner:

?- crypto(G,R,I,P,T,O,C,K).

Your solution should then produce all of the combinations of the digits that satisfy the multiplication problem above. Don't get confused between the letter "O" and the number "0" (zero).

Make sure you never let T=C, or C=K, etc... all of the distinct letters T,O,C,K have to stand for distinct digits.

Don't be surprised if it takes your computer a while to solve this problem.

Use generate-and-test!

4. Implement a rule "interleave" that takes two lists, and combines them into a single list by alternating the elements. For example:

?- interleave([3,4,5],[7,8,9],X) should respond X=[3,7,4,8,5,9]

If the two lists are different lengths, include the excess elements at the end of the result list, with a "999" inserted first. For example:

?- interleave([1,2],[4,5,6,7],X) results in X=[1,4,2,5,999,6,7] 

?- interleave([1,2,3,4],[6,7],X) results in X=[1,6,2,7,999,3,4]

5. Convert "digitinc" from Homework #2 into a Prolog rule. For example:

?- digitinc(22897,X) should respond X=33908.

Submit your solutions in a single file.

Problem 2 & 5 - Reference

"listPicker"

-  Inputs two lists the first list is the data and second list is the picker, and Outputs a list of values in the data list ref. by values in picker list.

"digitinc"

-  Takes as input integers with an arbitrary number of digits, and returns another digit integer constructed of the original input integer's digits, each incremented

Instructions for Prolog Assignment -

Note the following:

1. I recommend using the SWI-Prolog system.

2. You are only allowed to use basic functions which do not make the problems trivial.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92059905

Have any Question?


Related Questions in Programming Language

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As