Theory Part 1 - Computation

Dave White

Basics of computation

Data

Information represented in some format or language:

Some languages are better than others for certain tasks

Humans

Nature is encoded in many formats.

Sensory/Perception - translation to a human format

Computation

Computation transforming data into a different state or format

Example:
88 = 1011000
100 = 4
1 + 3 = 4

Computer Jargon

Data - Input/Output
Code - Instructions
Computation - change data into other data using code

Goal as scientists

Decode language of nature into human language.

Data - phenomena
Code - scientific process

Humans as compute-ers

Good: Inference
"Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are."

Bad: Arithmetic
"8329438*19834"

Good: Social logic
"Are you thirsty?"

Bad: Formal Logic
Ice-cream sales increased as a result of increased sunscreen consumption.

Human vs Machine Languages

Neuron populations - probabalistic (non-deterministic)
Transistors - strictly logical.

Machine Language

Your computer only speaks a specific dialect of binary
All machine codes must be very simple and exact

What can you do with binary code

Human to machine language

HUGE gap!

Programming languages are an interface
Still exists a very large gap in complexity between binary and programming languages
Programming code needs to be compiled or translated into machine code before it runs.

Human to machine language 2

With human to machine language
…still a gap!

Programming code needs to be compiled or translated into machine code before it runs.

Symbols on symbols on symbols…

Abstraction

Symbols simplify ideas making them manageable through abstraction
Complex ideas are packaged into language.

Symbolic Representation

Binary is a symbolic representation of voltage states across a transistor
Bindings associate some data with other data.

Name bindings

Name bindings = symbol/name + binding
They are functional functional: 1 symbol for each input

Low level example: ASCII

Name/Symbol Data
1 0001011
A 0001101
+ 1011010

Nothing special about 001011 vs 01101 - CONVENTIONS!

High level example: filenames

\[\underbrace{{\underbrace{\text{myFile}}_\text{symbol/name}}\rightarrow \underbrace{\text{Data}}_{\text{value}} }_\text{name binding}\]

Directories

Folders have their own namespace
Namespaces represent symbolic limits
The folder keeps things separated or provides context.

Example:
Filename "notes.txt" in directory "Programming" vs "Biology"

Scope

The scope is the context where a specific binding is applicable.
Directory 1/
File1
File2
Directory 2/
File 3
cat File1 > File2
cat File1 x File3

For our file, the scope is within the directory.

Namespace vs Scope

A namespace represents all possible names, those used, and whats available.
The scope is in reference to a specific variable: what can see it, what can it see?

Aliases

An alias or reference is a name for a name.
It points to the name of the first.

e.g. Dave

\[\underbrace{{\underbrace{\text{myAlias}}_\text{symbol/name}}\rightarrow \underbrace{\text{myFile}}_{\text{symbol/name}}}_\text{reference (binding)}\]

Pointers

Pointers point to where the Data is.

\[C\underbrace{\underbrace{\text{A}}_\text{symbol}\rightarrow \text{Data A}}_\text{variable (binding)}\]

Pointers

Pointers point to where the Data is.

\[\underbrace{\underbrace{\text{A}}_\text{symbol}\rightarrow{} \text{Data A}}_\text{variable (binding)}\]

\[\underbrace{\underbrace{\text{B}}_\text{symbol}\rightarrow{} \underbrace{\text{Data A Location}}_{\text{address}}}_\text{pointer (binding)} \rightarrow \text{Data A}\]

Example:
SSN

Behavior 1

Let:

What happens to A and P when B is:
renamed?
deleted?
bound elsewhere?

Behavior 2

Example:
Variable A bound to Data A.
Pointer P bound to Data A address.
Reference B bound to variable A.

What happens to A and B when P is:
renamed?
deleted?
bound elsewhere?

Behavior 3

Example:
Variable A bound to Data A.
Pointer P bound to Data A address.
Reference B bound to variable A.

What happens to B and P when A is:
renamed?
deleted?
bound elsewhere?

Review

name binding order bound to
traditional primary Data (+ address)
pointer secondary address
reference/alias tertiary symbol

Different types of data and how it is bound

filenames \(\rightarrow\) files
Drive Letters \(\rightarrow\) hard-drives
variables/functions/code \(\rightarrow\) code

Variable binding

three=3;
pi=3.141593;
myName='David White';

Variable binding 2

three=3;
pi=3.141593;
myName='David White';

% What happends when I do...
A=3;
B=A;
A=5;
B==5;

B=copy(A)
clear A;
% What do I want to happen?

Physical Representation

Bindings take

How much address space?

All data, even symbols

Details depend on

Abstraction

Example:
Run an experiment with subject info.

Abstraction paradigm

How do I treat my data? As
Programming paradigm

Abstraction

Imperative Object Oriented
Order Low High*
Compute time Fast Slower
Initial Implementation time Fast Slow
Human friendliness Low High
Generalizability Low High

Abstraction trade-off

Each level of abstraction requires additional

Abstraction trade-off example

In C

int A=5;
float B=3.2;
return A*A;

In python

A=5
B=3.2
A*B

Filename example

Filename Full Path Inode Data
A-z A-z/A-z/ 0x01fac9 … 0x0fffff 010100011101…

Type and Precision

\(10 \text{ vs. } 0.1\)
\(1.0 \text{ vs. } 1.00001\)
Both determined by data type

Basic Typing

integers
int8 -111111111 to +
int16
int32
uint8

float/decimal
single 16integers 16decimals
double 32 32

char
ABC &-

Precision

The more precise a value, the more required