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]
  rw [if_neg]
  case hnc => simp [← hp, 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'.head?
state_after: no goals

tactic: rfl
state_before: cs cs' : List Char
i p : Nat
hp : i + utf8Len [] = p
⊢ utf8GetAux? ([] ++ []) { byteIdx := i } { byteIdx := p } = [].head?
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').head?
state_after: no goals

tactic: simp only [utf8GetAux?, List.append_eq]
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'.head?
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 some c
    else utf8GetAux? (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    cs'.head?

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 some c
    else utf8GetAux? (cs ++ cs') ({ byteIdx := i } + c) { byteIdx := p }) =
    cs'.head?
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'.head?

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 [← hp, 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'.head?

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'.head?

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'.head?
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 [← hp, 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