# HG changeset patch # User Shinji KONO # Date 1624875068 -32400 # Node ID 186b66d56ab53d736582965eb7f6e508ded1381d # Parent 08994de7c82f4015cd5151281429623cf28910a8 ... diff -r 08994de7c82f -r 186b66d56ab5 automaton-in-agda/src/gcd.agda --- a/automaton-in-agda/src/gcd.agda Mon Jun 28 17:22:56 2021 +0900 +++ b/automaton-in-agda/src/gcd.agda Mon Jun 28 19:11:08 2021 +0900 @@ -330,6 +330,31 @@ ((suc i0 + suc j) - i0) ∎ ) div= ⟫ where open ≡-Reasoning +gcd>0 : ( i j : ℕ ) → 0 < i → 0 < j → 0 < gcd i j +gcd>0 i j 001 i i j j 001 : ( i i0 j j0 : ℕ ) → 0 < i0 → 0 < j0 → gcd1 i i0 j j0 > 0 + gcd>01 zero i0 zero j0 0 ¬a ¬b c = 001 zero i0 (suc zero) j0 001 zero zero (suc (suc j)) j0 001 zero (suc i0) (suc (suc j)) j0 001 i0 (suc i0) (suc j) (suc (suc j)) 001 (suc zero) i0 zero j0 001 (suc (suc i)) i0 zero zero 001 (suc (suc i)) i0 zero (suc j0) 001 (suc i) (suc (suc i)) j0 (suc j0) (s≤s z≤n) 001 (suc i) i0 (suc j) j0 001 i i0 j j0 0 (eqb * j) → ((eqa * i) - (eqb * j) ≡ gcd ) is-equ> : (eqb * j) > (eqa * i) → ((eqb * j) - (eqa * i) ≡ gcd ) -postulate - gcd-euclid : ( p q r : ℕ ) → 1 < p → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → Dividable p (q * r) → Dividable p q ∨ Dividable p r --- gcd-euclid1 : ( i i0 j j0 : ℕ ) → Dividable i0 ((j0 + i) - j ) ∧ Dividable j0 ((i0 + j) - i) → Euclid i0 j0 (gcd1 i i0 j j0) - ge3 : {a b c d : ℕ } → b > a → b - a ≡ d - c → d > c ge3 {a} {b} {c} {d} b>a eq = minus>0→x0 b>a)) @@ -634,6 +667,53 @@ gcd-euclid1 (suc i) i0 j j0 (gcd-next di) +gcd-euclid : ( p a b : ℕ ) → 1 < p → 0 < a → 0 < b → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → Dividable p (a * b) → Dividable p a ∨ Dividable p b +gcd-euclid p a b 1

a (s≤s (gcd>0 p x (<-trans a ¬a ¬b c = ⊥-elim ( nat-≡< (sym (prime (gcd p x) {!!} (gcd>0 p x (<-trans a ( Euclid.eqb ge11 * a ) → (Dividable.factor div-ab * Euclid.eqb ge11 - b * Euclid.eqa ge11 ) * p + 0 ≡ b + ge15 = {!!} + ge16 : Dividable p b + ge16 with <-cmp ( Euclid.eqa ge11 * p ) ( Euclid.eqb ge11 * a ) + ... | tri< a ¬b ¬c = record { factor = b * Euclid.eqa ge11 - Dividable.factor div-ab * Euclid.eqb ge11 ; is-factor = ge14 {!!} } + ... | tri≈ ¬a eq ¬c = record { factor = b * Euclid.eqa ge11 - Dividable.factor div-ab * Euclid.eqb ge11 ; is-factor = ge14 {!!} } + ... | tri> ¬a ¬b c = record { factor = Dividable.factor div-ab * Euclid.eqb ge11 - b * Euclid.eqa ge11 ; is-factor = ge15 {!!} } + + div→gcd : {n k : ℕ } → k > 1 → Dividable k n → gcd n k ≡ k div→gcd {n} {k} k>1 = n-induction {_} {_} {ℕ} {λ m → Dividable k m → gcd m k ≡ k } (λ x → x) I n where decl : {m : ℕ } → 0 < m → m - k < m @@ -679,31 +759,6 @@ gcd (m * n + 1) n ≡⟨ gcdmul+1 m n ⟩ 1 ∎ where open ≡-Reasoning -gcd>0 : ( i j : ℕ ) → 0 < i → 0 < j → 0 < gcd i j -gcd>0 i j 001 i i j j 001 : ( i i0 j j0 : ℕ ) → 0 < i0 → 0 < j0 → gcd1 i i0 j j0 > 0 - gcd>01 zero i0 zero j0 0 ¬a ¬b c = 001 zero i0 (suc zero) j0 001 zero zero (suc (suc j)) j0 001 zero (suc i0) (suc (suc j)) j0 001 i0 (suc i0) (suc j) (suc (suc j)) 001 (suc zero) i0 zero j0 001 (suc (suc i)) i0 zero zero 001 (suc (suc i)) i0 zero (suc j0) 001 (suc i) (suc (suc i)) j0 (suc j0) (s≤s z≤n) 001 (suc i) i0 (suc j) j0 001 i i0 j j0 0