Skip to content

Add Seq<T> as a model of Vec<T>#143

Open
coord-e wants to merge 7 commits into
mainfrom
claude/nifty-newton-wfxz2e
Open

Add Seq<T> as a model of Vec<T>#143
coord-e wants to merge 7 commits into
mainfrom
claude/nifty-newton-wfxz2e

Conversation

@coord-e

@coord-e coord-e commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Introduces thrust_models::model::Seq as (Array<Int, T>, Int), equipped with basic sequence operations and concatenation.

https://claude.ai/code/session_01A7nMxM1sJ8wxVJmMvsEvSX

@coord-e coord-e changed the title Phase 1: Seq&lt;T&gt; ghost type — len, push, indexing Phase 1: Seq&lt;T&gt; ghost type Jun 20, 2026
@coord-e coord-e force-pushed the claude/nifty-newton-wfxz2e branch 5 times, most recently from f2666fd to 6918241 Compare June 23, 2026 12:28
claude and others added 5 commits June 23, 2026 23:30
A spec-only `thrust_models::model::Seq<T>` analogous to the existing
`model::Vec`: the logical representation is `(Array<Int, T>, Int)`
(the array carries elements, the int carries length). The
`#[thrust::def::seq_model]` marker lets the analyzer recognise `Seq`
ADTs in future patches.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7nMxM1sJ8wxVJmMvsEvSX
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7nMxM1sJ8wxVJmMvsEvSX
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7nMxM1sJ8wxVJmMvsEvSX
@coord-e coord-e force-pushed the claude/nifty-newton-wfxz2e branch from 6918241 to 5182f56 Compare June 23, 2026 14:31
@coord-e coord-e changed the title Phase 1: Seq&lt;T&gt; ghost type Add Seq<T> as a model of Vec<T> Jun 23, 2026
@coord-e coord-e marked this pull request as ready for review June 23, 2026 14:40
@coord-e coord-e requested a review from Copilot June 23, 2026 14:40

@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: 5182f5650e

ℹ️ 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".

Comment thread src/chc/format_context.rs Outdated
Comment thread src/chc.rs
Comment on lines +758 to +759
Sort::Datatype(_) | Sort::Param(_) => {
unimplemented!("no default value for sort {sort:?}")

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 Handle ADT elements in empty sequence arrays

Seq::empty() and Seq::singleton() create ArrayEmpty(elem_sort), and SMT formatting asks Term::default_for(elem_sort) for the const-array value. For element models that lower to datatypes, such as Option<Int>/Result<..> or user enums, this newly added branch panics before the solver runs, so otherwise valid specs like comparing Seq::<Option<Int>>::empty() cannot be checked. Either provide a datatype default or avoid needing a concrete default value for empty arrays.

Useful? React with 👍 / 👎.

@coord-e coord-e Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

yes this is TODO

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a new logical sequence model thrust_models::model::Seq<T> (represented as (Array<Int, T>, Int)) and uses it as the underlying model for Rust Vec<T>, adding core sequence operations (empty/singleton/len/push/concat) plus SMT encoding support and UI tests.

Changes:

  • Add Seq<T> model definitions and switch Vec<T>’s model type to Seq<T> in std.rs.
  • Extend the CHC term language + SMT-LIB2 backend to support empty arrays and array concatenation (including a concat-recursive helper function).
  • Add UI pass/fail tests covering Seq basics, concat properties, and Vec specs expressed via the Seq model.

Reviewed changes

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

Show a summary per file
File Description
std.rs Defines model::Seq<T> and maps Vec<T>’s model to Seq, updating extern specs accordingly.
src/chc.rs Adds ArrayEmpty/ArrayConcat term forms, ite, and select peephole rewrites for concat.
src/chc/smtlib2.rs Prints SMT for ArrayEmpty and ArrayConcat; emits per-element-sort seq_concat_arr recursion.
src/chc/format_context.rs Tracks array element sorts to decide which seq_concat_arr helpers to emit.
src/chc/unbox.rs Extends unboxing pass to traverse/transform new array terms.
src/rty.rs Substitutes type params through the new CHC term variants.
src/annot.rs Tightens Resolver output bound to Clone to support term construction needs.
src/analyze/did_cache.rs Adds DefId caching for seq_* annotated defs.
src/analyze/annot.rs Adds attribute-path helpers for seq_* annotations.
src/analyze/annot_fn.rs Translates Seq operations and indexing into CHC terms (incl. concat -> ArrayConcat).
tests/ui/pass/seq_basic.rs Pass test for empty/singleton/len/push/index properties.
tests/ui/pass/seq_concat.rs Pass test for concat length property.
tests/ui/pass/seq_concat_index.rs Pass test for left-side index behavior under concat.
tests/ui/pass/seq_concat_const.rs Pass test for concat identity with empty.
tests/ui/pass/seq_specs_vec_build.rs Pass test showing Vec can be specified using Seq model structure/ops.
tests/ui/fail/seq_basic.rs Fail test with intentionally wrong push length spec.
tests/ui/fail/seq_concat.rs Fail test with intentionally wrong concat length spec.
tests/ui/fail/seq_concat_index.rs Fail test with intentionally wrong concat index spec.
tests/ui/fail/seq_concat_const.rs Fail test with intentionally wrong concat identity spec.
tests/ui/fail/seq_specs_vec_build.rs Fail test with intentionally wrong Vec element spec via Seq.

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

Comment thread src/chc/format_context.rs Outdated
Comment thread src/chc.rs Outdated
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.

3 participants