Predicate Calculus CS 270 Math Foundations of Computer Science Jeremy Johnson Presentation uses material from Huth and Ryan, Logic in Computer Science:

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

Section 1.3. More Logical Equivalences Constructing New Logical Equivalences We can show that two expressions are logically equivalent by developing.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
CSC 685 Logic Review. Logic: Modeling Human Reasoning syllogistic logic Syllogistic Logic (Aristotle). all/some X are/not Y Propositional Logic (Boole).
Predicate Calculus Formal Methods in Verification of Computer Systems Jeremy Johnson.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Discrete Mathematics Math 6A Instructor: M. Welling.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
Predicates and Quantifiers
CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science.
Chapter 1: The Foundations: Logic and Proofs
The Foundations: Logic and Proofs
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
1st-order Predicate Logic (FOL)
CS 103 Discrete Structures Lecture 05
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
CS344: Introduction to Artificial Intelligence Lecture: Herbrand’s Theorem Proving satisfiability of logic formulae using semantic trees (from Symbolic.
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 28– Interpretation; Herbrand Interpertation 30 th Sept, 2010.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Lecture 1.2: Equivalences, and Predicate Logic* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren, Zeph.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Predicates and Quantified Statements
CS6133 Software Specification and Verification
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
0 Propositional logic versus first-order (predicate) logic The universe of discourse Constants, variables, terms and valuations Predicates as generalized.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers.
Lecture 1.2: Equivalences, and Predicate Logic CS 250, Discrete Structures, Fall 2015 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph.
Proof by Contradiction CS 270 Math Foundations of CS Jeremy Johnson.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
An Introduction to Classical Logic (propositional and Predicate Logic)
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
English for Economic Informatics I Tomáš Foltýnek Theoretical Foundations of Informatics.
Lecture 1.2: Equivalences, and Predicate Logic
CSE15 Discrete Mathematics 01/23/17
Formal Modeling Concepts
The Propositional Calculus
Horn Clauses and Unification
Propositional Calculus: Boolean Functions and Expressions
Chapter 1 The Foundations: Logic and Proofs
The Foundations: Logic and Proofs
Propositional Calculus: Boolean Algebra and Simplification
CS201: Data Structures and Discrete Mathematics I
CS 1502 Formal Methods in Computer Science
CS 220: Discrete Structures and their Applications
CSE 311 Foundations of Computing I
Natural deduction Gerhard Gentzen.
CS 270 Math Foundations of CS
1st-order Predicate Logic (FOL)
Horn Clauses and Unification
Horn Clauses and Unification
MA/CSSE 474 More Math Review Theory of Computation
Horn Clauses and Unification
Computer Security: Art and Science, 2nd Edition
Horn Clauses and Unification
Predicates and Quantifiers
Encoding Knowledge with First Order Predicate Logic
The Foundations: Logic and Proofs
Encoding Knowledge with First Order Predicate Logic
CS201: Data Structures and Discrete Mathematics I
Lecture Notes for SWE 623 by Duminda Wijesekera
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
RESOLUTION.
Encoding Knowledge with First Order Predicate Logic
1st-order Predicate Logic (FOL)
Presentation transcript:

Predicate Calculus CS 270 Math Foundations of Computer Science Jeremy Johnson Presentation uses material from Huth and Ryan, Logic in Computer Science: Modelling and Reasoning about Systems, 2nd Edition

Outline 1.Motivation (program specification & derivation) 1.Variables, quantifiers and predicates 2.Syntax 1.Terms and formulas 2.Quantifiers, scope and substitution 3.Rules of natural deduction for quantifiers 4.Semantics 1.Models and semantic entailment 5.Undecidability and limitations

Hamiltonian Path G = (V,E) is an undirected graph with nodes V = {0,1,…,n-1} and edges E  V  V V = {0,1,2} E = {(0,1),(1,2)} edge(0,1), edge(1,0), edge(1,2), edge(2,1) 1 02

Hamiltonian Path A Hamiltonian path is a sequence of n nodes, where n = |V| where each node is visited exactly once (i.e. a permutation of the nodes) following edges  1  2 or 2  1  0

Hamiltonian Path path(i,j) is true when the jth node in the path is in the ith location Hamiltonian paths path(0,0), path(1,1), path(2,2) path(0,2), path(1,1), path(2,0) Not Hamiltonian paths path(0,0), path(1,2), path(2,1) path(0,0), path(0,1), path(1,1), path(2,2) path(0,0), path(1,1), path(1,0), path(2,2) 1 02

Hamiltonian Path Constraints Every node occurs exactly once in the path  j  i path(i,j)  j  i  k path(i,j)  path(k,j)  i = k Every location has exactly one node  i  j path(i,j)  i  j  k path(i,j)  path(i,k)  j = k Adjacent nodes must be connected by an edge  i  j  k (i<n-1)  (path(i,j)  path(i+1,k)  edge(j,k))

Simplification Every node occurs exactly once in the path  j  i  k path(i,j)  path(k,j)  i = k  j  i  k (i  k   (path(i,j)  path(k,j))  j  i  k (i  k)   path(i,j)   path(k,j)  j  i  k (i < k)   path(i,j)   path(k,j)

Simplification Adjacent nodes must be connected by an edge  i  j  k (i<n-1)  ((path(i,j)  path(i+1,k))  edge(j,k))  i  j  k (i<n-1)  (  edge(j,k)   (path(i,j)  path(i+1,k)))  i  j  k (i<n-1)  (  edge(j,k)  (  path(i,j)   path(i+1,k)))  i  j  k ((i<n-1) &  edge(j,k))  (  path(i,j)   path(i+1,k)))

Conversion to SAT  j  i path(i,j)  j=0..n-1  i=0..n-1 P ij  j  i  k (i < k)   path(i,j)   path(k,j)  j=0..n-1  i=0..n-1  k=i+1..n-1  P ij   P kj  i  j  k ((i<n-1) &  edge(j,k))  path(i,j)  path(i+1,k))  i=0..n-2  (j,k)  E  P ij   P i+1,k

Example 1 Every student is younger than some instructor  x ( S(x)   y(I(y)  Y(x,y) ) S(x) : x is a student I(x) : is an instructor Y(x,y) : x is younger than y

Example 2 Not all birds can fly   x ( B(x)  F(x) )  x ( (B(x)   F(x) ) B(x) : x is a bird F(x) : x can fly Semantically equivalent formulas

Example 3 Every child is younger than its mother  x  y ( C(x)  M(y,x)  Y(x,y) ) C(x) : x is child M(x,y) : x is y’s mother Y(x,y) : x is younger than y  x ( C(x)  Y(x,m(x)) m(x) : function for mother of x

Example 4 Andy and Paul have the same maternal grandmother  x  y  u  v ( M(x,y)  M(y,a)  M(u,v)  M(v,p)  x = u ) m(m(a)) = m(m(p)) a, b : variables for Andy and Paul = : binary predicate

Example 5 Everyone has a mother  x  y ( M(y,x) )  x  y ( M(y,x) ) [ not equivalent ] Everyone has exactly one mother  x  y ( M(y,x)   z (M(z,x)  z = y )

Example 6 Some people have more than one brother  x  y1  y2 ( B(y1,x)  B(y2,x)   (y1 = y2) )

Comparison to Propositional Calculus

Terms Terms are made up of variables, constants, and functions Term ::= Variable If c is a nullary function c is a term If t 1,…,t n are terms and f is an n-ary function then f(t 1,…,t n ) is a term

Formulas Formula ::= P is a predicate and t 1,…,t n are terms then P(t 1,…,t n ) is a formula If  is a formula  is a formula If  1 and  2 are formulas,  1   2,  1   2,  1   2 are formulas If  is a formula and x is a variable  x  and  x  are formulas

Parse Trees  x ( ( P(x)  Q(x) )  S(x,y) ) xx  S  xy P Q x x

Free and Bound Variables An occurrence of x in  is free if it is a leaf node in the parse tree for  with no quantifier as an ancestor xx  S  xy P Q x x xx  P Q x x    P x Q y

Substitution Given a variable x, a term t and a formula ,  [t/x] is the formula obtained by replacing each free occurrence of x by t xx  P Q x x   P x Q y  xx  P Q x x   P f Q y  x y  [f(x,y)/x]

Variable Capture t is free for x in  if no free x occurs in  in the scope of any quantifier for any variable y occurring in t. yy  S x  P Q x y

Variable Capture t is free for x in  if no free x occurs in  in the scope of any quantifier for any variable y occurring in t. yy  S x  P Q y f y y

Equality Rules Introduction Rule Elimination Rule = i t = t t 1 = t 2  [t 1 /x] =e  [t 2 /x]

Equivalence Relation 1premise 2=i 3=e 1,2 1premise 2 3=e 2,1

Conjunction Rules Introduction Rule Elimination Rule    i     e1      e2 

Universal Quantification Rules Introduction Rule Elimination Rule  x i  x   x e  [t/x] x 0 …  [x 0 /x]

Illegal Substitution Leads to False Reasoning  x   =  y (x < y)  [y/x] =  y (y < y) y is not free for x in 

Example Proof 1premise 2 3 x 0 P(x 0 )  Q(x 0 ) 4P(x 0 ) 5Q(x 0 )  e3,4 6

Disjunction Rules Introduction Rule Elimination Rule (proof by case analysis)   i1     e    i2    …… ……

Existential Quantification Rules Introduction Rule Elimination Rule (proof by case analysis)  [t/x]  x i  x   e  x 0  [x 0 /x] … 

Example Proof 1premise 2 3 x 0 P(x 0 )  Q(x 0 ) assumption 4 5Q(x 0 )  e P(x 0 )  e P(x 0 )  R(x 0 )  i7,6 9 10

Quantifier Equivalences

De Morgan’s Law 1premise 2assumption 3 4  i  e4,2 6  e 3-5 7assumption 8  i  e  e 2-12

Generalized De Morgan’s Law 1  x P(x) premise 2assumption 3x0x  e  x  P(x)  e 2-9

Generalized De Morgan’s Law 1  x  premise 2assumption 3x0x  e  x  e 2-9

Exercise

Models Let F be a set of functions and P a set of predicates. A model M for (F,P) consists of A non-empty set A [universe] of concrete values For each nullary f  F an element of A = f M For each n-ary f  F a function f M : A n  A For each n-ary P  P a subset P M  A n

Example 1 F = {i} and P = {R,F} i a constant function, R binary and F unary predicates Model – A set of states, initial state i, state transitions R, final states F A = {a,b,c} i M = a R M = {(a,a),(a,b),(a,c),(b,c), (c,c)} F M = {b,c}

Example 1  y R(i,y)  F(i)  x  y  z (R(x,y)  R(x,z)  y = z )  x  y R(x,y)

Example 2 F = {e,  } and P = {  } e a constant function,  a binary function,  a binary predicate Model – string prefix A = {binary strings} e M = ,  M concatenation,  M prefix ordering [011 is a prefix of

Example 2  x ((x  x  e)  x  e  x))  x  y (y  x)  y  x (y  x)  x  y  z ((x  y)  (y  z)  (x  z))  x  y  z ((x  y)  (x  z  y  z))

Satisfaction

Semantic Entailment

Soundness and Completeness

Post Correspondence Given a finite sequence (s 1,t 1 ),…,(s k,t k ) of pairs of binary strings. Is there a sequence of indices i 1,i 2,…,i n such that s i 1  s i n = t i 1  t i n Example s 1 = 1, s 2 = 10, s 3 = 011 t 1 = 101, t 2 = 00, t 3 = 11 Solution (1,3,2,3)

Undecidability

Consequences of Undecidability

Proof

Reachabilty When modeling systems via states and state transitions, we want to show that a “bad” state can not be reached from a “good” state. Given nodes n and n’ in a directed graph, is there a finite path of transitions from n to n’. s0 s1 s3 s2 A = {s0,s1,s2,s3} R M = {(s0,s1), (s1,s0), (s1,s1),(s1,s2), (s2,s0),(s3,s0),(s3,s2)}

Compactness Theorem Let  be a set of sentences of predicate calculus. If all finite subsets of  are satisfiable, then so is . Proof – uses soundness and completeness and finite length of proofs.

Reachability is Not Expressible Can reachability be expressed in predicate calculus? u=v   x (R(u,x)  R(x,v))   x 1  x 2 (R(u,x 1 )  R(x 1,x 2 )  R(x 2,v))  … This is infinite The answer is no! Proof follows from compactness theorem.

Reachability is Not Expressible Theorem. There is no predicate-logic formula  with u and v as its only free variables and R its only predicate such that  holds in directed graphs iff there is a path from u to v. Proof. By contradiction. Suppose there is such a formula. Let  n be the formula expressing that there is a path from c to c’  n =  x 1 …  x n-1 (R(c,x 1 )  …  R(x n-1,c)).

Reachability is Not Expressible Proof. By contradiction. Suppose there is such a formula . Let  n be the formula expressing that there is a path from c to c’  n =  x 1 …  x n-1 (R(c,x 1 )  …  R(x n-1,c)).  = {   i | I  0}   [c/u][c’/v] is unsatisfiable, but any finite subset is satisfiable. By compactness this leads to a contradiction and hence there is no such .

Reachability via HOL

Obtain formula for the existence of a path from u to v by negating previous formula (use DeMorgan’s law)  P  x  y  z (  C 1   C 2   C 3   C 4 ) If both  and  can range over predicates then second order logic.