| A of t * t\r
| L of t\r
| B (* bottom *)\r
- | C of int\r
+ | C (* constant *)\r
;;\r
\r
let delta = L(A(V 0, V 0));;\r
| L t1, t2 -> aux l1 (l2+1) t1 t2\r
| t1, L t2 -> aux (l1+1) l2 t1 t2\r
| V a, V b -> a + l1 = b + l2\r
- | C a, C b -> a = b\r
| A(t1,t2), A(u1,u2) -> aux l1 l2 t1 u1 && aux l1 l2 t2 u2\r
| _, _ -> false\r
in aux ;;\r
let rec string_of_term_w_pars level = function\r
| V v -> if v >= level then "`" ^ string_of_int (v-level) else\r
string_of_bvar (level - v-1)\r
- | C n -> "c" ^ string_of_int n\r
+ | C -> "C"\r
| A _\r
| L _ as t -> "(" ^ string_of_term_no_pars level t ^ ")"\r
| B -> "BOT"\r
function\r
| A(t,_) -> is_inert t\r
| V _ -> true\r
- | C _\r
+ | C\r
| L _ | B -> false\r
;;\r
\r
-let is_var = function V _ -> true | _ -> false;;\r
-let is_lambda = function L _ -> true | _ -> false;;\r
-\r
let rec get_inert = function\r
| V n -> (n,0)\r
| A(t, _) -> let hd,args = get_inert t in hd,args+1\r
| L t -> 1 + no_leading_lambdas (v+1) n t\r
| A _ as t -> let v', m = get_inert t in if v = v' then max 0 (n - m) else 0\r
| V v' -> if v = v' then n else 0\r
- | B | C _ -> 0\r
+ | B | C -> 0\r
;;\r
\r
let rec subst level delift sub =\r
let t1 = subst level delift sub t1 in\r
let t2 = subst level delift sub t2 in\r
mk_app t1 t2\r
- | C _ as t -> t\r
- | B -> B\r
+ | C | B as t -> t\r
and mk_app t1 t2 = if t2 = B || (t1 = delta && t2 = delta) then B\r
else match t1 with\r
| B -> B\r
| V m -> V (if m >= lev then m + n else m)\r
| L t -> L (aux (lev+1) t)\r
| A (t1, t2) -> A (aux lev t1, aux lev t2)\r
- | C _ as t -> t\r
- | B -> B\r
+ | C | B as t -> t\r
in aux 0\r
;;\r
let subst = subst 0 false;;\r
\r
let get_subterm_with_head_and_args hd_var n_args =\r
let rec aux lev = function\r
- | C _\r
- | V _ | B -> None\r
+ | C | V _ | B -> None\r
| L t -> aux (lev+1) t\r
| A(t1,t2) as t ->\r
let hd_var', n_args' = get_inert t1 in\r
| L t -> Pure.L (purify t)\r
| A (t1,t2) -> Pure.A (purify t1, purify t2)\r
| V n -> Pure.V n\r
- | C _ -> Pure.V max_int (* FIXME *)\r
+ | C -> Pure.V (min_int/2)\r
| B -> Pure.B\r
;;\r
\r
else no_leading_lambdas hd_var j t2)\r
else id) (max (aux hd t1) (aux hd t2))\r
| L t -> aux (hd+1) t\r
- | V _ -> 0\r
+ | V _ | C -> 0\r
| _ -> assert false\r
in aux hd_var\r
;;\r
let eat p =\r
print_cmd "EAT" "";\r
let var, k = get_inert p.div in\r
+ match var with\r
+ | C | L _ | B | A _ -> assert false\r
+ | V var ->\r
let phase = p.phase in\r
let p =\r
match phase with\r
\r
let problem_of (label, div, convs, ps, var_names) =\r
print_hline ();\r
- let rec aux = function\r
- | `Lam(_, t) -> L (aux t)\r
- | `I ((v,_), args) -> Listx.fold_left (fun x y -> mk_app x (aux y)) (V v) args\r
- | `Var(v,_) -> V v\r
+ let rec aux lev = function\r
+ | `Lam(_, t) -> L (aux (lev+1) t)\r
+ | `I (v, args) -> Listx.fold_left (fun x y -> mk_app x (aux lev y)) (aux lev (`Var v)) args\r
+ | `Var(v,_) -> if v >= lev && List.nth var_names (v-lev) = "C" then C else V v\r
| `N _ | `Match _ -> assert false in\r
assert (List.length ps = 0);\r
let convs = List.rev convs in\r
- let conv = List.fold_left (fun x y -> mk_app x (aux (y :> Num.nf))) (V (List.length var_names)) convs in\r
+ let conv = List.fold_left (fun x y -> mk_app x (aux 0 (y :> Num.nf))) (V (List.length var_names)) convs in\r
let var_names = "@" :: var_names in\r
let div = match div with\r
- | Some div -> aux (div :> Num.nf)\r
+ | Some div -> aux 0 (div :> Num.nf)\r
| None -> assert false in\r
let varno = List.length var_names in\r
let p = {orig_freshno=varno; freshno=1+varno; div; conv; sigma=[]; stepped=[]; phase=`One} in\r