Zulip Chat Archive

Stream: general

Topic: SizedStr


Asei Inoue (Dec 27 2025 at 04:48):

I'm surprised that I cannot show this by try?

def SizedStr (n : Nat) := { s : String // s.length  n }

def String.takeSized (s : String) (n : Nat) : SizedStr n :=
  let str := (s.take n).copy
  have : str.length  n := by
    fail_if_success try?
    sorry
  str, this

Asei Inoue (Dec 27 2025 at 04:48):

How can I show this?

Jakub Nowak (Dec 27 2025 at 11:09):

@loogle String.take

Jakub Nowak (Dec 27 2025 at 11:10):

@loogle String.take

loogle (Dec 27 2025 at 11:10):

:search: String.take

Jakub Nowak (Dec 27 2025 at 11:10):

There aren't any lemmas about String.take.

Jakub Nowak (Dec 27 2025 at 11:15):

There isn't much verification API around string at all it seems. You would have to create it. Or you could try using List Char or Array Char instead of String.

cmlsharp (Jan 03 2026 at 23:07):

Ah that’s a real shame. I suppose the difficulty is UTF-8?

Henrik Böving (Jan 04 2026 at 09:20):

These lemmas are on the list of the stdlib team and will come. We recently finished the refactoring to the new string API and the next evolutionary step for strings is to provide external proofs for the new API


Last updated: Feb 28 2026 at 14:05 UTC