0% found this document useful (0 votes)
6 views59 pages

CS 228: Logic in Computer Science: Krishna. S

Uploaded by

Dhruv Gattani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views59 pages

CS 228: Logic in Computer Science: Krishna. S

Uploaded by

Dhruv Gattani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

CS 228 : Logic in Computer Science

Krishna. S

1/16
Recap

◮ Signature τ : set containing relations and constants

2/16
Recap

◮ Signature τ : set containing relations and constants


◮ Each relation in τ has an arity

2/16
Recap

◮ Signature τ : set containing relations and constants


◮ Each relation in τ has an arity
◮ A FO formula is written over some signature τ ; that is, it uses the
relations and constants from τ . It also uses variables denoted xi ,
boolean connectives and quantifiers ∀, ∃.

2/16
Recap

◮ Signature τ : set containing relations and constants


◮ Each relation in τ has an arity
◮ A FO formula is written over some signature τ ; that is, it uses the
relations and constants from τ . It also uses variables denoted xi ,
boolean connectives and quantifiers ∀, ∃.
◮ A relation R of arity k is used in the formula as R(t1 , . . . , tk )
where ti ’s are variables or constants

2/16
Recap

◮ Signature τ : set containing relations and constants


◮ Each relation in τ has an arity
◮ A FO formula is written over some signature τ ; that is, it uses the
relations and constants from τ . It also uses variables denoted xi ,
boolean connectives and quantifiers ∀, ∃.
◮ A relation R of arity k is used in the formula as R(t1 , . . . , tk )
where ti ’s are variables or constants
◮ Equality t1 = t2 is available irrespective of τ

2/16
Recap

◮ Signature τ : set containing relations and constants


◮ Each relation in τ has an arity
◮ A FO formula is written over some signature τ ; that is, it uses the
relations and constants from τ . It also uses variables denoted xi ,
boolean connectives and quantifiers ∀, ∃.
◮ A relation R of arity k is used in the formula as R(t1 , . . . , tk )
where ti ’s are variables or constants
◮ Equality t1 = t2 is available irrespective of τ
◮ To make sense out of a formula, we need structures

2/16
Recap

◮ A structure of signature τ consists of a universe, and assigns


meanings to all the entities of τ

3/16
Recap

◮ A structure of signature τ consists of a universe, and assigns


meanings to all the entities of τ
◮ So, if R is a k -ary relational symbol of τ , the structure specifies
which k -tuples of elements from the universe are legitimate
relations for R
◮ If c is a constant in τ , the structure also maps c to some fixed
element of the universe

3/16
Recap

◮ A structure of signature τ consists of a universe, and assigns


meanings to all the entities of τ
◮ So, if R is a k -ary relational symbol of τ , the structure specifies
which k -tuples of elements from the universe are legitimate
relations for R
◮ If c is a constant in τ , the structure also maps c to some fixed
element of the universe
◮ So, structures of τ give life to τ

3/16
Recap

◮ A structure of signature τ consists of a universe, and assigns


meanings to all the entities of τ
◮ So, if R is a k -ary relational symbol of τ , the structure specifies
which k -tuples of elements from the universe are legitimate
relations for R
◮ If c is a constant in τ , the structure also maps c to some fixed
element of the universe
◮ So, structures of τ give life to τ
◮ Structures also tell you the set of values your variables xi can
assume : these are the elements from the universe

3/16
Recap

◮ A structure of signature τ consists of a universe, and assigns


meanings to all the entities of τ
◮ So, if R is a k -ary relational symbol of τ , the structure specifies
which k -tuples of elements from the universe are legitimate
relations for R
◮ If c is a constant in τ , the structure also maps c to some fixed
element of the universe
◮ So, structures of τ give life to τ
◮ Structures also tell you the set of values your variables xi can
assume : these are the elements from the universe
◮ A structure in PL will just consist of the universe {0, 1}, since
there is no signature. All variables assume values from this
Boolean universe.

3/16
Satisfiability in PL and FO

◮ The satisfiability of a PL formula depends on the existence of an


assignment satisfying it; likewise, the satisfiability of a FO
formula ϕ over signature τ depends on the existence of a
structure A of τ such that ϕ is true on A.

4/16
Free and Bound Variables

◮ For a wff ϕ = ∀x ψ, ψ is said to be the scope of the quantifier x

5/16
Free and Bound Variables

◮ For a wff ϕ = ∀x ψ, ψ is said to be the scope of the quantifier x


◮ Every occurrence of x in ∀x ψ is bound
◮ Any occurrence of x which is not bound is called free

5/16
Free and Bound Variables

◮ For a wff ϕ = ∀x ψ, ψ is said to be the scope of the quantifier x


◮ Every occurrence of x in ∀x ψ is bound
◮ Any occurrence of x which is not bound is called free
◮ ϕ = P(x , y ) → ∀x ((∀yR(x , y )) → Q(x , y ))
◮ y is free in Q(x, y ) and bound in R(x, y ),
◮ x is free in P(x, y ), and bound in Q(x, y ), R(x, y )

5/16
Free and Bound Variables

◮ For a wff ϕ = ∀x ψ, ψ is said to be the scope of the quantifier x


◮ Every occurrence of x in ∀x ψ is bound
◮ Any occurrence of x which is not bound is called free
◮ ϕ = P(x , y ) → ∀x ((∀yR(x , y )) → Q(x , y ))
◮ y is free in Q(x, y ) and bound in R(x, y ),
◮ x is free in P(x, y ), and bound in Q(x, y ), R(x, y )
◮ Given ϕ, denote by ϕ(x1 , . . . , xn ), that x1 , . . . , xn are the free
variables of ϕ, also free(ϕ)
◮ A sentence is a formula ϕ none of whose variables are free

5/16
P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))


P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

P ∀x
P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

P ∀x

x y

P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

P ∀x

x y

∀y Q
P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

P ∀x

x y

∀y Q

x y
R
P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

P ∀x

x y

∀y Q

x y
R

x y

6/16
P(x, y) → ∀x((∀yR(x, y)) → Q(x, y))

ϕ(s, t) = P(s, t) → ∀x ((∀yR(x , y )) → Q(x , t))


P ∀x

s t

∀y Q

x t
R

x y

7/16
∀x(R(x, y) → ∀yP(y))

∀x
∀x(R(x, y) → ∀yP(y))

∀x


∀x(R(x, y) → ∀yP(y))

∀x

R ∀y
∀x(R(x, y) → ∀yP(y))

∀x

R ∀y

x y P
∀x(R(x, y) → ∀yP(y))

∀x

R ∀y

x y P

y
∀x(R(x, y) → ∀yP(y))

∀x

R ∀y

x y P

8/16
∀x(R(x, y) → ∀yP(y))

∀x

R ∀y

x t P

ϕ(t) = ∀x (R(x , t) → ∀yP(y ))

9/16
Assignments on τ -structures

Assignments
For a τ -structure A, an assignment over A is a function α : V → u(A)
that assigns every variable x ∈ V a value α(x ) ∈ u(A). If t is a
constant symbol c, then α(t) is c A

10/16
Assignments on τ -structures

Assignments
For a τ -structure A, an assignment over A is a function α : V → u(A)
that assigns every variable x ∈ V a value α(x ) ∈ u(A). If t is a
constant symbol c, then α(t) is c A

Binding on a Variable
 α over A, α[x 7→ a] is the assignment
For an assignment
α(y ), y 6= x ,
α[x 7→ a](y ) =
a, y = x

10/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥
◮ A |=α t1 = t2 iff α(t1 ) = α(t2 )

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥
◮ A |=α t1 = t2 iff α(t1 ) = α(t2 )
◮ A |=α R(t1 , . . . , tk ) iff (α(t1 ), . . . , α(tk )) ∈ R A

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥
◮ A |=α t1 = t2 iff α(t1 ) = α(t2 )
◮ A |=α R(t1 , . . . , tk ) iff (α(t1 ), . . . , α(tk )) ∈ R A
◮ A |=α (ϕ → ψ) iff A 2α ϕ or A |=α ψ

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥
◮ A |=α t1 = t2 iff α(t1 ) = α(t2 )
◮ A |=α R(t1 , . . . , tk ) iff (α(t1 ), . . . , α(tk )) ∈ R A
◮ A |=α (ϕ → ψ) iff A 2α ϕ or A |=α ψ
◮ A |=α (∀x )ϕ iff for every a ∈ u(A), A |=α[x7→a] ϕ

11/16
Satisfaction

We define the relation A |=α ϕ (read as ϕ is true in A under the


assignment α) inductively:
◮ A 2α ⊥
◮ A |=α t1 = t2 iff α(t1 ) = α(t2 )
◮ A |=α R(t1 , . . . , tk ) iff (α(t1 ), . . . , α(tk )) ∈ R A
◮ A |=α (ϕ → ψ) iff A 2α ϕ or A |=α ψ
◮ A |=α (∀x )ϕ iff for every a ∈ u(A), A |=α[x7→a] ϕ
◮ A |=α (∃x )ϕ iff there is some a ∈ u(A), A |=α[x7→a] ϕ
Last two cases, α has no effect on the value of x . Thus, assignments
matter only to free variables.

11/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))

12/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))
◮ There is an assignment α which satisfies
G |=α ∃x(E(x, y ) ∧ E(x, z) ∧ y 6= z)

12/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))
◮ There is an assignment α which satisfies
G |=α ∃x(E(x, y ) ∧ E(x, z) ∧ y 6= z)
◮ G 2 ∃x∀yE(x, y ), G |= ∀x∃yE(x, y )
◮ W = abaaa

12/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))
◮ There is an assignment α which satisfies
G |=α ∃x(E(x, y ) ∧ E(x, z) ∧ y 6= z)
◮ G 2 ∃x∀yE(x, y ), G |= ∀x∃yE(x, y )
◮ W = abaaa
◮ There is an assignment α for which
W |=α (Qa (x) ∧ Qa (y ) ∧ S(x, y ))

12/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))
◮ There is an assignment α which satisfies
G |=α ∃x(E(x, y ) ∧ E(x, z) ∧ y 6= z)
◮ G 2 ∃x∀yE(x, y ), G |= ∀x∃yE(x, y )
◮ W = abaaa
◮ There is an assignment α for which
W |=α (Qa (x) ∧ Qa (y ) ∧ S(x, y ))
◮ There is no assignment α which satisfies
∃x∃y (Qb (x) ∧ Qb (y ) ∧ x 6= y )

12/16
Example of Satisfaction

◮ G = ({1, 2, 3}, E G = {(1, 2), (2, 1), (2, 3), (3, 2)})
◮ For any assignment α, G |=α ∀x∀y (E(x, y ) → E(y , x)) iff for every
a, b ∈ {1, 2, 3}, G |=α[x 7→a,y 7→b] (E(x, y ) → E(y , x))
◮ There is an assignment α which satisfies
G |=α ∃x(E(x, y ) ∧ E(x, z) ∧ y 6= z)
◮ G 2 ∃x∀yE(x, y ), G |= ∀x∃yE(x, y )
◮ W = abaaa
◮ There is an assignment α for which
W |=α (Qa (x) ∧ Qa (y ) ∧ S(x, y ))
◮ There is no assignment α which satisfies
∃x∃y (Qb (x) ∧ Qb (y ) ∧ x 6= y )
◮ Prove or disprove : W |= ∃x∀y [Qb (x) ∧ x < y ∧ Qa (y )]
◮ Prove or disprove : W |= ∃x∀y [Qb (x) ∧ x < y ⇒ Qa (y )]

12/16
Satisfiability, Validity and
Equivalence

◮ A formula ϕ over a signature τ is said to be satisfiable iff for


some τ -structure A and assignment α, A |=α ϕ

13/16
Satisfiability, Validity and
Equivalence

◮ A formula ϕ over a signature τ is said to be satisfiable iff for


some τ -structure A and assignment α, A |=α ϕ
◮ A formula ϕ over a signature τ is said to be valid iff for every
τ -structure A and assignment α, A |=α ϕ

13/16
Satisfiability, Validity and
Equivalence

◮ A formula ϕ over a signature τ is said to be satisfiable iff for


some τ -structure A and assignment α, A |=α ϕ
◮ A formula ϕ over a signature τ is said to be valid iff for every
τ -structure A and assignment α, A |=α ϕ
◮ Formulae ϕ(x1 , . . . , xn ) and ψ(x1 , . . . , xn ) are equivalent denoted
ϕ ≡ ψ iff for every A and α, A |=α ϕ iff A |=α ψ

13/16
Satisfiability, Validity and
Equivalence

◮ A formula ϕ over a signature τ is said to be satisfiable iff for


some τ -structure A and assignment α, A |=α ϕ
◮ A formula ϕ over a signature τ is said to be valid iff for every
τ -structure A and assignment α, A |=α ϕ
◮ Formulae ϕ(x1 , . . . , xn ) and ψ(x1 , . . . , xn ) are equivalent denoted
ϕ ≡ ψ iff for every A and α, A |=α ϕ iff A |=α ψ
◮ Recap ϕ1 (x ) = ∀yR(x , y ) and ϕ2 = ∃x ∀yR(x , y ).
◮ It is clear that whenever ϕ2 is satisfiable on A, one can find an
assignment α such that A |=α ϕ1 (x ).
◮ Likewise, if A |=α ϕ1 (x ), then A |= ϕ2 .
◮ Thus, ϕ1 (x ), ϕ2 agree on satisfiability.

13/16
True or False?

For a formula ϕ and assignments α1 and α2 such that for every


x ∈ free(ϕ), α1 (x ) = α2 (x ), A |=α1 ϕ iff A |=α2 ϕ

14/16
True or False?

For a formula ϕ and assignments α1 and α2 such that for every


x ∈ free(ϕ), α1 (x ) = α2 (x ), A |=α1 ϕ iff A |=α2 ϕ

◮ For example, ϕ(y ) = ∀x (R(x , y ) → ∀zP(z))

14/16
True or False?

For a formula ϕ and assignments α1 and α2 such that for every


x ∈ free(ϕ), α1 (x ) = α2 (x ), A |=α1 ϕ iff A |=α2 ϕ

◮ For example, ϕ(y ) = ∀x (R(x , y ) → ∀zP(z))


◮ Consider two assignments α1 , α2 such that
α1 (y ) = α2 (y ) = α(say )

14/16
True or False?

For a formula ϕ and assignments α1 and α2 such that for every


x ∈ free(ϕ), α1 (x ) = α2 (x ), A |=α1 ϕ iff A |=α2 ϕ

◮ For example, ϕ(y ) = ∀x (R(x , y ) → ∀zP(z))


◮ Consider two assignments α1 , α2 such that
α1 (y ) = α2 (y ) = α(say )
◮ Evaluate for all a, b ∈ u(A), R(a, α) → P(b)

14/16
True or False?

For a formula ϕ and assignments α1 and α2 such that for every


x ∈ free(ϕ), α1 (x ) = α2 (x ), A |=α1 ϕ iff A |=α2 ϕ

◮ For example, ϕ(y ) = ∀x (R(x , y ) → ∀zP(z))


◮ Consider two assignments α1 , α2 such that
α1 (y ) = α2 (y ) = α(say )
◮ Evaluate for all a, b ∈ u(A), R(a, α) → P(b)
◮ A |=α1 ϕ iff A |=α2 ϕ

14/16
True or False?

For a sentence ϕ, and any two assignments α1 and α2 , A |=α1 ϕ iff


A |=α2 ϕ

15/16
True or False?

For a sentence ϕ, and any two assignments α1 and α2 , A |=α1 ϕ iff


A |=α2 ϕ

No free variables!

15/16
Check SAT

◮ ϕ = ∃x [(∀yE(x , y )) ∧ ∀z[(∀yE(z, y )) → z = x ]]. Does ϕ evaluate


to true under some graph structure?

16/16
Check SAT

◮ ϕ = ∃x [(∀yE(x , y )) ∧ ∀z[(∀yE(z, y )) → z = x ]]. Does ϕ evaluate


to true under some graph structure?
◮ ψ = ∃x [Qa (x ) ∧ ∀y [(y < x ∧ Qb (y )) → (z < x ∧ y < z ∧ Qa (z))]].
Does ψ evaluate to true under some word structure?

16/16

You might also like