| 
39348
 | 
     1  | 
(* ========================================================================= *)
  | 
| 
 | 
     2  | 
(* FIRST ORDER LOGIC ATOMS                                                   *)
  | 
| 
39502
 | 
     3  | 
(* Copyright (c) 2001 Joe Hurd, distributed under the BSD License            *)
  | 
| 
39348
 | 
     4  | 
(* ========================================================================= *)
  | 
| 
 | 
     5  | 
  | 
| 
 | 
     6  | 
signature Atom =
  | 
| 
 | 
     7  | 
sig
  | 
| 
 | 
     8  | 
  | 
| 
 | 
     9  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    10  | 
(* A type for storing first order logic atoms.                               *)
  | 
| 
 | 
    11  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    12  | 
  | 
| 
 | 
    13  | 
type relationName = Name.name
  | 
| 
 | 
    14  | 
  | 
| 
 | 
    15  | 
type relation = relationName * int
  | 
| 
 | 
    16  | 
  | 
| 
 | 
    17  | 
type atom = relationName * Term.term list
  | 
| 
 | 
    18  | 
  | 
| 
 | 
    19  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    20  | 
(* Constructors and destructors.                                             *)
  | 
| 
 | 
    21  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    22  | 
  | 
| 
 | 
    23  | 
val name : atom -> relationName
  | 
| 
 | 
    24  | 
  | 
| 
 | 
    25  | 
val arguments : atom -> Term.term list
  | 
| 
 | 
    26  | 
  | 
| 
 | 
    27  | 
val arity : atom -> int
  | 
| 
 | 
    28  | 
  | 
| 
 | 
    29  | 
val relation : atom -> relation
  | 
| 
 | 
    30  | 
  | 
| 
 | 
    31  | 
val functions : atom -> NameAritySet.set
  | 
| 
 | 
    32  | 
  | 
| 
 | 
    33  | 
val functionNames : atom -> NameSet.set
  | 
| 
 | 
    34  | 
  | 
| 
 | 
    35  | 
(* Binary relations *)
  | 
| 
 | 
    36  | 
  | 
| 
 | 
    37  | 
val mkBinop : relationName -> Term.term * Term.term -> atom
  | 
| 
 | 
    38  | 
  | 
| 
 | 
    39  | 
val destBinop : relationName -> atom -> Term.term * Term.term
  | 
| 
 | 
    40  | 
  | 
| 
 | 
    41  | 
val isBinop : relationName -> atom -> bool
  | 
| 
 | 
    42  | 
  | 
| 
 | 
    43  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    44  | 
(* The size of an atom in symbols.                                           *)
  | 
| 
 | 
    45  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    46  | 
  | 
| 
 | 
    47  | 
val symbols : atom -> int
  | 
| 
 | 
    48  | 
  | 
| 
 | 
    49  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    50  | 
(* A total comparison function for atoms.                                    *)
  | 
| 
 | 
    51  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    52  | 
  | 
| 
 | 
    53  | 
val compare : atom * atom -> order
  | 
| 
 | 
    54  | 
  | 
| 
 | 
    55  | 
val equal : atom -> atom -> bool
  | 
| 
 | 
    56  | 
  | 
| 
 | 
    57  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    58  | 
(* Subterms.                                                                 *)
  | 
| 
 | 
    59  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    60  | 
  | 
| 
 | 
    61  | 
val subterm : atom -> Term.path -> Term.term
  | 
| 
 | 
    62  | 
  | 
| 
 | 
    63  | 
val subterms : atom -> (Term.path * Term.term) list
  | 
| 
 | 
    64  | 
  | 
| 
 | 
    65  | 
val replace : atom -> Term.path * Term.term -> atom
  | 
| 
 | 
    66  | 
  | 
| 
 | 
    67  | 
val find : (Term.term -> bool) -> atom -> Term.path option
  | 
| 
 | 
    68  | 
  | 
| 
 | 
    69  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    70  | 
(* Free variables.                                                           *)
  | 
| 
 | 
    71  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    72  | 
  | 
| 
 | 
    73  | 
val freeIn : Term.var -> atom -> bool
  | 
| 
 | 
    74  | 
  | 
| 
 | 
    75  | 
val freeVars : atom -> NameSet.set
  | 
| 
 | 
    76  | 
  | 
| 
 | 
    77  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    78  | 
(* Substitutions.                                                            *)
  | 
| 
 | 
    79  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    80  | 
  | 
| 
 | 
    81  | 
val subst : Subst.subst -> atom -> atom
  | 
| 
 | 
    82  | 
  | 
| 
 | 
    83  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    84  | 
(* Matching.                                                                 *)
  | 
| 
 | 
    85  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    86  | 
  | 
| 
 | 
    87  | 
val match : Subst.subst -> atom -> atom -> Subst.subst  (* raises Error *)
  | 
| 
 | 
    88  | 
  | 
| 
 | 
    89  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    90  | 
(* Unification.                                                              *)
  | 
| 
 | 
    91  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    92  | 
  | 
| 
 | 
    93  | 
val unify : Subst.subst -> atom -> atom -> Subst.subst  (* raises Error *)
  | 
| 
 | 
    94  | 
  | 
| 
 | 
    95  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    96  | 
(* The equality relation.                                                    *)
  | 
| 
 | 
    97  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
    98  | 
  | 
| 
 | 
    99  | 
val eqRelationName : relationName
  | 
| 
 | 
   100  | 
  | 
| 
 | 
   101  | 
val eqRelation : relation
  | 
| 
 | 
   102  | 
  | 
| 
 | 
   103  | 
val mkEq : Term.term * Term.term -> atom
  | 
| 
 | 
   104  | 
  | 
| 
 | 
   105  | 
val destEq : atom -> Term.term * Term.term
  | 
| 
 | 
   106  | 
  | 
| 
 | 
   107  | 
val isEq : atom -> bool
  | 
| 
 | 
   108  | 
  | 
| 
 | 
   109  | 
val mkRefl : Term.term -> atom
  | 
| 
 | 
   110  | 
  | 
| 
 | 
   111  | 
val destRefl : atom -> Term.term
  | 
| 
 | 
   112  | 
  | 
| 
 | 
   113  | 
val isRefl : atom -> bool
  | 
| 
 | 
   114  | 
  | 
| 
 | 
   115  | 
val sym : atom -> atom  (* raises Error if given a refl *)
  | 
| 
 | 
   116  | 
  | 
| 
 | 
   117  | 
val lhs : atom -> Term.term
  | 
| 
 | 
   118  | 
  | 
| 
 | 
   119  | 
val rhs : atom -> Term.term
  | 
| 
 | 
   120  | 
  | 
| 
 | 
   121  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
   122  | 
(* Special support for terms with type annotations.                          *)
  | 
| 
 | 
   123  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
   124  | 
  | 
| 
 | 
   125  | 
val typedSymbols : atom -> int
  | 
| 
 | 
   126  | 
  | 
| 
 | 
   127  | 
val nonVarTypedSubterms : atom -> (Term.path * Term.term) list
  | 
| 
 | 
   128  | 
  | 
| 
 | 
   129  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
   130  | 
(* Parsing and pretty printing.                                              *)
  | 
| 
 | 
   131  | 
(* ------------------------------------------------------------------------- *)
  | 
| 
 | 
   132  | 
  | 
| 
 | 
   133  | 
val pp : atom Print.pp
  | 
| 
 | 
   134  | 
  | 
| 
 | 
   135  | 
val toString : atom -> string
  | 
| 
 | 
   136  | 
  | 
| 
 | 
   137  | 
val fromString : string -> atom
  | 
| 
 | 
   138  | 
  | 
| 
 | 
   139  | 
val parse : Term.term Parse.quotation -> atom
  | 
| 
 | 
   140  | 
  | 
| 
 | 
   141  | 
end
  |