C, Python, etc. define sqrt as the positive square root.
If you think that numerical functions are the same as mathematics functions, you’re going to find yourself in a world of pain (I vividly remember the numerical analysis course I took, with all the error analysis stuff).
But your predicatesqrt/2 is fine if you want both positive and negative results.
Right?! So why don’t we have an appropriate sqrt/2 predicate in the standard library? The one we have is listed as being for Quintus compatibility and acts like the function, but it’d be nice to have a truthful one.
logical arithmetic is the domain of constraints. The closest I can get is this (clpqr doesn’t seem to know about sqrt/1. I might have missed something though as I never used these libraries).
?- use_module(library(clpr)).
?- { A^2 =:= 4 }.
A = 2.0 ;
A = -2.0 ;