Skip to content

Strong completeness of CST to AST translation and error collector - #15

Merged
ychtao merged 6 commits into
mainfrom
error-collector
Jul 24, 2026
Merged

Strong completeness of CST to AST translation and error collector#15
ychtao merged 6 commits into
mainfrom
error-collector

Conversation

@ychtao

@ychtao ychtao commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Implemented the error collecting semantics of Cedar CST. The implementation can be found in cedar-lean/Spec/CstErrorCollector.lean.

A theorem expr_error_collector_evaluate that states that the error collector generates the same values as the evaluator on expressions can be found in cedar-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_complete can be found in translation_is_strongly_complete.

@ychtao
ychtao requested a review from victornicolet July 20, 2026 19:12
@ychtao ychtao changed the title Error collecting semantics Strong completeness of CST to AST translation and error collector Jul 23, 2026
@ychtao
ychtao requested a review from Copilot July 23, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_complete and hooks it into the main translation theory import.
  • Extends CST error taxonomy (primaryOverflowError) and aligns CST semantics/guards (Primary.evaluate overflow + Cst.hasError guard 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)
@ychtao
ychtao merged commit bac10eb into main Jul 24, 2026
4 of 12 checks passed
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.

2 participants