:- module (mdb.declarative_execution).
:- interface.
:- import_module bool.
:- import_module io.
:- import_module list.
:- import_module maybe.
:- import_module (mdb.term_rep).
:- import_module (mdbcomp.prim_data).
:- import_module (mdbcomp.program_representation).
:- import_module (mdbcomp.rtti_access).
:- type event_number == int.
:- type goal_status
	--->	succeeded 
	;	failed 
	;	undecided .
:- type implicit_tree_info
	--->	implicit_tree_info(((mdb.declarative_execution).ideal_depth) :: int).
:- type sequence_number == int.
:- type suspicion_accumulator == int.
:- type trace_atom
	--->	atom(((mdb.declarative_execution).proc_layout) :: mdbcomp.rtti_access.proc_layout, ((mdb.declarative_execution).atom_args) :: list.list(mdb.declarative_execution.trace_atom_arg)).
:- type trace_atom_arg
	--->	arg_info(((mdb.declarative_execution).prog_visible) :: bool.bool, ((mdb.declarative_execution).prog_vis_headvar_num) :: int, ((mdb.declarative_execution).arg_value) :: maybe.maybe(mdb.term_rep.term_rep)).
:- type trace_node_id.
:- type trace_node_key.
:- type trace_node_map.
:- type trace_node_store.
:- type which_headvars
	--->	all_headvars 
	;	only_user_headvars .
:- type trace_node(R)
	--->	node_call(((mdb.declarative_execution).call_preceding) :: R, ((mdb.declarative_execution).call_last_interface) :: R, ((mdb.declarative_execution).call_atom_args) :: list.list(mdb.declarative_execution.trace_atom_arg), ((mdb.declarative_execution).call_seq) :: mdb.declarative_execution.sequence_number, ((mdb.declarative_execution).call_event) :: mdb.declarative_execution.event_number, ((mdb.declarative_execution).call_at_max_depth) :: maybe.maybe(mdb.declarative_execution.implicit_tree_info), ((mdb.declarative_execution).call_return_label) :: maybe.maybe(mdbcomp.rtti_access.label_layout), ((mdb.declarative_execution).call_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).call_io_seq_num) :: int, ((mdb.declarative_execution).call_suspicion) :: mdb.declarative_execution.suspicion_accumulator)
	;	node_exit(((mdb.declarative_execution).exit_preceding) :: R, ((mdb.declarative_execution).exit_call) :: R, ((mdb.declarative_execution).exit_prev_redo) :: R, ((mdb.declarative_execution).exit_atom_args) :: list.list(mdb.declarative_execution.trace_atom_arg), ((mdb.declarative_execution).exit_event) :: mdb.declarative_execution.event_number, ((mdb.declarative_execution).exit_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).exit_io_seq_num) :: int, ((mdb.declarative_execution).exit_suspicion) :: mdb.declarative_execution.suspicion_accumulator)
	;	node_redo(((mdb.declarative_execution).redo_preceding) :: R, ((mdb.declarative_execution).redo_exit) :: R, ((mdb.declarative_execution).redo_event) :: mdb.declarative_execution.event_number, ((mdb.declarative_execution).redo_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).redo_suspicion) :: mdb.declarative_execution.suspicion_accumulator)
	;	node_fail(((mdb.declarative_execution).fail_preceding) :: R, ((mdb.declarative_execution).fail_call) :: R, ((mdb.declarative_execution).fail_redo) :: R, ((mdb.declarative_execution).fail_event) :: mdb.declarative_execution.event_number, ((mdb.declarative_execution).fail_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).fail_suspicion) :: mdb.declarative_execution.suspicion_accumulator)
	;	node_excp(((mdb.declarative_execution).excp_preceding) :: R, ((mdb.declarative_execution).excp_call) :: R, ((mdb.declarative_execution).excp_redo) :: R, ((mdb.declarative_execution).excp_value) :: mdb.term_rep.term_rep, ((mdb.declarative_execution).excp_event) :: mdb.declarative_execution.event_number, ((mdb.declarative_execution).excp_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).excp_suspicion) :: mdb.declarative_execution.suspicion_accumulator)
	;	node_switch(((mdb.declarative_execution).switch_preceding) :: R, ((mdb.declarative_execution).switch_label) :: mdbcomp.rtti_access.label_layout)
	;	node_first_disj(((mdb.declarative_execution).first_disj_preceding) :: R, ((mdb.declarative_execution).first_disj_label) :: mdbcomp.rtti_access.label_layout)
	;	node_later_disj(((mdb.declarative_execution).later_disj_preceding) :: R, ((mdb.declarative_execution).later_disj_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).later_disj_first) :: R)
	;	node_cond(((mdb.declarative_execution).cond_preceding) :: R, ((mdb.declarative_execution).cond_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).cond_status) :: mdb.declarative_execution.goal_status)
	;	node_then(((mdb.declarative_execution).then_preceding) :: R, ((mdb.declarative_execution).then_cond) :: R, ((mdb.declarative_execution).then_label) :: mdbcomp.rtti_access.label_layout)
	;	node_else(((mdb.declarative_execution).else_preceding) :: R, ((mdb.declarative_execution).else_cond) :: R, ((mdb.declarative_execution).else_label) :: mdbcomp.rtti_access.label_layout)
	;	node_neg(((mdb.declarative_execution).neg_preceding) :: R, ((mdb.declarative_execution).neg_label) :: mdbcomp.rtti_access.label_layout, ((mdb.declarative_execution).neg_status) :: mdb.declarative_execution.goal_status)
	;	node_neg_succ(((mdb.declarative_execution).neg_succ_preceding) :: R, ((mdb.declarative_execution).neg_succ_enter) :: R, ((mdb.declarative_execution).neg_succ_label) :: mdbcomp.rtti_access.label_layout)
	;	node_neg_fail(((mdb.declarative_execution).neg_fail_preceding) :: R, ((mdb.declarative_execution).neg_fail_enter) :: R, ((mdb.declarative_execution).neg_fail_label) :: mdbcomp.rtti_access.label_layout).
:- inst (trace_node_call) == bound(node_call(ground, ground, ground, ground, ground, ground, ground, ground, ground, ground)).
:- inst (trace_node_cond) == bound(node_cond(ground, ground, ground)).
:- inst (trace_node_disj) == bound(node_first_disj(ground, ground) ; node_later_disj(ground, ground, ground)).
:- inst (trace_node_exit) == bound(node_exit(ground, ground, ground, ground, ground, ground, ground, ground)).
:- inst (trace_node_first_disj) == bound(node_first_disj(ground, ground)).
:- inst (trace_node_neg) == bound(node_neg(ground, ground, ground)).
:- inst (trace_node_redo) == bound(node_redo(ground, ground, ground, ground, ground)).
:- typeclass annotated_trace(S, R).
:- instance ((mdb.declarative_execution).annotated_trace(mdb.declarative_execution.trace_node_map, mdb.declarative_execution.trace_node_key)).
:- instance ((mdb.declarative_execution).annotated_trace(mdb.declarative_execution.trace_node_store, mdb.declarative_execution.trace_node_id)).
