Skip to content

Instant is monotonically nondecreasing - #43756

Merged
bors merged 2 commits into
rust-lang:masterfrom
sfackler:instant-nondecreasing
Aug 15, 2017
Merged

Instant is monotonically nondecreasing#43756
bors merged 2 commits into
rust-lang:masterfrom
sfackler:instant-nondecreasing

Conversation

@sfackler

Copy link
Copy Markdown
Member

We don't want to guarantee that Instant::now() != Instant::now() is
always true since that depends on the speed of the processor and the
resolution of the clock.

We don't want to guarantee that `Instant::now() != Instant::now()` is
always true since that depends on the speed of the processor and the
resolution of the clock.
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@kennytm

kennytm commented Aug 9, 2017

Copy link
Copy Markdown
Member

Mathematically speaking, "monotonically increasing" already means x ≥ y ⇒ f(x) ≥ f(y), what you are thinking is "strictly increasing".

@scalexm

Copy link
Copy Markdown
Contributor

@kennytm actually "strictly increasing" is:
∀x∀y (x ≥ y ⇔ f(x) ≥ f(y))

"Monotonically increasing" (or "nondecreasing") however is:
∀x∀y (x ≥ y ⇒ f(x) ≥ f(y))
(no reciprocal, take for a counterexample a constant function, which is nondecreasing)

@kennytm

Copy link
Copy Markdown
Member

@scalexm Thanks, updated the arrow.

@sfackler

Copy link
Copy Markdown
MemberAuthor

Ah right - I think only the second fix is needed then.

@sfackler

Copy link
Copy Markdown
MemberAuthor

Er, actually, I think the first change is still correct - Wolfram defines "monotonic function" as "A monotonic function is a function which is either entirely nonincreasing or nondecreasing." (http://mathworld.wolfram.com/MonotonicFunction.html), so Instant is monotonic, but not monotonically increasing, which is defined as "Always increasing; never remaining constant or decreasing." (http://mathworld.wolfram.com/MonotoneIncreasing.html)

@scalexm

Copy link
Copy Markdown
Contributor

@sfackler From my understanding of english terminology, "monotonically increasing" or simply "increasing" usually means "strictly increasing", but sometimes it can just mean "nondecreasing", depending on authors and contexts. So I think you should indeed stick with "monotonically nondecreasing" which is unambiguous.

But anyway the second fix is the most important since "greater" indeed means "strictly greater" with standard terminology.

Comment threadsrc/libstd/time/mod.rs Outdated
/// Opaque and useful only with `Duration`.
///
/// Instants are always guaranteed to be greater than any previously measured
/// Instants are always guaranteed to no less than any previously measured

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"be no less" ?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Fixed, thanks

@aidanhsaidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2017
@carols10cents

Copy link
Copy Markdown
Member

r? @alexcrichton

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+ rollup

@bors

bors commented Aug 14, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 97d046a has been approved by alexcrichton

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Aug 15, 2017
…lexcrichton
Instant is monotonically nondecreasing
We don't want to guarantee that `Instant::now() != Instant::now()` is
always true since that depends on the speed of the processor and the
resolution of the clock.
@frewsxcvfrewsxcv mentioned this pull request Aug 15, 2017
bors added a commit that referenced this pull request Aug 15, 2017
Rollup of 6 pull requests
- Successful merges: #43756, #43790, #43846, #43848, #43862, #43868
- Failed merges:
@bors
bors merged commit 97d046a into rust-lang:masterAug 15, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@sfackler@rust-highfive@kennytm@scalexm@carols10cents@alexcrichton@bors@brson@aidanhs