Documentation

EvmEquivalence.Interfaces.FuncInterface

KEVM Interface #

This file provides a proving interface for the KEVM function definitions. Some of the contents of this file may be ported to a utils file in the future.

Simple function behavior #

Behavioral results about simple functions like arithmetic or boolean operations.

@[simp]
@[simp]
axiom KEVMInterface.Axioms.Keq_def (k₁ k₂ : SortK) :
«_==K_» k₁ k₂ = some (k₁ == k₂)
axiom KEVMInterface.Axioms.Kneq_def (k₁ k₂ : SortK) :
«_=/=K_» k₁ k₂ = some (k₁ != k₂)
@[simp]
theorem KEVMInterface.orBool_def (b₁ b₂ : SortBool) :
_orBool_ b₁ b₂ = some (b₁ || b₂)
@[simp]
theorem KEVMInterface.andBool_def (b₁ b₂ : SortBool) :
_andBool_ b₁ b₂ = some (b₁ && b₂)
@[simp]
theorem KEVMInterface.eqInt_def (n m : SortInt) :
«_==Int_» n m = some (n == m)
@[simp]
@[simp]
theorem KEVMInterface.ltInt_def (n m : SortInt) :
«_<Int_» n m = some (decide (n < m))
@[simp]
theorem KEVMInterface.kite_def {SortSort : Type} (cnd : SortBool) (true_branch false_branch : SortSort) :
kite cnd true_branch false_branch = some (if cnd = true then true_branch else false_branch)

Behavior of «#sizeWordStack» #

Equating #sizeWordStack to List.length.

theorem KEVMInterface.sizeWordStackAuxAdd {n : SortInt} {ws : SortWordStack} :
sizeWordStackAux ws (n + 1) = do let asizeWordStackAux ws n let b«_+Int_» a 1 pure b

Behavior of K's in_keys function #

Axiomatically asserting in_keys behavior.

NOTE: These functions depend on the dummy implementation as maps being List (Key × Value).

def KEVMInterface.keys {K V : Type} (l : List (K × V)) :
Equations
Instances For

    Behavior of #inStorage function #

    This definition of #inStorage depends on the above inKeys_compute.

    noncomputable def KEVMInterface.inStorage_compute (map : SortMap) (acc key : SortInt) :
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem KEVMInterface.inStorage_def {ACCESSEDSTORAGE_CELL : SortMap} {ID_CELL W0 : SortInt} :
      #inStorage ACCESSEDSTORAGE_CELL (inj ID_CELL) W0 = some (inStorage_compute ACCESSEDSTORAGE_CELL ID_CELL W0)

      Memory results #

      Results that have to do with memory-related operations.

      theorem KEVMInterface.memoryUsageUpdate_rw (MEMORYUSED_CELL offset width : SortInt) (width_pos : 0 < width) :
      #memoryUsageUpdate MEMORYUSED_CELL offset width = some (MEMORYUSED_CELL Int.tdiv (offset + width + 31) 32)

      Explicit account for «#memoryUsageUpdate» with positive width.

      theorem KEVMInterface.mapWriteRange_rw (mem content : SortBytes) (index : SortInt) :
      mapWriteRange mem index content = if x : index < 0 then some ByteArray.empty else if x : ByteArray.size content = 0 then some mem else let padded := («padRightBytes(_,_,_)_BYTES-HOOKED_Bytes_Bytes_Int_Int» mem (index + (ByteArray.size content)) 0).get ; «replaceAtBytes(_,_,_)_BYTES-HOOKED_Bytes_Bytes_Int_Bytes» padded index content

      Explicit account for mapWriteRange.

      Bytes manipulation #

      Results to ease the reasoning about SortBytes manipulation functions.

      theorem KEVMInterface.padToWidth_rw (len : SortInt) (b : SortBytes) :
      #padToWidth len b = if len < 0 then some b else some { data := Array.leftpad (Int.toNat len) 0 b.data }

      Explicit account for «#padToWidth».

      This axiom states the following:

      Int2Bytes behaves as BE for positive integers and big endian representation.

      Note that the first parameter of Int2Bytes is the length of the corresponding encoding sequence.

      Explicit account for «#asByteStack».

      This result notoriously depends on Axioms.BE_IntToBytes_eq, which should be a theorem at some point.

      Given n : ℕ with n < UInt256.size, converting it to byteStack and padding the result to width 32, is the same as UInt256.toByteArray (n : UInt256).

      For any ByteArray b, Bytes2Int b .bigEndianBytes .unsignedBytes computes the same as fromByteArrayBigEndian b.

      This should be proved at some point.

      Friendlier interface for #range.

      This should be proven at some point.

      Converting a 32-byte chunk of memory into an unsigned integer never overflows chop.

      Misc #

      Miscellaneous and helpful results.

      @[simp]
      theorem KEVMInterface.inj_ID_CELL (ID_CELL : SortInt) :
      inj ID_CELL = SortAccount.inj_SortInt ID_CELL

      Explicit account for the SortIntSortAccount injection instance.