Introduction to Logic Programming

Similar documents
Introduction & Review

SC/MATH Boolean Formulae. Ref: G. Tourlakis, Mathematical Logic, John Wiley & Sons, York University

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

Declarative programming. Logic programming is a declarative style of programming.

Introduction to LISP. York University Department of Computer Science and Engineering. York University- CSE V.

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Introduction to Prolog

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Lisp History. Lisp and Prolog Background. Lisp Use. Lisp Availability

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

Automated Reasoning. Natural Deduction in First-Order Logic

Logic and its Applications

Knowledge Representation and Reasoning Logics for Artificial Intelligence

What is a Logic Program. Introduction to Logic Programming. Introductory Examples. Introductory Examples. Foundations, First-Order Language

Introduction to Logic Programming

Part I Logic programming paradigm

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

Towards a Logical Reconstruction of Relational Database Theory

Advanced Logic and Functional Programming

Com S 541. Programming Languages I

Introductory logic and sets for Computer scientists

Solutions to In-Class Problems Week 1, Fri

COMP4418 Knowledge Representation and Reasoning

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

The Formal Syntax and Semantics of Web-PDDL

Software Paradigms (Lesson 6) Logic Programming

Programming Languages Third Edition

Notes for Chapter 12 Logic Programming. The AI War Basic Concepts of Logic Programming Prolog Review questions

Which of the following is not true of FORTRAN?

Propositional Logic:

CSE 20 DISCRETE MATH. Fall

Fundamentals of Software Engineering

CSC 501 Semantics of Programming Languages

Knowledge Representation and Reasoning Logics for Artificial Intelligence

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

MIDTERM EXAM (Solutions)

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Lisp and Prolog Background

PROPOSITIONAL LOGIC (2)

CSE 20 DISCRETE MATH. Winter

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Diagnosis through constrain propagation and dependency recording. 2 ATMS for dependency recording

Module 8. Other representation formalisms. Version 2 CSE IIT, Kharagpur

Constraint Solving. Systems and Internet Infrastructure Security

Semantic Characterizations of XPath

Relational db: the origins. Relational Calculus (aka FO)

The discussion of Chapter 1 will be split into two sessions; the first will cover 1.1 and 1.2; the second will cover 1.3, 1.4, and 1.5.

CITS2211 Discrete Structures Logic

Predicate Calculus. Problems? Syntax. Atomic Sentences. Complex Sentences. Truth

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

LING 130: Quantified Noun Phrases

Lecture 5: Predicate Calculus. ffl Predicate Logic ffl The Language ffl Semantics: Structures

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

CSE Penn State University - Spring 2006 Professor John Hannan Lecture 7: Problem Solving with Logic - February 21&23, 2006

LOGIC AND DISCRETE MATHEMATICS

Part (04) Introduction to Programming

Knowledge-based Systems for Industrial Applications - Propositional Logic

logic with quantifiers (informally)

Prolog. Intro to Logic Programming

Propositional logic (Ch. 7)

Symbolic Methods. The finite-state case. Martin Fränzle. Carl von Ossietzky Universität FK II, Dpt. Informatik Abt.

A Small Interpreted Language

Introduction to Prolog

CSE Discrete Structures

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

quanüfied Statements; valid well-formed formulas; comparison of propositional and predicate wffs. Exercises

== is a decent equivalence

Semantics and Pragmatics of NLP

Computer Science Technical Report

Chapter 16. Logic Programming Languages

Formal Methods in Software Engineering 1

GSN Metamodel. In the following subsections we describe the model elements. All references are to sections within the GSN Community Standard.

Logic Programming and Resolution Lecture notes for INF3170/4171

Deductive Methods, Bounded Model Checking

Resolution (14A) Young W. Lim 6/14/14

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy

CS 540: Introduction to Artificial Intelligence

What is Prolog? - 1. A Prolog Tutorial. What is Prolog? - 2. Prolog Programming. » Declaring some facts about objects and their relationships

What is Prolog? - 1. A Prolog Tutorial. Prolog Programming. What is Prolog? - 2. » Declaring some facts about objects and their relationships

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

Conceptual modeling of entities and relationships using Alloy

Functions, Conditionals & Predicates

Definite-clause grammars: PSGs in Prolog (in principle, string rewrite described as a logical formula).

Propositional Logic. Part I

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

for all x, the assertion P(x) is false. there exists x, for which the assertion P(x) is true.

15-819M: Data, Code, Decisions

Lecture 17 of 41. Clausal (Conjunctive Normal) Form and Resolution Techniques

Example Scheme Function: equal

Functional Programming. Big Picture. Design of Programming Languages

SAT Solver. CS 680 Formal Methods Jeremy Johnson

Lecture Notes on Real-world SMT

Th(N, +) is decidable

Propositional Calculus. Math Foundations of Computer Science

CPS 506 Comparative Programming Languages. Programming Language Paradigm

Transcription:

Introduction to Logic Programming York University CSE 3401 Vida Movahedi York University CSE 3401 V. Movahedi 1

Overview Programming Language Paradigms Logic Programming Functional Programming Brief review of Logic Propositional logic Predicate logic York University CSE 3401 V. Movahedi 2

Why Logic Programming? View of the world imposed by a language A programming language tends to impose a certain view of the world on its users. Semantics of the programming languages To program with the constructs of a language requires thinking in terms of the semantics of those constructs York University CSE 3401 V. Movahedi 3

Programming Language Paradigms (1) Imperative programming Semantics: state based Computation viewed as state transition process Ct Categories: Procedural Object Oriented Other non structured For example: C, Pascal, Turing are in the Procedural category, steps of computation describe state changing process York University CSE 3401 V. Movahedi 4

Programming Language Paradigms (2) Declarative Programming g Focus is on logic (WHAT) rather than control (HOW) Categories: Logic Programming: Computation is a reasoning process, e.g. Prolog Functional Programming: Computation is the evaluation of a function, e.g. Lisp, Scheme,... Constrained Languages: Computation is viewed as constraint satisfaction problem, e.g. Prolog (R) Level of language Low level has a world view close to that of the computer High level has a world view closer to that of the specification (describing the problem to be solved, or the structure of the system to be presented) York University CSE 3401 V. Movahedi 5

Logic Programming Basedon first order predicate logic A programmer describes with formulas of predicate logic A mechanical problem solver makes inferences from these formulas York University CSE 3401 V. Movahedi 6

Propositional Logic (review) Alphabet Variables, e.g. p, q, r,..., p 1,..., p,... Constants: T and F Connectives: {,,,, } or {~, &, #, >, < > in some books} Brackets: ( and ) Well formed formula (wff) All variables and constants are wffs. If A and B are wffs, then the following are also wffs. ( A), ( A B), ( A B), ( A B), ( A B) Priority of connectives, and rules for removing brackets York University CSE 3401 V. Movahedi 7

Propositional Logic (cont.) Semantics and truth tables true (1) and false (0) state Tautologies: true inallpossible states Satisfiable A formula A is satisfiable iff there is at least one state v where v(a)=true A set of formulae X is satisfiable (or consistent) iff there is at least one state v where for every formula A in X, v(a)=true. Contradiction: (unsatisfiable, inconsistent) If A is a tautology, A is a contradiction York University CSE 3401 V. Movahedi 8

Predicate Logic (review) Alphabet Alphabet of propositional logic Object variables, e.g. x, y, z,..., x 1,..., x,... Object constants, t e.g. a, b, c,... Object equality symbol = Quantifier symbols (and ) and some functions & predicates Term An object variable ibl or constant, t e.g. x, a A function f of n arguments, where each argument is a term, e.g. f(t 1, t 2,...t n ) t 1 t n York University CSE 3401 V. Movahedi 9. f a term (in object domain)

Predicate Logic (cont.) Atomic formula A Boolean variable or constant The string t = s, where t and s are terms A predicate ø of n arguments where each argument is a term, e.g. ø(t 1, t 2,...t n ) Well formed formula t 1 t n. ø a formula (true or false) Any atomic formula If A and B are wffs, then the following are also wffs. ( A ), ( A B ), ( A B ), ( A B ), ( A B ), (( x)a), (( x)a) York University CSE 3401 V. Movahedi 10

Examples Numbers Object constants: 1, 2, 3,... Functions: +,, *, /,... Predicates: >, <,... Examples of wffs: > ( x, y) > ( + ( x,1), y) Or the familiar notation: x > y x + 1 > y Another example: x! = z ( x + 1)! = ( x + 1) * z Sets Object constants: {1}, {2,3},... Functions: U, I,... Predicates:,,... A wff: ( x I y ) ( x U y York University CSE 3401 V. Movahedi 11 )

More Examples Our world Object variables: X, Y,... upper case in PROLOG Constants t such as: john, mary, book, fish, flowers,... Note lower case in PROLOG Functions: distance(point1, X), wife(john) Predicates: owns(book, john), likes(mary, flowers),... true and false in PROLOG Relative to PROLOG s knowledge of the world False whenever it cannot find it in its database of facts (and rules) York University CSE 3401 V. Movahedi 12