44
CS1231 Discrete Structures Tong W. Ratanapan Tutorial 2: Sep 2-6, 2013 [email protected] slideshare.net/TongWR

CS1231 Tutorial 2

Embed Size (px)

Citation preview

Page 1: CS1231 Tutorial 2

CS1231 Discrete Structures

Tong W. Ratanapan

Tutorial 2: Sep 2-6, 2013

[email protected]

slideshare.net/TongWR

Page 2: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

CS1231 Tutorial 2 Tong W. Ratanapan

Correction

Consultation

Launchpad @ N-House (level 1, block 15, PGP)

Wednesday 1-2pm

Page 3: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

CS1231 Tutorial 2 Tong W. Ratanapan

Outline

Page 4: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

CS1231 Tutorial 2 Tong W. Ratanapan

0. Outline

1. Tutorial 1 1. Pigeon Hole Principle 2. Pure Existence Proof 3. Inclusion-Exclusion Principle

Page 5: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

CS1231 Tutorial 2 Tong W. Ratanapan

0. Outline

1. Tutorial 1 1. Pigeon Hole Principle 2. Pure Existence Proof 3. Inclusion-Exclusion Principle

2. Revision 1. Propositional Logic 2. Predicate Logic 3. Model Semantics

Page 6: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

CS1231 Tutorial 2 Tong W. Ratanapan

0. Outline

1. Tutorial 1 1. Pigeon Hole Principle 2. Pure Existence Proof 3. Inclusion-Exclusion Principle

2. Revision 1. Propositional Logic 2. Predicate Logic 3. Model Semantics

3. Discussion

Page 7: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Tutorial 1

Page 8: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Page 9: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Problems & Solutions: http://www.artofproblemsolving.com/Wiki/index.php/Pigeonhole_Principle Applications: http://mindyourdecisions.com/blog/2008/11/25/16-fun-applications-of-the-pigeonhole-principle

Page 10: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Page 11: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational?

Page 12: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

Page 13: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

Page 14: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

rational

Page 15: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

rational 𝑝 = π‘ž = 2 β†’ π‘π‘ž = 22

Page 16: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

rational 𝑝 = π‘ž = 2 β†’ π‘π‘ž = 22

; rational by assumption

Page 17: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

irrational

rational 𝑝 = π‘ž = 2 β†’ π‘π‘ž = 22

; rational by assumption

Page 18: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

irrational

rational 𝑝 = π‘ž = 2 β†’ π‘π‘ž = 22

; rational by assumption

𝑝 = 22, π‘ž = 2 β†’ π‘π‘ž = 2

22

= 2 ; rational

Page 19: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Pure Existence Proof

Q: Are there irrational 𝑝, π‘ž such that π‘π‘ž is rational? A: Yes!

22

irrational

rational 𝑝 = π‘ž = 2 β†’ π‘π‘ž = 22

; rational by assumption

𝑝 = 22, π‘ž = 2 β†’ π‘π‘ž = 2

22

= 2 ; rational

doesn’t matter, exists anyway!

Page 20: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Pigeonhole Principle Pure Existence Proof Inclusion-Exclusion Principle

CS1231 Tutorial 2 Tong W. Ratanapan

Inclusion-Exclusion Principle

Page 21: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Propositional Logic Predicate Logic Model Semantics

CS1231 Tutorial 2 Tong W. Ratanapan

Revision

Page 22: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Propositional Logic Predicate Logic Model Semantics

CS1231 Tutorial 2 Tong W. Ratanapan

Propositional Logic

Page 23: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Formal Syntax of Propositional Logic

2.2. Formal Syntax of Propositional Logic

Definition 2.2.1

Let us consider a collection of symbols called propositions orstatements. Let us consider the collection of symbols{>,βŠ₯,∨,∧,Β¬,β‡’,⇔,βŠ•}a. Let us consider the two parenthesissymbols ( and ).

F is a well formed formula (wff) (or atomic statementb) if F isa proposition.

The following are wff (or compound statements) iff F1 and F2are wff. >, βŠ₯, (F1 ∧ F2), (F1 ∨ F2), Β¬(F1), (F1 β‡’ F2),(F1 ⇔ F2), (F1 βŠ• F2).

the above are the only wff.

aThese are the standard connectives. There are more.bp and Β¬p are sometimes refer to as unit statements.

Page 24: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Formal Syntax of Propositional Logic

Different Notations

> T , true, 1βŠ₯ F , false, 0

(p ∧ q) (p.q), p Γ— q, (p&q), (p&&q)(p ∨ q) (p + q), (p | q), (pβ€–q)(p βŠ• q) (pΛ†q)(p ⇔ q) (p ↔ q), (p ≑ q)(p β‡’ q) (p β†’ q), (p βŠƒ q)Β¬p ∼ p, p, !p(p) [p]

Page 25: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Precedence

Precedence and Parenthesis

In this module we do not assume any precedence rule andsystematically use parenthesis to avoid ambiguity.

Page 26: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Negation

F1 Β¬F1true falsefalse true

Page 27: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Conjunction

F1 F2 F1 ∧ F2

true true truetrue false falsefalse true falsefalse false false

Page 28: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Disjunction

F1 F2 F1 ∨ F2

true true truetrue false truefalse true truefalse false false

Page 29: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Exclusive Disjunction

F1 F2 F1 βŠ• F2

true true falsetrue false truefalse true truefalse false false

Page 30: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Implication

F1 F2 F1 β‡’ F2

true true truetrue false falsefalse true truefalse false true

Page 31: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Truth Tables

Truth Table of Equivalence

F1 F2 F1 ⇔ F2

true true truetrue false falsefalse true falsefalse false true

Page 32: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Propositional Logic Predicate Logic Model Semantics

CS1231 Tutorial 2 Tong W. Ratanapan

Predicate Logic

Page 33: CS1231 Tutorial 2
Page 34: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Formal Syntax of Predicate Logic

Definition 2.4.5

Let us consider a collection of constants. Let us consider acollection of variables, let us consider a collection of predicates(each predicate is associated to a natural number n, called itsvalence or arity, we say that the predicate is n-ary). Let us considerthe corresponding Herbrand’s base. Let us consider the collectionof symbols {>,βŠ₯,∨,∧,Β¬,β‡’,⇔,βŠ•}. Let us consider the twosymbols βˆƒ (the existential quantifier; read β€œthere exists”) and βˆ€(the universal quantifier; read β€œfor all”) called quantifiers....

Page 35: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Formal Syntax of Predicate Logic

Definition 2.4.5 Cont.

F is a well formed formula (wff) or compound statement if Fis an atom of BH .

The following are wffs if F1 and F2 are wffs.

>,βŠ₯,(F1 ∧ F2),(F1 ∨ F2),Β¬(F1),(F1 β‡’ F2),(F1 ⇔ F2),(F1 βŠ• F2).

The following are wffs if F is a wff and X is a variable.

(βˆ€X F ),(βˆƒX F ).

the above are the only wff.

Page 36: CS1231 Tutorial 2

Propositional Logic Formal Syntax of Propositional Logic Predicate Logic Formal Syntax of Predicate Logic

Formal Syntax of Predicate Logic

For example the following are wff.

βˆ€X (βˆ€Y ((odd(X ) ∧ Β¬(even(Y )))β‡’ even(X + Y ))).

βˆ€X (βˆƒY (X ∈ Nβ‡’ (Y ∈ N ∧ Y = s(X )))).

βˆ€X (X ∈ Nβ‡’ s(X ) ∈ N).

For example the following are not wff.

βˆ€X (βˆ€Y ((odd(X ) ∧ ∧ ∧ Β¬(even(Y )))β‡’ even(X + Y ))).

βˆ€X ∧ (βˆƒY (X ∈ Nβ‡’ (Y ∈ N ∧ Y = s(X )))).

X (X ∈ Nβ‡’ s(X ) ∈ N.

Page 37: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Propositional Logic Predicate Logic Model Semantics

CS1231 Tutorial 2 Tong W. Ratanapan

Model Semantics

Page 38: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Propositional Calculus

3.2. Propositional Calculus

Definition 3.2.1

An interpretation I is a mapping of the propositions to the truthvalues {true, false} such that:

I (>) = true

I (βŠ₯) = false,

I (Β¬F1) = true if I (F1) = false , otherwise I (Β¬F1) = false,

I (F1 ∧ F2) = true if I (F1) = true and I (F2) = true, otherwiseI (F1 ∧ F2) = false,

I (F1 ∨ F2) = true if I (F1) = true or I (F2) = true (or both),otherwise I (F1 ∨ F2) = false,

...

Page 39: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Propositional Calculus

Definition Cont.

I (F1 β‡’ F2) = false if I (F1) = true and I (F2) = false,otherwise I (F1 β‡’ F2) = true,

I (F1 ⇔ F2) = true if I (F1) = true = I (F2) = true orI (F1) = false = I (F2) = false, otherwise I (F1 ⇔ F2) = false,

I (F1 βŠ• F2) = true if I (F1) = true or I (F2) = true but notboth, otherwise I (F1 βŠ• F2) = false.

The above is best summarized in truth tables. A truth tablepresents all interpretations of a formula.

Page 40: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Models

Definition 3.2.2

An interpretation I is a model of a formula F iff I (F ) = true.

Definition 3.2.3

An interpretation I is a counter-model of a formula F iffI (F ) = false.

Page 41: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Models

Definition 3.2.4

A formula F is a tautology (or is valid) iff all interpretations aremodels.

Definition 3.2.5

A formula F is a contradiction iff no interpretation is model.

Definition 3.2.6

A formula F is a contingency iff it is neither a tautology nor acontradiction.

Page 42: CS1231 Tutorial 2

Truth Tables Propositional Calculus Predicate Calculus

Models

Definition 3.2.7

Let F1 and F2 be two formulae. F2 is a logical consequence of F1,we write F1 |= F2 iff all models of F1 are models of F2.

Definition 3.2.8

Let Fn be formulae. Fn is a logical consequence of F1, ...,Fnβˆ’1, wewrite F1, ...,Fnβˆ’1 |= Fn iff all models common to F1, ...,Fnβˆ’1 aremodels of Fn.

Definition 3.2.9

Let F1 and F2 be two formulae F1 and F2 are logicaly equivalent,we write F1 ≑ F2, iff they have the same models.

Page 43: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Group activity

CS1231 Tutorial 2 Tong W. Ratanapan

Discussion

Page 44: CS1231 Tutorial 2

Outline Tutorial 1 Revision

Discussion

Group activity

CS1231 Tutorial 2 Tong W. Ratanapan

Divide into 5 groups

Each solves one from 2, 3, 4, 5.odd, 5.even