-exception NoOtherChoices;;
-let rec auto dbd = function
- [] -> []
- | (proof, [], sign)::tl -> (proof, [], sign)::tl
- | (proof, (goal,0)::_, _)::tl -> auto dbd tl
- | (proof, (((goal,depth)::gtl) as allg), sign)::tl ->
- (* first we check if the metavariable has not been already
- closed as a side effect by some other application *)
- let facts = (depth = 1) in
- let name,metasenv,p,statement = proof in
- let meta_inf =
- (try
- let (_, ey ,ty) = CicUtil.lookup_meta goal metasenv in
- Some (ey, ty)
- with _ -> None) in
- match meta_inf with
- Some (ey, ty) ->
- (* the goal is still there *)
- (*
- debug_print ("CURRENT GOAL = " ^ (CicPp.ppterm ty));
- debug_print ("CURRENT PROOF = " ^ (CicPp.ppterm p));
- debug_print ("CURRENT HYP = " ^ (fst (print_context ey)));
- *)
- (* if the goal contains metavariables we use the input
- signature for at_most constraints *)
- let is_meta_closed = CicUtil.is_meta_closed ty in
- let sign, new_sign =
- if is_meta_closed then
- None, Some (MetadataConstraints.signature_of ty)
- else sign,sign in (* maybe the union ? *)
- let local_choices =
- new_search_theorems
- search_theorems_in_context
- proof goal (depth-1) [] new_sign in
- let global_choices =
- new_search_theorems
- (fun status ->
- List.map snd
- (MetadataQuery.hint
- ~dbd ~facts:facts ?signature:sign status))
- proof goal (depth-1) [] new_sign in
- (* we proceed depth-first on the current goal. This is
- a MAJOR optimization, since in case of success, and
- if the goal is meta_closed, we may just drop the alternatives
- tl1, avoiding useless backtracking. *)
- let all_choices =
- local_choices@global_choices in
- (match (auto dbd all_choices)
- with
- [] -> auto dbd tl
- | (proof,[],_)::tl1 ->
- let all_choices =
- let gtl' = List.map fst gtl in
- if (gtl = [] || is_meta_closed) then
- (proof,gtl,sign)::tl
- else
- let tl2 =
- (List.map
- (function (p,l,s) -> (p,l@gtl,s)) tl1)
- in
- (proof,gtl,sign)::tl2@tl in
- auto dbd all_choices
- | _ -> assert false)
- | None -> auto dbd ((proof,gtl,sign)::tl)
-;;