L07_IntroLogic

L07_IntroLogic - 1-1COMP170Discrete Mathematical Toolsfor...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1-1COMP170Discrete Mathematical Toolsfor Computer ScienceDiscrete Math for Computer ScienceK. Bogart, C. Stein and R.L. DrysdaleSection 3.1, pp. 91-101Intro to LogicVersion 2.0: Last updated, May 13, 2007Slidesc2005 by M. J. Golin and G. Trippen2-13.1 Equivalence and Implication•Equivalence of Statements•Truth Tables•DeMorgan’s Laws•Implication•If and Only If3-1Equivalence of Statements3-2Equivalence of Statements(1) if ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+1(1) if (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+13-3Equivalence of Statements(1) if ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+1(1) if (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+1Consider the two piecesof code on the left.They are taken from twodifferentversionsofMergesort. Do they dothe same thing?&& =“and”||=“or”3-4Equivalence of Statements(1) if ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+1(1) if (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))(2)List3[k] = List1[i](3)i = i+1(4) else(5)List3[k] = List2[j](6)j = j+1(7) k = k+1Consider the two piecesof code on the left.They are taken from twodifferentversionsofMergesort. Do they dothe same thing?&& =“and”||=“or”Code is sameexcept for line 14-1(1) ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(1’) (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))&&=“and”||=“or”4-2(1) ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(1’) (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))&&=“and”||=“or”Are they equivalent?4-3(1) ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(1’) (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))&&=“and”||=“or”Are they equivalent?Let’s rewrite usings∼(i+j≤p+q)t∼(i≤p)u∼(j>q)v∼(List[i]≤List2[j])4-4(1) ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(1’) (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))&&=“and”||=“or”Are they equivalent?Let’s rewrite usings∼(i+j≤p+q)t∼(i≤p)u∼(j>q)v∼(List[i]≤List2[j])(1)sandtand (uorv)(1’) (sandtandu) or (sandtandv)4-5(1) ((i+j≤p+q) && (i≤p) &&((j > q) || (List1[i]≤List2[j])))(1’) (((i+j≤p+q) && (i≤p) && (j > q))|| ((i+j≤p+q) && (i≤p)&& (List1[i]≤List2[j])))&&=“and”||=“or”Are they equivalent?Are they equivalent?...
View Full Document

This note was uploaded on 08/25/2010 for the course COMP COMP170 taught by Professor M.j.golin during the Spring '10 term at HKUST.

Page1 / 104

L07_IntroLogic - 1-1COMP170Discrete Mathematical Toolsfor...

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

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