2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
12 (* $Id: terms.mli 9822 2009-06-03 15:37:06Z tassi $ *)
14 let eqPref = ref (fun _ -> assert false);;
15 let set_eqP t = eqPref := fun _ -> t;;
18 let uri = NUri.uri_of_string "cic:/matita/ng/Plogic/equality/peq.ind" in
19 let ref = NReference.reference_of_spec uri (NReference.Ind(true,0,2)) in
22 let set_default_eqP() = eqPref := default_eqP
24 let set_reference_of_oxuri f =
27 let r = f(UriManager.uri_of_string
28 "cic:/matita/logic/equality/eq.ind#xpointer(1/1)")
36 module type NCicContext =
38 val metasenv : NCic.metasenv
39 val subst : NCic.substitution
40 val context : NCic.context
43 module NCicBlob(C : NCicContext) : Terms.Blob
44 with type t = NCic.term and type input = NCic.term = struct
49 (* NCicReduction.alpha_eq C.metasenv C.subst C.context x y;; *)
53 | NCic.Rel i, NCic.Rel j -> j-i
54 | NCic.Meta (i,_), NCic.Meta (j,_) -> i-j
55 | NCic.Const r1, NCic.Const r2 -> NReference.compare r1 r2
56 | NCic.Appl l1, NCic.Appl l2 -> FoUtils.lexicograph compare l1 l2
57 | NCic.Rel _, ( NCic.Meta _ | NCic.Const _ | NCic.Appl _ ) -> ~-1
58 | ( NCic.Meta _ | NCic.Const _ | NCic.Appl _ ), NCic.Rel _ -> 1
59 | NCic.Const _, ( NCic.Meta _ | NCic.Appl _ ) -> ~-1
60 | ( NCic.Meta _ | NCic.Appl _ ), NCic.Const _ -> 1
61 | NCic.Appl _, NCic.Meta _ -> ~-1
62 | NCic.Meta _, NCic.Appl _ -> 1
67 (* if NCicReduction.alpha_eq C.metasenv C.subst C.context x y then 0 *)
73 NCicPp.ppterm ~context:C.context ~metasenv:C.metasenv ~subst:C.subst t;;
75 type input = NCic.term
77 let rec embed = function
78 | NCic.Meta (i,_) -> Terms.Var i, [i]
80 let rec aux acc l = function
82 |hd::tl -> if List.mem hd l then aux acc l tl else aux (hd::acc) l tl
84 let res,vars = List.fold_left
85 (fun (r,v) t -> let r1,v1 = embed t in (r1::r),aux [] v v1) ([],[]) l
86 in (Terms.Node (List.rev res)), vars
87 | t -> Terms.Leaf t, []
90 let embed t = fst (embed t) ;;
94 NCicMetaSubst.saturate ~delta:max_int C.metasenv C.subst C.context
98 if args = [] then Terms.Leaf t
99 else Terms.Node (Terms.Leaf t :: List.map embed args)
101 let sty = embed sty in
105 let eqP = (!eqPref)()