Type complexcons

John Fredsted's picture

This is a follow-up on one of the unresolved issues raised in a previous post of mine.

In view of the fact that 1 + I is indeed of type complexcons, can anybody please explain why the following is reasonable:

restart:
assume(x::complexcons):
evalc(x + conjugate(x)),
evalc(x - conjugate(x));
restart:
x := 1 + I:
evalc(x + conjugate(x)),
evalc(x - conjugate(x));
                            2 x~, 0
                             2, 2 I

complexcons

John,

Please see ?type,complexcons and ?type,complex and try this:

restart:
assume(x::complexcons):
type(x,complexcons);
assume(x::complex);
type(x,complexcons);
type(x,complex);
type(x,complex(name));

Plainly, x cannot be of type complexcons, but can be of type complex name.

Hope this helps.

J. Tarr

John Fredsted's picture

Flapping in the breeze

Please forgive me, but that does not satisfy me: Just as

restart:
assume(x::complexcons):
type(x,complexcons);

returns false, so does

restart:
assume(x::complex):
type(x,complex);

and so does

restart:
assume(x::posint):
type(x,posint);

etc., I suppose. Maybe it is just me being silly, but that does not seem reasonable because if some variable x is assumed to be of some type, then testing that variable for that type should return true. Otherwise in conjunction assume() and type() are just "flapping in the breeze".

assume and type

Sadly, this is the fact. ?type states:

Note: The type function does not check assumptions, it only considers the object itself. If you are using the assume facility, it is recommended that you use the is function.

I think because the assume facility was added at a later stage in the development of the system, and was not fully integrated.

JacquesC's picture

assume and type

'type' is for types, and 'assume' is for properties. In Maple, there used to be only types at one point, so the question "what is a type" was never really asked.

But in retrospect, the vast majority of types in Maple are ``syntactic'', in other words, they test something about the representation of an object. Of course, since types can be arbitrary computations in Maple, some are also semantic (like checking that an integer is prime). But the core types are syntactic, especially the so-called "structured types", which are really the work-horses of the dynamic type system of Maple.

Properties on the other hand are most definitely semantic. This is why one can assume that certain symbols have certain properties. 'is' then checks those properties, so in effect is a mini-automated-theorem-prover embedded in Maple (but as a pure black box).

One design decision was that all types were to be properties too. This is both really useful and (in hindsight) a serious mistake. To have both syntax and semantics together is very dangerous -- and doing this badly is the source of many of the paradoxes in logic, and incidentally includes Frege's original mistake in his logic (ie the Russel Paradox). It is not impossible to get a consistent logic that deals with both syntax and semantics, but it is remarkably hard to do so -- see Chiron: a multi-paradigm logic for one example.

As Robert Israel pointed out, a lot of types are not in fact known to assume, so 'is' cannot reason about them at all. So one needs to be careful to only use those names which are actually known to assume -- a set which is actually not documented! Just to make things more interesting, the type-formation operators (like and, or, not) are different from the property operators (And, Or, Non). Furthermore, the type logic is 2-valued [FAIL is not allowed in types] and the property logic is 3-valued!

acer's picture

bookmarking posts/responses

This is the kind of post that makes me want bookmarking capability within Mapleprimes.

acer

wiki

Perhaps a wiki could help, among other things, to organize the access to this information.

is

Having re-read the help page for the assume facility, I (re)discovered this gem:

Important: If the is command is used with a Maple type typename, it returns true if the corresponding type(..., typename) command returns true. This may lead to unexpected results.
There are convenient tests that can be used when programming with variables that carry assumptions. To test if the expression is real, use is(Im(x)=0). To test whether x is real and positive, use is(signum(x)=1). To test whether x is an integer, use is(Im(x)=0) and is(frac(x)=0).

So, if one places an assumption on something, expect the unexpected when testing the assumption, or find a test that does not involve a type-name.

J. Tarr

Robert Israel's picture

complexcons

The main problem (I almost said "the real problem") is that although complexcons is a property, Maple does not seem to know any relations between that property and others. For example:

> assume(z, complexcons):
  is(z, complex);

false

> is(z, constant);

false

> about(complexcons);
complexcons:
  nothing known about this object

Compare, for example:

> about(realcons);
realcons:
  property aliased to AndProp(real,constant)
  composite (and'ed) property, a property describing
  objects which have all the AndProp(real,constant) properties

> about(constant);
constant:
  an expression which is known to have a constant real or complex value
  a known property having {complex} as immediate parents
  and {BottomProp} as immediate children.

My suggestion is that you don't use "complexcons": use "constant" instead. If you want to assume z is a constant but is not real, use

> assume(z, AndProp(constant, Non(real)));

And then:

> evalc(z + conjugate(z));

z+conjugate(z)

John Fredsted's picture

Very valuable input

Thank you guys for your very valuable input. I will certainly bookmark this thread.

Even though I am happy to hereby having ascertained that I have not lost the ability to reason, I am worried about having to navigate through such incoherent behaviour of Maple: it seems that being neither a Maple newcomer nor a Maple master, but being in between those, can put you in some quite doubtful situations, because you are starting to take advantage of the more advanced issues of Maple without yet having the sufficient insight to avoid its unfortunate associated pitfalls. Of course, this is not the way it should be, I think.

widespread problems?

The subject of this thread seems to me quite close to this one for Axiom.

Apparently, similar problems occur there. I wonder whether there is a comparative review about how CAS implement types, properties, etc.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}