Issuu on Google+

1 of 29 Chemical Theory of AI and Natural Life By Ian Beardsley © 2016



2 of 29 In order to understand my AI equations, it might be useful to explain the chemistry of AI and natural life. My core AI equations are (Beardsley, The AI Matrices, 2016, ISBN: 978-1-365-57388-0):

 


3 of 29 Silicon: Has four electrons in its outer shell . . Si . . The outer shell wants eight to be full so, silicon atoms bind with other silicon atoms covalently, that is, each shares it four with the four of the other, to make a crystal: .. : Si : .. : Si : ..

.. Si : .. Si : ..

To make semi conductors, we dope silicon with boron and phosphorus. Boron has three electrons in its outer shell and phosphorus has five electrons in its outer shell: . . B.

.. . P . Doping silicon with boron makes it deficient by one electron, and, doping it with . phosphorus make it have an extra electron. This means doped silicon can carry a current, because in the case of phosphorus doped with boron there is a hole in which electrons can fall into, creating a new hole in another atom, and, in the case of silicon doped with phosphorus, the extra electron can move freely through the crystal.

.. .. .. : Si : Si : Si : .. .. .. : Si : B : Si : .. . .. : Si : Si : Si : .. .. ..

.. .. .. : Si : Si : Si: .. ‌ .. : Si : P : Si : .. .. .. : Si : Si : Si : .. .. ..

4+3=7 8-7=1+ positive type silicon (p type)

4+5=9 8-9=1negative type silicon (n type)  


4 of 29 1 1 2 3 4

2

13

H Li Be ………………………………….B Na Mg………………………………….Al K Ca………………………………….Ga

14

15

C Si Ge

N P As

16

17

18

He O…………Ne S…………Ar Se……….Kr

Let us look at the section of the period table of the elements that has all of the action. Notice that silicon (Si) has phosphorus (P) just to the right of it in period 3 meaning, it has one electron more. Silicon (Si) is in group 14 which, means it needs 4 electrons to to have the electron configuration of Argon (Ar) that is in group 18: 18-14=4. It wants to be like argon because it is in group 18 meaning, it has all of its electron shells full making it an inert, or noble, gas. Thus we say silicon acquires 4 electrons to attain noble gas electron configuration. Notice boron (B) is just to the left of silicon (Si) in group 14, but in period 2, not the period 3 of Si. Therefore, being in group 13, with Silicon in group 14, it has one electron less. Notice germanium (Ge), which can be doped to make semiconductors as well, is in group 14 like silicon and and carbon (C). Silicon, like germanium, is a core element of AI, like C is a core element of Natural Life. We see that AI, and Natural Life (NL) elements have group 14 in common. This is why they are central to life, whether it be artificial or natural. It is so because group 14 elements have a valence of 14-10=4 and ionization state of 18-14=4 meaning for group 14 elements: Valence Electrons = Ionization State. Just as silicon can be doped with boron just to the left of it, and, with phosphorus just to the right of it, germanium (Ge) can be doped with Gallium (Ga) just to the left of it and with Arsenic (As) just to the right of it. Notice the core elements of Life (C, N, O) are in the same area in the table except for Hydrogen (H). Likewise, for the core element of AI (P, B, Si) and (Ga, As, Ge). 



5 of 29 Important to this study is the octet rule. Let us look at that. The Octet Rule: Each atom binds such that it acquires eight electrons in its outer shell. Examples: Sulfur (S) is in group 16, therefore, it has 16-10=6 valence electrons. Thus we write it has a valence of 6e-, and oxygen (O) is in group 16 and, therefore, has 16-10=6 valence electrons. Thus we write it has a valence of 6e-, as well. The ionization state of sulfur (S) is S2- (18-16=2), and the ionization state of oxygen (O) is O2- (18-16=2). Let us consider sulfur trioxide (SO3): S = 6eO3= 3(6e-)=18eS+O3=6e- + 18e- =24eThe number of electron pairs is 24/2=12 Place four electron pairs around the sulfur (S): .. : S: .. That leaves 12-4=8 electron pairs left. Place them around the oxygen atoms, and make a double binding pairs with sulfur for one of them, and the octet rule is satisfied: .. .. : O:S:O: .. .. .. .. :O .. Notice, each atoms has eight electrons in its outer shell and each has a valence of 6e-. 


6 of 29 When metals react with non-metals, the metals lose electrons to become positive ions while the non-metals gain electrons to become negative ions. They combine such that they are neutral. This determines the number of each element in the compound. The amount of electrons gained by non-metals is such that the outer shells are filled so that they have noble gas electron configuration. This can be used with the periodic table of elements to determine the amount of electrons gained. When a metal combines with a non-metal like this, then, it is called ionic bonding. This is in contrast to how non-metals combine with one another. They share their valence electrons, or electrons in their outer shell in other words, such that their outer shells are filled. This is called covalent bonding. How does aluminum (Al) combine with Oxygen (O)? Al is a metal in group 13 in the periodic table. Therefore, Al loses three electrons to become Al_3+ and O is a non-metal in group 16 of the periodic table. The last group is group 18 and O wants to gain 2 electrons attain the nobel gas electron configuration of that group, so it become O_2-. For Al to combine with O and be neutral, it must have two atoms of Al to have a charge of plus six, and there must be three atoms of O to have a negative charge of –6, So, the chemical formula for Aluminum Oxide is: Al_2O_3 Four valence electrons shared with four valence electrons makes eight covalent bonds, which satisfies the octet rule. We need elements that can combine with themselves and, Carbon, Silicon, and Germanium, satisfy that rule because, they are all in group 14 of The Periodic Table of The Elements, having 4 valence electrons and ionization states of 4. That is 14-10=4 and 18-14=4. That is why life, natural or artificial, is composed of these elements. While the octet rule is just a rule, and there are exceptions to it, it is a powerful player in the way elements combine. What is the difference between ionization states and valence numbers? The ionization states are the number of electrons attained by an element to achieve noble gas electron configuration and, valence number is the number of electrons in the outer shell of an element. The ionization state is determined by 18 minus the group number of the element, and the valence number is determined by the group number of the element minus 10. In the case of group 14, these numbers are equal and, as such, group 14 elements are the elements of artificial intelligence (AI) and natural life (NL). 


7 of 29 Let us look at the electron configurations of the elements of AI (B, Si, P, Ga, Ge, As), and of NL (C, N, O):

As you can see, they are all in line with the theory we discussed. For example, silicon has its inner shells the same as those of neon so, we abbreviate them as [Ne] and, its outer shells 3s and 3p, each have have two electrons, for a sum total of 4, which is precisely the valence number of silicon. These are the electrons used for bonding.


8 of 29 Let us look at how carbon binds with itself and hydrogen to form rings or long chains, the backbones of organic matter, the hydrocarbons, and, how silicon can form crystals: Hydrocarbons: Arenes

| —C = C —C— | || —C = C — C— |

Alkanes

| | — C—C— | |

Alkenes | | —C = C— Alkynes — — C—C— — Silicon: .. .. .. : Si : Si : Si : : Si : Si : Si : .. .. ..


9 of 29 We have to ask, why is it so important that a current can flow through doped silicon. The answer is, that there are two types of doped silicon: p-type doped with boron and is electron deficient or, has a net positive charge in other words, and n-type doped with phosphorus and, has a surplus of electrons or, a net negative charge in other words. Current can flow through a copper wire but, if we join p-type silicon with n-type silicon a current can flow through it in only one direction. Thus it is called a semiconductor. Here is how it works: p-type n-type ++++++ | - - - - - ——— ++++++ | - - - - - - ——| | ++++++ | - - - - - | | <——| | | |——————+ V - —————-|

n-type —— - - - - - - | ------| ------| <—— | |——————-+

p-type + + + + + ——— +++++ | +++++ | ——- > | | V - ——————|

If the voltage exceeds 0.6 volts, the electrons on the right will jump the junction fall into the positive holes on the left and establish a current.


The power source, V, attracts to the electrons on left and the power source V attracts the positive side on the right.

| | |


10 of 29

The symbol for a diode, which is p-type silicon junctioned with n-type silicon is: ——-|>—— Which, means a current can flow through it like this: ——-|>—————> But, not like this: ——-|>——<——— What is so important about having an electrical component that does this? The answer is it allows us to build binary logic gates which, allows for making the binary circuits that are either on or off, that are either 0 or 1, to encode instructions for a computer, or AI, to carry out. Observe: “OR” Gate

“AND” Gate

A—-|>——-|———> out | | B—-|>——-| | —————-|——> out —— —-

A—-|<|—-|——-|——————-> out | R B—-|<|—-| | ——-+ — | —————————————> out

If A or B is on then, there is an output.

If A and B on then, there is an output.


11 of 29 The atomic number of an element describes how many protons it has and, since it is neutral, how many electrons it has. The number of electrons determines the electron configuration of the element and, thus its valence number and ionization state. Since Ga (31) is to the left of Ge (32) and, since As (33) is to the right of Ge, we have: Ga+1= Ge and As-1=Ge Ga+1=Ge + As-1+Ge —————Ga+As=2Ge Phosphorus (15) is to the right of silicon (14). Boron (5) is to the left of silicon (14) and Phosphorous (15) is to the right of silicon (14). Thus, we have: B+9=Si and P-1=Si B+9=Si + P-1=Si —————P+B+8=2Si For Carbon (6), Nitrogen (7), O(8), we have: C+1=N O-1=N, so, C+O=2N Taking all three together: Ga+As=2Ge P+B+8=2Si + C+O =2N ————————8=[2Si+2Ge-C]-[P+B+Ga+As]-[O-2N] The eight on the left is the eight electrons of the octet rule described in terms of the core elements of AI and natural life, on the right. Since carbon (C) = 6, Oxygen (O) = 8, Nitrogen (N) = 7 we can write it: 8 = [2Si+2Ge]-[P+B+Ga+As] And, this is the octet rule in terms of the core elements of AI. Lets’s put in the valence number of the elements:


12 of 29 8=[2(4)+2(4)]-[5+3+3+5]=0 This is interesting in that it says eight equals zero. In other words it says eight is a zeroing effect which is true in that an octet (eight electrons) is completed when, the elements of the compound will accept zero more electrons.â&#x20AC;Š


13 of 29 To get started in computer science, you need a compiler. When you take the free online classes at Harvard, they provide you with a compiler. It puts your source code (programming instructions) into zeros and ones, the language that computers understand. Under the hood a computer is a series of switches that are either on or off. Off is zero and on is one. With zeros and ones you can create any number: 0=0 1 =1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 =7 And so on,… With numbers in binary you can represent any character on your keyboard, numbers or letters. The numbers assigned to characters, from which your source code is built, are defined in the ASCII tables, the standardized tables of the language of computer scientists. In the introduction to computer science at Harvard you start out by learning the language called C. It begins with learning how to use the printf() and scanf(), although their compiler has a library that understands a function they substitute for scanf() that makes things easier in the beginning. They are called the GetInt(), GetFloat() or GetString() functions. However a standard C compiler that you buy won’t have these functions and I don’t think programs you write with them will run on most computers. That is why I have learned the scanf() and written some programs with it (provided here) to get a grasp of how it works. So I don’t use any functions that are in the CS50 library in those programs. I use the standard io library that all C compilers have and I am sure will run on any computer. I imagine we will learn the scanf() function as the class proceeds. I am about three weeks into it. Actually the first thing you learn is not print(f) and scan(f) but that at the top of every program you first define the library you are going to use and put the main() function, which tells the computer where your program begins: #include <stdio.h> int main (void) Ian Beardsley January 24, 2014



14 of 29 Binary To Decimal

Decimal (Base 10, Deca meaning 10) 437 400 + 30 + 7 4x100 + 3x10 + 1x7

Binary (Base 2, Bi meaning 2) 0 1 10 11 100 101 110 111 1000

256 64 32 16 2 + 1 ——371


=0 =1 =2 =3 =4 =5 =6 =7 =8

1 0 1 2^8 2^7 2^6 256 128 64

1 1 0 2^5 2^4 2^3 32 16 8

0 1 1 2^2 2^1 2^0 4 2 1

1X256 + 1X64 + 1X32 +1X16 + 1X2 +1X1


15 of 29 Decimal To Binary Convert 237 to Binary:

1 1 1 0 1 1 0 1 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 0 |

237 -128 ——— 109

237>128 put a 1

109

109 > 64 put a 1

- 64

=237

——— 45 45

- 32

45 > 32 put a 1

——— 13 13

- 8

13<16 put a 0

——— 5 Because 13 < 16 put a 1 over the eight (Borrowing) 5

- 4

5 > 4 put a one over the 4

——— 1 1

- 1

——— 0

1< 2 put a zero over the 2 and Borrow We have zero. Stop and write out the bits: 11101101 =237


16 of 29

The basic formula for your first program is: Declare a variable Prompt the user with a printf() function Get the userâ&#x20AC;&#x2122;s value for that variable and give it to the computer with a scanf() function Tell the computer what do with that value Then output the result to the user with a printf() function


17 of 29

learning scanf #include <stdio.h> int main(void) { int age; printf("What is your age? "); scanf("%d", &age); printf("You said your age was: %d\n", age); return 0; } running learning scanf jharvard@appliance (~): cd Dropbox/pset1 jharvard@appliance (~/Dropbox/pset1): ./age What is your age? 48 You said your age was: 48 jharvard@appliance (~/Dropbox/pset1):


18 of 29

The basic formula for your second program is (booleans): Prompt the user Get the userâ&#x20AC;&#x2122;s value for the variable Test it by asking if one thing about it is true. If true, then do something. If not, then do something else.â&#x20AC;Š


19 of 29

Learning Booleans #include <stdio.h> int main (void) { char name [15]; printf("What is your first name?: "); scanf("%s", name); printf("you said your name is: %s\n", name); int n; printf("Is this correct yes=1 no=0? "); scanf("%d", &n); if (n==1) { printf("thank you\n"); } else { printf("leave the room\n"); } } Running Learning Booleans jharvard@appliance (~): cd Dropbox/pset1 jharvard@appliance (~/Dropbox/pset1): make name clang -ggdb3 -O0 -std=c99 -Wall -Werror name.c -lcs50 -lm -o name jharvard@appliance (~/Dropbox/pset1): ./name What is your first name?: Ian you said your name is: Ian Is this correct yes=1 no=0? 1 thank you jharvard@appliance (~/Dropbox/pset1): ./name What is your first name?: Ian you said your name is: Ian Is this correct yes=1 no=0? 0 leave the room jharvard@appliance (~/Dropbox/pset1):


20 of 29

The basic formula for your third program is (loops): Repeat a command until something is true, even iterate it according to a pattern that fits your objective.


21 of 29

Learning Looping #include <stdio.h> int main (void) { int n; do { printf("give me a positive number: "); scanf("%d", &n); } while (n<0); for (int i=1; i<n+1; i++) { printf("%d\n", i); } printf("you promted the user for a number and counted to it with a for loop! \n"); } Running Learning Looping jharvard@appliance (~): cd Dropbox/pset1 jharvard@appliance (~/Dropbox/pset1): ./looping give me a positive number: -1 give me a positive number: 5 1 2 3 4 5 you promted the user for a number and counted to it with a for loop! jharvard@appliance (~/Dropbox/pset1):


22 of 29

One of my first assignments at harvardx was to write a program that uses what is called a Greedy algorithm. The idea is to have the user tell you how much money they are owed, then give them change in quarters, dimes, nickels, and pennies, such that you use the least number of coins. My program not only tells how many coins to give the user, but how many of each kind. Greedy algorithms are any programs that calculate how to achieve the most with the least for any given scenario.


23 of 29

Greedy 07: It is actually this one that works! #include <cs50.h> #include <stdio.h> int main (void) { printf("amount owed: "); float amount= GetFloat(); float cents= 100.0*amount; float quarter= 0; float dime= 0; float nickel= 0; float penni= 0; while (cents>0) if (cents>=25.0) { cents=cents-25.0; quarter=quarter+1; } else if (cents>=10.0) { cents=cents-10.0; dime=dime+1; } else if (cents>=5.0) { cents=cents-5.0; nickel=nickel+1; } else if (cents>=1.0) { cents=cents-1.0; penni=penni+1; } printf("%f %f %f %f %f\n",quarter,dime,nickel,penni,quarter+dime +nickel+penni); }â&#x20AC;Š


24 of 29

Running Greedy jharvard@appliance (~/Dropbox/pset1): ./greedy amount owed: 1.73 6.000000 2.000000 0.000000 3.000000 11.000000 jharvard@appliance (~/Dropbox/pset1): That says if you owe someone a dollar seventy three, give them six quarters, two dimes, zero nickels, and three pennies, eleven coins in total.


25 of 29 #include <stdio.h> #include <math.h> int main(void) { int n; do { printf("How many numbers do you want averaged? "); scanf("%d", &n); } while (n<=0); float num[n], sum=0.0, average; for (int i=1; i<=n; i++) { printf("%d enter a number: ", i); scanf("%f", &num[n]); sum+=num[n]; average=sum/n; } printf("sum of your numbers are: %.2f\n", sum); printf("average of your numbers is: %.2f\n", average); float a, b, product, harmonic; printf("enter two numbers): \n"); printf("give me a: "); scanf("%f", &a); printf("give me b: "); scanf("%f", &b); product = 2*a*b; sum=a+b; harmonic=product/sum; printf("harmonic mean: %.2f\n", harmonic); double geometric; geometric=sqrt(a*b); printf("geometic mean: %.2f\n", geometric); }


26 of 29 jharvard@appliance (~): cd Dropbox jharvard@appliance (~/Dropbox): ./meanvalue How many numbers do you want averaged? 4 1 enter a number: 1.8 2 enter a number: 3.6 3 enter a number: 5.4 4 enter a number: 7.2 sum of your numbers are: 18.00 average of your numbers is: 4.50 enter two numbers): give me a: 1.8 give me b: 7.2 harmonic mean: 2.88 geometic mean: 3.60 jharvard@appliance (~/Dropbox):â&#x20AC;Š


27 of 29 While Loop In Python count.py n=int(raw_input('Count to this integer: ')) x=0 if n>0: while (x!=n): x=x+1 print(str(x)) else: print('Give me a positive integer.â&#x20AC;&#x2122;)

While Loop In C cuenta.c #include <stdio.h> int main(void) { int i=0; int n; printf("Give me an integer less than 10: "); scanf("%i", &n); while (n>0) { i=i+1; n=n-1; printf("%i\n", i); } }â&#x20AC;Š


28 of 29

For Loop In Python For Loops in Python and C cuenta.py n=int(raw_input("Give me a positive int: ")) for number in range(1, n+1): print(str(number))

For Loop In C count.c #include<stdio.h> int main (void) { int n; do { printf("Count to this integer: "); scanf("%d", &n); } while (n<=0); for (int i = 1; i<=n; i++) { printf("%d\n", i); } }

Running the For Loop in C (Does same thing as the While Loops) jharvard@appliance (~): cd Dropbox/descubrir jharvard@appliance (~/Dropbox/descubrir): ./count Count to this integer: 5 1 2 3 4 5 jharvard@appliance (~/Dropbox/descubrir):


29 of 29

The Author


Chemistry of AI and Natural Life