Introduction to Prolog

Slides:



Advertisements
Similar presentations
-- in other words, logic is
Advertisements

Artificial Intelligence
Logic Use mathematical deduction to derive new knowledge.
Chapter 1 The Logic of Compound Statements. Section 1.3 Valid & Invalid Arguments.
CS128 – Discrete Mathematics for Computer Science
Symbolic Logic. Objectives Determine if a sentence or question is a statement or not. Write a sentence that represents the negation of a given statement.
Logic 3 Tautological Implications and Tautological Equivalences
CSE (c) S. Tanimoto, 2008 Propositional Logic
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Discrete Mathematics and its Applications
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Getting Started with Visual Prolog
Question of the Day!  We shared a lot of examples of illogical arguments!  But how do you make a LOGICAL argument? What does your argument need? What.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Chapter 3: Introduction to Logic. Logic Main goal: use logic to analyze arguments (claims) to see if they are valid or invalid. This is useful for math.
CS6133 Software Specification and Verification
Chapter 7. Propositional and Predicate Logic Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
Section 1.1 Propositions and Logical Operations. Introduction Remember that discrete is –the study of decision making in non-continuous systems. That.
CT214 – Logical Foundations of Computing Darren Doherty Rm. 311 Dept. of Information Technology NUI Galway
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Artificial Intelligence Logical Agents Chapter 7.
Sound Arguments and Derivations. Topics Sound Arguments Derivations Proofs –Inference rules –Deduction.
Deductive Reasoning. Inductive: premise offers support and evidenceInductive: premise offers support and evidence Deductive: premises offers proof that.
THE NATURE OF ARGUMENT. THE MAIN CONCERN OF LOGIC Basically in logic we deal with ARGUMENTS. Mainly we deal with learning of the principles with which.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Copyright © Peter Cappello
Making Inferences with Propositions (Rules of Inference)
Chapter 7. Propositional and Predicate Logic
Deductive reasoning.
2. The Logic of Compound Statements Summary
Valid and Invalid Arguments
CSE15 Discrete Mathematics 01/30/17
Knowledge Representation and Reasoning
Discrete Mathematics Logic.
Formal Logic CSC 333.
Methods of proof Section 1.6 & 1.7 Wednesday, June 20, 2018
Deductive Arguments.
Logic programming ( Handbook of Logic in Artificial Intelligence, Vol) by D. M. Gabbay, C. Hogger, J.A. Robinson .
Demonstrating the validity of an argument using syllogisms.
Principles of Computing – UFCFA3-30-1
2 Chapter Introduction to Logic and Sets
Logical Inferences: A set of premises accompanied by a suggested conclusion regardless of whether or not the conclusion is a logical consequence of the.
CS201: Data Structures and Discrete Mathematics I
Mathematical Reasoning
Logic Use mathematical deduction to derive new knowledge.
CS 270 Math Foundations of CS
Logical Forms.
CS 220: Discrete Structures and their Applications
Applied Discrete Mathematics Week 1: Logic
Propositional Logic.
Back to “Serious” Topics…
1 Chapter An Introduction to Problem Solving
Computer Security: Art and Science, 2nd Edition
Discrete Mathematics Logic.
1 Chapter An Introduction to Problem Solving
MAT 3100 Introduction to Proof
Chapter 7. Propositional and Predicate Logic
CSNB234 ARTIFICIAL INTELLIGENCE
Foundations of Discrete Mathematics
ece 720 intelligent web: ontology and beyond
Mathematical Reasoning
Logic of Informatics Introduction.
Intermediate Level Conditionals.
Phil2303 intro to logic.
Argumentation.
CS201: Data Structures and Discrete Mathematics I
Introduction to Computational Linguistics
Habib Ullah qamar Mscs(se)
Rules of inference Section 1.5 Monday, December 02, 2019
Presentation transcript:

Introduction to Prolog CS321

Brief History The first, official version of Prolog was developed at the University of Marseilles, France by Alain Colmerauer in the early 1970s as a tool for PROgramming in LOGic.

Application Areas Prolog has been a very important tool in artificial intelligence applications expert systems Updated versions of Prolog are now being used for natural language interfaces smart information management systems

Declarative Language This means that The programmer declares facts defines rules for reasoning with the facts Prolog uses deductive reasoning to determine new facts from old decide whether a proposed fact (goal) can be logically derived from known facts (such a decision is called a conclusion)

Predicate In classic logic, a declarative statement (fact) is called a predicate. The next few slides review relevant classic logic, as related to logic programming

Predicates A predicate is Examples: The sky is red. I am honest. decidable (true or false) A sentence that can be put in the place of “…” in the sentence Is it true that “…”? Examples: The sky is red. I am honest.

Primitive, Compound A predicate is a primitive statement it cannot be broken down into simpler form can be represented by a single symbol p: I am a computer science major. q: My printer is not working today. Predicates can be combined into compound statements with logical connectors

Logical Connectors Negation Conjunction ! q Conjunction p and q Disjunction (inclusive, one or both) p or q Disjunction (exclusive, one or the other) p or q , but not both

Implication (rule) An if…then “relationship” between predicates p :- q can mean any of “ if p is true, then q is also true” “q is necessary for p” “ p only if q’ Note: this is not necessarily a “cause and effect” type of relationship p is the hypothesis (premise) and q is the conclusion

Arguments Central to the notion of logic is an argument: Example: … a set of predicates used as hypotheses to justify a conclusion Example: If Socrates is a man then Socrates is mortal. Socrates is a man. Therefore, Socrates is mortal.

Argument Structure A (modus ponens) argument structure can be represented as: If Ssss is an xxxxx then Ssss is a yyyyy. Ssss is an xxxxx. Therefore, Ssss is a yyyyy. We can judge the validity of the argument by its structure (form), rather than by its meaning.

Formalizing Arguments Abstracting with symbols for predicates, we get an argument form that looks like this: if p then q p therefore q Thus, the formal representation ((p :- q)  p)  q

Predicate Logic When we look at predicates abstractly, we see that the correctness of an argument is not governed by its content (meaning), but by its logical form. There are rules (procedures) to decide whether or not a given argument is acceptable. (Rules of Inference)

Rules of Inference Modus Ponens Law of Syllogism If p then q, p, therefore q Law of Syllogism p, then q, q then r p, therefore r Modus Tollens (mode that denies) If P, then Q. Q is false. therefore P is false. Rule of Conjunction If p and q, therefore p or q

Logic Programming Language Prolog is a language where the language implementation is a collection of procedures (functions) based on the rules of inference in classical logic Modus Ponens Law of Syllogism Modus Tollens Rule of Conjunction

Inference Engine The procedures for reasoning logically about facts are combined with a pattern matcher to create the inference engine A pattern matcher retrieves stored facts by matching answers to questions. infers that a hypothesis is true by questioning the set of facts already known to be true

Prolog program Prolog's known world is the finite set of facts (and rules) that are given in a program. Typically, a Prolog program isn't a sequence of actions--it's a list of facts together with inference rules. The Prolog system arrives at conclusions by logically inferring new facts from known facts.

Writing Predicates in Prolog First eliminate all unnecessary words from your sentences. Then transform the sentence, placing the relationship first and grouping the objects after the relationship. The objects then become arguments that the relationship acts upon. See examples, next slide  

Examples Natural Language: Predicate Logic: A car is fun. fun(car). A rose is red. red(rose).   Bill likes a car likes(bill,Car)if fun(Car). if the car is fun.

Facts A Fact declares a relation between objects likes(bill, cindy). likes(cindy, bill). likes(bill, dogs). Facts can also express properties of objects green(kermit). girl(caitlin).

Rules Rules enable you to infer facts from other facts. Another way to say this is: a rule states a way to conclude a new fact -- if one or more other facts can be shown to be true. Cindy likes everything that Bill likes. Caitlin likes everything that is green.

Inference What new facts can we infer from the known facts and rules? likes(bill, cindy). likes(cindy, bill). likes(bill, dogs). green(kermit). girl(caitlin). RULES: Cindy likes everything that Bill likes. Caitlin likes everything that is green. What new facts can we infer from the known facts and rules? Cindy likes Cindy. Caitlin likes Kermit.