Documentation

EvmEquivalence.KEVM2Lean.Prelude

K Prelude in Lean 4 #

Functions with the hook attribute need to have a manual implementation in the backends. This file contains the Lean 4 definitions of the hooked functions in domains.md.

Currently we translate hooked functions as uninterpreted functions together with axioms asserting their behavior. The current definition can be put into three levels:

  1. Signature Level: The signature of the hooks, this includes aliases for Sorts and function symbols for hooked functions.

  2. Rule Level: The behavior of the uninterpreted symbols can be asserted through axioms or theorems. Inconsistencies can arise from them, so it falls under the user to make sure axioms are consistent and/or theorems provable.

  3. Simplification Level: With the theory defined through function rules, simplifications can be stated as theorems. These theorems should be provable directly from the function rules and the semantics of the Sorts.

Basic K types #

Abbreviations #

@[reducible, inline]
abbrev SortBool :
Equations
Instances For
    @[reducible, inline]
    abbrev SortBytes :
    Equations
    Instances For
      @[reducible, inline]
      abbrev SortId :
      Equations
      Instances For
        @[reducible, inline]
        abbrev SortInt :
        Equations
        Instances For
          @[reducible, inline]
          Equations
          Instances For
            @[reducible, inline]
            Equations
            Instances For

              Inductives #

              inductive SortEndianness :
              Instances For
                inductive SortSignedness :
                Instances For
                  structure MapHookSig (K V : Type) :
                  Instances For
                    axiom MapHookDef.unitAx (K V : Type) :
                    List (K × V)
                    axiom MapHookDef.consAx (K V : Type) :
                    KVList (K × V)List (K × V)
                    axiom MapHookDef.lookupAx (K V : Type) :
                    List (K × V)KOption V
                    axiom MapHookDef.lookupAx? (K V : Type) :
                    List (K × V)KV
                    axiom MapHookDef.updateAx (K V : Type) :
                    KVList (K × V)List (K × V)
                    axiom MapHookDef.deleteAx (K V : Type) :
                    List (K × V)KList (K × V)
                    axiom MapHookDef.concatAx (K V : Type) :
                    List (K × V)List (K × V)Option (List (K × V))
                    axiom MapHookDef.differenceAx (K V : Type) :
                    List (K × V)List (K × V)List (K × V)
                    axiom MapHookDef.updateMapAx (K V : Type) :
                    List (K × V)List (K × V)List (K × V)
                    axiom MapHookDef.removeAllAx (K V : Type) :
                    List (K × V)List KList (K × V)
                    axiom MapHookDef.keysAx (K V : Type) :
                    List (K × V)List K
                    axiom MapHookDef.in_keysAx (K V : Type) :
                    List (K × V)KBool
                    axiom MapHookDef.valuesAx (K V : Type) :
                    List (K × V)List V
                    axiom MapHookDef.sizeAx (K V : Type) :
                    List (K × V)Nat
                    axiom MapHookDef.includesAx (K V : Type) :
                    List (K × V)List (K × V)Bool
                    axiom MapHookDef.choiceAx (K V : Type) :
                    List (K × V)K
                    axiom MapHookDef.splitAx (K V : Type) :
                    List (K × V)List KOption (List V × List (K × V))
                    noncomputable def MapHook (K V : Type) :
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      structure SetHookSig (T : Type) :
                      Instances For
                        axiom SetHookDef.concatAx (T : Type) :
                        List TList TOption (List T)
                        axiom SetHookDef.elementAx (T : Type) :
                        TList T
                        axiom SetHookDef.unionAx (T : Type) :
                        List TList TList T
                        axiom SetHookDef.differenceAx (T : Type) :
                        List TList TList T
                        axiom SetHookDef.inSetAx (T : Type) :
                        TList TBool
                        axiom SetHookDef.choiceAx (T : Type) :
                        List TT
                        axiom SetHookDef.splitAx (T : Type) :
                        List TList TOption (List T)
                        noncomputable def SetHook (T : Type) :
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          structure listHookSig (T : Type) :
                          Instances For
                            axiom ListHookDef.concatAx (T : Type) :
                            List TList TOption (List T)
                            axiom ListHookDef.pushAx (T : Type) :
                            TList TList T
                            axiom ListHookDef.getAx (T : Type) :
                            IntList TOption T
                            axiom ListHookDef.updteAx (T : Type) :
                            IntTList TOption (List T)
                            axiom ListHookDef.makeAx (T : Type) :
                            IntTOption (List T)
                            axiom ListHookDef.updateAllAx (T : Type) :
                            List TIntList TOption (List T)
                            axiom ListHookDef.fillAx (T : Type) :
                            List TIntTOption (List T)
                            axiom ListHookDef.rangeAx (T : Type) :
                            List TIntIntOption (List T)
                            axiom ListHookDef.inListAx (T : Type) :
                            TList TBool
                            axiom ListHookDef.splitAx (T : Type) :
                            List TNatNatOption (List T × List T × List T)
                            noncomputable def ListHook (T : Type) :
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Inj class #

                              class Inj (From To : Type) :
                              • inj (x : From) : To
                              • retr (x : To) : Option From
                              Instances
                                def inj {From To : Type} [inst : Inj From To] (x : From) :
                                To
                                Equations
                                Instances For
                                  def retr {From To : Type} [inst : Inj From To] (x : To) :
                                  Option From
                                  Equations
                                  Instances For

                                    Instances #

                                    Unrelated to the Inj class

                                    Equations
                                    Equations
                                    Instances For

                                      Function Implementations #

                                      SortInt #

                                      Operations #

                                      Equations
                                      Instances For

                                        Comparisons #

                                        SortBytes #

                                        Int to Bytes conversion #

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Bytes manipulation #

                                            Pads to the right len - b.length bytes with specified val value

                                            Equations
                                            Instances For

                                              Pads to the left len - b.length bytes with specified val value

                                              Equations
                                              Instances For

                                                Replaces the contents of dest from index index with the contents of src If dest.size < index + src.size the result is none

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Get a new Bytes object containing a range of bytes from the input Bytes

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For