Skip to content

Correction: Update SPARK examples for GNAT FSF 16 - #1400

Closed
gusthoff wants to merge 3 commits into
AdaCore:mainfrom
gusthoff:dev/topic/content/general/gnat-16-update/spark/2026-11-06
Closed

gusthoff wants to merge 3 commits into
AdaCore:mainfrom
gusthoff:dev/topic/content/general/gnat-16-update/spark/2026-11-06

Conversation

@gusthoff

@gusthoff gusthoff commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Update three SPARK chapters for the current toolchain while preserving a
gradual teaching sequence. Introduce each necessary annotation or code
change before showing it, and keep the explanations focused on proper
SPARK use.

Syntactic guarantees

  • Show the direct C-to-Ada translation and its termination diagnostic
    before introducing Loop_Variant in a second example.
  • Remove the old toolchain pins and restore compilation and proof buttons.

State abstraction

  • Preserve the invalid abstract-state comparison as a no_button
    illustration, removing its old toolchain pins and build/proof requests.
  • Explain why a state abstraction cannot appear in an expression and
    identify the missing full-stack check before the corrected example.

Functional correctness

  • Revise the negative ring-buffer examples because GNAT FSF 16 misses
    their intended ghost-use diagnostics on record selectors.
  • Retain the record model, isolate missing model maintenance, and make
    the invalid dependency from ghost data to normal state explicit.
  • Pair each failure with a correction, including a new Example Added section on files and streams #5 that
    shares a computation derived from normal state.
  • Require Valid_Model after a push so the contract establishes agreement
    between the model and buffer lengths. The previous postcondition could
    prove even when the real length update was omitted.
  • Present the local ghost procedure as an alternative organization,
    restore proof buttons, remove old pins, and renumber later examples.

Scope and impact

  • 03_syntactic_guarantees.rst in SPARK for the MISRA C Developer.
  • 04_State_Abstraction.rst and
    05_Proof_Of_Functional_Correctness.rst in Intro to SPARK.

Validation

  • Check the Syntactic Guarantees chapter at the 80-column limit.
  • Confirm that GNAT FSF 16 syntax checking accepts the abstract-state
    illustration without crashing.
  • Check 13 ring-buffer cases, including deliberate update omissions,
    and confirm that the final examples match the tested candidates.
  • Verify HTML rendering, example numbering, and widget buttons.

Co-Authored-By: Codex noreply@openai.com

gusthoff and others added 3 commits November 6, 2026 20:03
- Show the direct translation and its termination diagnostic before
  introducing `Loop_Variant` in a second example.
- Remove old toolchain pins and restore compilation and proof buttons.

Co-Authored-By: Codex <noreply@openai.com>
- Keep the invalid comparison as a `no_button` illustration, removing
  the old toolchain pins and compilation/proof requests.
- Explain the abstract-state restriction and missing full-stack check.

Co-Authored-By: Codex <noreply@openai.com>
- GNAT FSF 16 misses the intended ghost-use diagnostics on record
  selectors in the original negative examples. Keeping those forms
  unchanged would obscure the mistakes and require toolchain-specific
  explanations.
- Retain the record model, but isolate missing model maintenance and
  make the invalid ghost dependency explicit. Explain each change before
  the code and pair proof failures with corrections, focusing the lesson
  on proper SPARK use.
- Require `Valid_Model` after a push so the contract establishes
  agreement about length. The original increment-only postcondition
  could prove even when the real length update was omitted.
- Add the corrected shared computation as Example #5, introduce the
  ghost procedure as an alternative organization, restore proof buttons,
  remove old toolchain pins, and renumber subsequent examples.
- Check 13 pipeline cases at the 80-column limit, including deliberate
  update omissions. Confirm the final Ada matches the tested candidates
  and verify the rendered numbering and buttons.

Co-Authored-By: Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant