Skip to content

Support struct.readm/writem of array-of-felt members - #732

Open
raghav198 wants to merge 16 commits into
mainfrom
raghav/smt-member-read-write-array
Open

raghav198 wants to merge 16 commits into
mainfrom
raghav/smt-member-read-write-array

Conversation

@raghav198

Copy link
Copy Markdown
Contributor

Add support for SMT lowering for struct.readm and struct.writem when the type of the member being read from/written to is an array of felt:

  • For writem, emit a quantified assertion over the array bounds
  • For readm, maybe quantify constrain uses?

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

0 files   -   2  0 suites   - 2   0s ⏱️ - 1m 3s
0 tests  - 462  0 ✅  - 458  0 💤  - 4  0 ❌ ±0 
0 runs   - 924  0 ✅  - 916  0 💤  - 8  0 ❌ ±0 

Results for commit d21bb5c. ± Comparison against base commit 5e0ea0d.

♻️ This comment has been updated with latest results.

@raghav198
raghav198 added this pull request to stack #733 September 14, 2026 20:39
@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch 5 times, most recently from 2c1f736 to 736bd74 Compare September 21, 2026 17:40
@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch from 83df4f3 to 1e47961 Compare September 23, 2026 16:44
@raghav198

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T17:36:25.398353Z 33303d1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33303d172b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

loc, *extents,
[this, &loc, &lhs, &builder, &lhsRange, &rhsRange, &prefix](ValueRange indices) -> Value {
auto lhsElement = emitter->emitArraySelect(loc, lhs, indices, builder);
auto rhsElement = emitter->emitArraySelect(loc, lhs, indices, builder);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Select the right-hand array for equality

For every statically shaped array write or array-valued constrain.eq, the quantified predicate selects both elements from lhs; rhs is never referenced. In the common canonical-range case this emits lhs[i] == lhs[i], so a struct.writem no longer connects the witness array to the value being written and the solver can accept incorrect witnesses. The second selection must use rhs.

Useful? React with 👍 / 👎.

Comment on lines +259 to +260
addConversion([this, ctx](array::ArrayType arrType) {
return smt::ArrayType::get(ctx, smt::IntType::get(ctx), convertType(arrType.getElementType()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve every source array dimension in the SMT type

For an array with rank greater than one, such as !array.type<2,3 x !felt.type>, this conversion creates only one !smt.array layer, while emitArraySelect later performs one select per source dimension. The first select therefore returns !smt.int, and the second attempts to use that integer as an SMT array, causing verification/lowering failure for valid multidimensional array members. Build nested SMT array types for all dimensions or consistently flatten the indices.

Useful? React with 👍 / 👎.

Comment on lines +1029 to +1032
for (auto memberDef : structDef.getMemberDefs()) {
if (!isa<felt::FeltType>(memberDef.getType())) {
continue;
}
// if (!isa<felt::FeltType>(memberDef.getType())) {
// continue;
// }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip unsupported struct members when declaring SMT symbols

When a struct contains an unused non-felt member, such as another struct or an array of non-felt elements, the pass now processes it even though only felt and array-of-felt reads/writes are supported. convertType leaves unsupported types unchanged, after which they are used as the result type of smt.declare_fun, whose result must be an SMT type; consequently modules that previously lowered by ignoring such unused members now produce invalid SMT IR. Retain a filter that admits only felt and supported array-of-felt members.

Useful? React with 👍 / 👎.

@raghav198
raghav198 marked this pull request as ready for review September 23, 2026 17:48
@raghav198
raghav198 requested a review from a team as a code owner September 23, 2026 17:48
@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch from 7ca26bf to 8d17b09 Compare September 23, 2026 18:36
Comment thread backends/smt/lib/Conversions/SMTLoweringCommon.cpp Outdated
Comment thread backends/smt/lib/Conversions/SMTLoweringCommon.cpp Outdated
Comment thread backends/smt/lib/Conversions/SMTLoweringCommon.h
Comment thread backends/smt/lib/Conversions/SMTLoweringCommon.h Outdated
Comment thread backends/smt/lib/Conversions/SMTLoweringPass.cpp Outdated
Comment thread backends/smt/lib/Conversions/SMTLoweringPass.cpp Outdated
Comment thread backends/smt/lib/Conversions/SMTLoweringPass.cpp Outdated
@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch from 94910f1 to 9723ba6 Compare September 24, 2026 15:50

@tim-hoffman tim-hoffman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM; leaving final approval to @shankarapailoor

@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch 3 times, most recently from 75325b2 to 4ba30c5 Compare September 30, 2026 20:03
@raghav198
raghav198 force-pushed the raghav/smt-member-read-write-array branch from 4ba30c5 to d21bb5c Compare October 2, 2026 19:21

This branch has not been deployed

No deployments
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