Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Macros | Functions
chunk.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include "chunk.h"
#include "symtab.h"
#include "wmem.h"
#include "gdatastructs.h"
#include "kernel.h"
#include "agent.h"
#include "instantiations.h"
#include "production.h"
#include "rhsfun.h"
#include "print.h"
#include "init_soar.h"
#include "prefmem.h"
#include "decide.h"
#include "explain.h"
#include "backtrace.h"
#include "recmem.h"
#include "rete.h"
#include "xml.h"
#include "soar_TraceNames.h"
#include "wma.h"
#include <ctype.h>

Go to the source code of this file.

Macros

#define BUFFER_GEN_CHUNK_NAME_SIZE   512
#define BUFFER_IMPASS_NAME_SIZE   32

Functions

void add_goal_or_impasse_tests (agent *thisAgent, chunk_cond *all_ccs)
void add_pref_to_results (agent *thisAgent, preference *pref)
void add_results_for_id (agent *thisAgent, Symbol *id)
void add_results_if_needed (agent *thisAgent, Symbol *sym)
Bool add_to_chunk_cond_set (agent *thisAgent, chunk_cond_set *set, chunk_cond *new_cc)
void build_chunk_conds_for_grounds_and_add_negateds (agent *thisAgent, chunk_cond **dest_top, chunk_cond **dest_bottom, tc_number tc_to_use, bool *reliable)
void chunk_instantiation (agent *thisAgent, instantiation *inst, bool dont_variablize, instantiation **custom_inst_list)
actioncopy_and_variablize_result_list (agent *thisAgent, preference *pref, bool variablize)
Symbolfind_goal_at_goal_stack_level (agent *thisAgent, goal_stack_level level)
Symbolfind_impasse_wme_value (Symbol *id, Symbol *attr)
Symbolgenerate_chunk_name_sym_constant (agent *thisAgent, instantiation *inst)
not_structget_nots_for_instantiated_conditions (agent *thisAgent, list *instantiations_with_nots, tc_number tc_of_grounds)
preferenceget_results_for_instantiation (agent *thisAgent, instantiation *inst)
void init_chunk_cond_set (chunk_cond_set *set)
void init_chunker (agent *thisAgent)
chunk_condmake_chunk_cond_for_condition (agent *thisAgent, condition *cond)
void make_clones_of_results (agent *thisAgent, preference *results, instantiation *chunk_inst)
void remove_from_chunk_cond_set (chunk_cond_set *set, chunk_cond *cc)
void reorder_instantiated_conditions (chunk_cond *top_cc, condition **dest_inst_top, condition **dest_inst_bottom)
bool should_variablize (agent *thisAgent, instantiation *inst)
void variablize_condition_list (agent *thisAgent, condition *cond)
void variablize_nots_and_insert_into_conditions (agent *thisAgent, not_struct *nots, condition *conds)
void variablize_symbol (agent *thisAgent, Symbol **sym)
void variablize_test (agent *thisAgent, test *t)

Macro Definition Documentation

#define BUFFER_GEN_CHUNK_NAME_SIZE   512
#define BUFFER_IMPASS_NAME_SIZE   32

Function Documentation

void add_goal_or_impasse_tests ( agent thisAgent,
chunk_cond all_ccs 
)
void add_pref_to_results ( agent thisAgent,
preference pref 
)

Definition at line 88 of file chunk.cpp.

References add_results_if_needed(), preference_struct::attr, preference_struct::id, preference_struct::inst, instantiation_struct::match_goal_level, preference_struct::next_clone, preference_struct::next_result, NIL, preference_is_binary(), preference_is_unary(), preference_struct::prev_clone, preference_struct::referent, agent_struct::results, agent_struct::results_match_goal_level, preference_struct::type, and preference_struct::value.

Referenced by add_results_for_id(), and get_results_for_instantiation().

{
/* --- if an equivalent pref is already a result, don't add this one --- */
for (p=thisAgent->results; p!=NIL; p=p->next_result) {
if (p->id!=pref->id) continue;
if (p->attr!=pref->attr) continue;
if (p->value!=pref->value) continue;
if (p->type!=pref->type) continue;
if (preference_is_unary(pref->type)) return;
if (p->referent!=pref->referent) continue;
return;
}
/* --- if pref isn't at the right level, find a clone that is --- */
if (pref->inst->match_goal_level != thisAgent->results_match_goal_level) {
for (p=pref->next_clone; p!=NIL; p=p->next_clone)
if (p->inst->match_goal_level == thisAgent->results_match_goal_level) break;
if (!p)
for (p=pref->prev_clone; p!=NIL; p=p->prev_clone)
if (p->inst->match_goal_level == thisAgent->results_match_goal_level) break;
if (!p) return; /* if can't find one, it isn't a result */
pref = p;
}
/* --- add this preference to the result list --- */
pref->next_result = thisAgent->results;
thisAgent->results = pref;
/* --- follow transitive closuse through value, referent links --- */
add_results_if_needed (thisAgent, pref->value);
add_results_if_needed (thisAgent, pref->referent);
}
void add_results_for_id ( agent thisAgent,
Symbol id 
)

Definition at line 123 of file chunk.cpp.

References add_pref_to_results(), add_results_if_needed(), preference_struct::all_of_slot_next, slot_struct::all_preferences, agent_struct::extra_result_prefs_from_instantiation, wme_struct::id, preference_struct::id, symbol_union::id, identifier_struct::input_wmes, preference_struct::inst_next, wme_struct::next, slot_struct::next, NIL, agent_struct::results_tc_number, identifier_struct::slots, wme_struct::value, and slot_struct::wmes.

Referenced by add_results_if_needed().

{
slot *s;
preference *pref;
wme *w;
id->id.tc_num = thisAgent->results_tc_number;
/* --- scan through all preferences and wmes for all slots for this id --- */
for (w=id->id.input_wmes; w!=NIL; w=w->next)
add_results_if_needed (thisAgent, w->value);
for (s=id->id.slots; s!=NIL; s=s->next) {
for (pref=s->all_preferences; pref!=NIL; pref=pref->all_of_slot_next)
add_pref_to_results(thisAgent, pref);
for (w=s->wmes; w!=NIL; w=w->next)
add_results_if_needed (thisAgent, w->value);
} /* end of for slots loop */
/* --- now scan through extra prefs and look for any with this id --- */
for (pref=thisAgent->extra_result_prefs_from_instantiation; pref!=NIL;
pref=pref->inst_next) {
if (pref->id==id) add_pref_to_results(thisAgent, pref);
}
}
void add_results_if_needed ( agent thisAgent,
Symbol sym 
)
inline

Definition at line 79 of file chunk.cpp.

References add_results_for_id(), common, IDENTIFIER_SYMBOL_TYPE, agent_struct::results_match_goal_level, and agent_struct::results_tc_number.

Referenced by add_pref_to_results(), and add_results_for_id().

{
if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)
if ( ((sym)->id.level >= thisAgent->results_match_goal_level) &&
((sym)->id.tc_num != thisAgent->results_tc_number) )
add_results_for_id(thisAgent, sym);
}
Bool add_to_chunk_cond_set ( agent thisAgent,
chunk_cond_set set,
chunk_cond new_cc 
)

Definition at line 364 of file chunk.cpp.

References agent_struct::chunk_cond_pool, chunk_cond_struct::compressed_hash_value, chunk_cond_struct::cond, conditions_are_equal(), FALSE, chunk_cond_struct::hash_value, insert_at_head_of_dll, chunk_cond_struct::next_in_bucket, NIL, and TRUE.

Referenced by backtrace_through_instantiation().

{
chunk_cond *old;
for (old=set->table[new_cc->compressed_hash_value]; old!=NIL;
old=old->next_in_bucket)
if (old->hash_value==new_cc->hash_value)
if (conditions_are_equal (old->cond, new_cc->cond))
break;
if (old) {
/* --- the new condition was already in the set; so don't add it --- */
free_with_pool (&thisAgent->chunk_cond_pool, new_cc);
return FALSE;
}
/* --- add new_cc to the table --- */
insert_at_head_of_dll (set->all, new_cc, next, prev);
next_in_bucket, prev_in_bucket);
return TRUE;
}
void build_chunk_conds_for_grounds_and_add_negateds ( agent thisAgent,
chunk_cond **  dest_top,
chunk_cond **  dest_bottom,
tc_number  tc_to_use,
bool *  reliable 
)

Definition at line 417 of file chunk.cpp.

References add_cond_to_tc(), chunk_cond_set_struct::all, agent_struct::chunk_cond_pool, CHUNK_THROUGH_LOCAL_NEGATIONS_SYSPARAM, chunk_cond_struct::cond, cond_is_in_tc(), copy_condition(), FALSE, cons_struct::first, free_cons(), agent_struct::grounds, chunk_cond_struct::instantiated_cond, agent_struct::negated_set, chunk_cond_struct::next, condition_struct::next, NIL, chunk_cond_struct::prev, condition_struct::prev, print_condition(), print_string(), remove_from_chunk_cond_set(), report_local_negation(), cons_struct::rest, agent_struct::sysparams, TRACE_BACKTRACING_SYSPARAM, and chunk_cond_struct::variablized_cond.

Referenced by chunk_instantiation().

{
cons *c;
condition *ground;
chunk_cond *cc, *first_cc, *prev_cc;
first_cc = NIL; /* unnecessary, but gcc -Wall warns without it */
/* --- build instantiated conds for grounds and setup their TC --- */
prev_cc = NIL;
while (thisAgent->grounds) {
c = thisAgent->grounds;
thisAgent->grounds = thisAgent->grounds->rest;
ground = static_cast<condition_struct *>(c->first);
free_cons (thisAgent, c);
/* --- make the instantiated condition --- */
allocate_with_pool (thisAgent, &thisAgent->chunk_cond_pool, &cc);
cc->cond = ground;
cc->instantiated_cond = copy_condition (thisAgent, cc->cond);
cc->variablized_cond = copy_condition (thisAgent, cc->cond);
if (prev_cc) {
prev_cc->next = cc;
cc->prev = prev_cc;
} else {
first_cc = cc;
cc->prev = NIL;
}
prev_cc = cc;
/* --- add this in to the TC --- */
add_cond_to_tc (thisAgent, ground, tc_to_use, NIL, NIL);
}
/* --- scan through negated conditions and check which ones are connected
to the grounds --- */
print_string (thisAgent, "\n\n*** Adding Grounded Negated Conditions ***\n");
while (thisAgent->negated_set.all) {
cc = thisAgent->negated_set.all;
if (cond_is_in_tc (thisAgent, cc->cond, tc_to_use)) {
/* --- negated cond is in the TC, so add it to the grounds --- */
print_string (thisAgent, "\n-->Moving to grounds: ");
print_condition (thisAgent, cc->cond);
}
cc->instantiated_cond = copy_condition (thisAgent, cc->cond);
cc->variablized_cond = copy_condition (thisAgent, cc->cond);
if (prev_cc) {
prev_cc->next = cc;
cc->prev = prev_cc;
} else {
first_cc = cc;
cc->prev = NIL;
}
prev_cc = cc;
} else {
/* --- not in TC, so discard the condition --- */
{
// this chunk will be overgeneral! don't create it
// SBW 5/07
// report what local negations are preventing the chunk,
// and set flags like we saw a ^quiescence t so it won't be created
report_local_negation ( thisAgent, cc->cond ); // in backtrace.cpp
*reliable = false;
}
free_with_pool (&thisAgent->chunk_cond_pool, cc);
}
}
if (prev_cc) {
prev_cc->next = NIL;
prev_cc->variablized_cond->next = NIL;
prev_cc->instantiated_cond->next = NIL;
} else {
first_cc = NIL;
}
*dest_top = first_cc;
*dest_bottom = prev_cc;
}
void chunk_instantiation ( agent thisAgent,
instantiation inst,
bool  dont_variablize,
instantiation **  custom_inst_list 
)

Definition at line 973 of file chunk.cpp.

References explain_chunk_struct::actions, add_goal_or_impasse_tests(), add_production_to_rete(), explain_chunk_struct::all_grounds, identifier_struct::allow_bottom_up_chunks, explain_chunk_struct::backtrace, agent_struct::backtrace_number, backtrace_through_instantiation(), instantiation_struct::bottom_of_instantiated_conditions, build_chunk_conds_for_grounds_and_add_negateds(), agent_struct::chunk_cond_pool, chunk_instantiation(), CHUNK_PRODUCTION_TYPE, agent_struct::chunks_this_d_cycle, explain_chunk_struct::conds, copy_and_variablize_result_list(), copy_condition_list(), agent_struct::current_phase, deallocate_action_list(), deallocate_condition_list(), DUPLICATE_PRODUCTION, excise_production(), explain_add_temp_to_chunk_list(), EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE, EXPLAIN_SYSPARAM, FALSE, fill_in_new_instantiation_stuff(), free_list(), instantiation_struct::GDS_evaluated_already, generate_chunk_name_sym_constant(), generate_new_sym_constant(), get_new_tc_number(), get_nots_for_instantiated_conditions(), get_printer_output_column(), get_results_for_instantiation(), agent_struct::grounds, agent_struct::grounds_tc, identifier_struct::higher_goal, preference_struct::id, symbol_union::id, instantiation_struct::in_ms, preference_struct::inst, preference_struct::inst_next, chunk_cond_struct::instantiated_cond, agent_struct::instantiation_pool, agent_struct::instantiations_with_nots, agent_struct::justification_count, JUSTIFICATION_PRODUCTION_TYPE, identifier_struct::level, agent_struct::locals, agent_struct::locals_tc, make_clones_of_results(), make_production(), instantiation_struct::match_goal, instantiation_struct::match_goal_level, agent_struct::max_chunks_reached, MAX_CHUNKS_SYSPARAM, explain_chunk_struct::name, sym_constant_struct::name, chunk_cond_struct::next, instantiation_struct::next, explain_chunk_struct::next_chunk, preference_struct::next_result, NIL, instantiation_struct::nots, agent_struct::positive_potentials, agent_struct::potentials_tc, instantiation_struct::preferences_generated, print(), print_action_list(), print_condition_list(), print_preference(), print_production(), print_string(), PRINT_WARNINGS_SYSPARAM, print_with_symbols(), instantiation_struct::prod, REFRACTED_INST_DID_NOT_MATCH, REFRACTED_INST_MATCHED, instantiation_struct::reliable, reorder_instantiated_conditions(), reset_backtrace_list(), reset_variable_generator(), symbol_union::sc, should_variablize(), smem_valid_production(), agent_struct::stop_soar, symbol_remove_ref(), agent_struct::sysparams, agent_struct::system_halted, TIMERS_ENABLED, instantiation_struct::top_of_instantiated_conditions, TRACE_BACKTRACING_SYSPARAM, TRACE_CHUNK_NAMES_SYSPARAM, TRACE_CHUNKS_SYSPARAM, trace_grounded_potentials(), TRACE_JUSTIFICATION_NAMES_SYSPARAM, TRACE_JUSTIFICATIONS_SYSPARAM, trace_locals(), trace_ungrounded_potentials(), TRUE, agent_struct::variablization_tc, variablize_condition_list(), variablize_nots_and_insert_into_conditions(), chunk_cond_struct::variablized_cond, xml_att_val(), xml_begin_tag(), xml_end_tag(), and xml_generate_warning().

Referenced by _epmem_process_buffered_wme_list(), _smem_process_buffered_wme_list(), chunk_instantiation(), and create_instantiation().

{
goal_stack_level grounds_level;
preference *results, *pref;
action *rhs;
production *prod;
instantiation *chunk_inst;
Symbol *prod_name;
byte prod_type;
Bool print_name, print_prod;
byte rete_addition_result;
condition *lhs_top, *lhs_bottom;
not_struct *nots;
chunk_cond *top_cc, *bottom_cc;
bool reliable = true;
bool variablize;
explain_chunk_str temp_explain_chunk;
memset(temp_explain_chunk.name, 0, EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE);
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
soar_process_timer local_timer;
local_timer.set_enabled( &( thisAgent->sysparams[ TIMERS_ENABLED ] ) );
#endif
#endif
/* --- if it only matched an attribute impasse, don't chunk --- */
if (! inst->match_goal)
return;
/* --- if no preference is above the match goal level, exit --- */
for (pref=inst->preferences_generated; pref!=NIL; pref=pref->inst_next)
{
if (pref->id->id.level < inst->match_goal_level)
break;
}
if (! pref)
return;
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.start();
#endif
#endif
results = get_results_for_instantiation (thisAgent, inst);
if (!results) goto chunking_done;
/* set allow_bottom_up_chunks to false for all higher goals to prevent chunking */
{
Symbol *g;
}
grounds_level = inst->match_goal_level - 1;
thisAgent->backtrace_number++;
if (thisAgent->backtrace_number==0)
thisAgent->backtrace_number=1;
thisAgent->grounds_tc++;
if (thisAgent->grounds_tc==0)
thisAgent->grounds_tc=1;
thisAgent->potentials_tc++;
if (thisAgent->potentials_tc==0)
thisAgent->potentials_tc=1;
thisAgent->locals_tc++;
if (thisAgent->locals_tc==0)
thisAgent->locals_tc=1;
thisAgent->grounds = NIL;
thisAgent->positive_potentials = NIL;
thisAgent->locals = NIL;
/* Start a new structure for this potential chunk */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
temp_explain_chunk.conds = NULL;
temp_explain_chunk.actions = NULL;
temp_explain_chunk.backtrace = NULL;
temp_explain_chunk.name[0] = '\0';
temp_explain_chunk.all_grounds = NIL;
temp_explain_chunk.next_chunk = NULL;
}
/* --- backtrace through the instantiation that produced each result --- */
for (pref=results; pref!=NIL; pref=pref->next_result)
{
{
print_string (thisAgent, "\nFor result preference ");
xml_begin_tag(thisAgent, kTagBacktraceResult);
print_preference (thisAgent, pref);
print_string (thisAgent, " ");
}
backtrace_through_instantiation (thisAgent, pref->inst, grounds_level, NULL, &reliable, 0);
{
xml_end_tag(thisAgent, kTagBacktraceResult);
}
}
while (TRUE)
{
trace_locals (thisAgent, grounds_level, &reliable);
if (! trace_ungrounded_potentials (thisAgent, grounds_level, &reliable)) break;
}
free_list (thisAgent, thisAgent->positive_potentials);
/* --- backtracing done; collect the grounds into the chunk --- */
{
tc_number tc_for_grounds;
tc_for_grounds = get_new_tc_number(thisAgent);
build_chunk_conds_for_grounds_and_add_negateds (thisAgent, &top_cc, &bottom_cc, tc_for_grounds, &reliable);
nots = get_nots_for_instantiated_conditions (thisAgent, thisAgent->instantiations_with_nots, tc_for_grounds);
}
variablize = !dont_variablize && reliable && should_variablize(thisAgent, inst);
/* --- check for LTI validity --- */
if ( variablize )
{
if ( top_cc )
{
// need a temporary copy of the actions
thisAgent->variablization_tc = get_new_tc_number(thisAgent);
rhs = copy_and_variablize_result_list (thisAgent, results, true);
if ( !smem_valid_production( top_cc->variablized_cond, rhs ) )
{
variablize = false;
{
print( thisAgent, "\nWarning: LTI validation failed, creating justification instead." );
xml_generate_warning( thisAgent, "LTI validation failed, creating justification instead." );
}
}
// remove temporary copy
deallocate_action_list (thisAgent, rhs);
}
}
/* --- get symbol for name of new chunk or justification --- */
if (variablize)
{
/* kjh (B14) begin */
thisAgent->chunks_this_d_cycle++;
prod_name = generate_chunk_name_sym_constant(thisAgent, inst);
/* kjh (B14) end */
/* old way of generating chunk names ...
prod_name = generate_new_sym_constant ("chunk-",&thisAgent->chunk_count);
thisAgent->chunks_this_d_cycle)++;
*/
prod_type = CHUNK_PRODUCTION_TYPE;
print_name = (thisAgent->sysparams[TRACE_CHUNK_NAMES_SYSPARAM] != 0);
print_prod = (thisAgent->sysparams[TRACE_CHUNKS_SYSPARAM] != 0);
}
else
{
prod_name = generate_new_sym_constant (thisAgent, "justification-", &thisAgent->justification_count);
print_name = (thisAgent->sysparams[TRACE_JUSTIFICATION_NAMES_SYSPARAM] != 0);
print_prod = (thisAgent->sysparams[TRACE_JUSTIFICATIONS_SYSPARAM] != 0);
}
/* AGR 617/634 begin */
if (print_name)
{
if (get_printer_output_column(thisAgent)!=1)
print (thisAgent, "\n");
print_with_symbols (thisAgent, "Building %y", prod_name);
xml_begin_tag(thisAgent, kTagLearning);
xml_begin_tag(thisAgent, kTagProduction);
xml_att_val(thisAgent, kProduction_Name, prod_name);
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagLearning);
}
/* AGR 617/634 end */
/* --- if there aren't any grounds, exit --- */
if (! top_cc)
{
{
print_string (thisAgent, " Warning: chunk has no grounds, ignoring it.");
xml_generate_warning(thisAgent, "Warning: chunk has no grounds, ignoring it.");
}
symbol_remove_ref(thisAgent, prod_name);
goto chunking_done;
}
/* MVP 6-8-94 */
if (thisAgent->chunks_this_d_cycle > static_cast<uint64_t>(thisAgent->sysparams[MAX_CHUNKS_SYSPARAM]) )
{
{
print (thisAgent, "\nWarning: reached max-chunks! Halting system.");
xml_generate_warning(thisAgent, "Warning: reached max-chunks! Halting system.");
}
thisAgent->max_chunks_reached = TRUE;
symbol_remove_ref(thisAgent, prod_name);
goto chunking_done;
}
lhs_top = top_cc->variablized_cond;
lhs_bottom = bottom_cc->variablized_cond;
if (variablize) {
reset_variable_generator (thisAgent, lhs_top, NIL);
thisAgent->variablization_tc = get_new_tc_number(thisAgent);
variablize_condition_list (thisAgent, lhs_top);
variablize_nots_and_insert_into_conditions (thisAgent, nots, lhs_top);
}
rhs = copy_and_variablize_result_list (thisAgent, results, variablize);
add_goal_or_impasse_tests (thisAgent, top_cc);
prod = make_production (thisAgent, prod_type, prod_name, &lhs_top, &lhs_bottom, &rhs, FALSE);
if (!prod)
{
print (thisAgent, "\nUnable to reorder this chunk:\n ");
print_condition_list (thisAgent, lhs_top, 2, FALSE);
print (thisAgent, "\n -->\n ");
print_action_list (thisAgent, rhs, 3, FALSE);
print (thisAgent, "\n\nThis error is likely caused by the reasons outlined section 4 of the Soar\n");
print (thisAgent, "manual, subsection \"revising the substructure of a previous result\".\n");
print (thisAgent, "\n");
print (thisAgent, "Check that the rules are not revising substructure of a result matched only\n");
print (thisAgent, "through the local state.\n");
{
while (top_cc)
{
cc = top_cc;
top_cc = cc->next;
free_with_pool (&thisAgent->chunk_cond_pool, cc);
}
}
deallocate_action_list (thisAgent, rhs);
symbol_remove_ref(thisAgent, prod_name);
// We cannot proceed, the GDS will crash in decide.cpp:decide_non_context_slot
thisAgent->stop_soar = TRUE;
thisAgent->system_halted = TRUE;
goto chunking_done;
}
{
condition *inst_lhs_top = 0, *inst_lhs_bottom = 0;
reorder_instantiated_conditions (top_cc, &inst_lhs_top, &inst_lhs_bottom);
/* Record the list of grounds in the order they will appear in the chunk. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
temp_explain_chunk.all_grounds = inst_lhs_top; /* Not a copy yet */
allocate_with_pool (thisAgent, &thisAgent->instantiation_pool, &chunk_inst);
chunk_inst->prod = prod;
chunk_inst->top_of_instantiated_conditions = inst_lhs_top;
chunk_inst->bottom_of_instantiated_conditions = inst_lhs_bottom;
chunk_inst->nots = nots;
chunk_inst->GDS_evaluated_already = FALSE; /* REW: 09.15.96 */
chunk_inst->reliable = reliable;
chunk_inst->in_ms = TRUE; /* set TRUE for now, we'll find out later... */
make_clones_of_results (thisAgent, results, chunk_inst);
fill_in_new_instantiation_stuff (thisAgent, chunk_inst, TRUE);
}
/* RBD 4/6/95 Need to copy cond's and actions for the production here,
otherwise some of the variables might get deallocated by the call to
add_production_to_rete() when it throws away chunk variable names. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
condition *new_top = 0;
condition *new_bottom = 0;
copy_condition_list (thisAgent, lhs_top, &new_top, &new_bottom);
temp_explain_chunk.conds = new_top;
temp_explain_chunk.actions = copy_and_variablize_result_list (thisAgent, results, variablize);
}
rete_addition_result = add_production_to_rete (thisAgent, prod, lhs_top, chunk_inst, print_name);
/* If didn't immediately excise the chunk from the rete net
then record the temporary structure in the list of explained chunks. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
if ((rete_addition_result != DUPLICATE_PRODUCTION)
&& ((prod_type != JUSTIFICATION_PRODUCTION_TYPE)
|| (rete_addition_result != REFRACTED_INST_DID_NOT_MATCH) ))
{
strncpy(temp_explain_chunk.name,prod_name->sc.name, EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE);
temp_explain_chunk.name[EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE - 1] = 0;
explain_add_temp_to_chunk_list (thisAgent, &temp_explain_chunk);
}
else
{
/* RBD 4/6/95 if excised the chunk, discard previously-copied stuff */
deallocate_condition_list (thisAgent, temp_explain_chunk.conds);
deallocate_action_list (thisAgent, temp_explain_chunk.actions);
}
}
/* --- deallocate chunks conds and variablized conditions --- */
deallocate_condition_list (thisAgent, lhs_top);
{
while (top_cc)
{
cc = top_cc;
top_cc = cc->next;
free_with_pool (&thisAgent->chunk_cond_pool, cc);
}
}
if (print_prod && (rete_addition_result!=DUPLICATE_PRODUCTION))
{
print_string (thisAgent, "\n");
xml_begin_tag(thisAgent, kTagLearning);
print_production (thisAgent, prod, FALSE);
xml_end_tag(thisAgent, kTagLearning);
}
if (rete_addition_result==DUPLICATE_PRODUCTION)
{
excise_production (thisAgent, prod, FALSE);
}
else if ((prod_type==JUSTIFICATION_PRODUCTION_TYPE)
&& (rete_addition_result==REFRACTED_INST_DID_NOT_MATCH))
{
excise_production (thisAgent, prod, FALSE);
}
if (rete_addition_result!=REFRACTED_INST_MATCHED)
{
/* --- it didn't match, or it was a duplicate production --- */
/* --- tell the firer it didn't match, so it'll only assert the
o-supported preferences --- */
chunk_inst->in_ms = FALSE;
}
/* --- assert the preferences --- */
chunk_inst->next = (*custom_inst_list);
(*custom_inst_list) = chunk_inst;
/* MVP 6-8-94 */
if (!thisAgent->max_chunks_reached)
chunk_instantiation (thisAgent, chunk_inst, dont_variablize, custom_inst_list);
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.stop();
thisAgent->timers_chunking_cpu_time[thisAgent->current_phase].update(local_timer);
#endif
#endif
return;
chunking_done: {}
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.stop();
thisAgent->timers_chunking_cpu_time[thisAgent->current_phase].update(local_timer);
#endif
#endif
}
action* copy_and_variablize_result_list ( agent thisAgent,
preference pref,
bool  variablize 
)

Definition at line 254 of file chunk.cpp.

References agent_struct::action_pool, preference_struct::attr, action_struct::attr, preference_struct::id, action_struct::id, MAKE_ACTION, action_struct::next, preference_struct::next_result, NIL, preference_is_binary(), action_struct::preference_type, preference_struct::referent, action_struct::referent, symbol_add_ref(), symbol_to_rhs_value(), preference_struct::type, action_struct::type, preference_struct::value, action_struct::value, and variablize_symbol().

Referenced by chunk_instantiation().

{
action *a;
Symbol *id, *attr, *val, *ref;
if (!pref) return NIL;
allocate_with_pool (thisAgent, &thisAgent->action_pool, &a);
id = pref->id;
attr = pref->attr;
val = pref->value;
ref = pref->referent;
if (variablize) {
variablize_symbol (thisAgent, &id);
variablize_symbol (thisAgent, &attr);
variablize_symbol (thisAgent, &val);
}
a->preference_type = pref->type;
if (preference_is_binary(pref->type)) {
if (variablize) {
variablize_symbol (thisAgent, &ref);
}
}
a->next = copy_and_variablize_result_list (thisAgent, pref->next_result, variablize);
return a;
}
Symbol* find_goal_at_goal_stack_level ( agent thisAgent,
goal_stack_level  level 
)

Definition at line 765 of file chunk.cpp.

References symbol_union::id, identifier_struct::level, identifier_struct::lower_goal, NIL, and agent_struct::top_goal.

Referenced by generate_chunk_name_sym_constant().

{
Symbol *g;
for (g = thisAgent->top_goal; g != NIL; g = g->id.lower_goal)
if (g->id.level == level)
return(g);
return(NIL);
}
Symbol* find_impasse_wme_value ( Symbol id,
Symbol attr 
)

Definition at line 774 of file chunk.cpp.

References wme_struct::attr, symbol_union::id, identifier_struct::impasse_wmes, wme_struct::next, NIL, and wme_struct::value.

Referenced by generate_chunk_name_sym_constant().

{
wme *w;
for (w = id->id.impasse_wmes; w != NIL; w = w->next)
if (w->attr == attr) return w->value;
return NIL;
}
Symbol* generate_chunk_name_sym_constant ( agent thisAgent,
instantiation inst 
)

Definition at line 782 of file chunk.cpp.

References agent_struct::attribute_symbol, BUFFER_GEN_CHUNK_NAME_SIZE, BUFFER_IMPASS_NAME_SIZE, agent_struct::chunk_count, agent_struct::chunk_name_prefix, agent_struct::chunks_this_d_cycle, CONFLICT_IMPASSE_TYPE, CONSTRAINT_FAILURE_IMPASSE_TYPE, agent_struct::d_cycle_count, find_goal_at_goal_stack_level(), find_impasse_wme_value(), find_sym_constant(), generate_new_sym_constant(), preference_struct::id, symbol_union::id, preference_struct::inst_next, identifier_struct::level, identifier_struct::lower_goal, make_sym_constant(), NIL, NO_CHANGE_IMPASSE_TYPE, NONE_IMPASSE_TYPE, agent_struct::operator_symbol, instantiation_struct::preferences_generated, print(), agent_struct::state_symbol, agent_struct::sysparams, TIE_IMPASSE_TYPE, agent_struct::top_goal, type_of_existing_impasse(), USE_LONG_CHUNK_NAMES, and xml_generate_warning().

Referenced by chunk_instantiation().

{
#define BUFFER_GEN_CHUNK_NAME_SIZE 512
#define BUFFER_IMPASS_NAME_SIZE 32
char impass_name[BUFFER_IMPASS_NAME_SIZE];
Symbol *generated_name;
Symbol *goal;
byte impasse_type;
goal_stack_level lowest_result_level;
if (!thisAgent->sysparams[USE_LONG_CHUNK_NAMES])
return(generate_new_sym_constant (thisAgent, thisAgent->chunk_name_prefix,
&thisAgent->chunk_count));
lowest_result_level = thisAgent->top_goal->id.level;
for (p=inst->preferences_generated; p!=NIL; p=p->inst_next)
if (p->id->id.level > lowest_result_level)
lowest_result_level = p->id->id.level;
goal = find_goal_at_goal_stack_level(thisAgent, lowest_result_level);
if (goal) {
impasse_type = type_of_existing_impasse (thisAgent, goal);
switch (impasse_type) {
#ifdef DEBUG_CHUNK_NAMES
print ("Warning: impasse_type is NONE_IMPASSE_TYPE during chunk creation.\n");
xml_generate_warning(thisAgent, "Warning: impasse_type is NONE_IMPASSE_TYPE during chunk creation.");
#endif
strncpy(impass_name,"unknownimpasse",BUFFER_IMPASS_NAME_SIZE);
break;
strncpy(impass_name,"cfailure",BUFFER_IMPASS_NAME_SIZE);
break;
strncpy(impass_name,"conflict",BUFFER_IMPASS_NAME_SIZE);
break;
strncpy(impass_name,"tie",BUFFER_IMPASS_NAME_SIZE);
break;
{
Symbol *sym;
if ((sym = find_impasse_wme_value(goal->id.lower_goal,thisAgent->attribute_symbol)) == NIL) {
#ifdef DEBUG_CHUNK_NAMES
// TODO: generate warning XML: I think we need to get a string for "do_print_for_identifier" and append it
// but this seems low priority since it's not even included in a normal build
print ("Warning: Failed to find ^attribute impasse wme.\n");
do_print_for_identifier(goal->id.lower_goal, 1, 0, 0);
#endif
strncpy(impass_name,"unknownimpasse",BUFFER_IMPASS_NAME_SIZE);
} else if (sym == thisAgent->operator_symbol) {
strncpy(impass_name,"opnochange",BUFFER_IMPASS_NAME_SIZE);
} else if (sym == thisAgent->state_symbol) {
strncpy(impass_name,"snochange",BUFFER_IMPASS_NAME_SIZE);
} else {
#ifdef DEBUG_CHUNK_NAMES
print ("Warning: ^attribute impasse wme has unexpected value.\n");
xml_generate_warning(thisAgent, "Warning: ^attribute impasse wme has unexpected value.");
#endif
strncpy(impass_name,"unknownimpasse",BUFFER_IMPASS_NAME_SIZE);
}
}
break;
default:
#ifdef DEBUG_CHUNK_NAMES
// TODO: generate warning XML: I think we need to create a buffer and SNPRINTF the impasse_type into it (since it's a byte)
// but this seems low priority since it's not even included in a normal build
print ("Warning: encountered unknown impasse_type: %d.\n", impasse_type);
#endif
strncpy(impass_name,"unknownimpasse",BUFFER_IMPASS_NAME_SIZE);
break;
}
} else {
#ifdef DEBUG_CHUNK_NAMES
print ("Warning: Failed to determine impasse type.\n");
xml_generate_warning(thisAgent, "Warning: Failed to determine impasse type.");
#endif
strncpy(impass_name,"unknownimpasse",BUFFER_IMPASS_NAME_SIZE);
}
impass_name[BUFFER_IMPASS_NAME_SIZE - 1] = 0; /* ensure null termination */
SNPRINTF (name, BUFFER_GEN_CHUNK_NAME_SIZE, "%s-%lu*d%lu*%s*%lu",
thisAgent->chunk_name_prefix,
static_cast<long unsigned int>(thisAgent->chunk_count++),
static_cast<long unsigned int>(thisAgent->d_cycle_count),
impass_name,
static_cast<long unsigned int>(thisAgent->chunks_this_d_cycle)
);
name[BUFFER_GEN_CHUNK_NAME_SIZE - 1] = 0; /* ensure null termination */
/* Any user who named a production like this deserves to be burned, but we'll have mercy: */
if (find_sym_constant (thisAgent, name)) {
uint64_t collision_count;
collision_count = 1;
print (thisAgent, "Warning: generated chunk name already exists. Will find unique name.\n");
xml_generate_warning(thisAgent, "Warning: generated chunk name already exists. Will find unique name.");
do {
SNPRINTF (name, BUFFER_GEN_CHUNK_NAME_SIZE, "%s-%lu*d%lu*%s*%lu*%lu",
thisAgent->chunk_name_prefix,
static_cast<long unsigned int>(thisAgent->chunk_count++),
static_cast<long unsigned int>(thisAgent->d_cycle_count),
impass_name,
static_cast<long unsigned int>(thisAgent->chunks_this_d_cycle),
static_cast<long unsigned int>(collision_count++)
);
name[BUFFER_GEN_CHUNK_NAME_SIZE - 1] = 0; /* ensure null termination */
} while (find_sym_constant (thisAgent, name));
}
generated_name = make_sym_constant(thisAgent, name);
return generated_name;
}
not_struct* get_nots_for_instantiated_conditions ( agent thisAgent,
list instantiations_with_nots,
tc_number  tc_of_grounds 
)

Definition at line 527 of file chunk.cpp.

References cons_struct::first, free_cons(), symbol_union::id, not_struct::next, NIL, agent_struct::not_pool, instantiation_struct::nots, cons_struct::rest, not_struct::s1, not_struct::s2, symbol_add_ref(), and identifier_struct::tc_num.

Referenced by chunk_instantiation().

{
cons *c;
not_struct *n1, *n2, *new_not, *collected_nots;
/* --- collect nots for which both id's are marked --- */
collected_nots = NIL;
while (instantiations_with_nots) {
c = instantiations_with_nots;
instantiations_with_nots = c->rest;
inst = static_cast<instantiation_struct *>(c->first);
free_cons (thisAgent, c);
for (n1=inst->nots; n1 != NIL; n1=n1->next) {
/* --- Are both id's marked? If no, goto next loop iteration --- */
if (n1->s1->id.tc_num != tc_of_grounds) continue;
if (n1->s2->id.tc_num != tc_of_grounds) continue;
/* --- If the pair already in collected_nots, goto next iteration --- */
for (n2=collected_nots; n2!=NIL; n2=n2->next) {
if ((n2->s1 == n1->s1) && (n2->s2 == n1->s2)) break;
if ((n2->s1 == n1->s2) && (n2->s2 == n1->s1)) break;
}
if (n2) continue;
/* --- Add the pair to collected_nots --- */
allocate_with_pool (thisAgent, &thisAgent->not_pool, &new_not);
new_not->next = collected_nots;
collected_nots = new_not;
new_not->s1 = n1->s1;
symbol_add_ref (new_not->s1);
new_not->s2 = n1->s2;
symbol_add_ref (new_not->s2);
} /* end of for n1 */
} /* end of while instantiations_with_nots */
return collected_nots;
}
preference* get_results_for_instantiation ( agent thisAgent,
instantiation inst 
)
void init_chunk_cond_set ( chunk_cond_set set)

Definition at line 339 of file chunk.cpp.

References CHUNK_COND_HASH_TABLE_SIZE, and NIL.

Referenced by init_chunker().

{
int i;
set->all = NIL;
for (i=0; i<CHUNK_COND_HASH_TABLE_SIZE; i++) set->table[i] = NIL;
}
void init_chunker ( agent thisAgent)

Definition at line 1371 of file chunk.cpp.

References agent_struct::chunk_cond_pool, init_chunk_cond_set(), init_memory_pool(), and agent_struct::negated_set.

Referenced by init_soar_agent().

{
init_memory_pool (thisAgent, &thisAgent->chunk_cond_pool, sizeof(chunk_cond), "chunk condition");
}
chunk_cond* make_chunk_cond_for_condition ( agent thisAgent,
condition cond 
)

Definition at line 346 of file chunk.cpp.

References agent_struct::chunk_cond_pool, chunk_cond_struct::compressed_hash_value, chunk_cond_struct::cond, hash_condition(), chunk_cond_struct::hash_value, LOG_2_CHUNK_COND_HASH_TABLE_SIZE, masks_for_n_low_order_bits, and uint32_t().

Referenced by backtrace_through_instantiation().

{
uint32_t remainder, hv;
allocate_with_pool (thisAgent, &thisAgent->chunk_cond_pool, &cc);
cc->cond = cond;
cc->hash_value = hash_condition (thisAgent, cond);
remainder = cc->hash_value;
hv = 0;
while (remainder) {
hv ^= (remainder &
remainder = remainder >> LOG_2_CHUNK_COND_HASH_TABLE_SIZE;
}
return cc;
}
void make_clones_of_results ( agent thisAgent,
preference results,
instantiation chunk_inst 
)

Definition at line 738 of file chunk.cpp.

References preference_struct::attr, preference_struct::id, insert_at_head_of_dll, preference_struct::inst, make_preference(), preference_struct::next_clone, preference_struct::next_result, NIL, preference_is_binary(), instantiation_struct::preferences_generated, preference_struct::prev_clone, preference_struct::referent, symbol_add_ref(), preference_struct::type, and preference_struct::value.

Referenced by chunk_instantiation().

{
preference *p, *result_p;
chunk_inst->preferences_generated = NIL;
for (result_p=results; result_p!=NIL; result_p=result_p->next_result) {
/* --- copy the preference --- */
p = make_preference (thisAgent, result_p->type, result_p->id, result_p->attr,
result_p->value, result_p->referent);
/* --- put it onto the list for chunk_inst --- */
p->inst = chunk_inst;
inst_next, inst_prev);
/* --- insert it into the list of clones for this preference --- */
p->next_clone = result_p;
p->prev_clone = result_p->prev_clone;
result_p->prev_clone = p;
if (p->prev_clone) p->prev_clone->next_clone = p;
}
}
void remove_from_chunk_cond_set ( chunk_cond_set set,
chunk_cond cc 
)

Definition at line 384 of file chunk.cpp.

References chunk_cond_struct::compressed_hash_value, and remove_from_dll.

Referenced by build_chunk_conds_for_grounds_and_add_negateds().

{
remove_from_dll (set->all, cc, next, prev);
cc, next_in_bucket, prev_in_bucket);
}
void reorder_instantiated_conditions ( chunk_cond top_cc,
condition **  dest_inst_top,
condition **  dest_inst_bottom 
)

Definition at line 692 of file chunk.cpp.

References chunk_cond_struct::instantiated_cond, chunk_cond_struct::next, condition_struct::next, NIL, condition_struct::prev, chunk_cond_struct::saved_prev_pointer_of_variablized_cond, and chunk_cond_struct::variablized_cond.

Referenced by chunk_instantiation().

{
/* --- Step 1: swap prev pointers out of variablized conds into chunk_conds,
and swap pointer to the corresponding instantiated conds into the
variablized conds' prev pointers --- */
for (cc=top_cc; cc!=NIL; cc=cc->next) {
}
/* --- Step 2: do the reordering of the instantiated conds --- */
for (cc=top_cc; cc!=NIL; cc=cc->next) {
if (cc->variablized_cond->next) {
} else {
*dest_inst_bottom = cc->instantiated_cond;
}
} else {
*dest_inst_top = cc->instantiated_cond;
}
}
/* --- Step 3: restore the prev pointers on variablized conds --- */
for (cc=top_cc; cc!=NIL; cc=cc->next) {
}
}
bool should_variablize ( agent thisAgent,
instantiation inst 
)

Definition at line 903 of file chunk.cpp.

References identifier_struct::allow_bottom_up_chunks, agent_struct::chunk_free_problem_spaces, agent_struct::chunky_problem_spaces, preference_struct::id, symbol_union::id, preference_struct::inst_next, LEARNING_ALL_GOALS_SYSPARAM, LEARNING_EXCEPT_SYSPARAM, LEARNING_ON_SYSPARAM, LEARNING_ONLY_SYSPARAM, identifier_struct::level, instantiation_struct::match_goal, instantiation_struct::match_goal_level, member_of_list(), instantiation_struct::preferences_generated, print(), agent_struct::soar_verbose_flag, symbol_to_string(), agent_struct::sysparams, TRACE_CHUNKS_SYSPARAM, and xml_generate_verbose().

Referenced by chunk_instantiation().

{
if ( thisAgent->sysparams[LEARNING_ON_SYSPARAM] == 0 )
{
return false;
}
if ( thisAgent->sysparams[LEARNING_EXCEPT_SYSPARAM] &&
{
if (thisAgent->soar_verbose_flag || thisAgent->sysparams[TRACE_CHUNKS_SYSPARAM])
{
char buf[64];
std::ostringstream message;
message << "\nnot chunking due to chunk-free state " << symbol_to_string(thisAgent, inst->match_goal, false, buf, 64);
print(thisAgent, message.str().c_str());
xml_generate_verbose(thisAgent, message.str().c_str());
}
return false;
}
if (thisAgent->sysparams[LEARNING_ONLY_SYSPARAM] &&
{
if (thisAgent->soar_verbose_flag || thisAgent->sysparams[TRACE_CHUNKS_SYSPARAM])
{
char buf[64];
std::ostringstream message;
message << "\nnot chunking due to non-chunky state " << symbol_to_string(thisAgent, inst->match_goal, false, buf, 64);
print(thisAgent, message.str().c_str());
xml_generate_verbose(thisAgent, message.str().c_str());
}
return false;
}
/* allow_bottom_up_chunks will be false if a chunk was already
learned in a lower goal
*/
{
return false;
}
/* if a result is created in a state higher than the immediate
superstate, don't make chunks for intermediate justifications.
*/
for (p=inst->preferences_generated; p; p=p->inst_next)
{
if (p->id->id.level < inst->match_goal_level-1)
{
return false;
}
}
return true;
}
void variablize_condition_list ( agent thisAgent,
condition cond 
)
void variablize_nots_and_insert_into_conditions ( agent thisAgent,
not_struct nots,
condition conds 
)

Definition at line 576 of file chunk.cpp.

References abort_with_fatal_error(), add_new_test_to_test(), three_field_tests_struct::attr_test, BUFFER_MSG_SIZE, agent_struct::complex_test_pool, complex_test_struct::data, condition_struct::data, FALSE, symbol_union::id, three_field_tests_struct::id_test, make_test_from_complex_test(), not_struct::next, condition_struct::next, NIL, NOT_EQUAL_TEST, POSITIVE_CONDITION, complex_test_struct::test_info_union::referent, not_struct::s1, not_struct::s2, symbol_add_ref(), test_includes_equality_test_for_symbol(), condition_struct::condition_main_data_union::tests, TRUE, complex_test_struct::type, condition_struct::type, three_field_tests_struct::value_test, and identifier_struct::variablization.

Referenced by chunk_instantiation(), and rl_build_template_instantiation().

{
Symbol *var1, *var2;
test t;
Bool added_it;
for (n=nots; n!=NIL; n=n->next) {
var1 = n->s1->id.variablization;
var2 = n->s2->id.variablization;
/* --- find where var1 is bound, and add "<> var2" to that test --- */
allocate_with_pool (thisAgent, &thisAgent->complex_test_pool, &ct);
ct->data.referent = var2;
added_it = FALSE;
for (c=conds; c!=NIL; c=c->next) {
if (c->type != POSITIVE_CONDITION) continue;
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.id_test), t);
added_it = TRUE;
break;
}
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.attr_test), t);
added_it = TRUE;
break;
}
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.value_test), t);
added_it = TRUE;
break;
}
}
if (!added_it) {
char msg[BUFFER_MSG_SIZE];
strncpy (msg,"chunk.c: Internal error: couldn't add Not test to chunk\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
} /* end of for n=nots */
}
void variablize_symbol ( agent thisAgent,
Symbol **  sym 
)

Definition at line 179 of file chunk.cpp.

References generate_new_variable(), symbol_union::id, IDENTIFIER_SYMBOL_TYPE, NIL, symbol_add_ref(), symbol_remove_ref(), identifier_struct::tc_num, identifier_struct::variablization, and agent_struct::variablization_tc.

Referenced by copy_and_variablize_result_list(), rl_make_simple_action(), and variablize_test().

{
char prefix[2];
Symbol *var;
if ((*sym)->common.symbol_type!=IDENTIFIER_SYMBOL_TYPE) return; // only variablize identifiers
if ((*sym)->id.smem_lti != NIL) // don't variablize lti (long term identifiers)
{
(*sym)->id.tc_num = thisAgent->variablization_tc;
(*sym)->id.variablization = (*sym);
return;
}
if ((*sym)->id.tc_num == thisAgent->variablization_tc) {
/* --- it's already been variablized, so use the existing variable --- */
var = (*sym)->id.variablization;
symbol_remove_ref (thisAgent, *sym);
*sym = var;
return;
}
/* --- need to create a new variable --- */
(*sym)->id.tc_num = thisAgent->variablization_tc;
prefix[0] = static_cast<char>(tolower((*sym)->id.name_letter));
prefix[1] = 0;
var = generate_new_variable (thisAgent, prefix);
(*sym)->id.variablization = var;
symbol_remove_ref (thisAgent, *sym);
*sym = var;
}
void variablize_test ( agent thisAgent,
test t 
)

Definition at line 210 of file chunk.cpp.

References complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, DISJUNCTION_TEST, cons_struct::first, GOAL_ID_TEST, IMPASSE_ID_TEST, NIL, complex_test_struct::test_info_union::referent, cons_struct::rest, test_is_blank_or_equality_test(), test_is_blank_test(), complex_test_struct::type, and variablize_symbol().

Referenced by variablize_condition_list().

{
cons *c;
if (test_is_blank_test(*t)) return;
variablize_symbol (thisAgent, (Symbol **) t);
/* Warning: this relies on the representation of tests */
return;
}
switch (ct->type) {
return;
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest)
variablize_test (thisAgent, reinterpret_cast<test *>(&(c->first)));
return;
default: /* relational tests other than equality */
variablize_symbol (thisAgent, &(ct->data.referent));
return;
}
}