Functions and Variables for Contexts
====================================

 -- Function: activate (CONTEXT_1, ..., CONTEXT_N)
     Activates the contexts CONTEXT_1, ..., CONTEXT_N. The facts in these contexts are then available to make deductions and retrieve information. The facts in these contexts are not listed by facts ().

     The variable activecontexts is the list of contexts which are active by way of the activate function.

 -- System variable: activecontexts
     Default value: []

     activecontexts is a list of the contexts which are active by way of the activate function, as opposed to being active because they are subcontexts of the current context.

 -- Function: assume (PRED_1, ..., PRED_N)
     Adds predicates PRED_1, ..., PRED_N to the current context. If a predicate is inconsistent or redundant with the predicates in the current context, it is not added to the context. The context accumulates predicates from each call to assume.

     assume returns a list whose elements are the predicates added to the context or the atoms redundant or inconsistent where applicable.

     The predicates PRED_1, ..., PRED_N can only be expressions with the relational operators < <= equal notequal >= and >. Predicates cannot be literal equality = or literal inequality # expressions, nor can they be predicate functions such as integerp.

     Compound predicates of the form PRED_1 and ... and PRED_N are recognized, but not PRED_1 or ... or PRED_N. not PRED_K is recognized if PRED_K is a relational predicate. Expressions of the form not (PRED_1 and PRED_2) and not (PRED_1 or PRED_2) are not recognized.

     Maxima's deduction mechanism is not very strong; there are many obvious consequences which cannot be determined by is. This is a known weakness.

     assume evaluates its arguments.

     See also is, facts, forget, context, and declare.

     Examples:

          (%i1) assume (xx > 0, yy < -1, zz >= 0);
          (%o1)              [xx > 0, yy < - 1, zz >= 0]
          (%i2) assume (aa < bb and bb < cc);
          (%o2)                  [bb > aa, cc > bb]
          (%i3) facts ();
          (%o3)     [xx > 0, - 1 > yy, zz >= 0, bb > aa, cc > bb]
          (%i4) is (xx > yy);
          (%o4)                         true
          (%i5) is (yy < -yy);
          (%o5)                         true
          (%i6) is (sinh (bb - aa) > 0);
          (%o6)                         true
          (%i7) forget (bb > aa);
          (%o7)                       [bb > aa]
          (%i8) prederror : false;
          (%o8)                         false
          (%i9) is (sinh (bb - aa) > 0);
          (%o9)                        unknown
          (%i10) is (bb^2 < cc^2);
          (%o10)                       unknown

 -- Option variable: assumescalar
     Default value: true

     assumescalar helps govern whether expressions expr for which nonscalarp (expr) is false are assumed to behave like scalars for certain transformations.

     Let expr represent any expression other than a list or a matrix, and let [1, 2, 3] represent any list or matrix. Then expr . [1, 2, 3] yields [expr, 2 expr, 3 expr] if assumescalar is true, or scalarp (expr) is true, or constantp (expr) is true.

     If assumescalar is true, such expressions will behave like scalars only for commutative operators, but not for noncommutative multiplication ..

     When assumescalar is false, such expressions will behave like non-scalars.

     When assumescalar is all, such expressions will behave like scalars for all the operators listed above.

 -- Option variable: assume_pos
     Default value: false

     When assume_pos is true and the sign of a parameter X cannot be determined from the current context or other considerations, sign and asksign (X) return true. This may forestall some automatically-generated asksign queries, such as may arise from integrate or other computations.

     By default, a parameter is X such that symbolp (X) or subvarp (X). The class of expressions considered parameters can be modified to some extent via the variable assume_pos_pred.

     sign and asksign attempt to deduce the sign of expressions from the sign of operands within the expression. For example, if a and b are both positive, then a + b is also positive.

     However, there is no way to bypass all asksign queries. In particular, when the asksign argument is a difference X - Y or a logarithm log(X), asksign always requests an input from the user, even when assume_pos is true and assume_pos_pred is a function which returns true for all arguments.

 -- Option variable: assume_pos_pred
     Default value: false

     When assume_pos_pred is assigned the name of a function or a lambda expression of one argument X, that function is called to determine whether X is considered a parameter for the purpose of assume_pos. assume_pos_pred is ignored when assume_pos is false.

     The assume_pos_pred function is called by sign and asksign with an argument X which is either an atom, a subscripted variable, or a function call expression. If the assume_pos_pred function returns true, X is considered a parameter for the purpose of assume_pos.

     By default, a parameter is X such that symbolp (X) or subvarp (X).

     See also assume and assume_pos.

     Examples:

          (%i1) assume_pos: true$
          (%i2) assume_pos_pred: symbolp$
          (%i3) sign (a);
          (%o3)                          pos
          (%i4) sign (a[1]);
          (%o4)                          pnz
          (%i5) assume_pos_pred: lambda ([x], display (x), true)$
          (%i6) asksign (a);
                                        x = a

          (%o6)                          pos
          (%i7) asksign (a[1]);
                                       x = a
                                            1

          (%o7)                          pos
          (%i8) asksign (foo (a));
                                     x = foo(a)

          (%o8)                          pos
          (%i9) asksign (foo (a) + bar (b));
                                     x = foo(a)

                                     x = bar(b)

          (%o9)                          pos
          (%i10) asksign (log (a));
                                        x = a

          Is  a - 1  positive, negative, or zero?

          p;
          (%o10)                         pos
          (%i11) asksign (a - b);
                                        x = a

                                        x = b

                                        x = a

                                        x = b

          Is  b - a  positive, negative, or zero?

          p;
          (%o11)                         neg

 -- Option variable: context
     Default value: initial

     context names the collection of facts maintained by assume and forget. assume adds facts to the collection named by context, while forget removes facts.

     Binding context to a name FOO changes the current context to FOO. If the specified context FOO does not yet exist, it is created automatically by a call to newcontext. The specified context is activated automatically.

     See contexts for a general description of the context mechanism.

 -- Option variable: contexts
     Default value: [initial, global]

     contexts is a list of the contexts which currently exist, including the currently active context.

     The context mechanism makes it possible for a user to bind together and name a collection of facts, called a context. Once this is done, the user can have Maxima assume or forget large numbers of facts merely by activating or deactivating their context.

     Any symbolic atom can be a context, and the facts contained in that context will be retained in storage until destroyed one by one by calling forget or destroyed as a whole by calling kill to destroy the context to which they belong.

     Contexts exist in a hierarchy, with the root always being the context global, which contains information about Maxima that some functions need.  When in a given context, all the facts in that context are "active" (meaning that they are used in deductions and retrievals) as are all the facts in any context which is a subcontext of the active context.

     When a fresh Maxima is started up, the user is in a context called initial, which has global as a subcontext.

     See also facts, newcontext, supcontext, killcontext, activate, deactivate, assume, and forget.

 -- Function: deactivate (CONTEXT_1, ..., CONTEXT_N)
     Deactivates the specified contexts CONTEXT_1, ..., CONTEXT_N.

 -- Function: facts (ITEM)
 -- Function: facts ()
     If ITEM is the name of a context, facts (ITEM) returns a list of the facts in the specified context.

     If ITEM is not the name of a context, facts (ITEM) returns a list of the facts known about ITEM in the current context.  Facts that are active, but in a different context, are not listed.

     facts () (i.e., without an argument) lists the current context.

 -- Declaration: features
     Maxima recognizes certain mathematical properties of functions and variables. These are called "features".

     declare (X, FOO) gives the property FOO to the function or variable X.

     declare (FOO, feature) declares a new feature FOO. For example, declare ([red, green, blue], feature) declares three new features, red, green, and blue.

     The predicate featurep (X, FOO) returns true if X has the FOO property, and false otherwise.

     The infolist features is a list of known features. These are integer, noninteger, even, odd, rational, irrational, real, imaginary, complex, analytic, increasing, decreasing, oddfun, evenfun, posfun, commutative, lassociative, rassociative, symmetric, and antisymmetric, plus any user-defined features.

     features is a list of mathematical features. There is also a list of non-mathematical, system-dependent features. See status.

 -- Function: forget (PRED_1, ..., PRED_N)
 -- Function: forget (L)
     Removes predicates established by assume. The predicates may be expressions equivalent to (but not necessarily identical to) those previously assumed.

     forget (L), where L is a list of predicates, forgets each item on the list.

 -- Function: killcontext (CONTEXT_1, ..., CONTEXT_N)
     Kills the contexts CONTEXT_1, ..., CONTEXT_N.

     If one of the contexts is the current context, the new current context will become the first available subcontext of the current context which has not been killed.  If the first available unkilled context is global then initial is used instead.  If the initial context is killed, a new, empty initial context is created.

     killcontext refuses to kill a context which is currently active, either because it is a subcontext of the current context, or by use of the function activate.

     killcontext evaluates its arguments. killcontext returns done.

 -- Function: newcontext (NAME)
     Creates a new, empty context, called NAME, which has global as its only subcontext.  The newly-created context becomes the currently active context.

     newcontext evaluates its argument. newcontext returns NAME.

 -- Function: supcontext (NAME, CONTEXT)
 -- Function: supcontext (NAME)
     Creates a new context, called NAME, which has CONTEXT as a subcontext. CONTEXT must exist.

     If CONTEXT is not specified, the current context is assumed.