Docsity

02A - Logic Notes - G, Lecture notes of Computer science

Toggle sidebar
bg1
Axiomatic Systems & Logic
֜
P, P
o
Q
Q
Slides by
Venkatesan
Guruswami
In mathematics, sometimes your intuition
can be quite wrong.
Here’s a
theorem
(called
Banach -Tarski paradox):
A solid ball in 3-dimensions can be cut up into
6 non-overlapping pieces, so that these pieces
can be moved around & assembled into two
identical copies of the original ball.
So it is important to:
Formalize concepts, give precise definitions
Make implicit assumptions explicit
Write careful proofs, where every step can
be checked carefully.
Even “mechanically”
using a “computing machine”, if you will
Part 1: Axiomatic systems.
Part 2: Propositional logic.
Part 3: First order logic. (just some basics)
This week, we will talk a bit about
formal logical reasoning and proofs.
TODAY
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download 02A - Logic Notes - G and more Lecture notes Computer science in PDF only on Docsity!

Axiomatic Systems & Logic

P, P^ o^ Q Q ֜

Slides byVenkatesanGuruswami In mathematics, sometimes your intuitioncan be quite wrong.Here’s atheorem (calledBanach -Tarski paradox):A solid ball in 3-dimensions can be cut up into6 non-overlapping pieces, so that these piecescan be moved around & assembled into twoidentical copies of the original ball.

So it is important to:Formalize concepts, give precise definitionsMake implicit assumptions explicitWrite careful proofs, where every step canbe checked carefully.Even “mechanically”using a “computing machine”, if you will Part 1: Axiomatic systems.Part 2: Propositional logic.Part 3: First order logic.

(just some basics)

This week, we will talk a bit aboutformal logical reasoning and proofs.

TODAY

AXIOMATIC SYSTEMS

example

An ATM has $2 bills and $5 billsWhat dollar amounts can it dispense?^25 7 = 2+54 = 2+210 = 5+56 = 4+28 = 6+210 = 8+212 = 10+2 …all even amounts

9 = 4+511 = 6+513 = 8+515 = 10+5 …any odd amount at least 5 Cannot^ make 1 or 3 ׵ All m in N except 0, 1, 3.

This is an example of an axiomatic system. “If you can make x and y, you can make x+y

“deduction rule”.” The quantities you can make:

“theorems”x is a “theorem”֞^ x ≠ 0,1, Initial amounts (2 & 5):

“axioms” In^ this^ axiomatic system:

Claim:^ ()))^ is NOT a theorem. Claim: Any theorem has equally many

(^ and^ ) Proof sketch:^ True for the axiom.WRAP:^ If S has equally many, so does

( S )

Follows from:^ CONCAT: If S, T have equal, so does ST Formal proof:^ structural induction(or strong induction on # of steps in deduction)For k^ ≥^ 1, let Fbe the statement “any theorem derived in exactly k lines has equally manyk^

( , ) ”.

The base case is k = 1. Fis true because a 1-line deduction must be an axiom, and the only axiom,^1

() , has

equally many^ ( , ). For general k > 1, let us suppose that F

is true for all 1^ ≤^ i < k. For the induction step, we must show that Fi^

k

is true.So suppose W is a theorem derived at the end of a k-line deduction.The final line of this deduction (which derives W) is an axiom

OR^ an application of WRAP to some previous line j < k^ OR^ an application of CONCAT to some two previous lines j

, j< k. We verify that W has equally 12 many^ ( , )^ in all three cases.th^ In case the k^ line is an axiom, W must be

() , which has equally many^ ( ,

). th^ In case the k line is WRAP applied to line j < k, we have W =

( S ) , where S is the theorem on line j. Since F

j

is true by assumption, S has the same number of

( , )^ —^ say c each.^ Then W has c+1 many

(^ and c+1 many^ ) ,

an equal number.th^ In case the k^ line is CONCAT applied to lines j

, j^ < k, we have W = TTwhere T 12 12

is the theorem on line j^1 and Tis the theorem on line j^2

. Since Fis true by assumption, T 2 j^

has the same number of^ ( , )^ 1

—^ say d^1

each. Similarly Thas the same number of^2

( , )^ —^ say deach. Hence W has d^2

+dmany^ (^ and d+dmany^12 ) ,

an equal number.In each of the three cases we have shown W has an equal number of

( , ). Thus Fis indeed true. Thek^ Exercise: Write a formal proof using structural induction.For comparison, here is a proof by strong induction:induction is complete.

soundness & completeness Next to “what stuff we can produce” (the “theorems”),there is also “what stuff we desire” (the “true stuff”). Two questions then arise: • Soundness: Is all produced stuff desirable? • Completeness: Is all desirable stuff produced? Then, this axiomatic system is

sound , namely:

-^ All theorems are true.But is it also^ “complete”

, namely

In our example: Suppose the^ •^ Are^ all^ “true” strings also theorems?

true stuff^ is: “all strings with an equal

numbers of ( and

Answer: No.^ ---For example, consider: ())(

Claim:^ a string of

( , )^ is a theorem in this system^ if and only if it’s a sequence of “balanced parentheses

Proof: Exercise

(or ask one of the course staff) That is, this axiomatic system is

sound & complete

for the truth concept:

“The^ parens^ are balanced”^ summary

-^ Vocabulary^ Axiomatic systems: summary(or Universe)^ (numbers, strings, tiles, graphs, …) Elements called^ expressions. -^ Axioms: initial set of expressions. •^ Deduction rules: rules for obtaining new

expressions from old ones.

-^ Theorem: an obtainable expression. •^ Typical problems: Show X is a theorem.Show Y is not a theorem. Is the system sound/complete for some “truth” concept?^ “Characterize” the set of all theorems.^ PROPOSITIONAL LOGIC

(Zero-Order Logic)

Propositional formulaeFormally, propositional formulae are definedby an axiomatic system!

from A,^ can obtain ¬Afrom A, B^ can obtain (A

רB)(AשB)(A→B) (A↔B)

axioms:^ deduction rules:

x^ , x^ , x^ , …^1 2 Definition:^ A formula is a

p ropositional formula (aka “well-formed” formula (WFF)) if and only if^ it is a

‘theorem’ in this system. meaning

The “meaning” of these connectives(A š^ B)^ “A and B”also as: (A & B)^

(A V B)^ “A or B” true if both A and Bare true^ ™ A^ “not A”

true if at least one ofA and B is true A^ B^ A^ š^ B T^ T^ T T^ F^ F F^ T^ F F^ F^ F true if A is false

A^ B^ A^ ›^ B T^ T^ T T^ F^ T F^ T^ T F^ F^ F A ™A T F F T

The “meaning” of these connectives(A o^ B)^ “if A then B”what are the rules for this?(A l B)^ “A if and only if B”

A^ B^ AoB T^ T^ T T^ F^ F^ F^ T^ T F^ F^ T “A implies B” same as (A o B) and (B o

A^ A)

B^ AlB T T^ T T F^ F F T^ F F F^ T Equivalent to ( ™

A V B)

truth “If potassium is observed then

carbon and hydrogen are also observed.”

(k→(cרh)) Q: Is this statement true? A: Depends. The question is ill specified.

Whether this statement/formula is true/falsedepends on whether the variables are true/false^ (“state of the world”). If k =^ T , c =^ T , h =^

F …^ … the formula

is^ False.

“If potassium is observed thencarbon and hydrogen are also observed.”(k→(

cרh)) If k =^ F , c =^ F , h =

T …^ … the formula

is^ True.

Truth assignment

α: assigns T or F^ to each variable

Extends to give a truth value

α^ [S] for any formula S by (recursively) applying these rules:A^ B^

¬A^ (AרB)^ (A

שB)^ (A→B)^ (A↔B) F^ F^

T^ F^

F^ T^

T

F^ T^

T^ F^

T^ T^

F

T^ F^

F^ F^

T^ F^

F

T^ T^

F^ T^

T^ T^

T

Valid:^ automatically true,

for ‘purely logical’ reasons

Unsatisfiable: automatically false,

for purely logical reasons

Satisfiable^ (but not valid)

: truth value dependson the state of the world

Example: S = (p

&^ (p^ o^ q))^ o^

q p^ q^ p^ o

q^ p^ &^ (p^ o^ q))^

(p^ &^ (p^ oq))^ oq T^ T T^ F F^ T F^ F

Truth table

p^ q^ p^ o

q^ p^ &^ (p^ o^ q))^

(p^ &^ (p^ o^ q))^ o^ q T^ T^

T^ T^

T T^ F^

F^ F^

T F^ T^

T^ F^

T F^ F^

T^ F^

T

Truth table Formula S is^ valid

Example: S = (p

&^ (p^ o^ q))^ o^

q

S = ((x→(y→z))↔((

xרy)→z)) Truth table x^ y^ z^

((x→(y→z))↔((x ר

y)→z)) F^ F^ F F^ F^ T F^ T^ F F^ T^ T T^ F^ F T^ F^ T T^ T^ F T^ T^ T

S is^ satisfiable

T!

S = ((x→(y→z))↔((

xרy)→z)) Truth table

x^ y^ z^

((x→(y→z))↔((x ר

y)→z)) F^ F^ F^

T F^ F^ T^

T F^ T^ F^

T F^ T^ T^

T T^ F^ F^

T T^ F^ T^

T T^ T^ F^

T T^ T^ T^

T S is valid! Deciding Satisfiability (or Validity)Truth table method:Pro:^ Always works Con: If S has n variables, takes ≈

n^2 time

Conjecture: (stronger than P

z^ NP)

But for a^ given^

formula, sometimes you canprove/disprove satisfiability cleverly. There is^ no^ O(1.

n^ ) time algorithm that works for every formula.

recap Quick recap

propositional formulasn-variable formula maps eachpossible “world” in {T,F}

n^ into either T or F Some formulas are “truths” (tautologies):they are true in all possible 2

n^ worlds Can check if a formula is a tautology in ~

n^ time

by truth table method.

Proof of new expansion ruleA

(hypothesis) B^ V^ A^

(expansion rule) A^ V^ B^

A A V^ B (commutativity)

Proof of “modus ponens”

A, A^ o^ B B A^

(hypothesis) A^ o^ B^

(hypothesis) ™ A^ V^ B^

(def. of^ o ) A^ V^ B^

(apply expansion to 1) B^ V^ B^

(cut rule to 2,3) B^

(contraction) Since the logical system does not have “

o ” we define it to be^ ™

A^ V^ B

(1) (2) (3)

What is a proof?A sequence of statements,each of whichis an axiom,or a hypothesis,or follows from previous statementsusing an inference ruleRecap: A logical Systemfor PropositionsAxiom: Inference Rules:A V (B V^ C)A^ V (A V B) V^ C

A A

A B V^ A ( ™ A^ V^ A) (A^ V^ B), ( ™ A^ V^ C)(B^ V^ C) associativity

contraction

expansion cut rule

(well-formed) propositional formulassome formulas are“theorems”p V^ ™^ p (p & (p^ o^ q))^ o^ q these are formulasfor which wecan give proofs

some formulas aretautologies (“truths”)p^ V^ ™^ p (p^ &^ (p^ o^ q))

o^ q can check bytruth-table Are all theorems “true” (i.e., tautologies)?Are all tautologies theorems?

Yes. (easy proof by induction)Yes. (proof lot more involved) For this logical system and propositional formulasYay! Our logical system is “sound”.We only prove truths.Double yay! Our logical system is “complete”.We can prove all the truths via inference rules.

This logical system issoundand completefor propositional truths (tautologies)

“all theorems are true”“all truths are theorems” proving tautologies by hand

FIRST-ORDER LOGICA model for

pretty much all mathematical reasoning “Not, And, Or, Implies, If And Only If” Plus: Quantifiers: For All (

׊), There Exists (

Equals (=) “constants”, “relations”, “functions”^ Variables like x now represent^ objects , not truth-values.

“Ben is taller than everyone”:^ ׊x IsTaller(

Ben ,x) relation name

constant name : stands for a mapping,objects հ T / F variable : stands for anobject (person): stands for aparticular object “Ben is taller than everyone”:^ ׊x IsTaller(

Ben ,x) “Ben is taller than everyone else”:^ ׊x (¬(x= Ben

)→^ IsTaller( Ben

,x)) th (^0) equality (of objects) order logic , as usual

“Ben’s dad is taller than everyone else’s dad”:^ ׊x (¬(x= Ben

)→^ IsTaller(Father(

Ben ),Father(x))) function name

: stands for a mapping,objects հ object “Ben is taller than everyone”:^ ׊x IsTaller(

Ben ,x) “Ben is taller than everyone else”:^ ׊x (¬(x= Ben

)→^ IsTaller( Ben

,x) Vocabulary:^ A collection of constant-names,

function-names,relation-names. Vocabulary from the previous slide:one constant-name:

Ben one function-name:

Father( ∙ ) one relation-name:

IsTaller( ∙ ,^ ∙

Vocabulary:^ A collection of constant-names,

function-names,relation-names. Another example of a vocabulary:^ one constant-name: Example “sentences”:

a two function-names:

Next( ∙ ),^ Combine(

∙ ,^ ∙ )

one relation-name:

IsPrior( ∙ ,^ ∙ ) ׌x (Next(x)= a ) ׊x^ ׊y (IsPrior(x,Combine(

a ,y)) → (Next(x)=y)) (׊x IsPrior(x,Next

(x))) → (Next( a

)=Next( a ))

Let’s talk about

TRUTH.

׌x (Next(x)=Combine(

a , a ))

Interpretation #2:^ •^ Universe =

natural numbers • a = 0 • Next(x) = x+1 • Combine(x,y) = x+y • IsPrior(x,y) =^ True^ iff x < yFor this interpretation, the sentence is…^

…False

Satisfiability / ValidityInterpretation^ ,^ satisfies sentence S: , [S] =^ T S is satisfiable:there exists^ ,^ such that

,^ [S] =^ T

S is unsatisfiable:^ ,^ [S] =^ F^ for all

S is^ valid :^ ,^ [S] =^ T^ for all

All sentences in a given vocabulary^ unsatisfiable satisfiable ׌x ¬(Next(x)=Next(x))^ ׌x (Next(x)=Combine(valid

a , a )) (׊x(x= a ))→(Next(

a )= a )

Valid:^ automatically true,

for ‘purely logical’ reasons

Unsatisfiable: automatically false,

for purely logical reasons

Satisfiable^ (but not valid)

: truth value dependson the interpretationof the vocabulary

(׌y^ ׊x (x=Next(y))) → ( Problem 1:^ Show this is satisfiable.

׊w^ ׊z (w=z)) Now (׌y^ ׊x (x=Next(y))) means^ “there’s an integer y such^ that every integer = y+

Let’s pick this interpretation: Universe = integers,

Next(y) = y+1. That’s False! So the whole sentence becomes

True. Hence the sentence

is satisfiable. (׌y^ ׊x (x=Next(y))) → ( Problem 2:^ Is it valid?

׊w^ ׊z (w=z)) There is no “truth table method”.You can’t enumerate all possible interpretations! You have to use some cleverness.

(׌y^ ׊x (x=Next(y))) → ( Problem 2:^ Is it valid?

׊w^ ׊z (w=z))

Solution:^ Yes, it

is valid! Proof:^ Let^ ,^

be any interpretation.If , [׌y^ ׊x (x=Next(y))] =

F ,

then the sentence is

True. If^ ,^ [׌y^ ׊x (x=Next(y))] =

T ,

then every object equals Next(y).In that case,^ ,^ [׊w^ ׊

z (w=z)] =^ T. So no matter what,

,^ [the sentence] =

T.

Axiomatic System for Validity?Can we find axioms & deduction rules so thatset of theorems = set of valid sentences ?A ridiculous way: Let axioms = “set of all valid sentences”. That is dumb because we at least want an^ algorithmic

way to check ifa given expression is an axiom.