2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
15 module BE = BrgEnvironment
16 module BR = BrgReduction
18 (* Internal functions *******************************************************)
22 let message1 st1 m t1 =
23 L.et_items1 "In the environment" m st1 t1
26 let s = s ^ " the term" in
27 L.log BR.specs level (message1 s m t)
29 let error1 err s m t =
32 let message2 m1 t1 m2 t2 =
33 let sm2, st2 = "In the environment", "the term" in
34 let sm1, st1 = "is valid, but in the environment", "it must be of type" in
35 L.et_items2 sm2 m2 st2 t2 ~sc2:sm1 ~c2:m1 st1 t1
37 let error2 err m1 t1 m2 t2 =
38 err (message2 m1 t1 m2 t2)
44 let assert_convertibility err f st m u t =
45 if BR.are_convertible st m zero u m one t then f () else
48 let assert_applicability err f st m v t =
49 match BR.xwhd st m None t with
51 error1 err "not a function" m t
52 | mw, B.Bind (_, B.Abst (_, w), _) ->
53 if BR.are_convertible st mw zero w m one v then f () else
55 | _ -> assert false (**)
57 let rec b_validate err f st m x =
58 log1 "Now checking" m x;
62 begin match BR.get m i with
66 error1 err "reference to excluded variable" m x
69 begin match BE.get_entity uri with
71 | _, _, E.Abbr _ -> f ()
73 error1 err "reference to unknown entry" m x
76 let f () = b_validate err f st (BR.push m a b) t in
78 | B.Abst (n, u) -> validate err f st m u
79 | B.Abbr v -> validate err f st m v
83 let f () = assert_applicability err f st m v t in
84 let f () = b_validate err f st m t in
87 let f () = assert_convertibility err f st m u t in
88 let f () = b_validate err f st m t in
91 (* Interface functions ******************************************************)
93 and validate err f st m x =
94 let f () = L.unbox level; f () in
95 L.box level; b_validate err f st m x