% From "Programming in Prolog", 5e by Clocksin and Mellish, p.91

average_taxpayer(X) :-
    foreigner(X), !, fail.

average_taxpayer(X) :-
    spouse(X,Spouse),
    gross_income(Spouse, SpouseIncome),
    SpouseIncome > 3000, !, fail.

average_taxpayer(X) :-
    gross_income(X, Inc),
    Inc > 2000, Inc < 20000.

gross_income(X,PensionIncome) :-
    receives_pension(X,PensionIncome),
    PensionIncome < 5000, !, fail.

gross_income(X,GrossIncome) :-
    gross_salary(X, GrossSalary),
    investment_income(X,InvestmentIncome),
    GrossIncome is GrossSalary + InvestmentIncome.

investment_income(X, InvestmentIncome) :-

investment_income(X, 1000).
