Skip to content

Commit

Permalink
Simplify OneSM/OneAttr/OneOp/OneMutable/... etc.
Browse files Browse the repository at this point in the history
Currently we have these three variants of `One`, together
with a bunch of synonyms for each:

- `OneImmutable` == `One` == `OneAttr` == `Identity`
- `OneMutable` == `OneOp`
- `OneSameMutability` == `OneSM`

This is then repeated for `Zero`, `Inverse`, `AdditiveInverse`.

The delegation between these is already complicated enough, but each
time I have to look into this, my head starts spinning due to the many
synonyms, and I can't quite remember which is which. I propose we
narrow this down a bit:

- the variants with `SM` seems to be purely to avoid some typing, so
  I've removed all uses of them. Turns out no packages uses it, either.
  So we can mark them as obsolete.

- the `Attr` variants are also almost unused, except for a single use in
  the FinInG package (removed in FinInG 1.5.4). Still, we can safely
  mark it as obsolete, and remove all users of it beyond the
  documentation. (As a bonus, also make `TransposedMatAttr` obsolete.)

- the `Op` synonym to me also seems redundant. Alas, a ton of packages
  use them, so I mostly left those alone.

- I think it is fine to keep `One` (and `Identity`) as synonyms for
  `OneImmutable`; at least for me personally it seems I can deal with
  that one synonym sufficiently well in my head.
  • Loading branch information
fingolfin committed Dec 13, 2022
1 parent 9c02f41 commit 55ffb74
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 100 deletions.
4 changes: 2 additions & 2 deletions doc/ref/lists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,8 @@ an operation that returns a result that is mutable
(<Ref Oper="ZeroOp"/>, <Ref Oper="AdditiveInverseOp"/>,
<Ref Oper="OneOp"/>, <Ref Oper="InverseOp"/>),
and an operation whose result has the same immutability level as the argument
(<Ref Oper="ZeroSM"/>, <Ref Oper="AdditiveInverseSM"/>,
<Ref Oper="OneSM"/>, <Ref Oper="InverseSM"/>).
(<Ref Oper="ZeroSameMutability"/>, <Ref Oper="AdditiveInverseSameMutability"/>,
<Ref Oper="OneSameMutability"/>, <Ref Oper="InverseSameMutability"/>).
The last kind of operations is equivalent to the corresponding infix
operations <C>0 * <A>list</A></C>, <C>- <A>list</A></C>,
<C><A>list</A>^0</C>, and <C><A>list</A>^-1</C>.
Expand Down
10 changes: 5 additions & 5 deletions doc/ref/objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ in&nbsp;<Ref Sect="Arithmetic for Lists"/>.
<P/>

It should be noted that
<C>0 * <A>obj</A></C> is equivalent to <C>ZeroSM( <A>obj</A> )</C>,
<C>-<A>obj</A></C> is equivalent to <C>AdditiveInverseSM( <A>obj</A> )</C>,
<C><A>obj</A>^0</C> is equivalent to <C>OneSM( <A>obj</A>)</C>,
and <C><A>obj</A>^-1</C> is equivalent to <C>InverseSM( <A>obj</A> )</C>.
The <Q>SM</Q> stands for <Q>same mutability</Q>, and indicates that the result is
<C>0 * <A>obj</A></C> is equivalent to <C>ZeroSameMutability( <A>obj</A> )</C>,
<C>-<A>obj</A></C> is equivalent to <C>AdditiveInverseSameMutability( <A>obj</A> )</C>,
<C><A>obj</A>^0</C> is equivalent to <C>OneSameMutability( <A>obj</A>)</C>,
and <C><A>obj</A>^-1</C> is equivalent to <C>InverseSameMutability( <A>obj</A> )</C>.
The suffix <Q>SameMutability</Q> indicates that the result is
mutable if and only if the argument is mutable.
<P/>
The operations <Ref Oper="ZeroOp"/>, <Ref Oper="AdditiveInverseOp"/>, <Ref Oper="OneOp"/>, and <Ref Oper="InverseOp"/>
Expand Down
73 changes: 62 additions & 11 deletions doc/ref/obsolete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,41 @@ This type of information is now collected in the global record
<P/>
Here are some further name changes.
<P/>
<Index Key="MonomialTotalDegreeLess"><C>MonomialTotalDegreeLess</C></Index>
<Index Key="NormedVectors"><C>NormedVectors</C></Index>
<Index Key="MutableIdentityMat"><C>MutableIdentityMat</C></Index>
<Index Key="MutableNullMat"><C>MutableNullMat</C></Index>
<Index Key="RadicalGroup"><C>RadicalGroup</C></Index>
<Table Align="l|l">
<Row>
<Item><E>OLD</E></Item>
<Item><E>NOW USE</E></Item>
</Row>
<HorLine/>
<Row>
<Item><C>MonomialTotalDegreeLess</C></Item>
<Item><C>MonomialTotalDegreeLess</C><Index Key="MonomialTotalDegreeLess"><C>MonomialTotalDegreeLess</C></Index></Item>
<Item><Ref Func="MonomialExtGrlexLess"/></Item>
</Row>
<Row>
<Item><C>NormedVectors</C></Item>
<Item><C>NormedVectors</C><Index Key="NormedVectors"><C>NormedVectors</C></Index></Item>
<Item><Ref Attr="NormedRowVectors"/></Item>
</Row>
<Row>
<Item><C>MutableIdentityMat</C></Item>
<Item><C>MutableIdentityMat</C><Index Key="MutableIdentityMat"><C>MutableIdentityMat</C></Index></Item>
<Item><Ref Func="IdentityMat"/></Item>
</Row>
<Row>
<Item><C>MutableNullMat</C></Item>
<Item><C>MutableNullMat</C><Index Key="MutableNullMat"><C>MutableNullMat</C></Index></Item>
<Item><Ref Func="NullMat"/></Item>
</Row>
<Row>
<Item><C>MultRowVector</C></Item>
<Item><C>MultRowVector</C><Index Key="MultRowVector"><C>MultRowVector</C></Index></Item>
<Item><Ref Oper="MultVectorLeft"/></Item>
</Row>
<Row>
<Item><C>RadicalGroup</C></Item>
<Item><C>RadicalGroup</C><Index Key="RadicalGroup"><C>RadicalGroup</C></Index></Item>
<Item><Ref Attr="SolvableRadical"/></Item>
</Row>
</Table>

<List>

<Item>
<Index Key="PositionFirstComponent"><C>PositionFirstComponent</C></Index>
The operation <C>PositionFirstComponent</C> has been deprecated in GAP
4.8 due to issues with its documentation and implementation, and was
Expand All @@ -193,18 +190,72 @@ Instead of <C>PositionFirstComponent(list,obj)</C>, you may use
<C>PositionSorted(list,[obj])</C> or
<C>PositionProperty(list,x->x[1]=obj)</C> as a replacement, depending on
your specific use case.
</Item>

<Item>
<Index Key="MultRowVector"><C>MultRowVector</C></Index>
The five argument version of the operation <C>MultRowVector</C> has been
deprecated in GAP 4.10 since it was unused and only available for coefficient
lists.
Note that <C>MultRowVector</C> was also renamed to <C>MultVectorLeft</C>.
</Item>

<Item>
<Index Key="TemporaryGlobalVarName"><C>TemporaryGlobalVarName</C></Index>
The function <C>TemporaryGlobalVarName</C> has been deprecated in GAP 4.11.
Code using it typically can be restructured to not need it, e.g. by
using <Ref Func="EvalString"/>.
</Item>

<Item>
A bunch of synonyms have been deprecated in GAP 4.13.
The alternative names have always existed and so are safe
to use even in code which is meant to run in older GAP versions.
<Table Align="l|l">
<Row>
<Item><E>Deprecated</E></Item>
<Item><E>Recommended alternative</E></Item>
</Row>
<HorLine/>
<Row>
<Item><C>OneSM</C><Index Key="OneSM"><C>OneSM</C></Index></Item>
<Item><Ref Func="OneSameMutability"/></Item>
</Row>
<Row>
<Item><C>InverseSM</C><Index Key="InverseSM"><C>InverseSM</C></Index></Item>
<Item><Ref Func="InverseSameMutability"/></Item>
</Row>
<Row>
<Item><C>ZeroSM</C><Index Key="ZeroSM"><C>ZeroSM</C></Index></Item>
<Item><Ref Func="ZeroSameMutability"/></Item>
</Row>
<Row>
<Item><C>AdditiveInverseSM</C><Index Key="AdditiveInverseSM"><C>AdditiveInverseSM</C></Index></Item>
<Item><Ref Func="AdditiveInverseSameMutability"/></Item>
</Row>

<Row>
<Item><C>OneAttr</C><Index Key="OneAttr"><C>OneAttr</C></Index></Item>
<Item><Ref Func="One"/>, <Ref Func="OneImmutable"/></Item>
</Row>
<Row>
<Item><C>InverseAttr</C><Index Key="InverseAttr"><C>InverseAttr</C></Index></Item>
<Item><Ref Func="Inverse"/>, <Ref Func="InverseImmutable"/></Item>
</Row>
<Row>
<Item><C>ZeroAttr</C><Index Key="ZeroAttr"><C>ZeroAttr</C></Index></Item>
<Item><Ref Func="Zero"/>, <Ref Func="ZeroImmutable"/></Item>
</Row>
<Row>
<Item><C>AdditiveInverseAttr</C><Index Key="AdditiveInverseAttr"><C>AdditiveInverseAttr</C></Index></Item>
<Item><Ref Func="AdditiveInverse"/>, <Ref Func="AdditiveInverseImmutable"/></Item>
</Row>

</Table>

</Item>

</List>

<ManSection>
<InfoClass Name="InfoObsolete"/>
Expand Down
4 changes: 2 additions & 2 deletions hpcgap/lib/ffeconway.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ InstallMethod(ZeroOp,
[ IsCoeffsModConwayPolRep and IsFFE],
FFECONWAY.Zero);

InstallMethod(ZeroAttr,
InstallMethod(ZeroImmutable,
[ IsCoeffsModConwayPolRep and IsFFE],
FFECONWAY.Zero);

Expand Down Expand Up @@ -1071,7 +1071,7 @@ InstallMethod(OneOp,
[ IsCoeffsModConwayPolRep and IsFFE],
FFECONWAY.One);

InstallMethod(OneAttr,
InstallMethod(OneImmutable,
[ IsCoeffsModConwayPolRep and IsFFE],
FFECONWAY.One);

Expand Down
2 changes: 1 addition & 1 deletion hpcgap/lib/vecmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ end );

#############################################################################
##
#M OneSM( <gf2mat> ) . . . . . . . . . . . . . . . . . . . identity GF2 matrix
#M OneSameMutability( <gf2mat> ) . . . . . . . . . . . . identity GF2 matrix
##
InstallMethod( OneSameMutability,
"for GF2 Matrix",
Expand Down
42 changes: 5 additions & 37 deletions lib/arith.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1379,22 +1379,18 @@ DeclareProperty( "IsOne", IsMultiplicativeElementWithOne );
#############################################################################
##
#A ZeroImmutable( <obj> ) . . additive neutral of an element/domain/family
#A ZeroAttr( <obj> ) synonym of ZeroImmutable
#A Zero( <obj> ) synonym of ZeroImmutable
#O ZeroMutable( <obj> ) . . . . . . mutable additive neutral of an element
#O ZeroOp( <obj> ) synonym of ZeroMutable
#O ZeroSameMutability( <obj> ) mutability preserving zero (0*<obj>)
#O ZeroSM( <obj> ) synonym of ZeroSameMutability
##
## <#GAPDoc Label="ZeroImmutable">
## <ManSection>
## <Attr Name="ZeroImmutable" Arg='obj'/>
## <Attr Name="ZeroAttr" Arg='obj'/>
## <Attr Name="Zero" Arg='obj'/>
## <Oper Name="ZeroMutable" Arg='obj'/>
## <Oper Name="ZeroOp" Arg='obj'/>
## <Oper Name="ZeroSameMutability" Arg='obj'/>
## <Oper Name="ZeroSM" Arg='obj'/>
##
## <Description>
## <Ref Attr="ZeroImmutable"/>, <Ref Oper="ZeroMutable"/>,
Expand All @@ -1417,9 +1413,7 @@ DeclareProperty( "IsOne", IsMultiplicativeElementWithOne );
## <C>ZeroSameMutability( <A>obj</A> )</C> is equivalent to
## <C>0 * <A>obj</A></C>.
## <P/>
## <Ref Attr="ZeroAttr"/> and <Ref Attr="Zero"/> are synonyms of
## <Ref Attr="ZeroImmutable"/>.
## <Ref Oper="ZeroSM"/> is a synonym of <Ref Oper="ZeroSameMutability"/>.
## <Ref Attr="Zero"/> is a synonym of <Ref Attr="ZeroImmutable"/>.
## <Ref Oper="ZeroOp"/> is a synonym of <Ref Oper="ZeroMutable"/>.
## <P/>
## If <A>obj</A> is a domain or a family then <Ref Attr="Zero"/> is defined
Expand Down Expand Up @@ -1452,7 +1446,6 @@ DeclareProperty( "IsOne", IsMultiplicativeElementWithOne );
DeclareAttribute( "ZeroImmutable", IsAdditiveElementWithZero );
DeclareAttribute( "ZeroImmutable", IsFamily );

DeclareSynonymAttr( "ZeroAttr", ZeroImmutable );
DeclareSynonymAttr( "Zero", ZeroImmutable );

DeclareOperationKernel( "ZeroMutable", [ IsAdditiveElementWithZero ],
Expand All @@ -1461,7 +1454,6 @@ DeclareSynonym( "ZeroOp", ZeroMutable );

DeclareOperationKernel( "ZeroSameMutability", [ IsAdditiveElementWithZero ],
ZERO_SAMEMUT );
DeclareSynonym( "ZeroSM", ZeroSameMutability );


#############################################################################
Expand All @@ -1474,22 +1466,18 @@ DeclareOperationKernel( "+", [ IsExtAElement, IsExtAElement ], SUM );
#############################################################################
##
#A AdditiveInverseImmutable( <elm> ) . . . . additive inverse of an element
#A AdditiveInverseAttr( <elm> ) . . . . additive inverse of an element
#A AdditiveInverse( <elm> ) . . . . additive inverse of an element
#O AdditiveInverseMutable( <elm> ) . mutable additive inverse of an element
#O AdditiveInverseOp( <elm> ) . mutable additive inverse of an element
#O AdditiveInverseSameMutability( <elm> ) . additive inverse of an element
#O AdditiveInverseSM( <elm> ) . additive inverse of an element
##
## <#GAPDoc Label="AdditiveInverseImmutable">
## <ManSection>
## <Attr Name="AdditiveInverseImmutable" Arg='elm'/>
## <Attr Name="AdditiveInverseAttr" Arg='elm'/>
## <Attr Name="AdditiveInverse" Arg='elm'/>
## <Oper Name="AdditiveInverseMutable" Arg='elm'/>
## <Oper Name="AdditiveInverseOp" Arg='elm'/>
## <Oper Name="AdditiveInverseSameMutability" Arg='elm'/>
## <Oper Name="AdditiveInverseSM" Arg='elm'/>
##
## <Description>
## <Ref Attr="AdditiveInverseImmutable"/>,
Expand All @@ -1513,10 +1501,8 @@ DeclareOperationKernel( "+", [ IsExtAElement, IsExtAElement ], SUM );
## <C>AdditiveInverseSameMutability( <A>elm</A> )</C> is equivalent to
## <C>-<A>elm</A></C>.
## <P/>
## <Ref Attr="AdditiveInverseAttr"/> and <Ref Attr="AdditiveInverse"/> are
## synonyms of <Ref Attr="AdditiveInverseImmutable"/>.
## <Ref Oper="AdditiveInverseSM"/> is a synonym of
## <Ref Oper="AdditiveInverseSameMutability"/>.
## <Ref Attr="AdditiveInverse"/> is a synonym of
## <Ref Attr="AdditiveInverseImmutable"/>.
## <Ref Oper="AdditiveInverseOp"/> is a synonym of
## <Ref Oper="AdditiveInverseMutable"/>.
## <P/>
Expand All @@ -1532,7 +1518,6 @@ DeclareOperationKernel( "+", [ IsExtAElement, IsExtAElement ], SUM );
## <#/GAPDoc>
##
DeclareAttribute( "AdditiveInverseImmutable", IsAdditiveElementWithInverse );
DeclareSynonymAttr( "AdditiveInverseAttr", AdditiveInverseImmutable );
DeclareSynonymAttr( "AdditiveInverse", AdditiveInverseImmutable );

DeclareOperationKernel( "AdditiveInverseMutable",
Expand All @@ -1541,7 +1526,6 @@ DeclareSynonym( "AdditiveInverseOp", AdditiveInverseMutable);

DeclareOperationKernel( "AdditiveInverseSameMutability",
[ IsAdditiveElementWithInverse ], AINV_SAMEMUT );
DeclareSynonym( "AdditiveInverseSM", AdditiveInverseSameMutability);


#############################################################################
Expand All @@ -1562,24 +1546,20 @@ DeclareOperationKernel( "*", [ IsExtRElement, IsExtLElement ], PROD );
#############################################################################
##
#A OneImmutable( <obj> ) multiplicative neutral of an element/domain/family
#A OneAttr( <obj> )
#A One( <obj> )
#A Identity( <obj> )
#O OneMutable( <obj> ) . . . . . . . . multiplicative neutral of an element
#O OneOp( <obj> )
#O OneSameMutability( <obj> )
#O OneSM( <obj> )
##
## <#GAPDoc Label="OneImmutable">
## <ManSection>
## <Attr Name="OneImmutable" Arg='obj'/>
## <Attr Name="OneAttr" Arg='obj'/>
## <Attr Name="One" Arg='obj'/>
## <Attr Name="Identity" Arg='obj'/>
## <Oper Name="OneMutable" Arg='obj'/>
## <Oper Name="OneOp" Arg='obj'/>
## <Oper Name="OneSameMutability" Arg='obj'/>
## <Oper Name="OneSM" Arg='obj'/>
##
## <Description>
## <Ref Attr="OneImmutable"/>, <Ref Oper="OneMutable"/>,
Expand All @@ -1603,9 +1583,8 @@ DeclareOperationKernel( "*", [ IsExtRElement, IsExtLElement ], PROD );
## <C>OneSameMutability( <A>obj</A> )</C>
## is equivalent to <C><A>obj</A>^0</C>.
## <P/>
## <Ref Attr="OneAttr"/>, <Ref Attr="One"/> and <Ref Attr="Identity"/> are
## <Ref Attr="One"/> and <Ref Attr="Identity"/> are
## synonyms of <C>OneImmutable</C>.
## <Ref Oper="OneSM"/> is a synonym of <Ref Oper="OneSameMutability"/>.
## <Ref Oper="OneOp"/> is a synonym of <Ref Oper="OneMutable"/>.
## <P/>
## If <A>obj</A> is a domain or a family then <Ref Attr="One"/> is defined
Expand Down Expand Up @@ -1644,7 +1623,6 @@ DeclareOperationKernel( "*", [ IsExtRElement, IsExtLElement ], PROD );
DeclareAttribute( "OneImmutable", IsMultiplicativeElementWithOne );
DeclareAttribute( "OneImmutable", IsFamily );

DeclareSynonymAttr( "OneAttr", OneImmutable );
DeclareSynonymAttr( "One", OneImmutable );
DeclareSynonymAttr( "Identity", OneImmutable );

Expand All @@ -1654,28 +1632,23 @@ DeclareSynonym( "OneOp", OneMutable);

DeclareOperationKernel( "OneSameMutability",
[ IsMultiplicativeElementWithOne ], ONE_SAMEMUT );
DeclareSynonym( "OneSM", OneSameMutability);


#############################################################################
##
#A InverseImmutable( <elm> ) . . . . multiplicative inverse of an element
#A InverseAttr( <elm> )
#A Inverse( <elm> )
#O InverseMutable( <elm> )
#O InverseOp( <elm> )
#O InverseSameMutability( <elm> ) . . multiplicative inverse of an element
#O InverseSM( <elm> )
##
## <#GAPDoc Label="InverseImmutable">
## <ManSection>
## <Attr Name="InverseImmutable" Arg='elm'/>
## <Attr Name="InverseAttr" Arg='elm'/>
## <Attr Name="Inverse" Arg='elm'/>
## <Oper Name="InverseMutable" Arg='elm'/>
## <Oper Name="InverseOp" Arg='elm'/>
## <Oper Name="InverseSameMutability" Arg='elm'/>
## <Oper Name="InverseSM" Arg='elm'/>
##
## <Description>
## <Ref Attr="InverseImmutable"/>, <Ref Oper="InverseMutable"/>, and
Expand Down Expand Up @@ -1713,10 +1686,7 @@ DeclareSynonym( "OneSM", OneSameMutability);
## <C>InverseSameMutability( <A>elm</A> )</C> is equivalent to
## <C><A>elm</A>^-1</C>.
## <P/>
## <Ref Attr="InverseAttr"/> and <Ref Attr="Inverse"/> are synonyms of
## <Ref Attr="InverseImmutable"/>.
## <Ref Oper="InverseSM"/> is a synonym of
## <Ref Oper="InverseSameMutability"/>.
## <Ref Attr="Inverse"/> is a synonym of <Ref Attr="InverseImmutable"/>.
## <Ref Oper="InverseOp"/> is a synonym of <Ref Oper="InverseMutable"/>.
## <P/>
## The default method of <Ref Attr="InverseImmutable"/> calls
Expand All @@ -1731,7 +1701,6 @@ DeclareSynonym( "OneSM", OneSameMutability);
## <#/GAPDoc>
##
DeclareAttribute( "InverseImmutable", IsMultiplicativeElementWithInverse );
DeclareSynonymAttr( "InverseAttr", InverseImmutable );
DeclareSynonymAttr( "Inverse", InverseImmutable );

DeclareOperationKernel( "InverseMutable",
Expand All @@ -1740,7 +1709,6 @@ DeclareSynonym( "InverseOp", InverseMutable );

DeclareOperationKernel( "InverseSameMutability",
[ IsMultiplicativeElementWithInverse ], INV_SAMEMUT );
DeclareSynonym( "InverseSM", InverseSameMutability );


#############################################################################
Expand Down
Loading

0 comments on commit 55ffb74

Please sign in to comment.