1. Two lists Xs and Ys such as [4,5,4,6,1,2,1] and [5,4,6,1,2,1] are said to be equivalent in their contents; in other words, every member in Xs appears in Ys and every member in Ys appears in Xs. Define a equivalentContents/ 2 predicate such that equivalentContents (Xs, Ys) is true if and only Xs and Ys are both lists and they have equivalent contents.
2. A list Xs such as [4,5,4,6,1,2,1] is not a compact list since members such as 4 and 1 appear more than once in it. Define a compact / 2 predicate such that given a list Xs, compact(Xs, Ys) will bind Ys to a list that contains every member in Xs exactly once. For example, given the concrete list [4,5,4,6,1,2,1] compact([4,5,4,6,1,2,1], Ys) should bind Ys to a list containing the each of the five distinct members 4,5,6,1,2 exactly once.
3. A list Xs such as [4,5,4,6,1,2,1] is not compact since members like 4 and 1 appear more than once in it. Define a numMembers / 2 predicate such that given a list Xs, numMembers(Xs, N) will bind N to the distinct number of members in the list. For example, numMembers([4,5,4,6,1,2,1] , N) should bind N to 5 since there are 5 distinct members in the list even if the the length of list is 7.
4. We can represent a the mathematical concept of sets as lists. For example, the list [4,5,6,1,2] can represent the a set of five distinct members 4,5,6,1 and 2. Define a setIntersction/ 3 predicate such that given two lists Xs and Ys representing two sets setIntersction (Xs, Ys, Zs) will bind Zs to the intersection of Xs and Ys. For example, setIntersction ([1,2,3,4], [2,4,6], Zs) should bind Zs to a (compact) list containing the two common members 2 and 4.
5. Define a setUnion/ 3 predicate such that given two lists Xs and Ys representing two sets setUnion (Xs, Ys, Zs) will bind Zs to the union of Xs and Ys. For example, setUnion ([1,2,3,4], [2,4,6], Zs) should bind Zs to a (compact) list containing the five members 1,2,3,4 and 6.
6. Define a setDiff/ 3 predicate such that given two lists Xs and Ys representing two sets setDiff (Xs, Ys, Zs) will bind Zs to a (compact) list containing each member that appears in Xs but not in Ys. For example, setDiff ([1,2,3,4], [2,4,6], Zs) should bind Zs to a (compact) list containing the two members 1 and 3.