Compare commits

...

4 Commits

Author SHA1 Message Date
Arkadiusz Hypki
207bf9c14c Merge branch 'master' of https://git.wmi.amu.edu.pl/ahypki/wmi-parprog 2024-04-22 13:41:01 +02:00
Arkadiusz Hypki
92f695e60c 'Added ex2 for Prolog;' 2024-04-22 13:40:57 +02:00
Arkadiusz Hypki
028724325d 'FIxing fac.pl' 2024-04-18 12:32:57 +02:00
Arkadiusz Hypki
1f5ba69a6d 'Added parent(mike,juliet).' 2024-04-18 09:14:14 +02:00
5 changed files with 22 additions and 1 deletions

View File

@ -23,6 +23,7 @@ parent(esther,rosie).
parent(esther,dicky).
parent(greatgramma,esther).
parent(randy,blair).
parent(mike,juliet).
male(mel).
male(teo).
@ -31,3 +32,18 @@ parent(melsr,teo).
father(X,Y) :- male(X),parent(X,Y).
mother(X,Y) :- female(X),parent(X,Y).
son(X,Y) :- male(X),parent(Y,X).
dauther(X,Y) :- female(X),parent(Y,X).
uncle(X,Y) :- male(X),brother(X,Z),parent(Z,Y).
aunt(X,Y) :- female(X),sister(X,Z),parent(Z,Y).
grandmother(X,Y) :- mother(Z,Y),mother(X,Z).
grandmother(X,Y) :- father(Z,Y),mother(X,Z).
grandmother(X,Y) :- female(X),parent(Z,Y),parent(X,Z).
%grandfather
sister(X,Y) :- female(X),parent(Z,X),parent(Z,Y),X\=Y.
brother(X,Y) :- male(X),parent(Z,X),parent(Z,Y),X\=Y.
cousin(X,Y) :- uncle(Z,Y),parent(Z,X).
cousin(X,Y) :- aunt(Z,Y),parent(Z,X).

Binary file not shown.

5
06_prolog/ex2-roads/desc Normal file
View File

@ -0,0 +1,5 @@
Parse the file Zarzadzenie_GD_nr_32_z_dnia_2022-12-27.pdf by extracting the connections between the cities (e.g. copy&paste from pdf, pinch of regex, mix for a few minutes). Create facts for Prolog and do the exercises:
1. Find any path from Suwałki to Jelenia Góra
2. Find all paths between Szczecin and Przemyśl and find the shortest one

View File

@ -5,6 +5,6 @@ fac(3,6).
fac(4,24).
fac(A,B) :-
A > 0,
fac(C,D),
C is A-1,
fac(C,D),
B is A*D.