Here we will present ideas of what constitutes a well written Coq source file. We discuss the general issues that affect the shape of the Coq scripts and consequently their legibility and re-usability. Yes, we are interested in reading and editing ASCII Coq sources!

This is intended to be a collection of suggestions for good style and good practice, acknowledging that usually more than one way is possible.

For the discussion of issues related to the content of specific formalisations and general (type theoretic) tips and traps to avoid please use TipsAndTricks.

File Structure

(************************************************************************)
(* Copyright <YEAR> <AUTHOR>                                            *)
(* <LICENSE>                                                            *)
(************************************************************************)

Layout

Layout of Proofs

Lemma foo:
Proof.
 <body of tactics before case>.
 case (compare_with_zero X).
  (* 0 < X *)
   <body of tactics>...
  (* X < 0  *)
   <body of tactics>... 
  (* X = 0  *)
   <body of tactics>... 
 
 <body of tactics after case>.
Qed.

An alternate possible layout is to use indentation to tell exactly how many subgoals remain: n indentation for n subgoals (variant: (n-1)). This is especially useful during development when you replay proofs after you have modified a definition above: you can easily find where your proof script behaves differently.

The previous example would look much less nice than with the former style; on the contrary this latter style fits better with a forward proof-style, using assert-like tactics.

Example:

Lemma bar:
Proof.
 assert (H: <some property>).
  rewrite foobar.
  intuition.
 assert (H2: <something else>).
  simpl.
  omega.
 assert (H3: ...).
  auto.
 <body of tactics>
Qed.

Naming

Lemmas and Data-types

Variables inside proofs

Extraction

Extraction Language Haskell.
Extraction "Xfoo.hs" foo.

CoqStyle (last edited 07-12-2007 20:37:51 by localhost)

Cocorico!WikiLicense