Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Prolog COMP 112 #31 2014.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Feature Structures and Unification.
1© 2003 T. Abou-Assaleh, N. Cercone, & V. Keselj Expressing Probabilistic Context-Free Grammars in the Relaxed Unification Formalism Tony Abou-Assaleh.
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
Cs7120 (Prasad)L21-DCG1 Definite Clause Grammars
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Creating and using Objects.
Racket Introduction CSC270 Pepper major portions credited to
Functional Programming COMP2003 A course on functional programming using Common Lisp Dr Fintan Costello.
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
Natural Language Processing - Feature Structures - Feature Structures and Unification.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Feature Structures and Unification.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Fall 2005-Lecture 2.
LING 364: Introduction to Formal Semantics Lecture 5 January 26th.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
LING 388: Language and Computers Sandiway Fong Lecture 17.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington User Interface COMP 112 #30.
Xiaoying Sharon Gao Mengjie Zhang Computer Science Victoria University of Wellington Introduction to Artificial Intelligence COMP 307.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
LING 388: Language and Computers Sandiway Fong Lecture 7.
Parsing arithmetic expressions Reading material: These notes and an implementation (see course web page). The best way to prepare [to be a programmer]
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
© Xiaoying Gao, Peter Andreae Introduction to Computer Program Design COMP T2. Xiaoying (Sharon) Gao Computer Science Victoria University of Wellington.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
© Xiaoying Gao, Peter Andreae Introduction to Computer Program Design COMP T2. Xiaoying (Sharon) Gao Computer Science Victoria University of Wellington.
Notes on Pinker ch.7 Grammar, parsing, meaning. What is a grammar? A grammar is a code or function that is a database specifying what kind of sounds correspond.
CT214 – Logical Foundations of Computing Lecture 8 Introduction to Prolog.
Syntax Why is the structure of language (syntax) important? How do we represent syntax? What does an example grammar for English look like? What strategies.
Grammars Grammars can get quite complex, but are essential. Syntax: the form of the text that is valid Semantics: the meaning of the form – Sometimes semantics.
Xiaoying Gao Computer Science Victoria University of Wellington Copyright: Xiaoying Gao, Peter Andreae, Victoria University of Wellington Exercise, printf,
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
The man bites the dog man bites the dog bites the dog the dog dog Parse Tree NP A N the man bites the dog V N NP S VP A 1. Sentence  noun-phrase verb-phrase.
OSes: 0. Prelim 1 Operating Systems v Objectives –to give some background on this subject Certificate Program in Software Development CSE-TC and CSIM,
Xiaoying Gao Computer Science Victoria University of Wellington Copyright: Xiaoying Gao, Peter Andreae, Victoria University of Wellington Creating Objects.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
Use function notation to evaluate and interpret functions
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Spring 2006-Lecture 2.
Xiaoying Gao Computer Science Victoria University of Wellington Copyright: Xiaoying Gao, Peter Andreae, Victoria University of Wellington Creating Objects.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Invitation to Computer Science, Java Version, Second Edition 1 Logic Programming Logic programming  Various facts are asserted to be true  On the basis.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Programs with Choice Booleans,
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Week 3 Help desks – Mon 4-5 CO238 Tutor: Su – Wed 1-2 CO238 Tutor: Urvesh – Fri CO238 Tutor: Bing Lectures: Mon, Tue, 3-4, HU119 Tutorial: Fri, 3-4,
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Creating and using Objects.
NATURAL LANGUAGE PROCESSING
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Xiaoying Gao Computer Science Victoria University of Wellington Copyright: Xiaoying Gao, Peter Andreae, Victoria University of Wellington Methods with.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW IRC, parsing, protocols COMP # 25.
Random Functions Selection Structure Comparison Operators Logical Operator
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
Scott C. Johnson Lecturer Rochester Institute of Technology Spring 2016.
Formal Languages and Automata FORMAL LANGUAGES FINITE STATE AUTOMATA.
Beginning Syntax Linda Thomas
课程名 编译原理 Compiling Techniques
Racket Introduction CSC270 Pepper
Lecture 2: General Structure of a Compiler
Artificial Intelligence CS370D
High Level Programming Languages
Programming Concepts and Database
Artificial Intelligence 2004 Speech & Natural Language Processing
Presentation transcript:

Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Prolog COMP 112 #

© Peter Andreae COMP :2 Outline Prolog – a very different programming language Admin: No lecture next Monday (Queen’s Birthday) Final lecture: summary, exam, Tues 3 rd June No lecture 5 th June Lab on Friday, but not next week.

© Peter Andreae COMP :3 Programming Paradigms Imperative programming Program tells the computer what to do. Object Oriented programming imperative plus organise data and code around classes of objects Functional programming Specify computation of values No side effects, Lazy evaluation Logic programming specify relationships that are true ask queries. interpreter works outs how to use the specified relationships to answer the queries.

© Peter Andreae COMP :4 Prolog program Variables start with uppercase: X, List, Explanation, (or an underscore: _rest) literals start with lowercase: a, b name, bsc lists are in [ … ] contains( [X], X). contains([X | _rest], X). contains([_any | Rest], X) :- contains(Rest, X). which is input and which is output?

© Peter Andreae COMP :5 Why use prolog If the core of the problem is expressing complex relationships between data, prolog is much easier to use than Java. eg rule-based “expert-systems”, (now called “business-intelligence”) codifying business rules (eg credit limit applications) eg landcare’s possum control decision support system. Parsing natural language prolog is excellent for expressing structure in language. It allows you to redefine the syntax to match the problem.

© Peter Andreae COMP :6 Checking degree rules. Student completed bsc with M major because E1 and E2 and E3 and E4 and E5 and EM:- Student has 360 points from any numbered because E1, Student has 180 points from any numbered because E2, Student has 72 points from bsc numbered because E3, Student has 270 points from bsc numbered because E4, Student has 120 points from bsc numbered because E5, Student completed M major because EM. Student completed comp major because E1 and E2 and E3:- Student has 60 points in comp numbered because E1, Student has comp201 and comp202 and (comp203 or comp204) because E2, Student has math114 and (stat193 or stat131 or quan102) and (math214 or math207 or opre251 or stat231) because E3.

© Peter Andreae COMP :7 Degree rules…. Student has Required points from Schedule numbered Range because (TotPts >= Required points from Schedule numbered Range) :- allCourses(Student, Courses), validPoints(Courses, Schedule, any, Range, TotPts), TotPoints >= Required. Student has Course1 and Course2 because Expl1 and Expl2 :- Student has Course1 because Expl1, Student has Course2 because Expl2. Student has Course because Course:- passed(Student, Course).

© Peter Andreae COMP :8 Degree rules…. code to enable the “natural language” syntax: :- op(815, xfx, has).:- op(807, fx, in). :- op(815, xfx, completed).:- op(805, xfy, --). :- op(813, xfx, because).:- op(803, xfy, or). :- op(811, xfx, points).:- op(801, xfy, and). :- op(811, xfx, of).:- op(801, xfy, with). :- op(809, xfx, numbered).:- op(800, xf, major). :- op(807, fx, from).:- op(800, xf, submajor).

© Peter Andreae COMP :9 Language rules in Prolog: Prolog program using DCG rules: sentence(sent(NP,VP)) --> noun_phrase(NP), verb_phrase(VP). noun_phrase(np(D,N)) --> det(D), noun(N). verb_phrase(vp(V,NP)) --> verb(V), noun_phrase(NP). det(the) --> [the]. det(a) --> [a]. noun(cat) --> [cat]. noun(bat) --> [bat]. noun(flies) --> [flies]. verb(eats) --> [eats]. verb(flies) --> [flies]. verb(gives) --> [gives]. parse(Tree, L) :- sentence(Tree, L, []).