Theorem: String.utf8SetAux_of_valid
File: .lake/packages/batteries/Batteries/Data/String/Lemmas.lean

tactic: rfl
state_before: c' : Char
cs cs' : List Char
i p : Nat
hp : i + utf8Len [] = p
⊢ utf8SetAux c' ([] ++ []) { byteIdx := i } { byteIdx := p } = [] ++ List.modifyHead (fun x => c') []
state_after: no goals

tactic: simp [← hp, utf8SetAux]
state_before: c' : Char
cs cs'✝ : List Char
i p : Nat
c : Char
cs' : List Char
hp : i + utf8Len [] = p
⊢ utf8SetAux c' ([] ++ c :: cs') { byteIdx := i } { byteIdx := p } = [] ++ List.modifyHead (fun x => c') (c :: cs')
state_after: no goals

tactic: simp only [utf8SetAux, List.append_eq, List.cons_append]
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8SetAux c' (c :: cs ++ cs') { byteIdx := i } { byteIdx := p } = c :: cs ++ List.modifyHead (fun x => c') cs'
state_after: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ (if { byteIdx := i } = { byteIdx := p } then c' :: (cs ++ cs')
    else c :: utf8SetAux c' (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    c :: (cs ++ List.modifyHead (fun x => c') cs')

tactic: rw [if_neg]
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ (if { byteIdx := i } = { byteIdx := p } then c' :: (cs ++ cs')
    else c :: utf8SetAux c' (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    c :: (cs ++ List.modifyHead (fun x => c') cs')
state_after: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ c :: utf8SetAux c' (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } =
    c :: (cs ++ List.modifyHead (fun x => c') cs')

case hnc
c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ ¬{ byteIdx := i } = { byteIdx := p }

tactic: case hnc => simp [← hp, Pos.ext_iff]; exact ne_self_add_add_csize
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ c :: utf8SetAux c' (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } =
    c :: (cs ++ List.modifyHead (fun x => c') cs')

case hnc
c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ ¬{ byteIdx := i } = { byteIdx := p }
state_after: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ c :: utf8SetAux c' (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } =
    c :: (cs ++ List.modifyHead (fun x => c') cs')

tactic: simpa [Nat.add_assoc, Nat.add_comm] using hp
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ { byteIdx := i }.byteIdx + c.utf8Size + utf8Len cs = p
state_after: no goals

tactic: simp [← hp, Pos.ext_iff]
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ ¬{ byteIdx := i } = { byteIdx := p }
state_after: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ ¬i = i + (utf8Len cs + c.utf8Size)

tactic: exact ne_self_add_add_csize
state_before: c' : Char
cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ ¬i = i + (utf8Len cs + c.utf8Size)
state_after: no goals