- try
- (match
- List.nth unsh_context (List.length unsh_context - context_len - 1)
- with
- | None -> assert false (* can't select a restricted hypothesis *)
- | Some (name, Cic.Decl ty) ->
- ProofEngineHelpers.pattern_of ~term:ty [term]
- | Some (name, Cic.Def (bo, _)) ->
- ProofEngineHelpers.pattern_of ~term:bo [term])
- with Failure _ | Invalid_argument _ ->
- ProofEngineHelpers.pattern_of ~term:conclusion [term]
+ let where =
+ match father_hyp with
+ None -> conclusion
+ | Some name ->
+ let rec aux =
+ function
+ [] -> assert false
+ | Some (Cic.Name name', Cic.Decl ty)::_ when name' = name -> ty
+ | Some (Cic.Name name', Cic.Def (bo,_))::_ when name' = name-> bo
+ | _::tl -> aux tl
+ in
+ aux unsh_context
+ in
+ ProofEngineHelpers.pattern_of ~term:where [term]