Example: trees with notes, read as pseudocode
Library · Source module
Example: trees with notes, read as pseudocode
A tree written with ops% or routine% has no note, and its declaration foo has a noted copy beside it: the same tree with the names of the source as notes (NLAlib.Ops.Stmt.note). noted_of% foo is that copy and NLAlib.Ops.Routine.pretty reads it as pseudocode. It is a reading aid, not a code emitter. The checks below fix its output on Routines.double and NLAlib.Ops.sumSeqRoutine (whose ifPos n is a loop of at most one round, with an unnamed variable), and show that erasing the notes of the copy gives the tree of the declaration. The same checks on routines of the algorithm directories are in NLAlibTools/OpsNotes.lean, because no file under NLAlib/Ops imports an algorithm.
The routines NLAlib.Ops.Examples.Routines.sum2, NLAlib.Ops.Examples.Integrator.myStep and NLAlib.Ops.Examples.Integrator.myIntegrate are written with noted%, which puts the notes in the value itself. Their judgments, certificates and counts are proved on the noted trees, by the same proofs as without notes; the library does not write its trees this way.
Main results
* The output of NLAlib.Ops.Routine.pretty on the noted copies of two routines, and of NLAlib.Ops.Stmt.pretty on three trees written with noted%, checked when the file is built. * The tree of a routine is its noted copy with the notes erased.