Prove that two Lie algebras are equal Suppose to have a Lie group $\mathbb G$ whose Lie algebra $g$ admits a stratification $g=V_1\bigoplus V_2$ with $\text{dim} V_1=m$ and $g=Lie(V_1)$, i.e. $g$ is generated by $V_1$. In other words, $\mathbb G$ is a Carnot group of step 2.
Moreover, suppose we have a basis for $V_1$ given by $\{X_1,\dots,X_m\}$ so we know that the vector fields  $\{X_1,\dots,X_m\}$ generate a subbundle $H\mathbb G$ of rank $m$ of the tangent bundle $T\mathbb G,$ in the sense that its fibers are given by $$(H\mathbb G)_p=\text{span}\{X_1(p),\dots,X_m(p)\}.$$
We call vector fields that are sections of $H\mathbb G$ horizontal vector fields. Thus, if $X$ is horizontal, there exist smooth functions $a_1,\dots,a_m:\mathbb G\to \mathbb R$ such that $X=\sum a_i X_i$.
Now, let $Y_1,\dots,Y_m$ be left invariant, smooth, horizontal vector fields that are orthonormal. 
My question is: $g=Lie\{Y_1,\dots, Y_m\}$?
It is clear that $g\supseteq Lie\{Y_1,\dots, Y_m\}$, the problem is the reverse inclusion. Any suggestions?
I've tried to prove that $\{X_1,\dots,X_m\}\subseteq Lie\{Y_1,\dots,Y_m\}$, but I'm stuck on this. I know that -since $Y_i$ are horizontal and orthonormal- $(H\mathbb G)_p=\text{span}\{Y_1(p),\dots,Y_m(p)\},$ so for any $p\in \mathbb G$ and for any $1\leq i\leq m$ there are coefficients $b^i_j, j=1,\dots,m$ which depend on $p$ such that $X_i(p)=\sum_{j=1}^m b^i_j Y_j(p).$ Does this imply $X_i\in Lie\{Y_1,\dots,Y_m\}$? If the coefficients $b^i_j$ didn't depend on $p$, I would say that  $X_i\in Lie\{Y_1,\dots,Y_m\}$ is true, but in general $b^i_j=b^i_j(p).$
 A: Yes it's true. It's based on a general result: if $\mathfrak{g}$ is any nilpotent Lie algebra over any field, and $\mathfrak{h}$ is any subalgebra such that $\mathfrak{h}+[\mathfrak{g},\mathfrak{g}]=\mathfrak{g}$. Then $\mathfrak{h}=\mathfrak{g}$. This is easy to prove by an induction on the nilpotency length.
A: In addition to Yves answer here a short proof:
Lemma: Let $\mathfrak{n}$ be a nilpotent Lie algebra and assume that $\mathfrak{h}$ is a subalgebra of $\mathfrak{n}$ for which $\mathfrak{h}+ [\mathfrak{n}, \mathfrak{n}]=\mathfrak{n}$. Then $\mathfrak{h}=\mathfrak{n}$.
Proof:
For any integer $i\ge 0$, we define $\mathfrak{h}_i= \mathfrak{h}+\mathfrak{n}^i$, where the $\mathfrak{n}^i$ denote the
terms of the lower central series of $\mathfrak{n}$, with $\mathfrak{n}^0=\mathfrak{n}$. By assumption we have
$\mathfrak{h}_1= \mathfrak{h}+ [\mathfrak{n},\mathfrak{n}]=\mathfrak{n}$ and $\mathfrak{h}_i=\mathfrak{h}$ for all $i$ bigger or equal than the
nilpotency class of $\mathfrak{n}$.
It is easy to see that $\mathfrak{h}_{i+1}$ is an ideal of $\mathfrak{h}_i$ for any $i$, and that the quotient
$\mathfrak{h}_i/\mathfrak{h}_{i+1}$ is abelian. Now assume that $\mathfrak{h}\neq \mathfrak{n}$. Then there exists a positive integer $i$ with
$\mathfrak{h}_i=\mathfrak{n}$ and $\mathfrak{h}_{i+1}\neq \mathfrak{n}$.
For this $i$ we have that $\mathfrak{h}_i/\mathfrak{h}_{i+1}=\mathfrak{n}/\mathfrak{h}_{i+1}$ is abelian and hence $[\mathfrak{n},\mathfrak{n}]\subseteq \mathfrak{h}_{i+1}$.
But then $\mathfrak{n}= \mathfrak{h}+[\mathfrak{n},\mathfrak{n}]\subseteq \mathfrak{h}_{i+1}$ which is a contradiction.
