---
# System prepended metadata

title: Lab 12- A Plethora of Definitions

---

# Lab 12- A Plethora of Definitions 
## Problem 1: Relatable

a. 
- dom$(R) = \{a, b, c, d, e\}$
- range$(R) = \{b, c, d, f\}$
- $R^{-1} = \{(b, a), (c, a), (d, b), (c, c), (b, d), (b, e), (f, e)\}$
- $R(a) = \{b,c\}$

b. $S$ is a set of people, $R(x,y)$ shows who $y$ is $x$'s favourite person.
c. 
* domain: all of the people who have a favorite person
* range: all of the people who are someone's favorite person
* inverse: The relation of people who are favorite people to people who have favourites.
* $R(a)$: all of a's favorite people

## Problem 2: Representatives

a.
- Partial:
    - $S = \{a , b, c\}$
    - $T = \{b\}$
    - $R = \{(a,b), (b,b)\}$
- Injective: 
    - $S = \{1, 2, 3\}$ 
    - $T = \{4, 5, 6, 7\}$  
    - $R = \{(1, 4), (2, 5), (3, 6)\}$
- Surjective:
    - $S = \{t, u, v\}$
    - $T = \{x\}$
    - $R = \{(t, x), (u, x), (v, x)\}$
- Left-Unique Partial:
    - $S = \{a\}$
    - $T = \{a, b , c\}$
    - $R = \{(a, a), (a, b)\}$
- Bijection:
    - $S = \{d\}$
    - $T = \{e\}$
    - $R = \{(d, e)\}$

b.
Partial:
```racket!
(define partial 
 (lambda (x)
     (if (= x 0)
         (partial x)
         3)))
```
Surjective:
```racket!
(define surjective
    (lambda(y)
    7))
```
## Problem 3: Applications to Programming
- Total programming functions would be able to handle all inputs of the input type specified, while a partial programming function may only be able to handle certain cases. 
- Being able to account for all inputs reduces errors and makes the function more widely usable.

## Problem 4: Compression

- If the functions were surjective but not injective, this would not be a good compression program. This is because a surjective funtion is not left-unique. A single zip file could point to several possible unique files.
- A function that is injective but not surjective is a better program for file compressions. This function is left total, so all possible inputs are accounted for. It is also right and left unique, so each input has a unique output and each output has a unique input.