Prolog
Prolog
Prolog
location(madhurai, tamilnadu).
location(coimbatore, tamilnadu).
location(mangalore, karnataka).
stays(raghul,madhurai).
stays(raja, coimbatore).
stays(anu, mangalore).
% Rules
person_state(Person, State) :-
stays(Person, City),
location(City, State).
% Queries
list_person_state_city :-
location(City, State),
stays(Person, City),
fail.
person_state_query(Person) :-
person_state(Person, State),
?- list_person_state_city.
false.
?- person_state_query(keerthana).
false.
2.
% Facts
parent(john, amy).
parent(john, sara).
parent(john, tom).
parent(kate, amy).
parent(kate, sara).
parent(kate, tom).
parent(peter, john).
parent(lisa, john).
parent(mary, kate).
parent(mary, luke).
parent(mark, sara).
parent(mark, tom).
% Rules
mother(Mother, Child) :-
parent(Mother, Child),
female(Mother).
father(Father, Child) :-
parent(Father, Child),
male(Father).
sibling(X, Y) :-
parent(Parent, X),
parent(Parent, Y),
X \= Y.
grandparent(Grandparent, Grandchild) :-
parent(Grandparent, Parent),
parent(Parent, Grandchild).
uncle(Uncle, NieceNephew) :-
sibling(Uncle, Parent),
parent(Parent, NieceNephew),
male(Uncle).
aunt(Aunt, NieceNephew) :-
sibling(Aunt, Parent),
parent(Parent, NieceNephew),
female(Aunt).
sister(Sister, Sibling) :-
sibling(Sister, Sibling),
female(Sister).
brother(Brother, Sibling) :-
sibling(Brother, Sibling),
male(Brother).
% Facts
parent(john, amy).
parent(john, sara).
parent(john, tom).
parent(kate, amy).
parent(kate, sara).
parent(kate, tom).
parent(peter, john).
parent(lisa, john).
parent(mary, kate).
parent(mary, luke).
parent(mark, sara).
parent(mark, tom).
% Gender facts
male(john).
male(peter).
male(mark).
male(tom).
female(kate).
female(amy).
female(sara).
female(lisa).
female(mary).
3.
celsius_to_fahrenheit(Celsius, Fahrenheit) :-
below_freezing(Temperature) :-
Temperature < 0.
celsius_to_fahrenheit(20, Fahrenheit).
Fahrenheit = 68.