intros goal gamma work context j.
cut
(forall (n : nat) (goal : form) (gamma : flist) (work : nf_list)
(context : flist) (j : Int),
weight_goal goal < n -> search_spec goal gamma work context j).
intros claim.
apply claim with (S (weight_goal goal)).
apply lt_n_Sn.
clear goal gamma work context j.
intros n; elim n; clear n.
intros goal gamma work context j lt_weight.
elimtype False.
apply (lt_n_O (weight_goal goal)); assumption.
intros n ih goal gamma work context j.
case goal; clear goal.
(* goal=Falsum *)
intros lt_weight.
elim (int_succ j).
intros j1 less1.
apply rule_gamma_falsum with j1; try assumption.
rewrite (vlist_eq gamma).
apply (search_atom_aux (S (weight_gamma (vlist2hlist (list2vlist gamma))))).
apply lt_n_Sn.
(* goal=(Atom i) *)
intros i lt_weight.
rewrite (vlist_eq gamma).
apply (search_atom_aux (S (weight_gamma (vlist2hlist (list2vlist gamma))))).
apply lt_n_Sn.
(* goal=(AndF g0 g1) *)
intros g0 g1 lt_weight.
elim (int_succ j).
intros j1 less1.
apply rule_gamma_a with j1; try assumption.
apply ih.
apply lt_S_n; assumption.
(* goal=(OrF g0 g1) *)
intros g0 g1 lt_weight.
elim (int_succ j).
intros j1 less1.
apply rule_gamma_a with j1; try assumption.
apply ih.
apply lt_S_n; assumption.
(* goal=(Imp g0 g1) *)
intros g0 g1 lt_weight.
apply rule_gamma_a_imp_b.
apply ih.
apply lt_S_n; assumption.
Qed.
(********************************************************************)
Inductive search_spec (goal : form) (gamma : flist) : Set :=
| derivable : Derivable gamma goal -> search_spec goal gamma
| refutable :
forall k : kripke_tree,
Is_Monotone_kripke_tree k ->
(forall a : form, In a gamma -> forces_t k a) ->
(forces_t k goal -> False) -> search_spec goal gamma.

(* Specifications: *)
Theorem search : forall (goal : form) (gamma : flist), search_spec goal gamma.
intros goal gamma.