title: Decision Tree in Prolog
body: <p>The following is my Prolog program for a decision tree which gives output oil or telecommunication or computers (investment option for the person:oil-high risk,telecommunication- moderate risk,computer-stable risk) depending on the input given name,marital_status, income and mortgage. But I am getting an error! 
      moderate_risk(X):-ask_marital_status(X,Y), Y=married, ask_income(X,I), 
                  I=&lt;50000, ask_mortgage(X,Z), Z=&lt;50000,!.</p>
  
  <pre><code>moderate_risk(X):-ask_marital_status(X,M),M=married,ask_income(X,I), I&gt;50000,!.
  
  
  moderate_risk(X):-ask_marital_status(X,M), M=single, ask_income(X,I), I=&lt;35000,!.
  
  
  stable_risk(X):-ask_marital_status(X,M), M=married, ask_income(X,I), I=&lt;50000,
  
  
                  ask_mortgage(X,Z), Z&gt;50000,!.
  
  
  stable_risk(X):-ask_marital_status(X,M), M=single, ask_income(X,I), I&gt;35000,  
  
  
                          ask_age(X,A),A&gt;50,!.
  
  
  high_risk(X):-ask_marital_status(X,M), M=single, ask_income(X,I), I&gt;35000,
  
  
  
                       ask_age(X,A),A=&lt;50,!.
  
  
  invest(X,oil):-stable_risk(X),!.
  
  
  invest(X,telecommunications):-moderate_risk(X),!.
  
  
  invest(X,computers):-high_risk(X),!.
  
  main(X,Z):-var(X), write('what is your name?'),read(X), invest(X,Z),!.
  
  
  main(X,Z):-invest(X,Z),!.
  
  
  ask_marital_status(X,Y):-marital_status(X,Y).
  
  
  ask_marital_status(X,Y):-not(marital_status(X,Y)), write('what is your marital
  
  
  
    status:married or single?'), read(Y), asserta(marital_status(X,Y)).
  
  
      ask_income(X,Y):-income(X,Y).
  
  
  ask_income(X,Y):-not(income(X,Y)),write('what is your annual income?'), read(Y),
  
  
  asserta(income(X,Y)).
  
  
  ask_mortgage(X,Z):-mortgage(X,Z).
  
  
  ask_mortgage(X,Z):-not(mortgage(X,Z)),write('what is your remaining mortgage?'),
  
  
   read(Z), asserta(mortgage(X,Z)).
  
  
  ask_age(X,A):-not(age(X,A)).
  
  
  ask_age(X,A):-not(age(X,A)), write('what is your age?'), read(A), asserta(age(X,A)).
  </code></pre>