6. Forethought operators (Polish notation, functions)

The following cmavo are discussed in this section:

     boi     BOI     numeral/lerfu string terminator
     va'a    VUhU    negation/additive inverse
     pe'o    PEhO    forethought flag
     ku'e    KUhE    forethought terminator
     py.     BY      letter “p”
     xy.     BY      letter “x”
     zy.     BY      letter “z”
     ma'o    MAhO    convert operand to operator
     fy.     BY      letter “f”

The infix form explained so far is reasonable for many purposes, but it is limited and rigid. It works smoothly only where all operators have exactly two operands, and where precedences can either be assumed from context or are limited to just two levels, with some help from parentheses.

But there are many operators which do not have two operands, or which have a variable number of operands. The preferred form of expression in such cases is the use of “forethought operators”, also known as Polish notation. In this style of writing mathematics, the operator comes first and the operands afterwards:

6.1)   li su'i paboi reboi ci[boi] du li xa
       The-number the-sum-of one two three equals the-number six.
       sum(1,2,3) = 6
Note that the normally elidable number terminator “boi” is required after “pa” and “re” because otherwise the reading would be “pareci” = 123. It is not required after “ci” but is inserted here in brackets for the sake of symmetry. The only time “boi” is required is, as in Example 6.1, when there are two consecutive numbers or lerfu strings.

Forethought mekso can use any number of operands, in Example 6.1, three. How do we know how many operands there are in ambiguous circumstances? The usual Lojban solution is employed: an elidable terminator, namely “ku'e”. Here is an example:

6.2)   li py. su'i va'a ny. ku'e su'i zy du li xy.
       The-number “p” plus negative-of(“n”) plus “z” equals the-number “x”.
       p + -n + z = x
where we know that “va'a” is a forethought operator because there is no operand preceding it.

“va'a” is the numerical negation operator, of selma'o VUhU. In contrast, “vu'u” is not used for numerical negation, but only for subtraction, as it always has two or more operands. Do not confuse “va'a” and “vu'u”, which are operators, with “ni'u”, which is part of a number.

In Example 6.2, the operator “va'a” and the terminator “ku'e” serve in effect as parentheses. (The regular parentheses “vei” and “ve'o” are NOT used for this purpose.) If the “ku'e” were omitted, the “su'i zy” would be swallowed up by the “va'a” forethought operator, which would then appear to have two operands, “ny” and “su'i zy.”, where the latter is also a forethought expression.

Forethought mekso is also useful for matching standard functional notation. How do we represent “z = f(x)”? The answer is:

6.3)   li zy du li ma'o fy.boi xy.
       The-number z equals the-number the-operator f x.
       z = f(x)
Again, no parentheses are used. The construct “ma'o fy.boi” is the equivalent of an operator, and appears in forethought here (although it could also be used as a regular infix operator). In mathematics, letters sometimes mean functions and sometimes mean variables, with only the context to tell which. Lojban chooses to accept the variable interpretation as the default, and uses the special flag “ma'o” to mark a lerfu string as an operator. The cmavo “xy.” and “zy.” are variables, but “fy.” is an operator (a function) because “ma'o” marks it as such. The “boi” is required because otherwise the “xy.” would look like part of the operator name. (The use of “ma'o” can be generalized from lerfu strings to any mekso operand: see Section 21.)

When using forethought mekso, the optional marker “pe'o” may be placed in front of the operator. This usage can help avoid confusion by providing clearly marked “pe'o” and “ku'e” pairs to delimit the operand list. Examples 6.1 to 6.3, respectively, with explicit “pe'o” and “ku'e”:

6.4)   li pe'o su'i paboi reboi ciboi ku'e du li xa

6.5)   li py. su'i pe'o va'a ny. ku'e su'i zy du li xy.

6.6)   li zy du li pe'o ma'o fy.boi xy. ku'e

Note: When using forethought mekso, be sure that the operands really are operands: they cannot contain regular infix expressions unless parenthesized with “vei” and “ve'o”. An earlier version of the complex Example 17.6 came to grief because I forgot this rule.