Files
notes/CS1029/practical-2023-11-03/relations
bluepython508 d320a956f8 2023-11-15
2023-11-15 08:53:39 +00:00

59 lines
1.8 KiB
Plaintext

1. a) {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5), (5, 5) }
Reflexive: \forall x. (x, x) \in R
Antisymmetric (& not symmetric): all pairs have x <= y. forall x, y. x <= y, !(y <= x) || y == x
Transitive
b) {(1, 2), (1, 4), (2, 1), (2, 3), (3, 2), (3, 4), (4, 1), (4, 3)}
Not reflexive: there are no pairs of (x, x)
Symmetric - all pairs have their reverse represented
Not antisymmetric: symmetric and anti-symmetric are mutually exclusive
Not transitive: (1, 2) and (2, 3) - 1 + 3 is not odd
2. {(item, quantity)}
{(Name, {(key, value)})}
{(Name, Address, {(Room type, price, {(key, value)})}, ...)}
3. 105 305 306 505 705 707 905 906 909
4. a) ab ac bc cb
b) {(a, a), (a, b), (a, c), (b, b), (b, a), (b, c), (c, a), (c, b), (d, d)}
5.a) {(1, 1), (1, 2), (1, 4), (2, 1), (2, 3), (3, 2), (3, 3), (3, 4), (4, 1), (4, 3), (4, 4)}
Not reflexive: (2, 2) is not present
Symmetric, therefore not anti-symmetric
Not transitive: (1, 2) and (2, 3), but not (1, 3)
b) 12 21 14 41 32 23 43 34
Not reflexive
Symmetric, therefore not antisymmetric
Not transitive: 12 and 23 but not 13
6. 1 1 0 0
1 1 0 0
1 0 1 1
0 0 0 1
Yes, it's reflexive
8. {(a, b) | a divides b OR b divides a}
9. No, it's not transitive. (a, b) & (b, d), but not (a, d)
10. a) Not equivalence relation: missing transitivity
(1, 3) and (3, 2), but not (1, 2)
b) {0}, {1, 2}, {3}
11. \forall n \in N_0:
0 + 3n
1 + 3n
2 + 3n
12. a) Y
b) N: 0 is in both - not disjoint
c) Y
d) N: 0 is missing
13. a) 00 11 22 33 44 55 12 21 34 43 35 53 45 54
b) 00 11 22 33 44 55 01 10 23 32 45 54
c) 00 11 22 33 44 55 01 10 02 20 12 21 34 43 35 53 45 54
14. a) Y, trivially
b) N: not antisymmetric ((2, 3) and (3, 2))
c) N: not reflexive (no (3, 3))