Verify date calculations #
Main theorems:
Get next_date of dt:
- if
dt.Dayis less then days indt.Monththen add 1 todt.Day, - else if
dt.Monthless then 12 then add 1 todt.Monthand setdt.Dayto 1, - else add 1 to
dt.Yearand setdt.Dayanddt.Monthto 1.
See UTC Time, Formally Verified.
Equations
- One or more equations did not get rendered due to their size.
Instances For
the default values of Date and Day are january 1 of year 1 and should be equal.
theorem
Verify.Gregorian.next_date_of_day_lt_eq'
{dt : Time.Date}
{dy : Nat}
{ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt }}
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : dt.Day.val < ml.val.snd)
(heq : Time.dy' false dt.Month dt.Day = dy)
(hl : Time.isLeapYear dt.Year = false)
:
theorem
Verify.Gregorian.next_date_of_day_lt_eq''
{dt : Time.Date}
{dy : Nat}
{ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt }}
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : dt.Day.val < ml.val.snd)
(heq : Time.dy' true dt.Month dt.Day = dy)
(hl : Time.isLeapYear dt.Year = true)
:
theorem
Verify.Gregorian.next_date_of_day_lt_eq
(dt : Time.Date)
(ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt })
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : dt.Day.val < ml.val.snd)
:
{ Year := dt.Year, Month := dt.Month, Day := ⟨dt.Day.val + 1, ⋯⟩, IsValid := ⋯ } = Time.ordinalDateToDate (OrdinalDate.next_date (Time.dateToOrdinalDate dt))
theorem
Verify.Gregorian.next_date_of_last_day_of_month_eq'
{simp : 1 ≤ 1 ∧ 1 ≤ 31}
{dt : Time.Date}
{dy : Nat}
{ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt }}
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : dt.Day.val = ml.val.snd)
(hm : dt.Month.val < 12)
(heq : Time.dy' false dt.Month dt.Day = dy)
(hl : Time.isLeapYear dt.Year = false)
:
theorem
Verify.Gregorian.next_date_of_last_day_of_month_eq''
{simp : 1 ≤ 1 ∧ 1 ≤ 31}
{dt : Time.Date}
{dy : Nat}
{ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt }}
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : dt.Day.val = ml.val.snd)
(hm : dt.Month.val < 12)
(heq : Time.dy' true dt.Month dt.Day = dy)
(hl : Time.isLeapYear dt.Year = true)
:
theorem
Verify.Gregorian.next_date_of_last_day_of_month_eq
{simp : 1 ≤ 1 ∧ 1 ≤ 31}
(dt : Time.Date)
(ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt })
(hml : ml = MonthLength.monthLengths_of_date dt)
(h : ¬dt.Day.val < ml.val.snd)
(hm : dt.Month.val < 12)
:
{ Year := dt.Year, Month := ⟨dt.Month.val + 1, ⋯⟩, Day := ⟨1, simp⟩, IsValid := ⋯ } = Time.ordinalDateToDate (OrdinalDate.next_date (Time.dateToOrdinalDate dt))
theorem
Verify.Gregorian.next_date_of_last_day_of_year_eq
(dt : Time.Date)
(ml : { m : Nat × Nat // MonthLength.monthLengthsOfDate m dt })
(hml : ml = MonthLength.monthLengths_of_date dt)
(h1 : ¬dt.Day.val < ml.val.snd)
(h2 : ¬dt.Month.val < 12)
:
{ Year := dt.Year + 1, Month := ⟨1, ⋯⟩, Day := ⟨1, ⋯⟩, IsValid := ⋯ } = Time.ordinalDateToDate (OrdinalDate.next_date (Time.dateToOrdinalDate dt))
Verify.Gregorian.next_date transforms to Verify.OrdinalDate.next_date
Verify.Gregorian.next_date transforms to Time.Day.addDays 1.
Verify.Gregorian.next_date equals to Time.Gregorian.addDays 1.