Math rigor in evaluating limits. There is a well known theorem that says $f: \mathbb{R} \to \mathbb{R}$ is continuous at $x_0$ if and only if 
$$\lim_{x\to x_0} f(x) = f(x_0)$$
We often use the above mentioned theorem to evaluate limits like this one:
$$\lim_{x \to 1} \ f(x) \ \text{where} \ f(x) = \frac{x^3-3x^2+2}{x^2-1}$$
Note that $f$ is defined for $\mathbb{R} \setminus \{\pm 1\}$, so it doesn't make sense to evaluate $f$ at $1$, but we can factor $(x-1)$ in the numerator and denominator of $f$, and we get:
$$f(x) = \frac{(x-1)(x^2-2x-2)}{(x-1)(x+1)} = \frac{x^2-2x-2}{x+1}$$
now we are able to apply the theorem and evaluate the limit:
$$\lim_{x \to 1}\ f(x) = f(1) = \frac{x^2-2x-2}{x+1} =\frac{-3}{2}$$
$\textbf{Question:}$ let $f(x) = \dfrac{x^3-3x^2+2}{x^2-1}$ and $g(x) =\dfrac{x^2-2x-2}{x+1}$ 
It's easy to see that $g$ is defined at $1$ while $f$ is not, so $f$ and $g$ are not the same functions, but in the above limit evaluation we used that 
$$\lim_{x \to 1} f(x) =g(1)$$
 but this is not a clear (at least to me) application of the theorem, as $f$ and $g$ are not the same functions. How could I justify this application of the theorem?
 A: I can sense the issue being faced by OP. There is one point which I must clarify.
$f$ is continuous at $x_{0}$ if $\lim_{x \to x_{0}}f(x) = f(x_{0})$. Note that this is a definition of continuity and to apply it means that you calculate $\lim_{x \to x_{0}}f(x)$ somehow and compare it with value of $f(x_{0})$. If you find them equal you declare that $f$ is continuous at $x = x_{0}$. Note that the calculation of limit of $f(x)$ as $x \to x_{0}$ can't be done by using continuity of $f(x)$.
For example consider $\lim_{x \to 2} x^{2}$. We calculate this as follows $$\lim_{x \to 2}x^{2} = \lim_{x \to 2}x\cdot\lim_{x \to 2}x = 2 \cdot 2 = 4$$ The fact that $\lim_{x \to 2}x = 2$ is a trivial application of definition of limit. After this exercise we see that value of $x^{2}$ at $x = 2$ is also $4$ and hence $x^{2}$ is continuous at $x = 2$.
Please understand that it does not happen in reverse. Proving continuity of common functions like polynomials, trigometric, exponential and logarithmic function is done by first finding their limits and then noticing that it matches their values also. Once this fact is established we don't try to go the complicated way of using limit rules to find limits of complicated expression containing polynomials (trig, exp, log function etc) but rather use the continuity of such functions and just plug the values of $x$ to get the limit. This procedure is only a shorthand (basically saving labor) of applying the limit rules used to evaluate the limits of such continuous functions.
Next we have a rule of limits which says that if $f(x) = g(x)$ for all $x$ in a neighborhood of $x = x_{0}$ except possibly at $x = x_{0}$ then $\lim_{x \to x_{0}}f(x) = \lim_{x \to x_{0}}g(x)$. This rule is used implicitly while evaluating limit of $f(x)$ when it is not defined at $x_{0}$. Basically we apply algebraic (trigonometric identities etc) to transform the expression for $f(x)$ into another function $g(x)$ which is probably defined at $x = x_{0}$ and whose limit at $x = x_{0}$ is known. Same technique has been used in the limit under consideration in this question.
Specifically we have $$\begin{aligned}L &= \lim_{x \to 1}\frac{x^{3} - 3x^{2} + 2}{x^{2} - 1}\\
&= \lim_{x \to 1}\frac{(x - 1)(x^{2} - 2x - 2)}{(x - 1)(x + 1)}\\
&= \lim_{x \to 1}\frac{x^{2} - 2x - 2}{x + 1}\\
&= \dfrac{{\displaystyle \lim_{x \to 1}x^{2} - 2x - 2}}{{\displaystyle \lim_{x \to 1}x + 1}}\\
&= \dfrac{{\displaystyle \lim_{x \to 1}x\cdot\lim_{x \to 1}x - 2\lim_{x \to 1}x - 2}}{{\displaystyle \lim_{x \to 1}x + 1}}\\
&= \frac{1\cdot 1 - 2\cdot 1 - 2}{1 + 1} = -\frac{3}{2}\end{aligned}$$
In reality we avoid the last 3 steps and directly put $x = 1$ in $x^{2} - 2x - 2$ and $x + 1$. This is just a shorthand which is justified because we have established beforehand that polynomials are continuous.
A: First of all, you should write in the line just above the question
$$``\lim_{x\rightarrow 1}f(x)=\lim_{x\rightarrow 1}\frac{x^2-2x-2}{x+1}=\frac{-3}{2}"$$
Now, to your question: In the definition of limit (which you can probably find in any calculus book), the limit of a function $f$ at a point $x$ independs of the value $f(x)$ - it depends only on the value of $f$ at points clsoe enough to $x$. So it is obvious that $\lim_{t\rightarrow x}f(t)$ exists if, and only if, $\lim_{t\rightarrow x}f|_{Dom(f)\setminus \left\{x\right\}}(t)$ exists, and in that case, they are equal (here, $Dom(f)$ is the domain of $f$ and $f|_A$ means the restriction of $f$ to $A$).
In your example, $f=g|_{Dom(g)\setminus\left\{1\right\}}$, and the above applies.
