Documentation

CordialMiners.Extract.MettaIL

def CordialMiners.encodeFact {Wave : Type u_1} {Hash : Type u_2} (eW : WaveSexpr) (eH : HashSexpr) :
TrecFact Wave HashSexpr

Encode a coarse fact as a MeTTaIL atom: a head symbol naming the fact, followed by its encoded fields. The ordered prefix is encoded as the head symbol consed onto the encoded hash list.

Equations
Instances For
    def CordialMiners.decodeFact {Wave : Type u_1} {Hash : Type u_2} (dW : SexprOption Wave) (dH : SexprOption Hash) :
    SexprOption (TrecFact Wave Hash)

    Parse a MeTTaIL atom back into a coarse fact, matching on the head symbol and field arity. Anything that does not match a known shape decodes to none.

    Equations
    Instances For
      theorem CordialMiners.mapM_map_leftInv {Hash : Type u_2} (e : HashSexpr) (d : SexprOption Hash) (hd : ∀ (a : Hash), d (e a) = some a) (l : List Hash) :

      A list of encoded items decodes back to the original list, given a field codec that is a left inverse. The list mirror of the round-trip property.

      theorem CordialMiners.extract_decode_encode {Wave : Type u_1} {Hash : Type u_2} (eW : WaveSexpr) (eH : HashSexpr) (dW : SexprOption Wave) (dH : SexprOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (f : TrecFact Wave Hash) :
      decodeFact dW dH (encodeFact eW eH f) = some f

      Extraction is lossless: decoding an encoded fact recovers it exactly, provided the field codecs are left inverses (dW (eW w) = some w and dH (eH h) = some h). Every coarse fact therefore has a faithful MeTTaIL image.