LMU ☀️ CMSI 585
PROGRAMMING LANGUAGE FOUNDATIONS
Quiz 1 Answers
  1. When processing arrays in a functional style to do something like getting the sum of the squares of the even numbers, which of the following is the correct pipeline?

    filter then map then reduce

  2. What are the six dimensions of programming language study we’ll be undertaking in this class? Just list them, don’t explain them.

    History, Language Diversity, Concepts, Foundations, Pragmatics, Implementation

  3. “Foundations of Programming Languages (FPL)” is one of the 17 knowledge areas identifed by the ACM/IEEE-CS Computer Science Curriculum. Why is it in some sense more fundamental to computer science than the others, including the venerable "Algorithmic Foundations (AL)"?

    Programming Language Foundations deals with how data and computation are formally expressed; without a means to do so, there would be no computer science.

  4. Match the decade with the big computational developments in computer science. (Draw a line connecting each decade with the corresponding development.)

    1960s — High-level languages become dominant
    1970s — Structured Programming
    1980s — OOP
    1990s — Web
    2000s — Dynamic Languages rise again
    2010s — Multicore and Big Data
    2020s — Gen AI

  5. What are the four main theories of computation and, in 10 words or less, their primary concern?

    Language Theory: How computations are expressed
    Automata Theory: How computations are executed
    Computability Theory: Limits of computation
    Complexity Theory: Efficiency of computations

  6. Logic deals primarily with _______________. (You have to get this word exactly right)

    inference

  7. Which of the following are accurate translations of “Either all programming languages suck or C++ is god tier”?
    ⬛ $\forall p. Lp \supset Sp \lor Gc$
    ⬛ $(\forall p. Lp \supset Sp) \lor Gc$
    ⬛ $\forall p. Lp \supset (Sp \lor Gc)$
    ⬛ $\forall p. (Lp \supset Sp \lor Gc)$
    ⬛ $\forall p. Gc \lor (Lp \supset Sp)$
    ⬜ $\forall p. (Gc \lor Lp \supset Sp)$
    ⬛ $Gc \lor \forall p. Lp \supset Sp$

    HOW TO SOLVE IT QUICKLY: The problem first assumes you know instantly that “all languages suck” is $\forall p. (Lp \supset Sp$).

    First, do a quick scan over the 7 possibilities and note that #2 and #7 are exact translations (since the order of the $\lor$ does not matter). Check them.

    Next, in pencil or pen, restore parentheses that were dropped due to precedence rules. This shows you that #1, #3, and #4 are all exactly the same thing! They all say $\forall p. (Lp \supset (Sp \lor Gc))$, that is, for every language, either it sucks or C++ is god tier. This is the same thing as the original statement. Check those as being correct.

    Next, note #5 says the same thing as the last three: check it too.

    #6 says for every $p$, no matter what it is, if either $Gc$ or $Lp$, THEN $Sp$, in particular, if C++ is god-tier then everything sucks (even your favorite song or food or friend), not just programming languages. WRONG. Do not check.

  8. Which is the best and correct translation of “English is the most widely spoken language in the world but less than 40% of its speakers are native speakers”.
    ◯ $\forall x. Ne \gt Nx \supset pr(Fpe \mid Spe) \lt 0.4$
    ⬤ $(\forall x. Ne \gt Nx) \land (\forall p. Spe \supset pr(Fpe) \lt 0.4)$
    ◯ $\forall x. Ne \gt Nx \land (\forall p. Spe \supset pr(Fpe) \gt 0.6)$
    ◯ $\forall x. Ne \gt Nx \land pr(Fpe \mid Spe) \leq 0.4$
  9. HOW TO SOLVE IT QUICKLY: The statement says “less than 40%” so you can immediately throw out the last two, that are less than or equal to 40%. The second one should jump out at you as being a direct translation of the statement, since it properly separates the two claims that English is the most widely spoken language and that less than 40% of its speakers are native speakers. Check it right away. If you need to verify that the first one is wrong, note that is says “For every language with fewer speakers than English, the number of English speakers with English as a first language is less than 40%.” It says nothing about English being the most widely spoken language at all.

  10. Write (in the logic notation used in this class) an encoding of “It is possible that something evil caused all evil things except itself”.

    $\Diamond \exists x. Ex \land \forall y. (Ey \land y \neq x \supset Cxy)$

    There are many other acceptable equivalent solutions; don’t worry if you did not get this one. One thing to be careful of is to not make it too restrictive, since the statement does that say the evil thing only caused evil things; it may also have caused good things too.

  11. Write (in the logic notation used in this class) an encoding of “Tanya runs quickly and explosively”.

    $QRt \land ERt$

    There are other solutions but I like this best. Here $Q$ and $E$ (adverbs) are higher-order predicates that modify the predicate $R$ (verb). The important thing I am looking for is that you did not write something like $Rt(Q \land E)$, which is a common mistake that English speakers make! The $\land$ does not apply to the adverbs directly but to the full subformulas. $Q$ and $E$ do not have truth values on their own! They are functions, not propositions.