Skip to content
TProverPublic

About

B models and generated C from PipelineB

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PipelineB: B models and generated C

B models and the C code generated from them, for 18 small programs. They come from PipelineB, a chain that goes from an informal specification to C with the B method: Claude Opus 5.5 writes the machines and the refinement rules, ProB checks the model against its properties and scenarios (animation, model checking, LTL), BART refines, Atelier B proves, C4B generates the code.

The C code is not proved. Proof covers the B models down to the implementations. The C comes from C4B and has not been verified: this is the gap that a check such as B2ACSL and Frama-C WP could address.

Layout

Each directory is one program:

  • README.md: the problem, its operations and properties, examples, the algorithm;
  • B/: machines, refinements and implementations, as loaded in the Atelier B project;
  • C/: output of C4B, C9X profile.

luhn/C/base/ holds the C of a basic machine, Digit_input. It is written by the model and tested, not generated by C4B. max-array and fill-array are exercises of the B Workbook (CC BY 4.0).

Programs

Proof obligations come from Atelier B. Where a proof rule was added, the count includes the obligations of the machine that validates the rule; those machines are not in this repository.

Program Proof obligations Note
luhn 199/199 Luhn check of a card number, with a basic machine
max-array 24/24 greatest value of an array of 11 integers
fill-array 18/18 fills an array of 11 integers, each position with its own number
count-array 27/27 counts a value in an array of 8 integers
find-array 30/30 first position of a value in an array of 8 integers
sorted-array 27/27 tests that an array of 8 integers is in ascending order
reverse-array 55/55 reverses an array of 8 integers in place
selection-sort 96/96 ascending selection sort of an array of 8 integers; two loops in two components
lower-bound 39/39 binary search of the first cell at least a value, in a sorted array of 8 integers
remove-array 94/94 removes a value from an array of 8 integers, keeping the order of the others
partition-array 72/72 moves the cells below a value to the start of an array of 8 integers; Lomuto partition
dutch-flag 93/93 sorts an array of 8 cells holding three colours; Dijkstra's Dutch national flag
insertion-sort 102/102 ascending insertion sort of an array of 8 integers; nested loops in one component
heap-build 160/160 builds a binary heap in an array of 8 integers
heap-sort 290/290 ascending heap sort of an array of 8 integers; four loops in one component
gcd-int 102/102 greatest common divisor of two integers from 1 to 10000, by Euclid's algorithm
isqrt-int 23/23 integer square root of an integer from 0 to 10000, by binary search
power-int 38/42 integer power by binary exponentiation; the 4 others are obligations on two added proof rules, closed in Lean with BARReL

Tools

Atelier B Community Edition 24.04.2, with BART and C4B; ProB 1.16.0 (nightly of 2026-04-14).

License

Creative Commons Attribution 4.0 International, see LICENSE.

About

B models and generated C from PipelineB

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages