// Souffle - A Datalog Compiler
// Copyright (c) 2017, The Souffle Developers. All rights reserved
// Licensed under the Universal Permissive License v 1.0 as shown at:
// - https://opensource.org/licenses/UPL
// - <souffle root>/licenses/SOUFFLE-UPL.txt

.type Street <: symbol

.decl greenSignal(s:Street)
.decl hasTraffic(s:Street)
.decl intersect(s1:Street, s2:Street)
.decl crashable(s1:Street, s2:Street)
.decl crashes(s:Street)

.output crashable
.output crashes

crashable(X, Y) :- intersect(X, Y), greenSignal(X), greenSignal(Y).
crashes(X) :- hasTraffic(X), crashable(X, Y), hasTraffic(Y).
crashes(X) :- hasTraffic(X), crashable(Y, X), hasTraffic(Y).

greenSignal("Abercrombie St").
greenSignal("Cleveland St").
greenSignal("Shepard St").
greenSignal("Elizabeth St").
greenSignal("Goulburn St").

hasTraffic("Abercrombie St").
hasTraffic("Lawson St").
hasTraffic("Elizabeth St").
hasTraffic("Goulburn St").

intersect("Abercrombie St", "Lawson St").
intersect("Cleveland St", "Shepard St").
intersect("Elizabeth St", "Goulburn St").
