Theorem: String.utf8PrevAux_of_valid
File: Std/Data/String/Lemmas.lean

tactic: match cs with
| [] => simp [utf8PrevAux, ← hp, Pos.addChar_eq]
| c'::cs =>
  simp [← hp, utf8PrevAux, Pos.addChar_eq]; rw [if_neg]
  case hnc => rw [Pos.ext_iff, Nat.add_right_comm, Nat.add_left_comm]; apply ne_add_csize_add_self
  refine (utf8PrevAux_of_valid (by simp [Nat.add_assoc, Nat.add_left_comm])).trans ?_
  simp [Nat.add_assoc, Nat.add_comm]
state_before: cs cs' : List Char
c : Char
i p : Nat
hp : i + (utf8Len cs + csize c) = p
⊢ utf8PrevAux (cs ++ c :: cs') { byteIdx := i } { byteIdx := p } = { byteIdx := i + utf8Len cs }

tactic: simp [utf8PrevAux, ← hp, Pos.addChar_eq]
state_before: cs cs' : List Char
c : Char
i p : Nat
hp : i + (utf8Len [] + csize c) = p
⊢ utf8PrevAux ([] ++ c :: cs') { byteIdx := i } { byteIdx := p } = { byteIdx := i + utf8Len [] }

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

tactic: rw [if_neg]
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ (if { byteIdx := i + csize c' } = { byteIdx := i + (utf8Len cs + csize c' + csize c) } then { byteIdx := i }
    else
      utf8PrevAux (cs ++ c :: cs') { byteIdx := i + csize c' } { byteIdx := i + (utf8Len cs + csize c' + csize c) }) =
    { byteIdx := i + (utf8Len cs + csize c') }

tactic: case hnc => rw [Pos.ext_iff, Nat.add_right_comm, Nat.add_left_comm]; apply ne_add_csize_add_self
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ utf8PrevAux (cs ++ c :: cs') { byteIdx := i + csize c' } { byteIdx := i + (utf8Len cs + csize c' + csize c) } =
    { byteIdx := i + (utf8Len cs + csize c') }

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

tactic: refine (utf8PrevAux_of_valid (by simp [Nat.add_assoc, Nat.add_left_comm])).trans ?_
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ utf8PrevAux (cs ++ c :: cs') { byteIdx := i + csize c' } { byteIdx := i + (utf8Len cs + csize c' + csize c) } =
    { byteIdx := i + (utf8Len cs + csize c') }

tactic: simp [Nat.add_assoc, Nat.add_comm]
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ { byteIdx := i + csize c' + utf8Len cs } = { byteIdx := i + (utf8Len cs + csize c') }

tactic: rw [Pos.ext_iff, Nat.add_right_comm, Nat.add_left_comm]
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ ¬{ byteIdx := i + csize c' } = { byteIdx := i + (utf8Len cs + csize c' + csize c) }

tactic: apply ne_add_csize_add_self
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ ¬{ byteIdx := i + csize c' }.byteIdx = { byteIdx := utf8Len cs + csize c + (i + csize c') }.byteIdx

tactic: simp [Nat.add_assoc, Nat.add_left_comm]
state_before: cs✝ cs' : List Char
c : Char
i p : Nat
c' : Char
cs : List Char
hp : i + (utf8Len (c' :: cs) + csize c) = p
⊢ i + csize c' + (utf8Len cs + csize c) = i + (utf8Len cs + csize c' + csize c)