Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
explain.h
Go to the documentation of this file.
1 /*************************************************************************
2  * PLEASE SEE THE FILE "license.txt" (INCLUDED WITH THIS SOFTWARE PACKAGE)
3  * FOR LICENSE AND COPYRIGHT INFORMATION.
4  *************************************************************************/
5 
6 /*************************************************************************
7  *
8  * file: explain.h
9  *
10  * =======================================================================
11  */
12 
13 #ifndef EXPLAIN_H
14 #define EXPLAIN_H
15 
16 #ifdef __cplusplus
17 //extern "C"
18 //{
19 #endif
20 
21 typedef char Bool;
22 typedef signed short goal_stack_level;
23 typedef struct condition_struct condition;
24 typedef struct action_struct action;
26 typedef struct cons_struct cons;
27 typedef struct wme_struct wme;
28 typedef struct agent_struct agent;
29 typedef union symbol_union Symbol;
30 
31 /*
32  For each chunk (or justification) take a copy of its conds and actions,
33  and the list of productions which were backtraced through in creating it.
34  Also keep a list of all of the grounds (WMEs in the supergoal) which were
35  tested as the chunk was formed.
36 */
37 
38 typedef struct explain_chunk_struct {
39 #define EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE 256
40  char name[EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE]; /* Name of this chunk/justification */
41  condition *conds; /* Variablized list of conditions */
42  action *actions; /* Variablized list of actions */
43  struct backtrace_struct *backtrace; /* List of back traced productions */
44  struct explain_chunk_struct *next_chunk; /* Next chunk in the list */
45  condition *all_grounds; /* All conditions which go to LHS --
46  must be in same order as the chunk's
47  conditions. */
49 /* AGR 564 ends */
50 
51 /* RBD added decl's of these routines because they were called from files
52  other than explain.c. I don't know what they do. */
53 extern void init_explain (agent* thisAgent);
54 extern void reset_backtrace_list (agent* thisAgent);
55 condition * copy_cond_list(agent* thisAgent, condition *top_list);
56 condition *copy_conds_from_list(agent* thisAgent, cons *top_list);
57 extern void explain_add_temp_to_backtrace_list (agent* thisAgent, backtrace_str *temp,
58  cons *grounds, cons *pots, cons *locals, cons *negateds);
59 extern void explain_add_temp_to_chunk_list(agent* thisAgent, explain_chunk_str *temp);
60 extern void free_explain_chunk(agent* thisAgent, explain_chunk_str *chunk);
61 extern void reset_explain (agent* thisAgent);
62 extern explain_chunk_str *find_chunk(agent* thisAgent, explain_chunk_str *chunk, char *name);
63 extern condition *find_ground(agent* thisAgent, explain_chunk_str *chunk, int number);
64 extern void explain_trace_chunk(agent* thisAgent, explain_chunk_str *chunk);
65 extern void explain_trace_named_chunk (agent* thisAgent, char *chunk_name);
66 extern condition *explain_find_cond(condition *target, condition *cond_list);
67 extern void explain_trace(agent* thisAgent, char *chunk_name, backtrace_str *prod_list, condition *ground);
68 extern void explain_chunk (agent* thisAgent, char *chunk_name, int cond_number);
69 extern void explain_cond_list (agent* thisAgent, char *chunk_name);
70 extern void explain_list_chunks (agent* thisAgent);
71 extern void explain_full_trace (agent* thisAgent);
72 /* REW: begin 08.20.97 */
73 
74 /* Export ms_change structure to entire code in order to include pointers to
75  assertion and retractions lists directly on goals. */
76 
77 /* BUGBUG ms changes only really need tok (the tok from the p-node),
78  not a tok+wme pair. Need to change the firer for this though. */
79 
80 /* --- info about a change to the match set --- */
81 typedef struct ms_change_struct {
82  struct ms_change_struct *next; /* dll for all p nodes */
84  struct ms_change_struct *next_of_node; /* dll for just this p node */
86  struct rete_node_struct *p_node; /* for retractions, this can be NIL
87  if the p_node has been excised */
88  struct token_struct *tok; /* for assertions only */
89 
90  wme *w; /* for assertions only */
91  struct instantiation_struct *inst; /* for retractions only */
92 /* REW: begin 08.20.97 */
94  goal_stack_level level; /* Level of the match of the assertion or retraction */
95  struct ms_change_struct *next_in_level; /* dll for goal level */
97 /* REW: end 08.20.97 */
98 } ms_change;
99 /* REW: end 08.20.97 */
100 
101  /* we really only needs these for interface.c, so maybe just
102  * explicitly include them there and get rid of this file... kjc */
103 
104 /* About 80 lines of stuff deleted. AGR 564 2-May-94 */
105 
106 /* KBS commented this out -- redundant with agent variable */
107 /* extern Bool explain_flag; Flag for whether we're explaining or not */
108 
109 /* added code related to explain.cpp back in (above) -ajc (5/1/02) */
110 
111 extern Bool explain_interface_routine (void);
112 extern char *help_on_explain[];
113 
114 #ifdef __cplusplus
115 //}
116 #endif
117 
118 #endif