Two definitions of formal schemes I have read two seemingly completely different definitions of formal schemes. 
Hartshorne defined a formal scheme as the formal completion of a noetherian scheme $X$ along a closed subscheme $Y$ of $X$. 
In Demazure's Lectures on p-Divisible Groups, a $k$-formal scheme is defined to be a left exact covariant functor from the category of finite dimensional $k$-algebras to the category of sets, where $k$ is a field. 
Are these two definitions of formal schemes the same (or related to each other)?
(update) Now I have read about the definition in EGA I, which defines an affine formal scheme as the formal spectrum $\mathop{\mathrm{Spf}}(A)$ of an admissible ring $A$. As Murray answered, Demazure defines an affine formal scheme over $k$ as $\mathop{\mathrm{Spf}}(A)$ for some profinite $k$-algebra. It a profinite $k$-algebra always admissible? (It seems to me that this is not true, for example consider the the product of infinitely many $k$. So the definition in EGA is not the most general case?) 
 A: Disclaimer: I am far from an expert. Feel free to ask for more details!
I was reading those lectures only recently. It is very important to acknowledge that Demazure uses the functor-of-points perspective for discussing schemes (see Chapter I.4 of those notes to see a discussion of the equivalence of this approach with the more standard one). Demazure gives 4 different (but equivalent) definitions of a formal scheme, one of those being the definition you stated. Another definition is stated in terms of profinite $k$-algebras. These are topological $k$-algebras $A$ such that (for some inverse system of open ideals $\{I_n\}$)


*

*$A\cong \varprojlim_n A/I_n$

*$A/I_n$ is finitely generated as a $k$-algebra.


Then the formal spectrum $\mathrm{Spf}(A)$ of $A$ is defined for a $k$-algebra $R$
as the set of continuous maps $\mathrm{Spf}(A)(R)$ (where $R$ is equipped with the discrete topology). Even better it is 
$$
\mathrm{Spf}(A)(R)\cong \varinjlim_n \mathrm{Spf}(A/I_n)(R)
$$
Back to considering Hartshorne: A closed subscheme $Y\subset X$ gives rise to an ideal sheaf $\mathcal{I}\subset \mathcal{O}_X$. If we consider the case that $X=\mathrm{Spec}A$ is affine then $\mathcal{I}$ is simply an ideal of $A$ and $Y\cong \mathrm{Spec}{(A/\mathcal{I})}$. 
We then place the $\mathcal{I}$-adic topology on $A$, check that it satisfies 1 and 2 above, and then the formal completion as given in Hartshorne exactly becomes 
$$
\mathrm{Spf}(A)(R)\cong \varinjlim_n \mathrm{Spf}(A/\mathcal{I}^n)(R)
$$
As @DonuArapura commented the case presented in Hartshorne is an example of a more general definition where rather than considering adic topological rings, we consider admissible topological rings. 
