Theorem: project.IsHeap_merge
Proof state before:
case neg
α : Type u_1
le : α → α → Bool
rx : ℕ
xs : List (BinTree α)
ry : ℕ
ys : List (BinTree α)
h₁ : BinTree α
t₁ : List (BinTree α)
h₂ : BinTree α
t₂ : List (BinTree α)
not_le_le : ∀ (x y : α), le x y = false → le y x = true
h✝³ : h₂.rank ≤ h₁.rank
h✝² : h₁.rank ≤ h₂.rank
h✝¹ : (h₁.rank + 1 != hRank t₁) = false
h✝ : (h₁.rank + 1 != hRank t₂) = false
heq : h₁.rank = h₂.rank
a✝³ : IsBinTree h₁
a✝² : rx < h₁.rank
hf : IsHeapForest' h₁.rank t₁
a✝¹ : IsBinTree h₂
a✝ : ry < h₂.rank
hf₂ : IsHeapForest' h₂.rank t₂
ih : IsHeapForest' (min h₁.rank h₂.rank) (mergeNodes le t₁ t₂)
hle : min (hRank t₁) (hRank t₂) ≤ hRank (mergeNodes le t₁ t₂)
h : ¬(t₁ = [] ∧ t₂ = [])
⊢ IsHeapForest' (h₁.rank + 1) (mergeNodes le t₁ t₂)
Tactic:
. apply IsHeapForest'_strengthen
  . apply ih
  . rw[Nat.min_eq] at hle
    split at hle
    . match hf₂ with
      | .nil =>
        rw[empty_heap_merge_right] at *
        match hf with
        | .nil =>
          contradiction
        | .cons (t := t) (ts := ts) _ _ _ =>
          rw[hrank_of_cons] at *
          unfold bne at *
          rw[Bool.not_eq_false', beq_iff_eq] at *
          simp at *
          contradiction
      | .cons (t := t) (ts := ts) _ _ _ => 
        match hf with
        | .nil => 
          rw[empty_heap_merge_left] at *
          rw[hrank_of_cons] at *
          unfold bne at *
          rw[Bool.not_eq_false', beq_iff_eq] at *
          simp at *
          contradiction
        | .cons (t := t₂) (ts := ts₂) _ _ _ =>
          repeat rw[hrank_of_cons] at *
          unfold bne at *
          rw[Bool.not_eq_false', beq_iff_eq] at *
          simp at *
          have ht₁ : IsHeapForest' h₁.rank (t₂ :: ts₂) := by
            apply IsHeapForest'_of_IsHeapForest' <;> assumption
          have ht₂ : IsHeapForest' h₁.rank (t :: ts) := by
            rw[← heq] at *
            apply IsHeapForest'_of_IsHeapForest' <;> assumption
          have : t₂.rank + 1 ≤ hRank (mergeNodes le (t₂ :: ts₂) (t :: ts)) := by
            apply hRank_mergeNodes_cons ht₁ ht₂
            simp_all
          rename_i heq₂ _
          rw[heq₂]
          apply Nat.lt_of_succ_le this
    . match hf₂ with
      | .nil =>
        rw[empty_heap_merge_right] at *
        cases hf
        . contradiction
        . rw[hrank_of_cons] at *
          unfold bne at *
          rw[Bool.not_eq_false', beq_iff_eq] at *
          simp at *
          contradiction
      | .cons (t := t) (ts := ts) _ _ _ =>
        rw[hrank_of_cons] at *
        unfold bne at *
        rw[Bool.not_eq_false', beq_iff_eq] at *
        simp at *
        match hf with
        | .nil =>
          contradiction
        | .cons (t := t₂) (ts := ts₂) _ _ _ =>
          rw[hrank_of_cons] at *
          simp at *
          have ht₁ : IsHeapForest' h₁.rank (t₂ :: ts₂) := by
            apply IsHeapForest'_of_IsHeapForest' <;> assumption
          have ht₂ : IsHeapForest' h₁.rank (t :: ts) := by
            rw[← heq] at *
            apply IsHeapForest'_of_IsHeapForest' <;> assumption
          have : t₂.rank + 1 ≤ hRank (mergeNodes le (t₂ :: ts₂) (t :: ts)) := by
            apply hRank_mergeNodes_cons ht₁ ht₂
            simp_all
          rename_i heq₂ _
          rw[heq₂]
          apply Nat.lt_of_succ_le this
Proof state after:
no goals