Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Macros | Functions
production.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include "production.h"
#include "mem.h"
#include "kernel.h"
#include "print.h"
#include "agent.h"
#include "gdatastructs.h"
#include "rhsfun.h"
#include "instantiations.h"
#include "reorder.h"
#include "symtab.h"
#include "init_soar.h"
#include "rete.h"
#include "utilities.h"
#include "reinforcement_learning.h"
#include <ctype.h>

Go to the source code of this file.

Macros

#define CANONICAL_TEST_ORDER   canonical_test
#define GENERATE_NEW_VARIABLE_BUFFER_SIZE   200 /* that ought to be long enough! */
#define NON_EQUAL_TEST_RETURN_VAL   0 /* some unusual number */

Functions

Bool action_is_in_tc (action *a, tc_number tc)
void add_action_to_tc (agent *thisAgent, action *a, tc_number tc, list **id_list, list **var_list)
void add_all_variables_in_action (agent *thisAgent, action *a, tc_number tc, list **var_list)
void add_all_variables_in_action_list (agent *thisAgent, action *actions, tc_number tc, list **var_list)
void add_all_variables_in_condition (agent *thisAgent, condition *c, tc_number tc, list **var_list)
void add_all_variables_in_condition_list (agent *thisAgent, condition *cond_list, tc_number tc, list **var_list)
void add_all_variables_in_rhs_value (agent *thisAgent, rhs_value rv, tc_number tc, list **var_list)
void add_all_variables_in_test (agent *thisAgent, test t, tc_number tc, list **var_list)
void add_bound_variables_in_condition (agent *thisAgent, condition *c, tc_number tc, list **var_list)
void add_bound_variables_in_condition_list (agent *thisAgent, condition *cond_list, tc_number tc, list **var_list)
void add_bound_variables_in_test (agent *thisAgent, test t, tc_number tc, list **var_list)
void add_cond_to_tc (agent *thisAgent, condition *c, tc_number tc, list **id_list, list **var_list)
void add_new_test_to_test (agent *thisAgent, test *t, test add_me)
void add_new_test_to_test_if_not_already_there (agent *thisAgent, test *t, test add_me, bool neg)
void add_symbol_to_tc (agent *thisAgent, Symbol *sym, tc_number tc, list **id_list, list **var_list)
void add_test_to_tc (agent *thisAgent, test t, tc_number tc, list **id_list, list **var_list)
Bool canonical_cond_greater (condition *c1, condition *c2)
uint32_t canonical_test (test t)
Bool cond_is_in_tc (agent *thisAgent, condition *cond, tc_number tc)
Bool conditions_are_equal (condition *c1, condition *c2)
conditioncopy_condition (agent *thisAgent, condition *cond)
void copy_condition_list (agent *thisAgent, condition *top_cond, condition **dest_top, condition **dest_bottom)
test copy_of_equality_test_found_in_test (agent *thisAgent, test t)
rhs_value copy_rhs_value (agent *thisAgent, rhs_value rv)
listcopy_symbol_list_adding_references (agent *thisAgent, list *sym_list)
test copy_test (agent *thisAgent, test t)
listcopy_test_list (agent *thisAgent, cons *c)
test copy_test_removing_goal_impasse_tests (agent *thisAgent, test t, Bool *removed_goal, Bool *removed_impasse)
void deallocate_action_list (agent *thisAgent, action *actions)
void deallocate_condition_list (agent *thisAgent, condition *cond_list)
void deallocate_list_of_nots (agent *thisAgent, not_struct *nots)
void deallocate_production (agent *thisAgent, production *prod)
void deallocate_rhs_value (agent *thisAgent, rhs_value rv)
void deallocate_symbol_list_removing_references (agent *thisAgent, list *sym_list)
void deallocate_test (agent *thisAgent, test t)
void excise_all_productions (agent *thisAgent, Bool print_sharp_sign)
void excise_all_productions_of_type (agent *thisAgent, byte type, Bool print_sharp_sign)
void excise_production (agent *thisAgent, production *prod, Bool print_sharp_sign)
char first_letter_from_rhs_value (rhs_value rv)
char first_letter_from_symbol (Symbol *sym)
char first_letter_from_test (test t)
Symbolgenerate_new_variable (agent *thisAgent, const char *prefix)
tc_number get_new_tc_number (agent *thisAgent)
uint32_t hash_condition (agent *thisAgent, condition *cond)
uint32_t hash_test (agent *thisAgent, test t)
void init_production_utilities (agent *thisAgent)
productionmake_production (agent *thisAgent, byte type, Symbol *name, condition **lhs_top, condition **lhs_bottom, action **rhs_top, Bool reorder_nccs)
void mark_identifier_if_unmarked (agent *thisAgent, Symbol *ident, tc_number tc, list **id_list)
void mark_variable_if_unmarked (agent *thisAgent, Symbol *v, tc_number tc, list **var_list)
void quickly_deallocate_test (agent *thisAgent, test t)
void reset_variable_generator (agent *thisAgent, condition *conds_with_vars_to_avoid, action *actions_with_vars_to_avoid)
Bool symbol_is_in_tc (Symbol *sym, tc_number tc)
Bool test_includes_equality_test_for_symbol (test t, Symbol *sym)
Bool test_includes_goal_or_impasse_id_test (test t, Bool look_for_goal, Bool look_for_impasse)
Bool test_is_in_tc (test t, tc_number tc)
Bool tests_are_equal (test t1, test t2, bool neg)
void unmark_identifiers_and_free_list (agent *thisAgent, list *id_list)
void unmark_variables_and_free_list (agent *thisAgent, list *var_list)

Macro Definition Documentation

#define CANONICAL_TEST_ORDER   canonical_test

Definition at line 578 of file production.cpp.

Referenced by canonical_cond_greater().

#define GENERATE_NEW_VARIABLE_BUFFER_SIZE   200 /* that ought to be long enough! */

Referenced by generate_new_variable().

#define NON_EQUAL_TEST_RETURN_VAL   0 /* some unusual number */

Definition at line 554 of file production.cpp.

Referenced by canonical_test().

Function Documentation

Bool action_is_in_tc ( action a,
tc_number  tc 
)
void add_action_to_tc ( agent thisAgent,
action a,
tc_number  tc,
list **  id_list,
list **  var_list 
)
void add_all_variables_in_action ( agent thisAgent,
action a,
tc_number  tc,
list **  var_list 
)

Definition at line 1298 of file production.cpp.

References add_all_variables_in_rhs_value(), action_struct::attr, action_struct::id, MAKE_ACTION, mark_variable_if_unmarked(), preference_is_binary(), action_struct::preference_type, action_struct::referent, rhs_value_to_symbol(), action_struct::type, action_struct::value, and VARIABLE_SYMBOL_TYPE.

Referenced by add_all_variables_in_action_list(), and reorder_action_list().

{
Symbol *id;
if (a->type==MAKE_ACTION) {
/* --- ordinary make actions --- */
if (id->common.symbol_type==VARIABLE_SYMBOL_TYPE)
mark_variable_if_unmarked (thisAgent, id, tc, var_list);
add_all_variables_in_rhs_value (thisAgent, a->attr, tc, var_list);
add_all_variables_in_rhs_value (thisAgent, a->value, tc, var_list);
add_all_variables_in_rhs_value (thisAgent, a->referent, tc, var_list);
} else {
/* --- function call actions --- */
add_all_variables_in_rhs_value (thisAgent, a->value, tc, var_list);
}
}
void add_all_variables_in_action_list ( agent thisAgent,
action actions,
tc_number  tc,
list **  var_list 
)

Definition at line 1317 of file production.cpp.

References add_all_variables_in_action(), action_struct::next, and NIL.

Referenced by reset_variable_generator().

{
action *a;
for (a=actions; a!=NIL; a=a->next)
add_all_variables_in_action (thisAgent, a, tc, var_list);
}
void add_all_variables_in_condition ( agent thisAgent,
condition c,
tc_number  tc,
list **  var_list 
)
void add_all_variables_in_condition_list ( agent thisAgent,
condition cond_list,
tc_number  tc,
list **  var_list 
)

Definition at line 1257 of file production.cpp.

References add_all_variables_in_condition(), condition_struct::next, and NIL.

Referenced by add_all_variables_in_condition(), and reset_variable_generator().

{
for (c=cond_list; c!=NIL; c=c->next)
add_all_variables_in_condition (thisAgent, c, tc, var_list);
}
void add_all_variables_in_rhs_value ( agent thisAgent,
rhs_value  rv,
tc_number  tc,
list **  var_list 
)

Definition at line 1278 of file production.cpp.

References cons_struct::first, mark_variable_if_unmarked(), NIL, cons_struct::rest, rhs_value_is_symbol(), rhs_value_to_funcall_list(), rhs_value_to_symbol(), and VARIABLE_SYMBOL_TYPE.

Referenced by add_all_variables_in_action().

{
list *fl;
cons *c;
Symbol *sym;
/* --- ordinary values (i.e., symbols) --- */
if (sym->common.symbol_type==VARIABLE_SYMBOL_TYPE)
mark_variable_if_unmarked (thisAgent, sym, tc, var_list);
} else {
/* --- function calls --- */
for (c=fl->rest; c!=NIL; c=c->rest)
add_all_variables_in_rhs_value (thisAgent, static_cast<char *>(c->first), tc, var_list);
}
}
void add_all_variables_in_test ( agent thisAgent,
test  t,
tc_number  tc,
list **  var_list 
)

Definition at line 1205 of file production.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, mark_variable_if_unmarked(), NIL, complex_test_struct::test_info_union::referent, referent_of_equality_test(), cons_struct::rest, test_is_blank_or_equality_test(), test_is_blank_test(), complex_test_struct::type, and VARIABLE_SYMBOL_TYPE.

Referenced by add_all_variables_in_condition().

{
cons *c;
Symbol *referent;
if (test_is_blank_test(t)) return;
if (referent->common.symbol_type==VARIABLE_SYMBOL_TYPE)
mark_variable_if_unmarked (thisAgent, referent, tc, var_list);
return;
}
switch (ct->type) {
break;
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest)
add_all_variables_in_test (thisAgent, static_cast<char *>(c->first), tc, var_list);
break;
default:
/* --- relational tests other than equality --- */
referent = ct->data.referent;
if (referent->common.symbol_type==VARIABLE_SYMBOL_TYPE)
mark_variable_if_unmarked (thisAgent, referent, tc, var_list);
break;
}
}
void add_bound_variables_in_condition ( agent thisAgent,
condition c,
tc_number  tc,
list **  var_list 
)
void add_bound_variables_in_condition_list ( agent thisAgent,
condition cond_list,
tc_number  tc,
list **  var_list 
)

Definition at line 1188 of file production.cpp.

References add_bound_variables_in_condition(), condition_struct::next, and NIL.

Referenced by make_production().

{
for (c=cond_list; c!=NIL; c=c->next)
add_bound_variables_in_condition (thisAgent, c, tc, var_list);
}
void add_bound_variables_in_test ( agent thisAgent,
test  t,
tc_number  tc,
list **  var_list 
)
void add_cond_to_tc ( agent thisAgent,
condition c,
tc_number  tc,
list **  id_list,
list **  var_list 
)
void add_new_test_to_test ( agent thisAgent,
test t,
test  add_me 
)

Definition at line 340 of file production.cpp.

References allocate_cons(), complex_test_from_test(), agent_struct::complex_test_pool, complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, FALSE, cons_struct::first, make_test_from_complex_test(), NIL, cons_struct::rest, test_is_blank_test(), test_is_complex_test(), TRUE, and complex_test_struct::type.

Referenced by add_gensymmed_equality_test(), add_goal_or_impasse_tests(), add_hash_info_to_id_test(), add_new_test_to_test_if_not_already_there(), add_rete_test_list_to_tests(), add_varnames_to_test(), copy_test_removing_goal_impasse_tests(), parse_attr_value_tests(), parse_head_of_conds_for_one_id(), parse_test(), parse_value_test_star(), rl_add_goal_or_impasse_tests_to_conds(), and variablize_nots_and_insert_into_conditions().

{
complex_test *ct = 0;
cons *c;
Bool already_a_conjunctive_test;
if (test_is_blank_test(add_me)) return;
if (test_is_blank_test(*t)) {
*t = add_me;
return;
}
/* --- if *t isn't already a conjunctive test, make it into one --- */
already_a_conjunctive_test = FALSE;
if (ct->type==CONJUNCTIVE_TEST) already_a_conjunctive_test = TRUE;
}
if (! already_a_conjunctive_test) {
allocate_with_pool (thisAgent, &thisAgent->complex_test_pool, &ct);
allocate_cons (thisAgent, &c);
c->first = *t;
c->rest = NIL;
}
/* --- at this point, ct points to the complex test structure for *t --- */
/* --- now add add_me to the conjunct list --- */
allocate_cons (thisAgent, &c);
c->first = add_me;
}
void add_new_test_to_test_if_not_already_there ( agent thisAgent,
test t,
test  add_me,
bool  neg 
)

Definition at line 383 of file production.cpp.

References add_new_test_to_test(), complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, deallocate_test(), cons_struct::first, NIL, cons_struct::rest, test_is_complex_test(), tests_are_equal(), and complex_test_struct::type.

Referenced by restore_saved_tests_to_test().

{
cons *c;
if (tests_are_equal (*t, add_me, neg)) {
deallocate_test (thisAgent, add_me);
return;
}
if (ct->type == CONJUNCTIVE_TEST)
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest)
if (tests_are_equal (static_cast<char *>(c->first), add_me, neg)) {
deallocate_test (thisAgent, add_me);
return;
}
}
add_new_test_to_test (thisAgent, t, add_me);
}
void add_symbol_to_tc ( agent thisAgent,
Symbol sym,
tc_number  tc,
list **  id_list,
list **  var_list 
)

Definition at line 1354 of file production.cpp.

References IDENTIFIER_SYMBOL_TYPE, mark_identifier_if_unmarked(), mark_variable_if_unmarked(), and VARIABLE_SYMBOL_TYPE.

Referenced by add_action_to_tc(), add_test_to_tc(), and calculate_compile_time_o_support().

{
if (sym->common.symbol_type==VARIABLE_SYMBOL_TYPE) {
mark_variable_if_unmarked (thisAgent, sym, tc, var_list);
} else if (sym->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) {
mark_identifier_if_unmarked (thisAgent, sym, tc, id_list);
}
}
void add_test_to_tc ( agent thisAgent,
test  t,
tc_number  tc,
list **  id_list,
list **  var_list 
)
Bool canonical_cond_greater ( condition c1,
condition c2 
)
uint32_t canonical_test ( test  t)
Bool cond_is_in_tc ( agent thisAgent,
condition cond,
tc_number  tc 
)

Definition at line 1427 of file production.cpp.

References add_cond_to_tc(), condition_struct::already_in_tc, cond_is_in_tc(), CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, FALSE, three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, condition_struct::next, NIL, test_is_in_tc(), condition_struct::condition_main_data_union::tests, ncc_info_struct::top, TRUE, condition_struct::type, unmark_identifiers_and_free_list(), and unmark_variables_and_free_list().

Referenced by add_tc_through_lhs_and_rhs(), build_chunk_conds_for_grounds_and_add_negateds(), cond_is_in_tc(), and trace_grounded_potentials().

{
Bool anything_changed;
Bool result;
list *new_ids, *new_vars;
return test_is_in_tc (cond->data.tests.id_test, tc);
/* --- conjunctive negations: keep trying to add stuff to the TC --- */
new_ids = NIL;
new_vars = NIL;
for (c=cond->data.ncc.top; c!=NIL; c=c->next)
while (TRUE) {
anything_changed = FALSE;
for (c=cond->data.ncc.top; c!=NIL; c=c->next)
if (! c->already_in_tc)
if (cond_is_in_tc (thisAgent, c, tc)) {
add_cond_to_tc (thisAgent, c, tc, &new_ids, &new_vars);
anything_changed = TRUE;
}
if (! anything_changed) break;
}
/* --- complete TC found, look for anything that didn't get hit --- */
result = TRUE;
for (c=cond->data.ncc.top; c!=NIL; c=c->next)
if (! c->already_in_tc) result = FALSE;
/* --- unmark identifiers and variables that we just marked --- */
unmark_identifiers_and_free_list (thisAgent, new_ids);
unmark_variables_and_free_list (thisAgent, new_vars);
return result;
}
Bool conditions_are_equal ( condition c1,
condition c2 
)

Definition at line 847 of file production.cpp.

References three_field_tests_struct::attr_test, conditions_are_equal(), CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, FALSE, three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, condition_struct::next, NIL, POSITIVE_CONDITION, condition_struct::test_for_acceptable_preference, condition_struct::condition_main_data_union::tests, tests_are_equal(), ncc_info_struct::top, TRUE, condition_struct::type, and three_field_tests_struct::value_test.

Referenced by add_to_chunk_cond_set(), conditions_are_equal(), and explain_find_cond().

{
if (c1->type != c2->type) return FALSE;
bool neg = true;
switch (c1->type) {
neg = false;
c2->data.tests.id_test, neg))
return FALSE;
c2->data.tests.attr_test, neg))
return FALSE;
c2->data.tests.value_test, neg))
return FALSE;
return FALSE;
return TRUE;
for (c1=c1->data.ncc.top, c2=c2->data.ncc.top;
((c1!=NIL)&&(c2!=NIL));
c1=c1->next, c2=c2->next)
if (! conditions_are_equal (c1,c2)) return FALSE;
if (c1==c2) return TRUE; /* make sure they both hit end-of-list */
return FALSE;
}
return FALSE; /* unreachable, but without it, gcc -Wall warns here */
}
condition* copy_condition ( agent thisAgent,
condition cond 
)
void copy_condition_list ( agent thisAgent,
condition top_cond,
condition **  dest_top,
condition **  dest_bottom 
)

Definition at line 825 of file production.cpp.

References copy_condition(), condition_struct::next, NIL, and condition_struct::prev.

Referenced by chunk_instantiation(), copy_cond_list(), copy_condition(), and rl_build_template_instantiation().

{
condition *New, *prev;
prev = NIL;
while (top_cond) {
New = copy_condition (thisAgent, top_cond);
if (prev) prev->next = New; else *dest_top = New;
New->prev = prev;
prev = New;
top_cond = top_cond->next;
}
if (prev) prev->next = NIL; else *dest_top = NIL;
*dest_bottom = prev;
}
test copy_of_equality_test_found_in_test ( agent thisAgent,
test  t 
)

Definition at line 739 of file production.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, copy_test(), complex_test_struct::data, cons_struct::first, NIL, cons_struct::rest, test_is_blank_or_equality_test(), test_is_blank_test(), and complex_test_struct::type.

Referenced by fill_in_attr_tests(), fill_in_id_tests(), parse_conds_for_one_id(), parse_head_of_conds_for_one_id(), print_condition_list(), and xml_condition_list().

{
cons *c;
char msg[BUFFER_MSG_SIZE];
strncpy (msg, "Internal error: can't find equality test in test\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
if (test_is_blank_or_equality_test(t)) return copy_test (thisAgent, t);
if (ct->type==CONJUNCTIVE_TEST) {
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest)
if ( (! test_is_blank_test (static_cast<test>(c->first))) &&
(test_is_blank_or_equality_test (static_cast<test>(c->first))) )
return copy_test (thisAgent, static_cast<char *>(c->first));
}
strncpy (msg, "Internal error: can't find equality test in test\n",BUFFER_MSG_SIZE);
abort_with_fatal_error(thisAgent, msg);
return 0; /* unreachable, but without it, gcc -Wall warns here */
}
rhs_value copy_rhs_value ( agent thisAgent,
rhs_value  rv 
)

Definition at line 954 of file production.cpp.

References allocate_cons(), copy_rhs_value(), cons_struct::first, funcall_list_to_rhs_value(), NIL, cons_struct::rest, rhs_value_is_funcall(), rhs_value_is_reteloc(), rhs_value_is_unboundvar(), rhs_value_to_funcall_list(), rhs_value_to_symbol(), and symbol_add_ref().

Referenced by copy_rhs_value(), parse_preferences(), and parse_preferences_soar8_non_operator().

{
cons *c, *new_c, *prev_new_c;
list *fl, *new_fl;
if (rhs_value_is_reteloc(rv)) return rv;
if (rhs_value_is_unboundvar(rv)) return rv;
allocate_cons (thisAgent, &new_fl);
new_fl->first = fl->first;
prev_new_c = new_fl;
for (c=fl->rest; c!=NIL; c=c->rest) {
allocate_cons (thisAgent, &new_c);
new_c->first = copy_rhs_value (thisAgent, static_cast<char *>(c->first));
prev_new_c->rest = new_c;
prev_new_c = new_c;
}
prev_new_c->rest = NIL;
return funcall_list_to_rhs_value (new_fl);
} else {
return rv;
}
}
list* copy_symbol_list_adding_references ( agent thisAgent,
list sym_list 
)

Definition at line 129 of file production.cpp.

References allocate_cons(), cons_struct::first, NIL, cons_struct::rest, and symbol_add_ref().

Referenced by add_rete_test_list_to_tests(), add_rete_tests_for_test(), and copy_test().

{
cons *c, *first, *prev;
if (! sym_list) return NIL;
allocate_cons (thisAgent, &first);
first->first = sym_list->first;
symbol_add_ref (static_cast<Symbol *>(first->first));
sym_list = sym_list->rest;
prev = first;
while (sym_list) {
allocate_cons (thisAgent, &c);
prev->rest = c;
c->first = sym_list->first;
symbol_add_ref (static_cast<Symbol *>(c->first));
sym_list = sym_list->rest;
prev = c;
}
prev->rest = NIL;
return first;
}
test copy_test ( agent thisAgent,
test  t 
)

Definition at line 188 of file production.cpp.

References complex_test_from_test(), agent_struct::complex_test_pool, complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, copy_symbol_list_adding_references(), copy_test_list(), complex_test_struct::data, complex_test_struct::test_info_union::disjunction_list, DISJUNCTION_TEST, GOAL_ID_TEST, IMPASSE_ID_TEST, make_blank_test(), make_equality_test(), make_test_from_complex_test(), complex_test_struct::test_info_union::referent, referent_of_equality_test(), symbol_add_ref(), test_is_blank_or_equality_test(), test_is_blank_test(), and complex_test_struct::type.

Referenced by copy_condition(), copy_of_equality_test_found_in_test(), copy_test_list(), copy_test_removing_goal_impasse_tests(), fill_in_attr_tests(), fill_in_id_tests(), and parse_attr_value_tests().

{
Symbol *referent;
complex_test *ct, *new_ct;
return make_blank_test();
return make_equality_test(referent);
}
allocate_with_pool (thisAgent, &thisAgent->complex_test_pool, &new_ct);
new_ct->type = ct->type;
switch(ct->type) {
break;
break;
new_ct->data.conjunct_list = copy_test_list (thisAgent, ct->data.conjunct_list);
break;
default: /* relational tests other than equality */
new_ct->data.referent = ct->data.referent;
break;
}
}
list* copy_test_list ( agent thisAgent,
cons c 
)

Definition at line 174 of file production.cpp.

References allocate_cons(), copy_test(), cons_struct::first, NIL, and cons_struct::rest.

Referenced by copy_test().

{
cons *new_c;
if (!c) return NIL;
allocate_cons (thisAgent, &new_c);
new_c->first = copy_test (thisAgent, static_cast<char *>(c->first));
new_c->rest = copy_test_list (thisAgent, c->rest);
return new_c;
}
test copy_test_removing_goal_impasse_tests ( agent thisAgent,
test  t,
Bool removed_goal,
Bool removed_impasse 
)

Definition at line 230 of file production.cpp.

References add_new_test_to_test(), complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, copy_test(), copy_test_removing_goal_impasse_tests(), complex_test_struct::data, destructively_reverse_list(), cons_struct::first, GOAL_ID_TEST, IMPASSE_ID_TEST, make_blank_test(), NIL, cons_struct::rest, test_is_blank_or_equality_test(), test_is_blank_test(), test_is_complex_test(), TRUE, and complex_test_struct::type.

Referenced by copy_test_removing_goal_impasse_tests(), print_condition_list(), remove_isa_state_tests_for_non_roots(), and xml_condition_list().

{
complex_test *ct, *new_ct;
cons *c;
test new_t, temp;
if (test_is_blank_or_equality_test(t)) return copy_test (thisAgent, t);
switch(ct->type) {
*removed_goal = TRUE;
return make_blank_test();
*removed_impasse = TRUE;
return make_blank_test();
new_t = make_blank_test();
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest) {
temp = copy_test_removing_goal_impasse_tests (thisAgent, static_cast<char *>(c->first),
removed_goal,
removed_impasse);
if (! test_is_blank_test(temp))
add_new_test_to_test (thisAgent, &new_t, temp);
}
if (test_is_complex_test(new_t)) {
new_ct = complex_test_from_test(new_t);
if (new_ct->type==CONJUNCTIVE_TEST)
new_ct->data.conjunct_list =
}
return new_t;
default: /* relational tests other than equality */
return copy_test (thisAgent, t);
}
}
void deallocate_action_list ( agent thisAgent,
action actions 
)
void deallocate_condition_list ( agent thisAgent,
condition cond_list 
)
void deallocate_list_of_nots ( agent thisAgent,
not_struct nots 
)

Definition at line 1024 of file production.cpp.

References not_struct::next, agent_struct::not_pool, not_struct::s1, not_struct::s2, and symbol_remove_ref().

Referenced by deallocate_instantiation().

{
not_struct *temp;
while (nots) {
temp = nots;
nots = nots->next;
symbol_remove_ref (thisAgent, temp->s1);
symbol_remove_ref (thisAgent, temp->s2);
free_with_pool (&thisAgent->not_pool, temp);
}
}
void deallocate_production ( agent thisAgent,
production prod 
)

Definition at line 1653 of file production.cpp.

References abort_with_fatal_error(), production_struct::action_list, BUFFER_MSG_SIZE, deallocate_action_list(), deallocate_condition_list(), deallocate_symbol_list_removing_references(), production_struct::documentation, production_struct::filename, free_memory_block_for_string(), production_struct::instantiations, production_struct::name, agent_struct::production_pool, production_struct::rhs_unbound_variables, production_struct::rl_template_conds, production_struct::rl_template_instantiations, and symbol_remove_ref().

Referenced by production_remove_ref().

{
if (prod->instantiations) {
char msg[BUFFER_MSG_SIZE];
strncpy (msg, "Internal error: deallocating prod. that still has inst's\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
deallocate_action_list (thisAgent, prod->action_list);
/* RBD 3/28/95 the following line used to use free_list(), leaked memory */
symbol_remove_ref (thisAgent, prod->name);
/* next line, kjh CUSP(B11) */
if (prod->filename) free_memory_block_for_string (thisAgent, prod->filename);
free_with_pool (&thisAgent->production_pool, prod);
}
void deallocate_rhs_value ( agent thisAgent,
rhs_value  rv 
)
void deallocate_symbol_list_removing_references ( agent thisAgent,
list sym_list 
)

Definition at line 155 of file production.cpp.

References cons_struct::first, free_cons(), cons_struct::rest, and symbol_remove_ref().

Referenced by add_production_to_rete(), deallocate_production(), deallocate_rete_test_list(), deallocate_test(), deallocate_trace_format_list(), deallocate_varnames(), and parse_attribute_path_in_brackets().

{
cons *c;
while (sym_list) {
c = sym_list;
sym_list = sym_list->rest;
symbol_remove_ref (thisAgent, static_cast<Symbol *>(c->first));
free_cons (thisAgent, c);
}
}
void deallocate_test ( agent thisAgent,
test  t 
)

Definition at line 275 of file production.cpp.

References complex_test_from_test(), agent_struct::complex_test_pool, complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, deallocate_symbol_list_removing_references(), deallocate_test(), complex_test_struct::test_info_union::disjunction_list, DISJUNCTION_TEST, cons_struct::first, free_cons(), GOAL_ID_TEST, IMPASSE_ID_TEST, complex_test_struct::test_info_union::referent, referent_of_equality_test(), cons_struct::rest, symbol_remove_ref(), test_is_blank_or_equality_test(), test_is_blank_test(), and complex_test_struct::type.

Referenced by add_new_test_to_test_if_not_already_there(), deallocate_test(), fill_in_attr_tests(), fill_in_id_tests(), parse_attr_value_tests(), parse_conds_for_one_id(), parse_disjunction_test(), parse_head_of_conds_for_one_id(), parse_test(), print_condition_list(), quickly_deallocate_test(), remove_isa_state_tests_for_non_roots(), and xml_condition_list().

{
cons *c, *next_c;
if (test_is_blank_test(t)) return;
return;
}
switch (ct->type) {
break;
break;
while (c) {
next_c = c->rest;
deallocate_test (thisAgent, static_cast<char *>(c->first));
free_cons (thisAgent, c);
c = next_c;
}
break;
default: /* relational tests other than equality */
symbol_remove_ref (thisAgent, ct->data.referent);
break;
}
free_with_pool (&thisAgent->complex_test_pool, ct);
}
void excise_all_productions ( agent thisAgent,
Bool  print_sharp_sign 
)

Definition at line 1705 of file production.cpp.

References excise_all_productions_of_type(), NUM_PRODUCTION_TYPES, agent_struct::sysparams, and TRACE_LOADING_SYSPARAM.

Referenced by destroy_soar_agent(), and load_rete_net().

{
// Excise all the productions of the four different types
for (int i=0; i < NUM_PRODUCTION_TYPES; i++) {
static_cast<byte>(i),
print_sharp_sign&&thisAgent->sysparams[TRACE_LOADING_SYSPARAM]);
}
}
void excise_all_productions_of_type ( agent thisAgent,
byte  type,
Bool  print_sharp_sign 
)

Definition at line 1693 of file production.cpp.

References agent_struct::all_productions_of_type, excise_production(), agent_struct::sysparams, and TRACE_LOADING_SYSPARAM.

Referenced by excise_all_productions().

{
// Iterating through the productions of the appropriate type and excising them
while (thisAgent->all_productions_of_type[type]) {
excise_production (thisAgent,
thisAgent->all_productions_of_type[type],
print_sharp_sign&&thisAgent->sysparams[TRACE_LOADING_SYSPARAM]);
}
}
void excise_production ( agent thisAgent,
production prod,
Bool  print_sharp_sign 
)

Definition at line 1674 of file production.cpp.

References agent_struct::all_productions_of_type, rl_param_container::apoptosis, rl_param_container::apoptosis_none, CHUNK_PRODUCTION_TYPE, excise_production_from_rete(), soar_module::constant_param< T >::get_value(), production_struct::name, NIL, agent_struct::num_productions_of_type, production_struct::p_node, print(), sym_constant_struct::production, production_remove_ref(), remove_from_dll, soar_module::object_memory< T, N >::remove_object(), remove_pwatch(), agent_struct::rl_params, agent_struct::rl_prods, rl_remove_refs_for_prod(), production_struct::rl_rule, symbol_union::sc, production_struct::trace_firings, and production_struct::type.

Referenced by chunk_instantiation(), do_one_top_level_phase(), excise_all_productions_of_type(), parse_production(), retract_instantiation(), and rl_build_template_instantiation().

{
if (prod->trace_firings) remove_pwatch (thisAgent, prod);
remove_from_dll (thisAgent->all_productions_of_type[prod->type], prod, next, prev);
// Remove reference from apoptosis object store
if ( ( prod->type == CHUNK_PRODUCTION_TYPE ) && ( thisAgent->rl_params ) && ( thisAgent->rl_params->apoptosis->get_value() != rl_param_container::apoptosis_none ) )
thisAgent->rl_prods->remove_object( prod );
// Remove RL-related pointers to this production
if ( prod->rl_rule )
rl_remove_refs_for_prod( thisAgent, prod );
thisAgent->num_productions_of_type[prod->type]--;
if (print_sharp_sign) print (thisAgent, "#");
if (prod->p_node) excise_production_from_rete (thisAgent, prod);
prod->name->sc.production = NIL;
production_remove_ref (thisAgent, prod);
}
char first_letter_from_rhs_value ( rhs_value  rv)

Definition at line 1008 of file production.cpp.

References first_letter_from_symbol(), rhs_value_is_symbol(), and rhs_value_to_symbol().

Referenced by copy_action_list_and_substitute_varnames(), and parse_attr_value_make().

{
return '*'; /* function calls, reteloc's, unbound variables */
}
char first_letter_from_symbol ( Symbol sym)
char first_letter_from_test ( test  t)
Symbol* generate_new_variable ( agent thisAgent,
const char *  prefix 
)

Definition at line 1515 of file production.cpp.

References variable_struct::current_binding_value, agent_struct::current_variable_gensym_number, GENERATE_NEW_VARIABLE_BUFFER_SIZE, variable_struct::gensym_number, agent_struct::gensymed_variable_count, make_variable(), NIL, symbol_remove_ref(), TRUE, and symbol_union::var.

Referenced by add_gensymmed_equality_test(), copy_rhs_value_and_substitute_varnames(), simplify_test(), substitute_for_placeholders_in_symbol(), and variablize_symbol().

{
#define GENERATE_NEW_VARIABLE_BUFFER_SIZE 200 /* that ought to be long enough! */
Symbol *New;
char first_letter;
first_letter = *prefix;
if (isalpha(first_letter)) {
if (isupper(first_letter)) first_letter = static_cast<char>(tolower(first_letter));
} else {
first_letter = 'v';
}
while (TRUE) {
SNPRINTF (name,GENERATE_NEW_VARIABLE_BUFFER_SIZE, "<%s%lu>", prefix,
static_cast<long unsigned int>(thisAgent->gensymed_variable_count[first_letter-'a']++));
name[GENERATE_NEW_VARIABLE_BUFFER_SIZE - 1] = 0; /* ensure null termination */
New = make_variable (thisAgent, name);
if (New->var.gensym_number != thisAgent->current_variable_gensym_number) break;
symbol_remove_ref (thisAgent, New);
}
return New;
}
tc_number get_new_tc_number ( agent thisAgent)
uint32_t hash_condition ( agent thisAgent,
condition cond 
)

Definition at line 883 of file production.cpp.

References abort_with_fatal_error(), three_field_tests_struct::attr_test, BUFFER_MSG_SIZE, CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, hash_condition(), hash_test(), three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, condition_struct::next, NIL, POSITIVE_CONDITION, condition_struct::test_for_acceptable_preference, condition_struct::condition_main_data_union::tests, ncc_info_struct::top, condition_struct::type, uint32_t(), and three_field_tests_struct::value_test.

Referenced by hash_condition(), and make_chunk_cond_for_condition().

{
uint32_t result;
switch (cond->type) {
result = hash_test (thisAgent, cond->data.tests.id_test);
result = (result << 24) | (result >> 8);
result ^= hash_test (thisAgent, cond->data.tests.attr_test);
result = (result << 24) | (result >> 8);
result ^= hash_test (thisAgent, cond->data.tests.value_test);
if (cond->test_for_acceptable_preference) result++;
break;
result = 1267818;
result ^= hash_test (thisAgent, cond->data.tests.id_test);
result = (result << 24) | (result >> 8);
result ^= hash_test (thisAgent, cond->data.tests.attr_test);
result = (result << 24) | (result >> 8);
result ^= hash_test (thisAgent, cond->data.tests.value_test);
if (cond->test_for_acceptable_preference) result++;
break;
result = 82348149;
for (c=cond->data.ncc.top; c!=NIL; c=c->next) {
result ^= hash_condition (thisAgent, c);
result = (result << 24) | (result >> 8);
}
break;
default:
{ char msg[BUFFER_MSG_SIZE];
strncpy (msg, "Internal error: bad cond type in hash_condition\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
result = 0; /* unreachable, but gcc -Wall warns without it */
}
return result;
}
uint32_t hash_test ( agent thisAgent,
test  t 
)

Definition at line 502 of file production.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, common, 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, GREATER_OR_EQUAL_TEST, GREATER_TEST, IMPASSE_ID_TEST, LESS_OR_EQUAL_TEST, LESS_TEST, NIL, NOT_EQUAL_TEST, complex_test_struct::test_info_union::referent, referent_of_equality_test(), cons_struct::rest, SAME_TYPE_TEST, test_is_blank_or_equality_test(), test_is_blank_test(), complex_test_struct::type, and uint32_t().

Referenced by hash_condition().

{
cons *c;
uint32_t result;
return 0;
return referent_of_equality_test(t)->common.hash_id;
switch (ct->type) {
case GOAL_ID_TEST: return 34894895; /* just use some unusual number */
case IMPASSE_ID_TEST: return 2089521;
result = 7245;
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest)
result = result + static_cast<Symbol *>(c->first)->common.hash_id;
return result;
result = 100276;
// bug 510: conjunctive tests' order needs to be ignored
//for (c=ct->data.disjunction_list; c!=NIL; c=c->rest)
// result = result + hash_test (thisAgent, static_cast<char *>(c->first));
return result;
case LESS_TEST:
return (ct->type << 24) + ct->data.referent->common.hash_id;
default:
{ char msg[BUFFER_MSG_SIZE];
strncpy (msg, "production.c: Error: bad test type in hash_test\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
}
return 0; /* unreachable, but without it, gcc -Wall warns here */
}
void init_production_utilities ( agent thisAgent)

Definition at line 53 of file production.cpp.

References agent_struct::action_pool, agent_struct::complex_test_pool, agent_struct::condition_pool, init_memory_pool(), init_reorderer(), agent_struct::not_pool, and agent_struct::production_pool.

Referenced by init_soar_agent().

{
init_memory_pool (thisAgent, &thisAgent->complex_test_pool, sizeof(complex_test), "complex test");
init_memory_pool (thisAgent, &thisAgent->condition_pool, sizeof(condition), "condition");
init_memory_pool (thisAgent, &thisAgent->production_pool, sizeof(production), "production");
init_memory_pool (thisAgent, &thisAgent->action_pool, sizeof(action), "action");
init_memory_pool (thisAgent, &thisAgent->not_pool, sizeof(not_struct), "not");
init_reorderer(thisAgent);
}
production* make_production ( agent thisAgent,
byte  type,
Symbol name,
condition **  lhs_top,
condition **  lhs_bottom,
action **  rhs_top,
Bool  reorder_nccs 
)

Definition at line 1562 of file production.cpp.

References production_struct::action_list, add_bound_variables_in_condition_list(), agent_struct::all_productions_of_type, calculate_compile_time_o_support(), production_struct::declared_support, production_struct::documentation, FALSE, production_struct::filename, production_struct::firing_count, get_new_tc_number(), get_number_from_symbol(), insert_at_head_of_dll, production_struct::instantiations, production_struct::interrupt, JUSTIFICATION_PRODUCTION_TYPE, MAKE_ACTION, production_struct::name, sym_constant_struct::name, agent_struct::name_of_production_being_reordered, action_struct::next, NIL, agent_struct::num_productions_of_type, production_struct::p_node, print(), print_with_symbols(), sym_constant_struct::production, agent_struct::production_pool, production_struct::reference_count, action_struct::referent, reorder_action_list(), reorder_lhs(), reset_variable_generator(), production_struct::rhs_unbound_variables, rhs_value_to_symbol(), production_struct::rl_delta_bar_delta_beta, production_struct::rl_delta_bar_delta_h, production_struct::rl_ecr, production_struct::rl_efr, production_struct::rl_ref_count, production_struct::rl_rule, production_struct::rl_template_conds, production_struct::rl_template_instantiations, production_struct::rl_update_count, rl_update_template_tracking(), rl_valid_rule(), symbol_union::sc, smem_valid_production(), action_struct::support, TEMPLATE_PRODUCTION_TYPE, production_struct::trace_firings, production_struct::type, action_struct::type, UNDECLARED_SUPPORT, and UNKNOWN_SUPPORT.

Referenced by chunk_instantiation(), parse_production(), and rl_build_template_instantiation().

{
action *a;
reset_variable_generator (thisAgent, *lhs_top, *rhs_top);
tc = get_new_tc_number(thisAgent);
add_bound_variables_in_condition_list (thisAgent, *lhs_top, tc, NIL);
if (! reorder_action_list (thisAgent, rhs_top, tc)) return NIL;
if (! reorder_lhs (thisAgent, lhs_top, lhs_bottom, reorder_nccs)) return NIL;
if ( !smem_valid_production( *lhs_top, *rhs_top ) )
{
print( thisAgent, "ungrounded LTI in production\n" );
return NIL;
}
#ifdef DO_COMPILE_TIME_O_SUPPORT_CALCS
calculate_compile_time_o_support (*lhs_top, *rhs_top);
#ifdef LIST_COMPILE_TIME_O_SUPPORT_FAILURES
for (a = *rhs_top; a!=NIL; a=a->next)
if ((a->type==MAKE_ACTION) && (a->support==UNKNOWN_SUPPORT)) break;
if (a) print_with_symbols (thisAgent, "\nCan't classify %y\n", name);
#endif
#else
for (a = *rhs_top; a!=NIL; a=a->next) a->support = UNKNOWN_SUPPORT;
#endif
} else {
/* --- for justifications --- */
/* force run-time o-support (it'll only be done once) */
for (a = *rhs_top; a!=NIL; a=a->next) a->support = UNKNOWN_SUPPORT;
}
allocate_with_pool (thisAgent, &thisAgent->production_pool, &p);
p->name = name;
if (name->sc.production) {
print (thisAgent, "Internal error: make_production called with name %s\n",
print (thisAgent, "for which a production already exists\n");
}
name->sc.production = p;
p->filename = NIL;
p->firing_count = 0;
insert_at_head_of_dll (thisAgent->all_productions_of_type[type], p, next, prev);
thisAgent->num_productions_of_type[type]++;
p->type = type;
p->p_node = NIL; /* it's not in the Rete yet */
p->action_list = *rhs_top;
p->rhs_unbound_variables = NIL; /* the Rete fills this in */
// Soar-RL stuff
p->rl_update_count = 0.0;
p->rl_rule = false;
p->rl_ref_count = 0;
p->rl_ecr = 0.0;
p->rl_efr = 0.0;
if ( ( type != JUSTIFICATION_PRODUCTION_TYPE ) && ( type != TEMPLATE_PRODUCTION_TYPE ) )
{
if ( p->rl_rule )
{
}
}
rl_update_template_tracking( thisAgent, name->sc.name );
return p;
}
void mark_identifier_if_unmarked ( agent thisAgent,
Symbol ident,
tc_number  tc,
list **  id_list 
)
inline

Definition at line 1098 of file production.cpp.

References push().

Referenced by add_symbol_to_tc().

{
if ((ident)->id.tc_num != (tc))
{
(ident)->id.tc_num = (tc);
if (id_list)
push (thisAgent, (ident),(*(id_list)));
}
}
void mark_variable_if_unmarked ( agent thisAgent,
Symbol v,
tc_number  tc,
list **  var_list 
)
inline

Definition at line 1113 of file production.cpp.

References push().

Referenced by add_all_variables_in_action(), add_all_variables_in_rhs_value(), add_all_variables_in_test(), add_bound_variables_in_test(), and add_symbol_to_tc().

{
if ((v)->var.tc_num != (tc))
{
(v)->var.tc_num = (tc);
if (var_list) push (thisAgent, (v),(*(var_list)));
}
}
void quickly_deallocate_test ( agent thisAgent,
test  t 
)
inline
void reset_variable_generator ( agent thisAgent,
condition conds_with_vars_to_avoid,
action actions_with_vars_to_avoid 
)

Definition at line 1489 of file production.cpp.

References add_all_variables_in_action_list(), add_all_variables_in_condition_list(), agent_struct::current_variable_gensym_number, cons_struct::first, free_list(), agent_struct::gensymed_variable_count, get_new_tc_number(), NIL, reset_variable_gensym_numbers(), and cons_struct::rest.

Referenced by chunk_instantiation(), make_production(), p_node_to_conditions_and_nots(), parse_production(), and rl_build_template_instantiation().

{
list *var_list;
cons *c;
int i;
/* --- reset counts, and increment the gensym number --- */
for (i=0; i<26; i++) thisAgent->gensymed_variable_count[i] = 1;
if (thisAgent->current_variable_gensym_number==0) {
}
/* --- mark all variables in the given conds and actions --- */
tc = get_new_tc_number(thisAgent);
var_list = NIL;
add_all_variables_in_condition_list (thisAgent, conds_with_vars_to_avoid,tc, &var_list);
add_all_variables_in_action_list (thisAgent, actions_with_vars_to_avoid, tc, &var_list);
for (c=var_list; c!=NIL; c=c->rest)
static_cast<Symbol *>(c->first)->var.gensym_number = thisAgent->current_variable_gensym_number;
free_list (thisAgent, var_list);
}
Bool symbol_is_in_tc ( Symbol sym,
tc_number  tc 
)

Definition at line 1401 of file production.cpp.

References FALSE, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, variable_struct::tc_num, identifier_struct::tc_num, symbol_union::var, and VARIABLE_SYMBOL_TYPE.

Referenced by action_is_in_tc(), and test_is_in_tc().

{
if (sym->common.symbol_type==VARIABLE_SYMBOL_TYPE)
return (sym->var.tc_num == tc);
if (sym->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)
return (sym->id.tc_num == tc);
return FALSE;
}
Bool test_includes_equality_test_for_symbol ( test  t,
Symbol sym 
)
Bool test_includes_goal_or_impasse_id_test ( test  t,
Bool  look_for_goal,
Bool  look_for_impasse 
)
Bool test_is_in_tc ( test  t,
tc_number  tc 
)
Bool tests_are_equal ( test  t1,
test  t2,
bool  neg 
)

Definition at line 411 of file production.cpp.

References variable_struct::common_symbol_info, complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, complex_test_struct::test_info_union::disjunction_list, DISJUNCTION_TEST, FALSE, cons_struct::first, GOAL_ID_TEST, IMPASSE_ID_TEST, NIL, complex_test_struct::test_info_union::referent, referent_of_equality_test(), cons_struct::rest, symbol_common_data_struct::symbol_type, test_is_blank_or_equality_test(), tests_are_equal(), TRUE, complex_test_struct::type, symbol_union::var, and VARIABLE_SYMBOL_TYPE.

Referenced by add_new_test_to_test_if_not_already_there(), conditions_are_equal(), pick_conds_with_matching_id_test(), tests_are_equal(), and xml_pick_conds_with_matching_id_test().

{
cons *c1, *c2;
complex_test *ct1, *ct2;
{
return FALSE;
if (t1 == t2) /* Warning: this relies on the representation of tests */
return TRUE;
if (!neg)
return FALSE;
// ignore variables in negation tests
{
return TRUE;
}
return FALSE;
}
if (ct1->type != ct2->type)
return FALSE;
switch(ct1->type) {
case GOAL_ID_TEST:
return TRUE;
return TRUE;
for (c1 = ct1->data.disjunction_list, c2 = ct2->data.disjunction_list; (c1!=NIL) && (c2!=NIL); c1 = c1->rest, c2 = c2->rest)
{
if (c1->first != c2->first)
return FALSE;
}
if (c1 == c2)
return TRUE; /* make sure they both hit end-of-list */
return FALSE;
// bug 510 fix: ignore order of test members in conjunctions
{
std::list<test> copy2;
for (c2 = ct2->data.conjunct_list; c2 != NIL; c2 = c2->rest)
copy2.push_back(static_cast<test>(c2->first));
std::list<test>::iterator iter;
for (c1 = ct1->data.conjunct_list; c1 != NIL; c1 = c1->rest)
{
// check against copy
for(iter = copy2.begin(); iter != copy2.end(); ++iter)
{
if (tests_are_equal(static_cast<test>(c1->first), *iter, neg))
break;
}
// iter will be end if no match
if (iter == copy2.end())
return FALSE;
// there was a match, remove it from unmatched
copy2.erase(iter);
}
// make sure no unmatched remain
if (copy2.empty())
return TRUE;
}
return FALSE;
default: /* relational tests other than equality */
if (ct1->data.referent == ct2->data.referent)
return TRUE;
return FALSE;
}
}
void unmark_identifiers_and_free_list ( agent thisAgent,
list id_list 
)

Definition at line 1123 of file production.cpp.

References cons_struct::first, free_cons(), symbol_union::id, cons_struct::rest, and identifier_struct::tc_num.

Referenced by cond_is_in_tc().

{
cons *next;
Symbol *sym;
while (id_list) {
sym = static_cast<symbol_union *>(id_list->first);
next = id_list->rest;
free_cons (thisAgent, id_list);
sym->id.tc_num = 0;
id_list = next;
}
}
void unmark_variables_and_free_list ( agent thisAgent,
list var_list 
)