2014-08-21 17:56:18 -07:00
|
|
|
|
import logic data.nat data.prod
|
|
|
|
|
|
2014-09-03 16:00:38 -07:00
|
|
|
|
open nat prod
|
|
|
|
|
open decidable
|
2014-08-21 17:56:18 -07:00
|
|
|
|
|
2015-10-13 15:39:03 -07:00
|
|
|
|
constant modulo1 (x : ℕ) (y : ℕ) : ℕ
|
2015-10-29 15:36:26 -04:00
|
|
|
|
infixl `mod`:70 := modulo1
|
2014-08-21 17:56:18 -07:00
|
|
|
|
|
2014-10-02 16:20:52 -07:00
|
|
|
|
constant gcd_aux : ℕ × ℕ → ℕ
|
2014-08-21 17:56:18 -07:00
|
|
|
|
|
|
|
|
|
definition gcd (x y : ℕ) : ℕ := gcd_aux (pair x y)
|
|
|
|
|
|
2014-09-07 22:22:04 -07:00
|
|
|
|
theorem gcd_def (x y : ℕ) : gcd x y = @ite (y = 0) (nat.has_decidable_eq (pr2 (pair x y)) 0) nat x (gcd y (x mod y)) :=
|
2014-08-21 17:56:18 -07:00
|
|
|
|
sorry
|
|
|
|
|
|
|
|
|
|
theorem gcd_succ (m n : ℕ) : gcd m (succ n) = gcd (succ n) (m mod succ n) :=
|
2014-10-01 18:50:17 -07:00
|
|
|
|
eq.trans (gcd_def _ _) (if_neg !succ_ne_zero)
|