administrivia
play

administrivia Course web: http://www.cs.washington.edu/311 Office - PowerPoint PPT Presentation

administrivia Course web: http://www.cs.washington.edu/311 Office hours: 12 office hours each week Me/James: MW 10:30-11:30/2:30-3:30pm or by appointment TA Section: Start next week Call me: Shayan Dont: Actually call me. Homework #1:


  1. administrivia Course web: http://www.cs.washington.edu/311 Office hours: 12 office hours each week Me/James: MW 10:30-11:30/2:30-3:30pm or by appointment TA Section: Start next week Call me: Shayan Don’t: Actually call me. Homework #1: Will be posted today, due next Friday by midnight (Oct 9 th ) Gradescope! (stay tuned) Extra credit: Not required to get a 4.0. Counts separately. In total, may raise grade by ~0.1 Don’t be shy (raise your hand in the back)! Do space out your participation. If you are not CSE yet, please do well!

  2. logical connectives p q p  q p  p T T T T F T F F F T F T F F F F NOT AND p q p q p  q p  q T T T T T F T F T T F T F T T F T T F F F F F F XOR OR

  3. 𝑞 → 𝑟 p q p  q • “If p , then q ” is a promise : F F T • Whenever p is true, then q is true F T T • Ask “has the promise been broken” T F F T T T If it’s raining, then I have my umbrella.

  4. related implications • Implication: p  q • Converse: q  p • Contrapositive:  q   p • Inverse:  p   q How do these relate to each other? How to see this?

  5. 𝑞 ↔ 𝑟 • p iff q • p is equivalent to q • p implies q and q implies p p q p  q

  6. Let’s think about fruits A fruit is an apple only if it is either red or green and a fruit is not red and green. 𝑞 : “Fruit is an apple” 𝑟 : “Fruit is red” 𝑠 : “Fruit is green”

  7. Let’s think about fruits A fruit is an apple only if it is either red or green and a fruit is not red and green. (FApple only if ( FGreen xor FRed )) and ( not ( FGreen and FRed)) (FApple → (FGreen ⊕ FRed )) ∧ ( ¬ (FGreen ∧ Fred)) p : FApple q : FGreen r : FRed

  8. Fruit Sentence with a truth table (𝒒 → 𝒓 ⊕ 𝐬 ) ∧ (¬ 𝒓 ∧ 𝒔 ) p q r 𝒓 ⊕ 𝒔 𝒒 → (𝒓 ⊕ 𝐬) 𝒓 ∧ 𝒔 ¬(𝒓 ∧ 𝒔) T T T T T F T F T T F F F T T F T F F F T F F F

  9. cse 311: foundations of computing Spring 2015 Lecture 2: Digital circuits & more logic

  10. digital circuits Computing with logic – T corresponds to 1 or “ high ” voltage – F corresponds to 0 or “ low ” voltage Gates: – Take inputs and produce outputs (functions) – Several kinds of gates – Correspond to propositional connectives

  11. AND gate AND Connective AND Gate vs. p p  q OUT q AND p q p  q p q OUT T T T 1 1 1 T F F 1 0 0 F T F 0 1 0 F F F 0 0 0 p OUT q AND “ block looks like D of AND ”

  12. OR gate OR Connective OR Gate vs. p p  q OUT q OR p q p  q p q OUT T T T 1 1 1 T F T 1 0 1 F T T 0 1 1 F F F 0 0 0 p OUT OR q “ arrowhead block looks like ∨ ”

  13. NOT gate NOT Gate vs. (Also called NOT Connective inverter ) p OUT NOT  p p  p p OUT 1 0 T F F T 0 1 p OUT NOT

  14. “gee, thanks.” blobs are okay You can write gates using blobs instead of shapes. p OUT q AND p OUT q OR p OUT NOT

  15. combinational logic circuits NOT AND NOT AND OR Values get sent along wires connecting gates

  16. combinational logic circuits AND OR NOT AND Wires can send one value to multiple gates!

  17. logical equivalence Terminology: A compound proposition is a… – Tautology if it is always true – Contradiction if it is always false – Contingency if it can be either true or false Classify! p   p p  p ( p  q )  p ( p  q )  ( p   q )  (  p  q )  (  p   q )

  18. logical equivalence Terminology: A compound proposition is a… – Tautology if it is always true – Contradiction if it is always false – Contingency if it can be either true or false Classify! 𝑞 ∧ 𝑟 ∧ 𝑠 ∨ ¬𝑞 ∧ 𝑟 ∧ ¬𝑠 ∧ 𝑞 ∨ 𝑟 ∨ ¬𝑡 ∨ 𝑞 ∧ 𝑟 ∧ 𝑡 NOT AND NOT AND OR

  19. logical equivalence A and B are logically equivalent if and only if A  B is a tautology i.e. A and B have the same truth table The notation A  B denotes A and B are logically equivalent. Example: p    p p  p   p p    p

  20. A  B vs. A  B A  B says that two propositions A and B always mean the same thing. A  B is a single proposition that may be true or false depending on the truth values of the variables in A and B. but A  B and (A  B)  T have the same meaning. Note: Why write A  B and not A = B ? [We use A = B to say that A and B are precisely the same proposition (same sequence of symbols)]

  21. de Morgan’s laws My code compiles or there is a bug. [let’s negate it] “Always wear breathable fabrics Write NAND using NOT and OR: when you get your picture taken.”

  22. de Morgan’s laws Verify:  𝑞  𝑟 ≡ (¬ 𝑞 ∨ ¬ 𝑟) p q  p  q  p   q p  q  ( p  q )  ( p  q )  ( p   q ) T T T F F T F F

  23. de Morgan’s laws  𝑞 ∧ 𝑟 ≡ ¬ 𝑞 ∨ ¬ 𝑟  𝑞 ∨ 𝑟 ≡ ¬ 𝑞 ∧ ¬ 𝑟 if ! ( front != null && value > front.data ) front = new ListNode(value, front); else { ListNode current = front; while ! ( current.next == null || current.next.data >= value ) current = current.next; current.next = new ListNode(value, current.next); }

  24. law of implication 𝑞 → 𝑟 ≡ (¬ 𝑞 ∨ 𝑟) p q p  q  p  p  q ( p  q )  (  p  q ) T T T F F T F F

  25. computing equivalence Describe an algorithm for computing if two logical expressions/circuits are equivalent. What is the run time of the algorithm?

  26. some familiar properties of arithmetic • 𝑦 + 𝑧 = 𝑧 + 𝑦 (commutativity) • 𝑦 ⋅ 𝑧 + 𝑨 = 𝑦 ⋅ 𝑧 + 𝑦 ⋅ 𝑨 (distributivity) 𝑦 + 𝑧 + 𝑨 = 𝑦 + (𝑧 + 𝑨) (associativity) • Logic has similar algebraic properties

  27. some familiar properties of arithmetic • 𝑦 + 𝑧 = 𝑧 + 𝑦 (commutativity) – 𝑞 ∨ 𝑟 ≡ 𝑟 ∨ 𝑞 – 𝑞 ∧ 𝑟 ≡ 𝑟 ∧ 𝑞 • 𝑦 ⋅ 𝑧 + 𝑨 = 𝑦 ⋅ 𝑧 + 𝑦 ⋅ 𝑨 (distributivity) – 𝑞 ∧ 𝑟 ∨ 𝑠 ≡ 𝑞 ∧ 𝑟 ∨ (𝑞 ∧ 𝑠) – 𝑞 ∨ 𝑟 ∧ 𝑠 ≡ 𝑞 ∨ 𝑟 ∧ (𝑞 ∨ 𝑠) 𝑦 + 𝑧 + 𝑨 = 𝑦 + (𝑧 + 𝑨) (associativity) • – 𝑞 ∨ 𝑟 ∨ 𝑠 ≡ 𝑞 ∨ 𝑟 ∨ 𝑠 – 𝑞 ∧ 𝑟 ∧ 𝑠 ≡ 𝑞 ∧ (𝑟 ∧ 𝑠)

  28. properties of logical connectives You will always get this list. Identity • – 𝑞 ∧ T ≡ 𝑞 Associative • – 𝑞 ∨ F ≡ 𝑞 𝑞 ∨ 𝑟 ∨ 𝑠 ≡ 𝑞 ∨ 𝑟 ∨ 𝑠 𝑞 ∧ 𝑟 ∧ 𝑠 ≡ 𝑞 ∧ 𝑟 ∧ 𝑠 Domination • – 𝑞 ∨ T ≡ T Distributive • – 𝑞 ∧ F ≡ F 𝑞 ∧ 𝑟 ∨ 𝑠 ≡ 𝑞 ∧ 𝑟 ∨ (𝑞 ∧ 𝑠) 𝑞 ∨ 𝑟 ∧ 𝑠 ≡ 𝑞 ∨ 𝑟 ∧ (𝑞 ∨ 𝑠) Idempotent • Absorption • – 𝑞 ∨ 𝑞 ≡ 𝑞 𝑞 ∨ 𝑞 ∧ 𝑟 ≡ 𝑞 – 𝑞 ∧ 𝑞 ≡ 𝑞 𝑞 ∧ 𝑞 ∨ 𝑟 ≡ 𝑞 Negation • Commutative • 𝑞 ∨ ¬𝑞 ≡ T – 𝑞 ∨ 𝑟 ≡ 𝑟 ∨ 𝑞 𝑞 ∧ ¬𝑞 ≡ F – 𝑞 ∧ 𝑟 ≡ 𝑟 ∧ 𝑞

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend