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.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Artificial Intelligence: Natural Language and Prolog
Predicate Logic Colin Campbell. A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical.
Logic Programming Two possible work modes: 1.At the lab: Use SICstus Prolog. To load a prolog file (*.pl or *.pro extension) to the interpreter, use: ?-
SLD-resolution Introduction Most general unifiers SLD-resolution
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Logic Use mathematical deduction to derive new knowledge.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
Knowledge Representation Methods
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
TR1413: Discrete Mathematics For Computer Science Lecture 3: Formal approach to propositional logic.
Let remember from the previous lesson what is Knowledge representation
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
(9.1) COEN Logic Programming  Logic programming and predicate calculus  Prolog statements  Facts and rules  Matching  Subgoals and backtracking.
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
DEDUCTIVE DATABASE.
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.
Chapter 3: Methods of Inference
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
1st-order Predicate Logic (FOL)
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.
1 Lecture 6 Logic Programming introduction to Prolog, facts, rules Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
1 Relational Algebra and Calculas Chapter 4, Part A.
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.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
Bertram Ludäscher Department of Computer Science & Engineering University of California, San Diego CSE-291: Ontologies in Data Integration.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
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 Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
CS6133 Software Specification and Verification
CSE Winter 2008 Introduction to Program Verification January 15 tautology checking.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
ISBN Chapter 16 Logic Programming Languages.
Semantics of Predicate Calculus For the propositional calculus, an interpretation was simply an assignment of truth values to the proposition letters of.
Knowledge Based Information System
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Introduction to Logic for Artificial Intelligence Lecture 2
Prolog a declarative language
Predicate logic CSC 333.
Logic Programming Languages
Logics for Data and Knowledge Representation
Prolog a declarative language
Prolog a declarative language
Prolog a declarative language
1st-order Predicate Logic (FOL)
Logic Programming Language
Logical Entailment Computational Logic Lecture 3
CSNB234 ARTIFICIAL INTELLIGENCE
Relational Calculus Chapter 4, Part B 7/1/2019.
1st-order Predicate Logic (FOL)
Presentation transcript:

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 reason.

First Order Logical Representations All zombies eat brains. This assumption can be represented in propositional logic by the propositional variable p. In first order logic, the expression can be broken down X (zombie(X) eatsbrains(X)) X (zombie(X) eats(X, brains)) X Y (zombie(X) eats(X, Y) ^ brains(Y)) Some people with no heartbeats are zombies. X (person(X) ^ zombie(X) ^ ¬ heartbeat(X))

Natural Deductive Rules Natural deductive rules are logical rules accepted as being intuitively true. Universal Instantiation: If a variable is assigned a value, it will always have that value. If X = joe, X (zombie(X) eatsbrains(X)) is the same as (zombie(joe) eatsbrains(joe)) Modus Ponens: For some pair of expressions p and q, p ^ (p q) q. If zombie(X), (zombie(X) eatsbrains(X)) becomes (eatsbrains(X))

Truth Tables Truth tables can be constructed from first order logic by transforming expressions into atomic formulas (something with value true or false). Atomic formulas can be constructed from first order logic by either quantifying a formula or mapping it to a value (analogous to valuation). Interpretations are analogous to truth tables.

Truth Tables zombie(joe) zombie(X) eatsbrains(joe) eatsbrains(X)... 0?0?1?0?0?0?1?0? zombie(joe) zombie(fred) eatsbrains(joe) eatsbrains(fred) By mapping (valuation) of X to fred

Brief Intro: Herbrand Base The Herbrand base is the set of ground atomic formulas. In the previous example, this is the set {zombie(joe), zombie(fred), eatsbrains(joe), eatsbrains(fred)}. A model is satisfiable if and only if it has a Herbrand Interpretation (a valid truth assignment given its Herbrand base).

Function Symbols Function symbols map an individual in the domain to another in the domain. Everyone loves their mother. In the expression X loves(X, mother(X)), mother(X) maps X to the element in the domain. Peano's Axioms for Arithmetic In the expression X (number(X) number(S(X)), the occurance of number in number(X) is a function symbol. In the second occurrence, number is a predicate and S(X) is a function symbol.

Relational Databases Assume there is a relational database with a patient table, visit table, and a prescription table. The patient table has fields ID, Date of Birth, and Gender. The visit table has fields ID, Visit Date, and Diagnosis Code. The prescription table has fields ID, Date, and Drug.

Relational Databases Patient Visit Prescription

Relational Databases In a relational database, the table can be represented by an atomic formula of a predicate objects composed of constants and/or function symbols. One such formula exists for each patient. Patient table: patient(id, date of birth, gender) Visit table: visit(id, date, diagnosis code) Prescription table: prescription(id, date, drug)

Relational Databases Any query can be represented as a formula. To find all male patients with diagnosis code 111, use the query formula P (interest(P)patient(P, B, male) ^ visit(P, D, 111) The query result can define a new table containing the desired data. Extensional: Write out entries in a table. Intensional: Write out tables via formula

First Order Logical Inference-Datalog Datalog is a syntactic variation on relational database queries. It forms an intensional representation to the query equivalent to those formed by relational algebra. All quanitifiers are assumed universal and out front of the formula. All formulas are atomic or implications. No function symbols are used. (interest(P)patient(P, B, male), visit(P, D, 111)

Queries in Datalog Datalog queries can be called with a goal. male-flu(P, D)(patient(P, B, male), visit(P, D, 111) Goals can be satisfied by finding all bindings on the goal variables and using pattern matching. The process of matching all atomic formulas by binding the variables to force matching is known as Unification.

Unification is most frequently executed by running a backtracking search for proofs satisfying all subgoals. Running unification on the male-flu example, if there exists patient(1, , male) and visit(1, , 111), there will be a new row binding in the resulting male-flu table with P=1, D= Queries in Datalog

Prolog All formulas have the format: atomic formula atomic formula [, atomic formula(s)] written in Prolog as: atomic formula :- atomic formula [, atomic formula(s)]. Prolog uses only universally quantified variables. Some arithmetic functions are allowed, such as W is X*Y Specification of correct output is allowed.

Prolog Lists cons(H, T) constructs the list with H as the head and T as the tail. This is equivalent to [H|T]. [1,2,3]=[1|[2, 3]]=[1|2|3|nil]]]=cons(1, cons(2, cons(3, nil))) where nil is the empty list. All functions are evaluated based on unification. Conventionally, arguments to a Prolog expression are given with inputs first, then outputs. Prolog is Turing-complete so long as function symbols are allowed.

Defining Prolog Functions Member function: member(H, [H|T]). member(H, [S|T]) member(H,T). Insertion Sort: sort([ ], [ ]). sort([H|T], L) sort(T, T2), insert(H, T2, L). insert(H, [A|T], [H,A|T] H = A, insert(H, T, L).

Running Prolog On CSL machines, Prolog is run via the yap interpreter. To load a file into the interpreter: ?- consult('filename'). Once a file has been loaded, definitions contained in that file may be executed. The code will then be run top down until a solution is found and then bound to the output. ?- sort([5, 1, 10, 3, 9], X). %Bind sorted list to X