Zulip Chat Archive

Stream: general

Topic: Extremely verbose aesop panic


Eric Wieser (Aug 13 2024 at 20:27):

The following code (in mathlib master) produces 1595 panics:

import Mathlib.Data.Finset.Basic

example
    (n : List   List )
    (hn :  A, n A = A.filter (fun p => true)) :
    0  0 := by
  exact (0, not_not.1 $ by aesop)

all of which are

PANIC at Lean.MetavarContext.getLevelDepth Lean.MetavarContext:920:14: unknown metavariable

Eric Wieser (Aug 13 2024 at 20:41):

Waiting for an LSP message eventually gives

aesop: internal error: extracted proof has metavariables.
  Proof: Eq.mpr (id Init.Classical._auxLemma.2)
    (?m.2081 (Eq.mp (forall_congr fun A => congrArg (Eq (n A)) (List.filter_true A)) h₂'))
  Unassigned metavariables: [_uniq.6175, _uniq.6176]

Eric Wieser (Aug 13 2024 at 20:57):

It seems this is somehow caused by

@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem singleton_nonempty (a : α) : ({a} : Finset α).Nonempty :=
  a, mem_singleton_self a

as the above example panics only after that lemma

Eric Wieser (Aug 13 2024 at 21:22):

Minimized to be mathlib-free at https://github.com/leanprover-community/aesop/issues/153

Bhavik Mehta (May 14 2025 at 15:01):

I just independently ran into the same aesop internal error, which seems to be caused by the same singleton_nonempty:

import Mathlib.Data.Finset.Card

lemma card_eq_two' {α : Type*} [DecidableEq α] {S : Finset α} (hS : S.card = 2)
    {a : α} (ha : a  S) :  b : α, a  b  S = {a, b} := by
  rw [Finset.card_eq_two] at hS
  obtain x, y, hxy, rfl := hS
  simp only [ne_eq, Finset.mem_insert, Finset.mem_singleton] at ha
  aesop

Jannis Limperg (May 18 2025 at 10:55):

This seems to be cause by a simp bug: lean4#5028

Violeta Hernández (Aug 14 2025 at 09:00):

Just came across a "aesop: internal error: extracted proof has metavariables." of my own.

Violeta Hernández (Aug 14 2025 at 09:01):

image.png
This is the goal state; doing refine fun _ ↦ ⟨n, ?_⟩ before this makes aesop work just fine.

Violeta Hernández (Aug 14 2025 at 09:01):

I'll try to minimize this to at least not depend on nimbers

Violeta Hernández (Aug 14 2025 at 09:05):

(deleted)

Violeta Hernández (Aug 14 2025 at 09:08):

This doesn't really break on Mathlib, though it doesn't solve the goal until you instantiate n.

import Mathlib.Algebra.Polynomial.Coeff

open Polynomial

example {R : Type*} [Semiring R] [PartialOrder R] [NeZero (1 : R)] [ZeroLEOneClass R] (p : R[X]) (n : ) :
    ( m, n < m  n = m  p.coeff m = 0)  ( (k : ), n < k  p.coeff k = (X ^ n).coeff k) 
     n, p.coeff n < (X ^ n).coeff n := by
  aesop -- failed after exhaustive search

Last updated: Dec 20 2025 at 21:32 UTC