Mark D. Niemiec's Numbers and Games Calculator

Calculator | Syntax | Unary Operations | Binary Operations | Vocabulary | Download



Calculator

I have written a simple desk calculator program that allows one to explore a little bit about Numbers and Games. It is implemented as a Windows-32 console application, but it has no system dependencies in it, so it can be easily ported to the platform of one's choice.

The program has the following features:

The program has some limitations:


Syntax

The calculator accepts successive lines of input, that it interprets as numeric expressions. It evaluates the expressions, then displays the results. Each expression may be a number, or a set of multiple numbers.

The calculator accepts expressions with the following syntax:

expr = name | '(' [expr] ')' | '{' [expr] '}' | unary expr | expr binary expr

Names consist of one or more letters, digits, or any non-blank punctuation characters except !&()+,-:;<=>?[]{|}~. Due to conflicts with defined operators, the two names . and .. are reserved.

Parentheses force order of evaluation. Braces form sets. Since the calculator treats all expressions as sets, the two can be used interchangeably. However, the characters themselves are not treated as equivalent; e.g. {0} ⇔ (0) ⇔ 0, but {0) is a syntax error. Empty sets can be entered via empty parentheses or braces, but there is really little need to do so, since the game composition operator | allows either of its left or right parameters to be omitted.

Unary operations bind most closely. Binary operations are always evaluated left-to-right (except assignments, that are evaluated right-to-left), but different operations have different binding precedences, with those with higher precedences binding more closely than those with lower ones.

An expression may also have a value that is an operator, rather than a number or game. Such an expression is created by specifying any operator alone (or between parentheses or braces). The composition operator | may not be used this way, because because an expression consisting of | is already interpreted as a number formed from two empty sets (i.e. 0). Such expressions may be used in three different ways:


Unary Operations

These are the supported unary operations, showing Conway's notation (if any), the calculator's notation, the operation name, and a brief description:

Conway Calculator Name Description
+x +x Self The game itself.
-x -x Negate Additive inverse.
xL <x Left Set Given x, return x's left set.
xR >x Right Set Given x, return x's right set.
D(x) &x Day Number Given x, return the day it was created.
(none) >>x Absolute Positive absolute value.
(none) <<x - Absolute Negative absolute value.
(none) ::x Relative Position This shows a number's position relative to all other defined numbers. It prints its result and does not actually return any result.
(none) ?? Summary This shows all defined names. It prints its result and does not actually return any result.


Binary Operations

These are the supported binary operations, showing the operation binding precedence group increasing from top to bottom, Conway's notation (if any), the calculator's notation, the operation name, and a brief description:

Prec. Conway Calculator Name Description
= x=y x=y Assign Variable Set a user-defined name x to value y. (5)
x=y x=:y Assign Constant Set a user-defined name x to value y, and use it as a constant for subsequent display. (5)
< x<y x<y Less Than Returns 1 if x is less than y. (1)
x>y x>y Greater Than Returns 1 if x is greater than y. (1)
xy x!<y Not Less Than Returns 1 if x is not less than y. (1)
xy x!>y Not Greater Than Returns 1 if x is not greater than y. (1)
xy x<=y Less or Equal Returns 1 if x is less than or equal to y. (1)
xy x>=y Greater or Equal Returns 1 if x is greater than or equal to y. (1)
xy xy x<?y Less or Fuzzy Returns 1 if x is less than or fuzzy to y. (1)
xy xy x>?y Greater or Fuzzy Returns 1 if x is greater than or fuzzy to y. (1)
xy x<>x More or Less Returns 1 if x is greater or less than y. (1)
xy x!<>x Not more or Less Returns 1 if x is not greater or less than y. (1)
x=y x==y Equals Returns 1 if x is equal to y. (1)
xy x!=y Not Equal Returns 1 if x is not equal to y. (1)
xy x?y Fuzzy Returns 1 if x is fuzzy to y. (1)
xy x!?y Not Fuzzy Returns 1 if x is not fuzzy to y. (1)
(none) x::x Compare Compare x and y. Return _1 if less than, 0 if equal, 1 if greater than, or * if fuzzy. (1)
| || ||| x|y x||y x|y x||y Bar Separate left and right sets. (2)
, x,y x,y Append Join two sets to form a larger set. (3)
! xy x!y Tardy Union (Or) Move in some components. (4)
xy x!!y Urgent Union (Ur) Move in some components; stop if any component stops. (4)
& xy x&y Fast Join (and) Move in all components; stop if any component stops. (4)
xy x&&y Slow Join (also) Move in all remaining components. (4)
>> (none) x>>y Maximum Whichever game is best for Left.
(none) x<<y Minimum Whichever game is best for Right.
+ x+y x+y Plus Move in one component.
x-y x-y Minus Plus negative.
x:y x:y Ordinal Sum Move in x, then in y when x is exhausted. (4)
. x·y x×y x.y Times Multiply numbers (and some games).
x·y x×y x..y Norton Multiply Multiply games.
Unary (See previous section.)
Space x,y x y Append Join two sets to form a larger set. (3)

Note 1: Comparison predicates return 1 if the entirety of set x compares appropriately against the entirety of set y, 0 otherwise.

Note 2: Any number of vertical bars may be used together, and the result is the same; the only difference is that higher number of bars bind at a lower precedence; i.e. a||b|ca|(b|c). Furthermore, it is permissible for one or both parameters to be empty.

Note 3: If no operation is given between two expressions, e.g. x y, a comma is assumed between them; this binds much tighter than comma itself does, or indeed any other operators, including unaries (e.g. -3,4 ⇔ _3 4 but -3 4 ⇔ _3 _4).

Note 4: This operation depends on the form of a game, not just its value. Unfortunately, the calculator performs most calculations on games assuming that equal games (i.e. ones with the same value) are interchangeable, so expressions involving this operation may not produce the desired results if any of the parameters are games in non-standard forms.

Note 5: This assigns a value to a user-defined name. The value must be a single number, and cannot be an empty set, or a set of two or more numbers. It can also be an operator (excluding |). If the name already has a value, the previous value is replaced. If the value is omitted, the variable is erased, and the previous value is returned.


Vocabulary

Other than seven basic constants (0, 1, _1, *, on, off, dud), the calculator has no pre-defined values. Rather, all values are explicitly defined in an externally-supplied script file. For values that occur in ranges, most such ranges define all related values for n varying from 0 to 10.

These are the characters used in script-defined constants, showing Conway's notation (if any), the calculator's notation, and the description:

Conway Calculator Name
n n Positive integers (0-10)
-;n _n Negative integers (0-10)
1/2…7/8 1/2…7/8 Positive binary fractions below 1
-1/2…7/8 _1/2…7/8 Negative binary fractions below 1
* *n * *n Nimbers (0-10)
↑ ⇑ ⤊ ⟰ ^ ^^ etc. Multiples of Up (1-10)
↓ ⇓ ⤋ ⟱ v vv etc. Multiples of Down (1-10)
↑* ⇑* etc. ^* ^^* etc. Multiples of Up (1-10) plus Star
↓* ⇓* etc. v* vv* etc. Multiples of Down (1-10) plus Star
x Tx Tiny (0-10,on;)
⧿x _Tx Miny (0-10,on)
*/2 */2 *n/2 Semi-stars (1-10)
-*/2 _*/2 *n/2 Negative Semi-stars (1-10)
↑/2 3/2↑ etc. ^/2 ^3/2 etc. Semi-up, Sesqui-up, etc. (1-11)
↓/2 3/2↓ etc. v/2 v3/2 etc. Semi-down, Sesqui-down, etc. (1-11)
±x \x Hot game { x | -x } (0-10)



Download

Download the program in either of the following forms. It is covered by the GPL (Gnu Public License), version 3. This can be compilable under MinGW under Windows, but should easily work with little or no change on most other operating systems:



Home page

Copyright © 1997, 1998, 1999, 2013, 2014 by Mark. D. Niemiec. All rights reserved.
This page was last updated on 2015-02-19.