johnazariah
2017-7-10 14:01:38

@johnazariah has joined the channel


johnazariah
2017-7-10 14:01:50

G’day all :slightly_smiling_face:


johnazariah
2017-7-10 14:01:57

where are those bagels! :stuck_out_tongue:


tov
2017-7-10 14:03:31

@tov has joined the channel


sergej
2017-7-10 14:04:56

I like the weather so far


robby
2017-7-10 14:11:01

Not 8:30 yet!


sergej
2017-7-10 14:11:30

well yes, you’re performing according to the spec so far, it’s just that we’re hungry :slightly_smiling_face:


sergej
2017-7-10 14:12:07

how do you guys type all those Unicode characters in Racket? lambdas and gammas and ⊢ and so on?


robby
2017-7-10 14:13:36

In DrRacket you type the latex command and then hit the magic Unicode button. Control- on a mac if I am not mistaken


robby
2017-7-10 14:14:06

(The edit menu has a dialog with a list of key bindings to get the actual keystroke)


robby
2017-7-10 14:14:24

The docs have a list of all of them somewhere.


sergej
2017-7-10 14:15:44

okay, command- gives me lambda


sergej
2017-7-10 14:16:09

but I don’t know about the rest


sergej
2017-7-10 14:18:10

okay, typing \Downarrow and then Ctrl- works :slightly_smiling_face:



zenspider
2017-7-10 15:21:19

emacs’ racket-mode: C-M-y to insert lambda


jim.sandridge
2017-7-10 15:58:01

twisol
2017-7-10 16:48:33

Working through the notes for this session, I noticed alpha-equivalent? requires the language to be passed in, even though default-language was called earlier in the file. Is that intentional?


twisol
2017-7-10 16:50:18

Or — alternative hypothesis, does default-language only affect metafunctions under term?


robby
2017-7-10 17:50:58

it would have been good if the two functions had consistent interfaces, I agree. IIRC, alpha-equivalent predated substitute and the whole “current language” plumbing into Redex.


johnazariah
2017-7-10 18:04:11

can you PM me the survey link here please?



johnazariah
2017-7-10 18:29:15

Thanks, @newcombj!


clarkson
2017-7-10 18:43:16

@clarkson has joined the channel



awe
2017-7-10 19:06:15

Our notion of PCF here is slightly different though because we have not introduced type checking.


twisol
2017-7-10 19:07:54

Is it possible to see which context decomposition was used to perform a particular reduction? I’m a little confused by something I’m seeing in traces, and I’m trying to work backwards to find out what’s causing it.


robby
2017-7-10 19:08:44

@twisol : use redex-match in the REPL.


robby
2017-7-10 19:08:46

Eg:


robby
2017-7-10 19:09:15
> (redex-match Lambda (in-hole C <lhs-of-reduction>) (term <expression that is confusing>))

twisol
2017-7-10 19:14:06

I’m not able to make that work; it’s giving me some errors about “in-hole’s first argument is expected to match exactly one hole”


twisol
2017-7-10 19:14:13

I’m through section 1.5 in the morning lecture notes, and I’m trying to understand how e3 gets broken down and reassembled to produce ((lambda (x«13») x«13») z)


robby
2017-7-10 19:14:40

that error comes about when you have an illformed C, which might, in fact, be the real problem


twisol
2017-7-10 19:15:20

Hmm, can traces or apply-reduction-relation even work with an illformed C?


twisol
2017-7-10 19:15:46

Also, I’m working with code copied direct from the lecture notes


robby
2017-7-10 19:19:15

Hm. I think my original response is still correct, so perhaps you should tell me what you actually did


twisol
2017-7-10 19:19:35

What I did with redex-match?


robby
2017-7-10 19:19:41

yes


twisol
2017-7-10 19:19:55
> (redacted; mispaste)

> (redex-match Lambda-calculus (in-hole C e3) ((lambda (x«13») x«13») z))
. . z: undefined;
 cannot reference an identifier before its definition

> (redex-match Lambda-calculus (in-hole e3 e) ((lambda (x«13») x«13») z))
. redex-match: in-hole's first argument is expected to match exactly one hole, but it cannot match a hole in: (in-hole e3 e)

twisol
2017-7-10 19:20:23

Oops


twisol
2017-7-10 19:20:26

first one was a mispaste


robby
2017-7-10 19:20:26

The second argument (the one after the language) needs to be a pattern


robby
2017-7-10 19:20:41

The e3 isn’t that


robby
2017-7-10 19:20:51

That’s what that error message mens


robby
2017-7-10 19:20:52

means


twisol
2017-7-10 19:21:03

Aah. (term ,e3)?


robby
2017-7-10 19:21:07

no


robby
2017-7-10 19:21:21

Put hte left-hand sside of the reduction rule that you’re interesting in where e3 appears


robby
2017-7-10 19:21:56

try: (redex-match Lambda-calculus (in-hole C ((lambda (x) e_1) e_2)) e3)


twisol
2017-7-10 19:22:19

Oh, by “expression that is confusing” I thought you meant the result I had called confusing.


twisol
2017-7-10 19:22:22

You meant the input.


willghatch
2017-7-10 19:37:25

@willghatch has joined the channel


twisol
2017-7-10 19:41:03

If anyone else got confused by this: in the definition of ->beta in the lecture notes, it looks like the arguments to substitute are flipped. It reads (in-hole C (substitute e_2 x e_1)) but it should be (in-hole C (substitute e_1 x e_2)).


twisol
2017-7-10 19:41:07

Thanks to the TA who helped me figure this out!


aviral-goel
2017-7-10 20:25:00

@aviral-goel has joined the channel


twisol
2017-7-10 23:36:04

I just finished #8 \o/


reamslin
2017-7-10 23:50:50

@reamslin has joined the channel


twisol
2017-7-11 00:01:51

Were the reimbursement forms handled already in the morning, or has that not happened yet? (I came in a little late…)


newcombj
2017-7-11 00:17:33

Where is everyone getting food? The student Union is closed…


newcombj
2017-7-11 00:19:47

Oh no talk of reimbursement yet @twisol


twisol
2017-7-11 00:33:18

I’m curious how anyone else approached #8. It seems like something you could reasonably arrive at a few different solutions for.


twisol
2017-7-11 00:34:28

oh, maybe this should be a subthread to avoid spoilers


twisol
2017-7-11 00:34:49

o/


nadeem
2017-7-11 00:35:39

it seems like the function from #6 was intended to be helpful, perhaps


twisol
2017-7-11 00:36:00

Yeah, I did end up using lookup


twisol
2017-7-11 00:36:37

I wrote an increment-env helper to add 1 to every expression in an environment, and used that whenever recursing under a lambda


nadeem
2017-7-11 00:36:37

i got one solution, but I thought of a different way that I’m going to try that avoids having to update everything in the environment all the time


nadeem
2017-7-11 00:36:49

yes, that’s the same approach I took.


nadeem
2017-7-11 00:37:20

but it feels very inefficient, though it works


twisol
2017-7-11 00:37:23

Cool! Ah, I wonder if you could do a lookup and push an incremented count when going under a lambda?


twisol
2017-7-11 00:37:31

Er, not incremented, zero’d


nadeem
2017-7-11 00:37:41

I think you can do better… :slightly_smiling_face:


twisol
2017-7-11 00:37:42

Wait, that’s mostly totally useless…


twisol
2017-7-11 00:38:37

Are you thinking of something like a zipper?


nadeem
2017-7-11 00:39:52

no… but increment a depth count and carry it along with the environment; then only push the count value with the variable when going under a lambda… when you actually hit a variable, you then do a lookup, but you have to adjust the actual value using the depth count…


twisol
2017-7-11 00:40:21

Hmm, I see.


twisol
2017-7-11 00:40:59

I was thinking of something like, (1) push a variable whenever you go under a lambda, and (2) count the number of variables before the first occurrence of a particular variable


nadeem
2017-7-11 00:41:22

by ‘before’ you mean in the environment?


twisol
2017-7-11 00:41:25

Yes


twisol
2017-7-11 00:41:32

so (z x y x) would correspond to ((x 1) (y 2) (z 0))


nadeem
2017-7-11 00:42:51

oh - so you don’t need an environment at all then? just a stack of variables and ability to count how far down in the stack a variable is


twisol
2017-7-11 00:43:03

Right, I think so. Which makes sense — that’s kind of what “scope” is, in some sense.


twisol
2017-7-11 00:43:19

There’s much less work to do when moving under a lambda, although you have to do more work when looking a variable up. And it’s more of a purely-functional data structure.


nadeem
2017-7-11 00:44:09

probably not, because you had to do a lookup anyway to find the variable in the environment, and it would be just as far down in the environment as it is in the stack, so same number of ops


twisol
2017-7-11 00:44:21

oh, good point. I was thinking of the current env as a direct lookup table.


nadeem
2017-7-11 00:48:45

@newcombj The Heritage center dining hall closes at 7pm, but I think there is a store with snacks there open till 8pm, and there’s https://new.dineoncampus.com/utah/lassonde-studios


nadeem
2017-7-11 00:48:51

wherever that is


newcombj
2017-7-11 00:54:17

Thanks @nadeem ! I’ll check out the lassonde tung next time


zenspider
2017-7-11 03:35:57

Um… is #4 really just a 1 word change or am I misunderstanding the scope of the change?


twisol
2017-7-11 03:38:03

I reused the error state from the previous exercise, but… that 1-word change does seem more straightforward.


zenspider
2017-7-11 03:38:38

kk. as long as I’m on the right page. thanks


zenspider
2017-7-11 03:45:21

Anyone seen this: define-metafunction: expected the same name in both positions ?


twisol
2017-7-11 03:45:43

Yeah — it’s possible you named it one thing, but aren’t using the same name in the pattern matching position


twisol
2017-7-11 03:46:30

If the signature is foo : n -> n, the clauses should look like e.g. [(foo n) n]


zenspider
2017-7-11 03:46:49

derp… yup.


zenspider
2017-7-11 04:13:42

@mflatt/@robby exercise 7 typo: (lambda (b a)) -> (lambda (b) a) — down in the term substitute code block


twisol
2017-7-11 04:14:35

Probably left-over from when it was a multi-def let


twisol
2017-7-11 04:15:42

(Which is a fun exercise once you complete 7, fwiw. Making it capture-avoiding is even better ^_^)


zenspider
2017-7-11 04:20:59

I assume you can do multiple let via recursion?


twisol
2017-7-11 04:21:16

At the metafunction level, yes.


zenspider
2017-7-11 04:22:01

hrm… you can’t just do a rewrite only version recursively?


twisol
2017-7-11 04:22:51

Metafunctions are essentially macro rewrite rules


zenspider
2017-7-11 04:23:01

sure


twisol
2017-7-11 04:23:03

You don’t need quote/unquote/term though.


awe
2017-7-11 04:23:29

It was quite frustrating when I tried to write it without metafunction recursion.


zenspider
2017-7-11 04:23:51

I just did 4–7 w/o too much trouble (other than my own blindness, thank you)… but 8? I don’t think I even understand the problem definition… static distance?


awe
2017-7-11 04:23:55

I wrote some nasty stuff with foldr, but couldn’t get it to work.


twisol
2017-7-11 04:24:08

zenspider, does the term “de Bruijn indices” help?


zenspider
2017-7-11 04:24:18

heh. nope


awe
2017-7-11 04:24:25

@twisol The answer to that question is probably universally no. :wink:


zenspider
2017-7-11 04:24:26

did I gloss over some reading?


twisol
2017-7-11 04:24:56

@awe I’ve spoken with several people over the last few weeks who know about that. It’s just a very brief way to explain it if someone already knows it.


twisol
2017-7-11 04:25:01

Stepping backwards…


twisol
2017-7-11 04:25:17

Take (lambda (x) (lambda (y) (x y))) as an example.


twisol
2017-7-11 04:25:44

That should be replaced with (lambda (x) (lambda (y) ((sd 1) (sd 0))))


twisol
2017-7-11 04:25:53

the lambda binding y is 0 distance “up”


twisol
2017-7-11 04:25:59

the lambda binding x is 1 distance “up”


twisol
2017-7-11 04:26:55

@nadeem has some test cases you could use to develop against, but I don’t want to redistribute them without permission


zenspider
2017-7-11 04:27:23

so this is like the variable rewriter x«0»


twisol
2017-7-11 04:27:58

No, that notation is utilized internally to Redex to generate fresh variable names


twisol
2017-7-11 04:29:27

lemme give a better example


twisol
2017-7-11 04:29:51

minor change: (lambda (x) (x (lambda (y) (x y)))).


twisol
2017-7-11 04:30:14

becomes: (lambda (x) ((sd 0) (lambda (y) ((sd 1) (sd 0)))))


twisol
2017-7-11 04:30:27

in this case, x is changed to two different things


zenspider
2017-7-11 04:30:30

so… this isn’t used for something like hygiene?… then… stack lookup?


twisol
2017-7-11 04:30:38

Stack lookup is basically exactly what it is.


zenspider
2017-7-11 04:31:10

hrm: “Terms written using these indices are invariant with respect to α-conversion, so the check for α-equivalence is the same as that for syntactic equality.”


twisol
2017-7-11 04:31:24

You’re referring to the de Bruijn page?


zenspider
2017-7-11 04:31:40

α-equivalence is just hygiene (gah I can NEVER spell that right), no?


zenspider
2017-7-11 04:31:58

yeah


twisol
2017-7-11 04:32:16

In a certain sense, hygiene (me either) is about preserving alpha-equivalence under substitution.


twisol
2017-7-11 04:32:47

Put it this way. Put a bunch of your friends in a line. You’ve got Alice, Bob, Mary, and Sue.


zenspider
2017-7-11 04:32:58

I hate them all so much


zenspider
2017-7-11 04:33:05

and that’s 20 years later… I still hate them


twisol
2017-7-11 04:33:08

If you ask Bob and Sue how far away Alice is, you’ll get different answers: 1 and 3.


twisol
2017-7-11 04:34:04

This is effectively what “static distance” is trying to capture. Different places referring to the same variable will be different distances away.


twisol
2017-7-11 04:34:43

(lambda (alice) (lambda (bob) (alice (lambda (mary) (lambda (sue) alice)))))


zenspider
2017-7-11 04:35:14

kk. got it. thanks.


twisol
2017-7-11 04:35:19

np, hope it helps!


zenspider
2017-7-11 04:35:48

not sure I can muster a fuck to give at this point… I’m so beat… but I can at least write some failing tests.


zenspider
2017-7-11 04:38:10

@twisol since you’re up…


zenspider
2017-7-11 04:38:37

Did you understand MF’s answer to my question about wrapping expected test values in (term ...)?


zenspider
2017-7-11 04:39:31

Because I didn’t… the javascript bit threw me… afaict, term is basically just an unquote (more than that, but sorta kinda)… is there some translation layer it goes through if I had to change the internal representation of the values?


twisol
2017-7-11 04:39:49

I don’t see that answer in chat history — was this in person?


zenspider
2017-7-11 04:40:39

yeah. sorry. in the room today. He was writing tests and doing (test--> ->value (term input...) (term expected...))


zenspider
2017-7-11 04:41:00

when the expected could be tested with just '(1 + 1) and the like


zenspider
2017-7-11 04:41:36

his answer was about when you’re implementing a language like javascript and you can’t just piggyback on racket’s number system


zenspider
2017-7-11 04:42:04

but I don’t see how (term 42) would work as an expected w/ a different number system unless there’s some translation layer


twisol
2017-7-11 04:42:16

I don’t fully (read: almost at all) understand what goes on under the hood in Redex, but there’s some conflation of domains when you’re working with primitive values.


twisol
2017-7-11 04:42:43

I’m pretty sure (term 42) is just 42


zenspider
2017-7-11 04:43:01

right… and that was the gist of the answer… and why I’m confused :slightly_smiling_face:


zenspider
2017-7-11 04:44:20

is skimming chapter 14 of redex book…


twisol
2017-7-11 04:44:21

Well, so, if addition in your language is different from addition in your host language, you can’t just write a non-term expression in the expected value, since you’re doing different operations.


twisol
2017-7-11 04:44:55

There’s an example of that on the third lecture notes page, http://www.ccs.neu.edu/home/matthias/summer-school/mon-aft.html


zenspider
2017-7-11 04:44:58

4 is 4… unless the internal representation is different


nadeem
2017-7-11 04:45:01

@twisol you can post those test cases (I’m not sure I know how to paste code snippets here)


twisol
2017-7-11 04:45:15

@nadeem, hit the + to the left of the message area and select “code snippet”


twisol
2017-7-11 04:45:39

but maybe put it as a reply to someone in case of spoilers


zenspider
2017-7-11 04:46:01

or type 3 backticks, paste, 3 backticks (or their own line) and hit return


twisol
2017-7-11 04:46:31

That kind of code block doesn’t collapse down, unfortunately


twisol
2017-7-11 04:46:42

snippets can be super long without impinging too much on the chat field


zenspider
2017-7-11 04:47:06

sure


nadeem
2017-7-11 04:47:39

ok, here’s a thread with a few test cases for #8 as hints


nadeem
2017-7-11 04:48:01
;; tests
(test-equal (term (sd* z)) (term z))
(test-equal (term (sd* (λ(x) y)))
            (term (λ(x) y)))
(test-equal (term (sd* (λ(x) x)))
            (term (λ(x) (sd 0))))
(test-equal (term (sd* (λ(x) (λ(y) x))))
            (term (λ(x) (λ(y) (sd 1)))))
(test-equal (term (sd* (λ (x) (λ (y) y))))
            (term (λ(x) (λ(y) (sd 0)))))
(test-equal (term (sd* (λ(z) ((λ(y) (y (λ(x) x))) (λ(x) (z x)))) ))
            (term      (λ(z) ((λ(y) ((sd 0) (λ(x) (sd 0)))) (λ(x) ((sd 1) (sd 0)))))))

(define left-term     (term (λ(a) ((λ(b)(b a))
                                   (λ(c) (λ(a) (a (c b))))))))
(define right-term    (term (λ(b) (b (λ(c) (λ(d) (d b)))))))

(define left-term/sd  (term (λ(a) ((λ(b)((sd 0) (sd 1)))
                                   (λ(c) (λ(a) ((sd 0) ((sd 1) b))))))))
(define right-term/sd (term (λ(b) ((sd 0) (λ(c) (λ(d) ((sd 0) (sd 2))))))))

(test-equal (term (sd* (,left-term ,right-term)))
            (term (,left-term/sd ,right-term/sd)))

twisol
2017-7-11 04:48:39

aww, it’s a shame snippets don’t work under threads.


nadeem
2017-7-11 04:48:45

yeah


zenspider
2017-7-11 04:49:32

cool. thanks @nadeem and @twisol


nadeem
2017-7-11 04:49:41

In these, I assumed that free variables (not bound by a lambda) remain unaffected.


zenspider
2017-7-11 04:49:44

the book doesn’t clarify my term q at all


twisol
2017-7-11 04:50:12

@zenspider: as far as I can tell, term ensures that metafunctions are expanded. If you didn’t use term you might produce a syntax tree with syntax not expected by the object language


twisol
2017-7-11 04:50:51

it’s probably good to use term habitually when dealing with object language constructions, to keep the host/object boundary fairly distinct


nadeem
2017-7-11 04:51:01

what was your term question?


zenspider
2017-7-11 04:51:26

zenspider
2017-7-11 04:51:31

ugh. I hope that works internally


twisol
2017-7-11 04:51:41

seems to!


zenspider
2017-7-11 04:53:12

HAH! run (render-language PCF) in your repl


zenspider
2017-7-11 04:53:39

I love that that even works in emacs


twisol
2017-7-11 04:54:04

yeah, I don’t think term does any special conversions to values. I think it’s just a quote customized for constructing syntax trees, and if you don’t need metafunctions, it’s probably practically equivalent to quote.


nadeem
2017-7-11 04:55:17

cool, even better (render-metafunctions sd* sd-help)


twisol
2017-7-11 04:55:46

oooooo


zenspider
2017-7-11 04:56:04

hah. with escaped racket code in bright pink


zenspider
2017-7-11 04:56:27

nadeem
2017-7-11 04:56:58

yes, I’ve been just reading term mostly as quote, so it seems to me you’d need do something like (term (js 42)) in the modeling javascript situation, where js is some metafunction that translates the racket representation of 42 to a proper javascript model of the number


twisol
2017-7-11 04:57:55

Do note this page though, where you can see all the things you can inject into your language: http://docs.racket-lang.org/redex/The_Redex_Reference.html#%28part._.Patterns%29


twisol
2017-7-11 04:58:55

of course, I don’t know whether Racket uses IEEE double-precision floats, but if it does, number might be sufficient…


twisol
2017-7-11 04:59:07

(I wonder what the difference between number and real is? It isn’t specified.)


twisol
2017-7-11 05:02:51



zenspider
2017-7-11 05:04:31

ok.. my brain is melted. thanks all.


zenspider
2017-7-11 05:05:01

and I still have 23% battery for today… damn


twisol
2017-7-11 05:05:24

electronic battery technology has surpassed human battery technology


ankit
2017-7-11 06:07:37

@ankit has joined the channel