First Order Logic: Syntax and Semantics

Similar documents
First Order Logic: Syntax and Semantics

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

cis32-ai lecture # 18 mon-3-apr-2006

Logic: Propositional Logic (Part I)

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

Propositional Logic. Jason Filippou UMCP. ason Filippou UMCP) Propositional Logic / 38

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Artificial Intelligence Knowledge Representation I

Advanced Topics in LP and FP

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Propositional Logic: Syntax

15414/614 Optional Lecture 1: Propositional Logic

02 Propositional Logic

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

Propositional Logic Review

Example. Logic. Logical Statements. Outline of logic topics. Logical Connectives. Logical Connectives

Mathematical Logic Part One

Propositional Logic Arguments (5A) Young W. Lim 11/8/16

Learning Goals of CS245 Logic and Computation

Logic. Propositional Logic: Syntax

Formal Logic. Critical Thinking

Tecniche di Verifica. Introduction to Propositional Logic

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Truth-Functional Logic

Ontology Engineering for the Semantic Web

Compound Propositions

Propositional Logic. Fall () Propositional Logic Fall / 30

Logic for Computer Science - Week 4 Natural Deduction

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Logic. Propositional Logic: Syntax. Wffs

3 The Semantics of the Propositional Calculus

Propositional Logic: Part II - Syntax & Proofs 0-0

Propositional Logic Language

22c:145 Artificial Intelligence

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

FORMAL PROOFS DONU ARAPURA

Logic, Human Logic, and Propositional Logic. Human Logic. Fragments of Information. Conclusions. Foundations of Semantics LING 130 James Pustejovsky

KB Agents and Propositional Logic

Section 1.1: Logical Form and Logical Equivalence

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

Knowledge Representation and Reasoning

Natural Deduction for Propositional Logic

Propositional logic (revision) & semantic entailment. p. 1/34

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

Artificial Intelligence. Propositional Logic. Copyright 2011 Dieter Fensel and Florian Fischer

Propositional Logic Arguments (5A) Young W. Lim 10/11/16

Chapter 1: The Logic of Compound Statements. January 7, 2008

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Intelligent Systems. Propositional Logic. Dieter Fensel and Dumitru Roman. Copyright 2008 STI INNSBRUCK

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

A brief introduction to Logic. (slides from

Propositional Logic Arguments (5A) Young W. Lim 11/29/16

Propositional Logic. Spring Propositional Logic Spring / 32

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Chapter 4: Classical Propositional Semantics

Propositional Logic Arguments (5A) Young W. Lim 11/30/16

Propositional Logic: Review

Deductive Systems. Lecture - 3

Automated Reasoning Lecture 2: Propositional Logic and Natural Deduction

Proving logical equivalencies (1.3)

Discrete Mathematics and Applications COT3100

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54

Proseminar on Semantic Theory Fall 2013 Ling 720 Propositional Logic: Syntax and Natural Deduction 1

Propositional and Predicate Logic

THE LOGIC OF COMPOUND STATEMENTS

Natural deduction for truth-functional logic

Definition 2. Conjunction of p and q

Foundation of proofs. Jim Hefferon.

Propositional and Predicate Logic

Propositional Logic and Semantics

MA103 STATEMENTS, PROOF, LOGIC

Lecture 7. Logic. Section1: Statement Logic.

Propositional Logic Arguments (5A) Young W. Lim 2/23/17

INF3170 Logikk Spring Homework #8 For Friday, March 18

PHI Propositional Logic Lecture 2. Truth Tables

Intermediate Logic. Natural Deduction for TFL

n logical not (negation) n logical or (disjunction) n logical and (conjunction) n logical exclusive or n logical implication (conditional)

Mathematical Logic Part One

An Introduction to Modal Logic III

COMP 2600: Formal Methods for Software Engineeing

Description Logics. Deduction in Propositional Logic. franconi. Enrico Franconi

CS100: DISCRETE STRUCTURES. Lecture 5: Logic (Ch1)

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Logical Structures in Natural Language: Propositional Logic II (Truth Tables and Reasoning

Logical Agents. Outline

Proof Rules for Correctness Triples

Mathematical Logic Part Three

Logic and Proof. Aiichiro Nakano

Mathematical Logic Part One

Gödel s Incompleteness Theorems

Logic: Bottom-up & Top-down proof procedures

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Reasoning. Inference. Knowledge Representation 4/6/2018. User

Logic: The Big Picture

Propositional Logic: Logical Agents (Part I)

Transcription:

irst Order Logic: Syntax and Semantics COMP30412 Sean Bechhofer sean.bechhofer@manchester.ac.uk Logic Recap You should already know the basics of irst Order Logic (OL) It s a prerequisite of this course! he next two lectures provide a brief refresher But we won t go over everything in detail You re strongly advised to do some background reading if this isn t familiar territory Much of the remainder of the course will rely on an understanding of this material. E.g. he Language of irst Order Logic, Jon Barwise & John Etchemendy, CSLI Lecture Notes, 1993 2 University of Manchester, 2010 1

What is a Logic? When people talk about logic they often mean propositional or firstorder predicate logic. However there are many other logics, for example modal and temporal logics and description logics. We ll meet some of these later on. A logic usually has a well defined syntax, semantics and proof theory. he syntax of a logic defines the syntactically acceptable objects of the logic, or well-formed formulae. he semantics of a logic associates each formula with a meaning. he proof theory is concerned with manipulating formulae according to certain rules. 3 Coming Up Over the course of the next few lectures, we ll look in some detail at the syntax, semantics and proof theory of propositional logic. We ll then move on to predicate logic, seeing how this extends propositional logic and touch on some of the key characteristics of such languages. 4 University of Manchester, 2010 2

An Example: Cloth Weaves [Maier & Warren, Computing with Logic, 1988] An example showing how we can represent the qualities and characteristics of cloth types using a simple propositional logic knowledge base. 5 Cloth Woven fabrics consist of two sets of threads interlaced at right angles. he warp threads run the length of the fabric he weft (fill, pick or woof) threads are passed back and forth between the warp threads. When weaving, the warp threads are raised or lowered in patterns, leading to different weaves. actors include: he pattern in which warps and wefts cross Relative sizes of threads Relative spacing of threads Colours of threads 6 University of Manchester, 2010 3

Plain Weave Over and under in a regular fashion 7 will Weave Warp end passes over more than one weft Known as floats Successive threads offset by 1 8 University of Manchester, 2010 4

Satin Weave Longer floats Offsets larger than 1 9 Classifying Cloth he example provides a number of rules that describe how particular kinds of cloth are described. alternatingwarp! plainweave If a piece of cloth has alternating warp, then it s a plain weave. hasloats, warpoffseteq1! twillweave If a piece of cloth has floats and a warp offset of 1, then it s a twill weave. here are many other properties concerning the colour of threads, spacings etc. 10 University of Manchester, 2010 5

Using the Rules We could use these rules to build a system that would be able to recognise different kinds of cloth through recognising the individual characteristics. he example given shows that once we have recognised the following characteristics diagonalexture floatgsink colouredwarp whiteill hen we can determine that this cloth is denim. 11 Knowledge Representation Although this is relatively simple (in terms of both the expressivity of the language used and the number of facts), this really is an example of Knowledge Representation. he rules represent some knowledge about cloth A machine can make use of this knowledge to deduce consequences. his particular example makes use of propositional logic. 12 University of Manchester, 2010 6

Propositional Logic he syntax of propositional logic is constructed from propositions and connectives. A proposition is a statement that is either true or false but not both. Examples: the following are propositions George Burley is Scotland Manager 2 + 3 = 5 abio Capello is Scotland Manager 2 + 3 = 6 the reactor is in a stable state whereas the following are not What's the time? antastic Goal! 2+3 antelope 13 Propositions In general, we can determine whether any given statement is a proposition by prefixing it with It is true that and seeing whether the result makes grammatical sense. Propositions are often abbreviated using propositional variables eg p, q, r. hus we must associate the propositional variable with its meaning i.e. Let p be Gordon Brown is Prime Minister. Alternatively we might write something like reactor_is_in_a_stable_state so that the intended meaning of the propositional variable is clearer. But we need to be very careful here that we don t encode too much information in the names of the propositions. 14 University of Manchester, 2010 7

Connectives Connectives allow us to form compound propositions by combining propositions. Æ and conjunction & Ç or disjunction not negation ~ ) if then implies!, if and only if iff $ 15 And (Conjunction) he conjunction p and q, written p q of two propositions is true when both p and q are true, false otherwise. p q p q It s Monday It s raining It s Monday and it s raining 16 University of Manchester, 2010 8

ruth ables ruth tables provide a summary of a connective. he truth table shows all possible combinations of the inputs to the connective, along with the outcome. Rows in the table give all possible settings of the propositions to true () or false (). or a connective with n inputs, we need 2 n rows in our truth table. A truth table for is: p q p q 17 Or (Disjunction) he disjunction p or q, written p q, of two propositions is true when p or q (or both) are true, false otherwise. his is sometimes called inclusive or, as we don t require that only one of the propositions is true. p q p q p q p q It s Monday It s raining It s Monday or it s raining 18 University of Manchester, 2010 9

Not (Negation) he negation not p of a proposition p is true when p is false and is false otherwise. Can also be read as it is false that p p p p Logic is easy p It s false that logic is easy It s not the case that logic is easy Logic isn t easy 19 If then (Implication) he implication p implies q, written p q, of two propositions is true when either p is false or q is true, and false otherwise. p q p q p q p q I study hard I get rich If I study hard then, I get rich When I study hard, I get rich 20 University of Manchester, 2010 10

If then (Implication) We need to be careful with as it may not quite capture our intuitions about implication. In particular (taking the previous example), p q is true in the following situations: I study hard and I get rich; or I don't study hard and I get rich; or I don't study hard and I don't get rich. Note the last two situations, where the implication is true regardless of the truth of p. he one thing we can say is that if I've studied hard but failed to become rich then the proposition is clearly false. 21 Iff (Bi-implication) he bi-implication p iff q (p if and only if q), written as p q, of two propositions is true when both p and q are true or when both p and q are false, and false otherwise. p q p q p q p q Sean is happy It s the weekend Sean is happy iff it s the weekend 22 University of Manchester, 2010 11

Propositional Logic: More formally he language of propositional logic consists of the following symbols. A set PROP, of proposition symbols, p, q, r etc A set of propositional connectives:- nullary connectives true and false; unary connective binary connectives,,, he symbols ( and ) these are used to avoid ambiguity. 23 Well ormed ormulae he set of Well-ormed ormulae (W) is defined as: Any propositional symbols is in W he nullary connectives true and false are in W If A and B are in W then so are A (A) A B A B A B A B 24 University of Manchester, 2010 12

Examples p (p) (()) true p true p q p q (p q) true false p q (p q) r p q r 25 ruth ables We can extend the basic truth tables to show interpretations of compound propositions. o draw up a truth table, construct a column for each proposition involved. We need 2 n rows for n propositions in order to record all possible ways of setting the propositions to and. If we have 3 propositions,, i.e. we need 2 3 = 8 rows. Construct a column for each connective, the most deeply nested first. Evaluate each column using values for propositions or previous columns. 26 University of Manchester, 2010 13

Example p q r I eat eggs for breakfast I eat cereal for breakfast I eat toast for breakfast (p q) r p q r p q (p q) r Compound proposition is true if I eat eggs, cereal and toast; or I eat eggs and toast; or I eat cereal and toast 27 Interpretations Given a particular formula, can you tell if it is true or not? he truth of a compound formula depends on the truth values of the component propositions. A truth valuation is a function: I v : PROP {,} which assigns a truth value to each atomic proposition Given a truth valuation, we can define a interpretation I that gives a truth value for a (well-formed) compound formula using the truth valuation for the atomic propositions and the truth tables for the connectives involved. 28 University of Manchester, 2010 14

Example Proposition: (p q) r ruth valuation: I v (p) =, I v (q) =, I v (r) = Applying the truth valuation gives us: I((p q) r) = (I v (p) I v (q)) I v (r)) = ( ) = = p q p q p q p q 29 Semantics of Propositional Logic Given an truth valuation I v :PROP! {,}, we can extend this to provide us with a interpretation I that assigns either or to any statement of the language. he symbol ² is used to represent the relationship between interpretations and formulae: I ² true I 2 false I ² p if, and only if I v (p) = I ² A if, and only if I 2 A I ² A Æ B if, and only if I ² A and I ² B I ² A Ç B if, and only if I ² A or I ² B I ² A ) B if, and only if If I ² A then I ² B I ² A, B if, and only if I ² A if and only if I ² B 30 University of Manchester, 2010 15

autologies and Satisfiability A formula is valid or is a tautology iff it is true under every interpretation. If A is a tautology, this is written ² A A formula is said to be satisfiable (or consistent) iff it is true under at least one interpretation. A formula is said to be unsatisfiable (or inconsistent or contradictory) iff there is no interpretation under which it is true If a formula A is a tautology then A is unsatisfiable. 31 ruth ables Each line of a truth table corresponds to an interpretation. So we can use truth tables to determine whether or not formulae are valid. Example: (p ) q) Ç (q ) p) p q p ) q q ) p (p ) q) Ç (q ) p) autology 32 University of Manchester, 2010 16

ruth ables Example: (p ) q) Æ p p q p ) q (p ) q) Æ p Not a tautology, but satisfiable 33 ranslations An alternative to providing a direct semantics (e.g. Interpretations as we ve seen here) is to provide a translation of the connectives or example, we can define p! q as p Ç q If we look at the truth tables for each of these formulae, then we can see that for any valuations of p and q, the result is the same. 34 University of Manchester, 2010 17

Defining New connectives Using this approach of translation rather than a direct semantics, we can define new connectives. p q p q Recall the truth table for or p Ç q is true when either p or q is true. It s also true when both p and q are true or some situations, we might want a new connective that tells us when only one of p or q is true: also known as exclusive or and sometimes written p q 35 Defining New connectives We could define p q using a truth table: p q p q Alternatively, we can give a translation to an equivalent expression using the other connectives: p q (p Ç q) Æ (p Æ q) 36 University of Manchester, 2010 18

unctional Completeness he above example illustrates that we don t actually need the exclusive or connective It can be defined in terms of Æ, Ç and So how many connectives do we really need? We say a set of connectives is functionally complete if there is no truth table that can not be expressed as a formula involving only these connectives. or example, the set {Æ, Ç, } is functionally complete In fact {Ç, } is functionally complete De Morgan s Laws 37 Logical Consequences We have provided definitions of the syntax and semantics of propositional logic. Given a set of formulae, we want to know which formulae are logical consequences of that set B is a consequence of A if it s the case that whenever A is true, then B must be true also. We write: A ² B or example, if we know that both p and p ) q hold, then we might want to be able to conclude that q also holds. 38 University of Manchester, 2010 19

Logical Consequences We can do this by constructing truth tables. If we want to know whether B follows from A 1, A 2,. A n, then we could construct a truth table for A 1 Æ A 2 Æ Æ A n ) B and check to see is this is a tautology. E.g. is it the case that q follows from (p ) q) and p? Construct a truth table for ((p ) q) Æ p) ) q p q (p ) q) (p ) q) Æ p ((p ) q) Æ p) ) q 39 Knowledge Bases We can now use thise notion of logical consequence. A Knowledge Base K = {p 1,, p n } is a collection of propositions that describe facts about a situation of affairs that we are trying to model We can then derive consequences from this knowledge base where q is a consequence if p 1,,p n ² q or example, the rules encapsulating the different characteristics and qualities of different cloth weaves. 40 University of Manchester, 2010 20

Logical Consequences As we saw before, we could test for logical consequence by constructing truth tables. If we want to know whether B follows from A 1, A 2,. A n, then we could construct a truth table for A 1 Æ A 2 Æ Æ A n ) B and check to see is this is a tautology. E.g. is it the case that q follows from (p ) q) and p? Construct a truth table for ((p ) q) Æ p) ) q) p q (p ) q) (p ) q) Æ p ((p ) q) Æ p) ) q) Problem: his is potentially expensive: we need 2 n rows for n propositions, so our truth tables may become large. 41 Proof Rules An alternative is to use some proof rules or proof theory. Proof rules provide us with a mechanism for determining logical consequences through some syntactic manipulation of the formulae. A rule stating that B follows (or is provable from) A 1,,A n is written as: A 1 A n B A well known proof rule is modus ponens: where A and B are any W. A ) B B A 42 University of Manchester, 2010 21

More Proof Rules A common rule, known as Æ-elimination is: A Æ B or B We can read the first as If A and B hold, then A must also hold. A Æ B A he Ç-introduction rule tells us: A A Ç B or Again, we can read the first as: If A holds, then A Ç B must also hold. B A Ç B 43 Proof By combining proof rules together, we can deduce consequences from premises. Ex: from p Æ q and q ) r, can we prove r? 1. p Æ q [given] 2. q ) r [given] 3. q [1 Æ-elimination] 4. r [2,3 modus ponens] 44 University of Manchester, 2010 22

Proof heory his reasoning about statements of the logic is being done without considering the interpretations We re not drawing up truth tables to work out if the consequences hold. Proof rules show us, given true statements, how to generate further true statements. Axioms describe universal truths of the logic or example, p Ç p is an axiom of propositional logic 45 Proofs If A 1, A n,b are W, then there is a proof of B from A 1,,A n iff there exists some sequence of formulae C 1,,C n such that C n = B and each formula C k for 1 k < n is either an axiom, one of the formulae A 1, A n or is the conclusion of a rule whose premises appeared earlier in the sequence. We write A 1,,A n ` B to show that B is provable from A 1,,A n (given some set of proof rules and axioms). Ex: from p ) q, ( r Ç q) ) (s Ç p), q can we prove s Ç q? 1. p ) q [given] 2. ( r Ç q) ) (s Ç p) [given] 3. q [given] 4. s Ç q [3, Ç-introduction] Alternative would be truth table for (p ) q Æ ( r Ç q) ) (s Ç p) Æ q ) ) (s Ç q) 46 University of Manchester, 2010 23

Relating Proofs and Semantics So far we ve considered notions of validity and provability Validity is related to semantics. A propositional formula is valid if it is satisfied under all possible interpretations We draw up a truth table and check that every line evaluates to true. Provability is related to the proof theory. A propositional formula is provable if it is an axiom or it is provable from other provable formulae We construct a proof applying proof rules at each step. What s the connections between the two? Soundness and Completeness 47 Soundness We write A 1,,A n ` B to denote that B is provable from A 1,,A n using a set of proof rules A Soundness theorem states that: If A 1,,A n ` B then A 1 Æ Æ A n ² B (i.e. A 1 Æ Æ A n ) B is valid) Informally, soundness gives us an assurance that our proof theory is producing correct answers 48 University of Manchester, 2010 24

Completeness A Completeness theorem states that: If A 1 Æ Æ A n ² B (i.e. A 1 Æ Æ A n ) B is valid) then A 1,,A n ` B Informally, completeness gives us an assurance that if a formula is valid, we can construct a proof of it using our proof theory. Note that completeness doesn t say anything at all about how we might go about constructing such a proof just that the proof exists. Note that both soundness and Completeness completeness are with respect to a particular set of axioms and proof rules. ² ` Soundness 49 Soundness and Completeness An example of an unsound rule is: A C Using this rule, given any p and q, we can deduce an arbitrary r. However p Æ q ) r is not a valid formula. hus including this rule in our proof rules would not give us soundness. B If we only have rules for modus ponens and Æ-elimination, we do not have completeness. With only those rules, we can t prove p ` p Ç q even though p ) (p Ç q) is valid 50 University of Manchester, 2010 25

Summary We ve seen a (brief) overview of propositional logic, its syntax, semantics and proof theory. We haven t seen all the details of the proof rules for propositional logic though. hese can be found in any introductory logic text. We ve seen the notions of soundness and completeness, relating the interpretation semantics and the proof theory. Next, we ll look at predicate calculus, which gives us a much more expressive language than propositional logic. 51 University of Manchester, 2010 26