Binary Relations Part One

Size: px
Start display at page:

Download "Binary Relations Part One"

Transcription

1 Binary Relations Part One

2 Outline for Today Binary Relations Reasoning about connections between objects. Equivalence Relations Reasoning about clusters. A Fundamental Theorem How do we know we have the right definition for something?

3 Relationships In CS103, you've seen examples of relationships between sets: A B between numbers: x < y x ₖ y x y between people: p loves q Since these relations focus on connections between two objects, they are called binary relations. The binary here means pertaining to two things, not made of zeros and ones.

4 What exactly is a binary relation?

5

6

7

8

9

10

11 <

12 10 12 <

13 < < 12

14 <

15 5-2 <

16 < < -2

17

18 7 10 ₃

19 ₃ ₃ 10

20 6 11 ₃

21 ₃ ₃ 11

22

23 R

24 R a b

25 R a b arb

26 R a b

27 R a b ar b

28 Binary Relations A binary relation over a set A is a predicate R that can be applied to ordered pairs of elements drawn from A. If R is a binary relation over A and it holds for the pair (a, b), we write arb. 3 = 3 5 < 7 Ø N If R is a binary relation over A and it does not hold for the pair (a, b), we write ar b <= 3 N = Ø

29 Properties of Relations Generally speaking, if R is a binary relation over a set A, the order of the operands is significant. For example, 3 < 5, but 5 <= 3. In some relations order is irrelevant; more on that later. Relations are always defined relative to some underlying set. It's not meaningful to ask whether 15, for example, since is defined over sets, not arbitrary objects.

30 Visualizing Relations We can visualize a binary relation R over a set A by drawing the elements of A and drawing an arrow between an element a and an element b if arb is true. Example: the relation a b (meaning a divides b ) over the set {1, 2, 3, 4} looks like this:

31 Visualizing Relations We can visualize a binary relation R over a set A by drawing the elements of A and drawing an arrow between an element a and an element b if arb is true. Example: the relation a b over the set {1, 2, 3, 4} looks like this:

32 Visualizing Relations We can visualize a binary relation R over a set A by drawing the elements of A and drawing an arrow between an element a and an element b if arb is true. Example: the relation a = b over the set {1, 2, 3, 4} looks like this:

33 Visualizing Relations We can visualize a binary relation R over a set A by drawing the elements of A and drawing an arrow between an element a and an element b if arb is true. Example: below is some relation over {1, 2, 3, 4} that's a totally valid relation even though there doesn't appear to be a simple unifying rule

34 Capturing Structure

35 Capturing Structure Binary relations are an excellent way for capturing certain structures that appear in computer science. Today, we'll look at one of them (partitions), and next time we'll see another (prerequisites). Along the way, we'll explore how to write proofs about definitions given in first-order logic.

36 Partitions

37

38

39

40

41

42

43

44

45

46

47 Partitions A partition of a set is a way of splitting the set into disjoint, nonempty subsets so that every element belongs to exactly one subset. Two sets are disjoint if their intersection is the empty set; formally, sets S and T are disjoint if S T = Ø. Intuitively, a partition of a set breaks the set apart into smaller pieces. There doesn't have to be any rhyme or reason to what those pieces are, though often there is one.

48 Partitions and Clustering If you have a set of data, you can often learn something from the data by finding a good partition of that data and inspecting the partitions. Usually, the term clustering is used in data analysis rather than partitioning. Interested to learn more? Take CS161 or CS246!

49 What's the connection between partitions and binary relations?

50

51 a a

52 a a

53

54 a b

55 a b

56 a b

57 b a

58

59 a b

60 a b

61 a bc

62 b c

63 ab c

64 a c

65 a a a b b a a b b c a c

66 ara arb bra arb brc arc

67 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

68 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

69 Reflexivity Some relations always hold from any element to itself. Examples: x = x for any x. A A for any set A. x ₖ x for any x. Relations of this sort are called reflexive. Formally speaking, a binary relation R over a set A is reflexive if the following first-order statement is true: a A. ara ( Every element is related to itself. )

70 Reflexivity Visualized a A. ara ( Every element is related to itself. )

71 Let Let R be be the the relation relation drawn drawn to to the the left. left. Is Is R reflexive? reflexive? a A. ara ( Every element is related to itself. )

72 a A. ara ( Every element is related to itself. )

73 a A. ara ( Every element is related to itself. ) a

74 a A. ara ( Every element is related to itself. ) a

75 a This This means means that that R is is not not reflexive, reflexive, since since the the first-order logic logic statement given given below below is is not not true. true. a A. ara ( Every element is related to itself. )

76 Is Is reflexive? reflexive? a A. ara ( Every element is related to itself. )

77 Is Is reflexive? reflexive? a??. a a

78 Is Is reflexive? reflexive? Reflexivity is is a property property of of relations, not not individual objects. objects. a??. a a

79 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

80 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

81 Symmetry In some relations, the relative order of the objects doesn't matter. Examples: If x = y, then y = x. If x ₖ y, then y ₖ x. These relations are called symmetric. Formally: a binary relation R over a set A is called symmetric if the following first-order statement is true about R: a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

82 Symmetry Visualized a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

83 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

84 Is This Relation Symmetric? b a a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

85 Is This Relation Symmetric? b a a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

86 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

87 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

88 Is This Relation Symmetric? a b a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

89 Is This Relation Symmetric? a b a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

90 Is This Relation Symmetric? a b a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

91 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

92 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

93 Is This Relation Symmetric? a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

94 Is This Relation Symmetric? a a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

95 Is This Relation Symmetric? a a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

96 Is This Relation Symmetric? a a A. b A. (arb bra) ( If a is related to b, then b is related to a. )

97 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

98 a A. ara a A. b A. (arb bra) a A. b A. c A. (arb brc arc)

99 Transitivity Many relations can be chained together. Examples: If x = y and y = z, then x = z. If R S and S T, then R T. If x ₖ y and y ₖ z, then x ₖ z. These relations are called transitive. A binary relation R over a set A is called transitive if the following first-order statement is true about R: a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

100 Transitivity Visualized a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

101 Is This Relation Transitive? a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

102 Is This Relation Transitive? a b c a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

103 Is This Relation Transitive? a b c a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

104 Is This Relation Transitive? a b c a A. b A. c A. (arb brc arc) ( Whenever a is related to b and b is related to c, we know a is related to c.)

105 Equivalence Relations An equivalence relation is a relation that is reflexive, symmetric and transitive. Some examples: x = y x ₖ y x has the same color as y x has the same shape as y.

106 Binary relations give us a common language to describe common structures.

107 Equivalence Relations Most modern programming languages include some sort of hash table data structure. Java: HashMap C++: std::unordered_map Python: dict If you insert a key/value pair and then try to look up a key, the implementation has to be able to tell whether two keys are equal. Although each language has a different mechanism for specifying this, many languages describe them in similar ways...

108 Equivalence Relations The equals method implements an equivalence relation on non-null object references: It is reflexive: for any non-null reference value x, x.equals(x) should return true. It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. Java 8 Documentation

109 Equivalence Relations The equals method implements an equivalence relation on non-null object references: It is reflexive: for any non-null reference value x, x.equals(x) should return true. It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. Java 8 Documentation

110 Equivalence Relations Each unordered associative container is parameterized by Key, by a function object type Hash that meets the Hash requirements ( ) and acts as a hash function for argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key. Additionally, unordered_map and unordered_multimap associate an arbitrary mapped type T with the Key. C++14 ISO Spec, /3

111 Equivalence Relations Each unordered associative container is parameterized by Key, by a function object type Hash that meets the Hash requirements ( ) and acts as a hash function for argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key. Additionally, unordered_map and unordered_multimap associate an arbitrary mapped type T with the Key. C++14 ISO Spec, /3

112 Time-Out for Announcements!

113 Girls Teaching Girls to Code Exec Team Applications are open now! Want to inspire the next generation of women in tech? Passionate about CS education and outreach? Join the Executive Team of Girls Teaching Girls to Code! Girls Teaching Girls to Code is a program for Stanford students to teach high school girls from around the Bay Area to code. Students learn programming basics, build exciting projects, and develop strong relationships with mentors in the field. We are currently accepting applicants from all majors who are interested in building our corporate relations, coordinating logistics for our events, creating and reviewing curricula, or supporting outreach efforts in the community. This year, we brought together over 200 high school girls and 60 Stanford mentors for a day-long programming experience. Aside from our main event, we also hosted smaller events throughout the year. We received overwhelmingly positive feedback, and we're looking for team leads help us grow GTGTC even more! Learn more about us at and apply at by Friday, October 12, 2018 at 11:59 pm!

114 Problem Set One Solutions We ve just released solutions to Problem Set One, both in hardcopy and online. You need to read over these solutions as soon as possible. Why? Each question is there for a reason. We ve described what it is that we hoped you would have learned when solving those problems. There are lots of different ways of solving these problems. Comparing what you did against our solutions, which are just one possible set of solutions, can help introduce new techniques.

115 Problem Set Two The Problem Set Two checkpoint was due today at 2:30PM. The remaining problems are due Friday at 2:30PM. Have questions? Stop by office hours! Ask on Piazza!

116 Your Questions

117 I m considering an independent contractor job. The contract is confusing- I don t want to get screwed, per se. Where can I get legal advice as an undergrad? You You can can get get free free legal legal advice advice from from the the ASSU ASSU (check (check this this link link for for more more details.) details.) I d I d like like to to hear hear more more about about why why you re you re considering considering this this job. job. If If you you need need the the money money and and they re they re offering offering to to pay pay well, well, or or if if it s it s for for a a project project you re you re genuinely genuinely excited excited about, about, great! great! If If you re you re trying trying to to improve improve your your coding coding skills, skills, make make sure sure that that you re you re actually actually signing signing up up for for something something where where that that will will happen. happen. You You learn learn best best when when you re you re surrounded surrounded by by other other skilled skilled people people who who know know what what they re they re doing. doing. Is Is that that the the case case here? here? If If you re you re doing doing this this to to improve improve your your resume resume are are you you sure sure you you need need to to do do that? that? You You aren t aren t expected expected to to have have past past job job experience experience when when applying applying for for internships internships and and the the like. like.

118 When s a good time and what s the best way to tell my PSet partner I like them? Think Think of of this this as as akin akin to to asking asking a a coworker coworker out out on on a a date. date Keep Keep the the Categorical Categorical Imperative Imperative in in mind mind and and remember remember that that many many people people legitimately legitimately do do not not like like being being hit hit on on in in the the workplace. workplace. As As an an undergrad undergrad there there is is basically basically no no separation separation between between home home and and the the workplace, workplace, but but working working on on problem problem sets sets together together is is way way more more of of the the workplace workplace than than home. home Think Think of of the the position position you you are are putting putting the the other other person person in. in. Your Your ask ask comes comes with with a a real real risk risk of of disrupting disrupting their their work work schedule. schedule. General General advice: advice: give give people people face-saving, face-saving, minimally-disruptive minimally-disruptive ways ways to to say say no. no The The more more important important question question is is do do you you have have a a reason reason to to believe believe the the other other person person enjoys enjoys your your company? company? Because Because if if the the answer answer is is no, no, then then the the answer answer is is never, never, since since otherwise otherwise you re you re weird weird and and awkward. awkward.

119 Back to CS103!

120 Equivalence Relation Proofs Let's suppose you've found a binary relation R over a set A and want to prove that it's an equivalence relation. How exactly would you go about doing this?

121 An Example Relation Consider the binary relation ~ defined over the set Z: a~b if a+b is even Some examples: 0~4 1~9 2~6 5~5 Turns out, this is an equivalence relation! Let's see how to prove it. We We can can binary binary relations relations by by giving giving a a rule, rule, like like this: this: a~b a~b if if some some property property of of a a and and b holds holds This This is is the the general general template template for for defining defining a a relation. relation. Although Although we're we're using using if if rather rather than than iff iff here, here, the the two two above above statements statements are are definitionally definitionally equivalent. equivalent. For For a a variety variety of of reasons, reasons, definitions definitions are are often often introduced introduced with with if if rather rather than than iff. iff. Check Check the the Mathematical Mathematical Vocabulary Vocabulary handout handout for for details. details.

122 What properties must ~ have to be an equivalence relation? Reflexivity Symmetry Transitivity Let's prove each property independently.

123 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

124 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

125 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is What even. is the formal definition of reflexivity? What is the formal definition of reflexivity? To see this, notice that a+a = 2a, so the sum a+a a can be written as a 2k Z. for Z. a some ~ a integer k (namely, a), so a+a is even. Therefore, a~a holds, as Therefore, Therefore, we'll we'll choose choose an an arbitrary arbitrary integer integer a, a, then then required. go go prove prove that that a ~ a. a.

126 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is What even. is the formal definition of reflexivity? What is the formal definition of reflexivity? To see this, notice that a+a = 2a, so the sum a+a a can be written as a 2k Z. for Z. a some ~ a integer k (namely, a), so a+a is even. Therefore, a~a holds, as Therefore, Therefore, we'll we'll choose choose an an arbitrary arbitrary integer integer a, a, then then required. go go prove prove that that a ~ a. a.

127 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is What even. is the formal definition of reflexivity? What is the formal definition of reflexivity? To see this, notice that a+a = 2a, so the sum a+a a can be written as a 2k Z. for Z. a some ~ a integer k (namely, a), so a+a is even. Therefore, a~a holds, as Therefore, Therefore, we'll we'll choose choose an an arbitrary arbitrary integer integer a, a, then then required. go go prove prove that that a ~ a. a.

128 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is What even. is the formal definition of reflexivity? What is the formal definition of reflexivity? To see this, notice that a+a = 2a, so the sum a+a a can be written as a 2k Z. for Z. a some ~ a integer k (namely, a), so a+a is even. Therefore, a~a holds, as Therefore, Therefore, we'll we'll choose choose an an arbitrary arbitrary integer integer a, a, then then required. go go prove prove that that a ~ a. a.

129 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is What even. is the formal definition of reflexivity? What is the formal definition of reflexivity? To see this, notice that a+a = 2a, so the sum a+a a can be written as a 2k Z. for Z. a some ~ a integer k (namely, a), so a+a is even. Therefore, a~a holds, as Therefore, Therefore, we'll we'll choose choose an an arbitrary arbitrary integer integer a, a, then then required. go go prove prove that that a ~ a. a.

130 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

131 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

132 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

133 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

134 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required.

135 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

136 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

137 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because What a+b = b+a, What is the this the formal means formal definition definition of that b+a of symmetry? is symmetry? even. Since b+a is even, we know that b~a, as required. a a Z. Z. b b Z. Z. (a (a ~ b b ~ a) a) Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a and and b where where a ~ b, b, then then prove prove that that b ~ a. a.

138 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because What a+b = b+a, What is the this the formal means formal definition definition of that b+a of symmetry? is symmetry? even. Since b+a is even, we know that b~a, as required. a a Z. Z. b b Z. Z. (a (a ~ b b ~ a) a) Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a and and b where where a ~ b, b, then then prove prove that that b ~ a. a.

139 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because What a+b = b+a, What is the this the formal means formal definition definition of that b+a of symmetry? is symmetry? even. Since b+a is even, we know that b~a, as required. a a Z. Z. b b Z. Z. (a (a ~ b b ~ a) a) Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a and and b where where a ~ b, b, then then prove prove that that b ~ a. a.

140 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because What a+b = b+a, What is the this the formal means formal definition definition of that b+a of symmetry? is symmetry? even. Since b+a is even, we know that b~a, as required. a a Z. Z. b b Z. Z. (a (a ~ b b ~ a) a) Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a and and b where where a ~ b, b, then then prove prove that that b ~ a. a.

141 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because What a+b = b+a, What is the this the formal means formal definition definition of that b+a of symmetry? is symmetry? even. Since b+a is even, we know that b~a, as required. a a Z. Z. b b Z. Z. (a (a ~ b b ~ a) a) Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a and and b where where a ~ b, b, then then prove prove that that b ~ a. a.

142 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

143 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

144 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

145 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

146 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required.

147 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

148 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

149 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that (a+b) + (b+c) = 2k + 2m. Rearranging, a we see that a Z. Z. b b Z. Z. c c Z. Z. (a (a ~ b b ~ c a ~ c) c) a+c + 2b = 2k + 2m, so What What is is the the formal formal definition definition of of transitivity? transitivity? Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a, a, b, b, and and c where where a ~ a+c b and = and 2k b + ~ c, 2m c, then then prove 2b = prove that 2(k+m b). that a ~ c. c. So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

150 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that (a+b) + (b+c) = 2k + 2m. Rearranging, a we see that a Z. Z. b b Z. Z. c c Z. Z. (a (a ~ b b ~ c a ~ c) c) a+c + 2b = 2k + 2m, so What What is is the the formal formal definition definition of of transitivity? transitivity? Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a, a, b, b, and and c where where a ~ a+c b and = and 2k b + ~ c, 2m c, then then prove 2b = prove that 2(k+m b). that a ~ c. c. So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

151 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that (a+b) + (b+c) = 2k + 2m. Rearranging, a we see that a Z. Z. b b Z. Z. c c Z. Z. (a (a ~ b b ~ c a ~ c) c) a+c + 2b = 2k + 2m, so What What is is the the formal formal definition definition of of transitivity? transitivity? Therefore, Therefore, we'll we'll choose choose arbitrary arbitrary integers integers a, a, b, b, and and c where where a ~ a+c b and = and 2k b + ~ c, 2m c, then then prove 2b = prove that 2(k+m b). that a ~ c. c. So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

152 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

153 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a~b and b~c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

154 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

155 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

156 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

157 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

158 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

159 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

160 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

161 An Observation

162 a~b if a+b is even Lemma 1: The binary relation ~ is reflexive. Proof: Consider an arbitrary a Z. We need to prove that a~a. From the definition of the ~ relation, this means that we need to prove that a+a is even. To see this, notice that a+a = 2a, so the sum a+a can be written as 2k for some integer k (namely, a), so a+a is even. Therefore, a~a holds, as required. The The formal formal definition definition of of reflexivity reflexivity is is given given in in first-order first-order logic, logic, but but this this proof proof does does not not contain contain any any first-order first-order logic logic symbols! symbols!

163 a~b if a+b is even Lemma 2: The binary relation ~ is symmetric. Proof: Consider any integers a and b where a~b. We need to show that b~a. Since a~b, we know that a+b is even. Because a+b = b+a, this means that b+a is even. Since b+a is even, we know that b~a, as required. The The formal formal definition definition of of symmetry symmetry is is given given in in first-order first-order logic, logic, but but this this proof proof does does not not contain contain any any first-order first-order logic logic symbols! symbols!

164 a~b if a+b is even Lemma 3: The binary relation ~ is transitive. Proof: Consider arbitrary integers a, b and c where a~b and b~c. We need to prove that a~c, meaning that we need to show that a+c is even. Since a~b and b~c, we know that a+b and b+c are even. This means there are integers k and m where a+b = 2k and b+c = 2m. Notice that Rearranging, we see that so (a+b) + (b+c) = 2k + 2m. a+c + 2b = 2k + 2m, The The formal formal definition definition of of transitivity transitivity is is given given in in first-order first-order logic, logic, but but this this proof proof does does not not contain contain any any first-order first-order logic logic symbols! symbols! a+c = 2k + 2m 2b = 2(k+m b). So there is an integer r, namely k+m b, such that a+c = 2r. Thus a+c is even, so a~c, as required.

165 First-Order Logic and Proofs First-order logic is an excellent tool for giving formal definitions to key terms. While first-order logic guides the structure of proofs, it is exceedingly rare to see first-order logic in written proofs. Follow the example of these proofs: Use the FOL definitions to determine what to assume and what to prove. Write the proof in plain English using the conventions we set up in the first week of the class. Please, please, please, please, please internalize the contents of this slide!

166 Next Time A Fundamental Theorem Why are equivalence relations so useful? Proofs on Relations Proving properties of abstract objects. Strict Orders Representing rankings and requirements. Hasse Diagrams How to draw strict orders.

Binary Relations Part One

Binary Relations Part One Binary Relations Part One Outline for Today Binary Relations Reasoning about connections between objects. Equivalence Relations Reasoning about clusters. A Fundamental Theorem How do we know we have the

More information

Lattice Tutorial Version 1.0

Lattice Tutorial Version 1.0 Lattice Tutorial Version 1.0 Nenad Jovanovic Secure Systems Lab www.seclab.tuwien.ac.at enji@infosys.tuwien.ac.at November 3, 2005 1 Introduction This tutorial gives an introduction to a number of concepts

More information

Introduction to Sets and Logic (MATH 1190)

Introduction to Sets and Logic (MATH 1190) Introduction to Sets and Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics and Statistics York University Dec 4, 2014 Outline 1 2 3 4 Definition A relation R from a set A to a set

More information

Binary Relations McGraw-Hill Education

Binary Relations McGraw-Hill Education Binary Relations A binary relation R from a set A to a set B is a subset of A X B Example: Let A = {0,1,2} and B = {a,b} {(0, a), (0, b), (1,a), (2, b)} is a relation from A to B. We can also represent

More information

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

CHAPTER 8. Copyright Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS Copyright Cengage Learning. All rights reserved. SECTION 8.3 Equivalence Relations Copyright Cengage Learning. All rights reserved. The Relation Induced by a Partition 3 The Relation

More information

Relations and Graphs

Relations and Graphs s and are Pictures of (Binary) s E. Wenderholm Department of Computer Science SUNY Oswego c 2016 Elaine Wenderholm All rights Reserved Outline 1 A Function that returns a boolean Special Properties of

More information

Lecture 1: Overview

Lecture 1: Overview 15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant

More information

10/11/2018. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings

10/11/2018. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings Sometimes, relations define an order on the elements in a set. Definition: A relation R on a set S is called a partial ordering or partial order if it is reflexive, antisymmetric, and transitive. A set

More information

CS103 Spring 2018 Mathematical Vocabulary

CS103 Spring 2018 Mathematical Vocabulary CS103 Spring 2018 Mathematical Vocabulary You keep using that word. I do not think it means what you think it means. - Inigo Montoya, from The Princess Bride Consider the humble while loop in most programming

More information

Power Set of a set and Relations

Power Set of a set and Relations Power Set of a set and Relations 1 Power Set (1) Definition: The power set of a set S, denoted P(S), is the set of all subsets of S. Examples Let A={a,b,c}, P(A)={,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}}

More information

equals() in the class Object

equals() in the class Object equals() in the class Object 1 The Object class implements a public equals() method that returns true iff the two objects are the same object. That is: x.equals(y) == true iff x and y are (references to)

More information

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N Mathematical Preliminaries Read pages 529-540 1. Set Theory 1.1 What is a set? A set is a collection of entities of any kind. It can be finite or infinite. A = {a, b, c} N = {1, 2, 3, } An entity is an

More information

9.5 Equivalence Relations

9.5 Equivalence Relations 9.5 Equivalence Relations You know from your early study of fractions that each fraction has many equivalent forms. For example, 2, 2 4, 3 6, 2, 3 6, 5 30,... are all different ways to represent the same

More information

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say Sets 1 Where does mathematics start? What are the ideas which come first, in a logical sense, and form the foundation for everything else? Can we get a very small number of basic ideas? Can we reduce it

More information

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55. 1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

More information

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper. Algebra of Sets Aditya Ghosh April 6, 2018 It is recommended that while reading it, sit with a pen and a paper. 1 The Basics This article is only about the algebra of sets, and does not deal with the foundations

More information

Mathematical Logic Part One

Mathematical Logic Part One Mathematical Logic Part One Question: How do we formalize the logic we've been using in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical equivalences.

More information

Relations I. Margaret M. Fleck. 7 November 2008

Relations I. Margaret M. Fleck. 7 November 2008 Relations I Margaret M. Fleck 7 November 2008 This lecture covers relations and basic properties of relations, which is most of section 8.1 of Rosen. 1 Announcements Model solutions for the second midterm

More information

Problem One: A Quick Algebra Review

Problem One: A Quick Algebra Review CS103A Winter 2019 Solutions for Week One Handout 01S Problem One: A Quick Algebra Review In the first week of CS103, we'll be doing a few proofs that will require some algebraic manipulations and reasoning

More information

CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist

CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist In Handout 28, the Guide to Inductive Proofs, we outlined a number of specifc issues and concepts to be mindful about when

More information

Algebra of Sets (Mathematics & Logic A)

Algebra of Sets (Mathematics & Logic A) Algebra of Sets (Mathematics & Logic A) RWK/MRQ October 28, 2002 Note. These notes are adapted (with thanks) from notes given last year by my colleague Dr Martyn Quick. Please feel free to ask me (not

More information

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation CS 441 Discrete Mathematics for CS Lecture 24 Relations IV Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square Equivalence relation Definition: A relation R on a set A is called an equivalence relation

More information

CMPSCI 250: Introduction to Computation. Lecture #22: Graphs, Paths, and Trees David Mix Barrington 12 March 2014

CMPSCI 250: Introduction to Computation. Lecture #22: Graphs, Paths, and Trees David Mix Barrington 12 March 2014 CMPSCI 250: Introduction to Computation Lecture #22: Graphs, Paths, and Trees David Mix Barrington 12 March 2014 Graphs, Paths, and Trees Graph Definitions Paths and the Path Predicate Cycles, Directed

More information

Graph Theory Part Two

Graph Theory Part Two Graph Theory Part Two Recap from Last Time A graph is a mathematical structure for representing relationships. Nodes A graph consists of a set of nodes (or vertices) connected by edges (or arcs) A graph

More information

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers. Nowadays, the Theory of Computation can be

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

More information

Lecture 3: Recursion; Structural Induction

Lecture 3: Recursion; Structural Induction 15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

More information

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from Discrete Mathematics and It's Applications Kenneth H.

More information

Logic and Discrete Mathematics. Section 2.5 Equivalence relations and partitions

Logic and Discrete Mathematics. Section 2.5 Equivalence relations and partitions Logic and Discrete Mathematics Section 2.5 Equivalence relations and partitions Slides version: January 2015 Equivalence relations Let X be a set and R X X a binary relation on X. We call R an equivalence

More information

Super-Classes and sub-classes

Super-Classes and sub-classes Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an

More information

The class Object. Lecture CS1122 Summer 2008

The class Object.  Lecture CS1122 Summer 2008 The class Object http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html Lecture 10 -- CS1122 Summer 2008 Review Object is at the top of every hierarchy. Every class in Java has an IS-A relationship

More information

lecture24: Disjoint Sets

lecture24: Disjoint Sets lecture24: Largely based on slides by Cinda Heeren CS 225 UIUC 22nd July, 2013 Announcements mp6 due tonight mp7 out soon! mt3 tomorrow night (7/23) Optional review instead of lab tomorrow Code Challenge

More information

Slides for Faculty Oxford University Press All rights reserved.

Slides for Faculty Oxford University Press All rights reserved. Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,

More information

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

CS103 Handout 14 Winter February 8, 2013 Problem Set 5 CS103 Handout 14 Winter 2012-2013 February 8, 2013 Problem Set 5 This fifth problem set explores the regular languages, their properties, and their limits. This will be your first foray into computability

More information

Foundations of Computer Science Spring Mathematical Preliminaries

Foundations of Computer Science Spring Mathematical Preliminaries Foundations of Computer Science Spring 2017 Equivalence Relation, Recursive Definition, and Mathematical Induction Mathematical Preliminaries Mohammad Ashiqur Rahman Department of Computer Science College

More information

What Is A Relation? Example. is a relation from A to B.

What Is A Relation? Example. is a relation from A to B. 3.3 Relations What Is A Relation? Let A and B be nonempty sets. A relation R from A to B is a subset of the Cartesian product A B. If R A B and if (a, b) R, we say that a is related to b by R and we write

More information

Chapter Seven: Regular Expressions. Formal Language, chapter 7, slide 1

Chapter Seven: Regular Expressions. Formal Language, chapter 7, slide 1 Chapter Seven: Regular Expressions Formal Language, chapter 7, slide The first time a young student sees the mathematical constant π, it looks like just one more school artifact: one more arbitrary symbol

More information

Assignment 4 Solutions of graph problems

Assignment 4 Solutions of graph problems Assignment 4 Solutions of graph problems 1. Let us assume that G is not a cycle. Consider the maximal path in the graph. Let the end points of the path be denoted as v 1, v k respectively. If either of

More information

Graph and Digraph Glossary

Graph and Digraph Glossary 1 of 15 31.1.2004 14:45 Graph and Digraph Glossary A B C D E F G H I-J K L M N O P-Q R S T U V W-Z Acyclic Graph A graph is acyclic if it contains no cycles. Adjacency Matrix A 0-1 square matrix whose

More information

Math 187 Sample Test II Questions

Math 187 Sample Test II Questions Math 187 Sample Test II Questions Dr. Holmes October 2, 2008 These are sample questions of kinds which might appear on Test II. There is no guarantee that all questions on the test will look like these!

More information

c) the set of students at your school who either are sophomores or are taking discrete mathematics

c) the set of students at your school who either are sophomores or are taking discrete mathematics Exercises Exercises Page 136 1. Let A be the set of students who live within one mile of school and let B be the set of students who walk to classes. Describe the students in each of these sets. a) A B

More information

Graph Matrices and Applications: Motivational Overview The Problem with Pictorial Graphs Graphs were introduced as an abstraction of software structure. There are many other kinds of graphs that are useful

More information

CSE 100 Advanced Data Structures

CSE 100 Advanced Data Structures CSE 100 Advanced Data Structures Overview of course requirements Outline of CSE 100 topics Review of trees Helpful hints for team programming Information about computer accounts Page 1 of 25 CSE 100 web

More information

Week 8: The fundamentals of graph theory; Planar Graphs 25 and 27 October, 2017

Week 8: The fundamentals of graph theory; Planar Graphs 25 and 27 October, 2017 (1/25) MA284 : Discrete Mathematics Week 8: The fundamentals of graph theory; Planar Graphs 25 and 27 October, 2017 1 Definitions 1. A graph 2. Paths and connected graphs 3. Complete graphs 4. Vertex degree

More information

Chapter 3. Set Theory. 3.1 What is a Set?

Chapter 3. Set Theory. 3.1 What is a Set? Chapter 3 Set Theory 3.1 What is a Set? A set is a well-defined collection of objects called elements or members of the set. Here, well-defined means accurately and unambiguously stated or described. Any

More information

Collections. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Collections. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff Collections by Vlad Costel Ungureanu for Learn Stuff Collections 2 Collections Operations Add objects to the collection Remove objects from the collection Find out if an object (or group of objects) is

More information

Relations. We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples.

Relations. We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples. Relations We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples. Relations use ordered tuples to represent relationships among

More information

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000 The Object Class Mark Allen Weiss Copyright 2000 1/4/02 1 java.lang.object All classes either extend Object directly or indirectly. Makes it easier to write generic algorithms and data structures Makes

More information

Mathematical Logic Part One

Mathematical Logic Part One Mathematical Logic Part One Question: How do we formalize the logic we've been using in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical equivalences.

More information

Recursively Enumerable Languages, Turing Machines, and Decidability

Recursively Enumerable Languages, Turing Machines, and Decidability Recursively Enumerable Languages, Turing Machines, and Decidability 1 Problem Reduction: Basic Concepts and Analogies The concept of problem reduction is simple at a high level. You simply take an algorithm

More information

Fundamental Graph Algorithms Part Three

Fundamental Graph Algorithms Part Three Fundamental Graph Algorithms Part Three Outline for Today Topological Sorting, Part II How can we quickly compute a topological ordering on a DAG? Connected Components How do we find the pieces of an undirected

More information

Symmetric Product Graphs

Symmetric Product Graphs Rochester Institute of Technology RIT Scholar Works Theses Thesis/Dissertation Collections 5-20-2015 Symmetric Product Graphs Evan Witz Follow this and additional works at: http://scholarworks.rit.edu/theses

More information

Functions, High-School Edition

Functions, High-School Edition Functions What is a function? Functions, High-School Edition f(x) = x4 5x2 + 4 source: https://saylordotorg.github.io/text_intermediate-algebra/section_07/6aaf3a5ab540885474d58855068b64ce.png source: http://study.com/cimages/multimages/16/asymptote_1.jpg

More information

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts

More information

Chapter 3: Theory of Modular Arithmetic 1. Chapter 3: Theory of Modular Arithmetic

Chapter 3: Theory of Modular Arithmetic 1. Chapter 3: Theory of Modular Arithmetic Chapter 3: Theory of Modular Arithmetic 1 Chapter 3: Theory of Modular Arithmetic SECTION A Introduction to Congruences By the end of this section you will be able to deduce properties of large positive

More information

Lecture 6,

Lecture 6, Lecture 6, 4.16.2009 Today: Review: Basic Set Operation: Recall the basic set operator,!. From this operator come other set quantifiers and operations:!,!,!,! \ Set difference (sometimes denoted, a minus

More information

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Relations Let s talk about relations! Grade 6 Math Circles November 6 & 7 2018 Relations, Functions, and

More information

CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH. Fall CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam

More information

CSE 20 DISCRETE MATH. Winter

CSE 20 DISCRETE MATH. Winter CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam

More information

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2 2.2 Set Operations 127 2.2 Set Operations Introduction Two, or more, sets can be combined in many different ways. For instance, starting with the set of mathematics majors at your school and the set of

More information

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below: Chapter 4 Relations & Graphs 4.1 Relations Definition: Let A and B be sets. A relation from A to B is a subset of A B. When we have a relation from A to A we often call it a relation on A. When we have

More information

Randomized Algorithms Part Four

Randomized Algorithms Part Four Randomized Algorithms Part Four Announcements Problem Set Three due right now. Due Wednesday using a late day. Problem Set Four out, due next Monday, July 29. Play around with randomized algorithms! Approximate

More information

Randomized Algorithms Part Four

Randomized Algorithms Part Four Randomized Algorithms Part Four Announcements Problem Set Three due right now. Due Wednesday using a late day. Problem Set Four out, due next Monday, July 29. Play around with randomized algorithms! Approximate

More information

Relations, Equivalence Relations, and Partial Orders

Relations, Equivalence Relations, and Partial Orders Massachusetts Institute of Technology Lecture 6 6.042J/18.062J: Mathematics for Computer Science February 17, 2000 Professors David Karger and Nancy Lynch Relations, Equivalence Relations, and Partial

More information

Today s Outline. Motivation. Disjoint Sets. Disjoint Sets and Dynamic Equivalence Relations. Announcements. Today s Topics:

Today s Outline. Motivation. Disjoint Sets. Disjoint Sets and Dynamic Equivalence Relations. Announcements. Today s Topics: Today s Outline Disjoint Sets and Dynamic Equivalence Relations Announcements Assignment # due Thurs 0/ at pm Today s Topics: Disjoint Sets & Dynamic Equivalence CSE Data Structures and Algorithms 0//0

More information

Theory of Computation

Theory of Computation Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

More information

(Refer Slide Time: 01.26)

(Refer Slide Time: 01.26) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.

More information

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL: Notes slides from before lecture CSE 21, Winter 2017, Section A00 Lecture 9 Notes Class URL: http://vlsicad.ucsd.edu/courses/cse21-w17/ Notes slides from before lecture Notes February 8 (1) HW4 is due

More information

Student Work for Triangle congruence ARC

Student Work for Triangle congruence ARC Student Work for Triangle congruence ARC Max Ray-Riek The Math Forum / NCTM Deidra Baker Mid-Prairie High School Wellman Iowa The Vision of the CRC Create an online mathematics education professional learning

More information

Figure 4.1: The evolution of a rooted tree.

Figure 4.1: The evolution of a rooted tree. 106 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES 4.6 Rooted Trees 4.6.1 The idea of a rooted tree We talked about how a tree diagram helps us visualize merge sort or other divide and conquer algorithms.

More information

Proofwriting Checklist

Proofwriting Checklist CS103 Winter 2019 Proofwriting Checklist Cynthia Lee Keith Schwarz Over the years, we ve found many common proofwriting errors that can easily be spotted once you know how to look for them. In this handout,

More information

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 16 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 16 Notes Goals for this week Graph basics Types

More information

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition. 18.433 Combinatorial Optimization Matching Algorithms September 9,14,16 Lecturer: Santosh Vempala Given a graph G = (V, E), a matching M is a set of edges with the property that no two of the edges have

More information

Lecture 10: Strongly Connected Components, Biconnected Graphs

Lecture 10: Strongly Connected Components, Biconnected Graphs 15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search

More information

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 This fifth problem set explores the regular languages, their properties, and their limits. This will be your first foray into computability theory,

More information

CS 4349 Lecture October 18th, 2017

CS 4349 Lecture October 18th, 2017 CS 4349 Lecture October 18th, 2017 Main topics for #lecture include #minimum_spanning_trees. Prelude Homework 6 due today. Homework 7 due Wednesday, October 25th. Homework 7 has one normal homework problem.

More information

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs: CS70 - Lecture 6 Graphs: Coloring; Special Graphs 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs: Trees: Three characterizations Hypercubes: Strongly connected! Administration You need

More information

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph Graphs and Trees Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) who is connected to whom Web search views web pages as a graph Who points to whom Niche graphs (Ecology):

More information

Outline for Today. Why could we construct them in time O(n)? Analyzing data structures over the long term.

Outline for Today. Why could we construct them in time O(n)? Analyzing data structures over the long term. Amortized Analysis Outline for Today Euler Tour Trees A quick bug fix from last time. Cartesian Trees Revisited Why could we construct them in time O(n)? Amortized Analysis Analyzing data structures over

More information

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan MATH 22 Lecture M: 10/14/2003 MORE ABOUT FUNCTIONS Form follows function. Louis Henri Sullivan This frightful word, function, was born under other skies than those I have loved. Le Corbusier D ora innanzi

More information

CPS122 Lecture: Course Intro; Introduction to Object-Orientation

CPS122 Lecture: Course Intro; Introduction to Object-Orientation Objectives: CPS122 Lecture: Course Intro; Introduction to Object-Orientation 1. To introduce the course requirements and procedures. 2. To introduce fundamental concepts of OO: object, class Materials:

More information

Lecture 22 Tuesday, April 10

Lecture 22 Tuesday, April 10 CIS 160 - Spring 2018 (instructor Val Tannen) Lecture 22 Tuesday, April 10 GRAPH THEORY Directed Graphs Directed graphs (a.k.a. digraphs) are an important mathematical modeling tool in Computer Science,

More information

An Introduction to Graph Theory

An Introduction to Graph Theory An Introduction to Graph Theory Evelyne Smith-Roberge University of Waterloo March 22, 2017 What is a graph? Definition A graph G is: a set V (G) of objects called vertices together with: a set E(G), of

More information

Basics of Computational Geometry

Basics of Computational Geometry Basics of Computational Geometry Nadeem Mohsin October 12, 2013 1 Contents This handout covers the basic concepts of computational geometry. Rather than exhaustively covering all the algorithms, it deals

More information

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Theory of Computation Dr. Weiss Extra Practice Exam Solutions Name: of 7 Theory of Computation Dr. Weiss Extra Practice Exam Solutions Directions: Answer the questions as well as you can. Partial credit will be given, so show your work where appropriate. Try to be

More information

1. Relations 2. Equivalence relations 3. Modular arithmetics. ! Think of relations as directed graphs! xry means there in an edge x!

1. Relations 2. Equivalence relations 3. Modular arithmetics. ! Think of relations as directed graphs! xry means there in an edge x! 2 Today s Topics: CSE 20: Discrete Mathematics for Computer Science Prof. Miles Jones 1. Relations 2. 3. Modular arithmetics 3 4 Relations are graphs! Think of relations as directed graphs! xry means there

More information

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grades 7 & 8, Math Circles 31 October/1/2 November, 2017 Graph Theory Introduction Graph Theory is the

More information

Balanced Trees Part One

Balanced Trees Part One Balanced Trees Part One Balanced Trees Balanced search trees are among the most useful and versatile data structures. Many programming languages ship with a balanced tree library. C++: std::map / std::set

More information

Outline Purpose Disjoint Sets Maze Generation. Disjoint Sets. Seth Long. March 24, 2010

Outline Purpose Disjoint Sets Maze Generation. Disjoint Sets. Seth Long. March 24, 2010 March 24, 2010 Equivalence Classes Some Applications Forming Equivalence Classes Equivalence Classes Some Applications Forming Equivalence Classes Equivalence Classes The class of all things equivelant

More information

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 3-A Graphs Graphs A directed graph (or digraph) G is a pair (V, E), where V is a finite set, and E is a binary relation on V The set V: Vertex set of G The set E: Edge set of

More information

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th COMS 1003 Fall 2005 Introduction to Computer Programming in C Bits, Boolean Logic & Discrete Math September 13 th Hello World! Logistics See the website: http://www.cs.columbia.edu/~locasto/ Course Web

More information

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Lecture 04 Software Test Automation: JUnit as an example

More information

AXIOMS FOR THE INTEGERS

AXIOMS FOR THE INTEGERS AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,

More information

Integer Partition Poset

Integer Partition Poset Integer Partition Poset Teena Carroll St. Norbert College Presented at the Clemson REU Summer 2010 Integer Partitions Given an integer, how can we break it down into the sum of positive integers? ex: n=5

More information

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 [talking head] This lecture we study theory design and implementation. Programmers have two roles to play here. In one role, they

More information

(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017

(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017 Integrated Introduction to Computer Science Hughes (Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017 Contents 1 Announcements 1 2 Evaluation Correction 1 3 Lists 2

More information

Congruence Arithmetic

Congruence Arithmetic Module 4 Congruence Arithmetic Popper 4 Introduction to what is like Modulus choices Partitions by modulus Mod 5 Mod 7 Mod 30 Modular Arithmetic Addition Subtraction Multiplication INTEGERS! Mod 12 Cayley

More information

Lecture 20 : Trees DRAFT

Lecture 20 : Trees DRAFT CS/Math 240: Introduction to Discrete Mathematics 4/12/2011 Lecture 20 : Trees Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last time we discussed graphs. Today we continue this discussion,

More information

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form Normal Forms for CFG s Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form 1 Variables That Derive Nothing Consider: S -> AB, A -> aa a, B -> AB Although A derives

More information

Reasoning About Imperative Programs. COS 441 Slides 10

Reasoning About Imperative Programs. COS 441 Slides 10 Reasoning About Imperative Programs COS 441 Slides 10 The last few weeks Agenda reasoning about functional programming It s very simple and very uniform: substitution of equal expressions for equal expressions

More information