:- module varset.
:- use_module assoc_list, builtin, int, list, map, maybe, pair, private_builtin, require, set, string, term.
:- type varset.varset(T)
	--->	varset((varset.var_supply) :: term.var_supply(T), (varset.var_names) :: tree234.tree234(term.var(T), string), (varset.var_values) :: tree234.tree234(term.var(T), term.term(T))).
:- pred varset.new_vars_2(int, list.list(term.var(T_1)), list.list(term.var(T_1)), varset.varset(T_1), varset.varset(T_1)).
:- mode varset.new_vars_2((builtin.in), (builtin.in), (builtin.out), (builtin.in), (builtin.out)) is det.
:- pred varset.bind_vars_2(list.list(pair.pair(term.var(T_1), term.term(T_1))), varset.varset(T_1), varset.varset(T_1)).
:- mode varset.bind_vars_2((builtin.in), (builtin.in), (builtin.out)) is det.
varset.init = VS_2 :-
    varset.init(VS_2).
varset.init(varset.varset(VarSupply_2, Names_3, Values_4)) :-
    term.init_var_supply(VarSupply_2),
    map.init(Names_3),
    map.init(Values_4).
varset.is_empty(varset.varset(VarSupply_2, V_3, V_4)) :-
    term.init_var_supply(VarSupply_2).
varset.new_named_var(Name_5, Var_6, varset.varset(STATE_VARIABLE_MaxId_0_10, STATE_VARIABLE_Names_0_11, Values_9), varset.varset(STATE_VARIABLE_MaxId_12, STATE_VARIABLE_Names_13, Values_9)) :-
    term.create_var(Var_6, STATE_VARIABLE_MaxId_0_10, STATE_VARIABLE_MaxId_12),
    map.set(Var_6, Name_5, STATE_VARIABLE_Names_0_11, STATE_VARIABLE_Names_13).
varset.new_vars(NumVars_5, NewVars_6, STATE_VARIABLE_VarSet_0_9, STATE_VARIABLE_VarSet_10) :-
    V_11 = list.[] : list.list(term.var(T_1)),
    varset.new_vars_2(NumVars_5, V_11, RevNewVars_8, STATE_VARIABLE_VarSet_0_9, STATE_VARIABLE_VarSet_10),
    list.reverse(RevNewVars_8, NewVars_6).
varset.delete_var(STATE_VARIABLE_VS_0_6, V_5) = STATE_VARIABLE_VS_7 :-
    varset.delete_var(V_5, STATE_VARIABLE_VS_0_6, STATE_VARIABLE_VS_7).
varset.delete_var(DeleteVar_4, STATE_VARIABLE_VarSet_0_11, STATE_VARIABLE_VarSet_12) :-
    STATE_VARIABLE_VarSet_0_11 = varset.varset(MaxId_6, Names0_7, Values0_8) : varset.varset(T_1),
    map.delete(DeleteVar_4, Names0_7, Names_9),
    map.delete(DeleteVar_4, Values0_8, Values_10),
    STATE_VARIABLE_VarSet_12 = varset.varset(MaxId_6, Names_9, Values_10) : varset.varset(T_1).
varset.delete_vars(STATE_VARIABLE_VS_0_6, Vs_5) = STATE_VARIABLE_VS_7 :-
    varset.delete_vars(Vs_5, STATE_VARIABLE_VS_0_6, STATE_VARIABLE_VS_7).
varset.delete_vars(DeleteVars_4, STATE_VARIABLE_VarSet_0_11, STATE_VARIABLE_VarSet_12) :-
    STATE_VARIABLE_VarSet_0_11 = varset.varset(MaxId_6, Names0_7, Values0_8) : varset.varset(T_1),
    map.delete_list(DeleteVars_4, Names0_7, Names_9),
    map.delete_list(DeleteVars_4, Values0_8, Values_10),
    STATE_VARIABLE_VarSet_12 = varset.varset(MaxId_6, Names_9, Values_10) : varset.varset(T_1).
varset.delete_sorted_vars(STATE_VARIABLE_VS_0_6, Vs_5) = STATE_VARIABLE_VS_7 :-
    varset.delete_sorted_vars(Vs_5, STATE_VARIABLE_VS_0_6, STATE_VARIABLE_VS_7).
varset.delete_sorted_vars(DeleteVars_4, STATE_VARIABLE_VarSet_0_11, STATE_VARIABLE_VarSet_12) :-
    STATE_VARIABLE_VarSet_0_11 = varset.varset(MaxId_6, Names0_7, Values0_8) : varset.varset(T_1),
    map.delete_sorted_list(DeleteVars_4, Names0_7, Names_9),
    map.delete_sorted_list(DeleteVars_4, Values0_8, Values_10),
    STATE_VARIABLE_VarSet_12 = varset.varset(MaxId_6, Names_9, Values_10) : varset.varset(T_1).
varset.vars(VS_3) = Vs_4 :-
    varset.vars(VS_3, Vs_4).
varset.name_var(STATE_VARIABLE_VS_0_8, V_6, S_7) = STATE_VARIABLE_VS_9 :-
    varset.name_var(V_6, S_7, STATE_VARIABLE_VS_0_8, STATE_VARIABLE_VS_9).
varset.lookup_name(VS_4, V_5) = S_6 :-
    varset.lookup_name(VS_4, V_5, S_6).
varset.lookup_name(VS1_5, V_6, S_7) = S2_8 :-
    varset.lookup_name(VS1_5, V_6, S_7, S2_8).
varset.search_name(varset.varset(V_4, Names_5, V_6), Id_7, Name_8) :-
    map.search(Names_5, Id_7, Name_8).
varset.bind_var(STATE_VARIABLE_VS_0_8, V_6, T_7) = STATE_VARIABLE_VS_9 :-
    varset.bind_var(V_6, T_7, STATE_VARIABLE_VS_0_8, STATE_VARIABLE_VS_9).
varset.bind_vars(STATE_VARIABLE_VS_0_6, S_5) = STATE_VARIABLE_VS_7 :-
    varset.bind_vars(S_5, STATE_VARIABLE_VS_0_6, STATE_VARIABLE_VS_7).
varset.bind_vars(Subst_4, STATE_VARIABLE_VarSet_0_7, STATE_VARIABLE_VarSet_8) :-
    map.to_assoc_list(Subst_4, VarTermList_6),
    varset.bind_vars_2(VarTermList_6, STATE_VARIABLE_VarSet_0_7, STATE_VARIABLE_VarSet_8).
varset.search_var(VarSet_4, Id_5, Val_6) :-
    VarSet_4 = varset.varset(V_8, V_9, Values_7) : varset.varset(T_1),
    map.search(Values_7, Id_5, Val_6).
varset.lookup_vars(VS_3) = S_4 :-
    varset.lookup_vars(VS_3, S_4).
varset.lookup_vars(VarSet_3, HeadVar__2_2) :-
    VarSet_3 = varset.varset(V_4, V_5, HeadVar__2_2) : varset.varset(T_1).
varset.merge(VarSetA_6, VarSetB_7, TermList0_8, VarSet_9, TermList_10) :-
    varset.merge_subst(VarSetA_6, VarSetB_7, VarSet_9, Subst_11),
    term.apply_substitution_to_list(TermList0_8, Subst_11, TermList_10).
varset.merge_without_names(VarSetA_6, VarSetB_7, TermList0_8, VarSet_9, TermList_10) :-
    varset.merge_subst_without_names(VarSetA_6, VarSetB_7, VarSet_9, Subst_11),
    term.apply_substitution_to_list(TermList0_8, Subst_11, TermList_10).
varset.get_bindings(VS_3) = S_4 :-
    varset.get_bindings(VS_3, S_4).
varset.get_bindings(VarSet_3, HeadVar__2_2) :-
    VarSet_3 = varset.varset(V_4, V_5, HeadVar__2_2) : varset.varset(T_1).
varset.set_bindings(VS1_4, S_5) = VS2_6 :-
    varset.set_bindings(VS1_4, S_5, VS2_6).
varset.set_bindings(VarSet_4, Values_5, HeadVar__3_3) :-
    (
    % barrier(removable)
      VarSet_4 = varset.varset(V_6, V_7, V_8) : varset.varset(T_1),
      HeadVar__3_3 = varset.varset(V_6, V_7, Values_5) : varset.varset(T_1)
    ).
varset.create_name_var_map(VS_3) = M_4 :-
    varset.create_name_var_map(VS_3, M_4).
varset.create_name_var_map(VarSet_3, NameVars_4) :-
    VarSet_3 = varset.varset(V_8, VarNames_5, V_9) : varset.varset(T_1),
    map.keys(VarNames_5, Vars_6),
    map.values(VarNames_5, Names_7),
    map.from_corresponding_lists(Names_7, Vars_6, NameVars_4).
varset.var_name_list(VS_3) = AL_4 :-
    varset.var_name_list(VS_3, AL_4).
varset.var_name_list(VarSet_3, VarNameList_4) :-
    VarSet_3 = varset.varset(V_6, VarNames_5, V_7) : varset.varset(T_1),
    map.to_assoc_list(VarNames_5, VarNameList_4).
varset.ensure_unique_names(Vs_5, S1_6, VS1_7) = VS2_8 :-
    varset.ensure_unique_names(Vs_5, S1_6, VS1_7, VS2_8).
varset.select(STATE_VARIABLE_VS_0_6, S_5) = STATE_VARIABLE_VS_7 :-
    varset.select(S_5, STATE_VARIABLE_VS_0_6, STATE_VARIABLE_VS_7).
varset.select(Vars_4, VarSet0_5, VarSet_6) :-
    VarSet0_5 = varset.varset(Supply_7, VarNameMap0_8, Values0_9) : varset.varset(T_1),
    map.select(VarNameMap0_8, Vars_4, VarNameMap_10),
    map.select(Values0_9, Vars_4, Values_11),
    VarSet_6 = varset.varset(Supply_7, VarNameMap_10, Values_11) : varset.varset(T_1).
varset.coerce(STATE_VARIABLE_VS_0_4) = STATE_VARIABLE_VS_5 :-
    varset.coerce(STATE_VARIABLE_VS_0_4, STATE_VARIABLE_VS_5).
varset.max_var(varset.varset(VarSupply_3, V_4, V_5)) = HeadVar__2_2 :-
    HeadVar__2_2 = term.var_supply_max_var(VarSupply_3).
varset.num_allocated(varset.varset(VarSupply_3, V_4, V_5)) = HeadVar__2_2 :-
    HeadVar__2_2 = term.var_supply_num_allocated(VarSupply_3).
:- pragma exceptions(function, (varset.init), 1, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.init), 1, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.is_empty), 1, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_var), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_named_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_uniquely_named_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_maybe_named_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_vars), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.delete_var), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.delete_var), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.delete_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.delete_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.delete_sorted_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.delete_sorted_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.vars), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.vars), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.name_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.name_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.lookup_name), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.lookup_name), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.lookup_name), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.lookup_name), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.search_name), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.bind_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.bind_var), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.bind_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.bind_vars), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.search_var), 3, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.lookup_vars), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (varset.lookup_vars), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (varset.merge_renaming), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.merge_subst), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.merge), 5, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.merge_renaming_without_names), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.merge_subst_without_names), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.merge_without_names), 5, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.get_bindings), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (varset.get_bindings), 2, 0, will_not_throw).
:- pragma exceptions(function, (varset.set_bindings), 3, 0, will_not_throw).
:- pragma exceptions(predicate, (varset.set_bindings), 3, 0, will_not_throw).
:- pragma exceptions(function, (varset.create_name_var_map), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.create_name_var_map), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.var_name_list), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.var_name_list), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.ensure_unique_names), 4, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.ensure_unique_names), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.select), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.select), 3, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.squash), 4, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.coerce), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (varset.coerce), 2, 0, will_not_throw).
:- pragma exceptions(function, (varset.max_var), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (varset.num_allocated), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.new_vars_2), 5, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (varset.bind_vars_2), 3, 0, may_throw(user_exception)).
:- pragma termination_info((varset.init) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.init((builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.is_empty((builtin.in)), finite(0, [no, no]), can_loop).
:- pragma termination_info(varset.new_var((builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.new_named_var((builtin.in), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.new_uniquely_named_var((builtin.in), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.new_maybe_named_var((builtin.in), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.new_vars((builtin.in), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.delete_var((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.delete_var((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.delete_vars((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.delete_vars((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.delete_sorted_vars((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.delete_sorted_vars((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.vars((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.vars((builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.name_var((builtin.in), (builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.name_var((builtin.in), (builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.lookup_name((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.lookup_name((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.lookup_name((builtin.in), (builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.lookup_name((builtin.in), (builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.search_name((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.bind_var((builtin.in), (builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.bind_var((builtin.in), (builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.bind_vars((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.bind_vars((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.search_var((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.lookup_vars((builtin.in)) = (builtin.out), finite(-3, [no, yes, no]), cannot_loop).
:- pragma termination_info(varset.lookup_vars((builtin.in), (builtin.out)), finite(-3, [no, yes, no]), cannot_loop).
:- pragma termination_info(varset.merge_renaming((builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.merge_subst((builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.merge((builtin.in), (builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.merge_renaming_without_names((builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.merge_subst_without_names((builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.merge_without_names((builtin.in), (builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.get_bindings((builtin.in)) = (builtin.out), finite(-3, [no, yes, no]), cannot_loop).
:- pragma termination_info(varset.get_bindings((builtin.in), (builtin.out)), finite(-3, [no, yes, no]), cannot_loop).
:- pragma termination_info(varset.set_bindings((builtin.in), (builtin.in)) = (builtin.out), finite(0, [no, yes, yes, no]), cannot_loop).
:- pragma termination_info(varset.set_bindings((builtin.in), (builtin.in), (builtin.out)), finite(0, [no, yes, yes, no]), cannot_loop).
:- pragma termination_info(varset.create_name_var_map((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.create_name_var_map((builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.var_name_list((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.var_name_list((builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.ensure_unique_names((builtin.in), (builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.ensure_unique_names((builtin.in), (builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.select((builtin.in), (builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.select((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.squash((builtin.in), (builtin.in), (builtin.out), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.coerce((builtin.in)) = (builtin.out), infinite, cannot_loop).
:- pragma termination_info(varset.coerce((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(varset.max_var((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.num_allocated((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(varset.new_vars_2((builtin.in), (builtin.in), (builtin.out), (builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(varset.bind_vars_2((builtin.in), (builtin.in), (builtin.out)), infinite, can_loop).
