**Let $f:\mathbb{R}\to \mathbb{R}$ be continuous at $x$ for every $x\in I$ where $I\subset \mathbb R$ could be arbitrary. Does there always exist a function $F:\mathbb{R}\to \mathbb{R}$ differentiable on $I$ and $F'(x) = f(x)$ for every $x \in I$?**


The definition of a primitive is naturally defined on an interval. what sort of weaker result can we obtain under weaker hypotheses?. 


* If I is an interval or an open set, the answer to the question is
positive.
* If f is locally Lebesgue integrable,the answer to the question is  

also positive.


I have already asked the question here <https://math.stackexchange.com/questions/2855483/existence-of-an-antiderivative-function-on-an-arbitrary-subset-of-mathbbr>



Existence of an antiderivative function on an arbitrary subset of $\mathbb{R}$
Let's start with the case of a locally bounded function $f:J\to\mathbb{R}$ (say defined on some nonempty open interval $ J\subset\mathbb{R}$, with a fixed $x\_0\in J$). We may consider for any $x\in J$ the [upper Darboux integral](https://en.wikipedia.org/wiki/Darboux_integral#Darboux_integrals) of $f$ from $x\_0\in J$ to $x$: $$F(x):=\overline {\int^x\_{x\_0}}f(t)dt$$ 
(with the usual convention that $\overline {\int\_b^a}f:=-\overline {\int\_a^b}f$ for $a\le b$). The upper integral is not linear wrto functions, but it is additive on intervals: $\overline {\int\_a^b}f=\overline {\int\_a^c}f+\overline {\int\_c^b}f$ for $a,b,c\in\mathbb{R}$. Also, recall that for $a\le b$
$$(b-a)\inf\_{a\le t\le b}f(t)\le\underline {\int\_a^b}fdt\le\overline {\int\_a^b}fdt\le (b-a)\sup\_{a\le t\le b}f(t).$$
As a consequence, the fundamental theorem of calculus still holds true for $F$ at any point $x$ of continuity of $f$:


$$F(x+h)=F(x)+ f(x)h+o(h),\qquad h\to0$$


so $F:J\to\mathbb{R}$ fulfills the requirement in the case of locally bounded $f$. 


For a general $f:\mathbb{R}\to\mathbb{R}$, I would suggest the following argument to reduce to the preceding case. Since $f$ is locally bounded at any point of continuity, the set of continuity points is covered by a collection of disjoint open intervals $J\_k$ such that $f\_{|J\_k}:J\_k\to\mathbb{R}$ is locally bounded. By the preceding argument we have a collection of $F\_k:J\_k\to\mathbb{R}$ that we can glue to a single $F:\mathbb{R}\to\mathbb{R}$ such that $F'(x)=F\_k'(x)=f(x)$ at any continuity point $x\in J\_k$ of $f$, and e.g. $F(x)=0$ for $x\in\mathbb{R}\setminus\cup\_k J\_k$.


