coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Théo Zimmermann <theo.zimmi AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Why is the signature of sqrt R->R ?
- Date: Fri, 1 Feb 2019 11:54:36 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=theo.zimmi AT gmail.com; spf=Pass smtp.mailfrom=theo.zimmi AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua1-f47.google.com
- Ironport-phdr: 9a23:9ek3QhZGJNQAkMd4DN7bdMH/LSx+4OfEezUN459isYplN5qZr828bnLW6fgltlLVR4KTs6sC17KG9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCa+bL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjm58axlVAHnhzsGNz4h8WHYlMpwjL5AoBm8oxBz2pPYbJ2JOPZ7eK7WYNEUSndbXstJWCNBDIGzYYsBAeQCIOhWsZXyqVQVoBuiHAmhHv/jxiNUinL026AxzuQvERvB3AwlB98ArnTUq8/yNKgKUu+1zazIzTDdYPNM3Dfy8o7IchY8qvyLQbJwcdTeyU41GwLEj1WQrInlPzKO2+QCtmiU9etgVea1h2E7rAFxpyGiy8ExgYfHgYIVz0rL9SR/wIstJN24TlJ7bsCgEJdKqi6VKZN6Td0mQ2FtoSo6zqcJuZi0fCQQz5Qn3RHfZvqaeIaL+hLuTPidLSt8iX5/e7+yhwy+/Va+xuHiTMW531RHoyxYmdfWrH8NzQbc6s2fR/t94Eih3TGP2hjW6u5eIEA0kbPXK4M7zbItj5YTv0vOEy3slEX5i6+WcUok+uy25Oj9frrmoZqcO5d1igH4LKsuhtSyDfokPgUKRWSW+uSx2Kf98UHnXrlGlPI7n6vBvJDfP8sbp6q5AwFP0oYk7hayFyum0NQGknkANl5EeROHj43sO1HPO/34AvK/jE6tkDdv3fzJIrrhApDVInjZjLjhZap961JbyAcr0d9f4ItUBqgdL/L3R0/+r8fVDgQ5Mgyx2+boEs9x1oIYWWKVA6+WKrnesVGS5rFnH+7ZT4gM8B35NvJts/XplDoynUIXVaivx5oeLn6iSKdIOUKcNEbsA9A2I2YPuwckSeXsjhXWTT5eYDCgXqc55xk0DYunCcHIQYX70+/J5zuyApADPjMOMVuLC3q9MtzcA65dOhLXGddol3k/bZbkToYg0R+0swqjkuhoK+PV/msTspexjYEptd2Wrgk78HlPN+rYy3uEFjgmkWYBRjtw16d68xQklwWzlJNgivkdLuR9ovNEVgBgaMzZxu1+Ts37A0fPIojPR1GhTdGrRzo2S4Bpzg==
Dear Michael,
This design question is fundamentally the same (but in a more complex
case) as the choice of defining 1/0=0 in the natural number domain.
This is something that incidentally continues to confuse beginners not
just in Coq but in other pure functional languages as well
(https://discourse.elm-lang.org/t/integer-division-by-zero/2923). The
alternatives are indeed dependently-typed functions (as highlighted by
Joseph), but also functions returning values of type option. In both
case, this breaks composability and is thus inconvenient.
The three solutions (dependently-typed functions, functions which
return an option and total functions) are all weird compared to the
usual “undefined” behavior of math. So it seems to me that the ideal
solution would be to actually emulate this “undefined” behavior by
raising an exception. Pierre-Marie Pédrot has worked on adding
exceptions to CIC without breaking consistency and has a plugin to do
that (that I've never tried). I don't know how far we are from having
exceptions in mainline Coq...
Théo
Le ven. 1 févr. 2019 à 10:38, Soegtrop, Michael
<michael.soegtrop AT intel.com>
a écrit :
>
> Dear Joseph,
>
>
>
> thanks for the detailed explanation of the design considerations!
>
>
>
> So in short the story is that all real functions with domain restrictions
> are extended to total functions over the complete R by returning some value
> which is convenient in most situations. E.g. for asin I could return –PI/2
> or PI/2 for out of domain arguments, so that I can prove that the function
> is everywhere continuous and that the result of asin is limited to –PI/2 to
> PI/2 without requiring domain restrictions. And when it comes to proving
> that my definition of asin has a certain taylor expansion or derivative, I
> limit the argument range of asin to –1 … 1. Or alternatively I could return
> 1/0 for out of range asin, which possibly would allow me to prove that the
> derivative of asin x equals 1/sqrt(1-x^2) everywhere, but then I would need
> a domain restriction for the lemma which shows that asin x is bounded.
>
> This design leads to that one can prove:
>
>
>
> Require Import Reals.
>
> Require Import Psatz.
>
> Open Scope R_scope.
>
>
>
> Lemma sqrt_minus_one_is_zero: sqrt (-1) = 0.
>
> Proof.
>
> unfold sqrt.
>
> destruct (Rcase_abs (-1)) as [H|H].
>
> - reflexivity.
>
> - contradict H; lra.
>
> Qed.
>
>
>
> I am not sure if I like that one can prove sqrt(-1) = 0, even if this does
> not lead to a prove of that x=0 solves x²=-1. It is an interesting system –
> a bit weird, but I guess one gets used to it over time. As I said, in
> practice the reals as defined in Coq are very convenient to use and I
> understand that one has to pay some price for that (like sqrt(-1)=0).
>
>
>
> Best regards,
>
>
>
> Michael
>
>
>
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Christin Eisenschmid
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
- RE: [Coq-Club] Why is the signature of sqrt R->R ?, Soegtrop, Michael, 02/01/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Théo Zimmermann, 02/01/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Florian Steinberg, 02/02/2019
- RE: [Coq-Club] Why is the signature of sqrt R->R ?, Soegtrop, Michael, 02/04/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Richard Ford, 02/04/2019
- RE: [Coq-Club] Why is the signature of sqrt R->R ?, Soegtrop, Michael, 02/07/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Florian Steinberg, 02/05/2019
- RE: [Coq-Club] Why is the signature of sqrt R->R ?, Soegtrop, Michael, 02/07/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Richard Ford, 02/04/2019
- RE: [Coq-Club] Why is the signature of sqrt R->R ?, Soegtrop, Michael, 02/04/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Florian Steinberg, 02/02/2019
- Re: [Coq-Club] Why is the signature of sqrt R->R ?, Théo Zimmermann, 02/01/2019
Archive powered by MHonArc 2.6.18.