Theorem: project.IsHeap_merge
Proof state before:
α : Type u_1
le : α → α → Bool
_x✝ :
  (rx : ℕ) ×'
    (xs : List (BinTree α)) ×' (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁷ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y _x✝ →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
rx : ℕ
xs✝ : (xs : List (BinTree α)) ×' (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁶ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := xs✝ } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
xs : List (BinTree α)
ry✝ : (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁵ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := ry✝ } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
ry : ℕ
ys✝ : (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁴ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := { fst := ry, snd := ys✝ } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
ys : List (BinTree α)
hxs✝¹ : (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹³ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := { fst := ry, snd := { fst := ys, snd := hxs✝¹ } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
hxs✝ : IsHeapForest' rx xs
hys✝ : IsHeapForest' ry ys
a✝¹² :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rx,
          snd := { fst := xs, snd := { fst := ry, snd := { fst := ys, snd := { fst := hxs✝, snd := hys✝ } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h₁ : BinTree α
t₁ : List (BinTree α)
h₂ : BinTree α
t₂ : List (BinTree α)
hxs : IsHeapForest' rx (h₁ :: t₁)
hys : IsHeapForest' ry (h₂ :: t₂)
x✝² :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rx,
          snd :=
            { fst := h₁ :: t₁, snd := { fst := ry, snd := { fst := h₂ :: t₂, snd := { fst := hxs, snd := hys } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝⁹ : ¬h₁.rank < h₂.rank
h✝⁸ : ¬h₂.rank < h₁.rank
h✝⁷ : ¬((combine le h₁ h₂).rank != hRank t₁) = true
h✝⁶ : ¬((combine le h₁ h₂).rank != hRank t₂) = true
heq : h₁.rank = h₂.rank
rank✝ : ℕ
t✝ : BinTree α
ts✝ : List (BinTree α)
a✝¹¹ : rank✝ < t✝.rank
a✝¹⁰ : IsBinTree t✝
a✝⁹ : IsHeapForest' t✝.rank ts✝
x✝¹ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rank✝,
          snd :=
            { fst := t✝ :: ts✝,
              snd :=
                { fst := ry,
                  snd :=
                    { fst := h₂ :: t₂, snd := { fst := (_ : IsHeapForest' rank✝ (t✝ :: ts✝)), snd := hys } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝⁵ : rx = rank✝
a✝⁸ : rx < t✝.rank
h✝⁴ : h₁ :: t₁ = t✝ :: ts✝
head_eq✝¹ : h₁ = t✝
a✝⁷ : IsBinTree h₁
hf✝ : IsHeapForest' h₁.rank ts✝
a✝⁶ : rx < h₁.rank
tail_eq✝¹ : t₁ = ts✝
hf : IsHeapForest' h₁.rank t₁
h✝³ : HEq hxs (_ : IsHeapForest' rx (h₁ :: t₁))
rank : ℕ
t : BinTree α
ts : List (BinTree α)
a✝⁵ : rank < t.rank
a✝⁴ : IsBinTree t
a✝³ : IsHeapForest' t.rank ts
x✝ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rank✝,
          snd :=
            { fst := t✝ :: ts✝,
              snd :=
                { fst := rank,
                  snd :=
                    { fst := t :: ts,
                      snd :=
                        { fst := (_ : IsHeapForest' rank✝ (t✝ :: ts✝)),
                          snd := (_ : IsHeapForest' rank (t :: ts)) } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝² : ry = rank
a✝² : ry < t.rank
h✝¹ : h₂ :: t₂ = t :: ts
head_eq✝ : h₂ = t
a✝¹ : IsBinTree h₂
hf₂✝ : IsHeapForest' h₂.rank ts
a✝ : ry < h₂.rank
tail_eq✝ : t₂ = ts
hf₂ : IsHeapForest' h₂.rank t₂
h✝ : HEq hys (_ : IsHeapForest' ry (h₂ :: t₂))
⊢ (invImage
        (fun a ↦
          PSigma.casesOn a
            fun rx snd ↦
              PSigma.casesOn snd
                fun xs snd ↦
                  PSigma.casesOn snd
                    fun ry snd ↦
                      PSigma.casesOn snd fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
        instWellFoundedRelation).1
    { fst := h₁.rank,
      snd := { fst := t₁, snd := { fst := h₂.rank, snd := { fst := t₂, snd := { fst := hf, snd := hf₂ } } } } }
    { fst := rank✝,
      snd :=
        { fst := t✝ :: ts✝,
          snd :=
            { fst := rank,
              snd :=
                { fst := t :: ts,
                  snd :=
                    { fst := (_ : IsHeapForest' rank✝ (t✝ :: ts✝)), snd := (_ : IsHeapForest' rank (t :: ts)) } } } } }
Tactic:
simp_wf
Proof state after:
α : Type u_1
le : α → α → Bool
_x✝ :
  (rx : ℕ) ×'
    (xs : List (BinTree α)) ×' (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁷ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y _x✝ →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
rx : ℕ
xs✝ : (xs : List (BinTree α)) ×' (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁶ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := xs✝ } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
xs : List (BinTree α)
ry✝ : (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁵ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := ry✝ } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
ry : ℕ
ys✝ : (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹⁴ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := { fst := ry, snd := ys✝ } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
ys : List (BinTree α)
hxs✝¹ : (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys
a✝¹³ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y { fst := rx, snd := { fst := xs, snd := { fst := ry, snd := { fst := ys, snd := hxs✝¹ } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
hxs✝ : IsHeapForest' rx xs
hys✝ : IsHeapForest' ry ys
a✝¹² :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rx,
          snd := { fst := xs, snd := { fst := ry, snd := { fst := ys, snd := { fst := hxs✝, snd := hys✝ } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h₁ : BinTree α
t₁ : List (BinTree α)
h₂ : BinTree α
t₂ : List (BinTree α)
hxs : IsHeapForest' rx (h₁ :: t₁)
hys : IsHeapForest' ry (h₂ :: t₂)
x✝² :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rx,
          snd :=
            { fst := h₁ :: t₁, snd := { fst := ry, snd := { fst := h₂ :: t₂, snd := { fst := hxs, snd := hys } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝⁹ : ¬h₁.rank < h₂.rank
h✝⁸ : ¬h₂.rank < h₁.rank
h✝⁷ : ¬((combine le h₁ h₂).rank != hRank t₁) = true
h✝⁶ : ¬((combine le h₁ h₂).rank != hRank t₂) = true
heq : h₁.rank = h₂.rank
rank✝ : ℕ
t✝ : BinTree α
ts✝ : List (BinTree α)
a✝¹¹ : rank✝ < t✝.rank
a✝¹⁰ : IsBinTree t✝
a✝⁹ : IsHeapForest' t✝.rank ts✝
x✝¹ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rank✝,
          snd :=
            { fst := t✝ :: ts✝,
              snd :=
                { fst := ry,
                  snd :=
                    { fst := h₂ :: t₂, snd := { fst := (_ : IsHeapForest' rank✝ (t✝ :: ts✝)), snd := hys } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝⁵ : rx = rank✝
a✝⁸ : rx < t✝.rank
h✝⁴ : h₁ :: t₁ = t✝ :: ts✝
head_eq✝¹ : h₁ = t✝
a✝⁷ : IsBinTree h₁
hf✝ : IsHeapForest' h₁.rank ts✝
a✝⁶ : rx < h₁.rank
tail_eq✝¹ : t₁ = ts✝
hf : IsHeapForest' h₁.rank t₁
h✝³ : HEq hxs (_ : IsHeapForest' rx (h₁ :: t₁))
rank : ℕ
t : BinTree α
ts : List (BinTree α)
a✝⁵ : rank < t.rank
a✝⁴ : IsBinTree t
a✝³ : IsHeapForest' t.rank ts
x✝ :
  ∀
    (y :
      (rx : ℕ) ×'
        (xs : List (BinTree α)) ×'
          (ry : ℕ) ×' (ys : List (BinTree α)) ×' (_ : IsHeapForest' rx xs) ×' IsHeapForest' ry ys),
    (invImage
            (fun a ↦
              PSigma.casesOn a
                fun rx snd ↦
                  PSigma.casesOn snd
                    fun xs snd ↦
                      PSigma.casesOn snd
                        fun ry snd ↦
                          PSigma.casesOn snd
                            fun ys snd ↦ PSigma.casesOn snd fun hxs snd ↦ List.length xs + List.length ys)
            instWellFoundedRelation).1
        y
        { fst := rank✝,
          snd :=
            { fst := t✝ :: ts✝,
              snd :=
                { fst := rank,
                  snd :=
                    { fst := t :: ts,
                      snd :=
                        { fst := (_ : IsHeapForest' rank✝ (t✝ :: ts✝)),
                          snd := (_ : IsHeapForest' rank (t :: ts)) } } } } } →
      IsHeapForest' (min y.1 y.2.2.1) (mergeNodes le y.2.1 y.2.2.2.1)
h✝² : ry = rank
a✝² : ry < t.rank
h✝¹ : h₂ :: t₂ = t :: ts
head_eq✝ : h₂ = t
a✝¹ : IsBinTree h₂
hf₂✝ : IsHeapForest' h₂.rank ts
a✝ : ry < h₂.rank
tail_eq✝ : t₂ = ts
hf₂ : IsHeapForest' h₂.rank t₂
h✝ : HEq hys (_ : IsHeapForest' ry (h₂ :: t₂))
⊢ List.length t₁ + List.length t₂ < Nat.succ (List.length ts✝) + Nat.succ (List.length ts)