Dolmen_std.TermSourceStandard implementation of terms
type builtin = | WildcardWildcard symbol, i.e placeholder for an expression to be inferred, typically during type-checking.
*)| TtypeBuiltin symbol for the type of Types.
*)| PropBuiltin symbol for the type of propositions.
*)| TrueThe true propositional constant.
| FalseThe false propositional constant.
| EqShould all arguments be pariwise equal ?
*)| DistinctShould all arguments be pairwise distinct ?
*)| IteCondional, usually applied to 3 terms (the condition, the then branch and the else branch).
*)| SequentSequent as term, usually takes two argument (left side, and right side of the sequent), which are respectively a conjunction and a disjunction of propositional formulas.
*)| IntBuiltin integer type. Currently specific to Zipperposition format; other languages might use constants with pre-defined name, such as tptp's "$int".
*)| MinusArithmetic unary minus.
*)| AddArithmetic addition.
*)| SubArithmetic substraction.
*)| MultArithmetic multiplication.
*)| LtArithmetic "less than" comparison (strict).
*)| LeqArithmetic "lesser or equal" comparison.
*)| GtArithmetic "greater than" comparison.
*)| GeqArithmetic "greater or equal" comparison.
*)| SubtypeSubtyping relation
*)| ProductProduct type constructor
*)| UnionUnion type constructor
*)| NotPropositional negation
*)| AndPropositional conjunction
*)| OrPropositional disjunction
*)| NandPropositional not-and connective
*)| XorPropositional exclusive disjunction
*)| NorPropositional not-or
*)| ImplyPropositional implication
*)| ImpliedPropositional left implication (i.e implication with reversed arguments).
*)| EquivPropositional equivalence
*)The type of builtins symbols for terms. Some languages have specific syntax for logical connectives (tptp's'&&' or '||' for isntance) whereas some (smtlib for instance) don't and treat them as constants.
type binder = | AllUniversal quantification. Each term in the list of quantified terms should represent a variable (optionnally typed using the Colon constructor.
| ExExistencial quantification Each term in the list of quantified terms should represent a variable (optionnally typed using the Colon constructor.
| PiPolymorphic type quantification in function type Each term in the list of quantified terms should represent a variable (optionnally typed using the Colon constructor.
| ArrowThe arrow binder, for function types. Allows for curified types, if wanted.
*)| LetLet bindings (either propositional or for terms). Term boud by a let can have many forms depending on the language, but usual shapes are:
Eq) between a variable (optionnally typed using the Colon constructor), and a term (e.g. in tptp)Equiv) between a variable (optionnally typed using the Colon constructor), and a term/proposition (e.g. in tptp)Colon constructor (e.g. in smtlib)| FunLambda, i.e function abstraction binder. Boud terms are the variables bound by the lambda, optionnally typed using the Colon constructor.
| ChoiceIndefinite description, or epsilon terms. Likely to have its usual shape change fllowing tptp's recent changes.
*)| DescriptionDefinite description. Likely to have its usual shape change fllowing tptp's recent changes.
*)The type of binders, these are pretty much always builtin in all languages.
type descr = | Symbol of Id.tConstants, variables, etc... any string-identified non-builtin atomic term.
*)| Builtin of builtinPredefined builtins, i.e constants with lexical or syntaxic defintion in the source language.
*)| Colon of t * tJuxtaposition of terms, usually used to annotate a term with its type (for quantified variables, functions arguments, etc...).
*)| App of t * t listHigher-order application
*)| Binder of binder * t list * t| Match of t * (t * t) listPattern matching, the list contains tuples of the form (pattern,branch).
The AST for terms
The type of terms. A record containing an optional location, and a description of the term.
Printing functionson buffer and formatters.
Include the Logic interface. This interface defines almost all term building functions that you may want to use.
include Dolmen_intf.Term.Logic
with type t := t
and type id := Id.t
and type location := locationThe terms representing equality and disequality, respectively.
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.
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.
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") .
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).
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).
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".
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).
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.
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.
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\""
Constructors for words defined as numeric formats by the languages specifications. These also can be safely aliased to const.
Represents juxtaposition of two terms, usually denoted "t : t'" in most languages, and mainly used to annotated terms with their supposed, or defined, type.
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).
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.
Conditional constructor, both for first-order terms and propositions. Used in the following schema: ite condition then_branch else_branch.
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.
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.
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).
Product type constructor, used for instance in the types of functions that takes multiple arguments in a non-curry way.
Union type constructor, currently used in tptp's THF format.
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.
Return the list of free variables (i.e currently, Ids that are in the Var namespace).
add_attr attr term rturns a term t equal to term, but with attr added to the list of attributes.
Set the given list of terms as th attributes of the given term. Will fail (with an assertion) if the given term already have some assertion. In such cases, use add_attr instead.
The main use of terms mapper is to map fuctions over some terms. Traditionally, a mapping will usually only care about a few syntax cases and leav all other untouched. In these cases, it is useful to override the identity mapper, redefining only the fields needed.
type 'a mapper = {symbol : 'a mapper -> attr:t list -> loc:location option -> Id.t -> 'a;builtin : 'a mapper -> attr:t list -> loc:location option -> builtin -> 'a;colon : 'a mapper -> attr:t list -> loc:location option -> t -> t -> 'a;app : 'a mapper -> attr:t list -> loc:location option -> t -> t list -> 'a;binder : 'a mapper ->
attr:t list ->
loc:location option ->
binder ->
t list ->
t ->
'a;pmatch : 'a mapper ->
attr:t list ->
loc:location option ->
t ->
(t * t) list ->
'a;}The type of a mapper on terms.