internlm/Lean-Github huggingface dataset:
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_left.refine_1.refine_1
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl_1 :
            2 * (2 * i + 1) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr :
            2 * (2 * i + 1) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 2] = false);
    IsHeap lt y (2 * i + 1)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_left x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_left x i y hi hl hr hx' hx h) hr_1 heap_right
⊢ ↑{ val := i, isLt := hi } < 2 * (2 * i + 1) + 1
Tactic:
exact trans (lt_child_left i) (lt_child_left (2*i+1))
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_left.refine_1.refine_2
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl_1 :
            2 * (2 * i + 1) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr :
            2 * (2 * i + 1) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 2] = false);
    IsHeap lt y (2 * i + 1)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_left x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_left x i y hi hl hr hx' hx h) hr_1 heap_right
⊢ ↑{ val := i, isLt := hi } < 2 * (2 * i + 1) + 2
Tactic:
exact trans (lt_child_left i) (lt_child_right (2*i+1))
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_left.refine_2.hjk
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl_1 :
            2 * (2 * i + 1) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr :
            2 * (2 * i + 1) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 2] = false);
    IsHeap lt y (2 * i + 1)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_left x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_left x i y hi hl hr hx' hx h) hr_1 heap_right
k : Nat
hk : k < Subarray.size y
hdk : Descendant (2 * i + 2) k
⊢ ↑{ val := 2 * i + 1, isLt := hl } ≠ k
Tactic:
. exact Nat.ne_of_lt <| trans (2*i+1).lt_succ_self hdk.le
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_left.refine_2.hik
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl_1 :
            2 * (2 * i + 1) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr :
            2 * (2 * i + 1) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 2] = false);
    IsHeap lt y (2 * i + 1)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_left x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_left x i y hi hl hr hx' hx h) hr_1 heap_right
k : Nat
hk : k < Subarray.size y
hdk : Descendant (2 * i + 2) k
⊢ ↑{ val := i, isLt := hi } ≠ k
Tactic:
exact Nat.ne_of_lt <| trans (lt_child_right i) hdk.le
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_left.refine_2.hjk
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * (2 * i + 1) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl_1 :
            2 * (2 * i + 1) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr :
            2 * (2 * i + 1) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
          lt y[2 * i + 1] y[2 * (2 * i + 1) + 2] = false);
    IsHeap lt y (2 * i + 1)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_left x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_left x i y hi hl hr hx' hx h) hr_1 heap_right
k : Nat
hk : k < Subarray.size y
hdk : Descendant (2 * i + 2) k
⊢ ↑{ val := 2 * i + 1, isLt := hl } ≠ k
Tactic:
exact Nat.ne_of_lt <| trans (2*i+1).lt_succ_self hdk.le
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_end_left
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y x : Subarray α
i : Nat
hi✝ : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = false
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt x[i] x[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_end_left x i hi✝ hl hr hx' hx) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt x[i] x[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_end_left x i hi✝ hl hr hx' hx) hr_1 heap_right
⊢ IsHeap lt x i
Tactic:
refine .node lt x i hr hx ?_ heap_left heap_right
Proof state after:
case node_end_left
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y x : Subarray α
i : Nat
hi✝ : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = false
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt x[i] x[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_end_left x i hi✝ hl hr hx' hx) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt x[i] x[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_end_left x i hi✝ hl hr hx' hx) hr_1 heap_right
⊢ lt x[i] x[2 * i + 2] = false
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_end_left
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y x : Subarray α
i : Nat
hi✝ : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = false
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt x[i] x[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_end_left x i hi✝ hl hr hx' hx) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt x[i] x[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_end_left x i hi✝ hl hr hx' hx) hr_1 heap_right
⊢ lt x[i] x[2 * i + 2] = false
Tactic:
exact LawfulLTBRel.ntrans hx <| LawfulLTBRel.asymm hx'
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_2
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
⊢ IsHeap lt y (2 * i + 2)
Tactic:
. show IsHeap lt y (2*i+2)
  refine IH ?_ ?_
  . refine heap_right.left.swap _ _ ?_ (lt_child_left (2*i+2))
    exact trans (lt_child_right i) (lt_child_left (2*i+2))
  . refine heap_right.right.swap _ _ ?_ (lt_child_right (2*i+2))
    exact trans (lt_child_right i) (lt_child_right (2*i+2))
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_1.hjk
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
k : Nat
hk : k < Subarray.size y
hdk : Descendant (2 * i + 1) k
⊢ ↑{ val := 2 * i + 2, isLt := hr } ≠ k
Tactic:
. dsimp; intro h; cases h; exact absurd hdk (Descendant.sibling_not i)
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_1.hik
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
k : Nat
hk : k < Subarray.size y
hdk : Descendant (2 * i + 1) k
⊢ ↑{ val := i, isLt := hi } ≠ k
Tactic:
exact Nat.ne_of_lt <| trans (lt_child_left i) hdk.le
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_1.hjk.refl
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
hk : 2 * i + 2 < Subarray.size y
hdk : Descendant (2 * i + 1) (2 * i + 2)
⊢ False
Tactic:
exact absurd hdk (Descendant.sibling_not i)
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_2.refine_2
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
⊢ IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)
Tactic:
. refine heap_right.right.swap _ _ ?_ (lt_child_right (2*i+2))
  exact trans (lt_child_right i) (lt_child_right (2*i+2))
Proof state after:
no goals
Theorem: Algdata.BinaryHeap.heapifyDown.OpSpec.is_heap
Proof state before:
case node_next_right.refine_2.refine_1
α : Type u
lt : α → α → Bool
inst✝ : LawfulLTBRel lt
x✝ : Subarray α
i✝ : Nat
y✝ x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀
    (heap_left :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 1))
    (heap_right :
      IsHeap lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * (2 * i + 2) + 2)),
    let _hy_left :=
      (_ :
        ∀
          (hl :
            2 * (2 * i + 2) + 1 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 1] = false);
    let _hy_right :=
      (_ :
        ∀
          (hr_1 :
            2 * (2 * i + 2) + 2 <
              Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
          lt y[2 * i + 2] y[2 * (2 * i + 2) + 2] = false);
    IsHeap lt y (2 * i + 2)
heap_left : IsHeap lt x (2 * i + 1)
heap_right : IsHeap lt x (2 * i + 2)
_hy_left : ∀ (hl_1 : 2 * i + 1 < Subarray.size x), lt y[i] y[2 * i + 1] = false :=
  fun hl_1 => not_lt_left (node_next_right x i y hi hl hr hx' hx h) hl_1 heap_left
_hy_right : ∀ (hr_1 : 2 * i + 2 < Subarray.size x), lt y[i] y[2 * i + 2] = false :=
  fun hr_1 => not_lt_right (node_next_right x i y hi hl hr hx' hx h) hr_1 heap_right
⊢ ↑{ val := i, isLt := hi } < 2 * (2 * i + 2) + 1
Tactic:
exact trans (lt_child_right i) (lt_child_left (2*i+2))
Proof state after:
no goals