Metamath

During my research on various theorem provers, today I stumbled upon Metamath.

To me, what was interesting about it was its simplicity. You start by defining a formal system, i.e. variables, symbols, axioms, inference rules. Then you build new theorems based on the formal system.

The core concept behind Metamath is substitution, and it’s using RPN notation to build hypothesis on the stack and then rewrite them using the inference rules to reach conclusion.

The program is written in C, and I compiled it on both OS X and my Android phone. It’s pretty light-weight and compiles in a few milliseconds, and it’s also interesting that you can take it anywhere you want on your phone.

Metamath has no special syntax. It will tokenize a file that we give to it, and tokens that start with $ are Metamath tokens, while everything else are user-defined tokens.

Here is a list of built-in Metamath tokens:

  • To define constants, use the $c token.
  • To define variables, use the $v token.
  • To define types of variables, use the $f token.
  • To define essential hypothesis, use the $e token.
  • To define axioms, use the $a token.
  • To define proofs, use the $p token.
  • To start proving in $p statement, use the $= token.
  • To end the statements above, use the $. token.
  • To insert comments, use the $( and $) tokens.
  • To define a block (has effect on scoping), use the ${ and $} tokens. Note that only $a and $p tokens will remain outside the scope.

That’s basically it. The package has included demo example and an example for the MU puzzle as well. There are other systems as well (Peano, Set).

There are some basic rules as well:

  • A hypothesis is either a $e or a $f statement
  • For every variable in $e, $a or $p, we must have a $p assertion, i.e. every variable in an essential hypothesis/axiom/proof must have a floating hypothesis (type)
  • A $f, $e, or $d statement is active from the place it occurs until the end of the block it occurs in. A $a or $p statement is active from the place it occurs through the end of the database.

For the complete syntax you can refer to the Metamath book.

Now for the example we’ll use, start by creating a test.mm file. We’ll define a formal system and demonstrate the usage of modus ponens to come up with a new theorem, based on our initial axioms.

$( Declare the constant symbols we will use $)
$c -> ( ) wff |- I J $.

$( Declare the variables we will use $)
$v p q $.

$( Specify properties of the variables, i.e. they are wff formulas $)
wp $f wff p $.
wq $f wff q $.

$( Define "mp", for the modus ponens inference rule $)
${
mp1 $e |- p $.
mp2 $e |- ( p -> q ) $.
mp  $a |- q $.
$}

$( Define our initial axioms. I and J are well-formed formulas,
we have a proof for I and we have conditional for I -> J $)
wI  $a wff I $.
wJ  $a wff J $.
wim $a wff ( p -> q ) $.

$( Prove that we can deduce J from the initial axioms. Note how we use
block scope here, since we don't want the hypothesis proof_I and
proof_I_imp_J to be visible outside of this scope. $)
${
$( Given I and I -> J $)
proof_I $e |- I $.§
proof_I_imp_J $e |- ( I -> J ) $.

$( Prove that we can deduce J $)
proof_J $p |- J $=
wI  $( Stack: [ 'wff I' ] $)
wJ  $( Stack: [ 'wff I', 'wff J' ] $)

$( Note that we had to specify wff for I and J before using mp,
since the types have to match, as set on line 8 and 9 $)

proof_I       $( Stack: [ 'wff I', 'wff J', '|- I' ] $)
proof_I_imp_J $( Stack: [ 'wff I', 'wff J', '|- I', '|- ( I -> J )' ] $)

mp  $( Stack: [ '|- J' ] $)
$.
$}

To verify our file, we run ./metamath 'read test.mm' 'verify proof *' exit.

Note how we had to separate wff from |-. Otherwise, if we just used |-, then all well formed formulas would be proven to be true, which doesn’t make much sense.

In addition to this, the reason why we have implication -> and turnstile provable assertion |- is that the former is a wff (i.e. statement in the object language) and works on propositions, while the latter is not a wff but rather a statement in the meta language and works on proofs.

The arrow -> is usually used to denote an “internalization” of the meaning of turnstile, into the object language. This allows us, in some sense (depending on the meaning ascribed to ->) to represent the relationships between hypotheses and conclusions in the object language, whereas without it it becomes difficult to reason about on a higher-order level (e.g. most systems do not allow A, (A |- B) |- B).

For more complete examples, you can check out:

  • logic.mm – where I define a basic logical system that contains definitions for and-elim and and-intro and proves some theorems.
  • peano.mm – where I define successor for natural numbers and prove some theorems about ordering of them.

Due to its minimalistic design, when compared to Coq it has no Calculus of Constructions, Inductive Types, etc.

To conclude, I think it’s a fun program to play with, but since it has no “real” framework, I don’t think it’s as industry ready as Coq.

My first GM experience

Grand Meetup is an event here at Automattic where the whole company gathers once a year to do classes, projects, or just hack around ideas in general.

This year it was held in Whistler, BC, Canada.

Working remotely with strangers and meeting them in person was a bit weird and overwhelming in the beginning.

However, I had already met my team during a team meetup in Vienna, so hanging out with them during the GM was more relaxing 🙂

I also met Matt!

Then, besides meeting all of these nice folks, I also played my first D&D game ever! My character was a Human Wizard (named Matt :D) and we slayed the dragon!

The food at the hotels was really good!

The village had some really nice views! We went for some souvenir shopping.

Then, for the closing party we had some arcades!

Also, my team Woo rocked the stage 😀

Some stats: before the GM I had met 1% of all Automatticians. Now that has moved up to around 20%. With that, my objective of meeting all the folks that I have interacted or worked with was completed!

So a few words about the company: Automattic is about transparency, passion, freedom, impact, people, differences. If you care about these things, Automattic is hiring and you can apply.

Thank you A8c for this great experience!

Soft skills

This month my professional career as a Software Engineer sums up to 10 years (although I’ve been programming longer than that). Here is a summary of what I think is really important for a good career.

Technical skills are important.
As you might have noticed, my blog is mostly technical.

But in this article I’d like to praise soft skills.

Being good with everybody, communicative, adaptable, helpful, truthful, modest, and being a good listener, observer, and learner is just some of the most important skills.

I would also like to quote our creed here at Automattic:

I will never stop learning. I won’t just work on things that are assigned to me. I know there’s no such thing as a status quo. I will build our business sustainably through passionate and loyal customers. I will never pass up an opportunity to help out a colleague, and I’ll remember the days before I knew everything. I am more motivated by impact than money, and I know that Open Source is one of the most powerful ideas of our generation. I will communicate as much as possible, because it’s the oxygen of a distributed company. I am in a marathon, not a sprint, and no matter how far away the goal is, the only way to get there is by putting one foot in front of another every day. Given time, there is no problem that’s insurmountable.

If you try to look 10 years back, you will mostly see memories of events and people and the time spent with them, not how you optimized that loop or that DB query (not that the latter is not important, thus the reason I said “mostly”).

Find inspiration and motivation in your successes, yourself, your family, nature, and other people. Maintain inner peace, and most of the soft skills will come naturally.

Life keywords

A few keywords for life that everybody should be doing on a regular basis. 🙂

Life. Family. Love. Health. Work. Improve/Grow. Socialize. (Keep) Try(ing). Patience. Belief. Balance. Food. Rest. Relax. Think.

If you can do most of these, you should be happy and consider yourself lucky.

Desiderata

Go placidly amid the noise and haste, and remember what peace there may be in silence.
As far as possible without surrender be on good terms with all persons.
Speak your truth quietly and clearly; and listen to others, even the dull and ignorant; they too have their story.
Avoid loud and aggressive persons, they are vexations to the spirit.
If you compare yourself with others, you may become vain and bitter;
for always there will be greater and lesser persons than yourself.

Enjoy your achievements as well as your plans.
Keep interested in your career, however humble; it is a real possession in the changing fortunes of time.
Exercise caution in your business affairs; for the world is full of trickery.
But let this not blind you to what virtue there is; many persons strive for high ideals;
and everywhere life is full of heroism.

Be yourself.
Especially, do not feign affection.
Neither be critical about love; for in the face of all aridity and disenchantment it is as perennial as the grass.

Take kindly the counsel of the years, gracefully surrendering the things of youth.
Nurture strength of spirit to shield you in sudden misfortune. But do not distress yourself with imaginings.
Many fears are born of fatigue and loneliness. Beyond a wholesome discipline, be gentle with yourself.

You are a child of the universe, no less than the trees and the stars;
you have a right to be here.
And whether or not it is clear to you, no doubt the universe is unfolding as it should.

Therefore be at peace with God, whatever you conceive Him to be,
and whatever your labors and aspirations, in the noisy confusion of life keep peace with your soul.
With all its sham, drudgery and broken dreams, it is still a beautiful world. Be careful. Strive to be happy.

© Max Ehrmann 1927