Propositional Logic - Brooklyn Collegechipp/cis32/lectures/Lecture...Propositional Logic • The...

Preview:

Citation preview

Propositional LogicBuilding Blocks for Rational Thinking

CIS 32

Functionalia

Today:

Project 1 Code Changes

Midterm Review

Propositional Logic

Project 1 Demo: Monday

Project 1 Deliverables: Next Thursday

Write-Up Criteria

.ZIPPED Code (either in e-mail, or on USB Key in class)

Knowledge Representation - Write One Page summary on your Role (it will be due in HW 3)

Why Logic?

• “Weak” (search-based) problem-solving does not scale to real problems.

• To succeed, problem solving needs domain specific knowledge.

• In search, knowledge = heuristic.

• We need to be able to represent knowledge efficiently.

• W3C - Web Consortium is developing a Logic Based Web-Service Descriptiors

(FLOWS - First-order Logic Ontology for Web-Services)

• One way to do this is to use logic.

What is Logic?

• When most people say “logic”, they mean either propositional logic or first-order predicate logic.

• However, the precise definition is quite broad, and literally hundreds of types of logics have been studied by philosophers, computer scientists and mathematicians.

• Any “formal system” can be considered a logic if it has:

– a well-defined syntax;

– a well-defined semantics; and

– a well-defined proof-theory.

Components of Logic

• The syntax of a logic defines the syntactically acceptable objects of the language.

Properly called well-formed formulae (wff). (We shall just call them formulae.)

Colorless green ideas sleep furiously.

• The semantics of a logic associate each formula with a meaning.

• The proof theory is concerned with manipulating formulae according to certain rules.

Propositional Logic

• The simplest, and most abstract, logic we can study is called propositional logic.

• Definition: A proposition is a statement that can be either true or false; it must be one or the other, and it cannot be both.

• EXAMPLES. The following are propositions:

– the reactor is on;

– the wing-flaps are up;

– It is raining outside.

whereas the following are not:

– are you going out somewhere?

– 2+3

Propositional Logic

• It is possible to determine whether any given statement is a proposition by prefixing it with:

It is true that . . .

and seeing whether the result makes grammatical sense.

• Atomic propositions. Intuitively, these are the set of smallest propositions.

• Definition: An atomic proposition is one whose truth or falsity does not depend on the truth or falsity of any other proposition.

• So all the above propositions are atomic.

• Shortcut: rather than write out propositions in full, we will abbreviate them by using propositional variables.

• It is standard practice to use the lower-case roman letters

p, q, r, . . .

to stand for propositions.

Sometimes, Greek letters are also used, e.g.:

• If we do this, we must define what we mean by writing something like:

Let p be It is raining outside.

• Another alternative is to write something like it-is-raining-outside, so that the interpretation of the propositional variable becomes obvious.

The Connectives

• Now, the study of atomic propositions is pretty boring. We therefore now introduce a number of connectives which will allow us to build up complex propositions.

• The connectives we introduce are:

∧ and (& or .)

∨ or (| or +)

¬ not (~)⇒ implies (⊃ or →)

⇔ iff (↔)

(Alternate symbols commonly used are in parentheses.)

And

• Any two propositions can be combined by the word “and” to form a third proposition called the conjunction of the original propositions.

• Definition: If p and q are arbitrary propositions, then the conjunction of p and q is written

p ∧ q

and will be true iff both p and q are true.

Truth Table

• We can summarise the operation of ∧ in a truth table. The idea of a truth table for some formula is that it describes the behavior of a formula under all possible interpretations of the primitive propositions that are included in the formula.

• If there are n different atomic propositions in some formula, then there are different lines in the truth table for that formula. (This is because each proposition can take one 1of 2 values—i.e., true or false.)

• Let us write T for truth, and F for falsity.

Then the truth table for p ∧ q is:

Or

• Any two propositions can be combined by the word “or” to form a third proposition called the disjunction of the originals.

• Definition: If p and q are arbitrary propositions, then the disjunction of p and q is written

p ∨ q

and will be true iff either p is true, or q is true, or both p and q are true.

Or Truth Table

• The operation of ∨ is summarised in the following truth table:

• Note that this “or” is a little different from the usual meaning we give to “or” in everyday natural language.

If. . . Then. . .

• Many statements, particularly in mathematics, are of the form:

if p is true then q is true.

Another way of saying the same thing is to write:

p implies q.

• In propositional logic, we have a connective that combines two propositions into a new proposition called the conditional, or implication of the originals, that attempts to capture the sense of such a statement.

• Definition: If p and q are arbitrary propositions, then the conditional of p and q is written

p ⇒ q

and will be true iff either p is false or q is true.

• The truth table for ⇒ is:

• The ⇒ operator is the hardest to understand of the operators we have

considered so far, and yet it is extremely important.

• If you find it difficult to understand, just remember that the p ⇒ q

means “if p is true, then q is true”. (Most intuitive meaning)

Further to that, if p is false, then we don’t care about q, and by default, we make p ⇒ q evaluate to T in this case. (does not imply q is T)

Otherwise, p ⇒ q is false when p is true and q is false.

• Terminology: if is the formula p ⇒ q, then p is the antecedent

of and q is the consequent.

Iff

• Another common form of statement in maths is:

p is true if, and only if, q is true.

• The sense of such statements is captured using the biconditional operator.

• Definition: If p and q are arbitrary propositions, then the biconditional of p and q is written:

p ⇔ q

and will be true iff either:

1. p and q are both true; or

2. p and q are both false.

• The truth table for ⇔ is:

• If p ⇔ q is true, then p and q are said to be logically equivalent.

They will be true under exactly the same circumstances.

Not• All of the connectives we have considered so far have been binary: they have taken two arguments.

• The final connective we consider here is unary: It only takes one argument.

• Any proposition can be prefixed by the word ‘not’ to form a second proposition called the negation of the original.

• Definition: If p is an arbitrary proposition then the negation of p is written

¬p

and will be true iff p is false.

• Truth table for ¬:

Well Formed Formulae

• We can nest complex formulae as deeply as we want.

• We can use parentheses i.e., ),(, to disambiguate formulae.

• EXAMPLES. If p, q, r, s and t are atomic propositions, then all of the following are formulae:

whereas none of the following is:

– p ∧– p ∧ q)– p¬

– p ∧ q ⇒ r

– p ∧ (q ⇒ r)

– (p ∧ (q ⇒ r)) ∨ s

– ((p ∧ (q ⇒ r)) ∨ s) ∧ t

Interpretation

• Given a particular formula, can you tell if it is true or not?

• No — you usually need to know the truth values of the component atomic propositions in order to be able to tell whether a formula is true.

• Definition: A valuation is a function which assigns a truth value to each primitive proposition.

• In C, we might write:

short Val( AtomicProp *p ) {

if ( *p )

return( 1 ); // true

else

return( 0 ); // false

}

• Given a valuation, we can say for any formula whether it is true or false.

• A valuation is also known as an interpretation

• EXAMPLE. Suppose we have a valuation v, such that:

v(p) = Fv(q) = Tv(r) = F

Then the truth value of (p ∨ q) ⇒ r is evaluated by:

Line (3) is justified since we know that F ∨ T = T.

Line (4) is justified since T ⇒ F = F.

If you can’t see this, look at the truth tables for ∨ and ⇒.

(v(p) ∨ v(q)) ⇒ v(r)

= (F ∨ T) ⇒ F

= T ⇒ F

= F

(1)

(2)

(3)

(4)

• When we consider formulae in terms of interpretations, it turns out that some have interesting properties.

• Definition:

1. A formula is a tautology iff it is true under every valuation;

2. A formula is consistent iff it is true under at least one valuation;

3. A formula is inconsistent iff it is not made true under any valuation.

• A tautology is said to be valid.

• A consistent formula is said to be satisfiable.

• An inconsistent formula is said to be unsatisfiable.

• Theorem: is a tautology iff ¬ is unsatisfiable.

• Each line in the truth table of a formula corresponds to a valuation.

• We can use truth tables to determine whether or not formulae are tautologies.

• If every line in the truth table has value T, the the formula is a tautology.

• Also use truth-tables to determine whether or not formulae are consistent.

• To check for consistency, we just need to find one valuation that satisfies the formula.

• If this turns out to be the first line in the truth-table, we can stop looking immediately! We have a certificate of satisfiability.

• To check for validity, we need to examine every line of the truth-table.

No short cuts.

• The lesson?

• Checking satisfiability is easier than checking validity.

Syntax

• We have already informally introduced propositional logic; we now define it formally.

• To define the syntax, we must consider what symbols can appear in formulae, and the rules governing how these symbols may be put together to make acceptable formulae.

• Definition: Propositional logic contains the following symbols:

1. A set of primitive propositions, = {p, q, r . . .}.

2. The unary logical connective ‘¬’ (not), and binary logical connective

‘∨’ (or). (We will see about the others shortly.)

3. The punctuation symbols ‘)’ and ‘(’.

• The primitive propositions will be used to represent statements such as:

• I am in Brooklyn

• It is raining

• It is Thursday the 12th of April.

These are primitive in the sense that they are indivisible; we cannot break them into smaller propositions.

• The remaining logical connectives (∧, ⇒, ⇔) will be introduced as

abbreviations.

Grammar• We now look at the rules for putting formulae together.

• Definition: The set WFF, of (well formed) formulae of propositional logic, is defined by the following rules:

1. If p ∈ , then p ∈ WFF.

2. If ∈ WFF, then:

3. If ∈ WFF and ∈ WFF, then ∨ ∈ WFF.

¬ ∈ WFF

( ) ∈ WFF

Connectives as Abbreviations

• The remaining connectives are defined by:

• These connectives are interpreted:

• This concludes the formal definition of syntax.

• The remaining connectives are defined by:

! ! " = ¬(¬! " ¬")

! # " = (¬!) " "

! $ " = (! # ") ! (" # !)

• These connectives are interpreted:

! And# Implies (if. . . then . . . )$ If, and only if

• This concludes the formal definition of syntax.

cis32-spring2006-sklar-lec18 29

Semantics

• We now look at the more di!cult issue of semantics, or meaning.

• What does a proposition mean?

• That is, when we write

It is raining.

what does it mean?

From the point of view of logic, this statement is a proposition: something that is either %or &.

• The meaning of a primitive proposition is thus either % or &.

• In the same way, the meaning of a formula of propositional logic is either % or &.

cis32-spring2006-sklar-lec18 30

• QUESTION: How can we tell whether a formula is % or &?

• For example, consider the formula(p ! q) # r

Is this %?

• The answer must be: possibly. It depends on your interpretation of the primitivepropositions p, q and r.

• The notion of an interpretation is easily formalised.

• Definition: An interpretation for propositional logic is a function

# : ! '( {T, F}

which assigns T (true) or F (false) to every primitive proposition.

cis32-spring2006-sklar-lec18 31

• But an interpretation only gives us the meaning of primitive propositions; what aboutcomplex propositions — arbitrary formulae?

• We use some rules which tell us how to obtain the meaning of an arbitrary formulae, givensome interpretation.

• Before presenting these rules, we introduce a symbol: |=. If # is an interpretation, and ! isa formula, then the expression

# |= !

will be used to represent the fact that ! is % under the interpretation #.

Alternatively, if # |= !, then we say that:

– # satisfies !; or

– # models !.

• The symbol |= is called the semantic turnstile.

cis32-spring2006-sklar-lec18 32

Semantics

• We now look at the more difficult issue of semantics, or meaning.

• What does a proposition mean?

• That is, when we write

It is raining.

what does it mean?

From the point of view of logic, this statement is a proposition: something that is either ⊤ or ⊥.

• The meaning of a primitive proposition is thus either ⊤ or ⊥.

• In the same way, the meaning of a formula of propositional logic is either ⊤ or ⊥.

• QUESTION: How can we tell whether a formula is ⊤ or ⊥?

• For example, consider the formula

(p ∧ q) ⇒ r

Is this ⊤?

• The answer must be: possibly. It depends on your interpretation of the primitive propositions p, q and r.

• The notion of an interpretation is easily formalised.

• Definition: An interpretation for propositional logic is a function

which assigns T (true) or F (false) to every primitive proposition.

– satisfies ; or– models .

• But an interpretation only gives us the meaning of primitive propositions;

What about complex propositions — arbitrary formulae?

• We use some rules which tell us how to obtain the meaning of an arbitrary formulae, given some interpretation.

• Before presenting these rules, we introduce a symbol: If is an interpretation, and is a formula, then the expression

will be used to represent the fact that is ⊤ under the interpretation .Alternatively, if , then we say that:

• The symbol is called the semantic turnstile (or entailment).

Entailment

Sentences Sentences

Would like to tell whether one set of Sentences entails the other?(If one set of Sentences are true then the other set will be true too)

Entailment

Sentences Sentencesse

man

tics

Interpretations

Through semantics arrive at a set of interpretations that satisfies the sentence.

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

Likewise.

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

Now the question is whether the first set of interpretations is a subset of the the other set.

subset

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

In all interpretations of the first set of sentences that are true are also true for the second set of sentences.

subset

entails

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

Viewed textually. Two sets of sentences (KB1 and KB2)

subset

entails

KB1 = A ∧ B

KB2 = B

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

Venn Diagrams. U the universe of discourse

subset

entails

KB1 = A ∧ B

KB2 = B

U

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

B (or rather the interpretations that make B true) lies within this domain.

subset

entails

KB1 = A ∧ B

KB2 = B

UB

Entailment

Sentences Sentencesse

man

tics

Interpretations

sem

antic

s

Interpretations

So A ∧ B is a model of of B, as all interpretations that lie within

A and B lie also within B.

subset

entails

KB1 = A ∧ B

KB2 = B U

BA ∧ B

• The rule for primitive propositions is quite simple. If then

• The remaining rules are defined recursively.

• The rule for ¬:

(where means ‘does not satisfy’.)

• The rule for ∨:

• Since these are the only connectives of the language, these are the only semantic rules we need.

• Since:

is defined as:

it follows that:

• And similarly for the other connectives we defined.

• If we are given an interpretation and a formula it is a simple

(if tedious) matter to determine whether

• We just apply the rules above, which eventually bottom out of the recursion into establishing if some proposition is true or not.

• So for:

we first establish if p ∨ q or q ∨ r are true and then work up to the

compound proposition.

Proof Theory

• What is logic used for? A number of things, but most importantly, it is a language for representing the properties of things.

• But also, we hope it will give us a method for establishing the properties of things.

• To see how logic may be used to establish the properties of things, it helps to look at its history.

• Logic was originally developed to make the notion of an argument precise.

(We do not mean argument as in fighting here!)

• Here is a classic argument:

All men are mortal

Socrates is a man

Socrates is mortal

• This example serves to illustrate a number of features of arguments:

– The argument has a number of premises — these are the statements that appear before the horizontal line;

– The argument has a conclusion — this is the statement that appears after the horizontal line;

– The argument has the form

Ifyou accept thatthe premises are true

thenyou must accept thatthe conclusion is true.

Soundness

• In mathematics, we are concerned with when arguments are sound.

• To formalise the notion of a sound argument, we need some extra terminology. . .

• Definition: If ∈ WFF, then:

1. if there is some interpretation such that

then is said to be satisfiable, otherwise is unsatisfiable.

2. if

for all interpretations , then is said to be valid.

• Valid formulae of propositional logic are called tautologies.

• Theorem:

1. If is a valid (tautology) formula, then ¬ is unsatisfiable;

2. If ¬ is unsatisfiable, then is valid.

• We indicate that a formula is valid by writing

• We can now define the logical consequence.

• Definition: If

then is said to be a logical consequence of iff is satisfied by all interpretations that satisfy

• We indicate that is a logical consequence of by writing

• An expression like this is called a semantic sequent.

• Theorem:

iff

• So we have a method for determining whether is a logical consequence of

we use a truth table to see whether is a tautology.

If it is, then is a logical consequence of

• Our main concern in proof theory is thus to have a technique for determining whether a given formula is valid, as this will then give us a technique for determining whether some formula is a logical consequence of some others.

• EXAMPLE. Show that

To do this, we construct a truth-table for

Here it is:

Since

is true under every interpretation, we have that p ∨ q is a logical

consequence of p ∧ q.

Truth Tables are Exhaustive

• The notion of logical consequence we have defined above is acceptable for a definition of a sound argument, but is not very helpful for checking whether a particular argument is sound or not.

• The problem is that we must look at all the possible interpretations of the primitive proposition s. While this is acceptable for, say, 4 primitive propositions, it will clearly be unacceptable for 100 propositions, as it would mean checking 2^100 interpretations.

(Moreover, for first-order logic, there will be an infinite number of such interpretations.)

• What we require instead is an alternative version of logical consequence, that does not involve this kind of checking.

This leads us to the idea of syntactic proof.

‘Syntactic’ Proof

• The idea of syntactic proof is to replace the semantic checking to determine whether a formula is valid by a procedure that involves purely syntactic manipulation.

• The kinds of techniques that we shall use are similar to those that we use when solving problems in algebra.

• The basic idea is that to show that is a logical consequence of we use a set of rules to manipulate formulae.

If we can derive from by using these rules, then is said to be proved from which we indicate by writing:

• The symbol ⊢ is called the syntactic turnstile.

• An expression of the form

is called a syntactic sequent.

• A rule has the general form:

Such a rule is read:

rule name

If

are proved

then

is proved.

• EXAMPLE. Here is an example of such a rule:

This rule is called and-introduction. It says that if we have proved , and we have also proved , then we can prove .

• EXAMPLE. Here is another rule:

This rule is called and elimination. It says that if we have proved , then we can prove both and ; it allows us to eliminate the ∧ symbol from between them.

Definition of Proof

• Let us now try to define precisely what we mean by proof.

• Definition: (Proof) If

then there is a proof of from iff there exists some sequence of formulae:

such that , and each formula , for 1 ≤ k < n is either one of the formula or else is the conclusion of a rule whose antecedents appeared earlier in the sequence.

• If there is a proof of from ,then we indicate this by writing:

• It should be clear that the symbols and are related. We now have to state exactly how they are related.

• There are two properties of ⊢ to consider:

– soundness;

– completness.

– Intuitively, is said to be sound if it is correct, in that it does not let us derive something that is not true.

– Intuitively, completeness means that will let us prove anything that is true.

• Definition: (Soundness) A proof system is said to be sound with respect to semantics iff

implies

• Definition: (Completeness) A proof system ⊢ is said to be complete with respect to semantics iff

implies

Recommended