Description
Problem 3.1: cartesian products (1+1 = 2 points)
Prove or disprove the following two propositions:
a) (A ∩ B) × (C ∩ D) = (A × C) ∩ (B × D)
b) (A ∪ B) × (C ∪ D) = (A × C) ∪ (B × D)
Problem 3.2: reflexive, symmetric, transitive (3 points)
For each of the following relations, determine whether they are reflexive, symmetric, or transitive.
Provide a reasoning.
a) The absolute difference of the integer numbers a and b is less than or equal to 3.
R = {(a, b)|a, b ∈ Z ∧ |a − b| ≤ 3}
b) The last digit of the decimal representation of the integer numbers a and b is the same.
R = {(a, b)|a, b ∈ Z ∧ (a mod 10) = (b mod 10)}
Problem 3.3: total, injective, surjective, bijective functions (1+1 = 2 points)
Are the following functions total, injective, surjective, or bijective? Expain why or why not.
a) f : N 7→ N with f(x) = 2x
2
b) f : R 7→ R with f(x) = x
2 + 6
Problem 3.4: function composition (1 point)
Given the functions f(x) = x + 1. g(x) = 2x, and h(x) = x
2
, determine an expression for the
following function compositions:
a) f ◦ g
b) f ◦ h
c) g ◦ f
d) g ◦ h
e) h ◦ f
f) h ◦ g
g) f ◦ (g ◦ h)
h) h ◦ (g ◦ f)
Problem 3.5: list comprehensions (haskell) (1+1 = 2 points)
Your list comprehensions should be correct, they do not have to be efficient. You are not getting
points for a list comprehension simply returning a hard coded solution list. In other words, your list
comprehensions should continue to function correctly if parameters are changed.
a) Write a list comprehension that returns all positive factors of the number 210. Try to write the
list comprehension in such a way that 210 can easily be replaced by a different number.
b) Write a list comprehension that returns a list of Pythagorean triads (a, b, c), where a, b, c are
positive integers in the range 1..100 and the Pythagorean triad is defined as a
2 + b
2 = c
2
. The
list should not contain any “duplicates” where a and b are swapped. If the list contains (3, 4, 5)
(since 3
2 + 42 = 25 = 52
), then is should not also include (4, 3, 5).