Coq packages


Info on some coq packages.


CoqEAL

General

refines

refines: (A -> B -> Type) -> A -> B -> Type
         |              |
         +--------------+
            |
        refinement relation

From here:

Refinement relation:

(* Type of refinement relations *)
R: SpecT -> ImplT -> Type

Transport lemma:

R_op: refines refinement_relation Spec Impl

Example:

Definition tup2seq (n:nat)
  : n.-tuple bool -> seq bool -> Type :=
  fun btup bseq => tval btup = bseq.

(Pseudo-) examples:

Refinement relation for seqmx in CoqEAL

Rseqmx: https://github.com/coq-community/coqeal/blob/1.1.3/refinements/seqmx.v#L298

R ==> S (hrel)

If there are functions R: A -> B and S: A' -> B', then there exists a function (A -> A') -> (B -> B').

Notation for hrespectful R S.

From relscope.

R: A -> B -> Type
S: C -> D -> Type
f: A -> C
g: B -> D

is

R ==> S

which in turn is

hrespectful R S: (A->C) -> (B->D) -> Type :=

fun f g => forall (a:A) (b:B),
    R a b -> S (f a) (g b)

Guesses

R spec impl means

fun_hrel

fun_hrel
     : forall A B : Type, (B -> A) -> A -> B -> Type

Like:

fun_hrel (A:=Spec) (B:=Impl): (Impl -> Spec) -> s -> i -> Type

QuickChick

Coq version of quickcheck

Combinators:

Check choose (0,3).
(* choose (0, 3) : G nat *)

Check List.hd 5 (sample (choose (0,3))).
(* List.hd 5 (sample (choose (0, 3))) : nat *)

Check choose.
(* choose : BinNums.N * BinNums.N -> G BinNums.N *)

Typeclasses:

Links:

Hierarchy builder

General

HB.about isFinite.
(*
HB: isFinite is a factory (from "./fintype.v", line 161)

HB: isFinite operations and axioms are:
    - enum_subdef
    - enumP_subdef

HB: isFinite requires the following mixins:
    - hasDecEq

HB: isFinite provides the following mixins:
    - isFinite
*)

Links:

eta

From structures.v.

Notation "[ 'eta' f ]" := (fun x => f x) : fun_scope (default interpretation)

Core

coqdoc

https://coq.inria.fr/refman/using/tools/coqdoc.html

Sections

(** * Level 1

    H1 size section. *)

(** ** Level 2

    H2 size section. *)

Increase the number of asterisks accordingly.

Verbatim

Enclose between << and >>.

Multi-line

Like,

<<
  let rec fact n =
    if n <= 1 then 1 else n * fact (n-1)
>>

Inline

Like,

caml expression: << fact (n-1) >>

company-coq (emacs)

Ltac2

Import with:

From Ltac2 Require Import Ltac2.

Modify a previously defined tactic

Use Ltac2 mutable when defining the tactic for the first time.

From Ltac2 Require Import Ltac2.

(* Initial definition *)
Ltac2 mutable x_mut := 3.
Ltac2 Eval x_mut.   (* - : int = 3 *)        

(* Changing definition *)
Ltac2 Set x_mut := 2.    
Ltac2 Eval x_mut.   (* - : int = 2 *)        

Attempts to modify an ltac2 tactic which was not explicitly set as mutable results in error.

Ltac2 x_immut := 3.                          

Fail Ltac2 Set x_immut := 2.                 
(*                                           
The command has indeed failed with message:  
The tactic x_immut is not declared as mutable
*)                                           

Old value of a mutable tactic can be accessed while redefining it using as:

Ltac2 mutable f x := Int.add x 1.                          
Ltac2 Eval f 3.                                            
(* - : int = 4 *)                                          

Ltac2 Set f as oldf := fun x => Int.add 10 (oldf x).       
Ltac2 Eval f 3.                                            
(* - : int = 14 *)                                         

Use ltac1 tactics in ltac2

Possible with ltac1:(tactic_name).

Ltac2 newintros () := ltac1:(intros).                                 

Tactic definitions without arguments

Must have at least a () as argument.

Fail Ltac2 newintros := ltac1:(intros).                               
(*
The command has indeed failed with message:                           
Tactic definition must be a syntactical value. Consider using a thunk.
*)

Ltac2 newintros () := ltac1:(intros).                                 

Notations

Ltac1 tactics are not available when using ltac2. Notations are helpful to reclaim use of ltac1.

Ltac2 newintros () := ltac1:(intros).                                 
Ltac2 Notation "intros" := newintros ().

Changing default tactic language

https://coq.inria.fr/doc/v8.19/refman/proofs/writing-proofs/proof-mode.html#coq:opt.Default-Proof-Mode

(* Use ltac1. This is the default. *)
Default Proof Mode "Classic".


(* Use ltac2. Require it first. *)
(* Importing Ltac2 implicitly sets default proof mode to ltac2. *)
From Ltac2 Require Ltac2.
Default Proof Mode "Ltac2".

Exceptions

More packages

Better 'stdlib'

Efforts have been made to augment Coq's stdlib. ʳ.

mathcomp has got a lot of stuff as well.

SAT/SMT interfaces, AI, etc