Fixpoint weight (a : form) : nat :=
  match a with
  | Falsum => 1
  | Atom _ => 1
  | AndF a b => S (weight a + weight b)
  | OrF Falsum b => S (weight b)
  | OrF (Atom _) b => S (weight b)
  | OrF a b => S (S (weight b + weight a))
  | Imp a b => weight_neg a + weight b
  end
 
 with weight_neg (a : form) : nat :=
  match a with
  | Falsum => 0
  | Atom _ => 0
  | AndF a b => S (weight_neg a + weight_neg b)
  | OrF a b => S (S (S (weight_neg a + weight_neg b)))
  | Imp Falsum b => 1
  | Imp (Atom _) Falsum => 2
  | Imp (Atom _) (Atom _) => 1
  | Imp (Atom _) b => S (S (S (weight_neg b)))
  | Imp a b => S (S (S (S (weight_neg b + weight a))))
  end.Fixpoint weight_goal (a : form) : nat :=
  match a with
  | Falsum => 0
  | Atom _ => 0
  | AndF _ _ => 1
  | OrF _ _ => 1
  | Imp _ b => S (weight_goal b)
  end.Definition weight_gamma :=
  fold_right (fun (a : form) (n : nat) => weight a + n) 0.

(* Specifications: *)
Lemma weight_ge_1 : forall a : form, 1 <= weight a.
Lemma weight_neg_le : forall (j : Int) (a : form), weight_neg (Imp (Atom j) a) <= S (S (S (weight_neg a))).
Lemma weight_vimp : forall (l : list Int) (a : form), weight (vimp l a) = weight a.
Lemma weight_gamma_weak : forall (a b : form) (gamma : flist) (n : nat), weight a < weight b -> weight_gamma (b :: gamma) < S n -> weight_gamma (a :: gamma) < n.
Lemma weight_gamma_weak' : forall (a b : form) (gamma : flist) (n : nat), weight a < weight b -> weight b + weight_gamma gamma < S n -> weight a + weight_gamma gamma < n.
Lemma weight_gamma_weak2 : forall (a b c : form) (gamma : flist) (n : nat), weight a + weight b < weight c -> weight_gamma (c :: gamma) < S n -> weight_gamma (a :: b :: gamma) < n.
Lemma weight_gamma_weak2' : forall (a b c : form) (gamma : flist) (n : nat), weight a + weight b < weight c -> weight c + weight_gamma gamma < S n -> weight a + (weight b + weight_gamma gamma) < n.
Lemma weight_gamma_weak3 : forall (a b c d : form) (gamma : flist) (n : nat), weight a + weight b + weight c < weight d -> weight_gamma (d :: gamma) < S n -> weight_gamma (a :: b :: c :: gamma) < n.
Lemma weight_gamma_weak3' : forall (a b c d : form) (gamma : flist) (n : nat), weight a + weight b + weight c < weight d -> weight d + weight_gamma gamma < S n -> weight a + (weight b + (weight c + weight_gamma gamma)) < n.