# Project Linear Rank Metric Codes in Sage – GSoC 2016

### Introduction:

This document is meant to be a reference for people who want to understand the work done on implementing Skew Polynomials and Rank Metric Codes in Sage as a part of this GSoC 2016 project. My mentors for this project are Johan Rosenkilde and David Lucas. This post provides a brief mathematical background, summary and status of the tickets related to the project and further links to detailed discussions and the code. It is assumed that the reader is familiar with the basic concepts of abstract algebra, coding theory and Sage itself.

### Background:

A Skew Polynomial is given by the equation:

$F(X) = a_{n} \times X^{n} + ... + a_0$

where the coefficients $a_i \in R$ and $X$ is a formal variable. Let $R$ be a commutative ring equipped with an automorphism $\sigma$. Addition between two skew polynomials is defined by the usual addition operation and the modified multiplication is defined by the rule $X \times a = \sigma(a) \times X$ for all $a$ in $R$. Skew polynomials are thus non-commutative and the degree of a product is equal to the sum of the degrees of the factors. Then the ring of skew polynomials can be written as $R[X, \sigma]$.

Linear Rank Metric Codes are linear error correcting codes over the rank-metric and not the Hamming metric. The distance between two matrices is defined as the rank of the difference between them. And this forms a metric. They are a way to build codes that can detect and correct multiple random rank errors. Gabidulin Codes are an example of linear rank metric codes.

A Gabidulin Code $Gab[n, k]$ over $\mathbb{F}_{q^m}$ of length $n$ (at most $m$) and dimension $k$ (at most $n$) is the set of all codewords, that are the evaluation of a skew polynomial $f(x)$ belonging to the skew polynomial constructed over the base ring $\mathbb{F}_{q^m}$ and the twisting automorphism $\sigma$.

$\text{Gab[n, k]} = \big\{ (f(g_0) f(g_1) ... f(g_{n-1})) = f(\textbf{g}) : \text{deg}(f(x)) < k \big\}$

where the fixed evaluation points $g_0, g_1,..., g_{n-1}$ are linearly independent over $\mathbb{F}_{q}$. These codes are the rank-metric equivalent of Reed Solomon Codes.

Implementation:

During the community bonding period, we started with a small fix to the wtdist_gap method from the module linear_code.py. This involved improving its documentation, changing to a better name and making the method private. We also opened a ticket for a new abstract class for Golay Codes. However, there was not enough time to finish this ticket since the coding period started.

David had already implemented a class to manage representation of elements of a field extension into a smaller field. We went through the review checklist in Sage. This has now been merged into Sage.

Xavier Caruso had authored a ticket on Skew Polynomials about four years ago. This was not reviewed at the time. And the category framework in Sage underwent massive restructuring and change since then. As a result, this ticket was very incompatible. We first started by resolving the several hundred doctest errors some of which were due to deprecated syntax errors while others were more technical. This ticket was the most difficult and complicated module and it took a lot longer than originally anticipated. Debugging the code ended up breaking Sage several times before all originally present doctest errors were resolved. Once the ticket started working, a lot of the methods and classes still did not have proper documentation and/or tests and we added those. Since this was a huge ticket, we then decided to break it up into five smaller tickets based on the content and dependencies to make the work more manageable. We majorly refactored the code in the first ticket to make it cleaner and then added methods such as operator evaluation, interpolation, minimum vanishing polynomial, etc to the appropriate various classes. For the purposes of the other targets for the GSoC project, we practically needed only the first of the five tickets (mentioned above) which dealt with the basic implementation of skew polynomials and skew polynomial rings. So the primary focus has been to get that merged. The second ticket based on skew polynomials over finite fields has also been worked upon. The remaining three tickets were more or less lifted directly from the original skew polynomial ticket and no effort has been made yet to accommodate for changes to these.

We then created a new abstract base class for Gabidulin Codes and implemented Generator Matrix based and Skew Polynomial Evaluation based encoders for it. This module also included a Gao Decoder for the Gabidulin Code and a Channel class to introduce random rank errors. Along with all of this, basic getter methods and methods to compute some basic combinatorial properties were also implemented.

Lastly, we worked on a new base class called AbstractLinearRankMetricCode that inherits from the AbstractLinearCode class and from which Gabidulin Code inherits. This class provides methods that are common to any Linear Rank Metric Code so as to facilitate the creation of other such codes. It also deletes those methods from the general linear code class that are not valid in the case of rank metric codes.

Current Status: The tickets related to skew polynomials, Gabidulin Codes and AbstractLinearRankMetricCode are currently still open. We believe that the skew polynomial ticket is almost ready to be merged into Sage. It has been well tested and we believe it is in stable condition. The Gabidulin Code ticket is not as rigorously tested and the Gao decoder in particular needs to be examined further. The completion of this ticket depends on the AbstractLinearRankMetricCode class which requires also requires some work.

I am currently attending Sage Days 75 in Paris to which I was invited by my mentors. We have coding sprints all week long and we aim to wrap up all of the starred tickets (see below) this week. The next section provides links to more elaborate details about the work done during the project.

### Code:

All relevant tickets, bug reports and code commits can be found below:

1. #20565 – Fix LinearCode.wtdist_gap method (enhancement)
2. – A class to manage Golay Codes (new)
3. #20284 – A class to manage representations of elements of field extensions (review)
4. – Skew polynomials (enhancement)
5. – A class for skew polynomials over finite fields (enhancement)
6. – Interpolation/evaluation methods for skew polynomials (content)
7. – Karatsuba-based methods for skew polynomials (content)
8. – Center-related content for skew polynomials (content)
9. – Factoring/irreducibility methods for skew polynomials (content)
10. – A class for Gabidulin codes (feature)
11. – An abstract class for rank-metric codes (feature)

Tickets in green represent merged code, tickets in blue represent mature code and the ones in brown represent immature tickets.

The daily project progress log that provides further details about the project can be found at the following link:

https://arpitdm.wordpress.com/sage-project-log/

The blog posts related to Sage can be found here:

https://arpitdm.wordpress.com/category/open-source/sage/

# Skew and Linearized Polynomials

Gabidulin Codes, one of the primary modules of my GSoC project, are Maximum Rank Distance (MRD) codes analogous to Reed Solomon in Rank-Metric. In this post, I give a basic overview of the one of the preliminaries, Skew and Linearized Polynomials, required in their construction in Sage.

Consider a non-commutative ring ${R = \mathbb{F}[X; \sigma, \delta]}$ where we have a ring A of usual polynomials in variable X, a ring endomorphism ${\sigma}$ on A and a ${\delta}$-derivation which is essentially a map ${\delta: A \rightarrow A}$ such that for all a, b in A,

${\delta(a + b) = \delta(a) + \delta(b)}$
${\delta(a + b) = \delta(a)b + \sigma(a)\delta(b)}$
This ring with the usual addition and modified multiplication subject to the relation above is called a Skew Polynomial Ring of Endomorphism type. Recall that, a Homomorphism is a structure preserving map from one mathematical object (such as group, ring, vector space) to another. And an Endomorphism is a homomorphism from a mathematical object onto itself.

Given a finite field ${\mathbb{F}_q}$ of order q and its extension field ${\mathbb{F}_{q^m}}$ for some fixed positive integer m, a Linearized Polynomial in variable X is given by

${L(X) = \sum_{i=0}^{n-1} a_i X^{q^i}}$

where each of the coefficients ${a_i}$ belongs to ${\mathbb{F}_{q^m}}$ and the exponents of the monomials are powers of q. The degree of this polynomial, also called the q-degree, is n-1. The non-commutative univariate Linearized Polynomial Ring consisting of all such polynomials L(X) over ${\mathbb{F}_{q^m}}$ is denoted by ${\mathbb{L}_{q^m}}[X]$. Ernst Gabidulin used this ring to build Gabidulin codes where codewords are given by the coefficients of the polynomials, i.e. ${C = (a_0, a_1, . . . , a_{n-1}) \in \mathbb{F}_{q^m}^{n} }$.

Linearized and Skew Polynomial Rings are isomorphic with matching evaluation maps. More specifically, when the derivation ${\delta}$ is 0 and the endomorphism ${\sigma}$ is a Frobenius Automorphism (recall that an automorphism is an endomorphism that admits an inverse and for a finite field, a Frobenius Endomorphism is always also a Frobenius Automorphism), the Skew Polynomial Ring becomes a Linearized Polynomial Ring. That is to say, the latter are a special case of the former.

Sage has an open ticket that already implements the Skew Polynomial Ring and provides functionality to evaluate a given polynomial and perform basic operations such as addition, subtraction, multiplication and division. Our aim therefore, is to complete the open ticket and use that to create the appropriate, required linearized polynomial ring.

# First Contributions

Setting up for developing Sage is one thing, actually contributing to the development is a completely different ball game. The development process, broadly speaking, consists of the following steps:

1. Identify a defect, bug, enhancement or new feature that Sage has or requires.
2. Open a ticket on Trac describing the exact problem.
3. Enter discussions with other community members on clarifying the issue and discuss solution and implementation ideas.
4. Write code and submit.
5. Get it reviewed by other at least one other independent programmer.
6. If review is positive, the ticket is closed and code is successfully merged. Otherwise, go back to step 3 and repeat.

As a contributor, one needs to know how to do both, review as well as successfully write code. And that is what this post describes. I’ll use tickets that I worked on, to illustrate these aspects of development in further detail. In order to avoid confusion, I’ll use Code while talking about Coding Theory and code to talk about programming.

### Reviewing a Ticket:

David and Johan (my mentors for the project) suggested Ticket #20113. The zero method in the linear_code.py file was supposed to return the zero vector of the associated Code. The original implementation called the gens method (the generators of the Code), took the first element of the returned list, multiplied it by 0. This resulted in all zero vector of length of the Code. While the solution wasn’t incorrect, this was a rather tedious way of obtaining it. David had already submitted a patch that simply called the zero element from the ambient space of the Code to produce the answer.

My job was to review this new code and at first glance, this seems trivially correct. And it was. But this may not always be the case. Sage is a massive beast and a small change in one part of the code could break something in some other seemingly unrelated part of the code. There are a lot of things that need to be verified and the best way is to simply follow the Reviewer’s Checklist. I’ll clarify some of the terms from there first and then provide a general rule-of-thumb workflow on how to interact with the git-trac system to review.

• Doctests and Coverage: The documentation for each of the methods in Sage contains examples of code that explains how to use the method. Python can search for and extract these commands, run them and compare the output to the one mentioned in the documentation. If the patch changes code, the doctests for all the changed methods must still hold true. To do this, run the command ./sage --coverage src/sage/coding/linear_code.py.
• Manuals and Building: Manuals serve as a reference book and can be incredibly useful for quick reference. Sage adds material to its manuals from the documentation in the source code itself. Which is why the documentation should follow a specific template. See here for examples and notice the formatting and indentation. Run ./sage –docbuild reference html to build the html version of the “Reference” Manual. Others include _tutorial, developer, constructions and installation_. These are also available in pdf versions.
• Speedup: Generally, it is hard to check the speed. Standard Python time-management (import time, time_clock()) can be used. The main idea is to ensure that the new code does not utterly slow down Sage. Patchbot reports can also be used but caution should be exercised and error reports should be double-checked. Run methods on large inputs, compare to other softwares that offer similar functionality, try boundary cases and consistency checks based on mathematical foundations.

Review Workflow:

1. git trac checkout TICKET_NUM (This will create a local branch say t/20113)
2. git checkout t/20113
3. ./sage -b (See if the code builds without errors)
4. Run through the Checklist above and note down errors, if any.
5. Run various test examples in an attempt to “break” the code.
6. Go to Trac and write comment(s).
7. Change ticket status.
8. Write your full name in the Reviewer field of the ticket.

### Writing a Ticket:

David and Johan suggested improving the efficiency of the decode_to_code method of the Nearest Neighbour Decoder. I opened a Ticket #20201 on Sage to fix this. The previous implementation created and stored the distances between the received word and every codeword. It then sorted the entire list in order to find the closest codeword. This took exponential memory and time in the size of the Code which can be very inefficient for large input. An obvious solution is to compute the Hamming weight for the first codeword and set that as the minimum. Then, iterating over the rest of the codewords and updating the minimum drastically brings down the memory and run time requirements.

There are some major differences when it comes to actually opening a new ticket and writing code for it. Whenever you write new code in Sage, you might want to add some print statements and code, run the files, test, make small changes and test again. In that case, you have to build sage (./sage -b) or in some cases even run make distclean &amp;&amp; make which can take a very long time. Instead, the best way is to write your new code in a myfile.sage file and then run ./sage myfile.sage.

Write Workflow:

1. Open a new ticket on Sage. Or if a ticket that has commits already exists, create a local branch on your system. And then pull the changes from the ticket onto your branch. Do not directly checkout the ticket. It can result in very weird errors.
2. Discuss solution idea on trac.
3. On the local branch (NOT master) corresponding to the ticket, write your code.
5. git add <changed_file(s)>
6. git commit -m "insert detailed message here."
7. git trac push TICKET_NUM`
8. Once you’re satisfied with your commits, set the ticket field to “needs_review”.
9. If positive, ticket closed. Else, go back to step 2.

As a final note, Sage is guaranteed to break down at any point for seemingly no valid, discernible reason and I’ve lost track of the time I’ve spent in trying to fix it. But in doing so, I’ve learnt a lot about the codebase and once you successfully manage to rebuild Sage, there is a weirdly awesome feeling of accomplishment!

# On Applying to Sage for GSoC

Sage is a viable open source mathematics software package that offers an extensive toolbox
for algebra, combinatorics and numerical computations. This massive project can seem daunting to someone who wants to begin contributing to it, especially in the short GSoC application period. In what follows, I cover a constantly updating collection of advice for new programmers, to simplify the process of applying to Sage.

#### 1) Where to find Sage

Mailing Lists:

The following are the primary ones:

• sage-devel – development discussion group of Sage
• sage-support – help in running/using Sage
• sage-gsoc – related discussions regarding the GSoC program

Apart from these, there are tons of other topic based lists dedicated to specific modules. For example, sage-coding-theory. When applying to GSoC, find a project from the Ideas page and post on sage-gsoc (with a cross post on the related topic-based list, if it exists) indicating your interest in the project and request more details; instead of simply asking for help in “getting started” since one is “very interested in contributing to open source”.

Source Code:

• git.sagemath.org – Online Sage repository. A good way to read the code online
• Documentation – Developer’s guide to the Sage
• Trac – Organizing development and code review through tickets

#### 2) Contributing to Sage

The following is more of a cheat sheet to setup everything you need so you can begin contributing. When in doubt or need of further clarity, always refer to the official documentation. It is really well written!

Installation:

1. Install Sage: Assuming the source code is downloaded, unzip it and go inside the directory. And run “make”. This should take a few hours. Once it finishes, you can run it by typing “./sage” on the command prompt.
2. Configure git: Assuming you have git installed, run the following two configuration commands (if you haven’t already)

git config –global user.name “Your Name”
git config –global user.email you@yourdomain.example.com

3. Install git-trac:Now, all development tasks can be performed in the usual way using git and a browser. Alternatively git-trac can simplify the communication process between git and trac. To use this, run:

git clone https://github.com/sagemath/git-trac-command.gitsource
git-trac-command/enable.sh (enables it temporarily)
cd git-trac-command
sudo python setup.py install

4. Obtain Sage Trac account: Development happens through tickets on Trac. In order to comment, review, commit or interact in any other active way with the source code, a Trac account is required. To do that, send an email to sage-trac-account@googlegroups.com, containing your full name, preferred username, contact email and reason for needing an account. Once the request is approved, a username and password will be assigned.
5. Configure git-trac: Authentication mechanism is required for read-write access. Simply put, sage needs to be told about trac with verification. To do this, run:

ssh-keygen (to generate a public/private rsa key pair)

Run the Sage prompt (./sage) and upload it to trac using the command “dev.upload_ssh_key()“. Use the credentials obtained above for completing the authentication.

Again, the Sage documentation is magnificent and it should be referred to in case of doubts or further explanations. Once all this is done, one can start contributing by checking out an existing ticket or opening a new one. There is a lovely cheat sheet on how to do all that, already available. The way development happens is, someone opens a ticket regarding a bug, defect, new feature or enhancement and writes code for it. Once the commit is ready, it is opened for review whereupon an independent second programmer checks it and suggests changes or gives it a thumbs up.

Communicating with the Sage community:

While the people in the community are extremely helpful, it is necessary to ask for help wisely. Through the communications, three aims need to be achieved:

1. Form a positive impression on the mentors and admins: Ask precise questions (and don’t hesitate to ask them), ask for help if you don’t understand something but do your homework before asking. For instance, I was asked to review a tiny patch and I didn’t know what review entailed. Sage documentation has a Reviewer’s Checklist and I tried to follow that and asked questions when I didn’t understand something from there.
2. Make a small contribution(s) to the code: Ask for tickets related to the project you are applying for since that will not only help you understand the development process better, but also the module itself. Ideally, I’ve found that a review of one ticket and writing another new ticket on an associated module can suffice.
3. Understand and further define the project: Mentors have usually given the project more thought and therefore it is a good idea to talk to them and get an idea about what they have in mind for it first. What is not available, is an exact statement on what all needs to be added and how. Ask for reading material, get clarity on the various modules that need to be implemented as part of the project and come up with a plan on what needs to be done to achieve that.

#### 3) Writing a GSoC Proposal

A good proposal cannot be prepared without a proper understanding of the organization and the project idea itself. And simply having a good understanding is not enough, if that is not visible through the proposal. There is no right way of preparing a proposal. The best way is to go over as many of them as you can find and then suitably adapting elements from each to suit the particular project in question. Here’s mine for what it’s worth: Rank-Metric Codes in Sage

There’s plenty of other advice on how to write a good proposal available; the recurring points being concise writing, clarity on project deliverables, structured timeline and review from mentors.

# Doctor Who: Sense of Time

December 9, 2014:

Any exposition on the ethos of Doctor Who has the potential for further exploration of what is quite simply one of the most iconic television shows of all time. That is in part because of the richness of the elements of the mythos such as the TARDIS and the archetypal villains and monsters; and also in part due to the coherency of the narrative structures and thematic contents that drive the show. Ultimately, what makes it so lovable is the way it is so alien to us and yet allows us to identify with countless aspects, none more so than the pathos of the Doctor himself and his companions as well.

When one is so far removed from the human race and then plunged into the rest of the cosmos exploring the strangest of lands and even stranger creatures, the overwhelming message that one receives is the sense of what it means to be human. The world described in this story is built on science, logic and reason and yet superstition and magic abound. Clara accepts that there are mystical forces because of which an entire planet gets covered by a forest overnight. The Doctor believes that there is a scientific explanation for it. And we as viewers, are asked to cede to both. By describing the limits of imposing a clean line of divide between science and mysticism, one is forced to confront the two warring sides in us. Thus this world is one where ritual and reason are basic tenets, anthropologically speaking. The Doctor lives in this world, subscribes to a rigid orthodoxy of rationalism by accepting only the logic part and abhors the superstitions of humans by constantly deriding them. The companions on the other hand are characters who have accepted and combined the rational and the irrational into one worldview.

We, humans, are used to divorcing the within from the without.  The Doctor and the companions represent these aforementioned two warring sides within us. The eternal internal conflict we struggle with. By believing in one and rejecting the other, we are attempting to recreate the world in our own image. When the world itself does not conform to this, the endeavour is doomed to fail. The Master is their way of showing this. When an embodiment of chaos tries to impose an order on the world, the result is never going to be a happy one. As an aside, that is why it an interesting result. Not to mention, watching Simm torment Tennant is just pure fun !
However, there is hope for redemption because we have a sense of time. Being human means having this remarkable characteristic; alongside so much selfishness and cruelty in specific instances, there is freedom from envy which the present displays towards the future. There is a certain innocence to idiocy in that one refuses to consider the larger ramifications of immediate actions. By choosing to let the universe explode just so that Smith could restart it and “save” everyone, shows the complete disregard to that present’s future in favour of the new world that is essentially the same.

Our display of utter forgetfulness towards the past is indeed a sad loss. There is much to glean from it. We are able to look further into the future only by standing on the shoulders of the giants of the past. Newton’s unified theory of gravity is the direct genesis of Galileo’s invention of the telescope and the subsequent observation that the earth does in fact revolve around the sun. Having the War Doctor begin calculations on the door in his time, so that they are complete by the time Smith arrives, although this all happens in the same instant, is the show’s way of showing that without the knowledge of the past, the present cannot function and the future cannot be built. A sense of time is thus very important. TARDIS is this show’s Chekhov’s gun in that it is irreplaceable and necessary and uniquely identifiable. Moreover, it stresses this very importance of the sense of time that being human, entails. We humans are TARDISes in our own right. We are bigger on the inside than the outside. We are able to recollect and rewrite our own past in the way we want and make designs on our future as well. We move through space and time, meet new people, encounter perplexing events and through it all try to maintain some semblance of balance in our own universes. And if we break, so does the universe.

Immanuel Kant posited a distinction between analytic and synthetic semiotics. He defined analytic as that which when negated, leads to a contradiction. Synthetic is everything else that is not analytic. Although according to Husserl’s phenomenology, nothing can ever be truly known, Kant’s theory that synthetic is the source of all new knowledge is thus a welcome one. One of the fundamental reasons that a show could get boring is if it sticks to the analytic and fails to bring in something new. You don’t want to see the same trait, same story rehashed and reiterated in a different way. Then, it can’t be negated and there is nothing new to learn. Who constantly chooses to reinvent its titular character by coming up with stories that tell us something that we didn’t know before. And that is why we choose to come back to it. The new hypothesis about the Doctor has the potential to be erroneous and that’s what sparks the debate. That’s what keeps us hooked.

Too much of anything, however good, is bad. You can’t change everything because you want your viewers to be grounded, tethered to familiar terra firma before launching them into the deep unknown. You can bring in cool bowties and fezzes, you can redesign the interior of the TARDIS, but at the end of the day you want the sonic screwdriver to be there. You want the Doctor to show up, figure out the answer and rain down on the wrong-doers with silent fury. Tennant did that in his first scene, and so did Smith and so did Capaldi ! Every time the Doctor regenerates and his persona changes, you want the new one to be different from the ones before him. But the underlying traits that make him the Doctor must be self-evident. Something old, something new. Moreover, while Doctor Who has become ubiquitous in popular culture today, it still has to be influenced by the happenings around the real world. The stories must thematically resonate with the audience. And so you must bring in elements from other genres, the real world and so on. The target audience being children, it is a great way to teach them history by literally going back in time and taking from legends and creating stories around it. Vincent and the Doctor, Shakespeare Code are but two examples of that. And TARDIS is a wonderful storytelling device that allows for this to happen. Something ‘borrowed’, something blue ! And when you marry these two rules together in perfect harmony, one can vow that the end result will be a happy one, for ever after. Here’s to fifty more years of Who and fifty after that… !

# Game of Thrones: Hardhome – Episode Review

Season 5, Episode 8:

Humanity. That’s what the show has been about. From the very beginning, it has attempted to lay down the basic tenets of what it means to be human and that thematic narrative has never been stronger than in tonight’s episode. The very first scene of the Series introduced the white walkers and while they have been absent for the most part since, we are never led afar from them. They are always in the back of the mind. Today, we get the first taste of the bigger picture. Humans have always been forgetful of the past. Give it some time and history becomes myth. The analogy of the ‘wheel’ that Dany seeks to break, is an apt reminder of our forgetfulness. The absence of the White Walkers for so long has resulted in a disillusionment that Lannisters are the enemies of Starks and Baratheons are foes to the Boltons. There is only one real enemy. The White Walkers. And why are they enemies? Hardhome answers that. Stannis claims the Iron Throne for himself out of a sense of familial right. Dany claims the throne because she believes she is the rightful heir, but also because she believes she can rule better than anyone else. Cersei, and Tommen through her, claim the throne because they are the most powerful, or so they believe. And so on for each of the Houses. Each of them has a personal motive, a legacy, a voice. The White Walkers don’t. Their leader (we need a name for him. Ice King, House Frost, Olawful (Frozen), … Olawful of House Frost. Yup ! ), Olawful of House Frost, sends the rest of the fighters hurtling over the mountain so they may join the attack faster and he doesn’t say a word. That chilling silence is all the indication you need. They are here to take the living, and turn them into undead soldiers to add to their ranks. Why? Just.

Every single person in Westeros has heard tales of the White Walkers. They have heard what they are capable of. Yet they choose to ignore the threat. We as watchers (pun intended), repeat the words Winter is Coming with the characters. But even we forget the real enemy. That’s why this episode is so crucial to the show. It has enough intimate moments to allow us to connect emotionally, but it’s main aim is to bring into focus the bigger picture. The scale of the world that GRRM has drawn up is revealed in one shocking, jaw-dropping scene after another in the battle sequence at the end (I’ll get to that later). And we see the series turning. We see the end coming. It’s still at least a couple of seasons away and therefore a while away, but we know it’s close. The start of the final lap is signaled today. And that realization, that climax is what is exhilarating. The fact that it is executed with such care by Benioff and Weiss in their writing and by Miguel in his direction, leaves us breathless. I know I sat gaping at the screen for quite a while, even after the episode ended.

Partnerships are the unifying force for all of us human beings. We forge them, we break them. The opening shot has Tyrion and Dany facing each other off. Something that has not yet happened in the books. It’s both of them sizing each other up. Make no mistake, Tyrion is just as sceptical of Dany as a ruler, as Dany is of Tyrion as an advisor. Tyrion has only heard of Dany through Varys’ whispers and seen her through Jorah’s devotion. But as established in “Cripples, Bastards and Broken Things”, he always wanted to explore the wall personally and lean off its edge to actually believe the wonder. Same holds true here. He wants to converse with the Mother of Dragons to find out for himself if she is really worthy of everything she is made out to be; whether she actually has it in her to overcome the challenges that lie in front of her. On the other hand, Dany is someone who has grown up listening to everyone speak and then deciding what she wants to do. It lets her know exactly how full of shit the other person is. She is strong and level-headed enough to recognize the wisdom in the speech of others and separate it from the personal motivations behind that speech thereby gauging the true merit of the proposal. And isn’t that what a leader is supposed to be doing? A good ruler is not someone who can solve math equations or make scientific breakthroughs and so on… She is someone who brings about an environment that fosters the same. Their conversation ties in directly with the underlying theme we have been discussing. It hurts Dany to hear ill of her father even after knowing of the Mad King’s atrocities. It pains Tyrion to admit that his own father sentenced him to die. Bonding over common difficulties is what we all do. That lays the ground for the more important discussion about Dany’s current predicament and its benefits and drawbacks. We’ve seen their struggles over the past four and half seasons, but this scene does complete justice to the immense significance of their meeting. She needs a shrewd politician by her side if she is going to successfully rule Westeros. Who better than Tyrion who has on numerous occasions proven himself, never more so than when he was the Acting Hand to King Joffrey ! Director Miguel Sapochnick does extremely well in that scene where he zooms into Peter and Emilia as they talk about their fathers and leaves us with a shot of the entire vast room to emphasize the magnitude of their meeting.

“Hardhome” has become my favourite Game of Thrones episode of all time, so far. As someone who has read up till the latest book, it is greatly satisfying to see Tyrion analyze Dany’s situation so succinctly and it converges the storyline in such a way so as to push us into the final lap that I earlier talked about. Dany finally reaching Westeros seems to be a distinct possibility because Tyrion can help her untie the Meereenese Knot (Wut Wut 😀 ). She commits to her principles and her providence, the Iron Throne, and Tyrion commits to her. Not since Littlefinger and Varys’ conversation about the “parts we play in this world” in the Throne Room have we had two people who understand each other perfectly. Beyond the Narrow Sea just got a whole lot more interesting  and I can’t wait for more conversations between the pair of them !

There are three other minor storylines in this episode, Cersei’s, Arya/Lana’s and Olly’s and I’ll talk about them because the thematic narrative here is built on the opening scenes and leads nicely into the second half of the episode, the battle at Hardhome. While, all three of these scenes are placeholders, they serve as positioning pieces before the end-game. Cersei rotting away in prison is a delight for the viewers, but there is the irony that her actions have consequences for her. This construct can be delineated in the Lana story too as she is asked to become someone else, observe and ultimately carry out the judgment on the ‘thin man’. As for the third one, Sam tried to offhandedly explain that sometimes, we do what we think is right even if others might think it is wrong, without proper context. I guess he didn’t pay enough attention to Aemon Targaryen. Anyway, I think that counts as a proper signal that Olly is going to be the one to stab Jon Snow when he returns with the wildlings. That look in his eyes before he closed the door was enough proof for me. But apart from this, there is a finer point that this is going to make. Going to make because it hasn’t happened yet in the show, but with the foresight due to the books, we know is going to happen. That point is, being human is intimately and intricately related to being powerful. Power is not only marked by wealth, but there is great currency in position, respect and of course intelligence. Cersei’s power derives itself from the station she holds herself in and when she will have the walk of shame in King’s Landing, it will take away her power and leave bare humanity (no pun intended, but as always is welcome) in place. When others begin to think that she is like them, that’s when Cersei feels the most insulted. Similarly, Arya is turning into someone else, and swapping identities like clothes. By judging those who are criminal, she defines humanity as something that differs from person to person and seeks to impose her own on others. Isn’t humanity universal? Shouldn’t there be just unified view? More on this after the events at King’s Landing and Braavos unfold. Incidentally, Sansa’s storyline adds another dimension to this by showing Boltons, clearly the main villains this season, to be inhumane.

It is thus difficult to decide which the biggest threat of them all is. Alternatively, whatever each of the Houses do to one another, is there a bigger threat to humanity than humanity itself? Why should Dany seek to break the “wheel” she spoke of? Because there is a bigger threat. The non-humans, or the former-humans, the White Walkers. The fundamental strategic weakness of the human race is that our dead outnumber the living. If they are relentless in their pursuit of us, we are doomed to fail. The battle at Hardhome reinforces the view that the Walkers are not left as an afterthought.

And lastly, to quote AV Club for the next bit:
It’s true there was no real suspense regarding Jon Snow, who unsurprisingly survived the battle after his Valyrian Steel proved just as effective as Dragonglass in taking down a Walker. But what makes “Hardhome” so effective is that it doesn’t solely depend on Jon’s heroism as an anchor in the battle. The introduction of Karsi is what makes the battle work as effectively as it does, offering an arc that speaks to our understanding of humanity. When she is introduced, she is headstrong and skeptical, albeit in rational ways that are completely understandable. When she agrees to work with Jon and Tormund, it is because she trusts Tormund and not Jon, and not because she has completely changed her mind or forgotten the two groups’ complicated past. She saves her children but not herself, placing the lives of many over her own by staying to help convince others. And she eventually dies because she couldn’t see past the fact that the wights who killed her were once children like her own daughters, much as Jon and Tormund might one day look at her as their former comrade-at-arms. The tragipoetic journey of Karsi in this episode didn’t need to be extended across an entire season. Although I may not have felt her death emotionally in the way I would feel the death of a character with the show since the beginning, her death resonated amidst the carnage of the battle around her, and was the punctuation mark to the White Walkers’ display of power. While Jon can talk about the undead all he wants, showing off dragonglass and perhaps explaining the research Sam has unearthed in the library at Castle Black, the threat to humanity is best understood by seeing someone’s humanity built up and stripped away right before your eyes.

Random Shit:

1. Would Wun Wun the giant, fit on Stannis’ boat?
2. I really hope they show the epilogue of Dance with Dragons in this season itself.
3. Thank goodness they chose not to introduce the Ironborn this season.
4. Aegon Targaryen. Will he come this season? I certainly hope so.
5. I’m guessing they are going to leave R+L=J for next season.
6. Bran. Bran. Bran. Bran. Bran. Bran. Bran.
7. Qyburn mentions that the work is nearly complete. Which means, Robert Strong is coming !
“There were shadows all around them. One Shadow was dark as ash, with the terrible face of a hound. Another was armored like the sun, golden and beautiful. Over them loomed a Giant in armor made of stone, but when he opened his visor, there was nothing inside but darkness and thick black blood.” – That was Bran in book 5.

# Game of Thrones: The Dance of Dragons – Episode Review

Season 5, Episode 9:

There are so many themes and so many topics that GoT forces you to discuss that it is an impossibly daunting task. Still, attempt we must. But anything and everything must come after The Death. Shireen.You can come to terms with Eddard’s death. Refer to it mockingly after a few years by saying Ned getting his head chopped off was shocking. Red Wedding was exhilarating, King Evil-Fucktard’s death jubilant and so on. But this one, was painful in a way none of the others were. It is just as pivotal as Ned’s was because it defines what the show and the world within it really is. Brutal and Cruel respectively. It happens off-screen which in itself is excruciating enough as is. It may not have hit us as viscerally as Ned’s or the Viper’s, but it packed a good wallop tonally. It was a deeply saddening moment to say goodbye to a child who was wise beyond her years and yet naive. In a show where every minute is important, spending more than five on her conversations with her real and surrogate fathers gave her death the depth it demanded. The parable of the Dance of Dragons is where our story begins.

As wise as she is, Shireen is still naive. Of course this comes as an afterthought for those of us watching. Even in our lives we have this refuge in the innocence of idiocy of not examining the repercussions of our current actions, in the future and, geometrically in the landscape of the lives of those around us. When the two Targaryen brothers fight, not choosing a side is the most logical option, in hindsight. When caught in the ravages of war, we must choose. Not choosing is not a choice that is usually available. If we don’t choose, someone else will surely choose for us. And once we choose, there are corresponding consequences. Tyrion says later in the episode, “It is easy to confuse what is with what ought to be, especially when what is has so often worked out in your favour.” Shireen’s idealistic view of the things is right. Had the rest of the people chosen not to participate in the fight between the two brothers in the parable, one would have in some form or another emerged victorious and that would have been that. There would have been no further bloodshed. But she is naive. She attempts to teach this to everyone. Peacefully. Through debate. And by being eloquent. But the eloquent are wrong just as often as the imbeciles, as Tyrion teaches us (Every great line is given to Tyrion. Save one which belong to Ygritte. The fan in me loves that. Keep it up ! 😀 ). This is an idealistic worldview which clashes with reality. We divorce what is within us, with what’s on the without, the outside world. By believing in one and rejecting the other, we attempt to reimagine the world as something it is not. This world does not behave that way. Obviously her endeavour is thus doomed to fail. Credit the Onion Knight for he is the real deal. Davos is the genius although he is not literate (education sucks. Down with the schooling system!) and he effectively manages to separate intelligence in Shireen’s teachings from the naivette when he counsels.

On the other end of the spectrum we have Stannis who does the same thing, recreate the world in his own image. Except that he is willing to slaughter everyone to achieve this. Man-made progress is always faster than Natural progress. By doing what he feels he must do, unmediated passion for ‘natural’(in his mind) progress has exacerbated his desire to bring the world to a state of ‘natural’ equilibrium. Through his actions namely to rule the world, be just etc, he tries to reduce the frequency and impact of Natural progress. History is witness to the lack of deference he has towards the consequences that those actions will inevitably have. For now, the voice of cold, hard reason tells Stannis that his *past sacrifices have worked in his favour and by induction, this one will too. His familial love however makes him pause. Davos is capable of persuading him to not commit the horrendous act of filicide (I swear, I’ve learnt so many ‘-cide’ words since ASOIAF !!!). They both know this. So he sends him away to the Wall before that can happen. And in doing so, he loses the capacity for positive virtue. He becomes simply a machine. There is this poem titled Miller of Dee that kinda captures this so aptly (can’t believe this poem I memorized as a child would be used some day !!!!! YAY. 😀 ), a verse from it goes…

“I live by my mill, God bless her! she’s kindred, child, and wife;
I would not change my station for any other in life;
No lawyer, surgeon, or doctor e’er had a groat from me;
I care for nobody, no not I, and nobody cares for me.”

This was the final step in his evolution. Stannis can’t go beyond this. He has cut away the humanity in him and married the rest with nature. There is no man versus nature with him. But few in history will judge him harshly as those in the present. Most will herald his actions. They might write songs and tales about the ‘noble’ sacrifice he made in the name of greater good.

Greater good. A topic that even Harry Potter in it’s finest hour philosophized. There is an intricate relation between politics and morality. There have been revolutions in the past in GoT. All of them were more violent, radical, crazy than this one. But none match the social agitation that underlay this one. What is this one perpetuated by? I think one of the reasons is faith and I shall once again defer that discussion for next week when Cersei’s downfall is complete. The other reason is morality and that I can speak about right now. The possibility of fabricating a social, political and cultural self-identity with none to very little recourse to moral codes speaks to an antiquated stylization of attitudes as evinced by Stannis. There is no longer any aesthetic to one’s existence (which is perhaps just a fancy way of saying that Stannis can now die for all I care 😛 ) after such a cruel recourse. Greater good when studied with a moral codification of knowledge, is open to interpretation. This subject of hermeneutics opposes or repudiates the grounding of oneself in a single objective (in this case, that of becoming the ruler) and allows one to recognize the place of the one in the context of many. I guess what I mean is, Stannis is so focused on becoming the ruler because he thinks he will be a good ruler and that Westeros as a whole will benefit from that, that he forgets what he is losing and what any other person is losing. In Spock’s immortal words, “The needs of the many outweigh the needs of the few, or the one.” The weighing of the needs comes from our sense of morality which is non-existent when it comes to pure reason. The greatest ruler is the progeny of rationality and morality. One without the other leads to foeticide AND matricide AND patricide. (see what I mean about the ‘-cide’ words? Plus, carrying the metaphor LikeABoss !) On a final note on this subject, kudos to Stephen Dillane, the actress playing Lady Selyse whose name I don’t remember and Liam Cunningham. Davos’ final moments with Shireen were heart-wrenching and the final scene before the sacrifice was just as brilliant.

I’ll pivot straight to the other main story, the Great Games in Meereen. I am running out of time and so this will be shorter. The world isn’t black and white as much as we would like to convince ourselves. In fact, it is infinite shades of grey (not finite, say for example 50. And please note the spelling of the last word). There is no single winning situation. Dany has seemingly restored peace to Meereen by marrying Hizdahr do Loraq, but to maintain that she reopens the fighting pits and with each clap, sends men to their deaths. Again there is thematic alignment with the greater good idea that was earlier set up. She is fighting an internal battle and she must face the consequences of her actions. Of course, this soon turns into a fully fledged battle when the Sons of Harpy emerge from the crowds. Any and all illusion of peace is shattered as there is an open riot. Hizdahr talks about how greatness can’t be achieved without cruelty and poetically falls at the hands of the masters too rooted to their pasts to accept the future. Dany survives because of the mercy she showed Jorah following Tyrion’s advice about devotion. Compare that with Stannis who wants his loyal soldiers who did not detect Roose and his men from setting the camp alight, beheaded. He who kills those devoted to him, does not inspire devotion ! Had Tyrion and not Melisandre joined Stannis, he would be winning, except with his humanity intact. But the circumstances crafted by GRRM were so perfect, that Tyrion joining Stannis was simply not possible and joining the Dany, the only logical choice. Did I mention I love Tyrion?

Lastly, the love quadrangle between Hizdahr, Daario, Jorah and Dany, punctuated by quips from Tyrion, was a treat to watch. It would have taken something very special to turn the frown after Shireen upside down. But the dragon ex machina (see what I did there? 😀 ) that they pulled did just that. Dragon rider ! I mean, Dragon rider ! To their credit though, Drogon arriving to save the day did not entirely feel like a cop out to me. It felt almost natural. It felt as if that is what would have happened anyway. Except perhaps the timing of, just when they were surrounded and about to die, was taking dramatic liberties, but we can of course grant them that. Meereen was never fully under Dany’s control. And her abandoning it to the onlooking four advisors is a magnificent conclusion to her story arc for this season.