Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
First Order Logic Logic is a mathematical attempt to formalize the way we think. First-order predicate calculus was created in an attempt to mechanize.
Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
Chapter 11 :: Logic Languages
Logic Programming Automated Reasoning in practice.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
Automated Reasoning Systems For first order Predicate Logic.
Logic Use mathematical deduction to derive new knowledge.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
CS 330 Programming Languages 12 / 12 / 2006 Instructor: Michael Eckmann.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Comp 205: Comparative Programming Languages Declarative Programming Languages Logic Programming Horn-Clause Logic Prolog Lecture notes, exercises, etc.,
Programming Languages Third Edition
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
Describing Syntax and Semantics
(9.1) COEN Logic Programming  Logic programming and predicate calculus  Prolog statements  Facts and rules  Matching  Subgoals and backtracking.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists1 Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim.
F28PL1 Programming Languages Lecture 16: Prolog 1.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
CHAPTER 15 & 16 Functional & Logic Programming Languages.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
The AI War LISP and Prolog Basic Concepts of Logic Programming
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
CS 363 Comparative Programming Languages Logic Programming Languages.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Systems For first order Predicate Logic.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Programming Languages Third Edition Chapter 4 Logic Programming.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
ISBN Chapter 16 Logic Programming Languages.
Dr. Muhammed Al-Mulhem ICS An Introduction to Prolog.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
1-1 An Introduction to Logical Programming Sept
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
For Friday No reading Prolog Handout 2. Homework.
Prolog 3 Tests and Backtracking 1. Arithmetic Operators Operators for arithmetic and value comparisons are built-in to Prolog = always accessible / don’t.
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.
1-1 An Introduction to Prolog Sept Prolog statements Like other programming languages, Prolog consists of collection of statements. Prolog.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (n-n-n-notes) Summer 2003 Dr. Carter Tiernan.
Logic Programming Lecture 2: Unification and proof search.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Tests, Backtracking, and Recursion
Logic Programming Languages
Horn Clauses and Unification
Logic Programming Language
Presentation transcript:

Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan

Ch. 13 Ch. 132 jcmt CSE 3302 Programming Languages Logic Programming Nonprocedural programming Higher-level language allows one to express the same program with less detail Language does more automatically Programmer focuses more on what to do not on how to do it

Ch. 13 Ch. 133 jcmt CSE 3302 Programming Languages Automatic deduction Automatic theorem proving –The development of programs that can construct formal proofs of propositions stated in symbolic language –Side effect of proof is construction of a result which demonstrates the proof Programs expressed in the form of propositions that assert the existence of a desired result

Ch. 13 Ch. 134 jcmt CSE 3302 Programming Languages Prolog Programs are structured like theorems –Clauses that define the problem domain –Facts (database of relationships among atomic individuals) –Goals Is a fact provable? Is there an individual satisfying the goal? Is there a solution satisfying the goal?

Ch. 13 Ch. 135 jcmt CSE 3302 Programming Languages Prolog Clauses Clauses define relationships or “predicates” Facts or hypotheses parent (charles, harry). Goals :- grandparent (elizabeth, X). Conditions or rules grandparent(Y, Z) :- parent (Y,W), parent(W,Z).

Ch. 13 Ch. 136 jcmt CSE 3302 Programming Languages Predicates :- Predicates –Relationship applied to terms – Relationships Properties of Relations among – Terms Atoms Variables Compound terms Horn clause form

Ch. 13 Ch. 137 jcmt CSE 3302 Programming Languages Goals Executing a goal –Match clauses in predicate by finding an assignment of values to the variables that makes the goal identical to the head of one of the clauses (unification) –Variables are bound (instantiated) to create subgoal –Recursive application and pattern matching

Ch. 13 Ch. 138 jcmt CSE 3302 Programming Languages Compound terms Compound term allows us to describe individuals without naming them Functor with atoms or variables d(X, plus(U,V), plus(DU,DV)) or d(X, U + V, DU + DV) Similar to LISP list structure Acts somewhat like a function but is not a function call

Ch. 13 Ch. 139 jcmt CSE 3302 Programming Languages Data structures No constructors Data structures are implicitly defined by their properties Few primitives Compound terms can provide logical description of structure –Some Prologs allow infix notation for functors

Ch. 13 Ch jcmt CSE 3302 Programming Languages Complex structures Compound terms represent themselves –Symbolic notations can be defined directly –Good for mathematical relationships Predicates can define structures –Predicates can replace compound terms –Expressions matched to clauses must exist within the Prolog “closed world” –Good for object-oriented relationships

Ch. 13 Ch jcmt CSE 3302 Programming Languages More data structures Abstract data types - so abstract they’re only described Infinite terms - “occurs check” Representation of ‘infinite’ list is finite –Circular structure

Ch. 13 Ch jcmt CSE 3302 Programming Languages Control Structures Separation of logic and control –Independent analysis Order of clauses has no effect on meaning or logic Control affects generation and unification of subgoals –Efficiency is an issue but not meaning

Ch. 13 Ch jcmt CSE 3302 Programming Languages Subgoal Generation Top-down –Start from goal; try to reach hypotheses –Recursive approach Bottom-up –Start with hypotheses; try to reach goal –Iterative approach

Ch. 13 Ch jcmt CSE 3302 Programming Languages Backtracking Multiple matching clauses may be available If a failure occurs after a choice point, execution backtracks to the last choice point Another match is made and execution continues. Implementation of efficient backtracking is crucial in logic programming

Ch. 13 Ch jcmt CSE 3302 Programming Languages Input / Output Parameters Goals attempt to satisfy subgoals with whatever value is unified Parameters are neither inherently input nor output. Which ever is supplied is used as input. When no parameter values are given, the systems attempts to search for any solution that satisfies the pattern

Ch. 13 Ch jcmt CSE 3302 Programming Languages Searching in Prolog Depth-first search is specified –Not pure logic programming Attempts to satisfy goals in the order written Will try matching clauses in the order in which they were entered into the DB

Ch. 13 Ch jcmt CSE 3302 Programming Languages Prolog vs. Logic Programming Interpretation of arithmetic jumps beyond the bounds of strict logic programming unless handled as succ() Efficiency requires the use underlying hardware support ‘is’ gives an assignment Binding forces ordering

Ch. 13 Ch jcmt CSE 3302 Programming Languages Search rationale Breadth-first –searches paths in parallel –needs exponentially more space than depth-first Depth-first –Can get caught in infinitely deep search –Programmer is required to order clauses to prevent endless search

Ch. 13 Ch jcmt CSE 3302 Programming Languages Nonmonotonic reasoning Updateable database –Assert –Retract Does not match logic Does match world state changes over time

Ch. 13 Ch jcmt CSE 3302 Programming Languages Cuts “You have found all the solutions there are; do not bother trying to find any others” Predicate that always succeeds, but past which you can never backtrack Used with repeat to provide looping

Ch. 13 Ch jcmt CSE 3302 Programming Languages Higher-order rules Parameters must be terms not predicates Logic programming is generally restricted to first-order logic Resolution algorithm is complete only for first-order logic

Ch. 13 Ch jcmt CSE 3302 Programming Languages Negation Unsatisfiability - cannot be proved true –Absence of data –Closed world assumption Conclusions can be drawn about relationships that DO hold NO conclusions can be made about relationships that do NOT hold not( -- ) predicate succeeds if -- fails

Ch. 13 Ch jcmt CSE 3302 Programming Languages Equivalence Term equality Other types of equivalence cannot be defined –In terms of logical properties Term inequality requires complete binding for correct interpretation