Shell and Batch Mode

Herbie can be used from the command-line or from the browser. This page covers using Herbie from the command line.

The Herbie shell

The Herbie shell lets you interact with Herbie: you type in input expressions and Herbie prints their more accurate versions. Run the Herbie shell with this command:

herbie shell
Herbie 2.0 with seed 2098242187
Find help on, exit with Ctrl-D

Herbie prints a seed, which you can use to reproduce a Herbie run, and links you to documentation. Then, it waits for inputs, which you can type directly into your terminal in FPCore format:

herbie> (FPCore (x) (- (+ 1 x) x))

Herbie suggests that 1 is more accurate than the original expression (- (+ 1 x) x). The the ... elides additional information provided by Herbie.

The Herbie shell only shows Herbie's most accurate variant.

Batch processing FPCores

Alternatively, you can run Herbie on a file with multiple expressions in it, writing Herbie's versions of each to a file. This mode is intended for use by scripts.

herbie improve bench/tutorial.fpcore out.fpcore
Starting Herbie on 3 problems (seed: 1551571787)...
  1/3	[   0.882s]   30→ 0	Cancel like terms
Warning: 24.7% of points produce a very large (infinite) output.
You may want to add a precondition.
See <> for more.
  2/3	[   1.721s]   29→ 0	Expanding a square
  3/3	[   2.426s]    0→ 0	Commute and associate

The output file out.fpcore contains more accurate versions of each program:

;; seed: 1551571787

(FPCore (x) ... 1)
(FPCore (x) ... (* x (- x -2)))
(FPCore (x y z) ... 0)

Note that output file is in the same order as the input file. For more control over Herbie, see the documentation of Herbie's command-line options.