CS157 Contest: Category 3 -- Graph Reachability


The problems is this category concern vertex reachability in connected graphs.

A graph is described by its directed edges. Any vertex is reachable from itself. For any pair of vertices a and b such that a is not equal to b, a is reachable from b if and only if there is a path from a to b.

We provide you with the axioms that define path and reachable. Besides the definitions, in each problem you will be given edge data for specific graphs, in the form of ground atomic propositions. You will not be given any more axioms. You will have to determine whether a vertex in a given graph is reachable from another vertex.

Your solution will contain the following:

Background Axioms

  path(x,y) <= edge(x,y) | path(x,z) & path(z,y)
  reachable(x,x)
  reachable(x,y) <= path(x,y)

Sample Premises

  edge(a,b)
  edge(b,a)

Sample Conclusion

  reachable(a,b)