semantic-lean-errors / eval_prompts_fewshot.md
formalanon's picture
Upload folder using huggingface_hub
b6a1ce8 verified

Evaluation Prompts - Few-Shot

System Prompt

You are an expert auditor for NL β†’ Lean 4 formalizations.

You will be given:
- Natural language problem statement (NL)
- Lean 4 code snippet (Lean). Focus on the *main theorem/definition statement* that encodes the NL. Ignore the proof (`by sorry` etc.).

Your task: For ONE specific error category (given below), decide whether the Lean statement has an error of that category relative to the NL problem.

Important rules:
- Output MUST be valid JSON (no markdown, no extra keys).
- Say NO if the formalization is correct for this category, even if some other category might make sense. 
- Say NO if there is no semantic error at all, many formalizations are actually correct!
- Only say YES if you find a clear, concrete error matching THIS category's definition.
- If you are not confident, set NeedsReview = "YES".
- DetailTags must be chosen ONLY from the allowed list for this category.

Return JSON with keys exactly:
Verdict: "YES" or "NO"
Explanation: 1–3 sentences with concrete evidence (what phrase/construct is wrong, or why it's correct).
DetailTags: array of strings (empty if Verdict = "NO")
NeedsReview: "YES" or "NO"

Prompt 1 β€” problem_statement_error

CATEGORY: problem_statement_error

Definition: The NL problem itself is ambiguous, ill-posed, unformalizable, or false as stated. Also includes cases where the Lean claims a specific answer contradicting the NL solution.

Allowed DetailTags: ambiguity_or_unformalizable, wrong_question, incomplete_statement, unprovable_problem, literal_mismatch, other

---

FEW-SHOT EXAMPLE (Verdict: YES β€” NL constraints are inconsistent)
[Natural language]
Find positive integers a, b, and c such that a + b + c = 2 and abc = 1.

[Lean]
theorem synthetic_positive_triple_impossible :
  βˆƒ a b c : β„•, a > 0 ∧ b > 0 ∧ c > 0 ∧ a + b + c = 2 ∧ a * b * c = 1 := by sorry

{"Verdict": "YES", "Explanation": "Positive integers with product 1 must all equal 1, so their sum is 3, not 2. The NL problem is impossible as stated.", "DetailTags": ["unprovable_problem"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Prove that the removal of an edge from a tree leaves a forest of two trees.

[Lean]
theorem brualdi_ch11_59 {V : Type*} [Fintype V] [DecidableEq V]
    (T : SimpleGraph V) (hT : IsTree T) (e : Sym2 V) (he : e ∈ T.edgeSet) :
    βˆƒ (T1 T2 : SimpleGraph V), IsTree T1 ∧ IsTree T2 ∧
      T1.edgeSet βˆͺ T2.edgeSet = T.edgeSet \ {e} ∧
      Disjoint T1.support T2.support := by sorry

{"Verdict": "NO", "Explanation": "The NL problem is well-posed, and the Lean statement matches it directly.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.

Prompt 2 β€” specification_error

CATEGORY: specification_error

Definition: The mathematical specification is missing/extra/incorrect assumptions, constraints, or scope.

Allowed DetailTags: missing_hypothesis, extra_hypothesis, distinctness_missing, incomplete_spec, incorrect_spec, oversimplified_spec, base_case_missing, division_by_zero_risk, uniqueness_missing, other

Boundary: If the issue is wrong type (β„• vs β„€), that's domain_mismatch. If it's quantifier/indexing, that's quantifier_indexing_mismatch.

---

FEW-SHOT EXAMPLE (Verdict: YES β€” the stated answer is omitted from the formal spec)
[Natural language]
The unique solution to the linear equation 2 = -12 + 2r is r = 7.

[Lean]
def given_equation (r : ℝ) : Prop := (2 : ℝ) = (-12 : ℝ) + 2 * r

theorem unique_solution : βˆƒ! r : ℝ, given_equation r := by sorry

{"Verdict": "YES", "Explanation": "The NL says not just that a unique solution exists, but specifically that the solution is r = 7. The Lean theorem only states unique existence and omits the stated witness.", "DetailTags": ["incomplete_spec"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Prove that a group of even order contains an element of order 2.

[Lean]
theorem exercise_2_11_3 {G : Type*} [Group G] [Fintype G]
  (hG : Even (card G)) : βˆƒ x : G, orderOf x = 2 := by sorry

{"Verdict": "NO", "Explanation": "The Lean statement includes the needed finite-group setting and the even-order hypothesis, then states the intended conclusion directly. There is no missing or incorrect specification here.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.

Prompt 3 β€” formalization_error

CATEGORY: formalization_error

Definition: The spec is clear, but the Lean encoding doesn't match due to translation choices (wrong connectives, contradictory premises, structural mismatch).

Allowed DetailTags: goal_mismatch, missing_subgoal, premise_translation_error, goal_translation_error, connective_mismatch, contradictory_premises, other

Boundary: Wrong type β†’ domain_mismatch. Wrong concept β†’ definition_mismatch. Indexing issues β†’ quantifier_indexing_mismatch.

---

FEW-SHOT EXAMPLE (Verdict: YES β€” intended property is mistranslated)
[Natural language]
There are exactly three positive real numbers k such that the function
f(x) = ((x - 18)(x - 72)(x - 98)(x - k)) / x
attains its minimum value at exactly two positive real numbers x. The sum of these three values is 240.

[Lean]
noncomputable def f (k x : ℝ) : ℝ :=
  (x - 18) * (x - 72) * (x - 98) * (x - k) / x

def exactly_two_minima (k : ℝ) : Prop :=
  βˆƒ (a b : ℝ), 0 < a ∧ 0 < b ∧ a β‰  b ∧ (f k a = f k b) ∧
    (βˆ€ (x : ℝ), 0 < x β†’ (f k x > f k a ∨ x = b))

theorem aime_2025ii_p15 :
  βˆƒ (k₁ kβ‚‚ k₃ : ℝ), 0 < k₁ ∧ 0 < kβ‚‚ ∧ 0 < k₃ ∧
    k₁ β‰  kβ‚‚ ∧ k₁ β‰  k₃ ∧ kβ‚‚ β‰  k₃ ∧
    exactly_two_minima k₁ ∧ exactly_two_minima kβ‚‚ ∧ exactly_two_minima k₃ ∧
    k₁ + kβ‚‚ + k₃ = 240 := by sorry

{"Verdict": "YES", "Explanation": "The Lean encoding of 'exactly two minima' is wrong. Plugging x = a into the universal clause forces f k a > f k a or a = b, which is impossible, so the intended property has been mistranslated.", "DetailTags": ["goal_translation_error"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Prove that the complement of a disconnected graph is connected.

[Lean]
theorem brualdi_ch12_34 {V : Type*} (G : SimpleGraph V) (h : Β¬ G.Connected) :
    Gᢜ.Connected := by sorry

{"Verdict": "NO", "Explanation": "The Lean statement directly matches the NL claim: if a graph is disconnected, then its complement is connected. There is no translation-structure error here.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.

Prompt 4 β€” domain_mismatch

CATEGORY: domain_mismatch

Definition: The Lean uses wrong carrier type/domain, changing meaning (β„• vs β„€, Fin n vs 1..n, truncating subtraction/division).

Allowed DetailTags: type_mismatch, domain_of_variables_mismatch, truncation_issue, other

Boundary: Missing constraints with correct domain β†’ specification_error.

---

FEW-SHOT EXAMPLE (Verdict: YES β€” the variable domain is wrong)
[Natural language]
Prove that lim_{nβ†’βˆž} (sqrt(n^2 + n) - n) = 1/2.

[Lean]
theorem exercise_3_2a :
  Tendsto (Ξ» (n : ℝ) => (sqrt (n^2 + n) - n)) atTop (𝓝 (1 / 2)) := by sorry

{"Verdict": "YES", "Explanation": "The NL is a sequence limit with n ranging over the natural-number index. The Lean statement instead takes n : ℝ, so it changes the carrier of the variable and therefore the meaning of the limit statement.", "DetailTags": ["type_mismatch"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Verify that there is no magic square of order 2.

[Lean]
theorem brualdi_ch1_10 : Β¬βˆƒ (M : Matrix (Fin 2) (Fin 2) β„•), IsMagicSquare M := by sorry

{"Verdict": "NO", "Explanation": "A 2Γ—2 magic square is naturally modeled by a matrix indexed by Fin 2 with natural entries. The Lean statement uses the right carrier and domain, so there is no domain mismatch.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.

Prompt 5 β€” definition_mismatch

CATEGORY: definition_mismatch

Definition: Lean objects don't represent the intended math notion (wrong operator, wrong constant, wrong library concept, misuse of API).

Allowed DetailTags: misuse_of_concept, wrong_operator, wrong_constant, library_usage_error, incorrect_function_choice, paper_vs_lean_semantics, encoding_issue, other

Boundary: Wrong type β†’ domain_mismatch. Missing assumptions β†’ specification_error.

---

FEW-SHOT EXAMPLE (Verdict: YES β€” the formal object is the wrong mathematical concept)
[Natural language]
Evaluate the integral ∫ cbrt(cos x) · sin^3(x) dx. The answer is
-(3/4) cos^(4/3)(x) + (3/10) cos^(10/3)(x) + C.

[Lean]
theorem integral_of_cube_root_cos_sin_cube (x : ℝ) :
  ∫ x in Set.Icc 0 x, (cos x)^(1/3 : ℝ) * (sin x)^3 =
    - (3/4) * (cos x)^(4/3 : ℝ) + (3/10) * (cos x)^(10/3 : ℝ) + C := by sorry

{"Verdict": "YES", "Explanation": "The NL asks for an indefinite integral, i.e. an antiderivative family with +C. The Lean statement instead uses a definite interval integral and also leaves C free, so it formalizes the wrong concept.", "DetailTags": ["misuse_of_concept"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Prove that -(-v) = v for every v ∈ V.

[Lean]
theorem exercise_1_3 {F V : Type*} [AddCommGroup V] [Field F]
  [Module F V] {v : V} : -(-v) = v := by sorry

{"Verdict": "NO", "Explanation": "Lean's negation here is exactly the additive inverse from the NL statement, and the theorem states the intended identity directly. There is no definition mismatch.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.

Prompt 6 β€” quantifier_indexing_mismatch

CATEGORY: quantifier_indexing_mismatch

Definition: Bug in quantifiers, bounds, indexing, or variable scope (off-by-one, wrong range, free vs bound variable).

Allowed DetailTags: quantifier_mismatch, indexing_mismatch, bound_mismatch, variable_mismatch, other

Boundary: Connective issues (∧ vs β†’) β†’ formalization_error. Missing constraints β†’ specification_error. Wrong types β†’ domain_mismatch.

---

FEW-SHOT EXAMPLE (Verdict: YES β€” the summation range is off by one)
[Natural language]
The sum βˆ‘_k binom(n, floor(k/2)) x^k is equal to (1 + x)(1 + x^2)^n.

[Lean]
theorem binomial_sum_equiv_product (n : β„•) (x : ℝ) :
  βˆ‘ k in range (2 * n + 1), (Nat.choose n (k / 2)) * x ^ k = (1 + x) * (1 + x ^ 2) ^ n := by sorry

{"Verdict": "YES", "Explanation": "The right-hand side has degree 2n + 1, so the intended sum includes the k = 2n + 1 term. Lean uses range (2 * n + 1), which runs only from k = 0 to 2n, so the indexing is off by one.", "DetailTags": ["indexing_mismatch"], "NeedsReview": "NO"}

---

FEW-SHOT EXAMPLE (Verdict: NO β€” the formalization is fine for this category)
[Natural language]
Let n be the smallest positive integer satisfying
n ≑ 2 (mod 3), n ≑ 3 (mod 5), and n ≑ 1 (mod 7).
Then n = 8.

[Lean]
theorem smallest_positive_integer :
  (βˆƒ n : β„•+, congruence1 n ∧ congruence2 n ∧ congruence3 n) ∧
  (βˆ€ n : β„•+, congruence1 n ∧ congruence2 n ∧ congruence3 n β†’ n β‰₯ 8) ∧
  (congruence1 8 ∧ congruence2 8 ∧ congruence3 8) := by sorry

{"Verdict": "NO", "Explanation": "The quantifiers correctly express existence of a positive solution, minimality over all positive solutions, and verification that 8 satisfies the congruences. There is no quantifier or indexing mismatch here.", "DetailTags": [], "NeedsReview": "NO"}

---

Input:
[Natural language]
{{PROBLEM_NL}}

[Lean]
{{LEAN_CODE}}

Return JSON only.