Skip to content

Support enum/existentials in formula_fn#64

Merged
coord-e merged 2 commits intomainfrom
coord-e/formula-fns
Mar 31, 2026
Merged

Support enum/existentials in formula_fn#64
coord-e merged 2 commits intomainfrom
coord-e/formula-fns

Conversation

@coord-e
Copy link
Copy Markdown
Owner

@coord-e coord-e commented Mar 30, 2026

for #57
continued from #65

@coord-e coord-e force-pushed the coord-e/formula-fns branch from 0acf1b4 to 64291aa Compare March 31, 2026 13:36
@coord-e coord-e changed the title Enable to annotate functions with formula_fn Support enum/existentials in formula_fn Mar 31, 2026
@coord-e coord-e force-pushed the coord-e/formula-fns branch 4 times, most recently from a4be706 to 1eba386 Compare March 31, 2026 14:44
@coord-e coord-e marked this pull request as ready for review March 31, 2026 14:44
@coord-e coord-e requested a review from Copilot March 31, 2026 14:45
Copy link
Copy Markdown

Copilot AI left a comment

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 extends #[thrust::formula_fn] translation to cover (1) existential quantification via an exists helper and (2) enum variant constructors, enabling requires/ensures specifications to mention these constructs directly in Rust expressions (continuing the work from #57 / #65).

Changes:

  • Add thrust_models::exists(...) as a definitional hook and teach AnnotFnTranslator to translate exists(|...| ...) into chc::Formula::exists.
  • Add enum variant-constructor term translation (X::A(...), unit variants, etc.) to formula_fn translation.
  • Add UI pass/fail tests validating existential and enum usage in formula_fn annotations.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/analyze/annot_fn.rs Adds TypeBuilder usage, enum constructor term translation, and exists closure lowering to CHC existentials.
src/analyze/did_cache.rs Caches the DefId for the new #[thrust::def::exists] hook.
src/analyze/annot.rs Adds the attribute path helper for thrust::def::exists.
std.rs Introduces the #[thrust::def::exists] stub in the injected thrust_models module.
tests/ui/pass/annot_exists_formula_fn.rs New passing test for existential quantification in formula_fn ensures.
tests/ui/fail/annot_exists_formula_fn.rs New failing test ensuring existential postcondition is rejected when not satisfied.
tests/ui/pass/annot_enum_simple_formula_fn.rs New passing test for enum constructor equality in formula_fn requires.
tests/ui/fail/annot_enum_simple_formula_fn.rs New failing counterpart for the enum constructor formula_fn test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coord-e coord-e force-pushed the coord-e/formula-fns branch from 1eba386 to 1162a2d Compare March 31, 2026 14:58
@coord-e coord-e force-pushed the coord-e/formula-fns branch from 1162a2d to 889b84e Compare March 31, 2026 14:59
@coord-e coord-e merged commit 9bce62e into main Mar 31, 2026
6 checks passed
@coord-e coord-e deleted the coord-e/formula-fns branch March 31, 2026 15:02
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