1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Chapter 2 logics (cont ) discrete structures for computing on august 31, 2017

54 3 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Logics (cont.) Discrete Structures for Computing
Tác giả Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Trường học University of Technology - VNUHCM
Chuyên ngành Computer Science and Engineering
Thể loại thesis
Năm xuất bản 2017
Thành phố HCM
Định dạng
Số trang 54
Dung lượng 403,34 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Discrete Structures for Computing on August 31, 2017 Nguyen An Khuong, Tran Tuan Anh, Le HongTrang Faculty of Computer Science andEngineering University of Technology - VNUHCM Nguyen An

Trang 1

Chapter 2

Logics (cont.)

Discrete Structures for Computing on August 31, 2017

Nguyen An Khuong, Tran Tuan Anh, Le HongTrang Faculty of Computer Science andEngineering University of Technology - VNUHCM

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 2

1 Predicate Logic

2 Exercise

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 3

Contents Predicate Logic Exercise

Trang 4

Limits of Propositional Logic

x > 3

All square numbers are not prime numbers 100 is a

square number Therefore 100 is not a prime number

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic Exercise

Trang 5

Definition

variables If values are assigned to all the variables in a

Contents Predicate Logic Exercise

Trang 6

Contents Predicate Logic Exercise

Trang 7

Truth value

x > 3 is true or false?

5 > 3

For every number x; x > 3 holds

There is a number x such that x > 3

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 8

8xP (x) = P (x) is T for all x

9xP (x) = There exists an element x such that P (x) is T

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 9

Let P (x) be the statement x < 2 What is the truth value of the

quantification 8xP (x), where the domain consists of all real

What is the truth value of the quantification 9xP (x), where

the domain consists of all real number?

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 10

Express the statement Some student in this class comes

from Central Vietnam

Solution 1

M(x) = x comes from Central Vietnam

Domain for x is the students in the class

Contents Predicate Logic

Exercise

Trang 11

Negation of Quantifiers

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Exam pleAll

CSE

tudents stud

y Discrete Math1C(x) deno

te x

is a CSE student

Trang 12

Let S(x) denote x studies Discrete Math 1

8x : C(x) ! S(x)

9x : :(C(x) ! S(x)) 9x : C(x) ^ :S(x)

There is a CSE student who does not study

Discrete Math 1 ContentsPredicate Logic

Exercise

2.11

Trang 13

Another Example

Example

Translate these:

All lions are fierce

Some lions do not drink coffee

Some fierce creatures do not drink coffee

Solution

Let P (x), Q(x) and R(x) be the statements x is a lion , x is

fierce and x drinks coffee , respectively

Contents

Predicate Logic

Exercise

Trang 14

The Order of Quantifiers

The order of quantifiers is important, unless all the quantifiers

are universal quantifiers or all are existential quantifiers

Read from left to right, apply from inner to outer

Contents

Predicate Logic

Exercise

Trang 15

Translating Nested Quantifiers

Example

8x (C(x) _ 9y (C(y) ^ F (x; y)) )

Provided that:

C(x): x has a computer,

F (x; y): x and y are friends,

x; y 2 all students in your school

Answer

For every student x in your school, x has a computer or there is a

student y such that y has a computer and x and y are friends

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 16

Translating Nested Quantifiers

Example

9x8y8z (((F (x; y) ^ F (x; z) ^ (y 6= z)) ! :F (y; z)))

Provided that:

F (x; y): x; y are friends

x; y; z 2 all students in your school

Answer

There is a student x, so that for every student y, every student

z not the same as y, if x and y are friends, and x and z are

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 17

Translating into Logical Expressions

Example

1 There is a student in the class has visited Hanoi

2 Every students in the class have visited Nha Trang or

Answer

Assume:

C(x) : x has visited Hanoi

D(x) : x has visited Nha Trang

E(x) : x has visited Vung Tau

Contents Predicate Logic Exercise

Trang 18

Translating into Logical Expressions

Contents Predicate Logic Exercise

Trang 19

Translating into Logical Expressions

Example

If a person is a woman and a parent, then this person is

mother of some one

Contents

Predicate Logic

Exercise

Trang 20

Example

If I have a girlfriend, I will take her to go shopping

Whenever I and my girlfriend go shopping and that day is a

special day, I will surely buy her some expensive gift

If I buy my girlfriend expensive gifts, I will eat noodles

for a week

Today is March 8

March 8 is such a special day

Therefore, if I have a girlfriend,

I will eat noodles for a week

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 21

Propositional Rules of Inferences

Rule of Inference

p

p ! q) q

:q

p ! q) :p

p ! q

q ! r

Trang 22

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 23

Propositional Rules of Inferences

Rule of Inference

Trang 24

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 25

If it rains today, then we will not have a barbecue today If we

do not have a barbecue today, then we will have a barbecue

tomorrow Therefore, if it rains today, then we will have a

barbecue tomorrow

Solution

p: It is raining today

q: We will not have a barbecue today

r: We will have barbecue tomorrow

Contents Predicate Logic Exercise

Trang 26

It is not sunny this afternoon

(:p) and it is colder than

yesterday (q)

We will go swimming (r) only if

it is sunny

If we do not go swimming, then

we will take a canoe trip (s)

If we take a canoe trip, then we

will be home by sunset (t)

We will be home by sunset (t)

Trang 28

Definition

Fallacies (ngöy bi»n) resemble rules of inference but are

based on contingencies rather than tautologies

Example

If you do correctly every questions in mid-term exam, you will

get 10 grade You got 10 grade

Therefore, you did correctly every questions in mid-term

exam Is [(p ! q) ^ q] ! p a tautology?

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 29

Rules of Inference for Quantified Statements

Rule of Inference

8xP (x)) P (c)

P (c)for an arbitrary c) 8xP (x)

Trang 30

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 31

A student in this class has not gone to class

Everyone in this class passed the first exam

Someone who passed the first exam has not gone to class

Hint

C(x): x is in this class

B(x): x has gone to class

P (x): x passed the first

exam Premises???

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 32

1 9x(C(x) ^ :B(x)) Premise

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 33

Given the predicate p(x) :00 x2 3x + 2 = 000 What is the

truth value (ch¥n trà) of the following propositions:

Contents Predicate Logic Exercise

Trang 34

Let x; y 2 Z+, and the predicate: p(x; y): "x is a divisor of y"

Determine the truth value of the following propositions:

Contents Predicate Logic

Exercise

Trang 35

O(x; y) : x is elder than y.

Express each of these statements using predicates:

grandfather, maternal grandmother’

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 36

9x9y(S(x; m) ^ O(x; m) ^ B(y; m) ^ :O(y; m))

8x(B(x; m) ! :O(x; m))

9x8y H(x; Thuyen) ^ H(y; Thuyen) ! (x = y)

or 9x8y H(x; Thuyen) ^ (x 6= y) ! :H(y; Thuyen)

9x8y(S(x; m) ^ :O(x; m) ^ S(y; m) ^ (x 6= y) ! O(y; m))

Contents

Predicate Logic

Exercise

Trang 37

Translating the following nested quantifiers:

Contents Predicate Logic Exercise

Trang 38

c is a brother (elder/younger) of m

If c is a brother of m and a is a father of m, then a is

elder than c and a is the father of c

Whoever is the sister of m, then c is also a brother of

that person

There is a sister of m or c is her husband, or there is a

husband of m and elder than m

All of the sisters of m are older or younger together

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 39

Given a predicate N(x) "x has been to Da Lat" with the

domain is the all students in Mathematics class Translate the

following predicates into English

a)There is a student in this class has been to Da Lat.

b)All students in Math class have been to Da Lat.

c)There is no exists a student in Math class has gone to Da Lat.

d)There is a student in this class has never gone to Da Lat.

f) All students

in Math class have never been to

Da Lat.

Trang 40

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 41

Given the predicate N(x) "x studies more than 5 hours in

class every weekday" with the domain is the all students in

Mathematics class Express the following predicates:

b)All of the students in Math class study over 5 hours every weekday.

c)There is a student who does not study in the class over 5 hours every

weekday.

d)There are no student studies in the class over 5 hours every weekday.

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic Exercise

Trang 42

H¢y cho bi‚t cæng thøc và tł cıa o⁄n m¢ gi£ (pseudo code) sau:

for (i = 0; i<numObjects; i++) {

There are no mushrooms that are poisonous and purple

8xM ushroom(x) ! :(P oisonous(x) ^ P urple(x))

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 43

H¢y cho bi‚t cæng thøc và tł cıa o⁄n m¢ gi£ (pseudo code) sau:

for (i=0; i<numObjects; i++) {

There is a mushroom that is purple and poisonous

9xM ushroom(x) ^ P oisonous(x) ^ P urple(x)

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 44

Cho o⁄n m¢ gi£ (pseudo code) sau:

// Look for first match

for (x=0; x<numKids; x++)

if isParent(Peter, kids[x])

match1Found = true;

// Now look for a second match

for (y=0; (y<numKids)&&(y!=x); y++)

if isParent(Peter, kids[y])

match2Found = true;

return match1Found && match2Found;

Bi‚t r‹ng: M£ng kids gçm 3 phƒn tß: { Alice, Bob, Charles } v

Peter ch¿ câ 1 con l Alice

H¢y cho bi‚t cæng thøc và tł cıa c¥u "Peter câ ‰t nh§t 2 con"

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 45

Cho P(x) l c¥u "x nâi ÷æc ti‚ng Nga" v Q(x) l c¥u "x bi‚t

a)Câ mºt sinh vi¶n ð tr÷íng b⁄n nâi ÷æc ti‚ng Nga v bi‚t Java.

b)Câ mºt sinh vi¶n ð tr÷íng b⁄n nâi ÷æc ti‚ng Nga nh÷ng khæng bi‚t Java.

c)Måi sinh vi¶n ð tr÷íng b⁄n •u nâi ÷æc ti‚ng Nga ho°c bi‚t Java.

d)Khæng câ mºt sinh vi¶n n o ð tr÷íng b⁄n nâi ÷æc ti‚ng Nga ho°c bi‚t

Contents

Predicate Logic

Exercise

Trang 46

Cho L(x,y) l c¥u "x y¶u y", vîi khæng gian cıa c£ x v y l t“p

hæp måi ng÷íi tr¶n th‚ giîi H¢y dòng c¡c l÷æng tł ” di„n ⁄t c¡c

c¥u sau

a)Måi ng÷íi •u y¶u Jerry.

b)Måi ng÷íi •u y¶u mºt ai â.

c)Câ mºt ng÷íi m t§t c£ måi ng÷íi •u y¶u.

d)Khæng câ ai y¶u t§t c£ måi ng÷íi.

e)Câ mºt ng÷íi m Lydia khæng y¶u.

f)Câ mºt ng÷íi m khæng ai y¶u.

g)Câ óng mºt ng÷íi m t§t c£ måi ng÷íi •u y¶u.

h)Câ óng hai ng÷íi m Lynn y¶u.

i)Måi ng÷íi •u y¶u ch‰nh m…nh.

j) Câ mºt ng÷íi n o â khæng y¶u ai ngo i ch‰nh m…nh.

z = y)))

x)j) 9x8y(L(x; y) ! x = y)

Trang 47

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 48

V… câ nhi•u c¡ch di„n ⁄t mºt cæng thøc và tł d÷îi d⁄ng ngæn

ngœ tü nhi¶n v sau ¥y l mºt c¡ch

÷ìng vîi x khæng d„

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 49

Dàch c¡c b£n mæ t£ sau ¥y sang ti‚ng Vi»t trong â F (p) l

b)N‚u t§t c£ m¡y in •u ang b“n in t i li»u th… s‡ câ t i li»u ang æi ÷æc in.

c)N‚u mºt t i li»u ang ÷æc æi in nh÷ng l⁄i bà m§t, chøng tä câ m¡y in n o â

¢ bà häng.

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 50

Chuy”n c¡c c¥u sau sang và tł, l÷æng tł v to¡n tß logic:

a)Khæng câ ai l ho n h£o.

b)Khæng ph£i måi ng÷íi •u ho n h£o.

c)T§t c£ b⁄n b– cıa b⁄n •u ho n h£o.

d)t nh§t câ mºt øa b⁄n cıa b⁄n l ho n h£o.

e)Måi ng÷íi •u l b⁄n cıa b⁄n v hå ho n h£o.

f)Khæng ph£i t§t c£ måi ng÷íi l b⁄n cıa b⁄n ho°c câ ai â khæng ho n h£o.

=) :8xD(x) _9yC(y)

Trang 51

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Trang 52

M»nh • và tł n o sau bi”u di„n c¥u : "Måi ch÷ìng tr…nh o t⁄o n‚u

câ möc ti¶u giŁng mºt ch÷ìng tr…nh kh¡c ¢ ¡p øng chu'n ABET

v k‚t qu£ ƒu ra câ th” ki”m chøng ÷æc th… công tu¥n theo

Contents Predicate Logic Exercise

Trang 53

Trong c¥u häi n y gi£ sß c¡c và tł:

Contents Predicate Logic Exercise

Trang 54

Chuy”n c¡c c¥u sau sang và tł, l÷æng tł v to¡n tß logic:

b¡o s‡ ÷æc gßi tîi måi ng÷íi dòng

ang «ng nh“p v o h» thŁng

bº nhî v tŁc º ÷íng tuy•n tŁi thi”u l 56 kbits/s

gh†t æng ta

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents

Predicate Logic

Exercise

Ngày đăng: 23/01/2022, 09:42

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w