-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassingm2.pl~
91 lines (60 loc) · 1.46 KB
/
assingm2.pl~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
EXP 2
NAME SOHAM DANGE
REGISTRATION NO 22BCE11323
DATE 29/11/22
Rules:
A rule is a predicate expression that uses logical implication (:-) to describe a relationship among facts. Thus a Prolog rule takes the form
Recursive rule:
A recursive rule is a rule that explains how to get the next term in a sequence (ordered list) of numbers based off of previous terms.
Unification:
Unification is a process of making two different logical atomic expressions identical by finding a substitution.
*/
/*Q1
1.*/
engineer(anyone).
likes(programming,anyone):-anyone(engineer).
/*2.*/
/*
clean(agent,X):dirty(X).
*/
/*3.
pp :- write('student'),nl,
read(sincere),nl,read(obedient),nl,
condition(sincere,obedient).
*/
/*4*/
coder(anyone).
code(coder,anyone):-anyone(coder).
/*5.*/
owns(someone,something).
loves(someone,something):-owns(someone,something).
/*Q2*/
p(a, b).
p(b, c).
p(X, Y):-p(Y, X).
/*
A.?- p(X,Y).
; Scrolls through all data in the variable then keeps running in the
loop.
X = a, Y = b ; X = b, Y = c ; X = b, Y = a ; X = c, Y = b ; X =
a, Y = b
*/
/*Q2 */
likes(jax, X).
likes(X, jin).
/*
1
?- likes(jax,X)=likes(X,jin).
false.
same variable cannot be assigned
2
?- food(X,Y,Z)=food(M,M,M).
X = Y, Y = Z, Z = M.
3
?- food(b, c, d(a))= food(X, X, X).
false.
*/
/*Q4*/
?- [X|Y]= [likes(jin, black(dog)),likes(kate, dog)].
X = likes(jin, black(dog)),