# Define (conditional) substitution rule for sum/difference of radicals

I want to tell Mathematica to simplify some expressions applying the following substitutions, conditioned on the fact that $a\geq 0,b \geq 0, a^2-b\geq0$

$$\sqrt{a+\sqrt{a^2-b}} \pm \sqrt{a-\sqrt{a^2-b}} \ \to \ \sqrt{2}\sqrt{a\pm\sqrt{b}}$$ or viceversa $$\sqrt{a+\sqrt{b}} \pm \sqrt{a-\sqrt{b}} \ \to \ \sqrt{2}\sqrt{a\pm\sqrt{a^2-b}}$$

How do I do that? I guess I have to set a replacement rule but I do not know how to do that in this case.

This could be used for example to simplify (assume $0 \leq k \leq 1$)

Sqrt[2 + k^4 + Sqrt[k^2 (8 + k^6)]] - Sqrt[2 + k^4 - Sqrt[k^2 (8 + k^6)]]

in Sqrt[2]Sqrt[2+k^4 - Sqrt[4 (1-k^2)^2]], and then (possibly) in Sqrt[2] k Sqrt[k^2 + 2].

Also, what if the original expression (given by MMA) is

Sqrt[2 + k^4 + k Sqrt[8 + k^6]] - Sqrt[2 + k^4 - k Sqrt[8 + k^6]]

can we use the same rule?

As a side note,

Assuming [0 <= k <= 1, (Sqrt[2 + k^4 + Sqrt[k^2 (8 + k^6)]] - Sqrt[2 + k^4 - Sqrt[k^2 (8 + k^6)]]) == (Sqrt[2] Sqrt[2 + k^4 - Sqrt[4 (1 - k^2)^2]]) // FullSimplify]

does not return True, even though the terms are non negative (within the assumptions) and their squares are equal, i.e.

Assuming [0 <= k <= 1,(Sqrt[2 + k^4 + Sqrt[k^2 (8 + k^6)]] - Sqrt[2 + k^4 - Sqrt[k^2 (8 + k^6)]])^2 == (Sqrt[2] k Sqrt[k^2 + 2])^2 // FullSimplify]

returns True.