(* This code extends 'mini_prelude'. *) let empty = Nil ;; let is_empty = (fun v3 -> (match v3 with Nil -> true | (Cons (v2, v1)) -> false)) ;; type ('a) tree = Node of int * 'a * (('a) tree) list ;; let rank = (fun v4 -> (match v4 with (Node (v3, v2, v1)) -> v3)) ;; let root = (fun v4 -> (match v4 with (Node (v3, v2, v1)) -> v2)) ;; let link = (fun v8 -> (fun v9 -> (fun v10 -> (fun v7 -> (match v10 with (Node (v6, v5, v4)) -> (match v7 with (Node (v3, v2, v1)) -> (if ((v9 (v8 v5)) (v8 v2)) then (Node ((v6 + 1), v5, (Cons ((Node (v3, v2, v1)), v4)))) else (Node ((v6 + 1), v2, (Cons ((Node (v6, v5, v4)), v1))))))))))) ;; let rec ins_tree v3 = (fun v4 -> (fun v5 -> (fun v6 -> (match v6 with Nil -> (Cons (v5, Nil)) | (Cons (v2, v1)) -> (if ((rank v5) < (rank v2)) then (Cons (v5, (Cons (v2, v1)))) else ((((ins_tree v3) v4) ((((link v3) v4) v5) v2)) v1)))))) ;; let insert = (fun v1 -> (fun v2 -> (fun v4 -> (fun v3 -> ((((ins_tree v1) v2) (Node (0, v4, Nil))) v3))))) ;; let rec merge v8 = (fun v9 -> (fun v10 -> (fun v7 -> (match v10 with Nil -> (match v7 with Nil -> Nil | (Cons (v2, v1)) -> (Cons (v2, v1))) | (Cons (v6, v5)) -> (match v7 with Nil -> (Cons (v6, v5)) | (Cons (v4, v3)) -> (if ((rank v6) < (rank v4)) then (Cons (v6, ((((merge v8) v9) v5) (Cons (v4, v3))))) else (if ((rank v4) < (rank v6)) then (Cons (v4, ((((merge v8) v9) (Cons (v6, v5))) v3))) else ((((ins_tree v8) v9) ((((link v8) v9) v6) v4)) ((((merge v8) v9) v5) v3))))))))) ;; let rec remove_min_tree x = (fun x1 -> (fun x2 -> (match x2 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v7, v6)) -> (match v6 with Nil -> (Pair (v7, Nil)) | (Cons (v5, v4)) -> (let v3 = (((remove_min_tree x) x1) (Cons (v5, v4))) in (match v3 with (Pair (v2, v1)) -> (if ((x1 (x (root v7))) (x (root v2))) then (Pair (v7, (Cons (v5, v4)))) else (Pair (v2, (Cons (v7, v1))))))))))) ;; let find_min = (fun v4 -> (fun v5 -> (fun v6 -> (let v3 = (((remove_min_tree v4) v5) v6) in (match v3 with (Pair (v2, v1)) -> (root v2)))))) ;; let delete_min = (fun v6 -> (fun v7 -> (fun v8 -> (match (((remove_min_tree v6) v7) v8) with (Pair (v5, v4)) -> (match v5 with (Node (v3, v2, v1)) -> ((((merge v6) v7) (REVERSE v1)) v4)))))) ;;