Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.

Slides:



Advertisements
Similar presentations
First-Order Logic: Better choice for Wumpus World Propositional logic represents facts First-order logic gives us Objects Relations: how objects relate.
Advertisements

Chapter 11 :: Logic Languages
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
ISBN Chapter 16 Logic Programming Languages.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
CPSC 322 Introduction to Artificial Intelligence September 15, 2004.
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
CSE 452: Programming Languages
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
CSE 452: Programming Languages
Predicate Calculus.
FIRST ORDER LOGIC Levent Tolga EREN.
Predicates and Quantifiers
Logic Programming Tasanawan Soonklang. Programming paradigms Imperative Object-oriented Functional Logic Procedural programming Non-procedural programming.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
CPS 506 Comparative Programming Languages
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
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.
1 COSC3306: Programming Paradigms Lecture 8: Declarative Programming Specifications Haibin Zhu, Ph.D. Computer Science Nipissing University (C) 2003.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
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.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
Programming Languages Tucker and Noonan – 2e Chapter 15 – Part 1 Logic Programming “Q: How many legs does a dog have if you call its tail a leg? A: Four.
By: Cory Canter CSC 415 Programming Languages. History  Created by Alain Colmerauer, Phillipe Roussel and Robert Kowalski in 1971  Started as a natural.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 17, 2012.
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.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
For Monday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
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.
Programming Languages Third Edition Chapter 4 Logic Programming.
CS 330 Programming Languages 11 / 25 / 2008 Instructor: Michael Eckmann.
Logic Programming (LP) expresses code using of a restricted form of symbolic logic. LP programs are declarative, rather than algorithmic. An LP program.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
ISBN Chapter 16 Logic Programming Languages.
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
Dr. Muhammed Al-Mulhem ICS An Introduction to Prolog.
Artificial Intelligence CS370D
1-1 An Introduction to Logical Programming Sept
For Friday No reading Prolog Handout 2. Homework.
For Wednesday No reading Prolog handout 2 Chapter 9, exercise 4.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
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:... :-....
Logic Programming Languages
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Prolog a declarative language
Logic Programming Languages
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Logic Programming Languages
Logic Programming Languages
Prolog a declarative language
Prolog a declarative language
Prolog a declarative language
CPSC 322 Introduction to Artificial Intelligence
Logic Programming Language
Predicate Logic: Syntax.
Predicate Logic.
Chapter 2: Prolog (Introduction and Basic Concepts)
PROLOG.
Presentation transcript:

Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.

Von Neumann Architecture

Imperative Languages Based directly on the von Neumann architecture – Variables have memory locations – Program flow of control is: sequential condition-based repeatable (e.g. loops) based on functions based on objects

Imperative Languages Based directly on the von Neumann architecture – Efficiency is the primary concern – Management of variables and data structures is a constant concern – Causes program complexity and therefore bugs

Logic Programming – Prolog Based on formal logic – Prolog is a goal-driven logic programming language – Prolog is a declarative language No flow of control....? – Apply known rules to facts to infer answers to queries Think of Prolog as an inference engine

Propositions A proposition is a logical statement that may or may not be true male('George'). female('Mary'). smart('Mary'). tall('George'). smart('George').

Propositions A proposition describes objects and their relationships – e.g. Mary is a parent of George – e.g. George is a child of Mary parent('Mary', 'George'). child('George', 'Mary').

Propositions A proposition is stated in one of two ways: – Fact : proposition assumed to be true – Query : truth of proposition is to be determined Facts are often organized into a knowledge base – Knowledge bases are utilized to answer queries – New knowledge is inferred via an inference engine

Symbolic Logic We utilize Symbolic logic to: – Express propositions – Express relationships between propositions – Describe how new propositions can be inferred from other propositions Particular form of symbolic logic used for logic programming is called first-order predicate calculus – Forms the basis for logic programming languages

Logical Operators NameSymbolExampleMeaning negation  a not a conjunction  a  b a and b disjunction  a  b a or b equivalence  a  b a is equivalent to b implication  a  b a  b a implies b b implies a

Quantifiers  X.(woman(X)  human(X))  Y.(mother('Mary', Y)  male(Y))  Z.(smarter(Z, 'Dr.G')) NameExampleMeaning universal  X.P For all X, P is true existential  X.P There exists a value of X such that P is true e.g.

Simplifying the Predicate Calculus To simplify a Prolog implementation, standardize propositions using the following clausal form : B 1  B 2  …  B n  A 1  A 2  …  A m The A terms represent the antecedent The B terms represent the consequent If all A s are true, then at least one B is true All propositions can be expressed using this clausal form

Simplifying the Predicate Calculus Simplify further using a Horn clause – Headless Horn clause : has no consequent parent('Mary', 'George'). child('George', 'Mary'). state facts

Simplifying the Predicate Calculus Simplify further using a Horn clause – Headed Horn clause : has a single proposition as consequent mother(X, Y)  parent(X, Y)  female(X) mother(X, Y) :- parent(X, Y), female(X). state inference rules

Additional Prolog Syntax In Prolog, the, operator denotes conjunction ( AND ) The ; operator denotes disjunction ( OR ) mother(X,Y) :- parent(X,Y), female(X). sibling(X,Y) :- brother(X,Y); sister(X,Y).

Additional Prolog Syntax Operators in Prolog – Equality is denoted using == operator – Inequality is denoted using \= operator same(X,Y) :- X == Y. mother(X,Y) :- parent(X,Y), female(X), X \= Y.

Additional Prolog Syntax Parentheses can be used to group logic together X is a sibling of Y if – X is a brother of Y or X is a sister of Y and – X is not the same entity as Y sibling(X,Y) :- (brother(X,Y); sister(X,Y)), X \= Y.

Prolog Family Tree Example Given only male(), female(), and parent(), write Prolog inference rules for the following: – mother() – father() – grandparent() – uncle() – aunt() – brother() – sister() assume that parent(X,Y) is read “ X is a parent of Y ” – cousin() – descendant()

Using SWI-Prolog SWI-Prolog is a free Prolog environment: Interactive Prolog interface

Handling Multiple Subgoals Prolog implementations use depth-first search ( dfs ) approach to finding a goal consisting of multiple subgoals – Backtracking as necessary.... Another approach is to use a breadth-first search ( bfs ), but dfs is usually preferred – to consume fewer resources—i.e. memory female(X), parent(X, 'Bob').

Atoms and Variables Atoms consist of symbols – Start with a lowercase letter Variables also consist of symbols – Start with an uppercase letter – An anonymous variable is the underscore character ( _ ) Use single quotes to create an atom that starts with a capital letter b dave next_solution X Y List1 P2 'Dave' 'Apple' 'Next'

Numbers and Arithmetic Numbers in Prolog include integers and reals – Prolog is not typically used for numeric computation – Predefined operators: – Prolog supports arithmetic evaluation via the is operator = + - * / mod X is X = order matters! distance(X,Y) :- speed_mph(X,Speed), time_minutes(X,Time), Y is Speed * Time / 60.

Using Arithmetic Expressions speed_mph(ford,100). speed_mph(chevy,105). speed_mph(dodge,95). speed_mph(volvo,80). time_minutes(ford,20). time_minutes(chevy,21). time_minutes(dodge,24). time_minutes(volvo,24). distance(X,Y) :- speed_mph(X,Speed), time_minutes(X,Time), Y is Speed * Time / 60. distance(ford,D)D = 2000distance(volvo,D)D = 1920

List Processing in Prolog Prolog supports list structures by using square brackets and commas: Prolog also supports list dismantling : [apple, prune, orange, grape] [ Head_of_List | Rest_of_List ] “dismantles” a list