1 / 7

TSSPTS

TSSPTS. Климовский Аркадий, мехмат МГУ. (Tiny and Slightly Slow Prolog for T-System:o). Представление правил и целей в виде списков. ( a b c ). b. с. a. Представление правил и целей в виде списков. ( a ( b c ) d ). a. d. b. c.

lily
Download Presentation

TSSPTS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 tptrlist_of_goals, TList tptrenvironment, TList tptrdatabase, TList tptrlevel) { TList tptrcop_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"); return 0; } }

  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; TListtptr 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. tfunTList tptrunify(TList tptrx, TList tptr y, TList tptrenvironment) { TList tptrlistxy; TListtptrt;TList tptrnew_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"); return cons(listxy, environment); }

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

More Related