Skip to content

Fix bug: ADT constructors do not change Map to Array when using useArrayTheory option.#1145

Open
thanhnguyen-aws wants to merge 3 commits into
strata-org:mainfrom
thanhnguyen-aws:arraytheoryadt
Open

Fix bug: ADT constructors do not change Map to Array when using useArrayTheory option.#1145
thanhnguyen-aws wants to merge 3 commits into
strata-org:mainfrom
thanhnguyen-aws:arraytheoryadt

Conversation

@thanhnguyen-aws
Copy link
Copy Markdown
Contributor

@thanhnguyen-aws thanhnguyen-aws commented May 8, 2026

Description of changes:

Bug: When useArrayTheory is enabled, the SMT encoder correctly converts Map types to Array in variable declarations and function signatures, but it did not perform this conversion for fields inside ADT (algebraic data type) constructor declarations. This caused a type mismatch: a datatype field would be declared with type Map while the rest of the encoding used Array.

Fix: Thread the useArrayTheory flag through the datatype emission pipeline:

  • lMonoTyToTermType now accepts useArrayTheory and converts Map to Array when enabled.
  • datatypeConstructorsToSMT passes the flag to lMonoTyToTermType.
  • SMT.Context.emitDatatypes accepts and forwards the flag.
  • encodeCore in Verifier.lean passes options.useArrayTheory to emitDatatypes.

Test: Added a unit test in SMTEncoderDatatypeTest.lean that verifies a datatype with a Map-typed field emits (Array Int Int) when useArrayTheory=true and (Map Int Int) when useArrayTheory=false.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@thanhnguyen-aws
Copy link
Copy Markdown
Contributor Author

@keyboardDrummer-bot Please add more PR description and add a test.

@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator

The PR description and tests are already in place:

  • Description: Explains the bug (Map→Array conversion missing in ADT constructor fields), the fix (threading useArrayTheory through lMonoTyToTermTypedatatypeConstructorsToSMTemitDatatypesencodeCore), and the test.
  • Tests: SMTEncoderDatatypeTest.lean includes containerWithMapDatatype with two #guard_msgs tests verifying that Map becomes Array when useArrayTheory=true and stays Map when false.

Let me know if you'd like any changes to the description or additional test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants