Remember: No late submissions will be accepted for this assignment!
No. 1 is a written question to be submitted on paper only (it must be typed---we can't grade what we can't read). For the remaining exercises, as usual, submit your code in one file named a4.pl electronically using turnin, and submit a printout of your code and test output (at least three usages of each predicate) in class.
This is no trick---both positions can be adequately defended by intelligent, eloquent computer scientists such as yourselves---so do not assume there's any one "right" answer. Your response should be no more than two or three paragraphs long and submitted on paper only. Type your answer, and use proper English exposition (e.g., no bulleted lists).
Now, for the Prolog...
As you've probably guessed, you should assume that the given list contains only 1s and/or 0s (consider making this assumption explicit in the form of a comment in your code).
example usages (edited SWI Prolog output):
14 ?- parity([0,1],X). X = 1 15 ?- parity([0,1,1,1,1,0],X). X = 0 16 ?- parity([0,1,1,1,1,0,1],X). X = 1
The idea here is to write predicates that can be used to plan bus trips between locations by answering questions like "What bus do I take to get from [some location] to [elsewhere]?"
More specifically, based on the busServes relation, you will define the following two predicates:
example usages (reformatted SWI Prolog output):
Copy and paste these relations into your Prolog file:2 ?- busServes(Bus,universityDistrict). Bus = 7 ; Bus = 46 ; Bus = 44 ; No 3 ?- busServes(174,downtown). Yes 4 ?- busConnects(wallingford,ballard,Bus). Bus = 46 ; Bus = 44 ; No 5 ?- busConnects(eastlake,seaTacAirport,Bus). No 6 ?- busConnectsVia(eastlake,seaTacAirport,TransferLoc,Bus1,Bus2). TransferLoc = downtown Bus1 = 25 Bus2 = 174 ; No
/* busServes(LineNo,Location) if Metro Bus No. LineNo serves, i.e. has * a stop in, area Location * * source: http://transit.metrokc.gov/bus/area_maps/seattle.html */ busServes(7,universityDistrict). busServes(7,capitolHill). busServes(7,broadway). busServes(7,downtown). busServes(7,internationalDistrict). busServes(7,rainierValley). busServes(7,columbiaCity). busServes(7,rainierBeach). busServes(25,downtown). busServes(25,eastlake). busServes(25,montlake). busServes(25,universityVillage). busServes(25,childrensHospital). busServes(25,laurelhurst). busServes(46,governmentLocks). busServes(46,ballard). busServes(46,fremont). busServes(46,wallingford). busServes(46,universityDistrict). busServes(44,governmentLocks). busServes(44,ballard). busServes(44,wallingford). busServes(44,universityDistrict). busServes(44,uwCampus). busServes(44,montlake). busServes(174,downtown). busServes(174,sodo). busServes(174,duwamish). busServes(174,seaTacAirport). busServes(174,midway). busServes(174,federalWay). busServes(34,tukwila). busServes(34,duwamish). busServes(34,gatewayCorporateCenter). busServes(34,whiteCenter). busServes(34,fauntleroy). busServes(34,westSeattleJunction). busServes(34,admiralDistrict).