860 likes | 886 Views
Dive into models of propositional and predicate logic, covering tautologies, contradictions, logical equivalences, and truth tables. Learn to prove logical equivalences and consequences with practical examples.
E N D
University of Aberdeen, Computing ScienceCS3518Lecture on Models and Satisfiability Further details: K.Rosen, Discrete Mathematics & Its Applications(any edition), chapter on logic Michael Frank / Kees van Deemter
These slides are not meant as a general-purpose introduction, but as preparation for • a proof that monadic Predicate Logic is decidable • a proof that full Predicate is undecidable • The slides contain questions Q1, Q2, etc. These questions will be addressed in the Practical Michael Frank / Kees van Deemter
First Propositional Logic Michael Frank / Kees van Deemter
The syntax of propositional logic • Atoms: p1, p2, p3, .. • Formulas: • All atoms are formulas • For all , if is a formula then ¬ is a formula • For all and , if and are formulas then the following are formulas: ( ), ( ), ( ) (etc.) CS2013 Univ of Aberdeen
Subformulas • A formula that is a substring of a formula ψ is a subformula of ψ • Example: (p q) has these subformulas: Michael Frank / Kees van Deemter
Subformulas • A formula that is a substring of a formula ψ is a subformula of ψ • Example: (p q) has these subformulas:(p q), (p q),p, q, p, q Michael Frank / Kees van Deemter
Tautologies A tautology is a compound proposition that is trueno matter what the truth values of its atomic propositions are! Ex.p p[What is its truth table?] CS2013 Univ of Aberdeen
Tautologies • When every row of the truth table gives T. • Example: p p T T FT F T TF CS2013 Univ of Aberdeen
Contradictions A contradiction is a compound proposition that is false no matter what! Ex.p p [Truth table?] CS2013 Univ of Aberdeen
Contradictions • When every row of the truth table gives F • Example: p p T F FT F F TF CS2013 Univ of Aberdeen
Propositional Equivalence Two syntactically (i.e., textually) different compound propositions may be semantically identical (i.e., have the same meaning). Here semantically identical means just that they have the same truth table for input truth values of the propositions. We call them logically equivalent. Notation: … … CS2013 Univ of Aberdeen
Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written pq, IFFp and q contain the same truth values in all rows of their truth tables CS2013 Univ of Aberdeen
Proving Equivalencevia Truth Tables Ex. Prove that pq (p q). Q1 CS2013 Univ of Aberdeen
Proving Equivalencevia Truth Tables Ex. Prove that pq (p q). F T T T F T T F F T T F T F T T F F F T Shows that OR is equivalent to a combination of NOT and AND. CS2013 Univ of Aberdeen
Logical consequence • Formula φ has formula ψ as a logical consequence if ψ “follows from φ” • Formally: every assignment of truth values that makes φ true makes ψ true as well • Notation: φ |= ψ • φ and ψ are logically equivalent iff φ |= ψ and ψ |= φ Michael Frank / Kees van Deemter
Example of one-sided logical consequence Ex. Prove that p&q p Q2 CS2013 Univ of Aberdeen
Example of one-sided logical consequence Ex. Prove that p&q p Each row that has T for p&q has T for p . CS2013 Univ of Aberdeen
Logical consequence Observe: φ |= ψ iff φ & −ψ is a contradiction Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic First-Order Predicate logic (FOPL) • An extension of Propositional Logic • Sometimes called quantificational logic, because it allows us to quantify over objects in a domain • E.g. saying that all/some objects have a property • Some odd numbers are prime • Futher extensions exist, e.g. second-order logic, which quantifies over properties, e.g. • 4 and 2+2 share all their semantic properties Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Predicates/relations with n places • Full FOPL permits predicates of any finite number of arguments. E.g.: S(x) = “x is even” (1 arg.) R(x,y) = “x adores y” (2 arg.) P(x,y,z) = “x gave y the grade z” (3 arg.) Q(x,y,z,u)= “x*(y+z)=u ”(4 arg.) Michael Frank / Kees van Deemter
Syntax of predicate logic (for 1- and 2-place predicates) • Variable: x,y,z,… Constants: a,b,c,… • 1-place predicates: P,Q,… • 2-place predicates: R,S,… Atomic formulas: If is a 1-place predicate and a var or constant then () is an atomic formula. If is a 2-place predicate and and are var or constants, (,) is an atomic formula. If each of and is a var or constant then = is an atomic formula Michael Frank / Kees van Deemter
Syntax of predicate logic (for 1- and 2-place predicates) (Wellformed) Formulas: • All atomic formulas are formulas • If and are formulas then , ( ), (), ( ) are formulas. • If is a formula then x and x are formulas. (Likewise, y and y,and so on.) Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Meaning of Quantified Expressions First, informally: • xP(x) means for all x in the u.d., P holds. • x P(x) means there exist x in the u.d. (that is, 1 or more) such thatP(x) is true. Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Free and Bound Variables • An expression like P(x) is said to have a free variablex (i.e., x is not “defined”). • A quantifier (either or ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more boundvariables. Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Example of Binding • P(x,y) has 2 free variables, x and y. • xP(x,y) has 1 free variable, and one bound variable. • An expression with zero free variables is called a sentence. Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Free variables, defined formally • The free-variable occurrences in an Atom are: all the variable occurrences in that Atom • The free-variable occurrences in are: the free-variable occurrences in • The free-variable occurrences in ( connective ) are: the free-variable occurrences in plus the free-variable occurrences in • The free-variable occurrences in xand xare: the free-variable occurrences in except for all/any occurrences of x. Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic A more precise definition of the truth/falsity of quantified formulas • Formulation is simplified somewhat because we assume that every object in the u.d. D has a `name` (i.e., a constant referring to it). • Notation: (x:=a) is the result of substituting all free occurrences of the variable x in by the constant a Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic A more precise definition • Let be a formula. Then x is true in D if at least one expression (x:=a) is true in D, and false otherwise. • A simple example: = P(x) P(x) is a formula, hence x P(x) is true in D if at least one expression of the form P(a) is true in D, and false otherwise. Michael Frank / Kees van Deemter
Topic #3 – Predicate Logic Similarly for • Let be a formula. Then the propositionx is true in D if every expression of the form (x:=a) is true in D, and false otherwise. • A simple example: = P(x) P(x) is a formula, hence x P(x) is true in D if every expression P(a) is true in D, and false otherwise. Michael Frank / Kees van Deemter
Predicate logic • A formula of FOPL is True (False) with respect to a model • Model = domain of objects plus specification of the “meanings” of the predicates, e.g., by • listing explicitly which objects the predicate is true of Michael Frank / Kees van Deemter
Interactions between quantifiers and connectives Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) Michael Frank / Kees van Deemter
I. Construct English paraphrases Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) Michael Frank / Kees van Deemter
I. Construct English paraphrases • x (Q(x) P(x)) Some places are free of charge and occupied • x (Q(x) P(x)) All places are free of charge and occupied • x (Q(x) P(x)) All places that are free of charge are occupied • x (Q(x) P(x)) For some places x, if x is free of charge then x is occupied Michael Frank / Kees van Deemter
II. Q3: Construct a model where 1 and 4 are true, while 2 and 3 are false Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) Michael Frank / Kees van Deemter
II. Construct a model where 1 and 4 are true, while 2 and 3 are false • x (Q(x) P(x)) (true for place a below) • x (Q(x) P(x)) (false for places b below) • x (Q(x) P(x)) (false for place b below) • x (Q(x) P(x)) (true for place a below) One solution: a model with exactly two objects in it. One object has the property Q and the property P; the other object has the property Q but not the property P. In a diagram: a: Q P b: Q not-P Michael Frank / Kees van Deemter
III. Q4: Construct a model where 1 and 3 and 4 are true, but 2 is false • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) Michael Frank / Kees van Deemter
III. Construct a model where 1 and 3 and 4 are true, but 2 is false • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) • x (Q(x) P(x)) Here is such a model (using a diagram). It has just two objects in its u.d., called a and b: a: Q P b: not-Q P Michael Frank / Kees van Deemter
Formally what is a model? • A model M is a pair <D,I> where D is a set (an u.d.), and I is a suitable ‘interpretation’ function. Informally speaking, a given M defines one way of giving a concrete ‘meaning’ to the symbols (other than ) in your formulas. • If a is an individual constant then I(a)D • If P is a 1-place predicate then I(P)D • If R is a 2-place predicate then I(P) is a set of pairs (,) such that D, and D Michael Frank / Kees van Deemter
An example of a model • Suppose M = (D,I) where D={John,Mary,Bill} and I(j)=John, I(m)=Mary, I(b)=Bill, I(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Note: John is a person (i.e., a part of the world)j is an individual constant (i.e., a part of the language of predicate logic).j“names”John. Michael Frank / Kees van Deemter
A specially defined relation: = • Some things can only be expressed in FOPL if we add a 2-place relation “=“ • We use infix notition: a=b instead of =(a,b) • Other 2-place relations do not have a fixed interpretation (think of the relation A on the previous page) • However, = is always interpreted as equality Michael Frank / Kees van Deemter
Formally (where M = <D,I>) atomic formulas Here is the start of the new truth definition: • 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). • A formula of the form = is true with respect to M iffI(a) = I(b) Michael Frank / Kees van Deemter
Formally (where M = <D,I>) formulas with propositional connectives • A formula of the form is true wrt M iff is false wrt M • 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 wrt M • A formula of the form is true wrt M iff is false wrt M or is true wrt M or both Michael Frank / Kees van Deemter
Formally (where M = <D,I>) quantified formulas • A formula of the form x is true wrt M iff at least one expression (x:=a) is true wrt M. (More precisely: there is an a such that ...) • A formula of the form x is true wrt M iff all expressions (x:=a) are true wrt M. (More precisely: for all a, ...) • (End of truth definition.) Michael Frank / Kees van Deemter
models: some illustrations • Suppose M= (D,I) , where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Michael Frank / Kees van Deemter
models: some illustrations • Suppose M=( D,I) , where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Yes Michael Frank / Kees van Deemter
models: some illustrations • Suppose M=(D,I), where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Yes • Is B(j)B(b)A(m,m) true wrt M? Michael Frank / Kees van Deemter
models: some illustrations • Suppose M=(D,I), where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Yes • Is B(j)B(b)A(m,m) true wrt M? No Michael Frank / Kees van Deemter
models: some illustrations • Suppose M=(D,I), where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Yes • Is B(j)B(b)A(m,m) true wrt M? No • Q5: Is x(B(x)A(x,m)) true wrt M? Michael Frank / Kees van Deemter
models: some illustrations • Suppose M=(D,I), where D={John,Mary,Bill}, andI(j)=John, I(m)=Mary, I(b)=Bill, andI(B)={John,Bill}I(G)={Mary}I(A)={(John,Mary),(Bill,Mary)} • Is B(j) true wrt M? Yes • Is B(j)B(b)A(m,m) true wrt M? No • Is x(B(x)A(x,m)) true wrt M? Yes Michael Frank / Kees van Deemter
models: some illustrations x(B(x)A(x,m)) true wrt M iff all expressions B(a) A(a,m) are true wrt M. These are the following: B(j) A(j,m) B(b) A(b,m) B(m) A(m,m) Michael Frank / Kees van Deemter