two problems involving continuous functions 
  
*
  
*Let $f:[0,1]\to [0,1]$ be such that $|f(x)-f(y)|\leq \frac{1}{2}|x-y|$  $\forall x,y\in[0,1]$. Let $$A=\{x\in[0,1]: f(x)=x\}.$$ Then number of elements in $A$ is what?   
  
*Let $f:[0,1]\to[0,1]$ be continuous and such that $f(0)=f(1)$. Let  $$A=\{(t,s) \in [0,1]\times [0,1]: t\neq s\text{ and }f(t)=f(s)\}.$$ Then the number of elements in $A$ is what?   
  

My thoughts:
For (1) from the given condition we get $f'(x) \leq 1/2$ if the derivative exist and $f$ is non-constant. So if $f(x)=x$ then $f'(x)=1$. So not possible. But if $f$ becomes a constant function then it has a fixed point. So the answer will be 1. Is my thinking correct?  
For (2) I am taking $\sin x$ from $[0,n\pi]$ to $[0,1]$ then it has so many points satisfying the given condition. Now $[0,n\pi]$ is homeomorphic to $[0,1]$. So $A$ has infinitely many points. Is my thinking correct?
 A: 2.
Since $f$ is continuous, it attains its maximum $a:=\max_{0\le x\le 1} f(x)$ and minimum $b:=\min_{0\le x\le 1} f(x)$ in $[0,1]$. Assume $f(x_1)=a$ and $f(x_2)=b$.
If $f(0)=f(1)<a$, then for every $y \in (f(0),a)$, there exists an $s\in(0,x_1)$ with $f(s)=y$ and there also exists $t\in (x_1,1)$ with $f(t)=y$. So in this case $A$ is uncountable.
Similarly, if $f(0)=f(1)>b$, we find for evarey $y\in (b,f(0))$ an $s\in (0,x_2)$ and $t\in(x_2,1)$ with $f(s)=f(t)=y$. So again $A$ is uncountable.
Remains the case that $f(0)=f(1)=a=b$. But then $f$ is constant, $A=[0,1]\times[0,1]$ uncountable.
A: For 1. if $|A|>1$ then we can pick $t,s\in A$. Since they are in A we get $f(t)=t$ AND $f(s)=s$. Since $A$ is a subset of $[0,1]$ we get $|f(t)-f(s)|\leq\frac{1}{2}|t-s|<\frac{3}{4}|t-s|$. Notice that $|f(t)-f(s)|=|t-s|$ since $f(t)=t$ AND $f(s)=s$. This tells us that $|t-s|<\frac{3}{4}|t-s|$, clearly a contradiction. 
Suppose now that $|A|=0$. Pick $t\in[0,1]$ arbitrarily. Let $a_1=t$, $a_2=f(t)$, $a_3=f(f(t))$ and so on. This defines a sequence $\{a_n\}_{n=1}^\infty \subseteq [0,1]$. 
Now, let $m,n\in\mathbb{N}$ be arbitrary and WLOG assume $m\geq n$. The Triangle Inequality tells us that $|a_m -a_n|\leq |a_m-a_{m-1}|+|a_{m-1}-a_{m-2}|+\cdots+|a_{n+1}-a_n|$. Notice though that we can write the absolute value of the difference of two consecutive terms in the sequence as $|a_{k+1}-a_k|=|f^k(t)-f^{k-1}(t)|\leq\frac{1}{2}|f^{k-1}(t)-f^{k-2}(t)|<\frac{3}{4}|f^{k-1}(t)-f^{k-2}(t)|=\frac{3}{4}|a_{k}-a_{k-1}|$. By induction, $|a_{k+1}-a_k|<(\frac{3}{4})^{k-1}|a_2-a_1|=(\frac{3}{4})^{k-1}|f(t)-t|$. Therefore 
$|a_m -a_n|\leq |a_m-a_{m-1}|+|a_{m-1}-a_{m-2}|+\cdots+|a_{n+1}-a_n|<|f(t)-t|((\frac{3}{4})^{m-2}+(\frac{3}{4})^{m-3}+\cdots+(\frac{3}{4})^{n-1})<|f(t)-t|(\frac{3}{4})^{n-1}\frac{1}{1-\frac{3}{4}}$
It follows by definition that $a_n$ is a Cauchy sequence. Since $\mathbb{R}$ is a complete metric space with the Euclidean metric, it follows that every Cauchy Sequence converges. This means $a_n$ converges. Let $a$ be the limit of $a_n$. Since $[0,1]$ is compact, $a\in [0,1]$. 
We show $f(a)=a$. By Triangle Ineq. $|f(a)-a|\leq|f(a)-f(a_n)|+|f(a_n)-a|$. Since by definition $f(a_n)=a_{n+1}$ we get that $|f(a)-a|\leq|f(a)-f(a_n)|+|a_{n+1}-a|$. We have $|f(a)-f(a_n)|<\frac{3}{4}|a-a_n|$. Therefore  $|f(a)-a|<\frac{3}{4}|a-a_n|+|a_{n+1}-a|$. By making both terms in the RHS of the inequality less than $\frac{\epsilon}{2}$ for arbitrary $\epsilon>0$, we show that $f(a)=a$. This tells us there exists an element in $[0,1]$ s.t. it is a fixed point. Therefore it follows that $|A|=1$. 
A: 1>
$g: [0,1] \rightarrow \mathbb R $ defined by  $g(x) =|f(x) - x|$ then g is continuous function.
$g$ attains its minimun at $a \in [0,1]$ if $f(a) \neq a $ then $g(f(a)) =|f(f(a)) - f(a)| \leq \frac{1}{2}|f(a)- a| \leq |f(a)- a|=g(a)$ contradicting the fact g attains minimum at $a$ hence $f(a) = a$. 
then $f$ can have atmat one fixed point as if $f(x) = x $ and $f(y)= y $  then $|f(x)- f(y)| = |x-y|\leq \frac{1}{2}|x- y|$ (a contradiction)
A: For problem $1$, $f$ is a contraction mapping on a complete metric space, so we see that it has a unique fixed point by the Banach fixed-point theorem.
