propositional language - syntaxcs245/logic02_prop...er, and p. van beek) university of waterloo...

41
Propositional Language - Syntax Lila Kari Notes on induction by Jonathan Buss (based in part on materials prepared by B. Bonakdarpour, with additional thanks to D. Maftuleac, R. Trefler, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41

Upload: others

Post on 13-Feb-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Propositional Language - Syntax

Lila KariNotes on induction by Jonathan Buss (based in part on materials

prepared by B. Bonakdarpour, with additional thanks to D.Maftuleac, R. Trefler, and P. Van Beek)

University of Waterloo

Propositional Language - Syntax CS245, Logic and Computation 1 / 41

Page 2: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Propositional language

• By using connectives, we can combine propositions,whether they are atomic themselves or compound.

• To prevent ambiguity, we introduce fully paranthesizedexpressions that can be parsed in a unique way.

• When possible, we will omit parentheses and useprecedence rules.

• We construct the propositional language Lp, which isthe formal language of the propositional logic.

Propositional Language - Syntax CS245, Logic and Computation 2 / 41

Page 3: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Propositional language Lp: syntax

Propositional language Lp is the formal language for propositionallogic.It consists of:

propositional variables: p, q, r .

logical connectives: ¬,∧,∨,→,↔.

Oral reading of logical connectives

¬ not negation∧ and conjunction∨ or (and/or) (inclusive) disjunction→ if, then (imply) implication↔ iff (equivalent to) equivalence

left and right parentheses : (, ).

Propositional Language - Syntax CS245, Logic and Computation 3 / 41

Page 4: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Expressions of Lp

expressions = finite strings of symbols– p, pq, (r), p∧ → q and ¬(p ∨ q) are expressions in Lp.

length of expression: the number of occurrences of symbols in it– for expressions above, length is 1, 2, 3, 4 and 6

empty expression = expression of length zero, denoted by λ (notto be confused with the empty set)

two expressions u and v are equal iff they are of the same lengthand have the same symbols in the same order.

scanning of expressions proceeds from left to right

Propositional Language - Syntax CS245, Logic and Computation 4 / 41

Page 5: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Expressions

concatenating two expressions u, v in this order is denoted uv .Note that λu = uλ = u

if u = w1vw2 where u, v ,w1,w2 are expressions, then v is asegment of u.

If v 6= u and v is non-empty then v is a proper segment of u.

If u = vw , where u, v ,w are expressions, then v is an initialsegment (prefix) of u. Similarly, w is a terminal segment (suffix)of u.

Propositional Language - Syntax CS245, Logic and Computation 5 / 41

Page 6: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Well-formed formulas

Definition. An atom (atomic formula) is an expression consisting of aproposition variable only. The set of atomic formulas in Lp isdenoted by Atom(Lp).Definition. An expression in Lp is called a formula (well-formedformula) iff it can be constructed according to the followingformation rules:

1 Every atomic formula is a formula;

2 If A is a formula then so is (¬A);

3 If A, B are formulas then so are (A ∨ B), (A ∧ B), (A→ B) and(A↔ B).

The set of all formulas in Lp is denoted by Form(Lp).Form(Lp) is the smallest class of expressions of Lp that containsAtom(Lp), and is closed under the formation rules of formulas.

Propositional Language - Syntax CS245, Logic and Computation 6 / 41

Page 7: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Example 1 (generating formulas)

The expression

((p ∨ q)→ ((¬p)↔ (q ∧ r)))

is a formula. How is it generated using the formation rules?

Propositional Language - Syntax CS245, Logic and Computation 7 / 41

Page 8: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Example 2 (parsing formulas)

If Michelle wins at the Olympics, everyone will admire her, and shewill get rich, but if she does not win, all her effort was in vain.

p: Michelle wins at the olympics.q: Everyone admires Michelle.r : Michelle will get rich.s: Michelle’s effort was in vain.The compound proposition becomes

((p → (q ∧ r)) ∧ ((¬p)→ s))

One can use parse trees to analyze formulas.

Propositional Language - Syntax CS245, Logic and Computation 8 / 41

Page 9: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Parse tree

The parse tree for the formula

(((¬p) ∧ q)→ (p ∧ (q ∨ (¬r)))

Propositional Language - Syntax CS245, Logic and Computation 9 / 41

Page 10: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Question: Can a formula be of two (or more) kinds?

For example, can it be both a conjunction and an implication?

Or both a negation and a disjunction?

Propositional Language - Syntax CS245, Logic and Computation 10 / 41

Page 11: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Claims

Every formula of Lp has the same number of occurrences of leftand right parentheses.

Any proper initial segment of a formula in Lp has moreoccurrences of left than right parentheses. Any proper terminalsegment of a formula in Lp has fewer occurrences of left thanright parentheses.

Thus, neither a proper initial segment nor a proper terminalsegment of a formula can itself be a formula of Lp.

(Unique Readability Theorem) Every formula of Lp is of exactlyone of the six forms: an atom, (¬A), (A ∧ B), (A ∨ B),(A→ B), or (A↔ B) and, in each case, it is of that form inexactly one way.

Propositional Language - Syntax CS245, Logic and Computation 11 / 41

Page 12: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Mathematical induction

To prove such claims, we will use mathematical induction.

Before doing the proof, we will review mathematical induction.This starts with the natural numbers.

Propositional Language - Syntax CS245, Logic and Computation 12 / 41

Page 13: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Natural numbers

The “natural numbers” are the numbers we use to count things.Before we start, we count 0; as we find things we count 1, 2, etc.The natural numbers form an unbounded sequence

0, 1, 2, 3, 4, . . .

Suppose P names a property. We write “P(2)” to mean “2 hasproperty P”, or “P holds for 2”.

A statement “every natural number has property P”corresponds to a sequence of statements

P(0), P(1), P(2), P(3), P(4), . . .

Propositional Language - Syntax CS245, Logic and Computation 13 / 41

Page 14: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Mathematical induction

Principle of mathematical induction:

Suppose we establish two things: that

0 has property P , and thatwhenever any number has property P , then the nextnumber also has property P .

Then we may conclude that every natural number hasproperty P .

Propositional Language - Syntax CS245, Logic and Computation 14 / 41

Page 15: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Mathematical induction example

Example: Show thatn∑

x=0

x = n(n+1)2

for every natural number n.

Let P be the property; that is, let P(n) be “n∑

x=0

x = n(n+1)2

”.

Propositional Language - Syntax CS245, Logic and Computation 15 / 41

Page 16: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Proof for the example

Step 1 (basis): The property P(0) is0∑

x=0

x = 0(0+1)2

.

The left side of the equation is just 0. Also the right side evaluatesto 0.

Thus 0 has property P .

Step 2 (inductive step): hypothesize that some number has propertyP (this is called the inductive hypothesis), that is,

some number∑x=0

x = some number (some number+1)2

For simplicity, we give a name to the “some number”, such as k .

Thus, the inductive hypothesis becomesk∑

x=0

x = k(k+1)2

.

Propositional Language - Syntax CS245, Logic and Computation 16 / 41

Page 17: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Step 2 (inductive step), continued:

We hypothesized that k has property P ; that is,k∑

x=0

x =k(k + 1)

2.

We now need to demonstrate that k + 1 has property P , that is,

k+1∑x=0

x =(k + 1) ((k + 1) + 1)

2=

(k + 1) (k + 2)

2

We calculate:

k+1∑x=0

x =( k∑

x=0

x)

+ (k + 1) definition of∑

= k(k+1)2

+ (k + 1) by the inductive hypothesis

=(k2

+ 1)(k + 1) ”algebra”

= (k+1)(k+2)2

DONE!

Propositional Language - Syntax CS245, Logic and Computation 17 / 41

Page 18: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Observations/Techniques

To talk about something, give it a name.E.g., property P, number k, etc.

A formula is a textual object. In this text, we can substitute onesymbol or expression for another. For example, we put “k + 1” inplace of “k”.

The induction principle gives a “template” for a proof:

The proof has two parts: the “basis” and the “inductive step”.

In the inductive step, hypothesize P(k) and prove P(k + 1) fromit.

But the induction principle does not say how to actually do eitherstep. We must invent those parts ourselves, and every problem isdifferent.

Propositional Language - Syntax CS245, Logic and Computation 18 / 41

Page 19: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

“Simple” induction vs. “Strong” induction

Simple Induction Strong Induction(course-of-values induction)

Basis: Show Q(0) Show P(0)Ind. Hyp.: Q(k) holds P(m) holds, for every m ≤ kInd. Step: Show Q(k + 1) holds Show P(k + 1) holdsConclusion: Q(k) holds for every k P(k) holds for every k

What is the difference? No difference!

Define Q(k) as the property “P(m) holds, for everym ≤ k”.

Q(0) is equivalent to P(0).Q(k + 1) is equivalent to “Q(k) and P(k + 1)”.To prove Q(k + 1) from Q(k), need only toprove P(k + 1).“Q(k) for every k” is equivalent to “P(k) for every k”.

Propositional Language - Syntax CS245, Logic and Computation 19 / 41

Page 20: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Induction example: Tiling checkerboards

Propositional Language - Syntax CS245, Logic and Computation 20 / 41

Page 21: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Induction example: Tiling checkerboards

Propositional Language - Syntax CS245, Logic and Computation 21 / 41

Page 22: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Induction example: Tiling checkerboards

Propositional Language - Syntax CS245, Logic and Computation 22 / 41

Page 23: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

All horses are the same colour

Base Case: P(1) = true - trivial

Inductive Step: Assume P(k) (I.H.) and prove P(k + 1).Consider k + 1 horses. First, exclude the last horse and look onlyat the first k horses; all these are the same color by I.H.Likewise, exclude the first horse and look only at the last khorses. These too, must also be of the same color, by the I.H.Therefore, the first horse in the group is of the same color as thehorses in the middle, who in turn are of the same color as thelast horse. Hence the first horse, middle horses, and last horseare all of the same color. Q.E.D. ?

Propositional Language - Syntax CS245, Logic and Computation 23 / 41

Page 24: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Structural induction

We want to prove: “Every formula in Lp has property P”.

How to prove such a statement? Can we use induction?

A formula is not a natural number. . . ., but it suffices to prove anyone of the following.

For every natural number n, every formula with n or fewersymbols has property P.

ORFor every natural number n, every formula with n or fewerconnectives has property P.

OR

Propositional Language - Syntax CS245, Logic and Computation 24 / 41

Page 25: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Structural induction (2)

We want to prove: “Every formula in Lp has property P”.

ORFor every natural number n, every formula whose parse treehas height n or less has property P.

ORFor every natural number n, every formula produciblewith n or fewer uses of the formation rules has property P.

In each of these formulations, the induction step requires showingthat

If P(A) and P(B), then P((¬A)

)and P

((A ? B)

).

Formulas A and B have smaller n values than (¬A) and (A ? B) do.

Propositional Language - Syntax CS245, Logic and Computation 25 / 41

Page 26: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

The principle of structural induction

Theorem. Suppose R is a property. If

1 For any atomic formula p ∈Atom(Lp), p has the property R .

2 For any formula A in Form(Lp), if A has property R , then (¬A)has the property R .

3 For any formulas A and B in Form(Lp), if A and B have propertyR then (A ∗ B) has property R , where ∗ ∈ {∧,∨,→,↔}.

then, any formula in Form(Lp) has property R .

This is called structural induction.

Propositional Language - Syntax CS245, Logic and Computation 26 / 41

Page 27: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Example: Parentheses in formulas

To illustrate structural induction, we shall prove the following.

Lemma. Every well-formed formula has an equal number ofleft and right parentheses.

Proof. We use structural induction. The property to prove is

R(A): A has an equal number of left and right parentheses

for every formula A.

Base case: A is an atom.A has no parentheses—only a propositional variable. Thus R(A)holds.This completes the proof of the base case.

Propositional Language - Syntax CS245, Logic and Computation 27 / 41

Page 28: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Example, cont’d — the Inductive Step

Inductive step:Inductive Hypothesis: formulas A and B both have property R .To prove: each of the formulas (¬A), (A ∧ B), (A ∨ B), (A→ B)and (A↔ B) has property R .Without loss of generality (w.l.o.g.), we consider (A ∧ B).

Notation: For any formula C , let l(C ) denote the numberof ’(’ in C , and let r(C ) denote the number of ’)’ in C .

We calculate l((A ∧ B)

):

l((A ∧ B)

)= 1 + l(A) + l(B) inspection

= 1 + r(A) + r(B) R(A) and R(B)

= r((A ∧ B)

)inspection

Propositional Language - Syntax CS245, Logic and Computation 28 / 41

Page 29: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Back to the Unique Readability Theorem

Theorem. Every formula is exactly one of: an atom, (¬A),(A ∧ B), (A ∨ B), (A→ B) or (A↔ B) and, in each case,it is of that form in exactly one way.

We want to prove this using structural induction. How will it go?

Base Case: Trivial, as every propositional variable is an atom (firsttype listed in the Theorem).

Inductive Step Idea: We will have consider, e.g., formulas of theform (A→ B) (one of the five subcases of the Inductive Step.)

Propositional Language - Syntax CS245, Logic and Computation 29 / 41

Page 30: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Unique Readability Theorem Observation

An example of such an “implication” formula (a formula of the type(A→B)), which will have to be considered as one of the five cases ofthe inductive step, is our previous example ((p ∧ q)→r), which has(p ∧ q) for A and r for B .

Question: Is this the only way to “parse” the formula ((p ∧ q)→ r)?What about parsing it as a conjunction, that is,

((p ∧ q)→ r) = (A′∧B ′),

where A′ is the expression ’(p’ and B ′ is the expression ’q)→r ’?)

Fortunately, neither A′ nor B ′ is a formula. (Why?)

Propositional Language - Syntax CS245, Logic and Computation 30 / 41

Page 31: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Does this proof idea always work?

How can we make sure that such a proof for the Inductive Step worksfor every formula (A→ B)?

That is, if (A′ ∧ B ′) is equal (identical) to the formula (A→ B), howcan we argue that neither A′ nor B ′ can be a formula?

Can A′ (or B ′) have an equal number of left and right parentheses?If not, why not?

To do the proof, we actually need to know more about formulas.This illustrates a common feature of inductive proofs: they oftenprove more than just the statement given in the theorem.

Propositional Language - Syntax CS245, Logic and Computation 31 / 41

Page 32: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Proving Unique Readability

Property P(n):

Every formula A containing at most n connectives satisfiesall three of the following.

(a) The first symbol of A is either ‘(’ or a variable.

(b) A has an equal number of ‘(’ and ‘)’, andeach proper prefix of A has more ‘(’ than ‘)’.

(c) A has a unique construction as a formula.

(A proper prefix of A is a non-empty expression x such that A is xyfor some non-empty expression y .)

We prove property P(n) for all n, by induction.

Base Case: The statements clearly hold for n = 0.

Propositional Language - Syntax CS245, Logic and Computation 32 / 41

Page 33: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

A key case of the Inductive Step

Inductive hypothesis: P(k) holds for some natural number k .To show that P(k + 1) holds, let formula A have k + 1 connectives.

We prove only property (c): Assume that A = (B ? C ), whereboth B and C have properties (a), (b) and (c) by inductivehypothesis.

To prove property (c), we must show that

If the very same formula A can be decomposed as (B ′ ?′ C ′), forformulas B ′ and C ′, then B = B ′, ? = ?′ and C = C ′.

Note: A = (B ∗ C ) = (B ′ ∗′ C ′) implies that (B ∗ C ) and (B ′ ∗′ C ′)are two different decompositions of the same formula (same length,and the same sequence of symbols, in the same order).

Propositional Language - Syntax CS245, Logic and Computation 33 / 41

Page 34: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

A key case of the Inductive Step contd.

Case (1): If B ′ has the same length as B , then they must be thesame string (both start at the second symbol of A).

Case (2): B ′ is a proper prefix of B . Since B and B ′ are formulaswith at most k connectives, the inductive hypothesis applies tothem. In particular, they have property (b).

* Since B ′ has the first half of property (b), B ′ should have an equalnumber of left and right parantheses.

* Since B has the second half of property (b), and since B ′ is aproper prefix of B , it follows that B ′ should have strictly more leftthan right parantheses.

We reached a contradiction, so Case (2) cannot hold.

Propositional Language - Syntax CS245, Logic and Computation 34 / 41

Page 35: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

A key case of the Inductive Step contd.

Case (3): B is a proper prefix of B ′ - impossible, using a similarreasoning as in Case (2).

Since Case (2) and Case (3) are impossible, the only case that canhold is Case (1), whereby the two decompositions of the formula Amust coincide.

That is, A has a unique construction, as required by property (c).

Propositional Language - Syntax CS245, Logic and Computation 35 / 41

Page 36: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Commentary

The “goal” of the proof is property (c) —unique formation.

However, properties (a) and (b) are required in order to prove (c).

There are actually two equally good options for a proof:

Prove (a), (b) c) simultaneously, as a single “compound”property (as done here).

Prove them separately: first (a), then (b), and finally (c).

Propositional Language - Syntax CS245, Logic and Computation 36 / 41

Page 37: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Consequences of unique formation

There are six kinds of formulas:

† A propositional variable is called an atom.

† (¬A) is called a negation (formula)

† (A ∧ B) is called a conjunction (formula)

† (A ∨ B) is called a disjunction (formula)

† (A→ B) is called an implication (formula)

† (A↔ B) is called an equivalence (formula),

and each formula is of exactly one kind.

Propositional Language - Syntax CS245, Logic and Computation 37 / 41

Page 38: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Consequences of unique formation

We will define the semantics (meaning) of a formula from its syntax.Thus unique formation ensures unambiguous formulas.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Given a formula, determine its sub-formulas by counting parentheses.

1 2 . . . m m + 1 m + 2 . . . n − 1 n

( ( 〈rest of subformula〉 )︸ ︷︷ ︸ ? 〈subformula 2〉 )

To determine m: countexcess of ’(’ over ’)’

When the count returns to zero, the subformula has ended.

Propositional Language - Syntax CS245, Logic and Computation 38 / 41

Page 39: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Precedence rules (for human logicians)¬ has precedence over ∧∧ has precedence over ∨∨ has precedence over →→ has precedence over ↔

Examples:

¬p ∨ q is to be understood as ((¬p) ∨ q).

p ∧ q ∨ r is to be understood as((p ∧ q) ∨ r).

p → q ∨ r is to be understood as(p → (q ∨ r))

p ↔ p → q must be understood as(p ↔ (p → q))

The proposition about Michelle can be written without all theparentheses, as:(p → q ∧ r) ∧ (¬p → s)

Propositional Language - Syntax CS245, Logic and Computation 39 / 41

Page 40: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Scope

If (¬A) is a segment of a formula C , then A is called the scopeof the negation ¬ in the formula C .

If (A ∧ B) is a segment of a formula C , then A is called the leftscope of the conjunction and B is called the right scope of theconjunction in the formula C .

Similar definitions hold for left/right scopes of disjunction,implication and equivalence.

Propositional Language - Syntax CS245, Logic and Computation 40 / 41

Page 41: Propositional Language - Syntaxcs245/Logic02_prop...er, and P. Van Beek) University of Waterloo Propositional Language - Syntax CS245, Logic and Computation 1 / 41 Propositional language

Example

Suppose A = (¬((p ∧ q) ∨ ((¬p)→ r))).

The scope of the first ¬ is ((p ∧ q) ∨ ((¬p)→ r)) and of the second¬ is p.The left and right scopes of ∧ are p and q.The left and right scopes of ∨ are (p ∧ q) and ((¬p)→ r).The scopes of → are (¬p) and r .

Propositional Language - Syntax CS245, Logic and Computation 41 / 41