summaryrefslogtreecommitdiff
path: root/knowledge_base.pl
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2025-03-26 13:05:30 +0200
committerZhongheng Liu <z.liu@outlook.com.gr>2025-03-26 13:05:30 +0200
commitcb233381dc6d818ae3d2efa416a8ba1434b85da5 (patch)
tree78b5b5f95d4ef6f45914f3d3c056fc6e3ce26aa9 /knowledge_base.pl
downloadprolog-master.tar.gz
prolog-master.tar.bz2
prolog-master.zip
feat: initial commit; sample prolog scriptHEADmaster
Diffstat (limited to 'knowledge_base.pl')
-rw-r--r--knowledge_base.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/knowledge_base.pl b/knowledge_base.pl
new file mode 100644
index 0000000..542ca70
--- /dev/null
+++ b/knowledge_base.pl
@@ -0,0 +1,32 @@
+human(jack).
+income(jack, 480).
+
+human(jones).
+income(jones, 20).
+
+human(joe).
+income(joe, 1000).
+
+human(jeremy).
+product(jeremy).
+
+product(grapes).
+cost(grapes, 5).
+
+product(pasta).
+cost(pasta, 1).
+
+product(car).
+cost(car, 400).
+likes(jack, pasta).
+likes(jones, car).
+likes(joe, car).
+can_afford(X, Y) :-
+ income(X, Income),
+ cost(Y, Cost),
+ Income > Cost.
+will_buy(X, Y) :-
+ human(X),
+ product(Y),
+ likes(X, Y),
+ can_afford(X, Y).