Skip to content

add api for slice/vec/array - #1237

Open
oliver-butterley wants to merge 8 commits into
AeneasVerif:mainfrom
oliver-butterley:Std-container-helper-lemmas
Open

add api for slice/vec/array#1237
oliver-butterley wants to merge 8 commits into
AeneasVerif:mainfrom
oliver-butterley:Std-container-helper-lemmas

Conversation

@oliver-butterley

Copy link
Copy Markdown
Collaborator

This PR adds various basic results for slice/vec/array that were not yet present in Aeneas but fit the pattern of what is included there and which help to make smooth proofs of spec theorems downstream.

@oliver-butterley
oliver-butterley marked this pull request as ready for review July 28, 2026 15:32
@oliver-butterley

oliver-butterley commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

TODO: Array.map deserves to be included in these additions.

/-- Map a function over an `Array`, preserving the length. -/
def Array.map {α : Type u} {β : Type v} {n : Usize} (f : α → β) (a : Array α n) : Array β n :=
  ⟨a.val.map f, by simp [a.property]⟩

EDIT: this def and two lemmas added

theorem Array.val_make {α : Type u} (n : Usize) (l : List α) (h : l.length = n) :
(Array.make n l h).val = l := rfl

@[scalar_tac Array.make n l h, grind =]

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.

We should add simp

Array.make n a.val h = a := rfl

theorem Array.make_inj {α : Type u} {n : Usize} (l₁ l₂ : List α) (h₁ : l₁.length = n)
(h₂ : l₂.length = n) : Array.make n l₁ h₁ = Array.make n l₂ h₂ ↔ l₁ = l₂ :=

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.

I think grind has an attribute for this kind of injectivity lemmas

@oliver-butterley oliver-butterley added the awaiting author A reviewer has asked the author a question or requested changes. label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author A reviewer has asked the author a question or requested changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants