Скачиваний:
7
Добавлен:
17.01.2022
Размер:
1.51 Кб
Скачать
domains
name=symbol
list=name*
predicates
nondeterm include_task(name, name)
nondeterm pipe(name, name)
nondeterm first(name, name)
nondeterm next(name, name)
nondeterm ahead(name, name)
nondeterm between(name, name, list)
nondeterm descendant(name, name)
clauses
include_task("A", "A1").
include_task("A", "A2").
include_task("A", "A3").
include_task("A1", "A11").
include_task("A1", "A12").
include_task("A1", "A13").
include_task("A2", "A21").
include_task("A2", "A22").
include_task("A22", "A221").
include_task("A22", "A222").
include_task("A21", "A211").

pipe("A1", "A2").
pipe("A2", "A3").
pipe("A21", "A22").
pipe("A12", "A13").
pipe("A11", "A12").
pipe("A221", "A222").

descendant(X,Y):- include_task(Y,X).
descendant(X,Y):- include_task(Y,Z), descendant(X,Z).

first(X,X):- not(include_task(X,_)), !.
first(X,Y):- include_task(X,Y), not(include_task(Y,_)), not(pipe(_,Y)), !.
first(X,Y):- include_task(X,Z), include_task(Z,_), not(pipe(_,Z)), first(Z,Y), !.

next(X,Y):- pipe(X,Z), first(Z,Y), !.
next(X,Y):- descendant(X,P1), pipe(P1,P2), first(P2,Y), !.

ahead(X,Y):- next(Y,Z), first(X,Z), !.
ahead(X,Y):- next(Y,Z), !, ahead(X,Z).

between(X,Y,[]):- descendant(X,Y), !; descendant(Y,X), !.
between(X,Y,Z):- ahead(X,Y), !, between(Y,X,Z).

between(X,Y,[]):- next(X,Z), first(Y,Z), !.
between(X,Y,[Z|Zs]):- next(X,Z), between(Z,Y,Zs).
goal
%ahead("A22","A21").
between("A12","A221",R).
Соседние файлы в папке Практика 3
  • #
    14.09.20221.72 Кб5dz3.pro
  • #
    14.09.202231.82 Кб5дерево.vsdx
  • #
    17.01.20221.51 Кб7код.txt
  • #
    17.01.202229.13 Кб10схема процессов.vsdx