feat(Foundations/Data): Function view for Turing tapes#499
Conversation
|
Seems like a good addition! My only comment is: Should we add tags like @[ext] or |
chenson2018
left a comment
There was a problem hiding this comment.
This looks straightforward, thanks! Just some style questions.
| obtain ⟨head₂, left₂, right₂⟩ := t₂ | ||
| have h_head : head₁ = head₂ := by simpa [get] using h_get_eq 0 | ||
| have h_right : right₁ = right₂ := by | ||
| apply StackTape.ext_get |
There was a problem hiding this comment.
Should StackTape.ext_get and this theorem have ext attributes?
There was a problem hiding this comment.
After adding the attributes to StackTape.ext and StackTape.ext_get, I can use ext1 p here, but how can I be sure that the ext tactic uses StackTape.ext_get instead of StackTape.ext?
There was a problem hiding this comment.
You're right, even if you remove both it picks up another usage of ext, so maybe this isn't helpful?
Co-authored-by: Chris Henson <[email protected]>
chenson2018
left a comment
There was a problem hiding this comment.
A couple more style comments.
| unfold move_right get | ||
| match p with | ||
| | Int.ofNat n => | ||
| rw [show Int.ofNat n + 1 = Int.ofNat (n + 1) by lia] |
There was a problem hiding this comment.
Is this the preferred way to do these proofs in Mathlib? I rarely work with integers, but this seems very low-level.
There was a problem hiding this comment.
To be honest, I don't know. I think the conversions between natural numbers and integers makes this cumbersome (in combination with the matching). That's another reason why a view Int -> Option Symbol for tapes is so useful: It's much easier to combine with head movements (when they are converted to Int using optionDirToInt).
Co-authored-by: Chris Henson <[email protected]>
The central addition in this PR is
BiTape.get: it allows (integer) index-based access to the Turing tape cells.In addition, adds several lemmas that make it easier to work with
BiTapes by viewing them as functionsℤ → Option Symbol. A sequence of moves and writes translates into a sequence ofFunction.updateand thus maps everything into a domain thatsimpandgrindcan already nicely work with.