Documentation Index
Fetch the complete documentation index at: https://mintlify.com/paulch42/lean-spec/llms.txt
Use this file to discover all available pages before exploring further.
LeanSpec.lib.Temporal provides a lightweight model of temporal entities: combined date-and-time values, durations, and intervals. The design draws from ISO 8601 and RFC 3339 but is deliberately simplified — it supplies enough precision to underpin the aviation-related specifications in the tutorial (TMI slot scheduling, FPL active periods, and similar) without attempting to be a production-quality calendar library. All definitions live in the Temporal namespace.
Constants
Fundamental time-conversion constants used throughout the module.| Constant | Value | Meaning |
|---|---|---|
secondsPerMinute | 60 | Seconds in one minute |
minutesPerHour | 60 | Minutes in one hour |
secondsPerHour | 3 600 | Seconds in one hour |
hoursPerDay | 24 | Hours in one day |
secondsPerDay | 86 400 | Seconds in one day |
Duration.oneDay, Duration.oneHour, and any specification that needs to express time offsets in terms of human-readable units.
DTG (Date/Time Group)
ADTG represents a combined date and time as the number of seconds elapsed since the epoch (year 0 in the Gregorian calendar). Granularity is to the nearest second. The name “Date/Time Group” is borrowed from aviation and military practice where a DTG identifies a precise moment in time.
Structure definition
dtg : Nat is the raw second count. Repr, Ord, and DecidableEq are derived automatically, giving structural equality, a total order, and a repr display for free.
OfNat instance
Natural number literals can be used directly as DTG values — the literal is interpreted as the number of seconds since the epoch:
Ordering instances
LT — strict less-than, delegating to Nat:
<:
LE — non-strict less-than-or-equal:
≤:
Min and Max instances
Add instance
Two DTG values can be added (useful when a DTG is used as a raw offset):
Duration
ADuration represents an elapsed time expressed as a whole number of seconds. Like DTG, it wraps a Nat and inherits a rich set of typeclass instances.
Structure definition
OfNat instance
Natural number literals are interpreted as durations in seconds:
Ordering instances
LT and decidable <:
LE and decidable ≤:
Min and Max instances
Arithmetic instances
Add — sum of two durations:
Sub — magnitude of the difference (symmetric):
Duration subtraction is commutative:
d₁ - d₂ = d₂ - d₁ = max d₁ d₂ - min d₁ d₂. It always returns the absolute difference rather than a signed result.Named constants
Heterogeneous Operations on DTG and Duration
TheseHAdd, HSub, HMul, and HDiv instances combine DTG and Duration values in the natural ways expected by a time-arithmetic library.
Adding a duration to a DTG
Shifts a point in time forward by a duration:Subtracting a duration from a DTG
Shifts a point in time backward. Natural number subtraction is used, so the result cannot precede the epoch (it saturates at 0):Duration between two DTGs
Returns the absolute time difference between two points in time:Like
Duration subtraction, DTG subtraction is symmetric: d₁ - d₂ = d₂ - d₁. It always yields the magnitude of the elapsed time between the two moments.Scaling a duration
Multiply a duration by a natural number:Interval
AnInterval represents a contiguous span of time bounded by a start DTG (inclusive) and an end DTG (exclusive). The empty interval is the degenerate case where starts = ends.
Structure definition
inv is a proof that ends is not earlier than starts, making it impossible to construct an ill-formed interval. The Inhabited default is the zero-length interval at the epoch:
∅ notation is also available for the empty interval:
Ordering
Two intervals are ordered by the relationi₁ < i₂ when i₁ ends no later than i₂ starts — that is, i₁ is strictly before i₂ with no overlap:
Interval.contains
Test whether a DTG falls within the interval. The start is inclusive; the end is exclusive:
Membership instance — enables dtg ∈ interval notation:
Interval.overlap
Test whether two intervals share at least one common point in time:
Interval.inter
The intersection of two intervals. If the intervals do not overlap the result is the empty (default) interval:
Inter instance — enables i₁ ∩ i₂ notation:
Interval.within
A proposition stating that i₁ is fully contained within i₂:
HasSubset instance — enables i₁ ⊆ i₂ notation:
⊆:
Interval.durationOf
Compute the length of an interval as a Duration. Because DTG - DTG returns the absolute difference and inv guarantees starts ≤ ends, the result equals ends - starts in seconds:
Interval.intervalOf
Construct the interval that begins at a given DTG and lasts for a given Duration: