fact: Definition sink1 (L : list A) (j : nat) : (list A) * (option nat) := match nth_error L j, nth_error L (left_child j), nth_error L (right_child j) with | None, _, _ | Some _, None, _ => (L, None) | Some root, Some Left, None => if root <<=? Left then (L, None) else (exchange L j (left_child j), Some (left_child j)) | Some root, Some Left, Some Right => if Right <<=? Left then if root <<=? Right then (L, None) else (exchange L j (right_child j), Some (right_child j)) else if root <<=? Left then (L, None) else (exchange L j (left_child j), Some (left_child j)) end.
imports: Psatz List Arith.Div2 Even Relations RelationClasses PeanoNat Peano_dec Recdef Sorting Permutation Multiset