How to call proof asistant Coq from external software

后端 未结 2 1637
走了就别回头了
走了就别回头了 2020-12-30 11:02

How to call proof assistant Coq from external software? Does Coq have some API? Is Coq command line interface rich enough to pass arguments in file and receive response in f

2条回答
  •  既然无缘
    2020-12-30 11:16

    The command line seems to be the way to go.

    Coq includes several command-line tools, including the coqc compiler. This program takes a Coq theory file as input and tries to compile it. If something is wrong with the theory, the command fails with a non-zero exit code and writes some feedback onto its output streams. If everything is OK, the command is (typically) silent, exits with a zero exit code, and writes a .vo file containing the compiled theory.

    For example:

    $ cat bad.v
    Lemma zero_less_than_one: 0 < 1.
    $ coqc bad.v ; echo $?
    Error: There are pending proofs
    1
    $ cat good.v
    Lemma zero_less_than_one: 0 < 1.
    Proof.
      auto.
    Qed.
    $ coqc good.v ; echo $?
    0
    

    Here are the docs for Coq's command line tools, which can take various flags: https://coq.inria.fr/refman/practical-tools/coq-commands.html

    I am aware of two tools that use Coq as a subordinate proof engine: Frama-C and Why3. Looking at the sources at https://github.com/Frama-C/Frama-C-snapshot/blob/master/src/plugins/wp/ProverCoq.ml (methods compile and check) and at https://github.com/AdaCore/why3/tree/master/drivers, these tools also seem to dump Coq theories to a file and then call Coq's command-line tools. As far as I can tell, there is no more direct API for Coq.

提交回复
热议问题