Zulip Chat Archive

Stream: lean4

Topic: How to prove theorem about hashes/string/metaprogramming?


Kitsune Kiriha (Jan 04 2026 at 10:44):

As the title indicates.
For example:

theorem t1 : mixHash 0 0 = 3866779316627607737 := by
  sorry

theorem t2 : "123".isNat := by
  sorry

Simple tactics does not work.

Are there some tactic that dedicates to these theorem?

Henrik Böving (Jan 04 2026 at 10:52):

mixHash is an opaque extern function, you cannot prove anything about it with normal tactics. The only thing you could possibly do would be to run native_decide.

Henrik Böving (Jan 04 2026 at 10:53):

Though I fear this is a bit of an #xy problem, proving things about mixHash should usually never be necessary.

Kitsune Kiriha (Jan 04 2026 at 10:53):

Thanks! native_decide is just what I want to seek.

Kitsune Kiriha (Jan 04 2026 at 10:57):

Another things is that I found https://localhost/mathlib4_docs/Batteries/Data/String/Lemmas.html#String.foldl_eq contains some lemma (e.g., String.foldl_eq) about strings. But the new API (String slice API) has no theorem about it.

So this make theorems like "123".isNat and further "123".toNat? = some 123, etc. very complicated to prove with normal ways.

Henrik Böving (Jan 04 2026 at 10:59):

Theorems for the new String API are on the list of our standard library team now that the API has finally settled though I can't make any concrete promises for a timeline at the moment.


Last updated: Feb 28 2026 at 14:05 UTC