gbsn

# Towards On-Demand Heralded Single-Photon Sources via Photon Blockade

Jiangshan Tang  College of Engineering and Applied Sciences, National
Laboratory of Solid State Microstructures, and Collaborative Innovation Center
of Advanced Microstructures, Nanjing University, Nanjing 210023, China  School
of Physics, Nanjing University, Nanjing 210023, China  Lei Tang  College of
Engineering and Applied Sciences, National Laboratory of Solid State
Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  Haodong Wu
College of Engineering and Applied Sciences, National Laboratory of Solid
State Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  Yang Wu  College
of Engineering and Applied Sciences, National Laboratory of Solid State
Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  School of Physics
and Information Technology, Shaanxi Normal University, Xi’an 710062, China
Hui Sun<EMAIL_ADDRESS>School of Physics and Information Technology,
Shaanxi Normal University, Xi’an 710062, China  Han Zhang<EMAIL_ADDRESS>College of Engineering and Applied Sciences, National Laboratory of Solid
State Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  School of Physics,
Nanjing University, Nanjing 210023, China  Tao Li  School of Science, Nanjing
University of Science and Technology, Nanjing 210094, China  Yanqing Lu (陆延青)
College of Engineering and Applied Sciences, National Laboratory of Solid
State Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  School of Physics,
Nanjing University, Nanjing 210023, China  Min Xiao  College of Engineering
and Applied Sciences, National Laboratory of Solid State Microstructures, and
Collaborative Innovation Center of Advanced Microstructures, Nanjing
University, Nanjing 210023, China  School of Physics, Nanjing University,
Nanjing 210023, China  Department of Physics, University of Arkansas,
Fayetteville, Arkansas 72701, USA  Keyu Xia (夏可宇<EMAIL_ADDRESS>College
of Engineering and Applied Sciences, National Laboratory of Solid State
Microstructures, and Collaborative Innovation Center of Advanced
Microstructures, Nanjing University, Nanjing 210023, China  School of Physics,
Nanjing University, Nanjing 210023, China

###### Abstract

Spontaneous parametric down-conversion (SPDC) in a laser pumped optical
nonlinear medium can produce heralded single photons with a high purity but a
very low yield. Improving the yield by increasing the pump power in SPDC
inevitably reduces the purity due to excitation of multi-photon events. We
propose a scheme to overcome this purity-yield trade-off by suppressing multi-
photon events in a cavity-enhanced SPDC via the photon blockade effect. By
introducing a strong photon-photon interaction into the intracavity medium and
increasing the pump power, we can improve the available single-photon yield to
larger than $90\%$, while maintaining a high purity of $99\%$, towards on-
demand generation of single photons through the SPDC process. Our quasi-on-
demand SPDC sources may boost single-photon-based quantum information
technology.

Single photons are at the heart of photon-based quantum information processing
Kok  _et al._ (2007); Senellart  _et al._ (2017); Degen  _et al._ (2017) such
as quantum communication Pan  _et al._ (2012), quantum simulations Georgescu
_et al._ (2014) and linear optical quantum computing Zhong  _et al._ (2020).
The quality of single-photon sources directly determines the development and
performance of photon-based quantum information technology Lodahl  _et al._
(2015); Zhong  _et al._ (2018); Xia  _et al._ (2018); Li  _et al._ (2020a).

Various methods have been studied for generating single photons, including
photon blockade of a weak coherent field Imamoḡlu  _et al._ (1997), nonlinear
wave mixing Sharping  _et al._ (2006); Yuan  _et al._ (2011); Silverstone  _et
al._ (2014); Caspani  _et al._ (2017), cavity quantum electrodynamics (CQED)
Houck  _et al._ (2007); Lang  _et al._ (2013); Ding  _et al._ (2016); Somaschi
_et al._ (2016); Wang  _et al._ (2019). Among these methods, CQED systems
using quantum dots (QDs) have achieved great success Ding  _et al._ (2016);
Somaschi  _et al._ (2016); Senellart  _et al._ (2017); Wang  _et al._ (2019),
and promise a kind of high-performance single-photon source. Some advanced
techniques such as the dichromatic excitation He  _et al._ (2019) and
asymmetrical cavities are reported to overcome the challenging issues of
polarization filtering Wang  _et al._ (2019), spectral overlap with the
exciting laser Koong  _et al._ (2021).

Another widely used and important approach of generating single photons is the
heralded single-photon source (HSPS) based on spontaneous parametric down-
conversion (SPDC) in an optical nonlinear medium. It provides another commonly
used approach for many important room-temperature applications in quantum
information technologies, in particular, requiring a narrow-band photon
sources Ou and Lu (1999); Zhang  _et al._ (2011); Guo  _et al._ (2017); Ma
_et al._ (2020). HSPSs are almost perfect in all aspects such as
indistinguishability Somaschi  _et al._ (2016), high purity Senellart  _et
al._ (2017), flexibility Guo  _et al._ (2017), and scalability Collins  _et
al._ (2013), except for the only drawback of the small photon yield, which is
typically few parts per thousand for guaranteeing a high purity Senellart  _et
al._ (2017). Cavity-enhanced narrow-band SPDC can reduce the single-photon
bandwidth to fit atomic systems and quantum memory Ou and Lu (1999); Zhang
_et al._ (2011), which normally operates in megahertz to gigahertz and at room
temperature Reim  _et al._ (2010).

There is a trade-off between the purity and the yield per pump pulse, namely
the purity-yield limitation, in HSPSs Senellart  _et al._ (2017); Christ and
Silberhorn (2012); Takeoka  _et al._ (2015). To produce heralded single
photons with a high single-photon purity, the pump laser in the conventional
HSPS must be weak enough that the probability of multi-photon emissions is
negligibly small. Inevitably, a weak pumping also leads to a small generation
probability of single photons, i.e. low single-photon yield. This inherent
constraint between high single-photon purity and large photon yield is the
fundamental limitation of applications of HSPSs Pan  _et al._ (2012);
Jennewein  _et al._ (2011). It is worth noting that multiplexed HSPS can
improve the yield of signal photons without considerably reducing the purity
by detecting a single idler photon from many individual HSPSs, different
spectral components or a series of time bin of many SPDC processes Migdall
_et al._ (2002); Pittman  _et al._ (2002); Grimau Puigibert  _et al._ (2017);
Kaneda and Kwiat (2019). However, overcoming the purity-yield trade-off still
remains a challenge. A principle breakthrough of solving this inherent
limitation is the key to boost applications of HSPSs, even open up many
unprecedented single-photon-based quantum information technologies.

In this paper, we propose a scheme to improve the single-photon generation
efficiency, namely yield per pump pulse, of HSPS based on the cavity-enhanced
SPDC but keep a high purity, therefore overcoming the purity-yield limitation.
By inserting warm N-type atoms in a ring optical cavity, we create a strong
photon-photon interaction (PPI) to suppress the multi-photon pair events in
SPDC under a strong pumping, and thus improve the yield of HSPSs from
conventional value of few parts per thousand to more than $90\%$, whereas the
purity simultaneously remains high.

Figure 1: (a) Schematic setup for overcoming the purity-yield trade-off in
HSPS. A pump laser enters the ring cavity and drives a PPKTP crystal to
produce idler-signal photon pairs. A KTP crystal enables dual-mode resonance
for the idler and signal modes. The control laser is used to induce strong PPI
in warm atoms for the signal mode. M1-M6: mirrors; DM: dichroic mirror; PBS:
polarization beam splitter; D1 and D2: single-photon detectors. (b) Level
diagram of N-type atoms. The signal photon (control field) drives the
transitions $|1\rangle\leftrightarrow|3\rangle$ and
$|2\rangle\leftrightarrow|4\rangle$ ( $|2\rangle\leftrightarrow|3\rangle$)
with detuning $\Delta_{31}$ and $\Delta_{42}$ ($\Delta_{c}$), and
corresponding coupling strength $g$ ($\Omega_{c}$).

Our system overcoming the purity-yield trade-off in cavity-enhanced HSPS via
the photon blockade is depicted in Fig. 1(a). A pump laser beam with frequency
$\omega_{p}$ and effective pump power $\xi\sqrt{P}$ is input into the ring
optical cavity formed with reflective mirrors M1-M4. It drives a type-II
phase-matched periodically poled $\text{KTiOPO}_{4}$ (PPKTP) crystal to induce
an optical SPDC process Zhang  _et al._ (2011). This SPDC process emits
photons in pairs: the idler and signal modes $a_{i}$ and $a_{s}$ with
frequency $\omega_{i}$ and $\omega_{s}$, respectively, doubly resonant with
the cavity Neergaard-Nielsen  _et al._ (2007); Bao  _et al._ (2008); Dai  _et
al._ (2012). The counter-propagating cavity modes are decoupled from the SPDC
due to the chirality in frequency conversion. The idler mode is orthogonal in
polarization to and different in frequency from the signal mode. It is off-
resonance with atomic transitions and thus decouples from Rb atoms. The pump
laser is separated by the DM from the generated photons. The idler photon
outputting from M2 is reflected by the PBS to the idler output channel and
monitored by a single-photon detector D1. The signal mode couples to Rb atoms
and is subject to strong PPI induced by the control laser field Sheng  _et
al._ (2011). It is detected by another detector D2 after leaving the cavity
through M2.

The N-type Rubidium (Rb) atoms embedded in the optical cavity at room
temperature creates a large PPI for the signal mode under the driving of the
control laser Sheng  _et al._ (2011). The energy levels of the N-type atom are
denoted as $|l\rangle$ with eigenfrequency $\omega_{l}$ ($l=1,2,3,4$), as
shown in Fig. 1(b). The state $|3\rangle$ decays to the states $|1\rangle$ and
$|2\rangle$ with rates $\gamma_{31}$ and $\gamma_{32}$, respectively. The
state $|4\rangle$ decays at a rate $\gamma_{42}$. The dephasing rates of both
ground states $|1\rangle$ and $|2\rangle$ are $\gamma_{21}$. For simplicity,
we assume $\gamma_{31}=\gamma_{32}=\gamma_{42}=\gamma_{0}$ and
$\gamma_{21}\ll\gamma_{0}$ Liu  _et al._ (2016); Xia  _et al._ (2018); Sagona-
Stophel  _et al._ (2020). The cavity mode couples to the transitions
$|1\rangle\leftrightarrow|3\rangle$ and $|2\rangle\leftrightarrow|4\rangle$
with strength g. The control laser beam has an angular frequency $\omega_{c}$,
and drives the transition $|2\rangle\leftrightarrow|3\rangle$ with Rabi
frequency $\Omega_{c}$. In the rotating frame, defined by an unitary
transformation
$U_{1}=\text{exp}\\{i\sum_{j=1}^{N}[\omega_{1}\sigma_{11}^{j}+(\omega_{s}+\omega_{1}-\omega_{c})\sigma_{22}^{j}+(\omega_{s}+\omega_{1})\sigma_{33}^{j}+(2\omega_{s}+\omega_{1}-\omega_{c})\sigma_{44}^{j}]t+i(\omega_{i}a_{i}^{\dagger}a_{i}+\omega_{s}a_{s}^{\dagger}a_{s})t\\}$,
the Hamiltonian of the system takes the form ($\hbar=1$)

$\begin{split}H=&\sum_{j=1}^{N}\sum_{l=2}^{4}\Delta_{ll}\sigma_{ll}^{j}+\xi\sqrt{P}(e^{-i\Delta_{p}t}a_{i}^{\dagger}a_{s}^{\dagger}+e^{i\Delta_{p}t}a_{i}a_{s})\\\
&+\sum_{j=1}^{N}\left[g(a_{s}^{\dagger}\sigma_{13}^{j}+a_{s}^{\dagger}\sigma_{24}^{j})+\Omega_{c}\sigma_{23}^{j}+h.c.\right]\;,\end{split}$
(1)

with $\Delta_{22}=\Delta_{c}-\Delta_{31}$, $\Delta_{33}=-\Delta_{31}$,
$\Delta_{44}=\Delta_{c}-\Delta_{42}-\Delta_{31}$, and
$\Delta_{p}=\omega_{p}-\omega_{s}-\omega_{i}$.
$\sigma_{mn}^{j}=|m\rangle\langle n|~{}(m,n=1,2,3,4)$ denotes the transition
operator for the $j$th atom. $\Delta_{31}=\omega_{s}-\omega_{31}$ (
$\Delta_{42}=\omega_{s}-\omega_{42}$ ) is the detuning between the cavity mode
and the transition of $|3\rangle\leftrightarrow|1\rangle$ (
$|4\rangle\leftrightarrow|2\rangle$ ), and $\Delta_{c}=\omega_{c}-\omega_{32}$
is the detuning between the control field and the
$|3\rangle\leftrightarrow|2\rangle$ transition
($\omega_{mn}=\omega_{m}-\omega_{n}$). The first term in Eq. (1) is the free
Hamiltonian of the system. The second term represents the pump field applied
to the PPKTP crystal Sangouard  _et al._ (2011). The second line represents
interaction of atoms with the cavity mode and the control laser field. Only
the signal mode in the cavity interact with atoms. At room temperature, the
inevitable random thermal motion of the $j$th atom moving with velocity
$v_{j}$ causes the “microscopic” Doppler shifts $k_{s}v_{j}$ and $k_{c}v_{j}$,
corresponding to wave vectors $k_{s}$ and $k_{c}$ of the cavity and control
fields, respectively. Here we have $|k_{s}|\approx|k_{c}|$ and approximately
take both as $k$. The control and the cavity fields propagate in the same
direction that $k_{s}v_{j}\approx k_{c}v_{j}$ Xia  _et al._ (2018). We
consider the condition of $|g|\ll|\Omega_{c}|$, leading to the population of
the atomic ground state $\rho_{11}\approx 1$. Then we can use the perturbation
approach to solve the master equation and obtain the effective PPI coefficient
in the presence of thermal motion as Tang  _et al._ (2020); Scully  _et al._
(1997); Okamoto (2006); Sheng  _et al._ (2011); Xia  _et al._ (2018) (see
Supplement 1)

$\begin{split}\eta=&\int\frac{ig^{4}\gamma_{32}}{|\Omega_{c}|^{4}\gamma_{21}(\gamma_{31}+\gamma_{32})}(\frac{1}{F(v)}+\frac{1}{F^{*}(v)})[\frac{(2\gamma_{21}+\gamma_{32})}{\gamma_{32}}\\\
&(\frac{1}{F^{*}(v)}-\frac{1}{F(v)})+(\frac{1}{F_{1}(v)}-\frac{1}{{F_{1}}^{*}(v)})]N(v)dv\;,\end{split}$
(2)

where
$F=-1/(i\Delta_{22}+\gamma_{21}/2)-(i(\Delta_{31}+kv)+(\gamma_{31}+\gamma_{32})/2)/|\Omega_{c}|^{2}$,
$F_{1}=1/(-i(\Delta_{42}-\Delta_{c})-(\gamma_{42}+\gamma_{31}+\gamma_{32})/2)-(i(\Delta_{42}+kv)+(\gamma_{21}+\gamma_{42})/2)/|\Omega_{c}|^{2}$.
The atomic velocity has the Maxwell-Boltzmann distribution that
$N(v)=N_{a}e^{-v^{2}/u^{2}}/u\sqrt{\pi}$, where $u$ is the room-mean-square
atomic velocity, and $N_{a}$ is the total atom number. At room temperature,
$ku\approx 300~{}\mathrm{M}\mathrm{Hz}$ for Rb atoms Wu  _et al._ (2008). This
Kerr nonlinearity causes the PPI. This perturbation approach provides an
estimation of Kerr nonlinearity in good agreement with experimental
observations Wang  _et al._ (2001); Li  _et al._ (2008); Sheng  _et al._
(2011); Wang  _et al._ (2013); Liu  _et al._ (2016); Sagona-Stophel  _et al._
(2020); Li  _et al._ (2020b). Moreover, the Kerr nonlinearity can be enhanced
by increasing the number of atoms or adjusting $\Omega_{c}$.

Applying an unitary transformation of
$U_{2}=\text{exp}\\{i(\omega_{p}-\omega_{i}-\omega_{s})a_{s}^{\dagger}a_{s}t\\}$
to the system, we get the effective Hamiltonian

$H_{\text{eff}}=(\Delta-\eta-\Delta_{p})a_{s}^{\dagger}a_{s}+\eta(a_{s}^{\dagger}a_{s})^{2}+\xi\sqrt{P}(a_{i}^{\dagger}a_{s}^{\dagger}+a_{i}a_{s})\;,$
(3)

where $\Delta=\int
N(v)dv[(g^{2}/{\Omega_{c}}^{2})(\gamma_{32}(\Delta_{31}-\Delta_{c})/(\gamma_{21}(\gamma_{31}+\gamma_{32}))(1/F+1/F^{*})+(\Delta_{31}+kv)/(\gamma_{31}+\gamma_{32}))(1/F+1/F^{*})+i(1/F^{*}-1/F))]$.
The influence of the unwanted linear frequency shift $\Delta$ can be
eliminated by selecting an appropriate pump frequency $\omega_{p}$ that
$\Delta=\Delta_{p}$. The PPI causes an energy shift
$\eta(a_{s}^{\dagger}a_{s})^{2}$ to the cavity mode $a_{s}$. This energy shift
depends on the cavity excitation $\langle a_{s}^{\dagger}a_{s}\rangle$. Once
the cavity mode is excited to include a on-resonance signal photon
($\Delta_{p}=\Delta$), exciting a second signal photon in the cavity requires
additional $2\eta$ energy and is suppressed. This photon blockade effect can
be used to suppress multi-photon events in the SPDC.

The master equation of the density matrix $\rho$ describing the dynamics of
our system is given by
$\dot{\rho}(t)=-i\left[H_{\text{eff}},\rho(t)\right]+\mathcal{L}\\{\kappa_{i},a_{i}\\}\rho++\mathcal{L}\\{\kappa_{s},a_{s}\\}\rho$,
where $\kappa_{i}=\kappa_{i,ex}+\kappa_{i,in}$
($\kappa_{s}=\kappa_{s,ex}+\kappa_{s,in}$) is the decay rate of the idler
(signal) mode. The subscripts “ex” and “in” indicate the external rate and the
internal loss rate, respectively. We assume
$\kappa_{i,ex}=\kappa_{s,ex}=\kappa_{ex}$ and
$\kappa_{i,in}=\kappa_{s,in}=\kappa_{in}$. The Lindblad term is
$\mathcal{L}\\{\kappa_{l},a_{l}\\}\rho=\kappa_{l}\left[2a_{l}\rho(t)a_{l}^{\dagger}-a_{l}^{\dagger}a_{l}\rho(t)-\rho(t)a_{l}^{\dagger}a_{l}\right]$
with $l\in\\{i,s\\}$. Using the density matrix, we can evaluate the photon
states in the cavity. After the pump pulse is switched off, the photons escape
from the cavity. Then, the outgoing photons are detected.

In contrast, the quantum trajectory simulation provides information of emitted
photon wavefunctions Plenio and Knight (1998); Gleyzes  _et al._ (2007);
Johansson  _et al._ (2012). By averaging many trajectories, we can calculate
the population of each photonic state in the outgoing wavefunctions by
counting the collapse of the system state over a period $\kappa_{s}t=6$ (see
Supplement 1). This period allows the generated photons to completely escape
from the cavity through mirror M2 and to be detected.

The escape efficiency of signal (idler) photons is evaluated as
$\eta_{esc,s(i)}=\kappa_{\text{ex}}/(\kappa_{\text{ex}}+\kappa_{\text{in}})$
Morin  _et al._ (2019). In a waveguide-based HSPS with complicate structure,
the mode mismatching and the system internal loss result in a low escape
efficiency Luo  _et al._ (2015). In our cavity-based HSPS, the cavity mode
profile is axial symmetric and can match the geometry of output mirror well.
The cavity internal loss can be small Luo  _et al._ (2015) and the escape
efficiency approaches to unity Neergaard-Nielsen  _et al._ (2007); Wolfgramm
_et al._ (2008); Le Jeannic  _et al._ (2016). To focus on the key physics of
interest, we consider the ideal case $\eta_{esc,s(i)}=1$ that the photons are
completely extracted through mirror M2.

The purity of the HSPS can be evaluated through the equal time second-order
autocorrelation function $g^{(2)}_{s}(0)$ of the signal mode, conditional on
the detection of the idler photon Senellart  _et al._ (2017). In our setup
[see Fig. 1(a)], once an idler photon is detected by D1, the system state
degrades to a reduced density matrix $\rho_{s}$. The autocorrelation function
$g^{(2)}_{s}(0)$ is given by Fasel  _et al._ (2004); Scholz  _et al._ (2009);
Bocquillon  _et al._ (2009) (see Supplement 1)

$g_{s}^{(2)}(0)=\frac{\langle
a_{s}^{\dagger}(t)a_{s}^{\dagger}(t)a_{s}(t)a_{s}(t)\rangle_{i}}{\langle
a_{s}^{\dagger}(t)a_{s}(t)\rangle^{2}_{i}}=\frac{\sum_{n_{s}\geq
1}n_{s}(n_{s}-1)\alpha_{n_{s}}}{(\sum_{n_{s}}n_{s}\alpha_{n_{s}})^{2}}\;,$ (4)

where $\langle\cdots\rangle_{i}$ is the average over the post-measurement
state when an idler photon is measured.
$\alpha_{n_{s}}=\sum_{n_{i}>0}P_{n_{s},n_{i}}/\sum_{n_{s}^{{}^{\prime}},n_{i}^{{}^{\prime}}>0}P_{n_{s}^{{}^{\prime}},n_{i}^{{}^{\prime}}}$
is the $n$-signal-photon probability after detecting an idler photon.
$P_{n_{s},n_{i}}$ is the probability of the states $|n_{s},n_{i}\rangle$ under
the Fock states representation of the associating system of the idler and
signal modes. The output signal mode is antibunching if $g_{s}^{(2)}(0)<1$.

In conventional HSPSs, improving the photon yield by increasing the pump laser
power can result in reduction of the single-photon purity. This inherent but
critical issue fundamentally limits scaling up of HSPS-based applications
Senellart  _et al._ (2017); Kaneda and Kwiat (2019). By exploiting the photon
blockade, we show a strong PPI can effectively suppress the generation of
multi-photon pairs in the SPDC process and thus guarantees a high purity but
allows us to greatly improve the production efficiency of heralded single
photons by increasing the pump laser power.

Below is the understanding of the physical mechanism breaking the fundamental
purity-yield limitation. When the signal mode is excited in the nonlinear
cavity, excitation of high Fock states is blocked due to the photon blockade
effect. In the SPDC process, the idler and signal photons are always generated
in pairs. Therefore, if the signal mode can only be generated in the form of
single photon, the idler mode is also subject to the same situation. As a
result, the generation of the high Fock-state photon pairs
$|n_{s},n_{i}\rangle$ ($n_{s}=n_{i}\geq 2$) is also blocked. On the other
hand, the probability of generating single-photon pairs becomes larger because
the pump laser power is stronger. In this way, we fundamentally circumvent the
inherent contradiction between remaining high purity and improving yield of
HSPSs. Detection of the idler photon with a probability close to unity means
quasi-on-demand generation of a single signal photon with high purity.

Figure 2:  (a) Population of Fock state $|1,1\rangle$, i.e., the probability
of single-photon pair, $P_{11}$ versus the pump laser power $\xi\sqrt{P}$ and
the effective nonlinear PPI strength $\eta$. (b) Population of paired Fock
states $|n_{s},n_{i}\rangle$ as a function of $\xi\sqrt{P}$ with different PPI
strength. Other parameters are $\kappa_{s}=\kappa_{i}=1$.
Figure 3:  (a) The equal-time second-order autocorrelation $g_{s}^{(2)}(0)$
versus the pump laser power $\xi\sqrt{P}$ and the PPI strength $\eta$. (b) The
second-order autocorrelation $g_{s}^{(2)}(0)$ as a function of $\xi\sqrt{P}$
with different PPI strength $\eta$. Other parameters are the same as in Fig.
2.

The evolution of the system can be obtained by solving the master equation.
The probability of generating a single photon in each outgoing light pulse is
a good measure of the yield $Y$ per pump pulse or brightness Senellart  _et
al._ (2017). If $P_{n}$ is the $n$-photon number probability, then $Y=P_{1}$
for $P_{1}\gg P_{n>1}$ and $Y=1$ for a deterministic single-photon source
Senellart  _et al._ (2017). In our system, as signal photons and idler photons
are created in pairs, then $Y=P_{11}$. For convenience, here the subscripts in
$P_{n_{s},n_{i}}$ represent signal and idler photon numbers, respectively.
Note that the yield $Y$ is essentially different from the so-called single-
photon heralding efficiency. The later describes the probability of
successfully heralding a signal photon when an idler photon is detected Le
Jeannic  _et al._ (2016); Li  _et al._ (2020c). Even at a low yield of photon
pair $|11\rangle$, high heralding efficiency can be obtained Fasel  _et al._
(2004); Slussarenko  _et al._ (2017).

Figure 2(a) shows the population $P_{11}$ of Fock state $|1,1\rangle$ versus
the pump laser power $\xi\sqrt{P}$ and the PPI strength $\eta$. The duration
$\tau_{p}$ of the pump laser pulse is fixed at $\tau_{p}=\pi/40\kappa_{s}$.
With the increase of $\eta$ to much larger than $\kappa_{s}$, the single-
photon pair population $P_{11}$ can be significantly improved and peaks when
$2\xi\sqrt{P}\tau_{p}=\pi$, corresponding to a $\pi$ pump pulse. For
$\eta/\kappa_{s}>75$ and $15<\xi\sqrt{P}/\kappa_{s}<25$, indicated by the
white solid curve, the yield can be higher than $80\%$. A larger PPI allows us
to achieve $Y>90\%$, see the red dashed curve. For a given PPI strength
$\eta$, the population $P_{11}$ shows a cosine-like oscillation as the pump
power increases, first increasing and then decreasing after reaching the
maximum. Two reasons are behind this result: one is the excitation population
oscillations as the pump pulse area $2\xi\sqrt{P}\tau_{p}$ increases, and the
other is that the given PPI becomes not large enough to suppress the multi-
photon pair generation excited by a strong pump field.

The available maximum yield is determined by the pump power $\xi\sqrt{P}$ and
the PPI strength $\eta$, see Fig. 2(b). Enhancing the pump power can improve
the single-photon yield, and increasing the PPI can suppress the multi-photon
excitation. Without nonlinearity-induced photon blockade, the probability of
creating photon pairs $|n_{s},n_{i}\rangle$ scales with pump intensity to the
$n$th power as predicted theoretically Senellart  _et al._ (2017), see Fig.
2(b). The maximum yield can only be $23.8\%$ at $\xi\sqrt{P}/\kappa_{s}\simeq
11$ at the expense of low purity ($\Pi\approx 4.3\%$) due to high excitation
of multiphoton-pair states Broome  _et al._ (2011); Christ and Silberhorn
(2012); Takeoka  _et al._ (2015); Grimau Puigibert  _et al._ (2017); Kaneda
and Kwiat (2019). With photon blockade, multi-photon events almost disappear,
see the dashed black for $P_{22}$ and dotted purple curves for $P_{33}$ in
Fig. 2(b). When $\eta/\kappa_{s}=80$, we obtain the maximum probability
$P_{11}$, i.e. the yield, of $81\%$ at $\xi\sqrt{P}/\kappa_{s}\simeq 19$.
Meanwhile, the vacuum state population drops rapidly with the power. We can
further improve the yield to 0.9 for $\eta/\kappa_{s}=200$ and
$\xi\sqrt{P}/\kappa_{s}=20$. When the yield is higher than $90\%$, it is
reasonable to claim that the HSPS becomes quasi-on-demand Tomm  _et al._
(2021). By “quasi-on-demand”, we mean each pump pulse can generate a single-
photon pulse with a large probability Eisaman  _et al._ (2011).

The single-photon purity $\Pi$ is defined as the single-photon fraction of the
total population of the heralding signal modes Fischer  _et al._ (2017); noz
_et al._ (2018). It can be quantified by the second-order autocorrelation
function $g_{s}^{(2)}(0)$ Senellart  _et al._ (2017); Wang  _et al._ (2019);
Fischer  _et al._ (2017); Schweickert  _et al._ (2018); noz  _et al._ (2018).
For a high purity, we use the relation $\Pi\approx 1-g_{s}^{(2)}(0)$ Ding  _et
al._ (2016) (see Supplement 1).

Figure 3(a) shows the correlation function $g_{s}^{(2)}(0)$ versus the PPI
strength and the pump power. we can obtain a high purity $\Pi>90\%$ when
$\eta$ is large enough, see the white solid curve. In the overlap region
marked by the curves showing $P_{11}>0.8$ and $g_{s}^{(2)}(0)<0.1$, we
simultaneously obtain $Y>80\%$ and $\Pi>90\%$. A larger pump power leads to a
decrease in the purity, because the probability of multi-photon events becomes
higher as the pump power increases, see $P_{22}$ and $P_{33}$ in Fig. 2(b). In
contrast to conventional HSPSs, increasing the PPI strength $\eta$ in our
scheme can suppress the excitation of multi-photon states, and thus can
maintain the high purity.

In Fig. 3(b), we show the equal time second-order autocorrelation function
$g_{s}^{(2)}(0)$ as an indicator of the single-photon purity for different PPI
strengths. When the PPI is absent or small, $g_{s}^{(2)}(0)$ increases to
larger than unity as the pump power increases, corresponding to the case of
heralded single-photon generation under a strong pumping. Without the PPI, we
derive $g_{s}^{(2)}(0)\approx 2\text{tanh}^{2}(\xi\sqrt{P}\tau_{p})$ (see
Supplement 1), in good agreement with the numerical result. The purity-yield
product is always bounded by $0.09$. The difference at high pump power is due
to the truncation of Hilbert space in simulation (see Supplement 1). The
purity increases rapidly as the PPI becomes larger. For example, when
$\eta/\kappa_{s}=80$, the yield is already $81\%$ and the purity reaches
$91\%$ ($g_{s}^{(2)}(0)=0.09$) at $\xi\sqrt{P}/\kappa_{s}=19$. If
$\eta/\kappa_{s}=200$, the yield and the purity increase to $91\%$ and $99\%$,
respectively.

Figure 4: Population of Fock state $|1,1\rangle$ (a) and the second-order
autocorrelation $g_{s}^{(2)}$ (b) versus the pump power $\xi\sqrt{P}$. Blue
(red) solid curves indicate the case with a fixed pulse duration
$\tau_{p}=\pi/40\kappa_{s}$ and the PPI strength $\eta/\kappa_{s}=80$
($\tau_{p}=\pi/80\kappa_{s}$ and $\eta/\kappa_{s}=500$). Blue (red) dash-
dotted curves represent the results for $\pi$-pulse excitation, i.e.
$2\xi\sqrt{P}\tau_{p}=\pi$, in the case of $\eta/\kappa_{s}=80$
($\eta/\kappa_{s}=500$). Other parameters are $\kappa_{s}=\kappa_{i}=1$ and
$\gamma_{0}=0.5\kappa_{s}$.

In our scheme, high Fock states of signal and idler modes are suppressed due
to the photon blockade effect. To provide an apparent physical picture, we
truncate the photonic basis to only include the vacuum and single-photon pair
states in the cavity. In the effective two-state space, the state
$|1,1\rangle$ can be completely populated from the vacuum state with a $\pi$
pump pulse Ding  _et al._ (2016) (see Supplement 1). In a real case including
high Fock-state photon pairs, instead of fixing the pump pulse duration
$\tau_{p}$ but changing the pump power $\xi\sqrt{P}$, we fix the pump pulse
area $2\xi\sqrt{P}\tau_{p}=\pi$ to excite the single-photon pair $|1,1\rangle$
and investigate the influence of the pump power on the yield and purity of
HSPS. As shown in Fig. 4, the single-photon yield per pump pulse can increase
to $80\%$ at $\xi\sqrt{P}/\kappa_{s}=6.6$ under $\pi$-pulse excitation, in
comparison with a yield of $22.6\%$ in fix-duration excitation. At the same
time, the purity remains nearly unchanged, larger than $99\%$ in both
excitation cases. For relative low pump power, the yield under $\pi$-pulse
excitation is much higher than the case of fix-duration excitation. In
contrast, the purities are very close. Thus, a $\pi$ pulse can excite the
single-photon pair state more efficiently and a high purity is guaranteed by
the photon blockade effect.

When the PPI is large enough, the nonlinear cavity can be modeled as a two-
level system Yan  _et al._ (2019). Then, our HSPS is equivalent to a CQED-
based single-photon source. Thus, the yield can approach unity in theory. To
show this, we calculate the yield and the purity in a very large PPI regime.
For example, when $\eta/\kappa_{s}=500$, we obtain $Y=95\%$ and $\Pi\approx
99\%$ ($g^{(0)}\approx 0.01$) at $\xi\sqrt{P}/\kappa_{s}=40$, see the red
curves in Fig. 4.

The generated photons are detected after escaping from the cavity. Our quantum
trajectory simulations show that the quantum statistical characters of single-
photon pairs outside the cavity is close to that of the single-photon pairs
prepared in the cavity when the pump laser is switched off, see the simulation
data markers at $\xi\sqrt{P}/\kappa_{s}=\\{6,8,10,12,14,16,18\\}$ in Figs.
2(b) and 3(b), and at $\xi\sqrt{P}/\kappa_{s}=\\{8,18,28,38\\}$ in Fig. 4.

Our scheme can be implemented by using a setup depicted in Fig. 1(a). The
high-quality ring optical cavity is formed with four reflective mirrors, M1-M4
Xiao  _et al._ (1995); Lilienfein  _et al._ (2017); Zhang  _et al._ (2018).
The mirror M2 has a relatively low reflectivity ($87.5\%$) as the output port
Neergaard-Nielsen  _et al._ (2007). Other three mirrors have high reflectivity
of $99.99\%$ Muller  _et al._ (2010). End faces of the PPKTP and KTP crystals
and the Rb atomic bubble are coated with $99.9\%$ anti-reflection layers for
both the idler and signal modes. We use the ring cavity with a one-round
length of $\text{0.8}\mathrm{m}$. The internal losses of the cavity is
calculated to be $\kappa_{\text{in}}=2\pi\times 0.37~{}\mathrm{M}\mathrm{Hz}$
and the external loss rate is $\kappa_{\text{ex}}=2\pi\times
8~{}\mathrm{M}\mathrm{Hz}$. The escape efficiency can reach
$\eta_{\text{esc},s(i)}=\kappa_{\text{in}}/(\kappa_{\text{in}}+\kappa_{\text{ex}})=95.6\%$.
An ensemble of warm Rb atoms is used to create a strong PPI for the signal
mode $a_{s}$, with $\gamma_{0}=2\pi\times 6~{}\mathrm{M}\mathrm{Hz}$ Xia  _et
al._ (2018). Four levels related to the D1 line of 87Rb atom are used for the
N-type configuration with $|1\rangle=|5^{2}S_{1/2},F=1,m_{F}=-1\rangle$,
$|2\rangle=|5^{2}S_{1/2},F=2,m_{F}=0\rangle$,
$|3\rangle=|5^{2}P_{1/2},F^{{}^{\prime}}=2,m_{F}^{{}^{\prime}}=-1\rangle$ and
$|4\rangle=|5^{2}P_{1/2},F^{{}^{\prime}}=2,m_{F}^{{}^{\prime}}=0\rangle$. The
signal mode and control laser drive the corresponding transitions in Fig. 1(b)
with the detunings $\Delta_{31}=18\kappa_{s}\approx
904~{}\mathrm{M}\mathrm{Hz}$, $\Delta_{c}=0$ and $\Delta_{42}=8.5\Delta_{31}$.
We can obtain the PPI strength of $\eta/\kappa_{s}=200$ when
$\Omega_{c}=30\gamma_{0}$ ($\text{0.9}\mathrm{m}\mathrm{W}$ Zhang  _et al._
(2013)) and $N_{a}(g/\kappa_{s})^{4}\sim 2.3\times 10^{3}$. With
$\pi$-excitation, we obtain the yield of $Y=0.91$, the purity of $\Pi=99\%$
and the escape efficiency of $\eta_{\text{esc},s}\eta_{\text{esc},i}=91.4\%$,
yielding a generation rate of $1$ M Hz , when the total period of single-
photon pulses takes $6\kappa_{s}^{-1}$. Alternatively, we can also use the
N-type configuration in Sheng  _et al._ (2011) to achieve a strong PPI (see
Supplement 1).

HSPSs and SPDC process have been realized in on-chip microring resonators Guo
_et al._ (2017); Ma  _et al._ (2020). Atomic cladding photonic circuits have
also been reported recently Stern  _et al._ (2013); Ritter  _et al._ (2015,
2018). Therefore, our scheme has the potential to be integrated on a chip if
the microring resonator is cladded by Rb atoms. In such on-chip realization,
the PPI can be significantly increased because the atom-light interaction in a
microring resonator is much stronger. At same time, the outcoupling rate
$\kappa_{ex}$ can be much larger than $\kappa_{in}$ if a bend coupling
waveguide is applied Ma  _et al._ (2020). Thus, we can expect better
performance of our HSPS.

We have presented a method to solve the challenging problem of simultaneously
achieving high purity and high yield in HSPSs. By exploiting the photon
blockade to the signal mode in the cavity-enhanced HSPS, we have improved the
single-photon yield of HSPS by two orders and keep the purity high.
Considering the perfect characters of HSPSs like indistinguishability,
bandwidth and flexibility, our quasi-on-demand HSPS may open a door for
scalable photon-based quantum information processing.

This work was supported by the National Key R&D Program of China (Grants No.
2019YFA0308700, No. 2017YFA0303703, No. 2017YFA0303701), the National Natural
Science Foundation of China (Grant Nos. 11874212, 11890704,
61671279,11574145,11690031), the Fundamental Research Funds for the Central
Universities (021314380095) and the Jiangsu Innovation Plan. We thank the High
Performance Computing Center of Nanjing University for doing the numerical
calculations on its blade cluster system. We also thank Professor Xilin Wang
for his helpful discussion.

## References

  * Kok  _et al._ (2007) P. Kok, W. J. Munro, K. Nemoto, T. C. Ralph, J. P. Dowling, and G. J. Milburn, Rev. Mod. Phys. 79, 135 (2007).
  * Senellart  _et al._ (2017) P. Senellart, G. Solomon, and A. White, Nat. Nanotechnol. 12, 1026 (2017).
  * Degen  _et al._ (2017) C. L. Degen, F. Reinhard, and P. Cappellaro, Rev. Mod. Phys. 89, 035002 (2017).
  * Pan  _et al._ (2012) J.-W. Pan, Z.-B. Chen, C.-Y. Lu, H. Weinfurter, A. Zeilinger, and M. Żukowski, Rev. Mod. Phys. 84, 777 (2012).
  * Georgescu  _et al._ (2014) I. M. Georgescu, S. Ashhab, and F. Nori, Rev. Mod. Phys. 86, 153 (2014).
  * Zhong  _et al._ (2020) H.-S. Zhong, H. Wang, Y.-H. Deng, M.-C. Chen, L.-C. Peng, Y.-H. Luo, J. Qin, D. Wu, X. Ding, Y. Hu, P. Hu, X.-Y. Yang, W.-J. Zhang, H. Li, Y. Li, X. Jiang, L. Gan, G. Yang, L. You, Z. Wang, L. Li, N.-L. Liu, C.-Y. Lu, and J.-W. Pan, Science , eabe8770 (2020).
  * Lodahl  _et al._ (2015) P. Lodahl, S. Mahmoodian, and S. Stobbe, Rev. Mod. Phys. 87, 347 (2015).
  * Zhong  _et al._ (2018) H.-S. Zhong, Y. Li, W. Li, L.-C. Peng, Z.-E. Su, Y. Hu, Y.-M. He, X. Ding, W. Zhang, H. Li, L. Zhang, Z. Wang, L. You, X.-L. Wang, X. Jiang, L. Li, Y.-A. Chen, N.-L. Liu, C.-Y. Lu, and J.-W. Pan, Phys. Rev. Lett. 121, 250505 (2018).
  * Xia  _et al._ (2018) K. Xia, F. Nori, and M. Xiao, Phys. Rev. Lett. 121, 203602 (2018).
  * Li  _et al._ (2020a) L. Li, Z. Liu, X. Ren, S. Wang, V.-C. Su, M.-K. Chen, C. H. Chu, H. Y. Kuo, B. Liu, W. Zang, G. Guo, L. Zhang, Z. Wang, S. Zhu, and D. P. Tsai, Science 368, 1487 (2020a).
  * Imamoḡlu  _et al._ (1997) A. Imamoḡlu, H. Schmidt, G. Woods, and M. Deutsch, Phys. Rev. Lett. 79, 1467 (1997).
  * Sharping  _et al._ (2006) J. E. Sharping, K. F. Lee, M. A. Foster, A. C. Turner, B. S. Schmidt, M. Lipson, A. L. Gaeta, and P. Kumar, Opt. Express 14, 12388 (2006).
  * Yuan  _et al._ (2011) C.-H. Yuan, L. Q. Chen, Z. Y. Ou, and W. Zhang, Phys. Rev. A 83, 054302 (2011).
  * Silverstone  _et al._ (2014) J. W. Silverstone, D. Bonneau, K. Ohira, N. Suzuki, H. Yoshida, N. Iizuka, M. Ezaki, C. M. Natarajan, M. G. Tanner, R. H. Hadfield, V. Zwiller, G. D. Marshall, J. G. Rarity, J. L. O’Brien, and M. G. Thompson, Nat. Photonics 8, 104 (2014).
  * Caspani  _et al._ (2017) L. Caspani, C. Xiong, B. J. Eggleton, D. Bajoni, M. Liscidini, M. Galli, R. Morandotti, and D. J. Moss, Light: Sci. Appl. 6, e17100 (2017).
  * Houck  _et al._ (2007) A. A. Houck, D. I. Schuster, J. M. Gambetta, J. A. Schreier, B. R. Johnson, J. M. Chow, L. Frunzio, J. Majer, M. H. Devoret, S. M. Girvin, and R. J. Schoelkopf, Nature (London) 449, 328 (2007).
  * Lang  _et al._ (2013) C. Lang, C. Eichler, L. Steffen, J. M. Fink, M. J. Woolley, A. Blais, and A. Wallraff, Nat. Phys. 9, 345 (2013).
  * Ding  _et al._ (2016) X. Ding, Y. He, Z.-C. Duan, N. Gregersen, M.-C. Chen, S. Unsleber, S. Maier, C. Schneider, M. Kamp, S. Höfling, C.-Y. Lu, and J.-W. Pan, Phys. Rev. Lett. 116, 020401 (2016).
  * Somaschi  _et al._ (2016) N. Somaschi, V. Giesz, L. De Santis, J. C. Loredo, M. P. Almeida, G. Hornecker, S. L. Portalupi, T. Grange, C. Antón, J. Demory, C. Gómez, I. Sagnes, N. D. Lanzillotti-Kimura, A. Lemaítre, A. Auffeves, A. G. White, L. Lanco, and P. Senellart, Nat. Photonics 10, 340 (2016).
  * Wang  _et al._ (2019) H. Wang, Y.-M. He, T. H. Chung, H. Hu, Y. Yu, S. Chen, X. Ding, M. C. Chen, J. Qin, X. Yang, R.-Z. Liu, Z. C. Duan, J. P. Li, S. Gerhardt, K. Winkler, J. Jurkat, L.-J. Wang, N. Gregersen, Y.-H. Huo, Q. Dai, S. Yu, S. Höfling, C.-Y. Lu, and J.-W. Pan, Nat. Photonics 13, 770 (2019).
  * He  _et al._ (2019) Y.-M. He, H. Wang, C. Wang, M. C. Chen, X. Ding, J. Qin, Z. C. Duan, S. Chen, J. P. Li, R.-Z. Liu, C. Schneider, M. Atatüre, S. Höfling, C.-Y. Lu, and J.-W. Pan, Nat. Phys. 15, 941 (2019).
  * Koong  _et al._ (2021) Z. X. Koong, E. Scerri, M. Rambach, M. Cygorek, M. Brotons-Gisbert, R. Picard, Y. Ma, S. I. Park, J. D. Song, E. M. Gauger, and B. D. Gerardot, Phys. Rev. Lett. 126, 047403 (2021).
  * Ou and Lu (1999) Z. Y. Ou and Y. J. Lu, Phys. Rev. Lett. 83, 2556 (1999).
  * Zhang  _et al._ (2011) H. Zhang, X.-M. Jin, J. Yang, H.-N. Dai, S.-J. Yang, T.-M. Zhao, J. Rui, Y. He, X. Jiang, F. Yang, G.-S. Pan, Z.-S. Yuan, Y. Deng, Z.-B. Chen, X.-H. Bao, S. Chen, B. Zhao, and J.-W. Pan, Nat. Photonics 5, 628 (2011).
  * Guo  _et al._ (2017) X. Guo, C.-l. Zou, C. Schuck, H. Jung, R. Cheng, and H. X. Tang, Light: Sci. Appl. 6, e16249 (2017).
  * Ma  _et al._ (2020) Z. Ma, J.-Y. Chen, Z. Li, C. Tang, Y. M. Sua, H. Fan, and Y.-P. Huang, Phys. Rev. Lett. 125, 263602 (2020).
  * Collins  _et al._ (2013) M. J. Collins, C. Xiong, I. H. Rey, T. D. Vo, J. He, S. Shahnia, C. Reardon, T. F. Krauss, M. J. Steel, A. S. Clark, and B. J. Eggleton, Nat. Commun. 4, 2582 (2013).
  * Reim  _et al._ (2010) K. F. Reim, J. Nunn, V. O. Lorenz, B. J. Sussman, K. C. Lee, N. K. Langford, D. Jaksch, and I. A. Walmsley, Nat. Photonics 4, 218 (2010).
  * Christ and Silberhorn (2012) A. Christ and C. Silberhorn, Phys. Rev. A 85, 023829 (2012).
  * Takeoka  _et al._ (2015) M. Takeoka, R.-B. Jin, and M. Sasaki, New J. Phys. 17, 043030 (2015).
  * Jennewein  _et al._ (2011) T. Jennewein, M. Barbieri, and A. G. White, J. Mod. Opt. 58, 276 (2011).
  * Migdall  _et al._ (2002) A. L. Migdall, D. Branning, and S. Castelletto, Phys. Rev. A 66, 053805 (2002).
  * Pittman  _et al._ (2002) T. B. Pittman, B. C. Jacobs, and J. D. Franson, Phys. Rev. A 66, 042303 (2002).
  * Grimau Puigibert  _et al._ (2017) M. Grimau Puigibert, G. H. Aguilar, Q. Zhou, F. Marsili, M. D. Shaw, V. B. Verma, S. W. Nam, D. Oblak, and W. Tittel, Phys. Rev. Lett. 119, 083601 (2017).
  * Kaneda and Kwiat (2019) F. Kaneda and P. G. Kwiat, Sci. Adv. 5 (2019), 10.1126/sciadv.aaw8586.
  * Neergaard-Nielsen  _et al._ (2007) J. S. Neergaard-Nielsen, B. M. Nielsen, H. Takahashi, A. I. Vistnes, and E. S. Polzik, Opt. Express 15, 7940 (2007).
  * Bao  _et al._ (2008) X.-H. Bao, Y. Qian, J. Yang, H. Zhang, Z.-B. Chen, T. Yang, and J.-W. Pan, Phys. Rev. Lett. 101, 190501 (2008).
  * Dai  _et al._ (2012) H.-N. Dai, H. Zhang, S.-J. Yang, T.-M. Zhao, J. Rui, Y.-J. Deng, L. Li, N.-L. Liu, S. Chen, X.-H. Bao, X.-M. Jin, B. Zhao, and J.-W. Pan, Phys. Rev. Lett. 108, 210501 (2012).
  * Sheng  _et al._ (2011) J. Sheng, X. Yang, H. Wu, and M. Xiao, Phys. Rev. A 84, 053820 (2011).
  * Liu  _et al._ (2016) Z.-Y. Liu, Y.-H. Chen, Y.-C. Chen, H.-Y. Lo, P.-J. Tsai, I. A. Yu, Y.-C. Chen, and Y.-F. Chen, Phys. Rev. Lett. 117, 203601 (2016).
  * Sagona-Stophel  _et al._ (2020) S. Sagona-Stophel, R. Shahrokhshahi, B. Jordaan, M. Namazi, and E. Figueroa, Phys. Rev. Lett. 125, 243601 (2020).
  * Sangouard  _et al._ (2011) N. Sangouard, C. Simon, H. de Riedmatten, and N. Gisin, Rev. Mod. Phys. 83, 33 (2011).
  * Tang  _et al._ (2020) J. Tang, Y. Wu, Z. Wang, H. Sun, L. Tang, H. Zhang, T. Li, Y. Lu, M. Xiao, and K. Xia, Phys. Rev. A 101, 053802 (2020).
  * Scully  _et al._ (1997) M. O. Scully, M. S. Zubairy, _et al._ ,  _Quantum Optics_ (Cambridge University Press, 1997).
  * Okamoto (2006) K. Okamoto,  _Fundamentals of optical waveguides_ (Academic press, 2006).
  * Wu  _et al._ (2008) H. Wu, J. Gea-Banacloche, and M. Xiao, Phys. Rev. Lett. 100, 173602 (2008).
  * Wang  _et al._ (2001) H. Wang, D. Goorskey, and M. Xiao, Phys. Rev. Lett. 87, 073601 (2001).
  * Li  _et al._ (2008) S. Li, X. Yang, X. Cao, C. Zhang, C. Xie, and H. Wang, Phys. Rev. Lett. 101, 073602 (2008).
  * Wang  _et al._ (2013) Y. Wang, J. Wan, B. Zou, J. Zhang, and Y. Zhu, Journal of Physics: Conference Series 414, 012001 (2013).
  * Li  _et al._ (2020b) E.-Z. Li, D.-S. Ding, Y.-C. Yu, M.-X. Dong, L. Zeng, W.-H. Zhang, Y.-H. Ye, H.-Z. Wu, Z.-H. Zhu, W. Gao, G.-C. Guo, and B.-S. Shi, Phys. Rev. Res. 2, 033517 (2020b).
  * Plenio and Knight (1998) M. B. Plenio and P. L. Knight, Rev. Mod. Phys. 70, 101 (1998).
  * Gleyzes  _et al._ (2007) S. Gleyzes, S. Kuhr, C. Guerlin, J. Bernu, S. Deléglise, U. Busk Hoff, M. Brune, J.-M. Raimond, and S. Haroche, Nature (London) 446, 297 (2007).
  * Johansson  _et al._ (2012) J. R. Johansson, P. D. Nation, and F. Nori, Comput. Phys. Commun. 183, 1760 (2012).
  * Morin  _et al._ (2019) O. Morin, M. Körber, S. Langenfeld, and G. Rempe, Phys. Rev. Lett. 123, 133602 (2019).
  * Luo  _et al._ (2015) K.-H. Luo, H. Herrmann, S. Krapick, B. Brecht, R. Ricken, V. Quiring, H. Suche, W. Sohler, and C. Silberhorn, New J. Phys. 17, 073039 (2015).
  * Wolfgramm  _et al._ (2008) F. Wolfgramm, X. Xing, A. Cerè, A. Predojević, A. M. Steinberg, and M. W. Mitchell, Opt. Express 16, 18145 (2008).
  * Le Jeannic  _et al._ (2016) H. Le Jeannic, V. B. Verma, A. Cavailles, F. Marsili, M. D. Shaw, K. Huang, O. Morin, S. W. Nam, and J. Laurat, Opt. Lett. 41, 5341 (2016).
  * Fasel  _et al._ (2004) S. Fasel, O. Alibart, S. Tanzilli, P. Baldi, A. Beveratos, N. Gisin, and H. Zbinden, New J. Phys. 6, 163 (2004).
  * Scholz  _et al._ (2009) M. Scholz, L. Koch, and O. Benson, Phys. Rev. Lett. 102, 063603 (2009).
  * Bocquillon  _et al._ (2009) E. Bocquillon, C. Couteau, M. Razavi, R. Laflamme, and G. Weihs, Phys. Rev. A 79, 035801 (2009).
  * Li  _et al._ (2020c) J. Li, J. Su, L. Cui, T. Xie, Z. Y. Ou, and X. Li, Appl. Phys. Lett. 116 (2020c).
  * Slussarenko  _et al._ (2017) S. Slussarenko, M. M. Weston, H. M. Chrzanowski, L. K. Shalm, V. B. Verma, S. W. Nam, and G. J. Pryde, Nat. Photonics 11, 700 (2017).
  * Broome  _et al._ (2011) M. A. Broome, M. P. Almeida, A. Fedrizzi, and A. G. White, Opt. Express 19, 22698 (2011).
  * Tomm  _et al._ (2021) N. Tomm, A. Javadi, N. O. Antoniadis, D. Najer, M. C. Löbl, A. R. Korsch, R. Schott, S. R. Valentin, A. D. Wieck, A. Ludwig, and R. J. Warburton, Nat. Nanotechnol. (2021).
  * Eisaman  _et al._ (2011) M. D. Eisaman, J. Fan, A. Migdall, and S. V. Polyakov, Rev. Sci. Instrum. 82, 071101 (2011).
  * Fischer  _et al._ (2017) K. Fischer, L. Hanschke, J. Wierzbowski, T. Simmet, C. Dory, J. Finley, J. Vučković, and K. Mü ller, Nat. Phys. 13, 649 (2017).
  * noz  _et al._ (2018) C. S. M. noz, F. P. Laussy, E. del Valle, C. Tejedor, and A. González-Tudela, Optica 5, 14 (2018).
  * Schweickert  _et al._ (2018) L. Schweickert, K. D. Jöns, K. D. Zeuner, S. F. Covre da Silva, H. Huang, T. Lettner, M. Reindl, J. Zichi, R. Trotta, A. Rastelli, and V. Zwiller, Appl. Phys. Lett. 112, 093106 (2018).
  * Yan  _et al._ (2019) Z. Yan, Y.-R. Zhang, M. Gong, Y. Wu, Y. Zheng, S. Li, C. Wang, F. Liang, J. Lin, Y. Xu, C. Guo, L. Sun, C.-Z. Peng, K. Xia, H. Deng, H. Rong, J. Q. You, F. Nori, H. Fan, X. Zhu, and J.-W. Pan, Science 364, 753 (2019).
  * Xiao  _et al._ (1995) M. Xiao, Y.-q. Li, S.-z. Jin, and J. Gea-Banacloche, Phys. Rev. Lett. 74, 666 (1995).
  * Lilienfein  _et al._ (2017) N. Lilienfein, C. Hofer, S. Holzberger, C. Matzer, P. Zimmermann, M. Trubetskov, V. Pervak, and I. Pupeza, Opt. Lett. 42, 271 (2017).
  * Zhang  _et al._ (2018) S. Zhang, Y. Hu, G. Lin, Y. Niu, K. Xia, J. Gong, and S. Gong, Nat. Photonics 12, 744 (2018).
  * Muller  _et al._ (2010) A. Muller, E. B. Flagg, J. R. Lawall, and G. S. Solomon, Opt. Lett. 35, 2293 (2010).
  * Zhang  _et al._ (2013) H. Zhang, L. Wang, J. Chen, S. Bao, L. Zhang, J. Zhao, and S. Jia, Phys. Rev. A 87, 033835 (2013).
  * Stern  _et al._ (2013) L. Stern, B. Desiatov, I. Goykhman, and U. Levy, Nat. Commun. 4, 1548 (2013).
  * Ritter  _et al._ (2015) R. Ritter, N. Gruhler, W. Pernice, H. Kübler, T. Pfau, and R. Löw, Appl. Phys. Lett. 107, 041101 (2015).
  * Ritter  _et al._ (2018) R. Ritter, N. Gruhler, H. Dobbertin, H. Kübler, S. Scheel, W. Pernice, T. Pfau, and R. Löw, Phys. Rev. X 8, 021032 (2018).


* Wang & Deng (2018) Wang, M., & Deng, W. (2018).  Deep visual domain adaptation: A survey.  Neurocomputing, 312, 135–153.
  * Wegner et al. (2017) Wegner, J.-D., Rottensteiner, F., Sohn, G., & Gerke, M. (2017).  The isprs 2d semantic labelling contest.  URL: www2.isprs.org/commissions/comm2/wg4/benchmark/semantic-labeling.(accessed22/12/2020).
  * Wittich (2020) Wittich, D. (2020).  Deep domain adaptation by weighted entropy minimization for the classification of aerial images.  In ISPRS Annals of Photogrammetry, Remote Sensing and Spatial Information Science (pp. 591–598).  volume V-2.
  * Wittich & Rottensteiner (2019) Wittich, D., & Rottensteiner, F. (2019).  Adversarial domain adaptation for the classification of aerial images and height data using convolutional neural networks.  In ISPRS Annals of Photogrammetry, Remote Sensing and Spatial Information Science (pp. 197–204).  volume IV-2/W7.
  * Yang et al. (2019) Yang, C., Rottensteiner, F., & Heipke, C. (2019).  Towards better classification of land cover and land use based on convolutional neural networks.  In International Archives of Photogrammetry, Remote Sensing and Spatial Information Science (pp. 139–146).  volume XLII-2/W13.
  * Yang et al. (2020a) Yang, C., Rottensteiner, F., & Heipke, C. (2020a).  Investigations on skip-connections with an additional cosince similarity loss for land cover classification.  In ISPRS Annals of Photogrammetry, Remote Sensing and Spatial Information Science (pp. 339–346).  volume V-3.
  * Yang et al. (2020b) Yang, Y., Lao, D., Sundaramoorthi, G., & Soatto, S. (2020b).  Phase consistent ecological domain adaptation.  In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 9011–9020).
  * Yang & Soatto (2020) Yang, Y., & Soatto, S. (2020).  Fda: Fourier domain adaptation for semantic segmentation.  In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 4085–4095).
  * Zhang et al. (2019) Zhang, G., Lei, T., Cui, Y., & Jiang, P. (2019).  A dual-path and lightweight convolutional neural network for high-resolution aerial image segmentation.  ISPRS International Journal of Geo-Information, 8, 582.
  * Zhang et al. (2017) Zhang, Y., David, P., & Gong, B. (2017).  Curriculum domain adaptation for semantic segmentation of urban scenes.  In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 2020–2030).
  * Zhang et al. (2018) Zhang, Y., Qiu, Z., Yao, T., Liu, D., & Mei, T. (2018).  Fully convolutional adaptation networks for semantic segmentation.  In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 6810–6818).
  * Zhu et al. (2017a) Zhu, J.-Y., Park, T., Isola, P., & Efros, A. A. (2017a).  Unpaired image-to-image translation using cycle-consistent adversarial networks.  In IEEE International Conference on Computer Vision (ICCV) (pp. 2223–2232).
  * Zhu et al. (2017b) Zhu, X. X., Tuia, D., Mou, L., Xia, G.-S., Zhang, L., Xu, F., & Fraundorfer, F. (2017b).  Deep learning in remote sensing: A comprehensive review and list of resources.  IEEE Geoscience and Remote Sensing Magazine, 5, 8–36.
  * Zou et al. (2018) Zou, Y., Yu, Z., Kumar, B., & Wang, J. (2018).  Unsupervised domain adaptation for semantic segmentation via class-balanced self-training.  In European Conference on Computer Vision (ECCV) (pp. 289–305).


# Toward a Theory of Programming Language and Reasoning Assistant Design:
Minimizing Cognitive Load

Michael Coblenz<EMAIL_ADDRESS>0000-0002-9369-4069 University of
Maryland8125 Paint Branch DriveCollege ParkMarylandUSA20742

(2021)

###### Abstract.

Current approaches to making programming languages and reasoning assistants
more effective for people focus on leveraging feedback from users and on
evaluating the success of particular techniques. These approaches, although
helpful, may not result in systems that are as usable as possible, and may not
lead to general design principles. This paper advocates for leveraging
theories from cognitive science, focusing on cognitive load theory, to design
more effective programming languages and reasoning assistants. Development of
these theories may enable designers to create more effective programming
languages and reasoning assistants at lower cost.

programming language design, cognitive load, short-term memory, psychology of
programming

††copyright: rightsretained††journalyear: 2021††doi:
10.1145/1122445.1122456††journal: JACM††journalvolume: 37††journalnumber:
4††article: 111††publicationmonth: 8††ccs: Software and its engineering
General programming languages††ccs: Human-centered computing HCI theory,
concepts and models

##  1\. Introduction

How can we design programming languages and reasoning assistants that make
users as effective as possible? User-centered design techniques, which have
recently been applied to programming languages (Coblenz et al., 2020), enable
designers to iteratively improve their designs using feedback from users.
Alternatively, when a designer has a design candidate that they believe may be
effective, the designer can evaluate the tradeoffs in a user study. However,
there are two problems with these approaches. First, perhaps the designs are
beneficial relative to other design candidates, but alternative designs might
be superior. That is, perhaps the process finds only a local maximum in the
design space. Second, the approach does not provide predictive power regarding
candidate designs, and in a search for effective designs, it is not cost-
effective to evaluate large numbers of design candidates. The results of
evaluating individual systems may not generalize to new systems that combine
techniques from earlier evaluated designs because of potential interactions
among design components. Of course, in particular situations, the designer
might hypothesize that prior results do apply on the basis of the designer’s
experience or on the basis of various kinds of theory.

An alternative approach to design languages that are more effective for users
would be to use a theory of usability of languages. If we had theories that
provided predictive power regarding programming language and reasoning
assistant (PL/RA) designs, designers might be able to create designs that are
more effective overall, avoiding the local maximum challenges that arise with
user-centered design iteration and the high costs of repeated evaluations with
users. Even if a theory does not provide quantitative predictions, it may help
a designer hypothesize which designs are likely to be more effective than
others, guiding the design process at lower cost than an empirically-driven
approach.

To illustrate the benefits of a user-centered theory-driven approach to PL/RA
design, in this paper, I consider the relevance of one particular theory
(cognitive load theory, CLT) to programming language designs. Many of these
implications pertain to type systems or the design of reasoning assistants
directly, though for the sake of completeness, I consider other implications
as well. In the future, we might turn our efforts to developing new theories,
potentially in collaboration with cognitive scientists. By showing how one
theory from cognitive science may have implications on PL/RA design, I aim to
promote the use and further development of human-related theory in PL/RA
design. These theories complement traditional mathematical theories of
programming languages, which should be used simultaneously. By coupling an
analysis of the cognitive load characteristics of a feature and participants’
task performance in user studies, it may be possible to develop a predictive
model of how designs affect language learnability and programming task
performance.

##  2\. Introduction to Cognitive Load Theory

Cognitive scientists have long modeled human memory as including a short-term
memory component, which temporarily stores facts that are relevant to one’s
current task (Glanzer and Cunitz, 1966). Unfortunately, the capacity of short-
term memory is limited, with researchers finding limits between 4 and 7 items
in adults (Cowan, 2010). In addition, items in short-term memory can be
discarded as a result of a change in attention or due to the passage of time.
Cognitive load theory (CLT) was developed by Sweller (Sweller and Chandler,
1994) in a context of studying learning. CLT models learning challenge in
terms of the number of items that one must remember at once in order to
accomplish the learning objective. If the learning process requires
remembering too many items, then performance suffers in terms of time
required, errors made, or both. CLT applies to problem-solving tasks,
particularly ones conducted in the context of learning (Sweller, 1988).

How can we write software effectively, considering the complexity of software
(even a single function or method likely has more than 4 lines of code)? There
are three techniques that allow us to work around the limits of short-term
memory. First, some relevant facts can be located in long-term memory.
Although adding items to long-term memory requires rehearsal, long-term memory
has an extremely large capacity. Second, by combining disparate facts into one
entity (“chunking”), the facts can share one memory “slot.” For example,
perhaps beacons (Wiedenbeck, 1986) reflect a way to chunk lines or tokens so
that they require less short-term memory. Finally, one can externalize
information by recording information in another form, such as in a text file
or on paper. Of course, paging this externalized information back in has a
time cost, and may be neglected entirely. Failure to restore externalized
information could be a source of bugs, as important requirements or facts are
omitted from consideration.

When cognitive load is high, CLT predicts lower learning efficiency (Sweller,
1988). High cognitive load is also associated with high error rates (Ayres,
2001). Even in small lab studies with 30-40 lines of code, cognitive load has
been found to be high when certain antipatterns are followed in identifier
selection (Fakhoury et al., 2018). Existing methods (also described by
Fakhoury et al. (Fakhoury et al., 2018)) can be used to measure cognitive
load, allowing researchers to investigate the effect of PL/RA designs on
cognitive load in relevant tasks.

CLT also predicts an effect called expertise reversal (Kalyuga et al., 2003)
in which providing cognitive support directed at novices can actually reduce
experts’ performance on the same tasks. The idea is that experts may
experience unnecessary cognitive load when processing beginner-level advice
that they do not need. This might point toward a need for customized error
messages or other tools.

##  3\. Impact of Designs on Cognitive Load

Programming languages, environments, and proof assistants each embody design
choices that impact their users’ cognitive load. Key techniques for reducing
cognitive load include reducing the amount of information needed for a task
(as in features that promote modularity); co-locating relevant information
(typically provided by IDE features such as _jump to definition_ ; and
visualizations.

###  3.1. Programming Languages

What programming language design decisions might influence short-term memory
requirements? Any programming subtask that does not directly relate to one of
the high-level requirements may consume short-term memory slots. Below is a
partial list of programming tasks that may unnecessarily occupy short-term
memory.

Determining reference validity:

When programming in a language in which references can be invalid, reference
validity may need to be checked. If neglected, this can result in undefined
behavior (in unsafe languages) or runtime errors.

Leveraging imprecise static type information:

Types constrain the operations that are permitted on an expression. When using
an unfamiliar type, a programmer might read declarations or documentation to
determine what operations are available, so these operations are in short-term
memory, not long-term memory. As a result, doing a sequence of operations with
the type might require re-reading the documentation. IDEs can help via
autocomplete tools, but these tools are less effective when an expression has
an imprecise type, since less information is available regarding what
operations are available.

In addition, autocomplete and autosuggest features can be made much more
precise in the presence of precise static type information; these features
prevent users from needing to remember the full names of uncommonly used
methods and functions.

Handling errors:

Handling errors requires that the programmer consider additional questions
that do not pertain to the programmer’s primary goal, such as: what might have
caused the error? Is the error recoverable? What should be done about it? C
programmers are expected to check return values for exit codes, but many of
the errors are not recoverable (for example, there is typically no solution if
malloc returns NULL). Java programmers need to handle exceptions, but
frequently do not bother to write appropriate handlers (Kery et al., 2016).
Future research should investigate whether writing error handling code is
problematic from a cognitive load perspective and consider whether separating
handling errors out as a separate development task might reduce cognitive
load.

Implicit operations:

Should a language allow implicit casts? If so, the semantics of operations may
be unclear; if not, the need to insert explicit casts may increase cognitive
load (since the programmer must think about the choices of which types to cast
to and from). Some languages, such as Scala and Agda, allow implicit
arguments. This may reduce cognitive load if the arguments are not relevant to
the task, but it may increase it if the programmer needs to figure out how the
implicit arguments are inferred.

Reasoning about code re-use:

Changing one function or module may break dependent modules. Therefore, when
making a change, the programmer should be aware of any requirements imposed by
clients of the changed code. This requires that the programmer add the
dependencies to short-term memory; keeping all of these in mind simultaneously
could easily exceed the size limit. One might argue for clear module
boundaries and complete requirement specifications, but specifications can be
redundant with parts of the implementation (must one re-state preconditions
that are expressed in assertions?), and specifications can themselves be
inconsistent with the code.

PL designers typically provide features for modularity to make it easier to
re-use code in different contexts and to protect clients of code from changes
in other parts of the codebase. Although this separation of concerns can
reduce cognitive load, it can come at a cost: more abstract code can result in
more abstract or less-localized error messages, which can be harder to
understand. In addition, leveraging modularity features results in more
architectural complexity, which can itself increase cognitive load for
clients. That is, there can be a tradeoff between load for clients and load
for API authors. One approach could be to use program optimization or partial
evaluation (Blazy and Facon, 1998; Harman and Danicic, 1997) to reduce
information needs for authors of clients. 111Thanks to reviewer 1 for this
observation..

Inheritance is one language feature that results in hidden dependencies; the
author of a superclass can be unaware of subclasses (the fragile base class
problem (Mikhajlov and Sekerinski, 1998)). Type systems are a key tool
designers can use to promote and inhibit code re-use, in part through
subtyping. Future work might investigate how subtyping impacts cognitive load.

Managing effects:

Designers of pure languages, such as Haskell, often tout the cognitive
benefits of avoiding side effects. From a cognitive load perspective, side
effects may demand that the programmer keep the possible side effects in
short-term memory when calling a function rather than being able to reason
only based on the inputs and outputs. If the effects pertain to a module that
is not in short-term memory, the programmer may need to load that module into
short-term memory, potentially flushing other needed information.

However, pure languages may also impose costs on short-term memory.
Programmers may need to track additional state explicitly (e.g., with
variables that represent the current environment), requiring additional slots
of short-term memory. If the state could have been externalized in a way that
does not require programmer attention, a stateful solution may well be better
from a cognitive load perspective. By providing a channel of communication
among parts of a program that is independent of control flow, state can reduce
the need for state transmission to occupy short-term memory slots.

Type systems that capture effects may make the problem even worse by forcing
programmers to attend to effects that are irrelevant to their concerns. For
example, they may not care whether the function logs to the console, but one
cannot do so without specifying an appropriate effect, which may increase
cognitive load. On the other hand, effect systems could reduce cognitive load
by preventing the programmer from having to consider all possible effects.
Future research should evaluate the cognitive load impact of particular effect
system designs.

Fulfilling proof obligations:

When using some verification tools, users may need to use ghost variables and
other techniques to fulfill proof obligations. These variables increase
cognitive load relative to approaches that do not require them (including ones
that do not use verification).

###  3.2. Programming Environments

Requirements and types. Software components typically need to meet collections
of requirements. Functions or methods may have requirements regarding
security, performance, invariant maintenance, error checking, error handling,
and of course functional correctness. Even this list of six categories may be
larger than the short-term memory size! It is not surprising that many
functions do not, in fact, meet all of their requirements without extensive
testing. Perhaps the process of writing tests helps programmers divide their
work in a way that lets them focus on just one or two requirements at a time —
a number that does fit in short-term memory. Then, they can fix their
implementations by using an external requirement store: the set of tests.

Requirements traceability refers to the ability to relate requirements (as
typically written in a natural language requirements document) to code or
other artifacts that implement the requirements (IEEE, 2010). This is useful
in software engineering so that software engineers can answer questions about
the purposes of particular sections of code. What if a programming environment
provided explicit requirements traceability functionality? The IDE could track
pending requirements for each module, and a programmer could annotate
components when fulfilling those requirements. Even without any kind of
verification process to mechanically ensure the requirements have been met,
the mechanism could still serve to help people keep track of which
requirements they needed to meet and which they had attended to so far.

Some IDEs provide limited support for tracking unmet requirements by
generating warnings that correspond to comments that start with TODO. But this
requires that programmers recall unmet requirements while writing code.
Instead, suppose programmers first listed requirements, and then worked toward
fulfilling them (an approach often recommended by instructors of beginning
programming courses!). The process is similar to that proposed by test-driven
design or test-first design, but lighter weight because it does not require
writing actual test cases first. Instead, prose requirements would suffice,
and the IDE could help the programmer track which ones were still to be
completed. New maintainers could re-check the revised code against the
original list of requirements, and the IDE could help by providing a checklist
to examine.

How would the IDE connect code to requirements? Verification approaches, such
as dependent types, are one approach, but these carry a significant burden for
users. Another approach, when formal verification is not cost-effective, is
for the code to carry metadata that maps between natural language requirements
and lines of code.

Dependency management. Many languages require that code both import required
modules in code (e.g. Java import) as well as specify version of libraries
that the program depends on (which the build tool should fetch before
building, e.g Maven dependencies). When adding a use of a new library, the
programmer must set aside the current task, manage the dependencies, and then
return to the current task — at which time the programmer must remember what
was in their short-term memory. Could programming environments help queue this
kind of work to avoid overloading the programmer’s short-term memory? To what
extent must these tools be workflow-specific — or can one class of management
tool apply in many different kinds of situations?

Information access. When working on programming tasks, programmers frequently
need a variety of different kinds of information: documentation, code
examples, notes, and of course the code being edited. Jump-to-definition
features help programmers easily access relevant information for some tasks.
Some systems, such as Code Bubbles (Bragdon et al., 2010), help users arrange
some of these items on the screen at once. This mitigates short-term memory
limitations, which prevent programmers from keeping all the relevant
information in their minds. However, IDEs typically do not provide assistance
keeping track of relevant facts automatically other than with a back/forward
button. Can IDEs automatically detect which relevant pieces of information are
unlikely to fit in short-term memory and provide appropriate assistance?

Visualizations. Although architectural diagramming tools exist, automatic
visualization tools frequently generate diagrams that are too densely-
populated for practical purposes. Programmers may need diagrams that include
information relevant to their current tasks, but many visualization tools
incorporate only limited task information when they generate the
visualizations. Visual representations matter in problem solving, however. For
example, Zhang (Zhang, 1997) showed how the representation of Tic-Tac-Toe can
make it seem like a completely different game.

###  3.3. Proof Assistants

Interactive proof assistants, such as Coq (Team, 2021), typically track the
pending proof obligations that the user is required to fulfill. This obviates
the programmer from needing to track these in short-term memory. They also
track the set of theorems that have already been proven. The latter presents a
challenge, however, since in working toward a particular proof obligation, the
user must either repeatedly scan the list of available theorems, or commit
them to their (small) short-term memory. Could proof assistants chunk the
available theorems in order to help the user fit more of them in short-term
memory? For example, could they combine them where possible to create a
smaller number of more-powerful theorems?

Tactics-based theorem provers require users to learn a set of available
tactics that can be applied to transform proof terms. Experts have large sets
of tactics available in their long-term memories; novices have learned much
smaller sets. But in many cases, the best tactic to apply may not be available
in long-term memory and also not have been used recently. Perhaps proof
assistants could suggest tactics to be applied. Unlike automatic proof search,
the idea would be to suggest specific tactics that might be useful, rather
than applying a sequence of them automatically. If the suggestions are
relevant enough of the time, this approach could help users learn tactics that
they could use in the future. Unlike traditional textual autocomplete in IDEs,
this form of autosuggest would not be based on lexical prefixes, but instead
on proof obligations and available proof terms.

##  4\. Related Work

Crichton et al. (Crichton et al., 2021) studied the role of short-term memory
in code tracing tasks, finding a limit of about 7 variable/value pairs and
proposing changes that could be made to programming tools to help with code
tracing tasks. Reducing cognitive load has been proposed in other HCI
contexts, such as multimedia interfaces (Oviatt, 2006). Shaffer et al.
proposed techniques that might reduce cognitive load in introductory
programming courses, such as partitioning information into small segments
(Shaffer et al., 2003).

Helgesson (Helgesson and Runeson, 2021) studied grounded theory analysis of
interviews and literature regarding cognitive load in software engineering,
finding several categories of contributions to cognitive load: task,
environment, information, tool, communication, interruption, structure and
temporal. This paper focuses on the tool perspective.

Programming with holes (Omar et al., 2019) and active code completion (Omar et
al., 2012) are both approaches that might help programmers maintain focus on
their tasks. Programming with holes allows programmers to defer work for
later, leaving type information to direct their follow-up work. Active code
completion allows domain-specific user interfaces to guide the user through
use of a specialized API, preventing the user from needing to consume short-
term memory slots with API details. Likewise, Agda (Bove et al., 2009) has an
emacs mode that allows the user to insert typed holes for completion later.

Code Bubbles (Bragdon et al., 2010) and JASPER (Coblenz et al., 2006) help
programmers collect and reference relevant pieces of information while working
in an IDE. Both tools allow programmers to arrange relevant information, such
as code, on the screen while working on tasks. These techniques may help
reduce programmers’ reliance on short-term memory.

##  5\. Future Work

The list of design decisions that may impact cognitive load is surely
incomplete; a more exhaustive list (and a method for enumerating it) would be
preferable. Future work should investigate whether the design decisions
described above indeed relate to cognitive load, whether the cognitive load
leads to a usability cost, and if so, how the cognitive load might be
decreased. Furthermore, cognitive load theory is only one of many existing
theories from cognitive science; others, such as the concept of attention,
should be investigated as well. Finally, the theoretical frameworks from
cognitive science are unlikely to suffice to justify every PL/RA design
decision, so the community should work toward richer theories that provide
more explanatory power regarding programmer behavior.

##  6\. Conclusion

Existing theories from cognitive science, such as cognitive load theory, may
offer guidance on a variety of programming language design questions. Many of
those questions have been the subject of debate or empirical evaluation, but
having a theory (particularly one with sufficient predictive power) could lead
to a more effective design strategy for programming languages and reasoning
assistants. This paper proposes exploration of the relationship between the
identified language design decisions, cognitive load, and performance, with
the hope of assessing whether cognitive load theory can be leveraged in
programming language design.

###### Acknowledgements.

Thanks very much to Clayton Lewis, Daniel Helgesson, and the anonymous HATRA
reviewers for their extensive feedback and suggestions on drafts of this
paper.

## References

  * (1)
  * Ayres (2001) Paul L. Ayres. 2001\.  Systematic Mathematical Errors and Cognitive Load.  _Contemporary Educational Psychology_ 26, 2 (2001), 227–248.  https://doi.org/10.1006/ceps.2000.1051
  * Blazy and Facon (1998) Sandrine Blazy and Philippe Facon. 1998.  Partial Evaluation for Program Comprehension.  _Comput. Surveys_ 30, 3es (1998), 17.  https://doi.org/10.1145/289121.289138
  * Bove et al. (2009) Ana Bove, Peter Dybjer, and Ulf Norell. 2009.  A brief overview of Agda–a functional language with dependent types. In _International Conference on Theorem Proving in Higher Order Logics_. Springer, 73–78.
  * Bragdon et al. (2010) Andrew Bragdon, Steven P. Reiss, Robert Zeleznik, Suman Karumuri, William Cheung, Joshua Kaplan, Christopher Coleman, Ferdi Adeputra, and Joseph J. LaViola. 2010.  Code Bubbles: Rethinking the User Interface Paradigm of Integrated Development Environments. In _Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering - Volume 1_ (Cape Town, South Africa) _(ICSE ’10)_. Association for Computing Machinery, New York, NY, USA, 455–464.  https://doi.org/10.1145/1806799.1806866
  * Coblenz et al. (2020) Michael Coblenz, Ariel Davis, Megan Hofmann, Vivian Huang, Siyue Jin, Max Krieger, Kyle Liang, Brian Wei, Mengchen Sam Yong, and Jonathan Aldrich. 2020.  User-Centered Programming Language Design: A Course-Based Case Study. In _HATRA_.  arXiv:2011.07565 [cs.PL]
  * Coblenz et al. (2006) Michael J. Coblenz, Amy J. Ko, and Brad A. Myers. 2006.  JASPER: An Eclipse Plug-in to Facilitate Software Maintenance Tasks. In _Proceedings of the 2006 OOPSLA Workshop on Eclipse Technology EXchange_ (Portland, Oregon, USA) _(eclipse ’06)_. Association for Computing Machinery, New York, NY, USA, 65–69.  https://doi.org/10.1145/1188835.1188849
  * Cowan (2010) Nelson Cowan. 2010\.  The magical mystery four: How is working memory capacity limited, and why?  _Current directions in psychological science_ 19, 1 (2010), 51–57.
  * Crichton et al. (2021) Will Crichton, Maneesh Agrawala, and Pat Hanrahan. 2021\.  _The Role of Working Memory in Program Tracing_.  Association for Computing Machinery, New York, NY, USA.  https://doi.org/10.1145/3411764.3445257
  * Fakhoury et al. (2018) Sarah Fakhoury, Yuzhan Ma, Venera Arnaoudova, and Olusola Adesope. 2018.  The effect of poor source code lexicon and readability on developers’ cognitive load. In _2018 IEEE/ACM 26th International Conference on Program Comprehension (ICPC)_. IEEE, 286–28610.
  * Glanzer and Cunitz (1966) Murray Glanzer and Anita R. Cunitz. 1966.  Two storage mechanisms in free recall.  _Journal of Verbal Learning and Verbal Behavior_ 5, 4 (1966), 351–360.  https://doi.org/10.1016/S0022-5371(66)80044-0
  * Harman and Danicic (1997) M. Harman and S. Danicic. 1997.  Amorphous program slicing. In _Proceedings Fifth International Workshop on Program Comprehension. IWPC’97_. 70–79.  https://doi.org/10.1109/WPC.1997.601266
  * Helgesson and Runeson (2021) Daniel Helgesson and Per Runeson. 2021.  Towards Grounded Theory Perspectives of Cognitive Load in Software Engineering.  https://www.ppig.org/papers/2021-ppig-32nd-helgesson/
  * IEEE (2010) IEEE. 2010.  ISO/IEC/IEEE International Standard - Systems and software engineering – Vocabulary.  _ISO/IEC/IEEE 24765:2010(E)_ (2010), 1–418.  https://doi.org/10.1109/IEEESTD.2010.5733835
  * Kalyuga et al. (2003) Slava Kalyuga, Paul Ayres, Paul Chandler, and John Sweller. 2003.  The Expertise Reversal Effect.  _Educational Psychologist_ 38, 1 (2003), 23–31.  https://doi.org/10.1207/S15326985EP3801_4
  * Kery et al. (2016) Mary Beth Kery, Claire Le Goues, and Brad A. Myers. 2016\.  Examining Programmer Practices for Locally Handling Exceptions. In _Proceedings of the 13th International Conference on Mining Software Repositories_ (Austin, Texas) _(MSR ’16)_. Association for Computing Machinery, 484–487.  https://doi.org/10.1145/2901739.2903497
  * Mikhajlov and Sekerinski (1998) Leonid Mikhajlov and Emil Sekerinski. 1998.  A Study of The Fragile Base Class Problem. In _European Conference on Object-Oriented Programming_ _(ECOOP 1998)_. 355–382.
  * Omar et al. (2019) Cyrus Omar, Ian Voysey, Ravi Chugh, and Matthew A. Hammer. 2019\.  Live Functional Programming with Typed Holes.  _Proc. ACM Program. Lang._ 3, POPL, Article 14 (Jan. 2019), 32 pages.  https://doi.org/10.1145/3290327
  * Omar et al. (2012) Cyrus Omar, Young Seok Yoon, Thomas D. LaToza, and Brad A. Myers. 2012.  Active code completion. In _2012 34th International Conference on Software Engineering (ICSE)_. 859–869.  https://doi.org/10.1109/ICSE.2012.6227133
  * Oviatt (2006) Sharon Oviatt. 2006\.  Human-Centered Design Meets Cognitive Load Theory: Designing Interfaces That Help People Think. In _Proceedings of the 14th ACM International Conference on Multimedia_ (Santa Barbara, CA, USA) _(MM ’06)_. Association for Computing Machinery, New York, NY, USA, 871–880.  https://doi.org/10.1145/1180639.1180831
  * Shaffer et al. (2003) Dale Shaffer, Wendy Doube, and Juhani Tuovinen. 2003\.  Applying Cognitive load theory to computer science education. In _PPIG_ , Vol. 1. 333–346.
  * Sweller (1988) John Sweller. 1988\.  Cognitive load during problem solving: Effects on learning.  _Cognitive science_ 12, 2 (1988), 257–285.
  * Sweller and Chandler (1994) John Sweller and Paul Chandler. 1994.  Why some material is difficult to learn.  _Cognition and instruction_ 12, 3 (1994), 185–233.
  * Team (2021) The Coq Development Team. 2021\.  _The Coq Proof Assistant_.  https://doi.org/10.5281/zenodo.4501022
  * Wiedenbeck (1986) Susan Wiedenbeck. 1986\.  Beacons in computer program comprehension.  _International Journal of Man-Machine Studies_ 25, 6 (1986), 697–709.  https://doi.org/10.1016/S0020-7373(86)80083-9
  * Zhang (1997) Jiajie Zhang. 1997\.  The nature of external representations in problem solving.  _Cognitive Science_ 21, 2 (1997), 179–217.  https://doi.org/10.1016/S0364-0213(99)80022-6