A regular curve is closed if and only if it has a regular periodic extension I have to prove the following statement:

A regular curve $\gamma:[a,b]\to\mathbb{R}^n$ is a closed curve if and only if there exists a periodic regular curve $\tilde\gamma:\mathbb{R}\to\mathbb{R}^n$ with period $b-a$ such that $\tilde\gamma(t)=\gamma(t)$ for all $t\in[a,b]$

I did the following proof, and I would be thankful if someone could verify it, tell me how to fix it if it is wrong, give me comments and tips, or share your own proofs if you want to.
Proof.
$(\implies)$ Suppose $\gamma$ is a closed curve. For each $x\in\mathbb{R}$ we define:
$$
E_x=\{k\in\mathbb{Z}:x\leq b+k(b-a)\}, K_x=\text{min}(E_x)
$$
It is clear that $K_x=\left[\dfrac{x-b}{b-a}\right]+1$, where $[\cdot]$ denotes the floor function. Futhermore it is easy to see that:
$$
x\leq b + K_x(b-a) \implies x-K_x(b-a)\leq b
$$
and
$$
x\geq b + (K_x-1)(b-a)=a+K_x(b-a) \implies x-K_x(b-a)\geq a
$$
therefore it happens that $x-K_x(b-a)\in[a,b]$ for all $x\in\mathbb{R}$. Now we define $\tilde\gamma:\mathbb{R}\to\mathbb{R}^n$ by $\tilde\gamma(x)=\gamma(x-K_x(b-a))$. Lets see that $\tilde\gamma$ has period $b-a$. Let $w\in\mathbb{Z}$. First notice that:
$$
k\in E_x \iff x\leq b+k(b-a) \iff x+w(b-a)\leq b+(k+w)(b-a) \iff k+w\in E_{x+w(b-a)}
$$
from where we have $E_x=E_{x+w(b-a)}$ and by definition of $K_x$ we have $K_x=K_{x+w(b-a)}-w$. This way we have:
$$
\tilde\gamma(x+w(b-a))=\gamma(x+w(b-a)-K_{x+w(b-a)}(b-a))=\gamma(x-(K_{x+w(b-a)}-w)(b-a)) =\gamma(x-K_x(b-a))=\tilde\gamma(x)
$$
Therefore, $\tilde\gamma$ has period $b-a$. Lets now see that $\tilde\gamma$ is differentiable in all of $\mathbb{R}$. Let $c\in\mathbb{R}$. If $c$ is not of the form $b+w(b-a)$ for some $w\in\mathbb{Z}$ then $\dfrac{c-b}{b-a}\notin\mathbb{Z}$ and this way the function $g(x)=\left[\dfrac{x-b}{b+a}\right]+1=K_x$ has a derivative in $c$ and $g'(c)=0$. This implies that $x\mapsto x-K_x(b-a)$ is differentiable in $c$ and has derivative $1$ from where we have that $\tilde\gamma$ is differentiable in $c$ and by the chain rule:
$$
\tilde\gamma'(c)=\gamma '(c-K_c(b-a))\neq 0
$$
Now, if $c=b+w(b-a)$ for some $w\in\mathbb{Z}$, notice the following:
$$
\lim_{x\to c^-}\dfrac{\tilde\gamma(x)-\tilde\gamma(c)}{x-c}=\lim_{x\to c^-}\dfrac{\tilde\gamma(x)-\tilde\gamma(b+w(b-a))}{x-b-w(b-a)}=\lim_{x\to c^-}\dfrac{\tilde\gamma(x)-\tilde\gamma(b)}{x-b-w(b-a)}
$$
Considering the change of variables $x=y+w(b-a)$ and considering that:
$$
\lim_{y\to b^-}y+w(b-a)=b^-+w(b-a)=c^-
$$
we have that, restricting the second limits on a "left-neighbourhood" of $b$ contained in $[a,b]$:
$$
\lim_{x\to c^-}\dfrac{\tilde\gamma(x)-\tilde\gamma(c)}{x-c}=\lim_{y\to b^-}\dfrac{\tilde\gamma(y+w(b-a))-\tilde\gamma(b)}{y+w(b-a)-b-w(b-a)}=\lim_{y\to b^-}\dfrac{\gamma(y+w(b-a)-w(b-a))-\gamma(b)}{y-b}=\lim_{y\to b^-}\dfrac{\gamma(y)-\gamma(b)}{y-b}=\gamma '(b)
$$
Similarly, we have that:
$$
\lim_{x\to c^+}\dfrac{\tilde\gamma(x)-\tilde\gamma(c)}{x-c}=\gamma '(b)
$$
and this way $\lim_{x\to c}\dfrac{\tilde\gamma(x)-\tilde\gamma(c)}{x-c}=\gamma '(b)$ from where $\tilde\gamma'(c)=\gamma'(b)\neq 0$.
In conclusion, $\tilde\gamma$ is differentiable in all of $\mathbb{R}$ and its derivative never vanishes, which implies that $\tilde\gamma$ is a regular curve. It is also easy to see that $\tilde\gamma|_{[a,b]}=\gamma$. We get that $\tilde\gamma$ is the desired curve.
$(\impliedby)$ Suppose there exists a periodic regular curve $\tilde\gamma:\mathbb{R}\to\mathbb{R}^n$ with period $b-a$ such that $\tilde\gamma(t)=\gamma(t)$ for all $t\in[a,b]$. It is known that all the derivatives of $\tilde\gamma$ must also have period $b-a$. This way, if $n\in\mathbb{N}$ then
$$
\gamma^{(n)}(a)=\tilde\gamma^{(n)}(a)=\tilde\gamma^{(n)}(a+b-a)=\tilde\gamma^{(n)}(b)=\gamma^{(n)}(b)
$$
which implies that $\gamma$ is a closed curve.
 A: I don't see any definition of a "regular curve", although perhaps I can guess a definition: To say that $\gamma : [a,b] \to \mathbb R^n$ is a regular curve means that $\gamma'(t)$ exists for all $t \in [a,b]$, as a 2-sided derivative if $t \in (a,b)$, and as a 1-sided derivative if $t=a$ or $b$. Maybe there's more than that, for example maybe $\gamma'(t)$ is required to be continuous as a function of $t$.
In which case here is a counterexample: the path $\gamma : [0,1] \to \mathbb R^2$ given by
$$\gamma(t) = \biggl(\cos\bigl(2 \pi \cdot \frac{t^2+2t}{3}\bigr), \sin\bigl(2 \pi \cdot \frac{t^2+2t}{3}\bigr)\biggr)
$$
That funny fraction $\frac{t^2+2t}{3}$ is chosen so that when restricted to $[0,1]$ it gives a strictly increasing function from $[0,1]$ to $[0,1]$, but its derivative when $t=0$ is $\frac{2}{3}$ whereas its derivative when $t=1$ is $\frac{4}{3}$. Because of this, by application of the chain rule you can compute the tangent vectors $\gamma'(0)$ and $\gamma'(1)$ and check for yourself that $\gamma'(0) \ne \gamma'(1)$, and therefore there does not exist a periodic regular curve extending $\gamma$ of period $1$. Nonetheless, $\gamma$ is a regular closed curve, because $\gamma(0)=\gamma(1)=(1,0)$, and in fact $\gamma$ wraps the interval $[0,1]$ exactly one time around the unit circle (but with increasing speed unlike the more familiar example $(\cos(2\pi t),\sin(2\pi t))$ that has constant speed).
I did not follow your proof carefully in the passage where you do the one-sided derivatives, but somewhere around there is where I think the error is. The bit where you switch between one sided limits at $c$ and one sided limits at $b$ looks particularly suspicious. If you want to locate exactly where the error is, you could work through your proof with my counterexample
