Looking for keywords - How is this kind of statistical problem called? I am trying to solve the following problem, but I cannot find google-relevant keywords for it (I'm not a statistician) :

*

*In a virtually infinite population

*All individues can have trait $A$ with a known probability $p_A$

*Individues who have no trait $A$, have an unknown probability $p_B$ of having trait $B$

*Individues can have either trait A, or trait B, or none. They cannot have two traits.

*In a sample of size $N$, we observe experimentally $X = #A + #B$, where $#A$ is the number of individues in the sample that have trait $A$ and $#B$ is the number of individues in the sample that have trait $B$. #A and #B are latent variables, we cannot observe them directly. Only their sum can be observed.

Given that The prior on $p_B$ is uniform in [0,1], $p_A$ is known. and X is known (but not #A nor #B separately) : What is the updated posterior probability distribution of $p_B$ ?
I am looking for a solution that would still be correct even with $p_A \cdot N \leq 5$ and $p_B \cdot N \leq 5$
I have the feeling that this should have already been solved in the literature, but I can't find it, nor the relevant keywords to find it
Intuitive extreme example:

*

*I have 1000 individues

*I have $p_A = 10^{-7}$

*I observe experimentally X = 500

*From this observation of X among N, I can deduce with an important confidence that $p_B \approx 0.5$

I have no idea what such a problem corresponds to in the literature, but the problem as you have stated it is quite simple to do inference on:
You have
$$
\begin{align*}
X|p_b &\sim \text{Binomial}(N,p_a + (1-p_a)p_b)\\
p_b &\sim \text{Beta}(1,1)
\end{align*}
$$
The posterior is then proportional to
$$
\begin{align*}
p(p_b|X) &\propto p(X|p_b)p(p_b)\\
&\propto (p_a + (1-p_a)p_b)^X(1 - (p_a + (1-p_a)p_b))^{N-X}
\end{align*}
$$
This doesn't correspond or simplify to any named distribution (as far as I know). However we can easily sample from the posterior to do inference on $p_b$. For example in R you can do this using rstan library
library(rstan)

model<-"
data {
  int<lower=0> X;          
  int<lower=0> N;          
  real<lower=0,upper=1> pA;
}
parameters {
  real<lower=0,upper=1> pB;
}
model {
  target += binomial_lpmf(X | N, pA + (1-pA) * pB);
  target += beta_lpdf(pB | 1.0, 1.0);
}
"

Lets test this for $N=1000$, $X=500$, and $p_a=0.25$
data <- list(
  pA=0.25,
  X=500,
  N=1000
)

fit <- stan(model_code=model, data=data)

We get
Inference for Stan model: 54c52a299004e265657393fabf67c2e0.
4 chains, each with iter=2000; warmup=1000; thin=1; 
post-warmup draws per chain=1000, total post-warmup draws=4000.

      mean se_mean   sd  2.5%   25%   50%   75% 97.5% n_eff Rhat
pB    0.33    0.00 0.02  0.29  0.32  0.33  0.35  0.38  1209    1
lp__ -5.68    0.02 0.71 -7.76 -5.81 -5.40 -5.23 -5.18  1498    1

Samples were drawn using NUTS(diag_e) at Fri Oct 29 07:48:30 2021.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at 
convergence, Rhat=1)

so the posterior mean is $0.33$ with a 95% credible interval $(0.29,0.38)$.
EDIT:
As @whuber points out if $U=(1-p_A)(1-p_B)$ then $$U|X \sim \text{Beta}(N-X+1,X+1)$$ The inverse transform gives $p_B = 1 - \dfrac{U}{1-p_A}$. As @whuber points out you can do many things now just using standard software for beta distributions like sample from the beta and then apply the inverse transform to get samples from posterior of $p_B$. Since the inverse transform is affine you can easily compute expectations
$$
\text{E}[p_B|X] = 1 - \dfrac{\text{E}[U|X]}{1-p_A} = 1 - \dfrac{\tfrac{N-X+1}{N-X+1 + X+1}}{1-p_A} 
$$
which is equal to $1/3$ for the example I used.
