## Saturday, 12 September 2015

### representing nuclear decay

The idea is simple enough. Let's use our new function process-reaction() to encode an example of nuclear decay. In this case fission of U_235, but the idea is general enough to extend to other nuclear and chemical reactions.

First, let's learn some example knowledge about fission of U_235:
```sa: load uranium-fission.sw
sa: dump
----------------------------------------
|context> => |context: uranium fission products>

fission-channel-1 |U: 235> => |Ba: 141> + |Kr: 92> + 3|n>
fission-channel-2 |U: 235> => |Xe: 140> + |Sr: 94> + 2|n>
fission-channel-3 |U: 235> => |La: 143> + |Br: 90> + 3|n>
fission-channel-4 |U: 235> => |Cs: 137> + |Rb: 96> + 3|n>
fission-channel-5 |U: 235> => |I: 131> + |Y: 89> + 16|n>
list-of-fission-channels |U: 235> => |op: fission-channel-1> + |op: fission-channel-2> + |op: fission-channel-3> + |op: fission-channel-4> + |op: fission-channel-5>

fission |*> #=> apply(weighted-pick-elt list-of-fission-channels |_self>,|_self>)
----------------------------------------
```
And a note that if we had probabilities for the different fission channels, we could encode that with coeffs other than 1. And this leads to an interesting thought. Standard QM needs complex numbers to work, so we can't do that with the current BKO. But what we can do is represent the results of QM calculations, ie the resulting probabilities, in BKO. The above fission example is the first hint of this idea.

Now, let's fission our uranium:
```sa: fission |U: 235>
|I: 131> + |Y: 89> + 16|n>

-- it's random, so if we try again we should get a different result:
sa: fission |U: 235>
|Xe: 140> + |Sr: 94> + 2|n>

sa: fission |U: 235>
|La: 143> + |Br: 90> + 3|n>

sa: fission |U: 235>
|Cs: 137> + |Rb: 96> + 3|n>

sa: fission |U: 235>
|Ba: 141> + |Kr: 92> + 3|n>

sa: fission |U: 235>
|I: 131> + |Y: 89> + 16|n>
```
This is already fun! But we can now use this to encode the full nuclear reaction:
```n + U_235 -> fission-of(U_235)
```
Let's start with 3 neutrons and 4 atoms of U_235: 3|n> + 4|U: 235>
```sa: process-reaction(3|n> + 4|U: 235>,|n> + |U: 235>,fission |U: 235>)
4|n> + 3|U: 235> + |Xe: 140> + |Sr: 94>

-- now again, this time starting with: 4|n> + 3|U: 235> + |Xe: 140> + |Sr: 94>
sa: process-reaction(4|n> + 3|U: 235> + |Xe: 140> + |Sr: 94>,|n> + |U: 235>,fission |U: 235>)
6|n> + 2|U: 235> + |Xe: 140> + |Sr: 94> + |La: 143> + |Br: 90>

-- and again. Feed in result from last reaction:
sa: process-reaction(6|n> + 2|U: 235> + |Xe: 140> + |Sr: 94> + |La: 143> + |Br: 90>,|n> + |U: 235>,fission |U: 235>)
8|n> + |U: 235> + |Xe: 140> + |Sr: 94> + 2|La: 143> + 2|Br: 90>

-- and again!
sa: process-reaction(8|n> + |U: 235> + |Xe: 140> + |Sr: 94> + 2|La: 143> + 2|Br: 90>,|n> + |U: 235>,fission |U: 235>)
23|n> + |Xe: 140> + |Sr: 94> + 2|La: 143> + 2|Br: 90> + |I: 131> + |Y: 89>

-- and again. Note, we have no U_235 left.
sa: process-reaction(23|n> + |Xe: 140> + |Sr: 94> + 2|La: 143> + 2|Br: 90> + |I: 131> + |Y: 89>,|n> + |U: 235>,fission |U: 235>)
23|n> + |Xe: 140> + |Sr: 94> + 2|La: 143> + 2|Br: 90> + |I: 131> + |Y: 89>
```
Noting that with no U_235 left, this final process-reaction() didn't change anything.

Then when we get around to implementing learn-sp rules, as mentioned in my last post, we can tidy this to:
```fission-uranium-235 (*) #=> process-reaction(|_self>,|n> + |U: 235>,fission |U: 235>)
```
And then we should be able to do say 5 reactions in a row, starting with say 3 neutrons and 4 atoms of U_235:
```fission-uranium-235^5 (3|n> + 4|U: 235>)
```
This structure is presumably general enough to represent most chemical and nuclear reactions. And we are not limited to just one reaction type. For example:
```chemical-reaction-1 (*) #=> process-reaction(|_self>,|x> + |y>,3|z>)
chemical-reaction-2 (*) #=> process-reaction(|_self>,|z>,2|a> + |b>)

|resulting bag of chemicals> => chemical-reaction-1 chemical-reaction-2^3 chemical-reaction-1 starting-bag-of-chemicals
```
And I suspect process-reaction() could be useful elsewhere, including things other than chemical/nuclear reactions. Eg I suspect we can use it to encode quantum entanglement too!

Update: The comment on process-reaction() being useful elsewhere. I have a couple of things in mind. One is to rename parts of a superposition. I don't yet have a concrete use-case in mind, but think it might be useful. The other is a version of pattern recognition. ie, something that is slightly different to our current similar[op]. Need to give that idea a little more thought though.