Verify date calculations #
Main theorems:
Get next_date of dt
:
- if
dt.dayOfYear
is less then days indt.year
then add 1 todt.dayOfYear
, - else add 1 to
dt.Year
and setdt.dayOfYear
to 1.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Verify.OrdinalDate.DayOfYear.lt_top (Time.DayOfYear.common ⟨dy, property⟩) = decide (dy < 365)
- Verify.OrdinalDate.DayOfYear.lt_top (Time.DayOfYear.leap ⟨dy, property⟩) = decide (dy < 366)
Instances For
def
Verify.OrdinalDate.DayOfYear.incr
(dt : Time.OrdinalDate)
(h : Verify.OrdinalDate.DayOfYear.lt_top dt.dayOfYear = true)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Verify.OrdinalDate.icc_eq
(dt : Time.OrdinalDate)
(a : Time.Icc 1 365)
(h : dt.dayOfYear = Time.DayOfYear.common a)
:
⟨a.val, ⋯⟩ = match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d
theorem
Verify.OrdinalDate.icc_eq'
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
(h : dt.dayOfYear = Time.DayOfYear.leap a)
:
a = match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d
theorem
Verify.OrdinalDate.val_eq
(dt : Time.OrdinalDate)
(a : Time.Icc 1 365)
(h : dt.dayOfYear = Time.DayOfYear.common a)
:
a.val = (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val
theorem
Verify.OrdinalDate.val_eq'
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
(h : dt.dayOfYear = Time.DayOfYear.leap a)
:
a.val = (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val
theorem
Verify.OrdinalDate.mjd_incr_eq_next_date
(dt : Time.OrdinalDate)
:
(Time.fromOrdinalDate (Verify.OrdinalDate.next_date dt)).modifiedJulianDay = (Time.fromOrdinalDate dt).modifiedJulianDay + 1
Equations
- Verify.OrdinalDate.days_in_100_years_without_year_divisible_by_400 = 76 * 365 + 24 * 366
Instances For
Equations
- Verify.OrdinalDate.days_since_1_1_1 dt a = Time.toModifiedJulianDay dt.year a.val - default.modifiedJulianDay
Instances For
Equations
Instances For
Equations
- Verify.OrdinalDate.days_since_1_1_1_mod_146097' dt a = Verify.OrdinalDate.days_since_1_1_1 dt a - (dt.year - 1) / 400 * 146097
Instances For
theorem
Verify.OrdinalDate.days_in_400_years_sub_one_eq_mul
(n : Int)
:
Verify.OrdinalDate.days_in_years_sub_one (n * 400) = n * 146096
theorem
Verify.OrdinalDate.days_in_400_years_sub_one_eq_mod
(n : Int)
:
Verify.OrdinalDate.days_in_years_sub_one (n * 400) % 146096 = 0
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_le
(dt : Time.OrdinalDate)
:
0 ≤ Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d)
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_lt
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) < 146097
theorem
Verify.OrdinalDate.days_since_1_1_1_mul_mod
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
:
Verify.OrdinalDate.days_since_1_1_1 dt a = (dt.year - 1) / 400 * 146097 + Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt a
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_div_eq_zero
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) / 146097 = 0
Equations
- Verify.OrdinalDate.quadcent dt = (dt.year - 1) / 400
Instances For
theorem
Verify.OrdinalDate.days_since_1_1_1_div_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.days_since_1_1_1 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) / 146097 = Verify.OrdinalDate.quadcent dt
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.days_since_1_1_1 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) % 146097 = Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d)
Equations
- Verify.OrdinalDate.cent dt = (dt.year - 1 - Verify.OrdinalDate.quadcent dt * 400) / 100
Instances For
def
Verify.OrdinalDate.days_since_1_1_1_mod_146097_mod_36524
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_mul_mod
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
:
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_mod_36524_le
(dt : Time.OrdinalDate)
:
0 ≤ Verify.OrdinalDate.days_since_1_1_1_mod_146097_mod_36524 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d)
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_mod_36524_lt
(dt : Time.OrdinalDate)
(h :
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366))
:
Verify.OrdinalDate.days_since_1_1_1_mod_146097_mod_36524 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) < 36524
theorem
Verify.OrdinalDate.days_since_1_1_1_mod_146097_div_eq
(dt : Time.OrdinalDate)
(h :
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366))
:
Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) / 36524 = Verify.OrdinalDate.cent dt
theorem
Verify.OrdinalDate.cent_eq
(dt : Time.OrdinalDate)
(h :
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366))
:
Verify.OrdinalDate.cent dt = Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) / 36524
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Verify.OrdinalDate.quad dt = (dt.year - 1 - Verify.OrdinalDate.quadcent dt * 400 - Verify.OrdinalDate.cent dt * 100) / 4
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Verify.OrdinalDate.year_of_dt_with_day_one_eq
(dt : Time.OrdinalDate)
:
dt.year = (Verify.OrdinalDate.dt_with_day_one dt).year
theorem
Verify.OrdinalDate.dayOfYear_of_dt_with_day_one_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.dayOfYear_with_day_one dt = (Verify.OrdinalDate.dt_with_day_one dt).dayOfYear
theorem
Verify.OrdinalDate.dayOfYear_of_dt_with_day_one_val_eq
(dt : Time.OrdinalDate)
:
(match Verify.OrdinalDate.dayOfYear_with_day_one dt with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 1
theorem
Verify.OrdinalDate.c_value_of_dt_with_day_one_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.c_value (Verify.OrdinalDate.dt_with_day_one dt) = (dt.year - 1) % 4 * 365 + Verify.OrdinalDate.c_value_factor dt * 1461
theorem
Verify.OrdinalDate.c_value_add_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.c_value dt = Verify.OrdinalDate.c_value (Verify.OrdinalDate.dt_with_day_one dt) + ↑(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - 1
Equations
- Verify.OrdinalDate.c_mod_1461 dt = Verify.OrdinalDate.c dt - Verify.OrdinalDate.quad dt * 1461
Instances For
Equations
- Verify.OrdinalDate.d' dt = Verify.OrdinalDate.c dt % 1461
Instances For
theorem
Verify.OrdinalDate.c_div_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.c (Verify.OrdinalDate.dt_with_day_one dt) / 1461 = Verify.OrdinalDate.c dt / 1461
theorem
Verify.OrdinalDate.c_div_eq_quad
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.c dt / 1461 = Verify.OrdinalDate.quad dt
theorem
Verify.OrdinalDate.year_eq_if_mod_eq_146096
(dt : Time.OrdinalDate)
(a : Time.Icc 1 366)
(h : Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt a = 146096)
:
theorem
Verify.OrdinalDate.mod_lt_146096_eq
(dt : Time.OrdinalDate)
(h :
Verify.OrdinalDate.days_since_1_1_1_mod_146097 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) < 146096)
:
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366)
theorem
Verify.OrdinalDate.d'_add_eq
(dt : Time.OrdinalDate)
:
Verify.OrdinalDate.d' dt = (dt.year - 1) % 4 * 365 + ↑(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - 1
theorem
Verify.OrdinalDate.days_eq_1460_mod_4_eq
(dt : Time.OrdinalDate)
(hmod : Verify.OrdinalDate.d' dt = 1460)
:
theorem
Verify.OrdinalDate.day_eq_if_days_eq_1460
(dt : Time.OrdinalDate)
(hmod : Verify.OrdinalDate.d' dt = 1460)
:
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366
theorem
Verify.OrdinalDate.year_eq_if_days_eq_1460
(dt : Time.OrdinalDate)
(hmod : Verify.OrdinalDate.d' dt = 1460)
:
Verify.OrdinalDate.quadcent dt * 400 + Verify.OrdinalDate.cent dt * 100 + Verify.OrdinalDate.quad dt * 4 + 4 = dt.year
theorem
Verify.OrdinalDate.year_lt_mod_1460_eq
(dt : Time.OrdinalDate)
(hNot :
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366))
:
(Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) / 146097 * 400 + (Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) % 146097 / 36524 * 100 + ((Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) % 146097 - (Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) % 146097 / 36524 * 36524) / 1461 * 4 + ((Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) % 146097 - (Time.toModifiedJulianDay dt.year
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val - default.modifiedJulianDay) % 146097 / 36524 * 36524) % 1461 / 365 + 1 = Verify.OrdinalDate.quadcent dt * 400 + Verify.OrdinalDate.cent dt * 100 + Verify.OrdinalDate.quad dt * 4 + Verify.OrdinalDate.d' dt / 365 + 1
theorem
Verify.OrdinalDate.d'_eq
(dt : Time.OrdinalDate)
(h :
¬(dt.year % 400 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366))
:
(Verify.OrdinalDate.days_since_1_1_1 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) % 146097 - Verify.OrdinalDate.days_since_1_1_1 dt
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d) % 146097 / 36524 * 36524) % 1461 = Verify.OrdinalDate.d' dt
theorem
Verify.OrdinalDate.d'_lt_1460_eq
(dt : Time.OrdinalDate)
(hlt : Verify.OrdinalDate.d' dt < 1460)
:
¬(dt.year % 4 = 0 ∧ (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val = 366)
theorem
Verify.OrdinalDate.d'_lt_1460_lt
(dt : Time.OrdinalDate)
(hlt : Verify.OrdinalDate.d' dt < 1460)
:
(match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val < 366
theorem
Verify.OrdinalDate.d'_lt_1460_eq_year
(dt : Time.OrdinalDate)
(hlt : Verify.OrdinalDate.d' dt < 1460)
:
Verify.OrdinalDate.quadcent dt * 400 + Verify.OrdinalDate.cent dt * 100 + Verify.OrdinalDate.quad dt * 4 + Verify.OrdinalDate.d' dt / 365 + 1 = dt.year
theorem
Verify.OrdinalDate.d'_lt_1460_eq_day_common
{a : Time.Icc 1 365}
(dt : Time.OrdinalDate)
(h : dt.dayOfYear = Time.DayOfYear.common a)
:
(Verify.OrdinalDate.d' dt % 365 + 1).toNat = (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val
theorem
Verify.OrdinalDate.d'_lt_1460_eq_day_leap
{a : Time.Icc 1 366}
(dt : Time.OrdinalDate)
(h : dt.dayOfYear = Time.DayOfYear.leap a)
(hlt : Verify.OrdinalDate.d' dt < 1460)
:
(Verify.OrdinalDate.d' dt % 365 + 1).toNat = (match dt.dayOfYear with
| Time.DayOfYear.common d => ⟨d.val, ⋯⟩
| Time.DayOfYear.leap d => d).val
Verify.OrdinalDate.next_date
equals to Time.OrdinalDate.addDays
1.
Verify.OrdinalDate.next_date
transforms to Time.Day.addDays
1.