SlideShare a Scribd company logo
info@adacore.com adacore.com
Pushing the Boundary
of Mostly Automatic
Program Proof
Yannick Moy
Copyright © AdaCore
High Integrity Software 2022 Conference - October 11, 2022
info@adacore.com adacore.com
The Verifying Compiler
A verifying compiler uses mathematical and logical reasoning to check the
correctness of the programs that it compiles.
Sir Tony Hoare, Journal of the ACM, 2003
2
Copyright © AdaCore
info@adacore.com adacore.com
Our formally verified microkernel, seL4, is now used across the world
in a number of applications that keeps growing.
June Andronick, Successes in Deployed Verified Software, 2019
The Verifying Compiler in Practice
3
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach
4
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach
• Use programming language as specification language
5
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach
• Use programming language as specification language
• Leverage array of automatic provers
6
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach
• Use programming language as specification language
• Leverage array of automatic provers
• Limit specifications to what can be “mostly” automated
7
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach
• Use programming language as specification language
• Leverage array of automatic provers
• Limit specifications to what can be “mostly” automated
• Use “ghost code” to reach fully automatic proof
8
Copyright © AdaCore
info@adacore.com adacore.com
The Auto-Active Approach in SPARK
• Use Ada as programming language and specification language (contracts)
• Leverage automatic provers Alt-Ergo, COLIBRI, cvc5, Z3
• Specifications are limited by the language (“contracts”) and best practices
• Code marked as “ghost” is only used for verification
9
Copyright © AdaCore
info@adacore.com adacore.com
Low-Hanging Fruits with Program Proof
10
Copyright © AdaCore
info@adacore.com adacore.com
Low-Hanging Fruits with Program Proof
• Absence of runtime errors
• no exception raised (predefined or explicitly in the code)
• no reads of uninitialized data
11
Copyright © AdaCore
info@adacore.com adacore.com
Low-Hanging Fruits with Program Proof
• Absence of runtime errors
• no exception raised (predefined or explicitly in the code)
• no reads of uninitialized data
• Correct API usage
• correct input context when calling functions
• correct sequencing of calls on data
12
Copyright © AdaCore
info@adacore.com adacore.com
Low-Hanging Fruits with Program Proof
• Absence of runtime errors
• no exception raised (predefined or explicitly in the code)
• no reads of uninitialized data
• Correct API usage
• correct input context when calling functions
• correct sequencing of calls on data
• Data invariants respected
• “permanent” invariants that should hold always
• “boundary” invariants that should hold for client code
13
Copyright © AdaCore
info@adacore.com adacore.com
Initialization is in general guaranteed by
sticking to an initialization policy checked
by a data-flow algorithm
More complex initialization patterns
require specifying:
• what parts of objects are initialized
• under which conditions
Mix of boolean conditions and arithmetic is
a strong suit of automatic provers
SPARK programming language has
constraints and specification features that
make it straightforward:
• memory safety amounts to checking
non-nullity of pointers and that indexes
are in bounds
• numerical type safety amounts to
checking that computations don’t
divide by zero or exceed bounds
(Integer) (Linear) Arithmetic is a strong suit
of automatic provers
Absence of Runtime Errors
14
Copyright © AdaCore
info@adacore.com adacore.com
Initialization is in general guaranteed by
sticking to an initialization policy checked
by a data-flow algorithm
More complex initialization patterns
require specifying:
• what parts of objects are initialized
• under which conditions
Mix of boolean conditions and arithmetic is
a strong suit of automatic provers
SPARK programming language has
constraints and specification features that
make it straightforward:
• memory safety amounts to checking
non-nullity of pointers and that indexes
are in bounds
• numerical type safety amounts to
checking that computations don’t
divide by zero or exceed bounds
(Integer) (Linear) Arithmetic is a strong suit
of automatic provers
Absence of Runtime Errors
15
Copyright © AdaCore
info@adacore.com adacore.com
Correct sequencing of calls expressed in
preconditions and postconditions:
• state of parameters wrt prescribed
automaton
• global state wrt prescribed automaton
Possibly using imported ghost functions
to express state
Resource reclamation (e.g. dynamic
memory deallocation)
Based on simple boolean conditions
Correct input context:
• value of parameters respect
conditions beyond type safety
• lifetime of pointer parameters
consistent with their use
• relations between parameters are
respected
• global state respects constraints
Preconditions that usually rely on mix of
arithmetic and boolean conditions
Correct API Usage
16
Copyright © AdaCore
info@adacore.com adacore.com
Correct sequencing of calls expressed in
preconditions and postconditions:
• state of parameters wrt prescribed
automaton
• global state wrt prescribed automaton
Possibly using imported ghost functions
to express state
Resource reclamation (e.g. dynamic
memory deallocation)
Based on simple boolean conditions
Correct input context:
• value of parameters respect
conditions beyond type safety
• lifetime of pointer parameters
consistent with their use
• relations between parameters are
respected
• global state respects constraints
Preconditions that usually rely on mix of
arithmetic and boolean conditions
Correct API Usage
17
Copyright © AdaCore
info@adacore.com adacore.com
Type invariants (“boundary” invariants)
only hold outside the unit:
• possibly violated locally
• restored before returning to client
Used to hide data invariant from client
unit
Same kinds of properties as predicates
Type predicates (“permanent” invariants)
always hold:
• subset of values from the base type
• conditions on bounds of arrays
• relations between fields of structures
(e.g. inequality comparisons)
• conditions on field initialization
Same mix of arithmetic and boolean
conditions as before
Data Invariants Respected
18
Copyright © AdaCore
info@adacore.com adacore.com
Type invariants (“boundary” invariants)
only hold outside the unit:
• possibly violated locally
• restored before returning to client
Used to hide data invariant from client
unit
Same kinds of properties as predicates
Type predicates (“permanent” invariants)
always hold:
• subset of values from the base type
• conditions on bounds of arrays
• relations between fields of structures
(e.g. inequality comparisons)
• conditions on field initialization
Same mix of arithmetic and boolean
conditions as before
Data Invariants Respected
19
Copyright © AdaCore
info@adacore.com adacore.com
Stretch Goals with Program Proof
20
Copyright © AdaCore
info@adacore.com adacore.com
Stretch Goals with Program Proof
• Prove full functional behavior
21
Copyright © AdaCore
info@adacore.com adacore.com
Stretch Goals with Program Proof
• Prove full functional behavior
• Prove the implementation of complex data structures
• absence of runtime errors
• data invariants respected
• functional behavior
22
Copyright © AdaCore
info@adacore.com adacore.com
Stretch Goals with Program Proof
• Prove full functional behavior
• Prove the implementation of complex data structures
• absence of runtime errors
• data invariants respected
• functional behavior
• Prove numerical algorithms
• exact result of computations
• bounds on the approximation wrt mathematical computation
23
Copyright © AdaCore
info@adacore.com adacore.com
Need to express the specification as
contracts, usually as a form of refinement:
• concrete types refine an ideal model
(mathematical integers, sets, maps…)
• concrete implementation respects the
ideal computation on models
• contracts can use quantification and
abstraction
Best practices: no existential, abstract
important properties
Need to write ghost code (assertions, loop
invariants) through interaction with
automatic provers
Prove Full Functional Behavior
24
Copyright © AdaCore
https://blog.adacore.com/i-cant-believe-that-i-can-prove-that-it-can-sort
info@adacore.com adacore.com
Example: sorting algorithms
• ideal model of bag / multiset
• sorting preserves model
• property uses quantification
• property should use abstraction: being
sorted on subrange, being the
maximum on subrange
With suitable properties, and little
adequate ghost code, this is easily proved
by automatic provers
Need to express the specification as
contracts, usually as a form of refinement:
• concrete types refine an ideal model
(mathematical integers, sets, maps…)
• concrete implementation respects the
ideal computation on models
• contracts can use quantification and
abstraction
Best practices: no existential, abstract
important properties
Need to write ghost code (assertions, loop
invariants) through interaction with
automatic provers
Prove Full Functional Behavior
25
Copyright © AdaCore
https://blog.adacore.com/i-cant-believe-that-i-can-prove-that-it-can-sort
info@adacore.com adacore.com
Need to structure the code to separate
concerns:
• different types provide different views
of the data with different models
• complexity is encapsulated at each
level through abstraction
Best practices: use privacy to hide
implementation and verification details
Need to write ghost code (lemmas for
induction) through interaction with
automatic provers
Prove Complex Data Structures
26
Copyright © AdaCore
https://blog.adacore.com/research-corner-auto-active-verification-in-spark
info@adacore.com adacore.com
Example: red-black trees for bare-metal
• level 1: binary trees
• level 2: sorted trees
• level 3: balanced trees
• properties at each level encoded as
type invariants on private types
size of contracts = 2 x size of code
size of ghost code = 5 x size of code
Implementation constraints matter: same
with dynamic allocation has four times
less ghost code
Need to structure the code to separate
concerns:
• different types provide different views
of the data with different models
• complexity is encapsulated at each
level through abstraction
Best practices: use privacy to hide
implementation and verification details
Need to write ghost code (lemmas for
induction) through interaction with
automatic provers
Prove Complex Data Structures
27
Copyright © AdaCore
https://blog.adacore.com/research-corner-auto-active-verification-in-spark
info@adacore.com adacore.com
Algorithms on integers:
• refine mathematical operations
• efficient implementations on machine
integers require bitwise
manipulations
Exploit dedicated support of bitvectors in
automatic provers
Algorithms on reals:
• implement control algorithms
• expectation is to remain “close” to the
ideal computation on reals despite
rounding errors and approximations
Exploit dedicated support of floats in
automatic provers
Prove Numerical Algorithms
28
Copyright © AdaCore
https://blog.adacore.com/proving-the-correctness-of-gnat-light-runtime-library
info@adacore.com adacore.com
Example: multi-place integer arithmetic
• mix of signed integers and modular
integers
• a lot of non-linear operations
(multiplications, shifting, division, mod)
size of contracts = 0.15 x size of code
size of ghost code = 5 x size of code
Proof of ≈100 lemmas requires use of all
four automatic provers: Alt-Ergo, COLIBRI,
cvc5, Z3
Algorithms on integers:
• refine mathematical operations
• efficient implementations on machine
integers require bitwise
manipulations
Exploit dedicated support of bitvectors in
automatic provers
Algorithms on reals:
• implement control algorithms
• expectation is to remain “close” to the
ideal computation on reals despite
rounding errors and approximations
Exploit dedicated support of floats in
automatic provers
Prove Numerical Algorithms
29
Copyright © AdaCore
https://blog.adacore.com/proving-the-correctness-of-gnat-light-runtime-library
info@adacore.com adacore.com
Challenges with Program Proof
30
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: …
31
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: better interaction mechanisms
32
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: better interaction mechanisms
• Predictability of proof results
• automatic provers are based on heuristic search
• solution: …
33
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: better interaction mechanisms
• Predictability of proof results
• automatic provers are based on heuristic search
• solution: know the low-hanging fruits from the stretch goals
34
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: better interaction mechanisms
• Predictability of proof results
• automatic provers are based on heuristic search
• solution: know the low-hanging fruits from the stretch goals
• Stability of proof results
• minor changes in code or tool can lead to losing proofs
• solution: …
35
Copyright © AdaCore
info@adacore.com adacore.com
Challenges with Program Proof
• Left-Over Principle of automation
• automation fails humans on the more complex cases
• solution: better interaction mechanisms
• Predictability of proof results
• automatic provers are based on heuristic search
• solution: know the low-hanging fruits from the stretch goals
• Stability of proof results
• minor changes in code or tool can lead to losing proofs
• solution: prover redundancy and advances in automatic proof technology
36
Copyright © AdaCore
info@adacore.com adacore.com
The Verifying Compiler
If the project is successful, a verifying compiler will be available as a standard tool
in some widely used programming productivity toolset.
Sir Tony Hoare, Journal of the ACM, 2003
37
Copyright © AdaCore
Thank you
Yannick Moy
moy@adacore.com
38
info@adacore.com Copyright © AdaCore
adacore.com

More Related Content

PDF
apidays Paris 2024 - API Governance for EDA, Frank Kilcommins, SmartBear
PPTX
Design patterns for salesforce app decomposition
PDF
How-To Find Malicious Backdoors and Business Logic Vulnerabilities in Your Code
PPTX
AngularJS 1.x - your first application (problems and solutions)
PPTX
Serverless patterns
PPTX
Beginners overview of automated testing with Rspec
PPTX
Designing a Future-proof API Program
PPT
Code Quality - Security
apidays Paris 2024 - API Governance for EDA, Frank Kilcommins, SmartBear
Design patterns for salesforce app decomposition
How-To Find Malicious Backdoors and Business Logic Vulnerabilities in Your Code
AngularJS 1.x - your first application (problems and solutions)
Serverless patterns
Beginners overview of automated testing with Rspec
Designing a Future-proof API Program
Code Quality - Security

Similar to Pushing the Boundary of Mostly Automatic Program Proof (20)

PPTX
Application Architecture
PDF
Addressing Cloud Security with OPA
PDF
Single Source of Truth for Network Automation
PPTX
Salesforce Multitenant Architecture: How We Do the Magic We Do
PDF
Secure Salesforce: Code Scanning with Checkmarx
PDF
AWS-Certified-ML-Engineer-Associate-Slides.pdf
PPTX
Curiosity and fourTheorem present: From Coverage Guesswork to Targeted Test G...
PPTX
The Changing Role of a DBA in an Autonomous World
PPT
NDepend Public PPT (2008)
PPTX
re:Invent 2023 - The Pragmatic Serverless Python Developer
PDF
Mobx Internals
PDF
Software design with Domain-driven design
PPTX
CIM Compliance.pptx
PDF
Group meeting: Identifying Information Disclosure in Web Applications with Re...
PPTX
Improving the Quality of Existing Software
PPTX
Static Analysis Primer
PPTX
Polaris presentation ioc - code conference
PDF
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
PDF
5 Ways to Accelerate Standards Compliance with Static Code Analysis
PPTX
Improving the Quality of Existing Software - DevIntersection April 2016
Application Architecture
Addressing Cloud Security with OPA
Single Source of Truth for Network Automation
Salesforce Multitenant Architecture: How We Do the Magic We Do
Secure Salesforce: Code Scanning with Checkmarx
AWS-Certified-ML-Engineer-Associate-Slides.pdf
Curiosity and fourTheorem present: From Coverage Guesswork to Targeted Test G...
The Changing Role of a DBA in an Autonomous World
NDepend Public PPT (2008)
re:Invent 2023 - The Pragmatic Serverless Python Developer
Mobx Internals
Software design with Domain-driven design
CIM Compliance.pptx
Group meeting: Identifying Information Disclosure in Web Applications with Re...
Improving the Quality of Existing Software
Static Analysis Primer
Polaris presentation ioc - code conference
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
5 Ways to Accelerate Standards Compliance with Static Code Analysis
Improving the Quality of Existing Software - DevIntersection April 2016

More from AdaCore (20)

PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Have we a Human Ecosystem?
PDF
Rust and the coming age of high integrity languages
PDF
SPARKNaCl: A verified, fast cryptographic library
PDF
Developing Future High Integrity Processing Solutions
PDF
Taming event-driven software via formal verification
PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Product Lines and Ecosystems: from customization to configuration
PDF
Securing the Future of Safety and Security of Embedded Software
PDF
Spark / Ada for Safe and Secure Firmware Development
PDF
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
PDF
The Future of Aerospace – More Software Please!
PDF
Adaptive AUTOSAR - The New AUTOSAR Architecture
PDF
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
PDF
Software Engineering for Robotics - The RoboStar Technology
PDF
MISRA C in an ISO 26262 context
PPTX
Application of theorem proving for safety-critical vehicle software
PDF
The Application of Formal Methods to Railway Signalling Software
PDF
Bounded Model Checking for C Programs in an Enterprise Environment
PDF
Multi-Core (MC) Processor Qualification for Safety Critical Systems
RCA OCORA: Safe Computing Platform using open standards
Have we a Human Ecosystem?
Rust and the coming age of high integrity languages
SPARKNaCl: A verified, fast cryptographic library
Developing Future High Integrity Processing Solutions
Taming event-driven software via formal verification
RCA OCORA: Safe Computing Platform using open standards
Product Lines and Ecosystems: from customization to configuration
Securing the Future of Safety and Security of Embedded Software
Spark / Ada for Safe and Secure Firmware Development
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
The Future of Aerospace – More Software Please!
Adaptive AUTOSAR - The New AUTOSAR Architecture
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
Software Engineering for Robotics - The RoboStar Technology
MISRA C in an ISO 26262 context
Application of theorem proving for safety-critical vehicle software
The Application of Formal Methods to Railway Signalling Software
Bounded Model Checking for C Programs in an Enterprise Environment
Multi-Core (MC) Processor Qualification for Safety Critical Systems

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Approach and Philosophy of On baking technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectroscopy.pptx food analysis technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25 Week I
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Approach and Philosophy of On baking technology
MIND Revenue Release Quarter 2 2025 Press Release
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.

Pushing the Boundary of Mostly Automatic Program Proof

  • 1. info@adacore.com adacore.com Pushing the Boundary of Mostly Automatic Program Proof Yannick Moy Copyright © AdaCore High Integrity Software 2022 Conference - October 11, 2022
  • 2. info@adacore.com adacore.com The Verifying Compiler A verifying compiler uses mathematical and logical reasoning to check the correctness of the programs that it compiles. Sir Tony Hoare, Journal of the ACM, 2003 2 Copyright © AdaCore
  • 3. info@adacore.com adacore.com Our formally verified microkernel, seL4, is now used across the world in a number of applications that keeps growing. June Andronick, Successes in Deployed Verified Software, 2019 The Verifying Compiler in Practice 3 Copyright © AdaCore
  • 4. info@adacore.com adacore.com The Auto-Active Approach 4 Copyright © AdaCore
  • 5. info@adacore.com adacore.com The Auto-Active Approach • Use programming language as specification language 5 Copyright © AdaCore
  • 6. info@adacore.com adacore.com The Auto-Active Approach • Use programming language as specification language • Leverage array of automatic provers 6 Copyright © AdaCore
  • 7. info@adacore.com adacore.com The Auto-Active Approach • Use programming language as specification language • Leverage array of automatic provers • Limit specifications to what can be “mostly” automated 7 Copyright © AdaCore
  • 8. info@adacore.com adacore.com The Auto-Active Approach • Use programming language as specification language • Leverage array of automatic provers • Limit specifications to what can be “mostly” automated • Use “ghost code” to reach fully automatic proof 8 Copyright © AdaCore
  • 9. info@adacore.com adacore.com The Auto-Active Approach in SPARK • Use Ada as programming language and specification language (contracts) • Leverage automatic provers Alt-Ergo, COLIBRI, cvc5, Z3 • Specifications are limited by the language (“contracts”) and best practices • Code marked as “ghost” is only used for verification 9 Copyright © AdaCore
  • 10. info@adacore.com adacore.com Low-Hanging Fruits with Program Proof 10 Copyright © AdaCore
  • 11. info@adacore.com adacore.com Low-Hanging Fruits with Program Proof • Absence of runtime errors • no exception raised (predefined or explicitly in the code) • no reads of uninitialized data 11 Copyright © AdaCore
  • 12. info@adacore.com adacore.com Low-Hanging Fruits with Program Proof • Absence of runtime errors • no exception raised (predefined or explicitly in the code) • no reads of uninitialized data • Correct API usage • correct input context when calling functions • correct sequencing of calls on data 12 Copyright © AdaCore
  • 13. info@adacore.com adacore.com Low-Hanging Fruits with Program Proof • Absence of runtime errors • no exception raised (predefined or explicitly in the code) • no reads of uninitialized data • Correct API usage • correct input context when calling functions • correct sequencing of calls on data • Data invariants respected • “permanent” invariants that should hold always • “boundary” invariants that should hold for client code 13 Copyright © AdaCore
  • 14. info@adacore.com adacore.com Initialization is in general guaranteed by sticking to an initialization policy checked by a data-flow algorithm More complex initialization patterns require specifying: • what parts of objects are initialized • under which conditions Mix of boolean conditions and arithmetic is a strong suit of automatic provers SPARK programming language has constraints and specification features that make it straightforward: • memory safety amounts to checking non-nullity of pointers and that indexes are in bounds • numerical type safety amounts to checking that computations don’t divide by zero or exceed bounds (Integer) (Linear) Arithmetic is a strong suit of automatic provers Absence of Runtime Errors 14 Copyright © AdaCore
  • 15. info@adacore.com adacore.com Initialization is in general guaranteed by sticking to an initialization policy checked by a data-flow algorithm More complex initialization patterns require specifying: • what parts of objects are initialized • under which conditions Mix of boolean conditions and arithmetic is a strong suit of automatic provers SPARK programming language has constraints and specification features that make it straightforward: • memory safety amounts to checking non-nullity of pointers and that indexes are in bounds • numerical type safety amounts to checking that computations don’t divide by zero or exceed bounds (Integer) (Linear) Arithmetic is a strong suit of automatic provers Absence of Runtime Errors 15 Copyright © AdaCore
  • 16. info@adacore.com adacore.com Correct sequencing of calls expressed in preconditions and postconditions: • state of parameters wrt prescribed automaton • global state wrt prescribed automaton Possibly using imported ghost functions to express state Resource reclamation (e.g. dynamic memory deallocation) Based on simple boolean conditions Correct input context: • value of parameters respect conditions beyond type safety • lifetime of pointer parameters consistent with their use • relations between parameters are respected • global state respects constraints Preconditions that usually rely on mix of arithmetic and boolean conditions Correct API Usage 16 Copyright © AdaCore
  • 17. info@adacore.com adacore.com Correct sequencing of calls expressed in preconditions and postconditions: • state of parameters wrt prescribed automaton • global state wrt prescribed automaton Possibly using imported ghost functions to express state Resource reclamation (e.g. dynamic memory deallocation) Based on simple boolean conditions Correct input context: • value of parameters respect conditions beyond type safety • lifetime of pointer parameters consistent with their use • relations between parameters are respected • global state respects constraints Preconditions that usually rely on mix of arithmetic and boolean conditions Correct API Usage 17 Copyright © AdaCore
  • 18. info@adacore.com adacore.com Type invariants (“boundary” invariants) only hold outside the unit: • possibly violated locally • restored before returning to client Used to hide data invariant from client unit Same kinds of properties as predicates Type predicates (“permanent” invariants) always hold: • subset of values from the base type • conditions on bounds of arrays • relations between fields of structures (e.g. inequality comparisons) • conditions on field initialization Same mix of arithmetic and boolean conditions as before Data Invariants Respected 18 Copyright © AdaCore
  • 19. info@adacore.com adacore.com Type invariants (“boundary” invariants) only hold outside the unit: • possibly violated locally • restored before returning to client Used to hide data invariant from client unit Same kinds of properties as predicates Type predicates (“permanent” invariants) always hold: • subset of values from the base type • conditions on bounds of arrays • relations between fields of structures (e.g. inequality comparisons) • conditions on field initialization Same mix of arithmetic and boolean conditions as before Data Invariants Respected 19 Copyright © AdaCore
  • 20. info@adacore.com adacore.com Stretch Goals with Program Proof 20 Copyright © AdaCore
  • 21. info@adacore.com adacore.com Stretch Goals with Program Proof • Prove full functional behavior 21 Copyright © AdaCore
  • 22. info@adacore.com adacore.com Stretch Goals with Program Proof • Prove full functional behavior • Prove the implementation of complex data structures • absence of runtime errors • data invariants respected • functional behavior 22 Copyright © AdaCore
  • 23. info@adacore.com adacore.com Stretch Goals with Program Proof • Prove full functional behavior • Prove the implementation of complex data structures • absence of runtime errors • data invariants respected • functional behavior • Prove numerical algorithms • exact result of computations • bounds on the approximation wrt mathematical computation 23 Copyright © AdaCore
  • 24. info@adacore.com adacore.com Need to express the specification as contracts, usually as a form of refinement: • concrete types refine an ideal model (mathematical integers, sets, maps…) • concrete implementation respects the ideal computation on models • contracts can use quantification and abstraction Best practices: no existential, abstract important properties Need to write ghost code (assertions, loop invariants) through interaction with automatic provers Prove Full Functional Behavior 24 Copyright © AdaCore https://blog.adacore.com/i-cant-believe-that-i-can-prove-that-it-can-sort
  • 25. info@adacore.com adacore.com Example: sorting algorithms • ideal model of bag / multiset • sorting preserves model • property uses quantification • property should use abstraction: being sorted on subrange, being the maximum on subrange With suitable properties, and little adequate ghost code, this is easily proved by automatic provers Need to express the specification as contracts, usually as a form of refinement: • concrete types refine an ideal model (mathematical integers, sets, maps…) • concrete implementation respects the ideal computation on models • contracts can use quantification and abstraction Best practices: no existential, abstract important properties Need to write ghost code (assertions, loop invariants) through interaction with automatic provers Prove Full Functional Behavior 25 Copyright © AdaCore https://blog.adacore.com/i-cant-believe-that-i-can-prove-that-it-can-sort
  • 26. info@adacore.com adacore.com Need to structure the code to separate concerns: • different types provide different views of the data with different models • complexity is encapsulated at each level through abstraction Best practices: use privacy to hide implementation and verification details Need to write ghost code (lemmas for induction) through interaction with automatic provers Prove Complex Data Structures 26 Copyright © AdaCore https://blog.adacore.com/research-corner-auto-active-verification-in-spark
  • 27. info@adacore.com adacore.com Example: red-black trees for bare-metal • level 1: binary trees • level 2: sorted trees • level 3: balanced trees • properties at each level encoded as type invariants on private types size of contracts = 2 x size of code size of ghost code = 5 x size of code Implementation constraints matter: same with dynamic allocation has four times less ghost code Need to structure the code to separate concerns: • different types provide different views of the data with different models • complexity is encapsulated at each level through abstraction Best practices: use privacy to hide implementation and verification details Need to write ghost code (lemmas for induction) through interaction with automatic provers Prove Complex Data Structures 27 Copyright © AdaCore https://blog.adacore.com/research-corner-auto-active-verification-in-spark
  • 28. info@adacore.com adacore.com Algorithms on integers: • refine mathematical operations • efficient implementations on machine integers require bitwise manipulations Exploit dedicated support of bitvectors in automatic provers Algorithms on reals: • implement control algorithms • expectation is to remain “close” to the ideal computation on reals despite rounding errors and approximations Exploit dedicated support of floats in automatic provers Prove Numerical Algorithms 28 Copyright © AdaCore https://blog.adacore.com/proving-the-correctness-of-gnat-light-runtime-library
  • 29. info@adacore.com adacore.com Example: multi-place integer arithmetic • mix of signed integers and modular integers • a lot of non-linear operations (multiplications, shifting, division, mod) size of contracts = 0.15 x size of code size of ghost code = 5 x size of code Proof of ≈100 lemmas requires use of all four automatic provers: Alt-Ergo, COLIBRI, cvc5, Z3 Algorithms on integers: • refine mathematical operations • efficient implementations on machine integers require bitwise manipulations Exploit dedicated support of bitvectors in automatic provers Algorithms on reals: • implement control algorithms • expectation is to remain “close” to the ideal computation on reals despite rounding errors and approximations Exploit dedicated support of floats in automatic provers Prove Numerical Algorithms 29 Copyright © AdaCore https://blog.adacore.com/proving-the-correctness-of-gnat-light-runtime-library
  • 30. info@adacore.com adacore.com Challenges with Program Proof 30 Copyright © AdaCore
  • 31. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: … 31 Copyright © AdaCore
  • 32. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: better interaction mechanisms 32 Copyright © AdaCore
  • 33. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: better interaction mechanisms • Predictability of proof results • automatic provers are based on heuristic search • solution: … 33 Copyright © AdaCore
  • 34. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: better interaction mechanisms • Predictability of proof results • automatic provers are based on heuristic search • solution: know the low-hanging fruits from the stretch goals 34 Copyright © AdaCore
  • 35. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: better interaction mechanisms • Predictability of proof results • automatic provers are based on heuristic search • solution: know the low-hanging fruits from the stretch goals • Stability of proof results • minor changes in code or tool can lead to losing proofs • solution: … 35 Copyright © AdaCore
  • 36. info@adacore.com adacore.com Challenges with Program Proof • Left-Over Principle of automation • automation fails humans on the more complex cases • solution: better interaction mechanisms • Predictability of proof results • automatic provers are based on heuristic search • solution: know the low-hanging fruits from the stretch goals • Stability of proof results • minor changes in code or tool can lead to losing proofs • solution: prover redundancy and advances in automatic proof technology 36 Copyright © AdaCore
  • 37. info@adacore.com adacore.com The Verifying Compiler If the project is successful, a verifying compiler will be available as a standard tool in some widely used programming productivity toolset. Sir Tony Hoare, Journal of the ACM, 2003 37 Copyright © AdaCore