* It may raise TermNotFound or TermFoundMultipleTimes
*)
let locate_in_conjecture ?(equality=(==)) what (_,context,ty) =
- let (@@) (l1,l2) (l1',t) = l1 @ l1', l2 @ [t] in
+ let (@@) (l1,l2) =
+ function
+ None -> l1,l2
+ | Some (l1',t) -> l1 @ l1', l2 @ [t] in
+ let locate_in_term what ~where context =
+ try
+ Some (locate_in_term ~equality what ~where context)
+ with
+ TermNotFound -> None in
let context,res =
List.fold_right
(fun entry (context,res) ->
match entry with
None -> entry::context, res
| Some (_, Cic.Decl ty) ->
- let res = res @@ locate_in_term ~equality what ~where:ty context in
+ let res = res @@ locate_in_term what ~where:ty context in
let context' = entry::context in
context',res
| Some (_, Cic.Def (bo,ty)) ->
- let res = res @@ locate_in_term ~equality what ~where:bo context in
+ let res = res @@ locate_in_term what ~where:bo context in
let res =
match ty with
None -> res
| Some ty ->
- res @@ locate_in_term ~equality what ~where:ty context in
+ res @@ locate_in_term what ~where:ty context in
let context' = entry::context in
context',res
) context ([],([],[]))
in
- let res = res @@ locate_in_term ~equality what ~where:ty context in
+ let res = res @@ locate_in_term what ~where:ty context in
match res with
context,[] -> raise TermNotFound
| context,[_] -> context