/* * Filename: mc5.pro (marriage counsellor 5) * * Programmer: Br. David Carlson * * Date of creation: September 4, 1993 * * Revised: December 11, 1999 * * Description: * * This program is used to predict the likelihood that 2 people have * (or will have) marriage problems. Use the goal: * problems(marriage, Probability). * You can also submit other goals such as: * problems(psychological, Probability), * Finally, you can try goals such as: * success(marriage, Probability). */ problems(marriage, Prob) :- problems(financial, FinProb), problems(sexual, SexProb), problems(communications, CommProb), problems(psychological, PsychProb), problems(parental_divorce, ParDivProb), average5(FinProb, SexProb, CommProb, PsychProb, ParDivProb, Prob). problems(financial, 1.0) :- unemployed(husband), unemployed(wife). problems(financial, 0.8) :- underemployed(husband), unemployed(wife). problems(financial, 0.8) :- unemployed(husband), underemployed(wife). problems(financial, 0.5) :- underemployed(husband), underemployed(wife). /* The 3 problems in the next section are seen as so important that the * resultant probability is the largest of the 3 probabilities, instead * of the average. */ problems(sexual, Prob) :- unfaithful(husband, HusbProb), unfaithful(wife, WifeProb), impotence(ImProb), maximum3(HusbProb, WifeProb, ImProb, Prob). /* In the next section as well, the resultant probability is taken to be * the largest of the component probabilities. */ problems(communications, Prob) :- dominance(DomProb), abuse(AbuseProb), reticence(RetProb), maximum3(DomProb, AbuseProb, RetProb, Prob). problems(psychological, Prob) :- abuse(AbuseProb), depression(DepressProb), psychosis(PsychProb), maximum3(AbuseProb, DepressProb, PsychProb, Prob). problems(parental_divorce, 1.0) :- divorced_parents(husband), divorced_parents(wife), !. problems(parental_divorce, 0.5) :- divorced_parents(husband), !. problems(parental_divorce, 0.5) :- divorced_parents(wife), !. problems(parental_divorce, 0.0). dominance(Prob) :- domineering(wife, WifeProb), domineering(husband, HusbProb), maximum2(WifeProb, HusbProb, Prob). abuse(Prob) :- abusive(husband, HusbProb), abusive(wife, WifeProb), maximum2(HusbProb, WifeProb, Prob). reticence(Prob) :- reticent(husband, HusbProb), reticent(wife, WifeProb), average2(HusbProb, WifeProb, Prob). depression(Prob) :- depressed(husband, HusbProb), depressed(wife, WifeProb), average2(HusbProb, WifeProb, Prob). psychosis(Prob) :- psychotic(husband, HusbProb), psychotic(wife, WifeProb), average2(HusbProb, WifeProb, Prob). success(Area, Prob) :- problems(Area, ProblemProb), Prob is 1 - ProblemProb. average5(N1, N2, N3, N4, N5, Avg) :- Avg is (N1 + N2 + N3 + N4 + N5) / 5. average3(N1, N2, N3, Avg) :- Avg is (N1 + N2 + N3) / 3. average2(N1, N2, Avg) :- Avg is (N1 + N2) / 2. maximum2(N1, N2, N1) :- N1 > N2, !. maximum2(N1, N2, N2). maximum3(N1, N2, N3, Max) :- N1 > N2, !, maximum2(N1, N3, Max). maximum3(N1, N2, N3, Max) :- maximum2(N2, N3, Max). /* In the next section, fill in the data on the husband and wife to be * counselled. */ unemployed(husband). underemployed(wife). unfaithful(husband, 0.3). unfaithful(wife, 0.1). impotence(0.1). domineering(husband, 0.6). domineering(wife, 0.0). abusive(husband, 0.5). abusive(wife, 0.0). reticent(husband, 0.2). reticent(wife, 0.6). depressed(husband, 0.1). depressed(wife, 0.4). psychotic(husband, 0.0). psychotic(wife, 0.0). divorced_parents(wife). divorced_parents(husband).