Git Product home page Git Product logo

math-comp's Introduction

pipeline status Join the chat

The Mathematical Components repository

The Mathematical Components Library is an extensive and coherent repository of formalized mathematical theories. It is based on the Coq proof assistant, powered with the Coq/SSReflect language.

These formal theories cover a wide spectrum of topics, ranging from the formal theory of general purpose data structures like lists, prime numbers or finite graphs, to advanced topics in algebra. The repository includes the foundation of formal theories used in a formal proof of the Four Colour Theorem (Appel - Haken, 1976) and a mechanization of the Odd Order Theorem (Feit - Thompson, 1963), a landmark result of finite group theory, which utilizes the library extensively.

Installation

If you already have OPAM installed (a fresh or up to date version of opam 2 is required):

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

Additional packages go by the name of coq-mathcomp-algebra, coq-mathcomp-field, etc... See INSTALL for detailed installation instructions in other scenarios.

How to get help

Publications and Tools using MathComp

A collection of papers using the Mathematical Components library

math-comp's People

Contributors

affeldt-aist avatar amahboubi avatar anton-trunov avatar chdoc avatar clayrat avatar cohencyril avatar ejgallego avatar erikmd avatar eupp avatar gares avatar ggonthier avatar gtaumaturgo avatar herbelin avatar hivert avatar jashug avatar jasongross avatar jouvelot avatar ju-sh avatar kimayabedarkar avatar llelf avatar maximedenes avatar pi8027 avatar ppedrot avatar ppomco avatar proux01 avatar strub avatar thery avatar tragicus avatar ybertot avatar yoshihiro503 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math-comp's Issues

[apply:] unexpectedly adds some subgoal on the shelf (using coq 8.5.1 and mathcomp 1.6)

Hi,
Using Coq 8.5.1 and Mathcomp 1.6, I was faced with the following situation, which is maybe a bug(?), namely the apply: Rle_trans _ (proj1 Hx) tactic in the minimal example below generates two subgoals (including one on the shelf) instead of a single one:

Require Import Reals mathcomp.ssreflect.ssreflect.
Local Open Scope R_scope.
Lemma test (a b x y z : R)
  (Hx : a - b <= x <= a + b)
  (Hy : y <= a - b) :
  y <= x.
Proof.
apply: Rle_trans _ (proj1 Hx).
(*
1 focused subgoal
(shelved: 1), subgoal 1 (ID 34)

  a, b, x, y, z : R
  Hx : a - b <= x <= a + b
  Hy : y <= a - b
  ============================
   y <= a - b
*)
Unshelve.
(*
2 subgoals, subgoal 1 (ID 34)

  a, b, x, y : R
  Hx : a - b <= x <= a + b
  Hy : y <= a - b
  ============================
   y <= a - b

subgoal 2 (ID 34) is:
 y <= a - b
*)
Undo 2.

This doesn't occur if we first pose proj1 Hx:

pose Hx' := proj1 Hx.
apply: Rle_trans _ Hx'.
(*
1 subgoal, subgoal 1 (ID 31)

  a, b, x, y, z : R
  Hx : a - b <= x <= a + b
  Hy : y <= a - b
  ============================
   y <= a - b
*)
Undo 2.

and neither with the apply tactic from vanilla Coq:

apply Rle_trans with (2 := proj1 Hx).
(*
1 subgoal, subgoal 1 (ID 13)

  a, b, x, y, z : R
  Hx : a - b <= x <= a + b
  Hy : y <= a - b
  ============================
   y <= a - b
*)

Kind regards.

Coq 8.4, 8.5, 8.6 : issues with ssrpattern and ssrpatternarg(pat)

Hello,
I've experimented the ssrpattern tactic with MathComp for Coq 8.4, 8.5, and 8.6, and I believe that the behavior/syntax of this tactic is not uniform across the versions of SSReflect.

EDIT: Below is an update of my report that relies on MathComp 1.6.1 for Coq 8.5 and 8.6.
Here is my setup:

  • OCaml 4.02.3, Coq 8.5pl2, MathComp 1.6.1
  • OCaml 4.02.3, Coq 8.6, MathComp 1.6.1

My report relies on the following test file:

Require Import mathcomp.ssreflect.ssreflect mathcomp.ssreflect.seq.
(* 1 *) From mathcomp (* ONLY FOR Coq 8.5 *)
Require Import ssrmatching.
(* 2 *) Declare ML Module "ssreflect". (* ONLY FOR Coq 8.5, cf. issue #61 *)
Tactic Notation "ssrpat" ssrpatternarg(pat) := ssrpattern pat.
Tactic Notation "ssrrew" ssrpatternarg(pat) :=
  rewrite [pat](eq_from_nth (x0 := 0) (s2 := [:: 99])).

Goal [::] = [::] :> list nat.
(* 3 *) ssrpattern RHS.

Goal [::] = [::] :> list nat.
(* 4 *) ssrpat RHS.

Goal [::] = [::] :> list nat.
(* 5 *) ssrrew RHS.

Goal [::] = [::] :> list nat.
(* 6 *) ssrpattern (X in _ = X).

Goal [::] = [::] :> list nat.
(* 7 *) ssrpat (X in _ = X).

Goal [::] = [::] :> list nat.
(* 8 *) ssrrew (X in _ = X).

Here is the summary of what I obtained:

  • Coq 8.6: everything compiles, if one removes Line 1 and Line 2 (which is a workaround for Coq 8.5).
  • Coq 8.5:
    • Line 3 raises "Error: RHS is bound to a notation that does not denote a reference."
    • Line 5 raises "Error: variable pat should be bound to a term."
    • Lines 6, 7, 8 raise "Error: Unknown interpretation for notation "( _ in _ )"."

Best,
Erik

contra_neq

The type of contra_neq is too restrictive:
contra_neq: forall (T : eqType) (x1 y1 x2 y2 : T),
(x2 = y2 -> x1 = y1) -> x1 != y1 -> x2 != y2
A better type is
contra_neq: forall (T1 T2 : eqType) (x1 y1:T1) (x2 y2 : T2),
(x2 = y2 -> x1 = y1) -> x1 != y1 -> x2 != y2

ssrmatching.v & Coq 8.6 : what about adding a "transitional" ssrmatching.v file?

Dear MathComp developers,
Given that ssrmatching.v will be provided with Coq 8.6, assuming someone wants to distribute a library Foo that is based on ssrmatching.v and MathComp, and that is compilable as-is with Coq 8.5 and Coq 8.6, do you think that it would make sense to add an extra ssrmatching.v file in
https://github.com/math-comp/math-comp/tree/master/mathcomp/ssreflect/plugin/v8.6
that would just do Require Import ssrmatching.?
In this case the Foo theories could just start with

Require Import mathcomp.ssreflect.ssreflect.
From mathcomp Require Import ssrmatching.

and stay compatible with both Coq 8.5 and Coq 8.6 (and Coq 8.4 as well IINM).
What's your opinion on this change?
Kind regards,
Erik

Missing colon in Search output

I use mathcomp 1.6 (and coq 8.5.1) and it seems that a typing colon is missing for each lemma displayed by the Search vernacular from ssreflect: instead, the ident and the type are separated with two spaces. Here is an example:

Require Import mathcomp.ssreflect.ssreflect.

Search _ locked.
(*
lock  forall (A : Type) (x : A), x = locked x
not_locked_false_eq_true  locked false <> true
*)

SearchAbout locked.
(*
lock: forall (A : Type) (x : A), x = locked x
not_locked_false_eq_true: locked false <> true
*)

feature: notation for lists conforming to the general schema

This code seems to work here:

Notation "[ :: x1 , x2 , .. , xn : s ]" := (x1 :: x2 :: .. (xn :: s) ..)
  (at level 0, format
  "'[hv' [ :: '['  x1 , '/'  x2 , '/'  .. , '/'  xn ']' '/ '  :  s ] ']'").

Check fun l => [:: true, false , false : l].

The general schema seems to be

[operator item, item, ..., item short_operator item]

For seq the short operator is & and I quite don't get why (and I have hard times explaining it).

@ggonthier is there a reason behind the current choice?

coq-extra-dev: opam files need some update

Dear MathComp developers,

I've just faced with an OPAM issue by running:

$ opam repo add coq-core-dev https://coq.inria.fr/opam/core-dev
$ opam repo add coq-extra-dev https://coq.inria.fr/opam/extra-dev
$ opam install --jobs=2 coq.8.5~beta3 coq-mathcomp-algebra
...
#=== ERROR while installing coq-mathcomp-basic.dev ============================#
...
### stderr ###
# make: *** mathcomp/basic: No such file or directory.  Stop.
...

I believe this is due to the recent change 14c9a3a with respect to which the following files are not up-to-date:

Best regards.

simpl converting nat to %Nrec

Hi, I was testing Coq 8.5 so that I could try native_compute, but I was not able to compile my library.
I'm not using NaTrec, but sometimes simpl converts numbers to %Nrec and the nat lemmas stop working. Here's an example:

From mathcomp Require Import ssreflect ssrbool eqtype ssrnat seq.

Variable l: seq nat.
Variable idx: nat.

Lemma test:
nth 0 (0 :: l) (idx.+1 + 0) = nth 0 l idx.
Proof.
Fail (rewrite /= addn0).
rewrite addn0 /= //.
Qed.

Thanks,
Felipe

"elim/v: t" weaker than "elim t using v"

testcase:

  Inductive wf T : bool -> option T -> Type :=
  | wf_f : wf false None
  | wf_t : forall x, wf true (Some x).

  Derive Inversion wf_inv with (forall T b (o : option T), wf b o) Sort Prop.

  Lemma Problem T b (o : option T) :
    wf b o ->
    match b with
    | true  => exists x, o = Some x
    | false => o = None
    end.
  Proof.
  (* Doesn't work *)
  (* case: b; elim/wf_inv. *)
  case: b; intros top; elim top using wf_inv; clear top.

subfilter doesn't exists

The documentation at the beggining of seq.v speak about a subfilter function:

(* subfilter s : seq sT == when sT has a subType p structure, the sequence    *)
(*                         of items of type sT corresponding to items of s    *)
(*                         for which p holds.                                 *)

I can't find anything like that in the file. Should we simply remove it from the documentation ?

Meta question: Should I ask this here or on the mailing list ?

[rewrite foo in hyp] does not work with setoids

For example:

Require Import mathcomp.ssreflect.ssreflect.
Require Import Morphisms Setoid.

Section test2.
Context {A} (equiv : relation A) (equiv_equivalence : Equivalence equiv).
Context (P : A -> Prop) (P_Proper : Proper (equiv ==> iff) P).

Lemma test2 x y : equiv x y -> P x -> True.
Proof.
  move=> H1 H2.
  Fail rewrite H1 in H2.
  (* Error: tampering with discharged assumptions of "in" tactical *)
  move: H2; rewrite H1 => H2.
Admitted.
End test2.

Make byte fails

After the recent build system changes, $ make byte fails with:

# Override COQDEP to find only the "right" copy .ml files
/bin/sh: 1: --no-print-directory: not found

it could well be that upstream's coq_makefile is broken, need to investigate more. Note that for bytecode the main plugin file has been renamed to ssreflect_plugin.cmo from ssreflect.cma.

[rewrite foo in hyp] changes order of hypotheses

For example:

Require Import mathcomp.ssreflect.ssreflect.
Require Import Morphisms Setoid.

Lemma test1 (P : nat -> Prop) x y : P x -> x = y -> True.
Proof.
  intros H1 H2.
  rewrite H2 in H1.
  (* flips the order of H1 and H2 *)
  Restart.
  intros H1 H2.
  rewrite ->H2 in H1.
  (* does not flip the order *)
Admitted.

This is purely aesthetic, but in the case of proofs with many hypotheses one can easily loose track if the order starts to change arbitrarily.

`apply:` does not cancel execution properly

Consider the following proof script:

From mathcomp Require Export ssreflect.

Class Decision (P : Prop) := decide : {P} + {~P}.
Arguments decide _ {_}.
Notation EqDecision A := (forall x y : A, Decision (x = y)).

Global Instance list_eq_dec A {dec : EqDecision A} : EqDecision (list A).
Proof. Admitted.

Section foo.
  Context (iProp: Type) (someP : forall (T:Type), iProp) (op : iProp -> iProp -> iProp) (ent : iProp -> iProp -> Prop).

  Definition PersistentP (P : iProp) := True.
  Existing Class PersistentP.

  Instance someI T `{EqDecision T} : PersistentP (someP T).
  Proof. exact I. Qed.

  Context (lem : forall P Q, PersistentP Q -> (ent P Q) -> ent P (op P Q)).
  Context (P Q : iProp).

  Instance: PersistentP Q | 1000. Proof. exact I. Qed.

  Goal (ent P Q) -> ent P (op P Q).
    intros H. timeout 5 apply: lem. done. (* HERE *)
  Qed. 
End foo.

In the line marked HERE, the timeout 5 apply: succeeds even though apply: itself diverges. This should not happen. It also breaks C-c C-c in ProofGeneral.

I first reported this against Coq as https://coq.inria.fr/bugs/show_bug.cgi?id=5204, but Enrico figured out that the following line in ssreflect is the culprit, it fails to properly forward the exception raised on a timeout:
https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/plugin/v8.6/ssreflect.ml4#L4392

Environ.NotEvaluableConst exception

From mathcomp Require Import ssreflect.all_ssreflect.
Definition cst2 {A B : Type} (a: A ) (H: A= B ) : B.
  rewrite <-H.
  exact a.
Qed. (* I know it should be 'defined' instead*)

Lemma test: cst2 4 Logic.eq_refl = 4.
  rewrite /cst2.

results in

Anomaly: Uncaught exception Environ.NotEvaluableConst(1). Please report.

Anonymous EVars are no longer named; breaks build.

File "./ssreflect/ssrnat.v", line 213, characters 7-56:
Anomaly: Evar ?X79 was not declared. Please report.
Makefile.coq:558: recipe for target 'ssreflect/ssrnat.vo' failed
make[1]: *** [ssreflect/ssrnat.vo] Error 129
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 2

See: coq/coq@f46a568

Naming convention for odd_order

I know this is a detail, but the linter of the bench asks for a - instead of a _ in the name of the package coq:mathcomp:odd_order: https://coq-bench.github.io/clean/Linux-x86_64-4.02.2-1.2.2/extra-dev/8.5.dev/mathcomp%3Aodd_order/dev.html

This is for the sake of uniformity, so that the users do not hesitate between a _, a -, or a big cap letter to separate two words in the name of a package while doing an opam install. But if this is too much constraints we could relax the rule.

Trouble with typeclass reslution

We have a case of a diverging apply: related to typeclass resolution. We are trying to apply a lemma of following type:

∀ (M : ucmraT) (P Q : uPred M), PersistentP Q → (P ⊢ Q) → P ⊢ P ∗ Q

where PersistentP is a typeclass. We apply (apply: lemma) this to an evar-free goal of the right shape own γ a ⊢ own γ a ∗ ✓ a. This diverges. The output of Set Typeclasses Debug shows that it is looking for an instance of PersistentP ?u:

<prompt>own_valid_r < 89 |own_valid_r| 0 < </prompt>Set Typeclasses Debug.

<prompt>own_valid_r < 91 |own_valid_r| 0 < </prompt>apply: uPred.always_entails_r.
<infomsg>Debug: 1.1: apply @big_sepS_empty_persistent on (PersistentP ?u0)
</infomsg>

This is with ssrelfect 23e57fb and Coq 3a51aa7.

Given the nature of the typeclass (deriving a property of assertions), it is not surprising that this query diverges -- coming up with any random assertion that is persistent makes no sense. However, I feel there is a already a bug here: We applied the lemma to a goal which determines P and Q. There is no reason to search for PersistentP ?u, it should be searching for PersistentP (✓ a) instead, which will easily succeed.

The same error happens when using ssreflect 1.6 and Coq 8.5. However, if we also go back to an older version of our development, the search worked:

Debug: 1.1: apply @big_sepS_empty_persistent on (PersistentP ?u0)
Debug: 1.1.1.1: apply @fin_dec on (EqDecision ?Goal0)
Debug: 1.1.2.1: apply @finite.finite_countable on (Countable (fin ?Goal1))
Debug: 1.1.2.1.1.1: apply finite.fin_finite on (finite.Finite (fin ?Goal0))
Debug: 1.1: apply @cmra_valid_persistent on (PersistentP (✓ a))

I don't know why the first search terminates here, but the fact that it is even starting this search is already wrong.

To reproduce this yourself, the offending place in our development is https://gitlab.mpi-sws.org/FP/iris-coq/blob/a9f7431c844f79b7df201529de75893b1e0d057e/base_logic/lib/own.v#L77.

  • Clone https://gitlab.mpi-sws.org/FP/iris-coq.git
  • Go to commit a9f7431c844f79b7df201529de75893b1e0d057e
  • Edit line 77 of base_logic/lib/own.v to replace apply (uPred.always_entails_r _ _) by apply: uPred.always_entails_r
  • See that statement diverge

The Iris commit where things still worked is b863b0453331e78bb03f3ba4af538a1e8de6fd48 (back then, the file was called program_logic/own.v).

`make install` fails with confusing error message when Coq was installed as root (release/1.6)

$ make install
# Override COQDEP to find only the "right" copy .ml files
cd "." && for i in  ssreflect.cmxs; do \
         install -d "`dirname """/home/jgross/.local64/coq/coq-8.5/lib/coq/user-contrib"/mathcomp/$i`"; \
         install -m 0755 $i """/home/jgross/.local64/coq/coq-8.5/lib/coq/user-contrib"/mathcomp/$i; \
        done
install: cannot change permissions of ‘/home/jgross/.local64/coq/coq-8.5/lib/coq/user-contrib/mathcomp’: No such file or directory
install: cannot create regular file ‘/home/jgross/.local64/coq/coq-8.5/lib/coq/user-contrib/mathcomp/ssreflect.cmxs’: No such file or directory
make[1]: *** [install-natdynlink] Error 1
make: *** [install] Error 2

I'm not sure if this is a bug in ssr, or in coq_makefile, or somewhere else...

Trouble with rewrite and primitive projections

When primitive projections are involved, rewrite /def can fail to unfold a definition where unfold def works.
The following file demonstrates the issue (thanks @robbertkrebbers for minimizing):

Require Import mathcomp.ssreflect.ssreflect.

Set Primitive Projections.

Record foo A := Foo { foo_car : A }.
Arguments foo_car : simpl never.

Definition bar : foo nat := Foo nat 10.

Goal foo_car _ bar = 10.
unfold foo_car. simpl. (* works. Resulting goal: 10 = 10 *)
Restart.
rewrite /foo_car. (* leaves goal unchanged *) 

This is using the Coq 8.6 branch (3e6fa1c) and ssreflect master (a4599ba).

Possibly related: #19

`make` is not idempotent

After running

  • git clean -xfd && git reset --hard HEAD
  • make && make install

git diff shows

diff --git a/mathcomp/ssreflect/Make b/mathcomp/ssreflect/Make
index a10b9c5..993c0a7 100644
--- a/mathcomp/ssreflect/Make
+++ b/mathcomp/ssreflect/Make
@@ -22,3 +22,4 @@ ssreflect.ml4

 -I .
 -R . mathcomp.ssreflect
+ssreflect_plugin.mlpack

The build process should not modify files that are under version control. This can lead, for example, to strange build failures after upgrades of Coq and/or ssreflect (see #75).

[rewrite] with evars in the goal: Logic.RefinerError(_).

The following file triggers the following error with its last tactic:
Anomaly: cvtac's exception: Logic.RefinerError(_). Please report.

Require Export Program Setoid Utf8.
Require Export mathcomp.ssreflect.ssreflect.

(* -*- mode: coq; coq-prog-args: ("-emacs" "-Q" "." "" "-top" "cmra") -*- *)
(* File reduced by coq-bug-finder from original input, then from 1113 lines to 184 lines *)

Class Equiv A := equiv: relation A.
Infix "≡" := equiv (at level 70, no associativity).
Notation "(≡)" := equiv (only parsing).
Class Assoc {A} (R : relation A) (f : A → A → A) : Prop :=
  assoc x y z : R (f x (f y z)) (f (f x y) z).

Class Op (A : Type) := op : A → A → A.
Infix "⋅" := op (at level 50, left associativity).
Notation "(⋅)" := op (only parsing).

Structure cmraT := CMRAT {
  cmra_car :> Type;
  cmra_equiv : Equiv cmra_car;
  cmra_op : Op cmra_car;
}.
Existing Instances cmra_op cmra_equiv.

Section cmra.
  Context {A : cmraT}.
  Global Instance cmra_equivalence : Equivalence ((≡) : relation A).
Admitted.
End cmra.


Section cmra_mixin.
  Context {A : cmraT}.
  Global Instance cmra_assoc : Assoc (≡) (@op A _).
Admitted.
End cmra_mixin.
Context {A : cmraT}.
Implicit Types x y z : A.

Lemma L x y z : z ⋅ x ⋅ y ≡ y ⋅ x.
Admitted.

Lemma l x y : x ⋅ y ≡ y ⋅ x.
Proof.
rewrite -L.
rewrite -!assoc.

Compilation fails with current Coq 8.6 branch

I am getting the following error when compiling ssreflect master (b0c734b) against Coq v8.6 (96ed527):

$ nice make -j5
Generating Makefile.coq for Coq v8.6 with COQBIN=/home/r/bin/coq-8.6/bin/
# Override COQDEP to find only the "right" copy .ml files
COQDEP ssreflect_plugin.mlpack
CAMLDEP -pp ssreflect.ml4
Redundant [TYPED AS] clause in [ARGUMENT EXTEND ssrindex].
COQDEP tuple.v
COQDEP prime.v
COQDEP path.v
COQDEP generic_quotient.v
COQDEP fintype.v
COQDEP finset.v
COQDEP fingraph.v
COQDEP finfun.v
COQDEP div.v
COQDEP choice.v
COQDEP binomial.v
COQDEP bigop.v
COQDEP ssrnat.v
COQDEP ssrfun.v
COQDEP ssreflect.v
COQDEP ssrbool.v
COQDEP seq.v
COQDEP eqtype.v
COQDEP all_ssreflect.v
CAMLC -pp -c ssreflect.ml4
Redundant [TYPED AS] clause in [ARGUMENT EXTEND ssrindex].
File "ssreflect.ml4", line 675, characters 55-68:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 755, characters 25-37:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 756, characters 19-31:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 756, characters 33-45:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 757, characters 5-44:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 1252, characters 10-24:
Warning 3: deprecated: Util.String.set
Use Bytes.set instead.
File "ssreflect.ml4", line 4441, characters 26-123:
Warning 40: this record of type Proofview.Goal.enter contains fields that are 
not visible in the current scope: enter.
They will not be selected if the type becomes unknown.
File "ssreflect.ml4", line 1049, characters 6-9:
Warning 26: unused variable fmt.
File "ssreflect.ml4", line 1053, characters 6-13:
Warning 26: unused variable tacname.
CAMLC -pack -o ssreflect_plugin.cmo
make[1]: *** No rule to make target 'ssreflect_plugin.mllib', needed by 'ssreflect_plugin.cmxa'.  Stop.
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 2

Wrong error message in rewrite with type class resolution

The following code:

Class C (n : nat) := mkC {}.
(*Instance c : C 3 := mkC _.*)

Goal forall m : nat, (forall n, C n -> m = n) -> m = 3.
Proof.
  move=> m H.
  rewrite H.

leads to the following error message:

Error: The LHS of H
    m
does not match any subterm of the goal

The message is wrong since it matches m but cannot find an instance of class C or value for n.

warning on startup

The following warning is given when I import mathcomp.algebra.matrix:

$ coqtop
Welcome to Coq 8.5pl1 (May 2016)

Coq < Require Import mathcomp.algebra.matrix.

Small Scale Reflection version 1.5 loaded.
Copyright 2005-2014 Microsoft Corporation and INRIA.
Distributed under the terms of the CeCILL-B license.

[Loading ML file ssreflect.cmxs ... done]

Small Scale Reflection version 1.5 loaded.
Copyright 2005-2014 Microsoft Corporation and INRIA.
Distributed under the terms of the CeCILL-B license.

[Loading ML file z_syntax_plugin.cmxs ... done]
[Loading ML file quote_plugin.cmxs ... done]
[Loading ML file newring_plugin.cmxs ... done]
Warning: No global reference exists for projection
valuefun
       (x : finfun.finfun_of
              (aT:=fintype.prod_finType
                     (fintype.ordinal_finType _UNBOUND_REL_2)
                     (fintype.ordinal_finType _UNBOUND_REL_1))
              (ssreflect.Phant
                 (fintype.ordinal _UNBOUND_REL_2 *
                  fintype.ordinal _UNBOUND_REL_1 -> _UNBOUND_REL_4)))
       (_ : is_true true) =>
     Matrix (R:=_UNBOUND_REL_5) (m:=_UNBOUND_REL_4) (n:=_UNBOUND_REL_3) x in
instance matrix_subType of eqtype.Sub, ignoring it.

Coq <   

I have the following opam packages installed:

$ opam list| grep coq
coq                     8.5.1  Formal proof management system.
coq-color               1.2.0  A library on rewriting theory and termination.
coq-dpdgraph              0.6  Compute dependencies between Coq objects (definit
coq-ext-lib             0.9.4  A library of Coq definitions, theorems, and tacti
coq-math-classes        1.0.4  A library of abstract interfaces for mathematical
coq-mathcomp-algebra      1.6  Mathematical Components Library on Algebra
coq-mathcomp-fingroup     1.6  Mathematical Components Library on finite groups
coq-mathcomp-ssreflect    1.6  Small Scale Reflection

Better syntax for scopes in rewrite patterns

This is a feature request. I brought this up on the list already, but I guess here it is less likely to be lost.

We are formalizing a shallow embedding of a logic in Coq, and we are
using scopes such that we can use the same notation for logic-level and
Coq-level assertions. However, unfortunately, this does not work well
with the ssreflect rewrite patterns: If, for example, "_ ★ _" is
registered as notation in a scope delimited by M, I have to write

  rewrite [(a ★ _)%M]lemma.

It would be great if a syntax like

  rewrite [a ★ _]lemma%M.

could be supported.

Here's a code snippet demonstrating the issue:

Require Import mathcomp.ssreflect.ssreflect Setoid.

Delimit Scope my_scope with M.
Notation "a ★ b" := (a /\ b) (at level 40) : my_scope.

Lemma sep_comm a b : (a ★ b <-> b ★ a)%M.
Proof. tauto. Qed.

Goal forall a b, (a ★ b <-> b ★ a)%M.
Proof.
  move=>a ?.
  (* Need nested parentheses to give a rewrite pattern. *)
  rewrite [(a ★ _)%M]sep_comm.

[rewrite] does not work when primitive projections are involved

In the following code, the rewrite at the end of the file fails. If I remove "Set Primitive Projections", it success. Same if I use the Coq rewriter instead of the ssreflect one.

(* File reduced by coq-bug-finder  *)
Axiom proof_admitted : False.
Tactic Notation "admit" := case proof_admitted.
Require Import Coq.Setoids.Setoid.
Require Import Coq.Unicode.Utf8.

Require Import mathcomp.ssreflect.ssreflect.

Class Equiv A := equiv: relation A.
Infix "≡" := equiv (at level 70, no associativity).
Notation "(≡)" := equiv (only parsing).

Set Primitive Projections.

Class Dist A := dist : nat → relation A.
Notation "x ={ n }= y" := (dist n x y)
  (at level 70, n at next level, format "x  ={ n }=  y").


Record CofeMixin A `{Equiv A, Dist A} := {
  mixin_equiv_dist x y : x ≡ y ↔ ∀ n, x ={n}= y;
  mixin_dist_equivalence n : Equivalence (dist n);
  mixin_dist_S n x y : x ={S n}= y → x ={n}= y;
  mixin_dist_0 x y : x ={0}= y;
}.

Structure cofeT := CofeT {
  cofe_car :> Type;
  cofe_equiv : Equiv cofe_car;
  cofe_dist : Dist cofe_car;
  cofe_mixin : CofeMixin cofe_car
}.
Existing Instances cofe_equiv cofe_dist.
Arguments cofe_car : simpl never.

Section cofe_mixin.
  Context {A : cofeT}.
  Implicit Types x y : A.
  Lemma equiv_dist x y : x ≡ y ↔ ∀ n, x ={n}= y.
admit.
Defined.
End cofe_mixin.
  Context {A : cofeT}.
  Global Instance cofe_equivalence : Equivalence ((≡) : relation A).
  Proof.
    split.
    *
 intros x. rewrite equiv_dist.

This is with Coq 8.5 and Ssreflect 1.6.

This Coq bug may or may not be related - it occurs in the same code, but using an apply instead of a rewrite: https://coq.inria.fr/bugs/show_bug.cgi?id=4529

Error when factorising code on subgoals

On 8.5 ssreflect 1.5 this works:

From mathcomp Require Import all_ssreflect.
Goal forall n : nat, [|| n == 1, n == 2 | n ==3] -> n < 4.
by move=> n /or3P[] /eqP ->.

but this fails

Goal forall n : nat, [|| n == 1, n == 2 | n ==3] -> n < 4.
move=> n H.
have /or3P[] /eqP-> := H.

with

Anomaly: The global environment cannot be accessed during parsing. Please report.

[rewrite] does not work with partial orders

Coq's rewrite tactic supports rewriting with partial orders, but in case of ssr's rewrite tactic this does not seem to work. For example:

Require Import Arith NPeano.
Require Import mathcomp.ssreflect.ssreflect.

Lemma foo x y z : x <= y -> y <= z -> x <= z.
Proof.
  move=> H1 H2.
  Fail rewrite H1.
  (* Error: not a rewritable relation: (le x y) in rule H1 *)
  rewrite ->H1.
Admitted.

[rewrite] Unable to match RHS

In the following code, ssreflect is unable to perform the rewrite, claiming that wp _ does not match the goal:

(* File reduced by coq-bug-finder *)
Require Import Coq.Setoids.Setoid.
Require Import Coq.Unicode.Utf8.
Require Import mathcomp.ssreflect.ssreflect.

Global Generalizable All Variables.

Class Lookup (K A M : Type) := lookup: K → M → option A.
Notation "m !! i" := (lookup i m) (at level 20).

Section S1.
Context `{∀ A, Lookup nat A (M A)}.

Definition iProp := Prop.
Definition state := M nat.

Program Definition wp (Q : iProp) : iProp := True.

(* Just some relation. *)
Inductive entails (P Q : Prop) : Prop :=
  | Entails : (P → Q) → entails P Q.

Lemma wp_lift_atomic_step {Q} (φ : state → Prop) :
  entails (False) (wp Q).
Admitted.

Instance uPred_entails_rewrite_relation : RewriteRelation entails.
Global Instance: PreOrder entails.
Proof. Admitted.

Lemma wp_alloc_pst (σ : state) Q :
  entails Q (wp Q).
Proof.
  set (φ σ' := ∃ l, σ' = σ ∧ σ !! l = None).
  rewrite -(wp_lift_atomic_step (λ σ', ∃ l, σ' = σ ∧ σ !! l = None))=>//.

This is obviously wrong, the RHS does match the goal. If I replace rewrite - by rewrite <-, the rewrite succeeds. Similar, if I replace the (λ ... ) by φ, the rewrite succeeds. Finally, if I replace σ !! l = None by l = 0, again the rewrite succeeds.

This is with ssreflect 1.6 and Coq 8.5.

ssrmatching & Coq 8.5 : ssrpattern was not found in the current environment

Hi,
I'm preparing a PR for contributing a tactic allowing one to rewrite under lambdas (e.g. for bigops), and it is based on ssrpattern. However it seems that since the refactoring at 0e36c8f the ssrpattern tactic does not work out of the box with Coq 8.5 (tested with 8.5pl2 and the master version of MathComp).
Here is a minimal example:

From mathcomp Require Import ssrmatching ssreflect.

Tactic Notation "ssrpat" ssrpatternarg(pat) := ssrpattern pat.
(* Error: The reference ssrpattern was not found in the current environment. *)

It does work by doing the following:

From mathcomp Require Import ssrmatching ssreflect.
Declare ML Module "ssreflect".

Tactic Notation "ssrpat" ssrpatternarg(pat) := ssrpattern pat.

but I am unsure if adding Declare ML Module "ssreflect". in ssrmatching.v would be the proper fix.
Best,
Erik

in 8.5 Type occurrences are compared too strictly

Once a pattern has been instantiated, we call Reduction.conv to find all occurrences. Such function says yes to Type_i = Type_j iff i=j is already a declared constraint.
Given that the user does not even see i and j, we should say yes if i=j is an admissible constraint (by calling a function that infers constraints and add them to the evar map I guess).

"set" with parentheses calls Coq's set tactic

I wan't aware until today that writing "set (x := t)" in ssreflect (as opposed to "set x := t") seems to actually call Coq's set, whose matching has all sorts of bad behaviors like https://coq.inria.fr/bugs/show_bug.cgi?id=4636

I find this way of switching between ssr's tactic and Coq's equivalent very fragile, compared to the usual ":" (or "<-" / "->" for rewrite). It could be especially confusing for people transitioning from plain Coq to ssr.

make does not work with OPAM-installed OCaml

I am getting build error when compiling Mathematical Components from sources. I got the official 1.6 tarball, extracted it and here's what I get when I run make. You can see that ocamldep and ocamlc executables are listed as missing. Log clearly shows that they are expected to be in /usr/bin. This is not where they are on my system since I have OCaml installation managed by OPAM. The files are definitely on my path:

[killy@GLaDOS : ~] which ocamldep
/home/killy/.opam/4.03.0/bin/ocamldep
[killy@GLaDOS : ~] which ocamlc
/home/killy/.opam/4.03.0/bin/ocamlc

Behaviour change of `apply` when creating evar.

It seems that apply recovered it 1.4 behaviour when creating evars. For an example, see the mail thread in the ssr mailing list entitled "ssreflect 1.5: regression in apply". For instance, in the following example, no more goal is produced for the introduced evar.

Section TEST.

Parameter A: Type.
Parameter world: Type.
Definition prop := world -> Prop.
Parameter wle: world-> world -> Prop.

Goal forall (P:prop) (w w':world), wle w w' -> P w ->
   (forall (w : world), P w -> forall (w' : world), wle w w' -> P w') -> 
    P w'.
Proof.
move => P w w' H_wle HP.
apply.

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.