From UBC Wiki

Crime Solver

Authors: Devon Kenzie and Myla White

What is the problem?

We are looking to explore the feasibility of using Prolog to solve crimes given witness testimony and details of the crime itself. Based off of this detective puzzle, we have written a program which takes real-life crimes committed in Vancouver over the past year, and hypothesized testimonies, and determines who committed each crime. Our program considers three aspects when determining whether or not a person is guilty:

  1. Actual location of the suspect (taking into account various suspect alibis)
  2. Evidence found on the scene of the crime
  3. Inconsistencies in suspect and witness testimonies

Where we find our program to be most valuable, in terms of real-life application, is its ability to take note of both major and minor discrepancies in testimonies, that might otherwise be missed by humans. Our goal with this project was prove that our program works efficiently on a small subset of data, as well as with examples of each of the key aspects of an investigation and verdict process, and therefore could be expanded to work with a much larger database, as well as using increasingly more information from the database itself.

What is the something extra?

The details of the crimes used in our program are a subset of data taken from the City of Vancouver's Open Data Catalogue for crimes in 2018. We parsed this data using JSON, integrating Prolog's JSON libraries into our program.

What did we learn from doing this?

Overall, we were both very interested and invested in this project as it allowed for us to program something that we could see real-life value in, while still being able to be artistic and creative with regards to its implementation, and the story we wanted it to tell. Because of the heavily intertwined nature of the example we modelled with the program, we got a lot of experience in visualizing the entirety of the program, and taking note of the effect each line and fact had on the final output. We both got more experience using Prolog, modelling complex systems with Prolog, and the integration between Prolog and JSON. We learned about parsing information from existing data bases to model complex ideas on a simple and restrained problem.

We found Prolog to be quite suitable for the task we presented it with. Parsing JSON was easy enough, due to Prolog's included libraries for integration with JSON. However, we had to break all 6 of our crimes into separate files to be able to access and use the data. It was unclear to us whether this was necessary because we did not have enough time to go further in depth as to whether or not we could access the data while it was all in one file (as well, our program worked just fine and was easy enough to implement with them all being in separate files), or because of limitations of the Prolog/JSON library. Further implementations could involve a more dynamic parser, able to access crime data from larger or more varied files. As implemented, our individual files looked as follows:

{	"type":"homicide",
	"address":"camosun st/w 30th ave",
	"neighbourhood":"dunbar southlands"},

We simplified the data from the original source slightly, so that only the fields we would be using were accessible.

In our limited example, we only used one of the fields for determining a guilty verdict. However, because our feasibility test was to see whether this simple task would work, and therefore could be expanded into a much more complicated one, this ability met all of our expectations. We are confident that this method would be able to be applied to greater sets of data.

Determining locations of crimes using parsed data:

location(CrimeName, Neighbourhood) :-
	string_concat(CrimeName,'.json', FileName),
	open(FileName, read, StrOut),
	json_read(StrOut, X),
	X = json(X1),
	==(NEIGHBOURHOOD, Neighbourhood).

We also found Prolog apt in interacting the user, as if the user were to give it any funny inputs, it would simply return false.

Links to code etc

Here is our project repository. Here is our final project file.