200 likes | 215 Views
Solve two logical problems: proving client's innocence based on evidence and determining if a program has a bug based on efficiency. Use propositional logic and logical operators.
E N D
Homework Problem • Some information about homework problem. • C' is the conclusion - it is NOT a hypothesisThe problem CAN be done using our original statements (i.e. without replacing T by K) Here’s what the lawyer said • If my client is guilty, then the knife was in the drawer • Either the knife was not in the drawer or Jason Pritchard saw the knife. • If the knife was not there on October 10, it follows that Jason Pritchard did not see the knife. • Furthermore, if the knife was there on October 10, then the knife was in the drawer and also the hammer was in the barn. • But we all know that the hammer was not in the barn. • Therefore, ladies and gentlemen of the jury, my client is innocent.
Here are the variables used • C client is guiltyK knife was in the drawerT knife was there on October 10S Jason Pritchard saw knifeH hammer was in the barn • 1. C -> K hypothesis2. K' v S hypothesis3. T' -> S' hypothesis4. T -> (K ^ H) hypothesis5. H' hypothesis
Proof • 6. H’ v K’ 5. addition • 7. (H ^ K)’ 6. DeMorgan’s • 8. (K ^ H)’ 7. commutative • 9. T’ 4,8 Modus Tollens • 10. S’ 3,9 Modus Ponens • 11. S v K’ 2 commutative • 12 K’ 10,11 disjunctive syllogism • 13 C’ 1,12 Modus Tollens
Statement of problem • If the program is efficient, it executes quickly • Either the program is efficient, or it has a bug. • However, the program does not execute quickly. • Therefore it has a bug. • Please use the letters E,Q,B
Propositional form • (E → Q) ⋀ (E ⋁ B) ⋀ Q’→ B
A solution • 1. E → Q hyp (simplification) • 2. E ⋁ B hyp (simplification) • 3. Q’ hyp (simplification) • 4. E’ 1,3 Modus Tollens • 5. B 2,4 Disjunctive syllogism
Another solution • 1. E → Q hyp (simplification) • 2. E ⋁ B hyp (simplification) • 3. Q’ hyp (simplification) • 4. E’⋁ Q 1 implication • 5. Q ⋁ E’ 4 commutative • 6. E’ 3,5 Disjunctive syllogism • 7. B 2,6 Disjunctive syllogism
Still another solution • 1. E → Q hyp (simplification) • 2. E ⋁ B hyp (simplification) • 3. Q’ hyp (simplification) • 4. Q’→ E’ 1 contraposition • 5. E’ 4,3 Modus Ponens • 6. (E’)’ ⋁ B 2 double negation • 7. E’→ B 6 implication • 8 B 7,5 Modus Ponens
And yet another one • 1. E → Q hyp (simplification) • 2. E ⋁ B hyp (simplification) • 3. Q’ hyp (simplification) • 4. (E’)’ ⋁ B 2 double negation • 5. E’→ B 4 implication • 6. E’ ⋁ Q 1 implication • 7. (E’ ⋁ Q) ⋀ Q’ 6,3 conjunction • 8. Q’ ⋀ (E’ ⋁ Q) 7 commutative • 9. (Q’ ⋀ E’) ⋁ (Q’ ⋀ Q) 8 distributive • 10. (E’ ⋀ Q’) ⋁ 0 9 complement property • 11. (E’ ⋀ Q’) 10 identity property • 12. E’ 11 simplification • 13. B 5,12 Modus Ponens
Definition: Compound proposition • “a proposition constructed by combining propositions using logical operators” • Conjunction – and • Disjunction - or
Definition: dual of a compound proposition • The dual of a compound proposition that contains only the logical operators ∨,,¬, is the proposition obtained by replacing each ∨ by, each by∨, each T by F and each F by T.
Definition: NAND • The proposition p NAND q is true when either p or q or both are false; and it is false when both p and q are true.
Definition: NOR • The proposition p NOR q is true when both p and q are false, and it is false otherwise.
Page 27, problem 34 • Find a compound proposition involving the propositions p,q and r that is true when p and q are true and r is false, but false otherwise.
Page 27, problem 35 • Find a compound proposition involving the propositions p, q, and r that is true when exactly two of p, q, and r are true and is false otherwise. • Hint: form a disjunction of conjunctions. Include a conjunction for each combination of values for which the proposition is true. Each conjunction should include each of the three propositions or their negation.
Modular Arithmetic • a.k.a. clock arithmetic • If a and b are integers and m is a positive integer, then we way that a is congruent to b modulo m if m divides a-b. • We use the notation a≡b (mod m) to indicate that a is congruent to b modulo m • If they are not congruent, we write • a≢ b (mod m)
Why do we care in c.s.? • Applications: • Stripping digits from a base 10 number • Check digits on credit cards • Hash codes for storing information • Generation of pseudo-random numbers • Cryptology • Check digits on bar codes • Enable error detection