We follow our Prolog implementation more closely.
- Two bugs detected. One solved, the other does not affect the
Grundlagen.
PREAMBLE_MA = ../matita/matita.ma.templ
PREAMBLE_V = coq/grundlagen.template
-PREAMBLE_ELPI = elpi/grundlagen.template
+PREAMBLE_ELPI = elpi/elpi.template
test-si-fast: $(MAIN).opt etc
@echo " HELENA -o -q -1 $(INPUTFAST)"
V_______________________________________________________________ *)
(* kernel version: basic, relative, global *)
-(* note : ufficial basic \lambda\delta *)
+(* note : ufficial basic \lambda\delta version 3 *)
module N = Layer
module E = Entity
type uri = E.uri
type attrs = E.node_attrs
-type bind = Void (* *)
- | Abst of N.layer * term (* layer, type *)
- | Abbr of term (* body *)
+(* x-reduced abstractions are output by RTM only *)
+type bind = Void (* *)
+ | Abst of bool * N.layer * term (* x-reduced?, layer, type *)
+ | Abbr of term (* body *)
and term = Sort of attrs * int (* attrs, hierarchy index *)
| LRef of attrs * int (* attrs, position index *)
(* Currified constructors ***************************************************)
-let abst n w = Abst (n, w)
+let abst x n w = Abst (x, n, w)
let abbr v = Abbr v
let bind a b t = Bind (a, b, t)
-let bind_abst n a u t = Bind (a, Abst (n, u), t)
+let bind_abst x n a u t = Bind (a, Abst (x, n, u), t)
-let bind_abbr a v t = Bind (a, Abbr v, t)
+let bind_abbr a u t = Bind (a, Abbr u, t)
let bind_void a t = Bind (a, Void, t)
and xlate_bind f a b x = match b with
| D.Abst (n, w) ->
- let f ww = f (B.Bind (a, B.Abst (n, ww), x)) in
+ let f ww = f (B.Bind (a, B.Abst (false, n, ww), x)) in
xlate_term f w
| D.Abbr v ->
let f vv = f (B.Bind (a, B.Abbr vv, x)) in
xlate_bk_term f t
and xlate_bk_bind f = function
- | B.Abst (n, t) ->
+ | B.Abst (_, n, t) ->
let f tt = f (D.Abst (n, tt)) in
xlate_bk_term f t
- | B.Abbr t ->
+ | B.Abbr t ->
let f tt = f (D.Abbr tt) in
xlate_bk_term f t
- | B.Void -> f D.Void
+ | B.Void -> f D.Void
(* interface functions ******************************************************)
E.name err f a
let rec out_term st e och = function
- | B.Sort (_, h) ->
+ | B.Sort (_, h) ->
let sort = if h = 0 then "k+0" else if h = 1 then "k+1" else assert false in
KP.fprintf och "(sort %s)" sort
- | B.LRef (_, i) ->
+ | B.LRef (_, i) ->
let _, _, a, b = B.get e i in
KP.fprintf och "%a" out_name a
- | B.GRef (_, s) ->
+ | B.GRef (_, s) ->
KP.fprintf och "%a" out_uri s
- | B.Cast (_, u, t) ->
+ | B.Cast (_, u, t) ->
KP.fprintf och "(cast %a %a)" (out_term st e) u (out_term st e) t
- | B.Appl (_, v, t) ->
- KP.fprintf och "(appx %a %a)" (out_term st e) v (out_term st e) t
- | B.Bind (a, B.Abst (n, w), t) ->
+ | B.Appl (_, v, t) ->
+ KP.fprintf och "(appr %a %a)" (out_term st e) v (out_term st e) t
+ | B.Bind (a, B.Abst (x, n, w), t) ->
let a = R.alpha B.mem e a in
- let ee = B.push e B.empty a (B.abst n w) in
+ let ee = B.push e B.empty a (B.abst x n w) in
+ let c = if x then "prod" else "abst" in
let l = match N.to_string st n with
| "1" -> "l+1"
| "2" -> "l+2"
| _ -> ok := false; "?"
in
- KP.fprintf och "(abst %s %a %a\\ %a)"
- l (out_term st e) w out_name a (out_term st ee) t
- | B.Bind (a, B.Abbr v, t) ->
+ KP.fprintf och "(%s %s %a %a\\ %a)"
+ c l (out_term st e) w out_name a (out_term st ee) t
+ | B.Bind (a, B.Abbr v, t) ->
let a = R.alpha B.mem e a in
let ee = B.push e B.empty a (B.abbr v) in
KP.fprintf och "(abbr %a %a\\ %a)"
let och = open_out (path ^ ext) in
out_preamble och;
out_top_comment och (KP.sprintf "This file was generated by %s: do not edit" G.version_string);
- out_clause och "k+succ k+0 k+2.";
- out_clause och "k+succ k+1 k+3.";
+ out_clause och "main :- grundlagen.";
out_clause och "grundlagen :- gv+ (";
output_entity och, close_out och
E.name err f a
let rec out_term st p e och = function
- | B.Sort (_, h) ->
+ | B.Sort (_, h) ->
let sort = if h = 0 then "Type" else if h = 1 then "Prop" else assert false in
KP.fprintf och "%s" sort
- | B.LRef (_, i) ->
+ | B.LRef (_, i) ->
let _, _, a, b = B.get e i in
KP.fprintf och "%a" out_name a
- | B.GRef (_, s) ->
+ | B.GRef (_, s) ->
KP.fprintf och "%a" out_uri s
- | B.Cast (_, u, t) ->
+ | B.Cast (_, u, t) ->
KP.fprintf och "(%a : %a)" (out_term st false e) t (out_term st false e) u
- | B.Appl (_, v, t) ->
+ | B.Appl (_, v, t) ->
let pt = match t with B.Appl _ -> false | _ -> true in
let op, cp = if p then "(", ")" else "", "" in
KP.fprintf och "%s%a %a%s" op (out_term st pt e) t (out_term st true e) v cp
- | B.Bind (a, B.Abst (n, w), t) ->
+ | B.Bind (a, B.Abst (x, n, w), t) ->
let p = true in
let op, cp = if p then "(", ")" else "", "" in
let a = R.alpha B.mem e a in
- let ee = B.push e B.empty a (B.abst n w) in
+ let ee = B.push e B.empty a (B.abst x n w) in
let ob, cb = match N.to_string st n with
| "1" -> "forall", ","
| "2" -> "fun", " =>"
in
KP.fprintf och "%s%s (%a:%a)%s %a%s"
op ob out_name a (out_term st false e) w cb (out_term st false ee) t cp
- | B.Bind (a, B.Abbr v, t) ->
+ | B.Bind (a, B.Abbr v, t) ->
let op, cp = if p then "(", ")" else "", "" in
let a = R.alpha B.mem e a in
let ee = B.push e B.empty a (B.abbr v) in
KP.fprintf och "%slet %a := %a in %a%s"
op out_name a (out_term st false e) v (out_term st false ee) t cp
- | B.Bind (a, B.Void, t) -> C.err ()
+ | B.Bind (a, B.Void, t) -> C.err ()
let close_out och () = close_out och
E.name err f a
let rec out_term st p e och = function
- | B.Sort (_, h) ->
+ | B.Sort (_, h) ->
let sort = if h = 0 then "Type[0]" else if h = 1 then "Prop" else assert false in
KP.fprintf och "%s" sort
- | B.LRef (_, i) ->
+ | B.LRef (_, i) ->
let _, _, a, b = B.get e i in
KP.fprintf och "%a" out_name a
- | B.GRef (_, s) ->
+ | B.GRef (_, s) ->
KP.fprintf och "%a" out_uri s
- | B.Cast (_, u, t) ->
+ | B.Cast (_, u, t) ->
KP.fprintf och "(%a : %a)" (out_term st false e) t (out_term st false e) u
- | B.Appl (_, v, t) ->
+ | B.Appl (_, v, t) ->
let pt = match t with B.Appl _ -> false | _ -> true in
let op, cp = if p then "(", ")" else "", "" in
KP.fprintf och "%s%a %a%s" op (out_term st pt e) t (out_term st true e) v cp
- | B.Bind (a, B.Abst (n, w), t) ->
+ | B.Bind (a, B.Abst (x, n, w), t) ->
let op, cp = if p then "(", ")" else "", "" in
let a = R.alpha B.mem e a in
- let ee = B.push e B.empty a (B.abst n w) in
+ let ee = B.push e B.empty a (B.abst x n w) in
let binder = match N.to_string st n, a.E.n_sort with
| "1", 0 -> "Π"
| "1", 1 -> "∀"
in
KP.fprintf och "%s%s%a:%a.%a%s"
op binder out_name a (out_term st false e) w (out_term st false ee) t cp
- | B.Bind (a, B.Abbr v, t) ->
+ | B.Bind (a, B.Abbr v, t) ->
let op, cp = if p then "(", ")" else "", "" in
let a = R.alpha B.mem e a in
let ee = B.push e B.empty a (B.abbr v) in
KP.fprintf och "%slet %a ≝ %a in %a%s"
op out_name a (out_term st false e) v (out_term st false ee) t cp
- | B.Bind (a, B.Void, t) -> C.err ()
+ | B.Bind (a, B.Void, t) -> C.err ()
let close_out och () = close_out och
}
let rec count_term_binder f c e = function
- | B.Abst (_, w) ->
+ | B.Abst (_, _, w) ->
let c = {c with tabsts = succ c.tabsts; nodes = succ c.nodes} in
count_term f c e w
- | B.Abbr v ->
+ | B.Abbr v ->
let c = {c with tabbrs = succ c.tabbrs; xnodes = succ c.xnodes} in
count_term f c e v
- | B.Void ->
+ | B.Void ->
let c = {c with tvoids = succ c.tvoids; xnodes = succ c.xnodes} in
f c
in
E.name err f a
+let pp_reduced och x =
+ if x then KP.fprintf och "%s" "^"
+
let pp_level st och n =
KP.fprintf och "%s" (N.to_string st n)
let rec pp_term st e och = function
- | B.Sort (_, h) ->
+ | B.Sort (_, h) ->
let err _ = KP.fprintf och "*%u" h in
let f s = KP.fprintf och "%s" s in
H.string_of_sort err f h
- | B.LRef (_, i) ->
+ | B.LRef (_, i) ->
let err _ = KP.fprintf och "#%u" i in
if !G.indexes then err () else
let _, _, a, b = B.get e i in
KP.fprintf och "%a" (name err) a
- | B.GRef (_, s) ->
+ | B.GRef (_, s) ->
KP.fprintf och "$%s" (U.string_of_uri s)
- | B.Cast (_, u, t) ->
+ | B.Cast (_, u, t) ->
KP.fprintf och "{%a}.%a" (pp_term st e) u (pp_term st e) t
- | B.Appl (_, v, t) ->
+ | B.Appl (_, v, t) ->
KP.fprintf och "(%a).%a" (pp_term st e) v (pp_term st e) t
- | B.Bind (a, B.Abst (n, w), t) ->
+ | B.Bind (a, B.Abst (x, n, w), t) ->
let a = R.alpha B.mem e a in
- let ee = B.push e B.empty a (B.abst n w) in
- KP.fprintf och "%a[%a:%a].%a" (pp_level st) n (name C.start) a (pp_term st e) w (pp_term st ee) t
- | B.Bind (a, B.Abbr v, t) ->
+ let ee = B.push e B.empty a (B.abst x n w) in
+ KP.fprintf och "%a%a[%a:%a].%a" (pp_level st) n pp_reduced x (name C.start) a (pp_term st e) w (pp_term st ee) t
+ | B.Bind (a, B.Abbr v, t) ->
let a = R.alpha B.mem e a in
let ee = B.push e B.empty a (B.abbr v) in
KP.fprintf och "[%a=%a].%a" (name C.start) a (pp_term st e) v (pp_term st ee) t
- | B.Bind (a, B.Void, t) ->
+ | B.Bind (a, B.Void, t) ->
let a = R.alpha B.mem e a in
let ee = B.push e B.empty a B.Void in
KP.fprintf och "[%a].%a" (name C.start) a (pp_term st ee) t
e: B.lenv; (* environment *)
s: (B.lenv * B.term) list; (* stack *)
l: int; (* level *)
- d: int; (* inferred type iterations *)
n: int option; (* expected type iterations *)
}
aux_bind f (b1, b2)
| _ -> err ()
and aux_bind f = function
- | B.Abbr v1, B.Abbr v2 -> aux f (v1, v2)
- | B.Abst (n1, v1), B.Abst (n2, v2) when n1 = n2 -> aux f (v1, v2)
- | B.Void, B.Void -> f ()
- | _ -> err ()
+ | B.Abbr v1, B.Abbr v2 -> aux f (v1, v2)
+ | B.Abst (x1, n1, v1), B.Abst (x2, n2, v2) when x1 = x2 && n1 = n2 -> aux f (v1, v2)
+ | B.Void, B.Void -> f ()
+ | _ -> err ()
in
if S.eq t1 t2 then f () else aux f (t1, t2)
let assert_tstep m vo = match m.n with
- | Some n -> n > m.d
+ | Some n -> n > 0
| None -> vo
-let tstep m = {m with d = succ m.d}
+let tstep m = match m.n with
+ | Some n -> {m with n = Some (pred n)}
+ | None -> m
let tsteps m = match m.n with
- | Some n when n > m.d -> n - m.d
- | _ -> 0
+ | Some n -> n
+ | None -> 0
let get m i =
let _, c, a, b = B.get m.e i in c, a, b
(* to share *)
-let rec step st m x =
+let rec step st m r =
if !G.trace >= sublevel then
- log1 st (Printf.sprintf "entering R.step: l:%u d:%i n:%s" m.l m.d (match m.n with Some n -> string_of_int n | None -> "infinite")) m.e x;
- match x with
- | B.Sort (a, h) ->
+ log1 st (Printf.sprintf "entering R.step: l:%u n:%s" m.l (match m.n with Some n -> string_of_int n | None -> "infinite")) m.e r;
+ match r with
+ | B.Sort (a, h) ->
if assert_tstep m false then
step st (tstep m) (B.Sort (a, H.apply h))
- else m, x, None
- | B.GRef (_, uri) ->
+ else m, r, None
+ | B.GRef (_, uri) ->
begin match BE.get_entity uri with
| _, _, _, E.Abbr v ->
if m.n = None || !G.expand then begin
if !G.summary then O.add ~gdelta:1 ();
step st m v
end else
- m, x, Some v
+ m, r, Some v
| _, _, _, E.Abst w ->
if assert_tstep m true then begin
if !G.summary then O.add ~grt:1 ();
step st (tstep m) w
end else
- m, x, None
+ m, r, None
| _, _, _, E.Void ->
assert false
end
- | B.LRef (_, i) ->
+ | B.LRef (_, i) ->
begin match get m i with
- | c, _, B.Abbr v ->
+ | c, _, B.Abbr v ->
if !G.summary then O.add ~ldelta:1 ();
step st {m with e = c} v
- | c, a, B.Abst (_, w) ->
+ | c, a, B.Abst (_, _, w) ->
if assert_tstep m true then begin
if !G.summary then O.add ~lrt:1 ();
step st {(tstep m) with e = c} w
end else
m, B.LRef (a, i), None
- | _, _, B.Void ->
+ | _, _, B.Void ->
assert false
end
- | B.Cast (_, u, t) ->
+ | B.Cast (_, u, t) ->
if assert_tstep m false then begin
if !G.summary then O.add ~e:1 ();
step st (tstep m) u
if !G.summary then O.add ~epsilon:1 ();
step st m t
end
- | B.Appl (_, v, t) ->
+ | B.Appl (_, v, t) ->
step st {m with s = (m.e, v) :: m.s} t
- | B.Bind (a, B.Abst (n, w), t) ->
+ | B.Bind (a, B.Abst (false, n, w), t) ->
let i = tsteps m in
+ if !G.summary then O.add ~x:i ();
let n = if i = 0 then n else N.minus st n i in
+ let r = B.Bind (a, B.Abst (true, n, w), t) in
+ step st m r
+ | B.Bind (a, B.Abst (true, n, w), t) ->
if !G.si || N.is_not_zero st n then begin match m.s with
| [] ->
- if i = 0 then m, x, None else
- m, B.Bind (a, B.Abst (n, w), t), None
+ m, B.Bind (a, B.Abst (true, n, w), t), None
| (c, v) :: s ->
+(*
if !G.cc && not (N.assert_not_zero st n) then assert false;
+*)
if !G.summary then O.add ~beta:1 ~theta:(List.length s) ();
- let v = if assert_tstep m false then B.Cast (E.empty_node, w, v) else v in
+ let v = B.Cast (E.empty_node, w, v) in
let e = B.push m.e c a (B.abbr v) in
step st {m with e = e; s = s} t
end else begin
if !G.summary then O.add ~upsilon:1 ();
- let e = B.push m.e m.e a B.Void in
+ let e = B.push m.e m.e a B.Void in (**) (* this is wrong in general *)
step st {m with e = e} t
end
| B.Bind (a, b, t) ->
let e = B.push m.e m.e a b in
step st {m with e = e} t
-let reset m ?(e=m.e) n =
- {m with e = e; n = n; s = []; d = 0}
+let assert_iterations m1 m2 =
+ m1.n = m2.n
-let assert_iterations m1 m2 = match m1.n, m2.n with
- | Some n1, Some n2 -> n1 - m1.d = n2 - m2.d
- | _ -> false
+let reset m ?(e=m.e) n =
+ {m with e = e; n = n; s = []}
let push m a b =
let a, l = match b with
let rec ac_nfs st (m1, t1, r1) (m2, t2, r2) =
if !G.trace >= level then log2 st "Now converting nfs" m1.e t1 m2.e t2;
match t1, r1, t2, r2 with
- | B.Sort (_, h1), _, B.Sort (_, h2), _ ->
+ | B.Sort (_, h1), _, B.Sort (_, h2), _ ->
h1 = h2
| B.LRef ({E.n_apix = e1}, _), _,
- B.LRef ({E.n_apix = e2}, _), _ ->
+ B.LRef ({E.n_apix = e2}, _), _ ->
if e1 = e2 then ac_stacks st m1 m2 else false
| B.GRef (_, u1), None, B.GRef (_, u2), None ->
if U.eq u1 u2 && assert_iterations m1 m2 then ac_stacks st m1 m2 else false
| B.GRef ({E.n_apix = e1}, u1), Some v1,
- B.GRef ({E.n_apix = e2}, u2), Some v2 ->
+ B.GRef ({E.n_apix = e2}, u2), Some v2 ->
if e1 < e2 then begin
if !G.summary then O.add ~gdelta:1 ();
ac_nfs st (m1, t1, r1) (step st m2 v2)
if !G.summary then O.add ~gdelta:2 ();
ac st m1 v1 m2 v2
end
- | _, _, B.GRef _, Some v2 ->
+ | _, _, B.GRef _, Some v2 ->
if !G.summary then O.add ~gdelta:1 ();
ac_nfs st (m1, t1, r1) (step st m2 v2)
- | B.GRef _, Some v1, _, _ ->
+ | B.GRef _, Some v1, _, _ ->
if !G.summary then O.add ~gdelta:1 ();
ac_nfs st (step st m1 v1) (m2, t2, r2)
- | B.Bind (a1, (B.Abst (n1, w1) as b1), t1), _,
- B.Bind (a2, (B.Abst (n2, w2) as b2), t2), _ ->
+ | B.Bind (a1, (B.Abst (true, n1, w1) as b1), t1), _,
+ B.Bind (a2, (B.Abst (true, n2, w2) as b2), t2), _ ->
if ((!G.cc && N.assert_equal st n1 n2) || N.are_equal st n1 n2) &&
ac st (reset m1 zero) w1 (reset m2 zero) w2
then ac st (push m1 a1 b1) t1 (push m2 a2 b2) t2
else false
- | B.Sort _, _, B.Bind (a, B.Abst (n, _), t), _ ->
+ | B.Sort _, _, B.Bind (a, B.Abst (true, n, _), t), _ ->
if !G.si then
if !G.cc && not (N.assert_zero st n) then false else begin
if !G.summary then O.add ~upsilon:1 ();
ac st (push m1 a B.Void) t1 (push m2 a B.Void) t end
else false
- | _ -> false
+ | _ -> false
and ac st m1 t1 m2 t2 =
(* L.warn "entering R.are_convertible"; *)
(* Interface functions ******************************************************)
let empty_rtm = {
- e = B.empty; s = []; l = 0; d = 0; n = None
+ e = B.empty; s = []; l = 0; n = None
}
let get m i =
let rec icm a = function
| B.Sort _
| B.LRef _
- | B.GRef _ -> succ a
- | B.Bind (_, B.Void, t) -> icm (succ a) t
- | B.Cast (_, u, t) -> icm (icm a u) t
+ | B.GRef _ -> succ a
+ | B.Bind (_, B.Void, t) -> icm (succ a) t
+ | B.Cast (_, u, t) -> icm (icm a u) t
| B.Appl (_, u, t)
- | B.Bind (_, B.Abst (_, u), t)
- | B.Bind (_, B.Abbr u, t) -> icm (icm (succ a) u) t
+ | B.Bind (_, B.Abst (_, _, u), t)
+ | B.Bind (_, B.Abbr u, t) -> icm (icm (succ a) u) t
let iter map d =
let rec iter_bind d = function
- | B.Void -> B.Void
- | B.Abst (n, w) -> B.Abst (n, iter_term d w)
- | B.Abbr v -> B.Abbr (iter_term d v)
+ | B.Void -> B.Void
+ | B.Abst (x, n, w) -> B.Abst (x, n, iter_term d w)
+ | B.Abbr v -> B.Abbr (iter_term d v)
and iter_term d = function
| B.Sort _ as t -> t
| B.GRef _ as t -> t
let assert_applicability err f st m u w v =
match BR.xwhd st m None u with
- | _, B.Sort _ ->
+ | _, B.Sort _ ->
error1 err "not a function type" m u
- | mu, B.Bind (_, B.Abst (n, u), _) ->
+ | mu, B.Bind (_, B.Abst (true, n, u), _) ->
if !G.cc && not (N.assert_not_zero st n) then error1 err "not a function type" m u else
if BR.are_convertible st mu zero u m zero w then f () else
error3 err m v w ~mu u
- | _ -> assert false (**)
+ | _ -> assert false (**)
-let rec b_type_of err f st m x =
- if !G.trace >= level then log1 st "Now checking" m x;
- match x with
- | B.Sort (a, h) ->
- let h = H.apply h in f x (B.Sort (a, h))
- | B.LRef (_, i) ->
+let rec b_type_of err f st m r =
+ if !G.trace >= level then log1 st "Now checking" m r;
+ match r with
+ | B.Sort (a, h) ->
+ let h = H.apply h in f r (B.Sort (a, h))
+ | B.LRef (_, i) ->
begin match BR.get m i with
- | B.Abst (_, w) ->
- f x (BS.lift (succ i) (0) w)
+ | B.Abst (_, _, w) ->
+ f r (BS.lift (succ i) (0) w)
| B.Abbr (B.Cast (_, w, _)) ->
- f x (BS.lift (succ i) (0) w)
+ f r (BS.lift (succ i) (0) w)
| B.Abbr _ -> assert false
| B.Void ->
- error1 err "reference to excluded variable" m x
+ error1 err "reference to excluded variable" m r
end
- | B.GRef (_, uri) ->
+ | B.GRef (_, uri) ->
begin match BE.get_entity uri with
- | _, _, _, E.Abst w -> f x w
- | _, _, _, E.Abbr (B.Cast (_, w, _)) -> f x w
+ | _, _, _, E.Abst w -> f r w
+ | _, _, _, E.Abbr (B.Cast (_, w, _)) -> f r w
| _, _, _, E.Abbr _ -> assert false
| _, _, _, E.Void ->
- error1 err "reference to unknown entry" m x
+ error1 err "reference to unknown entry" m r
end
- | B.Bind (a, B.Abbr v, t) ->
- let f xv xt tt =
- f (S.sh2 v xv t xt x (B.bind_abbr a)) (B.bind_abbr a xv tt)
+ | B.Bind (a, B.Abbr v, t) ->
+ let f rv rt tt =
+ f (S.sh2 v rv t rt r (B.bind_abbr a)) (B.bind_abbr a rv tt)
in
- let f xv m = b_type_of err (f xv) st m t in
- let f xv = f xv (BR.push m a (B.abbr xv)) in
- let f xv vv = match xv with
- | B.Cast _ -> f xv
- | _ -> f (B.Cast (E.empty_node, vv, xv))
+ let f rv m = b_type_of err (f rv) st m t in
+ let f rv = f rv (BR.push m a (B.abbr rv)) in
+ let f rv vv = match rv with
+ | B.Cast _ -> f rv
+ | _ -> f (B.Cast (E.empty_node, vv, rv))
in
type_of err f st m v
- | B.Bind (a, B.Abst (n, u), t) ->
- let f xu xt tt =
- f (S.sh2 u xu t xt x (B.bind_abst n a)) (B.bind_abst (N.minus st n 1) a xu tt)
+ | B.Bind (a, B.Abst (x, n, u), t) ->
+ let f ru rt tt =
+ f (S.sh2 u ru t rt r (B.bind_abst x n a)) (B.bind_abst x (N.minus st n 1) a ru tt)
in
- let f xu m = b_type_of err (f xu) st m t in
- let f xu _ = f xu (BR.push m a (B.abst n xu)) in
+ let f ru m = b_type_of err (f ru) st m t in
+ let f ru _ = f ru (BR.push m a (B.abst x n ru)) in
type_of err f st m u
- | B.Bind (a, B.Void, t) ->
- let f xt tt =
- f (S.sh1 t xt x (B.bind_void a)) (B.bind_void a tt)
+ | B.Bind (a, B.Void, t) ->
+ let f rt tt =
+ f (S.sh1 t rt r (B.bind_void a)) (B.bind_void a tt)
in
b_type_of err f st (BR.push m a B.Void) t
-
- | B.Appl (a, v, t) ->
- let f xv vv xt tt =
- let f _ = f (S.sh2 v xv t xt x (B.appl a)) (B.appl a xv tt) in
- assert_applicability err f st m tt vv xv
+ | B.Appl (a, v, t) ->
+ let f rv vv rt tt =
+ let f _ = f (S.sh2 v rv t rt r (B.appl a)) (B.appl a rv tt) in
+ assert_applicability err f st m tt vv rv
in
- let f xv vv = b_type_of err (f xv vv) st m t in
+ let f rv vv = b_type_of err (f rv vv) st m t in
type_of err f st m v
- | B.Cast (a, u, t) ->
- let f xu xt tt =
- let f _ = f (S.sh2 u xu t xt x (B.cast a)) xu in
- assert_convertibility err f st m xu tt xt
+ | B.Cast (a, u, t) ->
+ let f ru rt tt =
+ let f _ = f (S.sh2 u ru t rt r (B.cast a)) ru in
+ assert_convertibility err f st m ru tt rt
in
- let f xu _ = b_type_of err (f xu) st m t in
+ let f ru _ = b_type_of err (f ru) st m t in
type_of err f st m u
(* Interface functions ******************************************************)
-and type_of err f st m x = b_type_of err f st m x
+and type_of err f st m r = b_type_of err f st m r
let assert_applicability err f st m v t =
if !G.trace >= level then warn "Asserting applicability";
match BR.xwhd st m None t with
- | _, B.Sort _ ->
+ | _, B.Sort _ ->
error1 err "not a function" m t
- | mw, B.Bind (_, B.Abst (n, w), _) ->
+ | mw, B.Bind (_, B.Abst (true, n, w), _) ->
if !G.cc && not (N.assert_not_zero st n) then error1 err "not a function" m t
else begin
if !G.trace >= level then warn "Asserting convertibility for application";
| B.Bind (a, b, t) ->
let f () = b_validate err f st (BR.push m a b) t in
begin match b with
- | B.Abst (n, u) -> validate err f st m u
- | B.Abbr v -> validate err f st m v
- | B.Void -> f ()
+ | B.Abst (_, n, u) -> validate err f st m u
+ | B.Abbr v -> validate err f st m v
+ | B.Void -> f ()
end
| B.Appl (_, v, t) ->
let f () = assert_applicability err f st m v t in
(* interface functions ******************************************************)
-let version_string = "Helena 0.8.2 M (May 2015)"
+let version_string = "Helena 0.8.2 M (June 2015)"
let stage = ref 3 (* stage *)
lrt : int;
grt : int;
e : int;
+ x : int;
}
let level = 2
let initial_reductions = {
beta = 0; theta = 0; epsilon = 0; zeta = 0; ldelta = 0; gdelta = 0; upsilon = 0;
- lrt = 0; grt = 0; e = 0;
+ lrt = 0; grt = 0; e = 0; x = 0;
}
let reductions = ref initial_reductions
let add
?(beta=0) ?(theta=0) ?(epsilon=0) ?(ldelta=0) ?(gdelta=0) ?(zeta=0)
- ?(upsilon=0) ?(lrt=0) ?(grt=0) ?(e=0) ()
+ ?(upsilon=0) ?(lrt=0) ?(grt=0) ?(e=0) ?(x=0) ()
=
(*
if beta > 0 then L.warn level (KP.sprintf "BETA %u" beta);
lrt = !reductions.lrt + lrt;
grt = !reductions.grt + grt;
e = !reductions.e + e;
+ x = !reductions.x + x;
}
let print_reductions () =
let r = !reductions in
let rs = r.beta + r.ldelta + r.zeta + r.theta + r.epsilon + r.gdelta + r.upsilon in
- let prs = r.lrt + r.grt + r.e in
+ let prs = r.lrt + r.grt + r.e + r.x in
let delta = r.ldelta + r.gdelta in
let rt = r.lrt + r.grt in
L.warn level (KP.sprintf "Reductions summary");
L.warn level (KP.sprintf " Reference typing: %7u" rt);
L.warn level (KP.sprintf " Local: %7u" r.lrt);
L.warn level (KP.sprintf " Global: %7u" r.grt);
- L.warn level (KP.sprintf " Cast typing: %7u" r.e);
+ L.warn level (KP.sprintf " Cast typing: %7u" r.e);
+ L.warn level (KP.sprintf " Binder typing: %7u" r.x);
L.warn level (KP.sprintf "Relocated nodes (icm): %7u" !G.icm)
val add:
?beta:int -> ?theta:int -> ?epsilon:int -> ?ldelta:int -> ?gdelta:int ->
- ?zeta:int -> ?upsilon:int -> ?lrt:int -> ?grt:int -> ?e:int ->
+ ?zeta:int -> ?upsilon:int -> ?lrt:int -> ?grt:int -> ?e:int -> ?x:int ->
unit -> unit
val print_reductions: unit -> unit