Let X be a ball Banach function space on R n . In this article, under the mild assumption that the Hardy-Littlewood maximal operator is bounded on the associated space X ′ of X, the authors prove that, for anywith the positive equivalence constants independent of f , where q ∈ (0, ∞) is an index depending on the space X, and |E| denotes the Lebesgue measure of a measurable set E ⊂ R n . Particularly, when ), the above estimate holds true for any given q ∈ [1, p], which when q = p is exactly the recent surprising formula of H. Brezis, J. Van Schaftingen, and P.-L. Yung, and which even when q < p is new. This generalization has a wide range of applications and, particularly, enables the authors to establish new fractional Sobolev and Gagliardo-Nirenberg inequalities in various function spaces, including Morrey spaces, mixed-norm Lebesgue spaces, variable Lebesgue spaces, weighted Lebesgue spaces, Orlicz spaces, and Orlicz-slice (generalized amalgam) spaces, and, even in all these special cases, the obtained results are new. The proofs of these results strongly depend on the Poincaré inequality, the extrapolation, the exact operator norm on X ′ of the Hardy-Littlewood maximal operator, and the geometry of R n .