My Paper Writer » Essay Blog » Computer Science Essays Help » Write a program in PROLOG

Write a program in PROLOG

For this program, you are to write a program in PROLOG to solve the following logic problem. Note that ‘adjacent to’ or ‘neighbor’ may be on the left or the right unless other constraints dictate otherwise.

A particular street has 5 houses, numbered sequentially from left to right. Each house is a different color. The resident of each house is a different nationality. Each resident has a different favorite beverage, a different pet, and a favorite sports team.

The Raiders fan owns a dog.

The resident of the red house has a Vietnamese neighbor.

The cat owner is English.

The juice drinker lives next to the dog owner.

The milk drinker is Canadian.

The blue house is on the near (left) end.

The horse owner is Vietnamese.

The juice drinker lives in the yellow house.

The dog owner lives next to the blue house.

The Ravens fan owns a hamster.

The South African drinks tea.

The red house is adjacent to the far end.

The cat owner and the juice drinker are NOT neighbors.

The neighbor of the Raiders fan keeps a horse.

The red house is the home of the Ravens fan.

The Canadian lives in the green house.

The Chargers fan lives in the blue house.

The resident of the white house is South African.

The coffee drinker owns a cat.

The milk drinker lives at the far end of the street.

The Broncos fan lives in the yellow house.

What nationality is the owner of the red house, and what pet does the Chiefs fan have?

Write a PROLOG program that contains the above facts as a knowledge base, and functions to capture ‘adjacent to,’ ‘all different,’ etc. Your program should begin with the above facts and deduce the house color, nationality, beverage, pet, and sports team for each house on the street, printing the information at the end. Submit your program code and output from a sample execution.

House colors: blue, green, red, white, yellow

Nationalities: Canadian, Colombian, English, South African, Vietnamese

Pets: Cat, Dog, Hamster, Horse, Lizard

Beverage: Coffee, Juice, Milk, Tea, Water

Teams: Broncos, Chargers, Chiefs, Raiders, Ravens



Last Updated on October 26, 2019

Don`t copy text!