Skip to content

Review std::optional<unsigned char> specification and proofs - #168

Open
mahadkhan811 wants to merge 2 commits into
mainfrom
review/optional-uint8-minimal-artifacts
Open

mahadkhan811 wants to merge 2 commits into
mainfrom
review/optional-uint8-minimal-artifacts

Conversation

@mahadkhan811

@mahadkhan811 mahadkhan811 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a focused review packet for the std::optional<unsigned char> specification on libstdc++ 12.

It includes:

  • the abstract model, concrete representation predicate, and six operation contracts;
  • two positive C++ clients with proofs that end in Qed.;
  • one negative C++ client with an expected-failure proof committed using Fail Qed. and Abort.;
  • a short scope document and source checksums.

The client and proof directories are divided explicitly into positive/ and negative/. All files are contained under spec-review/optional-unsigned-char/ and are not connected to the repository Dune build.

Review focus

Feedback is requested on:

  • whether the empty/engaged model and representation predicate have the right shape;
  • whether the contracts express the intended value, ownership, and lifetime behavior;
  • whether the definitions are idiomatic for this repository;
  • whether the selected proofs establish useful consequences of the specification.

Pipeline implementation, mutation testing, and generated execution evidence are outside this review.

Validation

  • Source checksums pass.
  • All three selected C++ clients pass C++20 syntax checks.
  • The complete optional proof family builds successfully in the pinned project container, producing all 23 proof objects.

Start with the review README.

@skylabs-ai-ci

skylabs-ai-ci Bot commented Sep 4, 2026

Copy link
Copy Markdown

CI summary (Details)

Active Repos

Repo Job Branch Job Commit Branch Tip Base branch Base commit PR
fmdeps/brick-libcpp/ review/optional-uint8-minimal-artifacts a7d6c94 6455c7e main 94236d2 #168

Passive Repos

Repo Job Branch Job Commit
./ main db1581e
fmdeps/BRiCk/ main 389d262
fmdeps/auto/ main 1158e34
fmdeps/auto-docs/ main 6490c5f
bluerock/NOVA/ skylabs-proof bbb220a
bluerock/bhv/ skylabs-main e6646bb
fmdeps/ci/ main 6a09c2f
vendored/elpi/ skylabs-master c0b9653
vendored/flocq/ skylabs-master cf9cc84
vendored/rocq/ skylabs-master bef7df5
fmdeps/rocq-agent-toolkit/ main 227bb83
vendored/rocq-elpi/ skylabs-master 7dee592
vendored/rocq-equations/ skylabs-main 9cf8471
vendored/rocq-iris/ skylabs-master a7af9f7
vendored/rocq-lsp/ skylabs-main 64ef78a
vendored/rocq-stdlib/ skylabs-master 00897b3
vendored/rocq-stdpp/ skylabs-master 0c5e505
fmdeps/skylabs-fm/ main 69d6d20
vendored/vsrocq/ skylabs-main ee79e7a

No Changes in Warnings or Errors

Before New Fixed After
Errors 0 0 0 0
Warnings 117 0 0 117
Code quality details

Performance

Relative Master MR Change Filename
+0.00% 197191.3 197191.3 +0.0 total
+0.00% 53107.4 53107.4 +0.0 ├ translation units
+0.00% 144083.9 144083.9 +0.0 └ proofs and tests
Full Results
Relative Master MR Change Filename
+0.00% 197191.3 197191.3 +0.0 total
+0.00% 53107.4 53107.4 +0.0 ├ translation units
+0.00% 144083.9 144083.9 +0.0 └ proofs and tests

@pgiarrusso-sl pgiarrusso-sl 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.

My review is not complete, but I have some initial feedback.

At the high level:

  • compared to #110, this PR defines Reps concretely instead of using Parameter/Axioms. This probably is a good idea, since it reduces the risk of vacuous/incorrect assumptions, but it makes the specs harder to apply to other versions, so we should discuss further.

  • I will add some small comments on the code, but I will mark some as "nitpicks" because at the moment I don't know if it's worth addressing them — or lack budget to review fixes.

Comment on lines +8 to +11
Inductive state : Type :=
| empty
| engaged (byte : Z).

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.

This abstract is isomorphic to option Z, that's good. But the model seems to fail SwEng 101 — it reimplements it instead of reusing it.

Comment on lines +59 to +65
sl.lock
Definition optional_base_implR `{Σ : cpp_logic, σ : genv}
(q : cQp.t) : Rep :=
structR
"std::_Optional_base_impl<unsigned char, std::_Optional_base<unsigned char, 1b, 1b>>"
q.
#[only(cfracsplittable,type_ptr,lazy_unfold(export))] derive optional_base_implR.

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.

I wouldn't expect this predicate.

CFracValid1 storageR.
Proof. constructor. intros q s. rewrite storageR.unlock. destruct s; apply _. Qed.
#[global] Instance storageR_cfrac_splittable `{Σ : cpp_logic, σ : genv} :
CFracSplittable_1 storageR := {}.

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.

No action needed, but we should avoid CFracSplittable instances ( SkyLabsAI/BRiCk#282)

The LLM is confused because #[only(cfracsplittable)] derive R. doesn't produce CFracSplittable_1,
but I can't blame the model.

Suggested change
CFracSplittable_1 storageR := {}.


(* Use [optional_value_ptr.unlock] when proving facts about the nested byte. *)
sl.lock
Definition optional_value_ptr `{σ : genv} (this : ptr) : ptr :=

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.

This should be an Abbreviation not locked.

*)
Require Import skylabs.auto.cpp.prelude.proof.
Require Export skylabs.brick.libstdcpp.optional.model.

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.

Software engineering problem: names like storageR are ambiguous when imported unqualified.

Action needed: best to wrap these predicates using NES.Begin and NES.End for namespacing; here, NES.Begin std.optional.

Recommended action: search any examples that violate this guideline, and fix them.

CFracValid1 storageR.
Proof. constructor. intros q s. rewrite storageR.unlock. destruct s; apply _. Qed.
#[global] Instance storageR_cfrac_splittable `{Σ : cpp_logic, σ : genv} :
CFracSplittable_1 storageR := {}.

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.

Nitpick not to fix here, but we should avoid CFracSplittable instances ( SkyLabsAI/BRiCk#282)

The LLM is confused because #[only(cfracsplittable)] derive R. doesn't produce CFracSplittable_1,
but I can't blame the model for being confused.

Suggested change
CFracSplittable_1 storageR := {}.

- Are the representation and contract definitions idiomatic for this
repository?
- Do the three selected proofs demonstrate useful consequences of the spec,
rather than merely restating it?

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.

  • The abstract state should be option Z, but at least is isomorphic to it.
  • The contract/specs look good at first sight.
  • Some reps are not idiomatic, and I'm not yet sure they're used?
  • The selected proofs seem actual consequences (unlike the old oracle ones). Coverage seems a bit low, but I assume that's because we wanted a small PR for review. Larger coverage will be required for real use..

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