]> matita.cs.unibo.it Git - helm.git/blob - components/acic_procedural/proceduralMode.ml
433966d1b68200e0896b8748a7abe200fb5720d8
[helm.git] / components / acic_procedural / proceduralMode.ml
1 (* Copyright (C) 2003-2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 module C  = Cic
27 module Cl = ProceduralClassify
28
29 let is_eliminator = function
30    | _ :: C.MutInd _ :: _               -> true
31    | _ :: C.Appl (C.MutInd _ :: _) :: _ -> true
32    | _                                  -> false
33
34 let is_const = function
35    | C.Sort _
36    | C.Const _ 
37    | C.Var _ 
38    | C.MutInd _
39    | C.MutConstruct _ -> true 
40    | _                -> false 
41
42 let rec is_appl b = function
43    | C.Appl (hd :: tl) -> List.fold_left is_appl (is_const hd) tl
44    | t when is_const t -> b
45    | C.Rel _           -> b   
46    | _                 -> false 
47
48 let bkd c t =
49    let classes, rc = Cl.classify c t in
50    let premises, _ = Cl.split c t in
51    match rc with
52       | Some (i, j) when i > 1 && i <= List.length classes && is_eliminator premises -> true
53       | _ ->
54          let ts, _ = Cl.split c t in
55          is_appl true (List.hd ts)