begin %hospital% patient(name, id, cm, kg) :- name="Anderson", id=100, cm=200, kg=130. patient(name, id, cm, kg) :- name="Brown", id=111, cm=150, kg=50. patient(name, id, cm, kg) :- name="Davis", id=222, cm=190, kg=90. patient(name, id, cm, kg) :- name="Edwards", id=333, cm=160, kg=90. patient(name, id, cm, kg) :- name="Ford", id=345, cm=165, kg=100. patient(name, id, cm, kg) :- name="Hardy", id=454, cm=175, kg=70. patient(name, id, cm, kg) :- name="Johnson", id=567, cm=170, kg=50. patient(name, id, cm, kg) :- name="Smith", id=755, cm=180, kg=120. doctor(name, id, age, spec) :- name="Cheney", id=987, age=50, spec="pediatry". doctor(name, id, age, spec) :- name="Hardy", id=454, age=53, spec="osteopathology". doctor(name, id, age, spec) :- name="McBride", id=377, age=36, spec="radiology". doctor(name, id, age, spec) :- name="Miller", id=300, age=60, spec="gynecology". doctor(name, id, age, spec) :- name="Moss", id=244, age=30, spec="neurology". doctor(name, id, age, spec) :- name="Nelson", id=400, age=76, spec="cardiology". doctor(name, id, age, spec) :- name="O'Brien", id=181, age=56, spec="urology". doctor(name, id, age, spec) :- name="Paine", id=266, age=45, spec="cardiology". doctor(name, id, age, spec) :- name="Pepper", id=555, age=42, spec="cardiology". doctor(name, id, age, spec) :- name="Snow", id=500, age=65, spec="radiology". visit(pid, did, month, day, year) :- pid=100, did=555, month=6, day=30, year=1999. visit(pid, did, month, day, year) :- pid=100, did=181, month=5, day=20, year=2001. visit(pid, did, month, day, year) :- pid=111, did=987, month=8, day=20, year=2002. visit(pid, did, month, day, year) :- pid=111, did=987, month=5, day=28, year=2003. visit(pid, did, month, day, year) :- pid=222, did=266, month=9, day=12, year=2000. visit(pid, did, month, day, year) :- pid=222, did=400, month=5, day=20, year=2001. visit(pid, did, month, day, year) :- pid=222, did=555, month=5, day=20, year=2001. visit(pid, did, month, day, year) :- pid=333, did=987, month=6, day=23, year=2003. visit(pid, did, month, day, year) :- pid=345, did=300, month=5, day=16, year=2000. visit(pid, did, month, day, year) :- pid=454, did=244, month=1, day=18, year=2002. visit(pid, did, month, day, year) :- pid=567, did=454, month=5, day=28, year=2003. visit(pid, did, month, day, year) :- pid=567, did=377, month=2, day=20, year=2003. visit(pid, did, month, day, year) :- pid=755, did=987, month=6, day=23, year=2003. weight(kg, lb) :- 2.2kg-lb = 0. height(cm, in) :- 0.39cm-in = 0. weight_watcher(id, kg, month) :- id=100, kg+6month=130, month>=0, month<=5. weight_watcher(id, kg, month) :- id=100, kg+2month=110, month>=5, month<=12. weight_watcher(id, kg, month) :- id=755, kg+2month=120, month>=0, month<=12. weight_percent(percent, cm, kg) :- percent=95, kg-cm = -80. weight_percent(percent, cm, kg) :- percent=50, kg-0.833cm = -66.66. weight_percent(percent, cm, kg) :- percent=5, kg-0.666cm = -53.33. fit(type, cm, kg) :- type="overweight", kg-cm>-80. fit(type, cm, kg) :- type="normal", kg-cm<=-80, kg-0.66cm>=-53.33. fit(type, cm, kg) :- type="underweight", kg-0.66cm <-53.33. end %hospital%