announcements
play

Announcements Hand in Homework 8 now Pick up all old homework now - PowerPoint PPT Presentation

Announcements Hand in Homework 8 now Pick up all old homework now CSE 311 Foundations of Review session Computing I Sunday, June 9, 4 pm, EEB 125 List of Final Exam Topics and sampling of some Lecture 28 typical kinds of


  1. Announcements • Hand in Homework 8 now • Pick up all old homework now CSE 311 Foundations of • Review session Computing I – Sunday, June 9, 4 pm, EEB 125 – List of Final Exam Topics and sampling of some Lecture 28 typical kinds of exam questions on the web Computability Review, Course – Bring your questions to the review session! Summary • Final exam Spring 2013 – Monday, June 10, 2:30-4:20 pm, MGH 389 1 2 What makes the Halting Problem and related The “Always Halting” problem problems hard? Suppose we had a TM A for the Always Halting problem • Figuring out in some finite time something about what might happen in the infinite # of steps that x a general computation might take < Q > < < < > > > 1 if P(x) halts Convert A – e.g. having H (< P >, x ) output 0 when P doesn’t halt on x < < < < P > > > > 0 if P(x) does … not halt … a ← x • The following program does exist and won’t Read ( a ) … … generate any contradiction – Function V ( x ): We designed < < Q > < < > > > based on < P > and x so that: • if U ( x , x ) halts then < Q > always halts ⇔ ⇔ ⇔ ⇔ < P > halts on input x – while (true); /* loop forever */ • else So.. if A exists then we get a program H for the – no-op ; /* do nothing and halt */ ordinary halting problem, which we know can’t exist so A • endif 3 can’t exist 4

  2. A general phenomenon: Can’t tell a book by The “Always ERROR” problem its cover Suppose we had a TM E for the ERROR problem Rice’s Theorem: In general there is no way to tell < < < R > < > > > 1 if Q always anything about the input/output ( I / O ) behavior of a Convert’ E < Q > < > < < > > halts program P just given its code < P >! 0 if Q does not Q’s code Q’s code … … always halt end of Q end of Q Print ERROR We designed < < R > < < > based on < Q > so that: > > < R > always prints “ERROR” ⇔ ⇔ ⇔ ⇔ < Q > always halts So.. if E exists then we get a program A for the Always Halts problem, which we know can’t exist so E can’t exist 6 5 Quick lessons • Don’t rely on the idea of improved compilers and programming languages to CSE 311 Foundations of eliminate major programming errors Computing I – truly safe languages can’t possibly do general computation • Document your code!!!! Spring 2013 – there is no way you can expect someone else Course Summary to figure out what your program does with just your code ....since....in general it is provably impossible to do this! 7 8

  3. About the course Propositional Logic • Statements with truth values • From the CSE catalog: – The Washington State flag is red – CSE 311 Foundations of Computing I (4) – It snowed in Whistler, BC on January 4, 2011. Examines fundamentals of logic, set theory, – Rick Perry won the Iowa straw poll induction, and algebraic structures with – Space aliens landed in Roswell, New Mexico applications to computing; finite state machines; – If n is an integer greater than two, then the and limits of computability. Prerequisite: CSE equation a n + b n = c n has no solutions in non-zero integers a, b, and c. 143; either MATH 126 or MATH 136. – Propositional variables: p, q, r, s, . . . Negation (not) ¬ p • What this course is about: – Truth values: T for true, F for false Conjunction (and) p ∧ q – Compound propositions – Foundational structures for the practice of Disjunction (or) p ∨ q Exclusive or p ⊕ q computer science and engineering Implication p → q Biconditional p ↔ q 9 10 English and Logic Logical equivalence • Terminology: A compound proposition is a • You cannot ride the roller coaster if you – Tautology if it is always true are under 4 feet tall unless you are older – Contradiction if it is always false than 16 years old – Contingency if it can be either true or false – q : you can ride the roller coaster p ∨ ∨ ∨ ∨ ¬ ¬ ¬ ¬ p – r : you are under 4 feet tall – s : you are older than 16 p ⊕ p ( p → q ) ∧ p ( r ∧ ¬ s ) → ¬ q ( p ∧ q ) ∨ ( p ∧ ¬ q ) ∨ ( ¬ p ∧ q ) ∨ ( ¬ p ∧ ¬ q ) 11 12

  4. Logical Equivalence Digital Circuits • p and q are logically equivalent iff • Computing with logic p ↔ q is a tautology – T corresponds to 1 or “high” voltage • The notation p ≡ q denotes p and q are – F corresponds to 0 or “low” voltage logically equivalent • Gates – Take inputs and produce outputs • De Morgan’s Laws: • Functions – Several kinds of gates ¬ (p ∧ q) ≡ ¬ p ∨ ¬ q ¬ (p ∨ q) ≡ ¬ p ∧ ¬ q – Correspond to propositional connectives • Only symmetric ones (order of inputs irrelevant) 13 14 A simple example: 1-bit binary Combinational Logic Circuits adder Cout Cin • Inputs: A, B, Carry-in A A A A A B B B B B AND • Outputs: Sum, Carry-out S S S S S OR A S A B Cin Cout S B AND Cout 0 0 0 0 0 Cin 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 Cout = B Cin + A Cin + A B 1 0 0 0 1 1 0 1 1 0 Wires can send one value to multiple gates S = A’ B’ Cin + A’ B Cin’ + A B’ Cin’ + A B Cin 1 1 0 1 0 1 1 1 1 1 = A’ (B’ Cin + B Cin’ ) + A (B’ Cin’ + B Cin ) = A’ Z + A Z’ = A xor Z = A xor (B xor Cin) 16 15

  5. Sum-of-products canonical Boolean algebra forms • An algebraic structure consists of • Also known as disjunctive normal form – a set of elements B • Also known as minterm expansion George Boole – 1854 – binary operations { + , • } F = 001 011 101 110 111 – and a unary operation { ’ } F = + A’BC + AB’C + ABC’ + ABC A’B’C – such that the following axioms hold: A B C F F’ 0 0 0 0 1 1. the set B contains at least two elements: a, b 0 0 1 1 0 0 1 0 0 1 2. closure: a + b is in B a • b is in B 0 1 1 1 0 3. commutativity: a + b = b + a a • b = b • a 1 0 0 0 1 4. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c 1 0 1 1 0 5. identity: a + 0 = a a • 1 = a 1 1 0 1 0 6. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c) 1 1 1 1 0 F’ = A’B’C’ + A’BC’ + AB’C’ 7. complementarity: a + a’ = 1 a • a’ = 0 18 17 Predicate Calculus Statements with quantifiers Domain: Positive Integers • ∀ x (Even( x ) ∨ Odd( x )) • Predicate or Propositional Function Even( x ) – A function that returns a truth value Odd( x ) • ∃ x (Even( x ) ∧ Prime( x )) • “ x is a cat” Prime( x ) Greater( x , y ) • “student x has taken course y ” Equal( x , y ) • ∀ x ∃ y (Greater( y , x ) ∧ Prime( y )) • “ x > y ” • ∀ x P(x) : P(x) is true for every x in the • ∀ x (Prime( x ) → (Equal( x , 2) ∨ Odd( x )) domain • ∃ x P(x) : There is an x in the domain for • ∃ x ∃ y (Equal( x, y + 2) ∧ Prime( x ) ∧ Prime( y )) which P(x) is true 19 20

  6. Proofs Simple Propositional Inference Rules • Excluded middle ∴ p ∨¬ p • Start with hypotheses and facts • Two inference rules per binary connective one to • Use rules of inference to extend set of eliminate it, one to introduce it. facts p ∧ q p, q • Result is proved when it is included in the ∴ p, q ∴ p ∧ q set p p ∨ q , ¬ p ∴ p ∨ q, q ∨ p ∴ q p ⇒ q p, p → q Direct Proof Rule ∴ p → q ∴ q 21 22 Even(x) ≡ ∃ ∃ y (x=2y) ∃ ∃ Inference Rules for Quantifiers Even and Odd Odd(x) ≡ ∃ ∃ y (x=2y+1) ∃ ∃ Domain: Integers P(c) for some c ∀ x P(x) • Prove: “The square of every odd number is odd” ∴ ∃ x P(x) ∴ P(a) for any a English proof of: ∀ x (Odd(x) → Odd(x 2 )) Let x be an odd number. “Let a be anything”...P(a) ∃ x P(x) Then x=2k+1 for some integer k (depending on x) ∴ ∀ x P(x) ∴ P(c) for some special c Therefore x 2 =(2k+1) 2 = 4k 2 +4k+1=2(2k 2 +2k)+1. Since 2k 2 +2k is an integer, x 2 is odd. � 23 24

  7. Characteristic vectors One-time pad • Alice and Bob privately share random n-bit vector K • Let U = {1, . . ., 10}, represent the set – Eve does not know K {1,3,4,8,9} with • Later, Alice has n-bit message m to send to 1011000110 Bob • Bit operations: – Alice computes C = m ⊕ K – Alice sends C to Bob – 0110110100 ∨ 0011010110 = 0111110110 – Bob computes m = C ⊕ K which is (m ⊕ K) ⊕ K • ls –l drwxr-xr-x ... Documents/ • Eve cannot figure out m from C unless she can guess -rw-r--r-- ... file1 K 25 26 Arithmetic mod 7 Division Theorem • a + 7 b = (a + b) mod 7 Let a be an integer and d a positive integer. Then there are unique integers q and r , with • a × 7 b = (a × b) mod 7 0 ≤ r < d , such that a = dq + r . + 0 1 2 3 4 5 6 0 1 2 3 4 5 6 X q = a div d r = a mod d 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 1 1 2 3 4 5 6 0 1 0 1 2 3 4 5 6 2 2 3 4 5 6 0 1 2 0 2 4 6 1 3 5 3 3 4 5 6 0 1 2 3 0 3 6 2 5 1 4 4 4 5 6 0 1 2 3 4 0 4 1 5 2 6 3 5 5 6 0 1 2 3 4 5 0 5 3 1 6 4 2 6 6 0 1 2 3 4 5 6 0 6 5 4 3 2 1 27 28

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