Giter VIP home page Giter VIP logo

coq-smt-check's Introduction

coq-smt-check

This is a simple way to invoke an SMT solver on Coq goals. It does NOT generate proof objects. It is meant purely for sanity checking goals.

The main tactic is 'smt solve' which invokes an smt on the current goal. The core of the plugin is the conversion from Coq to SMT2 format. At the moment, the conversion handles the following:

  • boolean connectives, /, /, not
  • equality
  • variables
  • real numbers, +, -, /, constants

If your problem fits in this fragment (it can contain other facts as well), then you can run:

smt solve.

If the solver solves the goal then the tactic will succeed. If the solver returns an unsat core then the tactic will act like

clear - <unsat core>.

otherwise it will simply act like idtac (doing nothing to the goal). If the solver fails to solve the goal then the tactic will fail and display the sat model if the solver returns one. A common way to use the tactic is something like the following:

smt solve; admit.

which will admit the goal only if it is solved by the SMT solver.

You can also specify the solver to use in the tactic using the syntax:

smt solve calling "<solver-name>".

Where `' is, e.g. z3 or cvc4.

See the test-suite directory for examples.

Solvers

Currently, the code supports Z3 and CVC4. You need to set the solver using

Set SMT Solver "z3".

or

Set SMT Solver "cvc4".

You can toggle debugging globally using:

Set SMT Debug.
Unset SMT Debug.

Implementing Your Own Solver

You can implement your own solver interface using a Coq Plugin. At the high level, you should call:

SmtTactic.register_smt_solver : <name> -> (<options> -> <solver>) -> unit

and then set up the solver appropriately. Note that solver names can NOT contain colons (:). The string passed will be split on the first colon (if one exists) and the rest of the string will be passed as options above.

Install from OPAM

Make sure you added the Coq repository:

opam repo add coq-released https://coq.inria.fr/opam/released

and run:

opam install coq-smt-check

Contributors

This plugin was started by Vignesh Gowada at UCSD as part of the VeriDrone project. It was updated and is currently maintained by Gregory Malecha.

External contributions are always welcome.

coq-smt-check's People

Contributors

gmalecha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

coq-smt-check's Issues

Provide a way to print Z3 input for debugging

Hi @gmalecha ,
When I try to modify the coq-smt-check to add some new types, it is hard to debug without seeing the input of Z3. The best I can do is to write it into str_formatter, like this:

Format.fprintf Format.str_formatter "Z3 input\n" ;
RealInstance.write_instance Format.str_formatter inst;
debug (fun _ -> Pp.(str (Format.flush_str_formatter ())));

It can solve my problem to a certain degree, but it 's a temporary solution.
Is there a better way to deal with this?

Polya

Since you can export real number expressions from Coq, maybe it is possible to call Polya, too? @avigad or @rlewis1988 will know more about this.

Support custom types

Hi @gmalecha ,
Suppose I have a user-defined integer library as shown bellow(ignored the semantics).

Require Import ZArith.
Parameter int64: Type.
Parameter repr: Z -> int64.
Parameter and: int64 -> int64 -> int64.
Parameter or: int64 -> int64 -> int64.
...

I want to map this library to Bitvectors in Z3. How can I make the coq-smt-check support this library? I tried, but it looks complicated. The main problem is, the int64 is constructed by Z (repr: Z -> int64), and I want to map int64 to BitVec 64 directly.
For example, I want to map Int64.repr 5 into #x5. I can get something like (+ 1 (* (+ 1 1) (+ 1 1))) by using coq-smt-check or coq-plugin-utils. If we deal with Int or Real in Z3, it is ok to pass this syntax to Z3, like coq-smt-check did. But Z3 doesn't allow such syntax when build a BitVec. How can I get the result5 in hexadecimal format so that I can add the prefix #x, then pass it to Z3?

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.