提交信息
题目#6. 模同余相关性质和中国剩余定理证明
提交者jkjkmxmx
状态Unaccepted
分数0
提交时间2026/02/13 20:49:43
源代码
import Mathlib.Data.Int.GCD
import Mathlib.Tactic.Convert
import Mathlib.Tactic.Ring

local notation " ( " a " ≡ " b " mod " n " ) " => n ∣ a - b

theorem modulo_tran (a b c n : ℤ) (hab : (a ≡ b mod n)) (hbc : (b ≡ c mod n)) : (a ≡ c mod n) := by
  convert Int.dvd_add hab hbc using 1
  ring

theorem Int.dvd_mul_of_dvd_left {a b c : Int} (h : a ∣ b) : a ∣ b * c :=
  Int.dvd_trans h (Int.dvd_mul_right b c)

theorem modulo_mult_subst (a b c n : ℤ) (hab : (a ≡ b mod n)) : (a * c ≡ b * c mod n) := by
  convert Int.dvd_mul_of_dvd_left hab (c := c) using 1
  ring

theorem modulo_inv (m n : ℤ) (p : m.gcd n = 1) : ∃ x : ℤ, (m * x ≡ 1 mod n) := by
  refine ⟨m.gcdA n, ?_⟩
  have h := m.gcd_eq_gcd_ab n
  rw [p, Nat.cast_one] at h
  rw [h]
  simp

theorem SimpleChineseRemainder (m n : ℤ) (p : m.gcd n = 1) (a b : ℤ) : ∃ x : ℤ, (x ≡ a mod m) ∧ (x ≡ b mod n) := by
  refine ⟨m * m.gcdA n * b + n * m.gcdB n * a, ?_, ?_⟩
  · refine modulo_tran _ (m * m.gcdA n * a + n * m.gcdB n * a) _ m ?_ ?_
    · ring
      apply Int.dvd_sub <;> simp [Int.mul_assoc]
    · rw [← Int.add_mul, ← m.gcd_eq_gcd_ab n, p]
      simp
  · refine modulo_tran _ (m * m.gcdA n * b + n * m.gcdB n * b) _ n ?_ ?_
    · ring
      apply Int.dvd_add
      · simp
        rw [Int.mul_right_comm]
        simp
      · simp [Int.mul_assoc]
    · rw [← Int.add_mul, ← m.gcd_eq_gcd_ab n, p]
      simp

theorem P₅₀₅ :
  (∀ (a b c n : ℤ), (a ≡ b mod n) → (b ≡ c mod n) → (a ≡ c mod n)) ∧
  (∀ (a b c n : ℤ), (a ≡ b mod n) → (a * c ≡ b * c mod n)) ∧
  (∀ (m n : ℤ), m.gcd n = 1 → ∃ x : ℤ, (m * x ≡ 1 mod n)) ∧
  (∀ (m n : ℤ), m.gcd n = 1 → ∀ (a b : ℤ), ∃ x : ℤ, (x ≡ a mod m) ∧ (x ≡ b mod n)) :=
  ⟨modulo_tran, modulo_mult_subst, modulo_inv, SimpleChineseRemainder⟩
评测详情
compilecompile_problem
711 ms1091 MBOK
Built: problem
输出 (stdout / stderr)
[lean -o] /work/problem.lean:11:4: warning: declaration uses 'sorry'
/work/problem.lean:20:4: warning: declaration uses 'sorry'
/work/problem.lean:28:8: warning: declaration uses 'sorry'
/work/problem.lean:33:8: warning: declaration uses 'sorry'

[lean -c] /work/problem.lean:11:4: warning: declaration uses 'sorry'
/work/problem.lean:20:4: warning: declaration uses 'sorry'
/work/problem.lean:28:8: warning: declaration uses 'sorry'
/work/problem.lean:33:8: warning: declaration uses 'sorry'
compilecompile_usersol
882 ms1087 MBOK
Built: UserSol
输出 (stdout / stderr)
[lean -o] Try this: ring_nf
Try this: ring_nf

[lean -c] Try this: ring_nf
Try this: ring_nf
gradegrade
1179 ms1534 MBOK
Score: 0
输出 (stdout / stderr)
{"score": 0, "passed": false, "status": "wrong_answer", "subtasks": [{"id": 1, "name": "modulo_tran", "score": 0, "passed": false, "msg": "Kernel rejected"}, {"id": 2, "name": "modulo_mult_subst", "score": 0, "passed": false, "msg": "Kernel rejected"}, {"id": 3, "name": "modulo_inv", "score": 0, "passed": false, "msg": "Kernel rejected"}, {"id": 4, "name": "SimpleChineseRemainder", "score": 0, "passed": false, "msg": "Kernel rejected"}]}
评测结果
评分
Failed0
测试点结果信息得分
#1 modulo_tranWrong AnswerKernel rejected0
#2 modulo_mult_substWrong AnswerKernel rejected0
#3 modulo_invWrong AnswerKernel rejected0
#4 SimpleChineseRemainderWrong AnswerKernel rejected0