Documentation

PnP2023.Lec_03_08.Diaphontine

Linear Diaphontine Equations #

We solve linear diaphontine equations of the form a * x + b * y = c where a, b, c are integers if they have a solution with proof. Otherwise, we return a proof that there is no solution.

inductive DiaphontineSolution (a : ) (b : ) (c : ) :

Solution of the linear diaphontine equation a * x + b * y = c where a, b, c are integers or a proof that there is no solution.

Instances For

    This has a solution if and only if the gcd of a and b divides c.

    The main results we need are in the library. Here are most of them:

    #check Int.gcd_dvd_left -- ∀ (i j : ℤ), ↑(Int.gcd i j) ∣ i
    #check Int.emod_add_ediv -- ∀ (a b : ℤ), a % b + b * (a / b) = a
    #check Int.emod_eq_zero_of_dvd -- ∀ {a b : ℤ}, a ∣ b → b % a = 0
    #check Int.dvd_mul_right -- ∀ (a b : ℤ), a ∣ a * b
    #check Int.gcd_eq_gcd_ab -- ∀ (x y : ℤ), ↑(Int.gcd x y) = x * Int.gcdA x y + y * Int.gcdB x y
    #check dvd_add /-∀ {α : Type u_1} [inst : Add α] [inst_1 : Semigroup α] [inst_2 : LeftDistribClass α] {a b c : α},
      a ∣ b → a ∣ c → a ∣ b + c-/
    
    def dvdQuotient (a : ) (b : ) (h : b a) :
    { q // a = b * q }

    Given a b : ℤ such that b ∣ a, we return an integer q such that a = b * q.

    Instances For
      theorem eqn_solvable_divides (a : ) (b : ) (c : ) :
      (x y, a * x + b * y = c) → ↑(Int.gcd a b) c

      If a * x + b * y = c has a solution, then gcd a b divides c.

      Solution or proof there is no solution for a * x + b * y = c

      Instances For