Represent array type lengths as BigInt#1022
Merged
Merged
Conversation
Co-authored-by: Felix A. Wolf <felix.wolf@inf.ethz.ch>
There was a problem hiding this comment.
Pull request overview
This PR is a focused slice of #531 that changes how array type lengths are represented so they are treated as compile-time constants (BigInt) throughout the frontend → internal AST → Viper type encoding pipeline, making array types more consistent and removing the need to encode the length as an expression argument.
Changes:
- Make internal
ArrayTExprcarry aBigIntlength (instead of anExpr) and desugar frontend array type expressions using constant evaluation. - Refine type-head modeling by making
ArrayHDcarry the array size (BigInt) and adjust type encoding / comparability logic accordingly. - Add
evalBool/evalInt/evalString/evalPermconvenience APIs onTypeInfobacked by existing constant evaluation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/scala/viper/gobra/translator/encodings/interfaces/TypeComponentImpl.scala | Encodes array length into the type head serialization; simplifies typeToExpr and precise equality axiom generation accordingly. |
| src/main/scala/viper/gobra/frontend/info/implementation/property/ConstantEvaluation.scala | Adds eval* wrappers around existing constant evaluators. |
| src/main/scala/viper/gobra/frontend/info/TypeInfo.scala | Exposes the new eval* methods on the TypeInfo API. |
| src/main/scala/viper/gobra/frontend/Desugar.scala | Desugars PArrayType lengths via info.evalInt (constant) into internal ArrayTExpr. |
| src/main/scala/viper/gobra/ast/internal/transform/CGEdgesTerminationTransform.scala | Updates construction of ArrayTExpr to pass the BigInt length directly. |
| src/main/scala/viper/gobra/ast/internal/theory/TypeHead.scala | Changes ArrayHD from an object to case class ArrayHD(size: BigInt) and updates related logic. |
| src/main/scala/viper/gobra/ast/internal/theory/Comparability.scala | Updates pattern match for new ArrayHD form. |
| src/main/scala/viper/gobra/ast/internal/Program.scala | Changes ArrayTExpr(length: BigInt, ...) signature. |
| src/main/scala/viper/gobra/ast/internal/PrettyPrinter.scala | Prints array type expressions using BigInt length instead of expression pretty-printing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case StringHD => "string" | ||
| case PointerHD => "pointer" | ||
| case ArrayHD => "array" | ||
| case ArrayHD(n) => s"array$n" |
jcp19
approved these changes
May 2, 2026
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.
This is a subset of PR #531 in an attempt to make that PR's diff eventually smaller