[Question]
  [
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as
```
+ + + - - - + +
+ + - N - N - +
+ + - N - N - +
+ + - N N N - +
+ + + - - - + +
```
where
* `N` is the same number, repeated in those seven positions
* `-` (optional) represents any number different than `N`. Each `-` can be a different number
* `+` (optional) represents any number. Each `+` can be a different number.
The amount of `+` and `-` entries obviously depends on the size of the matrix. In particular, some `-` may not exist because the pattern is adjacent to a matrix border. The above representation corresponds to a 5×8 matrix.
The pattern must have the specified orientation. Reflections or rotations are not valid.
# Test cases
### Truthy
* Pattern with `N=8`:
```
 3 4 7 5 6 5 4 8
 8 7 3 8 5 8 2 4
 9 9 9 8 7 8 1 3
 4 5 3 8 8 8 3 6
 6 8 9 2 3 2 1 4
```
* Same pattern with some `N` values nearby:
```
 3 4 7 5 6 5 8 8
 8 7 3 8 5 8 2 4
 9 9 9 8 7 8 1 3
 4 5 3 8 8 8 3 6
 6 8 8 2 3 2 1 4
```
* Pattern with `N=3`, touching a matrix border:
```
 7 5 4 7 5 4 5 6
 7 1 5 3 5 3 6 3
 3 5 3 3 9 3 2 3
 3 1 2 6 7 3 3 3
 4 5 2 8 9 6 8 4 
```
* Pattern with `N=4`, touching a matrix corner:
```
 4 1 4 6
 4 3 4 3 
 4 4 4 5
 7 5 3 5
```
* Two patterns, with `N=5` and `N=9`:
```
 6 7 9 4 5 6 7
 5 2 5 9 8 9 8
 5 1 5 9 6 9 3
 5 5 5 9 9 9 4
 8 7 6 1 3 2 5
```
* Pattern with `N=3`, and broken pattern with `1`:
```
 1 2 1 2 3 2 3
 1 2 1 2 3 2 3
 1 1 1 1 3 3 3
```
* Numbers can be greater than `9`; here `N=25`:
```
 23 56 34 67 34  3
 34 25  4 25 48 49
 24 25 97 25 56 56
 12 25 25 25 32 88
```
* Minimalistic case, `N=2`:
```
 2 1 2
 2 5 2
 2 2 2
```
### Falsy
* Nothing special here:
```
 7 8 6 5 4
 3 4 5 6 3
 3 5 6 4 4
 7 8 9 3 2
```
* Rotated or reflected patterns are not valid:
```
 9 9 9 3 7 7 7 5
 4 4 9 2 7 8 7 6
 9 9 9 8 7 9 7 4
```
* Some `-` entry spoils the pattern
```
 9 5 5 6 5
 3 8 5 9 5
 2 9 5 5 5
```
* Some `-` entry spoils the pattern, even if the result would be a "U" with longer horns
```
 7 8 5 2 5
 9 2 5 6 5
 3 8 5 9 5
 2 9 5 5 5
```
* Minimalistic case, no pattern
```
 9 9 9
 9 8 9
 9 9 9 
```
# Additional rules
* You can choose to output:
	+ Any two distinct values/arrays/strings... depending on whether the matrix contains the specified pattern or not; or
	+ Anything [truthy](https://codegolf.meta.stackexchange.com/a/2194/36398) if the matrix contains the specified pattern, and anything [falsy](https://codegolf.meta.stackexchange.com/a/2194/36398) otherwise. The specific truthy and falsy values/arrays/strings... can be different for different inputs.
* The code should work in theory for matrices of arbitrarily large size, containing arbitrarily large numbers. In practice, it is acceptable if the program is limited by time, memory or data-type restrictions.
* Input and output are [flexible](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) as usual. [Programs or functions](http://meta.codegolf.stackexchange.com/a/2422/36398) are allowed, in any [programming language](https://codegolf.meta.stackexchange.com/questions/2028/what-are-programming-languages/2073#2073). [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* Shortest code in bytes wins.
  
[Answer]
# JavaScript (ES7), ~~124 110~~ 105 bytes
Returns a Boolean value.
```
m=>m.some((r,y)=>r.some((v,x)=>(g=n=>n--?v==(m[y+~-(n/5)]||0)[x+n%5-1]^144140166590/3**n%3&&g(n):1)(24)))
```
[Try it online!](https://tio.run/##nVFLb9swDL7rV/DSRmpelvWw3cLpaT3u0t2SDPBSJ/UQy5mdBA3W7a9npOR2QYFdBpq0KJHfx8f34lh0q7ba7ceueSrP6/xc57N60jV1yXk7Ool81vbecfSCHt/kLp@58fj@mOe8np@Gv8fcTY1Yvr5GYv4ydFdmLJdfpdZSR9Jak0VTdXPjrtT19YY7cSsFj7UQ4tyWPw5VW/LBuhuISVsWTw/Vtnw8uRWPxGTfPO7bym24mHS7bbXng4VbOAxcN@2nYvXMeTeCSkA@g58MoII8hwjuYdW4rtmWk22z4YP5l/awfz4tBwJuQ0j6MWTh5g/FtutjojvEunxf8@4vP7LXxY53RPp2PYXhNFx/PtTfyhY7E3fslzgr0JCAAYuqIWUpegr5DWoMmmVAQrcpSFBM4wu9kyiwzOI/w0iFKjGeXQKm/wmYXgImvrJgERZ96VNILQKEk0JQSiFf4t96WtUTxL5KgkZATbgIpIFqpQAS44kQjDHKzQIbJIyyjS8ZFT3pPUt86BnvkWjfqqWmKIMx6TuI@7I@ekFCiSxGXuwFq0rIUhcaYgPgrcayMxb7c5aQxWBjmYzpHD6FLaYIRByMCiaLQvNLw3b9asz7zCy17V/95Fi/GYVNkBg/F1pt4rdlLzaXoWpKMGHRLCwYfSQNtyYQ@@GxzI/wn4EemPkJ9@cwrfdu5Fs3fwA "JavaScript (Node.js) – Try It Online")
### How?
For each reference cell of value \$v\$ at \$(x,y)\$ in the input matrix \$m\$, we test 24 neighbor cells.
The constant \$144140166590\$ is \$111210001101011010121112\_3\$ in base 3. By reversing the digits and rearranging them into a 5x5 matrix, this gives:
$$\begin{pmatrix}2&1&1&1&2\\
1&\color{red}0&1&0&1\\
1&0&1&0&1\\
1&0&0&0&1\\
2&1&1&1&-\end{pmatrix}$$
where:
* the cell in red is the reference cell
* \$0\$ means that this cell must be equal to \$v\$
* \$1\$ means that this cell must be different from \$v\$
* \$2\$ means that we don't care
The bottom-right cell of the matrix is ignored, but it should be a \$2\$ anyway (for *we don't care*).
The \$n\$-th cell to test (0-indexed) is the cell whose coordinates are:
$$\big(x+(n\bmod 5)-1,y+\lfloor n/5\rfloor-1\big)$$
The corresponding value in the above matrix is given by:
$$V=\left\lfloor\frac{144140166590}{3^n}\right\rfloor\bmod 3$$
We do a bitwise XOR between the cell comparison test and \$V\$:
```
 is equal |  V  | XOR | success?
----------+-----+-----+--------------------------
     0    |  0  |  0  | no (should be equal)
     1    |  0  |  1  | yes
----------+-----+-----+--------------------------
     0    |  1  |  1  | yes
     1    |  1  |  0  | no (should be different)
----------+-----+-----+--------------------------
     0    |  2  |  2  | yes \__ always
     1    |  2  |  3  | yes /   ≠ 0
```
If all 24 tests are successful, we've found a valid `U`.
[Answer]
# [Julia 0.6](http://julialang.org/), ~~78~~ 75 bytes
```
x->any(n->7∈conv2(reshape(digits(287035908958,3)-1,5,5),1÷-~abs(x-n)),x)
```
[Try it online!](https://tio.run/##pVJdTsMwDH7nFH5MpFZakzg/ithFEA8FNiiayrQONF543o04ADfhIsV2NoE6JiEhz16S2v7sz358XnWtH5eX466et/2r6ut5@Nzvb5/6F6M2i@GhXS/UXXffbQdlYphZTLOYMFZW102FFeqq@Xiv39qbQe3qXutqp8f1puu3q14t1ZUFBwEQPKmDmCHS1ZJFUgMuQxLh5wgN2ExuKB4sFnym2Egehi6GPNy11hdnEOI/EOJZhCC1F4vsHsiJM7B6TliOllA4gzw0dPBSiT1CGumDsaYIjlE5swMryicWzIJL@ScRnDqVeiBkSY7SZGIKUApkrMTgKFJocIUgz0xw0CRvIwyYYx8n1yLS1CTSUJFEBrUR2AoLDgwCiHXUdcpg5JICW3JH6rkxfCk/SxzFaWKuIEuD8kdyMqBYFiwLffg9FM8sZpm8zGYSWCix9J0FC@u8aqGQ9HN3Eqk7iceyefmwcYmPBso7/lKmDCoLxt8DpYhcxnsoiTzGLw "Julia 0.6 – Try It Online")
Uses 2D-convolution to find the pattern encoded in the magic constant. The constant is derived via base 3 digits similarly to [Arnauld's answer](https://codegolf.stackexchange.com/a/206492/78274), but with 0 and 2 swapped. This way, after subtracting 1, we get the following correspondence: `N = 1, '+' = 0, '-' = -1`.
The input matrix is transformed to `N = 1, everything else = 0`. After convolution, the middle cell of the found pattern will accumulate a total of 7 (for the number of N's in the U-shape). If any of required N's is missing, the sum will not reach 7, and if an N (= 1) is present in the forbidden position, it will gain a negative contribution due to the multiplication by -1 in the pattern.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), ~~62~~ ~~51~~ 45 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ([SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set"))
-6 based on [fireflame241's solution](https://codegolf.stackexchange.com/a/206494/43319).
```
⍲,(⍱{'GILNQRS'≡⎕A[⍸,⍵]~'AEUY'}⌺5 5⍤=)¨∘⊂0⍪0,⊢
```
[Try it online!](https://tio.run/##pVLNSgNBDL77FN5GIYK7M7M7K3go4k@lKHb1IKUHoa0XUQ8eFNGDQtHiiB4Er4oHEUEUBfHYR8mL1CRTBekiiGRndpJJ8iXfZG17Y6yxt7axtT7W3N1pbjaajV4P/QuMoH/eV7PlysJSNVd4eoPnV6Ua@ndA/1Y/VKXplVV1gGcfdtiiv5sc7d7jyTV2jsbRP4wDdm57LWxfoD/HzjH6R/Sv3SeN7UvKk1enaF@eK@c9tVxdmZ5QQ63hcDWfLy6oWk2DgRQsJLQMuDrUHOkaHOkOYjBkyYCF7Q4i0GQxdMs@LBoSsiR0yshf04ooqv4rkvsnkvsVKZVewm4lJiVPzsMrkbzhrAmN8wRLRKdEatLf2LH0xZhFSIYrEAQD3F@IYrGCKpgFcYySheogJU/GsdJ5JsxYqZdxM8lpwYrOYvrMJcwQxxXkj4Sb@Lu3QT1I6HQwPqayiSdqLeVd6DEQM6G8ERkZmWLRspR3crfMQxSzFj5N5Lmi7FwLxzO/8idhPzVTquQFQ8rjIAMqzxRo@3rEhOkWsl14zALAQJwm0lhs/5F4XFMZtuTH6GW0TGEWG8ZXkJ08iJXyw40tHEUnQ2QFIf5zvFQlsa7/Z72uPgE "APL (Dyalog Extended) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 58 bytes
```
⊙θ∧‹¹κ⊙ι∧‹¹μ⬤θ⬤ν∨‹³⁺↔⁻ξ⊖κ↔⁻ρ⊖μ⁼⁼λπ∧›²↔⁻ξ⊖κ∨⁼¹↔⁻ρ⊖μ∧⁼ξκ⁼ρ⊖μ
```
[Try it online!](https://tio.run/##hU89D4IwEN39FR2vSR2Q0YlE46KRnXSo0ETCUaQFA7@@FtoQSYg2l/t67@5e86fQeSPQ2lSXqoNEjdAykqgCrtIYiBip6FSPUK7b9dRGnNkuKEbu2oMxIyn2BpKHgVupXDYwcpK5lrVUnSygonQaXmC9hmtKZ8K57QUaCAEZeVEv4aKl6KSGw/eSjRt01hTmo38X/e7AHvy/Q7UpcHlHa7Msc/udHu9j7/mOkV/9xWJvnHO7f@MH "Charcoal – Try It Online") Link is to verbose version of code. Takes input as an array and outputs a Charcoal boolean, i.e. `-` if it contains U, nothing if not. Explanation:
```
⊙θ∧‹¹κ
```
Find a valid bottom row where:
```
⊙ι∧‹¹μ
```
Find a valid right column where:
```
⬤θ⬤ν
```
All elements of the array must satisfy:
```
∨‹³⁺↔⁻ξ⊖κ↔⁻ρ⊖μ
```
The element has a Manhattan distance from the centre of the U of more than 3, or...
```
⁼⁼λπ
```
... the equality of the element with the outer element matches:
```
∧›²↔⁻ξ⊖κ
```
The vertical distance of the element from the centre of the U is less than 2, and...
```
∨⁼¹↔⁻ρ⊖μ
```
... the horizontal distance of the element from the centre of the U is exactly 1, or...
```
∧⁼ξκ⁼ρ⊖μ
```
... the element is the bottom centre of the U.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 62 bytes
```
{{∨/∊({7 9 12 14 17 18 19≡1 5 21 25~⍨⍸,⍵}⌺5 5)¨(,⍵)=¨⊂⍵}0⍪0,⍵}
```
[Try it online!](https://tio.run/##nVK9TgMxDN55Co@tREXzd0kGJhY6IVFeoFJblgoYGEAVDCBVpeIqGHgAtoqFBSTE2EfJixz2l2sRqGJAvvhix/7sz0nvbNTqX/ZGp8etwcX54KQ/6FfVeJymi500nTXGniIpTcqS8qQCqZjunhU50oq0u07lIpUf26l8v0r3n45cc7loiNncXS7S7EYO2ql8aSOkGqbJQyrnaf7UOUiz2@WrSZNHtrqHe6yP9jvdasjYIZVvZMiSZ6PgZSmwePYFOSbNnggRL3eFaIdzEcNZBf8jRxpeiuzWRuDwT@CwCdij06wFngeGVIc0U@8MgxukGz7XiDMQydLoWkpYYmRLVpCtFGKvRZQsi2if8dGCl0ABi@vyAufAJYKfglWgAQfJXC3YFmCrAWcynAJFXff728qC3tFqISmaoZksW160EaVlIqKYFV8J9tGL5lD@@IHxPn@GJxDQgQEcKmpQgaCSy@MO9eMwNeM84gLD8WBtkGDy/WSyTA3iECYvxNf0vy8@8rJIdDnR1e8lv5OIdrLX/WxoNXL9Z0JNLq5LrnZf "APL (Dyalog Extended) – Try It Online") (includes the new test case).
My first APL golf! Returns a `1` if there is a `U`, or `0` otherwise.
[Answer]
# [J](http://jsoftware.com/), 68 bytes
Builds up 16 U's with the 16 possible combinations of 0 and 1 in the corners, then looks for them in the position matrix of each number.
```
[:+./@,(0 4 4|.#:20 20 28(,4 4&#:)"p./i.16)E."2/[:(="{~,)4|:@|.@,&_]
```
[Try it online!](https://tio.run/##pVLdS8NADH@/vyJ0sLZYb@199a4yGIg@@eTrkCHimCIoOh/E4b9e87GhsJUhkia9HLn8kl/y2Gc6X8K0gxwqqKFDPdVwfn112c@7Ez2ZVUUNDtxGjzpTA32xqPBiPOrK7EVPHnQTygudmcm8K6bZ51dVuk032@hZNV7c9GV/f7d6hnz9@r5efeRKLaEeZ/pMLwwUjFcqsIjQgoeA6iAqiOhatB7VgFOQWOg6QgNWYZjnCBILQeHbiBEGHYMRTpVHkeI/kOJRpJZ7EevpWYvBlIk0UGI5WkSjTHzR4CFwRXYHbbgvwnQwAOWoDIJw3J8FOpF4KQOBBl4SVpICoVWM5rn7RNx4rpjAE1XjWYQfJ8wFoogeDeRvmCKza3DPFZFuD2cwWDyyhe21ZJkmB8YDsHVIS8IodlJLFsM9ctEYcuSzSGIcAqCKFDfOPxSMlKVd3j694c4eHm@UdZWd8j8jDUS9BPBkB3CFR4txJF5GRgvcCrO/NzGhusE8XvZZbfc40dFs7/3gdkaZtmLMvyfg4pTsyq5UVX4D "J – Try It Online")
]