Coder Social home page Coder Social logo

compile_and_prove_demo's Introduction

Compile_And_Prove_Demo

This is a repository for the examples of code that will be used on the AdaCore Community website, to demo compilation with GNAT and proof with SPARK.

Each example comes in 3 versions, stored in different sub-directories:

  • initial version - version with compilation errors or warnings, that is also unprovable
  • unproved version - version that is compilable but not provable
  • proved version - version that is both compilable and provable

The initial version contains either direct instructions on how to make the example compilable and provable, or hints on what to modify. Each sub-directory contains a Makefile with entries to compile and prove all examples.

The examples are in increasing order of difficulty:

hello world

sources: hello_world.adb

This shows basic use of the standard command line facilities to print a "hello, world" type of message on the standard output. In the initial version, the precondition of a call to a standard function may be violated. This must be fixed to prove the example.

absolute value

sources: absolute_value.adb

This shows basic use of Ada operators, statements and contracts. In the version that compiles, the postcondition of the function cannot be proved and a run-time check might fail. A precondition is required to fix both issues.

bitwise swap

sources: bitwise_swap.adb

This shows basic use of Ada modular types (the unsigned of C/C++) with bitwise operators, and a contract relating input and output values of a procedure. In the initial version, the compiler points to missing tokens to make the code valid.

saturate angle

sources: saturate.ads saturate.adb saturate_angle.ads

This shows basic use of generics in Ada, with a generic function being instantiated for two scalar values, and a contract on the generic function. In the initial version, the compiler rejects mistyped literals (there is no implicit conversion between integers and floats in Ada).

sensor average

sources: sensor_average.ads sensor_average.adb

This shows basic use of fixed-point types in Ada (real types with a fixed precision contrary to floating-point types) and variables with memory-mapped addresses for sensors. In the initial version, the postcondition of a local function cannot be proved due to missing parentheses in an expression.

strings

sources: strings.ads strings.adb

This shows basic use of arrays and strings in Ada, with a rich postcondition quantifying over the content of strings, and a loop invariant stating the same property during loop iteration. In the compilable version, the example cannot be proved due to a subtle off-by-one error.

communications

sources: communications.ads communications.adb

This shows basic use of a protected object to communicate between two tasks. In the initial version, the compiler rejects a declaration of the protected object that does not hide its components. In the compilable version, the safety of concurrent accesses to a global variable cannot be proved between the tasks.

landing procedure

sources: avionics.ads landing_procedure.adb

This shows basic use of object orientation in Ada, with an interface type being derived into a tagged type. In the initial version, the compiler rejects a derived type that fails to implement all abstract operations from its parent interface. In the compilable version, the safety of behavioral subtyping (weakening of preconditions and strengthening of postconditions) between the parent interface and the derived type cannot be proved. In the proved version, behavioral subtyping ensures that a dispatching call to the procedure with the contract satisfies the precondition of the call, whatever the dynamic type of the object.

compile_and_prove_demo's People

Contributors

setton avatar yannickmoy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.