Zulip Chat Archive
Stream: general
Topic: Basic help with logarithms
J Li (Aug 26 2023 at 06:12):
Hi, I'm new here and have a simple question. I just installed Lean with mathlib following https://leanprover-community.github.io/install/project.html in Lean 4. I imported "import Mathlib.Data.Nat.Log" and am trying to use expressions like "log 2 8" but getting the error "function expected at log, term has type ?m.15". I'm not sure what this means. Could someone please advise?
J Li (Aug 26 2023 at 06:20):
Another question: say I am looking for a logarithm function in mathlib, what's the easiest way to search for it?
Moritz Doll (Aug 26 2023 at 06:29):
You need to either open Nat
or write Nat.log 2 8
J Li (Aug 26 2023 at 06:30):
Thanks, is there any way to do it for real numbers?
Moritz Doll (Aug 26 2023 at 06:30):
yes, docs#Real.log
J Li (Aug 26 2023 at 06:33):
so to use this I would need to do import Mathlib.Analysis.SpecialFunctions.Log.Basic, and then how do I call the log function?
J Li (Aug 26 2023 at 06:33):
any reason Basic.Real.log doesn't work?
J Li (Aug 26 2023 at 06:36):
i'm getting this error failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Real.instDivisionRingReal', and it does not have executable code
Moritz Doll (Aug 26 2023 at 06:39):
yes, you need to import the corresponding file and the real logarithm is called Real.log
not Basic.Real.log
. Note also that you cannot evaluate the logarithm, but you can prove things about it.
J Li (Aug 26 2023 at 06:41):
sorry, why can't I evaluate the logarithm?
Ruben Van de Velde (Aug 26 2023 at 07:02):
The real numbers are implemented in mathlib in a way that doesn't support direct evaluation, but you could use #norm_num Real.log 1
if I'm getting the syntax right
Mario Carneiro (Aug 26 2023 at 07:07):
norm_num does not know logarithms, although that particular example can be solved by simp
Ruben Van de Velde (Aug 26 2023 at 09:10):
Well, if anything is going to work here in some generality, it's norm_num
. That doesn't mean it already works, though
Mario Carneiro (Aug 26 2023 at 09:14):
well, there is the fundamental issue that it's not clear what you would want Real.log 2
to "evaluate" to
Mario Carneiro (Aug 26 2023 at 09:15):
keeping in mind that norm_num is not an approximation tactic, it proves equalities
Last updated: Dec 20 2023 at 11:08 UTC