Lemma 7 and 9 implemented. Code is still buggy though...