1️⃣ BASIC QUERIES (Existential ∃)
Find entities that satisfy a predicate
Template: predicate(X, Y)
Examples using your extracted predicates:
• son_of(X, Y) → "Who is whose son?"
• originated_from(X, hellen) → "What originated from Hellen?"
• gained_power_in(hellenes, X) → "Where did Hellenes gain power?"
• entity(X, _, person) → "List all persons"
2️⃣ CONJUNCTION (∧) - AND Logic
Both conditions must be true. Use comma ,
Template: condition1, condition2, condition3
Examples:
• son_of(X, Y), gained_power_in(X, Z)
→ "Who is someone's son AND gained power somewhere?"
• entity(X, _, person), originated_from(Y, X), entity(Y, _, group_of_people)
→ "Persons from whom groups originated"
• existed_before(X, Y), son_of(Y, Z)
→ "What existed before someone who is someone else's son?"
3️⃣ DISJUNCTION (∨) - OR Logic
At least one condition must be true. Use semicolon ;
Template: (condition1 ; condition2 ; condition3)
⚠️ Must use parentheses!
Examples:
• (son_of(X, deucalion) ; originated_from(X, hellen))
→ "Who is Deucalion's son OR originated from Hellen?"
• (gained_power_in(X, phthiotis) ; lived_after(X, trojan_war))
→ "Who gained power in Phthiotis OR lived after Trojan War?"
• entity(X, _, person), (called(homer, X) ; named(homer, X))
→ "Persons whom Homer either called or named"
4️⃣ NEGATION (¬) - NOT Logic
Condition must be false. Use \+ (backslash plus)
Template: \+ predicate(X, Y)
Examples:
• entity(X, _, person), \+ son_of(X, _)
→ "Persons who are NOT anyone's son"
• entity(X, _, group_of_people), \+ existed_before(X, hellen)
→ "Groups that did NOT exist before Hellen"
• \+ lacked_unity_before(greece, X)
→ "What Greece did NOT lack unity before"
• entity(X, _, location), \+ gained_power_in(_, X), \+ from(_, X)
→ "Locations where no one gained power AND no one was from"
5️⃣ QUANTIFICATION
Find ALL matches, count, or check if ALL satisfy condition
🔸 EXISTENTIAL (∃) - Find All Solutions:
findall(X, predicate(X, Y), List)
Examples:
• findall(X, son_of(X, _), Sons)
→ "List ALL sons"
• findall(X, gained_power_in(X, phthiotis), Rulers)
→ "Everyone who gained power in Phthiotis"
• findall([X,Y], originated_from(X, Y), Origins)
→ "All origin pairs [what, from_whom]"
🔸 UNIVERSAL (∀) - Check All Satisfy:
forall(condition1, condition2)
Examples:
• forall(entity(X, _, person), existed_before(_, X))
→ "Do ALL persons have something that existed before them?"
• forall(son_of(X, _), entity(X, _, person))
→ "Are ALL sons classified as persons?"
🔸 COUNTING:
• count_type(person, N) → "How many persons?"
• count_type(location, N) → "How many locations?"
• findall(X, son_of(X, _), L), length(L, Count) → "Count all sons"
6️⃣ COMPLEX COMBINATIONS
Combine multiple operators for advanced reasoning
• son_of(X, Y), gained_power_in(X, Z), \+ lacked_unity_before(_, Z)
→ "Who is someone's son, gained power somewhere, and that place didn't lack unity before anything?"
• entity(X, _, person), (son_of(X, Y) ; originated_from(_, X)), \+ lived_after(X, trojan_war)
→ "Persons who are either a son OR someone originated from them, AND who did NOT live after Trojan War"
• findall(X, (originated_from(X, hellen), gained_power_in(X, _)), List), length(List, N)
→ "Count how many things originated from Hellen AND gained power somewhere"
• forall(son_of(X, _), (existed_before(_, X) ; gained_power_in(X, _)))
→ "Do ALL sons either have something before them OR gained power?"
7️⃣ READY-TO-USE QUERY TEMPLATES
Copy these and replace with your predicates
🔹 Genealogy & Origins:
• son_of(X, Y), son_of(Y, Z) → "Grandfather relationships"
• findall([Child, Parent], son_of(Child, Parent), Families) → "Family tree"
🔹 Power & Territory:
• gained_power_in(X, Y), from(Z, Y) → "Who gained power where someone was from?"
• entity(X, _, location), \+ gained_power_in(_, X) → "Places where no one gained power"
🔹 Temporal Reasoning:
• existed_before(X, Y), lived_after(Y, Z) → "X before Y, Y after Z"
• lacked_unity_before(X, Y), united_after(X, Z) → "Lacked unity before Y, united after Z"
🔹 Negative Facts:
• entity(X, _, person), \+ son_of(_, X) → "Persons with no children"
• entity(X, _, group_of_people), \+ originated_from(X, _) → "Groups without known origin"
💡 PRO TIP:
Use the "Available Predicates" section below (after extraction) to see EXACTLY what predicates you can query on your specific text!