Built with doc-gen4, running Lean4.
Bubbles () indicate interactive fragments: hover for details, tap to reveal contents.
Use Ctrl+βCtrl+βto navigate, Ctrl+π±οΈto focus.
On Mac, use Cmdinstead of Ctrl.
import Mathlib
/-!
## 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.
-/
/--
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.
-/
inductive
c
/-!
This has a solution if and only if the gcd of `a` and `b` divides `c`.
* If the gcd of `a` and `b` divides `c`, by Bezout's Lemma there are integers `x` and `y` such that `a * x + b * y = gcd a b`. Further, as `gcd a b` divides `c`, we have an integer `d` such that `(gcd a b) * d = c`. Then `x * d` and `y * d` are integers such that `a * (x * d) + b * (y * d) = c`.
* The converse follows as `gcd a b` divides `a` and `b`, hence `c = a * x + b * y`.
The main results we need are in the library. Here are most of them:
```lean
#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-/
```
-/
Int.gcd_dvd_left (i j : β€) : β(Int.gcd i j) β£ i
Int.gcd_dvd_left: β (i j : β€), β(Int.gcdij)β£i
Int.gcd_dvd_left -- β (i j : β€), β(Int.gcd i j) β£ i
Int.emod_add_ediv (a b : β€) : a % b + b * (a / b) = a
Int.emod_add_ediv: β (a b : β€), a%b+b* (a/b)=a
Int.emod_add_ediv -- β (a b : β€), a % b + b * (a / b) = a
Int.emod_eq_zero_of_dvd {a b : β€} (aβ : a β£ b) : b % a = 0
Int.emod_eq_zero_of_dvd: β {a b : β€}, aβ£b β b%a=0
Int.emod_eq_zero_of_dvd -- β {a b : β€}, a β£ b β b % a = 0
Int.gcd_eq_gcd_ab -- β (x y : β€), β(Int.gcd x y) = x * Int.gcdA x y + y * Int.gcdB x y
dvd_add.{u_1} {Ξ± : Type u_1} [instβ : Add Ξ±] [instβΒΉ : Semigroup Ξ±] [instβΒ² : LeftDistribClass Ξ±] {a b c : Ξ±}
(hβ : a β£ b) (hβ : a β£ c) : a β£ b + c
dvd_add /-β {Ξ± : Type u_1} [inst : Add Ξ±] [inst_1 : Semigroup Ξ±] [inst_2 : LeftDistribClass Ξ±] {a b c : Ξ±},
a β£ b β a β£ c β a β£ b + c-/
/--
Given `a b : β€` such that `b β£ a`, we return an integer `q` such that `a = b * q`.
-/
def
dvdQuotient: (a b : β€) β bβ£a β { q // a=b*q }