Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new plugin for polynomial inequalities (using OSDP) #499

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

ploc
Copy link

@ploc ploc commented Feb 10, 2022

The purpose of this PR is to add a new plugin based on semi-definite programming (SDP, aka convex optimization). It solves problems involving polynomial inequalities which cannot be solved with alt-ergo today. It relies on the opam package OSDP which provides the interface to SDP solvers.

It is developed as a plugin, following the structure of fm-simplex plugin.

Usage:
alt-ergo --polynomial-plugin osdp-plugin.cmxs file.ae

Details

  • The proposed PR builds a new package alt-ergo-osdp and does not rely on any new package except osdp which is currently being updated (cf New OSDP version 1.1.0 ocaml/opam-repository#20711 )
  • Nothing change for alt-ergo if one does not build and install that new package alt-ergo-osdp, and if one does not use the new option --polynomial-plugin

With @proux01, we commit to maintain the package alt-ergo-osdp and keep it in sync with alt-ergo, as well as OSDP.

Last, there is an issue with the loading order of modules for plugins. We solved this for our inequalities plugin, and will prepare a separate PR for fm-simplex which has the same issue (it is not currently properly loaded).

@proux01
Copy link
Contributor

proux01 commented Feb 11, 2022

The commit message contains the reference of the related publication and an example of goal that is now solved by Alt-Ergo. Should it be added to some non regression test?

Also note that this does not add any dependency to the currently existing opam packages for alt-ergo. Only the new alt-ergo-osdp packages depends on osdp (which has a non trivial depext).

@ploc ploc force-pushed the osdp branch 2 times, most recently from 99a6d57 to 9cdc3c5 Compare February 14, 2022 14:18
@ploc
Copy link
Author

ploc commented Feb 14, 2022

Updated opam osdp dependency to 1.1.0 which has been released (cf ocaml/opam-repository@c353c5a)

@Gbury
Copy link
Collaborator

Gbury commented Feb 14, 2022

That's very impressive ! We'll try and review as soon as possible, ^^

@ploc ploc force-pushed the osdp branch 3 times, most recently from 76cf4dc to d25b3d9 Compare February 15, 2022 10:35
@ploc
Copy link
Author

ploc commented Feb 15, 2022

Issues in CI workflows were caused by the recent release of Cmdliner (1.1.0). I don't know why it doesn't show up in the CI of the "next" branch. I added the explicit version to Cmdliner 1.0.4 in the dune-project and .opam files (see ploc@76cf4dc).

@Gbury
Copy link
Collaborator

Gbury commented Feb 15, 2022

Issues in CI workflows were caused by the recent release of Cmdliner (1.1.0). I don't know why it doesn't show up in the CI of the "next" branch. I added the explicit version to Cmdliner 1.0.4 in the dune-project and .opam files (see ploc@76cf4dc).

It doesn't show up in the Ci runs of next probably because the last run was before the release of cmdliner.1.1.0, ^^

@ploc
Copy link
Author

ploc commented Feb 15, 2022

Impact is significant ! Most uses of Cmdliner in Alt-ergo rely on the deprecated Term module. It causes many warning and one error in the last line of the module.

@Gbury
Copy link
Collaborator

Gbury commented Feb 15, 2022

Indeed, I'll try and fix that in next asap.

@Gbury
Copy link
Collaborator

Gbury commented Apr 7, 2022

The next branch has been fixed (with regards to the cmdliner changes, as well as other minor build-related fixes), so you should be able to rebase your branch on top of it and everything should work, ^^

@proux01
Copy link
Contributor

proux01 commented Apr 8, 2022

@ploc could you remove the last commit?

git reset --hard HEAD^
git push --force-with-lease

@proux01
Copy link
Contributor

proux01 commented Apr 8, 2022

(feel free to add Co-authored-by: Pierre-Loïc Garoche <[email protected]> at the end of the description of the commit)

@ploc
Copy link
Author

ploc commented May 10, 2022

Hi @Gbury , what's the status? Do you need us to do anything?

@Gbury
Copy link
Collaborator

Gbury commented May 11, 2022

my apologies, I've been busy with another project recently. I'll try and look at this PR in detail (including the thing about plugins) next week.

@proux01
Copy link
Contributor

proux01 commented Jun 10, 2022

@Gbury it seems we'll both attend JFLA in a few weeks. If you want, we could take some time there to look together at the code (and I could take the opportunity to improve comments as the code may sometimes be a bit dry).
If you want a good outlook of the underlying maths, you can have a look to the related paper https://hal.archives-ouvertes.fr/hal-01737737/document (you can skip section 4.3 which is dropped in this PR). That might look like a bunch of non trivial maths, but in fact the subset needed to be convinced of the soundness is relatively basic.

@ploc
Copy link
Author

ploc commented Jul 5, 2022

Any news since JFLA ? I am still interested in the merge!

@Gbury
Copy link
Collaborator

Gbury commented Jul 5, 2022

We talked a bit with @proux01 during the JFLA. There are a few things left to do before we can merge:

  • there are a few comments to add (e.g. a short description of the goals of the new plugins, and a link to the relevant research papers) and some doc comments for the new functions.
  • there should be at least a few non-regression tests to check that the plugin works as expected
  • a CLA needs to be signed: there should have been an email sent with the adequate CLA a while back, but we can probably resend it if you need to (cc @MuSSF )
  • I'll have to look a bit at what is installed by the new plugin and where, and there might require some changes, but it should be fairly minor

@proux01
Copy link
Contributor

proux01 commented Sep 26, 2022

Sorry, I'm ridiculously late here. I hope to complete my tasks in the coming weeks.

@proux01
Copy link
Contributor

proux01 commented Sep 27, 2022

So finally, here it is: https://github.com/proux01/alt-ergo/tree/osdp

@Gbury said:

there are a few comments to add (e.g. a short description of the goals of the new plugins, and a link to the relevant research papers) and some doc comments for the new functions.

done

there should be at least a few non-regression tests to check that the plugin works as expected

done

a CLA needs to be signed: there should have been an email sent with the adequate CLA a while back, but we can probably resend it if you need to (cc @ MuSSF )

Sorry, don't remember that but feel free to resend it, I'll have a look.

P.S.: @ploc can't push on your branch, you probably have to do something like:

git remote add proux01 https://github.com/proux01/alt-ergo  # likely already done
git fetch proux01
git checkout osdp
git reset --hard proux01/osdp
git push --force-with-lease

proux01 and others added 3 commits September 28, 2022 10:35
This is the plugin presented in the following paper:

A Non-linear Arithmetic Procedure for Control-Command Software Verification,
Pierre Roux, Mohamed Iguernlala, Sylvain Conchon, TACAS 2018

In particular, it enables to solve goals like:

logic v__0 : real
logic v_x0 : real
logic v_x1 : real
logic v_x2 : real
goal g:
  6.04 * v_x0 * v_x0 + (- (9.65)) * v_x0 * v_x1 + (- (2.26)) * v_x0 * v_x2
  + 11.36 * v_x1 * v_x1 + 2.67 * v_x1 * v_x2 + 3.76 * v_x2 * v_x2 <= 1.0
  and v__0 <= 1.0 and (- (1.0)) <= v__0
  -> 6.04
     * (0.9379 * v_x0 + (- (0.0381)) * v_x1 + (- (0.0414)) * v_x2
        + 0.0237 * v__0)
     * (0.9379 * v_x0 + (- (0.0381)) * v_x1 + (- (0.0414)) * v_x2
        + 0.0237 * v__0)
     + (- (9.65))
       * (0.9379 * v_x0 + (- (0.0381)) * v_x1 + (- (0.0414)) * v_x2
          + 0.0237 * v__0)
       * ((- (0.0404)) * v_x0 + 0.968 * v_x1 + (- (0.0179)) * v_x2
          + 0.0143 * v__0)
     + (- (2.26))
       * (0.9379 * v_x0 + (- (0.0381)) * v_x1 + (- (0.0414)) * v_x2
          + 0.0237 * v__0)
       * (0.0142 * v_x0 + (- (0.0197)) * v_x1 + 0.9823 * v_x2 + 0.0077 * v__0)
     + 11.36
       * ((- (0.0404)) * v_x0 + 0.968 * v_x1 + (- (0.0179)) * v_x2
          + 0.0143 * v__0)
       * ((- (0.0404)) * v_x0 + 0.968 * v_x1 + (- (0.0179)) * v_x2
          + 0.0143 * v__0)
     + 2.67
       * ((- (0.0404)) * v_x0 + 0.968 * v_x1 + (- (0.0179)) * v_x2
          + 0.0143 * v__0)
       * (0.0142 * v_x0 + (- (0.0197)) * v_x1 + 0.9823 * v_x2 + 0.0077 * v__0)
     + 3.76
       * (0.0142 * v_x0 + (- (0.0197)) * v_x1 + 0.9823 * v_x2 + 0.0077 * v__0)
       * (0.0142 * v_x0 + (- (0.0197)) * v_x1 + 0.9823 * v_x2 + 0.0077 * v__0)
     <= 1.0

that are out of reach of most SMT solvers.
This goals come from verification of the following linear controller:

typedef struct { double x0, x1, x2; } state;

/*@ predicate inv(state *s) = 6.04 * s->x0 * s->x0 - 9.65 * s->x0 * s->x1
  @   - 2.26 * s->x0 * s->x2 + 11.36 * s->x1 * s->x1
  @   + 2.67 * s->x1 * s->x2 + 3.76 * s->x2 * s->x2 <= 1; */

/*@ requires \valid(s) && inv(s) && -1 <= in0 <= 1;
  @ ensures inv(s); */
void step(state *s, double in0) {
  double pre_x0 = s->x0, pre_x1 = s->x1, pre_x2 = s->x2;

  s->x0 = 0.9379 * pre_x0 - 0.0381 * pre_x1 - 0.0414 * pre_x2 + 0.0237 * in0;
  s->x1 = -0.0404 * pre_x0 + 0.968 * pre_x1 - 0.0179 * pre_x2 + 0.0143 * in0;
  s->x2 = 0.0142 * pre_x0 - 0.0197 * pre_x1 + 0.9823 * pre_x2 + 0.0077 * in0;
}
@Halbaroth Halbaroth added this to the 2.5.0 milestone Jan 19, 2023
@CLAassistant
Copy link

CLAassistant commented Apr 13, 2023

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ploc
❌ proux01
You have signed the CLA already but the status is still pending? Let us recheck it.

@bclement-ocp bclement-ocp removed this from the 2.5.0 milestone Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants