%import string
from pylog import*
%RULES
AmmountEarned(_steady,_[steady|unsteady]) :- AmmountEarned(_steady,_unsteady)
min_savings(Dependents, Amount) :-
Amount is 5000 * Dependents.
min_income(Dependents, Amount) :-
Amount is (4000 * Dependents) + 15000.
%Strategies
investment(savings) :-
savings(inadequate).
investment(stocks) :-
savings(adequate), income(adequate).
investment(combo) :-
savings(adequate), income(inadequate).
%Logic
%
savings(adequate) :-
amount_saved(Amount),
numDependents(Dependents),
min_savings(Dependents, SavingsMin),
Amount > SavingsMin.
savings(adequate) :-
numDependents(Dependents),
Dependents == 0.
savings(inadequate) :-
amount_saved(Amount),
numDependents(Dependents),
min_savings(Dependents, SavingsMin),
Amount =< SavingsMin.
income(adequate) :-
earnings(AmountEarned, steady),
numDependents(Dependents),
min_income(Dependents, IncomeMin),
AmountEarned > IncomeMin.
income(inadequate) :-
earnings(AmountEarned, steady),
numDependents(Dependents),
min_income(Dependents, IncomeMin),
AmountEarned =< IncomeMin.
income(adequate) :-
numDependents(Dependents),
Dependents == 0.
income(inadeqate) :-
earnings(ammountEarned, unsteady).
amount_saved(22000).
numDependents(3).
earnings(25000, steady).
答案 0 :(得分:0)
该程序的第一行看起来像Python,而不是Prolog。将Python和Prolog混合在一个文件中是PyLog的一个特性吗?
涉及AmmountEarned
的行充满了语法和逻辑错误。它也与程序的其余部分无关。删除它。
此外,对于未来:请在问题正文中包含确切的错误消息,而不仅仅是标题中。如果错误消息指定某个程序点(例如,行号),也包括它。