Skip to content

Commit 3ce7d4e

Browse files
authored
chore: minor optimizations on the critical path (#10900)
This PR optimizes two `String` proofs and makes sure that `MkIffOfInductiveProp` does not import `Lean.Elab.Tactic`, which previously pushed it to the very end of the import graph.
1 parent 63c0672 commit 3ce7d4e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

src/Init/Data/String/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ private theorem ByteArray.utf8Decode?go_eq_utf8Decode?go_extract {b : ByteArray}
374374
simp only [size_extract, Nat.le_refl, Nat.min_eq_left, Option.map_map, ByteArray.extract_extract]
375375
have : (fun x => acc ++ x) ∘ (fun x => #[c] ++ x) = fun x => acc.push c ++ x := by funext; simp
376376
simp [(by omega : i + (b.size - i) = b.size), this]
377+
termination_by fuel
377378

378379
theorem ByteArray.utf8Decode?_utf8Encode_singleton_append {l : ByteArray} {c : Char} :
379380
([c].utf8Encode ++ l).utf8Decode? = l.utf8Decode?.map (#[c] ++ ·) := by

src/Init/Data/String/Decode.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,8 @@ public theorem ByteArray.isUTF8FirstByte_getElem_zero_utf8EncodeChar_append {c :
14641464
public theorem ByteArray.isUTF8FirstByte_of_isSome_utf8DecodeChar? {b : ByteArray} {i : Nat}
14651465
(h : (utf8DecodeChar? b i).isSome) : (b[i]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUTF8FirstByte := by
14661466
rw [utf8DecodeChar?_eq_utf8DecodeChar?_extract] at h
1467-
suffices ((b.extract i b.size)[0]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUTF8FirstByte by
1467+
suffices ((b.extract i b.size)[0]'
1468+
(by simpa using lt_size_of_isSome_utf8DecodeChar? h)).IsUTF8FirstByte by
14681469
simpa [ByteArray.getElem_extract, Nat.add_zero] using this
14691470
obtain ⟨c, hc⟩ := Option.isSome_iff_exists.1 h
14701471
conv => congr; congr; rw [eq_of_utf8DecodeChar?_eq_some hc]

src/Lean/Elab/MutualInductive.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Lean.Elab.ComputedFields
1515
import Lean.Meta.Constructions.CtorIdx
1616
import Lean.Meta.Constructions.CtorElim
1717
import Lean.Meta.IndPredBelow
18+
import Lean.Meta.Injective
1819

1920
public section
2021

src/Lean/Meta/MkIffOfInductiveProp.lean

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ module
1212

1313
prelude
1414

15-
public import Lean.Elab.Tactic
15+
public import Lean.Meta.Basic
16+
import Lean.Elab.Term.TermElabM
17+
import Lean.Elab.Tactic.Basic
18+
import Lean.Meta.Tactic.Apply
19+
import Lean.Meta.Tactic.Intro
20+
import Lean.Meta.Tactic.Cases
21+
1622

1723
namespace Lean.Meta
1824

0 commit comments

Comments
 (0)