{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

324-lecture2

# 324-lecture2 - Principles Principles of Programming...

This preview shows pages 1–8. Sign up to view the full content.

Principles of Programming Languages Lecture 2 Wael Aboulsaadat [email protected] http://portal.utoronto.ca/

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Logic Programming

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Logic Programming (LP) Evolution: Problem barb2right Algorithm barb2right Assembly Code barb2right Machine Code |----------- Assembler ------------------| |---- Imperative/functional Compiler/Interpreter --| |------------------ Logic Language Compiler/Interpreter ---------| E.g.: Find X and Y such that 3 X + 2 Y = 1 and X – Y = 4 Retrieve the telephone number of the person whose name is Tom Smith The value of X equals the value of Y + 3 Why LP? We can understand the meaning without knowing the “state” of the program A lot easier to say what , but not how . Direct manipulation of symbolic structures gives us it’s power. Popular LP languages: Prolog, SQL, Datalog
LP: introduction – cont’d cont’d LP Characteristics: Not based on state modifications Not procedural in nature Does not have control flow ( as we are used to thinking of it ) So, what does it have? A program in a logic programming language consists of a set of declarations related together using predicate calculus . An algorithm in a LP language = logic + control Logic: programmer provides the “logic” which is what the program does. Control: language run-time system provides the control (!)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LP: LP: Library Software Case Study Library Software Case Study Problem Statement: The Eng & Comp Sci library is part of the University of Toronto libraries. You were contacted by the library to develop a software for managing book loans. The library has 15,000 titles serving 40,000 students. An undergraduate student is allowed to borrow a book for up to 2 weeks and can borrow up to 5 books at a time. A graduate student is allowed to borrow a book for up to 4 weeks and can borrow up to 10 books. The library has a staff of 4 employees (librarians). An employee would be interested to know if a book is borrowed or in the library premise, if a book is a borrowed, how is borrowing it and when will it return.
LP: LP: Library Software Case Study Library Software Case Study

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}