Quid est veritas?
There is no strict, scientific answer to that question up to now. Nevertheless it's not so hard to figure out.
Na?ve definition of Verity/Truth: Well-defined statement that all people confide/trust. But, what about well-defined statement Earth is flat? Is it a true??Most people, before Copernicus, believed so and were doing quite well. Look with your own eyes at any part of the Earth and make sure - it is a plain, except mountains. Our maps are flat, 2-dimentional, so, for all intents and purposes, there is no need to doubt the flatness of earth. Even if it were square in reality, our convenience is to consider it flat. Ok, then we shall rephrase, Verity is Indisputable fact or Well-defined statement that most scientifically minded people confide at a given point of time. Naive is always a shit definition. We don't know intuitively, as Pontius Pilate, what Verity is exactly and even Jesus couldn't tell better than he is Son of God.
May be Nietzsche? Truth is the kind of error without which a certain species could not live. Well, he was an eccentric German professor which are many, like Marx, Freud and others, that were in fact unaware of strict mathematical definition of truth. Marx: the only truth is - I am not Marxist. Muller: clarity is a form of total fog.
?At this point, we must confess a stunning fact - we actually don't have intuitive and good enough, strict definition of such basic notion as what the Truth really is! And, that is an underlaying reason why flat-earthers easily win dispute with scientists to their sheer outrage. Descartes was profoundly right - In the majority of matters on which the learned dispute, the question is almost always one of names/definitions.
?Hopefully, it's not so hard to figure out. One just need to understand some very simple set of Javascript, which will be used here to illustrate our approach. First, on the subject to this notion. People/Learned/Species/Sons of God is not appropriate here. Mathematics is mostly algorithms. Abstraction of a man is also algorithm, that needs Verity as a base for his further action/living. So, Verity has to be a part of the Algorithm. But what is an algorithm? Turing Machine (TM)? Well, there is one confusing problem with the TM, that needs to be resolved in the first place. Algorithm is not just a discreet, determinate in every step, process of calculation. In fact, algorithm and a process of full search/enumeration are opposites, because many processes are inherently unlimited in time and space and the purpose of the algorithm is to be limited.
Classic TM is an engine/js-function, that takes only two substantial arguments - tape and script. Tape is just and array, capable to grow in both directions, having initial values from some limited alphabet. Script is a list of rules, limited map, from twoples of current state and read to triples of write, move and next-state.
Tape example:
tape = [0,0,1]
Which is the same as tape = [0,0,1,B,B,B,B], B stands for "blank", empty. Engine behaves the same for B and for absent/undefined symbol.
Script example:
const program = {
???q0: {
???????0: {w:1,m:R,n:q1},
???????1: {w:0,m:R,n:q0},
???????B: {w:0,m:L,n:q1}
???},
???q1: {
???????0: {w:1,m:L,n:q0},
???????1: {w:1,m:R,n:q1},
???????B: {w:B,m:R,n:halt}
???},
}
?Map is grouped, a little, for clarity of reading by human.
?The simplest possible TM engine implementation:
?const tm = function (
???script,
???tape,
???q = q0, // inner/tail state
???p = 0, // space/head state
???v = true // vebose
) {
???let step = 0;
???let name = '';
???tape = (typeof tape === 'string')? tape.toArray():tape;
?
???if (typeof script === "string") (name = script, script = require("./TMs/" + script));
?
???while (q in script ) {
???????with (script[q][tape[p] ?? "B"]) {
???????????tape.step = step + 1;
???????????let str = [...show(tape, p)].join(' ');
???????????if (v) console.log(`${name}:`,`step ${step}:`.padEnd(10," "), str, q, w, m, n);
???????????tape[p] = w
???????????q = n
???????????switch (m) {???????// move to next p-position
???????????????case L:
???????????????????p = p - 1;
???????????????????break;
???????????????case R:
???????????????????p = p + 1;
???????????????????break;
???????????????default:
???????????????????p = m; // or jump -)
???????????}
???????}
???????step++
???}
???const total = `${tape.step >= limit?"infinity".red.bold:tape.step}`;
???if (v) console.log(`${name}: step ${tape.step}:`, ...tape,?"total: " + total);
???return tape.step >= limit?"infinity":tape.step;
}
Engine goes in while-loop step by step through the tape, using script to calculate next position, state and write.
It uses very simple show-function to make output human readable:
领英推è
?function show(ar, p, shift = 20)
???if (p === undefined) {
???????console.log(`Position undefined`.red.bold);
???????return;
???} else {
???????p = p + shift
???}
???let out = []
???for (let i = 0; i < 2 * shift; i++) {
???????out[i] = ar[i - shift] ?? '_';
???}
???out = [...out.slice(0, p), `${out[p]}`.red.bold, ...out.slice(p + 1)]
???out = [...out.slice(0, shift), `${out[shift]}`.green.bold,
...out.slice(shift + 1)]
???return out
}
?And that is basically all trivial backstage science that allows obtaining very much untrivial results.
My point is the following: every beginner programmer nowadays is obliged to know at least basics of javascript language. Of all samples, this one is the best due to couple of reasons. First, it utilizes all substantial javascript technics. Second, it will never fade away, because of being as classical as possible. By my wide professional experience in programming, I'd recommend everyone to learn it by heart. Because by doing so you make tremendous step in all sciences at once, which no other example can provide. Power users must either way have general idea of so called scripts, nowadays. So, for everyone it's worth to play with this script.
There are a couple of problems to that definition of an algorithm.
?First, that is not definition of an algorithm, but rather of any "discreet, determined process" (DDP). It is physics in nature, not mathematics. They even claim that any discreet, determined physical process on earth has corresponding TM, that "implements" such a process (Church-Turing thesis on effective method). So, what is the difference between them? Consider two processes: first - Primality Test (PT), described like this: "Try dividing given integer by all previous integers. If negative for all of them - it's prime", second - Divisibility by 3 Rule (D3R): "Check if the sum of all digits of the given integer is divisible by 3 ".
?PT is a full row search by brute force, complete physical check, it doesn't use any mathematical theorems or properties of numbers. There are methods to greatly improve PT in efficiency, but still, all of them demand going through the same given number again and again, great many times, unlimited number of times. All computer security systems are based on the assumption that no method exists, that uses limited number of times of going through given number.
?D3R is using mathematical formula (10^p)%3 = 1, independently of p. And also Distributive Law of the Ring of Integers 3 × (2 + 4) = 3×2 + 3×4. It only needs to go through the given number one time. And it can use limited by 3 random access memory to hold the result of division by 3 of previous digit. D3R is genuine, limited in space and time mathematical algorithm. But PT - is not, because it doesn't reuse the information that is virtually already there after the first going through the given number. It uses exceeding number of steps, and unlimited memory, because performing division requires growing with given number memory capacity. There is something very different in the nature of these two processes. Both are surely discreet and determined. But while D3R is computable with limited resources, PT is hopefully not, because if it was, all computer security would fail. So, they are opposites in a sense, and if D3R is sure an algorithm, then PT is an anti-algorithm.
Second. The tape in TM serves two purposes - as an input and as random access memory. For starters, any finite input can be hardcoded in program script itself. For example, having tape = [1,2,3], is the same as to call an auxiliary function inside the script:
const next = (function () { t = [1,2,3]
??? let i = -1;
??? return function () { i++; return t[i]; }
}
)();
Note that TM Engine function takes both tape and script. But taking only script argument is much more convenient, then the tape would only serve as an inner Random Access Discreet Limited Memory. For which purpose much more reasonable would be just to use a simple variable, or a simple function like this one:
const radlm = (function () {
??????? t = [0,1,2];
??????? let m;
??????? return function (a) {
??????????? if (a === undefined) return m;
??????????? if ( t.indexOf(a) === -1) throw "not valid";
??????????? m = a;
??????????? return m;
??????? }
??? }
)()
?It appears that TM doesn't really need a tape, instead it only needs RADLM variable/function. Correspondingly, strange looking script with reads/writes, states and moves can/should be replaced by a call to Pure Function, performing all the magic and using RADLM for calculations. For example, for D3R it'd be like:
const pf = function (data)
??????? radlm((radlm() + data) % 3);
}{
Complete TM for D3R could look somewhat like this:
const next = function () {
??? let i = -1;
??? return function () { i++; return t[i]; }
}
?
const radlm = function () {
??????? let t = [0,1,2];
??????? let m = 0;
??????? return function (a) {
??????????? if (a === undefined) return m;
??????????? if ( t.indexOf(a) === -1) throw "not valid";
??????????? m = a;
??????????? return m;
??????? }
?}
?
const tm = function ( program ) {
??? let data = program.next();
??? while (data) {
??????? program.pf(data); // pure function, that performs magic, using calls to program.radlm
??????? data = program.next();
??? }
??? return program.rad();
}
?
const program = {
??? next : next(),
??? rad : radlm(),
??? pf : function (data) {
??????? this.rad((this.rad() + data) % 3);
??? }
}
let t = [4,2,5,7,5];
console.log('result = ',tm(program));
console.log('string = ',temp = t.join(''));
console.log('number = ',Number(temp));
console.log('in fact = ',Number(temp)%3);
It sure works in any Node.js environment and gives results as expected. Any mathematically "pure" algorithm must be capable to have implementation in this way. PT cannot in reality be implemented in this way. RADLM limitations won't allow that, as well as next function one-way behavior. This fact is relatively easy to prove. The major point in the proof is a fact that for however big limits for RADLM, always exist two primes with the same ending state. From that point one can proceed building both numbers simultaneously with equal integers so that one of them ends up in prime number and the other - in non-prime. But our algorithm must identify them both as primes or both as non-primes, because their states stay equal all the way.?
Final considerations about science of History.
?Some people refuse to accept history as a true science because motivational parts of events always have substantial random component, often unclear even to actors, that cannot be reconstructed later by means of strict deterministic science. Descendants will never be capable of true understanding of the exact meaning of past history plays. Precisely because of their being random. Nevertheless, the descendants know for sure their results. History has a list of chronological events, that sure happened. That list bears resemblance to the contents of our RADLM variable. What if the Verity/Truth/Veritas, we are looking for, is exactly the contents of that variable? Or, the contents of that list of historical events? So, remarkably, the science of history, that is not recognized as such by many people, appears to be the only place to look for the Truth! Regarding algorithms, the point of Truth is apparently the current value of RADLM variable.?