-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Distill the EvaluationProgram
#183
Conversation
ascent! { | ||
#![trace] | ||
|
||
struct DistilledAllocationProgram { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good! However, I think you were too aggressive and removed some non-signal relations. In particular, as far as I can tell, there are no surviving hashing rules (or related relations). You can see from first principles that this cannot be correct, since a proof will necessarily prove the hashes. If that weren't the case, it would be possible to falsify the digests.
This would actually be a useful test to add. I'm not being rhetorical, it would strengthen the test suite for memory in general. The test would be to replace digests with random values. If correctly constrained by rules that check the digests, such a randomization should fail. But I think in this DistilledAllocationProgram
it will go undetected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "assert" in the literal sense, so that a rule takes a join of the digest and relations, and then checks the hash? Otherwise I don't think there's an easy way to write the distilled program to support this, because you have to check the 3 cases of digest/relation/full pointers. For example, if I only want to register a cons_rel
if I have a cons_mem
but not a cons_digest_mem
, ascent doesn't let me write something like:
cons_rel(car, cdr, cons) <--
cons_mem(car, cdr, addr), let cons = Ptr(Tag::Cons.elt(), *addr),
!cons_digest_mem(value, addr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss further on zulip @porcuquine
a15be12
to
c04238d
Compare
src/loam/distilled_evaluation.rs
Outdated
relation eval_car(Ptr, Ptr, Ptr); // (expr, env, body) | ||
relation eval_car_cdr(Ptr, Ptr, Ptr, bool); // (expr, env, body, is_car) | ||
|
||
eval_input(body, env), eval_car(expr, env, body) <-- | ||
eval_input(expr, env), cons_rel(op, tail, expr), if op.is_car(), | ||
eval_input(body, env), eval_car_cdr(expr, env, body, is_car) <-- | ||
eval_input(expr, env), cons_rel(op, tail, expr), if op.is_car_cdr(), let is_car = op.is_car(), | ||
cons_rel(body, end, tail), if end.is_nil(); | ||
|
||
eval(expr, env, car) <-- | ||
eval_car(expr, env, body), | ||
eval_car_cdr(expr, env, body, true), | ||
eval(body, env, evaled), | ||
cons_rel(car, cdr, evaled); | ||
|
||
eval(expr, env, cdr) <-- | ||
eval_car_cdr(expr, env, body, false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be taken further. This is really eval_unop
, I think. Instead of a bool
, you can include op
(a Ptr
), as in fold
and friends. Later, we could remove the tag and just use the symbol address as an optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, same thoughts
61cdd49
to
23d77f1
Compare
eb07295
to
eb05080
Compare
I'm going to rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I didn't scrutinize the actual evaluation programs closely again, but I did review them over time as the work built up. Since that's all in flux anyway, I think this is good to merge now.
Let's try to keep PRs smaller, more focused, and less long-lived now that we're in the next phase of development. Good work.
…tion/debugging infra
8291411
to
9aeb926
Compare
9aeb926
to
f239959
Compare
🎉 |
This PR adds the distilled program and distilled memory to loam. Here are the changes:
cons/car/cdr/atom/quote
, as well as tests.ascent
, and for memory distillation.