Skip to content

Rewrite ingress, support bignum literals, fix FVar type inference#348

Open
arthurpaulino wants to merge 2 commits intomainfrom
ap/kernel
Open

Rewrite ingress, support bignum literals, fix FVar type inference#348
arthurpaulino wants to merge 2 commits intomainfrom
ap/kernel

Conversation

@arthurpaulino
Copy link
Member

Ingress: replace linear scan with position-map-based address resolution. Compute block layout in a separate pass, then build a parallel KGList mapping each loaded address to its kernel constant index. This removes the O(n²) find_*_position helpers and the U64-based ref_idxs/recur_idxs in favor of G-valued KGList lookups. Primitive type indices (Nat, String) are resolved by hardcoded blake3 address during ingress.

Literals: Nat literals now use KLimbs (little-endian bignum list of U64 limbs) instead of a single U64, supporting arbitrarily large Nat values. String literals use raw ByteStream instead of U64. Blob ingress returns raw bytes; conversion decodes them into the appropriate literal type.

Kernel: FVar now carries its domain type, fixing k_infer_val_type to return the actual type instead of the Sort 1 sentinel. Recursor iota uses rec_rule_try_find (returns KRecRuleMaybe) so missing rules produce an unreduced Const instead of a panic. Unit-like type equality and struct eta use kg_list_length for constructor counting.

Also adds lake exe kernel executable for standalone typechecking.

Ingress: replace linear scan with position-map-based address resolution.
Compute block layout in a separate pass, then build a parallel KGList
mapping each loaded address to its kernel constant index. This removes
the O(n²) find_*_position helpers and the U64-based ref_idxs/recur_idxs
in favor of G-valued KGList lookups. Primitive type indices (Nat, String)
are resolved by hardcoded blake3 address during ingress.

Literals: Nat literals now use KLimbs (little-endian bignum list of U64
limbs) instead of a single U64, supporting arbitrarily large Nat values.
String literals use raw ByteStream instead of U64. Blob ingress returns
raw bytes; conversion decodes them into the appropriate literal type.

Kernel: FVar now carries its domain type, fixing k_infer_val_type to
return the actual type instead of the Sort 1 sentinel. Recursor iota
uses rec_rule_try_find (returns KRecRuleMaybe) so missing rules produce
an unreduced Const instead of a panic. Unit-like type equality and
struct eta use kg_list_length for constructor counting.

Also adds `lake exe kernel` executable for standalone typechecking.
Reuse kernelCheck from Kernel.lean instead of duplicating the IOBuffer
setup logic. Replace individual kernelCheckNatAddComm and
kernelCheckNatSubLeOfLeAdd with a single kernelChecks that maps over
a list of constant names, adding String.Internal.append. Use
string-based name construction to prevent instantiation errors with
numerical limbs. Mark serde and kernel test cases as executionOnly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant