CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.

Slides:



Advertisements
Similar presentations
Some Prolog Prolog is a logic programming language
Advertisements

Biointelligence Lab School of Computer Sci. & Eng.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
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 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
CSE 425: Semantics II Implementing Scopes A symbol table is in essence a dictionary –I.e., every name appears in it, with the info known about it –Usually.
Chapter 12 - Logic Programming
Comp 205: Comparative Programming Languages Declarative Programming Languages Logic Programming Horn-Clause Logic Prolog Lecture notes, exercises, etc.,
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
LING 364: Introduction to Formal Semantics Lecture 3 January 19th.
1 CILOG User Manual Bayesian Networks Seminar Sep 7th, 2006.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Formal Models of Computation Part II The Logic Model
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
CSE 425: Concurrency III Monitors A monitor is a higher level construct for synchronizing multiple threads’ access to a common code segment –Can implement.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists1 Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
Computing & Information Sciences Kansas State University Wednesday, 20 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 12 of 42 Wednesday, 20 September.
CSE 425: Target Machine Architecture Target Machine Details Many architectures can be similar in overall structure –E.g., Von Neumann with CISC instruction.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
CSE 425: Syntax II Context Free Grammars and BNF In context free grammars (CFGs), structures are independent of the other structures surrounding them Backus-Naur.
Programming Languages. A Logic Programming Language: Prolog This lesson describes the basic structures and functions of the logic programming language:
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Computing & Information Sciences Kansas State University Lecture 14 of 42 CIS 530 / 730 Artificial Intelligence Lecture 14 of 42 William H. Hsu Department.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Computing & Information Sciences Kansas State University Monday, 25 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 14 of 42 Monday, 25 September.
CSE 425: Concurrency II Semaphores and Mutexes Can avoid bad inter-leavings by acquiring locks –Guard access to a shared resource to take turns using it.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
CS 337 Programming Languages Logic Programming I (Logic, Intro to Prolog)
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Propositional Logic Predicate Logic
Programming Languages Third Edition Chapter 4 Logic Programming.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Logic Programming: Prolog Lecture 21 – Prolog, Spring CSE3302 Programming Languages, UT-Arlington.
CSE 425: Syntax I Syntax and Semantics Syntax gives the structure of statements in a language –Allowed ordering, nesting, repetition, omission of symbols.
Of 38 lecture 6: rdf – axiomatic semantics and query.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
CSE 425: Control Abstraction II Exception Handling Previous discussion focuses on normal control flow –Sometimes program reaches a point where it cannot.
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
Knowledge Based Information System
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Computing & Information Sciences Kansas State University Wednesday, 13 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 10 of 42 Wednesday, 13 September.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Names and Attributes Names are a key programming language feature
Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may.
Iteration Implemented through loop constructs (e.g., in C++)
Parallelism and Concurrency
Horn Clauses and Unification
Delayed Evaluation Special forms in Scheme (e.g., if and cond) do not use applicative order evaluation Only one of two or more expressions is actually.
Horn Clauses and Unification
Chapter 2: Prolog (Introduction and Basic Concepts)
Representations & Reasoning Systems (RRS) (2.2)
PROLOG.
Presentation transcript:

CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic semantics Logic also can be the subject of computation –E.g., automatic deduction systems, theorem-provers Can handle computation and proof interchangeably –E.g., for restricted forms of logic (Horn Clauses  FOL) Programming languages then can help automate this –E.g., logic programming in Prolog Mechanisms readily implemented in a functional style –E.g., in Scheme or other functional programming languages

CSE 425: Logic Programming I Logic Programs Logic programming languages (and programming frameworks in other languages like Scheme or C++) –Provide a means for encoding well formed statements –Provide algorithms for implementing inference rules Sometimes called “deductive databases” –Logic programming systems as logic + control where the logic is specified and the control is automated –To be feasible, however, some restrictions are needed Widely applicable beyond theorem proving –E.g., programming robots to adapt to situational factors

CSE 425: Logic Programming I Intro to Prolog The most widely used logic programming language –Though lots of logic programming is done in other languages Syntax is similar to first-order-logic (FOL) syntax –E.g., ancestor(x,y)^ancestor(y,z) → ancestor(x,z) in FOL is ancestor(X,Z) :- ancestor(X,Y), ancestor(Y,Z) in Prolog –Note: variables are capitalized (or begin with an underscore) –Note: comma indicates conjunction (and) –Also, Prolog uses =< instead of <= for less-than-or equal Lists are delimited by square brackets in Prolog –E.g., [alice, bob, X] Can do head|tail matching (as in ML, Haskell) –E.g., [H|T] = [alice, bob, X] gives [alice] and [bob, X]

CSE 425: Logic Programming I Prolog Interpreter Environment Maintains a database of statements and variables –E.g., loaded from a file, and/or entered by the user User can enter a predicate as a query –E.g., ancestor(bob,alice) –Interpreter matches query to statements in its database –If query is fully bound, will produce a yes or no answer –If query has a variable, will find a satisfactory binding User also can ask for the result of an expression –E.g., X is 3 + 5, write(X) Unification in Prolog –A constant only unifies with itself (exact match is required), while a variable may unify via renaming and/or binding –Predicates unify if same signature, and the arguments unify

CSE 425: Logic Programming I Today’s Studio Exercises We’ll code up initial ideas from Scott Chapter 11 –Looking at basic parsing and evaluation mechanisms for propositional and predicate logic, and proceeding from there Today’s exercises are again in C++ –Please take advantage of the text books and the on-line pages that are linked on the course web site –As always, please ask for help as needed When done, your answers to the course account, with subject line “Logic Programming Studio I”