4 /* Test ability of parser to recognize curly braces notation on input.
14 [set (b, c), set (a)];
17 [set (a, b, c), set ()];
20 set (set (set (set (a, b, c))));
22 {a, b, 2^{c, d, e}, mogrify ({x, y, [{}]}, {[]})};
23 set (a, b, 2^set (c, d, e), mogrify (set (x, y, [set ()]), set ([])));
25 /* 1-d output should contain curly braces.
31 string (set (a, b, set (c, d, set (e))));
73 adjoin(false,set(false));
76 adjoin(false,set(true));
79 adjoin(a, set(set()));
85 adjoin(set(a),set(a));
97 errcatch(adjoin(a,b));
109 disjoin(0,set(0,1,2));
112 disjoin(1,set(0,1,2));
115 disjoin(2,set(0,1,2));
127 set(set(a,b),set(a,b),z);
139 union(set(false),set());
145 union(set(8,8,1932));
148 union(set(a),set(a,b),set(a,b,c));
154 union(set(a),set(b),set(c));
157 union(set(set(a)),set(a))$
160 errcatch(union(set(a),set(b),x));
166 union(set(),set(set()));
169 setdifference(set(a,b),set());
172 setdifference(set(a,b),set(a));
175 setdifference(set(a,b),set(b));
178 setdifference(set(a,b),set(x));
181 setdifference(set(a,b),set());
184 setdifference(set(),set(x));
187 setdifference(set(a),set(x));
190 setdifference(set(a,b),set(x));
193 errcatch(setdifference(a,b));
196 errcatch(setdifference(set(a),b));
199 errcatch(setdifference(a,set(b)));
202 errcatch(intersection());
205 intersection(set(x));
208 intersection(set(),set());
211 intersection(set(set()),set());
214 intersection(set(set()),set(set(),set(set())));
217 intersection(set(a,b),set(a,b,c));
220 intersection(set(a,b),set(x,y,z));
223 intersection(set(a,b,c),set(a,y,x),set(z,a),set(p,q,a));
226 errcatch(intersect());
232 intersect(set(),set());
235 intersect(set(set()),set());
238 intersect(set(set()),set(set(),set(set())));
241 intersect(set(a,b),set(a,b,c));
244 intersect(set(a,b),set(x,y,z));
247 intersect(set(a,b,c),set(a,y,x),set(z,a),set(p,q,a));
251 subsetp(set(),set());
254 subsetp(set(),set(a));
257 subsetp(set(a),set())$
260 subsetp(set(),set(set()));
263 subsetp(set(set()),set(set()));
266 subsetp(set(a,b),set(a,b,c));
269 subsetp(set(a,b,c),set(a,b));
272 errcatch(subsetp(a,b));
275 errcatch(subsetp(a,set(b)));
278 errcatch(subsetp(set(a),b));
281 disjointp(set(),set());
284 disjointp(set(set()),set());
287 errcatch(disjointp(a,a+b));
290 errcatch(disjointp(set(a),a+b));
293 errcatch(disjointp(a,set(a+b)));
296 disjointp(set(a),set(b));
299 disjointp(set(b,a),set(a));
305 subset(set(3,5,8),evenp);
308 errcatch(subset(a,oddp));
311 subset(set(a,b,4,sin(x)), evenp);
317 symmdifference(set());
320 symmdifference(set(1));
323 symmdifference(set(1,2,3));
326 symmdifference(set(a),set(b),set(c));
329 symmdifference(set(a),set(a,b),set(a,b,c));
332 symmdifference(set(a,b,c),set(a,b),set(a));
335 symmdifference(set(a,b,c),set(),set(1,2,3));
338 symmdifference(set(), set(1,2,3),set(a,b,c));
341 symmdifference(set(1,2,3),set(a,b,c),set());
344 symmdifference(set(), set(1,2,3),set(a,b,c),set(),set());
347 symmdifference(set(),set());
350 symmdifference(set(set()),set());
353 symmdifference(set(i,s,t,j), set(i,n,t,p));
356 errcatch(symmdifference(a,set(b)));
359 errcatch(symmdifference(set(a),b));
362 errcatch(symmdifference(a,set(b)));
365 symmdifference(set(a,b),set(a));
369 subsetp(set(),set());
372 subsetp(set(set()),set());
375 subsetp(set(),set(set()));
378 subsetp(set(x),set(set(x)));
381 subsetp(set(a,b),set(a,y));
384 subsetp(set(a,b),set(a,b));
387 subsetp(set(set(a)),set(x,y,set(a)));
390 subsetp(set(rat(x)),set(x));
393 subsetp(set(a,a,a,x),set(a,x));
409 union(set(1932),set());
412 union(set(set(8)),set(8));
415 is(union(set(a),set(b),set(c))= set(a,b,c));
418 is(union(set(set()),set(b),set()) = set(b,set()));
421 is(union(set(x=6),set(y=3),set(z=-8)) = set(z=-8,y=3,x=6));
439 setify([false,false]);
442 setify([false,false,true]);
451 listify(set(set(a)));
460 full_listify(set(false));
463 full_listify(set(set));
466 full_listify(set(x));
469 full_listify(set(set()));
472 full_listify(set(set(false)));
475 full_listify(set(a,set(b),set(set(c))));
481 full_listify(matrix([1,2],[3,4]));
484 full_listify(f(set(a)));
487 full_listify(f(set(set(a))));
490 full_listify(f(a,set(a), [a+b]));
502 full_listify(sin(x+7));
505 full_listify(7.8e-4);
511 full_listify(set + 7);
514 full_listify(a^b + 1/set + set^z);
526 full_listify(set(a,a,b));
529 full_listify(set(a,a,b,set()));
541 subst([a=x,b=x,c=x],set(a,b,c));
544 union(set(x),set(y));
550 errcatch(intersect());
556 intersect(set(a),set(a,b));
562 elementp(false, set());
565 elementp(false, set(false));
568 elementp(set(),set());
571 elementp(set(),set(set()));
577 elementp(rat(x),set(x));
580 elementp(x,set([x]));
583 union(set(false),set(true));
586 union(setify([true,false]), set(x));
610 fullsetify(matrix([1,2],[3,4]));
613 (remfunction(f,g),0);
684 flatten(f(g(f(f(x)))));
687 flatten(f(f(g(f(x)))));
690 /* Examples from Macsyma 422 */
692 flatten([a,b,[c,[d]],e,[[f],g,h]]);
695 flatten([a,b([c]),[d]]);
698 flatten(f(f(a,b), f(c,d)));
701 flatten(f[1](f[1](a,b), f[1](c,d)));
704 elementp(false,set());
707 elementp(false,set(1));
710 elementp(false,set(false));
725 elementp(1,set(0,2));
731 adjoin(false,set(1));
734 adjoin(false,set(false));
755 cardinality(set([]));
758 cardinality(set(8,8,1932));
761 errcatch(cardinality(x+y));
782 setp(set(set(a+b=c)));
794 listify(adjoin(-1,set(2,4,6)));
797 listify(adjoin(2,set(2,4,6)));
800 listify(adjoin(3,set(2,4,6)));
803 listify(adjoin(6,set(2,4,6)));
806 listify(adjoin(7,set(2,4,6)));
821 (s : listify(permutations([0,1,2,3,4])),0);
827 (s : listify(permutations([a,b,b,a])),0);
836 (s : permutations(q),0);
839 is(cardinality(s) = length(q)!);
842 elementp([5,3,2,1,4],s);
845 elementp([5,3,2,1,0],s);
848 (p : map(setify,s),0);
851 is(p = set(setify(q)));
864 set(set(),set(x),set(y),set(x,y))$
866 errcatch(powerset(a+b=c));
869 errcatch(powerset(rat(a)));
881 powerset(set(false));
882 set(set(),set(false))$
884 powerset(set(a+b=c),1);
887 powerset(set(1,2,3),2);
888 set(set(1,2),set(1,3),set(2,3))$
890 errcatch(powerset(a+b=c));
893 is(subset(powerset(set(a,b,c,d,e)),lambda([x],is(cardinality(x)=3))) = powerset(set(a,b,c,d,e),3));
896 is(subset(powerset(set(a,b,c,d,e)),lambda([x],is(cardinality(x)=5))) =
897 powerset(set(a,b,c,d,e),5));
900 is(subset(powerset(set(a,b,c,d,e)),lambda([x],is(cardinality(x)=7))) =
901 powerset(set(a,b,c,d,e),7));
904 extremal_subset(set(),lambda([x],x^2), max);
907 extremal_subset(set(-1,0,1),lambda([x],x^2), max);
910 extremal_subset(set(1,sqrt(2),3,%pi),log, max);
913 /* quote exp because some other tests assign a value to exp,
914 and kill refuses to kill the assigned value ... (sigh)
916 extremal_subset(set(sqrt(2),sqrt(3),sqrt(5)), 'exp, max);
919 extremal_subset(set(1+%i,sqrt(2),1-%i),abs, max);
920 set(1+%i,sqrt(2),1-%i)$
922 extremal_subset(set(a,a+b,1.4b0,sqrt(28)),lambda([x],if atom(x) then 0 else 1), max);
929 cartesian_product(set());
932 cartesian_product(set(a));
935 cartesian_product(set(),set(),set());
938 cartesian_product(set(a),set(b));
941 cartesian_product(set(u,n,k),set());
944 cartesian_product(set(), set(u,n,k));
947 cartesian_product(set(u,n,k),set(1));
948 set([u,1],[n,1],[k,1])$
950 cartesian_product(set(a,b),set(1,2));
951 set([a,1],[a,2],[b,1],[b,2])$
953 equiv_classes(set(),"=");
956 equiv_classes(set(),"#");
959 equiv_classes(set(a,b,c),"=");
960 set(set(a),set(b),set(c))$
962 equiv_classes(set(a,b,c),"#");
965 equiv_classes(set(1,2,3,4,5),lambda([x,y],remainder(x-y,2)=0));
966 set(set(1,3,5),set(2,4))$
968 partition_set(set(),evenp);
971 partition_set(set(9),evenp);
974 partition_set(set(2,4),evenp);
977 partition_set(set(a,b,c),lambda([x],false));
980 partition_set(set(a,b,c),lambda([x],true));
983 partition_set(set(a,b,c),lambda([x],orderlessp(x,b)));
986 set_partitions(set());
989 set_partitions(set(),1);
992 set_partitions(set(),2);
995 set_partitions(set(u,n,k),1);
996 set(set(set(u,n,k)))$
998 set_partitions(set(u,n,k),2);
999 set(set(set(u),set(n,k)),set(set(n),set(u,k)), set(set(k),set(u,n)))$
1001 makelist(stirling1(i,0),i,0,5);
1004 makelist(stirling1(i,i),i,0,5);
1007 factor(sum(stirling1(3,i)*x^i,i,0,3));
1010 makelist(stirling1(i,1) - (-1)^(i-1)*(i-1)!,i,1,5);
1013 sum(stirling1(8,k),k,1,8); /* A & S 24.1.3 */
1016 sum(stirling1(3,k),k,1,3);
1019 sum(stirling1(5,k)*(-1)^(5-k),k,0,5);
1022 sum(stirling1(2,k)*(-1)^(2-k),k,0,2);
1025 (declare([a,b],integer),0);
1028 (assume(a>0,b>0),0);
1037 (forget(a>0,b>0),0);
1040 (remove(a,integer), remove(b,integer),0);
1058 stirling2(10,5) - 5 * stirling2(9,5) - stirling2(9,4);
1061 sum((-1)^(12-m) * m! * stirling2(12,m),m,0,12);
1064 /* test stirling2 simplification rules */
1069 (e : stirling2(n,0),0);
1072 makelist(subst(n=i,e) - stirling2(i,0),i,-5,5);
1073 ''(makelist(0,i,-5,5))$
1075 (e : stirling2(n,1),0);
1078 makelist(subst(n=i,e) - stirling2(i,1),i,-5,5);
1079 ''(makelist(0,i,-5,5))$
1081 (e : stirling2(n,2),0);
1084 makelist(subst(n=i,e) - stirling2(i,2),i,-5,5);
1085 ''(makelist(0,i,-5,5))$
1087 (e : stirling2(n,n),0);
1090 makelist(subst(n=i,e) - stirling2(i,i),i,-5,5);
1091 ''(makelist(0,i,-5,5))$
1093 (assume(n >=0), declare(n,integer), declare(k,integer), declare(kk,integer), assume(k >=0),0);
1153 (forget(n>=0), forget(k >=0), remove(n,integer),remove(k,integer),remove(kk,integer),0);
1159 is(cardinality(set_partitions(set())) = belln(0));
1162 is(cardinality(set_partitions(set(1))) = belln(1));
1165 is(cardinality(set_partitions(set(1,2))) = belln(2));
1168 is(cardinality(set_partitions(set(1,2,3))) = belln(3));
1172 [belln(5),belln(6)]$
1174 integer_partitions(0);
1177 integer_partitions(1);
1180 integer_partitions(2);
1183 is(cardinality(integer_partitions(25)) = 1958)$
1186 map(lambda([x], apply("+",x)), integer_partitions(25));
1189 integer_partitions(2,1);
1192 integer_partitions(2,2);
1195 integer_partitions(5,3);
1196 set([5,0,0],[4,1,0],[3,1,1],[3,2,0],[2,2,1])$
1198 multinomial_coeff(0);
1201 multinomial_coeff(1);
1204 multinomial_coeff(5);
1207 multinomial_coeff(2,3,4);
1208 (2+3+4)! / (2! * 3! * 4!)$
1210 factor(sum(multinomial_coeff(i,5-i) * x^(5-i) * y^i,i,0,5));
1213 diff((x+y+z)^9,x,3,y,6);
1214 ''(multinomial_coeff(3,6,0) * 3! * 6!)$
1216 kron_delta(false,false);
1219 /* need to have true and false sysconsts (not standard) for this to work
1220 kron_delta(false,true);
1224 kron_delta(true,true);
1230 kron_delta(a+b,a+b);
1233 kron_delta(rat(x), x);
1236 kron_delta(x,y) - kron_delta(y,x);
1239 kron_delta(x,y) / 42 - kron_delta(y,x) / 42;
1242 kron_delta(%i*x,%i*y) - kron_delta(%i*y,%i*x);
1245 kron_delta(0.42,0.42);
1248 kron_delta(0.42, 42/100);
1249 kron_delta(0.42, 42/100)$
1260 kron_delta(%i*x,%i*y);
1261 kron_delta(%i*x,%i*y)$
1263 kron_delta(%i*x,%i*x);
1266 ratsimp(kron_delta(%i*(x+1)^2,%i*(x^2+2*x+1)));
1275 kron_delta(%i*a,%i*b);
1281 (assume(a < 1, b >= 3/2),0);
1290 kron_delta(5+%i,5+%i);
1293 kron_delta(5-%i,5+%i);
1296 kron_delta(3 + %i/7,1 + %i/7);
1299 kron_delta(1 + %i/5,1 + %i/7);
1302 /* new kronecker delta tests for multivariable version */
1304 (map('forget, facts()),0);
1307 errcatch(kron_delta(x));
1313 kron_delta(sqrt(2), 1/sqrt(2), %pi);
1319 subst(a=c, kron_delta(a,b,rat(c)));
1322 kron_delta(a,b)-kron_delta(-a,-b);
1325 kron_delta(a,-b)-kron_delta(-a,b);
1328 kron_delta(a,b,-c)-kron_delta(-a,-b,c);
1331 kron_delta(-a,b,-c)-kron_delta(a,-b,c);
1334 conjugate(kron_delta(a+%i,b,c));
1335 kron_delta(a+%i,b,c)$
1337 cabs(kron_delta(a,b,23 +%i));
1338 kron_delta(a,b,23 + %i)$
1340 abs(kron_delta(l,s,s));
1343 sign(kron_delta(u,n,k,1));
1346 featurep(kron_delta(a+%i, cos(x - %i), 42/19),'integer);
1349 /* end new kronecker delta tests */
1360 every(evenp,set(2));
1363 every(evenp,set(%pi));
1366 every(evenp,set(2,4,6,%pi));
1369 every(evenp,set(1,2,4,6));
1375 every("=",[1,2],[2,1]);
1378 every("#",[a,b],[b,a]);
1393 some(oddp,set(%i,1));
1399 some("<",[a,1],[4,2]);
1402 some("=",[a,4],[a,5]);
1405 some("<=",[5,a],[6,a]);
1417 rreduce(adjoin, [1,2,3,4], set());
1420 rreduce(lambda([x,y],x),[a,b,c,d]);
1423 rreduce(lambda([x,y],y),[a,b,c,d]);
1426 rreduce(concat,["a","m","h"],"");
1429 flatten(rreduce(f,[1,2,3,4]));
1441 lreduce(lambda([x,y],x),[a,b,c,d]);
1444 lreduce(lambda([x,y],y),[a,b,c,d]);
1447 lreduce(concat,["a","m","h"],"");
1450 flatten(lreduce(f,[1,2,3,4]));
1459 xreduce('max,[0,1]);
1462 xreduce('min,[0,1]);
1477 xreduce("and",[true]);
1480 xreduce("and",[false]);
1483 xreduce("and",[true,true],false)$
1486 xreduce("or",[true]);
1489 xreduce("or",[false]);
1492 xreduce("or",[true,true],false)$
1501 xreduce("and",[true]);
1504 xreduce("and",[false]);
1507 xreduce("and",[true,true],false)$
1510 xreduce("or",[true]);
1513 xreduce("or",[false]);
1516 xreduce("or",[true,true],false)$
1519 (nary ("@@@"), declare ("@@@", nary), "@@@" ([L]) := apply (FOO, L), kill (FOO));
1522 xreduce ("@@@", [a, e, c, b, d]);
1523 FOO (a, e, c, b, d);
1525 xreduce ("@@@", {a, e, c, b, d});
1526 FOO (a, b, c, d, e);
1528 (infix ("%%%"), "%%%" (aa, bb) := BAR (aa, bb), kill (BAR));
1531 xreduce ("%%%", [a, e, c, b, d]);
1532 BAR (BAR (BAR (BAR (a, e), c), b), d);
1534 xreduce ("%%%", {a, e, c, b, d});
1535 BAR (BAR (BAR (BAR (a, b), c), d), e);
1537 makeset(i,[i],set());
1540 makeset(i,[i],[[1]]);
1543 makeset(i,[i],[[true],[false]]);
1546 makeset(i/j,[i,j],[[2,6],[6,28]]);
1552 every(is, makelist(num_partitions(i)=cardinality(integer_partitions(i)),i,1,15));
1555 /* SF bug #2975: "number of distinct partitions gives wroing result" */
1558 makelist (num_partitions (n, 'list), n, 1, 10),
1559 makelist (makelist (num_partitions (m), m, 1, n), n, 1, 10));
1563 makelist (num_distinct_partitions (n, 'list), n, 1, 10),
1564 makelist (makelist (num_distinct_partitions (m), m, 1, n), n, 1, 10));
1567 (distinctp(l) := is(cardinality(setify(l)) = length(l)),0);
1570 (chk(n) := cardinality(subset(integer_partitions(n),distinctp)), 0);
1573 every(is, makelist(num_distinct_partitions(i)=chk(i),i,0,10));
1576 (remfunction(chk,distinctp),0);
1589 [set(1,2,4,7,14,28)]$
1592 divisors(a) = divisors(b)$
1594 every(is, makelist(divsum(i) = xreduce("+",divisors(i)),i,1,100));
1607 [moebius(3),moebius(4)]$
1609 /* See A & S 24.3.1 */
1611 every(is, makelist(xreduce("+", map(moebius, divisors(i))) = 0,i,2,100));
1614 (rprimep(i,j) := block([ ],
1615 if integerp(i) and integerp(j) then if gcd(i,j) > 1 then 0 else 1
1616 else funmake(rprimep,[i,j])),0);
1619 every(is, makeset(moebius(i*j) = moebius(i) * moebius(j) * rprimep(i,j),[i,j],
1620 cartesian_product(setify(makelist(i,i,1,15)),setify(makelist(j,j,1,15)))));
1623 /* Tests for random_permutation */
1625 (set_random_state (make_random_state (1234)), 0);
1628 (L : '[a + 1, b - 2, c * d, %pi, %e], S : setify (L), 0);
1631 [random_permutation (L), random_permutation (L), random_permutation (L)];
1632 '[[a + 1, %e, c*d, b - 2, %pi], [b - 2, a + 1, c*d, %e, %pi], [a + 1, c*d, b - 2, %e, %pi]];
1634 [random_permutation (S), random_permutation (S), random_permutation (S)];
1635 '[[c*d, b - 2, a + 1, %pi, %e], [%pi, %e, a + 1, b - 2, c*d], [b - 2, %pi, a + 1, %e, c*d]];
1637 apply ("+", makelist (if random_permutation ([1, 2, 3, 4]) = [4,2,1,3] then 1 else 0, i, 1, 1000));
1640 /* Tests for sublist_indices */
1642 sublist_indices ([], lambda([x], x='b));
1645 errcatch (sublist_indices (1, lambda([x], x='b)));
1648 sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], x='b));
1651 sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], integerp (x)));
1654 sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], symbolp);
1657 sublist_indices ([true, false, false, true, true], identity);
1660 sublist_indices ([1 > 0, 1 < 0, 2 < 1, 2 > 1, 2 > 0], identity);
1663 (kill (P), P(x) := ordergreatp (x, 'm), sublist_indices ('[a, %pi, x, z, h, y, %e, 1, s], P));
1666 sublist_indices ('[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], lambda ([x], evenp(x) and primep(x)));
1669 /* Tests for sublist (not part of nset but related functionality) */
1671 sublist ([], lambda([x], x='b));
1674 errcatch (sublist (1, lambda([x], x='b)));
1677 sublist ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], x='b));
1680 sublist ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], integerp (x)));
1683 sublist ('[a, b, b, c, 1, 2, b, 3, b], symbolp);
1686 sublist ([true, false, false, true, true], identity);
1689 sublist ([1 > 0, 1 < 0, 2 < 1, 2 > 1, 2 > 0], identity);
1690 [1 > 0, 2 > 1, 2 > 0];
1692 (kill (P), P(x) := ordergreatp (x, 'm), sublist ('[a, %pi, x, z, h, y, %e, 1, s], P));
1695 sublist ('[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], lambda ([x], evenp(x) and primep(x)));
1698 /* from mailing list 2009-08-27 "what happened to 'ev' ?" */
1700 block ([l1: [[2,3], [3,4], [4,5]]], local(s_list),
1701 s_list(list, option) := sublist(list, lambda([x], ev(option))),
1702 s_list(l1, x[2]<4));
1705 block ([l1: [[2,3], [3,4], [4,5]]], local(s_list_indices),
1706 s_list_indices(list, option) := sublist_indices(list, lambda([x], ev(option))),
1707 s_list_indices(l1, x[2]<4));
1710 /* SF bug 2698078 set_partitions does not produce simplified sets */
1711 (l : set_partitions({1,2,3,4},3),0);
1717 map(lambda([s], xreduce('union,s)), l);
1720 map(lambda([s], xreduce('intersection,s)), l);
1723 (l : set_partitions({1,2,3,4}),0);
1729 map(lambda([s], xreduce('union,s)), l);
1732 map(lambda([s], xreduce('intersection,s)), l);
1733 set(set(), set(1,2,3,4))$
1735 (l : set_partitions(set(a,b, set(c)),2),0);
1741 map(lambda([s], xreduce('union,s)), l);
1742 set(set(a,b,set(c)))$
1744 map(lambda([s], xreduce('intersection,s)), l);
1747 (l : set_partitions(set(a,b, set(c))),0);
1753 map(lambda([s], xreduce('union,s)), l);
1754 set(set(a,b,set(c)))$
1756 map(lambda([s], xreduce('intersection,s)), l);
1757 set(set(),set(a,b,set(c)))$
1762 in_exactly_one(set());
1765 in_exactly_one(set(l), set(s), set(s));
1768 in_exactly_one(set(r), set(e), set(n), set(e), set(e));
1771 in_exactly_one(set(m), set(a), set(x), set(i,m,a));
1774 in_exactly_one(set(x),set(x), set(a,b));
1777 /* bug reported to mailing list, is(f("x") > 0) => Lisp error
1778 * following example from Matthew Gwynne 2010-04-29, thanks Matthew!
1782 /* F as specified in original example
1783 F : {{gv("CSup"),-gv("DiagF"),-gv("DisT"),-gv("ProgF"),-gv("SymA"),-gv("Via")},
1784 {-gv("CSup"),-gv("DiagF"),-gv("DisT"),-gv("ProgF"),-gv("SymA"),-gv("Via")},
1785 {gv("CSup"),-gv("DiagF"),-gv("DisT"),-gv("ProgF"),-gv("SymA"),-gv("Via")},
1786 {-gv("CSup"),-gv("DiagF"),gv("DisT"),-gv("ProgF"),gv("SymA"),-gv("Via")},
1787 {-gv("CSup"),gv("DiagF"),-gv("DisT"),-gv("ProgF"),gv("SymA"),gv("Via")},
1788 {gv("CSup"),gv("DiagF"),-gv("DisT"),-gv("ProgF"),gv("SymA"),gv("Via")},
1789 {gv("CSup"),gv("DiagF"),gv("DisT"),-gv("ProgF"),gv("SymA"),gv("Via")},
1790 {gv("CSup"),gv("DiagF"),gv("DisT"),-gv("ProgF"),gv("SymA"),gv("Via")},
1791 {-gv("CSup"),gv("DiagF"),-gv("DisT"),gv("ProgF"),gv("SymA"),gv("Via")},
1792 {gv("CSup"),gv("DiagF"),gv("DisT"),gv("ProgF"),gv("SymA"),gv("Via")},
1793 {gv("CSup"),gv("DiagF"),gv("DisT"),gv("ProgF"),gv("SymA"),gv("Via")}}, */
1794 /* here is a smaller (fewer variables) example */
1795 F : {{gv("CSup"),-gv("DiagF"),-gv("DisT")},
1796 {gv("CSup"),gv("DiagF"),gv("DisT")},
1797 {gv("CSup"),gv("DiagF"),gv("DisT")}},
1798 var_cs(F) := map(abs,apply(union,listify(F))),
1801 apply(cartesian_product,
1802 map(lambda([v],{-v,v}),listify(V)))),
1803 fullcnf2fulldnf(F) := setdifference(all_tass(var_cs(F)),F),
1804 fullcnf2fulldnf(F));
1806 {{-abs(gv("CSup")),-abs(gv("DiagF")),-abs(gv("DisT"))},{-abs(gv("CSup")),-abs(gv("DiagF")),abs(gv("DisT"))},
1807 {-abs(gv("CSup")),abs(gv("DiagF")),-abs(gv("DisT"))},{-abs(gv("CSup")),abs(gv("DiagF")),abs(gv("DisT"))},
1808 {abs(gv("CSup")),-abs(gv("DiagF")),-abs(gv("DisT"))},{abs(gv("CSup")),-abs(gv("DiagF")),abs(gv("DisT"))},
1809 {abs(gv("CSup")),abs(gv("DiagF")),-abs(gv("DisT"))},{abs(gv("CSup")),abs(gv("DiagF")),abs(gv("DisT"))}}$
1811 /* full_listify - ID: 3005820 */
1812 full_listify(rat(3/4));
1815 /* is union nary? */
1819 /* kron_delta is scalar */
1821 featurep (kron_delta, scalar);
1824 (kill (a, b), declare ([a, b], nonscalar), 0);
1827 (a * kron_delta (i, j)) . b, dotscrules=true;
1828 (a . b)*'kron_delta (i, j);
1830 /* verify that scalar declaration is really needed */
1831 (a * kran_dalta (i, j)) . b, dotscrules=true;
1832 (a * kran_dalta (i, j)) . b;
1834 /* SF bug #3049: "set should act like list" */
1836 (kill (a, b, c, d, foo, bar, baz), foo : {a, b, c, d});
1839 ([a, b] : [17, 29], bar : '{a, b, c, d});
1848 is (baz = subst (['a = a, 'b = b], foo));
1860 /* examples listed under "Bugs" in doc/info/nset.texi -- all work as expected now */
1863 {[x], [''(rat(x))]};
1865 setify ([[rat(a)], [rat(b)]]);
1866 {[''(rat(a))], [''(rat(b))]};
1868 orderlessp ([rat(a)], [rat(b)]);
1871 is ([rat(a)] = [rat(a)]);
1877 /* for the record, q, r, s example is treated in greater generality in rtest1 */
1879 (kill (q, r, s), q: x^2, r: (x + 1)^2, s: x*(x + 2), 0);
1882 [orderlessp (q, r), orderlessp (r, s), orderlessp (q, s)];
1883 [true, false, false];
1885 kron_delta (1/sqrt(2), sqrt(2)/2);
1888 sign (1/sqrt(2) - sqrt(2)/2);
1891 /* apply(op({...}), [...]) doesn't yield a (($SET) ...) expression
1892 * bug reported to mailing list 2016-10-27
1894 (S1:{1}, S2:apply(op(S1), [2]));
1897 ?eq(?caar(S1), 'set);
1900 ?eq(?caar(S2), 'set);
1903 is (S1 = apply(op(S1), args(S1)));