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.
eval_zero,eval_succ— the two base codes output0and the successor of the input.eval_comp— composition inbindform:comp a brunsband thenaon its output.eval_comp_some— composition in the common case where the inner code converges: onceboutputsvonj, runningcomp a bonjis runningaonv.eval_left',eval_right'— the two projections are the halves ofNat.unpair.eval_pair_bind— pairing inbind/mapform. Upstream's clause is written with<*>, which does not meet abind-shaped goal.
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.
eval's comp clause in bind form: comp a b runs b on j and then a on whatever b
outputs.
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.
c computes x, output-from-nothing convention: run on input 0.
Equations
- KolmogorovComplexity.Computes c x = (c.eval 0 = Part.some x)
Instances For
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.