-(* FG *)
-
-let msg0 = lazy "Subst: not found in context"
-let msg1 = lazy "Subst: not a simple equality"
-let msg2 = lazy "Subst: recursive equation"
-
-let subst_tac ~hyp =
- let hole = C.Implicit (Some `Hole) in
- let map self = function
- | Some (C.Name s, _) when s <> self -> Some (s, hole)
- | _ -> None
- in
- let subst_tac status =
- let (proof, goal) = status in
- let (_, metasenv, _, _) = proof in
- let _, context, _ = CicUtil.lookup_meta goal metasenv in
- let what = match PEH.get_rel context hyp with
- | Some t -> t
- | None -> raise (PET.Fail msg0)
- in
- let ty, _ = TC.type_of_aux' metasenv context what CicUniv.empty_ugraph in
- let direction, i, t = match ty with
- | (C.Appl [(C.MutInd (uri, 0, [])); _; C.Rel i; t])
- when LO.is_eq_URI uri -> `LeftToRight, i, t
- | (C.Appl [(C.MutInd (uri, 0, [])); _; t; C.Rel i])
- when LO.is_eq_URI uri -> `RightToLeft, i, t
- | _ -> raise (PET.Fail msg1)
- in
- let var = match PEH.get_name context i with
- | Some name -> name
- | None -> raise (PET.Fail msg0)
- in
- if DTI.does_not_occur i t then () else raise (PET.Fail msg2);
- let pattern = None, PEH.list_rev_map_filter (map hyp) context, Some hole in
- let start = rewrite_tac ~direction ~pattern what in
- let continuation = PESR.clear ~hyps:[hyp; var] in
- let tac = T.then_ ~start ~continuation in
- PET.apply_tactic tac status
- in
- PET.mk_tactic subst_tac