------------------------------------------------------------------------ -- The Agda standard library -- -- Core definition of divisibility ------------------------------------------------------------------------ -- The definition of divisibility is split out from -- `Data.Nat.Divisibility` to avoid a dependency cycle with -- `Data.Nat.DivMod`. {-# OPTIONS --without-K --safe #-} module Data.Nat.Divisibility.Core where open import Data.Nat.Base using (ℕ; _*_) open import Data.Nat.Properties open import Level using (0ℓ) open import Relation.Nullary using (¬_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym) ------------------------------------------------------------------------ -- Definition -- -- m ∣ n is inhabited iff m divides n. Some sources, like Hardy and -- Wright's "An Introduction to the Theory of Numbers", require m to -- be non-zero. However, some things become a bit nicer if m is -- allowed to be zero. For instance, _∣_ becomes a partial order, and -- the gcd of 0 and 0 becomes defined. infix 4 _∣_ _∤_ record _∣_ (m n : ℕ) : Set where constructor divides field quotient : ℕ equality : n ≡ quotient * m open _∣_ using (quotient) public _∤_ : Rel ℕ 0ℓ m ∤ n = ¬ (m ∣ n)