Phil 455: More on Strings and Languages

We talked about atomic strings, which can’t be dissected further into two non-empty components as xs ⁀ ys. Such atomic strings have length 1, and we’ve also adopted the convention of calling them “letters.”

When introducing strings, we also talked about an alphabet which is the set of possible elements that strings are sequences of. We assume this set to be non-empty but finite. Some formal discussions call these elements “letters” or “characters,” but that’s just a label for the role they’re playing in the formal system. As we said, these elements don’t have to be characters of the Latin alphabet; they could also be emoji symbols, or English words, or numbers, or planets. Generally it’s a good idea not to conflate the elements of the alphabet with the atomic string/sequence made of one of them. The fact that “letters” is sometimes used as a label for one, sometimes for the other, shouldn’t encourage you to think they’re the same. For example, the number 37 is a number not a sequence. (It’s not the same as the string made from two digits, that’s just how we write the number. The number 37 is identical to the number thirty-seven is identical to the number siebenunddreißig is identical to the number xxxvii, but none of those four strings I just used to designate the number are identical to each other.) If we treat the number 37 as part of an alphabet, then the atomic string/sequence [37] made of it would be something different. It’s a sequence of length 1, not a number. (Here I’m using the [37, 4, 0, ...] notation for sequences, rather than the "blah blah" notation we used when the elements of our alphabet were characters from the Latin alphabet.)

All that said, some formal discussions do equate elements of the alphabet with length 1 strings, because for their purposes it does no harm and it can simplify some things. We’ll see a lot of these kind of equatings-that-do-no-harm-and-can-simplify-things as we go along. They’re bad for your conceptual hygiene, so I will try to call attention to them. But they come up everywhere in this discipline.

I haven’t provided any notation for referring to specific Latin characters themselves. I think we can get by without needing to do that. We’ll see. I could always say something like “the Latin character that the string "a" is made of.”

Sometimes we’ll talk about languages. We’ll introduce these more rigorously later, but the basic idea is that a language is a set of strings. So far, we’re thinking about all of the strings that could be made from a given alphabet. (This is called the “free monoid” over that alphabet. We’ll learn what those words mean in later classes.) But at some point, we’ll get more restrictive, and differentiate between some strings that the language counts as acceptable and others that it excludes. For instance, the language English contains the string "the mouse eats cheese", but doesn’t include the string "cheese the eats" or the string "sdkjsdk". When working with the languages of first-order logic, we’d want to include strings like "(Fa ∨ ∃y Rxy)" but exclude strings like "∨ ∃y". We’ll talk about how to do that later. For now, we can continue thinking about the languages that include all strings made from a given alphabet.

We said that we’re only thinking about strings/sequences that have a finite length. However, there is in general no upper bound on how long the strings can be. (A particular language that only counts some strings made from its alphabet as acceptable, though, may choose to exclude strings past a given length. But for now, we’re assuming no such restriction.)

Use versus Mention

Earlier on this page I wrote:

The number 37 is identical to the number thirty-seven is identical to the number siebenunddreißig is identical to the number xxxvii, but none of those four strings I just used to designate the number are identical to each other.

Consider the strings 37, thirty-seven, and so on. When I say “the number 37 is identical to the number thirty-seven,” I am using those strings to talk about a number. When I say “those four strings I just used,” I am instead mentioning the strings to talk about them as linguistic expressions, rather than to talk about the number they designate.

It’d be useful if there were always explicit signals about when an expression is being used versus being mentioned. Sometimes you may hear that the way to mention an expression in philosophy, or at least in formal contexts, is to surround it with quotes. There are a couple of problems with this though.

My practice will be to write like this:

when I am mentioning those expressions. Prefixes like “the constant,” “the literal,” and “the variable” indicate I want to designate an expression, so I’m probably mentioning what comes next. (When I want instead to use a variable to designate the expression, I’ll use a different typography, that we’ll introduce later in the course.) Similarly, if I write:

the literal 37

I’m mentioning an expression made of two digits, rather than using it, because to use it would be to designate a number, but literals are a kind of expression, and (in the languages we’re working with), numbers aren’t expressions. 37 is a number literal (it designates a number), whereas "37" is a string literal (it designates a string, in fact the very literal I was just discussing).

On the other hand, I’ll write:

the number 37

and:

when empty is concatenated to xs, the result is "abc"

when I am using the expressions 37 and empty and xs, and xs is assigned the string "abc". If instead you concatenated "empty" to "xs", the result would be "emptyxs".

If I wrote:

the number k

I would have to be using not mentioning the variable k, because that variable itself couldn’t correctly be called a number.

Expressions and their Values

When dealing with any language, there’s some vocabulary it’ll help us to use in a shared, systematic way. Some of the vocabulary is for sorting things out within the language, and other for sorting things out after or past the language, and other for sorting things out before it. What do I mean by “after” and “before” here? Well, consider a language that includes expressions like 37 and n and 37 + n > 128, where n is a variable that gets assigned numbers, and + is understood to express the addition function on natural numbers. We use these expressions to designate or talk about numbers and facts about them. When we’re studying/focusing on a language like this, we call it the object language, because it’s the object of our attention. When we want to talk about the expressions of that language, as we’re doing with the English sentences and formal notation of these webpages, we’re using a metalanguage. It’s “meta” in that it steps back and talks, in part, about the other language. This is what I meant by what’s “before” the object language. (Although, in Greek, the preposition “meta” means “after”. Go figure.) We’re going to want a general word for whatever has the role occupied in this example by numbers and facts about them. I’ll use the term values for this. The values of the object language we’re considering now are numbers and facts about them. By “facts about them”, here, I’ll just mean truth-values. Let’s say that our variable n is assigned the number 1. Then the expression 37 + n would designate the number value 38, and the expression 37 + n > 128 would designate the truth-value false. Those values are what I meant by what’s “after or past” that language.

We have to be careful when the values of our object language themselves can be strings. Talking about this rigorously and not getting confused takes some care. (And more care still if some of them might have themselves as values, for example the expression xs could be understood as a variable that is assigned the string "xs" as its value.)

Recall in last week’s homework near the end we were using single strings to “encode” sequences of strings. In that convention, the string ":abc:def::ghi:", although itself a string of length 14, was understood to encode a sequence of length four, whose first element (“head”) was the string "abc", whose second element was the string "def", whose third element was the empty string, and whose fourth element was the string "ghi". In a case like this, there are more levels than we had previously. One language here includes strings/notation like ":abc:def::ghi:" and xs and empty. When I say “strings/notation” now I am mentioning these symbolisms, where the first one starts with a quotation mark and the second one is made from two letters and the third one of five letters. The first of those was understood as what I’ve been calling a “string literal,” the second what I’ve been calling a “variable,” and the third what I’ve been calling a “constant.” The values of these strings in the language I’m using would be other strings. The value of the first is a string of length 14 (that does not include quotation marks, in fact there might not even be any punctuation besides colons in the alphabet such strings are made from). The value of the second is whatever string the variable xs is assigned. It could be a string of length 2 (it could even be the string "xs"), but it doesn’t need to be and generally it won’t be. It might be the empty string, or it might be the same length 14 string that the string literal designates. Let’s say it’s the last of these. Finally, as we’re understanding the language I’m using, the expression empty always designates the empty string.

As explained above, sometimes I’ve been using the language of this webpage to talk about strings in (what may be) another language. Other times I’ve mentioned or talked about the strings/notation of this webpage itself. Let’s give these languages names. I’ll say that “Stringlish” is the language of these webpages, that I’ve been gradually introducing you to. (You could say that Stringlish includes English as a subpart, or that it’s just the formal-looking stuff on these webpages, and that I’m usually talking in a mix of English and Stringlish. I don’t care.) Stringlish includes quotation marks and other punctuation. The whole string displayed on the next line is part of Stringlish:

length =def { λ empty. 0; λ ys ⁀ xs if letter(ys). 1 + length(xs) }

Let’s call our second language ABCish. We can suppose that ABCish doesn’t include any punctuation except colons. It doesn’t include quotation marks or lambdas or { } brackets. ABCish is the language we use Stringlish to talk about. The three Stringlish expressions I mentioned before — ":abc:def::ghi:" and xs and empty — designate strings of ABCish. The way we’re understanding the Stringlish variable xs, it’s assigned the same ABCish string that the Stringlish literal ":abc:def::ghi:" is. This ABCish string doesn’t include quotation marks. Its first letter is the colon ":".

We’ve been focusing on Stringlish as a language used to say things about ABCish. But we’ve also introduced conventions where we can understand ABCish as a language to say things about other things. (That’s what we’re doing when we say that the ABCish string ":abc:def::ghi:" encodes a sequence of four strings. We’ll get back to this in a moment.) Only when a string is used/interpreted to say something about some values will I call the string an expression. This is a broad term. Expressions can be subdivided into categories like sentences, singular terms, and so on. Singular terms subdivide further into literals, variables, constants, and so on. We’ll talk about this more below. For now, my point is that strings only count as “expressions” (or any of the more specific categories, like “variables”) when they’re playing the role of being used/interpreted to say something.

Returning to an earlier example, we could say that the string "37" (here I am using a Stringlish literal) is an expression that designates the number value 37. We could say that the string "37 + n > 128" (again I’m using a Stringlish literal) is an expression that designates a truth-value. I could also write:

the expressions 37 and 37 + n > 128

There I would be mentioning those expressions, rather than using Stringlish literals to designate them.

Now go back to ":abc:def::ghi:" and xs, where those Stringlish expressions are understood as designating the same ABCish string. We said that we’ve got a convention where this ABCish string could also be used/understood as an expression, this time designating a sequence of four strings (in some language that includes strings like "abc" but doesn’t include colons). The values of this ABCish expression are sequences. The sequences are made up of strings in some language. That language could be a subpart of ABCish, minus the colons. Let’s call it Minnie.

So now we’ve got:

Depending on where we direct our gaze, we could be attending to Stringlish as the metalanguage we use to talk about — whose values include strings in — the object language ABCish. We could be attending instead to ABCish as the language, and be interested in its values, which now are sequences of strings from the language Minnie. If ABCish could talk about individual strings of Minnie (in addition to sequences of them), and if those individual strings of Minnie were expressions talking about something-or-other, then Minnie could be an object language and ABCish could itself be a metalanguage for talking about Minnie. In that case, whether ABCish were the object language (values of Stringlish expressions) or the metalanguage (used to talk about the language Minnie) would be a matter of perspective.

Subdividing Expressions

We said earlier that expressions can be subdivided into categories like sentences, singular terms, and so on; and some of these subdivided further. Let’s start with the category of singular terms. Since we won’t be working with other kinds of terms (plural terms, mass terms), we’ll usually just say terms (as in common in logic literature).

Some subdivisions of terms we’ve already met: there are literals like "abc" and "37" and 37 (the first two being string literals, the last a number literal), and variables like n and xs, and constants like empty. Here I have mentioned six different strings or expressions of Stringlish.

Some variables may be assigned numbers as values, others strings, others yet other values, such as truth-values, or planets, or sequences or trees or sets of various of these other values.

All of the preceding terms are syntactically simple.

Other terms are syntactically complex. These involve applying some operator or functor expression to other terms. One operator/functor expression we’ve looked at is the primitive symbol , expressing the concatenation operation. We’d say that the expression "abc" ⁀ xs applies this symbol to the terms "abc" and xs. (You could also say it applies the concatenation operation to the values those terms designate.) The whole expression "abc" ⁀ xs is an example of a syntactically complex term. Another operator/functor expression we’ve looked at is take. The whole expression take("abc", 2) is another syntactically complex term. (Whereas the operator was taken as a primitive, take was something we defined.) Both of the operator/functors we’ve considered so far take two terms as arguments. So they are called dyadic functors. We understand them to represent operations or functions that take two values as arguments, which are called binary functions. Officially, the dyadic functor is the linguistic expression and the binary function is the value it expresses. Sometimes people (including me) use the words “binary” or “function” also to talk about the linguistic expressions.

Some operators/functors only take a single argument, for example our length and headOf. The whole expression length("abc") is a syntatically complex term that designates the number value 3, and the whole expression headOf(":abc::") is a Stringlish term that designates the Minnie string "abc". We see here that terms can represent values of different types (numbers or strings); we saw this also earlier when we said that variables can be understood as assigned numbers or strings.

Operators/functors that take a single argument are called monadic, and they’re understood to represent unary functions. As with dyadic/binary, sometimes people (including me) use “unary” also to talk about the linguistic expressions.

In some settings people also talk about operators/functors that take no arguments. These are said to represent nullary functions. In this class, we’re not going to be working with the kinds of phenomena where these are useful to have. Sometimes people say that constants like empty can be understood as an application of a functor taking zero arguments to those arguments, as if it were shorthand for empty().

Besides terms, another broad category of expression are predicates. We’ve seen some predicates already in our primitive symbol = and our defined letter. Some predicates like the first take two arguments (and so are also called dyadic), others like the second take one argument (and so are also called monadic). Sometimes dyadic predicates (and predicates of higher -adicities) are called relational predicates, or sometimes just relations. An expression that applies a predicate to the appropriate number of arguments is called a formula or sentence. Thus xs = empty and letter("abc") are sentences. The second sentence is false; whether the first is true or false depends on what value the variable xs is assigned.

In some settings, we also have constants like true and false (the latter is sometimes written ) and/or sentence constants like P, Q, and so on. Some people understand these as predicates taking no arguments.

We’ve been talking about the values expressed by the constants true and false as truth-values. Sometimes these are called “booleans,” after the logician George Boole.

You may have had the thought, what’s the difference between a sentence and an expression that applies a functor to the appropriate number of arguments and thereby designates a truth-value? In many contexts discussing logic and programming languages, there is no use for distinguishing these. So they are commonly equated. That is, a sentence may be understood as a term designating truth-values. (Likewise a predicate may be understood as a functor.) Other times it’s more convenient to keep those apart, so that, for example, what you call “terms” only designate values like numbers or sets of numbers, and never truth-values. It’s a substantial question in the philosophy of language/linguistics whether there is a difference here that we’re just sometimes conveniently ignoring, or whether these really should fundmaentally be understood as the same. In Frege scholarship this question plays an important role. These issues are interesting, but we’re not going to explore them in this class.

(Some of them will be explored further in part of the grad seminar I’ll be teaching in the fall. There one of the questions we’ll be asking is how to think about expressions of different syntactic categories, like “swim,” “swimming,” and “swimmers,” or “beautiful,” “beauty,” and “beauties,” that seem to essentially concern the same thing.)

In the specific language Stringlish we’ve been using, some expressions like dissect hs { λ xs if letter(xs)! 1; λ xs. 0 } had patterns like λ xs as parts. I won’t call pattern “expressions,” but they can be parts of expressions, like this one. A “dissect expression” has one or more clauses like λ xs if letter(xs)! 1. Each clause consists of a pattern followed by an optional guard expression (if followed by a sentence), followed by a period or sequence of !s, followed by a term. The term may designate a truth-value, which terms we’re equating with sentences.

Some strings express definitions in Stringlish, rather than expressions. The Stringlish string:

length =def {
    λ empty. 0;
    λ ys ⁀ xs if letter(ys). 1 + length(xs)
}

isn’t a sentence using the dyadic predicate =. It’s not true or false. It has a different role.

In Stringlish, we had constants like oneVowel that behave both as predicates/functors and as terms, in that they could be arguments to other functors, and what they designated could also be designated by complex term like { λ zs. … }. Languages where predicates/functors can behave in this way as terms, where their values can be assigned to variables, and so on, are called second (or higher) order. Languages that don’t permit that, but that do still distinguish between predicates/functors, on the one hand, and terms on the other, are called first order. (Especially when the terms include variables that can be “bound by” quantifiers.) When the language lacks quantifiers and term variables, but only has sentence constants (sometimes called sentence variables) like P, Q, and so on, it would be called sentential or propositional rather than first-order.

In a first-order language, the values the variables can be assigned may be simple things like numbers or planets. Or they may be “fancier” things like sets or functions or relations or what-not.

Sometimes we talk about values being complex objects. A set is complex in that it has other values as elements; similarly for string/sequence and for trees. The complexity of these objects is orthoganol to whether a simple or complex expression is used to designate them. We can use a syntactically simple expression like xs or a complex expression like "a" ⁀ "bc" to designate the string "abc", which is a complex object. We can use a syntactically simple expression like 38 or a complex expression like 37 + 1 to designate the number 38, which need not be a complex object. (I say “need not be” because in some contexts numbers are equated with certain sets. But it is a substantive and disputed question whether these really shold fundamentally be understood as the same.) Similarly, we can use a syntactically simple expression like Abraham or a complex expression like Issaac's father to designate a person, which is not a complex object in the sense of having the kind of structure that sets or strings/sequences or trees do.