internlm/Lean-Github huggingface dataset:
Theorem: KVChain.insertWith_cons_of_eq
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain r β
a : α
b₁ : β a
haxs : boundLeft a xs
b : β a
⊢ (match insertWithAux f KVChain.nil (KVChain.cons a b₁ xs haxs) True.intro a b True.intro with
    | { val := z, property := hz } => hinge z.fst z.snd hz) =
    Option.casesOn (f a b₁ b) xs fun bf => KVChain.cons a bf xs haxs
Tactic:
rw [insertWithAux_cons_rfl]
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain r β
a : α
b₁ : β a
haxs : boundLeft a xs
b : β a
⊢ (match
      Option.casesOn (f a b₁ b)
        { val := (KVChain.nil, xs), property := (_ : hingeable (KVChain.nil, xs).fst (KVChain.nil, xs).snd) } fun bf =>
        { val := (KVChain.cons a bf KVChain.nil True.intro, xs),
          property :=
            (_ :
              hingeable (KVChain.cons a bf KVChain.nil True.intro)
                (KVChain.cons a bf KVChain.nil True.intro, xs).snd) } with
    | { val := z, property := hz } => hinge z.fst z.snd hz) =
    Option.casesOn (f a b₁ b) xs fun bf => KVChain.cons a bf xs haxs
Theorem: KVChain.insertWith_cons_of_eq
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain r β
a : α
b₁ : β a
haxs : boundLeft a xs
b : β a
⊢ (match
      Option.casesOn (f a b₁ b)
        { val := (KVChain.nil, xs), property := (_ : hingeable (KVChain.nil, xs).fst (KVChain.nil, xs).snd) } fun bf =>
        { val := (KVChain.cons a bf KVChain.nil True.intro, xs),
          property :=
            (_ :
              hingeable (KVChain.cons a bf KVChain.nil True.intro)
                (KVChain.cons a bf KVChain.nil True.intro, xs).snd) } with
    | { val := z, property := hz } => hinge z.fst z.snd hz) =
    Option.casesOn (f a b₁ b) xs fun bf => KVChain.cons a bf xs haxs
Tactic:
cases f a b₁ b <;> rfl
Proof state after:
no goals
Theorem: KVChain.nil_mergeWith
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith f KVChain.nil { toList := xs, ascend := ascend✝ } = { toList := xs, ascend := ascend✝ }
Tactic:
dsimp [KVChain.nil, mergeWith, mergeWith.loop]
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith.loop f { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst (flip r)) []) }
      { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst r) []) } True.intro xs ascend✝
      (_ : List.predHead ((fun a => boundLeft a KVChain.nil) ∘ Sigma.fst) { toList := xs, ascend := ascend✝ }.toList) =
    { toList := xs, ascend := ascend✝ }
Theorem: KVChain.nil_mergeWith
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith.loop f { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst (flip r)) []) }
      { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst r) []) } True.intro xs ascend✝
      (_ : List.predHead ((fun a => boundLeft a KVChain.nil) ∘ Sigma.fst) { toList := xs, ascend := ascend✝ }.toList) =
    { toList := xs, ascend := ascend✝ }
Tactic:
cases xs <;> rfl
Proof state after:
no goals
Theorem: KVChain.mergeWith_nil
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith f { toList := xs, ascend := ascend✝ } KVChain.nil = { toList := xs, ascend := ascend✝ }
Tactic:
dsimp [KVChain.nil, mergeWith]
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith.loop f { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst (flip r)) []) }
      { toList := xs, ascend := ascend✝ } True.intro [] (_ : List.Ascending (Sigma.relOnFst r) [])
      (_ :
        List.predHead ((fun a => boundLeft a KVChain.nil) ∘ Sigma.fst)
          { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst r) []) }.toList) =
    { toList := xs, ascend := ascend✝ }
Theorem: KVChain.mergeWith_nil
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : List (Sigma β)
ascend✝ : List.Ascending (Sigma.relOnFst r) xs
⊢ mergeWith.loop f { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst (flip r)) []) }
      { toList := xs, ascend := ascend✝ } True.intro [] (_ : List.Ascending (Sigma.relOnFst r) [])
      (_ :
        List.predHead ((fun a => boundLeft a KVChain.nil) ∘ Sigma.fst)
          { toList := [], ascend := (_ : List.Ascending (Sigma.relOnFst r) []) }.toList) =
    { toList := xs, ascend := ascend✝ }
Tactic:
rfl
Proof state after:
no goals
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
⊢ ∀ {ys : List (Sigma β)} {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
Tactic:
intro ys
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
ys : List (Sigma β)
⊢ ∀ {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
ys : List (Sigma β)
⊢ ∀ {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
Tactic:
revert xs_r xs
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
ys : List (Sigma β)
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
ys : List (Sigma β)
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
Tactic:
induction ys <;> dsimp
Proof state after:
case nil
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) []}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) []},
    (mergeWith.loop f xs_r xs hxs [] hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := [], ascend := hascend }).toList

case cons
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
head✝ : Sigma β
tail✝ : List (Sigma β)
tail_ih✝ :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) tail✝}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) tail✝},
    (mergeWith.loop f xs_r xs hxs tail✝ hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := tail✝, ascend := hascend }).toList
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) (head✝ :: tail✝)}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (head✝ :: tail✝)},
    (mergeWith.loop f xs_r xs hxs (head✝ :: tail✝) hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := head✝ :: tail✝, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) []}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) []},
    (mergeWith.loop f xs_r xs hxs [] hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := [], ascend := hascend }).toList
Tactic:
case nil => intros; rfl
Proof state after:
no goals
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) []}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) []},
    (mergeWith.loop f xs_r xs hxs [] hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := [], ascend := hascend }).toList
Tactic:
intros
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs_r✝ : KVChain (flip r) β
xs✝ : KVChain r β
hxs✝ : hingeable xs_r✝ xs✝
hascend✝ : List.Ascending (Sigma.relOnFst r) []
hxsys✝ : List.predHead ((fun a => boundLeft a xs_r✝) ∘ Sigma.fst) []
⊢ (mergeWith.loop f xs_r✝ xs✝ hxs✝ [] hascend✝ hxsys✝).toList =
    List.reverseAux xs_r✝.toList (mergeWith f xs✝ { toList := [], ascend := hascend✝ }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs_r✝ : KVChain (flip r) β
xs✝ : KVChain r β
hxs✝ : hingeable xs_r✝ xs✝
hascend✝ : List.Ascending (Sigma.relOnFst r) []
hxsys✝ : List.predHead ((fun a => boundLeft a xs_r✝) ∘ Sigma.fst) []
⊢ (mergeWith.loop f xs_r✝ xs✝ hxs✝ [] hascend✝ hxsys✝).toList =
    List.reverseAux xs_r✝.toList (mergeWith f xs✝ { toList := [], ascend := hascend✝ }).toList
Tactic:
rfl
Proof state after:
no goals
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
⊢ ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)},
    (mergeWith.loop f xs_r xs hxs (y :: ys) hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Tactic:
intro xs_r xs hxs hascend hyxs
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ (mergeWith.loop f xs_r xs hxs (y :: ys) hascend hyxs).toList =
    List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ (mergeWith.loop f xs_r xs hxs (y :: ys) hascend hyxs).toList =
    List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Tactic:
unfold mergeWith.loop
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ (match xs.toList with
      | [] =>
        hinge xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) }
          (_ : hingeable xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) })
      | head :: tail =>
        match hmatch : insertWithAux f xs_r xs hxs y.fst y.snd hyxs with
        | { val := (xs_r', xs'), property := h } =>
          mergeWith.loop f xs_r' xs' h ys (_ : List.Ascending (Sigma.relOnFst r) ys)
            (_ : List.predHead ((fun a => boundLeft a xs_r') ∘ Sigma.fst) ys)).toList =
    List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hxs : hingeable xs_r xs
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ (match xs.toList with
      | [] =>
        hinge xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) }
          (_ : hingeable xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) })
      | head :: tail =>
        match hmatch : insertWithAux f xs_r xs hxs y.fst y.snd hyxs with
        | { val := (xs_r', xs'), property := h } =>
          mergeWith.loop f xs_r' xs' h ys (_ : List.Ascending (Sigma.relOnFst r) ys)
            (_ : List.predHead ((fun a => boundLeft a xs_r') ∘ Sigma.fst) ys)).toList =
    List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Tactic:
revert hxs
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ ∀ {hxs : hingeable xs_r xs},
    (match xs.toList with
        | [] =>
          hinge xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) }
            (_ : hingeable xs_r { toList := y :: ys, ascend := (_ : List.Ascending (Sigma.relOnFst r) (y :: ys)) })
        | head :: tail =>
          match hmatch : insertWithAux f xs_r xs hxs y.fst y.snd hyxs with
          | { val := (xs_r', xs'), property := h } =>
            mergeWith.loop f xs_r' xs' h ys (_ : List.Ascending (Sigma.relOnFst r) ys)
              (_ : List.predHead ((fun a => boundLeft a xs_r') ∘ Sigma.fst) ys)).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := y :: ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ ∀ (hxs : hingeable xs_r KVChain.nil),
    (mergeWith.loop f xs_r KVChain.nil hxs (y :: ys) hascend hyxs).toList =
      List.reverseAux xs_r.toList (mergeWith f KVChain.nil { toList := y :: ys, ascend := hascend }).toList
Tactic:
case nil =>
  intro hxy; rfl
Proof state after:
no goals
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
⊢ ∀ (hxs : hingeable xs_r KVChain.nil),
    (mergeWith.loop f xs_r KVChain.nil hxs (y :: ys) hascend hyxs).toList =
      List.reverseAux xs_r.toList (mergeWith f KVChain.nil { toList := y :: ys, ascend := hascend }).toList
Tactic:
intro hxy
Proof state after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
hxy : hingeable xs_r KVChain.nil
⊢ (mergeWith.loop f xs_r KVChain.nil hxy (y :: ys) hascend hyxs).toList =
    List.reverseAux xs_r.toList (mergeWith f KVChain.nil { toList := y :: ys, ascend := hascend }).toList
Theorem: KVChain.toList_mergeWith_loop_eq_reverseAux
Proof state before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
y : Sigma β
ys : List (Sigma β)
h_ind :
  ∀ {xs_r : KVChain (flip r) β} {xs : KVChain r β} {hxs : hingeable xs_r xs}
    {hascend : List.Ascending (Sigma.relOnFst r) ys}
    {hxsys : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) ys},
    (mergeWith.loop f xs_r xs hxs ys hascend hxsys).toList =
      List.reverseAux xs_r.toList (mergeWith f xs { toList := ys, ascend := hascend }).toList
xs_r : KVChain (flip r) β
xs : KVChain r β
hascend : List.Ascending (Sigma.relOnFst r) (y :: ys)
hyxs : List.predHead ((fun a => boundLeft a xs_r) ∘ Sigma.fst) (y :: ys)
hxy : hingeable xs_r KVChain.nil
⊢ (mergeWith.loop f xs_r KVChain.nil hxy (y :: ys) hascend hyxs).toList =
    List.reverseAux xs_r.toList (mergeWith f KVChain.nil { toList := y :: ys, ascend := hascend }).toList
Tactic:
rfl
Proof state after:
no goals