Skip to content

Commit

Permalink
feat: more useful Int/Rat lemmas
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienChampion committed Jul 22, 2024
1 parent 180678d commit eb8dbc1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Smt/Reconstruct/Int/Core.lean
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ protected theorem dvd_mul_left_of_dvd {i j : Int} (k : Int) : i ∣ j → i ∣
Int.mul_assoc i k n,
]

protected theorem natAbs_gcd_dvd {i : Int} {n : Nat} : ↑(i.natAbs.gcd n) ∣ i := by
refine ofNat_dvd_left.mpr ?_
exact Nat.gcd_dvd_left _ _

protected theorem natAbs_gcd_dvd' (i : Int) (n : Nat) : ↑(i.natAbs.gcd n) ∣ i :=
Int.natAbs_gcd_dvd

protected theorem dvd_mul_right_of_dvd {i j : Int} (k : Int) : i ∣ j → i ∣ j * k :=
Int.mul_comm j k ▸ Int.dvd_mul_left_of_dvd k

Expand Down
20 changes: 20 additions & 0 deletions Smt/Reconstruct/Rat/Core.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ theorem num_divInt_den (q : Rat) : q.num /. q.den = q :=
theorem mk'_eq_divInt {n d h c} : (⟨n, d, h, c⟩ : Rat) = n /. d :=
(num_divInt_den _).symm

theorem divInt_num (q : Rat) : (q.num /. q.den).num = q.num := by
simp [mkRat, q.den_nz, normalize, Rat.reduced]

theorem divInt_num'
{n : Int} {d : Nat}
(nz_d : d ≠ 0 := by omega)
(reduced : n.natAbs.Coprime d := by assumption)
: (n /. d).num = n := by
simp [mkRat, nz_d, normalize, reduced]

theorem divInt_den (q : Rat) : (q.num /. q.den).den = q.den := by
simp [mkRat, q.den_nz, normalize, Rat.reduced]

theorem divInt_den'
{n : Int} {d : Nat}
(nz_d : d ≠ 0 := by omega)
(reduced : n.natAbs.Coprime d := by assumption)
: (n /. d).den = d := by
simp [mkRat, nz_d, normalize, reduced]

@[elab_as_elim]
def numDenCasesOn.{u} {C : Rat → Sort u}
: ∀ (a : Rat) (_ : ∀ n d, 0 < d → (Int.natAbs n).Coprime d → C (n /. d)), C a
Expand Down

0 comments on commit eb8dbc1

Please sign in to comment.