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

tactic: match cs, cs' with
| [], [] => rfl
| [], c::cs' => simp [← hp, utf8GetAux]
| c::cs, cs' =>
  simp only [utf8GetAux, List.append_eq, Char.reduceDefault, ↓Char.isValue]
  rw [if_neg]
  case hnc => simp only [← hp, utf8Len_cons, Pos.ext_iff]; exact ne_self_add_add_csize
  refine utf8GetAux_of_valid cs cs' ?_
  simpa [Nat.add_assoc, Nat.add_comm] using hp
state_before: cs cs' : List Char
i p : Nat
hp : i + utf8Len cs = p
⊢ utf8GetAux (cs ++ cs') { byteIdx := i } { byteIdx := p } = cs'.headD default
state_after: no goals

tactic: rfl
state_before: cs cs' : List Char
i p : Nat
hp : i + utf8Len [] = p
⊢ utf8GetAux ([] ++ []) { byteIdx := i } { byteIdx := p } = [].headD default
state_after: no goals

tactic: simp [← hp, utf8GetAux]
state_before: cs cs'✝ : List Char
i p : Nat
c : Char
cs' : List Char
hp : i + utf8Len [] = p
⊢ utf8GetAux ([] ++ c :: cs') { byteIdx := i } { byteIdx := p } = (c :: cs').headD default
state_after: no goals

tactic: simp only [utf8GetAux, List.append_eq, Char.reduceDefault, ↓Char.isValue]
state_before: cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8GetAux (c :: cs ++ cs') { byteIdx := i } { byteIdx := p } = cs'.headD default
state_after: 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 else utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    cs'.headD 'A'

tactic: rw [if_neg]
state_before: 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 else utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    cs'.headD 'A'
state_after: cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } = cs'.headD 'A'

case hnc
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 only [← hp, utf8Len_cons, Pos.ext_iff]; exact ne_self_add_add_csize
state_before: cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } = cs'.headD 'A'

case hnc
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: cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } = cs'.headD 'A'

tactic: refine utf8GetAux_of_valid cs cs' ?_
state_before: cs✝ cs'✝ : List Char
i p : Nat
c : Char
cs cs' : List Char
hp : i + utf8Len (c :: cs) = p
⊢ utf8GetAux (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p } = cs'.headD 'A'
state_after: 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

tactic: simpa [Nat.add_assoc, Nat.add_comm] using hp
state_before: 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 only [← hp, utf8Len_cons, Pos.ext_iff]
state_before: 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: 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: 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