:- module pqueue.
:- use_module assoc_list, builtin, int, list, pair, private_builtin, require, table_builtin.
:- type pqueue.pqueue(K, V)
	--->	empty 
	;	pqueue(int, K, V, pqueue.pqueue(K, V), pqueue.pqueue(K, V)).
:- pred pqueue.remove_2(pqueue.pqueue(K_1, V_2), pqueue.pqueue(K_1, V_2), pqueue.pqueue(K_1, V_2)).
:- mode pqueue.remove_2((builtin.in), (builtin.in), (builtin.out)) is det.
pqueue.init = PQ_2 :-
    pqueue.init(PQ_2).
pqueue.init(pqueue.empty).
pqueue.is_empty(pqueue.empty).
pqueue.insert(STATE_VARIABLE_PQ_0_8, K_6, V_7) = STATE_VARIABLE_PQ_9 :-
    pqueue.insert(K_6, V_7, STATE_VARIABLE_PQ_0_8, STATE_VARIABLE_PQ_9).
pqueue.peek(pqueue.pqueue(V_4, K_5, V_6, V_7, V_8), K_5, V_6).
pqueue.peek_key(pqueue.pqueue(V_3, K_4, V_5, V_6, V_7), K_4).
pqueue.peek_value(pqueue.pqueue(V_3, V_4, V_5, V_6, V_7), V_5).
pqueue.det_peek_key(PQ_3) = K_4 :-
    pqueue.det_peek(PQ_3, K_4, V_5).
pqueue.det_peek_value(PQ_3) = V_4 :-
    pqueue.det_peek(PQ_3, V_5, V_4).
pqueue.remove(K_5, V_6, pqueue.pqueue(V_7, K_5, V_6, L0_8, R0_9), PQ_10) :-
    pqueue.remove_2(L0_8, R0_9, PQ_10).
pqueue.merge(A_4, B_5) = C_6 :-
    pqueue.merge(A_4, B_5, C_6).
pqueue.to_assoc_list(PQ_3) = AL_4 :-
    pqueue.to_assoc_list(PQ_3, AL_4).
pqueue.assoc_list_to_pqueue(AL_3) = PQ2_4 :-
    pqueue.assoc_list_to_pqueue(AL_3, PQ2_4).
pqueue.from_assoc_list(List_3) = PQueue_4 :-
    pqueue.assoc_list_to_pqueue(List_3, PQueue_4).
pqueue.length(pqueue.empty) = 0.
pqueue.length(pqueue.pqueue(D_3, V_4, V_5, V_6, V_7)) = HeadVar__2_2 :-
    HeadVar__2_2 = int.(D_3 + V_8),
    V_8 = 1 : int.
:- pragma exceptions(function, (pqueue.init), 1, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.init), 1, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.is_empty), 1, 0, will_not_throw).
:- pragma exceptions(function, (pqueue.insert), 4, 0, conditional).
:- pragma exceptions(predicate, (pqueue.insert), 4, 0, conditional).
:- pragma exceptions(predicate, (pqueue.peek), 3, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.peek_key), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.peek_value), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.det_peek), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (pqueue.det_peek_key), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (pqueue.det_peek_value), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (pqueue.remove), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (pqueue.det_remove), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (pqueue.merge), 3, 0, conditional).
:- pragma exceptions(predicate, (pqueue.merge), 3, 0, conditional).
:- pragma exceptions(function, (pqueue.to_assoc_list), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (pqueue.to_assoc_list), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (pqueue.assoc_list_to_pqueue), 2, 0, conditional).
:- pragma exceptions(predicate, (pqueue.assoc_list_to_pqueue), 2, 0, conditional).
:- pragma exceptions(function, (pqueue.from_assoc_list), 2, 0, conditional).
:- pragma exceptions(function, (pqueue.length), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (pqueue.remove_2), 3, 0, may_throw(user_exception)).
:- pragma termination_info((pqueue.init) = (builtin.out), finite(0, [no, no, no]), cannot_loop).
:- pragma termination_info(pqueue.init((builtin.out)), finite(0, [no, no, no]), cannot_loop).
:- pragma termination_info(pqueue.is_empty((builtin.in)), finite(0, [no, no, no]), cannot_loop).
:- pragma termination_info(pqueue.insert((builtin.in), (builtin.in), (builtin.in)) = (builtin.out), finite(5, [no, no, yes, yes, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.insert((builtin.in), (builtin.in), (builtin.in), (builtin.out)), finite(5, [no, no, yes, yes, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.peek((builtin.in), (builtin.out), (builtin.out)), finite(-5, [no, no, yes, no, no]), cannot_loop).
:- pragma termination_info(pqueue.peek_key((builtin.in), (builtin.out)), finite(-5, [no, no, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.peek_value((builtin.in), (builtin.out)), finite(-5, [no, no, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.det_peek((builtin.in), (builtin.out), (builtin.out)), finite(-5, [no, no, yes, no, no]), can_loop).
:- pragma termination_info(pqueue.det_peek_key((builtin.in)) = (builtin.out), finite(-5, [no, no, yes, no]), can_loop).
:- pragma termination_info(pqueue.det_peek_value((builtin.in)) = (builtin.out), finite(-5, [no, no, yes, no]), can_loop).
:- pragma termination_info(pqueue.remove((builtin.out), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(pqueue.det_remove((builtin.out), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(pqueue.merge((builtin.in), (builtin.in)) = (builtin.out), finite(0, [no, no, yes, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.merge((builtin.in), (builtin.in), (builtin.out)), finite(0, [no, no, yes, yes, no]), cannot_loop).
:- pragma termination_info(pqueue.to_assoc_list((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(pqueue.to_assoc_list((builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(pqueue.assoc_list_to_pqueue((builtin.in)) = (builtin.out), infinite, cannot_loop).
:- pragma termination_info(pqueue.assoc_list_to_pqueue((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(pqueue.from_assoc_list((builtin.in)) = (builtin.out), infinite, cannot_loop).
:- pragma termination_info(pqueue.length((builtin.in)) = (builtin.out), finite(0, [no, no, no, no]), cannot_loop).
:- pragma termination_info(pqueue.remove_2((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
