-
Notifications
You must be signed in to change notification settings - Fork 18
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
Partial Evaluation DRT #308
Conversation
12e7ba5
to
b1bc1f5
Compare
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.
Looks good to me overall
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.
Some high-level comments
- I imagine we'll also want to be DRT'ing policies, since the logic to compute the "definitely erroring policies" and such is a little confusing. Might make sense to add an additional target in this PR, like how we have
abac-type-directed
andeval_type_directed
. - Let's change the name to
partial-eval-type-directed
for consistency with the other targets. - Can you add support for PE to
Cli/Main.lean
too? Should be easy since you've already set up the DRT functionality.
cedar-policy-generators/src/expr.rs
Outdated
let unknown_type: Option<ast::Type> = target_type.clone().try_into().ok(); | ||
match unknown_type { | ||
Some(ty) => Ok(ast::Expr::unknown(ast::Unknown::new_with_type(name, ty))), | ||
None => Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))), | ||
} | ||
Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))) |
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.
What's the reason for this change?
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.
Bumping this question from @khieta as well
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.
Reverted, good catch @khieta
| .ok v => ValueOrExpr.value <$> (jsonToValue v) | ||
| .error _ => match json.getObjVal? "Expr" with | ||
| .ok e => ValueOrExpr.expr <$> (jsonToPartialExpr e) | ||
| .error _ => .error "Expected either `expr` or `value`" |
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.
| .error _ => .error "Expected either `expr` or `value`" | |
| .error _ => .error "jsonToValueOrExpr: expected either `Expr` or `Value`" |
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.
did you reject this suggestion? it was resolved but it doesn't appear in the latest diff
Absolutely, just waiting for partial auth code to be merged
Will do
Sure |
Partial auth code was merged last week (#299) :) |
807602b
to
b28b0b2
Compare
Blocked by: cedar-policy/cedar#898 |
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.
Nothing in my comments needs to be blocking
5fa3e9b
to
51ed147
Compare
cedar-policy-generators/src/expr.rs
Outdated
let unknown_type: Option<ast::Type> = target_type.clone().try_into().ok(); | ||
match unknown_type { | ||
Some(ty) => Ok(ast::Expr::unknown(ast::Unknown::new_with_type(name, ty))), | ||
None => Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))), | ||
} | ||
Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))) |
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.
Bumping this question from @khieta as well
Signed-off-by: Aaron Eline <[email protected]>
Signed-off-by: Aaron Eline <[email protected]>
cc79fee
to
122d198
Compare
PolicyKind::True => Expr::val(true), | ||
PolicyKind::False => Expr::val(false), | ||
PolicyKind::Error => Expr::add(Expr::val(1), Expr::val(false)), | ||
PolicyKind::Residual => Expr::get_attr(Expr::var(ast::Var::Context), "unknown".into()), |
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.
should this expression include an actual unknown?
theorem roundtrip (e : Spec.Expr) (pe : Partial.Expr) : | ||
e.asPartialExpr = pe ↔ pe.asSpec = some e := by | ||
apply Iff.intro <;> intros h | ||
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption } |
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.
maybe something like this is clearer?
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption } | |
· apply roundtrip₂ ; assumption | |
· apply roundtrip₁ ; assumption |
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.
Or, instead of assumption
, use h
directly.
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption } | |
· exact roundtrip₂ _ _ h | |
· exact roundtrip₁ _ _ h |
or something similar
| .ok v => ValueOrExpr.value <$> (jsonToValue v) | ||
| .error _ => match json.getObjVal? "Expr" with | ||
| .ok e => ValueOrExpr.expr <$> (jsonToPartialExpr e) | ||
| .error _ => .error "Expected either `expr` or `value`" |
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.
did you reject this suggestion? it was resolved but it doesn't appear in the latest diff
Issue #, if available:
N/A
Description of changes:
Adds DRT for partial evaluation
It does find a discrepancy