]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/lib/cps.ml
Added initial support for inversion principles in Matita NG.
[helm.git] / helm / software / lambda-delta / lib / cps.ml
index 199a786cdd1c1ae1b9b770cda229d611c491091d..e42faba498aa4b0806e4264f0b0099d67f9f6e30 100644 (file)
@@ -1,29 +1,19 @@
-(* Copyright (C) 2000, HELM Team.
- * 
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- * 
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA  02111-1307, USA.
- * 
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-let id x = x
+(*
+    ||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_______________________________________________________________ *)
+
+let err _ = assert false
+
+let start x = x
+
+let id f x = f x
 
 let rec list_sub_strict f l1 l2 = match l1, l2 with
    | _, []              -> f l1
@@ -42,6 +32,13 @@ let rec list_rev_map_append f map ~tail = function
          let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in
          map f hd
 
+let rec list_forall2 f map l1 l2 = match l1, l2 with
+   | [], []                 -> f true
+   | hd1 :: tl1, hd2 :: tl2 ->
+      let f b = if b then list_forall2 f map tl1 tl2 else f false in
+      map f hd1 hd2
+   | _                      -> f false
+
 let list_rev_append f =
    list_rev_map_append f (fun f t -> f t)
 
@@ -51,6 +48,29 @@ let list_rev_map =
 let list_rev =
    list_rev_append ~tail:[]
 
+let list_fold_right f map l a =
+   let map f a m = map f m a in
+   list_rev (list_fold_left f map a) l
+
 let list_map f =
    list_rev_map (list_rev f)
    
+let list_iter f map l =
+   let map f () x = map f x in
+   list_fold_left f map () l
+
+let rec list_fold_left2 f map a l1 l2 = match l1, l2 with
+   | [], []                 -> f a
+   | hd1 :: tl1, hd2 :: tl2 -> 
+      let f a = list_fold_left2 f map a tl1 tl2 in
+      map f a hd1 hd2
+   | _                      -> assert false
+
+let list_iter2 f map l1 l2 =
+   let map f () x1 x2 = map f x1 x2 in
+   list_fold_left2 f map () l1 l2
+
+let rec list_mem ?(eq=(=)) a = function
+   | []                   -> false
+   | hd :: _ when eq a hd -> true
+   | _ :: tl              -> list_mem ~eq a tl