Labs-
Lab - Create a KB called sjsu that contains the following information:
Turing is the instructor for CS152. Godel, Escher, Bach, and VonNeumann are enrolled in CS152.
Create a rule that defines the relationship Instructor X teaches student Y.
Lab: Recursion
Create and test a knowledge bases for the following scenario.
Homer is the parent of Bart, Lisa, and Maggie. Abe and Mona are Homer's parents.
Marge is also the parent of Bart, Lisa, and Maggie. Clancy and Jacquelin are her parents.
Clancy and Jacquelin are also the parents Selma and Patty.
Parents are ancestors as are ancestors of parents.
Siblings share a parent.
Lab: Arithmetic
We can use structures to represent positive integers in Prolog. For example:
0 = zero
1 = inc(zero)
2 = inc (inc (zero))
3 = inc (inc (inc (zero)))
etc.
Here inc(x) stands for the increment (add one) function.
Define and test the predicate add(X, Y, Z), which represents the relationship Z = X + Y.
Here's a start:
add(zero, X, ???).
add(inc(X), Y, inc(Z)) :- ???.
Define and test the predicate mul(X, Y, Z) which represents the relationship Z = X * Y.
Define and test the predicate exp(X, Y, Z) which represents the relationship Z = X ^ Y.
Define and test the predicate less(X, Y), which represents the relationship X < Y.
Lab: Org Charts, etc.
Define and test the following predicates:
supervises(X, Y) which represents the relationship X supervises Y or a supervisor of Y.
friend(X, Y) which represents the relationship X is a FB friend of Y.
equals(X, Y) which represents the relationship X == Y.
distance(X, Y, Z) which represents the relationship the distance from X to Y is Z hops where X and Y are nodes on an Ethernet wire.
Lab: Evaluating expressions
We can use structures to represent syntax trees in Prolog. For example, the expression
(3 * 4) + (5 + 6)
can be represented by the syntax tree:
sum(prod(num(3), num(4)), sum(num(5), num(6)))
Write an evaluator for the language of sums and products:
?-eval(sum(prod(num(3), num(4)), sum(num(5), num(6))), X).
X = 23.
Lab: Trees
Implement height(Tree, H) where H is the height of a tree of the form leaf or parent(LeftChild, RightChild)
Lab: Proplog
Proplog is a simplified version of Prolog that doesn't allow variables.
Attachment:- Assignment.rar