Exploring Predicate Logic: A Comprehensive Guide for Computing Science
This presentation dives into Predicate Logic, a vital concept in computing science and mathematics. It covers key topics including the importance of predicate logic, its applications, syntax, semantics, and how it extends propositional logic. The agenda includes discussions on bound and free variables, complex expressions, quantifier equivalences, and practical examples. We will also explore how predicate logic underpins various fields such as artificial intelligence and automatic program verification. This is an essential resource for students keen to master logic in the context of computing.
Exploring Predicate Logic: A Comprehensive Guide for Computing Science
E N D
Presentation Transcript
University of Aberdeen, Computing ScienceCS2013Mathematics for Computing ScienceAdam Wyner Slides adapted from Michael P. Frank's course based on the textDiscrete Mathematics & Its Applications(5th Edition)by Kenneth H. Rosen
Predicate Logic Rosen 5th ed., §§1.3-1.4 (but much extended)
Agenda • Why Predicate Logic? • Applications • Syntax and semantics – informal to formal • Work thorough examples • Bound and free variables • Complex expressions (quantifiers with logical connectives; nested quantifiers) • Quantifier equivalences • Vacuous quantification and false antecedents • Defining (or not) other quantifiers Frank / van Deemter / Wyner
To Predicate Logic • We can use propositional logic to prove that certain real-life inferences are valid. • If it’s cold then it snows. • If it snows there are accidents • There are no accidents. • Therefore, it’s not cold • In propositional logic: ((cssa a) c) is a tautology Frank / van Deemter / Wyner
Predicate Logic • In propositional logic: (((cs) (sa) a) c) is a tautology • Alternatively, it follows by propositional logic:(cs) (sa) a (premise) thatc (conclusion). Frank / van Deemter / Wyner
Predicate Logic • How to understand why Everyone is happy is false where the people are {bill, jill, mary} and Mary is not happy is true. • How to prove valid inferences that cannot be proven valid in propositional logic • Every human is mortal. Socrates is human. Therefore, Socrates is mortal. • We need a more expressive logic for quantifiers and predicates. Frank / van Deemter / Wyner
Predicate Logic • In propositional logic, we have simple propositions(atomic statements) and complex propositions (formed using truth functional operators). • In propositional logic, we have truth tables that represent alternative contexts. Frank / van Deemter / Wyner
Predicate Logic • Predicate logicextends propositional logic • Keeps the truth functional operators and truth tables. • Adds constants, variables and quantification over classes of entities. • Adds a distinction between the arguments of a sentence (e.g. subject, object, etc) and the predicates of a sentence (e.g. verbs). • Has models arguments and predicates of a domain. Frank / van Deemter / Wyner
Applications of Predicate Logic It is one of the most-used formal notations for writing mathematical definitions, axioms, and theorems. For example, in linear algebra, a partial order is introduced saying that a relation R is reflexive and transitive – and these notions are defined using predicate logic. Frank / van Deemter / Wyner
Applications of Predicate Logic • Basis for many Artificial Intelligence systems. • Automatic program verification systems • Real world rule engines with NL interfaces • Oracle Policy Automation http://www.youtube.com/OraclePAVideos • Predicate-logic like statements are supported by some database query engines. • Limitations (more later) Frank / van Deemter / Wyner
A Bit of Grammar • In The dog is sleeping: • The dog is an argument, the subject. • is sleeping is a one-place predicate (an intransitive verb), a property that is ascribed to the subject. • In The girl hit the ball: • The girl is the subject and the ball is the object. • hit is a two-place predicate (a transitive verb), a relation that is ascribed between the subject and object. • Predicate logic follows a similar form. Frank / van Deemter / Wyner
Constants and Variables (informal) • Individual constantsthatdenote individuals/objects: a,b,c,… Constants are a bit like proper names (e.g. names for things such as Bill, Jill, IBM). The meaning is fixed. • Individual variablesthat range over objects: x, y, z, … Variables are likepronouns (e.g. he, she, it). The meaning varies, depending on what is indicated. Frank / van Deemter / Wyner
Predicates and Arguments (informal) • A predicate Papplied to constant a is the proposition P(a). • Meaning: the object denoted by a has the property P. P(a) is T or F. • A predicate P applied to a variable x is a propositional form P(x). • Meaning: given an object that denotes a value of x, the object has the property P. P(x) is T or F depending on the value of x. Frank / van Deemter / Wyner
Forms and Evaluations (informal) • Jill is happy (NL) • is_happy'(jill'). • True if in the model the denotation of jill' is an element of the denotation of is_happy' (jill cannot vary). • He is happy (NL) • is_happy'(x). No gender on variables! • True if in the model given a denotation of x, that object is an element of the denotation of is_happy' (x can vary) Frank / van Deemter / Wyner
Models and Evaluation (informal) • A model, M, is a "toy" representation of a "world" has • a Domain (Universe) of Discourse D, which is the set ofthings that the predicates of the logic relate to and nothing else. • denotations for constants and predicates. Constants are related to a particular thing in D. The denotation (extension) of a predicate is the set of objects (set of relations) from D for which the predicate holds. • a manipulation on variables Frank / van Deemter / Wyner
Models and Evaluation (informal) • M1: • D = {jill, bill, phil, will, mary} • is_happy' denotes {jill, bill, phil} • jill' denotes jill • Evaluation (of Jill is happy) • is_happy'(jill') is T in m1 iffjill {jill, bill, phil} Frank / van Deemter / Wyner
Models and Evaluation (informal) • M1: D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, jill' denotes jill • Evaluation (of It is happy) • is_happy(x) is T in m1 iff x {jill, bill, phil}?? • Depends on what x is: • is F where x = mary, for mary{jill, bill, phil} • is T where x = phil, for phil {jill, bill, phil} • Say where x is assigned the value mary.... Frank / van Deemter / Wyner
Quantifiers (informal) • Someone is happy. • Is True iff for some value of y wrt D, is_happy'(y) is True. • y is_happy'(y) • Everyone is hungry. • Is True iff for every value of x wrt D, is_hungry'(x) is True. • x is_hungry'(x) • Everyone is happy. Quantifiers provide a notation to express 'some' and 'all'. Frank / van Deemter / Wyner
Models and Evaluation (informal) • M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill (and so on). • Evaluation (of Someone is happy) • y is_happy'(y) is T iff there is an assignment of a value from D to y such that is_happy'(y)is true. • is_happy'(y) is: T where y =jill; F where y =mary; F where y = will; T where y =phil; T where y = bill. • y is_happy'(y) is T for there is an assignment such that is_happy'(y)is true. Frank / van Deemter / Wyner
Models and Evaluation (informal) • M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill (and so on). • Evaluation (of Everyone is happy) • y is_happy'(y) is T iff for every assignment of a value from D to y, is_happy'(y) is true. • is_happy'(y) is: T where y =jill; F where y =mary; F where y = will; T where y =phil; T where y = bill. • y is_happy'(y) is F for it is false that for every assignment of a value to y, is_happy'(y)is true. Frank / van Deemter / Wyner
Models and Evaluation (informal) • M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill(and so on). • Evaluation (of Everyone is hungry) • x is_hungry'(x) is T iff for every assignment of a value from D to x, is_hungry'(x) is true. • is_hungry'(x) is: T where x =jill; T where x =mary; T where x = will; T where x =phil; T where x = bill. • y is_hungry'(x)is T for every assignment of a value to x, is_hungry'(x) is true. Frank / van Deemter / Wyner
Models and Evaluation (informal) • Questions: • Are x is_hungry'(x) and z is_hungry'(z) equivalent (true/false in the same models)? So, does the selection of variable matter? • Are x is_happy'(x) and z is_happy'(z)equivalent? • Does x is_hungry'(x) entail zis_hungry'(z)? • Are is_happy'(bill') and is_happy'(mary') equivalent? • Are is_happy'(x)and is_happy'(z) equivalent? • x is_happy'(x) andx is_hungry'(x) relate variables? Frank / van Deemter / Wyner
Formal SyntaxVariables, Constants, Predicates • Variable: x,y,z,… Constants: a,b,c,… • 1-place predicates: P,Q,… • 2-place predicates: R,S,… • 3-place, ... , n-place predicates: so on... Frank / van Deemter / Wyner
Formal SyntaxAtomic Formulae Atomic formulas: • If is a 1-place predicate and a variable or constant then () is an atomic formula. • If is a 2-place predicate and and are variables or constants then (,) is an atomic formula. • And so on for 3-place, etc. Frank / van Deemter / Wyner
Formal SyntaxWell-formed Formulas (Well-formed) Formulas: • All atomic formulas are formulas. • If and are formulas then ,( ), ( ), ( ) are formulas. • If is a formula then x and y are formulas. • Lots of comments to make about quantified well-formed formulas – variable binding, vacuous quantification, nested quantifiers... Frank / van Deemter / Wyner
SyntaxQuantified Expressions • Some well-formed expressions: xP(x) yQ(x) xy R(x,y) xP(b) • P(x) is a (atomic) formula, hence xP(x) is a formula • Q(x) is a (atomic) formula, hence yQ(x) is a formula • R(x,y) is a (atomic) formula, hence y R(x,y) is a formula, hence xy R(x,y) is a formula (nested quantifiers) • P(b) is a (atomic) formula, hence xP(b) is a formula (vacuous quantification). Frank / van Deemter / Wyner
Formal SemanticsModel • A model M is an ordered pair <D,I>, where D is a set of entities, and I is an interpretation function. Mdefines gives a specific ‘meaning’ to the non-logical symbols (logical symbols are ). • If a is an individual constant then I(a) D. Assume for every entity in D there is a constant. • If P is a 1-place predicate then I(P) D • If R is a 2-place predicate, then I(R) {(,): Dand D} • So on for 3-place predicates etc. Frank / van Deemter / Wyner
An Example of a Model • Suppose M = (D,I) where D={bill, jill, mary} • I(john') = john, I(mary') = mary, I(bill') = bill; I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)} • Note: billis a person (i.e., a part of the world)bill'is an individual constant (i.e., a part of the language of predicate logic). In a sentence, we would use the proper name "Bill". Frank / van Deemter / Wyner
Formal SemanticsTruth Definition Given a formula and a model, we want a systematic way to calculate whether (or not) the formula is true (or false) with respect to the model. The Truth Definitions are of the form formula is true iff.... Frank / van Deemter / Wyner
Formal SemanticsTruth of Predicate Formulae • A formula of the form P(a) is true with respect to M iffI(a) I(P). • A formula of the form R(a,b) is true with respect to M iff(I(a),I(b)) I(R). Frank / van Deemter / Wyner
FormalSemanticsTruth for Functional Connectives • A formula of the form is true wrt M iff is false wrtM. • A formula of the form is true wrt M iff is true wrt M or is true wrt M or both. • A formula of the form is true wrt M iff is true wrt M and is true wrtM. • A formula of the form is true wrt M iff is false wrt M or is true wrtM. Recall the Truth Tables Frank / van Deemter / Wyner
Formal SemanticsTruth with Variables and Quantifiers • Notation: where is a formula,(x:=a) is the result of substituting all free occurrences of the variable x in by the constant a. • More to say about 'free occurrences'. • A formula of the form x is true wrt M iff there is an I(a) D such that (x:=a) is true wrt M. • A formula of the form x is true wrt M ifffor every I(a) D, (x:=a) is true wrt M. Frank / van Deemter / Wyner
Examples - Simple • Suppose M = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)} • Is B(jill') true in M? • Is A(mary',bill') true in M? • Is A(jill',bill') true in M? Frank / van Deemter / Wyner
Examples - Connectives • Suppose M = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)} • Is [B(jill') G(bill')] true in M? • Is [A(mary',bill') G(mary')] true in M? Frank / van Deemter / Wyner
Examples - Quantifiers • Suppose M = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)} • Is y B(y) true in M? • Is y [B(y) G(y)]true in M? • Is y [B(y) A(y,bill')] true in M? Frank / van Deemter / Wyner
Examples - Quantifiers • Suppose M = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill), (mary,bill), (jill, jill)} • Is y B(y) true in M? • Is y [B(y) G(y)]true in M? • Is y [B(y) A(y,bill')] true in M? • Is x [B(x) A(x,jill)] true in M? Frank / van Deemter / Wyner
Next • Work thorough examples • Bound and free variables • Complex expressions (quantifiers with logical connectives; nested quantifiers) • Quantifier equivalences • Vacuous quantification and false antecedents • Defining (or not) other quantifiers • Other Frank / van Deemter / Wyner