]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_paramodulation/terms.mli
6ef3eeed86ca73018c65d6a662ed45aac9cf1816
[helm.git] / helm / software / components / ng_paramodulation / terms.mli
1 (*
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.                     
5     ||I||                                                                
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_______________________________________________________________ *)
11
12 (* $Id$ *)
13
14 type 'a foterm = 
15   | Leaf of 'a
16   | Var of int
17   | Node of ('a foterm) list
18
19 type 'a substitution = (int * 'a foterm) list
20
21 type comparison = Lt | Eq | Gt | Incomparable | Invertible
22
23 type rule = Superposition | Demodulation
24
25 (* A Discrimination tree is a map: foterm |-> (dir, clause) *)
26 type direction = Left2Right | Right2Left | Nodir
27
28 type position = int list
29
30 type 'a proof =
31   | Exact of 'a foterm
32          (* for theorems like T : \forall x. C[x] = D[x] the proof is 
33           * a foterm like (Node [ Leaf T ; Var i ]), while for the Goal
34           * it is just (Var g), i.e. the identity proof *)
35   | Step of rule * int * int * direction * position * 'a substitution
36          (* rule, eq1, eq2, direction of eq2, position, substitution *)
37
38 type 'a literal = 
39  | Equation of    'a foterm  (* lhs *)
40                 * 'a foterm  (* rhs *)
41                 * 'a foterm  (* type *)
42                 * comparison (* orientation *)
43  | Predicate of   'a foterm 
44
45 type varlist = int list
46
47 type 'a unit_clause =
48    int        (* ID *)
49  * 'a literal
50  * varlist
51  * 'a proof      (* proof *)
52
53 type 'a clause =
54     int
55     * ('a literal * bool) list (* left hand side of the arrow,
56                                   with flag for selection *)
57     * ('a literal * bool) list (* right hand side of the arrow,
58                                   with flag for selection *)
59     * varlist
60     * 'a proof
61
62 type 'a passive_clause = int * 'a clause (* weight * equation *)
63
64 val vars_of_term : ?start_acc:int list -> 'a foterm  -> int list
65
66 module M : Map.S with type key = int 
67
68 type 'a bag = int (* max ID  *)
69               * (('a unit_clause * bool * int) M.t)
70
71 (* also gives a fresh ID to the clause *)
72     val add_to_bag : 
73           'a unit_clause -> 'a bag ->
74             'a bag * 'a unit_clause
75
76     val replace_in_bag : 
77           'a unit_clause * bool * int -> 'a bag ->
78             'a bag
79
80     val get_from_bag : 
81           int -> 'a bag -> 'a unit_clause * bool * int
82
83     val empty_bag : 'a bag
84
85 module type Blob =
86   sig
87     (* Blob is the type for opaque leaves: 
88      * - checking equlity should be efficient
89      * - atoms have to be equipped with a total order relation
90      *)
91     type t
92     val eq : t -> t -> bool
93     val compare : t -> t -> int
94     val eqP : t
95     (* TODO: consider taking in input an imperative buffer for Format 
96      *  val pp : Format.formatter -> t -> unit
97      * *)
98     val pp : t -> string
99
100     type input
101     val embed : input -> t foterm
102     (* saturate [proof] [type] -> [proof] * [type] *)
103     val saturate : input -> input -> t foterm * t foterm
104
105   end
106