Search code examples
maple

Assuming many variables at once


I'm trying to set up the following constraints:

assume(E1A::integer,E2A::integer,...,E2B::integer,...,E3C::integer)

additionally(E1A>=0,E2A>=0,...,E3C>=0)

additionally(E1A<=3,E2A<=3,...,E3C<=3)

is there any way to do this without typing out all the terms E1A, E2A,...,E3C? I tried doing

for i from 0 to 3 do (assume(EiA::integer)) end do

as a shortcut, but Maple didn't like that, presumably because it didn't view the i as an indexing variable.


Solution

  • You can form names by concatenation.

    restart:
    
    assume( seq( cat(`E`,i,`A`)::integer, i=1..3 ) );
    

    And now, to test,

    [ seq( cat(`E`,i,`A`), i=1..3 ) ]:
    map( about, % ):
    
      Originally E1A, renamed E1A~:
        is assumed to be: integer
    
      Originally E2A, renamed E2A~:
        is assumed to be: integer
    
      Originally E3A, renamed E3A~:
        is assumed to be: integer
    

    You can also nest seq, eg,

    restart:
    assume( seq( seq( cat(`E`,i,abc)::integer, i=1..3), abc=[A,B,C] ) );
    
    [ seq( seq( cat(`E`,i,abc), i=1..3), abc=[A,B,C] ) ]:
    map( about, % ):