som basic logic equilance

som basic logic equilance - a 1 , a 2 , , a n : distinct...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Some basic logical equivalences: 1. Idempotence: (i) ( p p ) p (ii) ( p p ) p 2. Commutativity: (i) ( p q ) ( q p ) (ii) ( p q ) ( q p ) 3. Associativity: (i) (( p q ) r ) ( p ( q r )) (ii) (( p q ) r ) ( p ( q r )) 4. Distributivity: (i) ( p ( q r )) (( p q ) ( p r )) (ii) ( p ( q r )) (( p q ) ( p r )) 5. Double negation: (i) ¬ ( ¬ p) p 6. De Morgan’s law: (i) ¬ ( p q ) (( ¬ p ) ( ¬ q )) (ii) ¬ ( p q ) (( ¬ p ) ( ¬ q )) Basic rules of inference 1. Modus ponens: p p q q 2. Modus tollens: p q ¬ q ¬ p 3. Disjunctive syllogism: p q ¬ p q 4. Hypothetical syllogism (also called “the chain rule”): p q q r p r 5. Resolution: p r q ¬ r p q 6. Addition: p p q 7. Simplification p q p Page 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2 Additional logical equivalencies: p q ¬ q →¬ p p q ¬ p q ¬ ( p q ) p ¬ q ALGORITHM. Maximum Element of a Sequence procedure max ( a 1 , a 2 , …, a n : integers) max := a 1 for i := 2 to n if max < a i then max := a i { max is the largest element} ALGORITHM. The Linear Search Algorithm procedure linear search ( x : object,
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a 1 , a 2 , , a n : distinct objects) i := 1 while ( i n and x a i ) i := i + 1 if i n then location := i else location := 0 { location is the subscript of the term that equals x , or is 0 if x is not found} ALGORITHM. The Binary Search Algorithm procedure binary search ( x : integer, a 1 , a 2 , , a n : increasing integers) i := 1 { i is left endpoint of search interval} j := n { n is right endpoint of search interval} while i &lt; j begin m := ( i + j ) / 2 if x &gt; a m then i := m + 1 else j := m end if x = a i then location := i else location := 0 { location is the subscript of the term equal to x , or is 0 if x is not found} ALGORITHM. The Euclidean Algorithm procedure gcd( a, b : positive integers) x := a y := b while y 0 begin r := x mod y x := y y := r end {gcd( a , b ) is x }...
View Full Document

Page1 / 2

som basic logic equilance - a 1 , a 2 , , a n : distinct...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online