From c3955b4db6dcb1b2c815cfe684e57caaa12b6b6c Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Mon, 5 Dec 2005 16:48:44 +0000 Subject: [PATCH] added function term_of_equality to re-build the Cic.term from an equality --- helm/ocaml/paramodulation/inference.ml | 26 +++++++++++++++++++++++++ helm/ocaml/paramodulation/inference.mli | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/helm/ocaml/paramodulation/inference.ml b/helm/ocaml/paramodulation/inference.ml index 105b708e9..5633599d2 100644 --- a/helm/ocaml/paramodulation/inference.ml +++ b/helm/ocaml/paramodulation/inference.ml @@ -922,3 +922,29 @@ let is_identity ((metasenv, context, ugraph) as env) = function (fst (CicReduction.are_convertible ~metasenv:(metasenv @ menv) context left right ugraph))) ;; + + +let term_of_equality equality = + let _, _, (ty, left, right, _), menv, args = equality in + let eq i = function Cic.Meta (j, _) -> i = j | _ -> false in + let argsno = List.length args in + let t = + CicSubstitution.lift argsno + (Cic.Appl [Cic.MutInd (LibraryObjects.eq_URI (), 0, []); ty; left; right]) + in + snd ( + List.fold_right + (fun a (n, t) -> + match a with + | Cic.Meta (i, _) -> + let name = Cic.Name ("X" ^ (string_of_int n)) in + let _, _, ty = CicUtil.lookup_meta i menv in + let t = + ProofEngineReduction.replace + ~equality:eq ~what:[i] + ~with_what:[Cic.Rel (argsno - (n - 1))] ~where:t + in + (n-1, Cic.Prod (name, ty, t)) + | _ -> assert false) + args (argsno, t)) +;; diff --git a/helm/ocaml/paramodulation/inference.mli b/helm/ocaml/paramodulation/inference.mli index 55f3df414..30927dc72 100644 --- a/helm/ocaml/paramodulation/inference.mli +++ b/helm/ocaml/paramodulation/inference.mli @@ -109,6 +109,11 @@ exception TermIsNotAnEquality;; *) val equality_of_term: Cic.term -> Cic.term -> equality +(** + Re-builds the term corresponding to this equality +*) +val term_of_equality: equality -> Cic.term + val term_is_equality: Cic.term -> bool (** tests a sort of alpha-convertibility between the two terms, but on the -- 2.39.2