A diameter-limited perceptron, in Minsky and Papert's Perceptrons, adds up evidence from partial predicates that each see only a small window of the picture. Their argument that such a machine cannot decide whether a picture is connected uses four pictures. You will check the two facts the argument rests on: which of the four pictures are connected, and whether every window sees the same evidence in total from the pair as from the pair .
Implement local_evidence(x00, x01, x10, x11, d).
Inputs
x00, x01, x10, x11: four pictures of the same shape (H, W), each a list of lists of 0/1. A cell with 1 is black.d: the window size, a positive integer.Output: a tuple (components, balanced).
components: a list of four ints, the number of connected components of black cells in x00, x01, x10, x11 in that order. Two black cells are adjacent when they share an edge (up, down, left, right). Diagonal contact does not connect. A picture is connected when it has exactly one component.balanced: True when, for every window position, the two window contents taken from x00 and x11 are the same pair, in either order, as the two contents taken from x01 and x10.Windows. A window is a block of min(d, H) consecutive rows and min(d, W) consecutive columns. Every position of that block inside the picture is a window, including overlapping ones. The content of a window is the exact pattern of 0s and 1s inside it.
balanced is True, every machine of the form whose each depend on one window gives .