getStarLemmas lists the current module's star-indexed lemmas once more after each library search

Aperta
#16,415 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva

Direzione di ricerca

Read createModuleTreeRef in src/Lean/Meta/LazyDiscrTree.lean and libSearchFindDecls in src/Lean/Meta/Tactic/LibrarySearch.lean, then run the supplied Star.lean reproduction. Trace how current-module dropped entries are added to starLemmasExt across repeated searches; done when my_star_lemma appears once after three searches and the regression is covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Prerequisites
  • Check that your issue is not already filed:
    https://github.com/leanprover/lean4/issues
  • Reduce the issue to a minimal, self-contained, reproducible test case.
    Avoid dependencies to Mathlib or Batteries.
  • Test your test case against the latest nightly release. I tested 4.34.1 and 4.35.0. The code involved is unchanged on master (createModuleTreeRef in src/Lean/Meta/LazyDiscrTree.lean, and libSearchFindDecls in src/Lean/Meta/Tactic/LibrarySearch.lean).
  • When reporting a perceived soundness bug: not a soundness bug.
Description

getStarLemmas lists each of the current module's star-indexed lemmas once more after every library search in the same process. After three searches, a lemma of the current module is listed three times, so the last-resort pass of exact? and apply? tries it three times.

libSearchFindDecls passes the process-wide starLemmasExt to findMatches as droppedEntriesRef. findMatches builds a new tree of the current module on every call (createModuleTreeRef). Each time, createModuleTreeRef appends that module's dropped entries to the ref, after what's already there. The imported part is appended only once, when the imported tree is first made, so only the current module's part repeats.

Context

Found while comparing a program's own use of LazyDiscrTree with libSearchFindDecls and getStarLemmas, on goals in one file.

Steps to Reproduce
  1. Save this as Star.lean:
import Lean
open Lean Meta LibrarySearch
theorem my_star_lemma {α : Prop} (h : α) : α := h
#eval show MetaM Unit from do
  let _ ← libSearchFindDecls (mkConst ``True)
  let a ← getStarLemmas
  let _ ← libSearchFindDecls (mkConst ``True)
  let _ ← libSearchFindDecls (mkConst ``True)
  let b ← getStarLemmas
  let count (xs : Array (Name × DeclMod)) := (xs.filter (·.1 == ``my_star_lemma)).size
  IO.println s!"after 1 search: {a.size} star lemmas, my_star_lemma {count a} times"
  IO.println s!"after 3 searches: {b.size} star lemmas, my_star_lemma {count b} times"
  1. Run lean Star.lean.

Expected behavior: my_star_lemma is listed once, however many searches ran before.

Actual behavior:

after 1 search: 1660 star lemmas, my_star_lemma 1 times
after 3 searches: 1662 star lemmas, my_star_lemma 3 times

On 4.35.0, the counts are 1673 and 1675, again with my_star_lemma listed 1 and 3 times.

Versions
  • Lean (version 4.34.1, aarch64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release)
  • Lean (version 4.35.0, aarch64-unknown-linux-gnu, commit eb6cafb7290e8bd5f2937522d8d804f58f02bafc, Release)
  • Linux, aarch64
Additional Information

starLemmasExt lives as long as the process, so the list grows with every search the process makes: each exact? or apply? in one file adds that file's star-indexed lemmas again.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
19h 8m
PR unite (30g)
421

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.