1@menu
2* Introduction to Maximas Database::
3* Functions and Variables for Properties::
4* Functions and Variables for Facts::
5* Functions and Variables for Predicates::
6@end menu
7
8@c -----------------------------------------------------------------------------
9@node Introduction to Maximas Database, Functions and Variables for Properties, Maximas Database, Maximas Database
10@section Introduction to Maximas Database
11@c -----------------------------------------------------------------------------
12
13@c -----------------------------------------------------------------------------
14@node Functions and Variables for Properties, Functions and Variables for Facts, Introduction to Maximas Database, Maximas Database
15@section Functions and Variables for Properties
16@c -----------------------------------------------------------------------------
17
18@c -----------------------------------------------------------------------------
19@anchor{alphabetic}
20@defvr {Property} alphabetic
21
22@code{alphabetic} is a property type recognized by @mrefdot{declare}@w{}
23The expression @code{declare(@var{s}, alphabetic)} tells Maxima to recognize
24as alphabetic all of the characters in @var{s}, which must be a string.
25
26See also @ref{Identifiers}.
27
28Example:
29
30@c ===beg===
31@c xx\~yy\`\@ : 1729;
32@c declare ("~`@", alphabetic);
33@c xx~yy`@ + @yy`xx + `xx@@yy~;
34@c listofvars (%);
35@c ===end===
36@example
37(%i1) xx\~yy\`\@@ : 1729;
38(%o1)                         1729
39(%i2) declare ("~`@@", alphabetic);
40(%o2)                         done
41(%i3) xx~yy`@@ + @@yy`xx + `xx@@@@yy~;
42(%o3)               `xx@@@@yy~ + @@yy`xx + 1729
43(%i4) listofvars (%);
44(%o4)                  [@@yy`xx, `xx@@@@yy~]
45@end example
46
47@opencatbox
48@category{Declarations and inferences}
49@closecatbox
50@end defvr
51
52@c -----------------------------------------------------------------------------
53@anchor{bindtest}
54@defvr {Property} bindtest
55
56The command @code{declare(@var{x}, bindtest)} tells Maxima to trigger an error
57when the symbol @var{x} is evaluated unbound.
58
59@c ===beg===
60@c aa + bb;
61@c declare (aa, bindtest);
62@c aa + bb;
63@c aa : 1234;
64@c aa + bb;
65@c ===end===
66@example
67(%i1) aa + bb;
68(%o1)                        bb + aa
69(%i2) declare (aa, bindtest);
70(%o2)                         done
71(%i3) aa + bb;
72aa unbound variable
73 -- an error.  Quitting.  To debug this try debugmode(true);
74(%i4) aa : 1234;
75(%o4)                         1234
76(%i5) aa + bb;
77(%o5)                       bb + 1234
78@end example
79@end defvr
80
81@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
82@c CROSS REF declare, properties, ETC
83
84@c -----------------------------------------------------------------------------
85@anchor{constant}
86@deffn {Property} constant
87
88@code{declare(@var{a}, constant)} declares @var{a} to be a constant.  The
89declaration of a symbol to be constant does not prevent the assignment of a
90nonconstant value to the symbol.
91
92See @mref{constantp} and @mrefdot{declare}
93@c WHAT EXACTLY ARE THE CONSEQUENCES OF DECLARING AN ATOM TO BE CONSTANT ??
94
95Example:
96
97@example
98(%i1) declare(c, constant);
99(%o1)                         done
100(%i2) constantp(c);
101(%o2)                         true
102(%i3) c : x;
103(%o3)                           x
104(%i4) constantp(c);
105(%o4)                         false
106@end example
107
108@opencatbox
109@category{Declarations and inferences}
110@category{Constants}
111@closecatbox
112@end deffn
113
114@c -----------------------------------------------------------------------------
115@anchor{constantp}
116@deffn {Function} constantp (@var{expr})
117
118Returns @code{true} if @var{expr} is a constant expression, otherwise returns
119@code{false}.
120@c WHAT DOES MAXIMA KNOW ABOUT CONSTANT EXPRESSIONS ??
121
122An expression is considered a constant expression if its arguments are
123numbers (including rational numbers, as displayed with @code{/R/}),
124symbolic constants such as @mrefcomma{%pi} @mrefcomma{%e} and @mrefcomma{%i}@w{}
125variables bound to a constant or declared constant by @mrefcomma{declare}@w{}
126or functions whose arguments are constant.
127
128@code{constantp} evaluates its arguments.
129
130See the property @mref{constant} which declares a symbol to be constant.
131
132Examples:
133
134@c ===beg===
135@c constantp (7 * sin(2));
136@c constantp (rat (17/29));
137@c constantp (%pi * sin(%e));
138@c constantp (exp (x));
139@c declare (x, constant);
140@c constantp (exp (x));
141@c constantp (foo (x) + bar (%e) + baz (2));
142@c ===end===
143@example
144(%i1) constantp (7 * sin(2));
145(%o1)                                true
146(%i2) constantp (rat (17/29));
147(%o2)                                true
148(%i3) constantp (%pi * sin(%e));
149(%o3)                                true
150(%i4) constantp (exp (x));
151(%o4)                                false
152(%i5) declare (x, constant);
153(%o5)                                done
154(%i6) constantp (exp (x));
155(%o6)                                true
156(%i7) constantp (foo (x) + bar (%e) + baz (2));
157(%o7)                                false
158(%i8)
159@end example
160
161@opencatbox
162@category{Predicate functions}
163@category{Constants}
164@closecatbox
165@end deffn
166
167@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
168@c THIS ITEM IS EXTREMELY IMPORTANT
169@c ENSURE THAT ALL KEYWORDS RECOGNIZED BY declare HAVE THEIR OWN DOCUMENTATION ITEMS !!
170@c ALSO: HOW TO FIND THE LIST OF ALL SYMBOLS WHICH HAVE A GIVEN PROPERTY ??
171
172@c -----------------------------------------------------------------------------
173@anchor{declare}
174@deffn {Function} declare (@var{a_1}, @var{p_1}, @var{a_2}, @var{p_2}, @dots{})
175
176Assigns the atom or list of atoms @var{a_i} the property or list of properties
177@var{p_i}.  When @var{a_i} and/or @var{p_i} are lists, each of the atoms gets
178all of the properties.
179
180@code{declare} quotes its arguments.  @code{declare} always returns @code{done}.
181
182As noted in the description for each declaration flag, for some flags
183@code{featurep(@var{object}, @var{feature})} returns @code{true} if @var{object}
184has been declared to have @var{feature}.
185
186For more information about the features system, see @mrefdot{features} To
187remove a property from an atom, use @mrefdot{remove}
188
189@code{declare} recognizes the following properties:
190
191@table @code
192@item additive
193Tells Maxima to simplify @var{a_i} expressions by the substitution
194@code{@var{a_i}(x + y + z + ...)} @code{-->}
195@code{@var{a_i}(x) + @var{a_i}(y) + @var{a_i}(z) + ...}.
196The substitution is carried out on the first argument only.
197
198@item alphabetic
199Tells Maxima to recognize all characters in @var{a_i} (which must be a
200string) as alphabetic characters.
201
202@item antisymmetric, commutative, symmetric
203Tells Maxima to recognize @var{a_i} as a symmetric or antisymmetric
204function.  @mref{commutative} is the same as @code{symmetric}.
205
206@item bindtest
207Tells Maxima to trigger an error when @var{a_i} is evaluated unbound.
208
209@item constant
210Tells Maxima to consider @var{a_i} a symbolic constant.
211@c WHAT MAXIMA KNOWS ABOUT SYMBOLIC CONSTANTS IS PRETTY LIMITED
212@c DUNNO IF WE WANT TO GET INTO DETAILS HERE.
213@c MAYBE IN THE DOCUMENTATION FOR CONSTANT (IF THERE IS SUCH)
214
215@item even, odd
216Tells Maxima to recognize @var{a_i} as an even or odd integer variable.
217
218@item evenfun, oddfun
219Tells Maxima to recognize @var{a_i} as an odd or even function.
220
221@item evflag
222Makes @var{a_i} known to the @code{ev} function so that @var{a_i} is bound
223to @code{true} during the execution of @code{ev} when @var{a_i} appears as
224a flag argument of @code{ev}.  See @mrefdot{evflag}
225
226@item evfun
227Makes @var{a_i} known to @code{ev} so that the function named by @var{a_i}
228is applied when @var{a_i} appears as a flag argument of @code{ev}.
229See @mrefdot{evfun}
230
231@item feature
232Tells Maxima to recognize @var{a_i} as the name of a feature.
233Other atoms may then be declared to have the @var{a_i} property.
234
235@item increasing, decreasing
236Tells Maxima to recognize @var{a_i} as an increasing or decreasing
237function.
238@c MAXIMA FAILS TO DEDUCE F(2) > F(1) FOR INCREASING FUNCTION F
239@c AND FAILS TO DEDUCE ANYTHING AT ALL ABOUT DECREASING FUNCTIONS
240@c REPORTED AS SF BUG # 1483194
241
242@item integer, noninteger
243Tells Maxima to recognize @var{a_i} as an integer or noninteger variable.
244
245@item integervalued
246Tells Maxima to recognize @var{a_i} as an integer-valued function.
247
248@item lassociative, rassociative
249Tells Maxima to recognize @var{a_i} as a right-associative or
250left-associative function.
251
252@item linear
253Equivalent to declaring @var{a_i} both @code{outative} and
254@code{additive}.
255
256@item mainvar
257Tells Maxima to consider @var{a_i} a "main variable".  A main variable
258succeeds all other constants and variables in the canonical ordering of
259Maxima expressions, as determined by @code{ordergreatp}.
260
261@item multiplicative
262Tells Maxima to simplify @var{a_i} expressions by the substitution
263@code{@var{a_i}(x * y * z * ...)} @code{-->}
264@code{@var{a_i}(x) * @var{a_i}(y) * @var{a_i}(z) * ...}.
265The substitution is carried out on the first argument only.
266
267@anchor{nary}
268@item nary
269Tells Maxima to recognize @var{a_i} as an n-ary function.
270
271The @code{nary} declaration is not the same as calling the @code{nary}
272function.  The sole effect of @code{declare(foo, nary)} is to instruct the
273Maxima simplifier to flatten nested expressions, for example, to simplify
274@code{foo(x, foo(y, z))} to @code{foo(x, y, z)}.
275
276@item nonarray
277Tells Maxima to consider @var{a_i} not an array.  This declaration
278prevents multiple evaluation of a subscripted variable name.
279
280@item nonscalar
281Tells Maxima to consider @var{a_i} a nonscalar variable.  The usual
282application is to declare a variable as a symbolic vector or matrix.
283
284@item noun
285Tells Maxima to parse @var{a_i} as a noun.  The effect of this is to
286replace instances of @var{a_i} with @code{'@var{a_i}} or
287@code{nounify(@var{a_i})}, depending on the context.
288
289@item outative
290Tells Maxima to simplify @var{a_i} expressions by pulling constant factors
291out of the first argument.
292
293When @var{a_i} has one argument, a factor is considered constant if it is
294a literal or declared constant.
295
296When @var{a_i} has two or more arguments, a factor is considered constant
297if the second argument is a symbol and the factor is free of the second
298argument.
299
300@item posfun
301Tells Maxima to recognize @var{a_i} as a positive function.
302
303@item rational, irrational
304Tells Maxima to recognize @var{a_i} as a rational or irrational real
305variable.
306
307@item real, imaginary, complex
308Tells Maxima to recognize @var{a_i} as a real, pure imaginary, or complex
309variable.
310
311@item scalar
312Tells Maxima to consider @var{a_i} a scalar variable.
313
314@c OBSOLETE @code{special} (RECOGNIZED BY DECLARE BUT NEVER USED ANYWHERE)
315@c OBSOLETE @code{analytic} (RECOGNIZED BY DECLARE BUT NEVER USED ANYWHERE)
316@end table
317
318Examples of the usage of the properties are available in the documentation
319for each separate description of a property.
320
321@opencatbox
322@category{Declarations and inferences}
323@closecatbox
324@end deffn
325
326@c -----------------------------------------------------------------------------
327@anchor{decreasing}
328@anchor{increasing}
329@defvr  {Property} decreasing
330@defvrx {Property} increasing
331
332The commands @code{declare(@var{f}, decreasing)} or
333@code{declare(@var{f}, increasing)} tell Maxima to recognize the function
334@var{f} as an decreasing or increasing function.
335
336See also @mref{declare} for more properties.
337
338Example:
339
340@example
341(%i1) assume(a > b);
342(%o1)                        [a > b]
343(%i2) is(f(a) > f(b));
344(%o2)                        unknown
345(%i3) declare(f, increasing);
346(%o3)                         done
347(%i4) is(f(a) > f(b));
348(%o4)                         true
349@end example
350
351@opencatbox
352@category{Declarations and inferences}
353@closecatbox
354@end defvr
355
356@c -----------------------------------------------------------------------------
357@anchor{even}
358@anchor{odd}
359@defvr  {Property} even
360@defvrx {Property} odd
361
362@code{declare(@var{a}, even)} or @code{declare(@var{a}, odd)} tells Maxima to
363recognize the symbol @var{a} as an even or odd integer variable.  The
364properties @code{even} and @code{odd} are not recognized by the functions
365@mrefcomma{evenp} @mrefcomma{oddp} and @mrefdot{integerp}
366
367See also @mref{declare} and @mrefdot{askinteger}
368
369Example:
370
371@example
372(%i1) declare(n, even);
373(%o1)                         done
374(%i2) askinteger(n, even);
375(%o2)                          yes
376(%i3) askinteger(n);
377(%o3)                          yes
378(%i4) evenp(n);
379(%o4)                         false
380@end example
381
382@opencatbox
383@category{Declarations and inferences}
384@closecatbox
385@end defvr
386
387@c NEEDS EXPANSION AND CLARIFICATION
388
389@c -----------------------------------------------------------------------------
390@anchor{feature}
391@defvr {Property} feature
392
393Maxima understands two distinct types of features, system features and features
394which apply to mathematical expressions.  See also @mref{status} for information
395about system features.  See also @mref{features} and @mref{featurep} for
396information about mathematical features.
397@c PROPERTIES, DECLARATIONS FALL UNDER THIS HEADING AS WELL
398@c OTHER STUFF ??
399
400@code{feature} itself is not the name of a function or variable.
401@end defvr
402
403@c NEEDS CLARIFICATION, ESPECIALLY WRT THE EXTENT OF THE FEATURE SYSTEM
404@c (I.E. WHAT KINDS OF THINGS ARE FEATURES ACCORDING TO featurep)
405
406@c -----------------------------------------------------------------------------
407@anchor{featurep}
408@deffn {Function} featurep (@var{a}, @var{f})
409
410Attempts to determine whether the object @var{a} has the feature @var{f} on the
411basis of the facts in the current database.  If so, it returns @code{true},
412else @code{false}.
413
414Note that @code{featurep} returns @code{false} when neither @var{f}
415nor the negation of @var{f} can be established.
416
417@code{featurep} evaluates its argument.
418
419See also @mref{declare} and @mrefdot{features}
420
421@example
422(%i1) declare (j, even)$
423(%i2) featurep (j, integer);
424(%o2)                           true
425@end example
426
427@opencatbox
428@category{Predicate functions}
429@category{Declarations and inferences}
430@closecatbox
431@end deffn
432
433@c -----------------------------------------------------------------------------
434@anchor{features}
435@defvr {Declaration} features
436
437Maxima recognizes certain mathematical properties of functions and variables.
438These are called "features".
439
440@code{declare (@var{x}, @var{foo})} gives the property @var{foo}
441to the function or variable @var{x}.
442
443@code{declare (@var{foo}, feature)} declares a new feature @var{foo}.
444For example,
445@code{declare ([red, green, blue], feature)}
446declares three new features, @code{red}, @code{green}, and @code{blue}.
447
448The predicate @code{featurep (@var{x}, @var{foo})}
449returns @code{true} if @var{x} has the @var{foo} property,
450and @code{false} otherwise.
451
452The infolist @code{features} is a list of known features.  These are
453
454@verbatim
455   integer        noninteger      even
456   odd            rational        irrational
457   real           imaginary       complex
458   analytic       increasing      decreasing
459   oddfun         evenfun         posfun
460   constant       commutative     lassociative
461   rassociative   symmetric       antisymmetric
462   integervalued
463@end verbatim
464
465plus any user-defined features.
466
467@code{features} is a list of mathematical features.  There is also a list of
468non-mathematical, system-dependent features.  See @mrefdot{status}
469
470Example:
471
472@c ===beg===
473@c declare (FOO, feature);
474@c declare (x, FOO);
475@c featurep (x, FOO);
476@c ===end===
477@example
478(%i1) declare (FOO, feature);
479(%o1)                         done
480(%i2) declare (x, FOO);
481(%o2)                         done
482(%i3) featurep (x, FOO);
483(%o3)                         true
484@end example
485
486@opencatbox
487@category{Declarations and inferences}
488@closecatbox
489@end defvr
490
491@c -----------------------------------------------------------------------------
492@anchor{get}
493@deffn {Function} get (@var{a}, @var{i})
494
495Retrieves the user property indicated by @var{i} associated with
496atom @var{a} or returns @code{false} if @var{a} doesn't have property @var{i}.
497
498@code{get} evaluates its arguments.
499
500See also @mref{put} and @mrefdot{qput}
501
502@c ===beg===
503@c put (%e, 'transcendental, 'type);
504@c put (%pi, 'transcendental, 'type)$
505@c put (%i, 'algebraic, 'type)$
506@c typeof (expr) := block ([q],
507@c         if numberp (expr)
508@c         then return ('algebraic),
509@c         if not atom (expr)
510@c         then return (maplist ('typeof, expr)),
511@c         q: get (expr, 'type),
512@c         if q=false
513@c         then errcatch (error(expr,"is not numeric.")) else q)$
514@c typeof (2*%e + x*%pi);
515@c typeof (2*%e + %pi);
516@c ===end===
517@example
518(%i1) put (%e, 'transcendental, 'type);
519(%o1)                    transcendental
520(%i2) put (%pi, 'transcendental, 'type)$
521(%i3) put (%i, 'algebraic, 'type)$
522(%i4) typeof (expr) := block ([q],
523        if numberp (expr)
524        then return ('algebraic),
525        if not atom (expr)
526        then return (maplist ('typeof, expr)),
527        q: get (expr, 'type),
528        if q=false
529        then errcatch (error(expr,"is not numeric.")) else q)$
530(%i5) typeof (2*%e + x*%pi);
531x is not numeric.
532(%o5)  [[transcendental, []], [algebraic, transcendental]]
533(%i6) typeof (2*%e + %pi);
534(%o6)     [transcendental, [algebraic, transcendental]]
535@end example
536
537@opencatbox
538@category{Declarations and inferences}
539@closecatbox
540@end deffn
541
542@c -----------------------------------------------------------------------------
543@anchor{integer}
544@anchor{noninteger}
545@defvr  {Property} integer
546@defvrx {Property} noninteger
547
548@code{declare(@var{a}, integer)} or @code{declare(@var{a}, noninteger)} tells
549Maxima to recognize @var{a} as an integer or noninteger variable.
550
551See also @mrefdot{declare}
552
553Example:
554
555@example
556(%i1) declare(n, integer, x, noninteger);
557(%o1)                         done
558(%i2) askinteger(n);
559(%o2)                          yes
560(%i3) askinteger(x);
561(%o3)                          no
562@end example
563
564@opencatbox
565@category{Declarations and inferences}
566@closecatbox
567@end defvr
568
569@c -----------------------------------------------------------------------------
570@anchor{integervalued}
571@defvr {Property} integervalued
572
573@code{declare(@var{f}, integervalued)} tells Maxima to recognize @var{f} as an
574integer-valued function.
575
576See also @mrefdot{declare}
577
578Example:
579
580@example
581(%i1) exp(%i)^f(x);
582                              %i f(x)
583(%o1)                      (%e  )
584(%i2) declare(f, integervalued);
585(%o2)                         done
586(%i3) exp(%i)^f(x);
587                              %i f(x)
588(%o3)                       %e
589@end example
590
591@opencatbox
592@category{Declarations and inferences}
593@closecatbox
594@end defvr
595
596@c -----------------------------------------------------------------------------
597@anchor{nonarray}
598@deffn {Property} nonarray
599
600The command @code{declare(a, nonarray)} tells Maxima to consider @var{a} not
601an array.  This declaration prevents multiple evaluation, if @var{a} is a
602subscripted variable.
603
604See also @mrefdot{declare}
605
606Example:
607
608@c ===beg===
609@c a:'b$ b:'c$ c:'d$
610@c a[x];
611@c declare(a, nonarray);
612@c a[x];
613@c ===end===
614@example
615(%i1) a:'b$ b:'c$ c:'d$
616
617(%i4) a[x];
618(%o4)                          d
619                                x
620(%i5) declare(a, nonarray);
621(%o5)                         done
622(%i6) a[x];
623(%o6)                          a
624                                x
625@end example
626
627@opencatbox
628@category{Expressions}
629@closecatbox
630@end deffn
631
632@c NEEDS CLARIFICATION AND EXAMPLES
633
634@c -----------------------------------------------------------------------------
635@anchor{nonscalar}
636@defvr {Property} nonscalar
637
638Makes atoms behave as does a list or matrix with respect to the dot operator.
639
640See also @mrefdot{declare}
641
642@opencatbox
643@category{Declarations and inferences}
644@category{Vectors}
645@category{Matrices}
646@closecatbox
647@end defvr
648
649@c -----------------------------------------------------------------------------
650@anchor{nonscalarp}
651@deffn {Function} nonscalarp (@var{expr})
652
653Returns @code{true} if @var{expr} is a non-scalar, i.e., it contains
654atoms declared as non-scalars, lists, or matrices.
655
656See also the predicate function @mref{scalarp} and @mrefdot{declare}
657
658@opencatbox
659@category{Predicate functions}
660@category{Vectors}
661@category{Matrices}
662@closecatbox
663@end deffn
664
665@c NEEDS EXAMPLES
666
667@c -----------------------------------------------------------------------------
668@anchor{posfun}
669@defvr {Property} posfun
670
671@code{declare (f, posfun)} declares @code{f} to be a positive function.
672@code{is (f(x) > 0)} yields @code{true}.
673
674See also @mrefdot{declare}
675
676@opencatbox
677@category{Declarations and inferences}
678@category{Operators}
679@closecatbox
680@end defvr
681
682@c NEEDS WORK ESPECIALLY EXAMPLES
683@c WHOLE BUSINESS WITH PROPERTIES IS PRETTY CONFUSING, TRY TO CLEAR IT UP
684
685@c -----------------------------------------------------------------------------
686@anchor{printprops}
687@deffn  {Function} printprops @
688@fname{printprops} (@var{a}, @var{i}) @
689@fname{printprops} ([@var{a_1}, @dots{}, @var{a_n}], @var{i}) @
690@fname{printprops} (all, @var{i})
691
692Displays the property with the indicator @var{i} associated with the atom
693@var{a}.  @var{a} may also be a list of atoms or the atom @code{all} in which
694case all of the atoms with the given property will be used.  For example,
695@code{printprops ([f, g], atvalue)}.  @code{printprops} is for properties that
696cannot otherwise be displayed, i.e.  for @mrefcomma{atvalue}@w{}
697@mrefcomma{atomgrad} @mrefcomma{gradef} and @mrefdot{matchdeclare}
698
699@opencatbox
700@category{Declarations and inferences}
701@category{Display functions}
702@closecatbox
703@end deffn
704
705@c CROSS REF TO WHICH FUNCTION OR FUNCTIONS ESTABLISH PROPERTIES !! (VERY IMPORTANT)
706@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
707
708@c -----------------------------------------------------------------------------
709@anchor{properties}
710@deffn {Function} properties (@var{a})
711
712Returns a list of the names of all the properties associated with the atom
713@var{a}.
714
715@opencatbox
716@category{Declarations and inferences}
717@closecatbox
718@end deffn
719
720@c CROSS REF TO WHICH FUNCTION OR FUNCTIONS ESTABLISH PROPERTIES !! (VERY IMPORTANT)
721@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
722@c WHAT IS HIDDEN IN THE "etc" HERE ??
723
724@c -----------------------------------------------------------------------------
725@anchor{props}
726@defvr {System variable} props
727Default value: @code{[]}
728
729@code{props} are atoms which have any property other than those explicitly
730mentioned in @mrefcomma{infolists} such as specified by @mrefcomma{atvalue}@w{}
731@mrefcomma{matchdeclare} etc., as well as properties specified in the
732@mref{declare} function.
733
734@opencatbox
735@category{Declarations and inferences}
736@category{Global variables}
737@closecatbox
738@end defvr
739
740@c CROSS REF TO WHICH FUNCTION OR FUNCTIONS ESTABLISH PROPERTIES !! (VERY IMPORTANT)
741@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
742
743@c -----------------------------------------------------------------------------
744@anchor{propvars}
745@deffn {Function} propvars (@var{prop})
746
747Returns a list of those atoms on the @mref{props} list which
748have the property indicated by @var{prop}.  Thus @code{propvars (atvalue)}
749returns a list of atoms which have atvalues.
750
751@opencatbox
752@category{Declarations and inferences}
753@closecatbox
754@end deffn
755
756@c CROSS REF TO OTHER FUNCTIONS WHICH PUT/GET PROPERTIES !! (VERY IMPORTANT)
757@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
758@c ARE PROPERTIES ESTABLISHED BY put THE SAME AS PROPERTIES ESTABLISHED BY declare OR OTHER FUNCTIONS ??
759@c IS put (foo, true, integer) EQUIVALENT TO declare (foo, integer) FOR EXAMPLE ??
760
761@c -----------------------------------------------------------------------------
762@anchor{put}
763@deffn {Function} put (@var{atom}, @var{value}, @var{indicator})
764
765Assigns @var{value} to the property (specified by @var{indicator}) of
766@var{atom}.  @var{indicator} may be the name of any property, not just a
767system-defined property.
768
769@mref{rem} reverses the effect of @code{put}.
770
771@code{put} evaluates its arguments.
772@code{put} returns @var{value}.
773
774See also @mref{qput} and @mrefdot{get}
775
776Examples:
777
778@example
779(%i1) put (foo, (a+b)^5, expr);
780                                   5
781(%o1)                       (b + a)
782(%i2) put (foo, "Hello", str);
783(%o2)                         Hello
784(%i3) properties (foo);
785(%o3)            [[user properties, str, expr]]
786(%i4) get (foo, expr);
787                                   5
788(%o4)                       (b + a)
789(%i5) get (foo, str);
790(%o5)                         Hello
791@end example
792
793@opencatbox
794@category{Declarations and inferences}
795@closecatbox
796@end deffn
797
798@c -----------------------------------------------------------------------------
799@anchor{qput}
800@deffn {Function} qput (@var{atom}, @var{value}, @var{indicator})
801
802Assigns @var{value} to the property (specified by @var{indicator}) of
803@var{atom}.  This is the same as @mrefcomma{put} except that the arguments are
804quoted.
805
806See also @mrefdot{get}
807
808Example:
809
810@example
811(%i1) foo: aa$
812(%i2) bar: bb$
813(%i3) baz: cc$
814(%i4) put (foo, bar, baz);
815(%o4)                          bb
816(%i5) properties (aa);
817(%o5)                [[user properties, cc]]
818(%i6) get (aa, cc);
819(%o6)                          bb
820(%i7) qput (foo, bar, baz);
821(%o7)                          bar
822(%i8) properties (foo);
823(%o8)            [value, [user properties, baz]]
824(%i9) get ('foo, 'baz);
825(%o9)                          bar
826@end example
827
828@opencatbox
829@category{Declarations and inferences}
830@closecatbox
831@end deffn
832
833@c -----------------------------------------------------------------------------
834@anchor{rational}
835@anchor{irrational}
836@defvr  {Property} rational
837@defvrx {Property} irrational
838
839@code{declare(@var{a}, rational)} or @code{declare(@var{a}, irrational)} tells
840Maxima to recognize @var{a} as a rational or irrational real variable.
841
842See also @mrefdot{declare}
843
844@opencatbox
845@category{Declarations and inferences}
846@closecatbox
847@end defvr
848
849@c -----------------------------------------------------------------------------
850@anchor{real}
851@anchor{imaginary}
852@anchor{complex}
853@defvr  {Property} real
854@defvrx {Property} imaginary
855@defvrx {Property} complex
856
857@code{declare(@var{a}, real)}, @code{declare(@var{a}, imaginary)}, or
858@code{declare(@var{a}, complex)} tells Maxima to recognize @var{a} as a real,
859pure imaginary, or complex variable.
860
861See also @mrefdot{declare}
862
863@opencatbox
864@category{Declarations and inferences}
865@closecatbox
866@end defvr
867
868@c CROSS REF TO OTHER FUNCTIONS WHICH PUT/GET PROPERTIES !! (VERY IMPORTANT)
869@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
870@c HOW DOES THIS INTERACT WITH declare OR OTHER PROPERTY-ESTABLISHING FUNCTIONS ??
871@c HOW IS THIS DIFFERENT FROM remove ??
872
873@c -----------------------------------------------------------------------------
874@anchor{rem}
875@deffn {Function} rem (@var{atom}, @var{indicator})
876
877Removes the property indicated by @var{indicator} from @var{atom}.
878@code{rem} reverses the effect of @mrefdot{put}
879
880@code{rem} returns @code{done} if @var{atom} had an @var{indicator} property
881when @code{rem} was called, or @code{false} if it had no such property.
882
883@opencatbox
884@category{Declarations and inferences}
885@closecatbox
886@end deffn
887
888@c CROSS REF TO OTHER FUNCTIONS WHICH PUT/GET PROPERTIES !! (VERY IMPORTANT)
889@c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
890@c HOW DOES THIS INTERACT WITH declare OR OTHER PROPERTY-ESTABLISHING FUNCTIONS ??
891@c HOW IS THIS DIFFERENT FROM rem ??
892
893@c -----------------------------------------------------------------------------
894@anchor{remove}
895@deffn  {Function} remove @
896@fname{remove} (@var{a_1}, @var{p_1}, @dots{}, @var{a_n}, @var{p_n}) @
897@fname{remove} ([@var{a_1}, @dots{}, @var{a_m}], [@var{p_1}, @dots{}, @var{p_n}], @dots{}) @
898@fname{remove} ("@var{a}", operator) @
899@fname{remove} (@var{a}, transfun) @
900@fname{remove} (all, @var{p})
901
902Removes properties associated with atoms.
903
904@code{remove (@var{a_1}, @var{p_1}, ..., @var{a_n}, @var{p_n})}
905removes property @code{p_k} from atom @code{a_k}.
906
907@code{remove ([@var{a_1}, ..., @var{a_m}], [@var{p_1}, ..., @var{p_n}], ...)}
908removes properties @code{@var{p_1}, ..., @var{p_n}}
909from atoms @var{a_1}, @dots{}, @var{a_m}.
910There may be more than one pair of lists.
911
912@c VERIFY THAT THIS WORKS AS ADVERTISED
913@code{remove (all, @var{p})} removes the property @var{p} from all atoms which
914have it.
915
916@c SHOULD REFER TO A LIST OF ALL SYSTEM-DEFINED PROPERTIES HERE.
917The removed properties may be system-defined properties such as
918@code{function}, @code{macro}, or @mrefdot{mode_declare}
919@code{remove} does not remove properties defined by @mrefdot{put}
920
921@c VERIFY THAT THIS WORKS AS ADVERTISED
922@c IS transfun PECULIAR TO remove ?? IF SO, SHOW SPECIAL CASE AS @defunx
923A property may be @code{transfun} to remove
924the translated Lisp version of a function.
925After executing this, the Maxima version of the function is executed
926rather than the translated version.
927
928@code{remove ("@var{a}", operator)} or, equivalently,
929@code{remove ("@var{a}", op)} removes from @var{a} the operator properties
930declared by @mrefcomma{prefix} @mrefcomma{infix}@w{}
931@mxrefcomma{function_nary, nary} @mrefcomma{postfix} @mrefcomma{matchfix} or
932@mrefdot{nofix}  Note that the name of the operator must be written as a quoted
933string.
934
935@code{remove} always returns @code{done} whether or not an atom has a specified
936property.  This behavior is unlike the more specific remove functions
937@mrefcomma{remvalue} @mrefcomma{remarray} @mrefcomma{remfunction} and
938@mrefdot{remrule}
939
940@code{remove} quotes its arguments.
941
942@c IN SERIOUS NEED OF EXAMPLES HERE
943@opencatbox
944@category{Declarations and inferences}
945@closecatbox
946@end deffn
947
948@c -----------------------------------------------------------------------------
949@anchor{scalar}
950@defvr {Property} scalar
951
952@code{declare(@var{a}, scalar)} tells Maxima to consider @var{a} a scalar
953variable.
954
955See also @mrefdot{declare}
956
957@opencatbox
958@category{Declarations and inferences}
959@closecatbox
960@end defvr
961
962@c NEEDS CLARIFICATION AND EXAMPLES
963
964@c -----------------------------------------------------------------------------
965@anchor{scalarp}
966@deffn {Function} scalarp (@var{expr})
967
968Returns @code{true} if @var{expr} is a number, constant, or variable declared
969@mref{scalar} with @mrefcomma{declare} or composed entirely of numbers,
970constants, and such variables, but not containing matrices or lists.
971
972See also the predicate function @mrefdot{nonscalarp}
973
974@opencatbox
975@category{Predicate functions}
976@category{Vectors}
977@category{Matrices}
978@closecatbox
979@end deffn
980
981@c -----------------------------------------------------------------------------
982@node Functions and Variables for Facts, Functions and Variables for Predicates, Functions and Variables for Properties, Maximas Database
983@section Functions and Variables for Facts
984@c -----------------------------------------------------------------------------
985
986@c -----------------------------------------------------------------------------
987@anchor{activate}
988@deffn {Function} activate (@var{context_1}, @dots{}, @var{context_n})
989
990Activates the contexts @var{context_1}, @dots{}, @var{context_n}.
991The facts in these contexts are then available to
992make deductions and retrieve information.
993The facts in these contexts are not listed by @code{facts ()}.
994
995The variable @mref{activecontexts} is the list
996of contexts which are active by way of the @code{activate} function.
997
998@opencatbox
999@category{Declarations and inferences}
1000@closecatbox
1001@end deffn
1002
1003@c -----------------------------------------------------------------------------
1004@anchor{activecontexts}
1005@defvr {System variable} activecontexts
1006Default value: @code{[]}
1007
1008@code{activecontexts} is a list of the contexts which are active
1009by way of the @mref{activate} function, as opposed to being active because
1010they are subcontexts of the current context.
1011
1012@opencatbox
1013@category{Declarations and inferences}
1014@closecatbox
1015@end defvr
1016
1017@c THERE IS PROBABLY MORE TO THE STORY THAN WHAT IS INDICATED HERE ...
1018
1019@c -----------------------------------------------------------------------------
1020@anchor{askinteger}
1021@deffn  {Function} askinteger @
1022@fname{askinteger} (@var{expr}, integer) @
1023@fname{askinteger} (@var{expr}) @
1024@fname{askinteger} (@var{expr}, even) @
1025@fname{askinteger} (@var{expr}, odd)
1026
1027@code{askinteger (@var{expr}, integer)} attempts to determine from the
1028@code{assume} database whether @var{expr} is an integer.
1029@code{askinteger} prompts the user if it cannot tell otherwise,
1030@c UMM, askinteger AND asksign DO NOT APPEAR TO HAVE ANY EFFECT ON THE assume
1031@c DATABASE !!!
1032and attempt to install the information in the database if possible.
1033@code{askinteger (@var{expr})} is equivalent to
1034@code{askinteger (@var{expr}, integer)}.
1035
1036@code{askinteger (@var{expr}, even)} and @code{askinteger (@var{expr}, odd)}
1037likewise attempt to determine if @var{expr} is an even integer or odd integer,
1038respectively.
1039
1040@opencatbox
1041@category{Declarations and inferences}
1042@closecatbox
1043@end deffn
1044
1045@c THERE IS PROBABLY MORE TO THE STORY THAN WHAT IS INDICATED HERE ...
1046
1047@c -----------------------------------------------------------------------------
1048@anchor{asksign}
1049@deffn {Function} asksign (@var{expr})
1050
1051First attempts to determine whether the specified
1052expression is positive, negative, or zero.  If it cannot, it asks the
1053user the necessary questions to complete its deduction.  The user's
1054answer is recorded in the data base for the duration of the current
1055computation.  The return value of @code{asksign} is one of @code{pos},
1056@code{neg}, or @code{zero}.
1057
1058@opencatbox
1059@category{Declarations and inferences}
1060@closecatbox
1061@end deffn
1062
1063@c -----------------------------------------------------------------------------
1064@anchor{assume}
1065@deffn {Function} assume (@var{pred_1}, @dots{}, @var{pred_n})
1066
1067Adds predicates @var{pred_1}, @dots{}, @var{pred_n} to the current context.
1068If a predicate is inconsistent or redundant with the predicates in the current
1069context, it is not added to the context.  The context accumulates predicates
1070from each call to @code{assume}.
1071
1072@code{assume} returns a list whose elements are the predicates added to the
1073context or the atoms @code{redundant} or @code{inconsistent} where applicable.
1074
1075The predicates @var{pred_1}, @dots{}, @var{pred_n} can only be expressions
1076with the relational operators @code{< <= equal notequal >=} and @code{>}.
1077Predicates cannot be literal equality @code{=} or literal inequality @code{#}
1078expressions, nor can they be predicate functions such as @code{integerp}.
1079
1080Compound predicates of the form @code{@var{pred_1} and ... and @var{pred_n}}
1081are recognized, but not @code{@var{pred_1} or ... or @var{pred_n}}.
1082@code{not @var{pred_k}} is recognized if @var{pred_k} is a relational predicate.
1083Expressions of the form @code{not (@var{pred_1} and @var{pred_2})}
1084and @code{not (@var{pred_1} or @var{pred_2})} are not recognized.
1085
1086Maxima's deduction mechanism is not very strong;
1087there are many obvious consequences which cannot be determined by @mrefdot{is}
1088This is a known weakness.
1089
1090@code{assume} does not handle predicates with complex numbers.  If a predicate
1091contains a complex number @code{assume} returns @code{inconsistent} or
1092@code{redunant}.
1093
1094@code{assume} evaluates its arguments.
1095
1096See also @mrefcomma{is} @mrefcomma{facts} @mrefcomma{forget}@w{}
1097@mrefcomma{context} and @mrefdot{declare}
1098
1099Examples:
1100
1101@c ===beg===
1102@c assume (xx > 0, yy < -1, zz >= 0);
1103@c assume (aa < bb and bb < cc);
1104@c facts ();
1105@c is (xx > yy);
1106@c is (yy < -yy);
1107@c is (sinh (bb - aa) > 0);
1108@c forget (bb > aa);
1109@c prederror : false;
1110@c is (sinh (bb - aa) > 0);
1111@c is (bb^2 < cc^2);
1112@c ===end===
1113@example
1114(%i1) assume (xx > 0, yy < -1, zz >= 0);
1115(%o1)              [xx > 0, yy < - 1, zz >= 0]
1116(%i2) assume (aa < bb and bb < cc);
1117(%o2)                  [bb > aa, cc > bb]
1118(%i3) facts ();
1119(%o3)     [xx > 0, - 1 > yy, zz >= 0, bb > aa, cc > bb]
1120(%i4) is (xx > yy);
1121(%o4)                         true
1122(%i5) is (yy < -yy);
1123(%o5)                         true
1124(%i6) is (sinh (bb - aa) > 0);
1125(%o6)                         true
1126(%i7) forget (bb > aa);
1127(%o7)                       [bb > aa]
1128(%i8) prederror : false;
1129(%o8)                         false
1130(%i9) is (sinh (bb - aa) > 0);
1131(%o9)                        unknown
1132(%i10) is (bb^2 < cc^2);
1133(%o10)                       unknown
1134@end example
1135
1136@opencatbox
1137@category{Declarations and inferences}
1138@closecatbox
1139@end deffn
1140
1141@c -----------------------------------------------------------------------------
1142@anchor{assumescalar}
1143@defvr {Option variable} assumescalar
1144Default value: @code{true}
1145
1146@code{assumescalar} helps govern whether expressions @code{expr}
1147for which @code{nonscalarp (expr)} is @code{false}
1148are assumed to behave like scalars for certain transformations.
1149
1150Let @code{expr} represent any expression other than a list or a matrix,
1151and let @code{[1, 2, 3]} represent any list or matrix.
1152Then @code{expr . [1, 2, 3]} yields @code{[expr, 2 expr, 3 expr]}
1153if @code{assumescalar} is @code{true}, or @code{scalarp (expr)} is
1154@code{true}, or @code{constantp (expr)} is @code{true}.
1155
1156If @code{assumescalar} is @code{true}, such
1157expressions will behave like scalars only for commutative
1158operators, but not for noncommutative multiplication @code{.}.
1159
1160When @code{assumescalar} is @code{false}, such
1161expressions will behave like non-scalars.
1162
1163When @code{assumescalar} is @code{all}, such expressions will behave like
1164scalars for all the operators listed above.
1165
1166@opencatbox
1167@category{Declarations and inferences}
1168@closecatbox
1169@end defvr
1170
1171@c -----------------------------------------------------------------------------
1172@need 800
1173@anchor{assume_pos}
1174@defvr {Option variable} assume_pos
1175Default value: @code{false}
1176
1177When @code{assume_pos} is @code{true} and the sign of a parameter @var{x}
1178cannot be determined from the current context
1179@c WHAT ARE THOSE OTHER CONSIDERATIONS ??
1180or other considerations,
1181@code{sign} and @code{asksign (@var{x})} return @code{true}.
1182This may forestall some automatically-generated @code{asksign} queries,
1183such as may arise from @code{integrate} or other computations.
1184
1185By default, a parameter is @var{x} such that @code{symbolp (@var{x})}
1186or @code{subvarp (@var{x})}.
1187The class of expressions considered parameters can be modified to some extent
1188via the variable @code{assume_pos_pred}.
1189
1190@code{sign} and @code{asksign} attempt to deduce the sign of expressions
1191from the sign of operands within the expression.
1192For example, if @code{a} and @code{b} are both positive,
1193then @code{a + b} is also positive.
1194
1195However, there is no way to bypass all @code{asksign} queries.
1196In particular, when the @code{asksign} argument is a
1197difference @code{@var{x} - @var{y}} or a logarithm @code{log(@var{x})},
1198@code{asksign} always requests an input from the user,
1199even when @code{assume_pos} is @code{true} and @code{assume_pos_pred} is
1200a function which returns @code{true} for all arguments.
1201
1202@c NEED EXAMPLES HERE
1203@opencatbox
1204@category{Declarations and inferences}
1205@closecatbox
1206@end defvr
1207
1208@c -----------------------------------------------------------------------------
1209@anchor{assume_pos_pred}
1210@defvr {Option variable} assume_pos_pred
1211Default value: @code{false}
1212
1213When @code{assume_pos_pred} is assigned the name of a function
1214or a lambda expression of one argument @var{x},
1215that function is called to determine
1216whether @var{x} is considered a parameter for the purpose of @code{assume_pos}.
1217@code{assume_pos_pred} is ignored when @code{assume_pos} is @code{false}.
1218
1219The @code{assume_pos_pred} function is called by @code{sign} and @code{asksign}
1220with an argument @var{x}
1221which is either an atom, a subscripted variable, or a function call expression.
1222If the @code{assume_pos_pred} function returns @code{true},
1223@var{x} is considered a parameter for the purpose of @code{assume_pos}.
1224
1225By default, a parameter is @var{x} such that @code{symbolp (@var{x})}
1226or @code{subvarp (@var{x})}.
1227
1228See also @mref{assume} and @mrefdot{assume_pos}
1229
1230Examples:
1231
1232@c ===beg===
1233@c assume_pos: true$
1234@c assume_pos_pred: symbolp$
1235@c sign (a);
1236@c sign (a[1]);
1237@c assume_pos_pred: lambda ([x], display (x), true)$
1238@c asksign (a);
1239@c asksign (a[1]);
1240@c asksign (foo (a));
1241@c asksign (foo (a) + bar (b));
1242@c asksign (log (a));
1243@c input:p;
1244@c asksign (a - b);
1245@c input:p;
1246@c ===end===
1247@example
1248(%i1) assume_pos: true$
1249(%i2) assume_pos_pred: symbolp$
1250(%i3) sign (a);
1251(%o3)                          pos
1252(%i4) sign (a[1]);
1253(%o4)                          pnz
1254(%i5) assume_pos_pred: lambda ([x], display (x), true)$
1255(%i6) asksign (a);
1256                              x = a
1257
1258(%o6)                          pos
1259(%i7) asksign (a[1]);
1260                             x = a
1261                                  1
1262
1263(%o7)                          pos
1264(%i8) asksign (foo (a));
1265                           x = foo(a)
1266
1267(%o8)                          pos
1268(%i9) asksign (foo (a) + bar (b));
1269                           x = foo(a)
1270
1271                           x = bar(b)
1272
1273(%o9)                          pos
1274(%i10) asksign (log (a));
1275                              x = a
1276
1277Is  a - 1  positive, negative, or zero?
1278
1279p;
1280(%o10)                         pos
1281(%i11) asksign (a - b);
1282                              x = a
1283
1284                              x = b
1285
1286                              x = a
1287
1288                              x = b
1289
1290Is  b - a  positive, negative, or zero?
1291
1292p;
1293(%o11)                         neg
1294@end example
1295
1296@opencatbox
1297@category{Declarations and inferences}
1298@closecatbox
1299@end defvr
1300
1301@c -----------------------------------------------------------------------------
1302@anchor{context}
1303@defvr {Option variable} context
1304Default value: @code{initial}
1305
1306@code{context} names the collection of facts maintained by @mref{assume} and
1307@mrefdot{forget}  @code{assume} adds facts to the collection named by
1308@code{context}, while @code{forget} removes facts.
1309
1310Binding @code{context} to a name @var{foo} changes the current context to
1311@var{foo}.  If the specified context @var{foo} does not yet exist,
1312it is created automatically by a call to @mrefdot{newcontext}
1313@c ISN'T THIS NEXT BIT EQUIVALENT TO THE FIRST ??
1314The specified context is activated automatically.
1315
1316See @mref{contexts} for a general description of the context mechanism.
1317
1318@opencatbox
1319@category{Declarations and inferences}
1320@closecatbox
1321@end defvr
1322
1323@c UMM, I'M HAVING TROUBLE GETTING THE CONTEXT-SWITCHING STUFF TO BEHAVE AS EXPECTED
1324@c SOME EXAMPLES WILL HELP A LOT HERE
1325
1326@c -----------------------------------------------------------------------------
1327@anchor{contexts}
1328@defvr {Option variable} contexts
1329Default value: @code{[initial, global]}
1330
1331@code{contexts} is a list of the contexts which
1332currently exist, including the currently active context.
1333
1334The context mechanism makes it possible for a user to bind together
1335and name a collection of facts, called a context.
1336Once this is done, the user can have Maxima assume or forget large numbers
1337of facts merely by activating or deactivating their context.
1338
1339Any symbolic atom can be a context, and the facts contained in that
1340context will be retained in storage until destroyed one by one
1341by calling @mref{forget} or destroyed as a whole by calling @mref{kill}@w{}
1342to destroy the context to which they belong.
1343
1344Contexts exist in a hierarchy, with the root always being
1345the context @code{global}, which contains information about Maxima that some
1346functions need.  When in a given context, all the facts in that
1347context are "active" (meaning that they are used in deductions and
1348retrievals) as are all the facts in any context which is a subcontext
1349of the active context.
1350
1351When a fresh Maxima is started up, the user is in a
1352context called @code{initial}, which has @code{global} as a subcontext.
1353
1354See also @mrefcomma{facts} @mrefcomma{newcontext} @mrefcomma{supcontext}@w{}
1355@mrefcomma{killcontext} @mrefcomma{activate} @mrefcomma{deactivate}@w{}
1356@mrefcomma{assume} and @mrefdot{forget}
1357
1358@opencatbox
1359@category{Declarations and inferences}
1360@closecatbox
1361@end defvr
1362
1363@c -----------------------------------------------------------------------------
1364@anchor{deactivate}
1365@deffn {Function} deactivate (@var{context_1}, @dots{}, @var{context_n})
1366
1367Deactivates the specified contexts @var{context_1}, @dots{}, @var{context_n}.
1368
1369@opencatbox
1370@category{Declarations and inferences}
1371@closecatbox
1372@end deffn
1373
1374@c -----------------------------------------------------------------------------
1375@anchor{facts}
1376@deffn  {Function} facts @
1377@fname{facts} (@var{item}) @
1378@fname{facts} ()
1379
1380If @var{item} is the name of a context, @code{facts (@var{item})} returns a
1381list of the facts in the specified context.
1382
1383If @var{item} is not the name of a context, @code{facts (@var{item})} returns a
1384list of the facts known about @var{item} in the current context.  Facts that
1385are active, but in a different context, are not listed.
1386
1387@code{facts ()} (i.e., without an argument) lists the current context.
1388
1389@opencatbox
1390@category{Declarations and inferences}
1391@closecatbox
1392@end deffn
1393
1394@c -----------------------------------------------------------------------------
1395@anchor{forget}
1396@deffn  {Function} forget @
1397@fname{forget} (@var{pred_1}, @dots{}, @var{pred_n}) @
1398@fname{forget} (@var{L})
1399
1400Removes predicates established by @mrefdot{assume}
1401The predicates may be expressions equivalent to (but not necessarily identical
1402to) those previously assumed.
1403
1404@code{forget (@var{L})}, where @var{L} is a list of predicates,
1405forgets each item on the list.
1406
1407@opencatbox
1408@category{Declarations and inferences}
1409@closecatbox
1410@end deffn
1411
1412@c -----------------------------------------------------------------------------
1413@anchor{is}
1414@deffn {Function} is (@var{expr})
1415
1416Attempts to determine whether the predicate @var{expr} is provable from the
1417facts in the @code{assume} database.
1418
1419If the predicate is provably @code{true} or @code{false}, @code{is} returns
1420@code{true} or @code{false}, respectively.  Otherwise, the return value is
1421governed by the global flag @mrefdot{prederror}  When @code{prederror} is
1422@code{true}, @code{is} complains with an error message.  Otherwise, @code{is}
1423returns @code{unknown}.
1424
1425@code{ev(@var{expr}, pred)} (which can be written  @code{@var{expr}, pred} at
1426the interactive prompt) is equivalent to @code{is(@var{expr})}.
1427
1428See also @mrefcomma{assume} @mrefcomma{facts} and @mrefdot{maybe}
1429
1430Examples:
1431
1432@code{is} causes evaluation of predicates.
1433
1434@c ===beg===
1435@c %pi > %e;
1436@c is (%pi > %e);
1437@c ===end===
1438@example
1439(%i1) %pi > %e;
1440(%o1)                       %pi > %e
1441(%i2) is (%pi > %e);
1442(%o2)                         true
1443@end example
1444
1445@code{is} attempts to derive predicates from the @code{assume} database.
1446
1447@c ===beg===
1448@c assume (a > b);
1449@c assume (b > c);
1450@c is (a < b);
1451@c is (a > c);
1452@c is (equal (a, c));
1453@c ===end===
1454@example
1455(%i1) assume (a > b);
1456(%o1)                        [a > b]
1457(%i2) assume (b > c);
1458(%o2)                        [b > c]
1459(%i3) is (a < b);
1460(%o3)                         false
1461(%i4) is (a > c);
1462(%o4)                         true
1463(%i5) is (equal (a, c));
1464(%o5)                         false
1465@end example
1466
1467If @code{is} can neither prove nor disprove a predicate from the @code{assume}
1468database, the global flag @code{prederror} governs the behavior of @code{is}.
1469
1470@c ===beg===
1471@c assume (a > b);
1472@c prederror: true$
1473@c is (a > 0);
1474@c prederror: false$
1475@c is (a > 0);
1476@c ===end===
1477@example
1478(%i1) assume (a > b);
1479(%o1)                        [a > b]
1480(%i2) prederror: true$
1481(%i3) is (a > 0);
1482Maxima was unable to evaluate the predicate:
1483a > 0
1484 -- an error.  Quitting.  To debug this try debugmode(true);
1485(%i4) prederror: false$
1486(%i5) is (a > 0);
1487(%o5)                        unknown
1488@end example
1489
1490@opencatbox
1491@category{Predicate functions}
1492@category{Declarations and inferences}
1493@closecatbox
1494@end deffn
1495
1496@c -----------------------------------------------------------------------------
1497@anchor{killcontext}
1498@deffn {Function} killcontext (@var{context_1}, @dots{}, @var{context_n})
1499
1500Kills the contexts @var{context_1}, @dots{}, @var{context_n}.
1501
1502If one of the contexts is the current context, the new current context will
1503become the first available subcontext of the current context which has not been
1504killed.  If the first available unkilled context is @code{global} then
1505@code{initial} is used instead.  If the @code{initial} context is killed, a
1506new, empty @code{initial} context is created.
1507
1508@code{killcontext} refuses to kill a context which is
1509currently active, either because it is a subcontext of the current
1510context, or by use of the function @mrefdot{activate}
1511
1512@code{killcontext} evaluates its arguments.
1513@code{killcontext} returns @code{done}.
1514
1515@opencatbox
1516@category{Declarations and inferences}
1517@closecatbox
1518@end deffn
1519
1520@c -----------------------------------------------------------------------------
1521@anchor{maybe}
1522@deffn {Function} maybe (@var{expr})
1523
1524Attempts to determine whether the predicate @var{expr} is provable from the
1525facts in the @code{assume} database.
1526
1527If the predicate is provably @code{true} or @code{false}, @code{maybe} returns
1528@code{true} or @code{false}, respectively.  Otherwise, @code{maybe} returns
1529@code{unknown}.
1530
1531@code{maybe} is functionally equivalent to @code{is} with
1532@code{prederror: false}, but the result is computed without actually assigning
1533a value to @code{prederror}.
1534
1535See also @mrefcomma{assume} @mrefcomma{facts} and @mrefdot{is}
1536
1537Examples:
1538
1539@c ===beg===
1540@c maybe (x > 0);
1541@c assume (x > 1);
1542@c maybe (x > 0);
1543@c ===end===
1544@example
1545(%i1) maybe (x > 0);
1546(%o1)                        unknown
1547(%i2) assume (x > 1);
1548(%o2)                        [x > 1]
1549(%i3) maybe (x > 0);
1550(%o3)                         true
1551@end example
1552
1553@opencatbox
1554@category{Predicate functions}
1555@category{Declarations and inferences}
1556@closecatbox
1557@end deffn
1558
1559@c -----------------------------------------------------------------------------
1560@anchor{newcontext}
1561@deffn {Function} newcontext @
1562@fname{newcontext} (@var{name}) @
1563@fname{newcontext} ()
1564
1565Creates a new, empty context, called @var{name}, which
1566has @code{global} as its only subcontext.  The newly-created context
1567becomes the currently active context.
1568
1569If @var{name} is not specified, a new name is created (via @code{gensym}) and returned.
1570
1571@code{newcontext} evaluates its argument.
1572@code{newcontext} returns @var{name} (if specified) or the new context name.
1573
1574@opencatbox
1575@category{Declarations and inferences}
1576@closecatbox
1577@end deffn
1578
1579@c -----------------------------------------------------------------------------
1580@anchor{sign}
1581@deffn {Function} sign (@var{expr})
1582
1583Attempts to determine the sign of @var{expr} on the basis of the facts in the
1584current data base.  It returns one of the following answers: @code{pos}
1585(positive), @code{neg} (negative), @code{zero}, @code{pz} (positive or zero),
1586@code{nz} (negative or zero), @code{pn} (positive or negative), or @code{pnz}
1587(positive, negative, or zero, i.e. nothing known).
1588
1589@opencatbox
1590@category{Declarations and inferences}
1591@closecatbox
1592@end deffn
1593
1594@c -----------------------------------------------------------------------------
1595@anchor{supcontext}
1596@deffn {Function} supcontext @
1597@fname{supcontext} (@var{name}, @var{context}) @
1598@fname{supcontext} (@var{name}) @
1599@fname{supcontext} ()
1600
1601Creates a new context, called @var{name}, which has @var{context} as a
1602subcontext.  @var{context} must exist.
1603
1604If @var{context} is not specified, the current context is assumed.
1605
1606If @var{name} is not specified, a new name is created (via @code{gensym}) and returned.
1607
1608@code{supcontext} evaluates its argument.
1609@code{supcontext} returns @var{name} (if specified) or the new context name.
1610
1611@opencatbox
1612@category{Declarations and inferences}
1613@closecatbox
1614@end deffn
1615
1616@c -----------------------------------------------------------------------------
1617@node Functions and Variables for Predicates, , Functions and Variables for Facts, Maximas Database
1618@section Functions and Variables for Predicates
1619@c -----------------------------------------------------------------------------
1620
1621@c -----------------------------------------------------------------------------
1622@anchor{charfun}
1623@deffn {Function} charfun (@var{p})
1624
1625Return 0 when the predicate @var{p} evaluates to @code{false}; return 1 when
1626the predicate evaluates to @code{true}.  When the predicate evaluates to
1627something other than @code{true} or @code{false} (unknown),  return a noun form.
1628
1629Examples:
1630
1631@c ===beg===
1632@c charfun (x < 1);
1633@c subst (x = -1, %);
1634@c e : charfun ('"and" (-1 < x, x < 1))$
1635@c [subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
1636@c ===end===
1637@example
1638(%i1) charfun (x < 1);
1639(%o1)                    charfun(x < 1)
1640(%i2) subst (x = -1, %);
1641(%o2)                           1
1642(%i3) e : charfun ('"and" (-1 < x, x < 1))$
1643(%i4) [subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
1644(%o4)                       [0, 1, 0]
1645@end example
1646
1647@opencatbox
1648@category{Mathematical functions}
1649@closecatbox
1650@end deffn
1651
1652@c -----------------------------------------------------------------------------
1653@anchor{compare}
1654@deffn {Function} compare (@var{x}, @var{y})
1655
1656Return a comparison operator @var{op} (@code{<}, @code{<=}, @code{>}, @code{>=},
1657@code{=}, or @code{#}) such that @code{is (@var{x} @var{op} @var{y})} evaluates
1658to @code{true}; when either @var{x} or @var{y} depends on @code{%i} and
1659@code{@var{x} # @var{y}}, return @code{notcomparable}; when there is no such
1660operator or Maxima isn't able to determine the operator, return @code{unknown}.
1661
1662Examples:
1663
1664@c ===beg===
1665@c compare (1, 2);
1666@c compare (1, x);
1667@c compare (%i, %i);
1668@c compare (%i, %i + 1);
1669@c compare (1/x, 0);
1670@c compare (x, abs(x));
1671@c ===end===
1672@example
1673(%i1) compare (1, 2);
1674(%o1)                           <
1675(%i2) compare (1, x);
1676(%o2)                        unknown
1677(%i3) compare (%i, %i);
1678(%o3)                           =
1679(%i4) compare (%i, %i + 1);
1680(%o4)                     notcomparable
1681(%i5) compare (1/x, 0);
1682(%o5)                           #
1683(%i6) compare (x, abs(x));
1684(%o6)                          <=
1685@end example
1686
1687The function @code{compare} doesn't try to determine whether the real domains of
1688its arguments are nonempty; thus
1689
1690@c ===beg===
1691@c compare (acos (x^2 + 1), acos (x^2 + 1) + 1);
1692@c ===end===
1693@example
1694(%i1) compare (acos (x^2 + 1), acos (x^2 + 1) + 1);
1695(%o1)                           <
1696@end example
1697
1698@c IT IS NOT QUITE TRUE, WHAT ABOUT x=0 ?
1699The real domain of @code{acos (x^2 + 1)} is empty.
1700
1701@opencatbox
1702@category{Declarations and inferences}
1703@closecatbox
1704@end deffn
1705
1706@c -----------------------------------------------------------------------------
1707@anchor{equal}
1708@deffn {Function} equal (@var{a}, @var{b})
1709
1710Represents equivalence, that is, equal value.
1711
1712By itself, @code{equal} does not evaluate or simplify.
1713The function @mref{is} attempts to evaluate @code{equal} to a Boolean value.
1714@code{is(equal(@var{a}, @var{b}))} returns @code{true} (or @code{false}) if
1715and only if @var{a} and @var{b} are equal (or not equal) for all possible
1716values of their variables, as determined by evaluating
1717@code{ratsimp(@var{a} - @var{b})}; if @mref{ratsimp} returns 0, the two
1718expressions are considered equivalent.  Two expressions may be equivalent even
1719if they are not syntactically equal (i.e., identical).
1720
1721When @code{is} fails to reduce @code{equal} to @code{true} or @code{false}, the
1722result is governed by the global flag @mrefdot{prederror}  When @code{prederror}
1723is @code{true}, @code{is} complains with an error message.  Otherwise, @code{is}
1724returns @code{unknown}.
1725
1726In addition to @code{is}, some other operators evaluate @code{equal} and
1727@code{notequal} to @code{true} or @code{false}, namely @mrefcomma{if}@w{}
1728@mrefcomma{and} @mrefcomma{or} and @mrefdot{not}
1729
1730@c FOLLOWING STATEMENT IS MORE OR LESS TRUE BUT I DON'T THINK THE DETAILS ARE CORRECT
1731@c Declarations (integer, complex, etc)
1732@c for variables appearing in @var{a} and @var{b} are ignored by @code{equal}.
1733@c All variables are effectively assumed to be real-valued.
1734
1735The negation of @code{equal} is @mrefdot{notequal}
1736
1737Examples:
1738
1739By itself, @code{equal} does not evaluate or simplify.
1740
1741@c ===beg===
1742@c equal (x^2 - 1, (x + 1) * (x - 1));
1743@c equal (x, x + 1);
1744@c equal (x, y);
1745@c ===end===
1746@example
1747(%i1) equal (x^2 - 1, (x + 1) * (x - 1));
1748                        2
1749(%o1)            equal(x  - 1, (x - 1) (x + 1))
1750(%i2) equal (x, x + 1);
1751(%o2)                    equal(x, x + 1)
1752(%i3) equal (x, y);
1753(%o3)                      equal(x, y)
1754@end example
1755
1756The function @code{is} attempts to evaluate @code{equal} to a Boolean value.
1757@code{is(equal(@var{a}, @var{b}))} returns @code{true} when
1758@code{ratsimp(@var{a} - @var{b})} returns 0.  Two expressions may be equivalent
1759even if they are not syntactically equal (i.e., identical).
1760
1761@c ===beg===
1762@c ratsimp (x^2 - 1 - (x + 1) * (x - 1));
1763@c is (equal (x^2 - 1, (x + 1) * (x - 1)));
1764@c is (x^2 - 1 = (x + 1) * (x - 1));
1765@c ratsimp (x - (x + 1));
1766@c is (equal (x, x + 1));
1767@c is (x = x + 1);
1768@c ratsimp (x - y);
1769@c is (equal (x, y));
1770@c is (x = y);
1771@c ===end===
1772@example
1773(%i1) ratsimp (x^2 - 1 - (x + 1) * (x - 1));
1774(%o1)                           0
1775(%i2) is (equal (x^2 - 1, (x + 1) * (x - 1)));
1776(%o2)                         true
1777(%i3) is (x^2 - 1 = (x + 1) * (x - 1));
1778(%o3)                         false
1779(%i4) ratsimp (x - (x + 1));
1780(%o4)                          - 1
1781(%i5) is (equal (x, x + 1));
1782(%o5)                         false
1783(%i6) is (x = x + 1);
1784(%o6)                         false
1785(%i7) ratsimp (x - y);
1786(%o7)                         x - y
1787(%i8) is (equal (x, y));
1788(%o8)                        unknown
1789(%i9) is (x = y);
1790(%o9)                         false
1791@end example
1792
1793When @code{is} fails to reduce @code{equal} to @code{true} or @code{false},
1794the result is governed by the global flag @code{prederror}.
1795
1796@c ===beg===
1797@c [aa : x^2 + 2*x + 1, bb : x^2 - 2*x - 1];
1798@c ratsimp (aa - bb);
1799@c prederror : true;
1800@c is (equal (aa, bb));
1801@c prederror : false;
1802@c is (equal (aa, bb));
1803@c ===end===
1804@example
1805(%i1) [aa : x^2 + 2*x + 1, bb : x^2 - 2*x - 1];
1806                    2             2
1807(%o1)             [x  + 2 x + 1, x  - 2 x - 1]
1808(%i2) ratsimp (aa - bb);
1809(%o2)                        4 x + 2
1810(%i3) prederror : true;
1811(%o3)                         true
1812(%i4) is (equal (aa, bb));
1813Maxima was unable to evaluate the predicate:
1814       2             2
1815equal(x  + 2 x + 1, x  - 2 x - 1)
1816 -- an error.  Quitting.  To debug this try debugmode(true);
1817(%i5) prederror : false;
1818(%o5)                         false
1819(%i6) is (equal (aa, bb));
1820(%o6)                        unknown
1821@end example
1822
1823Some operators evaluate @code{equal} and @code{notequal} to @code{true} or
1824@code{false}.
1825
1826@c ===beg===
1827@c if equal (y, y - 1) then FOO else BAR;
1828@c eq_1 : equal (x, x + 1);
1829@c eq_2 : equal (y^2 + 2*y + 1, (y + 1)^2);
1830@c [eq_1 and eq_2, eq_1 or eq_2, not eq_1];
1831@c ===end===
1832@example
1833(%i1) if equal (y, y - 1) then FOO else BAR;
1834(%o1)                          BAR
1835(%i2) eq_1 : equal (x, x + 1);
1836(%o2)                    equal(x, x + 1)
1837(%i3) eq_2 : equal (y^2 + 2*y + 1, (y + 1)^2);
1838                         2                   2
1839(%o3)             equal(y  + 2 y + 1, (y + 1) )
1840(%i4) [eq_1 and eq_2, eq_1 or eq_2, not eq_1];
1841(%o4)                  [false, true, true]
1842@end example
1843
1844Because @code{not @var{expr}} causes evaluation of @var{expr},
1845@code{not equal(@var{a}, @var{b})} is equivalent to
1846@code{is(notequal(@var{a}, @var{b}))}.
1847
1848@c ===beg===
1849@c [notequal (2*z, 2*z - 1), not equal (2*z, 2*z - 1)];
1850@c is (notequal (2*z, 2*z - 1));
1851@c ===end===
1852@example
1853(%i1) [notequal (2*z, 2*z - 1), not equal (2*z, 2*z - 1)];
1854(%o1)            [notequal(2 z, 2 z - 1), true]
1855(%i2) is (notequal (2*z, 2*z - 1));
1856(%o2)                         true
1857@end example
1858
1859@opencatbox
1860@category{Operators}
1861@closecatbox
1862@end deffn
1863
1864@c -----------------------------------------------------------------------------
1865@anchor{notequal}
1866@deffn {Function} notequal (@var{a}, @var{b})
1867
1868Represents the negation of @code{equal(@var{a}, @var{b})}.
1869
1870Examples:
1871
1872@c ===beg===
1873@c equal (a, b);
1874@c maybe (equal (a, b));
1875@c notequal (a, b);
1876@c not equal (a, b);
1877@c maybe (notequal (a, b));
1878@c assume (a > b);
1879@c equal (a, b);
1880@c maybe (equal (a, b));
1881@c notequal (a, b);
1882@c maybe (notequal (a, b));
1883@c ===end===
1884@example
1885(%i1) equal (a, b);
1886(%o1)                      equal(a, b)
1887(%i2) maybe (equal (a, b));
1888(%o2)                        unknown
1889(%i3) notequal (a, b);
1890(%o3)                    notequal(a, b)
1891(%i4) not equal (a, b);
1892(%o4)                    notequal(a, b)
1893(%i5) maybe (notequal (a, b));
1894(%o5)                        unknown
1895(%i6) assume (a > b);
1896(%o6)                        [a > b]
1897(%i7) equal (a, b);
1898(%o7)                      equal(a, b)
1899(%i8) maybe (equal (a, b));
1900(%o8)                         false
1901(%i9) notequal (a, b);
1902(%o9)                    notequal(a, b)
1903(%i10) maybe (notequal (a, b));
1904(%o10)                        true
1905@end example
1906
1907@opencatbox
1908@category{Operators}
1909@closecatbox
1910@end deffn
1911
1912@c -----------------------------------------------------------------------------
1913@anchor{unknown}
1914@deffn {Function} unknown (@var{expr})
1915
1916Returns @code{true} if and only if @var{expr} contains an operator or function
1917not recognized by the Maxima simplifier.
1918
1919@opencatbox
1920@category{Predicate functions}
1921@category{Simplification functions}
1922@closecatbox
1923@end deffn
1924
1925@c THIS FUNCTION APPEARS TO BE A HACK; SEE 4'TH ITEM BELOW
1926@c DUNNO WHETHER WE CAN CLEAR THIS UP
1927
1928@c -----------------------------------------------------------------------------
1929@anchor{zeroequiv}
1930@deffn {Function} zeroequiv (@var{expr}, @var{v})
1931
1932Tests whether the expression @var{expr} in the variable @var{v} is equivalent
1933to zero, returning @code{true}, @code{false}, or @code{dontknow}.
1934
1935@code{zeroequiv} has these restrictions:
1936
1937@enumerate
1938@item
1939Do not use functions that Maxima does not know how to
1940differentiate and evaluate.
1941@item
1942If the expression has poles on the real line, there may be errors
1943in the result (but this is unlikely to occur).
1944@item
1945If the expression contains functions which are not solutions to first order
1946differential equations (e.g. Bessel functions) there may be incorrect results.
1947@item
1948The algorithm uses evaluation at randomly chosen points for carefully selected
1949subexpressions.  This is always a somewhat hazardous business, although the
1950algorithm tries to minimize the potential for error.
1951@end enumerate
1952
1953For example @code{zeroequiv (sin(2 * x) - 2 * sin(x) * cos(x), x)} returns
1954@code{true} and @code{zeroequiv (%e^x + x, x)} returns @code{false}.
1955On the other hand @code{zeroequiv (log(a * b) - log(a) - log(b), a)} returns
1956@code{dontknow} because of the presence of an extra parameter @code{b}.
1957
1958@opencatbox
1959@category{Predicate functions}
1960@closecatbox
1961@end deffn
1962
1963