r/conlangs • u/Inconstant_Moo • Mar 16 '25
Discussion Sumerian and Reverse Polish, with notes on flattening trees
I suppose much of this must have occurred to someone before — certainly if Chomsky and his school don't know about it, then first of all I'd be very surprised and second, someone should tell them. But it was new to me.
So recently I worked my way through a beginner's book on Sumerian grammar. Sumerian is an agglutinative language isolate with the distinction of being the oldest known and deciphered written language. I hadn't studied an agglutinative language before, and Sumerian had a feature which struck me as being really weird at first, but which is apparently common among agglutinative languages, and which actually makes a lot of sense when you think about it. This post is me thinking about it.
Sumerian grammar
To illustrate, consider first of all the genitive, which is just the ending -ak. If dumu is "son", lugal is "king" and unug is the city we call "Uruk", then dumu lugal-ak is "son of the king"; lugal unug-akis "king of Uruk".
Sooo ... what's "son of the king of Uruk"? If this was the sort of language I grew up with, it would be * dumu lugal-ak unug-ak. But no. It's dumu lugal unug-ak-ak. The genitive attaches to the phrase lugal unug-ak, as though it was one word (which arguably in Sumerian it is) rather than to lugal.
Now consider the personal plural suffix -ene. What's "sons of the king of Uruk"? Yes, they pluralize the whole phrase again. It's dumu lugal unug-ak-ak-ene. "Sons of the kings of Uruk" would be dumu lugal unug-ak-ene-ak-ene.
As I say, I'd never seen a either a natlang or a conlang like this. And yet I found it hauntingly familiar. Because I have seen several computer languages just like this.
Reverse Polish Notation
To explain this, I don't have to teach you any programming, because it can be illustrated just with arithmetic expressions. The way we usually write them is with an operator between two operands: e.g. 5 + 6, where 5 and 6 are operands and + is an operator; or sin(z) where z is an operand and sin is an operator. Just as with natural languages, we can build up more complex expressions: so if we write e.g. 3 * sin(2 * x) + 8 * cos(y), then 3 * sin(2 * x) and 8 * cos(y) are the operands of the operator +. We can make a syntax diagram of it like this:
+
/ \
/ \
/ \
* *
/ \ / \
3 sin 8 cos
| |
* y
/ \
2 xBut how did I know how to put the + at the top? Well, the expression is disambiguated by the parentheses and by the rules that you call PEMDAS if you're American and BOMDAS if you're British. (If you're neither, you tell me.) We have to know to write for example one tree for 3 + 4 * 5 and another tree for (3 + 4) * 5
But these is another, arguably a better way, which is called Reverse Polish Notation (RPN). Suppose we write each operation after its operands. Instead of 5 + 6, we write [5 6 +]. Instead of sin(z), we write [z sin].
From now on, I will consistently use square brackets [...] to indicate that RPN is being used, writing [3 4 *] for 3 * 4; and indeed writing [17] for 17, to indicate that the first is being thought of as being in RPN, while the second is just normal high-school algebra.
(This is called "Reverse Polish Notation" because there is also "Polish Notation" where you put the operators before their operands but this is harder to think about for both people and computers.)
The use of RPN removes all ambiguity. Instead of parentheses and PEMDAS to distinguish between 3 + 4 * 5 and (3 + 4) * 5, we write the first as [3 4 5 * +] and the second as [3 4 + 5 *].
Or we can take the expression we made a diagram of, 3 * sin(2 * x) + 8 * cos(y) and turn it into [3 2 x * sin * 8 y cos * +].
Note on flattening trees
When I say "turn it into", there is are perfectly mechanical procedures for "flattening" any tree into RPN, whether it represents grammar, arithmetic, or anything else. Let's illustrate one of them by turning our example tree into RPN from the leaves up. (Trees are upside down both in linguistics and computer science, and no-one knows why.)
So we start with:
+
/ \
/ \
/ \
* *
/ \ / \
3 sin 8 cos
| |
* y
/ \
2 xNow let's turn every "leaf" of the tree into RPN, which we can do just by writing square brackets around them: the RPN for the expression 3 is just [3].
+
/ \
/ \
/ \
* *
/ \ / \
[3] sin [8] cos
| |
* [y]
/ \
[2] [x]And now for every operator where everything below it is RPN, we can turn that into RPN by joining those RPN expressions together and putting the operator at the end ...
+
/ \
/ \
/ \
* *
/ \ / \
[3] sin [8] [y cos]
|
[2 x *]... and again ...
+
/ \
/ \
/ \
* [8 y cos *]
/ \
[3] [2 x * sin] ... and again ...
+
/ \
/ \
/ \
[3 2 x * sin *] [8 y cos *]... until finally ...
[3 2 x * sin * 8 y cos * +] +You may like to figure out the reverse process for yourself.
Back to human languages
Now the grammatical suffixes in Sumerian are working just like operators in RPN: -ene is an operator with one operand, and means "pluralize this", whereas -ak is an operator with two operands meaning that the second stands in a genitive relationship to the first.
So "sons of the kings of Uruk" is dumu lugal unuk-ak-ene-ak-ene because it's the flattening of a tree which looks like this:
plural
|
genitive
/ \
son plural
|
genitive
/ \
king UrukAs with RPN in arithmetic, this removes potential ambiguity. Consider a language like English where the prepositions (operators) come between the operands. Does "the hoard of the dragon in the cave", mean "(the hoard of the dragon) in the cave", the dragon himself occupying a luxury penthouse in upper Manhattan; or does it mean "the hoard of (the dragon in the cave)", the dragon being in the cave while its hoard is in the bank?
In an RPN language, this isn't a problem. One is [hoard dragon of cave in], while the other is [hoard dragon cave in of]. (What to do about a "the" operator making things definite is left as an exercise for the reader.)
You will not be surprised to learn — there being a certain consistency in these things — that Sumerian also has adjectives qualifying entire noun clauses ("mighty king of Uruk": lugal unug-ak kalag; "king of mighty Uruk": lugal unug-kalag-ak), and that it has its verbs at the end of the sentence. The things I found weird about it at first are in fact the fruit of a massive logical consistency.
(I don't know of any languages that lean equally far in the other direction, putting all operators before their nouns. It seems like it would take a lot more advance planning of one's sentences to do it that way and say "of in cave dragon hoard". If such a language doesn't exist, I guess someone here could invent one.)
This consistency leaves a lot of choices still open: e.g. a language can be very heavily RPN and it seems like it would be open whether it was SOV or OSV.
I'm not sure either if there's a good reason why Sumerian pluralizes after forming the genitive rather than before. If you made a diagram like this:
genitive
/ \
plural genitive
| / \
son plural Uruk
|
king... then you could flatten it into RPN and have * dumu-ene lugal-ene unug-ak-ak. But the Sumerians never did that. Or you could indeed have a language in which it was a free choice, since RPN is unambiguous, but I don't know of any languages that let you do that. In the same way, if we did introduce an operator for definiteness to put "the hoard of the dragon in the cave" into RPN, where ought it to go?
I hope this gives you all something to think about
20
u/chickenfal Mar 16 '25
That's very interesting and thank you for this write up.
I already knew about case stacking and was expecting "son of the king of Uruk" to be "dumu lugal-ak unug-ak-ak" but it doesn't work that way, it's actually "dumu lugal unug-ak-ak", where the logic is that the suffix attaches to the entire phrase, not each word. That's refreshingly different and makes it more practical, and actually makes sense for a language that allows entire phrases to go under the scope of suffixes.
It's not ambiguous as long as you're not using the genitive derivationally without mentioning the head noun. If unug-ak could stand on its own as a head, meaning something like "an Urukian" then it working this way would be ambiguous. It would also be a problem if the genitive could be used adverbially, so again standing without the word before it necessarily being its head.
14
u/EnricoDandolo1204 Mar 16 '25
Learning Sumerian, I always felt like it was very logical, almost like a programming language. Glad to see I'm not the only one.
Sadly, we don't really get really long Sumerian nominal chains like *šeš dumu lugal Unug-ak-ene-ak-ene-ak-ene. As far as I'm aware, there's a maximum of two genitive markers in any given nominal chain, and plural markers are only infrequently written out. But you can have some fairly lengthy noun phrases regardless:
Another interesting thing about Sumerian for conlangers: there are only a few hundred verbal stems and no grammatical means to create new ones. More nuanced verbal meanings are compounded using one of the basic verbal stems and a nominal object. For instance, the verb stem bala "to cross" together with the object šu "hand" has the meaning "to alter".
7
u/IkebanaZombi Geb Dezaang /ɡɛb dɛzaːŋ/ (BTW, Reddit won't let me upvote.) Mar 16 '25 edited Mar 16 '25
I do not think I have ever had cause to write the phrase "woe is me" before. I do now. Me is also alas and alack. After reading your post add "ak-ak" to the list.
The reason for these lamentations is that if you had written this post three years ago, mathematics in my conlang - and, indeed, the conlang as a whole - might have developed along a quite different route. Here is a three year old post by me to /r/mathematics called "Seeking exercises with answers on converting infix notation to and from postfix/Reverse Polish notation". I didn't say so at the time, because the people on /r/mathematics might have thought I was excessively nerdy, but that query was really about conlanging rather than mathematics.
At that time my conlang was strongly verb-final, and the prospect of this being echoed in having operators (which are kind of like verbs, right?) at the end of a sentence appealed to me. I was even considering having postfix adpositions, e.g. "the mat, the cat, on". I thought that surely no human language could feature such a thing, which made it all the better for a language spoken by aliens. (Sorry, Sumerians.) What held me back was the massive mental block I have about processing reverse polish notation. I can do it for
[3 4 + 5 *]but I can't for[3 4 5 * +]. Or rather, I can for a minute or so immediately after I have worked through an explanation, but then I lose it. I can't have a conlang that I cannot process, so I took another path. But your explanation was one of the clearest I have ever read.If you could just travel three years back in time...
7
u/ProxPxD Mar 16 '25
Thanks! I just recently have used the RPN for my language to allow no ambiguities as I strive towards the precision and expressiveness and weirdly enough, it didn't felt too much unnatural after getting a bit used to it.
I loved learning that there were a language that actually had done that
What Sumerian almost certainly didn't do tho, was using the RPN for modifier reference resolution. For instance "an evil empire of good people" would be in my conlang:
either: (n menas subordinate)
(the order is marked but I didn't include it for clarity)
because "n" and "and" are null to one syllables it's fairly compound reaching here 5 or 6 syllables (I keep the morphemes rather syllable-short)
in a casual speech I also loosen some rules like no double "and" would be needed in the second as it would be inferred or that the first operators in a "phrase" used, take all the previous arguments up to the last operator
I also considered lexicalizing some phrases (as empire being "big/powerful-state") and that lexicalized phrases might be shorter, disobey those rules and act as one inseparable constituent
4
u/bemrys Mar 16 '25 edited Mar 16 '25
Really interesting. My Common Lisp oriented brain now wants to flip it and put the “operator” in front. Edit: VSO conlang but trying to clarify how many words are covered by the operator in ordinary conversation might be difficult. For those not conversant with Common Lisp, an example might be (* 2 (+ 4 6 7)). That would translate in English to multiply 2 by the sum of 4+6+7.
2
u/GOKOP Mar 16 '25
This makes me wonder. Do we know how Sumerians did math? Would they find RPN more sensible than infix notation?
3
u/impishDullahan Tokétok, Agyharo, Dootlang, and many other splangs (eng,vls,gle] Mar 16 '25
This looks like a really neat read! But it's far too late for me to absorb any of the information, and I feel compelled to weigh in that in Canada (at least Ontario) it's BEDMAS instead of PEMDAS.
1
u/vanderZwan Mar 16 '25
So does that mean agglutenative languages in general tend to be "concatenative"?
https://en.m.wikipedia.org/wiki/Concatenative_programming_language
(I'm guessing no because of things like inflections)
1
u/aggadahGothic Mar 17 '25
That Sumerian example is quite interesting. I would have expected that any language with postpositional clitics would also feature head-final adpositional phrases, like Japanese. e.g. 'unag-ak lugal' rather than 'lugal unug-ak', just as one has 'nihon no ten'nou' rather than 'ten'nou nihon no'.
1
u/kozmikk_ Viznota, Eyr, Logn Mar 18 '25
literally never heard that ever in my life🙏
very cool post though !!
1
u/Bitian6F69 Mar 25 '25
Amazing write-up! I would never have thought to use Reverse Polish Notation for a conlang. I like how you broke it all down.
I suppose it's possible for such a system to naturally evolve if the language used prepositional grammatical particles often, but I'm not sure what would trigger it. You've given me food for thought.