Existence of an antiderivative function on an arbitrary subset of $\mathbb{R}$ 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
 A: As requested, I turn my comments into an answer.

First of all, we replace $f$ by its lower semi-continuous envelope:
$$ g(x) = \liminf_{y \to x} f(x) . $$
Observe that $g(x) = f(x)$ for $x \in I$ and $g$ is continuous at every $x \in I$. Furthermore, $g$ is lower semi-continuous, and hence Borel measurable.
If $g$ is continuous at $x$, then there is a neighbourhood $U_x$ of $x$ such that $g$ is bounded in $U_x$. Let $U$ be the union of $U_x$ over all $x \in I$.
Consider a connected component $(a, b)$ of $U$. Then $g$ is locally bounded on $(a, b)$ (for any compact subinterval of $(a, b)$ can be covered by finitely many sets $U_x$ with $x \in I$), and thus we can define
$$ F(x) = \int_{(a+b)/2}^x g(y) dy $$
for $x \in (a, b)$. Clearly, $F$ is differentiable at every point of continuity $x \in (a, b)$ of $g$, and $F'(x) = g(x)$. In particular, $F'(x) = g(x) = f(x)$ for all $x \in I \cap (a, b)$.
We define $F$ as above on every connected component $(a, b)$ of $U$, and we set $F(x) = 0$ for $x \notin U$. By construction, $F'(x) = f(x)$ for every $x \in I \cap U = I$, as desired.
A: 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 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$.
