%!TEX root = forallx-ubc.tex
\chapter{Quantified logic}
\label{ch.QL}

This chapter introduces a logical language called QL. It is a version of \emph{quantified logic}, because it allows for quantifiers like \emph{all} and \emph{some}. Quantified logic is also sometimes called \emph{predicate logic}, because the basic units of the language are predicates and terms.

\section{From sentences to predicates}
Consider the following argument, which is valid in English:
\begin{quote}
If everyone knows logic, then either no one will be confused or everyone will. Everyone will be confused only if we try to believe a contradiction. Everyone knows logic.\\
\therefore\ If we don't try to believe a contradiction, then no one will be confused.
\end{quote}
In order to symbolize this in SL, we will need a symbolization key.
\begin{ekey}
\item[L:] Everyone knows logic.
\item[N:] No one will be confused.
\item[E:] Everyone will be confused.
\item[B:] We try to believe a contradiction.
\end{ekey}
Notice that $N$ and $E$ are both about people being confused, but they are two separate sentence letters. We can't replace $E$ with $\enot N$. Why not? $\enot N$ means `It is not the case that no one will be confused.' This would be the case if even one person were confused, so it is a long way from saying that \emph{everyone} will be confused.

Because we have separate sentence letters for $N$ and $E$, however, our formalization does not encode any connection between the two. They are just two atomic sentences which might be true or false independently. It is impossible for it to be the case that both no one and everyone was confused. As sentences of SL, however, there is a truth-value assignment for which $N$ and $E$ are both true. This is a limitation of the descriptive power of SL. Some features of English sentences are not preserved in SL. Our new language, QL, will preserve more of this structure.

Expressions like `no one', `everyone', and `anyone' are called \emph{quantifiers}. By translating $N$ and $E$ as separate atomic sentences, we leave out the \emph{quantifier structure} of the sentences. In the example we've been discussing, the quantifier structure is not terribly important. The argument is valid without reference to it. As such, we can safely ignore it. To see this, we translate the argument to SL:
\begin{earg}
\item[]$L \eif (N \eor E)$
\item[]$E \eif B$
\item[]$L$
\item[\therefore]$\enot B \eif N$
\end{earg}
This is a valid argument form in SL. (You can construct a truth table, a tree, or a natural deduction proof to confirm this.)

Now consider another argument. This one is also valid in English.

\begin{quote}
\label{willard1}
Willard is a logician. All logicians wear funny hats.\\
\therefore\ Willard wears a funny hat.
\end{quote}

To symbolize it in SL, we define a symbolization key:
\begin{ekey}
\item[L:] Willard is a logician.
\item[A:] All logicians wear funny hats.
\item[F:] Willard wears a funny hat.
\end{ekey}

Now we symbolize the argument:
\begin{earg}
\item[]$L$
\item[]$A$
\item[\therefore] $F$
\end{earg}

This is pretty obviously an \emph{invalid} SL form. Nevertheless, this is clearly a valid argument in English. It's impossible for the premises to be true without the conclusion also being true. But the SL symbolization leaves out all quantificational structure in virtue of which it is valid. The sentence `All logicians wear funny hats' says something specific about both logicians and hat-wearing. By not translating this structure, treating the whole sentence as an atom, we lose the connection between Willard's being a logician and Willard's wearing a hat.

Some arguments with quantifier structure can be captured in SL, like the first example, even though SL ignores the quantifier structure. Other arguments' validity cannot be captured in SL, like the second example. Notice that the problem is not that we have made a mistake while symbolizing the second argument. We gave a perfectly appropriate translation; indeed, these are the best symbolizations we can give for these arguments \emph{in SL}.

If an English argument is properly translated into a form that is valid in SL, that argument is valid, even if it involves quantifiers. But if it does not have a valid SL form, that doesn't mean the English argument is invalid; valid arguments can have invalid forms. It just means that SL doesn't \emph{show} that the argument is valid. This will be the case when the argument's quantifier structure plays an important role in its validity.

Similarly, if a sentence with quantifiers comes out as a \emph{tautology in SL}, then the English sentence is logically true. If it comes out as \emph{contingent in SL}, then this might be because of the structure of the quantifiers that gets removed when we translate into the formal language.

In order to symbolize arguments that rely on quantifier structure, we need to develop a different, richer, logical language. We will call this language `quantified logic', or QL.

\section{Building blocks of QL}

Our first key notion in QL will be \define{predicates}. A predicate is analogous to an English description  --- an expression like `is a dog' or `has black fur'. Such descriptions are not sentences on their own. They are neither true nor false. They are descriptions that apply to some objects, but not to others. In order to be true or false, we need to specify an object: Who or what is it that is said to be a dog, or to have black fur? In SL, we have no way to give meaningful translations to English terms that are not full sentences. In QL, we will.

The details of this will be explained in the rest of the chapter, but here is the basic idea: In QL, we will represent predicates with capital letters. For instance, we might let $D$ stand for `\blank\ is a dog.' We will use lower-case letters as the names of specific things. For instance, we might let $b$ stand for Bertie. The expression $Db$ will be a sentence in QL. Given this symbolization, $Db$ is a translation of the sentence `Bertie is a dog.'

In order to represent quantifier structure, we will also have symbols that represent quantifiers. For instance, `$\exists$' will mean `There is some\blank.' So to say that there is a dog, we can write $\exists x Dx$; that is: There is some $x$ such that $x$ is a dog.

That will come later. We start by defining singular terms and predicates.

\section{Singular terms}
In English, a \define{singular term} is a word or phrase that refers to a \emph{specific} person, place, or thing. The word `dog' is not a singular term, because it is a general term that could apply to many individual animals. The phrase `Jonathan's dog Mezzo' is a singular term, because it refers to a specific little poodle mix. She is black, and soft, and wonderful.

A \define{proper name} is a singular term that picks out an individual directly. The name `Emerson' is a proper name, and the name alone does not tell you anything about Emerson. Of course, some names are traditionally given to boys, and others are traditionally given to girls. If `Jack Hathaway' is used as a singular term, you might guess that it refers to a man. However, the name does not necessarily mean that the person referred to is a man --- or even that the creature referred to is a person. Jack might be a giraffe for all you could tell just from the name. There is a great deal of philosophical action surrounding this issue, but the important point here is that a name is a singular term because it picks out a single, specific individual.

Other singular terms more obviously convey information about the thing to which they refer. For instance, you can tell without being told anything further that `Jonathan's dog Mezzo' is a singular term that refers to a dog. A \define{definite description} picks out an individual by means of a unique description. In English, definite descriptions are often phrases of the form `the such-and-so.' They refer to \emph{the} specific thing that matches the given description. For example, `the tallest member of Monty Python' and `the first emperor of China' are definite descriptions. A description that does not pick out a specific individual is not a definite description. `A member of Monty Python' and `an emperor of China' are not definite descriptions. We'll discuss definite descriptions in more detail in Chapter \ref{ch.identity}.

In English, the specification of a singular term may depend on context; `Willard' means a specific person and not just someone named Willard; `P.D. Magnus' as a logical singular term means the original author of this textbook, not the other person who has the same name. We live with this kind of ambiguity in English, but it is important to keep in mind that singular terms in QL must refer to just one specific thing.

In QL, we will symbolize singular terms with lower-case letters $a$ through $w$. We can add subscripts if we want to use some letter more than once. So $a,b,c,\ldots w, a_1, f_{32}, j_{390}$, and $m_{12}$ are all terms in QL.

Singular terms are called \define{constants} because they pick out specific individuals. Note that $x, y$, and $z$ are not constants in QL. They will be \define{variables}, letters which do not stand for any specific thing. We will need them when we introduce quantifiers.

\section{Predicates}
Simple one-place predicates are properties of individuals. They are things you can say about an object. Here are some one-place predicates:

\begin{earg}
\item[] `\blank\ is a dog'
\item[] `\blank\ is a member of Monty Python'
\item[] `\blank\ 's favourite ramen place is in Gastown'
\item[] `An anvil was dropped from a very high height onto \blank\ 's head'
\end{earg}

Predicates like these are called \define{one-place} or \define{monadic}, because there is only one blank to fill in. A one-place predicate and a singular term combine to make a sentence.

Other predicates are about the \emph{relation} between two things. For instance:

\begin{earg}
\item[] `\blank\ is bigger than \blank'
\item[] `\blank\ is to the left of \blank'
\item[] `\blank\ owes money to \blank'
\end{earg}

These are \define{two-place} or \define{dyadic} predicates, because they need to be filled in with two terms in order to make a sentence.

In general, you can think about predicates as schematic sentences that need to be filled out with some number of terms. Conversely, you can start with sentences and make predicates out of them by removing terms. Consider the sentence, `Buchanan Tower is North of Barber but South of Buchanan E.' By removing a singular term, we can recognize this sentence as using any of three different monadic predicates:
\begin{earg}
\item[] \blank is North of Barber but South of Buchanan E.\\
\item[] Buchanan Tower is North of \blank but South of Buchanan E.\\
\item[] Buchanan Tower is North of Barber but South of \blank.
\end{earg}

By removing two singular terms, we can recognize three different dyadic predicates:
\begin{earg}
\item[] Buchanan Tower is North of \blank but South of \blank.\\
\item[] \blank is North of Barber but South of \blank.\\
\item[] \blank is North of \blank but South of Buchanan E.\\
\end{earg}

By removing all three singular terms, we can recognize one \define{three-place} or \define{triadic} predicate:
\begin{center}
\item[] \blank is North of \blank but South of \blank.\\
\end{center}

If we are translating this sentence into QL, should we translate it with a one-, two-, or three-place predicate? It depends on what we want to be able to say. If we're only interested in discussing the location of buildings relative to Barber, then the generality of the three-place predicate is unnecessary. If we only want to discuss whether buildings are North of Barber and South of BUCH E, a one-place predicate will be enough.

In general, we can have predicates with as many places as we need. Predicates with more than one place are called \define{polyadic}. Predicates with $n$ places, for some number $n$, are called \define{n-place} or \define{n-adic}. You can make an $n$-adic predicate by replacing $n$ names in any sentence with blanks. You can even have a 0-place predicate --- this would be the result of replacing $0$ names in a sentence with blanks. In other words, a 0-place predicate is just a sentence.

In QL, we symbolize predicates with capital letters $A$ through $Z$, with or without subscripts. When we give a symbolization key for predicates, we will not use blanks; instead, we will use variables. By convention, constants are listed at the end of the key. So we might write a key that looks like this:
\begin{groupitems}
\begin{ekey}
\item[Ax:] $x$ is angry.
\item[Hx:] $x$ is happy.
\item[T$_1$xy:] $x$ is at least as tall as $y$.
\item[T$_2$xy:] $x$ is at least as tough as $y$.
\item[Bxyz:] $y$ is between $x$ and $z$.
\item[d:] Donald
\item[g:] Gregor
\item[m:] Marybeth
\end{ekey}
\end{groupitems}

We can symbolize sentences that use any combination of these predicates and terms. For example:
\begin{earg}
\nix{I am inclined to change these to Cordelia, Hamlet, and Macbeth}
\item[\ex{terms1}] Donald is angry.
\item[\ex{terms2}] If Donald is angry, then so are Gregor and Marybeth.
\item[\ex{terms3}] Marybeth is at least as tall and as tough as Gregor.
\item[\ex{terms4}] Donald is shorter than Gregor.
\item[\ex{terms5}] Gregor is between Donald and Marybeth.
\end{earg}

Sentence \ref{terms1} is straightforward: $Ad$. The `$x$' in the key entry `$Ax$' is just a placeholder; we replace it with other terms when translating.

Sentence \ref{terms2} can be paraphrased as, `If $Ad$, then $Ag$ and $Am$.' QL has all the truth-functional connectives of SL, so we translate this as $Ad \eif (Ag \eand Am)$.

Sentence \ref{terms3} can be translated as $T_1mg \eand T_2mg$.

Sentence \ref{terms4} might seem as if it requires a new predicate. If we only needed to symbolize this sentence, we could define a predicate like $Sxy$ to mean `$x$ is shorter than $y$.' However, this would ignore the logical connection between `shorter' and `taller.' Considered only as symbols of QL, there is no connection between $S$ and $T_1$. They might mean anything at all. Instead of introducing a new predicate, we paraphrase sentence \ref{terms4} using predicates already in our key: `It is not the case that Donald is as tall or taller than Gregor.' We can translate it as $\enot T_1dg$.

Sentence \ref{terms5} requires that we pay careful attention to the order of terms in the key. It becomes $Bdgm$.

\section{Quantifiers}
We are now ready to introduce quantifiers. Quantifiers (unlike names and predicates) are a new kind of logical connective; like conjunction, negation, etc., they can govern the interpretation of a QL sentence.  Consider these English sentences:
\begin{earg}
\item[\ex{q.a}] Everyone is happy.
\item[\ex{q.ac}] Everyone is at least as tough as Donald.
\item[\ex{q.e}] Someone is angry.
\end{earg}

It might be tempting to translate sentence \ref{q.a} as $Hd \eand Hg \eand Hm$. Yet this would only say that Donald, Gregor, and Marybeth are happy. We want to say that \emph{everyone} is happy, even if we have not defined a constant to name them. In order to do this, we introduce the `$\forall$' symbol. This is called the \define{universal quantifier}.

A quantifier is placed in front of the formula that it binds. It always comes along with an associated variable. Typically that formula will include the same variable. We can translate sentence \ref{q.a} as $\forall x Hx$. Paraphrased partially into English, this means `For all $x$, $x$ is happy.'

We call $\forall x$ an \emph{x-quantifier}. The formula that follows the quantifier is called the \emph{scope} of the quantifier. We will give a formal definition of scope later, but intuitively it is the part of the sentence that the quantifier quantifies over. In $\forall x Hx$, the scope of the universal quantifier is $Hx$.

Sentence \ref{q.ac} can be paraphrased as, `For all $x$, $x$ is at least as tough as Donald.' This translates as $\forall x T_2xd$.

In these quantified sentences, the variable $x$ is serving as a kind of placeholder. The expression $\forall x$ means that you can pick anyone and put them in as $x$. There is no special reason to use $x$ rather than some other variable. The sentence $\forall x Hx$ means exactly the same thing as $\forall y Hy$, $\forall z Hz$, and $\forall x_5 Hx_5$.

To translate sentence \ref{q.e}, we introduce another new symbol: the \define{existential quantifier}, $\exists$. Like the universal quantifier, the existential quantifier requires a variable. Sentence \ref{q.e} can be translated as $\exists x Ax$. This means that there is some $x$ which is angry. More precisely, it means that there is \emph{at least one} angry person. Once again, the variable is a kind of placeholder; we could just as easily have translated sentence \ref{q.e} as $\exists z Az$.

Consider these further sentences:
\begin{earg}
\item[\ex{q.ne}] No one is angry.
\item[\ex{q.en}] There is someone who is not happy.
\item[\ex{q.na}] Not everyone is happy.
\end{earg}

Sentence \ref{q.ne} can be paraphrased as, `It is not the case that someone is angry.' This can be translated using negation and an existential quantifier: $\enot \exists x Ax$. Yet sentence \ref{q.ne} could also be paraphrased as, `Everyone is not angry.' With this in mind, it can be translated using negation and a universal quantifier: $\forall x \enot Ax$. Both of these are acceptable translations, because they are logically equivalent. The critical thing is whether the negation comes before or after the quantifier.

In general, $\forall x\metaA{}$ is logically equivalent to $\enot\exists x\enot\metaA{}$. This means that any sentence which can be symbolized with a universal quantifier can be symbolized with an existential quantifier, and vice versa. One translation might seem more natural than the other, but there is no logical difference in translating with one quantifier rather than the other. For some sentences, it will simply be a matter of taste.

Sentence \ref{q.en} is most naturally paraphrased as, `There is some $x$ such that $x$ is not happy.' This becomes $\exists x \enot Hx$. Equivalently, we could write $\enot\forall x Hx$.

Sentence \ref{q.na} is most naturally translated as $\enot\forall x Hx$. This is logically equivalent to sentence \ref{q.en} and so could also be translated as $\exists x \enot Hx$.

%Although we have two quantifiers in QL, we could have an equivalent formal language with only one quantifier. We could proceed with only the universal quantifier, for instance, and treat the existential quantifier as a notational convention. We use square brackets [ ] to make some sentences more readable, but we know that these are really just parentheses ( ). In the same way, we could write `$\exists x$' knowing that this is just shorthand for `$\enot \forall x \enot$.' There is a choice between making logic formally simple and making it expressively simple. With QL, we opt for expressive simplicity. Both $\forall$ and $\exists$ will be symbols of QL.

\section{Universe of discourse}
Given the symbolization key we have been using, $\forall xHx$ means `Everyone is happy.' Who is included in this \emph{everyone}? When we use sentences like this in English, we usually do not mean everyone now alive on the Earth. We certainly do not mean everyone who was ever alive or who will ever live. We mean something more modest: everyone in the building, everyone in the class, or everyone in the room.

In order to eliminate this ambiguity, we will need to specify a \define{universe of discourse} --- abbreviated UD. The UD is the set of things that we are talking about. So if we want to talk about people in Chicago, we define the UD to be people in Chicago. We write this at the beginning of the symbolization key, like this:
\begin{ekey}
\item[UD:] people in Chicago
\end{ekey}
The quantifiers \emph{range over} the universe of discourse. Given this UD, $\forall x$ means `Everyone in Chicago' and $\exists x$ means `Someone in Chicago.' Each constant names some member of the UD, so we can only use this UD with the symbolization key above if Donald, Gregor, and Marybeth are all in Chicago. If we want to talk about people in places besides Chicago, then we need to include those people in the UD.

In QL, the UD must be \emph{non-empty}; that is, it must include at least one thing. It is possible to construct formal languages that allow for empty UDs, but this introduces complications; such languages are beyond the scope of this book.

Even allowing for a UD with just one member can produce some strange results. Suppose we have this as a symbolization key:
\begin{ekey}
\item[UD:] the Eiffel Tower
\item[Px:] $x$ is in Paris.
\end{ekey}
The sentence $\forall x Px$ might be paraphrased in English as `Everything is in Paris.' Yet that would be misleading. It means that everything \emph{in the UD} is in Paris. This UD contains only the Eiffel Tower, so with this symbolization key $\forall x Px$ just means that the Eiffel Tower is in Paris. We will rarely work with such bizarre domains as this.

It is a rule in QL that each constant will pick out exactly one member of the UD. (There is no rule prohibiting multiple different constants from referring to the same member of the UD.)

%\subsection{Non-referring terms}
%In QL, each constant must pick out exactly one member of the UD. A constant cannot refer to more than one thing --- it is a \emph{singular} term. Each constant must still pick out \emph{something}. This is connected to a classic philosophical problem: the so-called problem of non-referring terms.
%
%Medieval philosophers typically used sentences about the \emph{chimera} to exemplify this problem. Chimera is a mythological creature; it does not really exist. Consider these two sentences:
%\begin{earg}
%\item[\ex{chimera1}] Chimera is angry.
%\item[\ex{chimera2}] Chimera is not angry.
%\end{earg}
%It is tempting just to define a constant to mean `chimera.' The symbolization key would look like this:
%\begin{ekey}
%\item[UD:] creatures on Earth
%\item[Ax:] $x$ is angry.
%\item[c:] chimera
%\end{ekey}
%We could then translate sentence \ref{chimera1} as $Ac$ and sentence \ref{chimera2} as $\enot Ac$.
%
%Problems will arise when we ask whether these sentences are true or false.
%
%One option is to say that sentence \ref{chimera1} is not true, because there is no chimera. If sentence \ref{chimera1} is false because it talks about a non-existent thing, then sentence \ref{chimera2} is false for the same reason. Yet this would mean that $Ac$ and $\enot Ac$ would both be false. Given the truth conditions for negation, this cannot be the case.
%
%Since we cannot say that they are both false, what should we do? Another option is to say that sentence \ref{chimera1} is \emph{meaningless} because it talks about a non-existent thing. So $Ac$ would be a meaningful expression in QL for some interpretations but not for others. Yet this would make our formal language hostage to particular interpretations. Since we are interested in logical form, we want to consider the logical force of a sentence like $Ac$ apart from any particular interpretation. If $Ac$ were sometimes meaningful and sometimes meaningless, we could not do that.
%
%This is the \emph{problem of non-referring terms}, and we will return to it later (see p.~\pageref{subsec.defdesc}.) The important point for now is that each constant of QL \emph{must} refer to something in the UD, although the UD can be any set of things that we like. If we want to symbolize arguments about mythological creatures, then we must define a UD that includes them. This option is important if we want to consider the logic of stories. We can translate a sentence like `Sherlock Holmes lived at 221B Baker Street' by including fictional characters like Sherlock Holmes in our UD.
%

\section{Translating to QL}
We now have the basic pieces of QL. Translating more complicated sentences will only be a matter of knowing the right way to combine predicates, constants, quantifiers, variables, and sentential connectives. Consider these sentences:
\begin{earg}
\item[\ex{quan1}] Every coin in my pocket is a loonie.
\item[\ex{quan2}] Some coin on the table is a dime.
\item[\ex{quan3}] Not all the coins on the table are loonies.
\item[\ex{quan4}] None of the coins in my pocket are dimes.
\end{earg}
In providing a symbolization key, we need to specify a UD. Since we are talking about coins in my pocket and on the table, the UD must at least contain all of those coins. Since we are not talking about anything besides coins, we let the UD be all coins. Since we are not talking about any specific coins, we do not need to define any constants. So we define this key:
\begin{ekey}
\item[UD:] all coins
\item[Px:] $x$ is in my pocket.
\item[Tx:] $x$ is on the table.
\item[Lx:] $x$ is a loonie.
\item[Dx:] $x$ is a dime.
\end{ekey}
Sentence \ref{quan1} is most naturally translated with a universal quantifier. The universal quantifier says something about everything in the UD, not just about the coins in my pocket. Sentence \ref{quan1} means that, for any coin, \emph{if} that coin is in my pocket, \emph{then} it is a loonie. So we can translate it as $\forall x(Px \eif Lx)$.

Since sentence \ref{quan1} is about coins that are both in my pocket \emph{and} that are loonies, it might be tempting to translate it using a conjunction. However, the sentence $\forall x(Px \eand Lx)$ would mean that everything in the UD is both in my pocket and a loonie: All the coins that exist are loonies in my pocket. This would be nice, but it means something very different than sentence \ref{quan1}.

Sentence \ref{quan2} is most naturally translated with an existential quantifier. It says that there is some coin which is both on the table and which is a dime. So we can translate it as $\exists x(Tx \eand Dx)$.

Notice that we needed to use a conditional with the universal quantifier, but we used a conjunction with the existential quantifier. This is a common pattern. What would it mean to write $\exists x(Tx \eif Dx)$? Probably not what you think. It means that there is some member of the UD which would satisfy the subformula; roughly speaking, there is some name $\alpha$ such that $(T\alpha \eif D\alpha)$ is true. In SL, $\metaA{} \eif \metaB{}$ is logically equivalent to $\enot\metaA{} \eor \metaB{}$, and this will also hold in QL. So $\exists x(Tx \eif Dx)$ is true if there is some $\alpha$ such that $(\enot T\alpha \eor D\alpha)$; i.e., it is true if some coin is \emph{either} not on the table \emph{or} is a dime. Of course there is a coin that is not on the table --- there are coins in lots of other places. So $\exists x(Tx \eif Dx)$ makes an extremely weak claim. A conditional will usually be the natural connective to use with a universal quantifier, but a conditional within the scope of an existential quantifier can do very strange things. It's a pretty good rule of thumb that you shouldn't be putting conditionals in the scope of existential quantifiers. This is pretty much never a good translation of any natural English sentence.

Sentence \ref{quan3} can be paraphrased as, `It is not the case that every coin on the table is a loonie.' So we can translate it as $\enot \forall x(Tx \eif Lx)$. You might look at sentence \ref{quan3} and paraphrase it instead as, `Some coin on the table is not a loonie.' You would then translate it as $\exists x(Tx \eand \enot Lx)$. Although it is probably not obvious, these two translations are logically equivalent. (This is due to the logical equivalence between $\enot\forall x\metaA{}$ and $\exists x\enot\metaA{}$, along with the equivalence between $\enot(\metaA{}\eif\metaB{})$ and $\metaA{}\eand\enot\metaB{}$. We'll be able to prove this later.)

Sentence \ref{quan4} can be paraphrased as, `It is not the case that there is some dime in my pocket.' This can be translated as $\enot\exists x(Px \eand Dx)$. It might also be paraphrased as, `Everything in my pocket is a non-dime,' and then could be translated as $\forall x(Px \eif \enot Dx)$. Again the two translations are logically equivalent. Both are correct translations of sentence \ref{quan4}.

We can now translate the argument from p.~\pageref{willard1}, the one that motivated the need for quantifiers:
\begin{quote}
Willard is a logician. All logicians wear funny hats.\\
\therefore\ Willard wears a funny hat.
\end{quote}
\begin{ekey}
\item[UD:] people
\item[Lx:] $x$ is a logician.
\item[Fx:] $x$ wears a funny hat.
\item[w:] Willard
\end{ekey}
Translating, we get:
\begin{earg}
\item[] $Lw$
\item[] $\forall x(Lx \eif Fx)$
\item[\therefore] $Fw$
\end{earg}

This captures the structure that was left out of the SL translation of this argument, and this is a valid argument in QL.

\section{Empty predicates}
A predicate need not apply to anything in the UD. A predicate that applies to nothing in the UD is called an \define{empty} predicate.

Suppose we want to symbolize these two sentences:
\begin{earg}
\item[\ex{monkey1}]Every monkey knows sign language.
\item[\ex{monkey2}]Some monkey knows sign language.
\end{earg}
It is possible to write the symbolization key for these sentences in this way:
\begin{ekey}
\item[UD:] animals
\item[Mx:] $x$ is a monkey.
\item[Sx:] $x$ knows sign language.
\end{ekey}

Sentence \ref{monkey1} can now be translated as $\forall x(Mx \eif Sx)$.

Sentence \ref{monkey2} becomes $\exists x(Mx \eand Sx)$.

It is tempting to say that sentence \ref{monkey1} entails sentence \ref{monkey2}; that is: if every monkey knows sign language, then it must be that some monkey knows sign language. However, the entailment does not hold in QL. It is possible for the sentence $\forall x(Mx \eif Sx)$ to be true even though the sentence $\exists x(Mx \eand Sx)$ is false.

How can this be? The answer comes from considering whether these sentences would be true or false \emph{if there were no monkeys}.

We have defined $\forall$ and $\exists$ in such a way that $\forall\metaA{}$ is equivalent to $\enot \exists\enot \metaA{}$. As such, the universal quantifier doesn't involve the existence of anything --- only non-existence. If sentence \ref{monkey1} is true, then there are \emph{no} monkeys who don't know sign language. If there were no monkeys, then $\forall x(Mx \eif Sx)$ would be true and $\exists x(Mx \eand Sx)$ would be false.

A second reason to allow empty predicates is that we want to be able to say things like, `I do not know if there are any monkeys, but any monkeys that there are know sign language.' That is, we want to be able to have predicates that do not (or might not) refer to anything.

Third, consider: $\forall x (Px \eif Px)$. This should be a tautology. But if sentence \ref{monkey1} implied sentence \ref{monkey2}, then this would imply $\exists x (Px \eand Px)$. It would become a logical truth that for any predicate there is something that satisfies that predicate.

What happens if we add an empty predicate $R$ to the interpretation above? For example, we might define $Rx$ to mean `$x$ is a refrigerator.' Now the sentence $\forall x(Rx \eif Mx)$ will be true. This is counterintuitive, since we do not want to say that there are a whole bunch of refrigerator monkeys. It is important to remember, though, that $\forall x(Rx \eif Mx)$ means that any member of the UD which is a refrigerator is a monkey. Since the UD is animals, there are no refrigerators in the UD and so the sentence is trivially true.

If you were actually translating the sentence `All refrigerators are monkeys', then you would want to include appliances in the UD. Then the predicate $R$ would not be empty and the sentence $\forall x(Rx \eif Mx)$ would be false.

\begin{table}[t]
\factoidbox{
\begin{itemize}
\item A UD must have \emph{at least} one member.
\item A predicate may apply to some, all, or no members of the UD.
\item A constant must pick out \emph{exactly} one member of the UD.

 A member of the UD may be picked out by one constant, many constants, or none at all.
\end{itemize}
}
\end{table}

\section{Picking a universe of discourse}
The appropriate symbolization of an English language sentence in QL will depend on the symbolization key. In some ways, this is obvious: It matters whether $Dx$ means `$x$ is dainty' or `$x$ is dangerous.' The meaning of sentences in QL also depends on the UD.

Let $Rx$ mean `$x$ is a rose,' let $Tx$ mean `$x$ has a thorn,' and consider this sentence:
\begin{earg}
\item[\ex{pickUDrose}] Every rose has a thorn.
\end{earg}

It is tempting to say that sentence \ref{pickUDrose} should be translated as $\forall x(Rx \eif Tx)$. If the UD contains all roses, that would be correct. Yet if the UD is merely \emph{things on my kitchen table}, then $\forall x(Rx \eif Tx)$ would only mean that every rose on my kitchen table has a thorn. If there are no roses on my kitchen table, the sentence would be trivially true.

The universal quantifier only ranges over members of the UD, so we need to include all roses in the UD in order to translate sentence \ref{pickUDrose}. We have two options. First, we can restrict the UD to include all roses but \emph{only} roses. Then sentence \ref{pickUDrose} becomes $\forall x Tx$. This means that everything in the UD has a thorn; since the UD just is the set of roses, this means that every rose has a thorn. This option can save us trouble if every sentence that we want to translate using the symbolization key is about roses.

Second, we can let the UD contain things besides roses: rhododendrons, rats, rifles, and whatall else. Then sentence \ref{pickUDrose} must be $\forall x(Rx \eif Tx)$.

If we wanted the universal quantifier to mean \emph{every} thing, without restriction, then we might try to specify a UD that contains everything. But this notion is somewhat obscure. Does `everything' include things that have only been imagined, like fictional characters? On the one hand, we want to be able to symbolize arguments about Hamlet or Sherlock Holmes. So we need to have the option of including fictional characters in the UD. On the other hand, we never need to talk about every thing that does not exist. That might not even make sense. There are philosophical issues here that we will not try to address. We can avoid these difficulties by always specifying the UD. For example, if we mean to talk about plants, people, and cities, then the UD might be `living things and places.'

Suppose that we want to translate sentence \ref{pickUDrose} and, with the same symbolization key, translate these sentences:

\begin{earg}
\item[\ex{pickUDhair}] Esmerelda has a rose in her hair.
\item[\ex{pickUDcross}] Everyone is cross with Esmerelda.
\end{earg}

We need a UD that includes roses (so that we can symbolize sentence \ref{pickUDrose}) and a UD that includes people (so we can translate sentence \ref{pickUDhair}--\ref{pickUDcross}.) Here is a suitable key:
\begin{ekey}
\item[UD:] people and plants
\item[Px:] $x$ is a person.
\item[Rx:] $x$ is a rose.
\item[Tx:] $x$ has a thorn.
\item[Cxy:] $x$ is cross with $y$.
\item[Hxy:] $x$ has $y$ in their hair.
\item[e:] Esmerelda
\end{ekey}

Since we do not have a predicate that means `$\ldots$ has a rose in her hair', translating sentence \ref{pickUDhair} will require paraphrasing. The sentence says that there is a rose in Esmerelda's hair; that is, there is something which is both a rose and is in Esmerelda's hair. So we get: $\exists x(Rx \eand Hex)$.

It is tempting to translate sentence \ref{pickUDcross} as $\forall x Cxe$. Unfortunately, this would mean that every member of the UD is cross with Esmerelda --- both people and plants. It would mean, for instance, that the rose in Esmerelda's hair is cross with her. Of course, sentence \ref{pickUDcross} does not mean that.

`Everyone' means every person, not every member of the UD. So we can paraphrase sentence \ref{pickUDcross} as, `Every person is cross with Esmerelda.' We know how to translate sentences like this: $\forall x(Px \eif Cxe)$.

In general, the universal quantifier can be used to mean `everyone' if the UD contains only people. If there are people and other things in the UD, then `everyone' must be treated as `every person'.

\section{Translating pronouns}
When translating to QL, it is important to understand the structure of the sentences you want to translate. What matters is the final translation in QL, and sometimes you will be able to move from an English language sentence directly to a sentence of QL. Other times, it helps to paraphrase the sentence one or more times. Each successive paraphrase should move from the original sentence closer to something that you can translate directly into QL.

For the next several examples, we will use this symbolization key:

\begin{ekey}
\item[UD:] people
\item[Gx:] $x$ can play guitar.
\item[Rx:] $x$ is a rock star.
\item[c:] Chris
\item[l:] Lemmy
\end{ekey}

Now consider these sentences:

\begin{earg}
\item[\ex{pronoun1}] If Chris can play guitar, then they are a rock star.
\item[\ex{pronoun2}] If a person can play guitar, then they are a rock star.
\end{earg}

Sentence \ref{pronoun1} and sentence \ref{pronoun2} have the same words in the consequent (`$\ldots$ they are a rock star'), but they cannot be translated in the same way. It helps to paraphrase the original sentences, replacing pronouns with explicit references.

Sentence \ref{pronoun1} can be paraphrased as, `If Chris can play guitar, then \emph{Chris} is a rockstar.' The word `they' in sentence \ref{pronoun1} is being used to refer to a specific individual, Chris. This can obviously be translated as $Gc \eif Rc$.

Sentence \ref{pronoun2} must be paraphrased differently: `If a person can play guitar, then \emph{that person} is a rock star.' The pronoun `they' here is not about any particular person, so we need a variable. Translating halfway, we can paraphrase the sentence as, `For any person $x$, if $x$ can play guitar, then $x$ is a rock star.' Now this can be translated as $\forall x (Gx \eif Rx)$. This is the same as, `Everyone who can play guitar is a rock star.'

Consider these further sentences:

\begin{earg}
\item[\ex{anyone1}] If anyone can play guitar, then Lemmy can.
\item[\ex{anyone2}] If anyone can play guitar, then they are a rock star.
\end{earg}

These two sentences have the same antecedent (`If anyone can play guitar$\ldots$'), but they have different logical structures.

Sentence \ref{anyone1} can be paraphrased, `If someone can play guitar, then Lemmy can play guitar.' The antecedent and consequent are separate sentences, so it can be symbolized with a conditional as the main logical operator: $\exists x Gx \eif Gl$.

Sentence \ref{anyone2} can be paraphrased, `For anyone, if that one can play guitar, then that one is a rock star.' It would be a mistake to symbolize this with an existential quantifier, because it is talking about everybody. The sentence is equivalent to `All guitar players are rock stars.' It is best translated as $\forall x(Gx \eif Rx)$.

The English words `any' and `anyone' should typically be translated using quantifiers. As these two examples show, they sometimes call for an existential quantifier (as in sentence \ref{anyone1}) and sometimes for a universal quantifier (as in sentence \ref{anyone2}). If you have a hard time determining which is required, paraphrase the sentence with an English language sentence that uses words besides `any' or `anyone.'

\section{Quantifiers and scope}

In the sentence $\exists x Gx \eif Gl$, the scope of the existential quantifier is the expression $Gx$. Would it matter if the scope of the quantifier were the whole sentence? That is, does the sentence $\exists x (Gx \eif Gl)$ mean something different?

With the key given above, $\exists x Gx \eif Gl$ means that if there is some guitarist, then Lemmy is a guitarist. $\exists x (Gx \eif Gl)$ would mean that there is some person such that if that person were a guitarist, then Lemmy would be a guitarist. Recall that the conditional here is a material conditional; the conditional is true any time the antecedent is false. Let the constant $p$ denote the author of this book, someone who is certainly not a guitarist. The sentence $Gp \eif Gl$ is true because $Gp$ is false. Since someone (namely $p$) satisfies the sentence, then $\exists x (Gx \eif Gl)$ is true. The sentence is true because there is a non-guitarist, regardless of Lemmy's skill with the guitar.

Something strange happened when we changed the scope of the quantifier, because the conditional in QL is a material conditional. In order to keep the meaning the same, we would have to change the quantifier: $\exists x Gx \eif Gl$ means the same thing as $\forall x (Gx \eif Gl)$, and $\exists x (Gx \eif Gl)$ means the same thing as $\forall x Gx \eif Gl$.

%This oddity does not arise with other connectives or if the variable is in the consequent of the conditional. For example, $\exists x Gx \eand Gl$ means the same thing as $\exists x (Gx \eand Gl)$, and $Gl \eif \exists x Gx$ means the same things as $\exists x(Gl \eif Gx)$.

Note that quantifiers count as logical connectives, so one can sensibly ask whether the main connective of a given sentence is a quantifier or something else. (Calling it a `connective' can be slightly confusing, since, unlike connectives like conjunction and disjunction, it doesn't literally \emph{connect} two sentences. Quantifiers are like negations in this respect --- each does count as a connective.) If the scope of the quantifier is the entire sentence, then that quantifier is the main connective, as in $\forall x (Gx \eif Gl)$. If the scope of the quantifier is limited to a subsentence, then that quantifier is not the main connective. For example, in $\exists x Gx \eif Gl$, the main quantifier is the conditional; the existential is part of the antecedent.

\section{Ambiguous predicates}

Suppose we just want to translate this sentence:
\begin{earg}
\item[\ex{surgeon1}] Adina is a skilled surgeon.
\end{earg}
Let the UD be people, let $Kx$ mean `$x$ is a skilled surgeon', and let $a$ mean Adina. Sentence \ref{surgeon1} is simply $Ka$.

Suppose instead that we want to translate this argument:
\begin{quote}
The hospital will only hire a skilled surgeon. All surgeons are greedy. Billy is a surgeon, but is not skilled. Therefore, Billy is greedy, but the hospital will not hire him.
\end{quote}
We need to distinguish being a \emph{skilled surgeon} from merely being a \emph{surgeon}. So we define this symbolization key:
\begin{ekey}
\item[UD:] people
\item[Gx:] $x$ is greedy.
\item[Hx:] The hospital will hire $x$.
\item[Rx:] $x$ is a surgeon.
\item[Kx:] $x$ is skilled.
\item[b:] Billy
\end{ekey}

Now the argument can be translated in this way:
\begin{earg}
\label{surgeon2}
\item[] $\forall x\bigl[\enot (Rx \eand Kx) \eif \enot Hx\bigr]$
\item[] $\forall x(Rx \eif Gx)$
\item[] $Rb \eand \enot Kb$
\item[\therefore] $Gb \eand \enot Hb$
\end{earg}

Next suppose that we want to translate this argument:
\begin{quote}
\label{surgeon3}
Carol is a skilled surgeon and a tennis player. Therefore, Carol is a skilled tennis player.
\end{quote}
If we start with the symbolization key we used for the previous argument, we could add a predicate (let $Tx$ mean `$x$ is a tennis player') and a constant (let $c$ mean Carol). Then the argument becomes:
\begin{earg}
\item[] $(Rc \eand Kc) \eand Tc$
\item[\therefore] $Tc \eand Kc$
\end{earg}
This translation is a disaster! It takes what in English is a terrible argument and translates it as a valid argument in QL. The problem is that there is a difference between being \emph{skilled as a surgeon} and \emph{skilled as a tennis player}. Translating this argument correctly requires two separate predicates, one for each type of skill. If we let $K_1x$ mean `$x$ is skilled as a surgeon' and $K_2x$ mean `$x$ is skilled as a tennis player,' then we can symbolize the argument in this way:
\begin{earg}
\label{surgeon3correct}
\item[] $(Rc \eand K_1c) \eand Tc$
\item[\therefore] $Tc \eand K_2c$
\end{earg}
Like the English language argument it translates, this is invalid. %\nix{Notice that there is no logical connection between $K_1c$ and $Rc$. As symbols of QL, they might be any one-place predicates. In English there is a connection between being a \emph{surgeon} and being a \emph{skilled surgeon}: Every skilled surgeon is a surgeon. In order to capture this connection, we symbolize `Carol is a skilled surgeon' as $Rc \eand K_1c$. This means: `Carol is a surgeon and is skilled as a surgeon.'}

The moral of these examples is that you need to be careful of symbolizing predicates in an ambiguous way. Similar problems can arise with predicates like \emph{good}, \emph{bad}, \emph{big}, and \emph{small}. Just as skilled surgeons and skilled tennis players have different skills, big dogs, big mice, and big problems are big in different ways.

Is it enough to have a predicate that means `$x$ is a skilled surgeon', rather than two predicates `$x$ is skilled' and `$x$ is a surgeon'? Sometimes. As sentence \ref{surgeon1} shows, sometimes we do not need to distinguish between skilled surgeons and other surgeons.

Must we always distinguish between different ways of being skilled, good, bad, or big? No. As the argument about Billy shows, sometimes we only need to talk about one kind of skill. If you are translating an argument that is just about dogs, it is fine to define a predicate that means `$x$ is big.' If the UD includes dogs and mice, however, it is probably best to make the predicate mean `$x$ is big for a dog.'

\section{Multiple quantifiers}
Consider this following symbolization key and the sentences that follow it:
\begin{ekey}
\item{UD:} People and dogs
\item{Dx:} $x$ is a dog.
\item{Fxy:} $x$ is a friend of $y$.
\item{Oxy:} $x$ owns $y$.
\item{f:} Fifi
\item{g:} Gerald
\end{ekey}

\begin{earg}
\item[\ex{dog1}] Fifi is a dog.
\item[\ex{dog2}] Gerald is a dog owner.
\item[\ex{dog3}] Someone is a dog owner.
\item[\ex{dog4}] All of Gerald's friends are dog owners.
\item[\ex{dog5}] Every dog owner is the friend of a dog owner.
\end{earg}

Sentence \ref{dog1} is easy: $Df$.

Sentence \ref{dog2} can be paraphrased as, `There is a dog that Gerald owns.' This can be translated as $\exists x(Dx \eand Ogx)$.

Sentence \ref{dog3} can be paraphrased as, `There is some $y$ such that $y$ is a dog owner.' The subsentence `$y$ is a dog owner' is just like sentence \ref{dog2}, except that it is about $y$ rather than being about Gerald. So we can translate sentence \ref{dog3} as $\exists y \exists x(Dx \eand Oyx)$.
%(Although we could swap the $x$s and $y$s, it is important that we use two different variables here.)

Sentence \ref{dog4} can be paraphrased as, `Every friend of Gerald is a dog owner.' Translating part of this sentence, we get $\forall x(Fxg \eif\mbox{`$x$ is a dog owner'})$. Again, it is important to recognize that `$x$ is a dog owner' is structurally just like sentence \ref{dog2}. Since we already have an x-quantifier, we will need a different variable for the existential quantifier. Any other variable will do. Using $z$, sentence \ref{dog4} can be translated as $\forall x\bigl[Fxg \eif\exists z(Dz \eand Oxz)\bigr]$.

Sentence \ref{dog5} can be paraphrased as `For any $x$ that is a dog owner, there is a dog owner who is $x$'s friend.' Partially translated, this becomes $$\forall x\bigl[\mbox{$x$ is a dog owner}\eif\exists y(\mbox{$y$ is a dog owner}\eand Fxy)\bigr].$$ Completing the translation, sentence \ref{dog5} becomes $$\forall x\bigl[\exists z(Dz \eand Oxz)\eif\exists y\bigl(\exists z(Dz \eand Oyz)\eand Fxy\bigr)\bigr].$$

Consider this symbolization key and these sentences:
\begin{ekey}
\item[UD:] people
\item[Lxy:] $x$ likes $y$.
\item[i:] Imre.
\item[k:] Karl.
\end{ekey}
\begin{earg}
\item[\ex{likes1}]Imre likes everyone that Karl likes.
\item[\ex{likes2}]There is someone who likes everyone who likes everyone that he likes.
\end{earg}

Sentence \ref{likes1} can be partially translated as $\forall x(\mbox{Karl likes $x$}\eif\mbox{Imre likes $x$})$. This becomes $\forall x(Lkx\eif Lix)$.

Sentence \ref{likes2} is complex. There is little hope of writing down the whole translation immediately, but we can proceed by small steps. An initial, partial translation might look like this: $$\exists x\ \mbox{everyone who likes everyone that $x$ likes is liked by $x$}$$
The part that remains in English is a universal sentence, so we translate further: $$\exists x\forall y(\mbox{$y$ likes everyone that $x$ likes}\eif\mbox{$x$ likes $y$}).$$
The antecedent of the conditional is structurally just like sentence \ref{likes1}, with $y$ and $x$ in place of Imre and Karl. So sentence \ref{likes2} can be completely translated in this way $$\exists x\forall y\bigl[\forall z(Lxz \eif Lyz) \eif Lxy\bigr]$$

When symbolizing sentences with multiple quantifiers, it is best to proceed by small steps. Paraphrase the English sentence so that the logical structure is readily symbolized in QL. Then translate piecemeal, replacing the daunting task of translating a long sentence with the simpler task of translating shorter formulae.

\section{Grammaticality rules for QL}

In this section, we provide a formal definition for a \emph{well-formed formula} (wff) and \emph{sentence} of QL.

\subsection{Expressions}
There are six kinds of symbols in QL:

\begin{center}
\begin{tabular}{|c|c|}
\hline
predicates & $A,B,C,\ldots,Z$\\
with subscripts, as needed & $A_1, B_1, Z_1, A_2, A_{25}, J_{375},\ldots$\\
\hline
constants & $a,b,c,\ldots,w$\\
with subscripts, as needed & $a_1, w_4, h_7, m_{32},\ldots$\\
\hline
variables & $x,y,z$\\
with subscripts, as needed & $x_1, y_1, z_1, x_2,\ldots$\\
\hline
sentential connectives & \enot, \eand, \eor, \eif, \eiff\\
\hline
parentheses&( , )\\
\hline
quantifiers& $\forall, \exists$\\
\hline
\end{tabular}
\end{center}

%copied from the definition for SL
We define an \define{expression of QL} as any string of symbols of QL. Take any of the symbols of QL and write them down, in any order, and you have an expression.

\subsection{Well-formed formulae}

By definition, a \define{term of QL} is either a constant or a variable.

An \define{atomic formula of QL} is an n-place predicate followed by $n$ terms. $n$ here can be any non-negative integer, including 0. (A 0-place predicate is an atomic formula of QL just on its own. It does not require the addition of a term for meaningfulness or a truth value. Note that SL atoms are 0-place QL predicates, and so count as QL atoms too.)

Just as we did for SL, we will give a \emph{recursive} definition for a wff of QL. In fact, most of the definition will look like the definition of a wff of SL: Every atomic formula is a wff, and you can build new wffs by applying the sentential connectives.

We could just add a rule for each of the quantifiers and be done with it. For instance: If \metaA{} is a wff, then $\forall x\metaA{}$ and $\exists x\metaA{}$ are wffs. However, this would allow for some confusing sentences like $\forall x\exists x Dx$. What could these possibly mean? There are possible ways to give interpretations of such sentences, but instead we will write the definition of a wff so that such abominations do not even count as well-formed. QL will include the rule that in order for $\forall x\metaA{}$ or $\exists x\metaA{}$ to be a wff, \metaA{} must not already contain an x-quantifier. So $\forall x \exists x Dx$ will not count as a wff because $\exists x Dx$ already contains an x-quantifier.

\begin{enumerate}
\item Every atomic formula is a wff.
\item If \metaA{} is a wff, then $\enot\metaA{}$ is a wff.
\item If \metaA{} and \metaB{} are wffs, then $(\metaA{}\eand\metaB{})$ is a wff.
\item If \metaA{} and \metaB{} are wffs, $(\metaA{}\eor\metaB{})$ is a wff.
\item If \metaA{} and \metaB{} are wffs, then $(\metaA{}\eif\metaB{})$ is a wff.
\item If \metaA{} and \metaB{} are wffs, then $(\metaA{}\eiff\metaB{})$ is a wff.
\item If \metaA{} is a wff, \script{x} is a variable, and \metaA{} contains no \script{x}-quantifiers, then $\forall\script{x}\metaA{}$ is a wff.
\item If \metaA{} is a wff, \script{x} is a variable, and \metaA{} contains no \script{x}-quantifiers, then $\exists\script{x}\metaA{}$ is a wff.
\item All and only wffs of QL can be generated by applications of these rules.
\end {enumerate}

Notice that the `\script{x}' that appears in the definition above is not the variable $x$. It is a \emph{meta-variable} that stands in for any variable of QL. So $\forall xAx$ is a wff, but so are $\forall yAy$, $\forall zAz$, $\forall x_4Ax_4$, and $\forall z_9Az_9$.

We can now give a formal definition for scope: The \define{scope} of a quantifier is the subformula for which the quantifier is the main logical operator.

%\nix{
%Consider the expression $\forall x(\exists y(Dy \eif Ex) \eand \exists y Ey)$. Is it a wff?

%The main logical operator of this expression is the universal quantifier $\forall x$. The scope of the universal quantifier is the subformula $(\exists y(Dy \eif Ex) \eand \enot\exists y Ey)$. It contains one occurrence of $x$ and no x-quantifier, so by rule 7 the entire thing is a wff if this subformula is.

%The main logical operator of the subformula is conjunction. By rule 3, it is a wff if both $\exists y(Dy \eif Ex)$ and $\exists y Ey$ are wffs.

%Consider just $\exists y Ey$. The main logical operator is the existential quantifier $\exists y$, and its scope is $Ey$. Since $Ey$ contains at least one occurrence of $y$ and no y-quantifier, $\exists y Ey$ is a wff by rule 8 if $Ey$ is a wff. Assuming that E is a one-place predicate, $Ey$ is a wff by rule 1.

%We have shown that $\exists y Ey$ is a wff. By similarly reasoning, we can show that $\exists y(Dy \eif Ex)$ is a wff. So, the whole expression is a wff.
%}

\subsection{Sentences}

A {sentence} is something that can be either true or false. In SL, every wff was a sentence. This will not be the case in QL. Consider the following symbolization key:
\begin{ekey}
\item[UD:] people
\item[Lxy:] $x$ loves $y$
\item[b:] Boris
\end{ekey}
Consider the expression $Lzz$. It is an atomic formula: a two-place predicate followed by two terms. All atomic formula are wffs, so $Lzz$ is a wff. Does it mean anything? You might think that it means that $z$ loves himself, in the same way that $Lbb$ means that Boris loves himself. But $z$ is a variable; it does not name some person the way a constant would. The wff $Lzz$ does not tell us how to interpret $z$. Does it mean everyone? Anyone? Someone? Someone in particular? If we had a $z$-quantifier, it would tell us how to interpret $z$. For instance, $\exists zLzz$ would mean that someone loves themself.

Some formal languages treat a wff like $Lzz$ as implicitly having a universal quantifier in front. We will not do this for QL. If you want to say that everyone loves themself, then you need to write the quantifier: $\forall zLzz$

In order to make sense of a variable, we need a quantifier to tell us how to interpret that variable. The scope of an $x$-quantifier, for instance, is the part of the formula where the quantifier tells how to interpret $x$.

In order to be precise about this, we define a \define{bound variable} to be an occurrence of a variable \script{x} that is within the scope of an \script{x}-quantifier. A \define{free variable} is an occurrence of a variable that is not bound.

For example, consider this wff: $$\forall x(Ex \eor Dy) \eif \exists z(Rzx \eif Lzx)$$

The scope of the universal quantifier $\forall x$ is $(Ex \eor Dy)$, so the first $x$ is bound by the universal quantifier but the second and third $x$s are free. There is no $y$-quantifier, so the $y$ is free. The scope of the existential quantifier $\exists z$ is $(Rzx \eif Lzx)$, so both occurrences of $z$ are bound by it. Since this wff contains variables with no instructions for how to interpret them, we don't know how to evaluate it. It is not a sentence.

We define a \define{sentence} of QL as a wff of QL that contains no free variables.

\subsection{Notational conventions}

We will adopt the same notational conventions that we did for SL (p.~\pageref{SLconventions}). First, we may leave off the outermost parentheses of a formula. Second, we will sometimes use square brackets `[' and `]' in place of parentheses to increase the readability of formulae. Third, we give ourselves permission to leave out parentheses between each pair of conjuncts when writing long series of conjunctions. Fourth, we may similarly leave out parentheses between each pair of disjuncts when writing long series of disjunctions.

\section{Common student errors}

A sentence that says everything with one property also has another property should be translated as a universal governing a conditional. Using the obvious interpretation key:

\begin{itemize}
\item `Every student is working': $\forall x (Sx \eif Wx)$
\item `Every student has a friend': $\forall x (Sx \eif \exists y Fxy)$
\item `Only students with friends are working': $\forall x [(Sx \eand Wx) \eif \exists y Fxy]$
\end{itemize}

One common error is to translate sentences of this form with a different kind of shape --- for example, as a universal governing a conjunction, or as an existential governing a conditional. These are very inaccurate translations of these English sentences:

\begin{itemize}
\item $\forall x (Sx \eand Wx)$
\item $\forall x (Sx \eand \exists y Fxy)$
\item $\forall x [(Sx \eand Wx) \eand \exists y Fxy]$
\end{itemize}

These say that \emph{every} object in the UD is a student with the properties in question. Everyone is a student that is working; everyone is a student with a friend; everyone is a working student who has a friend. Any time you have a universal governing a conjunction, you are making a very strong claim --- you're not just talking about objects with a particular property, you're saying that multiple things are true about every single object in the domain. Be very careful if you find yourself offering a universal over a conjunction, and make sure you don't mean to use a conditional instead.

It is also a serious mistake to use an existential instead of a universal for sentences like these:

\begin{itemize}
\item $\exists x (Sx \eif Wx)$
\item $\exists x (Sx \eif \exists y Fxy)$
\item $\exists x [(Sx \eand Wx) \eif \exists y Fxy]$
\end{itemize}

These are very weak claims. They say that there is some object in the domain that satisfies a certain conditional. For example, $\exists x (Sx \eif Wx)$ says there is something in the domain such that, if it is a student, it is working. Given the truth conditions for the material conditional, this will be true if there is even one object in the domain that is not a student, regardless of who is and isn't working; it will also be true if there is even one object in the domain that is working, regardless of who is and isn't a student.

If you find yourself offering, as a translation of some English sentence, an existential governing a conditional, you are almost certainly making a mistake. This is not a reasonable translation of any ordinary English sentence. You probably want either a universal over a conditional (everything with one property has another property) or an existential over a conjunction (there is something with the following properties).

\practiceproblems

\problempart
\label{pr.QLbojackall}
Using the symbolization key given, translate each English-language sentence into QL. Hint: all of these sentences are well-translated as universals governing conditionals.
\begin{ekey}
\item[UD:] all humans and animals in the world of \emph{Bojack Horseman}
\item[Dx:] $x$ is a dog.
\item[Cx:] $x$ is a cat.
\item[Hx:] $x$ is a horse.
\item[Bx:] $x$ is a human being.
\item[Mx:] $x$ is a movie star.
\item[Lxy:] $x$ lives with $y$.
\item[Rxy:] $x$ represents $y$ (as $y$'s agent).
\item[Wxy:] $x$ worked on a movie with $y$.
\item[b:] Bojack
\item[c:] Princess Caroline
\item[d:] Dianne
\item[p:] Mr.\ Peanutbutter
\end{ekey}
\begin{earg}
\item Every movie star is a dog.
\item Every movie star is a dog or a cat.
\item All dog movie stars live with a human being.
\item Everyone who lives with Dianne is a movie star.
\item Princess Caroline represents every dog movie star.
\item Anyone who worked on a movie with Bojack lives with a movie star.
\item Only humans live with Mr.\ Peanutbutter.
\item Everyone who has ever worked on a movie with Bojack is either a dog, a cat, or someone who lives with a movie star.
\end{earg}

\solutions
\problempart
\label{pr.QLbojacksome}
Using the same symbolization key, translate each English-language sentence into QL. Hint: all of these sentences are well-translated as existentials governing conjunctions.
\begin{earg}
\item Mr.\ Peanutbutter lives with a human.
\item Dianne lives with a dog who worked on a movie with Bojack.
\item Princess Caroline represents a horse who lives with a human being.
\item Some human being who worked on a movie with Mr.\ Peanutbutter lives with a dog or a cat.
\item Bojack worked on a movie with a human movie star.
\item Bojack worked on a movie with a nonhuman movie star who lives with Dianne.
\end{earg}

\problempart
\label{pr.QLbojackother}
Using the same symbolization key, translate each English-language sentence into QL. Hint: these should have different forms than the cases above.
\begin{earg}
\item If Mr.\ Peanutbutter is a movie star, then all dogs are movie stars.
\item A dog lives with Dianne and Princess Caroline represents a horse.
\item Princess Caroline represents a horse and a dog.
\item Princess Caroline represents everyone.
\item Dianne doesn't live with anyone.
\item No movie star has ever both worked on a movie with Bojack, and worked on a movie with any cat.
\item Princess Caroline is a cat, but she doesn't represent any cats.
\end{earg}

\solutions
\problempart
\label{pr.QLalligators}
Using the symbolization key given, translate each English-language sentence into QL.
\begin{ekey}
\item[UD:] all animals
\item[Ax:] $x$ is an alligator.
\item[Mx:] $x$ is a monkey.
\item[Rx:] $x$ is a reptile.
\item[Zx:] $x$ lives at the zoo.
\item[Lxy:] $x$ loves $y$.
\item[a:] Amos
\item[b:] Bouncer
\item[c:] Cleo
\end{ekey}
\begin{earg}
\item Amos, Bouncer, and Cleo all live at the zoo.
\item Bouncer is a reptile, but not an alligator.
\item If Cleo loves Bouncer, then Bouncer is a monkey.
\item If both Bouncer and Cleo are alligators, then Amos loves them both.
\item Some reptile lives at the zoo.
\item Every alligator is a reptile.
\item Any animal that lives at the zoo is either a monkey or an alligator.
\item There are reptiles which are not alligators.
\item Cleo loves a reptile.
\item Bouncer loves all the monkeys that live at the zoo.
\item All the monkeys that Amos loves love him back.
\item If any animal is a reptile, then Amos is.
\item If any animal is an alligator, then it is a reptile.
\item Every monkey that Cleo loves is also loved by Amos.
\item There is a monkey that loves Bouncer, but Bouncer does not reciprocate this love.
\end{earg}

\problempart
\label{pr.BarbaraEtc}
These are syllogistic figures identified by Aristotle and his successors, along with their medieval names. Translate each argument into QL.
\begin{description}
\item[Barbara] All $B$s are $C$s. All $A$s are $B$s.
	\therefore\  All $A$s are $C$s.
\item[Baroco] All $C$s are $B$s. Some $A$ is not $B$.
	\therefore\  Some $A$ is not $C$.
\item[Bocardo] Some $B$ is not $C$. All $A$s are $B$s.
	\therefore\  Some $A$ is not $C$.
\item[Celantes] No $B$s are $C$s. All $A$s are $B$s.
	\therefore\  No $C$s are $A$s.
\item[Celarent] No $B$s are $C$s. All $A$s are $B$s.
	\therefore\  No $A$s are $C$s.
\item[Cemestres] No $C$s are $B$s. No $A$s are $B$s.
	\therefore\  No $A$s are $C$s.
\item[Cesare] No $C$s are $B$s. All $A$s are $B$s.
	\therefore\  No $A$s are $C$s.
\item[Dabitis] All $B$s are $C$s. Some $A$ is $B$.
	\therefore\  Some $C$ is $A$.
\item[Darii] All $B$s are $C$s. Some $A$ is $B$.
	\therefore\  Some $A$ is $C$.
\item[Datisi] All $B$s are $C$s. Some $A$ is $B$.
	\therefore\  Some $A$ is $C$.
\item[Disamis] Some $B$ is $C$. All $A$s are $B$s.
	\therefore\  Some $A$ is $C$.
\item[Ferison] No $B$s are $C$s. Some $A$ is $B$.
	\therefore\  Some $A$ is not $C$.
\item[Ferio] No $B$s are $C$s. Some $A$ is $B$.
	\therefore\  Some $A$ is not $C$.
\item[Festino] No $C$s are $B$s. Some $A$ is $B$.
	\therefore\  Some $A$ is not $C$.
\item[Baralipton] All $B$s are $C$s. All $A$s are $B$s.
	\therefore\  Some $C$ is $A$.
\item[Frisesomorum] Some $B$ is $C$. No $A$s are $B$s.
	\therefore\  Some $C$ is not $A$.
\end{description}

\solutions
\problempart Using the symbolization key given, translate each English-language sentence into QL.
\label{pr.QLdogtrans}
\begin{ekey}
\item[UD:] all animals
\item[Dx:] $x$ is a dog.
\item[Sx:] $x$ likes samurai movies.
\item[Lxy:] $x$ is larger than $y$.
\item[b:] Bertie
\item[e:] Emerson
\item[f:] Fergis
\end{ekey}
\begin{earg}
\item Bertie is a dog who likes samurai movies.
\item Bertie, Emerson, and Fergis are all dogs.
\item Emerson is larger than Bertie, and Fergis is larger than Emerson.
\item All dogs like samurai movies.
\item Only dogs like samurai movies.
\item There is a dog that is larger than Emerson.
\item If there is a dog larger than Fergis, then there is a dog larger than Emerson.
\item No animal that likes samurai movies is larger than Emerson.
\item No dog is larger than Fergis.
\item Any animal that dislikes samurai movies is larger than Bertie.
\item There is an animal that is between Bertie and Emerson in size.
\item There is no dog that is between Bertie and Emerson in size.
\item No dog is larger than itself.
\item For every dog, there is some dog larger than it.
\item There is an animal that is smaller than every dog.
\end{earg}

\problempart
\label{pr.QLarguments}
For each argument, write a symbolization key and translate the argument into QL.
\begin{earg}
\item Nothing on my desk escapes my attention. There is a computer on my desk. As such, there is a computer that does not escape my attention.
\item All my dreams are black and white. Old TV shows are in black and white. Therefore, some of my dreams are old TV shows.
\item Neither Holmes nor Watson has been to Australia. A person could see a kangaroo only if they had been to Australia or to a zoo. Although Watson has not seen a kangaroo, Holmes has. Therefore, Holmes has been to a zoo.
\item No one expects the Spanish Inquisition. No one knows the troubles I've seen. Therefore, anyone who expects the Spanish Inquisition knows the troubles I've seen.
\item An antelope is bigger than a bread box. I am thinking of something that is no bigger than a bread box, and it is either an antelope or a cantaloupe. As such, I am thinking of a cantaloupe.
\item All babies are illogical. Nobody who is illogical can manage a crocodile. Berthold is a baby. Therefore, Berthold is unable to manage a crocodile.
\end{earg}

\solutions
\problempart
\label{pr.QLcandies}
Using the symbolization key given, translate each English-language sentence into QL.
\begin{ekey}
\item[UD:] candies
\item[Cx:] $x$ has chocolate in it.
\item[Mx:] $x$ has marzipan in it.
\item[Sx:] $x$ has sugar in it.
\item[Tx:] Boris has tried $x$.
\item[Bxy:] $x$ is better than $y$.
\end{ekey}
\begin{earg}
\item Boris has never tried any candy.
\item Marzipan is always made with sugar.
\item Some candy is sugar-free.
\item The very best candy is chocolate.
\item No candy is better than itself.
\item Boris has never tried sugar-free chocolate.
\item Boris has tried marzipan and chocolate, but never together.
\item Any candy with chocolate is better than any candy without it.
\item Any candy with chocolate and marzipan is better than any candy that lacks both.
\end{earg}

\solutions
\problempart
\label{pr.QLpotluck}
Using the symbolization key given, translate each English-language sentence into QL.
\begin{ekey}
\item[UD:] people and dishes at a potluck
\item[Rx:] $x$ has run out.
\item[Tx:] $x$ is on the table.
\item[Fx:] $x$ is food.
\item[Px:] $x$ is a person.
\item[Lxy:] $x$ likes $y$.
\item[e:] Eli
\item[f:] Francesca
\item[g:] the guacamole
\end{ekey}
\begin{earg}
\item All the food is on the table.
\item If the guacamole has not run out, then it is on the table.
\item Everyone likes the guacamole.
\item If anyone likes the guacamole, then Eli does.
\item Francesca only likes the dishes that have run out.
\item Francesca likes no one, and no one likes Francesca.
\item Eli likes anyone who likes the guacamole.
\item Eli likes everyone who likes anyone that he likes.
\item If there is a person on the table already, then all of the food must have run out.
\end{earg}

\solutions
\problempart
\label{pr.QLballet}
Using the symbolization key given, translate each English-language sentence into QL.
\begin{ekey}
\item[UD:] people
\item[Dx:] $x$ dances ballet.
\item[Fx:] $x$ is female.
\item[Mx:] $x$ is male.
\item[Cxy:] $x$ is a child of $y$.
\item[Sxy:] $x$ is a sibling of $y$.
\item[e:] Elmer
\item[j:] Jane
\item[p:] Patrick
\end{ekey}
\begin{earg}
\item All of Patrick's children are ballet dancers.
\item Jane is Patrick's daughter.
\item Patrick has a daughter.
\item Jane is an only child.
\item All of Patrick's daughters dance ballet.
\item Patrick has no sons.
\item Jane is Elmer's niece.
\item Patrick is Elmer's brother.
\item Patrick's brothers have no children.
\item Jane is an aunt.
\item Everyone who dances ballet has a sister who also dances ballet.
\item Every man who dances ballet is the child of someone who dances ballet.
\end{earg}

\problempart
\label{pr.freeQL}
Identify which variables are bound and which are free.
\begin{earg}
\item $\exists x Lxy \eand \forall y Lyx$
\item $\forall x Ax \eand Bx$
\item $\forall x (Ax \eand Bx) \eand \forall y(Cx \eand Dy)$
\item $\forall x\exists y[Rxy \eif (Jz \eand Kx)] \eor Ryx$
\item $\forall x_1(Mx_2 \eiff Lx_2x_1) \eand \exists x_2 Lx_3x_2$
\end{earg}

\solutions
\problempart
\label{pr.subinstanceQL}
\begin{earg}
\item Identify which of the following are substitution instances of $\forall x Rcx$: $Rac$, $Rca$, $Raa$, $Rcb$, $Rbc$, $Rcc$, $Rcd$, $Rcx$
\item Identify which of the following are substitution instances of $\exists x\forall y Lxy$:
$\forall y Lby$, $\forall x Lbx$, $Lab$, $\exists x Lxa$
\end{earg}


\documentclass[12pt]{beamer}
\title{OSLAB Project 03}
\author{YaoShunyu  LvYingzhe}
\institute{10152130255 LvYingzhe}
\usepackage{beamerthemesplit}
\usepackage{listings}
\usepackage{graphicx}
\usetheme{Pittsburgh}
\usecolortheme{seagull}
\usepackage{courier}

\lstset{basicstyle=\ttfamily}

\begin{document}
\frame{\titlepage}

\section{Design}
\frame{
\frametitle{Basic Conceptions}
\begin{itemize}
\item Maintain an ordered free list
\item De-fragmentation after free
\end{itemize}
}

\begin{frame}[fragile]
\frametitle{Metadata}
\begin{lstlisting}[frame=single]
typedef struct _Node {
    struct _Node *next;
    int size;
} Node;

typedef struct _Header {
    int size;
    struct _Header *magic;
} Header;
\end{lstlisting}
\end{frame}

\subsection{Allocation}
\frame{
\frametitle{How Allocation Works?}
\begin{itemize}
\item Verify argument
\item Round up with bitwise operation
\item Find a suitable block
\item Split/Remove from free list
\item Transform into Header and return
\end{itemize}
}

\frame{
\frametitle{Split or Remove?}
\begin{center}
\begin{tabular}{c|c}
\hline
Condition& Action\\
\hline
pNode$\rightarrow$size $\geq$ size + sizeof(Node)& Split\\
pNode$\rightarrow$size $<$ size + sizeof(Node)& Remove\\
\hline
\end{tabular}
\end{center}
%\centering{sizeof(Node) = 16 bytes}
}

\subsection{Free}
\frame{
\frametitle{How Free Works?}
\begin{itemize}
\item Verify pointer argument
\item Transform into Node
\item Insert into free list
\item Try to merge with left/right neighbour
\end{itemize}
}

\subsection{Drawback}
\frame{
\frametitle{Dilemma}
16-byte header can store mere information!\\
\vspace{2em}
Free list? Fully connected? We want both!
}

\section{Another Implementation}
\frame{
\frametitle{Design}
\begin{itemize}
\item 24-byte Header
\item Maintain a free list
\item Link between neighbours
\end{itemize}
}

\begin{frame}[fragile]
\frametitle{24-byte Header}
\begin{lstlisting}
typedef struct _Node {
    struct _Node *free_next;
    struct _Node *pre;
    int size;
} Node;
\end{lstlisting}
\end{frame}

\frame{
\frametitle{Improvement}
\begin{itemize}
\item Same allocation speed
\item Much faster free speed
\end{itemize}
}

\section{Performance}
\subsection{Allocation}
\begin{frame}[fragile]
\frametitle{Allocation without Free}
\begin{lstlisting}
for i <- 1 to N:
	ptr[i] = alloc(rand(1, BOUND), STYLE)
\end{lstlisting}
\end{frame}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_4.png}
\end{center}
}

\frame{
\frametitle{Conclusion}
\large
The allocation is not the bottleneck.
}

\subsection{Short Free List}
\begin{frame}[fragile]
\frametitle{Random Allocation/Free Calls}
\begin{lstlisting}
op <- rand(ALLOC, FREE)
if op = ALLOC:
	size <- rand(1, BOUND)
	list.add(alloc(size))
else if op = FREE and list.size() > 0:
	index <- rand(list.size())
	free(list[index])
	list.remove(index)
\end{lstlisting}
\end{frame}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_1.png}
\end{center}
}

\frame{
\frametitle{Conclusion}
\large{
Both 16-byte and 24-byte stand the violent test,\\
despite that system performs better.
}
}

\subsection{Allocation Styles}
\frame{
\frametitle{Different Allocation Styles}
\large{
Same test method as short free list\\
\vspace{2em}
Change allocation styles respectively
}
}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_5.png}
\end{center}
}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_6.png}
\end{center}
}

\frame{
\frametitle{Conclusion}
\large{
Performance:\\
First Fit $>$ Best Fit $>$ Worst Fit
}
}

\subsection{Long Free List}
\begin{frame}[fragile]
\frametitle{Numerous Free after Allocation}
\begin{lstlisting}
indexes <- Fisher_Yates(N)
for i <- 1 to N:
	ptr[i] = alloc(rand(1, BOUND))
for i <- 1 to N:
	free(ptr[indexes[i]])
\end{lstlisting}
\end{frame}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_2.png}
\end{center}
}

\frame{
\begin{center}
\includegraphics[height=18em]{Figure_3.png}
\end{center}
}

\frame{
\frametitle{Conclusion}
\large
When free list is long,\\
the cost of free for 16-byte version is significant,\\
while 24-byte version performs like system malloc.
}

\section{Summary}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
\frame{
\frametitle{Comparison}
\begin{center}
\begin{tabular}{c|c|c|c}
\hline
Method& Speed& Fragment& Application\\
\hline
\tabincell{c}{Dynamic\\Allocator}& Moderate& \tabincell{c}{Little External\\No Internal}& malloc\\
\hline
\tabincell{c}{Buddy\\Allocator}& Fast& \tabincell{c}{Little External\\Much Internal}& jelloc\\
\hline
\tabincell{c}{Slab\\Allocator}& Very Fast& \tabincell{c}{No External\\Much Internal}& kalloc\\
\hline
\end{tabular}
\end{center}
}

\frame{
\frametitle{Summary}
\large{
Balance the cost and gain is the eternal theme.\\
\vspace{2em}
Nothing is best, only most suitable.
}
}

\frame{
\frametitle{Fin}
\Large{Thank you!}
}

\frame{
\begin{center}
\begin{tabular}{c|c}
\hline
Condition& Action\\
\hline
pNode$\rightarrow$size $\geq$ size+sizeof(Node)& Split\\
pNode$\rightarrow$size $==$ size + 8& Remove with extra 8-byte\\
pNode$\rightarrow$size $==$ size& Remove\\
\hline
\end{tabular}
\end{center}
}

\frame{
%\frametitle{Example 1}
\begin{center}
\includegraphics[height=16em]{P1.png}
\end{center}
}

\frame{
%\frametitle{Example 2}
\begin{center}
\includegraphics[height=16em]{P2.png}
\end{center}
}

\frame{
%\frametitle{Example 3}
\begin{center}
\includegraphics[height=16em]{P3.png}
\end{center}
}

\end{document}


\documentclass[12pt,letterpaper]{article}

%Packages
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amscd}
\usepackage{dsfont}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage{mathrsfs}
\usepackage{bbm}
\usepackage{framed}
\usepackage{mdframed}
\usepackage{cancel}
\usepackage{float}
\usepackage{mathtools}
%\usepackage[]{mcode}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{automata,arrows}

%Page formatting
\usepackage[letterpaper,voffset=-.5in,bmargin=3cm,footskip=1cm]{geometry}
\setlength{\parindent}{0.0in}
\setlength{\parskip}{0.1in}
\allowdisplaybreaks
\headheight 15pt
\headsep 10pt

% Common Commands
\newcommand\N{\mathbb N}
\newcommand\Z{\mathbb Z}
\newcommand\R{\mathbb R}
\newcommand\Q{\mathbb Q}
\newcommand\lcm{\operatorname{lcm}}
\newcommand\setbuilder[2]{\ensuremath{\left\{#1\;\middle|\;#2\right\}}}
\newcommand\E{\operatorname{E}}
\newcommand\V{\operatorname{V}}
\newcommand\Pow{\ensuremath{\operatorname{\mathcal{P}}}}

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

% 22 style
\newcommand\hint[1]{\textbf{Hint}: #1}
\newcommand\note[1]{\textbf{Note}: #1}
\newenvironment{22enumerate}{\begin{enumerate}[a.]\itemsep0em}{\end{enumerate}}
\newenvironment{22itemize}{\begin{itemize}\itemsep0em}{\end{itemize}}
\fancypagestyle{firstpagestyle} {
  \renewcommand{\headrulewidth}{0pt}%
  \lhead{\textbf{CSCI 0220}}%
  \chead{\textbf{Discrete Structures and Probability}}%
  \rhead{Klivans}%
}

\pagestyle{fancyplain}

\newcommand\EX{\mathds{E}}
\newcommand\PR{\mathds{P}}
\newcommand\zlam{Z_\lambda}
\DeclareMathOperator*{\argmin}{arg\,min}

\begin{document}
  \thispagestyle{firstpagestyle}
  \begin{center}
    {\large \textbf{Recitation 6}}

    {\large Computability}
  \end{center}

   \section*{Review}

	\textbf{Defn 1:} $\Pow{(S)}$ is the set of all subsets of $S$.

	\textbf{Thm 1:} $|\Pow({S})| = 2^{|S|}$ if $S$ is of finite length. If $S$ is an infinite set then $|\Pow({S})| > |S|$.

	\subsection*{Warm-Up}

	Have you ever wondered what a computer is?

	One of the simplest models of computation is a \textbf{Deterministic Finite Automata} (DFA), which takes in an input string (usually a \textbf{binary string}) and either \textbf{accepts} or \textbf{rejects}.

	Here is how it works:
	\begin{itemize}
		\item Each ``circle" is a state with incoming and outgoing ``transitions". Start at the state that is labeled ``start".
		\item Read the input string from left to right. For each input character, follow the labeled transitions from the state you are currently in. This may take you to another state.
		\item Once you have run out of symbols:
			\begin{itemize}
				\item If you are in a state with a double circle, \textbf{accept}.
				\item If you are in a state with a single circle, \textbf{reject}.
			\end{itemize}
	\end{itemize}

	Consider the following DFA, which takes in a string of only 1's.

    \begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 1, transform shape]

    \node[initial,state,minimum size=2cm] (A)                                {};
    \node[state,accepting,minimum size=2cm]         (B) [right of=A]                       {accepting};

    \path[->] (A) edge [bend left]       node [above,align=center]  {$1$} (B)
			    (B) edge [bend left]       node [below,align=center]  {$1$} (A)

        ;

    \end{tikzpicture}

	For example, consider running the DFA on input ``1" . You first start in the left state, then see a ``1" and move to the right state. Therefore the DFA accepts ``1".
	\begin{enumerate}[a.]
	\item Does the DFA accept or reject the following strings:
	\begin{enumerate}[i.]
		\item ``11"
		\item ``111"
		\item ``11111"
	\end{enumerate}
	\item What type of strings does this DFA accept? Prove your claim by induction on the length of the input string.

	\begin{mdframed}
		\vspace{10cm}
	\end{mdframed}
	\item From now on we will only be considering DFA's which take \textbf{binary strings} as input. Consider the following DFA

    \begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 1, transform shape]
	    \node[initial,state,minimum size=2cm] (A)                                {};
    \node[state,accepting,minimum size=2cm]         (B) [right of=A]                       {accepting};

    \path[->] (A) edge [bend left]       node [above,align=center]  {$0$} (B)
 				(A) edge [loop below]       node [align=center]  {$1$} (A)
			    (B) edge [bend left]       node [below,align=center]  {$0$} (A)
 				(B) edge [loop below]       node [align=center]  {$1$} (B);
	\end{tikzpicture}

	Let $L$ be the set of strings accepted by this DFA. Which of the following is correct:
	\begin{enumerate}[i.]
		\item $L = \{ w \ | \ w \text{ is a binary string of even length}\}$
		\item $L = \{ w \ | \ w \text{ is a binary string with an odd number of 0's}\}$
		\item $L = \{ w \ | \ w \text{ is a binary string with an odd number of 1's}\}$
	\end{enumerate}

	\item Let $\Sigma$ denote the set of 0/1 strings of any length. Is this set infinite?

	\item Consider an arbitrary input $w$ to a DFA. Circle all of the correct statements below.
	\begin{enumerate}[i.]
		\item $ w \subseteq \Sigma $
		\item $ w \in \Sigma $
		\item $ \{w\} \in \Pow({\Sigma}) $
	\end{enumerate}

	\item The \textbf{language} $L$ of a DFA is the set of strings which the DFA accepts. Circle all of the correct statements below.
	\begin{enumerate}[i.]
		\item $ L \subseteq \Sigma $
		\item $ L \in \Sigma $
		\item $ L \in \Pow({\Sigma}) $
	\end{enumerate}

	\item Design a DFA that accepts a binary string if it ends in a 0. For example, the string ``100" is accepted and the string ``1101" is rejected.

	\begin{mdframed}
	\vspace{7cm}
	\end{mdframed}

	\item Design a DFA that only takes in strings consisting of 1's and accepts a string only if it is a multiple of 3. (Note that 0 is a multiple of 3)

	\begin{mdframed}
	\vspace{7cm}
	\end{mdframed}

	\end{enumerate}

	\section*{Section Lesson - The Limit of Computation}

	\subsection*{Is there anything a computer can't do? (Set Proof)}

	Our complete model of computation is called a $\textbf{Turing Machine}$ after Alan Turing. We call it complete because a Turing Machine can do everything a computer program can do. It is very similar to a DFA and either accepts or rejects a binary string.

	A turing machine has a language $L$ of binary strings it accepts.

	\begin{enumerate}[a.]
		\item How many languages are there? Write your answer in terms of $|\Sigma|$, $|\Pow(\Sigma)|$ and explain.
		\begin{mdframed}
		\vspace{4cm}
		\end{mdframed}
		\item Like a computer program, a Turing Machine can be represented as a 0/1 string. How many Turing Machines are there? Write your answer in terms of $|\Sigma|$, $|\Pow(\Sigma)|$ and explain.
		\begin{mdframed}
		\vspace{1.6cm}
		\end{mdframed}
		\item What can you conclude from this? Can you build a computer program / Turing Machine for every language?
		\begin{mdframed}
		\vspace{1.6cm}
		\end{mdframed}
 	\end{enumerate}

	\subsection*{Side Note - History}
From Wikipedia: ``Turing is widely considered to be the father of theoretical computer science and artificial intelligence." During the second world war, ``Turing played a pivotal role in cracking intercepted coded messages that enabled the Allies to defeat the Nazis in many crucial engagements". Despite this, he was prosecuted as a criminal for homosexual acts and commited suicide in 1952 at age 41.

	\subsection*{Proof by Contradiction - \textit{Optional Challenge Problem}}

	\textit{This is confusing and is far beyond the scope of CS22, only read on if you are interested. This is not meant to be part of recitation.}

	Let $P$ be a computer program. $P(\omega)$ means that we are running the program $P$ on input $\omega$. Both a program and its input can be represented as a 0/1 string. This means that we can run a program on itself, written as $P(P)$.

	$P(\omega)$ can either terminate or enter an infinite loop. It would be helpful if we had another program, $HALT$, which would take as input $P(\omega)$ that would tell us if $P(\omega)$ would terminate or not.

	You will show that $HALT$ cannot exist with a proof by contradiction.

	Assume for sake of contradiction that $HALT$ exists.

	Using $HALT$ which we have assumed exists, we can build the program $OPPOSITE$. $OPPOSITE$ does not output anything, it either terminates or loops forever. $OPPOSITE$ takes as input a program $P$ and executes the following steps:
	\begin{enumerate}[(1)]
		\item Run $HALT$ on $P(P)$.
		\item If $HALT$ says that $P(P)$ loops forever, then terminate.
		\item If $HALT$ says that $P(P)$ terminates, then loop forever.
	\end{enumerate}

	Since $OPPOSITE$ takes a computer program as input, we can run it on itself.

	Consider running $OPPOSITE$ on $OPPOSITE$.

	\begin{enumerate}[a.]
		\setcounter{enumi}{3}
		\item Can $OPPOSITE(OPPOSITE)$ halt?

	\hint{If $OPPOSITE(OPPOSITE)$ halts, then what happens in step 2 of $OPPOSITE$? Is this a contradicition?}

			\begin{mdframed}
		\vspace{3.6cm}
		\end{mdframed}

		\item Can $OPPOSITE(OPPOSITE)$ loop forever?

	\hint{If $OPPOSITE(OPPOSITE)$ loops forever, then what happens in step 3 of $OPPOSITE$? Is this a contradicition?}

		\begin{mdframed}
		\vspace{3cm}
		\end{mdframed}

	\item Have we reached a contradiction? Why? If so we know that the $HALT$ program cannot exist.

		\begin{mdframed}
		\vspace{3cm}
		\end{mdframed}

	\end{enumerate}

\end{document}


\documentclass[t]{beamer}
\usetheme{Copenhagen}
\setbeamertemplate{headline}{} % remove toc from headers
\beamertemplatenavigationsymbolsempty

\usepackage{amsmath, array, tikz, tcolorbox, bm, tkz-euclide, pgfplots, graphicx}
\pgfplotsset{compat = 1.16}
\usetkzobj{all}
\everymath{\displaystyle}

\title{Circles}
\author{}
\date{}

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Objectives}
    \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\begin{frame}[c]
\includegraphics[scale=0.80]{Images/conics.jpg}
\end{frame}

\section{Identify the center and radius of a circle.}

\begin{frame}{Circles}
You may remember circles from geometry class. In this chapter, we will look at equations and properties of circles. \newline\\	\pause

\begin{tcolorbox}[colback=red!10!white, colframe=red!60!black,, title=\textbf{Circles}]
The set of points, each of whose distance from a fixed point (the center) is the same.
\end{tcolorbox}
\vspace{11pt}	\pause

The standard form of the equation of a circle is
\[
(x-h)^2+(y-k)^2 = r^2
\]

with center $(h, \, k)$ and radius $r$.
\end{frame}

\begin{frame}{Example 1}
Identify the center and exact radius of each.	\newline\\
(a)	\quad	$(x-4)^2 + (y+3)^2 = 49$	\newline\\
\onslide<2->{Center: $(4, -3)$}	\newline\\
\onslide<3->{Radius: $\sqrt{49}$ }	\onslide<4->{$=7$}
\end{frame}

\begin{frame}{Example 1}
(b)	\quad	$(x+1)^2 + (y-7)^2 = 72$	\newline\\
\onslide<2->{Center: $(-1, 7)$}	\newline\\
\onslide<3->{Radius: $\sqrt{72}$ } \onslide<4->{$=6\sqrt{2}$}
\end{frame}

\begin{frame}{Writing the Standard Form of the Equation of a Circle}

To get the standard form, perform the following steps:	\newline\\
\begin{enumerate}
    \item Bring the constant over to the other side of the equation.	\newline\\ \pause
    \item Find the vertex of the $x$-terms and $y$-terms. \newline\\ \pause
        \begin{itemize}
            \item The $x$-coordinates of each vertex will represent $h$ and $k$, respectively.	\newline\\ \pause
            \item The absolute value $y$-coordinates will be added to the constant.
        \end{itemize}
\end{enumerate}
\end{frame}

\begin{frame}{Example 2}
Identify the center and exact radius of each.	\newline\\
(a)	\quad	$x^2-4x+y^2+6y-23=0$
\onslide<2->{\[{\color{blue}\bm{x^2 - 4x}} \qquad + {\color{red}\bm{y^2 - 6y}} \qquad = 23\]}
\onslide<3->{{\color{blue}\textbf{Vertex: }$\bm{(2,-4)}$}}	\newline\\
\onslide<4->{{\color{red}\textbf{Vertex: }$\bm{(3,-9)}$}}
\onslide<5->{\[(x-2)^2 + (y-3)^2 = 23 + |-4| + |-9|\]}
\onslide<6->{\[(x-2)^2+(y-3)^2=36\]}	\\
\onslide<7->{Center: $(2,3)$ \quad Radius: 6}
\end{frame}

\begin{frame}{Example 2}
(b)	\quad $x^2+16x+y^2-8y-1=0$
\onslide<2->{\[{\color{blue}\bm{x^2 + 16x}} \qquad + {\color{red}\bm{y^2 - 8y}} \qquad = 1\]}
\onslide<3->{{\color{blue}\textbf{Vertex: }$\bm{(-8,-64)}$}}	\newline\\
\onslide<4->{{\color{red}\textbf{Vertex: }$\bm{(4,-16)}$}}
\onslide<5->{\[(x+8)^2 + (y-4)^2 = 1 + |-64| + |-16|\]}
\onslide<6->{\[(x+8)^2+(y-4)^2=81\]}	\\
\onslide<7->{Center: $(-8,4)$ \quad Radius: 9}
\end{frame}

\begin{frame}{Example 2}
(c)	\quad $x^2-10x+y^2+2y+14=0$	\newline\\
\onslide<2->{$x^2-10x+y^2+2y=-14$}
\onslide<3->{\[{\color{blue}\bm{x^2 - 10x}} \qquad + {\color{red}\bm{y^2 + 2y}} \qquad = -14\]}
\onslide<4->{{\color{blue}\textbf{Vertex: }$\bm{(5,-25)}$}}	\newline\\
\onslide<5->{{\color{red}\textbf{Vertex: }$\bm{(-1,-1)}$}}
\onslide<6->{\[(x-5)^2 + (y+1)^2 = 14 + |-25| + |-1|\]}
\onslide<7->{\[(x-5)^2+(y+1)^2=40\]}	\\
\onslide<8->{Center: $(5,-1)$ \quad Radius: $2\sqrt{10}$}
\end{frame}

\section{Write the general form of the equation of a circle in standard form}

\begin{frame}{General Form}
Circles can also be written in general form. General form is standard form multiplied out and simplified.    \newline\\	\pause

General form will have all terms on one side of the equation and 0 on the other.
\end{frame}

\begin{frame}{Example 3}
Write the general form of each of the following.	\newline\\
(a)	\quad $(x-3)^2+y^2=6$
\begin{align*}
\onslide<2->{(x-3)^2 + y^2 &= 6} \\[6pt]
\onslide<3->{x^2 - 6x + 9 + y^2 &= 6} \\[6pt]
\onslide<4->{x^2 - 6x + y^2 + 3 &= 0}
\end{align*}
\end{frame}

\begin{frame}{Example 3}
(b)	\quad $(x+7)^2+(y-5)^2=10$
\begin{align*}
\onslide<2->{(x+7)^2+(y-5)^2 &= 10} \\[6pt]
\onslide<3->{x^2 + 14x + 49 + y^2 - 10y + 25 &= 10} \\[6pt]
\onslide<4->{x^2 + 14x + y^2 - 10y + 74 &= 10} \\[6pt]
\onslide<5->{x^2 + 14x + y^2 - 10y + 64 &= 0}
\end{align*}
\end{frame}

\end{document}