Prolog:检查字典是否有特殊成员

Prolog: Check if dictionary has special member

根据我的问题,我有以下序言代码:

:-op(900, xfy, →).
:-op(900, xfy, ⟷).
    
find_axioms(Specific, BaseSet, Fullfill) :-
        findall(X, 
                ( member(X, Specific), 
                  member(X, BaseSet) ), 
                Fullfill).

我的输入

find_axioms([(peter → anna), (peter → peter)], [(A → A), (B → A) ⟷ (A → B)], Z).

给出:

Z = [peter→peter].

我现在的目标是以这种方式概括它,BaseSet 是一些字典。意味着所有公理都已经将名称作为键。所以:

find_axioms([(peter → anna), (peter → peter)], axioms{'axiom1':(A → A), 'axiom2':(B → A) ⟷ (A → B)}, Z).

会得到

Z = axioms{'axiom1':(peter l peter)}

最好的方法是什么?

我找到了一些解决方案。

:-op(900, xfy, →).
:-op(900, xfy, ⟷).
    
find_axioms(Specific, BaseSet, Fullfill) :-
        findall(X, 
                ( member(X, Specific), 
                  member(X, BaseSet) ), 
                Fullfill).

find_axioms_pair(Specific, BaseSet, Fullfill) :-
    pairs_values(BaseSet, BaseSet_Values),
    find_axioms(Specific, BaseSet_Values, Fullfill_Values),
    pairs_values(Fullfill, Fullfill_Values),
    subset(Fullfill, BaseSet).

find_axioms_dict(Specific, BaseSet, Fullfill) :-
    dict_pairs(BaseSet, _, BaseSet_Pairs),
    find_axioms_pair(Specific, BaseSet_Pairs, Fullfill_Pairs),
    dict_pairs(Fullfill, useable_axioms, Fullfill_Pairs).