dedbox
2018-2-9 16:28:49

Any redex wizards in the room? I’ve modeled a language design on paper and want to use redex to explore / prove interesting properties, like I might with CoQ. I prefer to model “reductions” as judgments, as in Pierce’s TaPL.


dedbox
2018-2-9 16:29:37

I’ve got a grammar compiled and can write a simple judgment, but it’s not clear what to do afterwards.


dedbox
2018-2-9 16:31:56

So far, I’ve figured out how to use #:binding-forms and #:refers-to to make substitute work properly.


ben
2018-2-9 16:32:41

I guess you’ll want a metafunction to reduce terms to values


ben
2018-2-9 16:32:55

and then write tests to see that evaluation works like you expect


dedbox
2018-2-9 16:33:21

here’s what I’m working with (define-language lambda [t ::= (λ (x) t) (t t) n x] [v ::= (λ (x) t) n] [n := number] [x ::= variable-not-otherwise-mentioned] #:binding-forms (λ (x) t #:refers-to x)) (define-judgment-form lambda #:mode (steps I O) #:contract (steps t t) [(steps ((λ (x) t) v) t*) (where t* (substitute x v t)) "E-AppAbs"])


ben
2018-2-9 16:33:59

is this a typo: [v ::= (λ (x) t n)]


dedbox
2018-2-9 16:34:26

no, that’s a single-var abstraction


dedbox
2018-2-9 16:35:19

Can I make progress with a judgment of this form?


dedbox
2018-2-9 16:35:55

oh


dedbox
2018-2-9 16:35:56

wait


dedbox
2018-2-9 16:35:57

yes


ben
2018-2-9 16:36:02

ok


ben
2018-2-9 16:36:22

well the next things I’d do are: (1) write tests with redex-match? and (2) write tests for steps


dedbox
2018-2-9 16:36:45

fixed the typo. Sorry, losing sleep over this


ben
2018-2-9 16:36:47

(with judgment-holds)


dedbox
2018-2-9 16:40:55

ok cool, so redex-match? will generate test cases automatically, like haskell quickcheck?


ben
2018-2-9 16:41:02

no


dedbox
2018-2-9 16:42:09

oh, then it matches a pattern against a term


dedbox
2018-2-9 16:42:48

i see, the “curried” version of redex-match is for efficiency


ben
2018-2-9 16:43:24

yep. I think there’s a way to use redex-check though


ben
2018-2-9 16:45:26

maybe (redex-check lambda t (redex-match? lambda t))


ben
2018-2-9 16:46:48

(I usually write tests by hand)


dedbox
2018-2-9 16:46:57

Neat, redex-check will search for counter-examples at least.


dedbox
2018-2-9 16:48:51

I’m curious, what is redex intended for?


ben
2018-2-9 16:49:47

modeling!


ben
2018-2-9 16:50:05

quickly build a language, judgments


ben
2018-2-9 16:50:11

and test that everything works like you expect


ben
2018-2-9 16:50:19

then later, you can add new features to the languages


ben
2018-2-9 16:50:22

*language


ben
2018-2-9 16:50:27

and test that you didn’t break anything


dedbox
2018-2-9 16:50:57

Could I use it to prove my model is sound?


ben
2018-2-9 16:51:04

no


ben
2018-2-9 16:51:09

but you can test soundness


ben
2018-2-9 16:51:25

and yeah, coq on the other hand would help you prove soundness


dedbox
2018-2-9 16:51:30

I see. Hence the “practical” qualifier?


ben
2018-2-9 16:51:37

but you have to do more work to get that


ben
2018-2-9 16:51:38

yep


dedbox
2018-2-9 16:51:49

cool, thanks @ben!


ben
2018-2-9 16:52:34

it would be great if someone extended redex to prove coq-like theorems


ben
2018-2-9 16:52:47

but I’m not sure I would use it as much as “basic redex”


ben
2018-2-9 16:53:16

(because no matter what, there’s usually a big gap between the model & actual language, so I just want a model that’s quick and easy to work with)


dedbox
2018-2-9 16:53:29

I’ve got a use case or two in mind


dedbox
2018-2-9 16:54:31

At this point in a project (too much mess, time to fix some structure), I have to transition from Racket to Haskell or CoQ.


pnwamk
2018-2-9 16:54:33

@ben did we ever consider not distinguishing between mutable and weak hashes at the type level?


dedbox
2018-2-9 16:55:22

Neither is ideal because they have entirely different sets of quirks that won’t matter back in Racket land.


ben
2018-2-9 16:55:35

no, I don’t think so


dedbox
2018-2-9 16:56:24

Sometimes, there’s too much friction to return to Racket land, which is tragic.


ben
2018-2-9 16:58:38

so you’d want to be able to use redex instead of coq?


dedbox
2018-2-9 17:02:00

short answer, yes


dedbox
2018-2-9 17:08:09

I want the benefits of types and ~inductive logic~ structural induction, but without the overhead of multiple toolchains. I was hoping to use Redex models to explore the language design as it evolves.


dedbox
2018-2-9 17:50:03

Found a tool called Ott (http://www.cl.cam.ac.uk/~pes20/ott/top2.html) that does something like what I thought redex would


dedbox
2018-2-9 17:50:59

Except more racket-y, like output to scribble