File: PseudomonomialPrimaryDecomposition.m2

package info (click to toggle)
macaulay2 1.24.11%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 171,648 kB
  • sloc: cpp: 107,850; ansic: 16,307; javascript: 4,188; makefile: 3,947; lisp: 682; yacc: 604; sh: 476; xml: 177; perl: 114; lex: 65; python: 33
file content (1185 lines) | stat: -rw-r--r-- 34,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
-- -*- coding: utf-8 -*-
newPackage(
    	  "PseudomonomialPrimaryDecomposition",
	  Headline => "Primary decomposition of square free pseudomonomial ideals",
   	  Version => "0.3",
	  Date => "January, 2022",
	  Authors => {{
		    Name => "Alan A. Veliz-Cuba",
		    Email => "avelizcuba1@udayton.edu",
		    HomePage => "https://sites.google.com/site/alanvelizcuba/"
		    }},
	  DebuggingMode => false,
	  Keywords => {"Commutative Algebra"},
	  Certification => {
	       "journal name" => "The Journal of Software for Algebra and Geometry",
	       "journal URI" => "https://msp.org/jsag/",
	       "article title" => "Primary decomposition of squarefree pseudomonomial ideals",
	       "acceptance date" => "18 July 2022",
	       "published article URI" => "https://msp.org/jsag/2022/12-1/p04.xhtml",
	       "published article DOI" => "10.2140/jsag.2022.12.27",
	       "published code URI" => "https://msp.org/jsag/2022/12-1/jsag-v12-n1-x04-PseudomonomialPrimaryDecomposition.m2",
	       "repository code URI" => "https://github.com/Macaulay2/M2/blob/master/M2/Macaulay2/packages/PseudomonomialPrimaryDecomposition.m2",
	       "release at publication" => "4c86bb7c1f80a36c5e2ce6786863f5702c13ddda",	    -- git commit number in hex
	       "version at publication" => "0.3",
	       "volume number" => "12",
	       "volume URI" => "https://msp.org/jsag/2022/12-1/"
	       }
	  )


export({"isSquarefreePseudomonomialIdeal", "primaryDecompositionPseudomonomial","isPseudomonomial"})


-------------------------------------------------------------------
-- subroutines to translate between polynomials and bitwise form --
-------------------------------------------------------------------


-- obtains the generators of a ring in which an ideal lives
-- Input:
-- an ideal I
-- Output:
-- A list of generators of R
getAllVariables = I -> gens ring I;


-- define the zero polynomial in bitwise form
-- this is added only for clarity in the algorithm
zeropolynomial := {-1,-1};


-- transforms a square free pseudomonomial to bitwise string...
-- for example, x1*(x3-1)*x4 will be converted to {1001,0100} = {9,4}
-- Input:
-- Square free pseudomonomial P in polynomial form
-- Output:
-- A list of the form {num1,num2} (so-called bitwise form of P)
fromPoly2Bit = (P,allVariables) -> ( 
    if P==0 then return zeropolynomial;
    factoredP := factor P; 
    -- initialize bitwise form {0,0}
    bitwisePOS := 0; 
    bitwiseNEG := 0;
    -- add factors to bitwise form
    for i to #factoredP-1 do ( 
        -- evaluate ith factor and skip units
        base := value factoredP#i; 
        if isUnit base then continue;
        -- find variable of ith factor and position in allVariables
        xi := (support base)_0; 
        pos := position(allVariables,x -> x === xi);
        -- make position of variable equal to 1 in bitwise format (adding 2^pos)
        if   xi === base then bitwisePOS = bitwisePOS | (1 << pos);
        if xi-1 === base then bitwiseNEG = bitwiseNEG | (1 << pos);
    );
    {bitwisePOS,bitwiseNEG}
)


-- finds log in base 2
-- Input:
-- a number m
-- Output:
-- a natural number
-- log2 = m -> round(log_2 m); -- OLD CODE
log2 = m -> (
    ans := 0;
    while (1 << ans) < m do ans = ans+1;
    ans
)


-- transforms a polynomial in bitwise form to polynomial form
-- Input:
-- (B,allVariables), B must be of the form {2^(k-1),0} or {0,2^(k-1)}
-- Output:
-- polynomial polyB of the form xk or xk-1
fromBit2Poly = (B,allVariables) -> ( 
    polyB := 1;
    if B_0 != 0 then polyB = allVariables_(log2(B_0));
    if B_1 != 0 then polyB = allVariables_(log2(B_1))-1;
    polyB
)



------------------------------------------------------------------------------
-- subroutines for intermediate steps of primary decomposition ---------------
-- NOTE: In ALL subroutines here the polynomial inputs are in bitwise form ---
------------------------------------------------------------------------------


-- determines if a square free pseudomonomial divides another
-- Input:
-- Two square free pseudomonomials in bitwise form B1, B2
-- Output:
-- true or false
isDivisor = (B1,B2) -> (
    -- we use the fact that P1|P2 if and only if
    -- product of factors xi in P1 divides the product of factors xi in P2 
    -- and
    -- product of factors xi-1 in P1 divides the product of factors xi-1 in P2.
    -- This is equivalent to B1_0<=B2_0 and B1_1<=B2_1 (bitwise)
    -- So we use the Boolean rule a<=b iff a&b=a (bitwise)
    (B1_0)&(B2_0) == B1_0 and (B1_1)&(B2_1) == B1_1
)


-- sets zi=0 in a square free pseudomonomial
-- Input:
-- A square free pseudomonomial ideal in bitwise form, and zi=xi-0/1 in bitwise form
-- Output:
-- A square free pseudomonomial ideal G where zi was set to 0 and zi-1 was set to 1 (in bitwise form)
---- Uses the functions:
---- isDivisor
---- Uses the constants
---- zeropolynomial
setEqualtoZero = (G,zi) -> (
    apply(G, B -> (   
        -- if zi divides B then zi=0 makes B=0 
        if isDivisor(zi,B) then return zeropolynomial;
        -- if zi-1 divides B then zi=0 removes zi-1 from B
        if (zi_0)&(B_1) == (zi_0) and 0 != zi_0 then return {B_0,B_1-zi_0};
        if (zi_1)&(B_0) == (zi_1) and 0 != zi_1 then return {B_0-zi_1,B_1};
        -- if neither zi nor zi-1 divide B then B is unchanged
        return B;  
    ))
)


-- finds the minimal elements according to a partial order
-- Input:
-- A list {G,ord}
-- G is a list and ord is a partial order
-- Output:
-- A set, minG
findMinimal = (G,ord) -> (
    minG := {};
    for i to #G-1 do (
        -- if g<=Gi for some g in minG then Gi cannot be minimal
        if any(minG, g-> ord(g,G_i)) then continue; 
        -- if g<!=Gi for all g in minG then Gi may be minimal
        -- and we remove from minG all g's such that Gi<=g 
        minG = select(minG, g -> not ord(G_i,g));
        minG = append(minG, G_i);
    );
    minG
)


-- removes redundant generators in the ideal <G>
-- Input:
-- list G of square free pseudomonomials in bitwise form
-- Output:
-- list with redundant generators removed in bitwise form
---- Uses the functions
---- findMinimal
---- isDivisor
---- Uses the constants
---- zeropolynomial
simplifyGens = G -> (
    -- remove zero polynomials and polynomials that are multiples of others
    redG := select(G,B -> B != zeropolynomial);
    findMinimal(unique redG,isDivisor)
)


-- determines if square free pseudomonomial is linear nonconstant ( zi=xi-0/1)
-- Input:
-- Square free pseudomonomial in bitwise form
-- Output:
-- true or false
isLinearPseudomonomial = B-> (
    -- if polynomial is 1 then false
    -- (B={0,0} in bitwise form)
    if (B_0) == 0 and (B_1) == 0 then return false;
    -- if polynomial is xi or xi-1 then true
    --  ({2^i,0} or {0,2^i} in bitwise form)
    if (B_0)&(-1+B_0) == 0 and B_1 == 0 then return true;
    if (B_1)&(-1+B_1) == 0 and B_0 == 0 then return true;
    false
)


-- finds all the factors of a square free pseudomonomial P (in bitwise form B)
-- Input:
-- Square free pseudomonomial in bitwise form
-- Output:
-- A list of square free pseudomonomials, each in bitwise form
getFactors = B -> (
    allfactors := {}; 
    leftoverB := B; 
    i := 0;
    while (leftoverB_0) != 0 or (leftoverB_1) != 0 do (
        -- check if xi or xi-1 is a factor
        pi := 1 << i;
        -- checking if xi is a factor (using bitwise form)
        if (leftoverB_0)&pi == pi then (
            allfactors = append(allfactors,{pi,0});
            leftoverB = {leftoverB_0-pi,leftoverB_1};
        );  
        -- checking if xi-1 is a factor (using bitwise form)  
        if (leftoverB_1)&pi == pi then (
            allfactors = append(allfactors,{0,pi});
            leftoverB = {leftoverB_0,leftoverB_1-pi};
        ) ;
        i = i+1;
    );
    allfactors
)


-- determines if a square free pseudomonomial ideal is generated by linear polynomials
-- Input:
-- list of generators of a square free pseudomonomial ideal in bitwise form
-- Output:
-- true or false
---- Uses the functions:
---- isLinearPseudomonomial
isPrimaryPseudomonomial = G -> (
    not any(G, B -> not isLinearPseudomonomial B)
    -- if any(G, B -> not isLinearPseudomonomial B) then return false;
    -- true
)


-- determines if a square free pseudomonomial ideal has gens xi and xi-1
-- Input:
-- list of generators of a square free pseudomonomial ideal in bitwise form
-- Output:
-- true or false
---- Uses the functions:
---- isLinearPseudomonomial
isProperPseudomonomial = G -> (
    if G == {{0,0}} then return false;
    -- look for generators xi and xi-1
    -- ({2^i,0} and {0,2^i} in bitwise form)
    for i to #G-1 do (
        if isLinearPseudomonomial(G_i) then (
            for j from i+1 to #G-1 do (
                if isLinearPseudomonomial(G_j) then (
                    if (G_i)_0 == (G_j)_1 and (G_i)_1 == (G_j)_0 then return false;
                )
            )
        )
    );
    true
)


-- writes a square free pseudomonomial ideal as an intersection
-- Input:
-- list G of generators of I in bitwise form
-- Output:
-- a list G1,...,Gm of polynomials (in bitwise form) where the intersection(G1,...,Gm)=I 
---- Uses the functions:
---- isLinearPseudomonomial
---- getFactors
---- setEqualtoZero
factorIdeal = G -> (
    --check if there is a polynomial of degree 2 or higher
    nonlinearpolynomials := select(1,G, B -> not isLinearPseudomonomial B);
    if nonlinearpolynomials == {} then return {G};
    -- use square free pseudomonomial of degree>=2: z1z2...zk
    B := nonlinearpolynomials_0;
    allfactors := getFactors(B);
    -- find  and simplify <G>=<G,z1>inter...inter<G,zk> 
    apply(allfactors, Bi -> append(setEqualtoZero(G,Bi),Bi))
)


-- finds the primary decomposition of a square free pseudomonomial ideal in bitwise form
-- Input:
-- list of generators of I in bitwise form
-- Output:
-- list of generators of primary ideals in bitwise form
---- Uses the following functions
---- isProperPseudomonomial
---- factorIdeal
---- simplifyGens
---- isPrimaryPseudomonomial
---- findMinimal
bitwisePD = G -> (    
    -- first check if ideal has generators xi and xi-1
    if not isProperPseudomonomial G then return {};
    -- initialize primary decomposition (P) and remaining ideals in the intersection (D)
    P := {}; 
    D := {G};
    while D != {} do (
        -- write <G>=<G,z1>inter...inter<G,zk>
        -- for each G in D
        DI := apply(D, GI -> (factorIdeal GI)/simplifyGens );
        -- combine all intersections into a single intersection
        ---- List + List := (X,Y) -> join(X,Y); -- old line 1
        ---- D = sum DI;                       -- old line 2
        --D = {}; scan(DI,GI -> D = join(D,GI));
        D = flatten DI;
        -- omit ideals that are generated by the polynomial 1
        D = select(D, GI -> isProperPseudomonomial GI);
        -- if ideal is primary save in G, if not primary save in D
        P = join(P, select(D, GI -> isPrimaryPseudomonomial GI) );
        D = select(D, GI -> not isPrimaryPseudomonomial GI);
    );
    findMinimal(P,isSubset)
)


-- determines if a polynomial is square free pseudomonomial
-- Input:
-- Polynomial P in bitwise form
-- Output:
-- true or false
isPseudomonomial = P -> ( 
    -- check if polynomial is a unit or zero
    if P == 0 then return false;
    if isUnit P then return true;
    -- factor polynomial P and initialize the support list
    factoredP := factor P;
    allSupport := {};
    -- test if some factor is not of the form (xi-a) where a=0 or 1
    for i to #factoredP-1 do ( 
        -- evaluate ith factor
        base := value factoredP#i; 
        -- if factor is not a unit but is a constant -> not a square free pseudomonomial
        if isUnit base then continue;
        if isConstant base then return false;
        -- find if factor is equal to xi or xi-1
        suppi := support base;
        if #suppi >= 2 then return false;
        if suppi_0 =!= base and suppi_0-1 =!= base then return false;
        allSupport = append(allSupport,suppi_0);
    );
    -- find if there are factors xi, xi-1 simultaneously -> not a square free pseudomonomial
    #(support P) == #allSupport
    -- if #(support P) != #allSupport then return false;
    -- true
)



--------------------------------
-- exported functions --
--------------------------------

-- determines if an ideal is square free pseudomonomial
-- Input:
-- Ideal I in polynomial form
-- Output:
-- true or false
---- Uses the functions:
---- isPseudomonomial
isSquarefreePseudomonomialIdeal = method()
isSquarefreePseudomonomialIdeal Ideal := Boolean => I -> (
    -- remove zero polynomials
    allgens := select(I_*, P -> P != 0); 
    -- look for polynomials that are not square free pseudomonomials
    --for i to #allgens-1 do (
    --    if not isPseudomonomial(allgens_i) then return false;
    --);
    --true
    all(allgens, isPseudomonomial)   
)


-- computes the primary decomposition of a square free pseudomonomial ideal
-- Input:
-- Square free pseudomonomial ideal in polynomial form
-- Output:
-- list of primary ideals in polynomial form
---- Uses the following functions:
---- isSquarefreePseudomonomialIdeal
---- fromPoly2Bit
---- isDivisor
---- findMinimal
---- bitwisePD
---- fromBit2Poly
---- getAllVariables
primaryDecompositionPseudomonomial = method()
primaryDecompositionPseudomonomial Ideal := I -> (
    -- looking for errors
    -- if class I =!= Ideal then error "Input must be a square free pseudomonomial ideal.";
    if not isSquarefreePseudomonomialIdeal(I) then error "Not a square free pseudomonomial ideal.";
    -- finding nonzero generators of ideal
    gensI := select (I_*, P -> P != 0); 
    -- if zero ideal just return trivial primary decomposition
    if gensI == {} then return {I};
    -- transform to bitwise form
    allVariables := getAllVariables I;
    G := apply(gensI, P -> fromPoly2Bit(P,allVariables) );
    -- remove redundant generators
    G = findMinimal(G, isDivisor);
    -- find primary decomposition using bitwise notation
    PD := bitwisePD G;
    -- go back to polynomial notation
    -- print allVariables;
    -- PDpolyform := apply( PD, PDi -> fromBit2Poly(PDi,allVariables) );
    apply( PD, PDi -> ideal apply(PDi, P-> fromBit2Poly(P,allVariables) ))
)



-------------------
-- Documentation --
-------------------

beginDocumentation()

doc ///
Key
  PseudomonomialPrimaryDecomposition
Headline
  primary decomposition of a square free pseudomonomial ideal
Description
  Text
    A pseudomonomial is a polynomial in K[x1,x2,...,xn] that can be written as a product of factors of the form (xi-ai)^ni, where ai is 0 or 1.  The xi's in the product should be distinct. A square free pseudomonomial ideal is an ideal generated by pseudomonomials such that each ni=1.

    This package finds the primary decomposition of square free pseudomonomial ideals. It also determines if an ideal is a pseudomonomial ideal.

    For example, x1^2*(x3-1) is a pseudomonomial, but not square free. The polynomial x1*(x3-1) is a square free pseudomonomial. The ideal ideal(x1*(x3-1),(x1-1)*(x2-1)*x4,x1*x2*x3,(x1-1)*x2*(x5-1)) is a square free pseudomonomial ideal.
  Example
    R = ZZ/2[x1,x2,x3,x4,x5];
    I = ideal(x1*(x3-1),(x1-1)*(x2-1)*x4,x1*x2*x3,(x1-1)*x2*(x5-1));
    isSquarefreePseudomonomialIdeal I
    C = primaryDecompositionPseudomonomial I
    intersect C == I    
///

document {
     Key => {primaryDecompositionPseudomonomial, (primaryDecompositionPseudomonomial, Ideal)},
     Headline => "primary decomposition of a square free pseudomonomial ideal",
     SeeAlso => {"Macaulay2Doc::primaryDecomposition"},
     Usage => "primaryDecompositionPseudomonomial(I)",
     Inputs => { 
	  "I" => {ofClass Ideal, ", a square free pseudomonomial ideal"}
	  },
     Outputs => {
	  "L" => {ofClass List, ", list L={P1,P2,...,Pk} of primary ideals with intersection equal to I"}
	  },
     Caveat => {
	  "The algorithm finds a decomposition even if the base field is not QQ or ZZ/p"
	  },
      "The algorithm is implemented bitwise (using Macaulay2 bitwise operations), which makes calculations faster.",
     " Examples:",
     EXAMPLE lines ///
          R=ZZ/2[x1,x2,x3,x4,x5];
          I = ideal(x1*x2,x3*x4,x5);
     	  primaryDecompositionPseudomonomial(I) 
          ///,
     EXAMPLE lines ///
          R=QQ[x1,x2,x3,x4,x5];
          I = ideal(x1*(x2-1),(x3-1)*x4,x5);
          primaryDecompositionPseudomonomial(I) 
           ///,
     EXAMPLE lines ///         
          R=ZZ/2[x1,x2];
          I = ideal(x1*(x2-1),(x1-1)*(x2-1),x1*x2,(x1-1)*x2);
          primaryDecompositionPseudomonomial(I) 
          ///,
     EXAMPLE lines ///
          R=QQ[x1,x2,x3,x4,x5];
          I = ideal(x5,x1*(x3-1)*(x5-1));
          primaryDecompositionPseudomonomial(I) 
	  ///,
     EXAMPLE lines ///
          R=ZZ/3[x1,x2];
          I = ideal(x5,(x3-1));
          primaryDecompositionPseudomonomial(I) 
	  ///
     }

document {
     Key => {isSquarefreePseudomonomialIdeal, (isSquarefreePseudomonomialIdeal, Ideal)},
     Headline => "determine if an ideal is a square free pseudomonomial ideal",
     SeeAlso => {monomials, monomialIdeal},
     Usage => "isSquarefreePseudomonomialIdeal(I)",
     Inputs => { 
	  "I" => {ofClass Ideal, ", an ideal"}
	  },
     Outputs => {
	  Boolean => {"true or false"}
	  },
     Caveat => {
	  "The algorithm disregards the base field. So, ideal(-x1) is a square free pseudomonomial ideal in F[x1] for F=ZZ,ZZ/p,QQ, whereas ideal(-x1) is not a monomial ideal when F=ZZ."
	  },
      "An ideal is a square free pseudomonomial ideal if its generators are square free pseudomonomials. A square free pseudomonomial is a polynomial of the form P=z1*z2*...*zk such that zi is either xi or xi-1 and a variable can only appear once in P. For example, x1*x3, x1*(x2-1)*(x3-1) are square free pseudomonomial and x2*x3^2, x1*(x1-1)*(x3-1) are not.",
     EXAMPLE lines ///
          R=ZZ/2[x1,x2,x3,x4,x5]; 
          I = ideal(x1*x2,x3*x4,x5);
     	  isSquarefreePseudomonomialIdeal(I) 
          ///,
     EXAMPLE lines ///          
          R=ZZ/2[x1,x2];
          I = ideal(x1*(x2-1),(x1-1)*(x2-1),x1*x2,(x1-1)*x2);
          isSquarefreePseudomonomialIdeal(I) 
	  ///,
     EXAMPLE lines ///          
          R=ZZ/3[x1,x2];
          I = ideal(x1,x2-1);
          isSquarefreePseudomonomialIdeal(I) 
	  ///,
     EXAMPLE lines ///          
          R=QQ[x1,x2,x3,x4,x5];
          I = ideal(x1*(x1-1),(x3-1)*x4,x5);
          not isSquarefreePseudomonomialIdeal(I)
          ///,
     EXAMPLE lines ///          
          R=QQ[x1,x2,x3,x4,x5];
          I = ideal(x1*(x5-1),(x3-1)*x4^2,x5);
          isSquarefreePseudomonomialIdeal(I) 
          ///
     }

------------------------------------------------------------------------------
--- testing internal functions fromPoly2Bit, fromBit2Poly, log2,         -----
--- findMinimal, isLinearPseudomonomial, getFactors (internal functions) -----
------------------------------------------------------------------------------


------ testing fromPoly2Bit----------
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x1*x2,gens R)=={3,0});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x3*x4,gens R)=={12,0});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x5,gens R)=={16,0});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x1*(x2-1),gens R)=={1,2});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit((x3-1)*x4, gens R)=={8,4});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit((x1-1)*(x2-1), gens R)=={0,3});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x1*(x3-1)*(x5-1),gens R)=={1,20});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(x2-1,gens R)=={0,2});
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(fromPoly2Bit(1_R,gens R)=={0,0});
///

------ testing fromPoly2Bit----------
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(x1==fromBit2Poly({1,0},gens R));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(x2==fromBit2Poly({2,0},gens R));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(x5==fromBit2Poly({16,0},gens R));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(x2-1==fromBit2Poly({0,2},gens R));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(x5-1==fromBit2Poly({0,16},gens R));
///

------- testing isDivisor
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B1=fromPoly2Bit(x1,gens R); 
B2=fromPoly2Bit(x1*x2, gens R);
assert(isDivisor(B1,B2));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B1=fromPoly2Bit(x1*x2,gens R); 
B2=fromPoly2Bit(x1, gens R);
assert(not isDivisor(B1,B2));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B1=fromPoly2Bit(x2-1,gens R); 
B2=fromPoly2Bit((x1-1)*(x2-1), gens R);
assert(isDivisor(B1,B2));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B1=fromPoly2Bit(x1*(x5-1),gens R); 
B2=fromPoly2Bit(x1*(x3-1)*(x5-1), gens R);
assert(isDivisor(B1,B2));
///

------- testing findMinimal (with respect to inclusion, ie isSubset)
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
G={set{2,1},set{2,3},set{2,1,3},set{4,5,3,2},set{5}};
assert(set findMinimal(G,isSubset) === set{set{1,2},set{5},set{2,3}})
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
G={set{2},set{2,3},set{2,1,3},set{4,5,3,2,1}};
assert(set findMinimal(G,isSubset) === set{set{2}})
///

-------- testing isLinearPseudomonomial
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(isLinearPseudomonomial(fromPoly2Bit(x1,gens R)));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(not isLinearPseudomonomial(fromPoly2Bit(x1*x2,gens R)));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(isLinearPseudomonomial(fromPoly2Bit(x1-1,gens R)));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(not isLinearPseudomonomial(fromPoly2Bit((x1-1)*(x2-1),gens R)));
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
assert(not isLinearPseudomonomial(fromPoly2Bit((x1-1)*x2,gens R)));
///


--------- testing getFactors
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B=fromPoly2Bit(x1*(x3-1)*(x5-1),gens R);
B1=fromPoly2Bit(x1,gens R); 
B2=fromPoly2Bit(x3-1,gens R);
B3=fromPoly2Bit(x5-1,gens R);
assert(set getFactors(B) === set{B1,B2,B3})
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
B=fromPoly2Bit(x2,gens R);
B1=fromPoly2Bit(x2,gens R); 
assert(set getFactors(B) === set{B1})
///

--------testing setEqualtoZero
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x1*(x3-1)*x5,x2*x3);
B1=fromPoly2Bit(x1*(x3-1)*x5,gens R);
B2=fromPoly2Bit(x2*x3*x4,gens R);
Idealbitform={B1,B2};
zi=fromPoly2Bit(x3,gens R);
anscode = setEqualtoZero(Idealbitform,zi);
ansmanual = {fromPoly2Bit(x1*(0-1)*x5,gens R),fromPoly2Bit(x2*0*x4,gens R)};
assert(set anscode === set ansmanual)
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x1*(x3-1)*x5,x2*x3*x4);
B1=fromPoly2Bit(x1*(x3-1)*x5,gens R);
B2=fromPoly2Bit(x2*x3*x4,gens R);
Idealbitform={B1,B2};
zi=fromPoly2Bit(x1-1,gens R);
anscode = setEqualtoZero(Idealbitform,zi);
ansmanual = {fromPoly2Bit(1*(x3-1)*x5,gens R),fromPoly2Bit(x2*x3*x4,gens R)};
assert(set anscode === set ansmanual)
///

---------- testing simplifyGens
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x1*(x3-1)*x5,x2*x3,x2,x1*(x3-1)*x4*x5,0);
B1=fromPoly2Bit(x1*(x3-1)*x5,gens R);
B2=fromPoly2Bit(x2*x3,gens R);
B3=fromPoly2Bit(x2,gens R);
B4=fromPoly2Bit(x1*(x3-1)*x4*x5,gens R);
B5=fromPoly2Bit(0,gens R);
Idealbitform={B1,B2,B3,B4,B5};
assert(set simplifyGens Idealbitform === set {B1,B3})
///

--------- testing isPrimaryPseudomonomial
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x1*(x3-1),x2,x4);
B1=fromPoly2Bit(x1*(x3-1),gens R);
B2=fromPoly2Bit(x2,gens R);
B3=fromPoly2Bit(x4,gens R);
Idealbitform={B1,B2,B3};
assert(not isPrimaryPseudomonomial Idealbitform)
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x3-1,x2,x4);
B1=fromPoly2Bit(x3-1,gens R);
B2=fromPoly2Bit(x2,gens R);
B3=fromPoly2Bit(x4,gens R);
Idealbitform={B1,B2,B3};
assert(isPrimaryPseudomonomial Idealbitform)
///


------ testing isProperPseudomonomial
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x3-1,x3,x4*x5);
B1=fromPoly2Bit(x3-1,gens R);
B2=fromPoly2Bit(x3,gens R);
B3=fromPoly2Bit(x4*x5,gens R);
Idealbitform={B1,B2,B3};
assert(not isProperPseudomonomial Idealbitform)
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x3-1,x2,x4*x5);
B1=fromPoly2Bit(x3-1,gens R);
B2=fromPoly2Bit(x2,gens R);
B3=fromPoly2Bit(x4*x5,gens R);
Idealbitform={B1,B2,B3};
assert(isProperPseudomonomial Idealbitform)
///

------- testing factorIdeal
TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x3-1,x2,x4*x5);
B1=fromPoly2Bit(x3-1,gens R);
B2=fromPoly2Bit(x2,gens R);
B3=fromPoly2Bit(x4*x5,gens R);
Idealbitform={B1,B2,B3};
anscode=(factorIdeal Idealbitform)/simplifyGens
ansmanual={{B1,B2,fromPoly2Bit(x4,gens R)},{B1,B2,fromPoly2Bit(x5,gens R)}}
assert(set anscode/set=== set ansmanual/set)
///

TEST ///
debug needsPackage "PseudomonomialPrimaryDecomposition"
R=ZZ/2[x1,x2,x3,x4,x5];
I=ideal(x3-1,x2,x3*x5);
B1=fromPoly2Bit(x3-1,gens R);
B2=fromPoly2Bit(x2,gens R);
B3=fromPoly2Bit(x3*x5,gens R);
Idealbitform={B1,B2,B3};
anscode=(factorIdeal Idealbitform)/simplifyGens
ansmanual={{fromPoly2Bit(1,gens R)},{B1,B2,fromPoly2Bit(x5,gens R)}}
assert(set anscode/set=== set ansmanual/set)
///



---------------------------------------------------
--- testing primaryDecompositionPseudomonomial-----
---------------------------------------------------

TEST ///
R=ZZ/2[x1,x2,x3,x4,x5];
I = ideal(x1*x2,x3*x4,x5);
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/3[x1,x2,x3,x4,x5];
I = ideal(x1*x2,x3*x4,x5);
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = QQ[x1,x2,x3,x4,x5];
I = ideal(x1*x2,x3*x4,x5);
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/2[x1,x2,x3,x4,x5];
I = ideal(x1*(x2-1),(x3-1)*x4,x5)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/3[x1,x2,x3,x4,x5];
I = ideal(x1*(x2-1),(x3-1)*x4,x5)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = QQ[x1,x2,x3,x4,x5];
I = ideal(x1*(x2-1),(x3-1)*x4,x5)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/2[x1,x2];
I = ideal(x1*(x2-1),(x1-1)*(x2-1),x1*x2,(x1-1)*x2)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/3[x1,x2];
I = ideal(x1*(x2-1),(x1-1)*(x2-1),x1*x2,(x1-1)*x2)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = QQ[x1,x2];
I = ideal(x1*(x2-1),(x1-1)*(x2-1),x1*x2,(x1-1)*x2)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R=ZZ/2[x1,x2,x3,x4,x5];
I = ideal(x5,x1*(x3-1)*(x5-1));
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R=ZZ/3[x1,x2,x3,x4,x5];
I = ideal(x5,x1*(x3-1)*(x5-1));
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R=QQ[x1,x2,x3,x4,x5];
I = ideal(x5,x1*(x3-1)*(x5-1));
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/2[x1,x2];
I = ideal(x1,x2-1)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = ZZ/3[x1,x2];
I = ideal(x1,x2-1)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = QQ[x1,x2];
I = ideal(x1,x2-1)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///

TEST ///
R = QQ[x1,x2];
I = ideal(x1,x2-1)
PD = primaryDecompositionPseudomonomial(I);
PDold = primaryDecomposition(I);
PDsorted = sort(apply(PD, J -> sort(J_*)));
PDoldsorted = sort(apply(PDold, J -> sort(J_*)));
assert ( PDsorted == PDoldsorted )
///



------------------------------------------------
--- testing isSquarefreePseudomonomialIdeal-----
------------------------------------------------


TEST ///
R = ZZ/2[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/3[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = QQ[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(4)[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(9)[x1,x2];
I = ideal(x1,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/2[x1,x2];
I = ideal(x1^2,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = ZZ/3[x1,x2];
I = ideal(x1,x2*(x2-1))
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = QQ[x1,x2];
I = ideal(x1,x2*(x2-1))
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = ZZ[x1,x2];
I = ideal(x1,x2*(x2-1))
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = GF(4)[x1,x2];
I = ideal(x1,x2*(x2-1))
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = GF(9)[x1,x2];
I = ideal(x1,x2*(x2-1))
assert ( isSquarefreePseudomonomialIdeal I == false )
///

TEST ///
R = ZZ/2[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/3[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = QQ[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(4)[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(9)[x1,x2,x3,x4];
I = ideal(x1*(x2-1),x3*x4,x2-1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/2[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/3[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = QQ[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(4)[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(9)[x1,x2,x3,x4];
I = ideal(x1*(x2-1)*x3*(x4-1))
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = ZZ/2[x1,x2,x3,x4];
I = ideal(1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = QQ[x1,x2,x3,x4];
I = ideal(1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///

TEST ///
R = GF(9)[x1,x2,x3,x4];
I = ideal(1)
assert ( isSquarefreePseudomonomialIdeal I == true )
///


end 

-- installPackage("PseudomonomialPrimaryDecomposition"); check(PseudomonomialPrimaryDecomposition)