{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

som basic logic equilance

som basic logic equilance - a 1 a 2 … a n distinct...

Info icon This 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
Image of page 1

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

View Full Document Right 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,
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 < j begin m := ⎣ ( i + j ) / 2 ⎦ if x > 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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern