Rahul Bothra 2016A7PS0015P
Sankalp Sangle 2016A7PS0110P
- To check whether a given binary relation is transitive over a given set.
- To compute the transitive closure of a binary relation over a given set.
Additional details are given in Question.pdf
Note:
- A, B are Lists.
- C is a element.
- S is a list of elements in the Set. (Input format: List of elements)
- R is the binary relation on the set S. (Input Format: List of 2-element lists)
- X is used to compute and return a value.
member(C,A): Builtin to check whether C is a member of A.
appendList(A,B,X): Appends A to B and returns them as X.
validRelation(S,R): Checks whether all elements in R belong to S.
transitiveCheck(R): Checks whether R is transitive.
transitive(S,R): Checks whether R is valid over S and is transitive.
closureCheck(R,X): Computes the transitive closure of the R and returns it as X.
closure(S,R): Checks whether R is valid over S and prints transitive closure of R.
- Load the file answer.pl
swipl answer.pl
- To check if a Relation R is transitive over a set S, type
transitive(S, R).
- To compute transitive closure of a Relation R, type
closure(S,R).
- To check whether a Relation R' is the transitive closure of Relation R, type
closureCheck(R,R').