Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Lookup

Polynomial-time association-list lookup #

Provides Turing.MultiTapeTM.ComputableInPolyTime.listLookup, certifying List.lookup on a computed key and framed association list for any lawful BEq key type with a readable encoding.

theorem Turing.MultiTapeTM.ComputableInPolyTime.listLookup {K V : Type} [BEq K] [LawfulBEq K] (encK : K ↪ List Bool) (encV : V ↪ List Bool) :
ComputableInPolyTime (fun (p : K × List (K × V)) => List.lookup p.1 p.2) (encPair encK (encList (encPair encK encV))) (encOption encV)

Looking up a key in an association list of framed key-value pairs is polynomial-time computable whenever equality of keys is decided via an injective encoding encK and a LawfulBEq K instance.