Go up to 2.3 Predicate Logic Go forward to 2.3.2 Atomic Formulas |
The meaning of a term therefore depends on the domain; changing the domain also changes the meaning of a term.
Operational Interpretation In the Logic Evaluator, every term is an instance of a Java class that implements the following interface:
public interface Term { Value eval() throws EvalException; }
For every Term
t, the evaluation of t.eval()
returns the value denoted by t (or throws an exception if some error
has occurred).
A variable assignment (Zuweisung, Belegung) maps every variable to a value of the domain.
The value of a variable therefore depends on a given assignment, e.g. the assignment [x |-> "one", y |-> "two"] on the domain of natural numbers maps the variable y to the value "two".
Please note that variables may be only mapped to values, i.e., to first order objects (Objekte erster Ordnung), not to relations or functions, i.e., to higher order objects (Objekte höherer Ordnung). The version of predicate logic that imposes this restriction is called first order predicate logic (Prädikatenlogik erster Stufe). As we will see in Chapter Sets, we can encode functions and relations as first order objects, such that this restriction does not limit the expressiveness of the language from the practical point of view.
We call a function constant of arity 0 an object constant (Objektkonstante).
We use the notion name for any combination of characters ("x_2") or symbols ("sqrt( )"). Since both variables and function constants are names, we apply in this document the syntactic convention that only names starting with the letters x, y, z denote variables (unless explicitly stated otherwise).
Terms are then constructed as follows.
fc(t0, ..., tn-1)is a term, called an elementary term (elementarer Term) or function application (Funktionsanwendung).
Terms do not necessarily appear in the "standard form" denoted above but they may appear in various syntactic formats.
the roof of the house of her fathercan be written in prefix form as
roof(house(father(she)))with function constants "roof", "house", "father" and a variable "she".
x + (y + 0).In the domain "natural numbers" with object constant 0 interpreted as the number "zero", the function constant + interpreted as addition and under the variable assignment [x |-> 1, y |-> 2], the value of this term is the number "three". However, under the variable assignment [x |-> 1, y |-> 0], its meaning is "one".
In the domain "character strings" with object constant 0 interpreted as the empty string, the function constant + interpreted as string concatenation and under the variable assignment [x |-> "hi, ", y |-> "babe"], the value of the term is "hi, babe".
The Logic Evaluator has the domain "natural numbers" builtin with object
constants 0
, 1
, ...and function constants
+
and *
. Since terms must be entered always in prefix notation,
terms can be evaluated as follows:
Operational Interpretation Elementary terms are implemented by the following Java class:
The Java termpublic final class Application implements Term { private String name; private Term[] arguments; public Application(String _name, Term[] _arguments) { name = _name; arguments = _arguments; } public Value eval() throws EvalException { Function function = Model.getFunction(name, arguments.length); if (function == null) throw new EvalException("unknown function " + name + "/" + arguments.length); Value[] values = new Value[arguments.length]; for (int i=0; i< values.length; i++) values[i] = arguments[i].eval(); return function.apply(values); } }
new Application(f, args).eval()
evaluates to the meaning of the term f(args) (where f
is a function constant and args is the list of arguments). As one
can see, first we determine the interpretation function of the function
constant in the given domain (Model
), then we evaluate the arguments
and apply the function to the results.
The operational interpretation of variables will be explained in Section Quantified Formulas.