summaryrefslogtreecommitdiff
path: root/prolog/facts
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/facts')
-rw-r--r--prolog/facts/denotational_semantics_aux__predicates.py32
-rw-r--r--prolog/facts/family_relations.py76
2 files changed, 108 insertions, 0 deletions
diff --git a/prolog/facts/denotational_semantics_aux__predicates.py b/prolog/facts/denotational_semantics_aux__predicates.py
new file mode 100644
index 0000000..4bf315b
--- /dev/null
+++ b/prolog/facts/denotational_semantics_aux__predicates.py
@@ -0,0 +1,32 @@
+id = 2
+
+name = 'denotational semantics aux. predicates'
+
+facts = '''\
+findblank(R, Bx) :-
+ findblank(R, 1, Bx).
+findblank([0|_], Bx, Bx) :- !.
+findblank([_|T], Cx, Bx) :-
+ Cx1 is Cx + 1,
+ findblank(T, Cx1, Bx).
+
+swap([H1,H2|T],2,[H2,H1|T]).
+swap([H|T],C0,[H|NewT]):-
+ C0 > 2,
+ C is C0 - 1,
+ swap(T,C,NewT).
+
+swap(R, I1, I2, NewR) :-
+ (I1 < I2, !,
+ Ix1 = I1, Ix2 = I2
+ ;
+ Ix1 = I2, Ix2 = I1),
+ Cut1 is Ix1 - 1,
+ Cut2 is Ix2 - Ix1 - 1,
+ length(LBef, Cut1),
+ length(LMid, Cut2),
+ lists:append(LBef, [E1|RRest], R),
+ lists:append(LMid, [E2|LAft], RRest),
+ lists:append(LBef, [E2|RIntermediate], NewR),
+ lists:append(LMid, [E1|LAft], RIntermediate).
+'''
diff --git a/prolog/facts/family_relations.py b/prolog/facts/family_relations.py
new file mode 100644
index 0000000..6be71fa
--- /dev/null
+++ b/prolog/facts/family_relations.py
@@ -0,0 +1,76 @@
+id = 1
+
+name = 'family relations'
+
+facts = '''\
+parent(tina, william).
+parent(thomas, william).
+parent(thomas, sally).
+parent(thomas, jeffrey).
+parent(sally, andrew).
+parent(sally, melanie).
+parent(andrew, joanne).
+parent(jill, joanne).
+parent(joanne, steve).
+parent(william, vanessa).
+parent(william, patricia).
+parent(vanessa, susan).
+parent(patrick, susan).
+parent(patricia, john).
+parent(john, michael).
+parent(john, michelle).
+
+parent(frank, george).
+parent(estelle, george).
+parent(morty, jerry).
+parent(helen, jerry).
+parent(jerry, anna).
+parent(elaine, anna).
+parent(elaine, kramer).
+parent(george, kramer).
+
+parent(margaret, nevia).
+parent(margaret, alessandro).
+parent(ana, aleksander).
+parent(aleksandr, aleksander).
+parent(nevia, luana).
+parent(aleksander, luana).
+parent(nevia, daniela).
+parent(aleksander, daniela).
+
+male(william).
+male(thomas).
+male(jeffrey).
+male(andrew).
+male(steve).
+male(patrick).
+male(john).
+male(michael).
+male(frank).
+male(george).
+male(morty).
+male(jerry).
+male(kramer).
+male(aleksandr).
+male(alessandro).
+male(aleksander).
+
+female(tina).
+female(sally).
+female(melanie).
+female(joanne).
+female(jill).
+female(vanessa).
+female(patricia).
+female(susan).
+female(michelle).
+female(estelle).
+female(helen).
+female(elaine).
+female(anna).
+female(margaret).
+female(ana).
+female(nevia).
+female(luana).
+female(daniela).
+'''