Function having a field as input

Fabio Stumbo <[email protected]> Wed, 20 Jun 2018 18:59:07 +0200
Newsgroups gmane.comp.mathematics.axiom.general
Organization Università di Ferrara
Message-ID <[email protected]>
I am writing, for didactic purposes, a function which performs =

factorization of a square-free polynomial using Berlekamp's algorithm.

As for now, I wrote something like

ber: UP(x,INT) -> List(UP(x,INT))
ber(pol) =3D=3D
 =A0car :=3D 5
 =A0GF =3D=3D> PF 5
 =A0f : UP(x,GF) :=3D pol
 =A0.....


and it works: the function compiles correctly and I get the list of all =

irreducible factor of the input polynomials of the input.

Clearly, this works only in the prime field GF(5): if I want to use it =

in another prime field, I have to change the "5" in the definition of =

the function.

In order to have the prime field also in input I tried something like


ber: (NNI,UP(x,INT)) -> List(UP(x,INT))
ber(p,pol) =3D=3D
 =A0car :=3D p
 =A0GF =3D=3D> PF p
 =A0f : UP(x,GF) :=3D pol
...


Putting aside sanity checks on the primality of p, it works but the =

function does not compile, it is just interpreted:

(5) -> ber(7,x^6+1)
 =A0=A0 Local variable or parameter used in type
 =A0=A0 We will attempt to interpret the code.

....



This makes me guess that I have been somewhat naif: what is wrong? How =

can I correct my function?


Thanks

Fabio