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:
Signature Level: The signature of the hooks, this includes aliases for Sorts and function symbols for hooked functions.
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.
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 #
Equations
Instances For
Inductives #
- bigEndianBytes : SortEndianness
- littleEndianBytes : SortEndianness
Instances For
Equations
- instBEqSortEndianness = { beq := beqSortEndianness✝ }
- signedBytes : SortSignedness
- unsignedBytes : SortSignedness
Instances For
Equations
- instBEqSortSignedness = { beq := beqSortSignedness✝ }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- instBEqUInt8_evmEquivalence = { beq := fun (a b : UInt8) => decide (a = b) }
Equations
- instBEqSortBytes = { beq := fun (a b : SortBytes) => ByteArray.toList a == ByteArray.toList b }
Equations
Function Implementations #
Operations
#
Comparisons
#
Equations
Instances For
Equations
- «Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness» x0 x1 SortEndianness.littleEndianBytes = some («Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness».littleEndian x0 x1).toByteArray
- «Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness» x0 x1 SortEndianness.bigEndianBytes = some («Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness».littleEndian x0 x1).reverse.toByteArray
Instances For
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.
- «Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness».littleEndian.bytes pad 0 n = []
- «Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness».littleEndian.bytes pad l.succ 0 = pad :: «Int2Bytes(_,_,_)_BYTES-HOOKED_Bytes_Int_Int_Endianness».littleEndian.bytes pad l 0
Instances For
Adapted from
https://github.com/runtimeverification/haskell-backend/blob/362dab30d6435ec117862fea722be67373572034/kore/src/Kore/Builtin/InternalBytes.hs#L527-L543
Note that we use List.foldl
and not ByteArray.foldl
for ease of reasoning
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
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
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.