GithubHelp home page GithubHelp logo

verimag-polyhedra / vpltactic Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 39 KB

A Coq Tactic for Arithmetic (based on VPL)

License: GNU Lesser General Public License v3.0

Makefile 1.95% OCaml 41.79% Coq 56.26%
coq coq-tactic arithmetic vpl-oracle polyhedron

vpltactic's Introduction

VplTactic (A Coq Tactic from Verified Polyhedra Library)

Current version: 0.4.2

Introduction

The VPL is an Ocaml library allowing to compute with convex polyhedra. It provides standard operators -- certified in Coq -- to use this library as an abstract domain of polyhedra.

The VplTactic is a tactic to solve arithmetic goals in Coq. It is implemented through a Coq plugin that invokes the guard operator of the VPL. The main feature of our tactic with respect to similar tactics (lra, fourier, omega, lia) is that our tactic never fails. Indeed, when it can not prove the goal, it tries to simplify the goal and in particular to replace inequalities by equalities. See examples below. Currently, this tactic is highly experimental and it only works on Qc which is a canonical type of rationals.

If you find a bug or have any comment, please contact us

Main Contributors: Alexandre Maréchal and Sylvain Boulmé. Developed at Verimag and supported by ANR Verasco and ERC Stator.

Using VplTactic

First, add the following lines at the head of your Coq files:

Require Import BinInt.
Require Import VplTactic.Tactic.
Add Field Qcfield: Qcft (decidable Qc_eq_bool_correct, constants [vpl_cte]).

Module VplTactic.Tactic actually provides several variants of our tactic. The most complex is vpl_auto.

Lemma ex_intro (x: Qc) (f: Qc -> Qc):
  x <= 1
  -> (f x) < (f 1)
  -> x < 1.
Proof.
  vpl_auto.
Qed.

Actually, vpl_auto is a macro for vpl_reduce; vpl_post where vpl_reduce is the main call to the VPL oracle. It try to find a polyhedron in your goal and then, it simplifies this polyhedron.

For example, consider the following goal:

Goal forall (v1 v2 v3: Qc) (f: Qc -> Qc),
   f ((v2 - 1)*v3) <> f ((2#3) * v1 * v2)
   -> v1+3 <= (v2 + v3)
   -> v1 <= 3*(v3-v2-1)
   -> 2*v1 < 3*(v3-2).

The vpl_reduce tactic simplifies this goal into

H : f ((v2 - (1 # 1)) * v3) = f ((2 # 3) * v1 * v2) -> False
============================
v1 = (-3 # 1) + (3 # 2) * v3
-> v2 = (1 # 2) * v3
-> False

Hence, the linear inequalities of the initial goal have been replaced by linear equalities. Then, vpl_post proves the remaining goal by combininig auto and field tactics.

The vpl tactic is a slight variant of vpl_reduce which rewrites the discovered equalities in the remaining goal: it is a macro for vpl_reduce; vpl_rewrite.

If needed, you may also directly invoke some subcomponent of vpl_reduce, see file theories/Tactic.v. You may also find examples in file test-suite/*.v.

Our ITP'18 paper presents this tactic in details.

Installation through opam

  1. Dependencies

  2. Installation

    First, add the following repository in your opam system:

       opam repo add vpl https://raw.githubusercontent.com/VERIMAG-Polyhedra/opam-vpl/master
    

    Then, install the following package:

       opam install coq-vpltactic
    

This will also install other opam-vpl packages.

Browsing the sources

Following usual conventions in Coq projects, directories are organized as follows:

  • src/ contains ocaml code for the plugin (reification + oracle wrapper).

  • theories/ contains the coq code of VplTactic

    • Input.v finds a polyhedron from the goal

    • Output.v exports back the reduced polyhedron into the goal

    • Reduction.v transforms the input goal into the output goal (thanks to a "script" provided by the VPL oracle)

    • Tactic.v is the main file

  • test-suite/ contains examples.

Currently, the code is not really documented (sorry!). It only includes a few comments inside.

vpltactic's People

Contributors

boulme avatar marechalalex avatar verimag-polyhedra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vbgl

vpltactic's Issues

Unable to build VplTactic on given VPL vagrant box

Hey,

I'm trying to build VPLTactic from source. I'm building it on the special vagrant box that was issued, but it doesn't work.

I'm using the vagrant setup described on opam-vpl.

make traceback
make -j -f tactic.mk src/vpltactics.cmx "OPT:=-opt" "CAMLC:=ocamlfind ocamlc -c -rectypes -thread -package vpl -linkpkg" "CAMLOPTC:=ocamlfind ocamlopt -c -rectypes -thread -package vpl -linkpkg" "CAMLLINK:=ocamlfind ocamlc -rectypes -thread -package vpl -linkpkg" "CAMLOPTLINK:=ocamlfind ocamlopt -rectypes -thread -package vpl -linkpkg"
make[1]: Entering directory '/home/ubuntu/work/VplTactic'
CAMLDEP src/reification.mli
COQDEP src/vpl_plugin.mllib
CAMLDEP src/reification.ml
COQDEP test-suite/Demo.v
COQDEP test-suite/Test.v
COQDEP theories/Tactic.v
COQDEP theories/Reduction.v
COQDEP theories/Input.v
*** Warning: vpl_plugin.mllib already found in src (discarding src/vpl_plugin.mllib)
COQDEP theories/Output.v
CAMLDEP -pp src/vpltactics.ml4
COQDEP test-suite/Examples.v
CAMLC -c src/reification.mli
File "src/reification.mli", line 19, characters 45-59:
Error: Unbound module EConstr
Hint: Did you mean Cstr or Cons?
tactic.mk:432: recipe for target 'src/reification.cmi' failed
make[1]: *** [src/reification.cmi] Error 2
make[1]: Leaving directory '/home/ubuntu/work/VplTactic'
Makefile:11: recipe for target 'tactic' failed
make: *** [tactic] Error 2

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.