Inductive nsearch_spec_result_aux (goal : Int) (work : nf_list) 
(ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
(a : atoms) (context : flist) : Set :=
  | NDerivable :
      Derivable context (Atom goal) ->
      nsearch_spec_result_aux goal work ds ni ai a context
  | NRefutable :
      forall k : kripke_tree,
      Is_Monotone_kripke_tree k ->
      forces_ngamma work ds ni ai a k ->
      (forces_t k (Atom goal) -> False) ->
      nsearch_spec_result_aux goal work ds ni ai a context.Inductive nsearch_spec_result_aux (goal : Int) (work : nf_list) 
(ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
(a : atoms) (context : flist) : Set :=
  | NDerivable :
      Derivable context (Atom goal) ->
      nsearch_spec_result_aux goal work ds ni ai a context
  | NRefutable :
      forall k : kripke_tree,
      Is_Monotone_kripke_tree k ->
      forces_ngamma work ds ni ai a k ->
      (forces_t k (Atom goal) -> False) ->
      nsearch_spec_result_aux goal work ds ni ai a context.Inductive nsearch_spec_result_aux (goal : Int) (work : nf_list) 
(ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
(a : atoms) (context : flist) : Set :=
  | NDerivable :
      Derivable context (Atom goal) ->
      nsearch_spec_result_aux goal work ds ni ai a context
  | NRefutable :
      forall k : kripke_tree,
      Is_Monotone_kripke_tree k ->
      forces_ngamma work ds ni ai a k ->
      (forces_t k (Atom goal) -> False) ->
      nsearch_spec_result_aux goal work ds ni ai a context.Inductive nsearch_spec_result (goal : Int) (work : nf_list) 
(ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
(a : atoms) (context : flist) : Set :=
    NSearch_Res :
      forall ni1 : nested_imps,
      le_ni ni1 ni ->
      deco_sound work ds ni1 ai a ->
      nsearch_spec_result_aux goal work ds ni1 ai a context ->
      nsearch_spec_result goal work ds ni ai a context.Inductive nsearch_spec_result (goal : Int) (work : nf_list) 
(ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
(a : atoms) (context : flist) : Set :=
    NSearch_Res :
      forall ni1 : nested_imps,
      le_ni ni1 ni ->
      deco_sound work ds ni1 ai a ->
      nsearch_spec_result_aux goal work ds ni1 ai a context ->
      nsearch_spec_result goal work ds ni ai a context.Definition nsearch_spec (goal : Int) (work : nf_list) 
  (ds : disjs) (ni : nested_imps) (ai : atomic_imps) 
  (a : atoms) (context : flist) :=
  deco_sound work ds ni ai a ->
  nsound work ds ni ai a context ->
  nminimal work ds ni ai a context ->
  nsearch_spec_result goal work ds ni ai a context.

(* Specifications: *)
Lemma fail : forall (i : Int) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), a_ai_disj a ai -> a_goal_disj a i -> nsearch_spec i nf_nil DNil (rev_app dni NNil) ai a context.
Lemma rule_shift_work_ds : forall (goal i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ((i, j) :: ds) ni ai a context -> nsearch_spec goal (NDisj i j :: work) ds ni ai a context.
Lemma rule_shift_work_ni0 : forall (goal : Int) (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ds (Undecorated x :: ni) ai a context -> nsearch_spec goal (NImp_NF x :: work) ds ni ai a context.
Lemma rule_shift_work_ai_new : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), (forall x : unit, LOOKUP unit i a x -> False) -> (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nsearch_spec goal work ds ni ai' a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context.
Lemma rule_shift_work_ai_old : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (context : flist), (forall x : unit, LOOKUP unit i a x -> False) -> LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nsearch_spec goal work ds ni ai' a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context.
Lemma rule_shift_work_a : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> (forall d : unit, LOOKUP unit i a d -> False) -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nsearch_spec goal work ds ni ai a' context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context.
Lemma shift_ni_dni : forall (goal : Int) (work : nf_list) (ds : disjs) (x : nimp) (k : kripke_tree) (ni : nested_imps) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ds (rev_app ((x, k) :: dni) ni) ai a context -> nsearch_spec goal work ds (rev_app dni (Decorated x k :: ni)) ai a context.
Lemma nax : forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), in_ngamma work ds ni ai a (NAtom goal) -> nsearch_spec goal work ds ni ai a context.
Lemma nefq : forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal (NFalsum :: work) ds ni ai a context.
Lemma contradiction_atoms : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), LOOKUP unit i a tt -> nsearch_spec goal work ds ni ai a context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context.
Lemma left_p_imp_work : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), forces0_t a i -> nsearch_spec goal (b :: work) ds ni ai a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context.
Lemma left_p_imp_ai : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a a' : atoms) (context : flist), LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> (forall d : unit, LOOKUP unit i a d -> False) -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nsearch_spec goal (bs ++ work) ds ni ai' a' context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context.
Lemma left_disj : forall (goal : Int) (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall ni1 : nested_imps, le_ni ni ni1 -> nsearch_spec goal (NAtom i :: work) ds ni1 ai a (Atom i :: context)) -> (forall ni2 : nested_imps, eqv_ni ni2 ni -> nsearch_spec goal (NAtom j :: work) ds ni2 ai a (Atom j :: context)) -> nsearch_spec goal work ((i, j) :: ds) ni ai a context.
Lemma left_nimp : forall (goal : Int) (work : nf_list) (ds : disjs) (a0 a1 : Int) (b : normal_form) (ni : nested_imps) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall ni1 : nested_imps, le_ni (rev_app dni ni) ni1 -> nsearch_spec a1 (AImp a1 b :: NAtom a0 :: work) ds ni1 ai a (Atom a0 :: context)) -> (forall ni1 : nested_imps, le_ni ni1 (rev_app dni ni) -> nsearch_spec goal (b :: work) ds ni1 ai a context) -> (forall (ni1 : nested_imps) (k : kripke_tree), le_ni ni1 (rev_app ((NImp a0 a1 b, k) :: dni) ni) -> nsearch_spec goal work ds ni1 ai a context) -> nsearch_spec goal work ds (rev_app dni (Undecorated (NImp a0 a1 b) :: ni)) ai a context.