C. Varela1 Programming Languages (CSCI 4430/6969) History, Syntax, Semantics, Essentials, Paradigms Carlos Varela Rennselaer Polytechnic Institute August.

Slides:



Advertisements
Similar presentations
An Introduction to Programming General Concepts. What is a program? A program is an algorithm expressed in a programming language. programming language.
Advertisements

Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
Gerardo Schneider Department of Informatics University of Oslo December 2008.
COP4020 Programming Languages Logic programming and Prolog Prof. Xin Yuan.
A brief history of programming languages
Spring 2010 CS 214 Programming Languages. Details Course homepage: cs.calvin.edu/curriculum/cs/214/ Important dates: February 19: Project language choice.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
Object-Oriented Programming OOP John Gilligan School of Computing DIT Kevin St.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 27: Prolog’s Resolution and Programming Techniques COMP 144 Programming Language.
Overview of Programming Paradigms
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 26: Introduction to Logic Programming with Prolog COMP 144 Programming Language.
C. Varela1 Logic Programming (PLP 11.3) Prolog Imperative Control Flow: Backtracking Cut, Fail, Not Carlos Varela Rennselaer Polytechnic Institute September.
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Chapter 1. Introduction.
Introduction to Programming Languages Where do we start to understand programming languages as a core concept of Computer Science? There are literally.
1 Lecture 15: Introduction to Logic Programming with Prolog (Section 11.3) A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill.
Introduction to Logic Programming with Prolog (Section 11.3)
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
Programming Languages – An introduction. There are 10 types of people in the world −Those who understand binary −Those who don’t.
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.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05.
C. Varela1 Programming Languages (CSCI 4430/6430) History, Syntax, Semantics, Essentials, Paradigms Carlos Varela Rennselaer Polytechnic Institute September.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Logical and Functional Programming
C. Varela1 Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure Carlos Varela Rennselaer Polytechnic Institute November.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Logic Programming: Prolog Lecture 21 – Prolog, Spring CSE3302 Programming Languages, UT-Arlington.
Programming Languages
C. Varela1 Logic Programming (PLP 11, CTM 9.1) Terms, Resolution, Unification, Search, Backtracking (Prolog) Relational Computation Model (Oz) Carlos Varela.
int k = Integer.MAX_VALUE; k++; int k = Integer.MAX_VALUE; k++; What happens when the following code executes? byte b = someFile.readByte(); b = (byte)(b.
Knowledge Based Information System
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 190 Programming Language Paradigms Fall 2014
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
1 Announcements We are almost done grading HW1 HW2 due today Download SWI Prolog! HW3 (Prolog) will be posted today, due on February 29 th Spring 16 CSCI.
Announcements Rainbow grades up HW1, Quiz 1-2 in HW Server Deadline for HW3 (Prolog) is extended to Monday, March 7 th. Submit in HW Server A few notes.
C. Varela1 Logic Programming (PLP 11, CTM 9.3) Prolog Imperative Control Flow: Backtracking, Cut, Fail, Not Lists, Append Carlos Varela Rennselaer Polytechnic.
CS 313 History of Programming Languages
Copyright © 2009 Elsevier Chapter 11 :: Logic Languages And other online sources (see links on schedule page) Michael L. Scott Based on Programming Language.
Programming Language Paradigms ITSK2314 Lecture 3.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
History. Development Driven by Function Functions of a Programming Language –To describe computation for use by computers –To describe computation and.
Language Paradigms CS655.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Programming Language History and Evolution
Chapter 1. Introduction.
CSCE 190 Programming Language Paradigms
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Carlos Varela Rennselaer Polytechnic Institute November 11, 2016
CS 3304 Comparative Languages
Carlos Varela Rennselaer Polytechnic Institute September 1, 2017
An Introduction to Programming
Carlos Varela Rensselaer Polytechnic Institute November 17, 2017
Carlos Varela Rensselaer Polytechnic Institute November 14, 2017
Logic Programming with Prolog: Resolution, Unification, Backtracking
Prolog fundamentals Module 14.2 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Chapter 11 :: Logic Languages
Chapter 11 :: Logic Languages
CSE 341 Programming Languages Autumn 2003
Programming Languages and Paradigms
Carlos Varela Rensselaer Polytechnic Institute November 10, 2017
Chapter 12 :: Logic Languages
Logic Programming Language
Chapter 12 :: Logic Languages
Overview of Programming Paradigms
An Introduction to Programming
Carlos Varela Rennselaer Polytechnic Institute November 15, 2016
Chapter 12 :: Logic Languages
Presentation transcript:

C. Varela1 Programming Languages (CSCI 4430/6969) History, Syntax, Semantics, Essentials, Paradigms Carlos Varela Rennselaer Polytechnic Institute August 27, 2007

C. Varela2 The first programmer ever Ada Augusta, the Countess of Lovelace, the daughter of the poet Lord Byron Circa 1843 Using Babbage’s Analytical Engine

C. Varela3 The first “high-level” (compiled) programming language FORTRAN 1954 Backus at IBM It was called “an automatic coding system”, not a “programming language” Used for numerical computing

C. Varela4 The first functional programming language Lisp 1958 McCarthy at Stanford For LISts Processing---lists represent both code and data Used for symbolic manipulation

C. Varela5 The first object oriented programming language Simula 1962 Dahl and Nygaard at University of Oslo, Norway Used for computer simulations

C. Varela6 The first logic programming language Prolog 1972 Roussel and Colmerauer at Marseilles University, France For “PROgrammation en LOGique”. Used for natural language processing and automated theorem proving

C. Varela7 The first concurrent programming language Concurrent Pascal 1974 Hansen at Caltech Used for operating systems development

C. Varela8 The first scripting language REXX 1982 Cowlishaw at IBM Only one data type: character strings Used for “macro” programming and prototyping

C. Varela9 The first multi-paradigm programming language Oz 1995 Smolka at Saarland University, Germany A logic, functional, imperative, object-oriented, constraint, concurrent, and distributed programming language Used for teaching programming and prototyping

C. Varela10 Other programming languages Algol (Naur 1958) Cobol (Hopper 1959) BASIC (Kennedy and Kurtz 1964) Pascal (Wirth 1970) C (Kernighan and Ritchie 1971) Ada (Whitaker 1979) Smalltalk (Kay 1980) C++ (Stroustrop 1980) Eiffel (Meyer 1985) Java (Gosling 1994) C# (Hejlsberg 2000) PLASMA (Hewitt 1975) Act (Lieberman 1981) ABCL (Yonezawa 1988) Actalk (Briot 1989) Erlang (Armstrong 1990) E (Miller et al 1998) SALSA (Varela and Agha 1999) ML (Milner 1973) Scheme (Sussman and Steele 1975) Haskell (Hughes et al 1987) Python (van Rossum 1985) Perl (Wall 1987) Tcl (Ousterhout 1988) Lua (Ierusalimschy et al 1994) JavaScript (Eich 1995) PHP (Lerdorf 1995) Ruby (Matsumoto 1995) Imperative Object-Oriented Actor-Oriented Functional Scripting

C. Varela11 Logic Programming (PLP 11.3) Horn Clauses Introduction to Prolog: Resolution, Unification

C. Varela12 An Early (1971) “Conversation” USER: Cats kill mice. Tom is a cat who does not like mice who eat cheese. Jerry is a mouse who eats cheese. Max is not a mouse. What does Tom do? COMPUTER: Tom does not like mice who eat cheese. Tom kills mice. USER: Who is a cat? COMPUTER: Tom. USER: What does Jerry eat? COMPUTER: Cheese. USER: Who does not like mice who eat cheese? COMPUTER: Tom. USER: What does Tom eat? COMPUTER: What cats who do not like mice who eat cheese eat.

C. Varela13 Another Conversation USER: Every psychiatrist is a person. Every person he analyzes is sick. Jacques is a psychiatrist in Marseille. Is Jacques a person? Where is Jacques? Is Jacques sick? COMPUTER: Yes. In Marseille. I don’t know.

C. Varela14 Logic programming A program is a collection of axioms, from which theorems can be proven. A goal states the theorem to be proved. A logic programming language implementation attempts to satisfy the goal given the axioms and built-in inference mechanism.

C. Varela15 Horn clauses A standard form for writing axioms, e.g.: father(X,Y)  parent(X,Y), male(X). The Horn clause consists of: –A head or consequent term H, and –A body consisting of terms B i H  B 0, B 1, …, B n The semantics is: « If B 0, B 1, …, B n, then H »

C. Varela16 Terms Constants rpi troy Variables University City Predicates located_at(rpi,troy) pair(a, pair(b,c)) Can be nested.

C. Varela17 Resolution To derive new statements, Robinson’s resolution principle says that if two Horn clauses: H 1  B 11, B 12, …, B 1m H 2  B 21, B 22, …, B 2n are such that H 1 matches B 2i, then we can replace B 2i with B 11, B 12, …, B 1m : H 2  B 21, B 22, …, B 2(i-1), B 11, B 12, …, B 1m, B 2(i+1) …, B 2n For example: C  A,B D  C D  A,B

C. Varela18 Resolution Example father(X,Y) :- parent(X,Y), male(X). ancestor(X,Y) :- father(X,Y). ancestor(X,Y) :- parent(X,Y), male(X). :- is Prolog’s notation (syntax) for .

C. Varela19 Unification During resolution, free variables acquire values through unification with expressions in matching terms. For example: male(carlos). parent(carlos, tatiana). father(X,Y) :- parent(X,Y), male(X). father(carlos, tatiana).

C. Varela20 Unification Process A constant unifies only with itself. Two predicates unify if and only if they have –the same functor, –the same number of arguments, and –the corresponding arguments unify. A variable unifies with anything. –If the other thing has a value, then the variable is instantiated. –If it is an uninstantiated variable, then the two variables are associated.

C. Varela21 Backtracking Forward chaining goes from axioms forward into goals. Backward chaining starts from goals and works backwards to prove them with existing axioms.

C. Varela22 Backtracking example rainy(seattle). rainy(rochester). cold(rochester). snowy(X) :- rainy(X), cold(X).

C. Varela23 Backtracking example rainy(seattle). rainy(rochester). cold(rochester). snowy(X) :- rainy(X), cold(X). snowy(C) snowy(X) AND OR rainy(X) cold(X) rainy(seattle)rainy(rochester) cold(rochester)

C. Varela24 Backtracking example rainy(seattle). rainy(rochester). cold(rochester). snowy(X) :- rainy(X), cold(X). snowy(C) snowy(X) AND OR rainy(X) cold(X) rainy(seattle)rainy(rochester) cold(rochester) _C = _X X = seattle cold(seattle) fails; backtrack.

C. Varela25 Backtracking example rainy(seattle). rainy(rochester). cold(rochester). snowy(X) :- rainy(X), cold(X). snowy(C) snowy(X) AND OR rainy(X) cold(X) rainy(seattle)rainy(rochester) cold(rochester) _C = _X X = seattle cold(seattle) fails; backtrack. X = rochester success

C. Varela26 Exercises 1.Download SWI Prolog and install it in your laptop. 2.Execute the “snowy(City)” example. Use “tracing” to follow backtracking step by step. 3.Create a knowledge base with Prolog facts about your family members using predicates and constants. Create Prolog rules using variables to define the following: brother, sister, uncle, aunt, nephew, niece, grandfather, grandmother, etc. Query your program for family relationships.