Let X, P and x be given.
Set z to be the term Eps_i (λz ⇒ z X P z) of type set.
Set F to be the term λx ⇒ if P x then x else z of type setset.
Apply (xm (zX, P z)) to the current goal.
Assume H1: zX, P z.
We will prove (x (if (zX, P z) then {F x|xX} else Empty)x X P x).
We prove the intermediate claim L1: (if (zX, P z) then {F x|xX} else Empty) = {F x|xX}.
An exact proof term for the current goal is (If_i_1 (zX, P z) {F x|xX} Empty H1).
rewrite the current goal using L1 (from left to right).
We will prove x {F x|xX}x X P x.
Assume H2: x {F x|xX}.
Apply (ReplE_impred X F x H2) to the current goal.
Let y be given.
Assume H3: y X.
Assume H4: x = F y.
We will prove x X P x.
Apply (xm (P y)) to the current goal.
Assume H5: P y.
We prove the intermediate claim L2: x = y.
rewrite the current goal using (If_i_1 (P y) y z H5) (from right to left).
An exact proof term for the current goal is H4.
rewrite the current goal using L2 (from left to right).
We will prove y X P y.
Apply andI to the current goal.
An exact proof term for the current goal is H3.
An exact proof term for the current goal is H5.
Assume H5: ¬ P y.
We prove the intermediate claim L2: x = z.
rewrite the current goal using (If_i_0 (P y) y z H5) (from right to left).
An exact proof term for the current goal is H4.
rewrite the current goal using L2 (from left to right).
We will prove z X P z.
An exact proof term for the current goal is (Eps_i_ex (λz ⇒ z X P z) H1).
Assume H1: ¬ zX, P z.
We will prove (x (if (zX, P z) then {F x|xX} else Empty)x X P x).
We prove the intermediate claim L1: (if (zX, P z) then {F x|xX} else Empty) = Empty.
An exact proof term for the current goal is (If_i_0 (zX, P z) {F x|xX} Empty H1).
rewrite the current goal using L1 (from left to right).
We will prove x Emptyx X P x.
Assume H2: x Empty.
We will prove False.
An exact proof term for the current goal is (EmptyE x H2).