pvs linear algebra libraries for verification of control ......pvs linear algebra libraries for...

75
Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mappin PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain Jobredeaux, Sam Owre, Pierre-Lo¨ ıc Garoche, Eric Feron, Gilberto Perez, Pablo Ascariz National Institute of Aerospace, Georgia Institute of Technology SRI International, ONERA, University of A Coru ˜ na April, 2012 Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Lo¨ ıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo Ascariz National Institute of Aerospace 1 / 35

Upload: others

Post on 17-Sep-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

PVS Linear Algebra Libraries for Verification ofControl Software Algorithms in C/ACSL

Heber Herencia-Zapana, Romain Jobredeaux, Sam Owre,Pierre-Loıc Garoche, Eric Feron, Gilberto Perez, Pablo

Ascariz

National Institute of Aerospace, Georgia Institute of Technology

SRI International, ONERA, University of A Coruna

April, 2012

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 1 / 35

Page 2: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Outline

1 Introduction

2 Stability and correctness

3 Defining quadratic invariants as code annotations

4 Verification conditions

5 Mapping ACSL predicates to PVS linear algebra concepts

6 Conclusions

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 2 / 35

Page 3: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The objective of control theory is to calculate a proper action fromthe controller that will result in stability for the systemThe software implementation of a control law can be inspected byanalysis toolsHowever these tools are often challenged by issues for whichsolutions are already available from control theory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 3 / 35

Page 4: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The objective of control theory is to calculate a proper action fromthe controller that will result in stability for the systemThe software implementation of a control law can be inspected byanalysis toolsHowever these tools are often challenged by issues for whichsolutions are already available from control theory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 3 / 35

Page 5: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The objective of control theory is to calculate a proper action fromthe controller that will result in stability for the systemThe software implementation of a control law can be inspected byanalysis toolsHowever these tools are often challenged by issues for whichsolutions are already available from control theory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 3 / 35

Page 6: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The objective of control theory is to calculate a proper action fromthe controller that will result in stability for the systemThe software implementation of a control law can be inspected byanalysis toolsHowever these tools are often challenged by issues for whichsolutions are already available from control theory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 3 / 35

Page 7: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Program verification uses proof assistants to ensure the validity ofuser-provided code annotations.These annotations may express the domain-specific properties ofthe code.However, formulating annotations correctly is nontrivial in practice.By correctly, we mean that the annotations formulate stabilityproperties of an intended mathematical interpretation from controltheory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 4 / 35

Page 8: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Program verification uses proof assistants to ensure the validity ofuser-provided code annotations.These annotations may express the domain-specific properties ofthe code.However, formulating annotations correctly is nontrivial in practice.By correctly, we mean that the annotations formulate stabilityproperties of an intended mathematical interpretation from controltheory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 4 / 35

Page 9: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Program verification uses proof assistants to ensure the validity ofuser-provided code annotations.These annotations may express the domain-specific properties ofthe code.However, formulating annotations correctly is nontrivial in practice.By correctly, we mean that the annotations formulate stabilityproperties of an intended mathematical interpretation from controltheory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 4 / 35

Page 10: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Program verification uses proof assistants to ensure the validity ofuser-provided code annotations.These annotations may express the domain-specific properties ofthe code.However, formulating annotations correctly is nontrivial in practice.By correctly, we mean that the annotations formulate stabilityproperties of an intended mathematical interpretation from controltheory.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 4 / 35

Page 11: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

In order to solve these two challenges this work proposes1 Axiomatization of Lyapunov-based stability as C code annotations,2 Implementation of linear algebra and control theory results in PVS.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 5 / 35

Page 12: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

In order to solve these two challenges this work proposes1 Axiomatization of Lyapunov-based stability as C code annotations,2 Implementation of linear algebra and control theory results in PVS.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 5 / 35

Page 13: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Stability and Correctness

The basic module for the description of a controller can bepresented as

ξ(k + 1) = f(ξ(k), ν(k)), ξ(0) = ξ0

ζ(k) = g(ξ(k), ν(k))

where ξ ∈ Rn is the state of the controller, ν is the input of thecontroller and ζ is the output of the controller.This system is bounded-input, bounded state stable if for every εthere exists a δ such that ||ν(k)|| ≤ ε implies ||ξ(k)|| ≤ δ, for everypositive integer k.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 6 / 35

Page 14: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Stability and Correctness

The basic module for the description of a controller can bepresented as

ξ(k + 1) = f(ξ(k), ν(k)), ξ(0) = ξ0

ζ(k) = g(ξ(k), ν(k))

where ξ ∈ Rn is the state of the controller, ν is the input of thecontroller and ζ is the output of the controller.This system is bounded-input, bounded state stable if for every εthere exists a δ such that ||ν(k)|| ≤ ε implies ||ξ(k)|| ≤ δ, for everypositive integer k.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 6 / 35

Page 15: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

If there exists a positive definite function V such that V (ξ(k)) ≤ 1implies V (ξ(k + 1)) ≤ 1 then this function can be used to establishthe stability of the system.This Lyapunov function, V , defines the ellipsoid {ξ| V (ξ) ≤ 1}, thisellipsoid plays an important role for the stability preservation at thecode level.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 7 / 35

Page 16: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

If there exists a positive definite function V such that V (ξ(k)) ≤ 1implies V (ξ(k + 1)) ≤ 1 then this function can be used to establishthe stability of the system.This Lyapunov function, V , defines the ellipsoid {ξ| V (ξ) ≤ 1}, thisellipsoid plays an important role for the stability preservation at thecode level.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 7 / 35

Page 17: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Control software and Hoare triples

Annotated with assertions in the Hoare style we get

{pre1}u = Ccxc +Dcyc

{post1}

{pre2}xc = Acxc +Bcyc

{post2}.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 8 / 35

Page 18: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

An ellipsoid-aware Hoare logic

To use ellipsoids to formally specify bounded input, bounded statestability in.Typically, an instruction S would be annotated in the following way:

{x ∈ EP } y = Ax+ b {y − b ∈ EQ} (1)

where the pre- and post- conditions are predicates expressing thatthe variables belong to some ellipsoid, withEp = {x : Rn|xTP−1x ≤ 1} and Q = APAT .

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 9 / 35

Page 19: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

An ellipsoid-aware Hoare logic

To use ellipsoids to formally specify bounded input, bounded statestability in.Typically, an instruction S would be annotated in the following way:

{x ∈ EP } y = Ax+ b {y − b ∈ EQ} (1)

where the pre- and post- conditions are predicates expressing thatthe variables belong to some ellipsoid, withEp = {x : Rn|xTP−1x ≤ 1} and Q = APAT .

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 9 / 35

Page 20: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

An ellipsoid-aware Hoare logic

The mathematical theorem that guarantees the relations is :

TheoremIf M , Q are invertible matrices, and(x− c)TQ−1(x− c) ≤ 1 andy = Mx+ bthen(y − b−Mc)T (MQMT )−1(y − b−Mc) ≤ 1

We will refer to it as the ellipsoid affine combination theorem.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 10 / 35

Page 21: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Verification conditions

Figure 1: VerificationHeber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 11 / 35

Page 22: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Now that we know the annotations that we want to generate onthe code, we have to find a concrete way to express them onactual C code.The ANSI/ISO C Specification Language (ACSL) allows its user tospecify the properties of a C program within comments,This language was proposed as part of the Frama-C platform,

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 12 / 35

Page 23: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Now that we know the annotations that we want to generate onthe code, we have to find a concrete way to express them onactual C code.The ANSI/ISO C Specification Language (ACSL) allows its user tospecify the properties of a C program within comments,This language was proposed as part of the Frama-C platform,

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 12 / 35

Page 24: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Now that we know the annotations that we want to generate onthe code, we have to find a concrete way to express them onactual C code.The ANSI/ISO C Specification Language (ACSL) allows its user tospecify the properties of a C program within comments,This language was proposed as part of the Frama-C platform,

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 12 / 35

Page 25: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Verification conditions

Figure 2: Verification

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 13 / 35

Page 26: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We outline the axiomatization in ACSL to fit our needs, whichconsist of expressing ellipsoid-based Hoare triples over C code.We first present the axiomatization of linear algebra elements inACSL.Then we present the Hoare triple annotations in ACSL and thePOs generated by them.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 14 / 35

Page 27: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We outline the axiomatization in ACSL to fit our needs, whichconsist of expressing ellipsoid-based Hoare triples over C code.We first present the axiomatization of linear algebra elements inACSL.Then we present the Hoare triple annotations in ACSL and thePOs generated by them.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 14 / 35

Page 28: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We outline the axiomatization in ACSL to fit our needs, whichconsist of expressing ellipsoid-based Hoare triples over C code.We first present the axiomatization of linear algebra elements inACSL.Then we present the Hoare triple annotations in ACSL and thePOs generated by them.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 14 / 35

Page 29: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The following abstract types are declared://@ type matrix; type vector

ACSL

With these abstract types, basic matrix operations and propertiesare introduced@ logic real mat select(matrix A, integer i, integer j);

@ logic integer mat row(matrix A);

@ logic integer mat col(matrix A);

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 15 / 35

Page 30: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The following abstract types are declared://@ type matrix; type vector

ACSL

With these abstract types, basic matrix operations and propertiesare introduced@ logic real mat select(matrix A, integer i, integer j);

@ logic integer mat row(matrix A);

@ logic integer mat col(matrix A);

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 15 / 35

Page 31: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The multiplication of a matrix with a vector is defined with functionvect mult(matrix A, vector x), which returns a vector.Addition and multiplication of 2 matrices, multiplication by a scalar,and inverse of a matrix are declared as matrix types

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 16 / 35

Page 32: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The multiplication of a matrix with a vector is defined with functionvect mult(matrix A, vector x), which returns a vector.Addition and multiplication of 2 matrices, multiplication by a scalar,and inverse of a matrix are declared as matrix types

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 16 / 35

Page 33: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

inverse of a matrix A, mat inverse(A) is defined using the predicateis invertible(A) as follows:

/*@ axiom mat inv select i eq j:@ ∀matrixA, integer i, j;

@ is invertible(A) && i == j ==>

@ mat select(mat mult(A,mat inverse(A)), i, j) = 1@

@ axiom mat inv select i dff j:@ ∀matrixA, integer i, j;

@ is invertible(A) && i! = j ==>

@ mat select(mat mult(A,mat inverse(A)), i, j) = 0@*/

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 17 / 35

Page 34: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Complex constructions or relations can be defined as uninterpretedpredicates. The following predicate is meant to express that vector xbelongs to EP :

//@ predicate in ellipsoid(matrix P, vector x);ACSL

mat of array or vect of array, is used to associate an ACSL matrixtype to a C array.//@ logic matrix mat of array{L}(float *A, integer row,

integer col);

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 18 / 35

Page 35: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Complex constructions or relations can be defined as uninterpretedpredicates. The following predicate is meant to express that vector xbelongs to EP :

//@ predicate in ellipsoid(matrix P, vector x);ACSL

mat of array or vect of array, is used to associate an ACSL matrixtype to a C array.//@ logic matrix mat of array{L}(float *A, integer row,

integer col);

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 18 / 35

Page 36: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

// @ axiom mat of array select:

@ forall float *A; forall integer i, j, k, l;

@ mat select(mat of array(A, k, l), i, j) == A[l*i+j];

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 19 / 35

Page 37: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The paramount notion in ACSL is the function contract.The key word requires is used to introduce the pre-conditions ofthe triple, and the key word ensures is used to introduce itspost-conditions.//@ require P//@ ensures RQ

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 20 / 35

Page 38: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The paramount notion in ACSL is the function contract.The key word requires is used to introduce the pre-conditions ofthe triple, and the key word ensures is used to introduce itspost-conditions.//@ require P//@ ensures RQ

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 20 / 35

Page 39: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The paramount notion in ACSL is the function contract.The key word requires is used to introduce the pre-conditions ofthe triple, and the key word ensures is used to introduce itspost-conditions.//@ require P//@ ensures RQ

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 20 / 35

Page 40: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The paramount notion in ACSL is the function contract.The key word requires is used to introduce the pre-conditions ofthe triple, and the key word ensures is used to introduce itspost-conditions.//@ require P//@ ensures RQ

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 20 / 35

Page 41: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We need to deal with memory issues. In general, we want allfunctions to be called with valid pointers as arguments, i.e., validarray and therefore valid matrices.This is what the built-in ACSL predicate valid does. The followingssnippet shows how the contract can be written using mat selectand mat of array,

/*@ requires (valid(a + (0..3)));@ ensures ∀integer i, j; 0 ≤ i < 2 && 0 ≤ j < 2@ ==> mat select(mat of array(a, 2, 2), i, j) == 0;@ */

void zeros 2x2(float* a)

{ a[0]=0; a[1]=0; a[2]=0; a[3]=0; }

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 21 / 35

Page 42: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We need to deal with memory issues. In general, we want allfunctions to be called with valid pointers as arguments, i.e., validarray and therefore valid matrices.This is what the built-in ACSL predicate valid does. The followingssnippet shows how the contract can be written using mat selectand mat of array,

/*@ requires (valid(a + (0..3)));@ ensures ∀integer i, j; 0 ≤ i < 2 && 0 ≤ j < 2@ ==> mat select(mat of array(a, 2, 2), i, j) == 0;@ */

void zeros 2x2(float* a)

{ a[0]=0; a[1]=0; a[2]=0; a[3]=0; }

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 21 / 35

Page 43: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We need to deal with memory issues. In general, we want allfunctions to be called with valid pointers as arguments, i.e., validarray and therefore valid matrices.This is what the built-in ACSL predicate valid does. The followingssnippet shows how the contract can be written using mat selectand mat of array,

/*@ requires (valid(a + (0..3)));@ ensures ∀integer i, j; 0 ≤ i < 2 && 0 ≤ j < 2@ ==> mat select(mat of array(a, 2, 2), i, j) == 0;@ */

void zeros 2x2(float* a)

{ a[0]=0; a[1]=0; a[2]=0; a[3]=0; }

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 21 / 35

Page 44: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

@ Ac = mat of 2x2 scalar(0.449,-0.05,0.01,1.);

@ P = mat of 2x2 scalar(1.5325,10.0383,10.0383,507.2450);

@ Q = mat mult(mat inv(transpose(Ac)),mat mult(P,mat inv(Ac)));

*/

@ requires (valid(xc + (0..1)));

@ requires (valid(yc + (0..1)));

@ requires in ellipsoid(P,vect of array(xc,2));

@ ensures in ellipsoid(Q,vect of array(yc,2));*/

void inst2(float* xc, float* yc)

{ yc[0]= 0.449*xc[0] + -0.05*xc[1];

yc[1]= .01*xc[0] + 1.*xc[1]; }

ACSL

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 22 / 35

Page 45: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Errors due to floating point approximations are thus not taken intoaccount.The Frama-C toolset offers the possibility of making thisassumption by including ’JessieFloatModel(Math)’.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 23 / 35

Page 46: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Errors due to floating point approximations are thus not taken intoaccount.The Frama-C toolset offers the possibility of making thisassumption by including ’JessieFloatModel(Math)’.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 23 / 35

Page 47: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Frama-C tools do not require an annotation at each line asproposed by Hoare.They rather rely weakest precondition calculus.The proof obligation (PO) is then P =⇒ wp(S,Q) where P is thepre-condition.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 24 / 35

Page 48: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Frama-C tools do not require an annotation at each line asproposed by Hoare.They rather rely weakest precondition calculus.The proof obligation (PO) is then P =⇒ wp(S,Q) where P is thepre-condition.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 24 / 35

Page 49: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Frama-C tools do not require an annotation at each line asproposed by Hoare.They rather rely weakest precondition calculus.The proof obligation (PO) is then P =⇒ wp(S,Q) where P is thepre-condition.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 24 / 35

Page 50: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

On the one hand, using ACSL and the Frama-C framework, wewere able to generate POs about the ellipsoid predicate.Frama-C tools even make it possible to express the PO in PVS,along with a complete axiomatisation in PVS of C programssemantics.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 25 / 35

Page 51: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

On the one hand, using ACSL and the Frama-C framework, wewere able to generate POs about the ellipsoid predicate.Frama-C tools even make it possible to express the PO in PVS,along with a complete axiomatisation in PVS of C programssemantics.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 25 / 35

Page 52: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

in ellipsoid?(P 0, vect of array(xc, 2, floatP floatM))))))

IMPLIES

in ellipsoid?(Q, vect of array(yc, 2, floatP floatM0))

PVS

vect of array(yc, 2, floatP floatM0)’vect =

Ac * vect of array(xc, 2, floatP floatM)’vect

PVS

For both POs,we must first interpret the uninterpreted types and to prove theproperties that are defined axiomatically.We must then discharge the verification conditions. This is doneby using PVS and a linear algebra extension of it.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 26 / 35

Page 53: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

in ellipsoid?(P 0, vect of array(xc, 2, floatP floatM))))))

IMPLIES

in ellipsoid?(Q, vect of array(yc, 2, floatP floatM0))

PVS

vect of array(yc, 2, floatP floatM0)’vect =

Ac * vect of array(xc, 2, floatP floatM)’vect

PVS

For both POs,we must first interpret the uninterpreted types and to prove theproperties that are defined axiomatically.We must then discharge the verification conditions. This is doneby using PVS and a linear algebra extension of it.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 26 / 35

Page 54: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Mapping:TYPE= [# dom: posnat, codom: posnat, mp:

[Vector[dom]->Vector[codom]] #]

PVS

L(n,m)(f) = (# rows:=m, cols:=n, matrix:=λ(j,i):f‘mp(e(n)(i))(j) #)

T(n,m)(A) = (# dom:=n, codom:=m, mp:=λ(x,j): ΣA‘cols−1i=0 (λ(i):

A‘matrix(j,i)*x(i) #))

PVS

Matrix inv(n):TYPE = {A: Square | squareMat?(n)(A) and

bijective?(n)(T(n,n)(A))}

PVS

inv(n)(A) = L(n,n)(inverse(n)(T(n,n)(A)))PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 27 / 35

Page 55: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Mapping:TYPE= [# dom: posnat, codom: posnat, mp:

[Vector[dom]->Vector[codom]] #]

PVS

L(n,m)(f) = (# rows:=m, cols:=n, matrix:=λ(j,i):f‘mp(e(n)(i))(j) #)

T(n,m)(A) = (# dom:=n, codom:=m, mp:=λ(x,j): ΣA‘cols−1i=0 (λ(i):

A‘matrix(j,i)*x(i) #))

PVS

Matrix inv(n):TYPE = {A: Square | squareMat?(n)(A) and

bijective?(n)(T(n,n)(A))}

PVS

inv(n)(A) = L(n,n)(inverse(n)(T(n,n)(A)))PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 27 / 35

Page 56: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Mapping:TYPE= [# dom: posnat, codom: posnat, mp:

[Vector[dom]->Vector[codom]] #]

PVS

L(n,m)(f) = (# rows:=m, cols:=n, matrix:=λ(j,i):f‘mp(e(n)(i))(j) #)

T(n,m)(A) = (# dom:=n, codom:=m, mp:=λ(x,j): ΣA‘cols−1i=0 (λ(i):

A‘matrix(j,i)*x(i) #))

PVS

Matrix inv(n):TYPE = {A: Square | squareMat?(n)(A) and

bijective?(n)(T(n,n)(A))}

PVS

inv(n)(A) = L(n,n)(inverse(n)(T(n,n)(A)))PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 27 / 35

Page 57: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Mapping:TYPE= [# dom: posnat, codom: posnat, mp:

[Vector[dom]->Vector[codom]] #]

PVS

L(n,m)(f) = (# rows:=m, cols:=n, matrix:=λ(j,i):f‘mp(e(n)(i))(j) #)

T(n,m)(A) = (# dom:=n, codom:=m, mp:=λ(x,j): ΣA‘cols−1i=0 (λ(i):

A‘matrix(j,i)*x(i) #))

PVS

Matrix inv(n):TYPE = {A: Square | squareMat?(n)(A) and

bijective?(n)(T(n,n)(A))}

PVS

inv(n)(A) = L(n,n)(inverse(n)(T(n,n)(A)))PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 27 / 35

Page 58: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

ellipsoid affine comb: LEMMA ∀ (n:posnat, Q, M: SquareMat(n), x,

y, b, c: Vector[n]):

bijective?(n)(T(n,n)(Q)) AND bijective?(n)(T(n,n)(M))

AND (x-c)*(inv(n)(Q)*(x-c))≤ 1

AND y=M*x + b

IMPLIES

(y-b-M*c)*(inv(n)(M*(Q*transpose(M)))*(y-b-M*c))≤ 1

PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 28 / 35

Page 59: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We have developed a PVS library that is able to reason aboutthese properties.We now must link these two worlds: ACSL ellipsoids predicateproof obligation in PVS must be connected with with our linearalgebra PVS library.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 29 / 35

Page 60: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

We have developed a PVS library that is able to reason aboutthese properties.We now must link these two worlds: ACSL ellipsoids predicateproof obligation in PVS must be connected with with our linearalgebra PVS library.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 29 / 35

Page 61: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Verification conditions and theory interpretation

Theory interpretation is a logical technique for relating oneaxiomatic theory to another.Interpretations can be used to show:An axiomatically defined specification is consistentor that a axiomatically defined specification captures its intendedmodels.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 30 / 35

Page 62: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Verification conditions and theory interpretation

Theory interpretation is a logical technique for relating oneaxiomatic theory to another.Interpretations can be used to show:An axiomatically defined specification is consistentor that a axiomatically defined specification captures its intendedmodels.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 30 / 35

Page 63: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Verification conditions and theory interpretation

Theory interpretation is a logical technique for relating oneaxiomatic theory to another.Interpretations can be used to show:An axiomatically defined specification is consistentor that a axiomatically defined specification captures its intendedmodels.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 30 / 35

Page 64: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

IMPORTING acsl theory{{ matrix := Matrix,

vector := Vector no param,

vect length := LAMBDA (v:Vector no param): v’length,

mat row := LAMBDA (M:Matrix): M’rows,

mat col := LAMBDA (M:Matrix): M’cols,

mat mult := *,

in ellipsoid := in ellipsoid?

mat inv := LAMBDA (M:Matrix): IF square?(M) THEN IF

bijective?(M’rows)(T(M’rows,M’rows)(M))

THEN inv(M’rows)(M)

ELSE M

ENDIF

ELSE M ENDIF }}

PVS

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 31 / 35

Page 65: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

in ellipsoid?(P 0, vect of array(xc, 2, floatP floatM))))))

IMPLIES

in ellipsoid?(Q, vect of array(yc, 2, floatP floatM0))

PVS

bijections :LEMMA

bijective?(2)(T(2,2)(P 0)) AND bijective?(2)(T(2,2)(Ac))

PVS

where Ac = mat of 2x2 scalar(0.449,−0.05, 0.01, 1.) andP = mat of 2x2 scalar(1.5325, 10.0383, 10.0383, 507.2450)

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 32 / 35

Page 66: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

in ellipsoid?(P 0, vect of array(xc, 2, floatP floatM))))))

IMPLIES

in ellipsoid?(Q, vect of array(yc, 2, floatP floatM0))

PVS

bijections :LEMMA

bijective?(2)(T(2,2)(P 0)) AND bijective?(2)(T(2,2)(Ac))

PVS

where Ac = mat of 2x2 scalar(0.449,−0.05, 0.01, 1.) andP = mat of 2x2 scalar(1.5325, 10.0383, 10.0383, 507.2450)

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 32 / 35

Page 67: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Conclusions

We have described a global approach to validate stabilityproperties of C code implementing controllers.Our approach requires the code to be annoted by Hoare triples,proving the stability of the control code using ellipsoid affinecombinations.We have defined an ACSL extension to describe predicates overthe code, as well as a PVS library able to manipulate thesepredicates.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 33 / 35

Page 68: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Conclusions

We have described a global approach to validate stabilityproperties of C code implementing controllers.Our approach requires the code to be annoted by Hoare triples,proving the stability of the control code using ellipsoid affinecombinations.We have defined an ACSL extension to describe predicates overthe code, as well as a PVS library able to manipulate thesepredicates.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 33 / 35

Page 69: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Conclusions

We have described a global approach to validate stabilityproperties of C code implementing controllers.Our approach requires the code to be annoted by Hoare triples,proving the stability of the control code using ellipsoid affinecombinations.We have defined an ACSL extension to describe predicates overthe code, as well as a PVS library able to manipulate thesepredicates.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 33 / 35

Page 70: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Conclusions

We have described a global approach to validate stabilityproperties of C code implementing controllers.Our approach requires the code to be annoted by Hoare triples,proving the stability of the control code using ellipsoid affinecombinations.We have defined an ACSL extension to describe predicates overthe code, as well as a PVS library able to manipulate thesepredicates.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 33 / 35

Page 71: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Theory interpretation maps proof obligations generated from thecode to their equivalent in this PVS library.This mapping allows to discharge POs using the ellipsoid affinecombination theorem implemented in PVS.Linear algebra PVS libraries can be used for the formalspecification of control theory properties

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 34 / 35

Page 72: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Theory interpretation maps proof obligations generated from thecode to their equivalent in this PVS library.This mapping allows to discharge POs using the ellipsoid affinecombination theorem implemented in PVS.Linear algebra PVS libraries can be used for the formalspecification of control theory properties

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 34 / 35

Page 73: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Theory interpretation maps proof obligations generated from thecode to their equivalent in this PVS library.This mapping allows to discharge POs using the ellipsoid affinecombination theorem implemented in PVS.Linear algebra PVS libraries can be used for the formalspecification of control theory properties

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 34 / 35

Page 74: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

Theory interpretation maps proof obligations generated from thecode to their equivalent in this PVS library.This mapping allows to discharge POs using the ellipsoid affinecombination theorem implemented in PVS.Linear algebra PVS libraries can be used for the formalspecification of control theory properties

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 34 / 35

Page 75: PVS Linear Algebra Libraries for Verification of Control ......PVS Linear Algebra Libraries for Verification of Control Software Algorithms in C/ACSL Heber Herencia-Zapana, Romain

Introduction Stability and correctness Defining quadratic invariants as code annotations Verification conditions Mapping ACSL predicates to PVS linear algebra concepts Conclusions Acknowledgments

The authors would like to thankA. Goodloe for his suggestion of the use of the Frama-C toolsetand his help in axiomatising of linear algebra in ACSL.

Heber Herencia-Zapana,, Romain Jobredeaux,, Sam Owre,, Pierre-Loıc Garoche,, Eric Feron,, Gilberto Perez,, Pablo AscarizNational Institute of Aerospace 35 / 35