Today work has focused on two things; The ctest extension work, and the Lean book problems. Iāve continued working my way through a bunch of refactors affecting the module resolution algorithm.
I started off by continuing work on the path aggregate synchronization function that was left unfinished from last week. I ended up both simplifying and getting more work done in the same function.
Last weekās plan for the synchronization logic consisted of going through all packed items in an item container, looking up the diffed path aggregate between the items and the module tree where to effect the updates.
This was fairly verbose, so I refactored it into considering only one item at a time, and producing an updated module tree each time it ran. Passing an item would have required the sym type that gathers them, and I didnāt want that.
So I instead also changed the passed item to be a closure that got passed a path aggregate store, and yield back a path aggregate store. The whole point here was to allow abstracting over the specifics required for each parsed item type.
This way, I traverse the entirety of the module tree that we also get passed, and for each item in turn, I make sure the closure runs with the itemās path aggregate. Being a private API, I do set some expectations on the closure.
The logic within it will run for all items, even though a given closure should only handle a specific itemās path aggregate. This means I expect the same input path aggregate to be output if the item does not match.
This would also mean there would be need for a function that drove this process by iterating through the items about to be merged in the merging function, calling into this utility to update the module tree with an appropriate closure.
One such example of a closure would compose the functions I already provide in the generic path interface for attempting to check whether the items contain some matching path in their aggregates, and for synchronizing it.
This is also where it popped into my mind that modules also need to be special-cased when handling additions ot their path aggregate. A module being now addressable by a new path also affects the items living in its subtree.
This started another refactor to incorporate a function that modified the path aggregate of items into the generic path interface. This also brought with it a refactor of the type used for path aggregates, so as to make it append-only.
The refactor on the path aggregate addition function for modules is not yet done. The idea is mostly clear, but thereās a few things I need to really clear my mind on, and which I would apprecate looking at with fresher eyes.
The above has thus far consisted purely of handwritten notes and implementation, with a tidbit of stuff I got time to actually implement in the code. Iāve decided to take this approach because it seems my ideas are clearer.
In terms of Lean work, I quickly got out of the rose tree rabbit hole I had gotten into yesterday by finishing a single entrypoint function with which a user of the library would create a term of the type.
Recall I had had to implement with some type-level indexing to inline the list data constructors into the rose tree data structure. The purpose of this was to preserve structural recursion when traversing the tree.
But those typechecking details I considered irrelevant to a user of the library, so I instead provided a reducible abbreviation for the type that used a fixed point in the data index.
This, of course, meant that users needed some way of building the rose tree, as the actual data constructors were part of a private type. That is where the following function came in.
open RoseT RoseTree in
def RoseT.mk : α ā List (RoseT α) ā RoseT α :=
open List in (Ā·ā foldr f RoseTree.nil) ā node
where f := consThis essentially reverse folds a list of rose trees using the abbreviation and uses them for another rose tree. A leaf node would be built off of some anciliary data and an empty list, and induction would follow from that.
Afterwards, I continued work on the problems from the current chapter of the Lean book Iām reading. This went fairly well because I got the chance to try and come up with multiple solutions to the same problem.
The problem statement is to build a data type for even natural numbers. This I have started work on by using a new data type with the same structure as that of Peano numbers, but with different semantics in its type class instances.
Stuff like addition and multiplication are simple enough through a cast to āregularā naturals, followed by multiplication with two. This is not quite enough when casting from a āregularā natural.
Efforts then shifted to designing a proposition for even natural numbers, its proof, and a few lemmas to prove that my new data type fits that proposition, and that both addition and multiplication of even numbers preserve parity.
None.
I expect to continue working on ctest matters tomorrow. I think the refactor should be nearing its end, because the idea is mostly clear, and I donāt anticipate there being some sudden miscalculation in the plan.
Lean work is at high time, and Iām really excited for the current proof work Iām doing. I guess it will just continue.