Let $f : \mathbb R \to \mathbb R$ be a continuous function. Suppose that the restriction of $f$ to the set of irrational numbers is injective. What can we say about $f$? Answer the analogous question if $f$ is restricted to rationals.
1. **Given**: \( f : \mathbb{R} \to \mathbb{R} \) is a continuous function, and the restriction of \( f \) to the set of irrational numbers is injective.
2. **To Prove**: \( f \) is injective and strictly monotonic on the whole \( \mathbb{R} \).

### Proof:
#### Lemma 1:
Exactly one of the following two alternatives holds:
(a) \( \forall x_1, x_2 \in \mathbb{R} - \mathbb{Q}, x_1 < x_2 \Rightarrow f(x_1) < f(x_2) \).
(b) \( \forall x_1, x_2 \in \mathbb{R} - \mathbb{Q}, x_1 < x_2 \Rightarrow f(x_1) > f(x_2) \).

**Proof of Lemma 1**:
- Assume the assertion is not true. Then there exist irrational numbers \( x_1 < x_2 < x_3 \) such that:
  1. \( f(x_1) < f(x_2) \) and \( f(x_2) > f(x_3) \), or
  2. \( f(x_1) > f(x_2) \) and \( f(x_2) < f(x_3) \).

- Assume case (1) holds (case (2) is similar). Let \( y_0 \in (f(x_1), f(x_2)) \cap (f(x_3), f(x_2)) \). Because \( f \) is continuous, there exists \( x_0 \in (x_1, x_2) \) such that \( y_0 = f(x_0) \) and there exists \( \delta > 0 \) such that \( \forall x \in (x_0 - \delta, x_0 + \delta) \Rightarrow x_1 < x < x_2 \) and \( f(x) \in (f(x_1), f(x_2)) \cap (f(x_3), f(x_2)) \).

- Let \( I \) denote the set of all irrational points in \( (x_0 - \delta, x_0 + \delta) \). Fix some \( x \in I \) and define \( F_x = \{ z \mid z \in (x_2, x_3), f(z) = f(x) \} \).

- Then \( F_x \neq \emptyset \) and \( F_x \subset \mathbb{Q} \) because \( f \) is injective on the irrational numbers. Moreover, \( \forall x, y \in I, x \neq y \Rightarrow F_x \cap F_y = \emptyset \).

- This is impossible because \( I \) is uncountable while \( \mathbb{Q} \) is countable. This contradiction proves Lemma 1. \( \blacksquare \)

#### Conclusion from Lemma 1:
- \( f \) is strictly monotonic on the irrational numbers. Due to the continuity of \( f \), it follows that \( f \) is strictly monotonic on \( \mathbb{R} \).

- Assume without loss of generality that \( f \) is strictly increasing on \( \mathbb{R} - \mathbb{Q} \). Let \( r_1, r_2 \in \mathbb{Q}, r_1 < r_2 \). Then there exist sequences \( \{x_i\}, \{y_i\} \) with \( x_i, y_i \in \mathbb{R} - \mathbb{Q} \) such that \( \lim_{i \to \infty} x_i = r_1 \) and \( \lim_{i \to \infty} y_i = r_2 \). Hence, \( f(r_1) < f(r_2) \).

- Therefore, \( f \) is strictly monotonic and injective on \( \mathbb{R} \).

### Analogous Question for Rationals:
- Consider the function \( f(x) = -x \) for \( x < 0 \) and \( f(x) = \sqrt{2}x \) for \( x \geq 0 \).

- The restriction of \( f \) to the set of rational numbers is injective, but \( f \) is not injective on \( \mathbb{R} \).

The final answer is \( \boxed{ f } \) is injective and strictly monotonic on the whole \( \mathbb{R} \) if it is injective on the irrationals. If \( f \) is injective on the rationals, it does not necessarily follow that \( f \) is injective on \( \mathbb{R} \).