Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a PROLOG program that investigates family relationships using lists. The facts should be organized as follows: m ([first_male_name, second_male_name, ..., last_male_name]). f([first female
1. Write a PROLOG program that investigates family relationships using lists. The facts should be organized as follows: m ([first_male_name, second_male_name, ..., last_male_name]). f([first female name, second female name, ..., last female name]). family ( [father, mother, [child 1, child_2,..., child_n]]). Write rules that define the following relations: male (X) female (X) father, mother, parent siblingsl, siblings2 brotherl, brother2 sisterl, sister2 cousins uncle, aunt grandchild, grandson, granddaughter greatgrandparent ancestor For each of these rules show an example of its use. 2. Write a PROLOG program that includes the following operations with lists: membership testing (is an element member of a list?) first element last element two adjacent elements three adjacent elements append list1 to list2 producing list3 delete element from a list append element to a list insert element in a list Compute the length of list reverse a list check whether a list is a palindrome display a list For each of these operations write your implementation of the operation and show an example of its use. If a predicate already exists (predefined in Prolog), modify its name (e.g. myappend or appendl). Lists to be processed can be created by an auxiliary program, defined as facts, or entered from the keyboard. 3. Write a PROLOG program that solves the 8 queens problem (location of 8 queens on a chess board so that no queens have each other in check, i.e. are not located in the same row/column/diagonal). 1. Write a PROLOG program that investigates family relationships using lists. The facts should be organized as follows: m ([first_male_name, second_male_name, ..., last_male_name]). f([first female name, second female name, ..., last female name]). family ( [father, mother, [child 1, child_2,..., child_n]]). Write rules that define the following relations: male (X) female (X) father, mother, parent siblingsl, siblings2 brotherl, brother2 sisterl, sister2 cousins uncle, aunt grandchild, grandson, granddaughter greatgrandparent ancestor For each of these rules show an example of its use. 2. Write a PROLOG program that includes the following operations with lists: membership testing (is an element member of a list?) first element last element two adjacent elements three adjacent elements append list1 to list2 producing list3 delete element from a list append element to a list insert element in a list Compute the length of list reverse a list check whether a list is a palindrome display a list For each of these operations write your implementation of the operation and show an example of its use. If a predicate already exists (predefined in Prolog), modify its name (e.g. myappend or appendl). Lists to be processed can be created by an auxiliary program, defined as facts, or entered from the keyboard. 3. Write a PROLOG program that solves the 8 queens problem (location of 8 queens on a chess board so that no queens have each other in check, i.e. are not located in the same row/column/diagonal)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
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