Q:

exact definition of open sets

What is the exact definition of open sets? 
I know both definitions of open sets with respect to metric space and topological space. but what is most general definition that covers the both.

A:

Let $X$ be a set. An open set is an element of a collection $\mathcal{T}$ (whose elements are subsets of $X$), called a topology, which satisfies three conditions.

$\varnothing$ and $X$ are elements of $\mathcal{T}$.
For any subcollection $\mathcal{S}$ of $\mathcal{T}$, the union $\bigcup\mathcal{S}$ is an element of $\mathcal{T}$.
For any finite subcollection $\mathcal{S}$ of $\mathcal{T}$, the intersection $\bigcap\mathcal{S}$ is an element of $\mathcal{T}$.

Let $(M,\rho)$ be a metric space. Then the metric topology $\mathcal{T}_{\rho}$ induced by the metric $\rho$ is the collection of sets of the form $\bigcup\mathcal{B}$, where $\mathcal{B}$ is any collection (possibly empty) of open balls. Here an open ball is a set of the form $\{x\in M:\rho(x_0,x)<r_0\}$ for fixed $x_0\in M$ and for fixed positive real number $r_0$.

A:

There is no definition of what an open set is.  
There is a definition of what a Topology, and each Topology will have a class of sets that are called open but these sets can pretty much be anything we want so far as the class of sets obey certain rules of inclusion.
A metric space is a type of topological space and the definition of an open set in a metric space is such that the class of all open sets obeys the rules of inclusion required for the metric space to be considered a topology.
So the definition of a Topology is the most general definition.  But every topology will have its own classification of what open sets are.  These classifications of sets must obey certain rules but the actual open sets themselves need not have any consistent properties.
....
More precisely if a have a universal set $X$ then ANY $T \subset P(X)$ (any class of subsets of $X$) can be called the class of all "open" sets so long as the following apply:

$X$ and $\emptyset$ are elements of $T$.
The union of sets in $T$ will itself be in $T$
Any finite intersection of sets in $T$ will itself be in $T$

As long as those rules are obeyed any set can be considered open.
If we have a metric space $X$ and we define that if a set $A\subset X$ is such: that for every  point $x\in A$ there will be an open ball $B_r(x)$ around $x$ so that $B_r(x) \subset A$;  we call such a set PEN-Oay.
Now $X$ is PEN-Oay because everything including all open balls are subsets of it.  And $\emptyset$ is PEN-Oay vacuously because it has no points (as every point can be said to have any property).
And we can prove but I will not that any union (even infinite unions) of PEN-Oay sets are PEN-Oay.
And we can prove any finite intersection of PEN-Oay sets are PEN-Oay.
So if being PEN-Oay satisfies all three conditions for the class of all PEN-Oay sets to be considered a class of all "open" sets.
So we can say the metric space is a Topology so that $T = \{$ all "open" set$\} = \{$ all PEN-Oay sets$\}$.

