coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Abhishek Anand <abhishek.anand.iitg AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Problems with ignored notations
- Date: Thu, 9 Feb 2017 10:23:22 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f172.google.com
- Ironport-phdr: 9a23:qfiNwxamh24kFVpyb8Ol1ET/LSx+4OfEezUN459isYplN5qZr8i+bnLW6fgltlLVR4KTs6sC0LuK9fC9EjBRqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjSwbLd9IRmsrgjctsYajIRmJ60s1hbHv3xEdvhMy2h1P1yThRH85smx/J5n7Stdvu8q+tBDX6vnYak2VKRUAzs6PW874s3rrgTDQhCU5nQASGUWkwFHDBbD4RrnQ5r+qCr6tu562CmHIc37SK0/VDq+46t3ThLjlSEKPCM7/m7KkMx9lKBUoByhqRJxwIDafZ+bO+Zlc6zHYd8XX3BMUtpNWyFDBI63cosBD/AGPeZdt4Twu0ABrRu/BQm3BOPg1DxIjWLq0K08yeshFxzJ1xEnEt0Uq3vUrNT1NLwSUe+rz6nE1y/Mb/VM1jf79YfEaBEhofCQXbJ/asfRxkwvGBnEjlWUs4DqIzSV1uEUvmWd8uFuW+Wvi2s9pAFwpDii3tsjio7ThoIT1F/E8SF5zJwrKtKlVU53ed+kEJ1KtyGbLYR6WM0iQ3twtCY+0LIJooS7fCkQxJQp3R7SbeGMfYuQ4h/7SuqdPTN1iGhmdb+/nRq+71Wsx+zmWsWp0ltGsCxImcTWuH8XzRzc8M2HR+N9/ki/3TaP0Bje6uReLkA1karXMochwqIsmpYKv0TPAy37lFvsgK+ZcUUk/eeo6+D5bbn8upCcMIp0hhn/MqQohMO/Hfw1PhYSU2Wf4+ix173u8VfnTLlXj/A6iLTVvZLEKcgDo662GQ5V0oIt6xalCDem1cwVkmMcI1JFeRKHlIjpNE/NIPziF/i/hU6jkDF2yPzcP73hA4nNLnfYnbfueLZy8U9cyA4pwd9D4JJUD6kNIOjvVU/pqNzYEhg5PhSozObgEdVxz58RWWaSAqCCK67Sql+J5uc3I+aWfoMVuTD9K+Ik5/H0l3M5l0UdLuGV2s4cb2n9FfB7KQ3Nan31x9wFDG0ivwwkTeWshkfUAhBJYHPndqg85yo7BYHuJIHKQIzl1LWL3CagHpBVIGlAA1aAV3bpa4qsVPIFaSbUKchkxG9XHYO9QpMsgEn9/DTxzKBqe7LZ
Sorry, I may have misunderstood your question. Here are some observations that may be relevant:
Note that in the proof of the lemma "example" in my email, simpl won't unfold the notation "0". To do that, you need to unfold
the definition canonical_names.zero, just as you would unfold any other definition.
You can also control which definitions simpl unfolds:
In your style, Z0 was an abbreviation. I don't know how simpl's behavior on abbreviations can be customized.
-- Abhishek
http://www.cs.cornell.edu/~aa755/On Thu, Feb 9, 2017 at 9:44 AM, Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
An alternative is to have just one notation and to use the typeclass resolution machinery to resolve it to the appropriate instance, based on types.MathClasses already defines typeclasses for the kind of notations you want.Here is your example rewritten in that style:Require Import Utf8_core.Require Import MathClasses.interfaces.canonical_names.Open Scope mc_scope.Notation "〈 a , b 〉" := (pair a b)(no associativity).Inductive ℕ := Zero : ℕ | Suc : ℕ → ℕ.Global Instance ZeroN : canonical_names.Zero ℕ := Zero.Global Instance OneN : canonical_names.One ℕ := (Suc 0).(* 0, which is a notation for canonical_names.zero, is resolved to thelatest typeclassInstance of Zero in scope. If that is not the instance you want,you need to help the typeclass resolution by providing casts (see below),or implicit arguments *)Check 0.Check Zero.Check Suc Zero.Notation ℤ := (ℕ * ℕ)%type.Check (〈0,1〉).Check (〈Zero, Suc Zero〉).Notation "ℤ-1" := (〈0, 1〉 : ℤ).Global Instance ZeroZ : canonical_names.Zero ℤ := 〈0, 0〉.Global Instance OneZ : canonical_names.One ℤ := 〈1, 0〉.Check 0.Check (0:ℕ).Global Instance EquivN ℕ : Equiv ℕ := (Coq.Init.Logic.eq).Lemma example : ℤ-1 = ℤ-1 ∧ (0 = (0:ℤ)) ∧ 1 = (1:ℤ).split;[|split]; reflexivity.Admitted.If you are new to typeclasses, you may want to first walk through some tutorial, e.g.-- Abhishekhttp://www.cs.cornell.edu/~aa755/On Thu, Feb 9, 2017 at 8:57 AM, Sebastian Böhne <boehne AT uni-potsdam.de> wrote:Dear Coq-community!
We, Tim Richter and Sebastian Böhne, have problems with some notations we introduced for numbers in Coq. Sometimes an already introduced notation is ignored by Coq and -- even worse -- when processing in a proof our notations are replaced by their original versions. This is a big problem, since even simple contents become very confusing.
You find a minimal example below and attached.
Thank you very much for your help!
Best regards
Tim Richter and Sebastian Böhne
PS: We use CoqIde 8.4pl3.
----------------------------------
Require Import Utf8_core.
Notation "〈 a , b 〉" := (pair a b)
(no associativity).
Inductive ℕ := Zero : ℕ | Suc : ℕ → ℕ.
Notation ℕ0 := (Zero).
Notation ℕ1 := (Suc ℕ0).
Check ℕ0.
Check Zero.
Check Suc Zero.
(* Here Coq sticks correctly to notations and
furthermore retranslates objects, which can be
displayed as Notations *)
Notation ℤ := (ℕ * ℕ)%type.
Check (〈ℕ0,ℕ1〉).
Check (〈Zero, Suc Zero〉).
(* So Coq does not seem to have problems with
the pair notation *)
Notation ℤ0 := (〈ℕ0, ℕ0〉 : ℤ).
Notation ℤ1 := (〈ℕ1, ℕ0〉 : ℤ).
Notation "ℤ-1" := (〈ℕ0, ℕ1〉 : ℤ).
Check ℤ1.
(* Still like expected *)
Check (〈ℕ1, ℕ0〉).
(* Here Coq does not retranslate anymore *)
Check (〈ℕ1, ℕ0〉 : ℤ).
(* However, with some little help it still
works *)
Lemma example : ℤ-1 = ℤ-1 ∧ ℤ0 = ℤ0 ∧ ℤ1 = ℤ1.
Proof.
simpl.
(* We did not even do anything but Coq
replaces our abbreviations with the longer
original versions. Why? *)
admit.
Admitted.
----------------------------------
- [Coq-Club] Problems with ignored notations, Sebastian Böhne, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Gaetan Gilbert, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Guillaume Melquiond, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Sebastian Böhne, 02/10/2017
- Re: [Coq-Club] Problems with ignored notations, Guillaume Melquiond, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Abhishek Anand, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Abhishek Anand, 02/09/2017
- Re: [Coq-Club] Problems with ignored notations, Gaetan Gilbert, 02/09/2017
Archive powered by MHonArc 2.6.18.