  Generation of high fidelity photonic non-Gaussian states is a crucial
ingredient for universal quantum computation using continous-variable
platforms, yet it remains a challenge to do so efficiently. We present a
general framework for a probabilistic production of multimode non-Gaussian
states by measuring few modes of multimode Gaussian states via
photon-number-resolving detectors. We use Gaussian elements consisting of
squeezed displaced vacuum states and interferometers, the only non-Gaussian
elements consisting of photon-number-resolving detectors. We derive analytic
expressions for the output Wigner function, and the probability of generating
the states in terms of the mean and the covariance matrix of the Gaussian state
and the photon detection pattern. We find that the output states can be written
as a Fock basis superposition state followed by a Gaussian gate, and we derive
explicit expressions for these parameters. These analytic expressions show
exactly what non-Gaussian states can be generated by this probabilistic scheme.
Further, it provides a method to search for the Gaussian circuit and
measurement pattern that produces a target non-Gaussian state with optimal
fidelity and success probability. We present specific examples such as the
generation of cat states, ON states, Gottesman-Kitaev-Preskill states, NOON
states and bosonic code states. The proposed framework has potential
far-reaching implications for the generation of bosonic error-correction codes
that require non-Gaussian states, resource states for the implementation of
non-Gaussian gates needed for universal quantum computation, among other
applications requiring non-Gaussianity. The tools developed here could also
prove useful for the quantum resource theory of non-Gaussianity.
