mathlib icon indicating copy to clipboard operation
mathlib copied to clipboard

Complexity Theory

Open BoltonBailey opened this issue 3 years ago • 6 comments

~~A definition of mu-recursive functions (currently on the naturals).~~ It's my hope that this can be the start of computational complexity in mathlib. Anyone who is interested in seeing complexity theory happen should feel welcome to contribute.

Here are a few potential TODOs:

  • [x] Create a mapping from mu_recursive, which describes algorithms, to the functions those algorithms compute. Edit: as gebner commented, this already exists in nat.partrec_code.
  • [x] Define a non-computable partial function to return the time a particular function takes on a particular input / a proposition to say that a particular function on a particular input terminates in a particular amount of time.
  • [ ] Prove useful lemmas for managing statements about time complexity.
  • [x] mu-recursive functions are currently from tuples of naturals to naturals. Is there a convenient way of extending this to functions from lists of arbitrary symbols? Note: we are now working with lists of naturals instead.

  • [x] depends on: #11868 [instances for part]
  • [x] depends on: #12001 [lemmas for instances for part]
  • [x] depends on : #12109

Open in Gitpod

BoltonBailey avatar Dec 25 '21 00:12 BoltonBailey

We already have (essentially) this definition, it's called nat.partrec.code.

Create a mapping from mu_recursive, which describes algorithms, to the functions those algorithms compute.

This is the nat.partrec.code.eval function.

gebner avatar Dec 27 '21 10:12 gebner

We already have (essentially) this definition, it's called nat.partrec.code.

Create a mapping from mu_recursive, which describes algorithms, to the functions those algorithms compute.

This is the nat.partrec.code.eval function.

I like that this version has explicit arity, but perhaps it's better not to reinvent the wheel too much. I'm changing the title of this PR to make it more broadly complexity-theory focused.

BoltonBailey avatar Jan 04 '22 19:01 BoltonBailey

This PR/issue depends on:

  • ~~leanprover-community/mathlib#11868~~
  • ~~leanprover-community/mathlib#12001~~ By Dependent Issues (🤖). Happy coding!

See discussion here this might not work.

BoltonBailey avatar Mar 27 '22 21:03 BoltonBailey

@BoltonBailey I've implemented this using a new definition of code here: https://github.com/prakol16/lean_complexity_theory_polytime_defs/tree/main/src

Should I use this PR to try to merge them or do you want me to make a new one?

prakol16 avatar Apr 03 '22 03:04 prakol16

@prakol16 Seeing as how you're using a different code definition I would suggest making a new PR or PRs. Feel free to reuse any of the code here if it's useful there. I may end up eventually closing this PR without merging.

BoltonBailey avatar Apr 03 '22 19:04 BoltonBailey