Theorem: KVChain.insertWithAux_cons_rel (Algdata/Data/KVChain/MergeWith.lean)

State before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
⊢ ∀ (ha₁a : r a₁ a),
    insertWithAux f xs (KVChain.cons a₁ b₁ ys ha₁ys) ha₁xs a b haxs =
      insertWithAux f (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys
        (_ : hingeable (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys) a b ha₁a
Tactic:
intro hbc
State after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux f xs (KVChain.cons a₁ b₁ ys ha₁ys) ha₁xs a b haxs =
    insertWithAux f (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys
      (_ : hingeable (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys) a b hbc

State before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux f xs (KVChain.cons a₁ b₁ ys ha₁ys) ha₁xs a b haxs =
    insertWithAux f (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys
      (_ : hingeable (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys) a b hbc
Tactic:
unfold insertWithAux
State after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux.loop f a b xs (KVChain.cons a₁ b₁ ys ha₁ys).toList
      (_ : List.Ascending (Sigma.relOnFst r) (KVChain.cons a₁ b₁ ys ha₁ys).toList)
      (_ :
        List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
          (KVChain.cons a₁ b₁ ys ha₁ys).toList)
      haxs =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc

State before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux.loop f a b xs (KVChain.cons a₁ b₁ ys ha₁ys).toList
      (_ : List.Ascending (Sigma.relOnFst r) (KVChain.cons a₁ b₁ ys ha₁ys).toList)
      (_ :
        List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
          (KVChain.cons a₁ b₁ ys ha₁ys).toList)
      haxs =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc
Tactic:
conv in KVChain.cons a₁ b₁ ys ha₁ys => unfold KVChain.cons
State after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux.loop f a b xs
      { toList := { fst := a₁, snd := b₁ } :: ys.toList,
          ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList
      (_ :
        List.Ascending (Sigma.relOnFst r)
          { toList := { fst := a₁, snd := b₁ } :: ys.toList,
              ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList)
      (_ :
        List.predHead ((fun a => boundLeft a xs) ∘ Sigma.fst)
          { toList := { fst := a₁, snd := b₁ } :: ys.toList,
              ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList)
      haxs =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc

State before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ insertWithAux.loop f a b xs
      { toList := { fst := a₁, snd := b₁ } :: ys.toList,
          ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList
      (_ :
        List.Ascending (Sigma.relOnFst r)
          { toList := { fst := a₁, snd := b₁ } :: ys.toList,
              ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList)
      (_ :
        List.predHead ((fun a => boundLeft a xs) ∘ Sigma.fst)
          { toList := { fst := a₁, snd := b₁ } :: ys.toList,
              ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }.toList)
      haxs =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc
Tactic:
dsimp [insertWithAux.loop]
State after:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ (if hya : r a₁ a then
      insertWithAux.loop f a b
        (KVChain.cons a₁ b₁ xs
          (_ :
            List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
              (KVChain.cons a₁ b₁ ys ha₁ys).toList))
        ys.toList (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
        (_ : List.predHead (Sigma.relOnFst r { fst := a₁, snd := b₁ }) ys.toList) hya
    else
      if hay : r a a₁ then
        {
          val :=
            (KVChain.cons a b xs haxs,
              { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }),
          property :=
            (_ :
              hingeable
                (KVChain.cons a b xs haxs,
                    { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                      ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }).fst
                (KVChain.cons a b xs haxs,
                    { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                      ascend :=
                        (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }).snd) }
      else
        match f a₁ b₁ ((_ : a = { fst := a₁, snd := b₁ }.fst) ▸ b) with
        | none =>
          { val := (xs, { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }),
            property :=
              (_ : hingeable xs { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }) }
        | some z =>
          {
            val :=
              (KVChain.cons a₁ z xs
                  (_ :
                    List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
                      (KVChain.cons a₁ b₁ ys ha₁ys).toList),
                { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }),
            property :=
              (_ :
                hingeable
                  (KVChain.cons a₁ z xs
                    (_ :
                      List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
                        (KVChain.cons a₁ b₁ ys ha₁ys).toList))
                  { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }) }) =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc

State before:
α : Type u
r : α → α → Prop
inst✝¹ : StrictLinearOrder r
inst✝ : DecidableRel r
β : α → Type v
f : (a : α) → β a → β a → Option (β a)
xs : KVChain (flip r) β
a₁ : α
b₁ : β a₁
ys : KVChain r β
ha₁ys : boundLeft a₁ ys
ha₁xs : hingeable xs (KVChain.cons a₁ b₁ ys ha₁ys)
a : α
b : β a
haxs : boundLeft a xs
hbc : r a₁ a
⊢ (if hya : r a₁ a then
      insertWithAux.loop f a b
        (KVChain.cons a₁ b₁ xs
          (_ :
            List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
              (KVChain.cons a₁ b₁ ys ha₁ys).toList))
        ys.toList (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
        (_ : List.predHead (Sigma.relOnFst r { fst := a₁, snd := b₁ }) ys.toList) hya
    else
      if hay : r a a₁ then
        {
          val :=
            (KVChain.cons a b xs haxs,
              { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }),
          property :=
            (_ :
              hingeable
                (KVChain.cons a b xs haxs,
                    { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                      ascend := (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }).fst
                (KVChain.cons a b xs haxs,
                    { toList := { fst := a₁, snd := b₁ } :: ys.toList,
                      ascend :=
                        (_ : List.Ascending (Sigma.relOnFst r) ({ fst := a₁, snd := b₁ } :: ys.toList)) }).snd) }
      else
        match f a₁ b₁ ((_ : a = { fst := a₁, snd := b₁ }.fst) ▸ b) with
        | none =>
          { val := (xs, { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }),
            property :=
              (_ : hingeable xs { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }) }
        | some z =>
          {
            val :=
              (KVChain.cons a₁ z xs
                  (_ :
                    List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
                      (KVChain.cons a₁ b₁ ys ha₁ys).toList),
                { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }),
            property :=
              (_ :
                hingeable
                  (KVChain.cons a₁ z xs
                    (_ :
                      List.predHead (fun b => List.predHead (flip (fun a b => r a.fst b.fst) b) xs.toList)
                        (KVChain.cons a₁ b₁ ys ha₁ys).toList))
                  { toList := ys.toList, ascend := (_ : List.Ascending (Sigma.relOnFst r) ys.toList) }) }) =
    insertWithAux.loop f a b (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)) ys.toList
      (_ : List.Ascending (Sigma.relOnFst r) ys.toList)
      (_ :
        List.predHead
          (fun b =>
            List.predHead (flip (fun a b => r a.fst b.fst) b) (KVChain.cons a₁ b₁ xs (_ : boundLeft a₁ xs)).toList)
          ys.toList)
      hbc
Tactic:
rw [dif_pos hbc]
State after:
no goals