Skip to content

Commit c2b8057

Browse files
committed
start working on the proof
1 parent 773368f commit c2b8057

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

HumanEvalLean/HumanEval75.lean

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,39 @@ example : isMultiplyPrime (9 * 9 * 9) = false := by native_decide
3535
example : isMultiplyPrime (11 * 9 * 9) = false := by native_decide
3636
example : isMultiplyPrime (11 * 13 * 7) = true := by native_decide
3737

38-
3938
def Nat.IsPrime (n : Nat) : Prop :=
4039
n > 1 ∧ ∀ m, m ∣ n → m = 1 ∨ m = n
4140

4241
def IsMultiplyPrimeIff (solution : Nat → Bool) : Prop :=
4342
(a : Nat) → solution a ↔ ∃ (p₁ p₂ p₃ : Nat), p₁ * p₂ * p₃ = a ∧ Nat.IsPrime p₁ ∧ Nat.IsPrime p₂ ∧ Nat.IsPrime p₃
4443

44+
-- https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/BigOperators/Group/List/Defs.html#List.prod
45+
def List.prod {α} [Mul α] [One α] : List α → α :=
46+
List.foldr (· * ·) 1
47+
48+
structure PrimeDecomposition (n : Nat) where
49+
-- Multiset is only available in mathlib, using List instead
50+
ps : List Nat
51+
all_prime : ∀ p ∈ ps, p.IsPrime
52+
is_decomposition : ps.prod = n
53+
54+
def PrimeDecomposition.length (d : PrimeDecomposition n) : Nat := d.ps.length
55+
56+
theorem isMultipleOfKPrimes_primeDecompositionLength (n k : Nat) :
57+
isMultipleOfKPrimes n k ↔ ∃ (d : PrimeDecomposition n), d.length = k := by
58+
59+
60+
sorry
61+
62+
theorem primeDecomposition_length_3 (n : Nat) :
63+
(∃ (p₁ p₂ p₃ : Nat), p₁ * p₂ * p₃ = n ∧ Nat.IsPrime p₁ ∧ Nat.IsPrime p₂ ∧ Nat.IsPrime p₃)
64+
↔ ∃ (d : PrimeDecomposition n), d.length = 3 := by
65+
sorry
66+
4567
theorem isMultiplyPrime_is_correct : IsMultiplyPrimeIff isMultiplyPrime := by
4668
intro a
47-
constructor
48-
· sorry
49-
· sorry
69+
rw [primeDecomposition_length_3 a]
70+
simp [isMultiplyPrime, isMultipleOfKPrimes_primeDecompositionLength]
5071

5172
/-!
5273
## Prompt

0 commit comments

Comments
 (0)