Documentation

CodeLayer.Code.EvalLaws

Structural evaluation laws for Nat.Partrec.Code #

Upstream states Nat.Partrec.Code.eval at the recursion constructor (eval_prec_zero, eval_prec_succ) and at the derived codes (eval_const, eval_id, eval_curry), but not at zero, succ, comp, left, right or pair, whose clauses are left to unfold definitionally at each use. This module states those six, once.

It also holds the output-from-nothing convention shared by the complexity measures built on codes: KolmogorovComplexity.Computes (a code computes x when it outputs x on input 0), KolmogorovComplexity.const_computes and KolmogorovComplexity.Computes.unique (a code computes at most one value).

The module stays deliberately light: it knows codes and their evaluation, and nothing about the step-counting cost model built on top of them.

Base eval law: zero outputs 0 on every input.

Base eval law: succ outputs the successor of its input.

theorem CodeEvalLaws.eval_comp (a b : Nat.Partrec.Code) (j : ℕ) :
(a.comp b).eval j = (b.eval j).bind a.eval

eval's comp clause in bind form: comp a b runs b on j and then a on whatever b outputs.

theorem CodeEvalLaws.eval_comp_some {a b : Nat.Partrec.Code} {j v : ℕ} (hv : b.eval j = Part.some v) :
(a.comp b).eval j = a.eval v

If b outputs v on input j, then comp a b runs a on v (the comp eval law is definitional, then Part.bind_some).

Base eval law: left is left unpairing.

Base eval law: right is right unpairing.

theorem CodeEvalLaws.eval_pair_bind (cf cg : Nat.Partrec.Code) (n : ℕ) :
(cf.pair cg).eval n = (cf.eval n).bind fun (u : ℕ) => Part.map (Nat.pair u) (cg.eval n)

eval's pair clause in bind/map form (upstream states it with <*>).

c computes x, output-from-nothing convention: run on input 0.

Equations
Instances For
    theorem KolmogorovComplexity.Computes.unique {c : Nat.Partrec.Code} {x y : ℕ} (hx : Computes c x) (hy : Computes c y) :
    x = y

    A code computes at most one value: its output on input 0 is a single Part.some.

    The constant code outputs x from any input.