You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In leanprover-community/batteries#671, there was an issue in the simpNF linter which was reduced to the setting of foApprox from the MetaM state. The problem is that not all methods for lifting a MetaM into IO to run it set the config in the same way:
import Lean.Meta.Tactic.Simp.Main
import Std.Tactic.OpenPrivate
import Std.Tactic.RunCmd
defMyPred (_ : Nat → Nat) : Prop := True
@[simp]theorembad1 (f : Unit → Nat → Nat) : MyPred (f ()) = True := sorryopen Lean Elab Meta Tactic Term
deftest : MetaM Unit := withReducible dolet (t, _) ← Elab.Term.TermElabM.run do
Elab.Term.elabTerm (← `(fun f : Unit → Nat → Nat => MyPred (f ()))) none
let ctx := { ← Simp.Context.mkDefault with config.decide := false }
lambdaLetTelescope t fun _ lhs => dolet ({ expr := lhs', .. }, _) ← simp lhs ctx
if lhs == lhs' then throwError "did not simplify"run_cmd Command.runTermElabM fun _ => test -- okrun_cmd Command.liftTermElabM test -- ok
run_elab test -- ok
run_meta test -- ok#evalshow TermElabM _ from test -- ok#evalshow MetaM _ from test -- fail#evalshow CoreM _ from MetaM.run' test {} {} -- fail#evalshow CoreM _ from MetaM.run' test { config.foApprox := true } {} -- okopenprivate mkMetaContext from Lean.Elab.Command in#evalshow CoreM _ from MetaM.run' test mkMetaContext {} -- ok
The fact that the default MetaM context constructed by {} is not the same as the MetaM context used by liftTermElabM (and transitively, most regular metaprogramming code) is error-prone since it means that you get different results depending on whether you use MetaM.run' or liftTermElabM, resulting in the above-demonstrated inconsistency. My recommendation is to have the current mkMetaContext be the default (i.e. make {} do the same thing as mkMetaContext).
In leanprover-community/batteries#671, there was an issue in the
simpNF
linter which was reduced to the setting offoApprox
from the MetaM state. The problem is that not all methods for lifting aMetaM
into IO to run it set the config in the same way:The fact that the default MetaM context constructed by
{}
is not the same as the MetaM context used byliftTermElabM
(and transitively, most regular metaprogramming code) is error-prone since it means that you get different results depending on whether you useMetaM.run'
orliftTermElabM
, resulting in the above-demonstrated inconsistency. My recommendation is to have the currentmkMetaContext
be the default (i.e. make{}
do the same thing asmkMetaContext
).cc: @leodemoura
The text was updated successfully, but these errors were encountered: