File size: 775 Bytes
bff4ec7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import AUXLib.ListLib
import AUXLib.Prime
namespace Algorithms.integer_divide.lean
open AUXLib
export AUXLib.Prime (prime)
inductive HdRel {A : Type u} (R : A → A → Prop) (a : A) : List A → Prop where
| HdRel_nil : HdRel R a []
| HdRel_cons (b : A) (l : List A) : R a b → HdRel R a (b :: l)
inductive Sorted {A : Type u} (R : A → A → Prop) : List A → Prop where
| Sorted_nil : Sorted R []
| Sorted_cons (a : A) (l : List A) : Sorted R l → HdRel R a l → Sorted R (a :: l)
def PrimeFactorization (original : Int) (factors : List Int) : Prop :=
Forall prime factors ∧ Sorted (· ≤ ·) factors ∧
factors.foldr (· * ·) 1 = original ∧
∀ q : Int, q ∈ factors ↔ prime q ∧ Z.divide q original
end Algorithms.integer_divide.lean
|