Difference - Maple Help

RegularChains

 ConstructibleSetTools[Difference]
 compute the difference of two constructible sets
 SemiAlgebraicSetTools[Difference]
 compute the difference of two semi-algebraic sets

 Calling Sequence Difference(cs1, cs2, R) Difference(lrsas1, lrsas2, R)

Parameters

 cs1, cs2 - constructible sets lrsas1 - list of regular semi-algebraic systems lrsas2 - list of regular semi-algebraic systems R - polynomial ring

Description

 • This command computes the set-theoretic difference of two constructible sets or two semi-algebraic sets, depending on the input type.
 • A constructible set must be encoded as an constructible_set object; see the type definition in ConstructibleSetTools.
 • A semi-algebraic set must be encoded by a list of regular_semi_algebraic_system, see the type definition of RealTriangularize.
 • The command Difference(cs1, cs2, R) returns a constructible set which is the set theoretic difference of two constructible sets. The polynomial ring may have characteristic zero or a prime characteristic.
 • The command Difference(lrsas1, lrsas2, R) returns a list of regular semi-algebraic systems, encoding the set-theoretic difference of two semi-algebraic sets. The polynomial ring must have characteristic zero.
 • The output may contain certain redundancy among the defining regular systems.
 • This command is available once RegularChains[ConstructibleSetTools] submodule or RegularChains[SemiAlgebraicSetTools] submodule have been loaded. It can always be accessed through one of the following long forms: RegularChains:-ConstructibleSetTools:-Difference or RegularChains:-SemiAlgebraicSetTools:-Difference.

Examples

 > $\mathrm{with}\left(\mathrm{RegularChains}\right):$
 > $\mathrm{with}\left(\mathrm{ChainTools}\right):$
 > $\mathrm{with}\left(\mathrm{ConstructibleSetTools}\right):$
 > $\mathrm{with}\left(\mathrm{SemiAlgebraicSetTools}\right):$

First, define a polynomial ring.

 > $R≔\mathrm{PolynomialRing}\left(\left[x,y\right]\right)$
 ${R}{≔}{\mathrm{polynomial_ring}}$ (1)

Use Triangularize to solve the polynomial equations given by $F$ and $G$ below.

 > $F≔2{x}^{2}+3xy+{y}^{2}-3x-3y$
 ${F}{≔}{2}{}{{x}}^{{2}}{+}{3}{}{x}{}{y}{+}{{y}}^{{2}}{-}{3}{}{x}{-}{3}{}{y}$ (2)
 > $G≔x{y}^{2}-x$
 ${G}{≔}{x}{}{{y}}^{{2}}{-}{x}$ (3)
 > $\mathrm{dec}≔\mathrm{Triangularize}\left(\left[F,G\right],R,\mathrm{output}=\mathrm{lazard}\right)$
 ${\mathrm{dec}}{≔}\left[{\mathrm{regular_chain}}{,}{\mathrm{regular_chain}}{,}{\mathrm{regular_chain}}{,}{\mathrm{regular_chain}}{,}{\mathrm{regular_chain}}{,}{\mathrm{regular_chain}}\right]$ (4)
 > $\mathrm{map}\left(\mathrm{Equations},\mathrm{dec},R\right)$
 $\left[\left[{x}{-}{2}{,}{y}{+}{1}\right]{,}\left[{x}{-}{1}{,}{y}{-}{1}\right]{,}\left[{x}{+}{1}{,}{y}{-}{1}\right]{,}\left[{x}{,}{y}{-}{3}\right]{,}\left[{x}{-}{1}{,}{y}{+}{1}\right]{,}\left[{x}{,}{y}\right]\right]$ (5)

Now remove points which cancel the following $H$.

 > $H≔{y}^{3}-y$
 ${H}{≔}{{y}}^{{3}}{-}{y}$ (6)

First, build the common solution set of $F$ and $G$ as a constructible set and also build one with $H$.

 > $\mathrm{rcH}≔\mathrm{Chain}\left(\left[H\right],\mathrm{Empty}\left(R\right),R\right)$
 ${\mathrm{rcH}}{≔}{\mathrm{regular_chain}}$ (7)
 > $\mathrm{cs1}≔\mathrm{ConstructibleSet}\left(\left[\mathrm{RegularSystem}\left(\mathrm{rcH},R\right)\right],R\right)$
 ${\mathrm{cs1}}{≔}{\mathrm{constructible_set}}$ (8)
 > $\mathrm{cs2}≔\mathrm{ConstructibleSet}\left(\mathrm{map}\left(\mathrm{RegularSystem},\mathrm{dec},R\right),R\right)$
 ${\mathrm{cs2}}{≔}{\mathrm{constructible_set}}$ (9)

Then use Difference to find a new constructible set which encodes those points that cancel $F$ and $G$, but do not cancel $H$.

 > $\mathrm{cs3}≔\mathrm{Difference}\left(\mathrm{cs2},\mathrm{cs1},R\right)$
 ${\mathrm{cs3}}{≔}{\mathrm{constructible_set}}$ (10)

You can check the result using the Info command: cs2 consists of six points, and five of them cancel $H$.

 > $\mathrm{Info}\left(\mathrm{cs2},R\right)$
 $\left[\left[{x}{-}{2}{,}{y}{+}{1}\right]{,}\left[{1}\right]\right]{,}\left[\left[{x}{-}{1}{,}{y}{-}{1}\right]{,}\left[{1}\right]\right]{,}\left[\left[{x}{+}{1}{,}{y}{-}{1}\right]{,}\left[{1}\right]\right]{,}\left[\left[{x}{,}{y}{-}{3}\right]{,}\left[{1}\right]\right]{,}\left[\left[{x}{-}{1}{,}{y}{+}{1}\right]{,}\left[{1}\right]\right]{,}\left[\left[{x}{,}{y}\right]{,}\left[{1}\right]\right]$ (11)

The set cs3 consists of a single point which does not cancel $H$.

 > $\mathrm{Info}\left(\mathrm{cs3},R\right)$
 $\left[\left[{x}{,}{y}{-}{3}\right]{,}\left[{1}\right]\right]$ (12)

An example on semi-algebraic set difference: to check whether or not two formula/conditions are equivalent. # Semi-algebraic Difference, verifying results

 > $\mathrm{C1}≔\left[0
 > $\mathrm{C2}≔\left[0
 > $\mathrm{S1}≔\left[\mathrm{C1},\mathrm{C2}\right]$
 ${\mathrm{S1}}{≔}\left[\left[{0}{<}{a}{,}{0}{<}{b}{,}{0}{<}{c}{,}{a}{<}{b}{+}{c}{,}{b}{<}{a}{+}{c}{,}{c}{<}{a}{+}{b}{,}{{a}}^{{2}}{+}{{b}}^{{2}}{-}{{c}}^{{2}}{\le }{0}\right]{,}\left[{0}{<}{a}{,}{0}{<}{b}{,}{0}{<}{c}{,}{a}{<}{b}{+}{c}{,}{b}{<}{a}{+}{c}{,}{c}{<}{a}{+}{b}{,}{c}{}{\left({{a}}^{{2}}{+}{{b}}^{{2}}{-}{{c}}^{{2}}\right)}^{{2}}{<}{a}{}{{b}}^{{2}}{}\left({-}{{a}}^{{2}}{+}{2}{}{a}{}{c}{+}{{b}}^{{2}}{-}{{c}}^{{2}}\right)\right]\right]$ (13)
 > $\mathrm{S2}≔\left[a-c<0,0
 ${\mathrm{S2}}{≔}\left[{a}{-}{c}{<}{0}{,}{0}{<}{a}{,}{0}{<}{b}{,}{0}{<}{c}{,}{a}{<}{b}{+}{c}{,}{b}{<}{a}{+}{c}{,}{c}{<}{a}{+}{b}\right]$ (14)
 > $R≔\mathrm{PolynomialRing}\left(\left[a,b,c\right]\right):$
 > $\mathrm{dec1}≔\mathrm{map}\left(\mathrm{op},\mathrm{map}\left(\mathrm{RealTriangularize},\mathrm{S1},R\right)\right)$
 ${\mathrm{dec1}}{≔}\left[{\mathrm{regular_semi_algebraic_system}}{,}{\mathrm{regular_semi_algebraic_system}}{,}{\mathrm{regular_semi_algebraic_system}}\right]$ (15)
 > $\mathrm{dec2}≔\mathrm{RealTriangularize}\left(\mathrm{S2},R\right)$
 ${\mathrm{dec2}}{≔}\left[{\mathrm{regular_semi_algebraic_system}}\right]$ (16)

Verify dec1 = dec2 as set of points by Difference.

 > $\mathrm{Difference}\left(\mathrm{dec1},\mathrm{dec2},R\right)$
 $\left[\right]$ (17)
 > $\mathrm{Difference}\left(\mathrm{dec2},\mathrm{dec1},R\right)$
 $\left[\right]$ (18)

References

 Chen, C.; Golubitsky, O.; Lemaire, F.; Moreno Maza, M.; and Pan, W. "Comprehensive Triangular Decomposition". Proc. CASC 2007, LNCS, Vol. 4770: 73-101. Springer, 2007.
 Chen, C.; Davenport, J.-D.; Moreno Maza, M.; Xia, B.; and Xiao, R. "Computing with semi-algebraic sets represented by triangular decomposition". Proceedings of 2011 International Symposium on Symbolic and Algebraic Computation (ISSAC 2011), ACM Press, pp. 75--82, 2011.

Compatibility

 • The RegularChains[SemiAlgebraicSetTools][Difference] command was introduced in Maple 16.
 • The lrsas1 and lrsas2 parameters were introduced in Maple 16.