From 8543a1599467ec0d2812f935b6981724d240f77f Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 31 Jan 2015 21:36:02 -0500 Subject: [PATCH] update week1 notes --- week1.mdwn | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/week1.mdwn b/week1.mdwn index 7a8b00aa..dffe0605 100644 --- a/week1.mdwn +++ b/week1.mdwn @@ -97,6 +97,35 @@ Functions are another class of values we'll have in our language. They aren't "l (By the way, I really am serious about thinking of *the numbers themselves* as being expressions in this language; rather than some "numerals" that aren't themselves numbers. We can talk about this down the road. For now, don't worry about it too much.) -I said we wanted to be starting with a fragment of arithmetic, so we'll keep the function values off-stage for the moment, and also all the symbolic atoms except for `'true` and `'false`. So we've got numbers, truth-values, and some functions and relations (that is, boolean functions) defined on them. We also help ourselves to a notion of bounded quantification, as in ∀`x < M.` φ, where `M` and φ are (simple or complex) expressions that evaluate to a number and a boolean, respectively. +I said we wanted to be starting with a fragment of arithmetic, so we'll keep the function values off-stage for the moment, and also all the symbolic atoms except for `'true` and `'false`. So we've got numbers, truth-values, and some functions and relations (that is, boolean functions) defined on them. We also help ourselves to a notion of bounded quantification, as in ∀`x < M.` φ, where `M` and φ are (simple or complex) expressions that evaluate to a number and a boolean, respectively. We limit ourselves to *bounded* quantification so that the fragment we're dealing with can be "effectively" or mechanically decided. (As we extend the language, we will lose that property, but it will be a topic for later discussion exactly when that happens.) -*More to come* +As I mentioned in class, I will sometimes write ∀ x : ψ . φ in my informal metalanguage, where the ψ clause represents the quantifier's *restrictor*. Other people write this like `[`∀ x : ψ `]` φ, or in various other ways. My notation is meant to parallel the notation some linguists (for example, Heim & Kratzer) use in writing λ x : ψ . φ, where ψ clause restricts the range of arguments over which the function designated by the λ expression is defined. Later we will see the colon used in a somewhat similar (but also somewhat different) way in our programming languages. But that's just foreshadowing. + +So we have bounded quantification as in ∀ `x < 10.` φ. Obviously we could also make sense of ∀ `x == 5.` φ in just the same way. This would evaluate φ but with the variable `x` now bound to the value `5`, ignoring whatever it may be bound to in broader contexts. I will express this idea in a more perspicuous vocabulary, like this: `let x be 5 in` φ. + +As one of you was quick to notice in class, though, when I shift to the `let`-vocabulary, I no longer restricted myself to just the case where φ evaluates to a boolean. I also permitted myself expressions like this: + + let x be 5 in x + 1 + +which evaluates to `6`. Okay, fair enough, so I am moving beyond the ∀ `x==5.` φ idea when I do this. But the rule for how to interpret this are just a straightforward generalization of our existing understanding for how to interpret bound variables. So there's nothing fundamentally novel here. + +We can have multiple `let`-expressions embedded, as in: + + let y be (let x be 5 in x + 1) in 2 * y + + let x be 5 in let y be x + 1 in 2 * y + +both of which evaluate to `12`. When we have a stack of `let`-expressions as in the second example, I will write it like this: + + let + x be 5; + y be x + 1 + in 2 * y + +It's okay to also write it all inline, like so: `let x be 5; y be x + 1 in 2 * y`. The `;` represents that we have a couple of `let`-bindings coming in sequence. The earlier bindings in the sequence are considered to be in effect for the later right-hand expressions in the sequence. Thus in: + + let x be 0 in (let x be 5; y be x + 1 in 2 * y) + +The `x + 1` that is evaluated to give the value that `y` gets bound to uses the (more local) binding of `x` to `5`, not the (previous, less local) binding of `x` to `0`. By the way, the parentheses in that displayed expression were just to focus your attention. It would have parsed and meant the same without them. + +*More to come.* -- 2.11.0