\chapter{Blood and Guts}
 \index{Blood and Guts} \index{Blood} \index{Guts}

Death and dismemberment are common dangers for adventurers to face in Dungeon World. In the course of play, characters will take damage, heal, and maybe even die. A character's health is measure by their HP (HP being short for hit points). Damage subtracts from HP, which may lead to death. In the right conditions, or with medical or magical help, damage is healed and HP is restored.

\section{HP}  \index{HP} \index{Hp}

A character's HP is a measure of their stamina, endurance, and health. More HP means the character can fight longer and endure more before facing Death's cold stare. Think of HP in the abstract—a character with high HP can't be hit in the head any more times than one with low HP—they just have greater stores of energy to expend before it comes to blows-to-the-head.

Your class tells you how many HP you get. Your Constitution (the score, not the modifier) always comes into play as well so more Constitution means more HP. If your Constitution permanently changes during play you adjust your HP to reflect your new Constitution score. Unless your Constitution changes your maximum HP stays the same.

\subsection{Damage}  \index{Damage} \index{Damage}

When a character takes damage they subtract the damage dealt from their current HP. Armor mitigates damage; if a character has armor they subtract their armor's value from the damage dealt. Damage can never take a character below 0 HP.

Damage is decided by the attacker. Each class has a base damage die, which may be modified by the weapon used. No matter the implement, the Fighter will always deal more damage than a Wizard—it's about training and skill. Monsters and other non-player characters have a static damage instead of a dice to roll.

Player characters deal damage according to their class, the weapon used and the move they've made. When a character is armed, they deal their class's damage. If a character is unarmed, they probably can't deal damage, or they might do 1 stun damage.

If a move just says "deal damage" the character rolls their class's damage dice plus any bonuses or penalties from moves or weapons. If a move specifies an amount of damage, use that in place of the class's damage roll.

Monsters' damage is listed in their description. Use this damage any time the monster takes direct action to hurt someone, even if they use a method other than their normal attack.

Other sources of damage—like being struck by a chunk of a collapsing tower, or falling into a pit—are left to the GM based on these options:

\startitemize[1,packed]

\item It threatens bruises and scrapes at worst: d4 damage

\item It's likely to spill some blood, but nothing horrendous: d6 damage

\item It might break some bones: d8 damage

\item It could kill a common person: d10 damage

\stopitemize

Add the Ignores Armor tag if the source of the damage is particularly large or if the damage comes from magic or poison.

Temporary or circumstantial armor works the same way: 1 armor for partial cover, 2 armor for major cover.

Remember that damage is both prescriptive and descriptive: if a move says someone takes damage—they have been struck by the weapon or ability causing the damage. If a character is struck by a weapon, they take damage. This means that you can deal damage without making a move. Think of it like an implied move: if you hurt someone and no other move applies, you just deal your damage.

Damage only applies when the injury is general. Falling into a pit trap is general, it could cause any sort of injury, so it's represented by HP loss. When the harm is specific, like an orc pulling your arm from its socket, HP should be part of the effect but not the entirety of it. The bigger issue is dealing with the newly disjointed arm: how do you swing a sword or cast a spell? Likewise having your head chopped off is not HP damage, it's just death.

\subsubsection{Damage From Multiple Creatures}  \index{Damage From Multiple Creatures} \index{Damage} \index{Multiple} \index{Creatures}

It's a brave monster that goes into battle alone. Most creatures fight with someone at their side, and maybe another at their back, and possibly an archer covering the rear, and so on. This can lead to multiple monsters dealing their damage at once.

If multiple creatures attack at once roll the damage die for each of them and take the highest result. If some of the creatures deal a different amount of damage roll the damage with the highest potential for each creature involved in the attack and take the highest result.

\startExample
A goblin orkaster (d10+1 damage ignores armor) and three goblins (d6 damage) all throw their respective weapons—a magical acid orb for the orkaster, spears for the rest—at Lux as she assaults their barricade. I roll the highest damage, d10+1 ignores armor, four times: once for the orkaster, and once for each of the other goblins. I take the highest result, a roll of 8, and tell Lux she takes 9 damage ignoring armor as the acid leaks into the scratches left by the spears.
\stopExample

\subsection{Stun Damage}  \index{Stun Damage} \index{Stun} \index{Damage}

Stun damage is non-lethal damage. A PC who takes stun damage is Defying Danger to do anything at all, the danger being "you're stunned." A GM character that takes stun damage counts it against their HP as usual, but when they are out of HP they are knocked out, not at the GM's mercy.

\subsection{Healing}  \index{Healing}

There are two sources of healing in Dungeon World: the passage of time and medical aid.

Whenever a character spends some time resting without aggravating their wounds they heal. The amount of healing is described in the move (Make Camp for a night in a makeshift bed, Recover for says in civilization).

Medical aid, both magical and mundane, also provides healing. The amount of damage healed is dependent on the move or item used. Some moves may fully replenish HP while others are just enough to keep someone standing through a fight.

No matter the source of the healing a character's HP can never increase over their maximum.

\subsection{Death}  \index{Death} \index{Death}

Death walks the edges of every battle. It waits silently to claim those that fall. A characters who is reduced to 0 HP immediately takes his Last Breath. Death comes for commoner and king alike—no stat is added to the Last Breath roll.

What lies beyond the Black Gates of Death is unknown but it is said that many secrets of the mortal plane are laid bare in what lies beyond.

Death's bargains range from the simple to the costly. Death is capricious. One life may be traded for two more dead while for another Death may demand eternal servitude.

Depending on the outcome of the Last Breath the character may become stable. A stable character stays at 0 HP but is alive and unconscious. If they receive healing they regain consciousness and may return to battle or seek safety. If a stable character takes damage again they face Death and draw their Last Breath once more.

\subsection{After Death}  \index{After Death} \index{Death}

Being an adventurer isn't easy—it's cold nights in the wild and sharp swords and monsters. Sooner or later, you're going to make that long walk to the Black Gates and give up the ghost. In Dungeon World, Death is always watching and waiting for an adventurer to slip up and visit the other side. That doesn't mean you have to give it the satisfaction of sticking around. Death, in its way, is just another challenge to conquer. Even dead adventurers can rise again.

If your character dies, you can ask the GM and the other players to try and resurrect you. The GM will tell them what it will cost to return your poor, dead character to life. If you're all willing to pay that cost and succeed at the goal set before you then your character can cross back over to the land of the living. The Resurrection spell is a special case of this: the magic of the spell gives you an easier way to get a companion back, but the GM still has a say.

While this quest is underway you can play a new character. Maybe a hireling becomes a full-fledged adventurer worthy of a whole share and a part in the real action. Maybe the characters in the party find a new friend in a steading, willing to join them. Maybe your character had a vengeful family member who now seeks to take up their blades and spells to make right what happened. In any case, make your new character as you normally would at level 1. Add Bonds with the other player characters and join in the quest to resurrect the fallen. When the price has been paid and the quest is done, you can choose which character to play. You can then retire your new character to safety or simply have them vanish into the background. At the start of any given session, choose which character you'll be playing that time around and set the other aside. Make sure this change makes sense in the story you've created—characters can't just appear out of nowhere without a good excuse.

GM, when you tell the players what needs to be done to bring their comrade back, don't feel like it has to derail the flow of the current game. Weave it in to your fronts, steadings and prep. This is a great opportunity to change focus or introduce an element you've been waiting to show off. Don't feel, either, that it has to be some great and epic quest. If the character died at the end of a goblin pike, maybe all it takes is an awkward walk home and a few thousand gold pieces donated to a local temple. Think about the ramifications of such a charitable act and how it might affect the world, give the character back his sweet, sweet life and remember; Death never forgets a soul stolen from his realm.

\section{Debilities}  \index{Debilities} \index{Debilities}

Losing HP is a general thing, it's getting tired, bruised, cut, and so on. Some wounds are deeper though. These are debilities.

\startitemize[1,packed]

\item Weak (Str): You can't exert much force. Maybe some important muscles were slashed, or maybe the strength was pulled out of you by magic.

\item Shaky (Dex): You're a little unsteady on your feet and you've got a shake in your hands.

\item Sick (Con): Something just isn't right deep inside. It could be a disease or it might be an organ swollen to bursting.

\item Stunned (Int): You're having trouble… remembering? Is that how that sentence ends?

\item Confused (Wis): Ears ringing. Vision blurred. You're more than a little out of it.

\item Scarred (Cha): It may not be permanent, but for now you don't look so good. Your voice is probably weak too.

\stopitemize

Debilities are inflicted by certain monsters. Not every attack inflicts a debility—they're most often associated with magic, poison, or stranger things like a vampire sucking your blood. Each debility is tied to a stat and gives you -1 to that stat's modifier. The stat's score is unaffected so you don't have to worry about changing your Load when you're Weak.

You can only have each debility once. If you're already Sick and something makes you Sick you just ignore it.

Debilities are harder to heal than HP. Some high level magic can do it, sure, but your best bet is getting somewhere safe and spending a few days in a soft warm bed. Of course debilities are both descriptive and prescriptive: if something happens that would remove a debility, that debility is gone.

Debilities don't replace descriptions and using the established fiction. When someone loses an arm that isn't Weak, that's losing an arm. They can't hold a shield, to begin with. Don't let debilities limit you. A specific disease can have whatever effects you can dream up, Sick is just a convenient shorthand for some anonymous fever picked up from a filthy rat.

\section{Advancement}  \index{Advancement} \index{Advancement}

Dungeon World is ever-changing. The characters change, too. As their adventures progress, player characters gain experience or XP, which lets them level up. This prepares them for greater danger, bigger adventures, and mightier deeds.

Advancement, like everything else in Dungeon World, is both prescriptive and descriptive. Prescriptive means that when a player changes their character sheet the character changes. Descriptive means that when the character changes the player should change the character sheet to reflect that.

This isn't a benefit or detriment to the players or the GM; it's not an excuse to gain more powers or take them away. It's just a reflection of life in Dungeon World.

\startExample
Gregor offers his signature weapon, an axe permanently dyed green in orc blood, as a desperate bargain to save the King from eternal damnation. Without his axe he gets none of the benefits of his signature weapon. Should he recover it he'll have access to its benefits again.
\stopExample

\startExample
Avon, despite being a Wizard, has risen to the notice of Lenoral, the deity of arcane knowledge. After being blessed by an avatar of Lenoral, Avon is under the deity's watch. He can fulfill Petitions and gain boons like a Cleric.
\stopExample

Descriptive changes only happen when the character has clearly gained access to an ability. Befriending a stray dog does not have the same benefits as an animal companion.

\subsection{Level Up}  \index{Level Up} \index{Level}

When you {\bf have a safe moment and XP equal to (or greater than) your current level + 7} , reset your XP to 0 and choose a new advanced move from your class. If you are the Wizard, you also get to add a new spell to your spellbook.

New moves are chosen based on the character's new level. If a move requires 6th level, it's available as the character advances from 5th to 6th level.

If your new level is 3, 6, or 9, you also get to increase a stat by 2. Increase the base score of the stat of your choice by 2, adjust the modifier to reflect the new score. Changing your Constitution increases your maximum and current HP. Ability scores can't go higher than 18.

\subsection{Requires \& Replaces}  \index{Requires \& Replaces} \index{Requires} \index{\&} \index{Replaces}

Some moves depend on other moves. If another move is listed along with the word {\bf Requires}  or {\bf Replaces}  you can only gain the new move if you have the move it requires or replaces.

A move the requires another move can only be taken if you have the move it requires already. You then have both moves and they both apply.

A move that replaces another move can only be taken if you have the move it replaces already. You lose access to the replaced move and just have the new one. The new move will usually include all the benefits of the replaced one: maybe you replace a move that gives you 1 armor with one that gives you 2 armor instead.

\section{Bonds}  \index{Bonds} \index{Bonds}

Bonds are what make you a party of adventurers, not just a random assortment of people. Seeing your bonds evolve and play off each other is one of the best parts of the game.

That said, this isn't high drama. How you feel about Titanius doesn't matter so much when you're both fighting for life and limb against a horde of demons who would happily end the world if they could. Bonds are the icing on the cake: they make your adventures (and your adventurers) more interesting.

\subsection{Resolving Bonds}  \index{Resolving Bonds} \index{Bonds}

At the end of each session you may resolve one bond. Resolution of a bond depends on both you and the player of the character you share the bond with: you suggest that the bond has been resolved and, if they agree, it is.

A bond is resolved when it no longer describes how you relate to that person. That may be because circumstances have changed—Thelian used to have your back but after he didn't rush to save you from the ankheg you're not so sure. Or it could be because that's no longer a question—you guided Wesley before and he owed you, but he paid that debt when he saved your life with a well-timed spell. Any time you look at a Bond and think "that's not a big factor in how we relate anymore" the bond is at a good place to resolve.

If a character has blank Bonds left over from character creation they can resolve that Bond without asking anyone and write a new one or they can add a character's name to the Bond instead of writing a new Bond. Ignoring a Bond at character creation does not reduce the total Bonds available to the character.

\subsection{Writing New Bonds}  \index{Writing New Bonds} \index{Bonds}

You write a new bond whenever you resolve an old one. Your new bond may be with the same character, but it doesn't have to be.

When you write a new bond first choose another character. Then pick something relevant to the last session you've just finished—maybe a place you traveled together or a treasure you discovered. Lastly, choose a thought or belief your character holds that ties the two together and an action, something you're going to do about it. You'll end up with something like this:

\startitemize[1,packed]

\item Avon proved himself a coward in the dungeons of Xax'takar, he is a dangerous liability to the party and must be watched.

\item Mouse's quick thinking saved me from the white dragon we faced. I owe her a boon.

\item Xotoq won the Bone-and-Whispers Axe through trickery! It will be mine, I swear it.

\item Valeria's kindness to the Gnomes of the Vale has swayed my heart. I will find a way to prove to her my love.

\stopitemize

These new bonds act just like the old ones. They are still resolved and still grant XP when resolved.

If you chose not to use a starting Bond you can replace it with a new Bond at the end of any session. This does not count as resolving a Bond, you don't get XP for it.

\section{Alignment}  \index{Alignment} \index{Alignment}

Alignment is your characters' way of thinking and moral compass. For the character, this is reflected as an ethical ideal, religious strictures, or maybe just a gut instinct. It reflects the things your character might aspire to be and can guide you when you're not sure what to do next. Some characters might proudly proclaim their alignment while others might hide it away. A character might not say "I'm an evil person" but may instead say "I put myself first." That's all well and good for a character, but the world knows otherwise. Buried deep down inside is the ideal self a person wants to become—it is this mystic core that certain spells and abilities tap into when detecting someone's alignment. Every sentient creature in Dungeon World bears an alignment, be she an elf, a human, or some other, stranger thing.

The alignments are Good, Lawful, Neutral, Chaotic, and Evil. Each one shows an aspiration to be a different type of person.

Lawful creatures aspire to impose order on the world, either for their own benefit or for that of others. Chaotic creatures embrace change and idealize the messy reality of the world, prizing freedom above all else. Good creatures seek to put others before themselves. Evil creatures put themselves first at the expense of others.

A Neutral creature looks out for itself so long as that doesn't hurt anyone else much. Neutral characters are content to live their lives and pursue their own goals and let others do the same.

Most creatures are Neutral. They take no particular pleasure in harming others, but will do it if it is justified by their situation. Those that put an ideal, be it Law, Chaos, Good, or Evil, above themselves are rarer.

Even two creatures of the same alignment can come into conflict. Aspiring to help others does not grant infallibility, two Good creatures may fight and die over two different views of how to help others. A great king may wage war on a free city despite his good alignment since he sees (justly, perhaps) that the peoples of the free city will live a better life under his enlightened rule.

\subsection{Changing Alignment}  \index{Changing Alignment} \index{Alignment}

Alignment can, and will, change. Usually such a change comes about as a gradual slide to a decisive moment when the pain caused becomes too great or the benefit too others too small.

Any time a player would earn XP from their current alignment they can, instead of taking the XP, change the alignment. The player must have a reason for the change which they can explain to the other players. If they can't explain why their character has had a change of heart they can't change alignment. Don't abuse the privilege.

The first time a player character changes alignment it must be to another alignment listed for their class, though they can choose any of the alignment moves below for a listed alignment. After that they can go to any alignment they like.

In some cases a player character may switch alignment moves while still keeping the same alignment. This reflects a smaller shift, one of priority instead of a wholesale shift in thinking. They simply choose a new move for the same alignment from below and mention why their character now sees this as important.

GM characters can change alignment as well, even if the players have already discerned the character's alignment. Since NPCs do not earn XP the GM can change the NPC's alignment any time it's warranted. The GM is subject to the same justification requirement: if an NPC with a known alignment is no longer that alignment the players may ask the GM for a reason why.

\subsubsection{Lawful}  \index{Lawful} \index{Lawful}

\startitemize[1,packed]

\item Uphold the letter of the law over the spirit

\item Fulfill a promise of import

\item Bring someone to justice

\item Choose honor over personal gain

\item Put power in its rightful hands

\item Return treasure to its rightful owner

\stopitemize

\subsubsection{Good}  \index{Good} \index{Good}

\startitemize[1,packed]

\item Ignore danger to aid another

\item Lead others into righteous battle

\item Give up powers or riches for the greater good

\item Reveal a dangerous lie

\item Show mercy

\stopitemize

\subsubsection{Neutral}  \index{Neutral} \index{Neutral}

\subsubsection{Chaotic}  \index{Chaotic} \index{Chaotic}

\startitemize[1,packed]

\item Reveal corruption

\item Break an unjust law to benefit another

\item Defeat a tyrant

\item Reveal hypocrisy

\stopitemize

\subsubsection{Evil}  \index{Evil} \index{Evil}

\startitemize[1,packed]

\item Take advantage of someone's trust

\item Cause suffering for its own sake

\item Destroy something beautiful

\item Upset the rightful order

\item Harm an innocent

\stopitemize


\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
With the rollout of robots in pedestrian-rich environments, the capability for robots to navigate among them safely, anticipative and efficiently becomes increasingly important. However, while intuitive to humans, socially-aware navigation still poses a difficult problem, mainly due to the stochastic and highly dynamic nature of human movement. Despite of the rise of the predictive capabilities of state-of-the-art, deep generative, multi-modal and probabilistic pedestrian prediction models, existing works mostly either use strong simplifying assumptions for human movement or non-interpretable methods for robot decision-making. This work combines the predictive power of deep learned prediction models and the certifiability of constrained trajectory optimization methods. Therefore, it proposes an optimization formulation to efficiently leverage generative models for trajectory optimization beyond their outputs, while guaranteeing a safe robot-human-interaction. The proposed algorithm is shown to enable anticipative, safe, but not overly conservative movements among many pedestrians.

\vspace{1cm}
\textbf{Keywords}: Human-Robot Interaction, Crowd-Navigation


\chapter{Introduction}

\section*{Exercise Solutions}

\begin{enumerate}
	\item Bounded by one plane: \textbf{half-space} \\
	Bounded by two planes: \textbf{infinite wedge} \\
	Bounded by three planes: \textbf{open ended infinite triangular prism} \\
	Bounded by four planes: \textbf{tetrahedron}

	\item Suppose figure \textit{A} is congruent to \textit{B} and figure \textit{B} is congruent to \textit{C}. Align \textit{A} and \textit{B} such that they completely coincide. We essentially have two names \textit{A} and \textit{B} for the same geometric figure. Now \textit{C} can be super-imposed onto \textit{B}, which is the same as \textit{A}. So \textit{C} coincides completely with \textit{A} hence \textit{C} and \textit{A} are congruent as well.

	\item If two different lines don't intersect they meet at zero points. Following the property mentioned in $\S4$ page 2, it is impossible for two distinct lines to coincide in two or more points. This implies that if two distinct lines intersect then they intersect at exactly point.

	\item If the line doesn't intersect a plane then they meet at zero points. Again following the property mentioned in $\S4$ page 2, if a line lies on a plane then it intersects with the plane at two or more points. This implies that if a line is NOT on the plane then it can intersect the plane at atmost one point.

	\item *

	\item Pick any two points on the plane. From $\S4$ we know that ``\textit{For every two points in space there is a unique line passing through these}''. Again as mentioned in $\S4$ we also know that ``\textit{If a straight line passes through two points of a plane then this line lies on the plane}''.

	\item Consider the following figure:

	\includegraphics[scale=0.75]{chapters/ch00/images/07}

	If we align the straight edge along with the line. If line is perfectly straight then we should not see the ``bumps'' in figures B and C. If in one case the bumps were hidden underneath the ruler then flipping the ruler would reveal them.

	\item *

	\item For any point $p$ on a plane there are infinite other points on the same plane to form a pair. Let's call the second point $q$. From $\S4$ we recall that ``\textit{If a straight line passes through two points (p and q in this case) of a plane then this line lies on the plane}''. For each $p$ there exist infinite $q$ implying that infinite number of lines lying on the same plane as $p$ that pass through $p$.

	\item Cylinder, paper bent into an arc etc

	\item \underline{Infinite lines}: It is obvious to see

	\underline{Rays}: Move one of the rays such that the end points of both rays intersect. Now transform one of the rays such that it superimposes the other. Apply argument given for infinite lines above.

	\item Three steps are required:

	\includegraphics[scale=1.3]{chapters/ch00/images/12}

	\vskip 5cm
%13:
	\item Yes, it is unique.

	\includegraphics[scale=0.8]{chapters/ch00/images/13}

	Consider two segments $OA$ and $AB$ on the $y$ axis. Their sum would be segment $OB$. Now we find two segments on the $x$ axis $OA^{'}$ (which is congruent to $OA$) and $A^{'}B^{'}$ (congruent to $AB$). Their sum would be $OB^{'}$. Since lengths of $OB$ and $OB^{'}$ are exactly equal, one can simply rotate $OB$ 90\degree clockwise about $O$ to get $B$ exactly on top of $B^{'}$. Hence they are congruent.

%14:
	\item Non-congruent arcs belonging to non-congruent circles:

	\includegraphics[scale=0.8]{chapters/ch00/images/14}

	Non-congruent arcs belonging to congruent circles:

	\includegraphics[scale=0.8]{chapters/ch00/images/14b}

	Non-congruent arcs belonging to same circle:

	\includegraphics[scale=0.8]{chapters/ch00/images/14c}

	\vskip 5cm
%15:
	\item Non congruent arcs subtended by congruent cords:

	\includegraphics[scale=0.8]{chapters/ch00/images/15a}

	\vskip 3mm
	Yes:

	\includegraphics[scale=0.8]{chapters/ch00/images/15b}

%16:
	\item

	\item

	\item No. Yes.

	\item Suppose that segment $AD$ is the sum of $AB$, $BC$ and $CD$:

	\includegraphics[scale=0.8]{chapters/ch00/images/19a}

	Recognizing $AD$ with $DA$ we get:

	\includegraphics[scale=0.8]{chapters/ch00/images/19b}

	Of course $AD$ and $DA$ are congruent:

	$$ AB + BC + CD = DC + CB + BA $$

	If we identify the segments $DC$, $CB$ and $BA$ with $CD$, $BC$ and $AB$ respectively, we get:

	$$ AB + BC + CD = CD + BC + AB $$

	It obeys commutativity law because even though filliping a segment may change its position relative to others but its size remains exactly the same.

\end{enumerate}

books/[On going] Geometry, Book I - Planimetry (Kiselev)/solutions/chapters/ch00/ch00.tex


         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         % Information sheet for the Matlab lab - Maths 6111 %
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[10pt]{article}
\input ma_no_html_header

\usepackage{color}
\usepackage{hyperref}
\hypersetup{breaklinks=true,colorlinks=true}
%\input ma_header
\setlength{\parindent}{0pt}
\pagestyle{myheadings}
% \markright{
% \protect {\protect \epsfxsize=0.2 true cm \protect \epsffile {dolph.line.eps}}
% \it Maths 3018/6111 - Numerical methods \hfill}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\thispagestyle{empty}
\begin{center}
\textbf{\Large Maths 3018/6111 - Numerical Methods \\*[8mm]
Worksheet 5 - Solutions}\\*[.8cm]
\end{center}

\section*{Theory}

\begin{enumerate}
\item Explain when multistep methods such as Adams-Bashforth are
  useful and when multistage methods such as RK methods are better.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
  {\bf Note:} There were typos (transposing multistep and multistage)
  on early versions of this worksheet.

  Multistep methods are more computationally efficient (fewer function
  evaluations) and more accurate than multistage methods. However,
  they are not self-starting, difficult to adapt to use variable step
  sizes, and the theory to show that they are stable and convergent is
  more complex. They are most useful when efficiency is the primary
  concern and the system is sufficiently well controlled that equally
  spaced steps can be taken.

  In other situations, as discussed on worksheet 4, the self-starting
  simplicity combined with adaptive stepping means that multistage
  methods are preferrable.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
\item Compute the coefficients of the AB3 algorithm.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
  For Adams-Bashforth methods we have
  \begin{equation*}
    y_{n+1} = y_n + b_{k-1} f_n + b_{k-2} f_{n-1} + \dots + b_0
    f_{n+1-k}.
  \end{equation*}
  Here we have $k=3$ and so we have
  \begin{equation*}
    y_{n+1} = y_n + h \left[b_{2} f_n + b_{1} f_{n-1} + b_0 f_{n-2}
    \right].
  \end{equation*}

  We want to ensure that this gives an exact approximation of the
  integral form for polynomials of order $s = 0, \dots, 2$. That is,
  we want
  \begin{equation*}
    \int_{x_n}^{x_{n+1}} p_s(x) = h \left[b_{2} p_s(x_n) + b_{1}
      p_s(x_{n-1}) + b_0 p_s(x_{n-2}) \right].
  \end{equation*}
  For simplicity, and without loss of generality, we set $n=0$, and
  use the polynomials
  \begin{align*}
    p_0(x) & = 1, \\
    p_1(x) & = x, \\
    p_2(x) & = x (x + h).
  \end{align*}
  We then see that we get
  \begin{align*}
    s &= 0: & \int_0^h 1 & = h \left[ b_2 \times 1 + b_1 \times 1 +
      b_0 \times 1 \right] \\
    && 1 & = b_2 + b_1 + b_0. \\
    s &= 1: & \int_0^h x & = h \left[ b_2 \times 0 + b_1 \times (-h) +
      b_0 \times (-2h) \right] \\
    && 1/2 & = - b_1 -2 b_0. \\
    s &= 2: & \int_0^h x (x + h) & = h \left[ b_2 \times 0 + b_1 \times 0 +
      b_0 \times (2h^2) \right] \\
    && 5/6 & = 2 b_0. \\
  \end{align*}

  By back substitution we find
  \begin{equation*}
    b_0 = \frac{5}{12}, \qquad b_1 = -\frac{4}{3}, \qquad b_2 =
    \frac{23}{12},
  \end{equation*}
  which means that the algorithm is
  \begin{equation*}
    y_{n+1} = y_n + \frac{h}{12} \left[ 23 f_n - 16 f_{n-1} + 5
      f_{n-2} \right].
  \end{equation*}
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
\item Explain the meaning of stability, consistency and convergence
  when applied to numerical methods for IVPs. State the theorem
  connecting these.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
  \emph{Stability}: The numerical solution is bounded at all
  iterations over a finite interval. I.e., if the true solution is
  $y(x)$ and $x \in [0, X]$ with $X$ finite, and we use $N+1$ steps
  with $x_0=0$ and $x_N=X$, then $|y_i|$ is finite for all $i = 0, 1,
  \dots, N$, irrespective of the value of $N$.

  \emph{Consistency}: The numerical method is a faithful
  representation of the differential equation to lowest order in $h$.
  That is, if you Taylor expand the numerical difference scheme and
  let $h \rightarrow 0$ you recover the original differential equation
  independent of the limiting process.

  \emph{Convergence}: If $y(x)$ is the exact solution and $y(x;h)$ the
  numerical solution using step size $h$, in the limit as $h
  \rightarrow 0$ the numerical solution is the exact solution:
  \begin{equation*}
    \lim_{h \rightarrow 0} y(x;h) = y(x).
  \end{equation*}

  The theorem states that consistency and stability are equivalent to
  convergence.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
\item Using the stability polynomial and your results above, check the
  order of accuracy and the stability of the 3 step Adams-Bashforth
  method.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
  The coefficients of AB3 in the standard $k$-step formula notation are
  \begin{align*}
    a_3 & = 1 & a_2 & = -1 & a_1 & = 0 & a_0 & = 0 \\
    b_3 & = 0 & b_2 & = \frac{23}{12} & b_1 & = -\frac{4}{3} & b_0 & =
    \frac{5}{12}.
  \end{align*}
  Therefore the stability polynomial is
  \begin{equation*}
    p(z) = z^3 - z^2
  \end{equation*}
  with derivative
  \begin{equation*}
    p'(z) = 3 z^2 - 2 z
  \end{equation*}
  and the other required polynomial is
  \begin{equation*}
    q(z) = \frac{1}{12} \left( 23 z^2 - 16 z + 5 \right).
  \end{equation*}

  To check consistency we need that $p(1) = 0$ and $p'(1) = q(1)$,
  which we check:
  \begin{align*}
    p(1) & = 1 - 1 \\
    & = 0. \\
    p'(1) - q(1) & = (3 - 2) - \frac{1}{12} \left( 23 - 16 + 5 \right)
    \\
    & = 1 - \frac{12}{12} \\
    & = 0.
  \end{align*}
  So the method is consistent.

  To check stability we have to find the roots of the stability
  polynomial $p(z)$. We write
  \begin{equation*}
    p(z) = z^2 (z - 1)
  \end{equation*}
  to see that the roots are 0 (twice) and 1, which means that the
  method satisfies the \emph{strong} root condition implying both
  stability and relative stability, meaning it is a useful method.
  %
  \begin{center}
    \rule{0.9\textwidth}{.1pt}
  \end{center}
  %
\end{enumerate}

\end{document}


\chapter{Social Interactions}\label{ch:socialInteractions}
In order to adjudicate a social encounter, a GM should track the opposing side's resolve against any given argument, their annoyance, and the group's overall progress in convincing the opposing side of their position. \\
Depending on the difficulty of the encounter, these numbers range in the following areas:\\
Resolve: 1--24\\
Annoyance: 0--5\\
Progress: 0--5\\
These values start at a value that the GM decides, but annoyance and progress usually start at 0, unless the characters have interacted with the opposing side previously, or if the opposing side has already heard of the characters.\\
Resolve is basically the bonus that is added to any given DV of a check that the characters have to roll against the opposing side.\\
Whenever a PC makes an argument, the GM decides if that argument can change the opposing side's mind and if it can fail to do so.\\
If the argument can both succeed or fail, the Character rolls the given check against the NPCs Resolve + a specific value that the GM decides based on the PCs argument and the NPCs annoyance.\\
If the argument can not fail, the GM adds one point to the Progress.\\
If the argument can not succeed, the GM adds one point to the Annoyance.\\
If the annoyance or progress reach 5, the social interaction ends.
If it ends because the group annoyed the opposing side too much, they failed the encounter.
If they brought forth enough good arguments to reach a progress of 5, the party wins the argument.\\
Of course, these values can be changed based on the situation.


% !TEX root = ../thesis.tex
%
\chapter{Related Work}
\label{sec:related}
In this chapter we quickly want to revise other works touching the tasks of this thesis. In \treft{sec:related:detection} we discuss multiple successful object detection methods using \glspl{cnn} and in \treft{sec:related:retrieval} we list previous image retrieval systems also focusing on those employing \glspl{cnn}.

\section{Object detection}
\label{sec:related:detection}
The first work to approach object detection with a \gls{cnn} were \citet{girshick_rich_2014}, with their \textbf{\gls{rcnn}}. For each image they use Selective Search to generate a set of region proposals. Selective Search is a technique to identify object-like, but type independent, regions probing texture and color of the image at multiple scales. All these boxes are reshaped to a uniform size and forwarded through a normal classification network (in their case AlexNet \citep{krizhevsky_imagenet_2012}) to yield feature vectors from the \gls{fc} layers. Lastly a multi-class \gls{svm} classifies these proposals. Additionally the \gls{rcnn} is trailed by a linear regression model which uses the classified boxes to produce tighter box coordinates. Although the results proved that \glspl{cnn} can greatly improve detection results, the method is hard to train because the classifier network, the \gls{svm} and the regressor have to be trained independently. Also at test time classifying each region box independently is extremely slow.

A year later again \citet{girshick_fast_2015} released \textbf{Fast \gls{rcnn}} which improves computation performance and training complexity. Instead of computing features for each proposed region, Fast \gls{rcnn} computes the features for the whole image at once. Then the regions in the image are projected onto the feature map of the network, thus yielding the patch-wise features. Those patch-wise feature maps are pooled, forwarded through \gls{fc} layers and finally into a classifier and the box regressor. The \gls{svm} is replaced with a SoftMax and the linear regression model with a additional \gls{fc} layer. As such the three models from \gls{rcnn} become one unified network which is faster and easier to train.
\clearpage
In the same year \citet{ren_faster_2015} tackled the big bottleneck of this approach, which is the region proposal system, with their \textbf{Faster \gls{rcnn}}. The previously used Selective Search is slow and still independent of the model. Using also the features generated by the \gls{conv} layers, they add a new network branch, a \gls{rpn}, to generate box proposals. These are used for the same \gls{roi} pooling as in the Fast \gls{rcnn}. The \gls{rpn} is a \gls{fcn} that takes the feature map and at each positions tests for a predefined set of $k$ anchor boxes whether those could be objects. So for each window the \gls{rpn} outputs a score of \textit{objectness} and coordinates of the bounding box. Those are then the inputs for the Fast \gls{rcnn} method.

This year \citet{he_mask_2017} extended this approach with \textbf{Mask \gls{rcnn}} to pixel-wise segmentation of images. In the previous versions the regions from the original image were projected onto the feature maps by just down-scaling their shapes with the respective factor and discretizing them on the feature grid. This rounding introduces errors in the proposed bounding boxes and leads to misalignment. Instead they use bilinear interpolation inside each region to find more precise feature representations. This process is done by a new branch inside the Faster \gls{rcnn} and outputs binary pixel-wise masks for each \gls{roi}. The regions are classified as in the Faster \gls{rcnn} and as such they are able to return semantic image segmentations.

\citet{dai_r-fcn:_2016} incorporates the \gls{roi}-wise processing into the main network branch of their \textbf{R-FCN} through a series of \gls{conv} layers. The \gls{conv} layers encode scores at relative positions like top-left or bottom-center. Next the regions from the \gls{rpn} are divided into the same relative sub-regions and each sub-region is used to pool from the corresponding layer and then to vote for the whole \gls{roi}.

As our work also has to focus on time performance, it is related to other fast object detectors. \citet{redmon_you_2016} use a freshly designed network architecture \textbf{YOLO} to achieve object detection at real-time. The input image is divided into a regular grid. The last \gls{fc} layer from their network predicts for each cell of the grid the class probabilities and the coordinates and objectness confidence of two bounding boxes. Detections get selected by the multiplication of their conventional class probabilities and their individual confidence predictions. While the method is extremely fast it is limited by the shape of bounding boxes it will predict.
\clearpage
\section{Image retrieval}
\label{sec:related:retrieval}
Retrieving relevant images from large databases by searching for similarities to an exemplar image, is a long used idea. The first methods employed hand-crafted features like histograms, SIFT or \gls{hog} to compare different images in a low dimensional space. Problems in such approaches arise with semantically close groups of objects with wide visual differences.\\
One of the more classical but successful approaches is \textbf{OASIS} \citep{chechik_large_2010}. Here the authors solve a bilinear similarity function for whole images using sparse local pattern descriptors. While the approach is successful under its training settings it is heavily restricted in that it has to be trained on all needed image classes.

\citet{wu_online_2013} learns image similarity using stacked neural networks. The inputs for those are low image features and they learn representations of modalities of these features giving a optimized multi-model combination. With a bag of five features they achieve better results, retrieving similar images, than OASIS but also lack wider applicability through the complexity of training.

The step forward to just learning similarity on top of raw pixels is done by \citet{babenko_neural_2014}, as they show that using just the distance between  the outputs of \gls{fc} layers, it is possible to retrieve visually similar images. More sophisticated is \textbf{DeepRanking} \citep{wang_learning_2014} use the deep feature of an AlexNet, together with visual features extracted by convolutions, in a linear embedding as a image descriptor. With the distance between the embeddings as measure, they rank the similarity of images to a query image. The visual features and the linear embedding are learned by feeding the network triplets of query, positive, and negative images. They show that the learned features outperform hand-crafted ones.

Neural networks shown success in being used in reverse image search systems. In \citep{khosla_building_2015} they train different network architectures on images of shoes and use a distance measure between the descriptors from the trailing \gls{fc} layer to retrieve alike shoes to a query shoe. Similarly the image descriptions from a task-specifically fine-tuned network are used in \citep{chen_visual-based_2015} to select similar styles inside clothing catalogs. Using the idea of \citep{wang_learning_2014} \citet{bell_learning_2015} learn a embedding of image descriptors. They use a siamese network architecture to learn from tuples of similar or dissimilar pairs. With the learned embedding space they retrieve similar interior designs given a query product by picking close training samples in the embedding space.


\chapter{Introduction}

\section{Background and Recent Research}
\subsection{Global Value Numbering}
Global value numbering (GVN) is a program analysis that categorizes expressions in the program that compute the same static value\cite{vandrunen}. This information can be used to remove redundant computations.

\subsection{Literature Survey}
Kildall in 1973\cite{kildall} introduced the most precise global analysis algorithm for program optimization by using the concept of an optimizing function for generalization. Optimizing functions for constant propagation and common subexpression elimination were described but the algorithm had an exponential cost.

Alpern, Wegman and Zadeck (AWZ) introduced an efficient algorithm in 1988\cite{awz} which uses a value graph to represent symbolic execution of a program. It represents the values of variables after a join using a selection function $\phi$, similar to the selection function in static single assignment (SSA) form, and treats these functions as uninterpreted, hence remains incomplete.

The polynomial time algorithm introduced by Ruthing, Knoop and Steffen (RKS) in 1999\cite{ruthing} extends the algorithm by AWZ. It employs a normalization process using some rewrite rules for terms involving $\phi$ functions, until congruence classes reach a fixed point. This results in discovery of more equivalences and is optimal for acyclic programs but remains incomplete.

Karthik Gargi proposed balanced algorithms in 2002\cite{gargi} which extend AWZ to perform forward propagation and reassociation and to consider back edges in SSA graph. This discovers more equivalences but is still incomplete.

Gulwani and Necula in 2004\cite{gulwani} proposed a polynomial time algorithm which is optimal if only equalities of bounded size are considered.

\textbf{A Simple Algorithm for Global Value Numbering} proposed recently by N Saleena and Vineeth Paleri\cite{sagvn} builds on Kildall's approach and is complete in terms of number of redundancies identified. It introduces the concept of a \emph{Value Expression} to represent a set of equivalent expressions which makes this algorithm fairly simple to understand. We decided to implement this algorithm on GCC framework as we are interested in a complete algorithm for global analysis problem.

\section{Motivation}
A compiler is a fairly large software program and forms an excellent software engineering case study. Study of compiler optimizations provides a good blend of theory (for generality and correctness) and practice (for validation and efficiency). Global Value Numbering, specifically, is an interesting global data flow analysis for study. Also, this was an opportunity to work on a popular open source software such as GCC, learn about its huge professional code base and interact with its community of developers.


\documentclass[12pt]{article}
\usepackage{graphics}
\begin{document}

\section*{NYU Physics 1---Final Exam}

\vfill

\paragraph{Name:} ~

\paragraph{email:} ~

\vfill

This exam consists of six problems.  Write only in this booklet.  Be
sure to show your work.

\vfill

\emph{You must ensure that the proctor checks off your name on the
attendance sheet when you hand in your exam.  Your exam will
\textbf{not} be graded if your name is not checked off.}

\clearpage

\section*{Problem 1}

(a) A block of mass $M$ slides down a plane inclined at an angle
$\theta$ to the horizontal.  There is a coefficient of sliding
friction $\mu$ between block and plane.  What is the magnitude of the
acceleration $a$ of the block down the plane?  Be sure to draw a
free-body diagram.

\vfill

(b) A \emph{different} block of mass $M$ sits on the same plane.  In
this case, the frictional force is so great that the block does not
slide down the plane.  What is the magnitude $f$ and direction of the
frictional force?  Try to give your answer in terms of $M$, $g$ and
$\theta$ only.

\vfill ~

\clearpage

\section*{Problem 2}

A major-league baseball pitcher can throw a baseball at about
$100~\mathrm{mi\,hr^{-1}}$.  Estimate the impulse $\Delta p$ given to
the ball by the pitcher.  Make an estimate of the work done $\Delta W$
by the pitcher on the ball during the throw.  Now figure out some way
to compute the average force $F$ applied by the pitcher to the ball.
Does your answer seem reasonable?  \emph{Clearly state your
assumptions, and justify any that are non-trivial.}

\clearpage

\section*{Problem 3}

Draw free-body diagrams for all the masses and pulleys in this
mechanism.  Find the tensions in all three strings and the
accelerations of the two blocks.
\\ \rule{0.35\textwidth}{0pt}
\resizebox{0.3\textwidth}{!}{\includegraphics{../mp/tackle_blocks.eps}}
\\
Be careful with your kinematic constraints, and assume that all the
strings and pulleys are massless and frictionless.

\clearpage

\section*{Problem 4}

A figure skater spins in place on frictionless ice at angular speed
$\omega_i$ with her hands outstretched.  She has a total moment of
inertia $I_i$.  As the skater draws her hands into her body, her
moment of inertia decreases to $I_f=I_i/2$.  Does her kinetic energy
$K$ increase, decrease, or stay the same?  \emph{Explain your answer
concisely but clearly with either one sentence or a short
calculation.}

\clearpage

\section*{Problem 5}

A ``seconds'' pendulum has a period of exactly $2.000~\mathrm{s}$.

\textsl{(a)}~If $g=9.797~\mathrm{m\,s^{-2}}$ in Austin Texas, how long
should a Texan make her or his seconds pendulum?

\vfill

\textsl{(b)}~If $g$ is 0.1~percent (a factor of 1.001) larger in
Paris, France, than in Austin, how different, in percent, should the
length of a Parisian's seconds pendulum be than a Texan's?  Should it
be longer or shorter?  \emph{Note:} You can answer this question
without getting part (a) correct.

\vfill ~

\clearpage

\section*{Problem 6}

Consider the following attractive radial force law, which is
\emph{very different} from Newton's law of gravity:
\begin{equation}
F = \frac{k\,M\,m}{r^4}
\end{equation}
Where $k$ is a constant.

Consider a body of mass $m$ orbiting in a circular orbit of radius $R$
around another body of mass $M$, with $m\ll M$, according to the above
force law.

\textsl{(a)}~One of Kepler's laws is that for gravity, orbital period
$T$ is related to orbital radius $r$ by $T\propto r^{3/2}$.  Use
either a dimensional argument or a direct calculation to get the
equivalent relation for this \emph{very different} radial force law.

\vfill

\textsl{(b)}~What is the potential energy of the mass $m$ at radius
$r=R$, relative to its potential energy at infinite $r$?  \emph{Note:}
You can answer this question without getting part (a) correct.

\vfill ~

\clearpage

[This page intentionally left blank for calculations or other work.]

\end{document}


%\documentclass[12pt]{article}
\documentclass[12pt,landscape]{article}

\include{preamble}

\newcommand{\instr}{\small Your answer will consist of a lowercase string (e.g. \texttt{aebgd}) where the order of the letters does not matter. \normalsize}

\title{Math 342W / 650 Fall \the\year{} \\ Midterm Examination Two}
\author{Professor Adam Kapelner}

\date{Thursday, May 13, \the\year{}}

\begin{document}
\maketitle

%\noindent Full Name \line(1,0){410}

\thispagestyle{empty}

\section*{Code of Academic Integrity}

\footnotesize
Since the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.

Activities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:

\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using an unauthorized cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.
\\

\noindent By taking this exam, you acknowledge and agree to uphold this Code of Academic Integrity. \\

%\begin{center}
%\line(1,0){250} ~~~ \line(1,0){100}\\
%~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date
%\end{center}

\normalsize

\section*{Instructions}
This exam is 100 minutes (variable time per question) and closed-book. You are allowed \textbf{two} 8.5 $\times$ 11'' pages (front and back) of a \qu{cheat sheet}, blank scrap paper and a graphing calculator. Please read the questions carefully. No food is allowed, only drinks. %If the question reads \qu{compute,} this means the solution will be a number otherwise you can leave the answer in \textit{any} widely accepted mathematical notation which could be resolved to an exact or approximate number with the use of a computer. I advise you to skip problems marked \qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \fbox{Box} in your final answers. Good luck!

\pagebreak

\problem\timedsection{11} Consider the following causal diagrams where all events have other causes that are not displayed. It is assumed that the timing of events is known and to scale. Assume you have a training set $\mathbb{D}$ with a large sample size $n$ with columns x, y, z (and w if included).

\vspace{-.3cm}
\begin{figure}[htp]
\centering
\includegraphics[width=7in]{basic_causal_diagrams}
\end{figure}

\vspace{-.4cm}

\vspace{-0.3cm}\benum\truefalsesubquestionwithpoints{11}

\begin{enumerate}[(a)]
%\item In diagram A, x and z could be spuriously correlated.
%\item In diagram D, w and y could be spuriously correlated.
%\item In diagram E, w and y could be spuriously correlated.
%\item Assume the data generating process that $\mathbb{D}$ is sampled from is diagram A. When running the OLS model y $\sim$ x you find a strong correlation. This correlation is spurious.
\item Assume  diagram A is the data generating process that $\mathbb{D}$ is sampled from. When running the OLS model y $\sim$ x you find a strong correlation. In out-of-sample data there would likely be a near-zero correlation betweeen y and x.
\item In diagram A, z is a lurking variable when analyzing the causal effect of x on y.
\item In diagram B, z is a lurking variable when analyzing the causal effect of x on y.
\item In diagram D, w is a lurking variable when analyzing the causal effect of x on y.
\item In diagram E, w is a lurking variable when analyzing the causal effect of x on y.
\item In diagram C, x causes y (according to our in-class definition of causality).
\item In diagram B, an OLS model of y $\sim$ x demonstrates that x and y are correlated but this correlation disappears if you run an OLS model of y $\sim$ x + z
\item In diagram D, an OLS model of y $\sim$ x demonstrates that x and y are correlated but this correlation disappears if you run an OLS model of y $\sim$ x + w
\item In diagram D, x can be used to predict y better than $g_0$ (out of sample)
\item In diagram D, w can be used to predict y better than $g_0$ (out of sample)
\item In diagram E, an OLS model of y $\sim$ x demonstrates that x and y are correlated but this correlation disappears if you run an OLS model of y $\sim$ x + w

\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\problem\timedsection{7} \ingray{Consider the following causal diagrams where all events have other causes that are not displayed. It is assumed that the timing of events is known and to scale.} Assume now you have a training set $\mathbb{D}$ with a large sample size $n$ with columns x, y, z (and w if included).
%
%
%\begin{figure}[htp]
%\centering
%\includegraphics[width=7in]{basic_causal_diagrams}
%\end{figure}
%
%\vspace{-.5cm}
%
%\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{14}
%
%\begin{enumerate}[(a)]
%\item Assume the data generating process that $\mathbb{D}$ is sampled from is diagram A. When running the OLS model y $\sim$ x you find a strong correlation. This correlation is spurious.
%\item Assume the data generating process that $\mathbb{D}$ is sampled from is diagram A. When running the OLS model y $\sim$ x you find a strong correlation. In out-of-sample data there would likely be a near-zero correlation betweeen y and x.
%\item Assume the data generating process that $\mathbb{D}$ is sampled from is diagram E. When running the OLS model y $\sim$ x you find a strong correlation. This correlation is spurious.
%\item Assume the data generating process that $\mathbb{D}$ is sampled from is diagram E. When running the OLS model y $\sim$ x you find a strong correlation. In out-of-sample data there would likely be a near-zero correlation betweeen y and x.
%\end{enumerate}
%\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{7} Consider the \texttt{iris} data frame, a famous dataset of four measurements on $n = 150$ iris flowers where the response is \texttt{Species}, a categorical variable with three levels: versicolor, viriginica and setosa (where each species has 50 observations). Below is a sample:

\lstset{
  basicstyle=\footnotesize,
  xleftmargin=.2\textwidth, xrightmargin=.2\textwidth
}
\begin{lstlisting}
   Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
          5.5         4.2          1.4         0.2     setosa
          7.6         3.0          6.6         2.1     virginica
          7.2         3.2          6.0         1.8     virginica
          5.6         3.0          4.1         1.3     versicolor
          5.2         4.1          1.5         0.1     setosa
...
\end{lstlisting}

\vspace{-0.7cm}

\noindent And also consider the \texttt{common\_name} data frame which provides the common names:

\lstset{
  basicstyle=\footnotesize,
  xleftmargin=.3\textwidth, xrightmargin=.3\textwidth
}
\begin{lstlisting}
Species         English_Name
aphylla	        table iris
setosa 		      bristle-pointed iris
reichenbachii   rock iris
versicolor      blue flag iris
flavescens      lemonyellow iris
\end{lstlisting}
\vspace{-1cm}

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{8}

%\begin{changemargin}{-0.8cm}{0cm}
Joining the two data frames on the \texttt{Species} column via a ...
\begin{enumerate}[(a)]
%\item These two data frames can be joined by either a left join, a right join, an inner join and a full join.\\
\item ... left join (where \texttt{iris} was on the left) would yield a new data frame with 150 rows.
\item ... right join (where \texttt{iris} was on the right) would yield a new data frame with 150 rows.
\item ... left join (where \texttt{common\_name} was on the left) would yield a new data frame with 150 rows.
\item ... right join (where \texttt{common\_name} was on the right) would yield a new data frame with 150 rows.
\item ... inner join would yield a new data frame with 150 rows.
\item ... full join would yield a new data frame with 150 rows.
\item ... inner join would yield a new data frame with 100 rows.
\item ... full join would yield a new data frame with 100 rows.
\end{enumerate}
%\end{changemargin}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{6} \ingray{Consider the \texttt{iris} data frame, a famous dataset of four measurements on $n = 150$ iris flowers where the response is \texttt{Species}, a categorical variable with three levels: versicolor, viriginica and setosa (where each species has 50 observations).} Consider the subset of the observations for only y = setosa. Below is a sample:

\lstset{
  basicstyle=\footnotesize,
  xleftmargin=.25\textwidth, xrightmargin=.25\textwidth
}
\begin{lstlisting}
  Sepal.Length Sepal.Width Petal.Length Petal.Width
          5.2         4.1          1.5         0.1
          5.4         3.4          1.7         0.2
          5.3         3.7          1.5         0.2
          4.5         2.3          1.3         0.3
          4.8         3.0          1.4         0.3
...
\end{lstlisting}
\vspace{-1cm}
\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{7}

If you were to convert this dataset from wide format to long format ...

\begin{enumerate}[(a)]
\item ... there would be two columns
\item ... there would be four columns
\item ... all columns would have continuous features
\item ... all columns would have categorical features
\item ... there would be 50 rows
\item ... there would be 200 rows
\item ... the resulting data frame would be easier to manipulate using a visualization library such as \texttt{ggplot2}
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{9} \ingray{Consider the \texttt{iris} data frame, a famous dataset of four measurements on $n = 150$ iris flowers where the response is \texttt{Species}, a categorical variable with three levels: versicolor, viriginica and setosa (where each species has 50 observations).} We fit a CART model with \texttt{Nodesize} = 1 to this dataset. The result is a model with 17 internal nodes and 9 leaf nodes with $\hat{y}$ values of 1 (= setosa), 2 (= virginica) and 3 (= versicolor). Below is an abridged illustration of the tree. Ignore the ``M$\rightarrow$'' and \qu{$\leftarrow$M} notation. Numbers in parentheses indicate number of observation in a node. The left direction means the split condition is true.

\vspace{-0.2cm}
\begin{figure}[htp]
\centering
\includegraphics[width=5.3in]{classification_tree.png}
\end{figure}
\vspace{-0.3cm}
\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{14}
\vspace{-0.2cm}
\begin{enumerate}[(a)]
\item This is a regression tree model
\item This model can be written as a linear model of the form $g(\x) = b_0 + b_1 x_1 + b_2 x_2 + b_3 x_3 + b_4 x_4$ where $x_1, x_2, x_3, x_4$ are the four measurements \texttt{Sepal.Length}, \texttt{Sepal.Width}, \texttt{Petal.Length} and \texttt{Petal.Width}
\item This model is overfit
\item If the stump is considered depth zero, then this tree has a depth of 3
\item For all $\mathbb{D}$, a binary split on \texttt{Petal.Length} is the best overall split to reduce heterogeneity in the response
\item For future data, this model will likely predict setosa correctly with high probability
\item If \texttt{Petal.Length} $> 2.45$, there exists a second binary split that is able to isolate all virginica observations in one leaf and all versicolor observations in the other leaf
\item If \texttt{Petal.Length} $> 4.95$, $\hat{y}$ will always be the same
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{6} Consider the following data frame displayed in random order, where missingess is visualized in red. The last column is the response $y$ and there is no missingness in the response. The feature that has the most missingness is $x_{34}$ and the observation with the most missingness is row \#10.

\begin{figure}[htp]
\centering
\includegraphics[width=7in]{missingness.png}
\end{figure}

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{7}

\begin{enumerate}[(a)]
\item Dropping all observations with missingness (listwise deletion) will seriously impact future performance of any model fit with the data
\item The dataset exhibits one MCAR missingness mechanism and this mechanism is the same for all entries
\item The dataset may exhibit a different independent NMAR missingness mechanism for each feature
\item When building a predictive model, the most prudent thing to do is to drop the feature $x_{34}$ and to drop observation \#10
\item Imputing missing values using the columns' sample averages will result in a data frame with no missingness
\item The recommended procedure is to impute with the \texttt{missForest} and then use only the imputed matrix $\X$ to construct your model ignoring the original $\X$ matrix
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{6} \ingray{Consider the following data frame, where missigness is visualized in red. The last column is the response $y$ and there is no missingness in the response. The feature that has the most missingness is $x_{34}$ and the observation with the most missingness is row \#10.}

\begin{figure}[htp]
\centering
\includegraphics[width=7in]{missingness.png}
\end{figure}

\noindent Now assume that $x_{34}$ and observation \#10 were dropped and the remaining missing values were imputed via the \texttt{missForest} algorithm.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{6}

\begin{enumerate}[(a)]
\item An OLS model cannot be fit on the imputed data frame
\item A ridge model with $\lambda = 10^{-6}$ cannot be fit on the imputed data frame
\item A lasso model with $\lambda = 10^{-6}$ cannot be fit on the imputed data frame
\item An elastic net model with $\lambda = 10^{-6}$ and $\alpha = 0.1$ cannot be fit on the imputed data frame
\item After using the model selection procedure to select $\lambda$ for the lasso based on oos $s_e$, the number of nonzero linear coefficients in the resulting model will likely be small relative to $p$
\item After using the model selection procedure to select $\lambda$ for the ridge based on oos $s_e$, the number of nonzero linear coefficients in the resulting model will likely be small relative to $p$
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\problem\timedsection{7} Consider the \texttt{diamonds} data frame, which has $n = 53940$ diamonds with 9 measurements each and the response variable \texttt{price} measured in USD. Below is a sample of five observations:
%
%\lstset{
%  basicstyle=\footnotesize,
%  xleftmargin=.2\textwidth, xrightmargin=.2\textwidth
%}
%\begin{lstlisting}
%  carat       cut color clarity depth table price    x    y    z
%  0.41 Very Good     D     SI2  62.3    61   638 4.72 4.75 2.95
%  0.50 Very Good     F     VS2  62.8    57  1402 5.05 5.08 3.18
%  1.03      Fair     I     SI2  65.2    56  3530 6.42 6.35 4.16
%  1.10     Ideal     I     SI1  62.1    57  5037 6.60 6.64 4.11
%  1.51 Very Good     E     VS2  63.3    61 13757 7.24 7.17 4.56
%...
%\end{lstlisting}
%\vspace{-.5cm}
%
%\noindent We wish to fit many models to this dataset: (1) OLS with the formula $y \sim .$ (2) OLS with the formula $y \sim . * .$ (3) OLS with the formula $y \sim . * . * .$ (4) a regression tree with \texttt{nodesize} = 10 (5) a Random Forest (RF) with 500 trees. The dataset is sampled into a distinct training set of size $n=3,000$, a distinct select set of $n=3,000$ and a distinct test set of $n=3,000$ and these three subsets are used in accordance with the modeling selection procedure we learned about in class.
%
%\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{14}
%
%\begin{enumerate}[(a)]
%\item The training set is fit to each of the five models above
%\item The select set is fit to each of the five models above
%\item Predicting on the training set is \qu{out of sample}
%\item Predicting on the select set is \qu{out of sample}
%\item Each of the five models above predict on the select set
%\item Each of the five models above predict on the test set
%\item The model that predicts on the test set was fit on $n=6000$ observations
%\item The final model was fit on $n=6000$ observations
%\item For the RF model, there is no need to use a separate out-of-sample set as you can assess the oos performance using the oob error estimate
%\end{enumerate}
%\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{14} Consider the \texttt{diamonds} data frame, which has $n = 53940$ diamonds with 9 measurements each and the response variable \texttt{price} measured in USD. We wish to fit many models to this dataset: (1) OLS with the formula $y \sim .$ (2) OLS with the formula $y \sim . * .$ (3) OLS with the formula $y \sim . * . * .$ (4) a regression tree with \texttt{nodesize} = 10 (5) a Random Forest (RF) with 500 trees. Consider two model selection procedures:
\vspace{-0.1cm}
\begin{enumerate}[A.]
\item The three-split dataset model selection procedure where the original dataset is sampled into a distinct training set of size $n=3,000$, a distinct select set of $n=3,000$ and a distinct test set of $n=3,000$.
\item The \textit{nested resampling procedure} for model selection where $K_{select} = 3$ and $K_{test} = 5$ on a subset of $n=9,000$ observations from the original data frame.
\end{enumerate}

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{16}

\begin{enumerate}[(a)]
\item In procedure [A], the training set is fit to each of the five models above
\item In procedure [A], the the select set is fit to each of the five models above
\item In procedure [A], predicting on the training set is \qu{out of sample}
\item In procedure [A], predicting on the select set is \qu{out of sample}
\item In procedure [A], each of the five models above predict on the test set
\item In procedure [A], the model that predicts on the test set was fit on $n=6000$ observations
\item In procedure [A], the final model was fit on $n=6000$ observations
%\item For the RF model, there is no need to use a separate out-of-sample set as you can assess the oos performance using the oob error estimate
\item Procedure [B] is more computationally costly than procedure [A]
\item Procedure [B] has lower variance in its estimate of future performance
\item Procedure [B] is likely to select a model with better future performance than procedure [A]
\item There are a total of 16 models fit during procedure [B] including the final model
\item There are a total of 26 models fit during procedure [B] including the final model
\item There are a total of 65 models fit during procedure [B] including the final model
\item There are a total of 76 models fit during procedure [B] including the final model
\item During procedure [B], for each of the $K_{test}$ outer resamplings, there could be a different model that predicts on the test set
\item In procedure [B], the final model will be the modal model out of the $K_{test}$ models selected
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{8} \ingray{Consider the \texttt{diamonds} data frame, which has $n = 53940$ diamonds with 9 measurements each and the response variable \texttt{price} measured in USD.} Beginning with the design matrix $\tilde{\X}$ created by the OLS model of $y \sim . * . * .$ we consider the \emph{greedy forward stepwise} linear model algorithm. The dataset is sampled into a distinct training set of size $n=3,000$, a distinct select set of $n=3,000$ and a distinct test set of $n=3,000$ and these three subsets are used in accordance with the modeling selection procedure we learned about in class.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{7}

\begin{enumerate}[(a)]
\item This algorithm at most has $p+1$ iterations where $p+1$ is the number of columns in $\tilde{\X}$ and in each iteration, it fits a different linear model
\item This algorithm likely has less than $p+1$ iterations
\item The prediction error in the training set is monotonically decreasing
\item The prediction error in the select set is monotonically decreasing
\item The prediction error in the test set is monotonically decreasing
\item When predicting on the test set, the model will definitely have the same number of degrees of freedom as the final model
\item The future performance of the model selected by the \emph{greedy forward stepwise} linear model algorithm will be better than the future performance of the OLS model of  $y \sim .$ based on your knowledge of this dataset from class
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{7} \ingray{Consider the \texttt{diamonds} data frame, which has $n = 53,940$ diamonds with 9 measurements each and the response variable \texttt{price} measured in USD. Beginning with the design matrix $\tilde{\X}$ created by the OLS model of $y \sim . * . * .$ we consider the \emph{greedy forward stepwise} linear model algorithm. The dataset is sampled into a distinct training set of size $n=3,000$, a distinct select set of $n=3,000$ and a distinct test set of $n=3,000$ and these three subsets are used in accordance with the modeling selection procedure we learned about in class.} The design matrix $\tilde{\X}$ has $p+1 = 1477$ number of columns. Consider the case where we run through all of the $t = 1, 2, \ldots, 1477$ iterations of this stepwise algorithm.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{7}

Let $g_t$ denote the model fit at every iteration $t$.

\begin{enumerate}[(a)]
\item As $t$ increases the bias of $g_t$ increases monotonically
\item As $t$ increases the variance of $g_t$ increases monotonically
\item As $t$ increases the MSE of $g_t$ increases monotonically
\item $g_1, g_2, \ldots, g_{1477}$ are independent models\\

Consider the model $g_{avg}$ that averages models $g_1, g_2, \ldots, g_{1477}$.

\item $g_{avg}$ is called a \qu{bagged} model
\item $g_{avg}$ has lower bias than $g_{1477}$
\item $g_{avg}$ always has lower MSE than the model that was selected by the greedy forward stepwise linear model algorithm
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{12} Consider the \texttt{adult} data frame, which has data on $n = 32,560$ people with 14 measurements each and the response variable \texttt{income} which is binary (1 = the person has an income $>$50K and 0 = the person has an income  $\leq$50K). Consider the following model fit to \texttt{adult\_train}, a training set of $n=10,000$ leaving the remainder of the data as a holdout set. The $\b$ vector for the fitted model is displayed below on the last line.

\lstset{
  basicstyle=\footnotesize,
  xleftmargin=.0\textwidth, xrightmargin=.0\textwidth
}
\begin{lstlisting}
> lmod = glm(income ~ age + hours_per_week + capital_gain + education_num, adult_train, family = "binomial")
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
> coef(lmod)
   (Intercept)            age hours_per_week   capital_gain  education_num
       -8.1582         0.0454         0.0380         0.0003         0.3200
\end{lstlisting}

\vspace{-0.8cm}\benum\truefalsesubquestionwithpoints{12}

\begin{enumerate}[(a)]
\item The vector $\b$ was computed solely using linear algebra calculations
\item For a future person $\x_*$, the quantity $\x_*\b$ can be used to produce probability predictions in the set (0, 1)
\item For a future person $\x_*$, if $\x_*\b < 0$, this model is predicting that it is impossible for this person's income to be $>$50K
\item The Brier score for this model's predictions in-sample will likely be closer to zero than the Brier score for predictions out-of-sample.
\item The probability predictions of this model will be the same predictions as a probit model fit to the same data
\item \qu{For a future person $\x_*$, the probability that this person's income $>$50K will increase by 0.044 if the person becomes one year older}.
\item \qu{For a future person $\x_*$, the probability that this person's income $>$50K will increase by 0.044 if the person becomes one year older as long as the three other measurements for this person do not change}.
\item If \texttt{age} increases and the three other variables remain the same, the predicted probability will increase for any $\x$
\item The warning message means there was numerical underflow and/or overflow during the computation of $\b$
\item For a 20yr-old with no job, capital gains or education, the probability he has an income of $>$50K is 0.9993 to the nearest four significant digits
\item For a 20yr-old with no job, capital gains or education, the probability he has an income of $>$50K is 0.0007095 to the nearest four significant digits
\item You have all the information necessary in this problem statement to trace out a DET curve
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{14} \ingray{Consider the \texttt{adult} data frame, which has data on $n = 32,560$ people with 14 measurements each and the response variable \texttt{income} which is binary (1 = the person has an income $>$50K and 0 = the person has an income  $\leq$50K).} Considering the model from the previous quesiton fit to \texttt{adult\_train}, a training set of $n=10,000$ leaving the remainder of the data as a holdout set, we now predict on \texttt{adult\_test} and perform binary classification:

\lstset{
  basicstyle=\footnotesize,
  xleftmargin=.15\textwidth, xrightmargin=.15\textwidth
}
\begin{lstlisting}
> yhat = as.numeric(predict(lmod, adult_test, type = "response") > 0.9)
> table(y_test, yhat)
             yhat
y_test     0     1
     0 15107    30
     1  4439   585
\end{lstlisting}

\vspace{-0.8cm}\benum\truefalsesubquestionwithpoints{9}

\begin{enumerate}[(a)]
\item This is likely an asymmetric cost classification model
\item The FDR, FOR, FPR calculated using the above table are honest estimates of future performance
\item This model makes mistakes 22.2\% of the time to the nearest three significant digits
\item This classification model is absolutely the best classification model you could build from \texttt{lmod} to minimize costs when the cost of a FP is \$9 and the cost of a FN is \$9
\item This model implies the point (0.00198, 0.116) on an ROC curve to the nearest three significant digits
\item When predicting in the future using this classification model, if $\hat{y} = 1$, then the probability of making an error is 4.88\% to the nearest three signification digits
\item If the cost of a false positive is \$100 and the cost of false negatives was negligible and there is no reward for classifying correctly, then you expect to lose \$0.15 per prediction to the nearest two signification digits
\item If the probability threshold was increased within the binary classification model, then the number of FP's would decrease
\item You have all the information necessary in this problem statement to compute the AUC for \texttt{lmod}
\end{enumerate}
\eenum\instr\pagebreak
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%!TEX root = forallxyyc-solutions.tex
%\part{Interpretations}
%\label{ch.semantics}
%\addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}

\stepcounter{chapter} % Extensionality

\chapter{Truth in FOL}\setcounter{ProbPart}{0}
\problempart
\label{pr.TorF1}
Consider the following interpretation:
	\begin{ebullet}
		\item The domain comprises only Corwin and Benedict
		\item `$\atom{A}{x}$' is to be true of both Corwin and Benedict
		\item `$\atom{B}{x}$' is to be true of Benedict only
		\item `$\atom{N}{x}$' is to be true of no one
		\item `$c$' is to refer to Corwin
	\end{ebullet}
Determine whether each of the following sentences is true or false in that interpretation:
\begin{earg}
\item $\atom{B}{c}$ \hfill \myanswer{False}
\item $\atom{A}{c} \eiff \enot \atom{N}{c}$ \hfill \myanswer{True}
\item $\atom{N}{c} \eif (\atom{A}{c} \eor \atom{B}{c})$ \hfill \myanswer{True}
\item $\forall x\,\atom{A}{x}$ \hfill \myanswer{True}
\item $\forall x \enot \atom{B}{x}$ \hfill \myanswer{False}
\item $\exists x(\atom{A}{x} \eand \atom{B}{x})$ \hfill \myanswer{True}
\item $\exists x(\atom{A}{x} \eif \atom{N}{x})$ \hfill \myanswer{False}
\item $\forall x(\atom{N}{x} \eor \enot \atom{N}{x})$ \hfill \myanswer{True}
\item $\exists x\,\atom{B}{x} \eif \forall x\,\atom{A}{x}$ \hfill \myanswer{True}
\end{earg}

\problempart
\label{pr.TorF2}
Consider the following interpretation:
	\begin{ebullet}
		\item The domain comprises only Lemmy, Courtney and Eddy
		\item `$\atom{G}{x}$' is to be true of Lemmy, Courtney and Eddy.
		\item `$\atom{H}{x}$' is to be true of and only of Courtney
		\item `$\atom{M}{x}$' is to be true of and only of Lemmy and Eddy
		\item `$c$' is to refer to Courtney
		\item `$e$' is to refer to Eddy
	\end{ebullet}
Determine whether each of the following sentences is true or false in that interpretation:
\begin{earg}
\item $\atom{H}{c}$ \hfill \myanswer{True}
\item $\atom{H}{e}$\hfill \myanswer{False}
\item $\atom{M}{c} \eor \atom{M}{e}$ \hfill \myanswer{True}
\item $\atom{G}{c} \eor \enot \atom{G}{c}$ \hfill \myanswer{True}
\item $\atom{M}{c} \eif \atom{G}{c}$ \hfill \myanswer{True}
\item $\exists x\,\atom{H}{x}$ \hfill \myanswer{True}
\item $\forall x\,\atom{H}{x}$ \hfill \myanswer{False}
\item $\exists x \enot \atom{M}{x}$ \hfill \myanswer{True}
\item $\exists x(\atom{H}{x} \eand \atom{G}{x})$ \hfill \myanswer{True}
\item $\exists x(\atom{M}{x} \eand \atom{G}{x})$ \hfill \myanswer{True}
\item $\forall x(\atom{H}{x} \eor \atom{M}{x})$ \hfill \myanswer{True}
\item $\exists x\,\atom{H}{x} \eand \exists x\,\atom{M}{x}$ \hfill \myanswer{True}
\item $\forall x(\atom{H}{x} \eiff \enot \atom{M}{x})$ \hfill \myanswer{True}
\item $\exists x\,\atom{G}{x} \eand \exists x \enot \atom{G}{x}$ \hfill \myanswer{False}
\item $\forall x\exists y(\atom{G}{x} \eand \atom{H}{y})$ \hfill \myanswer{True}
\end{earg}

\problempart
\label{pr.TorF3}
Following the diagram conventions introduced at the end of \S23, consider the following interpretation:
\begin{center}
\begin{tikzpicture}
\node (atom1) at (0,2) {1};
\node (atom2) at (2,2) {2};
\node (atom4) at (0,0) {3};
\node (atom5) at (2,0) {4};
\node (atom6) at (4,0) {5};
\draw[->, thick] (atom1)+(-0.15,0.15) arc (-330:-30:.3);
\draw[->, thick] (atom6)+(0.15,-0.15) arc (-150:150:.3);
\draw[->, thick] (atom1) -- (atom2);
\draw[->, thick] (atom1) -- (atom4);
\draw[<->, thick] (atom1) -- (atom5);
\draw[->, thick] (atom1) -- (atom6);
\draw[->, thick] (atom2) -- (atom6);
\end{tikzpicture}
\end{center}
Determine whether each of the following sentences is true or false in that interpretation:
\begin{earg}
\item $\exists x\,\atom{R}{x,x}$ \hfill \myanswer{True}
\item $\forall x\,\atom{R}{x,x}$ \hfill \myanswer{False}
\item $\exists x \forall y\,\atom{R}{x,y}$ \hfill \myanswer{True}
\item $\exists x \forall y\,\atom{R}{y,x}$ \hfill \myanswer{False}
\item $\forall x \forall y \forall z ((\atom{R}{x,y} \eand \atom{R}{y,z}) \eif \atom{R}{x,z})$ \hfill \myanswer{False}
\item $\forall x \forall y \forall z ((\atom{R}{x,y} \eand \atom{R}{x,z}) \eif \atom{R}{y,z})$ \hfill \myanswer{False}
\item $\exists x \forall y \enot \atom{R}{x,y}$ \hfill \myanswer{True}
\item $\forall x(\exists y\,\atom{R}{x,y} \eif \exists y\,\atom{R}{y,x})$ \hfill \myanswer{True}
\item $\exists x \exists y (\enot x = y \eand \atom{R}{x,y} \eand \atom{R}{y,x})$ \hfill \myanswer{True}
\item $\exists x \forall y(\atom{R}{x,y} \eiff x = y)$ \hfill \myanswer{True}
\item $\exists x \forall y(\atom{R}{y,x} \eiff x = y)$ \hfill \myanswer{False}
\item $\exists x \exists y(\enot x = y \eand \atom{R}{x,y} \eand \forall z(\atom{R}{z,x} \eiff y = z))$ \hfill \myanswer{True}
\end{earg}

\stepcounter{chapter} % Semantic concepts

\chapter{Using Interpretations}\setcounter{ProbPart}{0}

\solutions
\problempart
\label{pr.Contingent}
Show that each of the following is neither a validity nor a contradiction:
\begin{earg}
\item $\atom{D}{a} \eand \atom{D}{b}$

\myanswer{The sentence is true in this model:
\begin{ekey}
	\item[\text{domain}] Stan
	\item[D(x)] Stan
	\item[a] Stan
	\item[b] Stan
\end{ekey}
And it is false in this model:
\begin{ekey}
	\item[\text{domain}] Stan
	\item[D(x)] % $\emptyset$
	\item[a] Stan
	\item[b] Stan
\end{ekey}}
\item \leftsolutions\ $\exists x\,\atom{T}{x,h}$

\myanswer{The sentence is true in this model:
\begin{ekey}
	\item[\text{domain}] Stan
	\item[T(x,y)] \ntuple{Stan, Stan}
	\item[h] Stan
\end{ekey}
And it is false in this model:
\begin{ekey}
	\item[\text{domain}] Stan
	\item[T(x,y)] % $\emptyset$
	\item[h] Stan
\end{ekey}}

\item $\atom{P}{m} \eand \enot\forall x\,\atom{P}{x}$

\myanswer{	The sentence is true in this model:
\begin{ekey}
	\item[\text{domain}] Stan, Ollie
	\item[P(x)] Stan
	\item[m] Stan
\end{ekey}
And it is false in this model:
\begin{ekey}
	\item[\text{domain}] Stan
	\item[P(x)] % $\emptyset$
	\item[m] Stan
\end{ekey}}
\item $\forall z\, \atom{J}{z} \eiff \exists y\,\atom{J}{y}$
\item $\forall x (\atom{W}{x,m,n} \eor \exists y\atom{L}{x,y})$
\item $\exists x (\atom{G}{x} \eif \forall y\,\atom{M}{y})$
\item $\exists x (x = h \eand x = i)$
\end{earg}

\solutions
\problempart
\label{pr.NotEquiv}
Show that the following pairs of sentences are not logically equivalent.
\begin{earg}
\item $\atom{J}{a}$, $\atom{K}{a}$

\myanswer{Making the first sentence true and the second false:
\begin{ekey}
	\item[\text{domain}] $0$
	\item[J(x)] $0$
	\item[K(x)] % $\emptyset$
	\item[a] $0$
\end{ekey}}
\item $\exists x\,\atom{J}{x}$, $\atom{J}{m}$

\myanswer{Making the first sentence true and the second false:
\begin{ekey}
	\item[\text{domain}] $0$, $1$
	\item[J(x)] $0$
	\item[m] $1$
\end{ekey}}
\item $\forall x\,\atom{R}{x,x}$, $\exists x\,\atom{R}{x,x}$

\myanswer{Making the first sentence false and the second true:
\begin{ekey}
	\item[\text{domain}] $0$, $1$
	\item[R(x,y)] \ntuple{$0$,$0$}
\end{ekey}}
\item $\exists x\,\atom{P}{x} \eif \atom{Q}{c}$, $\exists x (\atom{P}{x} \eif \atom{Q}{c})$

\myanswer{Making the first sentence false and the second true:
\begin{ekey}
	\item[\text{domain}] $0$, $1$
	\item[P(x)] $0$
	\item[Q(x)] % $\emptyset$
	\item[c] $0$
\end{ekey}}
\item $\forall x(\atom{P}{x} \eif \enot \atom{Q}{x})$, $\exists x(\atom{P}{x} \eand \enot \atom{Q}{x})$

\myanswer{Making the first sentence true and the second false:
\begin{ekey}
	\item[\text{domain}] $0$
	\item[P(x)] % $\emptyset$
	\item[Q(x)] % $\emptyset$
\end{ekey}}
\item $\exists x(\atom{P}{x} \eand \atom{Q}{x})$, $\exists x(\atom{P}{x} \eif \atom{Q}{x})$

\myanswer{Making the first sentence false and the second true:
\begin{ekey}
	\item[\text{domain}] $0$
	\item[P(x)] % $\emptyset$
	\item[Q(x)] $0$
\end{ekey}}
\item $\forall x(\atom{P}{x}\eif \atom{Q}{x})$, $\forall x(\atom{P}{x} \eand \atom{Q}{x})$

\myanswer{Making the first sentence true and the second false:
\begin{ekey}
	\item[\text{domain}] $0$
	\item[P(x)] % $\emptyset$
	\item[Q(x)] $0$
\end{ekey}}
\item $\forall x\exists y\,\atom{R}{x,y}$, $\exists x\forall y\,\atom{R}{x,y}$

\myanswer{Making the first sentence true and the second false:
\begin{ekey}
	\item[\text{domain}] $0$, $1$
	\item[R(x,y)] \ntuple{$0$, $1$}, \ntuple{$1$, $0$}
\end{ekey}}
\item $\forall x\exists y\,\atom{R}{x,y}$, $\forall x\exists y\,\atom{R}{y,x}$

\myanswer{Making the first sentence false and the second true:
\begin{ekey}
	\item[\text{domain}] $0$, $1$
	\item[R(x,y)] \ntuple{$0$, $0$}, \ntuple{$0$, $1$}
\end{ekey}}
\end{earg}

\problempart
Show that the following sentences are jointly satisfiable:
\begin{earg}
\item $\atom{M}{a}, \enot \atom{N}{a}, Pa, \enot \atom{Q}{a}$
\item $\atom{L}{e,e}, \atom{L}{e,g}, \enot \atom{L}{g,e}, \enot \atom{L}{g,g}$
\item $\enot (\atom{M}{a} \eand \exists x\,\atom{A}{x}), Ma \eor \atom{F}{a}, \forall x(\atom{F}{x} \eif \atom{A}{x})$
\item $\atom{M}{a} \eor \atom{M}{b}, \atom{M}{a} \eif \forall x \enot \atom{M}{x}$
\item $\forall y\,\atom{G}{y}, \forall x (\atom{G}{x} \eif \atom{H}{x}), \exists y \enot \atom{I}{y}$
\item $\exists x(\atom{B}{x} \eor \atom{A}{x}), \forall x \enot \atom{C}{x}, \forall x\bigl[(\atom{A}{x} \eand \atom{B}{x}) \eif Cx\bigr]$
\item $\exists x\,\atom{X}{x}, \exists x\,\atom{Y}{x}, \forall x(\atom{X}{x} \eiff \enot \atom{Y}{x})$
\item $\forall x(\atom{P}{x} \eor \atom{Q}{x}), \exists x\enot(\atom{Q}{x} \eand \atom{P}{x})$
\item $\exists z(\atom{N}{z} \eand \atom{O}{z,z}), \forall x\forall y(\atom{O}{x,y} \eif \atom{O}{y,x})$
\item $\enot \exists x \forall y\,\atom{R}{x,y}, \forall x \exists y\,\atom{R}{x,y}$
\item $\enot \atom{R}{a,a}$, $\forall x (x=a \eor \atom{R}{x,a})$

\myanswer{The sentences are both true in this interpretation:
\begin{ekey}
	\item[\text{domain}] Harry, Sally
	\item[R(x,y)]\ntuple{Sally, Harry}
	\item[a] Harry
	\end{ekey}}
\item $\forall x\forall y\forall z[(x=y \eor y=z )\eor x=z]$, $\exists x\exists y\ \enot x= y$

\myanswer{There are no predicates or constants, so we only need to give a domain.
Any domain with 2 elements will do.}
\item $\exists x\exists y((\atom{Z}{x} \eand \atom{Z}{y} )\eand x=y)$, $\enot \atom{Z}{d}$, $d=e$
\end{earg}

\problempart
Show that the following arguments are invalid:
\begin{earg}
\item $\forall x(\atom{A}{x} \eif \atom{B}{x}) \therefore \exists x\,\atom{B}{x}$
\item $\forall x(\atom{R}{x} \eif \atom{D}{x}), \forall x(\atom{R}{x} \eif \atom{F}{x}) \therefore \exists x(\atom{D}{x} \eand \atom{F}{x})$
\item $\exists x(\atom{P}{x}\eif \atom{Q}{x}) \therefore \exists x\,\atom{P}{x}$
\item $\atom{N}{a} \eand \atom{N}{b} \eand \atom{N}{c} \therefore \forall x\,\atom{N}{x}$
\item $\atom{R}{d,e}, \exists x\,\atom{R}{xd} \therefore \atom{R}{e,d}$
\item $\exists x(\atom{E}{x} \eand \atom{F}{x}), \exists x\,\atom{F}{x} \eif \exists x\,\atom{G}{x} \therefore \exists x(\atom{E}{x} \eand \atom{G}{x})$
\item $\forall x\,\atom{O}{x,c}, \forall x\,\atom{O}{c,x} \therefore \forall x\,\atom{O}{x,x}$
\item $\exists x(\atom{J}{x} \eand \atom{K}{x}), \exists x \enot \atom{K}{x}, \exists x \enot \atom{J}{x} \therefore \exists x(\enot \atom{J}{x} \eand \enot \atom{K}{x})$
\item $\atom{L}{a,b} \eif \forall x\,\atom{L}{x,b}, \exists x\,\atom{L}{x,b} \therefore \atom{L}{b,b}$
\item $\forall x(\atom{D}{x} \eif \exists y\,\atom{T}{y,x}) \therefore \exists y \exists z\ \enot y= z$
\end{earg}

\stepcounter{chapter} % Reasoning about interpretations