Polynomial-time lookup and tabulation on rectangular integer row tables #
Executable two-dimensional tables of integers with runtime-varying dimensions are represented as
lists of rows List (List ℤ) encoded under encList (encList encIntBin). This module provides
shared total entry lookup (Cslib.rowEntry, defaulting out-of-bounds indices to 0), rectangular
r × c table construction (Cslib.tabulateTable), rectangular shape predicates and extensionality
(Cslib.IsTableShape, Cslib.eq_of_isTableShape_of_rowEntry_eq), and plain polynomial-time
composition rules (Cslib.computableInPolyTime_rowEntry,
Cslib.computableInPolyTime_tabulateTable) with dimensions and indices in unary.
Main definitions #
Cslib.IsTableShape: predicate assertingrows.length = rand every row ofrowshas lengthc.Cslib.rowEntry: total(i, j)entry lookup onList (List ℤ)returning0when missing.Cslib.tabulateTable: construct ther × clist of rows whose(i, j)entry isg i j.
Main results #
Cslib.isTableShape_tabulateTable,Cslib.rowEntry_tabulateTable,Cslib.rowEntry_tabulateTable_of_lt: shape and entry lookup oftabulateTable.Cslib.exists_rowEntry_eq_of_mem,Cslib.exists_rowEntry_eq,Cslib.rowEntry_rel_of_mem: correspondence between stored list elements and indexedrowEntryvalues.Cslib.eq_of_isTableShape_of_rowEntry_eq,Cslib.tabulateTable_rowEntry: extensionality and re-tabulation on(r, c)-shaped tables.Cslib.computableInPolyTime_rowEntry,Cslib.computableInPolyTime_tabulateTable: plain@[fun_prop]polynomial-time certificates over unary indices/dimensions andencIntBinentries.
Shape, lookup, and rectangular tabulation #
Tabulating an r × c table produces r rows.
Every row in tabulateTable r c g has length c.
Every tabulated r × c table has shape (r, c).
In-bounds lookup on tabulateTable r c g returns g i j.
Two (r, c)-shaped tables are equal when their in-bounds entries agree.
Re-tabulating an (r, c)-shaped table from rowEntry recovers it unchanged.
Plain polynomial-time certificates #
Entry lookup rowEntry on a list of integer rows is computable in polynomial time.
Tabulating an r × c table of binary integers from unary dimensions (r, c) is computable
in polynomial time.