Compare commits

...

4 Commits

Author SHA1 Message Date
Leonardo de Moura
5c8b449965 test: for new issue 2025-04-07 13:51:07 -07:00
Leonardo de Moura
d9b94924f5 chore: fix tests 2025-04-07 13:49:25 -07:00
Leonardo de Moura
9bdc8885e2 fix: updateAppMap before activateTheoremPatterns 2025-04-07 13:46:44 -07:00
Leonardo de Moura
0986416dfd chore: add trace messages 2025-04-07 13:46:30 -07:00
6 changed files with 25 additions and 11 deletions

View File

@@ -74,5 +74,7 @@ builtin_initialize registerTraceClass `grind.debug.mbtc
builtin_initialize registerTraceClass `grind.debug.ematch
builtin_initialize registerTraceClass `grind.debug.proveEq
builtin_initialize registerTraceClass `grind.debug.pushNewFact
builtin_initialize registerTraceClass `grind.debug.ematch.activate
builtin_initialize registerTraceClass `grind.debug.appMap
end Lean

View File

@@ -42,6 +42,7 @@ adds entry `f ↦ e` to `appMap`. Recall that `appMap` is a multi-map.
-/
private def updateAppMap (e : Expr) : GoalM Unit := do
let key := e.toHeadIndex
trace_goal[grind.debug.appMap] "{e} => {repr key}"
modify fun s => { s with
appMap := if let some es := s.appMap.find? key then
s.appMap.insert key (e :: es)
@@ -168,13 +169,16 @@ private def activateTheoremPatterns (fName : Name) (generation : Nat) : GoalM Un
modify fun s => { s with ematch.thmMap := thmMap }
let appMap := ( get).appMap
for thm in thms do
trace[grind.debug.ematch.activate] "`{fName}` => `{thm.origin.key}`"
unless ( get).ematch.thmMap.isErased thm.origin do
let symbols := thm.symbols.filter fun sym => !appMap.contains sym
let thm := { thm with symbols }
match symbols with
| [] => activateTheorem thm generation
| [] =>
trace_goal[grind.debug.ematch.activate] "`{thm.origin.key}`"
activateTheorem thm generation
| _ =>
trace_goal[grind.ematch] "reinsert `{thm.origin.key}`"
trace_goal[grind.debug.ematch.activate] "reinsert `{thm.origin.key}`"
modify fun s => { s with ematch.thmMap := s.ematch.thmMap.insert thm }
/--
@@ -256,6 +260,7 @@ private partial def internalizeImpl (e : Expr) (generation : Nat) (parent? : Opt
internalizeMatchCond e generation
else e.withApp fun f args => do
mkENode e generation
updateAppMap e
checkAndAddSplitCandidate e
pushCastHEqs e
addMatchEqns f generation
@@ -280,7 +285,6 @@ private partial def internalizeImpl (e : Expr) (generation : Nat) (parent? : Opt
internalize arg generation e
registerParent e arg
addCongrTable e
updateAppMap e
Arith.internalize e parent?
propagateUp e
propagateBetaForNewApp e

View File

@@ -0,0 +1,13 @@
reset_grind_attrs%
set_option grind.warning false
attribute [grind] List.length_set
attribute [grind ] List.eq_nil_of_length_eq_zero
attribute [grind] List.getElem_set
open List in
example {as : List α} {i : Nat} (h : i < as.length) :
as.set i as[i] = as := by
apply ext_getElem
· sorry
· grind

View File

@@ -14,8 +14,6 @@ set_option trace.grind.assert true
/--
info: [grind.assert] ¬f (f (f a)) = f a
[grind.assert] f (f (f (f a))) = f (f (f a))
[grind.assert] f (f (f a)) = f (f a)
[grind.assert] f (f a) = f a
-/
#guard_msgs (info) in

View File

@@ -22,10 +22,7 @@ example [DecidableEq α] (s₁ s₂ : Set α) (a₁ a₂ : α) :
s₂ = insertElem s₁ a₁ a₁ = a₂ contains s₂ a₂ := by
grind
/--
info: [grind.ematch] reinsert `contains_insert`
[grind.ematch] activated `contains_insert`, [@contains #3 (@insertElem _ #2 #1 #0) #0]
-/
/-- info: [grind.ematch] activated `contains_insert`, [@contains #3 (@insertElem _ #2 #1 #0) #0] -/
#guard_msgs (info) in
example [DecidableEq α] (s₁ s₂ : Set α) (a₁ a₂ : α) :
¬ contains s₂ a₂ s₂ = insertElem s₁ a₁ a₁ = a₂ False := by

View File

@@ -14,9 +14,9 @@ example : f (f (f x)) = f x := by
grind only [fthm]
/--
info: [grind.ematch.instance] fthm: f (f (f (f x))) = f (f (f x))
info: [grind.ematch.instance] fthm: f (f x) = f x
[grind.ematch.instance] fthm: f (f (f x)) = f (f x)
[grind.ematch.instance] fthm: f (f x) = f x
[grind.ematch.instance] fthm: f (f (f (f x))) = f (f (f x))
-/
#guard_msgs (info) in
set_option trace.grind.ematch.instance true in