leanprover / leanprover/cslib

feat(Computability): Framework for encoding arbitrary types on Turing machines

Open
#590 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
709
Forks
200
Avg merge
3d 6h
Merged PRs (30d)
45

Description

Description:

This issue addresses the first TODO in Cslib/Computability/Turing/SingleTapeTM.lean:

"Encoding of types in lists to represent computations on arbitrary types."

Currently, TimeComputable and PolyTimeComputable are restricted to functions of type List Symbol → List Symbol. To expand this to standard computable functions (e.g., over Nat, Bool, pairs, and eventually Rat for Computable Analysis), we need a standardized way to represent arbitrary types on the TM tape.

Proposed Architecture

I propose introducing a TapeEncodable typeclass that bundles the encoding function, the decoding function, and the proof of round-trip correctness:

class TapeEncodable (α : Type) (Symbol : Type) where
  encode : α → List Symbol
  decode : List Symbol → Option α
  decode_encode_eq : ∀ (a : α), decode (encode a) = some a
Implementation Plan

I would like to break this into a few manageable PRs:

  • Phase 1 (This week): Introduce the TapeEncodable typeclass and provide the trivial instance for List Symbol.

  • Phase 2: Provide basic instances (e.g., for Bool, Nat, and α × β).

  • Phase 3: Generalize TimeComputable and PolyTimeComputable to accept arbitrary types α and β given [TapeEncodable α Symbol] and [TapeEncodable β Symbol].

I will start with PR 1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the first TODO in Cslib/Computability/Turing/SingleTapeTM.lean and read the existing TimeComputable and PolyTimeComputable definitions. Phase 1 is done when TapeEncodable is introduced with encode, decode, and round-trip correctness, plus the trivial List Symbol instance.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.