Let A, B, f and g be given.
Assume Hf Hg.
Apply Hf to the current goal.
Assume Hf1 Hf2.
Apply Hg to the current goal.
Assume Hg1 Hg2.
Set F to be the term λX ⇒ {g y|yB {f x|xA X}} of type setset.
We prove the intermediate claim L1: U𝒫 A, F U 𝒫 A.
Let U be given.
Assume HU.
We will prove {g y|yB {f x|xA U}} 𝒫 A.
Apply image_In_Power B A g Hg1 to the current goal.
We will prove B {f x|xA U} 𝒫 B.
Apply setminus_In_Power to the current goal.
We prove the intermediate claim L2: U V𝒫 A, U VF U F V.
Let U be given.
Assume HU.
Let V be given.
Assume HV HUV.
We will prove {g y|yB {f x|xA U}} {g y|yB {f x|xA V}}.
Apply image_monotone g to the current goal.
We will prove B {f x|xA U} B {f x|xA V}.
Apply setminus_antimonotone to the current goal.
We will prove {f x|xA V} {f x|xA U}.
Apply image_monotone f to the current goal.
We will prove A V A U.
Apply setminus_antimonotone to the current goal.
An exact proof term for the current goal is HUV.
Apply KnasterTarski_set A F L1 L2 to the current goal.
Let Y be given.
Assume H1.
Apply H1 to the current goal.
Assume H1: Y 𝒫 A.
Assume H2: F Y = Y.
Set h to be the term λx ⇒ if x Y then inv B g x else f x of type setset.
We will prove f : setset, bij A B f.
We use h to witness the existential quantifier.
Apply bijI to the current goal.
Let x be given.
Assume Hx.
We will prove (if x Y then inv B g x else f x) B.
Apply xm (x Y) to the current goal.
Assume H3: x Y.
rewrite the current goal using If_i_1 (x Y) (inv B g x) (f x) H3 (from left to right).
We will prove inv B g x B.
We prove the intermediate claim L1: x F Y.
rewrite the current goal using H2 (from left to right).
An exact proof term for the current goal is H3.
Apply ReplE_impred (B {f x|xA Y}) g x L1 to the current goal.
Let y be given.
Assume H4: y B {f x|xA Y}.
Assume H5: x = g y.
We prove the intermediate claim L2: y B.
An exact proof term for the current goal is setminusE1 B {f x|xA Y} y H4.
rewrite the current goal using H5 (from left to right).
We will prove inv B g (g y) B.
rewrite the current goal using inj_linv B g Hg2 y L2 (from left to right).
We will prove y B.
An exact proof term for the current goal is L2.
Assume H3: x Y.
rewrite the current goal using If_i_0 (x Y) (inv B g x) (f x) H3 (from left to right).
We will prove f x B.
Apply Hf1 to the current goal.
An exact proof term for the current goal is Hx.
Let x be given.
Assume Hx.
Let y be given.
Assume Hy.
We will prove (if x Y then inv B g x else f x) = (if y Y then inv B g y else f y)x = y.
Apply xm (x Y) to the current goal.
Assume H3: x Y.
rewrite the current goal using If_i_1 (x Y) (inv B g x) (f x) H3 (from left to right).
We will prove inv B g x = (if y Y then inv B g y else f y)x = y.
We prove the intermediate claim Lx: x F Y.
rewrite the current goal using H2 (from left to right).
An exact proof term for the current goal is H3.
Apply ReplE_impred (B {f x|xA Y}) g x Lx to the current goal.
Let z be given.
Assume Hz1: z B {f x|xA Y}.
Assume Hz2: x = g z.
Apply setminusE B {f x|xA Y} z Hz1 to the current goal.
Assume Hz1a Hz1b.
Apply xm (y Y) to the current goal.
Assume H4: y Y.
rewrite the current goal using If_i_1 (y Y) (inv B g y) (f y) H4 (from left to right).
We will prove inv B g x = inv B g yx = y.
We prove the intermediate claim Ly: y F Y.
rewrite the current goal using H2 (from left to right).
An exact proof term for the current goal is H4.
Apply ReplE_impred (B {f x|xA Y}) g y Ly to the current goal.
Let w be given.
Assume Hw1: w B {f x|xA Y}.
Assume Hw2: y = g w.
rewrite the current goal using Hz2 (from left to right).
rewrite the current goal using Hw2 (from left to right).
rewrite the current goal using inj_linv B g Hg2 z Hz1a (from left to right).
rewrite the current goal using inj_linv B g Hg2 w (setminusE1 B {f x|xA Y} w Hw1) (from left to right).
Assume H5: z = w.
We will prove g z = g w.
Use f_equal.
An exact proof term for the current goal is H5.
Assume H4: y Y.
rewrite the current goal using If_i_0 (y Y) (inv B g y) (f y) H4 (from left to right).
We will prove inv B g x = f yx = y.
rewrite the current goal using Hz2 (from left to right).
rewrite the current goal using inj_linv B g Hg2 z Hz1a (from left to right).
We will prove z = f yg z = y.
Assume H5: z = f y.
We will prove False.
Apply Hz1b to the current goal.
We will prove z {f x|xA Y}.
rewrite the current goal using H5 (from left to right).
Apply ReplI to the current goal.
We will prove y A Y.
Apply setminusI to the current goal.
An exact proof term for the current goal is Hy.
An exact proof term for the current goal is H4.
Assume H3: x Y.
rewrite the current goal using If_i_0 (x Y) (inv B g x) (f x) H3 (from left to right).
We will prove f x = (if y Y then inv B g y else f y)x = y.
Apply xm (y Y) to the current goal.
Assume H4: y Y.
rewrite the current goal using If_i_1 (y Y) (inv B g y) (f y) H4 (from left to right).
We will prove f x = inv B g yx = y.
We prove the intermediate claim Ly: y F Y.
rewrite the current goal using H2 (from left to right).
An exact proof term for the current goal is H4.
Apply ReplE_impred (B {f x|xA Y}) g y Ly to the current goal.
Let w be given.
Assume Hw1: w B {f x|xA Y}.
Assume Hw2: y = g w.
Apply setminusE B {f x|xA Y} w Hw1 to the current goal.
Assume Hw1a Hw1b.
rewrite the current goal using Hw2 (from left to right).
rewrite the current goal using inj_linv B g Hg2 w Hw1a (from left to right).
Assume H5: f x = w.
We will prove False.
Apply Hw1b to the current goal.
We will prove w {f x|xA Y}.
rewrite the current goal using H5 (from right to left).
Apply ReplI to the current goal.
Apply setminusI to the current goal.
An exact proof term for the current goal is Hx.
An exact proof term for the current goal is H3.
Assume H4: y Y.
rewrite the current goal using If_i_0 (y Y) (inv B g y) (f y) H4 (from left to right).
We will prove f x = f yx = y.
An exact proof term for the current goal is Hf2 x Hx y Hy.
Let w be given.
Assume Hw: w B.
Apply xm (w {f x|xA Y}) to the current goal.
Assume H3: w {f x|xA Y}.
Apply ReplE_impred (A Y) f w H3 to the current goal.
Let x be given.
Assume H4: x A Y.
Assume H5: w = f x.
Apply setminusE A Y x H4 to the current goal.
Assume H6: x A.
Assume H7: x Y.
We use x to witness the existential quantifier.
Apply andI to the current goal.
An exact proof term for the current goal is H6.
We will prove (if x Y then inv B g x else f x) = w.
rewrite the current goal using If_i_0 (x Y) (inv B g x) (f x) H7 (from left to right).
Use symmetry.
An exact proof term for the current goal is H5.
Assume H3: w {f x|xA Y}.
We prove the intermediate claim Lgw: g w Y.
rewrite the current goal using H2 (from right to left).
We will prove g w F Y.
We will prove g w {g y|yB {f x|xA Y}}.
Apply ReplI to the current goal.
Apply setminusI to the current goal.
We will prove w B.
An exact proof term for the current goal is Hw.
We will prove w {f x|xA Y}.
An exact proof term for the current goal is H3.
We use (g w) to witness the existential quantifier.
Apply andI to the current goal.
We will prove g w A.
Apply Hg1 to the current goal.
An exact proof term for the current goal is Hw.
We will prove (if g w Y then inv B g (g w) else f (g w)) = w.
rewrite the current goal using If_i_1 (g w Y) (inv B g (g w)) (f (g w)) Lgw (from left to right).
An exact proof term for the current goal is inj_linv B g Hg2 w Hw.