(* This code extends 'mini_prelude'. *) type ('a) heap = Tree of int * 'a * ('a) heap * ('a) heap | Empty ;; let rank = (fun v5 -> (match v5 with Empty -> 0 | (Tree (v4, v3, v2, v1)) -> v4)) ;; let make_node = (fun v3 -> (fun v1 -> (fun v2 -> (if ((rank v1) > (rank v2)) then (Tree (((rank v2) + 1), v3, v1, v2)) else (Tree (((rank v1) + 1), v3, v2, v1)))))) ;; let empty = Empty ;; let is_empty = (fun v5 -> (match v5 with Empty -> true | (Tree (v4, v3, v2, v1)) -> false)) ;; let rec merge v13 = (fun v14 -> (fun v15 -> (fun v16 -> (match v15 with Empty -> (match v16 with Empty -> Empty | (Tree (v4, v3, v2, v1)) -> (Tree (v4, v3, v2, v1))) | (Tree (v12, v11, v10, v9)) -> (match v16 with Empty -> (Tree (v12, v11, v10, v9)) | (Tree (v8, v7, v6, v5)) -> (if ((v14 (v13 v11)) (v13 v7)) then (((make_node v11) v10) ((((merge v13) v14) v9) (Tree (v8, v7, v6, v5)))) else (((make_node v7) v6) ((((merge v13) v14) (Tree (v12, v11, v10, v9))) v5)))))))) ;; let insert = (fun v1 -> (fun v3 -> (fun v4 -> (fun v2 -> ((((merge v1) v3) (Tree (1, v4, Empty, Empty))) v2))))) ;; let find_min = (fun x1 -> (match x1 with Empty -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Tree (v4, v3, v2, v1)) -> v3)) ;; let delete_min = (fun x1 -> (fun x2 -> (fun x3 -> (match x3 with Empty -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Tree (v4, v3, v2, v1)) -> ((((merge x1) x2) v2) v1))))) ;;