-----------------------------------------------
-- Пример программы на Акторном Прологе. --
-- (c) 2003, Алексей А. Морозов, ИРЭ РАН. --
-- Построение теоретико-модельной семантики. --
-----------------------------------------------
-- Шаг 3. Моделирование отключающих портов. --
-----------------------------------------------
project: (('Example'))
-----------------------------------------------
class 'Example':
--
p1 = ('C1');
--
p2 = ('C2',
target=p1,
protecting:output=data);
--
p3 = ('C3',
receiver=p1,
/* suspending: */ input=data);
--
data;
--
[
goal.
]
-----------------------------------------------
class 'C1':
--
internal_data;
--
[
goal:-
accept(internal_data).
--
accept(_).
--
message1(A):-
internal_data== A.
--
function1()= 100.
function1()= 300.
function1()= internal_data.
]
-----------------------------------------------
class 'C2':
--
target;
output;
--
data = target ?? function1();
--
[
goal:-
output == data.
]
-----------------------------------------------
class 'C3':
--
input;
receiver;
--
g = ('Ground');
--
[
goal:-
input == #.
goal:-
g ? ground_term(input),
is_not_suspending_value(input),
native_goal.
--
is_not_suspending_value(#):-!,
-- Отсечение "!" необходимо для
-- моделирования операции not.
-- Чтобы not имел смысл, перед
-- is_not_suspending_value
-- должен применяться предикат
-- ground_term.
fail.
is_not_suspending_value(_).
--
native_goal:-
receiver <- message1(input).
]
-----------------------------------------------
-- В классе 'Ground' реализован --
-- вспомогательный предикат ground_term. --
-----------------------------------------------
class 'Ground':
[
goal.
--
ground_term(T):-
simple_ground_term(T).
ground_term(L):-
ground_list(L).
--
simple_ground_term(#).
simple_ground_term(100).
simple_ground_term(300).
--
ground_list([]).
ground_list([H|Tail]):-
ground_term(H),
ground_list(Tail).
]
-----------------------------------------------
|