Top Banner
A CASE STUDY OF THE COMBINATORICS OF LINEAR CODES WITH SAGE INTRODUCTION TO SAGE RINGS,IDEALS AND STANDARD BASES INTRODUCTION TO CODING THEORY SPECIAL CONSTRUCTIONS CODE BOUNDS CODING THEORY NOT YET IN SAGE EXERCICES A CASE STUDY OF THE COMBINATORICS OF LINEAR CODES WITH SAGE I. M ´ ARQUEZ-CORBELLA 1 E. MART´ INEZ-MORO 2 1 Department of Algebra, Geometry and Topology, University of Valladolid. Supported by a FPU grant AP2008-01598 by Spanish MEC. 2 Department of Applied Mathematics, University of Valladolid. ACAGM summer school
143

A case study of the combinatorics of linear codes with SAGE · 2012. 1. 18. · a case study of the combinatorics of linear codes with sage introduction to sage rings, ideals and

Feb 18, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    A CASE STUDY OF THE COMBINATORICS OFLINEAR CODES WITH SAGE

    I. MÁRQUEZ-CORBELLA 1 E. MARTÍNEZ-MORO 2

    1Department of Algebra, Geometry and Topology, University of Valladolid.Supported by a FPU grant AP2008-01598 by Spanish MEC.

    2Department of Applied Mathematics, University of Valladolid.

    ACAGM summer school

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    WHAT IS SAGE?

    SAGE is . . .

    Ü Software for Algebra and Geometry Experimentation.

    Ü A distribution of free open-source mathematics software system.

    Everything is GPL-compatible.You can check the source code.

    Ü Take a tour of the website: http: // www.sagemath.org

    Ü Based on the Python language, which may be used to script SAGE commands.

    Mission: Creating a viable free open source alternative to Magma, Maple,Mathematica and Matlab.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    WHAT IS PYTHON?

    Ü A powerful dynamic programming language.

    Ü Often compared to Tcl, Perl, Ruby, Scheme or Java.

    Ü Some of its key distinguishing features include:

    1 Very clear readable syntax.2 Natural expression of code.3 Intuitive object orientation.4 Extensions and modules easily written in C, C++.

    Ü Powerful and fast.

    Ü Friendly and easy to learn.

    Ü Open.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    WHAT IS IN SAGE?

    When you install Sage you get:

    Cython language for writing C and C++ extension modules for PythonGAP system for computational discrete algebraGfan software package for computing Gröbner fans and tropical varietiesjsmath JavaScript implementation of LaTeXLcalc L-functions calculatorlibcrypt crypto library that implements a wide range of cryptographic algorithmsMaxima computer algebra system for the manipulation of symbolic and numerical expressionsMoinMoin Wiki software implemented in Python and distributed as Free SoftwareNetworkX python package for the creation, manipulation and study of graphsGMP free bignum libraryPari GP computer algebra system designed for fast computations in number theoryPolyBoRi C++ library for polynomials over boolean ringsPynac derivative of the C++ library GiNaC for the manipulation of symbolic expressionsR language and environment for statistical computing and graphicsScipy open-source package for scientific computing in Python programming languageSympow python package for computing special values of L-functionsSympy python library for symbolic mathematicsSingular computer algebra system for polynomial computations

    . . . and much more !!

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    SOME COMPONENTS OF THE SAGE DISTRIBUTION

    Algebra GAP, SingularGraph Theory NetworkXApplied mathematics Maxima, SympyNumber theory Pari GP, GMPStatistics RCryptography libcryptGraphical Interface Sage NotebookGraphics jmol, Matplotlib,

    Ü SAGE includesinterfaces to GAP,PARI GP, Kash,Macauly2, Magma,Maple, Mathematica,Maxima, Octave,Singular, etc.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    SOME HISTORY

    1 Nov 2004: William Stein, Professor of mathematics at the University ofWashington developed Manin, a precursor to SAGE.

    2 Feb 2005: birth of SAGE 0.1 (Pari included).3 April 2005: Interfaces to Mathematica, Magma, etc.4 Oct 2005 : SAGE 0.8 (GAP and Singular included as standard).5 Feb 2006: SAGE Days 1 Workshop - SAGE 1.0.6 June 2006: SAGE Notebook developed by William Stein, Alex Clemsha and

    Tom Boothby.7 May 2011: SAGE v4.7

    SAGE Days Workshops

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    WHO IS WRITING SAGE?

    Professors, Postdocs, Graduate students, Undergraduates, High schoolteachers, Professionals, retired techies, YOU!

    Ü Contributors Include:

    Tom Boothby,Robert Bradshaw,David Harvey,Craig Citro,Bobby Moretti,Emily Kirkman,Yi Qiang,Josh Kantor,David Kohel,David Joyner,Iftikhar Burhanuddin,John Cremona,Martin Albrecht,Wilson Cheung,Alex Clemesha,

    Didier Deshommes,Naqi Jaffery,Kiran Kedlaya,David Roe,David Kirkby,Jon Hanke,Gregg Musiker,Fernando Perez,Nathan Ryan,Kyle Schalm,Steven Sivek,Jaap Spies,Gonzalo Tornaria,Justin Walker,Mark Watkins,Joe Weening,Joe Wetherell

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    TOUR - BENCMARKS I

    Ü Here are some comparisons of SAGE with other systems.

    Each pair of comparison was made on the same system and it wascarfully avoided to hit swap memory to avoid accidental slowdows.

    Unless otherwise noted, all timings are in seconds.

    Multiply Integers (12345678900 − 1) × (67890123456 − 1)SAGE 4.1.1sage: a1 = 12345ˆ678900 - 1sage: a2 = 67890ˆ123456 - 1sage: %timeit a1*a210 loops, best of 3: 278ms per loopNote: ms is Milliseconds (10−3)

    Mathematica 7In[2]:= a1 = 12345ˆ678900 -1;In[3]:= a2 = 67890̂123456 -1;In[4]:= Timing[a1*a2][[1]]Out[4]= 0.368023

    Ü SAGE is 32% faster.System: Intel 32bit, Linux

    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    Factorial 10000000!SAGE 4.1.1sage: time a =factorial(10000000)CPU times: user 13.79s,...

    Mathematica 7In[12]:=Timing[10000000!][[1]]Out[12]= 19.2908

    Ü SAGE is 40% faster.Ü System: Mac OSX

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    TOUR - BENCMARKS II

    SAGE vs. MAGMAMachines used: 4-core: model name: Intel(R) Core(TM)2 QuadCPU Q6600 @ 2.40GHz

    1 SAGE is faster at multiplying large numbers.sage:a=ZZ.random element(2ˆ100000)sage:b=ZZ.random element(2ˆ100000)sage: time c = [a*b for i in[1..10000]]CPU times: user 6.20 s,sys: 0.00 s, total: 6.20sWall time: 6.20 s

    sage: aa=magma(a)sage: bb=magma(b)sage: magma.eval(’timez:=[%s*%s : i in[1..10000]]’%(aa.name(),bb.name()))’Time: 11.210’

    2 SAGE is faster at factoring large numbers.3 Sage is faster at proving primality.4 Computing factorials (Sage is more than twice the speed).5 Large degree polynomial multiplication modulo n (Sage is three times as

    fast).6 Large degree polynomial multiplication over ZZ (Sage is five times as fast).7 Multiplication of random dense matrices over GF(2).

    And more in http://wiki.sagemath.org/sagebeatsmagma

    And even more inhttp://www.sagemath.org/tour-benchmarks.html

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    SAGE AND CODING THEORY

    Ü Contributors Include:David Joyner, Professor in the Mathematics Department at the UnitedStates Naval Academy.Nick Alexander doctor in Mathematics.Kwankyu LeeNiles Johnson Postdoctoral Associate in the Department of Mathematicsat the University of Georgia.

    Ü SAGE contains GUAVA (GAP’s coding theory package).All of GUAVA’s functions can be accessed within SAGE.

    Ü GUAVA homepage:http://sage.math.washington.edu/home/wdj/guava/

    Nick Alexander Niles Johnson

    Robert Miller Cen Tjhal Tom Boothby Joe Fields

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    WAYS TO USE SAGE

    Ü You can use SAGE in several ways:

    1 Notebook Graphical Interface.

    2 Interactive Command Line.

    3 Programs: By writing interpreted and compiled programs in SAGE.

    4 Scripts: By writing stand-alone Python scripts that use the SAGE library.

    INSTALLATION:

    Try SAGE now online at:

    http://tutorial.sagenb.org

    Installing SAGE on your computer. See SAGE installation GUIDE at

    http://www.sagemath.org

    Ü Recommendation: Use the pre-compiled binary version of sage is easier andquicker to install that the source code version.

    Just unpack the file and run SAGE!!!!!

    Ü SAGE uses Python, IPython, PARI, GAP, Singular, Maxima, NTL, GMP, . . .

    But you do not need to install them separately.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    THE NOTEBOOK INTERFACE

    Ü The sage notebook is run by typing

    sage: notebook()

    on the command line of SAGE.

    Ü A Notebook is a collection of user accounts each of which can have anynumber of worksheets.

    Ü A Worksheet is an ordered collections of numbered cells.

    They are embedded in a web page that is served by the SAGE server.

    Ü When you create a new worksheet, the data that defines it is stored in thedirectory:

    worksheets/username/number

    In each such directory there is a plain text file worksheet.txt

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    TRY SAGE NOW! I

    1 Visit the webpage http://tutorial.sagenb.org.

    2 Click on Sign up for a new Sage Notebook on the right side of the screen.

    3 Fill out the form

    4 Go back to http://tutorial.sagenb.org and login.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    TRY SAGE NOW! II

    5 Once you log in, click New Worksheet.

    6 Enter a title for the new worksheet.

    7 Enter 2 + 2 and press Shift + Enter or click the evaluate link.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    TRY SAGE NOW! III

    Note: An input cell can have multiple lines of input.

    8 Save and Quit when you have finished.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD KEY AVAILABLE IN THE NOTEBOOK I

    EVALUATE: Press Shift + Enter.

    DELETE CELLS: Delete all cell contents and press Backspace.

    INSERT NEW CELL:

    Put the mouse between output and input until an horizontal line appearsand click.Or press Alt + Enter.

    INSERT NEW HTML CELL: Press Shift + clik between cells.

    EDIT EXISTING HTML CELL: Double click on it.

    Note: Use $ . . . $ and $$ . . . $$ to include math equations in the HTML block.

    PARENTHESIS MATCHING: Press Ctrl + 0 to fix unmatched parentheses, bracesor brackets.

    COMMENT / UNCOMMENT BLOCKS:

    Press Ctrl + 3 to comment it.And Ctrl + 4 to uncomment it.

    SPILT CELLS:

    Press Ctrl + Enter to spilt a cell and evaluate both pieces. (The differentlines must be separated by ;)Press Ctrl + Backspace to join them.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD KEY AVAILABLE IN THE NOTEBOOK II

    If obj is an object, type in sage: sage:LinearCode. and hit thetabulation key and you find out what you can do with this object.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD KEY AVAILABLE IN THE NOTEBOOK III

    To learn how to generate, for example a generator matrix of suchLinear code you just add ? at the end of the function’s name.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD KEY AVAILABLE IN THE NOTEBOOK IV

    To know the source code of the function add ?? at the end of the function’sname.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    BASIC RINGS

    We illustrate some basic rings in SAGE:

    1 The field Q of rational numbers may be referred to using eitherRationalField() or QQ:

    EXAMPLE

    sage: RationalField() Rational Field

    sage: QQ Rational Field

    sage: 1/2 in QQ True

    sage: pi in QQ False

    sage: i in QQ False

    2 Other pre-defined SAGE rings are the integers ZZ, the real numbers RR, thecomplex numbers CC.

    3 The finite field Fq is denoted by GF(q) and the extension field Fqr by GF(qˆr,’a’).

    EXAMPLE

    sage: GF(3) Finite Field of size 3

    sage: GF(4,’a’) Finite Field in a of size 2ˆ2

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    LOCAL RINGS

    LOCAL RING

    A ring A is local if it has exactly one maximal ideal m.

    Examples:

    Fields are local rings.

    A polynomial ring K[x] is never local.The formal power series ring K[[x1, . . . , xn]] with maximal idealm = 〈x1, . . . , xn〉 are local rings.

    Ü Localization of ring means enlarging the ring by allowing denominators, similarto the passage from Z to Q.

    Ü The localization of K[x] w.r.t. the maximal ideal 〈x〉 = 〈x1, . . . , xn〉 is:

    K[x]〈x〉 ={

    fg| f , g ∈ K[x] and g(0) 6= 0

    }Ü Important fact: We can compute in this ring without explicit denominators just

    by defining a suitable monomial ordering on K[x].(cf. slide Leading monomial II).

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    UNIVARIATE POLYNOMIALS I

    Ü There are three ways to create polynomial rings:

    1 sage: R=PolynomialRing(QQ,’t’); R Univariate PolynomialRing in t over Rational Field

    Ü This create a polynomial ring and tells SAGE to use the string t as theindeterminate.

    However this does not define the symbol t for use in SAGE, so you cannot useit to enter a polynomial such as tˆ2 +1 belonging to R unless you force it withthe following line:

    sage: t= R.gen() Univariate Polynomial Ring in t overRational Field

    2 An alternative way is:

    sage: S= QQ[’t’]; S

    sage: S == R True

    Ü This has the same issue regarding t.

    3 A third very convenient way is:

    sage: R. = PolynomialRing(QQ)

    Or sage: R. = QQ[’t’]

    Or even sage: R. = QQ[]

    Ü This has the additional side effect that it defines the variable t to be theindeterminate of the polynomial ring.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    UNIVARIATE POLYNOMIALS II

    Ü You can easily construct elements of R as follows:

    EXAMPLE

    sage: f = (t+1) * (t+2)

    sage: f in R True

    Some arithmetic in Q[t]:sage: g= fˆ2; g tˆ4 + 6*tˆ3 + 13*tˆ2 + 12*t + 4

    sage: F = factor(g); F (t + 1)ˆ2 * (t + 2)ˆ2

    sage: F.unit() 1

    sage: list(F) [(t + 1, 2), (t + 2, 2)]

    sage: h=R.cyclotomic polynomial(7); h

    tˆ6 + tˆ5 + tˆ4 + tˆ3 + tˆ2 + t + 1

    Notice that if you type R.cyclotomic polynomial?? you can see the sourcecode.

    Dividing two polynomials construct an element of the fraction field (which SAGEcreates automatically)

    sage: f=tˆ3 +1; g = tˆ2 -17

    sage: h=f/g; h.parent()

    Fraction Field of Univariate Polynomial Ring in t overRational Field

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    UNIVARIATE POLYNOMIALS III

    Ü The ring is determined by the variable:

    If we name the variable differently we obtain a different univariatepolynomial ring.

    EXAMPLE

    sage: R. = PolynomialRing(QQ)sage: S. = PolynomialRing(QQ)sage: R == S False

    If we make another ring with the same variable it does not return adifferent ring.

    EXAMPLE

    sage: T = PolynomialRing(QQ, ’x’)sage: R == T True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MULTIVARIATE POLYNOMIALS

    Ü We declare the polynomial ring in one of the following ways:

    1 sage: R = PolynomialRing(GF(5), 2, ’z’)

    here 2 = number of variables

    sage: R; Multivariate Polynomial Ring in z0, z1 overFinite Field of size 5

    2 sage: R = GF(5)[’z0,z1,z2’]

    3 sage: R. = GF(5)[]

    Ü To use the variable z0, z1, z2 in SAGE you have to declare them:

    sage: z = GF(5)[’z0,z1,z2’].gens()

    sage: (z[0] + z[1] + z[2])ˆ2 z0ˆ2 + 2*z0*z1 + z1ˆ2 +2*z0*z2 + 2*z1*z2 + z2ˆ2

    Ü If you want the variable names to be single letters then you can use thefollowing shorthand:

    4 sage: R = PolynomialRing(GF(5),3,’xyz’)

    sage: x,y,z = R.gens()

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MONOMIAL ORDERINGS I

    Ü The presentation of a polynomial as a linear combination of monomials isunique up to an order of the summands. We can make this order unique bychoosing a total ordering on the set of monomials.

    MONOMIAL ORDERING

    A Monomial ordering � is a total ordering on the set of monomials with thefollowing property:

    xa � xb ⇒ xa+c � xb+c, for all a, b, c ∈ Zn≥0

    Furthermore:

    If xa � 1 for all a ∈ Zn≥0 then � is called global ordering.

    If xa ≺ 1 for all a ∈ Zn≥0 then � is called local ordering.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS I

    Ü Let us fix an enumeration x1, . . . , xn of the variables.

    1 LEXICOGRAPHICAL ORDERING order = ’lex’

    xa ≺lex xb ⇔ a 6= b and ∃i ∈ {1, . . . , n} : a1 = b1, . . . , ai−1 = bi−1, ai < bi

    This term ordering is called lp in Singular.

    2 INVERSE LEXICOGRAPHIC ORDERING order = ’invlex’

    xa ≺invlex xb ⇔ a 6= b and ∃i ∈ {1, . . . , n} : an = bn, . . . , ai+1 = bi+1, ai > bi

    This term ordering is called rp in Singular.

    Note: The ring K[x1, . . . , xn] with term ordering invelex is equivalent to thering K[xn, . . . , x1] with term ordering lex.

    3 NEGATIVE LEXICOGRAPHIC ORDERING order = ’neglex’

    xa ≺neglex xb ⇐⇒ xa �lex xb

    This term ordering is called ls in Singular.

    4 DEGREE REVERSE LEXICOGRAPHICAL ORDERING order = ’degrevlex’

    xa ≺degrevlex xb ⇐⇒{

    deg(xa) < deg(xb) ordeg(xa) = deg(xb) and xa ≺invlex xb

    This term ordering is called dp in Singular.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS II

    5 DEGREE LEXICOGRAPHIC ORDERING order = ’deglex’

    xa ≺degrevlex xb ⇐⇒{

    deg(xa) < deg(xb) ordeg(xa) = deg(xb) and xa ≺lex xb

    This term ordering is called Dp in Singular.

    6 NEGATIVE DEGREE REVERSE LEXICOGRAPHIC ORDERING

    order = ’negdegrevlex’

    xa ≺negdegrevlex xb ⇐⇒{

    deg(xa) > deg(xb) ordeg(xa) = deg(xb) and xa �invlex xb

    This term ordering is called ds in Singular.

    7 NEGATIVE DEGREE LEXICOGRAPHIC ORDERING order = ’negdeglex’

    xa ≺negdeglex xb ⇐⇒{

    deg(xa) > deg(xb) ordeg(xa) = deg(xb) and xa �lex xb

    This term ordering is called Ds in Singular.

    Ü Only degrevlex, deglex, invlex and lex are global orderings.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS III

    EXAMPLE

    Global orderings:

    sage: R1. = PolynomialRing(GF(2),3,order=’lex’)

    // lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    xˆ3*y*z + xˆ3 + x*yˆ2 + yˆ5 + zˆ4

    sage: R2. = PolynomialRing(GF(2),3,order=’degrevlex’)

    // degree reverse lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    yˆ5 + xˆ3*y*z + zˆ4 + xˆ3 + x*yˆ2

    sage: R3. = PolynomialRing(GF(2),3,order=’deglex’)

    // degree lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2

    sage: R4. = PolynomialRing(GF(2),3,order=’invlex’)

    // inverse lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    zˆ4 + xˆ3*y*z + yˆ5 + x*yˆ2 + xˆ3

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS IV

    EXAMPLE

    Local orderings:

    sage: R5. = PolynomialRing(GF(2),3,order=’neglex’)

    // negative lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    zˆ4 + yˆ5 + x*yˆ2 + xˆ3 + xˆ3*y*z

    sage: R6. =PolynomialRing(GF(2),3,order=’negdegrevlex’)

    // negative degree reverse lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    xˆ3 + x*yˆ2 + zˆ4 + yˆ5 + xˆ3*y*z

    sage: R7. = PolynomialRing(GF(2),3,order=’negdeglex’)

    // negative degree lexicographical

    sage: f = xˆ3*y*z + yˆ5 + zˆ4 + xˆ3 + x*yˆ2; f

    xˆ3 + x*yˆ2 + zˆ4 + xˆ3*y*z + yˆ5

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS V

    PRODUCT OR BLOCK ORDERINGS

    Let �1 be a monomial ordering on K[x1, . . . , xn] and �2 be a monomial ordering onK[y1, . . . , ym] then the product ordering �= (�1,�2) is defined as:

    xayc � xbyd ⇔{

    xa �1 xb orxa = xb and yc �2 yd

    Ü This block orderings are constructed in SAGE by giving a comma separated alist of monomial orderings with the length of each block attached to them.

    EXAMPLE

    The first four variables are compared using the degree lexicographical orderingwhile the last two are compared using the negative lexicographical ordering.

    sage: P. = PolynomialRing(QQ, 6,order=’degrevlex(4),neglex(2)’)

    sage: f = a*bˆ2 + aˆ5*eˆ2 + fˆ7 + cˆ3; f

    aˆ5*eˆ2 + a*bˆ2 + cˆ3 + fˆ7

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF MONOMIAL ORDERINGS VI

    MATRIX ORDERING

    Given non-singular, square matrix A we define a matrix ordering �A by setting:

    xa �A xb ⇔ AaT > AbT

    EXAMPLE

    sage: A = matrix(3,[1,0,0,0,1,0,0,0,1])

    sage: T = TermOrder(A); T

    Matrix term order with matrix

    [1 0 0]

    [0 1 0]

    [0 0 1]

    sage: R1. = PolynomialRing(GF(2), 3, order=T)

    sage: f=R1.random element(); h1=f.lm()

    sage: R2.=PolynomialRing(GF(2),3,order=’lex’)

    sage: h2=f.lm()

    sage: h1 == h2 True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    LEADING MONOMIAL I

    Ü Let � be a monomial ordering on the ring K[x] then any f ∈ K[x] can be write ina unique way as:

    f = aαxα + aβx

    β + . . . + aγxγ

    with aα, aβ , . . . , aγ ∈ K and xα � xβ � . . . � xγ . Then we can define:The leading monomial of f: lm(f ) = xα.

    The leading term of f: lt(f ) = aαxα.

    The leading coefficient of f: lc(f ) = aα.

    The leading exponent of f: le(f ) = α.

    The tail of f: tail(f ) = f − lt(f ) = aβxβ + . . . + aγxγ

    EXAMPLE

    sage: P. = PolynomialRing(QQ, 3, order=’lex’)

    sage: f = yˆ4*zˆ3 + 2*xˆ2*yˆ2*zˆ2 + 4*zˆ4 + 5*yˆ2

    sage: f; 2*xˆ2*yˆ2*zˆ2 + yˆ4*zˆ3 + 5*yˆ2 + 4*zˆ4

    sage: f.lm() xˆ2*yˆ2*zˆ2 //leading monomial

    sage: f.lt() 2*xˆ2*yˆ2*zˆ2 //leading term

    sage: f.lc() 2 //leading coefficient

    sage: le = (f.lm()).degree(); le 6 //leading exponent

    sage: tail = f - f.lt(); tail yˆ4*zˆ3 + 5*yˆ2 + 4*zˆ4

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    LEADING MONOMIAL II

    Ü In local monomial orderings since xi < 1 for all i = 1, . . . , n thenlm(1 + xi ) = 1 so in this case the leading data does not gives much information.

    RING ASSOCIATED TO MONOMIAL ORDERINGS

    For any monomial ordering � on K[x] we define:

    K[x]� ={

    fg| f , g ∈ K[x] and lm(g) = 1

    }as the ring associated to K[x] and �.

    Ü Remark:

    1 K[x] = K[x]� ⇐⇒� is a global ordering.2 K[x]� = K[x]〈x〉 ⇐⇒� is a local ordering.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    LEADING MONOMIAL III

    Now we can extend the leading data to the ring K[x]�.

    GENERALIZED LEADING DATA

    Ü For any f ∈ K[x]� choose u ∈ K[x] such that lt(u) = 1 and uf ∈ K[x]. Thenwe define:

    Generalized leading monomial of f : LM(f ) = lm(uf ).

    Generalized leading term of f : LT(f ) = lt(uf ).

    Generalized leading coefficient of f : LC(f ) = lc(uf ).

    Generalized leading exponent of f : LE(f ) = le(uf ).

    Generalized tail of f : TAIL(f ) = f − LT(f ).

    This definition is independent of the choice of u.

    Ü Note that for global orderings the generalized leading data is equivalent to theleading data.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    IDEALS

    IDEALS

    A subset I in any commutative ring A is an ideal if it satisfies:0 ∈ I

    f , g ∈ I ⇒ f + g ∈ I.

    f ∈ I, a ∈ A ⇒ a · f ∈ I

    Ü Furthermore:I is finite generated if it has a finite system of generators.I is principal if it can be generated by one element.

    ⇒ A is a principal ring if every ideal in A is principal.I is prime if I 6= A and for each a, b ∈ A : ab ∈ I ⇒ a ∈ I or b ∈ I.I s maximal if it is maximal w.r.t. inclusion. That is,

    for any ideal J ⊂ A : I ⊂ J ⇒ I = J .

    Note: Every maximal ideal is prime.

    Ü Let I1, I2 be ideals in A thenPRODUCT IDEAL: I1 · I2 = {ab | a ∈ I1 and b ∈ I2} is an ideal in A.SUM IDEAL: I1 + I2 = {a + b | a ∈ I1 and b ∈ I2} is an ideal in A.The UNION of ideals is, in general, not an ideal.The INTERSECTION of ideals is an ideal.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    IDEALS IN SAGE I

    Ü We can create an ideal in any commutative ring A by one of the following ways:1 By simply multiplying its generators by A:

    sage: I =(f,g) * R

    2 By giving a list of generators:

    sage: I = R.ideal ([f,g]) or I = ideal([f,g])

    3 Or even: sage: I = ideal(f,g)

    EXAMPLE

    sage: R = ZZ

    sage: I = R.ideal(6); I Principal ideal (6) of Integer Ring

    sage: I.is maximal() False

    // In Z the ideal 〈6〉 is not maximal since 〈3〉 is a proper ideal of Z containing 〈6〉sage: I.is prime() False

    // In Z the ideal 〈6〉 is not prime since 2× 3 ∈ 〈6〉, but 2, 3 /∈ 〈6〉.sage: I2 = R.ideal(5); I2.is maximal(); I2.is prime()

    True, True.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    IDEALS IN SAGE II

    Ü The function is maximal() is not implemented for many rings.

    Recall that if K is a field and I is an ideal of the polynomial ring K[x] then:

    I is maximal ⇔ I = 〈f (x)〉 for some irreducible polynomial f (x) ∈ K[x].

    Also try the functions embedded primes(), associated primes(),is prime(), is principal(), minimal associated primes() . . .There is a lot of work to do here!

    EXAMPLE

    sage: R.=PolynomialRing(QQ,2,order=’lex’)

    sage: f=(xˆ3 + 2*yˆ2*x) * (xˆ2 + x + 1)

    sage: F = f.factor(); F

    x * (xˆ2 + 2*yˆ2) * (xˆ2 + x + 1)

    sage: I = R.ideal([f])

    sage: I.is principal() True

    sage: I.is maximal()

    Traceback (click to the left of this block for traceback)

    ...

    NotImplementedError

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    QUOTIENT RING I

    QUOTIENT RING

    Let A be a ring and I and ideal of A. We define the quotient ring A/I as the set ofcosets {[a] := a + I | a ∈ A} with the addition and multiplication defined viarepresentatives:

    [a] + [b] := [a + b]. [a] · [b] := [a · b]

    Ü Remark:I ⊂ A is a prime ideal⇔ A/I is an integral domain (i.e. A \ {0} has non-zerodivisors).I ⊂ A is a maximal ideal⇔ A/I is a field.

    EXAMPLE: IN Z[x] THE IDEAL I = 〈x〉 IS PRIME BUT NOT MAXIMAL

    sage: R. = ZZ[]

    sage: I = R.ideal([x])

    sage: S = R.quotient ring(I)

    sage: S.is field() False

    sage: S.is integral domain() True

    sage: I.is maximal(); I.is prime()

    Traceback (click to the left of this block for traceback)

    ...

    NotImplementedError

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    QUOTIENT RING II

    EXAMPLE: EQUALITY TEST IN QUOTIENT RINGS

    The test f == g does not work correctly in quotient rings. Instead we have tocompute a normal form of the difference f − g.

    sage: R. = PolynomialRing(GF(2),3,order=’degrevlex’)

    sage: I = R.ideal(xˆ2 + yˆ2-zˆ5, z-x-yˆ2)

    sage: S = R.quotient ring(I)

    sage: f = zˆ2+yˆ2

    sage: g=zˆ2+2*x -2*z -3*zˆ5 + 3*xˆ2+6*yˆ2

    sage: f==g False

    sage: f.reduce(I) zˆ2 + x + z

    sage: g.reduce(I) zˆ2 + x + z

    sage: (f-g).reduce(I) 0

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    LEADING IDEALS

    LEADING IDEAL

    For any subset G ⊂ K[x]� we can define the leading ideal of G:

    L(G) = 〈LM(g) | g ∈ G \ {0}〉

    Ü Note: Let I be a finite generated ideal in K[x], i.e. ∃f1, . . . , fk ∈ K[x] such thatI = 〈f1, . . . , fk 〉 then L ({f1, . . . , fk}) in, in general, not L (I).

    EXAMPLE:

    sage: R. = PolynomialRing(QQ,2,order=’degrevlex’)

    sage: f = x*yˆ2 + x*y

    sage: g = xˆ2*y + xˆ2 -y

    sage: I = R.ideal([f,g])

    sage: LG = R.ideal([f.lt(),g.lt()])

    sage: h=x*f - y*g; h yˆ2

    sage: h in I True

    sage: h in LG False

    // Thus y2 ∈ L(I) but y2 /∈ L(f , g)

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD BASE

    STANDARD BASE

    Let I be an ideal in the ring A. A finite set G ⊆ A is called a Standard basis of Iw.r.t. a monomial ordering � if:

    G ⊆ I and L(I) = L(G) .

    Ü If � is a global ordering, a standard basis is also called a Gröbner basis.

    REDUCED STANDARD BASE

    A standard basis G = {g1, . . . , gs} is reduced if :LC(gi ) = 1 for all i = 1, . . . , s.

    LM(gi ) /∈ L(G \ {gi}) for all i = 1, . . . , s.

    tail(gi ) is completely reduced w.r.t. G.

    THEOREM:

    If a global ordering � is fixed then every ideal I ⊆ K[x] has a unique reducedGröbner basis.

    Ü But reduced standard bases are in general, not computable.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ELIMINATION ORDERING

    ELIMINATION ORDERING

    A monomial ordering � on K[x1, . . . , xn] satisfying the following property (called theelimination property):

    ∀f ∈ K[x1, . . . , xn] : LM(f ) ∈ K[xs+1, . . . , xn] =⇒ f ∈ K[xs+1, . . . , xn]

    is an elimination ordering for x1, . . . , xs .

    Remark:

    1 An elimination ordering for x1, . . . , xs must be global on K[x1, . . . , xs].2 The lexicographic ordering is an elimination ordering.

    THEOREM

    Let � be an elimination ordering for x1, . . . , xs on K[x1, . . . , xs] and letI ⊆ K[x1, . . . , xn]� be an ideal. If S = {g1, . . . , gk} is a standard basis of I then

    S′ = {g ∈ S | LM(g) ∈ K[xs+1, . . . , xn]}

    is a standard basis of I ∩ K[xs+1, . . . , xn]

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    NORMAL FORMS

    NORMAL FORM

    Let G = {G | G standard basis ⊂ K[x]}. A function

    NF : K[x]× G −→ K[x](f ,G) 7−→ NF(f ,G)

    is called normal form on K[x] if:1 NF(0,G) = 0 for all G ∈ G.

    2 NF(f ,G) 6= 0⇒ LM (NF (f ,G)) /∈ L(G) for all f ∈ K[x] and G ∈ G.3 For all f ∈ K[x] and all G = {g1, . . . , gs} ∈ G:

    r = f−NF(f ,G) =

    0∑si=1 ai gi with ai ∈ K[x]and LM(f ) ≥ LM(ai gi ) ∀i : ai gi 6= 0Ü In the case of Global orderings there is a unique normal form.Ü Ideal Membership: For a Gröbner basis G of I the following holds:

    f ∈ I ⇔ NF(f ,G) = 0.

    Ü In the general case, such a function is not unique.Ü Different Standard basis algorithms are due to different normal forms.Ü Ideal Membership in the general case:

    f ∈ I ⇔(

    NF (f ,G) = 0 or LM (NF (f ,G)) /∈ L(I))

    Ü The procedure reduce computes a normal form.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ALGORITHMS TO COMPUTE STANDARD BASES

    Ü Algorithms to compute Standard Bases:

    1 For global orderings this is Buchberger’s algorithm.

    Which is a generalization of the Gaussian elimination algorithm and theEuclidean algorithm.

    2 For local orderings it is Mora’s tangent cone algorithm.

    Which itself is a variant of Buchberger’s algorithm.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD BASES IN SAGE I

    Ü To compute the standard basis of an ideal we can use the proceduregroebner basis().

    Ü This procedure could take as input an algorithm from the list below:

    1 singular:groebner: Singular’s groebner command.

    Computes a standard basis of an ideal or module by:

    an specified method std, slimgb, hilb, fglm.heuristically chosen method which choose the best algorithm to computethe basis.

    There exists no uniform best method for computing standard bases but thedifference in performance of a method on different examples can be huge.

    It is recommended for global orderings.

    HINT: It is recommended to test for hard examples various method on asimplified example. (e.g. use characteristic 32003 instead of 0 or substitute asubset of parameters/variables by integers).

    2 singular:std or libsingular:std: Singular’s std command.

    The standard basis is computed with a straight-forward implementation of theclassical Buchberger (resp. Mora) algorithm.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD BASES IN SAGE II

    HOMOGENEOUS IDEAL

    An homogeneous ideal in K[x] is an ideal generated by a set of homogeneouspolynomials, i.e. consisting of terms of the same degree.

    3 singular:stdhilb: Singular’s stdhilb command.

    Computes the standard basis of an homogeneous ideal via a Hilbert drivenstandard computation.

    4 singular:stdfglm: Singular’s stdfglm command.

    1 Computes a Gröbner basis of the ordering given as the second argument(if no second argument is given degrevlex is used).

    2 Converted it to the ordering or the basering via linear algebra (using thefglm algorithm).

    5 singular:slimgb or libsingular:slimgb: Singular’s slimgb command.

    The monomial ordering has to be global.

    The algorithm is described in the thesis of Michael Brickenstein written in 2004under supervision of G.M. Greuel in Kaiserslautern.

    It is designed to keep polynomials with small coefficients.

    Best resuts are examples over function fields.

    The implementation is not optimal for weighted degree orderings.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    STANDARD BASES IN SAGE III

    6 macaulay2:gb: Macaulay2’s gb command (if available).

    7 magma:GroebnerBasis: Magma’s stdfglm command (if available).

    8 toy:buchberger: SAGE’s educational buchberger algorithm withoutBuchberger criteria.

    9 toy:buchberger2: SAGE’s educational buchberger algorithm withBuchberger criteria.

    10 toy:d basis: SAGE’s educational buchberger algorithm for computation overPIDs.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF STANDARD BASES IN SAGE I

    EXAMPLE

    sage: P. = PolynomialRing(QQ,3,order=’lex’)

    sage: f = a+2*b+2*c-1

    sage: g=aˆ2-a+2*bˆ2+2*cˆ2

    sage: h=2*a*b+2*b*c-b

    sage: I = P.ideal([f,g,h])

    sage: B1 = I.groebner basis(); B1

    [a - 60*cˆ3 + 158/7*cˆ2 + 8/7*c - 1, b + 30*cˆ3 - 79/7*cˆ2+ 3/7*c, cˆ4 - 10/21*cˆ3 + 1/84*cˆ2 + 1/84*c]

    sage: B2 = I.groebner basis(’singular:groebner’); B1 == B2True

    sage: B3 = I.groebner basis(’singular:std’); B1 == B3 True

    sage: B4 = I.groebner basis(’singular:stdhilb’); B1 == B4True

    sage: B5 = I.groebner basis(’singular:stdfglm’); B1 == B5True

    sage: B6 = I.groebner basis(’singular:slimgb’); B1 == B6True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXAMPLES OF STANDARD BASES IN SAGE II

    TIME COMPARISONS IN MICROSECONDS

    sage: %timeit I.groebner basis()

    625 loops, best of 3: 1.16 µs per loop

    sage: %timeit I.groebner basis(’singular:groebner’)

    625 loops, best of 3: 3.92 µs per loop

    sage: %timeit I.groebner basis(’singular:std’)

    625 loops, best of 3: 3.92 µs per loop

    sage: %timeit I.groebner basis(’singular:stdhilb’)

    625 loops, best of 3: 3.84 µs per loop

    sage: %timeit I.groebner basis(’singular:stdfglm’)

    625 loops, best of 3: 3.85 µs per loop

    sage: %timeit I.groebner basis(’singular:slimgb’)

    625 loops, best of 3: 3.79 µs per loop

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXERCICES I

    1 Compute the leading term and the leading coefficient of

    f = 4xy2z + 4z2 − 5x3 + 7xy2 − 7y4

    with respect to the orderings:

    lex on Q[x, y, z]deglex on (Z/2Z) [z, y, x ]

    2 Determine matrices defining the orderings (for 3 variables): lex, neglex,degrevlex, deglex, negdegrevlex and negdeglex.

    3 Give one possible realization of the following rings in SAGE:

    Q[x, y, z]F5[y, x, z]Q[x, y, z]/〈x5 + y3 + z2〉

    (Z/Z2) [x1, . . . , x10]F5[x, y, z]〈x,y,z〉Q[x, y, z]〈x,y〉

    HINT: Let� be a local ordering on K[x1, . . . , xn ] then:

    K[x1, . . . , xn, y1, . . . , ym ] = K(y1, . . . , ym)[x1, . . . , xn ]�.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXERCICES II

    4 Which of the following orderings are elimination orderings: lex, neglex or(lex(n), neglex(m)).

    Compute a standard basis of the ideal 〈x − t2, y − t3, z − t4〉 for all thoseorderings.

    5 Obtain an standard basis of the ideal I ∩ K[x, y, z] whereI = 〈t2 + x2 + y2 + z2, t2 + 2x2 − xy − z2〉 ⊂ K[x, y, z, t].

    6 Check whether the following polynomials are contained in the idealI = 〈x10 + x9y2, y8 − x2y7〉 of the ring Q[x, y, z] and the local ringQ[x, y, z]〈x,y,z〉.

    f1 = x2y7 + y14

    f2 = xy13 + y12.

    7 Use SAGE to solve the following linear system of equation:

    x + 5y = 2−3x + 6y = 15

    Compared the standard basis algorithm with the Gaussian elimination algorithmin this case. Try also the procedure solve.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASESBASIC RINGS

    LOCAL RINGS

    POLYNOMIALS

    MONOMIAL ORDERINGS

    LEADING MONOMIAL

    IDEALS

    QUOTIENT RING

    LEADING IDEALS

    STANDARD BASE

    EXERCICES

    INTRODUCTION TO CODINGTHEORY

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    EXERCICES III

    HOMOGENIZATION

    Let f (x, y) ∈ K[x, y ]. The polynomial

    f h(x, y, z) = zd f(

    xz,

    yz

    )∈ K[x, y, z]

    where d = det(f ) is called the homogenization of f.

    Ü Notice that every monomial of F has degree d .

    Similarly if I is an ideal in K[x1, . . . , xn] then

    Ih ={

    f h | f ∈ I}

    is its homogenization and is an homogeneous ideal.

    8 Apply the corresponding procedures from SAGE to check whether an ideal or apolynomial is homogeneous and to compute its homogenization.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    INTRODUCTION TO CODING THEORY

    A Mathematical Theory of Communication(Claude Shannon, 1948)

    Coding Theory Information Theory

    Message

    k -tuple

    ENCODER Channel DECODER

    Noise

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    INTRODUCTION TO CODING THEORY

    A linear code C of parameters [n, k ] over the alphabet Fq is a k -dimensionalsubspace of Fnq .Its size is M = qk , the information rate is R = kn and the redundancy is n − k .

    The Generator Matrix of a linear code C is a matrix G ∈ Fk×nq whose rows forma basis of C, i.e.

    C ={

    xG : x ∈ Fkq}.

    A generator matrix of the form G =(

    Ik P)

    is said to be in standard form.

    The Parity-Check Matrix of a linear code C is a matrix H ∈ F(n−k)×nq whosenullspace is generated by the codewords of C, i.e.

    C ={

    y ∈ Fnq : Hyt = 0

    }.

    The Hamming distance between x, y ∈ Fnq is: dH (x, y) = | {i : xi 6= yi} |.The support of a vector x ∈ Fnq is: supp(x) = {i : xi 6= 0}.The Hamming weight of a vector x ∈ Fnq is: wH (x) = |supp(x)|.The Minimum distance of a linear code

    dmin(C) = minc1, c2 ∈ C

    c1 6= c2

    {dH (c1, c2)} .

    PROPERTIES

    1 dmin(C) = minc∈C\{0} wH (c).

    2 GHT = 03 Singleton Bound d ≤ n − k + 1.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    INTRODUCTION TO CODING THEORY

    EXAMPLE: THE REPETITION CODE OVER Fq

    C = {(λ, . . . , λ) : λ ∈ Fq}

    Ü Is a linear [n, 1, n] code. Ü G =(

    1 1 . . . 1)∈ F1×nq is a

    generator matrix for C.Ü A parity check matrix for C is

    H =

    1 −1 0 . . . 0 0 00 1 −1 . . . 0 0 0...

    .

    .

    .

    .

    .

    .. . .

    .

    .

    .

    .

    .

    .

    .

    .

    .0 0 0 . . . 1 −1 00 0 0 . . . 0 1 −1

    ∈ F(n−1)×nq

    EXAMPLE: TRIVIAL CODES

    {0} is a linear [n, 0, n + 1] code with generator matrix G = ∅ and parity checkmatrix H = In.

    Fq is a linear [n, n, 1] code with generator matrix G = In and parity check matrixH = ∅.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    GENERAL CONSTRUCTIONS

    Ü LinearCode

    EXAMPLE

    sage: MG = MatrixSpace(GF(2),4,7)

    sage: G = MG([[1,1,1,0,0,0,0], [1,0,0,1,1,0,0],[0,1,0,1,0,1,0], [1,1,0,1,0,0,1]])

    sage: C = LinearCode(G) ; C

    Linear code of lenght 7, dimension 4 over Finite Field ofsize 2

    Ü LinearCodeFromCheckMatrix

    EXAMPLE

    sage: MH = MatrixSpace(GF(2),3,7)

    sage: H =MH([[1,0,1,0,1,0,1],[0,1,1,0,0,1,1],[0,0,0,1,1,1,1]])

    sage: C = LinearCodeFromCheckMatrix(H) ; C

    Linear code of lenght 7, dimension 4 over Finite Field ofsize 2

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    GENERAL CONSTRUCTIONS

    Ü LinearCodeFromVectorSpace

    EXAMPLE

    sage: V = VectorSpace(GF(2), 7)

    sage: W=V.subspace([[1,1,1,0,0,0,0], [1,0,0,1,1,0,0],[0,1,0,1,0,1,0], [1,1,0,1,0,0,1]])

    sage: C=LinearCodeFromVectorSpace(W); C

    Linear code of lenght 7, dimension 4 over Finite Field ofsize 2

    Ü RandomLinearCode

    EXAMPLE

    sage: C=RandomLinearCode(7,4,GF(2)); C

    Linear code of lenght 7, dimension 4 over Finite Field ofsize 2

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    CONSTRUCTION OF A CODEWORD

    Ü random element

    EXAMPLE

    sage: C=RandomLinearCode(7,4,GF(2))

    sage: C.random element()

    (1, 0, 1, 0, 1, 1, 0)

    Ü Information vector

    EXAMPLE

    sage: G=C.gen mat()

    sage: c2 = vector([1,1,1,1])

    sage: c=c2 * G; c

    (0, 1, 1, 1, 0, 1, 1)

    Ü Fixed matrix or vector

    EXAMPLE

    sage: F=GF(2); a=F.gen()

    sage: v1=vector([a,F(0),a,a,a,a,F(0)])

    sage: v2=matrix([[a, F(0), a, a, a, a, F(0)]]

    sage: v1 in C; v2 in C

    True, True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    CODING THEORY FUNCTIONS

    gen mat, check mat

    EXAMPLE

    Let us construct [7, 4, 3] binary Hamming code via its parity check matrix. Weproceed as follows:

    sage: MH = MatrixSpace(GF(2),3,7)

    sage: H =MH([[1,0,1,0,1,0,1],[0,1,1,0,0,1,1],[0,0,0,1,1,1,1]])

    sage: C = LinearCodeFromCheckMatrix(H); C

    Linear code of lenght 7, dimension 4 over Finite Field ofsize 2

    We can now check the property of the check matrix:

    sage: G=C.gen mat()

    sage: G*H.transpose()

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    CODING THEORY FUNCTIONS

    SPECTRUM OR WEIGHT DISTRIBUTION

    The spectrum of a linear code C is the set (A0, . . . ,An) where Aw denotes thenumber of codewords in C of weight w .

    Ü The support of C return the set of indices j where Aj is nonzero.

    WEIGHT ENUMERATOR

    Ü The weight enumerator of C is the following polynomial:

    WC(X) =n∑

    w=0

    Aw Xw.

    Ü The homogeneous weight enumerator of C is

    WC(X ,Y ) =n∑

    w=0

    Aw Xn−w Y w

    PROPERTIES

    The minimum distance is determined by the weight enumerator:

    dmin(C) = min {i | Ai 6= 0 and i > 0} .

    Also the dimension of C: WC(1, 1) =∑n

    w=0 Aw = qk(C).

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    CODING THEORY FUNCTIONS

    We can compute the weight enumerator for C⊥ via the MacWilliams identity.

    MACWILLIAMS IDENTITY

    WC⊥ (X ,Y ) = q−k WC(X + (q − 1)Y ,X − Y ))

    EXAMPLE

    sage: GC=RandomLinearCode(7,4,GF(2))

    sage: C.length(); C.dimension()

    7, 4

    sage: C.minimum distance()

    2

    sage: C.spectrum()

    [ 1, 0, 7, 0, 7, 0, 1, 0]

    sage: C.weight enumerator()

    x7 + 7x5y2 + 7x3y4 + xy6

    sage: C.support()

    [ 0, 2, 4, 6 ]

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    DUAL CODE

    DUAL CODE

    Given a linear [n, k ] code C we define the dual code C⊥ as

    C⊥ ={

    x ∈ Fnq | c · x = 0∀c ∈ C}

    C⊥ is a linear [n, n − k ] code.(C⊥)⊥

    = C.

    G is a generator matrix of C ⇔ G is a parity check matrix of C⊥.

    EXAMPLE

    sage: C=RandomLinearCode(7,4,GF(2)); C

    Linear code of length 7, dimension 4 over Finite Field ofsize 2

    sage: D=C.dual code(); D

    Linear code of length 7, dimension 3 over Finite Field ofsize 2

    We can now check the above properties:

    sage: C.gen mat() == D.check mat()

    True

    sage: C.dual code().dual code() == C

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    BOOLEAN CODING THEORY FUNCTIONS

    is self dual, is self orthogonal, is subcode, ==

    DEFINITIONS

    Let C and D be linear codes over Fq of length n.

    C is self-dual if C = C⊥.

    C is self-orthogonal if C ⊂ C⊥.

    D is a subcode of C if D ⊆ C.

    EXAMPLE

    We can construct a subcode of a given linear code as follows:

    sage: C = RandomLinearCode(7,4,GF(2))

    sage: G1 = C1.gen mat()

    sage: G2 = G1.matrix from rows([1,2])

    sage: C2 = LinearCode(G2)

    sage: C2.is subcode(C1)

    True

    The following example is a self-dual and self-orthogonal code:

    sage: C = ExtendedBinaryGolayCode()

    sage: C.is self dual(); C.is self orthogonal()

    True, True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    BOOLEAN CODING THEORY FUNCTIONS

    is permutation automorphism, is permutation equivalent

    DEFINITIONS

    Let C and D be two Fq -linear codes of the same length. ThenC is permutation equivalent to D if there exists a permutation matrix Π such thatΠ(C) = D.

    The permutation automorphism group of C is the set of permutation matrix suchthat Π(C) = C.

    EXAMPLE

    sage: C = HammingCode(3,GF(2))

    sage: g = SymmetricGroup(7).random element(); g

    (1,4,7,2,3,5)

    sage: Gp = C.permuted code(g)

    sage: Cp.is permutation equivalent(C)

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    BOOLEAN CODING THEORY FUNCTIONS

    In the following example we compute the permutation group of a linear code

    EXAMPLE

    sage: C = HammingCode(3,GF(2))

    sage: AG = C.automorphism group binary code(); AG

    Permutation Group with generators [(3,4)(5,6), (3,5)(4,6),(2,3)(5,7), (1,2)(5,6)]

    sage: S7=SymmetricGroup(7)

    sage: g1 = S7("(1,4,7,2,3,5)")

    sage: C.is permutation automorphism(g1)

    False

    sage: g2 = S7("(3,4),(5,6)")

    sage: C.is permutation automorphism(g2)

    True

    sage: Cp2=C.permuted code(g2); Cp2 == C

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    CODING THEORY FUNCTIONS

    Let G ∈ Fk×nq be a generator matrix of a [n, k ] linear code C and I ⊆ {1, . . . , n}.Ü We denote by GI the submatrix formed by the I-indexed columns of G.

    INFORMATION SET

    A subset I of size k is an information set if GI is invertible.

    SYSTEMATIC MATRIX

    A generator matrix is systematic at the position I = (i1, . . . , ik ) if GI = Ik .

    In Sage the function Information Set return the pivots (j1, . . . , jk ) of a systematicgenerator matrix of the code C which is an information set of C.

    EXAMPLE

    sage: G = matrix (GF(3), 2, [[1,2,1],[2,1,1]])

    sage: C = LinearCode(G);

    sage: C.gen mat()

    [1 2 1],[2 1 1]

    sage: C.gen mat systematic()

    [1 2 0],[0 0 1]

    sage: C.information set()

    [0, 2]

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    Ü Let C be a linear [n, k ] code over Fq and (J, J) be a partition of {1, . . . , n}.Ü We denote by x|J =

    (xj | j ∈ J

    )the restriction of any vector x ∈ Fnq to the

    coordinates indexed by J.

    Ü Via the operation of puncturing and shortening we can obtained codes ofshorter lenght from C.

    PUNCTURING A CODE(C|J)

    We can punctured C by deleting columns from a generator matrix of C i.e.

    C|J ={

    c|J | c ∈ C}

    Note that we keep its dimension fixed but we vary its length and redundancy.

    SHORTENING A CODE (C.J )

    We can shorten C by deleting columns from a parity check matrix of C. Thus thewords of C.J are codewords of the initial code that have a zero in the J-location, i.e.

    C.J ={

    c|J | c ∈ C and c|J = 0}

    Note that we keep its redundancy fixed but we vary its length and dimension.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    EXAMPLE

    Ü Syntax for the puncturing construction, (not always the dimension is fixed).

    sage: C = RandomLinearCode(7,4,GF(2)); CLinear code of length 7, dimension 4sage: C1 = C.punctured([6]); C1Linear code of length 6, dimension 4sage: C2 = C.punctured([3,4,6]); C2Linear code of length 4, dimension 3

    Ü Syntax for the shortening construction, (normally the dimension also decrease).

    sage: C1 = C.shortened([5]); C1Linear code of length 6, dimension 4sage: C2 = C.punctured([6]); C2Linear code of length 6, dimension 3sage: C3 = C.punctured([3,4,6]); C3Linear code of length 4, dimension 1

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    PROPOSITION

    Puncturing a code is dual to shortening, i.e.

    (C.J )⊥ = (C⊥)|J and (C|J )⊥ = (C⊥).J

    EXAMPLE

    We can check the above property.

    1 We construct a random linear code C

    sage: C = RandomLinearCode(7,4,GF(2))

    2 We take the dual⇒ C1 = C⊥

    sage: C1 = C.dual code()

    3 We shorten at the first position C ⇒ C2 = C.{1}sage: C2 = C.shortened([1])

    4 We punctured at the first position C1 ⇒ C3 = (C⊥)|{1}sage: C3 = C1.punctured([1])

    5 Finally we check that C2 = C3sage: C2.dual code() == C3

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    Ü Let C be a linear [n, k, d ] code over Fq .Ü Via the operation of extending we can obtained longer codes from C.

    EXTENDING A CODE (Ĉ)

    We can extend C by adding a coordinate cn+1 to each codeword c ∈ C such thatc1 + . . . + cn + cn+1 = 0, i.e.

    Ĉ ={

    (c1, . . . , cn+1) ∈ Fn+1q | (c1, . . . , cn) ∈ C and c1 + . . . + cn + cn+1 = 0}

    Note that we keep its dimension fixed but we vary its length and redundancy.

    PROPOSITION

    Let G and H be a generator and a parity check matrix respectively for C. Then agenerator and a parity check matrix for Ĉ are given by

    Ĝ =(

    G vT)

    and Ĥ =(

    1 1H 0

    )with v ∈ Fkq such that vi = −

    ∑nj=1 gij .

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    PROPOSITION

    Ĉ is a linear [n + 1, k, d̂ ] code with d̂ = d or d + 1. In the binary case,

    d̂ ={

    d If d is evend + 1 Otherwise

    PROPOSITION

    The inverse of extending a code is puncturing at the last position (and viceversa).

    EXAMPLE

    Ü The extension of the [7, 4, 3] binary Hamming code C is equal to an [8, 4, 4]code.

    sage: C = HammingCode(3,GF(2))

    sage: C1 = C.extended code(); C1

    Linear code of length 8, dimension 4

    Ü The code obtained by puncturing on the last position the extended binaryHamming code gives the original Hamming code.

    sage: C1.punctured([7]) == C

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    EXAMPLE

    Ü We compared the generator matrices of C

    sage: C.gen mat()[1 0 0 1 0 1 0]

    [0 1 0 1 0 1 1]

    [0 0 1 1 0 0 1]

    [0 0 0 0 1 1 1]

    sage: C1.gen mat()[1 0 0 1 0 1 0 1]

    [0 1 0 1 0 1 1 0]

    [0 0 1 1 0 0 1 1]

    [0 0 0 0 1 1 1 1]

    Ü We check that Ĥ is a parity check matrix for Ĉ

    sage: C.check mat()

    [1 0 0 1 1 0 1]

    [0 1 0 1 0 1 1]

    [0 0 1 1 1 1 0]

    Ü We construct Ĥ following the equation of the previous Proposition

    sage: H = matrix (GF(2), 4, [[1,1,1,1,1,1,1,1],[1,0,0,1,1,0,1,0], [0,1,0,1,0,1,1,0], [0,0,1,1,1,1,0,0]])

    sage: C1.random element()*H.transpose() == 0

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    For i ∈ {1, 2}, let Ci be a linear [ni , ki , di ] code over Fq with Gi as generator matrixand Hi as parity check matrix.

    THE DIRECT SUM CODE (C1 ⊕ C2)

    The direct sum C1 ⊕ C2 is defined by

    C1 ⊕ C2 = {(c1, c2) | c1 ∈ C1 and c2 ∈ C2}

    PROPERTIES

    Ü C1 ⊕ C2 is a linear [n1 + n2, k1 + k2, d ] code with d = min{d1, d2}.

    Ü G =(

    G1 00 G2

    )is a generator matrix for C1 ⊕ C2.

    Ü H =(

    H1 00 H2

    )is a parity check matrix for C1 ⊕ C2.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    EXAMPLE

    We implement the direct sum of two linear codes:

    sage: C1=RandomLinearCode(7,4,GF(3)); C1

    Linear code of length 7, dimension 4

    sage: C1.minimum distance()

    2

    sage: C2=HammingCode(3,GF(3)); C2

    Linear code of length 13, dimension 10

    sage: C=C1.direct sum(C2); C

    Linear code of length 20, dimension 14

    sage: C.minimum distance()

    2

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MODIFYING CODES

    PROPOSITION

    If C is a direct sum of C1 and C2 then

    WC(X ,Y ) = WC1 (X ,Y ) ·WC2 (X ,Y ).

    EXAMPLE

    sage: C1 = RandomLinearCode(7,4,GF(3))

    sage: f=C1.weight enumerator()

    sage: C2 = HammingCode(3,GF(3))

    sage: g=C2.weight enumerator()

    sage: C=C1.direct sum(C2)

    sage: C.weight enumerator() == f*g

    True

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ENCODING-DECODING PROCESSES

    Ü Encoding: works simply by multiplying an information vector with a generatormatrix of the code.

    EXAMPLE

    sage: G=C.gen mat()

    sage: c2 = vector([1,1,1,1])

    sage: c=c2 * G; c

    (0, 1, 1, 1, 0, 1, 1)

    Ü Decoding: is done by the function Decode.

    FUNCTION DECODE

    C.decode(received vector, method)

    Optional methods are: guava, nearest neighbor and syndrome. By defaultsyndrome decoding is used.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ENCODING-DECODING PROCESSES

    Let C be a [n, k, d ] code over Fq and H ∈ F(n−k)×nq a parity check matrix of C.

    NEAREST NEIGHBOR ≡ BRUTE FORCE

    Given a received word y ∈ Fnq this method try to find a codeword c ∈ C thatminimizes the hamming distance dH (c, y).

    COMPLEXITY

    This algorithm has running time of

    O (Ns) = O(kqn)

    where N is the cardinality of Fnq and s is the dimension of the code C.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ENCODING-DECODING PROCESSES

    SYNDROME

    The syndrome of a vector x ∈ Fnq is the vector s(x) = HxT ∈ Fn−kq .

    1 c ∈ C if and only if s(c) = 0.

    2 If x1, x2 ∈ Fnq and s(x1) = s(x2) then x1 − x2 ∈ C.

    COSET LEADER

    We can partition C into qn−k sets of size qk called cosets of C and denoted by x + Cwith x ∈ Fnq .

    1 Two vectors x, y belong to the same coset if s(x) = s(y).

    2 Any vector of minimal weight in a coset is called coset leader.

    Ü Every coset of weight t ≤⌊

    d−12

    ⌋has a unique coset leader.

    Algorithm 3.1: Syndrome decoding algorithmData: A table with a list of pairs (s(e), e) where e ∈ Fnq is a coset leader of the coset

    with syndrome s(e) ∈ Fn−kq and the received word y ∈ Fnq .

    Result: A codeword c ∈ C such that dH (y, c) ≤ minx∈C {d(y, x)}.Computes s(y).1Look at the unique pair (s(y), e) in the table.2Return y− e ∈ C.3

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    ENCODING-DECODING PROCESSES

    EXAMPLE

    sage: RandomLinearCode(10,3,GF(2))

    sage: C.minimum distance()

    3 % We can correct up to 1 error

    sage: c=C.random element(); c

    (0, 0, 1, 1, 0, 0, 1, 1, 1, 0)

    sage: e=vector(GF(2),[1,0,0,0,0,0,0,0,0,0]); e; e in C;

    (1, 0, 0, 0, 0, 0, 0, 0, 0, 0) False

    sage: y = vector(c+e);y; y in C

    (1, 0, 1, 1, 0, 0, 1, 1, 1, 0) False

    sage: C.decode(y) == c True

    sage: C.decode(y,method="nearest neighbor") == c True

    If there are more than 1 error the decoder could be unsuccesful

    sage: e=vector(GF(2),[1,1,1,0,0,0,0,0,0,0]); e; e in C;

    (1, 1, 1, 0, 0, 0, 0, 0, 0, 0) False

    sage: y = vector(c+e);y; y in C

    (1, 1, 0, 1, 0, 0, 1, 1, 1, 0) False

    sage: C.decode(y) == c

    False

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    NOTATION

    Characteristic crossing functions :

    H : Zs → Zsq and N : Zsq → Z

    s

    where:

    The map H is reduction modulo q.The map N replaces the class of 0, 1, . . . , q − 1 by the same symbolsregarded as integers.

    Support of a vector

    supp(u) = {i : ui 6= 0} ⊆ {1, . . . , n}.

    Every u ∈ Zn can be written uniquely as u = u+ − u− where u+, u− ∈ Nnand have disjoint supports.

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MINIMAL SUPPORT CODEWORDS

    Let A ∈ Zm×nq , b ∈ Zmq and w ∈ R

    n , we define

    IPA,w,q (b) =

    Minimize w · Nu

    subject to

    {Aut ≡ b mod qu ∈ Znq

    Modular Integer Programming Problem

    Let C be a linear [n, k ] code. Given a re-ceived word y ∈ Fnq MDD is to find acodeword x ∈ C that minimizes the Ham-ming distance dH (x, y).

    Minimum Distance Decoding (MDD)

    6= except for the binary case

    A test-set for IPA,w,q (b) is a subset T�w ⊆ kerZq (A)such that for each non-optimal solution u there existst ∈ T�w such that u − t is also a solution and t �w 0.

    Test-SetA test-set for the code C is a subset

    T ⊆ C

    such that for every vector y ∈ Fnqeither y ∈ C or there exists a t ∈ Tsuch that wH (y − t) < wH (y)

    Test-Set

    We can define the ideal associated to IPA,w,q (b) as

    I(A⊥) =〈{

    xNwj − 1

    }kj=1∪{

    xqi − 1}q

    i=1

    where {w1, . . . , wk} ⊆ Znq is a set of Zq -generators of

    the row space of the matrix A ∈ Zm×nq .

    A reduced Gröbner basis of I(A⊥) induced a test-set for IPA,w,q (b)

    6= except for the binary case

    Universal Test-Set for IPH,q(b

    ) = Codewords of minimal

    support of C

    A Graver basis of I(H⊥ )

  • A CASE STUDY OF THECOMBINATORICS OF LINEAR

    CODES WITH SAGE

    INTRODUCTION TO SAGE

    RINGS, IDEALS ANDSTANDARD BASES

    INTRODUCTION TO CODINGTHEORY

    GENERAL CONSTRUCTIONS

    CODING THEORY FUNCTIONS

    DUAL CODE

    BOOLEAN CODING THEORYFUNCTIONS

    MODIFYING CODES

    ENCODING-DECODING PROCESSES

    MINIMAL SUPPORT CODEWORDS

    SPECIAL CONSTRUCTIONS

    CODE BOUNDS

    CODING THEORY NOT YET INSAGE

    EXERCICES

    MINIMAL SUPPORT CODEWORDS

    Let C be a [n, k ] linear code over the alphabet Zq with GC ∈ Zk×nq andHC ∈ Z(n−k)×nq as generator and parity check matrices respectively.

    MINIMAL SUPPORT CODEWORD

    c ∈ C \ {0} has minimal support if its support is not contained in the support of anyother codeword. We denote byMC the set of codewords of minimal support of C.

    THEOREM [MÁRQUEZ-MARTÍNEZ 2010]

    The set of codewords of minimal support of the code C ⊆ Znq corresponds to theGraver basis o