简体   繁体   中英

Can any additional axiom make Coq Turing complete?

Here I mean axiom as what we can define with the Axiom keyword in Coq Gallina, not with such command-line argument passing to Coq.

I know some axioms make Coq inconsistent. However, AFAIK they don't make Coq Turing complete. In my rough understanding, it's because they don't offer any additional computational behavior.

Is there one that makes Coq turning complete? If not, could you give a more concrete explanation of why it's impossible?

The answer to your question largely depends on where you want your functions defined in Coq to compute. In general, there is no problem to encode arbitrary partial functions in Coq using for instance step-indexing, see Mc Bride's " Turing completeness, totally free " for more details. But you will only be able to evaluate these functions up to a specified finite bound in Coq.

If the goal is to write formally verified programs that could use arbitrary recursion and run them outside of Coq, then you don't need axioms, you can use the Extraction mechanism and its proof-erasure semantics as shown by the following example of an unbounded while loop:

Inductive Loop : Prop := Wrap : Loop -> Loop.
Notation next := (fun l => match l with Wrap l' => l' end).

Definition while {A : Type} (f : A -> A * bool) : Loop -> A -> A :=
  fix aux (l : Loop) (a : A) {struct l} :=
    let '(x, b) := f a in
    if b then aux (next l) x else x.

Require Extraction.
Recursive Extraction while.

with extraction result:

type bool =
| True
| False

type ('a, 'b) prod =
| Pair of 'a * 'b

(** val while0 : ('a1 -> ('a1, bool) prod) -> 'a1 -> 'a1 **)

let rec while0 f x =
  let Pair (x0, b) = f x in (match b with
                             | True -> while0 f x0
                             | False -> x0)

Note that the function while requires a proof of termination in Coq that is erased once it is turned to ocaml.

Finally, as you explain, you would need to extend Coq's computational reduction machinery if you wanted evaluation of partial functions to stay inside Coq. There is no general mechanism providing this feature at the moment (even though there is a coq enhancement proposal to add rewriting rules ). It might be possible to abuse definitional UIP to evaluate partial functions. In all cases, adding the possibility to evaluate partial functions inside Coq, making it part of the conversion, automatically entails that the theory itself because undecidable (the proof assistant may fail to return a typechecking result).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM