$\textsf{Unit} \to \textsf{Unit}$ _______________________
$\textsf{Void} \to \textsf{Void}$ _______________________
$\textsf{Unit} \to \textsf{Void}$ _______________________
$\textsf{Nat} \to \textsf{Bool}$ _______________________
$\textsf{Bool} \to \textsf{Nat}$ _______________________
$\textsf{Nat} \to \textsf{Nat}$ _______________________
$\textsf{Bool} \to (\textsf{Bool} \to \textsf{Bool})$ _______________________
$(\textsf{Bool} \to \textsf{Bool}) \to \textsf{Bool}$ _______________________
$(\textsf{Nat} \to \textsf{Nat}) \to \textsf{Nat}$ _______________________
$\textsf{Void} \to \textsf{Nat} \to \textsf{Bool}$ _______________________
Here are the introduction rules for logical disjunction in propositional logic: $\frac{A}{A \lor B}$, $\frac{B}{A \lor B}$. Show the corresponding (Curry-Howard) typing rules in type theory.
We learned that Set Theory is built on top of first-order logic, but that in Type Theory, logic emerges, since the logical operators can be defined in terms of typed functions. Show how to define the logical operators $\lor$, $\forall$, and $\exists$ as Type-theoretic functions $\textsf{or :Bool$\to$Bool$\to$Bool}$ and $\textsf{forall: ($t\to$Bool)$\to$Bool}$ and $\textsf{exists: ($t\to$Bool)$\to$Bool}$. You may assume that function equality is already defined.
Complete the generative grammar for formulae in first-order predicate logic which is started below. You need only add the rule for Formula. Formulae should include truth, falsity, predicates applied to terms (remember $Lrj$—Romeo likes Juliet), negation, the four usual boolean connectives, and the quantified expressions. Require parentheses around all binary operators in order to avoid ambiguity—simpler than creating new syntactic categories to enforce precedence and associativity!
$\begin{array}{lcl}
\texttt{var} & \longrightarrow & \texttt{"p"} \mid \texttt{"q"} \mid \texttt{"r"} \mid \texttt{var "$'$"} \\
\texttt{constant} & \longrightarrow & \texttt{"a"} \mid \texttt{"b"} \mid \texttt{"c"} \mid \texttt{constant "$'$"} \\
\texttt{function} & \longrightarrow & \texttt{"f"} \mid \texttt{"g"} \mid \texttt{"h"} \mid \texttt{function "$'$"} \\
\texttt{predicate} & \longrightarrow & \texttt{"P"} \mid \texttt{"Q"} \mid \texttt{"R"} \mid \texttt{predicate "$'$"} \\
\texttt{Term} & \longrightarrow & \texttt{var} \mid \texttt{constant} \mid \texttt{function Term}^+ \mid \texttt{"(" Term ")"} \\
\end{array}$
Explain, briefly, the difference between an entity and a value. To receive full credit you must define each term in 8 words or less, and give two examples of each. By examples we mean just the names of two things that are clearly values and names of two things that are clearly entities.
Draw a picture of the value denoted by &(x: (1,2), y: &{type: "ok", set: "nope"})
A grammar has the rule Exp -> Term ("+" Term)*. Which of the following best describes the + operator?
- It is left associative
- It is right associative
- It is non-associative
- Its associativity is indeterminate
Draw the abstract syntax tree for the Astro program a = a ** 2 ** 1 + b - a; print a % (2 + 5.5);
What is this natural semantics rule defining?
$$ \dfrac{e_1,m \Longrightarrow a \;\;\;\; e_2,m \Longrightarrow b \;\;\;\; x\geq a \;\;\;\; x\lt b}{[\![e_1 \lozenge e_2]\!],m \Longrightarrow x}$$
- Nothing, it is utter nonsense, $x$ is not defined
- Nothing, there is a syntax error in the semantic rule
- The diamond operator produces a random number between its left operand inclusive and its right operand exclusive
- The static semantics of a TypeScript union type
- The diamond operator is a modal operator meaning that $b$ is possible if $a$ is