Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary reduction of nosimpl wrapper #10849

Open
llelf opened this issue Oct 7, 2019 · 1 comment
Open

Unnecessary reduction of nosimpl wrapper #10849

llelf opened this issue Oct 7, 2019 · 1 comment
Labels
part: ssreflect The SSReflect proof language.

Comments

@llelf
Copy link
Contributor

llelf commented Oct 7, 2019

Description of the problem

From Coq Require Import ssreflect. (* for nosimpl and if-is notation *)
(* NB: nosimpl ≡ Notation nosimpl t := (let: tt := tt in t). *)

Fixpoint foo (n : nat) : nat := if n is S n' then foo n' else S n.
Definition add := nosimpl Nat.add.

Goal forall m n, 0 <> foo (add (S m) n). simpl.
(* Expected: forall m n : nat, 0 <> foo (add m n)
   Actual:   forall m n : nat, 0 <> foo (m + n)
*)
Abort.

A slightly less silly and more real-world example:

From mathcomp Require Import ssreflect ssrbool ssrnat.

Fixpoint fib (n : nat) : nat :=
  if n is (n''.+1 as n').+1 then fib n'' + fib n' else n.
Arguments fib n : simpl nomatch.

Goal forall m n, 0 <= fib (m.+1 + n).+1. move=> /=.
(* Unexpected, but actual:
     forall m n : nat, 0 <= fib (m + n)%Nrec + fib (m.+1 + n) *)
Abort.

Coq Version

8.9.1, 8.10+β3, master

@anton-trunov anton-trunov added the part: ssreflect The SSReflect proof language. label Oct 7, 2019
@llelf llelf changed the title coq cannot recover ssreflect’s nosimpl after expanding it Unnecessary reduction of nosimpl wrapper Oct 7, 2019
@llelf
Copy link
Contributor Author

llelf commented Oct 20, 2019

TIL:

From mathcomp Require Import ssreflect ssrnat.

Lemma addnAC a b c : a + b + c = a + c + b.    (* addn *)
by rewrite -> PeanoNat.Nat.add_shuffle0.       (* Nat.add *)
Qed.

Check PeanoNat.Nat.add_shuffle0 : forall a b c, _ = (_ + _)%nat.
Check PeanoNat.Nat.add_shuffle0 : forall a b c, _ = (_ + _)%coq_nat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: ssreflect The SSReflect proof language.
Projects
None yet
Development

No branches or pull requests

2 participants