X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fsrc%2Fcommon%2Falpha.ml;fp=helm%2Fsoftware%2Flambda-delta%2Fsrc%2Fcommon%2Falpha.ml;h=01c2aafe885af82d9bea7bc5497bd24221629855;hb=ab13cfa248f0ee58d239ceeddfb50ec49a6b5c6d;hp=0000000000000000000000000000000000000000;hpb=514017fb6545009bdc62dcaf294f4317beb251b2;p=helm.git diff --git a/helm/software/lambda-delta/src/common/alpha.ml b/helm/software/lambda-delta/src/common/alpha.ml new file mode 100644 index 000000000..01c2aafe8 --- /dev/null +++ b/helm/software/lambda-delta/src/common/alpha.ml @@ -0,0 +1,39 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department, University of Bologna, Italy. + ||I|| + ||T|| HELM is free software; you can redistribute it and/or + ||A|| modify it under the terms of the GNU General Public License + \ / version 2 or (at your option) any later version. + \ / This software is distributed as is, NO WARRANTY. + V_______________________________________________________________ *) + +module Y = Entity + +(* internal functions *******************************************************) + +let rec rename ns n = + let token, mode = n in + let n = token ^ "_", mode in + if List.mem n ns then rename ns n else n + +let alpha_name acc attr = + let ns, a = acc in + match attr with + | Y.Name n -> + if List.mem n ns then + let n = rename ns n in + n :: ns, Y.Name n :: a + else + n :: ns, attr :: a + | _ -> assert false + +(* interface functions ******************************************************) + +let alpha ns a = + let f a names = + let _, names = List.fold_left alpha_name (ns, []) (List.rev names) in + List.rev_append a names + in + Y.get_names f a