comp3411 comp9418 Prolog

Question 2.1 (2 marks):
Intra-construction. This transformation takes two rules, with the same head, such as
<- [b, c, d, e] <- [a, b, d, f] and replaces the with rules <- [b, d, z] 2 <- [C, e] That is, we merge the two, ×, clauses, keeping the intersection and adding a new predicate, , that distributes the differences to two new clauses. ?- intra_construction(x <- [b, c, d, e], x <- [a, b, d, f], X, Y, Z). X = x<-[b, d, z1], Y = z1<-[C, e], Z = z1<-[a, f]. The predicate should fail if there is no intersection between the two clauses. Question 2.2 (2 marks): Absorption. This transformation takes two rules, with the different heads, such as and replaces the with rules x <- [d, e, y] <- [a, b, c] Note that the second clause is unchanged. This operator checks to see if the body of one clause is a subset of the other. If it is, the common elements can be removed from the larger clause and the head of the smaller one appended to the larger one. ?- absorption(x <- [a, b, c, d, e], y <- [a, b, c], X, Y). The predicate should fail if there is the body of the second clause is not a subset of the body of the first. Question 2.3 (2 marks): Truncation. This is the simplest transformation. It takes two rules that have the same head and simply drops the differences to leave just one rule. For example are replaced by x <- [a, c] That is. the body of the new clause is just the intersection of the bodies of the input ?- truncation(x <- [a, b, c, d], x <- [a, c, j, kJ, X). X = x<- [a, c]. The complete Duce algorithm performs a search, looking for combination of these operators that will lead to the greater compression over the database of examples. Here compression is measured by the reduction in the number of symbols in the database. You don't have to worry about the search algorithm, just implement the operators, as