数学中国

 找回密码
 注册
搜索
热搜: 活动 交友 discuz
查看: 51|回复: 1
打印 上一主题 下一主题

Lean4验证崔坤恒等式及其r2(N)≥1的源代码

[复制链接]
跳转到指定楼层
1#
发表于 2026-11-22 12:28 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
Lean4验证崔坤恒等式及其r2(N)≥1的源代码
作者:崔坤
单位:独立研究员
第一:崔坤恒等式:r2(N)+N/2 = C(N)+2π(N-3)
其中偶数N≥6,π(N-3)是不超过N-3的所有素数的个数。
r2(N)为有序奇素数对个数,C(N)为有序奇合数对个数。
第二:Lean4验证崔坤恒等式及其r2(N)≥1的源代码
import Mathlib.Data.Nat.Prime
import Mathlib.Data.Finset.Filter
import Mathlib.Tactic
namespace CuiKun
def isPrime : Nat → Bool
| 0 => false
| 1 => false
| n + 2 =>
let rec aux : Nat → Bool
| 0 => true
| d + 1 => (n + 2) % (d + 2) ≠ 0 && aux d
aux n
def isOdd (n : Nat) : Bool := n % 2 = 1
def isOddPrime (n : Nat) : Bool := isOdd n && isPrime n
def isOddComposite (n : Nat) : Bool := isOdd n && 1 < n && !isPrime n
def pi (x : Nat) : Nat :=
(Finset.range (x + 1)).filter (fun i => isPrime i) |>.card
def r2 (N : Nat) : Nat :=
(Finset.range (N + 1)).filter (fun p => isOddPrime p && isOddPrime (N - p)) |>.card
def C (N : Nat) : Nat :=
(Finset.range (N + 1)).filter (fun a => isOddComposite a && isOddComposite (N - a)) |>.card
def checkIdentity (N : Nat) : Bool :=
if h : N % 2 = 0 ∧ 6 ≤ N then
r2 N + N / 2 = C N + 2 * pi (N - 3)
else true
def checkR2Ge1 (N : Nat) : Bool :=
if h : N % 2 = 0 ∧ 6 ≤ N then r2 N ≥ 1 else true
def checkR2Min (N : Nat) : Bool :=
if h : N % 2 = 0 ∧ 6 ≤ N then r2 N ≥ r2 6 else true
def verifyUpTo (M : Nat) : Bool :=
(Finset.range (M + 1)).all (fun N => checkIdentity N && checkR2Ge1 N && checkR2Min N)
example : verifyUpTo 2000 := by decide
example : r2 6 = 1 := by decide
example : r2 8 = 2 := by decide
example : checkIdentity 6 := by decide
example : checkIdentity 8 := by decide
example : checkR2Ge1 6 := by decide
example : checkR2Ge1 8 := by decide
end CuiKun
2#
 楼主| 发表于 2026-11-22 20:36 | 显示全部楼层
111111111111111
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|数学中国 ( 京ICP备05040119号 )

GMT+8, 2026-11-25 00:48 , Processed in 0.685704 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表