Project

General

Profile

Design #1232

IsPrime(0)

Added by John Abbott over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Various
Start date:
29 Oct 2018
Due date:
% Done:

100%

Estimated time:
0.66 h
Spent time:

Description

What should IsPrime(0) do?

Currently it gives error (because arg must be strictly positive).

I ask because I wanted to write a short demo for the students, and wanted to check whether the coeffring of a polyring is a (prime) finite field. I first wrote this:

  k := CoeffRing(P);
  if not(IsField(k)) or not(IsPrime(characteristic(k))) then error(...); endif;

These lines will not handle gracefully the case that the coeffring is QQ (or any other field of char 0). Instead I would have to write
  k := CoeffRing(P);
  if not(IsField(k)) or characteristic(k) = 0 or not(IsPrime(characteristic(k))) then error(...); endif;

In fact, CoCoA offers the functions IsFiniteField and LogCardinality, so maybe this issue is pointless?

Anyway, I'd like a brief discussion.


Related issues

Related to CoCoALib - Feature #898: New function: cardinality of finite field?In Progress2016-06-27

History

#1 Updated by Anna Maria Bigatti over 5 years ago

  • % Done changed from 0 to 10

I'd rather keep the error, as in this case you already have IsFiniteField.
I'm not sure whether one would expect it to be true in all possible situations.

#2 Updated by John Abbott over 5 years ago

  • Status changed from New to Closed
  • Assignee set to John Abbott
  • % Done changed from 10 to 100
  • Estimated time set to 0.66 h

Indeed, I probably created IsFiniteField exactly for this reason. Also the correct code is clearer to read:

  if not(IsFiniteField(k)) or LogCardinality(k) > 1 then error(...)

Though I admit that LogCardinality is not the most obvious name; maybe FiniteFieldExtnDeg would be clearer?
(FFED is a bit long though)

I confirm that the manual page for IsField refers also to IsFiniteField, so the fn is visible.

So, as Anna says, let's leave it as it is currently. Closing.

#3 Updated by Anna Maria Bigatti over 5 years ago

John Abbott wrote:

Though I admit that LogCardinality is not the most obvious name; maybe FiniteFieldExtnDeg would be clearer?

yes, it would.
Maybe AlgExtDeg? in principle one could also ask it for QQ[x]/(f).

#4 Updated by John Abbott over 5 years ago

  • Related to Feature #898: New function: cardinality of finite field? added

Also available in: Atom PDF