Strong completeness of CST to AST translation and error collector - #15
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a CST “error collector” that traverses CST syntax without short-circuiting, enabling a strong completeness result for CST→AST translation: if comprehensive collection finds no translation (cstError) errors, translation succeeds even if runtime (non-cstError) evaluation errors may occur.
Changes:
- Adds a CST error-collection semantics (
Cedar/Spec/CstErrorCollector.lean) plus accompanying translation-completeness theorems (Cedar/Thm/Translation/CstErrorCollector.lean). - Strengthens the translation story with a new theorem
translation_is_strongly_completeand hooks it into the main translation theory import. - Extends CST error taxonomy (
primaryOverflowError) and aligns CST semantics/guards (Primary.evaluateoverflow +Cst.hasErrorguard expansion).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cedar-lean/Cedar/Thm/Translation/ExprComplete.lean | Imports the CST error-collector infrastructure for expression completeness results. |
| cedar-lean/Cedar/Thm/Translation/CstErrorCollector.lean | Adds theorems connecting the collector to translation/evaluation and list/policy completeness. |
| cedar-lean/Cedar/Thm/Translation/AuxComplete.lean | Adds lemma equating toPolicy?.isNone with the expanded hasError translation guard. |
| cedar-lean/Cedar/Thm/Translation.lean | Integrates collector theorems and adds translation_is_strongly_complete. |
| cedar-lean/Cedar/Spec/Value.lean | Adds new CST error constructor primaryOverflowError. |
| cedar-lean/Cedar/Spec/CstSemantics.lean | Updates numeric overflow to a CST error and expands the hasError translation guard. |
| cedar-lean/Cedar/Spec/CstErrorCollector.lean | Implements comprehensive CST error collection plus ordering for Set Error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+22
| def noCstError (es : Set Error) : Bool := | ||
| ∀ e ∈ es, ¬ (Error.isCstError e) |
Comment on lines
+171
to
+187
| let argErrs := (collectExprList args req es).1 | ||
| match CstCommon.Ident.toUnreservedString? i with | ||
| | none => | ||
| (Set.singleton (Error.cstError .stringError) ∪ argErrs ∪ (Member.collectAccessors none rest req es).1, none) | ||
| | some m => | ||
| match CstCommon.String.toMethodOp? m with | ||
| | some (.inl bop) => | ||
| match args with | ||
| | [arg] => | ||
| let step : CollectResult := | ||
| match head, (arg.collectErrors req es).2 with | ||
| | some hv, some av => CollectResult.ofResult (apply₂ bop hv av es) | ||
| | _, _ => (∅, none) | ||
| let rst := Member.collectAccessors step.2 rest req es | ||
| (argErrs ∪ step.1 ∪ rst.1, rst.2) | ||
| | _ => | ||
| (Set.singleton (Error.cstError .arityError) ∪ argErrs ∪ (Member.collectAccessors none rest req es).1, none) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented the error collecting semantics of Cedar CST. The implementation can be found in
cedar-lean/Spec/CstErrorCollector.lean.A theorem
expr_error_collector_evaluatethat states that the error collector generates the same values as the evaluator on expressions can be found incedar-lean/Thm/Translation/ExprComplete.lean.Proved the strong completeness theorem -- if the CST error collection does not detect CST Errors then it can be translated.
The final theorem
translation_is_strongly_completecan be found intranslation_is_strongly_complete.