Skip to content

clear_value fails unexpectedly #25053

@Qiu233

Description

@Qiu233

Prerequisites

Description

The tactic clear_value fails in a specific context with unreasonable trace.

Context

This snippet is generated by our coding agent.

Steps to Reproduce

The following is a working example followed by the bug example.

example : True := by
  let x := 1
  have x_def : x = 1 := by rfl
  have : x + 1 = 2 := by
    clear_value x
    rw [x_def]
  sorry
import Mathlib

set_option trace.Meta.check true
open Rat

variable (m : ℚ) (h₀ : 0 < m) (h₁ : ∑ k in Finset.Icc (1 : ℕ) 35, Real.sin (5 * ↑k * Real.pi / 180) = Real.tan (↑m * Real.pi / 180)) (h₂ : (↑m.num / ↑m.den : ℝ) < 90) in
example : True := by
  letI deg_to_rad := fun (x : ℝ) => x * Real.pi / 180
  letI S_val := ∑ k in Finset.Icc (1 : ℕ) 35, Real.sin (deg_to_rad (5 * ↑k))
  letI f_cos := fun (j : ℝ) => Real.cos (deg_to_rad (5 * j))
  letI telescoped_sum_val := f_cos 0 + f_cos 1 - f_cos 35 - f_cos 36
  have telescoped_sum_val_def : telescoped_sum_val = f_cos (0 : ℝ) + f_cos (1 : ℝ) - f_cos (35 : ℝ) - f_cos (36 : ℝ) := by funext; rfl
  have subprob_S_val_eq_h1_lhs_proof : S_val = ∑ k in Finset.Icc (1 : ℕ) 35, Real.sin (5 * ↑k * Real.pi / 180) := by
    clear_value telescoped_sum_val
    sorry
  sorry

Expected behavior: No error.

Actual behavior: Failed and log with head Meta.check.

Versions

  • 4.20.0-rc5
  • 4.12.0-rc1
  • 4.9.0

Additional Information

The log is as the following.

[Meta.check] ❌️ ∀ (telescoped_sum_val : ℝ),
      telescoped_sum_val = f_cos 0 + f_cos 1 - f_cos 35 - f_cos 36 →
        S_val = ∑ k ∈ Finset.Icc 1 35, Real.sin (5 * ↑k * Real.pi / 180) ▼
  [] application type mismatch
        ?m.2653 telescoped_sum_val telescoped_sum_val_def
      argument
        telescoped_sum_val_def
      has type
        telescoped_sum_val = f_cos 0 + f_cos 1 - f_cos 35 - f_cos 36 : Prop
      but is expected to have type
        f_cos 0 + f_cos 1 - f_cos 35 - f_cos 36 = f_cos 0 + f_cos 1 - f_cos 35 - f_cos 36 : Prop 

Impact

Our coding agent heavily depends on clear_value. This bug breaks many snippets it generates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions