Previous Page Next Page Contents

getprop -- query properties of expressions

Introduction

getprop(f) returns a mathematical property of the expression f.

Call(s)

getprop(f)
getprop()

Parameters

f - an arithmetical expression

Returns

getprop(f) returns a property of type Type::Property, or the expression f itself. The call getprop() returns a property or the identifier Global.

Related Functions

assume, is, property::hasprop, Type::Property, unassume

Details

Example 1

If x is an integer, then x^2 + 1 must be a positive integer number:

>> assume(x, Type::Integer):
   getprop(x^2 + 1)
                               Type::PosInt

If x represents a number in the interval [1, infinity[, the expression 1 - x has the following property:

>> assume(x, Type::Interval([1], infinity)):
   getprop(1 - x)
                       ]-infinity, 0] of Type::Real
>> unassume(x):

Example 2

An expression is returned unchanged if it is constant, or if no properties are attached to the identifiers involved:

>> getprop(x), getprop(x + 2*y), getprop(sin(3))
                            x, x + 2 y, sin(3)

Example 3

Properties that are assumed for all identifiers are stored in the global variable Global. Presently, no global property is set:

>> getprop()
                                  Global

In the following, a global property is set. Now, all identifiers have this property:

>> assume(Type::Real):
   getprop(x), getprop(y), getprop((x + y)^2 + 1/2)
                  Type::Real, Type::Real, Type::Positive

The functions getprop and is combine the global property and the properties of individual identifiers with the logical ``and'':

>> assume(Type::Positive):
   assume(x, Type::Integer):
   getprop(x)
                               Type::PosInt

The global property may contradict the individual properties. In this case the ``empty property'' property::Null is returned:

>> assume(Type::Positive):
   assume(x < 0):
   getprop(x)
                              property::Null
>> delete x: unassume():

Example 4

The functions abs, Re, and Im have a ``minimal property'': they produce real values. In fact, abs produces nonnegative real values:

>> delete x:
   getprop(abs(x)), getprop(Re(x)), getprop(Im(x))
                 Type::NonNegative, Type::Real, Type::Real

Example 5

The set containing the squares of all prime numbers cannot be represented by one of the properties available in the Type library. Therefore, getprop returns the weaker property 'x^2 is a positive integer':

>> assume(x, Type::Prime):
   getprop(x^2)
                               Type::PosInt
>> unassume(x):

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000