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

Extend typechecker inversion lemma for type annotation #569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

john-h-kastner-aws
Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws commented Mar 6, 2025

Some changes pulled out of #533

  • Updates type inversion lemmas to prove that type-annotated AST have the same child expression as the input AST
  • Also contains the update for to type-annotation for if

Signed-off-by: John Kastner <jkastner@amazon.com>
∃ tx₁ c₁ tx₂ c₂,
typeOf x₁ c env = Except.ok (tx₁, c₁) ∧
typeOf x₂ c env = Except.ok (tx₂, c₂) ∧
∃ ty, tx = .binaryApp op₂ tx₁ tx₂ ty
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to combine the two existential quantifiers? Btw, there's no detailed specification of ty, like other inversion theorems. Is it intended?

Copy link
Contributor

Choose a reason for hiding this comment

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

I realized that these inversion theorems essentially say that typedOf produces well-typed expressions and subsequent proofs are "Well typed programs cannot go wrong." I'm not sure if we can complete the TPE soundness proof using this inversion theorem. That being said, we can always expand the theorem later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it ok to combine the two existential quantifiers?

I don't see why not

Btw, there's no detailed specification of ty

I don't actually care about ty for my proofs, so this is good enough. The inversion lemma for the specific binary operators do specify ty, but I wanted one inversion lemma for all binary operators to make my proofs simpler. We could extend this lemma to specify the types of tx tx\1 and tx\2 in a match on op\2. Then other inversion lemma could be done in terms of this one, but I didn't need to go that far.

I realized that these inversion theorems essentially say that typedOf produces well-typed expressions

Yeah, there's probably some overlap here. I expect that TPE will need something stronger than what I needed for levels, but we'll probably be able to end up with both proof using the same inversion theorems.

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