Opened 2 years ago

# LinearCode.minimum_distance "Gap terminated unexpectedly while reading in a large line"

Reported by: Owned by: asante major coding theory days94 N/A

### Description

When computing the minimum distance of a linear code defined by a matrix over an quotient ring, gap crashes with the following error:

```% sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.3.beta7, Release Date: 2018-06-23               │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: from sage.coding.linear_code import LinearCode
....: R = GF(2)['x'].quo(GF(2)['x']("x^4+x+1"))
....: LinearCode(matrix(R, 2, 2, map(R, ["1","1","1","1"]))).minimum_distance()
....:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-4142638f6b1f> in <module>()
1 from sage.coding.linear_code import LinearCode
2 R = GF(Integer(2))['x'].quo(GF(Integer(2))['x']("x^4+x+1"))
----> 3 LinearCode(matrix(R, Integer(2), Integer(2), map(R, ["1","1","1","1"]))).minimum_distance()

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10823)()
1951                 return cache[k]
1952         except KeyError:
-> 1953             w = self._instance_call(*args, **kwds)
1954             cache[k] = w
1955             return w

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:10279)()
1827             True
1828         """
-> 1829         return self.f(self._instance, *args, **kwds)
1830
1831     cdef fix_args_kwds(self, tuple args, dict kwds):

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/coding/linear_code.pyc in minimum_distance(self, algorithm)
2574             d = C.MinimumWeight()
2575             return ZZ(d)
-> 2576         return self._minimum_weight_codeword(algorithm).hamming_weight()
2577
2578     def _minimum_weight_codeword(self, algorithm = None):

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/coding/linear_code.pyc in _minimum_weight_codeword(self, algorithm)
2617         n, k = self.length(), self.dimension()
2618         F = self.base_field()
-> 2619         Gmat = self.generator_matrix()._gap_init_()
2620
2621         current_randstate().set_seed_gap()

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/matrix/matrix1.pyx in sage.matrix.matrix1.Matrix._gap_init_ (build/cythonized/sage/matrix/matrix1.c:3341)()
139         # It is needed to multiply with 'One(...)', because
140         # otherwise the result would not be a gap matrix
--> 141         return '[%s]*One(%s)'%(','.join(v),sage.interfaces.gap.gap(self.base_ring()).name())
142
143     def _libgap_(self):

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
280             return cls(self, x, name=name)
281         try:
--> 282             return self._coerce_from_special_method(x)
283         except TypeError:
284             raise

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _coerce_from_special_method(self, x)
306             s = '_gp_'
307         try:
--> 308             return (x.__getattribute__(s))(self)
309         except AttributeError:
310             return self(x._interface_init_())

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/structure/sage_object.pyx in sage.structure.sage_object.SageObject._gap_ (build/cythonized/sage/structure/sage_object.c:6377)()
752             import sage.interfaces.gap
753             G = sage.interfaces.gap.gap
--> 754         return self._interface_(G)
755
756     def _gap_init_(self):

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/structure/sage_object.pyx in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5894)()
728             except Exception:
729                 raise NotImplementedError("coercion of object %s to %s not implemented:\n%s\n%s" % (repr(self), I))
--> 730         X = I(s)
731         if c:
732             try:

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
278
279         if isinstance(x, string_types):
--> 280             return cls(self, x, name=name)
281         try:
282             return self._coerce_from_special_method(x)

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1443             except (RuntimeError, ValueError) as x:
1444                 self._session_number = -1
-> 1445                 raise_(TypeError, TypeError(*x.args), sys.exc_info()[2])
1446             except BaseException:
1447                 self._session_number = -1

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1438         else:
1439             try:
-> 1440                 self._name = parent._create(value, name=name)
1441             # Convert ValueError and RuntimeError to TypeError for
1442             # coercion to work properly.

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _create(self, value, name)
474     def _create(self, value, name=None):
475         name = self._next_var_name() if name is None else name
--> 476         self.set(name, value)
477         return name
478

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in set(self, var, value)
1387         """
1388         cmd = ('%s:=%s;;' % (var, value)).replace('\n','')
-> 1389         self._eval_line(cmd, allow_use_file=True)
1390
1391     def get(self, var, use_file=False):

/home/asante/.local/src/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt, restart_if_needed)
787                     return ''
788             else:
--> 789                 raise RuntimeError(message)
790
791         except KeyboardInterrupt:

TypeError: Gap terminated unexpectedly while reading in a large line:
Gap produced error output
Error, Variable: 'Univariate' must have a value
Syntax error: ; expected in /home/asante/.sage/temp/Thalamus/21109/interface/t\
mp21147 line 1
\\$sage1:=Univariate Quotient Polynomial Ring in xbar over Finite Field of size\
2 with modulus x^4 + x + 1;;
^

```

(this is a 64bit linux machine, if this is necessary..)

### comment:1 Changed 2 years ago by tscrim

So the GAP error message might be a bit of a red herring. It seems like the issue might come from the fact that `R` cannot be read by GAP:

```sage: gap(R)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[same as in the ticket description]

TypeError: Gap terminated unexpectedly while reading in a large line:
Gap produced error output
Error, Variable: 'Univariate' must have a value
Syntax error: ; expected in /home/travis/.sage/temp/apricot/10948/interface/tm\
p10995 line 1
\\$sage4:=Univariate Quotient Polynomial Ring in xbar over Finite Field of size\
2 with modulus x^4 + x + 1;;
^

```

Contrast this with

```sage: gap(R.ambient())
PolynomialRing( GF(2), ["x"] )
```

### comment:2 Changed 18 months ago by embray

• Milestone sage-8.3 deleted

Removing from closed milestone.

Note: See TracTickets for help on using tickets.