5. Simple infix expressions and equations

The following cmavo are discussed in this section:

     du      GOhA    equals
     su'i    VUhU    plus
     vu'u    VUhU    minus
     pi'i    VUhU    times
     te'a    VUhU    raised to the power
     ny.     BY      letter “n”
     vei     VEI     left parenthesis
     ve'o    VEhO    right parenthesis

Let us begin at the beginning: one plus one equals two. In Lojban, that sentence translates to:

5.1)   li pa su'i pa du li re
       The-number one plus one equals the-number two.
       1 + 1 = 2
Example 5.1, a mekso sentence, is a regular Lojban bridi that exploits mekso features. “du” is the predicate meaning “x1 is mathematically equal to x2”. It is a cmavo for conciseness, but it has the same grammatical uses as any brivla. Outside mathematical contexts, “du” means “x1 is identical with x2” or “x1 is the same object as x2”.

The cmavo “li” is the number article. It is required whenever a sentence talks about numbers as numbers, as opposed to using numbers to quantify things. For example:

5.2)   le ci prenu
       the three persons
requires no “li” article, because the “ci” is being used to specify the number of “prenu”. However, the sentence
5.3)   levi sfani cu grake li ci
       This fly masses-in-grams the-number three.
       This fly has a mass of 3 grams.
requires “li” because “ci” is being used as a sumti. Note that this is the way in which measurements are stated in Lojban: all the predicates for units of length, mass, temperature, and so on have the measured object as the first place and a number as the second place. Using “li” for “le” in Example 5.2 would produce
5.4)   li ci prenu
       The-number 3 is-a-person.
which is grammatical but nonsensical: numbers are not persons.

The cmavo “su'i” belongs to selma'o VUhU, which is composed of mathematical operators, and means “addition”. As mentioned before, it is distinct from “ma'u” which means the positive sign as an indication of a positive number:

5.5)   li ma'u pa su'i ni'u pa du li no
       The-number positive-sign one plus negative-sign one equals the-number zero.
       +1 + -1 = 0

Of course, it is legal to have complex mekso on both sides of “du”:

5.6)   li mu su'i pa du li ci su'i ci
       The-number five plus one equals the-number three plus three.
       5 + 1 = 3 + 3
Why don’t we say “li mu su'i li pa” rather than just “li mu su'i pa”? The answer is that VUhU operators connect mekso operands (numbers, in Example 5.6), not general sumti. “li” is used to make the entire mekso into a sumti, which then plays the roles applicable to other sumti: in Example 5.6, filling the places of a bridi

By default, Lojban mathematics is like simple calculator mathematics: there is no notion of “operator precedence”. Consider the following example, where “pi'i” means “times”, the multiplication operator:

5.7)   li ci su'i vo pi'i mu du li reci
       The-number three plus four times five equals the-number two-three.
       3 + 4 × 5 = 23
Is the Lojban version of Example 5.7 true? No! “3 + 4 × 5” is indeed 23, because the usual conventions of mathematics state that multiplication takes precedence over addition; that is, the multiplication “4 × 5” is done first, giving 20, and only then the addition “3 + 20”. But VUhU operators by default are done left to right, like other Lojban grouping, and so a truthful bridi would be:
5.8)   li ci su'i vo pi'i mu du li cimu
       The-number three plus four times five equals the-number three-five.
       3 + 4 × 5 = 35
Here we calculate 3 + 4 first, giving 7, and then calculate 7 × 5 second, leading to the result 35. While possessing the advantage of simplicity, this result violates the design goal of matching the standards of mathematics. What can be done?

There are three solutions, all of which will probably be used to some degree. The first solution is to ignore the problem. People will say “li ci su'i vo pi'i mu” and mean 23 by it, because the notion that multiplication takes precedence over addition is too deeply ingrained to be eradicated by Lojban parsing, which totally ignores semantics. This convention essentially allows semantics to dominate syntax in this one area.

(Why not hard-wire the precedences into the grammar, as is done in computer programming languages? Essentially because there are too many operators, known and unknown, with levels of precedence that vary according to usage. The programming language ’C’ has 13 levels of precedence, and its list of operators is not even extensible. For Lojban this approach is just not practical. In addition, hard-wired precedence could not be overridden in mathematical systems such as spreadsheets where the conventions are different.)

The second solution is to use explicit means to specify the precedence of operators. This approach is fully general, but clumsy, and will be explained in Section 20.

The third solution is simple but not very general. When an operator is prefixed with the cmavo “bi'e” (of selma'o BIhE), it becomes automatically of higher precedence than other operators not so prefixed. Thus,

5.9)   li ci su'i vo bi'e pi'i mu du li reci
       The-number three plus four-times-five equals the-number two-three.
       3 + 4 × 5 = 23
is a truthful Lojban bridi. If more than one operator has a “bi'e” prefix, grouping is from the right; multiple “bi'e” prefixes on a single operator are not allowed.

In addition, of course, Lojban has the mathematical parentheses “vei” and “ve'o”, which can be used just like their written equivalents “(” and “)” to group expressions in any way desired:

5.10)  li vei ny. su'i pa ve'o pi'i vei ny. su'i pa [ve'o] du
            li ny. [bi'e] te'a re su'i re bi'e pi'i ny. su'i pa
       The-number (“n” plus one) times (“n” plus one)
            equals the-number n-power-two plus two-times-“n” plus 1.
       (n + 1)(n + 1) = n2 + 2n + 1
There are several new usages in Example 5.10: “te'a” means “raised to the power”, and we also see the use of the lerfu word “ny”, representing the letter “n”. In mekso, letters stand for just what they do in ordinary mathematics: variables. The parser will accept a string of lerfu words (called a “lerfu string”) as the equivalent of a single lerfu word, in agreement with computer-science conventions; “abc” is a single variable, not the equivalent of “a × b × c”. (Of course, a local convention could state that the value of a variable like “abc”, with a multi-lerfu name, was equal to the values of the variables “a”, “b”, and “c” multiplied together.)

The explicit operator “pi'i” is required in the Lojban verbal form whereas multiplication is implicit in the symbolic form. Note that “ve'o” (the right parenthesis) is an elidable terminator: the first use of it in Example 5.10 is required, but the second use (marked by square brackets) could be elided. Additionally, the first “bi'e” (also marked by square brackets) is not necessary to get the proper grouping, but it is included here for symmetry with the other one.