An application of the Inclusion Principle to Chemistry? (Proof Verification) Background
I’m taking chemistry and one thing they have us do is draw Lewis structures for molecules. Guessing if there are going to be double or triple bonds is kind of annoying. I’d like to be able to come up with a formula to predict the total number of bonds a molecule will form. I count a double bond as $2$ bonds, and a triple bond as $3$.

What I’d like to prove
Count a single bond as $1$ bond, a double as $2$ bonds, and a triple as $3$. 
Scrolling through YouTube one video seems to suggest that when octets (or a duet for hydrogen) are formed, the number of bonds a molecule will form is,
$$B=\frac{N-H}{2}$$
Where $N$ is the sum of the electrons needed on each atom. Ex: In $H_2O$, we have $N=2+2+8=12$.
And $H$ is the number of electrons we have to distribute. In our case $1+1+6=8$ hence, $B=\frac{12-8}{2}=2$ and water forms $2$ bonds as expected (two single bonds). 
I’d like to be sure this holds in general for the conditions mentioned to be sure I’m not using some nonsense. I think I came up with a proof:

My proof
Suppose we have $n$ atoms $X_1,X_2,\dotsc,X_n$ part of a molecule. Think of each atom $X_i$ as a set consisting of it’s electrons (in the molecule form). $X_1 \cup X_2 \cup \dotsb \cup X_n$ is what you get when you combine these elements/electrons and overlapping may occur. $X_1 \cup \dotsb \cup X_n$ is the molecule, which has a cardinality of $H$ electrons by definition. 
By inclusion exclusion,
$$
    H
  = \left| \bigcup_{k=1}^{n} X_k \right|
  =   \sum_{k=1}^{n} |X_k|
    - \sum_{1 \leq i < j \leq n} |X_i \cap X_j|
    + \dotsb
    + (-1)^{n-1} \left| \bigcap_{k=1}^{n} X_k \right|
$$
On the right most part of the equation above, everything vanishes except $|\sum_{k=1}^{n} |X_k|-\sum_{1 \leq i < j \leq n} |X_i \cap X_j|$ since each electron can only share $2$ atoms at most. 
Finally, $\sum_{k=1}^{n} |X_k|=N$ since the cardinality of each atom is exactly how many electrons it needs, if we give it what it needs. And $\sum_{1 \leq i < j \leq n} |X_i \cap X_j|$ is the some of the bonding electrons (no double counting), between each element. That is $\sum_{1 \leq i < j \leq n} |X_i \cap X_j|=2B$.
So, $H=N-2B$ and $\frac{N-H}{2}=B$. 
Question
Is the above proof correct. 

I arrived at the same conclusion using another approach. My approach is to let $G(X,E)$ be a graph whose vertices are the atoms $X_i$, and the edges are the bonds $b_{ij}=(X_i,X_j)$. And using your definition of $H_i$ and $N_i$ , we observe that for all vertices:$$H_i +\deg(X_i) = N_i$$ Since degree of an atom corresponds to the number of bonds that atom made, number of electrons needed in the final configuration is just the number of electrons already existing in the atom and the ones that are gained by bonds and since each bond brings another electron this statement holds. Then, using Handshaking lemma:$$ \sum_{X_i\in{X}}\deg(X_i)=2|E|=2B \\ \sum_{X_i\in{X}}\deg(X_i)=\sum_{X_i\in{X}}(N_i-H_i)=N-H \\ B=\frac{N-H}{2}$$
