containers.lp
No OneTemporary

File Metadata

Created
Fri, Mar 13, 7:46 PM

containers.lp

implementation(hashlist). implementation(linkedlist). implementation(treelist).
operation(at). operation(sort). operation(insert).
relation (recommends). relation (satisfied). relation(unsupported).
relation_score(satisfied, 0).
relation_score(recommends, 1).
relation_score(unsupported, -1).
relation_op(at, hashlist, recommends). relation_op(at,treelist, satisfied).
relation_op(sort, linkedlist, satisfied). relation_op(sort, treelist, satisfied). relation_op(sort, hashlist, unsupported).
impl_fulfill(OP, IMPL, SCORE):- relation_op(OP, IMPL, RL), relation_score(RL, SCORE), operation(OP), implementation(IMPL), RL!=unsupported.
impl_not_fulfill(OP, IMPL):- relation_op(OP, IMPL, unsupported).
%static analysis:
var(a).var(b).
bind_var_op(a, at).
bind_var_op(a, sort).
bind_var_op(b, insert).
var_connection(a, b).
%* var_connection(VAR_FROM, VAR_TO, connection_type) *%
%* var_cluster(VAR_FROM, VAR_TO) *%
connection_type(ct_inherits). connection_type(ct_convert).
var_connection(VAR_FROM, VAR_TO, CT):connection_type(CT) :- var_connection(VAR_FROM, VAR_TO).
var_cluster_root(VAR) :- {var_connection(VAR_F, VAR, ct_inherits): var(VAR_F)} 0, var(VAR).
var_cluster(VAR0, VAR_TO) :- var_connection(VAR0, VAR_TO, ct_inherits), var_cluster_root(VAR0).
var_cluster(VAR0, VAR_TO2) :- var_connection(VAR_TO1, VAR_TO2, ct_inherits), var_cluster(VAR0, VAR_TO1).
var_cluster(VAR0, VAR0):- var_cluster_root(VAR0).
#domain implementation(IMPL).
%#domain var(VAR).
impl_fulfill_cluster(VAR0, OP, IMPL, SCORE) :- var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_fulfill(OP, IMPL, SCORE), var_cluster_root(VAR0).
impl_not_fulfill_cluster(VAR0, IMPL):-var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_not_fulfill(OP, IMPL), var_cluster_root(VAR0).
%bind_cluster_op(VAR0, OP) :- bind_var_op(VAR0, OP).
bind_var_impl(VAR0, IMPL, SCORE_RESULT) :- SCORE_RESULT = #sum[impl_fulfill_cluster(VAR0, _, IMPL, SCORE) = SCORE], {impl_not_fulfill_cluster(VAR0, IMPL)}0, var_cluster_root(VAR0).
%:- bind_var_impl(VAR0, IMPL, _), var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_not_fulfill(OP, IMPL).
%impl_fulfill(OP, IMPL, SCORE) : bind_var_op(VAR, OP), var(VAR), SCORE_RESULT = 0 , relation_score(_, SCORE).
%%* *%
#hide.
#show bind_var_impl/3.
#show var_cluster_owner/1.
#show var_connection/3.
#show bind_var_op/2.

Event Timeline