EDAN20 Language Technology A Short Introduction to Prolog

Similar documents
DAY 1 WHO, WHERE, WHY, WHEN?

The Odyssey. December 5, 2016

B.C. Amphora with Chariot Race

A LONG AND DIFFICULT JOURNEY

King Of Ithaca (Adventures Of Odysseus) By Glyn Iliffe READ ONLINE

Religious Practices. The Ancient Greeks believe in many different gods, each of them was in charge of a different aspect of life.

The Odyssey Background Notes. Written by Homer

#5 Introduction to The Odyssey CN

The Odyssey. Now I will avow that men call me Odysseus, Sacker of Cities, Laertes' son, a Prince of the Achaeans," said the Wanderer.

The Iliad and the Odyssey, Part 1

The Trojan War: Real or Myth?

EPISODES OF NOSTALGIA: THE WARRIORS RETURN HOME

4 What god punishes the Greeks with plague for withholding the girl from her father? a. Zeus b. Athena c. Thetis d. Apollo e.

ACHILLES FATE FOLLOWS AND MEN AND CHILDREN WILL BE SLAUGHTERED AS

GREEK MYTHS. But the baby is rescued and the king and queen of Corinth adopt the baby, But they don't tell the baby, Oedipus, that he is adopted.

The Odyssey. The Trojan War. The Odyssey is the sequel to the poem, The Iliad.

Teacher s Pet Publications

homer the odyssey 92DD8E230BE554A34FEDE BB68 Homer The Odyssey 1 / 6

Passenger Rebooking - Decision Modeling Challenge

Homer s The Odyssey - Review Guide

Homer s Epics 11/21/2011 1

HOMER ODYSSEY LECTURE 2-6 JANUARY 10-22, 2018

THE GIFT THAT HID A NASTY SURPRISE The war between the Greek and Trojan armies finally ended last week when the Greeks used a cunning trick to mount

The odyssey. an introduction by David Adams Leeming

An Introduction to The Odyssey

Of course, Paris chose Aphrodite. This action set in motion several things which would eventually culminate in the Trojan War.

Level: DRA: Genre: Strategy: Skill: Word Count: Online Leveled Books HOUGHTON MIFFLIN

Study Guide. By John O Neil. Wheelock Family Theatre 200 The Riverway Boston, MA

The Odyssey-The Story Of Odysseus By Homer; W.H.D. Rouse READ ONLINE

Clst 181SK Ancient Greece and the Origins of Western Culture. Homer s Iliad. Final Preliminaries

Background & Books One and Nine

The Princess Of Prophecy: Heroes Of The Trojan War, Volume II By Aria Cunningham READ ONLINE

DO NOW: Pick up the map of Eastern Europe pg 978

THE PREHISTORIC AEGEAN AP ART HISTORY CHAPTER 4

Greece Intro.notebook. February 12, Age of Empires

1. Sea: heavy influence on physical environment of Greece (Aegean Sea, Ionian Sea)

Configuring a Secure Access etrust SiteMinder Server Instance (NSM Procedure)

Introduction to the Odyssey

INTRODUCTION TO THE ODYSSEY

The Myth of Troy. Mycenaeans (my see NEE ans) were the first Greek-speaking people. Trojan War, 1200 B.C.

Ancient Greece. Chapter 6 Section 1 Page 166 to 173

Lessons & Activities for the Elementary & Middle School Focusing on Ancient Greek Language and Culture

From Greece to Rome: Homer, Vergil and the Trojan War

TROY: Sacrifice and Survival

A FEW NOTES ABOUT HOMER AND HIS WORKS

TEACHER S PET PUBLICATIONS. PUZZLE PACK for THE ODYSSEY based on the work by Homer

THE HOUSE OF ATREUS ZEUS TANTALUS PELOPS NIOBE = AMPHION ATREUS THYESTES 14 CHILDREN 2 CHILDREN MENELAUS= HELEN AGAMEMNON = CLYTEMNESTRA AEGISTHUS

Name: # Block: V BN M dlskfsdflk JO EWRN;DFL/ 5 G 6 K 9 P R 1 T 3 Y 4 U 5 I 6 O 8 P 0 G - H = J 9. V BN M dlskfsdflk JO EWRN;DFL/

Agamemnon Aeschylus The Oresteia Iphigenia s Death View Women

Global formulas. Page1. Video filmed with GeneXus X Evolution 2

soon after being placed in the ocean (Tripp, ).

Fiction Excerpt 2: Excerpts from Homer s Iliad. The Judgment of Paris

Achilles Study Guide. fire or, in some accounts, dipped him into the River Styx by his heel in order to make him

Query formalisms for relational model relational algebra

Clst 181SK Ancient Greece and the Origins of Western Culture. Homer s Iliad. Books 6, 9

Text 3: Homer and the Great Greek Legends. Topic 5: Ancient Greece Lesson 1: Early Greece

Topic Page: Agamemnon (Greek mythology)

Aeschylus. Won his first Dionysia in 484. Title unknown.

The Odyssey Of Homer By William Morris READ ONLINE

The Odyssey. By Homer

The Odyssey Traits Of Odysseus Essay

10.1 Beliefs. pp Essential Question: What makes the Greek s culture unique? Standard 6.56

ENG 208 Baker Outline / Summary Odyssey

History Lesson 4 The Rise of Ancient Greece (Grade 6) Instruction 4-1 Aegean Civilizations (Grade 6)

The Odyssey: Synthesis Notes

Trojan War Actors at their best (I can look at an event from different perspectives and act out what can happen when two different civilizations want

Activity Template. Drexel-SDP GK-12 ACTIVITY. Subject Area(s): Sound Associated Unit: Associated Lesson: None

ELENI DIKAIOU ILLUSTRATED BY LOUISA KARAGEORGIOU

THE HISTORY OF ANCIENT GREECE

Salma Parvin Suma * * Lecturer, Department of English, Asian University of Bangladesh,

Plan of the City of Troy 7/9/2009

The Minoans and Mycenaeans. Who were they? Where did they come from? What did they accomplish? Where did they go?

GEC Model United Nations

Ancient Greece B.C.E.

MINOAN AND MYCENAEAN WORLDS BC

Iliad Book I. 3. Did the Achaeans know why Apollo plagued them at first? 7. What did Agamemnon take and from whom to replace Chryseis?

TURKEY PACKAGE. AFFORDABLE TURKEY - ORNAFFT (7 Nights/ 8 Days)

1) The Greek Hero: How did the Concept Evolve? - What made each of these figures heroic? For what qualities did they receive respect or admiration?

ACCORDING to tradition,l the Alexandrian critics Aristarchus

The Iliad AND THE ODYSSEY. Marshall High School Mr. Cline Western Civilization I: Ancient Foundations Unit Three BA

Ancient Greece BCE

Troy: From Homer's Iliad To Hollywood Epic READ ONLINE

Risk Assessment in Winter Backcountry Travel

Part 1. Part 2. airports100.csv contains a list of 100 US airports.

Topic Page: Iphigenia (Greek mythology)

World History I SOL WH1.5e, f Mr. Driskell

Iliad: The Story Of Achilles By Homer

World History María E. Ortiz Castillo

Topic Page: Achilles (Greek mythology)

1146 S. Cedar Crest Boulevard and 1148 S. Cedar Crest Boulevard Allentown, Pa 18103

Iliad: The Story Of Achilles (Library Edition) By Homer

TIMS to PowerSchool Transportation Data Import

1. Keep the tri-fold of notes as your bookmark. That information, along with other links on mrs.praser.com and Moodle can help you.

- Credits - Sample file. Green Ronin Publishing. P.O. Box 1723 Renton, WA Web Site:

Famous Greeks. Course Guidebook. Topic History. Subtopic Ancient History. Professor J. Rufus Fears. Guidebook

CONTENTS. Appendix. Teaching Guidelines...4. Book 1: The Anger of Achilles...6. Genealogies Book 2: Before Battle...8

22 years/années 12 years/années EDL 26/09/2013/ Council of Europe

I T N E T R E N R A N T A I T ON O AL A L A R A R R I R VA V L A S L S A N A D N D D E D PA

CONTENTS. Appendix. Teaching Guidelines...4. Book 1: The Anger of Achilles...6

New Zealand Transport Outlook. Origin and Destination-Based International Air Passenger Model. November 2017

Transcription:

EDAN20 http://cs.lth.se/edan20/ Pierre Nugues Lund University Pierre.Nugues@cs.lth.se http://cs.lth.se/pierre_nugues/ September 2, 2015 Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 1/19

Facts character(priam, iliad). character(hecuba, iliad). character(achilles, iliad). % Male characters % Female characters male(priam). female(hecuba). male(achilles). female(andromache). male(agamemnon). female(helen). male(patroclus). female(penelope). male(hector). male(rhesus). male(ulysses). male(menelaus). male(telemachus). male(laertes). male(nestor). character(ulysses, odyssey). character(penelope, odyssey). character(telemachus, odyssey). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 2/19

More Facts % Fathers % Mothers father(priam, hector). mother(hecuba, hector). father(laertes,ulysses). mother(penelope,telemachus). father(atreus,menelaus). mother(helen, hermione). father(menelaus, hermione). father(ulysses, telemachus). king(ulysses, ithaca, achaean). king(menelaus, sparta, achaean). king(agamemnon, argos, achaean). king(priam, troy, trojan). A Prolog fact corresponds to: relation(object1, object2,..., objectn). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 3/19

Terms Terms male(ulysses) Graphical representations male ulysses father(ulysses, telemachus) father ulysses telemachus character(ulysses, odyssey, king(ithaca, achaean)) character ulysses odyssey king ithaca achaean Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 4/19

Queries Is Ulysses a male??- male(ulysses). Yes Is Penelope a male??- male(penelope). No Is Menelaus a male and is he the king of Sparta and an Achaean??- male(menelaus), king(menelaus, sparta, achaean). Yes Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 5/19

Variables Characters of the Odyssey?- character(x, odyssey). X = ulysses What is the city and the party of king Menelaus? etc.?- king(menelaus, X, Y). X = sparta, Y = achaean?- character(menelaus, X, king(y, Z)). X = iliad, Y = sparta, Z = achaean?- character(menelaus, X, Y). X = iliad, Y = king(sparta, achaean) Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 6/19

Multiple Solutions All the males:?- male(x). X = priam ; X = achilles ;... No Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 7/19

Shared Variables Is the king of Ithaca also a father??- king(x, ithaca, Y), father(x, Z). X = ulysses, Y = achaean, Z = telemachus The anonymous variable _:?- king(x, ithaca, _), father(x, _). X = ulysses Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 8/19

Rules Derive information from facts: son(x, Y) :- father(y, X), male(x). son(x, Y) :- mother(y, X), male(x). HEAD :- G1, G2, G3,... Gn.?- son(telemachus, Y). Y = ulysses; Y = penelope; No parent(x, Y) :- mother(x, Y). parent(x, Y) :- father(x, Y). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 9/19

Recursive Rules grandparent(x, Y) :- parent(x, Z), parent(z, Y). grand_grandparent(x, Y) :- parent(x, Z), parent(z, W), parent(w, Y). ancestor(x, Y) :- parent(x, Y). ancestor(x, Y) :- parent(x, Z), ancestor(z, Y).?- ancestor(x, hermione). X= menelaus; X = helen; X = atreus; No Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 10/19

Unification Prolog uses unification in queries to match a goal and in term equation T1 = T2. T1 = character(ulysses, Z, king(ithaca, achaean)) T2 = character(ulysses, X, Y) character = character ulysses Z king ulysses X Y ithaca achaean Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 11/19

Lists Lists are useful data structures Examples of lists: [a] is a list made of an atom [a, b] is a list made of two atoms [a, X, father(x, telemachus)] is a list made of an atom, a variable, and a compound term [[a, b], [[[father(x, telemachus)]]]] is a list made of two sublists [] is the atom representing the empty list. Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 12/19

Head and Tail of a List It is often necessary to get the head and tail of a list:?- [a, b] = [H T]. H = a, T = [b]?- [a] = [H T]. H = a, T = []?- [a, [b]] = [H T]. H = a, T = [[b]] The empty list can t be split:?- [] = [H T]. No Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 13/19

The member/2 List Predicate member/2 checks whether an element is a member of a list:?- member(a, [b, c, a]). Yes?- member(a, [c, d]). No member/2 can be queried with variables to generate elements member of a list as in:?- member(x, [a, b, c]). X = a ; X = b ; X = c ; No. Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 14/19

The member/2 Definition member/2 is defined as member(x, [X Y]). % Termination case member(x, [Y YS]) :-% Recursive case member(x, YS). We could also use anonymous variables to improve legibility and rewrite member/2 as member(x, [X _]). member(x, [_ YS]) :- member(x, YS). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 15/19

The append/3 List Predicate append/3 appends two lists and unifies the result to a third argument:?- append([a, b, c], [d, e, f], [a, b, c, d, e, f]). Yes?- append([a, b], [c, d], [e, f]). No?- append([a, b], [c, d], L). L = [a, b, c, d]?- append(l, [c, d], [a, b, c, d]). L = [a, b]?- append(l1, L2, [a, b, c]). L1 = [], L2 = [a, b, c] ; L1 = [a], L2 = [b, c] ; etc. with all the combinations. Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 16/19

The append/3 Definition append/3 is defined as append([], L, L). append([x XS], YS, [X ZS]) :- append(xs, YS, ZS). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 17/19

Searching the Minotaur link(r1, r2). link(r1, r3). link(r1, r4). link(r1, r5). link(r2, r6). link(r2, r7). link(r3, r6). link(r3, r7). link(r4, r7). link(r4, r8). link(r6, r9). Room 1 Room 2 Room 3 Room 4 Room 5 Since links can be traversed both ways, the s/2 predicate is: Room 6 Room 7 Room 8 Room 9 s(x, Y) :- link(x, Y). s(x, Y) :- link(y, X). And minotaur(r8). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 18/19

Depth-First Search %% depth_first_search(+node, -Path) depth_first_search(node, Path) :- depth_first_search(node, [], Path). %% depth_first_search(+node, +CurrentPath, -FinalPath) depth_first_search(node, Path, [Node Path]) :- goal(node). depth_first_search(node, Path, FinalPath) :- s(node, Node1), \+ member(node1, Path), depth_first_search(node1, [Node Path], FinalPath). The goal is expressed as: goal(x) :- minotaur(x). Pierre Nugues EDAN20 http://cs.lth.se/edan20/ September 2, 2015 19/19