งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

Chapter 1 Mathematics and Computer Science

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "Chapter 1 Mathematics and Computer Science"— ใบสำเนางานนำเสนอ:

1 Chapter 1 Mathematics and Computer Science
Reference M. Morris Mano, Computer System Architecture, 3rd Edition, Prentice-Hall. K. H. Rosen, Discrete Mathematics and Its Applications, 5th Edition, McGraw-Hill. 1/

2 Outline Boolean Algebra Logic Circuit Proof Techniques

3 5.1 Boolean Algebra 1854 George Boole นักคณิตศาสตร์ชาวอังกฤษ พีชคณิต
Binary Variables Logic Operations สามารถนำไปประยุกต์กับ การออกแบบวงจรตรรกะ (Logic Circuit)

4 5.1 Boolean Algebra Definition: Let B = {0, 1}. The variable x is called a Boolean variable if it assumes values only from B. ค่า Boolean Variable ได้แก่ ค่าที่เป็นลักษณะฐานสอง เช่น 1/0, true/false, on/off, high/low เป็นต้น เขียน Boolean Variable แทนด้วยตัวอักษรภาษาอังกฤษ เช่น A, B, F, x, y, z

5 5.1 Boolean Algebra Logic Operation ประกอบด้วย Operation พื้นฐาน 3 อย่าง คือ AND เขียนแทนด้วยสัญลักษณ์ * • “ ”   เช่น A AND B, A*B, A•B, AB, A  B, A  B OR เขียนแทนด้วยสัญลักษณ์ +  V เช่น A OR B, A+B, A  B, A V B Complement เขียนแทนด้วยสัญลักษณ์ ~ / ´ เช่น ~A, A, /A, A´

6 5.1 Boolean Algebra Truth Table A A 0 1 1 0 A B AB 0 0 0 0 1 0 1 0 0
Complement, Inverter A B AB Boolean Product A B A+B Boolean Sum

7 5.1 Boolean Algebra การเขียน Boolean Function F(x, y, z) = x + yz
เขียนในรูปแบบพีชคณิต เรียกว่า Boolean Expression Boolean Variables, Logic Operation Symbols, (, ) และ = เช่น F = x + yz F(x, y, z) = x + yz ผลลัพธ์ของ Boolean Function จะให้ค่า 0 หรือ 1 ขึ้นอยู่กับค่าของ Boolean Variables ที่กำหนด

8 5.1 Boolean Algebra ความสัมพันธ์ระหว่าง Boolean Function และ Boolean Variables สามารถแสดงได้ด้วย Truth Table เช่น F = x + y´z x y z y´ y´z F 1 1 1 1 1 1

9 5.1 Boolean Algebra แต่ละ Boolean Function เขียนเป็น Boolean Expression ได้หลายแบบ ประยุกต์ Boolean Algebra Rules บางนิพจน์จะอยู่ในรูปแบบที่ง่ายกว่านิพจน์อื่น นำไปสร้างเป็นวงจรจะได้วงจรที่ง่ายขึ้น ประกอบด้วย Gate น้อยลง Gates are blocks of hardware that produce signal of binary 1 or 0 when input logic requirements are satisfied.

10 Basic Boolean Identities
(x´)´ = x Law of the double complement x + x = x x · x = x Idempotent laws x + 0 = x x · 1 = x Identity laws x + 1 = 1 x · 0 = 0 Domination laws x+y = y+x xy = yx Commutative laws x+(y+z) = (x+y)+z x(yz) = (xy)z Associative laws x+yz = (x+y)(x+z) x(y+z) = xy+xz Distributive laws (xy)´ = x´+y´ (x+y)´ = x´y´ DeMorgan’s laws x+xy = x x(x+y) = x Absorption laws x+x´ = Unit property xx´ = Zero property

11 5.1 Boolean Algebra กรณี DeMorgan’s Theorem มักใช้กับ NOR หรือ NAND Gates NOR Gate NAND Gate x (x + y)´  x´y´ x y y x (xy)´ = x´ + y´ x y y

12 5.1 Boolean Algebra ทุก Identity ที่ระบุสามารถพิสูจน์ได้ด้วย Truth Table ตัวอย่างที่ 1 AB´ + C´D + AB´ + C´D ให้ x = AB´ + C´D เราสามารถเขียนนิพจน์ข้างบนใหม่ว่า x + x จาก Idempotent x + x = x นิพจน์ข้างต้นสามารถลดรูปได้ว่า AB´ + C´D + AB´ + C´D = AB´ + C´D

13 5.1 Boolean Algebra ตัวอย่างที่ 2 F = ABC + ABC´ + A´C
F = AB(C+C´) + A´C - Distributive law = AB(1) + A´C - Unit property = AB + A´C - Identity law

14 5.1 Boolean Algebra ตัวอย่างที่ 3 จงพิสูจน์ Absorption law x(x+y) = x
x (x + y) = (x + 0)(x + y) Identity law for the Boolean sum = x + 0 · y Distributive law of the Boolean sum over the Boolean product = x + y · 0 Commutative law for the Boolean product = x + 0 Domination law for the Boolean product = x Identity law for the Boolean sum

15 5.1 Boolean Algebra ตัวอย่างที่ 4 ให้หาค่าของ F(x, y, z) = xy + z´
x y z xy z´ F(x,y,z) = xy + z´ 1 1 1 1 1 1

16 5.1 Exercise 1. หาผลลัพธ์ของนิพจน์ต่อไปนี้ 1 · 0´ = ? 1 + 1´ = ?
1 · 0´ = ? 1 + 1´ = ? 0´ · 0 = ? (1+0)´ = ?

17 5.1 Exercise 2. ให้หาว่าค่า Boolean Variable x จะต้องมีค่าเท่าใด
x + x = 0 x · 1 = x x · x´ = 1

18 5.1 Exercise 3. ให้ลดรูป Expression ด้วย Boolean Algebra A + AB
AB + AB´ A´BC + AC A´B + ABC´ + ABC

19 5.1 Exercise 4. ให้ลดรูป Expression ด้วย Boolean Algebra
AB + A(CD + CD´) (BC´ + A´D) (AB´ + CD´) 5. ให้ใช้ DeMorgan’s Theorem เพื่อแสดงว่า (A + B)´ (A´ + B´) ´ = 0 A + A´B + A´B´ = 1

20 5.1 Exercise 6. แสดง Truth Table ของ Boolean Function ต่อไปนี้
F(x, y) = x´y F(x, y, z) = x + yz F(x, y, z) = xy´+(xyz)´ F(x, y, z) = x(yz+(yz)´) 7. จงพิสูจน์ Absorption law x + xy = x โดยใช้กฎข้ออื่น ๆ 8. ให้พิสูจน์ว่า xy´+yz´+x´z = x´y+y´z+xz´

21 5.1.1 Representing Boolean Functions
จากค่าของ Boolean Function ที่ให้ หากต้องการหาว่า Boolean Expression ของฟังก์ชันดังกล่าวคืออะไร ทุก Boolean Function สามารถแทนด้วย Boolean Sum of Boolean products ของ Boolean Variables และ Complements

22 5.1.1 Representing Boolean Functions
x y z F G จากตารางค่าความจริงให้หานิพจน์ของ F และ G วิธีทำ เลือกนิพจน์ที่ทำให้ F มีค่า 1 คือ x=z= 1 และ y = 0 นิพจน์อื่น ๆ ทำให้ F มีค่าเป็น 0 ไม่ต้องสนใจ แทนด้วย Boolean product ของ x, y´, z F = xy´z นิพจน์ที่ทำให้ G มีค่า 1 นำมาแทนด้วย Boolean sum of Boolean products G = x´yz´ + xyz´

23 5.1.1 Representing Boolean Functions
Definition A literal is a Boolean variable or its complement A minterm of the Boolean variables x1, x2, ..., xn is a Boolean product y1y2...yn where yi = xi or yi = xi. Hence, a minterm is a product of n literals, with one literal for each variable.

24 5.1.1 Representing Boolean Functions
ตัวอย่างที่ 5 หา Minterm ที่เท่ากับ 1 ถ้า x1=x3= 0 และ x2=x4=x5=1 และมีค่าเท่ากับ 0 ในกรณีอื่น Minterm คือ x1x2x3x4x5

25 5.1.1 Representing Boolean Functions
จากค่าใด ๆ ที่ระบุ เราสามารถเขียน Boolean Express ในรูปของBoolean sums ของกลุ่ม Minterm (Boolean product) Boolean sums ให้ค่าเป็น 1 เมื่อ Minterm ให้ค่า 1 ให้ค่าเป็น 0 เมื่อ Minterm ให้ค่า 0 Sum ของ Minterm นี้มีชื่อเรียกว่า Sum-of-products expansion หรือ Disjunctive normal form ของ Boolean Function

26 5.1.1 Representing Boolean Functions
ตัวอย่างที่ 6 ให้หาค่า Sum-of-products expansion ของฟังก์ชัน F(x, y, z) = (x+y)z´ มีวิธีการหา 2 วิธี วิธีแรก ใช้ Boolean Identities F(x, y, z) = (x+y) z´ = x z´ +y z´ Distributive law = x1z´+1yz´ Identity law = x(y+y´)z´+(x+x´)yz´ Unit property = xyz´+xy´z´+xyz´+x´yz´ Distributive law = xyz´+xy´z´+ x´yz´ Idempotent law

27 5.1.1 Representing Boolean Functions
xyz´ F = + xy´z´ + x´yz´ วิธีที่สอง หาจากค่า F x y z x+y z´ F(x,y,z) = (x+y)z´ 1 1 1 1 1 1

28 5.1.1 Exercise ให้หา sum-of-products expansion ของ Boolean Function ต่อไปนี้ F(x, y) = x´+ y F(x, y) = xy´ F(x, y, z) = x + y + z F(x, y, z) = (x+z)y F(x, y, z) = x F(x, y, z) = xy´

29 5.2 Logic Circuits ปี ค.ศ C.E. Shannon นำ Boolean Algebra มาใช้ในวิชา Theory of Switching Circuits เน้นไปในด้านการออกแบบสวิทซ์แม่เหล็กไฟฟ้า (Electromechanical Relay Network) ใช้ในวงจรแบบ Solid-state Electronic ได้ดี

30 5.2 Logic Circuits ประโยชน์หนึ่งของ Boolean Algebra คือ ช่วยอำนวยความสะดวกในการวิเคราะห์และออกแบบวงจรดิจิตอล (Digital Circuits) Boolean Algebra มีเครื่องมือต่าง ๆ ที่ช่วยดังนี้ อธิบายความสัมพันธ์ของ Binary Variables ในรูปของ Truth Table อธิบายความสัมพันธ์ของ Input และ Output ในรูปของ Logic Diagram สามารถหาวงจรที่ง่ายกว่าได้สำหรับฟังก์ชันเดียวกัน

31 5.2 Logic Circuits Truth Table A B AB A A 0 0 0 0 1 0 1 0 1 0 1 0 0
A A INVERTER GATE AND GATE A B A XOR B A XOR B = AB + AB A B A+B XOR GATE OR GATE

32 5.2 Logic Circuits Gates with n inputs x1x2 ...xn x1+x2 ...+xn x1 x2

33 5.2 Boolean Algebra ความสัมพันธ์ระหว่าง Boolean Function และ Boolean Variables สามารถแสดงได้ด้วย Truth Table x y z F F = x + y´z y z x F

34 5.2 Logic Circuits โดยที่ Input และ Output ที่เกิดขึ้นจะมีค่าอยู่ใน {0, 1} คอมพิวเตอร์ หรืออุปกรณ์อิเล็กทรอนิกส์ต่าง ๆ สร้างขึ้นจากวงจร (Circuit) มาประกอบเข้าด้วยกัน แต่ละวงจรออกแบบขึ้นมาโดยใช้กฎของ Boolean Algebra องค์ประกอบที่เล็กที่สุดของวงจร เรียกว่า Gate แต่ละ Gate จะทำให้เกิด Boolean Operation Gates are blocks of hardware that produce signal of binary 1 or 0 when input logic requirements are satisfied.

35 5.2 Logic Circuits Gate หลาย ๆ Gate จะประกอบรวมกันเพื่อทำงานอย่างใดอย่างหนึ่ง เรียกว่า Circuit โดยที่ Circuit เหล่านี้จะไม่มีหน่วยความจำภายในตัวเอง แต่จะให้ผลลัพธ์อย่างใดนั้น จะต้องขึ้นอยู่กับข้อมูลจาก Input ที่รับเข้ามา เรียก Circuit เหล่านี้ว่า Combinational Circuit (วงจรรวม) หรือ Gate Networks

36 5.2.1 Combinations of Gates Combinational Circuit สามารถสร้างขึ้นจากการรวมกลุ่มของ Inverter, OR gate, และ AND gate สอดคล้องกับ Boolean Operation พื้นฐานของ Boolean Algebra การวาด Combinational Circuits หลาย Gate ใช้ Input ร่วมกัน แยก Input สำหรับแต่ละ Gate

37 5.2.1 Combinations of Gates ตัวอย่างการวาดวงจร F = xy+xy
Gate รับสัญญาณจาก Input แยกเส้นกัน

38 5.2.1 Combinations of Gates ตัวอย่างการวาดวงจร F = xy+xy
Gate รับสัญญาณจาก Input เส้นเดียวกัน

39 5.2.1 Exercise ให้วาดวงจรต่าง ๆ ต่อไปนี้ F = (x + y) x F = x (y + z)
F = (x + y + z) (x y z)

40 5.2.1 ตัวอย่าง กรณี 3 สวิทซ์ ทำเป็นการบ้าน
Sometimes light fixtures are controlled by more than one switch. Circuits need to be designed so that flipping any one of the switches for the fixture turns the light on when it is off and turns the light off when it is on. Design circuits that accomplish this when there are two switches and when there are three switches. กรณี 3 สวิทซ์ ทำเป็นการบ้าน สมมติให้มี 2 สวิทซ์ คือ x และ y ถ้ามีค่าเป็น 1 แสดงว่า สวิทซ์ปิด ถ้ามีค่าเป็น 0 แสดงว่า สวิทซ์เปิด

41 5.2.1 ตัวอย่าง ลองสมมติค่า x, y กรณีต่าง ๆ ที่เป็นไปได้
F(x, y) = 1 แสดงว่าไฟเปิด F(x, y) = 0 แสดงว่าไฟปิด ลองสมมติค่า x, y กรณีต่าง ๆ ที่เป็นไปได้ ถ้าสวิทซ์ทั้ง 2 ปิด ไฟจะเปิด F(1, 1) = 1 ถ้าสวิทซ์ใดสวิทซ์หนึ่งเปิด ไฟจะปิด F(1, 0) = F(0, 1) = 0 ถ้าสวิทซ์ทั้ง 2 เปิด ไฟจะเปิด F(0, 0) = 1

42 5.2.1 ตัวอย่าง จะได้ Truth Table ดังนี้ ให้วาดวงจรดังกล่าว F = xy + xy
x y F(x, y) จะได้ Truth Table ดังนี้ F = xy + xy ให้วาดวงจรดังกล่าว

43 5.2.1 Exercise ให้หา Boolean Function, Truth Table, วาดวงจร
A committee of three individuals decides issues for an organization. Each individual votes either yes or no for each proposal that arises. A proposal is passed if it receives at least two yes votes. Design a circuit that determines whether a proposal passes. ให้หา Boolean Function, Truth Table, วาดวงจร click for answer F = xyz’ + xy’z + x’yz + xyz

44 5.2.2 Adders วงจรนี้เรียกว่า Multiple Output Circuit
เนื่องจากให้ผลลัพธ์มากกว่าหนึ่งค่านี้ วงจรแรกเรียกว่า Half Adder เนื่องจากเป็นการบวกเลข 2 bit โดยไม่สนใจตัวทดจาก bit ที่มาก่อนหน้านั้น เราสามารถเขียน Truth Table ของวงจรนี้จากความรู้เรื่องการบวกเลขฐานสอง และนำไปคำนวณหา Boolean Function ซึ่งจะนำไปเขียนวงจรได้

45 5.2.2 Adders Truth Table s = x y + x y = (x + y)(xy) c = x y x y s c
input output x y s c s = x y + x y = (x + y)(xy) c = x y

46 5.2.2 Adders กรณี Full Adder คือ การบวกโดยที่สนใจตัวทด
มี Input 3 ตัว คือ x, y, ci ให้ Output 2 ตัว คือ s, ci+1

47 5.2.2 Adders ได้ Truth Table คือ x y ci ci+1 s 0 0 0 0 0 0 0 1 0 1
s = xyci+xyci+xyci+xyci ci+1 = xyci+xyci+xyci+xyci

48 5.2.2 Adders ปกติเราจะใช้วงจร Half Adder ในการสร้าง Full Adder
s = xyci+xyci+xyci+xyci ci+1 = xyci+xyci+ xyci+xyci

49 5.2.2 Exercise กำหนด Boolean Function F = xy´z + x´y´z + xyz
เขียน Truth Table ของฟังก์ชันดังกล่าว วาด Logic Diagram ของฟังก์ชันที่ให้ ลดรูปของฟังก์ชันด้วย Boolean Algebra เขียน Truth Table ของฟังก์ชันที่ลดรูปแล้ว วาด Logic Diagram ของฟังก์ชันที่ลดรูปแล้ว เปรียบเทียบ Truth Table และ Logic Diagram ของฟังก์ชันทั้งสอง

50 5.2.3 Minimizing of Circuits
ประสิทธิภาพของ Combinational Circuit จะขึ้นอยู่กับจำนวนและการจัดเรียงของ Gate กระบวนการออกแบบวงจรเบื้องต้น มีดังนี้ กำหนด Input Output และค่าของสถานะ สร้าง Truth Table ของ Output ที่เกิดจาก Input ต่าง ๆ กัน (แสดงความสัมพันธ์ระหว่าง Input กับ Output) สร้างฟังก์ชัน ลดรูปฟังก์ชันนั้นให้ง่ายที่สุด ออกแบบวงจร

51 5.2.3 Minimizing of Circuits
ปัญหา ผลลัพธ์ที่ได้ที่อยู่ในรูปของ Sum-of-product Expansion อาจจะอยู่ในรูปที่ซับซ้อนมาก เนื่องจาก เทอมของ Product ต้องมี Variable ครบทุกตัว สมมติให้ Circuit มีผลลัพธ์เท่ากับ 1 iff x=y=z=1 และ เมื่อ x=z=1 และ y=0 เขียนสมการได้ว่า xyz + xy’z = xz(y+y’) = xz · 1 = xz เมื่อเขียนวงจรออกมา จะพบว่า วงจรทั้งสองมีความยุ่งยากที่ต่างกัน

52 5.2.3 Minimizing of Circuits
Karnaugh Map (K-map) ออกแบบโดย Maurice Karnaugh เมื่อปี 1953 มีเป้าหมายเพื่อที่จะลดความซับซ้อนของวงจรด้วยมือ ใช้ได้ตัวแปรสูงสุด 6 ตัว

53 5.2.3 Minimizing of Circuits
การใช้ K-maps กับตัวแปร 2 ตัว x, y หากแทนด้วย sum-of-product expansion จะประกอบด้วย minterm สูงสุด 4 term คือ xy, xy’, x’y, xy เขียนเป็น k-maps ได้ว่า y x y’(0) y(1) x’(0) 00 01 10 11 x(1)

54 5.2.3 Minimizing of Circuits
y x 1 ตัวอย่าง ให้เขียน K-maps xy + x’y xy’ + x’y xy’ + x’y + x’y’ 1 1 y x 1 1 1 y x 1 1 1

55 5.2.3 Minimizing of Circuits
เราสามารถรวม minterm เข้าด้วยกันจาก K-maps กรณีที่มี 1 อยู่ใน Cell ที่เป็น Adjacent กัน สามารถลดตัวแปรที่ต่างกัน เหลือเพียงตัวแปรที่เหมือนกัน ตัวอย่างเช่น xy + x’y xy + x’y = y เทียบกับการใช้กฎ xy + x’y = y(x+x’) = y · 1 = y y x 1 1 1 y

56 5.2.3 Minimizing of Circuits
ตัวอย่าง xy’ + x’y y x 1 1 1 xy’ + x’y

57 5.2.3 Minimizing of Circuits
ตัวอย่าง xy’ + x’y + x’y’ y x 1 1 x’ 1 y’ xy’+x’y+x’y’ = xy’+x’(y+y’) = xy’+x’ = (x’+x)(x’+y’) = x’+y’

58 5.2.3 Minimizing of Circuits
กรณีที่มี 1 อยู่ใน Cell ทั้ง 4 สามารถลด 4 minterm เหลือเพียง 1 minterm เรียกว่า Boolean expression 1 ซึ่งไม่ต้องมีตัวแปรเลย ใช้การวงรอบ cell ของ minterm ที่รวมกันได้ ต้องพยายามวงรอบให้ใด้วงที่ใหญ่ที่สุดที่เป็นไปได้ map ที่เห็นสามารถม้วนทุก ๆ ด้านเข้าหากัน

59 5.2.3 Minimizing of Circuits
สำหรับ 3 ตัวแปร เลขบิตจะเปลี่ยน step เดียว BC A 00 01 11 10 1

60 5.2.3 Minimizing of Circuits
ตัวอย่างสำหรับ 3 ตัวแปร BC A 00 01 11 10 B’C = A’B’C+AB’C 1 BC A 00 01 11 10 AC’ = AB’C’+ABC’ 1

61 5.2.3 Minimizing of Circuits
Exercise BC A 00 01 11 10 C = A’B’C+AB’C+A’BC+ABC 1 BC A 00 01 11 10 A = AB’C’+AB’C+ABC+ABC’ 1

62 5.2.3 Minimizing of Circuits
Exercise BC A 00 01 11 10 1 = A’B’C’+A’B’C+A’BC+A’BC’+ AB’C’+AB’C+ABC+ABC’ 1 BC A 00 01 11 10 C’ = A’B’C’+A’BC’+AB’C’+ABC’ 1

63 5.2.3 Minimizing of Circuits
ให้ใช้ k-map เพื่อลดค่า sum-of-product expansion เหล่านี้ AB’C’+ABC+A’B’C+A’BC AB’C’+ABC+ABC’+A’BC’ A’B’C’+A’B’C+A’BC+A’BC’+AB’C’+ABC+ABC’ A’B’C+A’BC+ABC+ABC’

64 5.2.3 Minimizing of Circuits
ตัวอย่างการลดค่าสำหรับ 3 ตัวแปร BC A 00 01 11 10 1 F = AB’C’+A’C+BC 1 BC A 00 01 11 10 1 F = AB+BC’+AC’ 1

65 5.2.3 Minimizing of Circuits
Exercise การลดค่าสำหรับ 3 ตัวแปร BC A 00 01 11 10 00 1 F = A’+B+C’ 1 BC A 01 11 10 1 F = A’C+AB 1

66 5.2.3 Minimizing of Circuits
สำหรับ 4 ตัวแปร CD AB 00 01 11 10 A’BCD’ 00 01 11 10 ABC’D

67 5.2.3 Minimizing of Circuits
ตัวอย่าง CD AB 00 01 11 10 00 01 11 10 A’BD’ = A’BC’D’+A’BCD’

68 5.2.3 Minimizing of Circuits
Exercise CD AB 00 01 11 10 00 01 11 10 AB = ABC’D’+ABC’D+ABCD+ABCD’

69 5.2.3 Minimizing of Circuits
Exercise CD AB 00 01 11 10 00 01 11 10 B’D’ = A’B’C’D’+A’B’CD’+AB’C’D’+AB’CD’

70 5.2.3 Minimizing of Circuits
Exercise CD AB 00 01 11 10 00 01 11 10 D = A’B’C’D+A’B’CD+A’BC’D+A’BCD+ ABC’D+ABCD+AB’C’D+AB’CD

71 5.2.3 Minimizing of Circuits
ให้ใช้ k-map เพื่อลดค่า sum-of-product expansion เหล่านี้ ABCD+ABCD’+ABC’D’+AB’CD+AB’C’D+ AB’C’D’+A’BC’D+A’B’CD+A’B’CD’ ABC’D’+AB’CD+AB’CD’+AB’C’D’+A’BC’D’+ A’B’CD’+A’B’C’D’ ABCD’+ABC’D’+AB’CD+AB’CD’+AB’C’D’+ A’BCD+A’BCD’+A’BC’D’+A’BC’D+A’B’CD’+A’B’C’D’

72 5.2.3 Minimizing of Circuits
ABCD+ABCD’+ABC’D’+AB’CD+AB’C’D+ AB’C’D’+A’BC’D+A’B’CD+A’B’CD’ Exercise CD AB 00 01 11 10 1 00 01 11 10 A’B’C+ABC+AC’D’+AB’D+A’BC’D

73 5.2.3 Minimizing of Circuits
ABC’D’+AB’CD+AB’CD’+AB’C’D’+A’BC’D’+ A’B’CD’+A’B’C’D’ Exercise CD AB 00 01 11 10 1 00 01 11 10 C’D’+AB’C+B’D’

74 5.2.3 Minimizing of Circuits
Exercise ABCD’+ABC’D’+AB’CD+AB’CD’+AB’C’D’+ A’BCD+A’BCD’+A’BC’D’+A’BC’D+A’B’CD’+A’B’C’D’ CD AB 00 01 11 10 1 00 01 11 10 D’+AB’C+A’B

75 5.2.3 Minimizing of Circuits
Don’t care condition เป็นสัญลักษณ์พิเศษที่ใส่ใน cell บางวงจรเราจะสนใจเฉพาะผลลัพธ์ที่เกิดจาก input บางกรณีเท่านั้น เนื่องจาก Input กรณีอื่นนั้นเป็นสิ่งที่เป็นไปไม่ได้ หรืออาจจะไม่อาจเกิดขึ้นได้ input กรณีอื่นนั้น จะใส่เครื่องหมาย don’t care (d) ไว้ใน cell ใช้ don’t care เพื่อช่วยลดความซับซ้อนของวงจร

76 5.2.3 Minimizing of Circuits
ตัวอย่าง วิธีการแปลงรหัสเลขฐานสิบวิธีหนึ่งคือ ใช้ 4 บิตในการแปลงเลขฐานสิบแต่ละหลัก เช่น 873 คือ วิธีนี้มีชื่อว่า Binary Coded Decimal Expansion (BCD) จะเห็นว่าเลขฐาน 2 จำนวน 4 บิตที่ใช้ ใช้เพียง 0-9 4 บิตแทนได้ตั้งแต่ เลขที่เหลือคือ ไม่ได้ใช้ ปัญหา ให้สร้างวงจรเพื่อตรวจว่า input มีค่าตั้งแต่ 5 ขึ้นไปหรือไม่

77 5.2.3 Minimizing of Circuits
วิธีการ ต้องใช้ input 4 ตัว แทนแต่ละบิต (ใช้น้อยกว่านั้นไม่ได้) Output ถ้ามากกว่าหรือเท่ากับ 5 จะให้ค่า 1 แต่ถ้าน้อยกว่า 5 จะให้ค่าเป็น 0 Digit A B C D F

78 5.2.3 Minimizing of Circuits
วาด K-map CD AB 00 01 11 10 1 00 01 11 10 F = AB’C’+A’BD+A’BC

79 5.2.3 Minimizing of Circuits
จะพบว่ามีกรณี Don’t care อยู่ในปัญหานี้ ค่าเลข ให้ใส่ d CD AB 00 01 11 10 1 d 00 01 11 10 F = A+BC+BD

80 5.3 Proof Techniques การ proof statement ใด ๆ
การโน้มน้าว ต้องอธิบายให้เห็นได้ว่า statement นั้นเป็นจริง ต้องแสดงว่า statement นั้นเกี่ยวข้องกับ statement อื่นอย่างไร และ ต้องแสดงว่า Statement นั้นสอดคล้องกับทฤษฎีที่อ้างถึง statement นั้น

81 5.3 Proof Techniques ขั้นตอนทั่วไปในการ proof คือ การพิสูจน์ statement จาก Assumption หรือ Hypotheses Statement อื่นที่ได้รับการพิสูจน์มาก่อนแล้ว ความจริง (Fact) ที่เป็นที่ยอมรับทั่วไป โดยใช้หลักการทั่วไปของเหตุผลทางตรรกะ (Logical Reasoning) โดยทั่วไปเราจะพิสูจน์ statement ที่อยู่ในรูปแบบ p->q

82 5.3.1 Direct Proof Direct proof สมมติว่า statement p เป็นจริง และแสดงว่า statement q เป็นจริง Ex. for any integer a and b, if a and b are odd, then ab is odd. พิสูจน์ สมมติฐาน คือ จำนวนเต็ม n เป็นเลขคี่ ถ้าหากมีจำนวนเต็ม x ที่ทำให้ n = 2x+1 ให้ a และ b เป็นเลขคี่ใด ๆ สอดคล้องกับสมมติฐานจะได้ว่า มีจำนวนเต็ม x ที่ทำให้ a = 2x + 1 และมีจำนวนเต็ม y ที่ทำให้ b = 2y+1

83 5.3.1 Direct Proof เราต้องแสดงว่ามีจำนวนเต็ม z ที่ทำให้ ab = 2z+1 แสดงได้ว่า ab = (2x+1)(2y+1) = 4xy+2x+2y+1 = 2(2xy+x+y)+1 จะได้ว่าถ้ามี z = 2xy+x+y นั่นแสดงว่า มีจำนวนจริง z ที่ทำให้ ab = 2z+1 มีอยู่จริง ดังนั้นสรุปได้ว่า สำหรับจำนวนเต็ม a และ b ใด ๆ ที่เป็นจำนวนคี่ จะได้ว่า ab เป็นจำนวนคี่ด้วย

84 5.3.1 Direct Proof x+y = 2a+2b พิสูจน์
Ex. พิสูจน์ว่าผลบวกของเลขจำนวนคู่ ได้ผลลัพธ์เป็นเลขจำนวนคู่ พิสูจน์ สมมติฐาน คือ จำนวนเต็ม n เป็นเลขคู่ ถ้าหากมีจำนวนเต็ม a ที่ทำให้ n = 2a สำหรับเลขจำนวนคู่ x และ y ใด ๆ จะได้ว่า x = 2a และ y = 2b เมื่อ a และ b เป็นเลขจำนวนเต็มใด ๆ พิสูจน์ว่า x+y เป็นเลขจำนวนคู่ ดังนี้ x+y = 2a+2b = 2(a+b) จากสมมติฐาน ถ้ามี z = a+b เป็นเลขจำนวนเต็มใด ๆ จะได้ว่า ผลบวกของเลขจำนวนคู่ x และ y จะได้ผลลัพธ์เป็นเลขจำนวนคู่ คือ 2z

85 5.3.1 Exercise จงพิสูจน์ว่า ถ้า k เป็นจำนวนคี่ แล้ว k2 เป็นจำนวนคี่
จงพิสูจน์ว่า ถ้า 6x+9y = 101 แล้ว x หรือ y ไม่ใช่จำนวนเต็ม

86 5.3.2 Induction Proof Suppose P(n) is a statement involving an integer n. Then to prove that P(n) is true for every n >= n0, it is sufficient to show these two things: P(n0) is true. (basis step) For any k >= n0, if P(k) is true, then P(k+1) is true. (induction step) In the induction step, we assume that k is a number >= n0 and that the state P(n) is true in the case n=k; we call this assumption the induction hypothesis.

87 5.3.2 Induction Proof Ex. Let P(n) be the statement
1+2+3+…+n = n(n+1)/2 To show that P(n) is true for every n>=0 Basis step We must show that P(0) is true. P(0) is the statement 0 = 0(0+1)/2, and this is obviously true. Induction hypothesis k >= 0 and …+k = k(k+1)/2 Statement to be shown in induction step 1+2+3+…+(k+1) = (k+1)((k+1)+1)/2

88 5.3.2 Induction Proof Proof of induction step
1+2+3+…+(k+1) = (1+2+3+…+k)+(k+1) = (k(k+1)/2)+(k+1) (by induction hypothesis) = (k+1)(k/2+1) = (k+1)(k+2)/2 = (k+1)((k+1)+1)/2 Hypothesis: …+k = k(k+1)/2 Proof: …+(k+1) = (k+1)((k+1)+1)/2

89 5.3.2 Induction Proof Ex. Prove that for every n >= 1,
1+4+9+…+n2 = n(n+1)(2n+1)/6 Basis step สำหรับ n = 1, 1 = 1(1+1)(2(1)+1)/6 = 1(2)(3)/6 = 6/6 = 1 Induction hypothesis สำหรับ k >= 1 and 1+4+9+…+k2 = k(k+1)(2k+1)/6 Statement to be shown in induction step 1+4+9+…+(k+1)2 = (k+1)((k+1)+1)(2(k+1)+1)/6 = (k+1)(k+2)(2k+3)/6

90 5.3.2 Induction Proof Proof of induction step
1+4+9+…+(k+1)2 = (1+4+9+…+k2)+(k+1)2 = (k(k+1)(2k+1)/6)+(k+1)2 (by induction hypothesis) = (k(k+1)(2k+1)/6)+(6(k+1)2/6) = (k(k+1)(2k+1)+6(k+1)2)/6 = (k+1)(k(2k+1)+6(k+1))/6 = (k+1)((2k2+k)+(6k+6))/6 = (k+1)(2k2+7k+6)/6 = (k+1)(k+2)(2k+3)/6 Hypothesis: …+k2 = k(k+1)(2k+1)/6 Proof: …+(k+1)2 = (k+1)(k+2)(2k+3)/6

91 5.3.2 Exercise Use mathematic induction to prove that the sum of the first n odd positive integers is n2 Prove that for every n >= 1, 1+3+5+…+(2n-1) = n2 Use mathematic induction to prove the inequality n < 2n for all positive integer n. Use mathematical induction to show that …+2n = 2n+1-1 for all non-negative integer n.

92


ดาวน์โหลด ppt Chapter 1 Mathematics and Computer Science

งานนำเสนอที่คล้ายกัน


Ads by Google