@@ -21,9 +21,9 @@ Warning: we currently do not take into account the rules having higher-order
2121
2222Remark: When trying to unify a subterm of a rule LHS with the LHS of another
2323 rule, we need to rename the pattern variables of one of the LHS to avoid
24- name clashes. To this end, we use the [shift ] function below which replaces
25- [Patt(i,n,_)] by [Patt(-i-1,n ^ "'",_)]. The printing function [subs] below
26- takes this into account. *)
24+ name clashes. To this end, we use the [reindex ] function below which
25+ replaces [Patt(i,n,_)] by [Patt(-i-1,n ^ "'",_)]. The printing function
26+ [subs] below takes this into account. *)
2727
2828open Core open Term open Print
2929open Timed
@@ -99,8 +99,8 @@ let occurs : int -> term -> bool = fun i ->
9999 | LLet _ -> assert false
100100 in occ
101101
102- (* * [shift t] replaces in [t] every pattern index i by -i-1. *)
103- let rec shift : term -> term = fun t ->
102+ (* * [reindex t] replaces in [t] every pattern index i by -i-1. *)
103+ let rec reindex : term -> term = fun t ->
104104 match unfold t with
105105 | Vari _
106106 | Type
@@ -109,16 +109,16 @@ let rec shift : term -> term = fun t ->
109109 | Wild
110110 | Plac _
111111 | TRef _ -> t
112- | Prod (a ,b ) -> mk_Prod (shift a, shift_binder b)
113- | Abst (a ,b ) -> mk_Abst (shift a, shift_binder b)
114- | Appl (a ,b ) -> mk_Appl (shift a, shift b)
115- | Meta (m ,ts ) -> mk_Meta (m, Array. map shift ts)
112+ | Prod (a ,b ) -> mk_Prod (reindex a, reindex_binder b)
113+ | Abst (a ,b ) -> mk_Abst (reindex a, reindex_binder b)
114+ | Appl (a ,b ) -> mk_Appl (reindex a, reindex b)
115+ | Meta (m ,ts ) -> mk_Meta (m, Array. map reindex ts)
116116 | Patt (None,_ ,_ ) -> assert false
117- | Patt (Some i ,n ,ts ) -> mk_Patt (Some (- i-1 ), n ^ " '" , Array. map shift ts)
117+ | Patt (Some i ,n ,ts ) -> mk_Patt (Some (- i-1 ), n ^ " '" , Array. map reindex ts)
118118 | Bvar _ -> assert false
119- | LLet (a ,t ,b ) -> mk_LLet (shift a, shift t, shift_binder b)
120- and shift_binder b =
121- let x, t = unbind b in bind_var x (shift t)
119+ | LLet (a ,t ,b ) -> mk_LLet (reindex a, reindex t, reindex_binder b)
120+ and reindex_binder b =
121+ let x, t = unbind b in bind_var x (reindex t)
122122
123123(* * Type for pattern variable substitutions. *)
124124type subs = term IntMap .t
@@ -372,7 +372,7 @@ let iter_cps_with_rule :
372372 (* if Logger.log_enabled() then
373373 log_cp "iter_cps_with_rule@.%a@.%a" Print.rule lr Print.rule gd;*)
374374 let l = lhs lr and r = rhs lr and g = lhs gd and d = rhs gd in
375- let l = shift l and r = shift r in
375+ let l = reindex l and r = reindex r in
376376 let i = id_sym_rule lr and j = id_sym_rule gd in
377377 let f _ p l_p = cp_cand_fun h pos i l r p l_p j g d in
378378 iter_subterms pos f l
@@ -555,7 +555,7 @@ let check_cps_subterms_eq : Pos.popt -> sym_rule -> unit =
555555 if Logger. log_enabled() then log_cp " check_cps_subterms_eq" ;
556556 (* if Logger.log_enabled() then
557557 log_cp "check_cps_subterms_eq@.%a@.%a" Print.rule lr Print.rule gd;*)
558- let l = shift (lhs lr) and r = shift (rhs lr) in
558+ let l = reindex (lhs lr) and r = reindex (rhs lr) in
559559 let i = id_sym_rule lr in
560560 let f s p l_p =
561561 match ! (s.sym_def) with
0 commit comments