# First Midterm Exam

### Directions:

• This is a closed book and notes exam.
• No computer or calculators of any kind are allowed.
• Please make sure that your phone is turned off and out of reach.
• There are seven questions for 100 total points. Scale was A = 95, C = 75.
• If you finish early, please read over your solutions and make sure that they are clear and correct. Use any extra time to improve their correctness and clarity.
• Partial credit will be given for partial solutions. Good luck!

```  Q1: 20 points
Q2: 15 points
Q3: 10 points
Q4: 15 points
Q5: 15 points
Q6: 10 points
Q7: 15 points
Total: 100 points
```

• Question 1 (20): Determine whether the following rules define functions from the given domain to co-domain, and if so, whether they are 1:1, onto, both, or neither. If you say that the function is 1:1 and onto, then also describe its inverse. Recall that Σb = {0, 1}.

• (a) a: RR where a(x) = x3
• (b) b: Σb × Σb → Σb × Σb where b(x, y) = (x ⊕ y, y)
• (c) c: RR where c(x) = 1/x
• (d) d: ZZ where d(x) = x ⋅ |x|
• (e) e: N × NZ where e(x, y) = 6x - 3y

• Question 2 (15): Let r be the proposition "it is raining", let c be "I go to class today", let h be "I did my homework", let b be "I go bicycling today", and let g be "I will have a great day". Write PropCalc formulas to express each of the following. Then convert each of your formulas to CNF. (Recall that CNF is conjunctive normal form: and's of or's of literals.)

• (a) If I've done my homework and I go to class then I will have a great day.
• (b) If I go bicycling and do not go to class then I will have a great day, but I won't go bicycling if it is raining.

• Question 3 (10): Define {a, b}* = {λ, a, b, aa, ab, ba, bb, aaa,...} to be the set of all finite strings from the alphabet {a, b}. A finite string is a finite sequence of symbols, including λ which is the empty string. Argue that {a, b}* is countably infinite, i.e., it has the same cardinality as N.

• Question 4 (15): Use Euclid's algorithm to solve the following problems:

• (a) Compute gcd(119, 15).
• (b) Express gcd(119, 5) as a linear combination of 119 and 15.
• (c) If 15 has a multiplicative inverse modulo 119, compute it. If not, explain why not.

• Question 5 (15): Use Euclid's algorithm to solve the following problems:

• (a) Compute gcd(253, 66).
• (b) Express gcd(253, 66) as a linear combination of 253 and 66.
• (c) If 66 has a multiplicative inverse modulo 253, compute it. If not, explain why not.

• Question 6 (10): Compute 99 mod 11. Please use the repeated-squaring method taught in class.

• Question 7 (10): Find the smallest natural number that satisfies the following congruences: x ≡ 3 (mod 4), x ≡ 4 (mod 5), and x ≡ 1 (mod 7). Please use the method taught in class.