Presentation is loading. Please wait.

Presentation is loading. Please wait.

TSSPTS Климовский Аркадий, мехмат МГУ.

Similar presentations


Presentation on theme: "TSSPTS Климовский Аркадий, мехмат МГУ."— Presentation transcript:

1 TSSPTS Климовский Аркадий, мехмат МГУ

2 Представление правил и целей в виде списков
(Tiny and Slightly Slow Prolog for T-System:o) Представление правил и целей в виде списков ( a b c ) b с a

3 Представление правил и целей в виде списков
( a ( b c ) d ) a d b c

4 tfun int prove(TList tptr list_of_goals, TList tptr environment, TList tptr database, TList tptr level) { TList tptr cop_database; if (list_of_goals==NULL) printf("\nURA!!!!!\n"); print_bindings(environment, environment); printf("\nexit\n"); return 0; } else cop_database=copy_list(database); try_each(cop_database, database, cdr (list_of_goals), car (list_of_goals), environment, level); printf("\nunsuccessful exit\n");

5 tfun TList tptr try_each(TList tptr database_left, TList tptr database, TList tptr goals_left, TList tptr goal, TList tptr environment, TList tptr level) { TList tptr assertion; TList tptr new_environment; if (database_left==NULL) return NULL; assertion=copy_list(rename_variables(car(database_left), create_list(NULL, level, "empty"))); new_environment=copy_list(unify(goal, car(assertion), environment)); if (new_environment==NULL) return try_each(cdr(database_left), database, goals_left, goal, environment, level); prove(append(cdr(assertion), goals_left), new_environment, database, create_list(NULL,NULL,strcat(level->content,"1"))); return try_each(cdr (database_left), database, goals_left, goal, environment, level); }

6 tfun TList tptr unify(TList tptr x, TList tptr y, TList tptr environment)
{ TList tptr listxy; TList tptr t; TList tptr new_environment; x=copy_list(value(x, environment)); y=copy_list(value(y, environment)); if (variable_p(x)) t=create_list(NULL, y, "empty"); listxy=create_list(t, x, "empty"); return cons(listxy, environment); } if (variable_p(y)) t=create_list(NULL, x, "empty"); listxy=create_list(t, y, "empty");

7 else { if (atom(x)||atom(y)) if (equal(x,y)) return environment; return NULL; } new_environment=copy_list(unify(car(x), car(y), environment)); if (new_enviroment!=NULL) return unify(cdr(x), cdr(y), new_environment);


Download ppt "TSSPTS Климовский Аркадий, мехмат МГУ."

Similar presentations


Ads by Google