# Abstraction (Computer Science)
There is a beautiful explanation in [this video on ML Street Talk](https://youtu.be/rie-9AEhYdY?t=3222):
> Abstracting a lot of the specificity away, and making your problem statement more general, you might think would make your problem harder. But it actually makes it easier. If there is a lot going on there is a lot to grab on to, but if I can reduce the things that I'm allowed to grab onto, I can think more clearly about them, and the elegance allows me to reason clearly about them. "Why does this do this? How does this work?" So you abstract away the analytical detail to a problem and then suddenly it becomes tractable, it becomes conceivable.
This is touched on again in the same video [here](https://www.youtube.com/watch?v=rie-9AEhYdY&t=4625s):
> The point of abstraction is to get away from all of this extra baggage that you might think is providing you information but actually isn't.
### General Defintion
An abstraction is the process of removing details. We step back from concrete objects to consider a number of objects with identical abstracted properties. We can define it as:
> **Abstraction**: An emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail).
Why do we actually perform an abstraction? *To reduce complexity by hiding irrelevant detail*! Note, the reduction of complexity is also a goal of [Generalization](Generalization.md).
Let us consider an abstraction of a *cake*. We can imagine that a cake will often contain *many* different types of frosting and cake batter, while being many different shapes and sizes. We can *abstract* the properties of the cake that we feel are the most important, leaving us with an *abstraction* of cake. The key idea here is that we are *removing detail*. So, we may state that in order to qualify as a piece of our abstract cake you must have:
* Frosting
* A texture/filling that is very light and hence low density
Visually, we can think of our abstraction as:

And we can think of an instantiation of this abstract class as:

Mathematically we can view this hierarchy as:
$\text{A cake} \subset \text{Cakes in the abstract}$
### In computer Science
Abstraction is very common in computer science, particularly in the are of *object oriented programming*. In essence, it allows us to move *up and down* a hierarchy of concepts. This is incredibly important because as humans we have limited cognitive processing power and must use it wisely. For instance (sticking with the dessert theme), imagine that your partner asks you to go to the store to buy a cake. Only she doesn't have access to the concept of an abstract cake, so she asks you the following: "Could you go to the store and buy a fluffy sugar-bread mix with confectionary butter topping?" She had to included all of this *extra detail* because she wasn't able to use the common abstraction of "a cake". Consider the cognitive overhead if this approach was always needed to be used!
Now, let us think about computer science. [Wikipedia defines it](https://en.wikipedia.org/wiki/Abstraction_(computer_science)) as follows:
> the process of removing physical, spatial, or temporal details or attributes in the study of objects or systems to focus attention on details of greater importance
As an example, Lets take the old example of a system that manages books for a library. A book has tons of properties (number of pages, weight, font size(s), cover,...) but for the purpose of our library we may only need
```
Book(title, ISBN, borrowed)
```
We just abstracted from the real books in our library, and only took the properties that interested us in the context of our application.
---
References:
* [Abstraction and generalization of objects](https://bor0.wordpress.com/2019/08/08/abstraction-and-generalization-of-objects/)
* [Abstract Ideas](https://english.stackexchange.com/questions/83918/what-does-abstract-ideas-mean)
* [Abstraction vs. Generalization](https://stackoverflow.com/questions/19291776/whats-the-difference-between-abstraction-and-generalization/19464520#19464520)
* [Technical overview](https://www.d.umn.edu/~tcolburn/papers/Abstraction.pdf)
[^1]: Note we could likely, objectively, state that these ideas *do* indeed have a physical existence. They correspond to a neural activation pattern a persons mind that maps to the abstract idea.