Theorem: Substring.ValidFor.prevn
File: .lake/packages/batteries/Batteries/Data/String/Lemmas.lean

tactic: simp [Substring.prevn]
state_before: l m₂ r m₁ : List Char
x✝¹ : Substring
x✝ : ValidFor l (m₁.reverse ++ m₂) r x✝¹
⊢ x✝¹.prevn 0 { byteIdx := utf8Len m₁ } = { byteIdx := utf8Len (List.drop 0 m₁) }
state_after: no goals

tactic: simp only [Substring.prevn]
state_before: l m₂ r m₁ : List Char
s : Substring
h : ValidFor l (m₁.reverse ++ m₂) r s
n : Nat
⊢ s.prevn (n + 1) { byteIdx := utf8Len m₁ } = { byteIdx := utf8Len (List.drop (n + 1) m₁) }
state_after: l m₂ r m₁ : List Char
s : Substring
h : ValidFor l (m₁.reverse ++ m₂) r s
n : Nat
⊢ s.prevn n (s.prev { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len (List.drop (n + 1) m₁) }

tactic: match m₁ with
| [] => simp
| c::m₁ =>
  rw [List.reverse_cons, List.append_assoc] at h
  have := h.prev; simp at this; simp [this, h.prevn n]
state_before: l m₂ r m₁ : List Char
s : Substring
h : ValidFor l (m₁.reverse ++ m₂) r s
n : Nat
⊢ s.prevn n (s.prev { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len (List.drop (n + 1) m₁) }
state_after: no goals

tactic: simp
state_before: l m₂ r m₁ : List Char
s : Substring
n : Nat
h : ValidFor l ([].reverse ++ m₂) r s
⊢ s.prevn n (s.prev { byteIdx := utf8Len [] }) = { byteIdx := utf8Len (List.drop (n + 1) []) }
state_after: no goals

tactic: rw [List.reverse_cons, List.append_assoc] at h
state_before: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l ((c :: m₁).reverse ++ m₂) r s
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }
state_after: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }

tactic: have := h.prev
state_before: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }
state_after: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
this : s.prev { byteIdx := utf8Len m₁.reverse + c.utf8Size } = { byteIdx := utf8Len m₁.reverse }
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }

tactic: simp at this
state_before: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
this : s.prev { byteIdx := utf8Len m₁.reverse + c.utf8Size } = { byteIdx := utf8Len m₁.reverse }
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }
state_after: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
this : s.prev { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ }
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }

tactic: simp [this, h.prevn n]
state_before: l m₂ r m₁✝ : List Char
s : Substring
n : Nat
c : Char
m₁ : List Char
h : ValidFor l (m₁.reverse ++ ([c] ++ m₂)) r s
this : s.prev { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ }
⊢ s.prevn n (s.prev { byteIdx := utf8Len (c :: m₁) }) = { byteIdx := utf8Len (List.drop (n + 1) (c :: m₁)) }
state_after: no goals