Skip to content

Conversation

@affeldt-aist
Copy link
Member

@affeldt-aist affeldt-aist commented Jun 24, 2025

Motivation for this change

closes draft PR #1613

@jmmarulang : I have duplicated your PR to avoid pushing on your master

Checklist
  • added corresponding entries in CHANGELOG_UNRELEASED.md
  • added corresponding documentation in the headers

Reference: How to document

Merge policy

As a rule of thumb:

  • PRs with several commits that make sense individually and that
    all compile are preferentially merged into master.
  • PRs with disorganized commits are very likely to be squash-rebased.
Reminder to reviewers

@affeldt-aist
Copy link
Member Author

Note that the last commit changes the definition of lne so that lne -oo = -oo
and then we can write

Lemma lne_div : {in `]0, +oo] &, {morph lne : x y / x / y >-> x - y}}.

instead of

Lemma lne_div x y :
  0 < x -> 0 < y -> lne (x * (fine y)^-1%:E) = lne x - lne y.

(fyi: @CohenCyril)

@jmmarulang It looks a bit better but is it as useful to you?

@affeldt-aist affeldt-aist changed the title natural logarithme for extended real numbers natural logarithm for extended real numbers Jul 7, 2025
@affeldt-aist affeldt-aist force-pushed the jairo_lne branch 2 times, most recently from 05f39b0 to bc4f303 Compare July 7, 2025 12:43
Copy link
Member

@hoheinzollern hoheinzollern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@affeldt-aist affeldt-aist force-pushed the jairo_lne branch 2 times, most recently from ceceff0 to c30e735 Compare August 6, 2025 08:29
@affeldt-aist
Copy link
Member Author

This PR has been discussed, already been approved, CI errors seem unrelated, and comments have been addressed.

@jmmarulang and @hoheinzollern , you may want to take a last look before squash-merge.

@proux01 there is a minor fix in constructive_ereal.v, as a big contributor to this file you maybe want to double-check

proux01
proux01 previously requested changes Aug 7, 2025
Copy link
Collaborator

@proux01 proux01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I have a comment

Comment on lines -1287 to +1294
by apply: contraTT => /norP[]; apply: mule_neq0.
by apply: contraTT => /norP[]; exact: mule_neq0.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, I tend to use exact instead of apply to conclude because we gain the coloring.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally agree, but here it is redundant with the by at the beginning of the line, so the color is more distracting than anything.

Notation "0" := (@GRing.zero (\bar _)) : ereal_scope.
Notation "1" := (1%R%:E : dual_extended _) : ereal_dual_scope.
Notation "1" := (1%R%:E) : ereal_scope.
Notation "- 1" := ((-1)%R%:E) : ereal_scope.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure we want that: this introduces a special case for - 1 that becomes (- 1)%:E whereas - 2 remains - 2%:E. So - <n> is - <n>%:E, except when <n> is 1 where it is (- <n>)%:E. That can be a surprising exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. On the other hand, - 1 is also a notation in ssralg.v, this PR provides an example that looks more natural with this notation, and it also helped us spotting an error in the definition of mulN1e, so it is not entirely negative imo. This is true that this is an exceptional case but given the many N1 lemmas, it seems to me that we already treat it as a special case. I am not sure what to do but I lean a bit towards the special notation. :-/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't even think about the notation priority thing, that makes it even worse :( if - 1 * n and - 2 * n are not parsed the same way.
And yes -1 is a notation in ssralg.v but so is - <n>, the - 1 is only to have - GRing.one.

Copy link
Member Author

@affeldt-aist affeldt-aist Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notation reverted, but they led to reintroduce 1%E's. :-/ (even though the notation is defined by Notation "- x" := (oppe x%E) : ereal_scope.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, that might be a bug in Rocq? We should probably minimize it.

Copy link
Member Author

@affeldt-aist affeldt-aist Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to minimize:

From mathcomp Require Import all_ssreflect all_algebra.

Declare Scope ereal_scope.

Local Open Scope ring_scope.

Variant extended {R : Type} := EFin of R.

Notation "r %:E" := (@EFin _ r%R) (format "r %:E").
Notation "1" := (1%R%:E) : ereal_scope.

Axiom oppe : forall {R : zmodType}, @extended R -> @extended R.

Delimit Scope ereal_scope with E.

Notation "- x" := (oppe x%E) : ereal_scope.

Local Open Scope ereal_scope.

Axiom R : numDomainType.

Fail Check - 1 : @extended R.
(* The command has indeed failed with message:
The term "-1" has type
 "GRing.Zmodule.sort
    (join_GRing_Ring_between_GRing_SemiRing_and_GRing_Zmodule ?t)"
while it is expected to have type "extended".
*)
Check - 1%E : @extended R.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to minimize:

Thanks, nice first step

From mathcomp Require Import all_ssreflect all_algebra.

We now need to get rid of that to report it as a Rocq bug.
But I'm now wondering whether it's really a bug.
In fact it's probably not. And our solution would be to add a small Number Notation in ereal scope. Will try that in a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #1704

@proux01
Copy link
Collaborator

proux01 commented Aug 7, 2025

CI errors seem unrelated

I agree but let me rebase it to be extra safe.

@proux01 proux01 dismissed their stale review August 7, 2025 06:12

Fixed

@proux01
Copy link
Collaborator

proux01 commented Aug 7, 2025

@affeldt-aist CI green, I let you squash / merge at your convenience

@affeldt-aist
Copy link
Member Author

@affeldt-aist CI green, I let you squash / merge at your convenience

Thanks! (I wait a bit for input by the other participants to the conversation.)

@affeldt-aist affeldt-aist merged commit 61d8adf into math-comp:master Aug 7, 2025
56 checks passed
@proux01
Copy link
Collaborator

proux01 commented Aug 18, 2025

So, apparently I was right to want to get green CI but this wasn't enough. This PR ended up in a strange situation where this doesn't compile on MC master with Rocq <= 9.1, a combination we didn't test since we only test MC master on Rocq master.
C.f. #1703

yosakaon pushed a commit to yosakaon/analysis that referenced this pull request Dec 4, 2025
* add lne

* ln -oo = -oo

* fix mulN1e

---------

Co-authored-by: jmmarulang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants