# Bitcoin Class with Satoshi looks at stack machines, predicate logic and how Bitcoin does it

Even if you don’t understand the advanced math side of Bitcoin, you might pick up a few ideas by thinking about it. Xiaohui Liu’s “Bitcoin Class” series of video tutorials with Bitcoin creator Dr. Craig Wright offers a fresh way of looking at things, some inspiration on the real power of Bitcoin Script and its capabilities.

This latest episode dives into Predicate Calculus in the first few minutes—don’t worry if you’ve never studied it, neither has Xiaohui. But all that’s needed is a quick search on this type of logic, and a few of its basic principles and concepts, to grasp a little more about what Dr. Wright is talking about.

ScienceDirect describes Predicate Calculus as “a notation with a distinguished position in AI: it serves as the universal standard by which other representations are defined and evaluated.”

“A predicate calculus representation assumes a universe of individuals, with relations and functions on those individuals, and sentences formed by combining relations with the logical connectives and, or, and not.”

Doing this on Bitcoin involves thinking about more complex conditionals than we’re probably used to. Dr. Wright talks of complex circuits where only certain input data feeds into future transactions. By creating tables of how this data interacts, you can instruct Bitcoin to automate almost anything (as long as you know how to write the algorithms).

“You can actually make very complex pathways with very simple predicates,” he says. Think about something more complex than a two-of-three multisig. Think about Truth Tables and alternatives. You can allow for all sorts of events to happen, and variables on when and in which order they happen, to determine the outcome of the transaction that finally gets written to the Bitcoin blockchain.

There’s a section on “stack machines”. Bitcoin is built on a stack, and it’s possible to have the main stack and an “alt-stack”—one that you save material on, and a counter-stack. You could have multiple stack machines running horizontally and parallel.

One problem is, Dr. Wright says, in these sorts of circumstances, how do you know when something is “final”? Bitcoin provides the solution to that:

Not every output from every transaction needs to be written on-chain. The output from one transaction may feed into another, forming a chain. And then, when the outcome of each step produces a true, false, or invalid result, only the true result provides the next input.

Once something is written into a Bitcoin block and processed, that result could be considered final. That’s what makes Bitcoin and its blockchain structure more useful than any system that came before.

Dr. Wright gives some examples and business scenarios to ease understanding, such as the different outcomes that might happen if person A and B agree on something, then C agrees later; or if they commit to the agreement in a different order… or a script could even pass the decision on to an external mediator if none of the parties agree.

Why Forth?

Xiaohui asks about using Forth as a basis for Bitcoin Script and the way it works. Dr. Wright says Forth “is fast and replicates the type of language you get in predicate systems,” and that if you’re talking about logic functions, Forth is one of the best languages to express them.

Xiaohui describes Forth as a “kind of assembly language,” and wonders if it might be possible one day to build higher-level languages on top of it. Dr. Wright agrees that it could. Given Xiaohui’s work at sCrypt involves making Bitcoin Script development more accessible, this could be a future project.

The Bitcoin Class series can be tough going for non mathematicians or those without a computer science background (including, clearly, this reviewer). However, there’s always something in there to trigger ideas by looking at new angles and imagining the possibilities.

To watch previous episodes of the Theory of Bitcoin and Bitcoin Class, check out the Theory of Bitcoin YouTube channel here and the Bitcoin Class with Satoshi YouTube channel here.

New to blockchain? Check out CoinGeek’s Blockchain for Beginners section, the ultimate resource guide to learn more about blockchain technology.