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

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

46 4 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

Định dạng
Số trang 46
Dung lượng 272,79 KB

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

Nội dung

Nguyen An Khuong, Tran Tuan Anh, Le Hong TrangContents Predicate Logic Exercise Predicates Definition A predicate vị từ is a statementcontaining one or more variables.. Nguyen An Khuong,

Trang 1

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Chapter 2

Logics (cont.)

Discrete Structures for Computing on August 31, 2017

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Faculty of Computer Science and Engineering

University of Technology - VNUHCM

Trang 2

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Contents

1 Predicate Logic

2 Exercise

Trang 3

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Course outcomes

Course learning outcomes

L.O.1.1 – Describe definition of propositional and predicate logic

L.O.1.2 – Define basic discrete structures: set, mapping, graphs

L.O.2.1 – Logically describe some problems arising in Computing

L.O.2.2 – Use proving methods: direct, contrapositive, induction

L.O.2.3 – Explain problem modeling using discrete structures

L.O.3.1 – Define basic probability theory

L.O.3.2 – Explain discrete random variables

L.O.4.1 – Operate (compute/ optimize) on discrete structures

L.O.4.2 – Compute probabilities of various events, conditional

ones, Bayes theorem

Trang 4

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

Trang 5

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Predicates

Definition

A predicate (vị từ) is a statementcontaining one or more

variables Ifvalues are assignedto all the variables in a predicate,

the resulting statement is aproposition(mệnh đề )

Example:

• x > 3 (predicate)

• 5 > 3 (proposition)

• 2 > 3 (proposition)

Trang 6

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trang 7

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

Trang 8

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Quantifiers

• ∀: Universal – Với mọi

• ∀xP (x) = P (x) is T for all x

• ∃: Existential – Tồn tại

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

• We need adomain of discoursefor variable

Trang 9

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Example

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

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

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

domain consists of all real number?

Trang 10

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Example

Express the statement “Some student in this class comes from

Central Vietnam.”

Solution 1

• M (x) = x comes from Central Vietnam

• Domain for x isthe students in the class

• ∃xM (x)

Solution 2

• Domain for x is all people

Trang 11

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

• AllCSE students study Discrete Math 1

• Let C(x) denote “x is a CSE student”

• Let S(x) denote “x studies Discrete Math 1”

• ∀x : C(x) → S(x)

• ∃x : ¬(C(x) → S(x)) ≡ ∃x : C(x) ∧ ¬S(x)

• There isa CSE student who does not study Discrete Math 1

Trang 12

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

• ∀x(P (x) → Q(x))

• ∃x(P (x) ∧ ¬R(x))

• ∃x(Q(x) ∧ ¬R(x))

Trang 13

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

The Order of Quantifiers

• Theorderof quantifiers isimportant, unlessall the quantifiers

are universal quantifiers or all are existential quantifiers

• Read from left to right, apply from inner to outer

Trang 14

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating Nested Quantifiers

Example

∀x (C(x) ∨∃y (C(y) ∧ F (x, y)))

Provided that:

• C(x): x has a computer,

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

• x, y ∈ all students in your school

Answer

For every student x in your school, x has a computer orthere isa

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

Trang 15

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating Nested Quantifiers

Example

∃x∀y∀z (((F (x, y) ∧ F (x, z) ∧ (y 6= z)) → ¬F (y, z)))

Provided that:

• F (x, y): x, y are friends

• x, y, z ∈ all students in your school

Answer

There isa student x, so thatfor everystudent y,everystudent z

not the sameas y,ifx and y are friends,andx and z are friends,

then y and z arenotfriends

Trang 16

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating into Logical Expressions

Example

1 “There isa student in the class has visited Hanoi”

2 “Every students in the class have visited Nha Trangor Vung

Tau”

Answer

Assume:

C(x) : x has visited Hanoi

D(x) : x has visited Nha Trang

E(x) : x has visited Vung Tau

We have:

1 ∃xC(x)

2 ∀x(D(x) ∨ E(x))

Trang 17

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating into Logical Expressions

Trang 18

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating into Logical Expressions

Trang 19

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Inference

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

Trang 20

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Propositional Rules of Inferences

Rule of Inference Name

Trang 21

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Propositional Rules of Inferences

Rule of Inference Name

p

∴ p ∨ q Addition(Quy tắc cộng )

p ∧ q

∴ p Simplification(Rút gọn)p

Trang 22

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Example

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

p → q

q → r

∴ p → r

Hypothetical syllogism

Trang 23

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Example

(¬p) and it is colder than

yesterday (q)

it is sunny

we will take a canoe trip (s)

will be home by sunset (t)

• We will be home by sunset (t)

Trang 24

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Fallacies

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?

Trang 25

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Rules of Inference for Quantified Statements

Rule of Inference Name

∴ P (c)for some element c Existential instantiation(Cụ thể hóa tồn tại )

P (c)for some element c

∴ ∃xP (x) Existential generalization(Tổng quát hóa tồn tại )

Trang 26

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Example

• 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???

Trang 27

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

1 ∃x(C(x) ∧ ¬B(x)) Premise

2 C(a) ∧ ¬B(a) Existential instantiation from (1)

3 C(a) Simplification from (2)

4 ∀x(C(x) → P (x)) Premise

5 C(a) → P (a) Universal instantiation from (4)

6 P (a) Modus ponens from (3) and (5)

7 ¬B(a) Simplification from (2)

8 P (a) ∧ ¬B(a) Conjunction from (6) and (7)

9 ∃x(P (x) ∧ ¬B(x)) Existential generalization from (8)

Trang 28

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

value (chân trị) of the following propositions:

Trang 29

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

Determine the truth value of the following propositions:

Trang 30

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

• O(x, y) : x is elder than y

Express each of these statements using predicates:

a) ‘He (a person) has an elder sister and younger brother’

b) ‘All of her brothers are younger than her’

c) ‘Thuyen has only one husband’ (Thuyen is a private name)

d) ‘One of his sisters is younger than him’

e) ‘Everyone has grandfather, grandmother, maternal grandfather,

maternal grandmother’

f) ‘A father of a person cannot be a mother of other ones’

Trang 31

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Solutions:

a) ‘He (a person) has an elder sister and younger brother’

∃x∃y(S(x, m) ∧ O(x, m) ∧ B(y, m) ∧ ¬O(y, m))

b) ‘All of her brothers are younger than her’

∀x(B(x, m) → ¬O(x, m))

c) ‘Thuyen has only one husband’ (Thuyen is a private name)

∃x∀y H(x, Thuyen) ∧ H(y, Thuyen) → (x = y)

or ∃x∀y H(x, Thuyen) ∧ (x 6= y) → ¬H(y, Thuyen)

d) ‘One of his sisters is younger than him’

∃x∀y(S(x, m) ∧ ¬O(x, m) ∧ S(y, m) ∧ (x 6= y) → O(y, m))

e) ‘Everyone has grandfather, grandmother, maternal grandfather,

maternal grandmother’ ∀x∃y∃z∃y1∃y2∃z1∃z2

(F (y, x) ∧ M (z, x) ∧ F (y1, y) ∧ M (y2, y) ∧ F (z1, z) ∧ M (z2, z))

f) ‘A father of a person cannot be a mother of other ones’

∃x∃y∀z(F (x, y) → ¬M (x, z))

Trang 32

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Translating the following nested quantifiers:

Trang 33

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Solutions:

a) B(c, m) ∧ (O(c, m) ∨ O(m, c))

c is a brother (elder/younger) of m

b) B(c, m) ∧ F (a, m) → O(a, c) ∧ F (a, c)

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

c) ∀x∀y(S(x, m) ∧ B(c, y) → x = y)

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

person

d) ∃x((S(x, m) ∨ H(c, x)) ∨ ∃x(H(x, m) ∧ O(x, m)))

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

of m and elder than m

e) ∀x∀y(S(x, m) ∧ S(y, m) → O(x, y) ∨ O(y, x))

All of the sisters of m are older or younger together

Trang 34

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

Trang 35

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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:

weekday.

Trang 36

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

• ∀xM ushroom(x) → ¬(P oisonous(x) ∧ P urple(x))

Trang 37

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

• ∃xM ushroom(x) ∧ P oisonous(x) ∧ P urple(x)

Trang 38

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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"

∃x∃y(P arentOf (P eter, x) ∧ P arentOf (P eter, y) ∧ ¬(x = y))

Trang 39

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Cho P(x) là câu "x nói được tiếng Nga" và Q(x) là câu "x biết

Trang 40

Logics (cont.)

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

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

Trang 41

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Cho các vị từ:

-P(x): "x là một vấn đề toán học"

-Q(x): "x khó" (theo một tiêu chuẩn được định nghĩa tốt

nào đó)

-R(x): "x dễ" (theo một tiêu chuẩn được định nghĩa tốt nào

đó - giống như trên)

-S(x): "x không thể giải được"

Diễn giải những công thức vị từ sau dưới dạng ngôn ngữ tự nhiên

a) ∀x(P (x) → (Q(x) ⇐⇒ ¬R(x)))

b) ∃x(S(x) ∧ ¬P (x))

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

a) Nếu x là một vấn đề toán học thì x là bài toán khó tương

đương với x không dễ

b) Có vấn đề không toán học không thể giải được

Trang 42

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Dịch các bản mô tả sau đây sang tiếng Việt trong đó F (p) là

việc in vẫn phải chờ, thì sẽ có một việc in nào đó bị mất.

Trang 43

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Chuyển các câu sau sang vị từ, lượng từ và toán tử logic:

Trang 44

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Cho các vị từ sau:

- P(x): Chương trình x đáp ứng chuẩn ABET

- Q(x,y): Chương trình x có mục tiêu đào tạo giống chương

trình y

- R(x): Kết quả đầu ra của chương trình x là có thể kiểm

chứng được

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 chuẩn ABET"

A) ∀x(P (x) ∧ ¬Q(x)) → ∃x(R(x))

B) ∀x(∃y(Q(x, y) ∧ P (y) ∧ R(x)) → P (x))

C) ∀x(∃y(Q(x, y) ∧ P (y) ∧ R(x)) → P (x) ∨ R(x))

D) ∀x(∀y(Q(x, y) ∧ P (y) ∨ R(x)) → P (x))

Trang 45

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Trong câu hỏi này giả sử các vị từ:

- P (x, y): x là phụ huynh của y

Trang 46

Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang

Contents Predicate Logic Exercise

Chuyển các câu sau sang vị từ, lượng từ và toán tử logic:

a) Khi ổ cứng còn ít hơn 30 GB, một thông điệp cảnh báo sẽ

được gửi tới mọi người dùng

b) Không được sao lưu hệ thống tập tin nếu có một người nào đó

đang đăng nhập vào hệ thống

c) Đoạn phim Youtube sẽ được buffer khi còn ít nhất 8 MB bộ

nhớ và tốc độ đường tuyền tối thiểu là 56 kbits/s

d) Chỉ vài sinh viên máy tính lập trình tốt

e) Không một sinh viên máy tính nào không cần cù

f) Không phải tất cả các sinh viên máy tính đều thông minh

g) Tất cả người Pompei hoặc trung thành với Caesar hoặc ghét

ông ta

h) Mỗi người đều trung thành với một người nào đó

i) Người ta chỉ muốn ám sát những nhà cầm quyền mà người ta

không trung thành

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

TRÍCH ĐOẠN

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

TÀI LIỆU LIÊN QUAN

w