123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233(* This file is free software, part of dolmen. See file "LICENSE" for more information *)(** Interfaces for Terms.
This module defines Interfaces that implementation of terms must
respect in order to be used to instantiated the corresponding
language classes. *)(** {2 Signature for Logic languages} *)moduletypeLogic=sig(** Signature used by the Logic class, which parses languages
such as tptp, smtlib, etc...
Mainly used to parse first-order terms, it is also used to
parse tptp's THF language, which uses higher order terms, so
some first-order constructs such as conjunction, equality, etc...
also need to be represented by standalone terms.
*)typet(** The type of terms. *)typeid(** The type of identifiers used for constants. *)typelocation(** The type of locations attached to terms. *)(** {3 Predefined terms} *)valeq_t:?loc:location->unit->tvalneq_t:?loc:location->unit->t(** The terms representing equality and disequality, respectively. *)valwildcard:?loc:location->unit->t(** The wildcard term, usually used in place of type arguments
to explicit polymorphic functions to not explicit types that
can be inferred by the type-checker. *)valtType:?loc:location->unit->t(** The type of types, defined as specific token by the Zipperposition format;
in other languages, will be represented as a constant (the "$tType" constant
in tptp for instance). Used to define new types, or quantify type variables
in languages that support polymorphism. *)valty_int:?loc:location->unit->t(** The type of integers, defined as a specific token by the Zipperposition format;
in other languages, it might be represented as a constant with a specific name
(for isntance, tptp's "$int") .*)valprop:?loc:location->unit->t(** The type of propositions. Also defined as a lexical token by the Zipperposition
format. Will be defined as a constant in most other languages (for instance,
"$o" in tptp). *)valtrue_:?loc:location->unit->tvalfalse_:?loc:location->unit->t(** The constants for the true and false propositional constants. Again defined
as lexical token in the Zipperposition format, while treated as a constant
in other languages ("$true" in tptp). *)valnot_t:?loc:location->unit->tvalor_t:?loc:location->unit->tvaland_t:?loc:location->unit->tvalxor_t:?loc:location->unit->tvalnor_t:?loc:location->unit->tvalnand_t:?loc:location->unit->tvalequiv_t:?loc:location->unit->tvalimplied_t:?loc:location->unit->tvalimplies_t:?loc:location->unit->t(** Standard logical connectives viewed as terms. [implies_t] is usual
right implication, i.e [apply implies_t \[p; q\] ] is "p implies q",
while [apply implied_t \[p; q \]] means "p is implied by q" or
"q implies p". *)valdata_t:?loc:location->unit->t(** Term without semantic meaning, used for creating "data" terms.
Used in tptp's annotations, and with similar meaning as smtlib's
s-expressions (as used in the [sexpr] function defined later). *)(** {3 Terms leaf constructors} *)valvar:?loc:location->id->tvalconst:?loc:location->id->t(** Variable and constant constructors. While in some languages
they can distinguished at the lexical level (in tptp for instance),
in most languages, it is an issue dependant on scoping rules,
so terms parsed from an smtlib file will have all variables
parsed as constants. *)valatom:?loc:location->int->t(** Atoms are used for dimacs cnf parsing. Positive integers denotes variables,
and negative integers denote the negation of the variable corresponding to
their absolute value. *)valdistinct:?loc:location->id->t(** Used in tptp to specify constants different from other constants, for instance the
'distinct' "Apple" should be syntactically different from the "Apple"
constant. Can be safely aliased to the [const] function as the
[distinct] function is always given strings already enclosed with quotes,
so in the example above, [const] would be called with ["Apple"] as
string argument, while [distinct] would be called with the string ["\"Apple\""] *)valint:?loc:location->string->tvalrat:?loc:location->string->tvalreal:?loc:location->string->tvalhexa:?loc:location->string->tvalbinary:?loc:location->string->t(** Constructors for words defined as numeric formats by the languages
specifications. These also can be safely aliased to [const]. *)(** {3 Term constructors} *)valcolon:?loc:location->t->t->t(** Represents juxtaposition of two terms, usually denoted "t : t'"
in most languages, and mainly used to annotated terms with their
supposed, or defined, type. *)valeq:?loc:location->t->t->tvalnot_:?loc:location->t->tvalor_:?loc:location->tlist->tvaland_:?loc:location->tlist->tvalimply:?loc:location->t->t->tvalequiv:?loc:location->t->t->t(** Proposition construction functions. The conjunction and disjunction
are n-ary instead of binary mostly because they are in smtlib (and
that is subsumes the binary case). *)valapply:?loc:location->t->tlist->t(** Application constructor, seen as higher order application
rather than first-order application for the following reasons:
being able to parse tptp's THF, having location attached
to function symbols. *)valite:?loc:location->t->t->t->t(** Conditional constructor, both for first-order terms and propositions.
Used in the following schema: [ite condition then_branch else_branch]. *)valmatch_:?loc:location->t->(t*t)list->t(** Pattern matching. The first term is the term to match,
and each tuple in the list is a match case, which is a pair
of a pattern and a match branch. *)valpi:?loc:location->tlist->t->tvalletin:?loc:location->tlist->t->tvalforall:?loc:location->tlist->t->tvalexists:?loc:location->tlist->t->tvallambda:?loc:location->tlist->t->tvalchoice:?loc:location->tlist->t->tvaldescription:?loc:location->tlist->t->t(** Binders for variables. Takes a list of terms as first argument
for simplicity, the lists will almost always be a list of variables,
optionally typed using the [colon] term constructor.
- Pi is the polymorphic type quantification, for instance
the polymorphic identity function has type: "Pi alpha. alpha -> alpha"
- Letin is local binding, takes a list of equality of equivalences
whose left hand-side is a variable.
- Forall is universal quantification
- Exists is existential quantification
- Lambda is used for function construction
- Choice is the choice operator, also called indefinite description, or
also epsilon terms, i.e "Choice x. p(x)" is one "x" such that "p(x)"
is true.
- Description is the definite description, i.e "Description x. p(x)"
is the {b only} "x" that satisfies p.
*)(** {3 Type constructors} *)valarrow:?loc:location->t->t->t(** Function type constructor, for curryfied functions. Functions
that takes multiple arguments in first-order terms (and so
naturally not curryfied) will take a product as only argument
(see the following [product] function). *)valproduct:?loc:location->t->t->t(** Product type constructor, used for instance in the types of
functions that takes multiple arguments in a non-curry way. *)valunion:?loc:location->t->t->t(** Union type constructor, currently used in tptp's THF format. *)valsubtype:?loc:location->t->t->t(** Subtype relation for types. *)(** {3 Arithmetic constructors} *)valuminus:?loc:location->t->t(** Arithmetic unary minus. *)valadd:?loc:location->t->t->t(** Arithmetic addition. *)valsub:?loc:location->t->t->t(** Arithmetic substraction. *)valmult:?loc:location->t->t->t(** Arithmetic multiplication. *)vallt:?loc:location->t->t->t(** Arithmetic "lesser than" comparison (strict). *)valleq:?loc:location->t->t->t(** Arithmetic "lesser or equal" comparison. *)valgt:?loc:location->t->t->t(** Arithmetic "greater than" comparison (strict). *)valgeq:?loc:location->t->t->t(** Arithmetic "greater or equal" comparison. *)(** {3 Special constructions} *)valquoted:?loc:location->string->t(** Create an attribute from a quoted string (in Zf). *)valsequent:?loc:location->tlist->tlist->t(** Sequents as terms *)valannot:?loc:location->t->tlist->t(** Attach a list of attributes (also called annotations) to a term. Attributes
have no logical meaning (they can be safely ignored), but may serve to give
hints or meta-information. *)valsexpr:?loc:location->tlist->t(** S-expressions (for smtlib attributes), should probably be related
to the [data_t] term. *)end