I'm doing an exercise in a lecture note
Let $A$ be a non-empty set of $\mathbb{R}^{n}$. Show that $A$ is convex if and only if $\frac{x}{2}+\frac{y}{2} \in A$ for any $x,y \in A$.
I feel that this maybe not true. I construct a counter-example as follows. Could you please verify if my understanding is fine?
We define a sequence $(A_n)$ by $A_0 = \{x,y\}$ where $x \neq y$ and $A_{n+1} = \{\frac{a+b}{2} \mid a,b \in A_n\}$. Let $B = \bigcup A_n$. Then $B$ satisfies the condition that $\frac{a+b}{2} \in B$ for all $a,b \in B$. Next we verify that $B$ is not convex. For $b \in B$, we have $b \in A_n$ for some natural number $n$. Then $b = \frac{a_{n-1,1}+a_{n-1,2}}{2} \in B$ for some $a_{n-1,1},a_{n-1,2} \in A_{n-1}$. Recursively, we have $$b = \frac{\sum_{i=1}^{2n} a_{0,i}}{2^n}$$ where $a_{0,i} \in A_0$ for all $i$. As a result, we have for some $k$, $$b = \frac{k}{2^n}x + \frac{(2n-k)}{2^n}y$$
It follows that if $b = \frac{e}{3}x + \frac{3-e}{3} y$ then $b \notin B$.