]> matita.cs.unibo.it Git - fireball-separation.git/blobdiff - ocaml/num.ml
Tentative implementation of strong separation algorithm
[fireball-separation.git] / ocaml / num.ml
index e7b6290fc64afb7efb7212ac1bc0536067c3a3ab..8ecf12491be1d9931dfdc39fbbe4c9403f391008 100644 (file)
@@ -92,14 +92,23 @@ let free_vars = (List.map fst) ++ free_vars';;
 module ToScott =
 struct
 
+let delta = let open Pure in L(A(V 0, V 0))
+
+let bomb = ref(`Var(-1, -666));;
+
 let rec t_of_i_num_var =
  function
   | `N n -> Scott.mk_n n
-  | `Var(v,_) -> Pure.V v
+  | `Var(v,_) as x -> assert (x <> !bomb); Pure.V v
   | `Match(t,_,liftno,bs,args) ->
-      let bs = List.map (fun (n,t) -> n, t_of_nf (lift liftno t)) !bs in
+      let bs = List.map (
+        function (n,t) -> n,
+         (if t = !bomb then delta
+          else L (t_of_nf (lift (liftno+1) t)))
+        ) !bs in
       let t = t_of_i_num_var t in
       let m = Scott.mk_match t bs in
+      let m = Pure.A(m,delta) in
       List.fold_left (fun acc t -> Pure.A(acc,t_of_nf t)) m args
   | `I((v,_), args) -> Listx.fold_left (fun acc t -> Pure.A(acc,t_of_nf t)) (Pure.V v) args
 and t_of_nf =