Declarative Programming Autumn 2014 Introduction.

Slides:



Advertisements
Similar presentations
Intelligent Architectures for Electronic Commerce A (Brief) Prolog Tutorial.
Advertisements

Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Models and interpretations in the fifties: Carnap and Kemeny Pierre Wagner Université Paris 1 Panthéon-Sorbonne.
Prolog Programming slides written by Dr W.F. Clocksin.
Logic programming. Introduction To express program in symbolic logic Also called declarative language Only the specification of desired results are stated.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Introduction to Computer Programming in C
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Artificial Intelligence Modal Logic
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
CPSC 322, Lecture 20Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Computer Science cpsc322, Lecture 20 (Textbook.
CS 331 / CMPE 334 – Intro to AI CS 531 / CMPE AI Course Outline.
Methods of Proof Chapter 7, second half.
CS101- Lecture 11 CS101 Fall 2004 Course Introduction Professor Douglas Moody –Monday – 12:00-1:40 – – –Web Site: websupport1.citytech.cuny.edu.
Symbolic AI Lecture Every Monday 12:30-13:30 Lab Session (two groups) Tuesday 16:30 3P30 Tuesday 17:30 3P30.
OBJECT ORIENTED PROGRAMMING I LECTURE 1 GEORGE KOUTSOGIANNAKIS
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
Symbolic AI weeks of even numbers Lecture Monday 13:00-14:00 (2Q50) Lab Sessions (five groups, all in 2Q52) Monday.
Slides 00 1 Advanced Logics Part 1: Lambda Calculus and Type Theory Lecturer: Lim Yohanes Stefanus Part 2: Modal Logic Lecturer: Gregory Wheeler.
LISP and PROLOG AI Programming Language Submitted To: Dr. Hesham El-Zoka Submitted By: Eng. Ismail Fathalla El-Gayar.
Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2010 Adina Magda Florea
CST 229 Introduction to Grammars Dr. Sherry Yang Room 213 (503)
MATH 224 – Discrete Mathematics
programmation en logique
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
F28PL1 Programming Languages Lecture 16: Prolog 1.
Artificial Intelligence Programming in Prolog Lecture 1: An Introduction 23/09/04.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now Chapter 9, exs 4 and 6. –6 must be in Horn clause form Prolog Handout 2.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
Computing & Information Sciences Kansas State University Wednesday, 20 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 12 of 42 Wednesday, 20 September.
Fortran Fortran – Formula Translation –Developed by John Backus (IBM) in the mid 1950s. –It was a team effort and the design goal was to produce a translation.
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 17 Wednesday, 01 October.
Computing & Information Sciences Kansas State University Monday, 25 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 14 of 42 Monday, 25 September.
Logical and Functional Programming
CSE 425: Syntax I Syntax and Semantics Syntax gives the structure of statements in a language –Allowed ordering, nesting, repetition, omission of symbols.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Logic Programming Dr. Yasser Nada Fall 2010/2011 Lecture 1 1 Logic Programming.
Construction and Analysis of Efficient Algorithms Introduction Autumn 2015, Juris Vīksna.
Albert Gatt LIN3021 Formal Semantics Lecture 3. Aims This lecture is divided into two parts: 1. We make our first attempts at formalising the notion of.
ARTIFICIAL INTELLIGENCE Lecture 2 Propositional Calculus.
The Prolog Language by Piyabut Thavilthicakul
Course Information CSE 2031 Fall Instructor U. T. Nguyen /new-yen/ Office: CSEB Office hours:  Tuesday,
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
Introduction to Artificial Intelligence Heshaam Faili University of Tehran.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Programming Languages 2nd edition Tucker and Noonan
Construction and Analysis of Efficient Algorithms
PROGRAMMING LANGUAGES
Computer Science cpsc322, Lecture 20
Programming Language Design Concepts
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Prolog Programming slides written by
Developing Applications
Programming Languages 2nd edition Tucker and Noonan
Accelerated Introduction to Computer Science
Dr. Yasser Nada Fall 2010/2011 Lecture 1
Computer Science cpsc322, Lecture 20
Presentation transcript:

Declarative Programming Autumn 2014 Introduction

Lecture times Regular lectures on Wednesdays 16:30-18:05, room lectures The lectures at the following dates will be rescheduled (dates/times to be agreed, but likely to some time in November/December): Some other changes are possible (but hopefully, not too many).

Web page(s) Is expected to contain: short summaries of lectures power point presentations (when present) problems for programming assignments/project your grades other relevant information (exam dates, changes in lecture times etc) Course material also available as e-course:

Contact information Juris Vīksna Room 421, Rainis boulevard 29 phone: Consultations: "official" consultation times: Thursdays (???) 16:30-18:00, Rainis bouleverd 29, room 421; by individual arrangements. In "official" times I will be usually (but probably not always) available without an appointment, so just in case I recommend to check in advance.

Programming languages ImperativeFunctionalLogical C++LispProlog PascalML JavaHaskell... Imperative Declarative

Declarative vs imperative languages [Adapted from U.Nilsson]

Declarative vs imperative languages [Adapted from U.Nilsson]

Imperative languages Program is a list of explicit steps of computation list procedure cat(list a, list b) { list t = list u = copylist(a); while (t.tail != nil) t = t.tail; t.tail = b; return u; }

Functional languages Program is a composition of functions cat(a,b) if b = nil then a else cons(head(a), cat(tail(a),b))

Logical languages Program is a list of facts that are known to be true and a query, which has to be proved or disproved cat([], Z, Z). cat([H|T], L, [H|Z]) :- cat(T, L, Z).  u (S(u)   z (R(z)   P(u,z)))  y (S(y) &  w (Q(w)  P(y,w)))  y (Q(y)   R(y)) Can this really be done (at least efficiently)? Depends...

Propositional logic (propositional calculus) Infinite set of variables:A,B,C,D,... Finite set of operators: , , , ,  Finite set of auxiliary symbols:(,) Set of rules that defines syntactically correct formulas, e.g.: (  A  B)  (A  B) Interpretation of formulas: We assign truth values 0 and 1 to each of variables in a formula. The truth value of formula is computed using rules such as:  A = 1  A = 0 A  B = 1  A = 1 and B = 1

Propositional logic (propositional calculus)

Predicate logic (first-order) Infinite set of constants:c 1,c 2,... Infinite set of variables:x 1,x 2,... Infinite set of function symbols:f 1,f 2,... Infinite set of relation symbols:r 1,r 2,... Finite set of operators: , , , , , ,  Finite set of auxiliary symbols:(,),”,”, Set of rules that defines syntactically correct formulas, e.g.: (  x)(r(x)  c)  (  y)q(c,y) (  x)(  y)r(x,y,c) r(x,y,c) “might” mean e.g.: “for given c and for any x there exists y such that x+y=c”

Predicate logic (first-order) How to assign truth values to predicate logic formulas? Again we use notion of interpretation, however now it gets more complicated. interpretation domain D c3c3 c1c1 c2c2 f(c 3 ) = c 2 r(c 2,c 2 ) = 1 or 0 (true or false) Thus, interpretation defines: - domain D - “semantics” of functional and relational symbols. Given interpretation we can assign truth values to formulas!

Predicate logic (first-order)

Motivation  logic programming is quite important and useful concept in computer science  kind of fun!  there are problems for which PROLOG may be a natural choice of programming language

Requirements  4-6 short programming assignments0 – 50% (half of them must be submitted before the exam session, in order to be allowed to proceed, others are optional)  1 programming project (optional)0 – 30%  Exam (open book, optional)–20 – 20% (?)

Academic honesty You are expected to submit only your own work! Sanctions: Receiving a zero on the assignment (in no circumstances a resubmission will be allowed) No admission to the exam and no grade for the course

Textbooks Ivan Bratko PROLOG programming for artificial intelligence Pearson Range Extension Paul 2011 (4 th ed)

Textbooks Leon Sterling, Ehud Shapiro The art of Prolog MIT Press 1994 (2 nd ed)

Textbooks Richard A. O’Keefe The craft of Prolog MIT Press 1990 (reprint 2009)

Textbooks W.F. Clocksin, C.S.Mellish Programming in Prolog Springer Verlag 2003 (4 th /5 th ed) (5 th ed looks like just a reprint of 4 th ed from 2003)

Textbooks This one can be downloaded from the internet: Ulf Nilsson and Jan Maluszynski Logic, Programming and Prolog (2ed) Previously published by John Wiley & Sons Ltd.

Textbooks Also available from the internet: Attila Csenki Applications of Prolog Prolog Techniques

Textbooks L.C.Paulson ML for working programmer Cambridge University Press, 1996

Prolog compilers/interpreters SWI Prologhttp://

Prolog compilers/interpreters SWI Prolog Editor /swiprolog/indexe.html An integrated environment that allows editing and running of Prolog programs + provides some debugging functionality. Http link also from SWI Prolog site.

Prolog compilers/interpreters SICSTUS Prolog

Prolog compilers/interpreters [Adapted from wikipedia.org]

Workplan  PROLOG syntax4 formal (its quite simple...) special keywords and their semantics (also there is not that much...)  Computational model of PROLOG programs1  PROLOG interpreters - how to use them1  Program examples7 PROLOGish (often AI related) general (for training - to try to write thing that are hard in PROLOG)  Functional programming 2

Prolog – short history 1961Resolution method for predicate calculus (John Robinson) 1965ABSYS (Aberdeen System), ABSET (Aberdeen Set Language) (Michael Foster, Ted Ellock) 1971SYSTEMQ (Colmerauer, Kowalski), eventually it become Prolog st FORTRAN compiler for Prolog (David Warren) Was generally considered to be a very promising language up to early 1990s

Prolog is a ‘declarative’ language Clauses are statements about what is true about a problem, instead of instructions how to accomplish the solution. The PROLOG system uses the clauses to work out how to accomplish the solution by searching through the space of possible solutions. Not all problems have pure declarative specifications. Sometimes extralogical statements are needed.

What a program looks like % At the Zoo % elephant(george). elephant(mary). panda(chi_chi). panda(ming_ming). dangerous(X) :- big_teeth(X). dangerous(X) :- venomous(X). guess(X, tiger) :- stripey(X), big_teeth(X), isaCat(X). guess(X, koala) :- arboreal(X), sleepy(X). guess(X, zebra) :- stripey(X), isaHorse(X).

Example: Concatenate lists a and b list procedure cat(list a, list b) { list t = list u = copylist(a); while (t.tail != nil) t = t.tail; t.tail = b; return u; } In an imperative language: In a declarative language In a functional language: cat(a,b) if b = nil then a else cons(head(a),cat(tail(a),b)) cat([], Z, Z). cat([H|T], L, [H|Z]) :- cat(T, L, Z).

Prolog “pseudocodes” “Hand computation” Prolog program “Pseudocode” [Adapted from A.Csenki]