User:Addemf/sandbox/Technical Reasoning/First-order Expressions

First-order Expressions
Consider the sentence,


 * "All cats are mammals, and all mammals are animals."

The propositional analysis that we have studied up to now, would only allow us to abstract this sentence as


 * $$P\land Q$$

That is to say, propositional logic does not have the "expressive power" to capture the notion of objects, and properties of those objects.

Therefore we extend our propositional logic to so-called "first-order" logic, which is capable of representing objects and their properties.

Predicates and Named Objects
To take a very simple example sentence, consider,

"The ball" refers to that unique ball which is "within the domain of discourse". We would like to give it an abstract name. Therefore we may use the abstract constant symbol b to replace "the ball".

We may replace the property "is red", with the symbol R.

As we've seen before, to assert that b has the property R we write $$R(b)$$.

Therefore the abstraction of this sentence is


 * $$R(b)$$

To take another example, this time just a little more complex,

we may abstract this as


 * $$L(r,o)\land \neg L(o,o)$$

using r for "zero", o for "one", and L for "less than".

This demonstrates, by the way, that we do not "lose" any of the propositional analysis from before. Rather we are merely extending the expressive power of our analysis, by taking propositions and decomposing them into statements about objects and their properties.

Arity
It has probably been conspicuous by now that some properties, like "x is a cat", applies only to a single object. Other properties, like "x is less than y", apply to two; others like "y is between x and z" apply to three.

If any property applies to two or more objects, we more often call it a "relation" rather than a "property". However, it is still correct to call relations "properties".

If a property applies to just one object, we call it a "unary property". If it applies to two, then it is a "binary relation"; if it applies to three, it is a "ternary relation".

More generally, if a property applies to n objects, then we call it n-ary. For any property, we call this number n the "arity" of the property.

Big And, Big Or
Suppose that we have a party with 30 people, named $$a_1,\dots,a_{30}$$. Suppose further that the first 12 are men. To express this we could write
 * $$M(a_1)\land M(a_2)\land \cdots\land M(a_{12})$$

This is somewhat cumbersome, it is more compact and convenient to instead write
 * $$\bigwedge_{i=1}^{12}M(a_i)$$

This is, in fact, in a perfect analogy with similar notation used to talk about indexed intersections and unions. The big conjunction, $$\bigwedge$$, indicates that we will join together expressions, with a conjunction between them.

The writing below $$\bigwedge$$, which is $$i=1$$, indicates that i is the index, and it starts at 1. The upper text, 12, indicates the final index value.

After the big conjunction, we write the expressions that are to-be-conjoined, with index i. In this example, the expression to-be-conjoined is $$P(a_i)$$.

Suppose that the people indexed 13 to 30, above, are not men. Write an expression which expresses this.

Consider the sentence

Use $$E(x)$$ to express that object x is an engineer.

Define a notation for "big disjunction", similar to the notation introduced above for big conjunction. Then use it to express the sentence above.

Following the exercise above, express the sentence

Suppose that we would like to state that there is "at most one engineer at the party".

One could accomplish this by effectively saying,

First, suppose that i is any integer $$1\le i\le n$$. Let us express

with the symbolization
 * $$ E(a_i)\to \bigwedge_{j\ne i} \neg E(a_j)$$

We implicitly know that this new index j can only range from 1 to 30, and the subtext says that we further require $$j\ne i$$.

Finally, to express that the party has at most one engineer, we write
 * $$\bigwedge_{i=1}^{30} \left(E(a_i)\to \bigwedge_{j\ne i}\neg E(a_j)\right)$$

Let us express that "x is a friend of y" by the expression $$F(x,y)$$.

Write a sentence for the sentence

Write a sentence for the sentence

Hint: To say that there is exactly one, is simply to say "there is at least one, and at most one". You have already seen now to formalize each of these individually.

Quantifiers
Returning now to the "all cats are mammals" example sentence, let us express "x is a cat" with $$C(x)$$ and "x is a mammal" with $$M(x)$$.

To express that every cat is a mammal, we could take every thing in the universe, and say of it "If this is a cat then it is a mammal."

Imagine giving the name $$a_1$$ to some cat, and then $$a_2$$ to a rock, and then $$a_3$$ to a bowl of fruit.

It is certainly correct to say
 * $$(C(a_1)\to M(a_1))\land(C(a_2)\to M(a_2))\land (C(a_3)\to M(a_3))$$

Explain why the sentence above is true.

We could continue naming all the objects in the universe (in some sense, maybe), and keep adding more conjunctions to the sentence.

But it is much more attractive to instead have a quantifier, which represents a claim that "all things in the universe" satisfy this or that sentence. Therefore we use the "universal quantifier", written as $$\forall$$, to express this.

To say that "all cats are mammals", we write,


 * $$\forall x(C(x)\to M(x))$$

One can read this as saying,

We also have another quantifier, the "existential quantifier", written $$\exists$$. This is used to claim that there is something in the domain, with some property.

For example, we might want to claim that "There exists an even prime number." With E and P representing "even" and "prime" respectively, then we write
 * $$\exists x(E(x)\land P(x))$$

Domain of Discourse
One does, however, have to wonder "What values can x refer to?" Clearly it is intended that x could refer to some cats, in the example above. Possibly it could refer to rocks and bowls of fruit, or more things.

Could it also refer to atoms and subatomic particles? Could it refer to weirder things like the concept of communism, or the experience of seeing blue?

For one thing, we may not want to allow x to range over such a broad spectrum of referents. It might just seem unnatural and possibly problematic.

For another thing, it is a natural practice to have a "domain of discourse". Someone might say that

and they don't mean there are no more tacos in the world. That would obviously be false.

What they mean is "within the relevant area, there are no more tacos". The relevant area might be the room where people are gathered; it might mean the restaurant where people are ordering food.

Often the domain of discourse is determined implicitly, and inferred by the people in the conversation.

Names and Objects
As we become more formal about these notions, we will need to have a distinction between an object in the domain and a name of the object in the domain.

There is clearly a distinction between, say, the person Muhammad Ali, and the name "Muhammad Ali". In fact, the person Cassius Clay, is the same person as Muhammad Ali, even though the names "Cassius Clay" and "Muhammad Ali" are different.

Especially in certain mathematical contexts it will become important to keep this distinction clear, because we will have names for some (but not all) objects with certain domains of discourse. For example, we have a few names of real numbers like $$\sqrt 2$$ and $$\pi$$. But we do not have names for most of the real numbers, even though all of them are within the domain of discourse when talking about real numbers.

To keep the distinction between names and objects clear, we will often write names with Latin letters, like $$a_1$$ and $$a_2$$. On the other hand, when talking about the corresponding objects in the domain, we write the Devanagari character, ए1 and ए2, and so on. The reason for this choice is, for one thing, we have already used up capital and lower-case letters from English. For another thing, this character is pronounced in Devanagari like "eh" which is similar to the English 'a'.

We will frequently use the name ai for the object एi. Therefore if we write
 * $$P(a_7)$$

we are expressing that object ए7 has the property expressed by P.

Of course another reason why it is important to distinguish between names and objects is, just like in the "Muhammad Ali" and "Cassius Clay" example, sometimes a single object will have multiple names. Therefore we might consider a domain like
 * $$U = \{\text{Muhammad Ali}, \text{Sunny Liston}, \text{Joe Frasier}\}$$

with names $$a,b,c,d$$. We might then say that Muhammad Ali has names a and b, while Sunny Liston has the name c, and Joe Frasier has the name d.

It would then be correct to write


 * $$a=b$$

because the two names refer to the same thing. On the other hand, no other equation with these names would be correct.

In fact, equations only make sense when you have multiple ways of referring to the same object in your domain. Without the possibility of a single object being referred to in multiple ways, equations wouldn't make any sense at all!

Finite and Infinite Domains
Suppose that the domain of discourse is finite,
 * $$U=\{\text{ए}_1,\dots,\text{ए}_n\}$$ for some natural number n.

Further suppose that the name for any एi is ai.

Further suppose that there is a property, P, and we would like to say that everything in the universe has property P.

Then notice that


 * $$\bigwedge_{i=1}^n P(a_i)$$

and


 * $$\forall x P(x)$$

both say exactly the same thing. They both express that every element of the domain has property P.

Therefore, for finite domains, there is no need for the universal quantifier, because we could do everything with the "big and" symbol.

However, now consider an infinite domain,


 * $$U' = \{\text{ए}_1,\text{ए}_2,\dots\}$$

With this as the domain, there is no choice of n for which


 * $$\bigwedge_{i=1}^n P(a_i)$$

is equivalent to


 * $$\forall x P(x)$$

You might wonder why we cannot instead write something like


 * $$\bigwedge_{i=1}^\infty P(a_i)$$

to get around this tedious issue. But the most natural way to understand what $$\bigwedge_{i=1}^\infty P(a_i)$$ means, is to read it as a so-to-speak "infinite sentence". But we do not permit infinite sentences — such things are just regarded as syntactically invalid.

In effect, the whole point of the universal quantifier is allow a finite sentence to make a claim about an infinite domain.

Of course, in the same sort of way, for finite domains like U above,


 * $$\exists x P(x)$$

is equivalent to


 * $$\bigvee_{i=1}^n P(a_i)$$

And of course, for infinite domains, there is no finite sentence which is equivalent to $$\exists x P(x)$$.

Abstract and symbolize the following sentences.

1. "There is a matrix, M, such that $$M\cdot M = M$$."

2. "If a number is divisible by 4 then it is divisible by 2."

3. "Every mammal is an animal and has hair on its skin."

4. "If any massive object exerts a force on another massive object, then the second object exerts a force on the first object."

5. "Every natural number is bigger than some natural number."

6. "Some natural number is bigger than every natural number."

7. "If n is a prime natural number then there is a natural number m which is not 1 and not n, and m divides n."

Use quantifiers to express the sentence

and

Write a sentence to express



The diagram to the right shows Aristotle's Square of Opposition, which displays four abstract sentences at each of the four corners:


 * All S are P.
 * No S is P.
 * Some S are P.
 * some S are not P.

The diagram also shows corresponding diagrams for sets, where S is used to represent the set of all objects with property S. Likewise P is used to represent the set of all objects with property P.

For example, consider the upper-left corner, "All S are P." The set diagram shows the region of S which does not intersect P as a dark, empty region. This makes sense, since if all S are P, then the region in S which is not in P should be empty.

This sentence is also formalized by the sentence
 * $$\forall x (S(x)\to P(x))$$

Note that the sentences on the top of the diagram tell you that some region is empty. The sentences on the bottom tell you that some region has at least one element.

Give the sentence for each of the other sentences in the diagram.

Mixed Quantifiers
Consider the relationship "x loves y" represented by the expression $$L(x,y)$$. Then consider each of the following sentences,

1. Everybody loves someone.

2. Someone loves everyone.

3. Everybody is loved by someone.

4. Someone is loved by everyone.

Sentence (1.) is perhaps like a statement about the human condition.

Sentence (2.) describes a Jesus-like figure of unconditional love. (I write this in a slightly cheeky tone. No offense intended; and no endorsement of any religion intended.)

Sentence (3.) expresses perhaps a hopefully message.

Sentence (4.) describes a Taylor Swift-like, universally beloved figure.

Their respective formalizations are

1. $$\forall x\exists y L(x,y)$$

2. $$\exists x\forall y L(x,y)$$

3. $$\forall x\exists y L(y,x)$$

4. $$\exists x\forall y L(y,x)$$

Consider a universe of three people (just big enough to be interesting but still small enough that we can try to list out all possible permutations).


 * $$U = \{\text{ए}_1,\text{ए}_2,\text{ए}_3\}$$

Use $$L(x,y)$$ for "x loves y". For each एi in the domain, we use the name ai.

Then $$\forall x \exists y L(x,y)$$ is equivalent to
 * $$(\exists y L(a_1,y))\land (\exists y L(a_2,y))\land (\exists y L(a_3,y))$$

which in turn is equivalent to
 * $$\begin{aligned}

&(L(a_1,a_1)\lor L(a_1,a_2)\lor L(a_1,a_3))\land \\ &(L(a_2,a_1)\lor L(a_2,a_2)\lor L(a_2,a_3))\land \\ &(L(a_3,a_1)\lor L(a_3,a_2)\lor L(a_3,a_3)) \end{aligned}$$

Perform a similar "expansion" to the sentence $$\exist x\forall y L(x,y)$$ to see why this is not equivalent to $$\forall x\exists y L(x,y)$$.

Further, use a similar expansion for $$\forall y\exists x L(y,x)$$ to see why this is equivalent to $$\forall x\exists y L(x,y)$$.

Further, given an argument for why $$\forall x\forall y L(x,y)$$ is equivalent to $$\forall x\forall y L(y,x)$$. Also $$\exists x\exists y L(x,y)$$ and $$\exists x\exists y L(y,x)$$ are equivalent.

For every sentence above, give its interpretation in natural English, using the idea that L means "love" and the objects of the domain are three different people.

Equality
There are a few relations which we use so often that it would be a shame not to use their traditional names! It will make them so much more recognizable.

Possibly the most famous example is the "equality" relation. Suppose that we write the name a for the number 1, and b for the number 2/2. We would like to express that $$a=b$$ but up to now, we haven't yet allowed such an expression.

We could instead make a relation symbol, E, which is meant to express the equality relation. We could then state


 * $$E(a,b)$$

to be the symbolization of $$a=b$$. Which is very consistent with everything else we've been saying so far!

Indeed, we can do precisely this. However, equality is such an important relationship that we wouldn't want to obscure our meaning this way. It is much more immediately clear what we are trying to say, if we simply add the '=' symbol to our first-order language.

Notice that, so far, all of our property symbols are "prefix symbols". Which is to say that we write the property symbol before the objects about which it "speaks". Our traditional use of the equality symbol is an "infix symbol", written between the two objects.

We will strike a compromise. Technically, we will adopt the notation
 * $$=\!\! (a,b)$$

to express that a equals b. However, we will also permit ourselves to write
 * $$a = b$$

and know that this actually just is "syntactic sugar" for $$=\!\!(a,b)$$.

Decide which of the following expresses a true sentence, no matter what the constants a and b denote. As usual, take letters a through t to represent constants, and u through z to be variables.

1. $$a = a$$

2. $$\exists x (x=x)$$ (additional parentheses are used here to help readability)

3. $$\forall x (x=x)$$

4. $$a = b$$

5. $$a=b \to b=a$$

6. $$\forall x( (a=x\land b=x)\to a=b)$$

Less Than
Similar to the discussion about equality, we allow notation for "less than" when dealing with numbers, or any other ordered objects. To begin with, consider the "strict" less-than relation, written "<".

As before, we officially write


 * $$<\!\!(1,2)$$

in prefix notation, to express that 1 is less than 2. However, we immediately permit the syntactic sugar,


 * $$ 1<2 $$

so that it looks like the familiar expression.

Likewise we adopt the official notation $$\le\!\!(1, 2)$$ for the "inclusive less-than-or-equal to". We also use the syntactic sugar, $$1\le 2$$.

And likewise for $$>$$ and $$\ge$$.

Syntax
Our goal now is to define sentences so that we can distinguish them from meaningless expressions.

Note that constants and variables play significantly different roles in expressions. The sentence
 * $$P(a)$$

is valid because a is a constant. This is intended to express the claim that a (or, the object it refers to) has property P.

On the other hand, for a variable x, the expression
 * $$P(x)$$

is not a sentence. Which is to say, it is strictly speaking, meaningless.

On the other hand, $$\forall x P(x)$$ is a sentence, because the variable has been quantified!

By the way, if P is a symbol with arity one, like above, then it should also be invalid to write $$P(x,y)$$. That is to say, we should use a symbol's arity consistently.

With these distinctions in hand, we then need to be able to build up "open formulas" like $$P(x)$$ and $$\neg(Q(x,y)\to R(z))$$. These will not, in themselves, be meaningful. But we define them anyway, so that we can then talk about quantifying their variables.

For example, from the open formula $$\neg(Q(x,y)\to R(z))$$, we may quantify its variables in a number of different ways. Here are two.


 * $$\forall x\forall y\exists z\neg(Q(x,y)\to R(z))$$

and
 * $$\exists y\forall z\forall x\neg(Q(x,y)\to R(z))$$

Therefore to define a sentence in first-order logic, we start by defining open formulas. It will be defined very analogously to the definition of a propositional sentence.

Formulas
Similar to the definition above, let i be any nonnnegative natural number, and give a reasonable definition for an atomic formula of arity i.

Decide which of the following are formulas, using the formal definition above.

1. $$R(x,y)$$

2. $$R(a,x)$$

3. $$\forall y R(a,x)$$

4. $$R(x,y)\land P(\neg x)$$

5. $$x \land y$$

6. $$\exists x x$$

7. $$\exists x \exists x P(x)$$

Free and Bound Variables, Sentences
The free variables of $$\forall xR(x,y)$$ is the set of variables not bound by any quantifier. In this case, that is the set


 * $$\text{fr}(\forall x R(x,y)) = \{y\}$$

The sentence $$\forall x\exists y R(x,y)$$ has no free variables, so


 * $$\text{fr}(\forall x\exists y R(x,y)) = \emptyset$$

Find the free variables in the following formulas, using the formal definition above.

1. $$P(x)$$

2. $$\exists x P(x)$$

3. $$\exists y P(x)$$

4. $$R(a,x)$$

5. $$\forall x\forall y\forall z(P(x)\to (R(z)\land Q(y)))$$

Decide which of the following are sentences.

1. $$\forall x R(x,y)$$

2. $$P(x)$$

3. $$P(a)$$

Terms
We will often have a need to refer to objects by means of a function. For instance, we would like to be able to express "$$1+2= 3$$" in a way that reflects this as "input 1 and 2, output a new number, 3."

In logic, we call such a thing a term.

Just as with properties, terms may have just about any arity.

To see an example of a unary term, consider the function $$f(x)=x+1$$.

We might want to express the sentence, "For every real number x, the input to f is always less than the output." If the domain of discourse is the real numbers, then we can express this as


 * $$\forall x( L(x, f(x)))$$

where $$L(x,y)$$ expresses "x is less than y".