Background
I have a bunch of old and grainy black-and-white images. Some of them depict vines climbing on a wall, others don't – your task is to classify them for me.
Input and output
Your input is a rectangular 2D array of bits A, given in any convenient format. It will not be empty, but it's not guaranteed to contain both 0s and 1s. The array depicts a vine if the following conditions hold:
- The bottom row of A contains at least one 1. These are the roots of the vine.
- Every 1 in A is connected to the bottom row by a path of 1s that only goes left, right and down (not up, and not diagonally). These paths are the branches of the vine.
Your output is a consistent truthy value if the input depicts a vine, and a consistent falsy value otherwise.
Examples
This array depicts a vine:
0 0 1 0 0 1
0 1 1 0 0 1
0 1 0 1 1 1
1 1 0 1 0 1
0 1 1 1 0 1
0 0 1 0 1 1
This input does not depict a vine, since there's a 1 at the middle of the right border that's not connected to the roots by a branch:
0 0 0 1 1 0
0 1 0 1 1 1
0 1 0 1 0 1
0 1 1 1 1 0
0 0 1 1 0 1
The all-0 array never depicts a vine, but the all-1 array always does.
Rules and scoring
You can write a full program or a function. The lowest byte count wins, and standard loopholes are disallowed.
Test cases
Truthy inputs:
1
0
1
1
01
11
0000
0111
1100
1001
1111
1111
1111
1111
001001
011001
010111
110101
011101
001011
1011011
1001001
1111111
0100000
0111111
1111001
1001111
1111101
0000000
0011100
0010100
0011100
0001000
1111111
0001000
0011100
0010100
0010100
Falsy inputs:
0
1
0
10
01
000
000
000
011
110
000
111111
000000
101011
111001
010010
001000
000010
110001
001100
111111
110101
010011
111011
000110
010111
010101
011110
001101
11000000
10110001
10011111
11110001
01100011
00110110
01101100
01100001
01111111