Computational Thinking, and the Four Habits It Names
Chapter Twelve
Syllabus topic Module 1, "aligned with computational thinking", "symbolic abstraction"
Pages 35 to 37 of 378
In one line
Computational thinking is the habit of turning a problem into something a stupid but tireless machine could finish.
In the wording you can write in an examination: computational thinking is a set of problem-solving habits drawn from computer science and applicable outside it, conventionally given as four: decomposition, breaking a problem into sub-problems; pattern recognition, noticing that a sub-problem has been solved before; abstraction, discarding the detail that does not bear on the problem; and algorithm design, stating the solution as a finite sequence of unambiguous steps.
Why the word is in this syllabus
MU's first course objective for this paper asks you to see śāstra as a structured and formal knowledge system "aligned with computational thinking". So the phrase is examinable, and the alignment is the thing to be argued.
The argument is not that classical authors were programmers. It is narrower and it is defensible: a tradition that has to transmit a discipline through human memory is under the same pressures as one that has to transmit it to a machine. Both must be exact, because there is no author to ask. Both must be compact. Both must handle the case where two rules apply at once. Those pressures produce the same four habits.
Decomposition
The habit. Split a problem into parts that can be solved separately, so that each part is small enough to be got right.
In a śāstra. Piṅgala does not solve "list every metre". He solves "list every metre of one syllable", which is two lines, and then states a rule that turns a list for n syllables into the list for n plus one. Two small problems instead of one unbounded one.
In a program. A compiler is not one procedure. It is a reader, a scanner, a parser, a type checker and a code generator, each of which can be written, tested and replaced on its own.
The test of whether you have done it. Can you check one part without running the others? If not, you have divided the text and not the problem.
Pattern recognition
The habit. Notice that this problem has the shape of one already solved, and reuse the solution rather than the answer.
In a śāstra. The number of metres of six syllables with exactly two light ones, and the number of ways of choosing two objects from six, are the same number. Halāyudha's Meru-prastāra computes both because they are the same problem wearing two descriptions. [Pascal Triangle and Combinatorics] works that out.
In a program. Finding the shortest route between two towns and finding the cheapest sequence of edits between two words are the same problem, so the same algorithm solves both.
The trap. Two problems that look alike may differ in exactly the respect that matters. A pattern is a hypothesis, and it has to be checked.
Computational Thinking, and the Four Habits It Names
Abstraction
The habit. Throw away everything that does not bear on the question, and keep a name for what is left.
In a śāstra. A Sanskrit syllable has a sound, a meaning, a pitch and a length. Piṅgala keeps the length and throws away the rest, and reduces it to two values, light or heavy. Once a syllable is one of two things, counting metres becomes arithmetic. That single decision is what makes the whole of Module I possible.
In a program. Here is the same abstraction, run.
# A metre, abstracted to nothing but the weight of each syllable.
LINES = [
("a ga na tri pa da", [1, 1, 1, 1, 1, 1]),
("ma dhu ra ya ti", [1, 1, 1, 2, 1]),
("so ma pa la", [2, 1, 1, 1]),
]
for text, weights in LINES:
pattern = "".join("G" if w == 2 else "L" for w in weights)
print("%-22s %-8s syllables %d, heavy %d"
% (text, pattern, len(pattern), pattern.count("G")))a ga na tri pa da LLLLLL syllables 6, heavy 0
ma dhu ra ya ti LLLGL syllables 5, heavy 1
so ma pa la GLLL syllables 4, heavy 1The words have gone. What is left is a string over two symbols, which is a thing a rule can be stated about.
The cost. An abstraction is a decision to be blind to something. Piṅgala's abstraction cannot express which syllables rhyme, because rhyme is part of what was discarded.
Algorithm design
The habit. State the steps so exactly that someone who does not understand the problem can carry them out and get the right answer.
In a śāstra. Halāyudha's own words on the prastāra rule are a procedure: write a row of all heavy syllables; then find the first heavy syllable, make it light, make what precedes it heavy, leave what follows alone; repeat until the row is all light. Nothing in that requires you to know what a metre is.
In a program. The same three sentences, in Python, in [Prastāra in Code].
The test. Give the steps to somebody outside the subject. If they need to ask you a question, the steps are a description and not an algorithm. [The Prastāra Rule Read as an Algorithm] applies that test properly, against the five standard properties.
The four habits as a table
| Habit | What you do | Piṅgala's instance | What it costs |
|---|---|---|---|
| Decomposition | split into separately solvable parts | one syllable, then a growth rule | more parts to keep consistent |
| Pattern recognition | reuse a solution, not an answer | metres by weight are combinations | a false pattern misleads confidently |
| Abstraction | discard what does not bear on the question | a syllable becomes one of two symbols | you become blind to what was discarded |
| Algorithm design | state unambiguous finite steps | the prastāra procedure | rigidity: the steps fit one shape of problem |
Computational Thinking, and the Four Habits It Names
What computational thinking is NOT
It is not programming. No machine appears in any of the four habits. A student who thinks the phrase means writing code will misread MU's objective.
It is not a claim that everything is computable. Deciding whether a general connection holds, which is the load-bearing step of every inference in Module II, is not made mechanical by any of the four.
It is not modern. This is the claim MU's syllabus is actually making, and it is the one you should be able to argue in five marks: the habits are habits of anyone who must transmit an exact procedure without being present to explain it.
Quick revision
- Four habits: decomposition, pattern recognition, abstraction, algorithm design. MU's CO 1 names computational thinking.
- Decomposition: Piṅgala solves one syllable plus a growth rule. Test: can you check one part alone?
- Pattern recognition: metres by weight are combinations. Trap: a pattern is a hypothesis.
- Abstraction: a syllable becomes one of two symbols, and that one decision makes Module I arithmetic. Cost: blindness to what was discarded.
- Algorithm design: steps a person outside the subject can follow. Test: do they have to ask a question?
Test yourself
1. Name the four habits and give Piṅgala's instance of abstraction.
Decomposition, pattern recognition, abstraction, algorithm design. Abstraction: a syllable's sound, meaning and pitch are discarded and only its weight is kept, reduced to two values, so that a metre becomes a string over two symbols.
2. What is the test of whether you have really decomposed a problem?
Whether one part can be checked without running the others. If it cannot, the text has been divided but the problem has not.
3. Give the cost of abstraction, with an example from this paper.
You become blind to what you discarded. Piṅgala's scheme cannot say anything about rhyme or meaning, because both were thrown away when the syllable was reduced to its weight.
4. Why is it wrong to read MU's "computational thinking" as meaning programming?
Because none of the four habits mentions a machine. They are habits of stating a problem and a procedure exactly, which is why a tradition transmitting a discipline through memory develops them without any computer at all.
The rest of this subject
These notes are cut from the University's printed syllabus. Open the syllabus itself for the same subject.