Question

In: Computer Science

Define the subtraction predicate: set_difference(Set1,Set2,SetDifference) where all the three sets are represented as lists. For example,...

Define the subtraction predicate: set_difference(Set1,Set2,SetDifference) where all the three sets are represented as lists. For example, set_difference([a,b,c,d],[b,d,e,f],[a,c]). should return true. Also, the predicate should terminate as soon as the first solution is found when unifying variables for these arguments. That is, set_difference([a,b,c,d],[b,d,e,f],X). should terminate immediately after finding the first solution, X = [a,c].

Solutions

Expert Solution

Explanation:

Predicate logic:

In mathematical logic, a predicate is commonly understood to be a Boolean-valued function F, such that X→ {true, false}, called a predicate on X. However, predicates have many different uses and interpretations in mathematics and logic, and their precise definition, meaning and use varies from one theory to another. When a theory defines the concept of a relation, a predicate simply becomes the characteristic function or the indicator function of the relation.

In the light of the above discussion, the given subtraction predicate is discussed as follows:

The Subtraction Predicate:

The given subtraction predicate : set_difference(Set1,Set2,SetDifference) where all the three sets are represented as lists.

Therefore, the subtraction predicate can be defined as the differece between the first two arguments of the set_difference function, viz Set1 and Set2 and the difference of the subtraction is compared to the thrid argument, viz SetDifference. If the values of the result of the subtraction and the argument SetDifference are found to be the same, atleast til finding the first solution, then the function returns a boolean TRUE and otherwise, if the values are unequal, then the returned value is a boolean FALSE. Mathematically, this can be denoted as follows:

FindDifference = Set1 - Set2;

If FindDifference =  SetDifference, then return TRUE else return FALSE.

The Example Given:

In accordance to the given definition, the given example is analysed as follows:

Given: Set1 = [a,b,c,d] , Set2 =  [b,d,e,f], SetDifference = [a,c]

FindDifference = Set1 - Set2 = [a,b,c,d] - [b,d,e,f] = elements of Set1 - elements of Set2 that are in Set1

= [a,b,c,d] - [b,d] = [a,c] = SetDifference

Since, FindDifference =  SetDifference, therefore it returns TRUE.

This defines the subtraction predicate set_difference(Set1,Set2,SetDifference) along with the necessary explanations and analysis of the given example. Please like the answer if it serves your purpse. Thank you.


Related Solutions

Sets can be though of as lists that don't contain any repeated elements. For example, [a,4,6]...
Sets can be though of as lists that don't contain any repeated elements. For example, [a,4,6] is a set, but [a,4,6,a] is not (as it contains 2 occurrences of a). Write a Prolog program, powerset/2 that generates the set of all subsets of a list in sorted order. (Note the input list may not, itself, be a set.) Example1: powerset([a,b],X). should yield: X = [[],[a],[a,b],[b],[b,a]]. Example2: powerset([a,b,a],X). should also yield (note input list is not actually a set): X =...
Define the three forms of the efficient market hypothesis. Give an example of each.
Define the three forms of the efficient market hypothesis. Give an example of each.
Define each of Weber's three types of authority and give an example of each.
Define each of Weber's three types of authority and give an example of each.
Define the three types of selection and provide an example of each. (please type for easier...
Define the three types of selection and provide an example of each. (please type for easier read)
Define critical period. Provide an example of a critical period for each of the three domains...
Define critical period. Provide an example of a critical period for each of the three domains (physical, psychosocial, cognitive) of development.
List and define the three types of integration discussed in Topic 5. Give an example of...
List and define the three types of integration discussed in Topic 5. Give an example of each. (Be specific)
Define the three types of hypothesis tests and explain why they are used. Give an example...
Define the three types of hypothesis tests and explain why they are used. Give an example for each.
The subject is Applied Decision Methods. Define break even point analysis and give an example where...
The subject is Applied Decision Methods. Define break even point analysis and give an example where you used a break-even point analysis?
With the example of sugarcane, explain the interdependence of all the three sectors of the economy.
With the example of sugarcane, explain the interdependence of all the three sectors of the economy.
Define healthcare finance and provide an example of how it affects managers at all levels within...
Define healthcare finance and provide an example of how it affects managers at all levels within the organization. Also, explain why budgets are important to all organizations and illustrate how different types of budgets are used.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT