Documentation

CordialMiners.Runtime.Encode

inductive CordialMiners.Runtime.Event (Wave : Type u_3) (Hash : Type u_4) :
Type (max u_3 u_4)

A runtime input event. Proposal and ordering are spontaneous in TrecState.Step, so the runtime carries them in an inbox and consumes them by rewriting.

  • propose {Wave : Type u_3} {Hash : Type u_4} (w : Wave) (h : Hash) : Event Wave Hash
  • order {Wave : Type u_3} {Hash : Type u_4} (hs : List Hash) : Event Wave Hash
Instances For
    @[implicit_reducible]
    instance CordialMiners.Runtime.instReprEvent {Wave✝ : Type u_3} {Hash✝ : Type u_4} [Repr Wave✝] [Repr Hash✝] :
    Repr (Event Wave✝ Hash✝)
    Equations
    def CordialMiners.Runtime.instReprEvent.repr {Wave✝ : Type u_3} {Hash✝ : Type u_4} [Repr Wave✝] [Repr Hash✝] :
    Event Wave✝ Hash✝Std.Format
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      A nullary symbol leaf in the MeTTaIL AST.

      Equations
      Instances For

        An S-expression with a string head.

        Equations
        Instances For

          Runtime list terminator for variable-length payloads.

          Equations
          Instances For

            Runtime list cons for variable-length payloads.

            Equations
            Instances For

              Decode an explicit AST list payload.

              Equations
              Instances For
                theorem CordialMiners.Runtime.decodeListA_encodeListA {α : Type u_3} (e : αMeTTaIL.AST) (d : MeTTaIL.ASTOption α) (hd : ∀ (a : α), d (e a) = some a) (xs : List α) :

                Encoded AST lists decode back to the original Lean list under a left-inverse element codec.

                Executable natural-number encoder used by the Nat/Nat demo instance.

                Equations
                Instances For

                  Executable natural-number decoder used by the Nat/Nat demo instance.

                  Equations
                  Instances For

                    The Nat codec is lossless on encoded naturals.

                    def CordialMiners.Runtime.decodePairA {Wave : Type u_1} {Hash : Type u_2} {α : Type u_3} (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (mk : WaveHashα) (a b : MeTTaIL.AST) :

                    Decode a pair of Wave/Hash fields and assemble the result.

                    Equations
                    Instances For

                      Decode an ordered-prefix payload. Runtime terms use one explicit list payload. Legacy shallow extraction used variadic hash arguments, so this decoder accepts that shape too.

                      Equations
                      Instances For
                        theorem CordialMiners.Runtime.decodeOrderedPayloadA_encodeListA {Hash : Type u_2} (eH : HashMeTTaIL.AST) (dH : MeTTaIL.ASTOption Hash) (hH : ∀ (h : Hash), dH (eH h) = some h) (hs : List Hash) :

                        Runtime ordered payloads decode back to the original hash list.

                        theorem CordialMiners.Runtime.mapM_map_leftInvA {Hash : Type u_2} (e : HashMeTTaIL.AST) (d : MeTTaIL.ASTOption Hash) (hd : ∀ (a : Hash), d (e a) = some a) (l : List Hash) :

                        A list of encoded AST items decodes back to the original list.

                        theorem CordialMiners.Runtime.decodeFactA_encodeFactA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (f : TrecFact Wave Hash) :
                        decodeFactA dW dH (encodeFactA eW eH f) = some f

                        Direct AST extraction is lossless for individual facts under left-inverse field codecs.

                        The AC label used for coarse states.

                        Equations
                        Instances For

                          The AC label used for pending input events.

                          Equations
                          Instances For

                            The top-level runtime configuration label.

                            Equations
                            Instances For

                              Sentinel leaf for right-nested AC collections. The sentinel is not an identity law.

                              Equations
                              Instances For

                                A binary collection node.

                                Equations
                                Instances For
                                  theorem CordialMiners.Runtime.decodeEventA_encodeEventA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (event : Event Wave Hash) :
                                  decodeEventA dW dH (encodeEventA eW eH event) = some event

                                  Encoded runtime input events decode back to the original event under left-inverse field codecs.

                                  def CordialMiners.Runtime.encStateList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (facts : List (TrecFact Wave Hash)) :

                                  Encode a list of coarse facts as a right-nested state collection. Executable scenarios use this encoder.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    noncomputable def CordialMiners.Runtime.encState {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (s : TrecState Wave Hash) :

                                    Encode a finite coarse state as a right-nested state collection. The wrapper is noncomputable because Finset forgets order; executable scenarios use encStateList.

                                    Equations
                                    Instances For
                                      def CordialMiners.Runtime.encInbox {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (events : List (Event Wave Hash)) :

                                      Encode an inbox as a right-nested inbox collection.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        def CordialMiners.Runtime.encConfigList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (events : List (Event Wave Hash)) (facts : List (TrecFact Wave Hash)) :

                                        Encode a full runtime configuration from an ordered fact list. Executable scenarios use this encoder.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          noncomputable def CordialMiners.Runtime.encConfig {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (events : List (Event Wave Hash)) (s : TrecState Wave Hash) :

                                          Encode a full runtime configuration.

                                          Equations
                                          Instances For

                                            Payloads are clean when they do not contain an embedded runtime configuration head. Payload cleanliness is the syntactic side condition needed by the later backward classifier: protocol rules should fire at the configuration boundary, not inside encoded field payloads.

                                            Equations
                                            Instances For

                                              The runtime sentinel is clean payload.

                                              theorem CordialMiners.Runtime.noEmbeddedConfig_encodeListA {α : Type u_3} (e : αMeTTaIL.AST) (h : ∀ (x : α), NoEmbeddedConfig (e x)) (xs : List α) :

                                              Explicit AST lists preserve payload cleanliness.

                                              theorem CordialMiners.Runtime.noEmbeddedConfig_encodeFactA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (fact : TrecFact Wave Hash) :

                                              Encoded facts are clean when their field codecs are clean.

                                              theorem CordialMiners.Runtime.noEmbeddedConfig_encodeEventA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (event : Event Wave Hash) :

                                              Encoded input events are clean when their field codecs are clean.

                                              theorem CordialMiners.Runtime.noEmbeddedConfig_encStateList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (facts : List (TrecFact Wave Hash)) :

                                              Encoded state lists are clean when their field codecs are clean.

                                              theorem CordialMiners.Runtime.noEmbeddedConfig_encInbox {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (events : List (Event Wave Hash)) :
                                              NoEmbeddedConfig (encInbox eW eH events)

                                              Encoded inboxes are clean when their field codecs are clean.

                                              theorem CordialMiners.Runtime.runtimeConfigShape_encConfigList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (events : List (Event Wave Hash)) (facts : List (TrecFact Wave Hash)) :
                                              RuntimeConfigShape (encConfigList eW eH events facts)

                                              Encoded configuration lists satisfy the runtime configuration shape invariant.

                                              theorem CordialMiners.Runtime.runtimeConfigShape_encConfig {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (hW : ∀ (w : Wave), NoEmbeddedConfig (eW w)) (hH : ∀ (h : Hash), NoEmbeddedConfig (eH h)) (events : List (Event Wave Hash)) (s : TrecState Wave Hash) :
                                              RuntimeConfigShape (encConfig eW eH events s)

                                              Encoded finite-state configurations satisfy the runtime configuration shape invariant.

                                              Flatten one binary collection label. Nonmatching nodes are leaves.

                                              Equations
                                              Instances For
                                                theorem CordialMiners.Runtime.decodedCollection_foldr {α : Type u_3} (op : MeTTaIL.Label) (encode : αMeTTaIL.AST) (decode : MeTTaIL.ASTOption α) (hLeaf : ∀ (x : α), collectA op (encode x) = [encode x]) (hDecode : ∀ (x : α), decode (encode x) = some x) (hNil : decode cmNil = none) (hSelf : (op == op) = true) (xs : List α) :
                                                List.filterMap decode (collectA op (List.foldr (fun (x rest : MeTTaIL.AST) => consA op x rest) cmNil (List.map encode xs))) = xs

                                                Decoding a right-nested encoded collection recovers the source list when encoded elements are leaves for that collection and the element codec is lossless.

                                                def CordialMiners.Runtime.decodeInboxA {Wave : Type u_1} {Hash : Type u_2} (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (t : MeTTaIL.AST) :
                                                List (Event Wave Hash)

                                                Decode an inbox collection to the list of well-formed input events it contains. Malformed leaves are ignored, matching the state decoder's abstraction.

                                                Equations
                                                Instances For
                                                  def CordialMiners.Runtime.astToInbox {Wave : Type u_1} {Hash : Type u_2} (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) :
                                                  MeTTaIL.ASTList (Event Wave Hash)

                                                  Decode the inbox component of a runtime configuration. A bare inbox collection is accepted too, which mirrors astToState and keeps intermediate lemmas small.

                                                  Equations
                                                  Instances For
                                                    def CordialMiners.Runtime.decodeStateA {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (t : MeTTaIL.AST) :
                                                    TrecState Wave Hash

                                                    Decode a state collection, ignoring malformed leaves and collapsing duplicates.

                                                    Equations
                                                    Instances For
                                                      def CordialMiners.Runtime.astToState {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) :
                                                      MeTTaIL.ASTTrecState Wave Hash

                                                      Decode the state component of a runtime configuration. A bare collection is accepted too, which makes the abstraction useful in intermediate lemmas.

                                                      Equations
                                                      Instances For
                                                        theorem CordialMiners.Runtime.collectA_stateOp_encodeFactA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (fact : TrecFact Wave Hash) :
                                                        collectA stateOp (encodeFactA eW eH fact) = [encodeFactA eW eH fact]

                                                        Encoded facts are leaves of the runtime state collection.

                                                        theorem CordialMiners.Runtime.collectA_inboxOp_encodeEventA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (event : Event Wave Hash) :
                                                        collectA inboxOp (encodeEventA eW eH event) = [encodeEventA eW eH event]

                                                        Encoded input events are leaves of the runtime inbox collection.

                                                        theorem CordialMiners.Runtime.decodedFacts_encStateList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (facts : List (TrecFact Wave Hash)) :

                                                        Decoding the flattened encoded state list recovers the source fact list.

                                                        theorem CordialMiners.Runtime.decodeStateA_encStateList {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (facts : List (TrecFact Wave Hash)) :
                                                        decodeStateA dW dH (encStateList eW eH facts) = facts.toFinset

                                                        Decoding an encoded state list gives the finite set represented by the list.

                                                        theorem CordialMiners.Runtime.decodeInboxA_encInbox {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (events : List (Event Wave Hash)) :
                                                        decodeInboxA dW dH (encInbox eW eH events) = events

                                                        Decoding an encoded inbox recovers the source event list.

                                                        theorem CordialMiners.Runtime.decodeInboxA_cons_encodeEventA {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (event : Event Wave Hash) (rest : MeTTaIL.AST) :
                                                        decodeInboxA dW dH (consA inboxOp (encodeEventA eW eH event) rest) = event :: decodeInboxA dW dH rest

                                                        Prepending an encoded event to a decoded inbox collection conses the decoded event.

                                                        theorem CordialMiners.Runtime.decodeStateA_cons_encodeFactA {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (fact : TrecFact Wave Hash) (rest : MeTTaIL.AST) :
                                                        decodeStateA dW dH (consA stateOp (encodeFactA eW eH fact) rest) = insert fact (decodeStateA dW dH rest)

                                                        Prepending an encoded fact to a decoded state collection inserts the decoded fact.

                                                        theorem CordialMiners.Runtime.decodeStateA_cons_comm {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (a b : MeTTaIL.AST) :

                                                        Decoding a state collection is insensitive to the AC commutativity generator.

                                                        theorem CordialMiners.Runtime.decodeStateA_cons_assoc {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (a b c : MeTTaIL.AST) :

                                                        Decoding a state collection is insensitive to the AC associativity generator.

                                                        theorem CordialMiners.Runtime.astToState_inbox_irrelevant {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (ib ib' st : MeTTaIL.AST) :

                                                        The decoded state of a runtime configuration does not depend on its inbox component.

                                                        theorem CordialMiners.Runtime.astToState_cons_comm {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (ib a b : MeTTaIL.AST) :

                                                        The decoded state of a runtime configuration is insensitive to state commutativity.

                                                        theorem CordialMiners.Runtime.astToState_cons_assoc {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (ib a b c : MeTTaIL.AST) :

                                                        The decoded state of a runtime configuration is insensitive to state associativity.

                                                        theorem CordialMiners.Runtime.decodeStateA_cons_encodeFactA_stutter {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (fact : TrecFact Wave Hash) (rest : MeTTaIL.AST) (hmem : fact decodeStateA dW dH rest) :
                                                        decodeStateA dW dH (consA stateOp (encodeFactA eW eH fact) rest) = decodeStateA dW dH rest

                                                        Re-adding an already decoded fact is a stutter under decodeStateA.

                                                        theorem CordialMiners.Runtime.astToState_cons_encodeFactA_stutter {Wave : Type u_1} {Hash : Type u_2} [DecidableEq Wave] [DecidableEq Hash] (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hW : ∀ (w : Wave), dW (eW w) = some w) (hH : ∀ (h : Hash), dH (eH h) = some h) (fact : TrecFact Wave Hash) (ib rest : MeTTaIL.AST) (hmem : fact astToState dW dH (MeTTaIL.AST.sexp cmOp [ib, rest])) :

                                                        Re-adding an already decoded fact to a runtime configuration is a stutter under astToState.

                                                        theorem CordialMiners.Runtime.astToInbox_encConfigList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) (hCodec : (∀ (w : Wave), dW (eW w) = some w) ∀ (h : Hash), dH (eH h) = some h) (events : List (Event Wave Hash)) (facts : List (TrecFact Wave Hash)) :
                                                        astToInbox dW dH (encConfigList eW eH events facts) = events

                                                        Decoding an encoded configuration list gives back its inbox event list.

                                                        theorem CordialMiners.Runtime.astToInbox_encConfig {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) [DecidableEq Wave] [DecidableEq Hash] (hCodec : (∀ (w : Wave), dW (eW w) = some w) ∀ (h : Hash), dH (eH h) = some h) (events : List (Event Wave Hash)) (s : TrecState Wave Hash) :
                                                        astToInbox dW dH (encConfig eW eH events s) = events

                                                        Decoding an encoded finite-set configuration gives back its inbox event list.

                                                        theorem CordialMiners.Runtime.astToState_encConfigList {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) [DecidableEq Wave] [DecidableEq Hash] (hCodec : (∀ (w : Wave), dW (eW w) = some w) ∀ (h : Hash), dH (eH h) = some h) (events : List (Event Wave Hash)) (facts : List (TrecFact Wave Hash)) :
                                                        astToState dW dH (encConfigList eW eH events facts) = facts.toFinset

                                                        Decoding an encoded configuration list gives the finite set represented by its state list.

                                                        theorem CordialMiners.Runtime.astToState_encConfig {Wave : Type u_1} {Hash : Type u_2} (eW : WaveMeTTaIL.AST) (eH : HashMeTTaIL.AST) (dW : MeTTaIL.ASTOption Wave) (dH : MeTTaIL.ASTOption Hash) [DecidableEq Wave] [DecidableEq Hash] (hCodec : (∀ (w : Wave), dW (eW w) = some w) ∀ (h : Hash), dH (eH h) = some h) (events : List (Event Wave Hash)) (s : TrecState Wave Hash) :
                                                        astToState dW dH (encConfig eW eH events s) = s

                                                        Decoding an encoded finite-set configuration gives back its coarse state.