⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ans_121a.pro

📁 prolog,人工智能推理程序,运行环境prolog
💻 PRO
字号:
/*
   Turbo Prolog 2.0, Answer to first Exercise on page 121.
   
   Copyright (c) 1986, 88 by Borland International, Inc
*/

Domains
    person = symbol

Predicates
    special_taxpayer(person)
    average_taxpayer(person)
    is_a_citizen(person)
    married(person,person)
    has_kids(person,integer)
    has_two_kids(person,integer)
    makes_bucks(person,integer)
    right_income(person,integer)

Clauses
    is_a_citizen(tom).
    is_a_citizen(albert).
    is_a_citizen(suzie).
    is_a_citizen(bonnie).
    is_a_citizen(Person):- 
        married(Person,Spouse),
        is_a_citizen(Spouse),!.   /* The cut must be placed here to prevent
                                     unnecessary backtracking. To see this, 
                                     trace thru the program, first with
                                     and then without the cut.                  
                                  */
    married(tom,chris).
    married(albert,rachel).
    married(fred,suzie).
    married(duke,joanne).

    has_kids(albert,3).
    has_kids(suzie,2).
    has_kids(fred,2).
    has_kids(bonnie,1).
    has_kids(tom,0).

    has_two_kids(Person,X):-
        has_kids(Person,X),
        X=2.                   

    makes_bucks(tom,250).
    makes_bucks(fred,3000).
    makes_bucks(albert,1500).
    makes_bucks(suzie,0).

    right_income(Person,N):-
        makes_bucks(Person,N),
        500 <= N,               
        N <= 2000.

    average_taxpayer(Person):-
        is_a_citizen(Person),
        right_income(Person,_),
        has_two_kids(Person,_),
        married(Person,_),
        write(Person," is an average taxpayer").

    special_taxpayer(Person):-
        not(average_taxpayer(Person)),
        write(Person," is a special taxpayer").

Goal
    special_taxpayer(fred).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -