Skip to content
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

Proof that subst preserves errors #368

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

cdisselkoen
Copy link
Contributor

The next lemma required for PE soundness. We already have a lemma stating that "if partial evaluation returns a concrete value, then it returns the same concrete value after any substitution of unknowns [in the original expression/request/entity store]". This is the counterpart for when partial evaluation returns an error.

Notably, the statement is not that partial evaluation must return the same error after any substitution of unknowns; that doesn't hold (one of many counterexamples: principal.foo + false where the principal is initially unknown, but the substitution maps it to some entity which doesn't have a foo attribute. This gives a type error before substitution, but an attrDoesNotExist error after substitution.) Instead, the statement is that partial evaluation must return some error (not necessarily the same error) after any substitution of unknowns.

As of this writing, I have not yet normalized the simps in this PR.

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall structure and theorem statement seems fine to me. Approving as-is, though I imagine you'll still do some hacking on the proofs (e.g., normalizing simps)

cedar-lean/lake-manifest.json Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Partial/Evaluation/AndOr.lean Outdated Show resolved Hide resolved
If partial evaluation returns ok after any substitution of unknowns,
then it must return ok before that substitution
-/
theorem subst_preserves_errors_mt {expr : Partial.Expr} {req req' : Partial.Request} {entities : Partial.Entities} {subsmap : Subsmap}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why _mt?

Copy link
Contributor Author

@cdisselkoen cdisselkoen Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Latin "modus tollens", which in formal logic is the rule for contrapositives. I named this in analogue to Lean's use of mp (from the Latin "modus ponens") to mean the forward direction of an implication. Suggestions for a different name? I suppose _contrapositive?

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Copy link
Contributor

@emina emina left a 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.

@cdisselkoen cdisselkoen merged commit 31949a6 into main Jun 26, 2024
5 of 6 checks passed
@cdisselkoen cdisselkoen deleted the cdisselkoen/subst-preserves-errors branch June 26, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants