keripy icon indicating copy to clipboard operation
keripy copied to clipboard

Algorithm for Most Compact Version of ACDC

Open SmithSamuelM opened this issue 2 years ago • 6 comments

The algorithm for computing the “most” compact version for computing a said is as follows.

Recursively ascending the document tree of nested blocks.

  • If a block has a said field d then the most compact version for the next higher block that includes that block is the oneOf representation that is the block label with a str value that is its said.

  • The actual said of any block that does not have any nested saided blocks must be the full expansion of that block. Otherwise a nested block would have to have a subblock with a saided field in order for it not to be fully expanded.

  • So ascending the tree with any non-nested saided blocks, we call such a block a leaf block. Its said must be the full block i.e. leaf (there are no other variants possible).

  • The computation of the said of any block is as follows.

    • Each saided block represents each of its nested saided sub-blocks with str fields where the field value is the said of the nested block.
    • Non saided sub-blocks are fully expanded (they can’t be any other way) and
    • other top level fields at the level of the said are represented as is.

So the algorithm can be computed recursively as a depth first search of the fields of the top level acdc or part. Descend depth first until reach a leaf then compute the said of the leaf then ascend up and compute the saids of any siblings (by recursive descent) then compute the said of the higher block and so one until the said of the tope leveel block is computed. Thereby there is one and only one said for any given ACDC and each ACDC part has the same said as the one used to compute the ACDC itself. So there is never any ambiguiity.

SmithSamuelM avatar Jun 06 '23 13:06 SmithSamuelM

Quoting @pfeairheller A new concept that I had not considered before but is insinuated with your breakdown above is that the schema becomes a “oneOf” just like the attributes, rules and edges. So it can be contained and shipped in the s field of a credential or as a separate packet with its own packet type.

SmithSamuelM avatar Jun 06 '23 13:06 SmithSamuelM