computability.tm_to_partrec
⟷
Mathlib.Computability.TMToPartrec
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -319,10 +319,10 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
case prim.comp m n f g hf hg IHf IHg => simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg
case prim.prec n f g hf hg IHf IHg =>
obtain ⟨cf, hf⟩ := IHf; obtain ⟨cg, hg⟩ := IHg
- simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
+ simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
refine' ⟨prec cf cg, fun v => _⟩; rw [← v.cons_head_tail]
specialize hf v.tail; replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
- simp only [Vector.cons_val, Vector.tail_val] at hf hg
+ simp only [Vector.cons_val, Vector.tail_val] at hf hg
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons,
PFun.coe_val, Vector.tail_val]
simp only [← Part.pure_eq_some] at hf hg ⊢
@@ -386,10 +386,10 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
refine' PFun.fixInduction h1 fun v₁ h2 IH => _; clear h1
rintro n rfl hm
have := PFun.mem_fix_iff.1 h2
- simp only [hf, Part.bind_some] at this
- split_ifs at this
+ simp only [hf, Part.bind_some] at this
+ split_ifs at this
· simp only [List.headI, exists_false, or_false_iff, Part.mem_some_iff, List.tail_cons,
- false_and_iff] at this
+ false_and_iff] at this
subst this; exact ⟨_, ⟨h, hm⟩, rfl⟩
· refine' IH (n.succ::v.val) (by simp_all) _ rfl fun m h' => _
obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'; exacts [hm _ h, h]
@@ -689,20 +689,20 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
· rw [Part.mem_some_iff.1 hv₂]; exact Or.inl (Part.mem_some _)
· exact Or.inr ⟨_, Part.mem_some _, hv₂⟩
refine' fun c he => eval_induction he fun y h IH => _
- rintro v (⟨v'⟩ | ⟨k', v'⟩) rfl hr <;> rw [cfg.then] at h IH
+ rintro v (⟨v'⟩ | ⟨k', v'⟩) rfl hr <;> rw [cfg.then] at h IH
· have := mem_eval.2 ⟨hr, rfl⟩
- rw [fok, Part.bind_eq_bind, Part.mem_bind_iff] at this
+ rw [fok, Part.bind_eq_bind, Part.mem_bind_iff] at this
obtain ⟨v'', h₁, h₂⟩ := this
- rw [reaches_eval] at h₂ ; swap; exact refl_trans_gen.single rfl
+ rw [reaches_eval] at h₂; swap; exact refl_trans_gen.single rfl
cases Part.mem_unique h₂ (mem_eval.2 ⟨refl_trans_gen.refl, rfl⟩)
- refine' ⟨v', h₁, _⟩; rw [step_ret] at h
+ refine' ⟨v', h₁, _⟩; rw [step_ret] at h
revert h;
by_cases he : v'.head = 0 <;> simp only [exists_prop, if_pos, if_false, he] <;> intro h
· refine' ⟨_, Part.mem_some _, _⟩
rw [reaches_eval]; exact h; exact refl_trans_gen.single rfl
· obtain ⟨k₀, v₀, e₀⟩ := step_normal.is_ret f cont.halt v'.tail
have e₁ := step_normal_then f cont.halt (cont.fix f k) v'.tail
- rw [e₀, cont.then, cfg.then] at e₁
+ rw [e₀, cont.then, cfg.then] at e₁
obtain ⟨v₁, hv₁, v₂, hv₂, h₃⟩ :=
IH (step_ret (k₀.then (cont.fix f k)) v₀) _ v'.tail _ step_ret_then _
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
@@ -713,15 +713,15 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
· apply refl_trans_gen.single; rw [e₀]; exact rfl
· exact IH _ rfl _ _ step_ret_then (refl_trans_gen.tail hr rfl)
· rintro ⟨v', he, hr⟩
- rw [reaches_eval] at hr ; swap; exact refl_trans_gen.single rfl
+ rw [reaches_eval] at hr; swap; exact refl_trans_gen.single rfl
refine' PFun.fixInduction he fun v (he : v' ∈ f.fix.eval v) IH => _
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff]
obtain he | ⟨v'', he₁', _⟩ := PFun.mem_fix_iff.1 he
- · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rwa [step_ret, if_pos h]
- · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
clear he₂ he₁'
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
@@ -1337,7 +1337,7 @@ theorem splitAtPred_eq {α} (p : α → Bool) :
Option.elim' (L = l₁ ∧ l₂ = []) (fun a => p a = true ∧ L = l₁ ++ a::l₂) o →
splitAtPred p L = (l₁, o, l₂)
| [], _, none, _, _, ⟨rfl, rfl⟩ => rfl
- | [], l₁, some o, l₂, h₁, ⟨h₂, h₃⟩ => by simp at h₃ <;> contradiction
+ | [], l₁, some o, l₂, h₁, ⟨h₂, h₃⟩ => by simp at h₃ <;> contradiction
| a::L, l₁, o, l₂, h₁, h₂ => by
rw [split_at_pred]
have IH := split_at_pred_eq L
@@ -1374,9 +1374,9 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
· revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
· refine' trans_gen.head rfl _; simp
- cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e ; · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
+ cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
simp [e₂]
convert @IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
@@ -1427,9 +1427,9 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
· revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
· refine' trans_gen.head rfl _; simp
- cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e ; · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
+ cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
simp [e₂]
convert @IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
@@ -1472,7 +1472,7 @@ theorem trNat_natEnd (n) : ∀ x ∈ trNat n, natEnd x = false :=
#print Turing.PartrecToTM2.trList_ne_consₗ /-
theorem trList_ne_consₗ : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.consₗ
| a::l, x, h => by
- simp [tr_list] at h
+ simp [tr_list] at h
obtain h | rfl | h := h
· rintro rfl; cases tr_nat_nat_end _ _ h
· rintro ⟨⟩
@@ -1552,7 +1552,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (tr_pos_num a ++ [Γ'.cons]) l₁ c d⟩
⟨some (unrev q), s', K'.elim (l₂' ++ [Γ'.cons]) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit0::l₁, [Γ'.bit1], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
@@ -1594,7 +1594,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
⟨some (q₁.pred q₂), s, K'.elim (tr_pos_num a.succ ++ Γ'.cons::tr_list v) l₁ c d⟩
⟨some (unrev q₂), s', K'.elim (l₂' ++ Γ'.cons::tr_list v) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit1::l₁, [], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
@@ -1726,12 +1726,12 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
rw [reaches_eval h₂.to_refl]; simp
refine' ⟨fun h => _, _⟩
· obtain ⟨c, hc₁, hc₂⟩ := tr_eval_rev tr_respects h₁ h
- simp [step_normal_eval] at hc₂
+ simp [step_normal_eval] at hc₂
obtain ⟨v', hv, rfl⟩ := hc₂
exact ⟨_, hv, hc₁.symm⟩
· rintro ⟨v', hv, rfl⟩
have := tr_eval tr_respects h₁
- simp [step_normal_eval] at this
+ simp [step_normal_eval] at this
obtain ⟨_, ⟨⟩, h⟩ := this _ hv rfl
exact h
#align turing.partrec_to_TM2.tr_eval Turing.PartrecToTM2.tr_eval
@@ -2015,11 +2015,11 @@ theorem ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (
have W := fun {q} => tr_stmts₁_self q
cases k
case halt => trivial
- case cons₁ => rw [cont_supp_cons₁, Finset.union_subset_iff] at H₁ ; exact fun _ => H₁.1 W
- case cons₂ => rw [cont_supp_cons₂, Finset.union_subset_iff] at H₁ ; exact fun _ => H₁.1 W
- case comp => rw [cont_supp_comp] at H₁ ; exact fun _ => H₁ (code_supp_self _ _ W)
+ case cons₁ => rw [cont_supp_cons₁, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
+ case cons₂ => rw [cont_supp_cons₂, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
+ case comp => rw [cont_supp_comp] at H₁; exact fun _ => H₁ (code_supp_self _ _ W)
case fix =>
- rw [cont_supp_fix] at H₁
+ rw [cont_supp_fix] at H₁
have L := @Finset.mem_union_left; have R := @Finset.mem_union_right
intro s; dsimp only; cases nat_end s.iget
· refine' H₁ (R _ <| L _ <| R _ <| R _ <| L _ W)
@@ -2036,7 +2036,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
cases' Finset.insert_subset_iff.1 HS₁ with h₁ h₂
first
| have h₃ := h₂ W
- | try simp [Finset.subset_iff] at h₂
+ | try simp [Finset.subset_iff] at h₂
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩
-- move
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩
@@ -2067,7 +2067,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStmts₁ q ∪ K ⊆ S)
(H₃ : K ⊆ S → Supports K S) : Supports (trStmts₁ q ∪ K) S :=
by
- simp [Finset.union_subset_iff] at H₂
+ simp [Finset.union_subset_iff] at H₂
exact supports_union.2 ⟨tr_stmts₁_supports H₁ H₂.1, H₃ H₂.2⟩
#align turing.partrec_to_TM2.tr_stmts₁_supports' Turing.PartrecToTM2.trStmts₁_supports'
-/
@@ -2079,14 +2079,14 @@ theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Sup
case zero' => exact Finset.union_subset_right Hk
case succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
case tail => exact Finset.union_subset_right Hk
- case cons f fs IHf IHfs => apply IHf; rw [code_supp_cons] at Hk ;
+ case cons f fs IHf IHfs => apply IHf; rw [code_supp_cons] at Hk;
exact Finset.union_subset_right Hk
- case comp f g IHf IHg => apply IHg; rw [code_supp_comp] at Hk ; exact Finset.union_subset_right Hk
+ case comp f g IHf IHg => apply IHg; rw [code_supp_comp] at Hk; exact Finset.union_subset_right Hk
case case f g IHf
IHg =>
- simp only [code_supp_case, Finset.union_subset_iff] at Hk
+ simp only [code_supp_case, Finset.union_subset_iff] at Hk
exact ⟨IHf Hk.2.1, IHg Hk.2.2⟩
- case fix f IHf => apply IHf; rw [code_supp_fix] at Hk ; exact Finset.union_subset_right Hk
+ case fix f IHf => apply IHf; rw [code_supp_fix] at Hk; exact Finset.union_subset_right Hk
#align turing.partrec_to_TM2.tr_normal_supports Turing.PartrecToTM2.trNormal_supports
-/
@@ -2097,20 +2097,20 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
iterate 3
exact tr_stmts₁_supports (tr_normal_supports H) (Finset.Subset.trans (code_supp_self _ _) H)
case cons f fs IHf IHfs =>
- have H' := H; simp only [code_supp_cons, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_cons, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
· simp only [code_supp, Finset.union_subset_iff, cont_supp] at h H ⊢
exact ⟨h.2.2.1, h.2.2.2, H.2⟩
refine' supports_union.2 ⟨IHfs _, _⟩
- · rw [code_supp, cont_supp_cons₁] at H'
+ · rw [code_supp, cont_supp_cons₁] at H'
exact Finset.union_subset_right (Finset.union_subset_right H'.2)
exact
tr_stmts₁_supports (head_supports <| Finset.union_subset_right H)
(Finset.union_subset_right h)
case comp f g IHf IHg =>
- have H' := H; rw [code_supp_comp] at H' ; have H' := Finset.union_subset_right H'
+ have H' := H; rw [code_supp_comp] at H'; have H' := Finset.union_subset_right H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHg H', _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
@@ -2118,11 +2118,11 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
exact ⟨h.2.2, H.2⟩
exact IHf (Finset.union_subset_right H')
case case f g IHf IHg =>
- have H' := H; simp only [code_supp_case, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_case, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
exact supports_union.2 ⟨IHf H'.2.1, IHg H'.2.2⟩
case fix f IHf =>
- have H' := H; simp only [code_supp_fix, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_fix, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
@@ -2139,19 +2139,19 @@ theorem contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S
induction k
· simp [cont_supp_halt, supports]
case cons₁ f k IH =>
- have H₁ := H; rw [cont_supp_cons₁] at H₁ ; have H₂ := Finset.union_subset_right H₁
+ have H₁ := H; rw [cont_supp_cons₁] at H₁; have H₂ := Finset.union_subset_right H₁
refine' tr_stmts₁_supports' (tr_normal_supports H₂) H₁ fun h => _
refine' supports_union.2 ⟨code_supp'_supports H₂, _⟩
- simp only [code_supp, cont_supp_cons₂, Finset.union_subset_iff] at H₂
+ simp only [code_supp, cont_supp_cons₂, Finset.union_subset_iff] at H₂
exact tr_stmts₁_supports' (head_supports H₂.2.2) (Finset.union_subset_right h) IH
case cons₂ k IH =>
- have H' := H; rw [cont_supp_cons₂] at H'
+ have H' := H; rw [cont_supp_cons₂] at H'
exact tr_stmts₁_supports' (head_supports <| Finset.union_subset_right H') H' IH
case comp f k IH =>
- have H' := H; rw [cont_supp_comp] at H' ; have H₂ := Finset.union_subset_right H'
+ have H' := H; rw [cont_supp_comp] at H'; have H₂ := Finset.union_subset_right H'
exact supports_union.2 ⟨code_supp'_supports H', IH H₂⟩
case fix f k IH =>
- rw [cont_supp] at H
+ rw [cont_supp] at H
exact supports_union.2 ⟨code_supp'_supports H, IH (Finset.union_subset_right H)⟩
#align turing.partrec_to_TM2.cont_supp_supports Turing.PartrecToTM2.contSupp_supports
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -361,9 +361,9 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
show ∀ x, pure x = [x] from fun _ => rfl] at hf ⊢
refine' Part.ext fun x => _
simp only [rfind, Part.bind_eq_bind, Part.pure_eq_some, Part.map_eq_map, Part.bind_some,
- exists_prop, eval, List.headI, pred_eval, Part.map_some, Bool.false_eq_decide_iff,
+ exists_prop, eval, List.headI, pred_eval, Part.map_some, false_eq_decide_iff,
Part.mem_bind_iff, List.length, Part.mem_map_iff, Nat.mem_rfind, List.tail,
- Bool.true_eq_decide_iff, Part.mem_some_iff, Part.map_bind]
+ true_eq_decide_iff, Part.mem_some_iff, Part.map_bind]
constructor
· rintro ⟨v', h1, rfl⟩
suffices
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -1887,8 +1887,7 @@ theorem codeSupp_comp (f g k) :
trStmts₁ (trNormal (Code.comp f g) k) ∪ codeSupp g (Cont'.comp f k) :=
by
simp [code_supp, code_supp', cont_supp, Finset.union_assoc]
- rw [← Finset.union_assoc _ _ (cont_supp k),
- Finset.union_eq_right_iff_subset.2 (code_supp'_self _ _)]
+ rw [← Finset.union_assoc _ _ (cont_supp k), Finset.union_eq_right.2 (code_supp'_self _ _)]
#align turing.partrec_to_TM2.code_supp_comp Turing.PartrecToTM2.codeSupp_comp
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,10 +3,10 @@ Copyright (c) 2020 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
-import Mathbin.Computability.Halting
-import Mathbin.Computability.TuringMachine
-import Mathbin.Data.Num.Lemmas
-import Mathbin.Tactic.DeriveFintype
+import Computability.Halting
+import Computability.TuringMachine
+import Data.Num.Lemmas
+import Tactic.DeriveFintype
#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"bd15ff41b70f5e2cc210f26f25a8d5c53b20d3de"
@@ -599,7 +599,7 @@ def Cfg.then : Cfg → Cont → Cfg
#align turing.to_partrec.cfg.then Turing.ToPartrec.Cfg.then
-/
-/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:340:16: warning: unsupported simp config option: constructor_eq -/
+/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:342:16: warning: unsupported simp config option: constructor_eq -/
#print Turing.ToPartrec.stepNormal_then /-
/-- The `step_normal` function respects the `then k'` homomorphism. Note that this is an exact
equality, not a simulation; the original and embedded machines move in lock-step until the
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,17 +2,14 @@
Copyright (c) 2020 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module computability.tm_to_partrec
-! leanprover-community/mathlib commit bd15ff41b70f5e2cc210f26f25a8d5c53b20d3de
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Computability.Halting
import Mathbin.Computability.TuringMachine
import Mathbin.Data.Num.Lemmas
import Mathbin.Tactic.DeriveFintype
+#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"bd15ff41b70f5e2cc210f26f25a8d5c53b20d3de"
+
/-!
# Modelling partial recursive functions using Turing machines
mathlib commit https://github.com/leanprover-community/mathlib/commit/8b981918a93bc45a8600de608cde7944a80d92b9
@@ -2037,7 +2037,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
have W := fun {q} => tr_stmts₁_self q
induction q <;> simp [tr_stmts₁] at HS₁ ⊢
any_goals
- cases' Finset.insert_subset.1 HS₁ with h₁ h₂
+ cases' Finset.insert_subset_iff.1 HS₁ with h₁ h₂
first
| have h₃ := h₂ W
| try simp [Finset.subset_iff] at h₂
@@ -2131,7 +2131,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
· simp only [code_supp', code_supp, Finset.union_subset_iff, cont_supp, tr_stmts₁,
- Finset.insert_subset] at h H ⊢
+ Finset.insert_subset_iff] at h H ⊢
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
mathlib commit https://github.com/leanprover-community/mathlib/commit/2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
@@ -458,10 +458,10 @@ to `v'` in finitely many steps if and only if `code.eval c v = some v'`.
/-- The type of continuations, built up during evaluation of a `code` expression. -/
inductive Cont
| halt
- | cons₁ : Code → List ℕ → cont → cont
- | cons₂ : List ℕ → cont → cont
- | comp : Code → cont → cont
- | fix : Code → cont → cont
+ | cons₁ : Code → List ℕ → Cont → Cont
+ | cons₂ : List ℕ → Cont → Cont
+ | comp : Code → Cont → Cont
+ | fix : Code → Cont → Cont
deriving Inhabited
#align turing.to_partrec.cont Turing.ToPartrec.Cont
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -146,9 +146,11 @@ def nil : Code :=
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
-/
+#print Turing.ToPartrec.Code.nil_eval /-
@[simp]
theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil]
#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval
+-/
#print Turing.ToPartrec.Code.id /-
/-- `id` is the identity function: `id v = v`. -/
@@ -157,9 +159,11 @@ def id : Code :=
#align turing.to_partrec.code.id Turing.ToPartrec.Code.id
-/
+#print Turing.ToPartrec.Code.id_eval /-
@[simp]
theorem id_eval (v) : id.eval v = pure v := by simp [id]
#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval
+-/
#print Turing.ToPartrec.Code.head /-
/-- `head` gets the head of the input list: `head [] = [0]`, `head (n :: v) = [n]`. -/
@@ -168,9 +172,11 @@ def head : Code :=
#align turing.to_partrec.code.head Turing.ToPartrec.Code.head
-/
+#print Turing.ToPartrec.Code.head_eval /-
@[simp]
theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head]
#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval
+-/
#print Turing.ToPartrec.Code.zero /-
/-- `zero` is the constant zero function: `zero v = [0]`. -/
@@ -179,9 +185,11 @@ def zero : Code :=
#align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero
-/
+#print Turing.ToPartrec.Code.zero_eval /-
@[simp]
theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero]
#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval
+-/
#print Turing.ToPartrec.Code.pred /-
/-- `pred` returns the predecessor of the head of the input:
@@ -191,10 +199,12 @@ def pred : Code :=
#align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred
-/
+#print Turing.ToPartrec.Code.pred_eval /-
@[simp]
theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by
simp [pred] <;> cases v.head <;> simp
#align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_eval
+-/
#print Turing.ToPartrec.Code.rfind /-
/-- `rfind f` performs the function of the `rfind` primitive of partial recursive functions.
@@ -249,6 +259,7 @@ def prec (f g : Code) : Code :=
attribute [-simp] Part.bind_eq_bind Part.map_eq_map Part.pure_eq_some
+#print Turing.ToPartrec.Code.exists_code.comp /-
theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ}
(hf : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v)
(hg : ∀ i, ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> g i v) :
@@ -270,6 +281,7 @@ theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
-Subtype.val_eq_coe]
rfl⟩
#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.comp
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -294,6 +306,7 @@ theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.ToPartrec.Code.exists_code /-
theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v :=
by
@@ -400,6 +413,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
simp only [hf, hm n.lt_succ_self, Part.bind_some, List.headI, eq_self_iff_true, if_false,
Part.mem_some_iff, and_self_iff, List.tail_cons]
#align turing.to_partrec.code.exists_code Turing.ToPartrec.Code.exists_code
+-/
end Code
@@ -569,12 +583,14 @@ def Cont.then : Cont → Cont → Cont
#align turing.to_partrec.cont.then Turing.ToPartrec.Cont.then
-/
+#print Turing.ToPartrec.Cont.then_eval /-
theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.eval :=
by
induction k generalizing v <;> simp only [cont.eval, cont.then, bind_assoc, pure_bind, *]
· simp only [← k_ih]
· split_ifs <;> [rfl; simp only [← k_ih, bind_assoc]]
#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_eval
+-/
#print Turing.ToPartrec.Cfg.then /-
/-- The `then k` function is a "configuration homomorphism". Its operation on states is to append
@@ -628,12 +644,14 @@ def Code.Ok (c : Code) :=
#align turing.to_partrec.code.ok Turing.ToPartrec.Code.Ok
-/
+#print Turing.ToPartrec.Code.Ok.zero /-
theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
eval step (stepNormal c Cont.halt v) = Cfg.halt <$> Code.eval c v :=
by
rw [h, ← bind_pure_comp_eq_map]; congr; funext v
exact Part.eq_some_iff.2 (mem_eval.2 ⟨refl_trans_gen.single rfl, rfl⟩)
#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zero
+-/
#print Turing.ToPartrec.stepNormal.is_ret /-
theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v' :=
@@ -648,6 +666,7 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
-/
+#print Turing.ToPartrec.cont_eval_fix /-
theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
eval step (stepNormal f (Cont.fix f k) v) = f.fix.eval v >>= fun v => eval step (Cfg.ret k v) :=
by
@@ -712,6 +731,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
rwa [step_ret, if_neg h]
exact IH v₁.tail ((Part.mem_map_iff _).2 ⟨_, he₁, if_neg h⟩)
#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fix
+-/
#print Turing.ToPartrec.code_is_ok /-
theorem code_is_ok (c) : Code.Ok c :=
@@ -735,10 +755,13 @@ theorem code_is_ok (c) : Code.Ok c :=
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
-/
+#print Turing.ToPartrec.stepNormal_eval /-
theorem stepNormal_eval (c v) : eval step (stepNormal c Cont.halt v) = Cfg.halt <$> c.eval v :=
(code_is_ok c).zero
#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_eval
+-/
+#print Turing.ToPartrec.stepRet_eval /-
theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
by
induction k generalizing v
@@ -763,6 +786,7 @@ theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
congr; funext; rw [bind_pure_comp_eq_map, ← IH]
exact reaches_eval (refl_trans_gen.single rfl)
#align turing.to_partrec.step_ret_eval Turing.ToPartrec.stepRet_eval
+-/
end ToPartrec
@@ -1244,25 +1268,33 @@ def K'.elim (a b c d : List Γ') : K' → List Γ'
#align turing.partrec_to_TM2.K'.elim Turing.PartrecToTM2.K'.elim
-/
+#print Turing.PartrecToTM2.K'.elim_update_main /-
@[simp]
theorem K'.elim_update_main {a b c d a'} : update (K'.elim a b c d) main a' = K'.elim a' b c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_main Turing.PartrecToTM2.K'.elim_update_main
+-/
+#print Turing.PartrecToTM2.K'.elim_update_rev /-
@[simp]
theorem K'.elim_update_rev {a b c d b'} : update (K'.elim a b c d) rev b' = K'.elim a b' c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_rev Turing.PartrecToTM2.K'.elim_update_rev
+-/
+#print Turing.PartrecToTM2.K'.elim_update_aux /-
@[simp]
theorem K'.elim_update_aux {a b c d c'} : update (K'.elim a b c d) aux c' = K'.elim a b c' d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_aux Turing.PartrecToTM2.K'.elim_update_aux
+-/
+#print Turing.PartrecToTM2.K'.elim_update_stack /-
@[simp]
theorem K'.elim_update_stack {a b c d d'} : update (K'.elim a b c d) stack d' = K'.elim a b c d' :=
by funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_stack Turing.PartrecToTM2.K'.elim_update_stack
+-/
#print Turing.PartrecToTM2.halt /-
/-- The halting state corresponding to a `list ℕ` output value. -/
@@ -1881,6 +1913,7 @@ theorem codeSupp_fix (f k) :
#align turing.partrec_to_TM2.code_supp_fix Turing.PartrecToTM2.codeSupp_fix
-/
+#print Turing.PartrecToTM2.contSupp_cons₁ /-
@[simp]
theorem contSupp_cons₁ (fs k) :
contSupp (Cont'.cons₁ fs k) =
@@ -1891,6 +1924,7 @@ theorem contSupp_cons₁ (fs k) :
codeSupp fs (Cont'.cons₂ k) :=
by simp [code_supp, code_supp', cont_supp, Finset.union_assoc]
#align turing.partrec_to_TM2.cont_supp_cons₁ Turing.PartrecToTM2.contSupp_cons₁
+-/
#print Turing.PartrecToTM2.contSupp_cons₂ /-
@[simp]
@@ -1966,10 +2000,12 @@ theorem supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K
#align turing.partrec_to_TM2.supports_union Turing.PartrecToTM2.supports_union
-/
+#print Turing.PartrecToTM2.supports_biUnion /-
theorem supports_biUnion {K : Option Γ' → Finset Λ'} {S} :
Supports (Finset.univ.biUnion K) S ↔ ∀ a, Supports (K a) S := by
simp [supports] <;> apply forall_swap
#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_biUnion
+-/
#print Turing.PartrecToTM2.head_supports /-
theorem head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S := fun _ => by
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -586,7 +586,7 @@ def Cfg.then : Cfg → Cont → Cfg
#align turing.to_partrec.cfg.then Turing.ToPartrec.Cfg.then
-/
-/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:337:16: warning: unsupported simp config option: constructor_eq -/
+/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:340:16: warning: unsupported simp config option: constructor_eq -/
#print Turing.ToPartrec.stepNormal_then /-
/-- The `step_normal` function respects the `then k'` homomorphism. Note that this is an exact
equality, not a simulation; the original and embedded machines move in lock-step until the
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -377,7 +377,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
rintro n rfl hm
have := PFun.mem_fix_iff.1 h2
simp only [hf, Part.bind_some] at this
- split_ifs at this
+ split_ifs at this
· simp only [List.headI, exists_false, or_false_iff, Part.mem_some_iff, List.tail_cons,
false_and_iff] at this
subst this; exact ⟨_, ⟨h, hm⟩, rfl⟩
@@ -669,7 +669,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
this _ h _ _ (step_normal_then _ cont.halt _ _) refl_trans_gen.refl
refine' ⟨v₂, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some]
- split_ifs at hv₂ ⊢
+ split_ifs at hv₂ ⊢
· rw [Part.mem_some_iff.1 hv₂]; exact Or.inl (Part.mem_some _)
· exact Or.inr ⟨_, Part.mem_some _, hv₂⟩
refine' fun c he => eval_induction he fun y h IH => _
@@ -691,7 +691,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
IH (step_ret (k₀.then (cont.fix f k)) v₀) _ v'.tail _ step_ret_then _
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
- split_ifs at hv₂ ⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);
+ split_ifs at hv₂ ⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);
exact Or.inr ⟨_, rfl, hv₂⟩]
· rw [step_ret, if_neg he, e₁]; rfl
· apply refl_trans_gen.single; rw [e₀]; exact rfl
@@ -701,11 +701,11 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
refine' PFun.fixInduction he fun v (he : v' ∈ f.fix.eval v) IH => _
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff]
obtain he | ⟨v'', he₁', _⟩ := PFun.mem_fix_iff.1 he
- · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rwa [step_ret, if_pos h]
- · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
clear he₂ he₁'
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
@@ -1349,7 +1349,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
simp [e₂]
- convert@IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
+ convert @IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
simp [Function.update_comm h₁.symm]
#align turing.partrec_to_TM2.move_ok Turing.PartrecToTM2.move_ok
@@ -1402,7 +1402,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
simp [e₂]
- convert@IH (update S k Sk) _ _ using 2 <;> simp [e₃]
+ convert @IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -309,13 +309,13 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
case prim.comp m n f g hf hg IHf IHg => simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg
case prim.prec n f g hf hg IHf IHg =>
obtain ⟨cf, hf⟩ := IHf; obtain ⟨cg, hg⟩ := IHg
- simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
+ simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
refine' ⟨prec cf cg, fun v => _⟩; rw [← v.cons_head_tail]
specialize hf v.tail; replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
- simp only [Vector.cons_val, Vector.tail_val] at hf hg
+ simp only [Vector.cons_val, Vector.tail_val] at hf hg
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons,
PFun.coe_val, Vector.tail_val]
- simp only [← Part.pure_eq_some] at hf hg⊢
+ simp only [← Part.pure_eq_some] at hf hg ⊢
induction' v.head with n IH <;>
simp [prec, hf, bind_assoc, ← Part.map_eq_map, ← bind_pure_comp_eq_map,
show ∀ x, pure x = [x] from fun _ => rfl, -Subtype.val_eq_coe]
@@ -348,7 +348,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
obtain ⟨cf, hf⟩ := IHf; refine' ⟨rfind cf, fun v => _⟩
replace hf := fun a => hf (a ::ᵥ v)
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, PFun.coe_val,
- show ∀ x, pure x = [x] from fun _ => rfl] at hf⊢
+ show ∀ x, pure x = [x] from fun _ => rfl] at hf ⊢
refine' Part.ext fun x => _
simp only [rfind, Part.bind_eq_bind, Part.pure_eq_some, Part.map_eq_map, Part.bind_some,
exists_prop, eval, List.headI, pred_eval, Part.map_some, Bool.false_eq_decide_iff,
@@ -376,13 +376,13 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
refine' PFun.fixInduction h1 fun v₁ h2 IH => _; clear h1
rintro n rfl hm
have := PFun.mem_fix_iff.1 h2
- simp only [hf, Part.bind_some] at this
- split_ifs at this
+ simp only [hf, Part.bind_some] at this
+ split_ifs at this
· simp only [List.headI, exists_false, or_false_iff, Part.mem_some_iff, List.tail_cons,
- false_and_iff] at this
+ false_and_iff] at this
subst this; exact ⟨_, ⟨h, hm⟩, rfl⟩
· refine' IH (n.succ::v.val) (by simp_all) _ rfl fun m h' => _
- obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'; exacts[hm _ h, h]
+ obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'; exacts [hm _ h, h]
· rintro ⟨n, ⟨hn, hm⟩, rfl⟩; refine' ⟨n.succ::v.1, _, rfl⟩
have :
(n.succ::v.1 : List ℕ) ∈
@@ -394,7 +394,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
else Sum.inr (v.head.succ::v.tail))
(n::v.val) :=
PFun.mem_fix_iff.2 (Or.inl (by simp [hf, hn, -Subtype.val_eq_coe]))
- generalize (n.succ::v.1 : List ℕ) = w at this⊢; clear hn
+ generalize (n.succ::v.1 : List ℕ) = w at this ⊢; clear hn
induction' n with n IH; · exact this
refine' IH (fun m h' => hm (Nat.lt_succ_of_lt h')) (PFun.mem_fix_iff.2 (Or.inr ⟨_, _, this⟩))
simp only [hf, hm n.lt_succ_self, Part.bind_some, List.headI, eq_self_iff_true, if_false,
@@ -573,7 +573,7 @@ theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.
by
induction k generalizing v <;> simp only [cont.eval, cont.then, bind_assoc, pure_bind, *]
· simp only [← k_ih]
- · split_ifs <;> [rfl;simp only [← k_ih, bind_assoc]]
+ · split_ifs <;> [rfl; simp only [← k_ih, bind_assoc]]
#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_eval
#print Turing.ToPartrec.Cfg.then /-
@@ -631,7 +631,7 @@ def Code.Ok (c : Code) :=
theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
eval step (stepNormal c Cont.halt v) = Cfg.halt <$> Code.eval c v :=
by
- rw [h, ← bind_pure_comp_eq_map]; congr ; funext v
+ rw [h, ← bind_pure_comp_eq_map]; congr; funext v
exact Part.eq_some_iff.2 (mem_eval.2 ⟨refl_trans_gen.single rfl, rfl⟩)
#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zero
@@ -643,7 +643,7 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
case cons f fs IHf IHfs => apply IHf
case comp f g IHf IHg => apply IHg
case case f g IHf IHg => rw [step_normal];
- cases v.head <;> simp only [Nat.rec] <;> [apply IHf;apply IHg]
+ cases v.head <;> simp only [Nat.rec] <;> [apply IHf; apply IHg]
case fix f IHf => apply IHf
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
-/
@@ -669,42 +669,43 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
this _ h _ _ (step_normal_then _ cont.halt _ _) refl_trans_gen.refl
refine' ⟨v₂, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some]
- split_ifs at hv₂⊢
+ split_ifs at hv₂ ⊢
· rw [Part.mem_some_iff.1 hv₂]; exact Or.inl (Part.mem_some _)
· exact Or.inr ⟨_, Part.mem_some _, hv₂⟩
refine' fun c he => eval_induction he fun y h IH => _
- rintro v (⟨v'⟩ | ⟨k', v'⟩) rfl hr <;> rw [cfg.then] at h IH
+ rintro v (⟨v'⟩ | ⟨k', v'⟩) rfl hr <;> rw [cfg.then] at h IH
· have := mem_eval.2 ⟨hr, rfl⟩
- rw [fok, Part.bind_eq_bind, Part.mem_bind_iff] at this
+ rw [fok, Part.bind_eq_bind, Part.mem_bind_iff] at this
obtain ⟨v'', h₁, h₂⟩ := this
- rw [reaches_eval] at h₂; swap; exact refl_trans_gen.single rfl
+ rw [reaches_eval] at h₂ ; swap; exact refl_trans_gen.single rfl
cases Part.mem_unique h₂ (mem_eval.2 ⟨refl_trans_gen.refl, rfl⟩)
- refine' ⟨v', h₁, _⟩; rw [step_ret] at h
+ refine' ⟨v', h₁, _⟩; rw [step_ret] at h
revert h;
by_cases he : v'.head = 0 <;> simp only [exists_prop, if_pos, if_false, he] <;> intro h
· refine' ⟨_, Part.mem_some _, _⟩
rw [reaches_eval]; exact h; exact refl_trans_gen.single rfl
· obtain ⟨k₀, v₀, e₀⟩ := step_normal.is_ret f cont.halt v'.tail
have e₁ := step_normal_then f cont.halt (cont.fix f k) v'.tail
- rw [e₀, cont.then, cfg.then] at e₁
+ rw [e₀, cont.then, cfg.then] at e₁
obtain ⟨v₁, hv₁, v₂, hv₂, h₃⟩ :=
IH (step_ret (k₀.then (cont.fix f k)) v₀) _ v'.tail _ step_ret_then _
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
- split_ifs at hv₂⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);exact Or.inr ⟨_, rfl, hv₂⟩]
+ split_ifs at hv₂ ⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);
+ exact Or.inr ⟨_, rfl, hv₂⟩]
· rw [step_ret, if_neg he, e₁]; rfl
· apply refl_trans_gen.single; rw [e₀]; exact rfl
· exact IH _ rfl _ _ step_ret_then (refl_trans_gen.tail hr rfl)
· rintro ⟨v', he, hr⟩
- rw [reaches_eval] at hr; swap; exact refl_trans_gen.single rfl
+ rw [reaches_eval] at hr ; swap; exact refl_trans_gen.single rfl
refine' PFun.fixInduction he fun v (he : v' ∈ f.fix.eval v) IH => _
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff]
obtain he | ⟨v'', he₁', _⟩ := PFun.mem_fix_iff.1 he
- · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rwa [step_ret, if_pos h]
- · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
clear he₂ he₁'
refine' ⟨_, he₁, _⟩
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
@@ -719,17 +720,17 @@ theorem code_is_ok (c) : Code.Ok c :=
iterate 3 simp only [code.eval, pure_bind]
case cons f fs IHf IHfs =>
rw [code.eval, IHf]
- simp only [bind_assoc, cont.eval, pure_bind]; congr ; funext v
+ simp only [bind_assoc, cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
- rw [step_ret, IHfs]; congr ; funext v'
+ rw [step_ret, IHfs]; congr; funext v'
refine' Eq.trans _ (Eq.symm _) <;> try exact reaches_eval (refl_trans_gen.single rfl)
case comp f g IHf IHg =>
rw [code.eval, IHg]
- simp only [bind_assoc, cont.eval, pure_bind]; congr ; funext v
+ simp only [bind_assoc, cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rw [step_ret, IHf]
case case f g IHf IHg => simp only [code.eval];
- cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf;apply IHg]
+ cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf; apply IHg]
case fix f IHf => rw [cont_eval_fix IHf]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
-/
@@ -746,20 +747,20 @@ theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
exact Part.eq_some_iff.2 (mem_eval.2 ⟨refl_trans_gen.refl, rfl⟩)
case cons₁ fs as k IH =>
rw [cont.eval, step_ret, code_is_ok]
- simp only [← bind_pure_comp_eq_map, bind_assoc]; congr ; funext v'
+ simp only [← bind_pure_comp_eq_map, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rw [step_ret, IH, bind_pure_comp_eq_map]
case cons₂ ns k IH => rw [cont.eval, step_ret]; exact IH
case comp f k IH =>
rw [cont.eval, step_ret, code_is_ok]
- simp only [← bind_pure_comp_eq_map, bind_assoc]; congr ; funext v'
+ simp only [← bind_pure_comp_eq_map, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rw [IH, bind_pure_comp_eq_map]
case fix f k IH =>
rw [cont.eval, step_ret]; simp only [bind_pure_comp_eq_map]
split_ifs; · exact IH
simp only [← bind_pure_comp_eq_map, bind_assoc, cont_eval_fix (code_is_ok _)]
- congr ; funext; rw [bind_pure_comp_eq_map, ← IH]
+ congr; funext; rw [bind_pure_comp_eq_map, ← IH]
exact reaches_eval (refl_trans_gen.single rfl)
#align turing.to_partrec.step_ret_eval Turing.ToPartrec.stepRet_eval
@@ -952,14 +953,16 @@ instance : DecidableEq Λ' := fun a b =>
#print Turing.PartrecToTM2.Stmt' /-
/-- The type of TM2 statements used by this machine. -/
def Stmt' :=
- TM2.Stmt (fun _ : K' => Γ') Λ' (Option Γ')deriving Inhabited
+ TM2.Stmt (fun _ : K' => Γ') Λ' (Option Γ')
+deriving Inhabited
#align turing.partrec_to_TM2.stmt' Turing.PartrecToTM2.Stmt'
-/
#print Turing.PartrecToTM2.Cfg' /-
/-- The type of TM2 configurations used by this machine. -/
def Cfg' :=
- TM2.Cfg (fun _ : K' => Γ') Λ' (Option Γ')deriving Inhabited
+ TM2.Cfg (fun _ : K' => Γ') Λ' (Option Γ')
+deriving Inhabited
#align turing.partrec_to_TM2.cfg' Turing.PartrecToTM2.Cfg'
-/
@@ -1305,7 +1308,7 @@ theorem splitAtPred_eq {α} (p : α → Bool) :
Option.elim' (L = l₁ ∧ l₂ = []) (fun a => p a = true ∧ L = l₁ ++ a::l₂) o →
splitAtPred p L = (l₁, o, l₂)
| [], _, none, _, _, ⟨rfl, rfl⟩ => rfl
- | [], l₁, some o, l₂, h₁, ⟨h₂, h₃⟩ => by simp at h₃ <;> contradiction
+ | [], l₁, some o, l₂, h₁, ⟨h₂, h₃⟩ => by simp at h₃ <;> contradiction
| a::L, l₁, o, l₂, h₁, h₂ => by
rw [split_at_pred]
have IH := split_at_pred_eq L
@@ -1337,14 +1340,14 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
swap; · rw [Function.update_noteq h₁.symm]; rfl
refine' trans_gen.head' rfl _
simp; cases' S k₁ with a Sk; · cases e; rfl
- simp [split_at_pred] at e⊢
- cases p a <;> simp at e⊢
+ simp [split_at_pred] at e ⊢
+ cases p a <;> simp at e ⊢
· revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
· refine' trans_gen.head rfl _; simp
- cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
+ cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e ; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
simp [e₂]
convert@IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
@@ -1390,14 +1393,14 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
induction' L₁ with a L₁ IH generalizing S s
· refine' trans_gen.head' rfl _
simp; cases' S k with a Sk; · cases e; rfl
- simp [split_at_pred] at e⊢
- cases p a <;> simp at e⊢
+ simp [split_at_pred] at e ⊢
+ cases p a <;> simp at e ⊢
· revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
· refine' trans_gen.head rfl _; simp
- cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
+ cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e ; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e ; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e ; cases e
simp [e₂]
convert@IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
@@ -1440,7 +1443,7 @@ theorem trNat_natEnd (n) : ∀ x ∈ trNat n, natEnd x = false :=
#print Turing.PartrecToTM2.trList_ne_consₗ /-
theorem trList_ne_consₗ : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.consₗ
| a::l, x, h => by
- simp [tr_list] at h
+ simp [tr_list] at h
obtain h | rfl | h := h
· rintro rfl; cases tr_nat_nat_end _ _ h
· rintro ⟨⟩
@@ -1520,7 +1523,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (tr_pos_num a ++ [Γ'.cons]) l₁ c d⟩
⟨some (unrev q), s', K'.elim (l₂' ++ [Γ'.cons]) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit0::l₁, [Γ'.bit1], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
@@ -1562,7 +1565,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
⟨some (q₁.pred q₂), s, K'.elim (tr_pos_num a.succ ++ Γ'.cons::tr_list v) l₁ c d⟩
⟨some (unrev q₂), s', K'.elim (l₂' ++ Γ'.cons::tr_list v) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit1::l₁, [], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
@@ -1591,8 +1594,8 @@ theorem trNormal_respects (c k v s) :
refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _; simp; swap
refine' split_at_pred_eq _ _ (tr_nat v.head) _ _ (tr_nat_nat_end _) _
cases v <;> simp
- case
- cons f fs IHf IHfs =>
+ case cons f fs IHf
+ IHfs =>
obtain ⟨c, h₁, h₂⟩ := IHf (cont.cons₁ fs v k) v none
refine' ⟨c, h₁, trans_gen.head rfl <| (move_ok (by decide) (split_at_pred_ff _)).trans _⟩
simp [step_normal]
@@ -1621,8 +1624,8 @@ theorem tr_ret_respects (k v s) :
by
induction k generalizing v s
case halt => exact ⟨_, rfl, trans_gen.single rfl⟩
- case
- cons₁ fs as k IH =>
+ case cons₁ fs as k
+ IH =>
obtain ⟨s', h₁, h₂⟩ := tr_normal_respects fs (cont.cons₂ v k) as none
refine' ⟨s', h₁, trans_gen.head rfl _⟩; simp
refine' (move₂_ok (by decide) _ (split_at_pred_ff _)).trans _; · rfl; simp
@@ -1651,7 +1654,7 @@ theorem tr_ret_respects (k v s) :
cases' v with n; · exact ⟨rfl, rfl⟩; cases n; · simp
rw [tr_list, List.headI, tr_nat, Nat.cast_succ, Num.add_one, Num.succ, List.tail]
cases (n : Num).succ' <;> exact ⟨rfl, rfl⟩
- by_cases v.head = 0 <;> simp [h] at this⊢
+ by_cases v.head = 0 <;> simp [h] at this ⊢
· obtain ⟨c, h₁, h₂⟩ := IH v.tail (tr_list v).head?
refine' ⟨c, h₁, trans_gen.head rfl _⟩
simp [tr_cont, tr_cont_stack, this]; exact h₂
@@ -1694,12 +1697,12 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
rw [reaches_eval h₂.to_refl]; simp
refine' ⟨fun h => _, _⟩
· obtain ⟨c, hc₁, hc₂⟩ := tr_eval_rev tr_respects h₁ h
- simp [step_normal_eval] at hc₂
+ simp [step_normal_eval] at hc₂
obtain ⟨v', hv, rfl⟩ := hc₂
exact ⟨_, hv, hc₁.symm⟩
· rintro ⟨v', hv, rfl⟩
have := tr_eval tr_respects h₁
- simp [step_normal_eval] at this
+ simp [step_normal_eval] at this
obtain ⟨_, ⟨⟩, h⟩ := this _ hv rfl
exact h
#align turing.partrec_to_TM2.tr_eval Turing.PartrecToTM2.tr_eval
@@ -1739,7 +1742,11 @@ theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trSt
#print Turing.PartrecToTM2.trStmts₁_self /-
theorem trStmts₁_self (q) : q ∈ trStmts₁ q := by
- induction q <;> · first |apply Finset.mem_singleton_self|apply Finset.mem_insert_self
+ induction q <;>
+ ·
+ first
+ | apply Finset.mem_singleton_self
+ | apply Finset.mem_insert_self
#align turing.partrec_to_TM2.tr_stmts₁_self Turing.PartrecToTM2.trStmts₁_self
-/
@@ -1773,7 +1780,10 @@ def codeSupp' : Code → Cont' → Finset Λ'
#print Turing.PartrecToTM2.codeSupp'_self /-
@[simp]
theorem codeSupp'_self (c k) : trStmts₁ (trNormal c k) ⊆ codeSupp' c k := by
- cases c <;> first |rfl|exact Finset.subset_union_left _ _
+ cases c <;>
+ first
+ | rfl
+ | exact Finset.subset_union_left _ _
#align turing.partrec_to_TM2.code_supp'_self Turing.PartrecToTM2.codeSupp'_self
-/
@@ -1973,11 +1983,11 @@ theorem ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (
have W := fun {q} => tr_stmts₁_self q
cases k
case halt => trivial
- case cons₁ => rw [cont_supp_cons₁, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
- case cons₂ => rw [cont_supp_cons₂, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
- case comp => rw [cont_supp_comp] at H₁; exact fun _ => H₁ (code_supp_self _ _ W)
+ case cons₁ => rw [cont_supp_cons₁, Finset.union_subset_iff] at H₁ ; exact fun _ => H₁.1 W
+ case cons₂ => rw [cont_supp_cons₂, Finset.union_subset_iff] at H₁ ; exact fun _ => H₁.1 W
+ case comp => rw [cont_supp_comp] at H₁ ; exact fun _ => H₁ (code_supp_self _ _ W)
case fix =>
- rw [cont_supp_fix] at H₁
+ rw [cont_supp_fix] at H₁
have L := @Finset.mem_union_left; have R := @Finset.mem_union_right
intro s; dsimp only; cases nat_end s.iget
· refine' H₁ (R _ <| L _ <| R _ <| R _ <| L _ W)
@@ -1989,10 +1999,12 @@ theorem ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (
theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts₁ q ⊆ S) :
Supports (trStmts₁ q) S := by
have W := fun {q} => tr_stmts₁_self q
- induction q <;> simp [tr_stmts₁] at HS₁⊢
+ induction q <;> simp [tr_stmts₁] at HS₁ ⊢
any_goals
cases' Finset.insert_subset.1 HS₁ with h₁ h₂
- first |have h₃ := h₂ W|try simp [Finset.subset_iff] at h₂
+ first
+ | have h₃ := h₂ W
+ | try simp [Finset.subset_iff] at h₂
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩
-- move
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩
@@ -2023,7 +2035,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStmts₁ q ∪ K ⊆ S)
(H₃ : K ⊆ S → Supports K S) : Supports (trStmts₁ q ∪ K) S :=
by
- simp [Finset.union_subset_iff] at H₂
+ simp [Finset.union_subset_iff] at H₂
exact supports_union.2 ⟨tr_stmts₁_supports H₁ H₂.1, H₃ H₂.2⟩
#align turing.partrec_to_TM2.tr_stmts₁_supports' Turing.PartrecToTM2.trStmts₁_supports'
-/
@@ -2033,16 +2045,16 @@ theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Sup
by
induction c generalizing k <;> simp [Λ'.supports, head]
case zero' => exact Finset.union_subset_right Hk
- case succ => intro ; split_ifs <;> exact Finset.union_subset_right Hk
+ case succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
case tail => exact Finset.union_subset_right Hk
- case cons f fs IHf IHfs => apply IHf; rw [code_supp_cons] at Hk;
+ case cons f fs IHf IHfs => apply IHf; rw [code_supp_cons] at Hk ;
exact Finset.union_subset_right Hk
- case comp f g IHf IHg => apply IHg; rw [code_supp_comp] at Hk; exact Finset.union_subset_right Hk
- case
- case f g IHf IHg =>
- simp only [code_supp_case, Finset.union_subset_iff] at Hk
+ case comp f g IHf IHg => apply IHg; rw [code_supp_comp] at Hk ; exact Finset.union_subset_right Hk
+ case case f g IHf
+ IHg =>
+ simp only [code_supp_case, Finset.union_subset_iff] at Hk
exact ⟨IHf Hk.2.1, IHg Hk.2.2⟩
- case fix f IHf => apply IHf; rw [code_supp_fix] at Hk; exact Finset.union_subset_right Hk
+ case fix f IHf => apply IHf; rw [code_supp_fix] at Hk ; exact Finset.union_subset_right Hk
#align turing.partrec_to_TM2.tr_normal_supports Turing.PartrecToTM2.trNormal_supports
-/
@@ -2053,37 +2065,37 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
iterate 3
exact tr_stmts₁_supports (tr_normal_supports H) (Finset.Subset.trans (code_supp_self _ _) H)
case cons f fs IHf IHfs =>
- have H' := H; simp only [code_supp_cons, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_cons, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
- · simp only [code_supp, Finset.union_subset_iff, cont_supp] at h H⊢
+ · simp only [code_supp, Finset.union_subset_iff, cont_supp] at h H ⊢
exact ⟨h.2.2.1, h.2.2.2, H.2⟩
refine' supports_union.2 ⟨IHfs _, _⟩
- · rw [code_supp, cont_supp_cons₁] at H'
+ · rw [code_supp, cont_supp_cons₁] at H'
exact Finset.union_subset_right (Finset.union_subset_right H'.2)
exact
tr_stmts₁_supports (head_supports <| Finset.union_subset_right H)
(Finset.union_subset_right h)
case comp f g IHf IHg =>
- have H' := H; rw [code_supp_comp] at H'; have H' := Finset.union_subset_right H'
+ have H' := H; rw [code_supp_comp] at H' ; have H' := Finset.union_subset_right H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHg H', _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
- · simp only [code_supp', code_supp, Finset.union_subset_iff, cont_supp] at h H⊢
+ · simp only [code_supp', code_supp, Finset.union_subset_iff, cont_supp] at h H ⊢
exact ⟨h.2.2, H.2⟩
exact IHf (Finset.union_subset_right H')
case case f g IHf IHg =>
- have H' := H; simp only [code_supp_case, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_case, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
exact supports_union.2 ⟨IHf H'.2.1, IHg H'.2.2⟩
case fix f IHf =>
- have H' := H; simp only [code_supp_fix, Finset.union_subset_iff] at H'
+ have H' := H; simp only [code_supp_fix, Finset.union_subset_iff] at H'
refine' tr_stmts₁_supports' (tr_normal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' tr_stmts₁_supports' (tr_normal_supports _) (Finset.union_subset_right h) fun h => _
· simp only [code_supp', code_supp, Finset.union_subset_iff, cont_supp, tr_stmts₁,
- Finset.insert_subset] at h H⊢
+ Finset.insert_subset] at h H ⊢
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
@@ -2095,19 +2107,19 @@ theorem contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S
induction k
· simp [cont_supp_halt, supports]
case cons₁ f k IH =>
- have H₁ := H; rw [cont_supp_cons₁] at H₁; have H₂ := Finset.union_subset_right H₁
+ have H₁ := H; rw [cont_supp_cons₁] at H₁ ; have H₂ := Finset.union_subset_right H₁
refine' tr_stmts₁_supports' (tr_normal_supports H₂) H₁ fun h => _
refine' supports_union.2 ⟨code_supp'_supports H₂, _⟩
- simp only [code_supp, cont_supp_cons₂, Finset.union_subset_iff] at H₂
+ simp only [code_supp, cont_supp_cons₂, Finset.union_subset_iff] at H₂
exact tr_stmts₁_supports' (head_supports H₂.2.2) (Finset.union_subset_right h) IH
case cons₂ k IH =>
- have H' := H; rw [cont_supp_cons₂] at H'
+ have H' := H; rw [cont_supp_cons₂] at H'
exact tr_stmts₁_supports' (head_supports <| Finset.union_subset_right H') H' IH
case comp f k IH =>
- have H' := H; rw [cont_supp_comp] at H'; have H₂ := Finset.union_subset_right H'
+ have H' := H; rw [cont_supp_comp] at H' ; have H₂ := Finset.union_subset_right H'
exact supports_union.2 ⟨code_supp'_supports H', IH H₂⟩
case fix f k IH =>
- rw [cont_supp] at H
+ rw [cont_supp] at H
exact supports_union.2 ⟨code_supp'_supports H, IH (Finset.union_subset_right H)⟩
#align turing.partrec_to_TM2.cont_supp_supports Turing.PartrecToTM2.contSupp_supports
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -146,12 +146,6 @@ def nil : Code :=
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
-/
-/- warning: turing.to_partrec.code.nil_eval -> Turing.ToPartrec.Code.nil_eval is a dubious translation:
-lean 3 declaration is
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.nil v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.nil.{0} Nat))
-but is expected to have type
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.nil v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.nil.{0} Nat))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_evalₓ'. -/
@[simp]
theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil]
#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval
@@ -163,12 +157,6 @@ def id : Code :=
#align turing.to_partrec.code.id Turing.ToPartrec.Code.id
-/
-/- warning: turing.to_partrec.code.id_eval -> Turing.ToPartrec.Code.id_eval is a dubious translation:
-lean 3 declaration is
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.id v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) v)
-but is expected to have type
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.id v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) v)
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_evalₓ'. -/
@[simp]
theorem id_eval (v) : id.eval v = pure v := by simp [id]
#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval
@@ -180,12 +168,6 @@ def head : Code :=
#align turing.to_partrec.code.head Turing.ToPartrec.Code.head
-/
-/- warning: turing.to_partrec.code.head_eval -> Turing.ToPartrec.Code.head_eval is a dubious translation:
-lean 3 declaration is
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.head v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (List.headI.{0} Nat Nat.inhabited v) (List.nil.{0} Nat)))
-but is expected to have type
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.head v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (List.headI.{0} Nat instInhabitedNat v) (List.nil.{0} Nat)))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_evalₓ'. -/
@[simp]
theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head]
#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval
@@ -197,12 +179,6 @@ def zero : Code :=
#align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero
-/
-/- warning: turing.to_partrec.code.zero_eval -> Turing.ToPartrec.Code.zero_eval is a dubious translation:
-lean 3 declaration is
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.zero v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (List.nil.{0} Nat)))
-but is expected to have type
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.zero v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (List.nil.{0} Nat)))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_evalₓ'. -/
@[simp]
theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero]
#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval
@@ -215,12 +191,6 @@ def pred : Code :=
#align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred
-/
-/- warning: turing.to_partrec.code.pred_eval -> Turing.ToPartrec.Code.pred_eval is a dubious translation:
-lean 3 declaration is
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.pred v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (Nat.pred (List.headI.{0} Nat Nat.inhabited v)) (List.nil.{0} Nat)))
-but is expected to have type
- forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.pred v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (Nat.pred (List.headI.{0} Nat instInhabitedNat v)) (List.nil.{0} Nat)))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_evalₓ'. -/
@[simp]
theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by
simp [pred] <;> cases v.head <;> simp
@@ -279,12 +249,6 @@ def prec (f g : Code) : Code :=
attribute [-simp] Part.bind_eq_bind Part.map_eq_map Part.pure_eq_some
-/- warning: turing.to_partrec.code.exists_code.comp -> Turing.ToPartrec.Code.exists_code.comp is a dubious translation:
-lean 3 declaration is
- forall {m : Nat} {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat} {g : (Fin n) -> (PFun.{0, 0} (Vector.{0} Nat m) Nat)}, (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (f v)))) -> (forall (i : Fin n), Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (g i v)))) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (Vector.{0} Nat n) Nat (Vector.mOfFn.{0, 0} Part.{0} Part.monad.{0} Nat n (fun (i : Fin n) => g i v)) f))))
-but is expected to have type
- forall {m : Nat} {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat} {g : (Fin n) -> (PFun.{0, 0} (Vector.{0} Nat m) Nat)}, (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (f v)))) -> (forall (i : Fin n), Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (g i v)))) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (Vector.{0} Nat n) Nat (Vector.mOfFn.{0, 0} Part.{0} Part.instMonadPart.{0} Nat n (fun (i : Fin n) => g i v)) f))))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.compₓ'. -/
theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ}
(hf : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v)
(hg : ∀ i, ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> g i v) :
@@ -307,12 +271,6 @@ theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
rfl⟩
#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.comp
-/- warning: turing.to_partrec.code.exists_code -> Turing.ToPartrec.Code.exists_code is a dubious translation:
-lean 3 declaration is
- forall {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat}, (Nat.Partrec' n f) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (f v))))
-but is expected to have type
- forall {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat}, (Nat.Partrec' n f) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (f v))))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.exists_code Turing.ToPartrec.Code.exists_codeₓ'. -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -611,12 +569,6 @@ def Cont.then : Cont → Cont → Cont
#align turing.to_partrec.cont.then Turing.ToPartrec.Cont.then
-/
-/- warning: turing.to_partrec.cont.then_eval -> Turing.ToPartrec.Cont.then_eval is a dubious translation:
-lean 3 declaration is
- forall {k : Turing.ToPartrec.Cont} {k' : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Cont.eval (Turing.ToPartrec.Cont.then k k') v) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (List.{0} Nat) (List.{0} Nat) (Turing.ToPartrec.Cont.eval k v) (Turing.ToPartrec.Cont.eval k'))
-but is expected to have type
- forall {k : Turing.ToPartrec.Cont} {k' : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Cont.eval (Turing.ToPartrec.Cont.then k k') v) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (List.{0} Nat) (List.{0} Nat) (Turing.ToPartrec.Cont.eval k v) (Turing.ToPartrec.Cont.eval k'))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_evalₓ'. -/
theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.eval :=
by
induction k generalizing v <;> simp only [cont.eval, cont.then, bind_assoc, pure_bind, *]
@@ -676,12 +628,6 @@ def Code.Ok (c : Code) :=
#align turing.to_partrec.code.ok Turing.ToPartrec.Code.Ok
-/
-/- warning: turing.to_partrec.code.ok.zero -> Turing.ToPartrec.Code.Ok.zero is a dubious translation:
-lean 3 declaration is
- forall {c : Turing.ToPartrec.Code}, (Turing.ToPartrec.Code.Ok c) -> (forall {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v)))
-but is expected to have type
- forall {c : Turing.ToPartrec.Code}, (Turing.ToPartrec.Code.Ok c) -> (forall {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v)))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zeroₓ'. -/
theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
eval step (stepNormal c Cont.halt v) = Cfg.halt <$> Code.eval c v :=
by
@@ -702,12 +648,6 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
-/
-/- warning: turing.to_partrec.cont_eval_fix -> Turing.ToPartrec.cont_eval_fix is a dubious translation:
-lean 3 declaration is
- forall {f : Turing.ToPartrec.Code} {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, (Turing.ToPartrec.Code.Ok f) -> (Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal f (Turing.ToPartrec.Cont.fix f k) v)) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (List.{0} Nat) Turing.ToPartrec.Cfg (Turing.ToPartrec.Code.eval (Turing.ToPartrec.Code.fix f) v) (fun (v : List.{0} Nat) => Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.Cfg.ret k v))))
-but is expected to have type
- forall {f : Turing.ToPartrec.Code} {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, (Turing.ToPartrec.Code.Ok f) -> (Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal f (Turing.ToPartrec.Cont.fix f k) v)) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (List.{0} Nat) Turing.ToPartrec.Cfg (Turing.ToPartrec.Code.eval (Turing.ToPartrec.Code.fix f) v) (fun (v : List.{0} Nat) => Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.Cfg.ret k v))))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fixₓ'. -/
theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
eval step (stepNormal f (Cont.fix f k) v) = f.fix.eval v >>= fun v => eval step (Cfg.ret k v) :=
by
@@ -794,22 +734,10 @@ theorem code_is_ok (c) : Code.Ok c :=
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
-/
-/- warning: turing.to_partrec.step_normal_eval -> Turing.ToPartrec.stepNormal_eval is a dubious translation:
-lean 3 declaration is
- forall (c : Turing.ToPartrec.Code) (v : List.{0} Nat), Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v))
-but is expected to have type
- forall (c : Turing.ToPartrec.Code) (v : List.{0} Nat), Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_evalₓ'. -/
theorem stepNormal_eval (c v) : eval step (stepNormal c Cont.halt v) = Cfg.halt <$> c.eval v :=
(code_is_ok c).zero
#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_eval
-/- warning: turing.to_partrec.step_ret_eval -> Turing.ToPartrec.stepRet_eval is a dubious translation:
-lean 3 declaration is
- forall {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepRet k v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Cont.eval k v))
-but is expected to have type
- forall {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepRet k v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Cont.eval k v))
-Case conversion may be inaccurate. Consider using '#align turing.to_partrec.step_ret_eval Turing.ToPartrec.stepRet_evalₓ'. -/
theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
by
induction k generalizing v
@@ -1313,45 +1241,21 @@ def K'.elim (a b c d : List Γ') : K' → List Γ'
#align turing.partrec_to_TM2.K'.elim Turing.PartrecToTM2.K'.elim
-/
-/- warning: turing.partrec_to_TM2.K'.elim_update_main -> Turing.PartrecToTM2.K'.elim_update_main is a dubious translation:
-lean 3 declaration is
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {a' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.main a') (Turing.PartrecToTM2.K'.elim a' b c d)
-but is expected to have type
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {a' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.main a') (Turing.PartrecToTM2.K'.elim a' b c d)
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_main Turing.PartrecToTM2.K'.elim_update_mainₓ'. -/
@[simp]
theorem K'.elim_update_main {a b c d a'} : update (K'.elim a b c d) main a' = K'.elim a' b c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_main Turing.PartrecToTM2.K'.elim_update_main
-/- warning: turing.partrec_to_TM2.K'.elim_update_rev -> Turing.PartrecToTM2.K'.elim_update_rev is a dubious translation:
-lean 3 declaration is
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {b' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.rev b') (Turing.PartrecToTM2.K'.elim a b' c d)
-but is expected to have type
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {b' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.rev b') (Turing.PartrecToTM2.K'.elim a b' c d)
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_rev Turing.PartrecToTM2.K'.elim_update_revₓ'. -/
@[simp]
theorem K'.elim_update_rev {a b c d b'} : update (K'.elim a b c d) rev b' = K'.elim a b' c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_rev Turing.PartrecToTM2.K'.elim_update_rev
-/- warning: turing.partrec_to_TM2.K'.elim_update_aux -> Turing.PartrecToTM2.K'.elim_update_aux is a dubious translation:
-lean 3 declaration is
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {c' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.aux c') (Turing.PartrecToTM2.K'.elim a b c' d)
-but is expected to have type
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {c' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.aux c') (Turing.PartrecToTM2.K'.elim a b c' d)
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_aux Turing.PartrecToTM2.K'.elim_update_auxₓ'. -/
@[simp]
theorem K'.elim_update_aux {a b c d c'} : update (K'.elim a b c d) aux c' = K'.elim a b c' d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_aux Turing.PartrecToTM2.K'.elim_update_aux
-/- warning: turing.partrec_to_TM2.K'.elim_update_stack -> Turing.PartrecToTM2.K'.elim_update_stack is a dubious translation:
-lean 3 declaration is
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {d' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.stack d') (Turing.PartrecToTM2.K'.elim a b c d')
-but is expected to have type
- forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {d' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.stack d') (Turing.PartrecToTM2.K'.elim a b c d')
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_stack Turing.PartrecToTM2.K'.elim_update_stackₓ'. -/
@[simp]
theorem K'.elim_update_stack {a b c d d'} : update (K'.elim a b c d) stack d' = K'.elim a b c d' :=
by funext x <;> cases x <;> rfl
@@ -1967,12 +1871,6 @@ theorem codeSupp_fix (f k) :
#align turing.partrec_to_TM2.code_supp_fix Turing.PartrecToTM2.codeSupp_fix
-/
-/- warning: turing.partrec_to_TM2.cont_supp_cons₁ -> Turing.PartrecToTM2.contSupp_cons₁ is a dubious translation:
-lean 3 declaration is
- forall (fs : Turing.ToPartrec.Code) (k : Turing.PartrecToTM2.Cont'), Eq.{1} (Finset.{0} Turing.PartrecToTM2.Λ') (Turing.PartrecToTM2.contSupp (Turing.PartrecToTM2.Cont'.cons₁ fs k)) (Union.union.{0} (Finset.{0} Turing.PartrecToTM2.Λ') (Finset.hasUnion.{0} Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b)) (Turing.PartrecToTM2.trStmts₁ (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.main Turing.PartrecToTM2.K'.aux (Turing.PartrecToTM2.move₂ (fun (s : Turing.PartrecToTM2.Γ') => Decidable.decide (Eq.{1} Turing.PartrecToTM2.Γ' s Turing.PartrecToTM2.Γ'.consₗ) (Turing.PartrecToTM2.Γ'.decidableEq s Turing.PartrecToTM2.Γ'.consₗ)) Turing.PartrecToTM2.K'.stack Turing.PartrecToTM2.K'.main (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.aux Turing.PartrecToTM2.K'.stack (Turing.PartrecToTM2.trNormal fs (Turing.PartrecToTM2.Cont'.cons₂ k)))))) (Turing.PartrecToTM2.codeSupp fs (Turing.PartrecToTM2.Cont'.cons₂ k)))
-but is expected to have type
- forall (fs : Turing.ToPartrec.Code) (k : Turing.PartrecToTM2.Cont'), Eq.{1} (Finset.{0} Turing.PartrecToTM2.Λ') (Turing.PartrecToTM2.contSupp (Turing.PartrecToTM2.Cont'.cons₁ fs k)) (Union.union.{0} (Finset.{0} Turing.PartrecToTM2.Λ') (Finset.instUnionFinset.{0} Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b)) (Turing.PartrecToTM2.trStmts₁ (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.main Turing.PartrecToTM2.K'.aux (Turing.PartrecToTM2.move₂ (fun (s : Turing.PartrecToTM2.Γ') => Decidable.decide (Eq.{1} Turing.PartrecToTM2.Γ' s Turing.PartrecToTM2.Γ'.consₗ) (Turing.PartrecToTM2.instDecidableEqΓ' s Turing.PartrecToTM2.Γ'.consₗ)) Turing.PartrecToTM2.K'.stack Turing.PartrecToTM2.K'.main (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.aux Turing.PartrecToTM2.K'.stack (Turing.PartrecToTM2.trNormal fs (Turing.PartrecToTM2.Cont'.cons₂ k)))))) (Turing.PartrecToTM2.codeSupp fs (Turing.PartrecToTM2.Cont'.cons₂ k)))
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.cont_supp_cons₁ Turing.PartrecToTM2.contSupp_cons₁ₓ'. -/
@[simp]
theorem contSupp_cons₁ (fs k) :
contSupp (Cont'.cons₁ fs k) =
@@ -2058,12 +1956,6 @@ theorem supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K
#align turing.partrec_to_TM2.supports_union Turing.PartrecToTM2.supports_union
-/
-/- warning: turing.partrec_to_TM2.supports_bUnion -> Turing.PartrecToTM2.supports_biUnion is a dubious translation:
-lean 3 declaration is
- forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.biUnion.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (Option.fintype.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.Γ'.fintype)) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
-but is expected to have type
- forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.biUnion.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (instFintypeOption.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.instFintypeΓ')) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_biUnionₓ'. -/
theorem supports_biUnion {K : Option Γ' → Finset Λ'} {S} :
Supports (Finset.univ.biUnion K) S ↔ ∀ a, Supports (K a) S := by
simp [supports] <;> apply forall_swap
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -294,14 +294,11 @@ theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
∃ c : code, ∀ v : Vector ℕ m, c.eval v.1 = Subtype.val <$> Vector.mOfFn fun i => g i v
· obtain ⟨cf, hf⟩ := hf
exact
- ⟨cf.comp cg, fun v =>
- by
- simp [hg, hf, map_bind, seq_bind_eq, (· ∘ ·), -Subtype.val_eq_coe]
+ ⟨cf.comp cg, fun v => by simp [hg, hf, map_bind, seq_bind_eq, (· ∘ ·), -Subtype.val_eq_coe];
rfl⟩
clear hf f; induction' n with n IH
· exact ⟨nil, fun v => by simp [Vector.mOfFn] <;> rfl⟩
- · obtain ⟨cg, hg₁⟩ := hg 0
- obtain ⟨cl, hl⟩ := IH fun i => hg i.succ
+ · obtain ⟨cg, hg₁⟩ := hg 0; obtain ⟨cl, hl⟩ := IH fun i => hg i.succ
exact
⟨cons cg cl, fun v =>
by
@@ -353,13 +350,10 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
exact ⟨c.comp tail, fun v => by simpa [← Vector.get_tail] using h v.tail⟩
case prim.comp m n f g hf hg IHf IHg => simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg
case prim.prec n f g hf hg IHf IHg =>
- obtain ⟨cf, hf⟩ := IHf
- obtain ⟨cg, hg⟩ := IHg
+ obtain ⟨cf, hf⟩ := IHf; obtain ⟨cg, hg⟩ := IHg
simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
- refine' ⟨prec cf cg, fun v => _⟩
- rw [← v.cons_head_tail]
- specialize hf v.tail
- replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
+ refine' ⟨prec cf cg, fun v => _⟩; rw [← v.cons_head_tail]
+ specialize hf v.tail; replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
simp only [Vector.cons_val, Vector.tail_val] at hf hg
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons,
PFun.coe_val, Vector.tail_val]
@@ -383,15 +377,11 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
else Sum.inr (v::v::x.headI::v))
(a::b::Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a::v.val.tail)
by
- rw [(_ : PFun.fix _ _ = pure _)]
- swap
- exact Part.eq_some_iff.2 (this 0 n (zero_add n))
+ rw [(_ : PFun.fix _ _ = pure _)]; swap; exact Part.eq_some_iff.2 (this 0 n (zero_add n))
simp only [List.headI, pure_bind, List.tail_cons]
- intro a b e
- induction' b with b IH generalizing a e
+ intro a b e; induction' b with b IH generalizing a e
· refine' PFun.mem_fix_iff.2 (Or.inl <| Part.eq_some_iff.1 _)
- simp only [hg, ← e, pure_bind, List.tail_cons]
- rfl
+ simp only [hg, ← e, pure_bind, List.tail_cons]; rfl
· refine' PFun.mem_fix_iff.2 (Or.inr ⟨_, _, IH (a + 1) (by rwa [add_right_comm])⟩)
simp only [hg, eval, pure_bind, Nat.rec_add_one, List.tail]
exact Part.mem_some_iff.2 rfl
@@ -424,23 +414,18 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
∃ a : ℕ,
(f (a ::ᵥ v) = 0 ∧ ∀ {m : ℕ}, m < a → ¬f (m ::ᵥ v) = 0) ∧ [a] = [v'.head.pred]
by exact this _ h1 0 rfl (by rintro _ ⟨⟩)
- clear h1
- intro v₀ h1
- refine' PFun.fixInduction h1 fun v₁ h2 IH => _
- clear h1
+ clear h1; intro v₀ h1
+ refine' PFun.fixInduction h1 fun v₁ h2 IH => _; clear h1
rintro n rfl hm
have := PFun.mem_fix_iff.1 h2
simp only [hf, Part.bind_some] at this
split_ifs at this
· simp only [List.headI, exists_false, or_false_iff, Part.mem_some_iff, List.tail_cons,
false_and_iff] at this
- subst this
- exact ⟨_, ⟨h, hm⟩, rfl⟩
+ subst this; exact ⟨_, ⟨h, hm⟩, rfl⟩
· refine' IH (n.succ::v.val) (by simp_all) _ rfl fun m h' => _
- obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'
- exacts[hm _ h, h]
- · rintro ⟨n, ⟨hn, hm⟩, rfl⟩
- refine' ⟨n.succ::v.1, _, rfl⟩
+ obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'; exacts[hm _ h, h]
+ · rintro ⟨n, ⟨hn, hm⟩, rfl⟩; refine' ⟨n.succ::v.1, _, rfl⟩
have :
(n.succ::v.1 : List ℕ) ∈
PFun.fix
@@ -451,10 +436,8 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
else Sum.inr (v.head.succ::v.tail))
(n::v.val) :=
PFun.mem_fix_iff.2 (Or.inl (by simp [hf, hn, -Subtype.val_eq_coe]))
- generalize (n.succ::v.1 : List ℕ) = w at this⊢
- clear hn
- induction' n with n IH
- · exact this
+ generalize (n.succ::v.1 : List ℕ) = w at this⊢; clear hn
+ induction' n with n IH; · exact this
refine' IH (fun m h' => hm (Nat.lt_succ_of_lt h')) (PFun.mem_fix_iff.2 (Or.inr ⟨_, _, this⟩))
simp only [hf, hm n.lt_succ_self, Part.bind_some, List.headI, eq_self_iff_true, if_false,
Part.mem_some_iff, and_self_iff, List.tail_cons]
@@ -674,13 +657,9 @@ embedded machine reaches the halt state. -/
theorem stepRet_then {k k' : Cont} {v} : stepRet (k.then k') v = (stepRet k v).then k' :=
by
induction k generalizing v <;> simp only [cont.then, step_ret, cfg.then, *]
+ · rw [← step_normal_then]; rfl
· rw [← step_normal_then]
- rfl
- · rw [← step_normal_then]
- · split_ifs
- · rw [← k_ih]
- · rw [← step_normal_then]
- rfl
+ · split_ifs; · rw [← k_ih]; · rw [← step_normal_then]; rfl
#align turing.to_partrec.step_ret_then Turing.ToPartrec.stepRet_then
-/
@@ -751,26 +730,20 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
refine' ⟨v₂, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some]
split_ifs at hv₂⊢
- · rw [Part.mem_some_iff.1 hv₂]
- exact Or.inl (Part.mem_some _)
+ · rw [Part.mem_some_iff.1 hv₂]; exact Or.inl (Part.mem_some _)
· exact Or.inr ⟨_, Part.mem_some _, hv₂⟩
refine' fun c he => eval_induction he fun y h IH => _
rintro v (⟨v'⟩ | ⟨k', v'⟩) rfl hr <;> rw [cfg.then] at h IH
· have := mem_eval.2 ⟨hr, rfl⟩
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff] at this
obtain ⟨v'', h₁, h₂⟩ := this
- rw [reaches_eval] at h₂
- swap
- exact refl_trans_gen.single rfl
+ rw [reaches_eval] at h₂; swap; exact refl_trans_gen.single rfl
cases Part.mem_unique h₂ (mem_eval.2 ⟨refl_trans_gen.refl, rfl⟩)
- refine' ⟨v', h₁, _⟩
- rw [step_ret] at h
- revert h
+ refine' ⟨v', h₁, _⟩; rw [step_ret] at h
+ revert h;
by_cases he : v'.head = 0 <;> simp only [exists_prop, if_pos, if_false, he] <;> intro h
· refine' ⟨_, Part.mem_some _, _⟩
- rw [reaches_eval]
- exact h
- exact refl_trans_gen.single rfl
+ rw [reaches_eval]; exact h; exact refl_trans_gen.single rfl
· obtain ⟨k₀, v₀, e₀⟩ := step_normal.is_ret f cont.halt v'.tail
have e₁ := step_normal_then f cont.halt (cont.fix f k) v'.tail
rw [e₀, cont.then, cfg.then] at e₁
@@ -779,33 +752,22 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
split_ifs at hv₂⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);exact Or.inr ⟨_, rfl, hv₂⟩]
- · rw [step_ret, if_neg he, e₁]
- rfl
- · apply refl_trans_gen.single
- rw [e₀]
- exact rfl
+ · rw [step_ret, if_neg he, e₁]; rfl
+ · apply refl_trans_gen.single; rw [e₀]; exact rfl
· exact IH _ rfl _ _ step_ret_then (refl_trans_gen.tail hr rfl)
· rintro ⟨v', he, hr⟩
- rw [reaches_eval] at hr
- swap
- exact refl_trans_gen.single rfl
+ rw [reaches_eval] at hr; swap; exact refl_trans_gen.single rfl
refine' PFun.fixInduction he fun v (he : v' ∈ f.fix.eval v) IH => _
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff]
obtain he | ⟨v'', he₁', _⟩ := PFun.mem_fix_iff.1 he
- · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he
- split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v', he₁, he₂⟩ := (Part.mem_map_iff _).1 he; split_ifs at he₂ <;> cases he₂
refine' ⟨_, he₁, _⟩
- rw [reaches_eval]
- swap
- exact refl_trans_gen.single rfl
+ rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rwa [step_ret, if_pos h]
- · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'
- split_ifs at he₂ <;> cases he₂
+ · obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'; split_ifs at he₂ <;> cases he₂
clear he₂ he₁'
refine' ⟨_, he₁, _⟩
- rw [reaches_eval]
- swap
- exact refl_trans_gen.single rfl
+ rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rwa [step_ret, if_neg h]
exact IH v₁.tail ((Part.mem_map_iff _).2 ⟨_, he₁, if_neg h⟩)
#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fix
@@ -1445,11 +1407,9 @@ theorem splitAtPred_eq {α} (p : α → Bool) :
have IH := split_at_pred_eq L
cases o
· cases' l₁ with a' l₁ <;> rcases h₂ with ⟨⟨⟩, rfl⟩
- rw [h₁ a (Or.inl rfl), cond, IH L none [] _ ⟨rfl, rfl⟩]
- rfl
+ rw [h₁ a (Or.inl rfl), cond, IH L none [] _ ⟨rfl, rfl⟩]; rfl
exact fun x h => h₁ x (Or.inr h)
- · cases' l₁ with a' l₁ <;> rcases h₂ with ⟨h₂, ⟨⟩⟩
- · rw [h₂, cond]
+ · cases' l₁ with a' l₁ <;> rcases h₂ with ⟨h₂, ⟨⟩⟩; · rw [h₂, cond]
rw [h₁ a (Or.inl rfl), cond, IH l₁ (some o) l₂ _ ⟨h₂, _⟩] <;> try rfl
exact fun x h => h₁ x (Or.inr h)
#align turing.partrec_to_TM2.split_at_pred_eq Turing.PartrecToTM2.splitAtPred_eq
@@ -1470,30 +1430,17 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
by
induction' L₁ with a L₁ IH generalizing S s
· rw [(_ : [].reverseAux _ = _), Function.update_eq_self]
- swap
- · rw [Function.update_noteq h₁.symm]
- rfl
+ swap; · rw [Function.update_noteq h₁.symm]; rfl
refine' trans_gen.head' rfl _
- simp
- cases' S k₁ with a Sk
- · cases e
- rfl
+ simp; cases' S k₁ with a Sk; · cases e; rfl
simp [split_at_pred] at e⊢
cases p a <;> simp at e⊢
- · revert e
- rcases split_at_pred p Sk with ⟨_, _, _⟩
- rintro ⟨⟩
+ · revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
- · refine' trans_gen.head rfl _
- simp
- cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e
- · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e
- swap
- · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩
- rw [e₃, split_at_pred] at e
- cases e
+ · refine' trans_gen.head rfl _; simp
+ cases' e₁ : S k₁ with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
simp [e₂]
convert@IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
@@ -1538,26 +1485,15 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
by
induction' L₁ with a L₁ IH generalizing S s
· refine' trans_gen.head' rfl _
- simp
- cases' S k with a Sk
- · cases e
- rfl
+ simp; cases' S k with a Sk; · cases e; rfl
simp [split_at_pred] at e⊢
cases p a <;> simp at e⊢
- · revert e
- rcases split_at_pred p Sk with ⟨_, _, _⟩
- rintro ⟨⟩
+ · revert e; rcases split_at_pred p Sk with ⟨_, _, _⟩; rintro ⟨⟩
· simp only [e]
- · refine' trans_gen.head rfl _
- simp
- cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e
- · cases e
- cases e₂ : p a' <;> simp only [e₂, cond] at e
- swap
- · cases e
- rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩
- rw [e₃, split_at_pred] at e
- cases e
+ · refine' trans_gen.head rfl _; simp
+ cases' e₁ : S k with a' Sk <;> rw [e₁, split_at_pred] at e; · cases e
+ cases e₂ : p a' <;> simp only [e₂, cond] at e; swap; · cases e
+ rcases e₃ : split_at_pred p Sk with ⟨_, _, _⟩; rw [e₃, split_at_pred] at e; cases e
simp [e₂]
convert@IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
@@ -1569,9 +1505,7 @@ theorem copy_ok (q s a b c d) :
⟨some q, none, K'.elim (List.reverseAux b a) [] c (List.reverseAux b d)⟩ :=
by
induction' b with x b IH generalizing a d s
- · refine' trans_gen.single _
- simp
- rfl
+ · refine' trans_gen.single _; simp; rfl
refine' trans_gen.head rfl _; simp; exact IH _ _ _
#align turing.partrec_to_TM2.copy_ok Turing.PartrecToTM2.copy_ok
-/
@@ -1604,8 +1538,7 @@ theorem trList_ne_consₗ : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.consₗ
| a::l, x, h => by
simp [tr_list] at h
obtain h | rfl | h := h
- · rintro rfl
- cases tr_nat_nat_end _ _ h
+ · rintro rfl; cases tr_nat_nat_end _ _ h
· rintro ⟨⟩
· exact tr_list_ne_Cons l _ h
#align turing.partrec_to_TM2.tr_list_ne_Cons Turing.PartrecToTM2.trList_ne_consₗ
@@ -1645,9 +1578,7 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
(move_ok (by decide)
(split_at_pred_eq _ _ [] (some Γ'.Cons) L₃ (by rintro _ ⟨⟩) ⟨rfl, rfl⟩))
(trans_gen.head rfl (trans_gen.head rfl _))
- convert unrev_ok
- simp
- rfl
+ convert unrev_ok; simp; rfl
· refine'
trans_gen.trans
(move_ok (by decide)
@@ -1661,8 +1592,7 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
(split_at_pred_eq _ _ (tr_list L₂) (some Γ'.Cons) L₃
(fun x h => Bool.decide_false (tr_list_ne_Cons _ _ h)) ⟨rfl, by simp⟩))
_
- convert unrev_ok
- simp [List.reverseAux_eq]
+ convert unrev_ok; simp [List.reverseAux_eq]
#align turing.partrec_to_TM2.head_stack_ok Turing.PartrecToTM2.head_stack_ok
-/
@@ -1675,17 +1605,9 @@ theorem succ_ok {q s n} {c d : List Γ'} :
by
simp [tr_nat, Num.add_one]
cases' (n : Num) with a
- · refine' trans_gen.head rfl _
- simp
- rw [if_neg]
- swap
- rintro ⟨⟩
- rw [if_pos]
- swap
- rfl
- convert unrev_ok
- simp
- rfl
+ · refine' trans_gen.head rfl _; simp
+ rw [if_neg]; swap; rintro ⟨⟩; rw [if_pos]; swap; rfl
+ convert unrev_ok; simp; rfl
simp [Num.succ, tr_num, Num.succ']
suffices
∀ l₁,
@@ -1694,21 +1616,15 @@ theorem succ_ok {q s n} {c d : List Γ'} :
reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (tr_pos_num a ++ [Γ'.cons]) l₁ c d⟩
⟨some (unrev q), s', K'.elim (l₂' ++ [Γ'.cons]) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []
- simp [List.reverseAux] at e
- refine' h.trans _
- convert unrev_ok using 2
- simp [e, List.reverseAux_eq]
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit0::l₁, [Γ'.bit1], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
simp [tr_pos_num]
· obtain ⟨l₁', l₂', s', e, h⟩ := IH (Γ'.bit0::l₁)
- refine' ⟨l₁', l₂', s', e, trans_gen.head _ h⟩
- swap
+ refine' ⟨l₁', l₂', s', e, trans_gen.head _ h⟩; swap
simp [PosNum.succ, tr_pos_num]
- · refine' ⟨l₁, _, some Γ'.bit0, rfl, trans_gen.single _⟩
- simp
- rfl
+ · refine' ⟨l₁, _, some Γ'.bit0, rfl, trans_gen.single _⟩; simp; rfl
#align turing.partrec_to_TM2.succ_ok Turing.PartrecToTM2.succ_ok
-/
@@ -1727,19 +1643,12 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
⟨some q₂, s', K'.elim (trList (n::v.tail)) [] c d⟩) :=
by
rcases v with (_ | ⟨_ | n, v⟩)
- · refine' ⟨none, trans_gen.single _⟩
- simp
- rfl
- · refine' ⟨some Γ'.cons, trans_gen.single _⟩
- simp
- refine' ⟨none, _⟩
- simp [tr_nat, Num.add_one, Num.succ, tr_num]
+ · refine' ⟨none, trans_gen.single _⟩; simp; rfl
+ · refine' ⟨some Γ'.cons, trans_gen.single _⟩; simp
+ refine' ⟨none, _⟩; simp [tr_nat, Num.add_one, Num.succ, tr_num]
cases' (n : Num) with a
· simp [tr_pos_num, tr_num, show num.zero.succ' = PosNum.one from rfl]
- refine' trans_gen.head rfl _
- convert unrev_ok
- simp
- rfl
+ refine' trans_gen.head rfl _; convert unrev_ok; simp; rfl
simp [tr_num, Num.succ']
suffices
∀ l₁,
@@ -1749,18 +1658,13 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
⟨some (q₁.pred q₂), s, K'.elim (tr_pos_num a.succ ++ Γ'.cons::tr_list v) l₁ c d⟩
⟨some (unrev q₂), s', K'.elim (l₂' ++ Γ'.cons::tr_list v) l₁' c d⟩
by
- obtain ⟨l₁', l₂', s', e, h⟩ := this []
- simp [List.reverseAux] at e
- refine' h.trans _
- convert unrev_ok using 2
- simp [e, List.reverseAux_eq]
+ obtain ⟨l₁', l₂', s', e, h⟩ := this []; simp [List.reverseAux] at e
+ refine' h.trans _; convert unrev_ok using 2; simp [e, List.reverseAux_eq]
induction' a with m IH m IH generalizing s <;> intro l₁
· refine' ⟨Γ'.bit1::l₁, [], some Γ'.cons, rfl, trans_gen.head rfl (trans_gen.single _)⟩
simp [tr_pos_num, show pos_num.one.succ = pos_num.one.bit0 from rfl]
· obtain ⟨l₁', l₂', s', e, h⟩ := IH (some Γ'.bit0) (Γ'.bit1::l₁)
- refine' ⟨l₁', l₂', s', e, trans_gen.head _ h⟩
- simp
- rfl
+ refine' ⟨l₁', l₂', s', e, trans_gen.head _ h⟩; simp; rfl
· obtain ⟨a, l, e, h⟩ : ∃ a l, (tr_pos_num m = a::l) ∧ nat_end a = ff := by
cases m <;> refine' ⟨_, _, rfl, rfl⟩
refine' ⟨Γ'.bit0::l₁, _, some a, rfl, trans_gen.single _⟩
@@ -1796,10 +1700,8 @@ theorem trNormal_respects (c k v s) :
rw [step_normal]
obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
cases' v.head with n
- · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
- exact ⟨_, h₁, h.trans h₂⟩
- · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
- exact ⟨_, h₁, h.trans h₂⟩
+ · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'; exact ⟨_, h₁, h.trans h₂⟩
+ · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'; exact ⟨_, h₁, h.trans h₂⟩
case fix f IH => apply IH
#align turing.partrec_to_TM2.tr_normal_respects Turing.PartrecToTM2.trNormal_respects
-/
@@ -1842,21 +1744,16 @@ theorem tr_ret_respects (k v s) :
nat_end (tr_list v).head?.iget = ff ∧
(tr_list v).tail = (tr_nat v.head).tail ++ Γ'.cons::tr_list v.tail :=
by
- cases' v with n
- · exact ⟨rfl, rfl⟩
- cases n
- · simp
+ cases' v with n; · exact ⟨rfl, rfl⟩; cases n; · simp
rw [tr_list, List.headI, tr_nat, Nat.cast_succ, Num.add_one, Num.succ, List.tail]
cases (n : Num).succ' <;> exact ⟨rfl, rfl⟩
by_cases v.head = 0 <;> simp [h] at this⊢
· obtain ⟨c, h₁, h₂⟩ := IH v.tail (tr_list v).head?
refine' ⟨c, h₁, trans_gen.head rfl _⟩
- simp [tr_cont, tr_cont_stack, this]
- exact h₂
+ simp [tr_cont, tr_cont_stack, this]; exact h₂
· obtain ⟨s', h₁, h₂⟩ := tr_normal_respects f (cont.fix f k) v.tail (some Γ'.cons)
refine' ⟨_, h₁, trans_gen.head rfl <| trans_gen.trans _ h₂⟩
- pick_goal 3
- simp [tr_cont, this.1]
+ pick_goal 3; simp [tr_cont, this.1]
convert clear_ok (split_at_pred_eq _ _ (tr_nat v.head).tail (some Γ'.cons) _ _ _) using 2
· simp
· exact fun x h => tr_nat_nat_end _ _ (List.tail_subset _ h)
@@ -1925,16 +1822,10 @@ theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trSt
simp (config := { contextual := true }) only [tr_stmts₁, Finset.mem_insert, Finset.mem_union,
or_imp, Finset.mem_singleton, Finset.Subset.refl, imp_true_iff, true_and_iff]
iterate 4 exact fun h => Finset.Subset.trans (q_ih h) (Finset.subset_insert _ _)
- · simp
- intro s h x h'
- simp
- exact Or.inr ⟨_, q_ih s h h'⟩
+ · simp; intro s h x h'; simp; exact Or.inr ⟨_, q_ih s h h'⟩
· constructor
- · rintro rfl
- apply Finset.subset_insert
- · intro h x h'
- simp
- exact Or.inr (Or.inr <| q_ih h h')
+ · rintro rfl; apply Finset.subset_insert
+ · intro h x h'; simp; exact Or.inr (Or.inr <| q_ih h h')
· refine' ⟨fun h x h' => _, fun h x h' => _, fun h x h' => _⟩ <;> simp
· exact Or.inr (Or.inr <| Or.inl <| q_ih_q₁ h h')
· cases' Finset.mem_insert.1 h' with h' h' <;> simp [h', unrev]
mathlib commit https://github.com/leanprover-community/mathlib/commit/8d33f09cd7089ecf074b4791907588245aec5d1b
@@ -638,7 +638,7 @@ theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.
by
induction k generalizing v <;> simp only [cont.eval, cont.then, bind_assoc, pure_bind, *]
· simp only [← k_ih]
- · split_ifs <;> [rfl, simp only [← k_ih, bind_assoc]]
+ · split_ifs <;> [rfl;simp only [← k_ih, bind_assoc]]
#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_eval
#print Turing.ToPartrec.Cfg.then /-
@@ -718,7 +718,7 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
case cons f fs IHf IHfs => apply IHf
case comp f g IHf IHg => apply IHg
case case f g IHf IHg => rw [step_normal];
- cases v.head <;> simp only [Nat.rec] <;> [apply IHf, apply IHg]
+ cases v.head <;> simp only [Nat.rec] <;> [apply IHf;apply IHg]
case fix f IHf => apply IHf
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
-/
@@ -778,8 +778,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
IH (step_ret (k₀.then (cont.fix f k)) v₀) _ v'.tail _ step_ret_then _
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
- split_ifs at hv₂⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂),
- exact Or.inr ⟨_, rfl, hv₂⟩]
+ split_ifs at hv₂⊢ <;> [exact Or.inl (Part.mem_some_iff.1 hv₂);exact Or.inr ⟨_, rfl, hv₂⟩]
· rw [step_ret, if_neg he, e₁]
rfl
· apply refl_trans_gen.single
@@ -828,7 +827,7 @@ theorem code_is_ok (c) : Code.Ok c :=
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rw [step_ret, IHf]
case case f g IHf IHg => simp only [code.eval];
- cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf, apply IHg]
+ cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf;apply IHg]
case fix f IHf => rw [cont_eval_fix IHf]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/e3fb84046afd187b710170887195d50bada934ee
@@ -1910,7 +1910,7 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
def trStmts₁ : Λ' → Finset Λ'
| Q@(Λ'.move p k₁ k₂ q) => insert Q <| tr_stmts₁ q
| Q@(Λ'.push k f q) => insert Q <| tr_stmts₁ q
- | Q@(Λ'.read q) => insert Q <| Finset.univ.bunionᵢ fun s => tr_stmts₁ (q s)
+ | Q@(Λ'.read q) => insert Q <| Finset.univ.biUnion fun s => tr_stmts₁ (q s)
| Q@(Λ'.clear p k q) => insert Q <| tr_stmts₁ q
| Q@(Λ'.copy q) => insert Q <| tr_stmts₁ q
| Q@(Λ'.succ q) => insert Q <| insert (unrev q) <| tr_stmts₁ q
@@ -2168,16 +2168,16 @@ theorem supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K
#align turing.partrec_to_TM2.supports_union Turing.PartrecToTM2.supports_union
-/
-/- warning: turing.partrec_to_TM2.supports_bUnion -> Turing.PartrecToTM2.supports_bunionᵢ is a dubious translation:
+/- warning: turing.partrec_to_TM2.supports_bUnion -> Turing.PartrecToTM2.supports_biUnion is a dubious translation:
lean 3 declaration is
- forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.bunionᵢ.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (Option.fintype.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.Γ'.fintype)) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
+ forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.biUnion.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (Option.fintype.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.Γ'.fintype)) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
but is expected to have type
- forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.bunionᵢ.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (instFintypeOption.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.instFintypeΓ')) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
-Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_bunionᵢₓ'. -/
-theorem supports_bunionᵢ {K : Option Γ' → Finset Λ'} {S} :
- Supports (Finset.univ.bunionᵢ K) S ↔ ∀ a, Supports (K a) S := by
+ forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.biUnion.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (instFintypeOption.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.instFintypeΓ')) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_biUnionₓ'. -/
+theorem supports_biUnion {K : Option Γ' → Finset Λ'} {S} :
+ Supports (Finset.univ.biUnion K) S ↔ ∀ a, Supports (K a) S := by
simp [supports] <;> apply forall_swap
-#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_bunionᵢ
+#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_biUnion
#print Turing.PartrecToTM2.head_supports /-
theorem head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S := fun _ => by
mathlib commit https://github.com/leanprover-community/mathlib/commit/403190b5419b3f03f1a2893ad9352ca7f7d8bff6
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
! This file was ported from Lean 3 source module computability.tm_to_partrec
-! leanprover-community/mathlib commit 6155d4351090a6fad236e3d2e4e0e4e7342668e8
+! leanprover-community/mathlib commit bd15ff41b70f5e2cc210f26f25a8d5c53b20d3de
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -16,6 +16,9 @@ import Mathbin.Tactic.DeriveFintype
/-!
# Modelling partial recursive functions using Turing machines
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
This file defines a simplified basis for partial recursive functions, and a `turing.TM2` model
Turing machine for evaluating these functions. This amounts to a constructive proof that every
`partrec` function can be evaluated by a Turing machine.
mathlib commit https://github.com/leanprover-community/mathlib/commit/28b2a92f2996d28e580450863c130955de0ed398
@@ -73,6 +73,7 @@ evaluator for this basis, which we take up in the next section.
namespace ToPartrec
+#print Turing.ToPartrec.Code /-
/-- The type of codes for primitive recursive functions. Unlike `nat.partrec.code`, this uses a set
of operations on `list ℕ`. See `code.eval` for a description of the behavior of the primitives. -/
inductive Code
@@ -85,10 +86,12 @@ inductive Code
| fix : code → code
deriving DecidableEq, Inhabited
#align turing.to_partrec.code Turing.ToPartrec.Code
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.ToPartrec.Code.eval /-
/-- The semantics of the `code` primitives, as partial functions `list ℕ →. list ℕ`. By convention
we functions that return a single result return a singleton `[n]`, or in some cases `n :: v` where
`v` will be ignored by a subsequent function.
@@ -129,56 +132,98 @@ def Code.eval : Code → List ℕ →. List ℕ
| code.fix f =>
PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail
#align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval
+-/
namespace Code
+#print Turing.ToPartrec.Code.nil /-
/-- `nil` is the constant nil function: `nil v = []`. -/
def nil : Code :=
tail.comp succ
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
+-/
+/- warning: turing.to_partrec.code.nil_eval -> Turing.ToPartrec.Code.nil_eval is a dubious translation:
+lean 3 declaration is
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.nil v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.nil.{0} Nat))
+but is expected to have type
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.nil v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.nil.{0} Nat))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_evalₓ'. -/
@[simp]
theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil]
#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval
+#print Turing.ToPartrec.Code.id /-
/-- `id` is the identity function: `id v = v`. -/
def id : Code :=
tail.comp zero'
#align turing.to_partrec.code.id Turing.ToPartrec.Code.id
+-/
+/- warning: turing.to_partrec.code.id_eval -> Turing.ToPartrec.Code.id_eval is a dubious translation:
+lean 3 declaration is
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.id v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) v)
+but is expected to have type
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.id v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) v)
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_evalₓ'. -/
@[simp]
theorem id_eval (v) : id.eval v = pure v := by simp [id]
#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval
+#print Turing.ToPartrec.Code.head /-
/-- `head` gets the head of the input list: `head [] = [0]`, `head (n :: v) = [n]`. -/
def head : Code :=
cons id nil
#align turing.to_partrec.code.head Turing.ToPartrec.Code.head
+-/
+/- warning: turing.to_partrec.code.head_eval -> Turing.ToPartrec.Code.head_eval is a dubious translation:
+lean 3 declaration is
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.head v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (List.headI.{0} Nat Nat.inhabited v) (List.nil.{0} Nat)))
+but is expected to have type
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.head v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (List.headI.{0} Nat instInhabitedNat v) (List.nil.{0} Nat)))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_evalₓ'. -/
@[simp]
theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head]
#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval
+#print Turing.ToPartrec.Code.zero /-
/-- `zero` is the constant zero function: `zero v = [0]`. -/
def zero : Code :=
cons zero' nil
#align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero
+-/
+/- warning: turing.to_partrec.code.zero_eval -> Turing.ToPartrec.Code.zero_eval is a dubious translation:
+lean 3 declaration is
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.zero v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (List.nil.{0} Nat)))
+but is expected to have type
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.zero v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (List.nil.{0} Nat)))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_evalₓ'. -/
@[simp]
theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero]
#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval
+#print Turing.ToPartrec.Code.pred /-
/-- `pred` returns the predecessor of the head of the input:
`pred [] = [0]`, `pred (0 :: v) = [0]`, `pred (n+1 :: v) = [n]`. -/
def pred : Code :=
case zero head
#align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred
+-/
+/- warning: turing.to_partrec.code.pred_eval -> Turing.ToPartrec.Code.pred_eval is a dubious translation:
+lean 3 declaration is
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.pred v) (Pure.pure.{0, 0} Part.{0} (Applicative.toHasPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) (List.cons.{0} Nat (Nat.pred (List.headI.{0} Nat Nat.inhabited v)) (List.nil.{0} Nat)))
+but is expected to have type
+ forall (v : List.{0} Nat), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval Turing.ToPartrec.Code.pred v) (Pure.pure.{0, 0} Part.{0} (Applicative.toPure.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) (List.cons.{0} Nat (Nat.pred (List.headI.{0} Nat instInhabitedNat v)) (List.nil.{0} Nat)))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_evalₓ'. -/
@[simp]
theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by
simp [pred] <;> cases v.head <;> simp
#align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_eval
+#print Turing.ToPartrec.Code.rfind /-
/-- `rfind f` performs the function of the `rfind` primitive of partial recursive functions.
`rfind f v` returns the smallest `n` such that `(f (n :: v)).head = 0`.
@@ -193,7 +238,9 @@ it calls `f (n :: v)` as the exit test and `n+1 :: v` as the next state. At the
def rfind (f : Code) : Code :=
comp pred <| comp (fix <| cons f <| cons succ tail) zero'
#align turing.to_partrec.code.rfind Turing.ToPartrec.Code.rfind
+-/
+#print Turing.ToPartrec.Code.prec /-
/-- `prec f g` implements the `prec` (primitive recursion) operation of partial recursive
functions. `prec f g` evaluates as:
@@ -225,10 +272,17 @@ def prec (f g : Code) : Code :=
let F := case id <| comp (comp (comp tail tail) (fix G)) zero'
cons (comp F (cons head <| cons (comp f tail) tail)) nil
#align turing.to_partrec.code.prec Turing.ToPartrec.Code.prec
+-/
attribute [-simp] Part.bind_eq_bind Part.map_eq_map Part.pure_eq_some
-theorem ExistsCode.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ}
+/- warning: turing.to_partrec.code.exists_code.comp -> Turing.ToPartrec.Code.exists_code.comp is a dubious translation:
+lean 3 declaration is
+ forall {m : Nat} {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat} {g : (Fin n) -> (PFun.{0, 0} (Vector.{0} Nat m) Nat)}, (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (f v)))) -> (forall (i : Fin n), Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (g i v)))) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (Vector.{0} Nat n) Nat (Vector.mOfFn.{0, 0} Part.{0} Part.monad.{0} Nat n (fun (i : Fin n) => g i v)) f))))
+but is expected to have type
+ forall {m : Nat} {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat} {g : (Fin n) -> (PFun.{0, 0} (Vector.{0} Nat m) Nat)}, (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (f v)))) -> (forall (i : Fin n), Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (g i v)))) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat m), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) m) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (Vector.{0} Nat n) Nat (Vector.mOfFn.{0, 0} Part.{0} Part.instMonadPart.{0} Nat n (fun (i : Fin n) => g i v)) f))))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.compₓ'. -/
+theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ}
(hf : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v)
(hg : ∀ i, ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> g i v) :
∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> ((Vector.mOfFn fun i => g i v) >>= f) :=
@@ -251,8 +305,14 @@ theorem ExistsCode.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
simp [Vector.mOfFn, hg₁, map_bind, seq_bind_eq, bind_assoc, (· ∘ ·), hl,
-Subtype.val_eq_coe]
rfl⟩
-#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.ExistsCode.comp
-
+#align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.comp
+
+/- warning: turing.to_partrec.code.exists_code -> Turing.ToPartrec.Code.exists_code is a dubious translation:
+lean 3 declaration is
+ forall {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat}, (Nat.Partrec' n f) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toHasPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.monad.{0})) Nat) (f v))))
+but is expected to have type
+ forall {n : Nat} {f : PFun.{0, 0} (Vector.{0} Nat n) Nat}, (Nat.Partrec' n f) -> (Exists.{1} Turing.ToPartrec.Code (fun (c : Turing.ToPartrec.Code) => forall (v : Vector.{0} Nat n), Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Code.eval c (Subtype.val.{1} (List.{0} Nat) (fun (l : List.{0} Nat) => Eq.{1} Nat (List.length.{0} Nat l) n) v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) Nat (List.{0} Nat) (Pure.pure.{0, 0} List.{0} (Applicative.toPure.{0, 0} List.{0} (Monad.toApplicative.{0, 0} List.{0} List.instMonadList.{0})) Nat) (f v))))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.exists_code Turing.ToPartrec.Code.exists_codeₓ'. -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -436,6 +496,7 @@ to `v'` in finitely many steps if and only if `code.eval c v = some v'`.
-/
+#print Turing.ToPartrec.Cont /-
/-- The type of continuations, built up during evaluation of a `code` expression. -/
inductive Cont
| halt
@@ -445,9 +506,11 @@ inductive Cont
| fix : Code → cont → cont
deriving Inhabited
#align turing.to_partrec.cont Turing.ToPartrec.Cont
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.ToPartrec.Cont.eval /-
/-- The semantics of a continuation. -/
def Cont.eval : Cont → List ℕ →. List ℕ
| cont.halt => pure
@@ -458,7 +521,9 @@ def Cont.eval : Cont → List ℕ →. List ℕ
| cont.comp f k => fun v => Code.eval f v >>= cont.eval k
| cont.fix f k => fun v => if v.headI = 0 then k.eval v.tail else f.fix.eval v.tail >>= k.eval
#align turing.to_partrec.cont.eval Turing.ToPartrec.Cont.eval
+-/
+#print Turing.ToPartrec.Cfg /-
/-- The set of configurations of the machine:
* `halt v`: The machine is about to stop and `v : list ℕ` is the result.
@@ -471,9 +536,11 @@ inductive Cfg
| ret : Cont → List ℕ → cfg
deriving Inhabited
#align turing.to_partrec.cfg Turing.ToPartrec.Cfg
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.ToPartrec.stepNormal /-
/-- Evaluating `c : code` in a continuation `k : cont` and input `v : list ℕ`. This goes by
recursion on `c`, building an augmented continuation and a value to pass to it.
@@ -500,8 +567,10 @@ def stepNormal : Code → Cont → List ℕ → Cfg
v.headI.elim (step_normal f k v.tail) fun y _ => step_normal g k (y::v.tail)
| code.fix f, k, v => step_normal f (Cont.fix f k) v
#align turing.to_partrec.step_normal Turing.ToPartrec.stepNormal
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.ToPartrec.stepRet /-
/-- Evaluating a continuation `k : cont` on input `v : list ℕ`. This is the second part of
evaluation, when we receive results from continuations built by `step_normal`.
@@ -522,7 +591,9 @@ def stepRet : Cont → List ℕ → Cfg
| cont.comp f k, v => stepNormal f k v
| cont.fix f k, v => if v.headI = 0 then step_ret k v.tail else stepNormal f (Cont.fix f k) v.tail
#align turing.to_partrec.step_ret Turing.ToPartrec.stepRet
+-/
+#print Turing.ToPartrec.step /-
/-- If we are not done (in `cfg.halt` state), then we must be still stuck on a continuation, so
this main loop calls `step_ret` with the new continuation. The overall `step` function transitions
from one `cfg` to another, only halting at the `cfg.halt` state. -/
@@ -530,7 +601,9 @@ def step : Cfg → Option Cfg
| cfg.halt _ => none
| cfg.ret k v => some (stepRet k v)
#align turing.to_partrec.step Turing.ToPartrec.step
+-/
+#print Turing.ToPartrec.Cont.then /-
/-- In order to extract a compositional semantics from the sequential execution behavior of
configurations, we observe that continuations have a monoid structure, with `cont.halt` as the unit
and `cont.then` as the multiplication. `cont.then k₁ k₂` runs `k₁` until it halts, and then takes
@@ -550,7 +623,14 @@ def Cont.then : Cont → Cont → Cont
| cont.comp f k, k' => Cont.comp f (k.then k')
| cont.fix f k, k' => Cont.fix f (k.then k')
#align turing.to_partrec.cont.then Turing.ToPartrec.Cont.then
+-/
+/- warning: turing.to_partrec.cont.then_eval -> Turing.ToPartrec.Cont.then_eval is a dubious translation:
+lean 3 declaration is
+ forall {k : Turing.ToPartrec.Cont} {k' : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Cont.eval (Turing.ToPartrec.Cont.then k k') v) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (List.{0} Nat) (List.{0} Nat) (Turing.ToPartrec.Cont.eval k v) (Turing.ToPartrec.Cont.eval k'))
+but is expected to have type
+ forall {k : Turing.ToPartrec.Cont} {k' : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} (List.{0} Nat)) (Turing.ToPartrec.Cont.eval (Turing.ToPartrec.Cont.then k k') v) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (List.{0} Nat) (List.{0} Nat) (Turing.ToPartrec.Cont.eval k v) (Turing.ToPartrec.Cont.eval k'))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_evalₓ'. -/
theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.eval :=
by
induction k generalizing v <;> simp only [cont.eval, cont.then, bind_assoc, pure_bind, *]
@@ -558,6 +638,7 @@ theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.
· split_ifs <;> [rfl, simp only [← k_ih, bind_assoc]]
#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_eval
+#print Turing.ToPartrec.Cfg.then /-
/-- The `then k` function is a "configuration homomorphism". Its operation on states is to append
`k` to the continuation of a `cfg.ret` state, and to run `k` on `v` if we are in the `cfg.halt v`
state. -/
@@ -565,8 +646,10 @@ def Cfg.then : Cfg → Cont → Cfg
| cfg.halt v, k' => stepRet k' v
| cfg.ret k v, k' => Cfg.ret (k.then k') v
#align turing.to_partrec.cfg.then Turing.ToPartrec.Cfg.then
+-/
/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:337:16: warning: unsupported simp config option: constructor_eq -/
+#print Turing.ToPartrec.stepNormal_then /-
/-- The `step_normal` function respects the `then k'` homomorphism. Note that this is an exact
equality, not a simulation; the original and embedded machines move in lock-step until the
embedded machine reaches the halt state. -/
@@ -579,7 +662,9 @@ theorem stepNormal_then (c) (k k' : Cont) (v) :
· cases v.head <;> simp only [Nat.rec]
case fix c ih => rw [← ih, cont.then]
#align turing.to_partrec.step_normal_then Turing.ToPartrec.stepNormal_then
+-/
+#print Turing.ToPartrec.stepRet_then /-
/-- The `step_ret` function respects the `then k'` homomorphism. Note that this is an exact
equality, not a simulation; the original and embedded machines move in lock-step until the
embedded machine reaches the halt state. -/
@@ -594,7 +679,9 @@ theorem stepRet_then {k k' : Cont} {v} : stepRet (k.then k') v = (stepRet k v).t
· rw [← step_normal_then]
rfl
#align turing.to_partrec.step_ret_then Turing.ToPartrec.stepRet_then
+-/
+#print Turing.ToPartrec.Code.Ok /-
/-- This is a temporary definition, because we will prove in `code_is_ok` that it always holds.
It asserts that `c` is semantically correct; that is, for any `k` and `v`,
`eval (step_normal c k v) = eval (cfg.ret k (code.eval c v))`, as an equality of partial values
@@ -605,7 +692,14 @@ evaluates to `cfg.halt (code.eval c v)`. -/
def Code.Ok (c : Code) :=
∀ k v, eval step (stepNormal c k v) = Code.eval c v >>= fun v => eval step (Cfg.ret k v)
#align turing.to_partrec.code.ok Turing.ToPartrec.Code.Ok
+-/
+/- warning: turing.to_partrec.code.ok.zero -> Turing.ToPartrec.Code.Ok.zero is a dubious translation:
+lean 3 declaration is
+ forall {c : Turing.ToPartrec.Code}, (Turing.ToPartrec.Code.Ok c) -> (forall {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v)))
+but is expected to have type
+ forall {c : Turing.ToPartrec.Code}, (Turing.ToPartrec.Code.Ok c) -> (forall {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v)))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zeroₓ'. -/
theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
eval step (stepNormal c Cont.halt v) = Cfg.halt <$> Code.eval c v :=
by
@@ -613,6 +707,7 @@ theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
exact Part.eq_some_iff.2 (mem_eval.2 ⟨refl_trans_gen.single rfl, rfl⟩)
#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zero
+#print Turing.ToPartrec.stepNormal.is_ret /-
theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v' :=
by
induction c generalizing k v
@@ -623,7 +718,14 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
cases v.head <;> simp only [Nat.rec] <;> [apply IHf, apply IHg]
case fix f IHf => apply IHf
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
+-/
+/- warning: turing.to_partrec.cont_eval_fix -> Turing.ToPartrec.cont_eval_fix is a dubious translation:
+lean 3 declaration is
+ forall {f : Turing.ToPartrec.Code} {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, (Turing.ToPartrec.Code.Ok f) -> (Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal f (Turing.ToPartrec.Cont.fix f k) v)) (Bind.bind.{0, 0} Part.{0} (Monad.toHasBind.{0, 0} Part.{0} Part.monad.{0}) (List.{0} Nat) Turing.ToPartrec.Cfg (Turing.ToPartrec.Code.eval (Turing.ToPartrec.Code.fix f) v) (fun (v : List.{0} Nat) => Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.Cfg.ret k v))))
+but is expected to have type
+ forall {f : Turing.ToPartrec.Code} {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, (Turing.ToPartrec.Code.Ok f) -> (Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal f (Turing.ToPartrec.Cont.fix f k) v)) (Bind.bind.{0, 0} Part.{0} (Monad.toBind.{0, 0} Part.{0} Part.instMonadPart.{0}) (List.{0} Nat) Turing.ToPartrec.Cfg (Turing.ToPartrec.Code.eval (Turing.ToPartrec.Code.fix f) v) (fun (v : List.{0} Nat) => Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.Cfg.ret k v))))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fixₓ'. -/
theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
eval step (stepNormal f (Cont.fix f k) v) = f.fix.eval v >>= fun v => eval step (Cfg.ret k v) :=
by
@@ -706,6 +808,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
exact IH v₁.tail ((Part.mem_map_iff _).2 ⟨_, he₁, if_neg h⟩)
#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fix
+#print Turing.ToPartrec.code_is_ok /-
theorem code_is_ok (c) : Code.Ok c :=
by
induction c <;> intro k v <;> rw [step_normal]
@@ -725,11 +828,24 @@ theorem code_is_ok (c) : Code.Ok c :=
cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf, apply IHg]
case fix f IHf => rw [cont_eval_fix IHf]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
+-/
+/- warning: turing.to_partrec.step_normal_eval -> Turing.ToPartrec.stepNormal_eval is a dubious translation:
+lean 3 declaration is
+ forall (c : Turing.ToPartrec.Code) (v : List.{0} Nat), Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v))
+but is expected to have type
+ forall (c : Turing.ToPartrec.Code) (v : List.{0} Nat), Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepNormal c Turing.ToPartrec.Cont.halt v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Code.eval c v))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_evalₓ'. -/
theorem stepNormal_eval (c v) : eval step (stepNormal c Cont.halt v) = Cfg.halt <$> c.eval v :=
(code_is_ok c).zero
#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_eval
+/- warning: turing.to_partrec.step_ret_eval -> Turing.ToPartrec.stepRet_eval is a dubious translation:
+lean 3 declaration is
+ forall {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepRet k v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.monad.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Cont.eval k v))
+but is expected to have type
+ forall {k : Turing.ToPartrec.Cont} {v : List.{0} Nat}, Eq.{1} (Part.{0} Turing.ToPartrec.Cfg) (Turing.eval.{0} Turing.ToPartrec.Cfg Turing.ToPartrec.step (Turing.ToPartrec.stepRet k v)) (Functor.map.{0, 0} Part.{0} (Applicative.toFunctor.{0, 0} Part.{0} (Monad.toApplicative.{0, 0} Part.{0} Part.instMonadPart.{0})) (List.{0} Nat) Turing.ToPartrec.Cfg Turing.ToPartrec.Cfg.halt (Turing.ToPartrec.Cont.eval k v))
+Case conversion may be inaccurate. Consider using '#align turing.to_partrec.step_ret_eval Turing.ToPartrec.stepRet_evalₓ'. -/
theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
by
induction k generalizing v
@@ -871,6 +987,7 @@ section
open ToPartrec
+#print Turing.PartrecToTM2.Γ' /-
/-- The alphabet for the stacks in the program. `bit0` and `bit1` are used to represent `ℕ` values
as lists of binary digits, `cons` is used to separate `list ℕ` values, and `Cons` is used to
separate `list (list ℕ)` values. See the section documentation. -/
@@ -881,7 +998,9 @@ inductive Γ'
| bit1
deriving DecidableEq, Inhabited, Fintype
#align turing.partrec_to_TM2.Γ' Turing.PartrecToTM2.Γ'
+-/
+#print Turing.PartrecToTM2.K' /-
/-- The four stacks used by the program. `main` is used to store the input value in `tr_normal`
mode and the output value in `Λ'.ret` mode, while `stack` is used to keep all the data for the
continuations. `rev` is used to store reversed lists when transferring values between stacks, and
@@ -893,9 +1012,11 @@ inductive K'
| stack
deriving DecidableEq, Inhabited
#align turing.partrec_to_TM2.K' Turing.PartrecToTM2.K'
+-/
open K'
+#print Turing.PartrecToTM2.Cont' /-
/-- Continuations as in `to_partrec.cont` but with the data removed. This is done because we want
the set of all continuations in the program to be finite (so that it can ultimately be encoded into
the finite state machine of a Turing machine), but a continuation can handle a potentially infinite
@@ -908,7 +1029,9 @@ inductive Cont'
| fix : Code → cont' → cont'
deriving DecidableEq, Inhabited
#align turing.partrec_to_TM2.cont' Turing.PartrecToTM2.Cont'
+-/
+#print Turing.PartrecToTM2.Λ' /-
/-- The set of program positions. We make extensive use of inductive types here to let us describe
"subroutines"; for example `clear p k q` is a program that clears stack `k`, then does `q` where
`q` is another label. In order to prevent this from resulting in an infinite number of distinct
@@ -924,6 +1047,7 @@ inductive Λ'
| pred (q₁ q₂ : Λ')
| ret (k : Cont')
#align turing.partrec_to_TM2.Λ' Turing.PartrecToTM2.Λ'
+-/
instance : Inhabited Λ' :=
⟨Λ'.ret Cont'.halt⟩
@@ -933,18 +1057,23 @@ instance : DecidableEq Λ' := fun a b =>
induction a generalizing b <;> cases b <;> try apply Decidable.isFalse; rintro ⟨⟨⟩⟩; done
all_goals exact decidable_of_iff' _ (by simp [Function.funext_iff])
+#print Turing.PartrecToTM2.Stmt' /-
/-- The type of TM2 statements used by this machine. -/
def Stmt' :=
TM2.Stmt (fun _ : K' => Γ') Λ' (Option Γ')deriving Inhabited
#align turing.partrec_to_TM2.stmt' Turing.PartrecToTM2.Stmt'
+-/
+#print Turing.PartrecToTM2.Cfg' /-
/-- The type of TM2 configurations used by this machine. -/
def Cfg' :=
TM2.Cfg (fun _ : K' => Γ') Λ' (Option Γ')deriving Inhabited
#align turing.partrec_to_TM2.cfg' Turing.PartrecToTM2.Cfg'
+-/
open TM2.Stmt
+#print Turing.PartrecToTM2.natEnd /-
/-- A predicate that detects the end of a natural number, either `Γ'.cons` or `Γ'.Cons` (or
implicitly the end of the list), for use in predicate-taking functions like `move` and `clear`. -/
@[simp]
@@ -953,50 +1082,66 @@ def natEnd : Γ' → Bool
| Γ'.cons => true
| _ => false
#align turing.partrec_to_TM2.nat_end Turing.PartrecToTM2.natEnd
+-/
+#print Turing.PartrecToTM2.pop' /-
/-- Pop a value from the stack and place the result in local store. -/
@[simp]
def pop' (k : K') : Stmt' → Stmt' :=
pop k fun x v => v
#align turing.partrec_to_TM2.pop' Turing.PartrecToTM2.pop'
+-/
+#print Turing.PartrecToTM2.peek' /-
/-- Peek a value from the stack and place the result in local store. -/
@[simp]
def peek' (k : K') : Stmt' → Stmt' :=
peek k fun x v => v
#align turing.partrec_to_TM2.peek' Turing.PartrecToTM2.peek'
+-/
+#print Turing.PartrecToTM2.push' /-
/-- Push the value in the local store to the given stack. -/
@[simp]
def push' (k : K') : Stmt' → Stmt' :=
push k fun x => x.iget
#align turing.partrec_to_TM2.push' Turing.PartrecToTM2.push'
+-/
+#print Turing.PartrecToTM2.unrev /-
/-- Move everything from the `rev` stack to the `main` stack (reversed). -/
def unrev :=
Λ'.move (fun _ => false) rev main
#align turing.partrec_to_TM2.unrev Turing.PartrecToTM2.unrev
+-/
+#print Turing.PartrecToTM2.moveExcl /-
/-- Move elements from `k₁` to `k₂` while `p` holds, with the last element being left on `k₁`. -/
def moveExcl (p k₁ k₂ q) :=
Λ'.move p k₁ k₂ <| Λ'.push k₁ id q
#align turing.partrec_to_TM2.move_excl Turing.PartrecToTM2.moveExcl
+-/
+#print Turing.PartrecToTM2.move₂ /-
/-- Move elements from `k₁` to `k₂` without reversion, by performing a double move via the `rev`
stack. -/
def move₂ (p k₁ k₂ q) :=
moveExcl p k₁ rev <| Λ'.move (fun _ => false) rev k₂ q
#align turing.partrec_to_TM2.move₂ Turing.PartrecToTM2.move₂
+-/
+#print Turing.PartrecToTM2.head /-
/-- Assuming `tr_list v` is on the front of stack `k`, remove it, and push `v.head` onto `main`.
See the section documentation. -/
def head (k : K') (q : Λ') : Λ' :=
Λ'.move natEnd k rev <|
(Λ'.push rev fun _ => some Γ'.cons) <|
Λ'.read fun s =>
- (if s = some Γ'.Cons then id else Λ'.clear (fun x => x = Γ'.Cons) k) <| unrev q
+ (if s = some Γ'.consₗ then id else Λ'.clear (fun x => x = Γ'.consₗ) k) <| unrev q
#align turing.partrec_to_TM2.head Turing.PartrecToTM2.head
+-/
+#print Turing.PartrecToTM2.trNormal /-
/-- The program that evaluates code `c` with continuation `k`. This expects an initial state where
`tr_list v` is on `main`, `tr_cont_stack k` is on `stack`, and `aux` and `rev` are empty.
See the section documentation for details. -/
@@ -1006,13 +1151,15 @@ def trNormal : Code → Cont' → Λ'
| code.succ, k => head main <| Λ'.succ <| Λ'.ret k
| code.tail, k => Λ'.clear natEnd main <| Λ'.ret k
| code.cons f fs, k =>
- (Λ'.push stack fun _ => some Γ'.Cons) <|
+ (Λ'.push stack fun _ => some Γ'.consₗ) <|
Λ'.move (fun _ => false) main rev <| Λ'.copy <| tr_normal f (Cont'.cons₁ fs k)
| code.comp f g, k => tr_normal g (Cont'.comp f k)
| code.case f g, k => Λ'.pred (tr_normal f k) (tr_normal g k)
| code.fix f, k => tr_normal f (Cont'.fix f k)
#align turing.partrec_to_TM2.tr_normal Turing.PartrecToTM2.trNormal
+-/
+#print Turing.PartrecToTM2.tr /-
/-- The main program. See the section documentation for details. -/
@[simp]
def tr : Λ' → Stmt'
@@ -1046,7 +1193,7 @@ def tr : Λ' → Stmt'
| Λ'.ret (cont'.cons₁ fs k) =>
goto fun _ =>
move₂ (fun _ => false) main aux <|
- move₂ (fun s => s = Γ'.Cons) stack main <|
+ move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)
| Λ'.ret (cont'.cons₂ k) => goto fun _ => head stack <| Λ'.ret k
| Λ'.ret (cont'.comp f k) => goto fun _ => trNormal f k
@@ -1056,7 +1203,9 @@ def tr : Λ' → Stmt'
cond (natEnd s.iget) (Λ'.ret k) <| Λ'.clear natEnd main <| trNormal f (Cont'.fix f k)
| Λ'.ret cont'.halt => (load fun _ => none) <| halt
#align turing.partrec_to_TM2.tr Turing.PartrecToTM2.tr
+-/
+#print Turing.PartrecToTM2.trCont /-
/-- Translating a `cont` continuation to a `cont'` continuation simply entails dropping all the
data. This data is instead encoded in `tr_cont_stack` in the configuration. -/
def trCont : Cont → Cont'
@@ -1066,9 +1215,11 @@ def trCont : Cont → Cont'
| cont.comp c k => Cont'.comp c (tr_cont k)
| cont.fix c k => Cont'.fix c (tr_cont k)
#align turing.partrec_to_TM2.tr_cont Turing.PartrecToTM2.trCont
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.trPosNum /-
/-- We use `pos_num` to define the translation of binary natural numbers. A natural number is
represented as a little-endian list of `bit0` and `bit1` elements:
@@ -1083,7 +1234,9 @@ def trPosNum : PosNum → List Γ'
| PosNum.bit0 n => Γ'.bit0::tr_pos_num n
| PosNum.bit1 n => Γ'.bit1::tr_pos_num n
#align turing.partrec_to_TM2.tr_pos_num Turing.PartrecToTM2.trPosNum
+-/
+#print Turing.PartrecToTM2.trNum /-
/-- We use `num` to define the translation of binary natural numbers. Positive numbers are
translated using `tr_pos_num`, and `tr_num 0 = []`. So there are never any trailing `bit0`'s in
a translated `num`.
@@ -1098,25 +1251,33 @@ def trNum : Num → List Γ'
| Num.zero => []
| Num.pos n => trPosNum n
#align turing.partrec_to_TM2.tr_num Turing.PartrecToTM2.trNum
+-/
+#print Turing.PartrecToTM2.trNat /-
/-- Because we use binary encoding, we define `tr_nat` in terms of `tr_num`, using `num`, which are
binary natural numbers. (We could also use `nat.binary_rec_on`, but `num` and `pos_num` make for
easy inductions.) -/
def trNat (n : ℕ) : List Γ' :=
trNum n
#align turing.partrec_to_TM2.tr_nat Turing.PartrecToTM2.trNat
+-/
+#print Turing.PartrecToTM2.trNat_zero /-
@[simp]
theorem trNat_zero : trNat 0 = [] := by rw [tr_nat, Nat.cast_zero] <;> rfl
#align turing.partrec_to_TM2.tr_nat_zero Turing.PartrecToTM2.trNat_zero
+-/
+#print Turing.PartrecToTM2.trNat_default /-
@[simp]
theorem trNat_default : trNat default = [] :=
trNat_zero
#align turing.partrec_to_TM2.tr_nat_default Turing.PartrecToTM2.trNat_default
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.trList /-
/-- Lists are translated with a `cons` after each encoded number.
For example:
@@ -1130,9 +1291,11 @@ def trList : List ℕ → List Γ'
| [] => []
| n::ns => trNat n ++ Γ'.cons::tr_list ns
#align turing.partrec_to_TM2.tr_list Turing.PartrecToTM2.trList
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.trLList /-
/-- Lists of lists are translated with a `Cons` after each encoded list.
For example:
@@ -1143,13 +1306,15 @@ For example:
[[1, 2], [0]] = [bit1, cons, bit0, bit1, cons, Cons, cons, Cons]
-/
@[simp]
-def trLlist : List (List ℕ) → List Γ'
+def trLList : List (List ℕ) → List Γ'
| [] => []
- | l::ls => trList l ++ Γ'.Cons::tr_llist ls
-#align turing.partrec_to_TM2.tr_llist Turing.PartrecToTM2.trLlist
+ | l::ls => trList l ++ Γ'.consₗ::tr_llist ls
+#align turing.partrec_to_TM2.tr_llist Turing.PartrecToTM2.trLList
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.contStack /-
/-- The data part of a continuation is a list of lists, which is encoded on the `stack` stack
using `tr_llist`. -/
@[simp]
@@ -1160,13 +1325,17 @@ def contStack : Cont → List (List ℕ)
| cont.comp _ k => cont_stack k
| cont.fix _ k => cont_stack k
#align turing.partrec_to_TM2.cont_stack Turing.PartrecToTM2.contStack
+-/
+#print Turing.PartrecToTM2.trContStack /-
/-- The data part of a continuation is a list of lists, which is encoded on the `stack` stack
using `tr_llist`. -/
def trContStack (k : Cont) :=
- trLlist (contStack k)
+ trLList (contStack k)
#align turing.partrec_to_TM2.tr_cont_stack Turing.PartrecToTM2.trContStack
+-/
+#print Turing.PartrecToTM2.K'.elim /-
/-- This is the nondependent eliminator for `K'`, but we use it specifically here in order to
represent the stack data as four lists rather than as a function `K' → list Γ'`, because this makes
rewrites easier. The theorems `K'.elim_update_main` et. al. show how such a function is updated
@@ -1178,32 +1347,60 @@ def K'.elim (a b c d : List Γ') : K' → List Γ'
| K'.aux => c
| K'.stack => d
#align turing.partrec_to_TM2.K'.elim Turing.PartrecToTM2.K'.elim
+-/
+/- warning: turing.partrec_to_TM2.K'.elim_update_main -> Turing.PartrecToTM2.K'.elim_update_main is a dubious translation:
+lean 3 declaration is
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {a' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.main a') (Turing.PartrecToTM2.K'.elim a' b c d)
+but is expected to have type
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {a' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.main a') (Turing.PartrecToTM2.K'.elim a' b c d)
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_main Turing.PartrecToTM2.K'.elim_update_mainₓ'. -/
@[simp]
theorem K'.elim_update_main {a b c d a'} : update (K'.elim a b c d) main a' = K'.elim a' b c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_main Turing.PartrecToTM2.K'.elim_update_main
+/- warning: turing.partrec_to_TM2.K'.elim_update_rev -> Turing.PartrecToTM2.K'.elim_update_rev is a dubious translation:
+lean 3 declaration is
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {b' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.rev b') (Turing.PartrecToTM2.K'.elim a b' c d)
+but is expected to have type
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {b' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.rev b') (Turing.PartrecToTM2.K'.elim a b' c d)
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_rev Turing.PartrecToTM2.K'.elim_update_revₓ'. -/
@[simp]
theorem K'.elim_update_rev {a b c d b'} : update (K'.elim a b c d) rev b' = K'.elim a b' c d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_rev Turing.PartrecToTM2.K'.elim_update_rev
+/- warning: turing.partrec_to_TM2.K'.elim_update_aux -> Turing.PartrecToTM2.K'.elim_update_aux is a dubious translation:
+lean 3 declaration is
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {c' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.aux c') (Turing.PartrecToTM2.K'.elim a b c' d)
+but is expected to have type
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {c' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.aux c') (Turing.PartrecToTM2.K'.elim a b c' d)
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_aux Turing.PartrecToTM2.K'.elim_update_auxₓ'. -/
@[simp]
theorem K'.elim_update_aux {a b c d c'} : update (K'.elim a b c d) aux c' = K'.elim a b c' d := by
funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_aux Turing.PartrecToTM2.K'.elim_update_aux
+/- warning: turing.partrec_to_TM2.K'.elim_update_stack -> Turing.PartrecToTM2.K'.elim_update_stack is a dubious translation:
+lean 3 declaration is
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {d' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.K'.decidableEq a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.stack d') (Turing.PartrecToTM2.K'.elim a b c d')
+but is expected to have type
+ forall {a : List.{0} Turing.PartrecToTM2.Γ'} {b : List.{0} Turing.PartrecToTM2.Γ'} {c : List.{0} Turing.PartrecToTM2.Γ'} {d : List.{0} Turing.PartrecToTM2.Γ'} {d' : List.{0} Turing.PartrecToTM2.Γ'}, Eq.{1} (Turing.PartrecToTM2.K' -> (List.{0} Turing.PartrecToTM2.Γ')) (Function.update.{1, 1} Turing.PartrecToTM2.K' (fun (a : Turing.PartrecToTM2.K') => List.{0} Turing.PartrecToTM2.Γ') (fun (a : Turing.PartrecToTM2.K') (b : Turing.PartrecToTM2.K') => Turing.PartrecToTM2.instDecidableEqK' a b) (Turing.PartrecToTM2.K'.elim a b c d) Turing.PartrecToTM2.K'.stack d') (Turing.PartrecToTM2.K'.elim a b c d')
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.K'.elim_update_stack Turing.PartrecToTM2.K'.elim_update_stackₓ'. -/
@[simp]
theorem K'.elim_update_stack {a b c d d'} : update (K'.elim a b c d) stack d' = K'.elim a b c d' :=
by funext x <;> cases x <;> rfl
#align turing.partrec_to_TM2.K'.elim_update_stack Turing.PartrecToTM2.K'.elim_update_stack
+#print Turing.PartrecToTM2.halt /-
/-- The halting state corresponding to a `list ℕ` output value. -/
def halt (v : List ℕ) : Cfg' :=
⟨none, none, K'.elim (trList v) [] [] []⟩
#align turing.partrec_to_TM2.halt Turing.PartrecToTM2.halt
+-/
+#print Turing.PartrecToTM2.TrCfg /-
/-- The `cfg` states map to `cfg'` states almost one to one, except that in normal operation the
local store contains an arbitrary garbage value. To make the final theorem cleaner we explicitly
clear it in the halt state so that there is exactly one configuration corresponding to output `v`.
@@ -1213,9 +1410,11 @@ def TrCfg : Cfg → Cfg' → Prop
∃ s, c' = ⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩
| cfg.halt v, c' => c' = halt v
#align turing.partrec_to_TM2.tr_cfg Turing.PartrecToTM2.TrCfg
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.splitAtPred /-
/-- This could be a general list definition, but it is also somewhat specialized to this
application. `split_at_pred p L` will search `L` for the first element satisfying `p`.
If it is found, say `L = l₁ ++ a :: l₂` where `a` satisfies `p` but `l₁` does not, then it returns
@@ -1227,9 +1426,11 @@ def splitAtPred {α} (p : α → Bool) : List α → List α × Option α × Lis
let ⟨l₁, o, l₂⟩ := split_at_pred as
⟨a::l₁, o, l₂⟩
#align turing.partrec_to_TM2.split_at_pred Turing.PartrecToTM2.splitAtPred
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.splitAtPred_eq /-
theorem splitAtPred_eq {α} (p : α → Bool) :
∀ L l₁ o l₂,
(∀ x ∈ l₁, p x = false) →
@@ -1250,12 +1451,16 @@ theorem splitAtPred_eq {α} (p : α → Bool) :
rw [h₁ a (Or.inl rfl), cond, IH l₁ (some o) l₂ _ ⟨h₂, _⟩] <;> try rfl
exact fun x h => h₁ x (Or.inr h)
#align turing.partrec_to_TM2.split_at_pred_eq Turing.PartrecToTM2.splitAtPred_eq
+-/
+#print Turing.PartrecToTM2.splitAtPred_false /-
theorem splitAtPred_false {α} (L : List α) : splitAtPred (fun _ => false) L = (L, none, []) :=
splitAtPred_eq _ _ _ _ _ (fun _ _ => rfl) ⟨rfl, rfl⟩
#align turing.partrec_to_TM2.split_at_pred_ff Turing.PartrecToTM2.splitAtPred_false
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.move_ok /-
theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁ ≠ k₂)
(e : splitAtPred p (S k₁) = (L₁, o, L₂)) :
Reaches₁ (TM2.step tr) ⟨some (Λ'.move p k₁ k₂ q), s, S⟩
@@ -1292,13 +1497,17 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
simp [Function.update_comm h₁.symm]
#align turing.partrec_to_TM2.move_ok Turing.PartrecToTM2.move_ok
+-/
+#print Turing.PartrecToTM2.unrev_ok /-
theorem unrev_ok {q s} {S : K' → List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (unrev q), s, S⟩
⟨some q, none, update (update S rev []) main (List.reverseAux (S rev) (S main))⟩ :=
move_ok (by decide) <| splitAtPred_false _
#align turing.partrec_to_TM2.unrev_ok Turing.PartrecToTM2.unrev_ok
+-/
+#print Turing.PartrecToTM2.move₂_ok /-
theorem move₂_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂)
(h₂ : S rev = []) (e : splitAtPred p (S k₁) = (L₁, o, L₂)) :
Reaches₁ (TM2.step tr) ⟨some (move₂ p k₁ k₂ q), s, S⟩
@@ -1319,7 +1528,9 @@ theorem move₂_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k
simp only [Function.update_noteq h₁.1.symm, Function.update_noteq h₁.2.2.symm,
Function.update_noteq h₁.2.1, Function.update_same, List.reverse_reverse]
#align turing.partrec_to_TM2.move₂_ok Turing.PartrecToTM2.move₂_ok
+-/
+#print Turing.PartrecToTM2.clear_ok /-
theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p (S k) = (L₁, o, L₂)) :
Reaches₁ (TM2.step tr) ⟨some (Λ'.clear p k q), s, S⟩ ⟨some q, o, update S k L₂⟩ :=
by
@@ -1348,7 +1559,9 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
simp [e₂]
convert@IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
+-/
+#print Turing.PartrecToTM2.copy_ok /-
theorem copy_ok (q s a b c d) :
Reaches₁ (TM2.step tr) ⟨some (Λ'.copy q), s, K'.elim a b c d⟩
⟨some q, none, K'.elim (List.reverseAux b a) [] c (List.reverseAux b d)⟩ :=
@@ -1359,7 +1572,9 @@ theorem copy_ok (q s a b c d) :
rfl
refine' trans_gen.head rfl _; simp; exact IH _ _ _
#align turing.partrec_to_TM2.copy_ok Turing.PartrecToTM2.copy_ok
+-/
+#print Turing.PartrecToTM2.trPosNum_natEnd /-
theorem trPosNum_natEnd : ∀ (n), ∀ x ∈ trPosNum n, natEnd x = false
| PosNum.one, _, Or.inl rfl => rfl
| PosNum.bit0 n, _, Or.inl rfl => rfl
@@ -1367,17 +1582,23 @@ theorem trPosNum_natEnd : ∀ (n), ∀ x ∈ trPosNum n, natEnd x = false
| PosNum.bit1 n, _, Or.inl rfl => rfl
| PosNum.bit1 n, _, Or.inr h => tr_pos_num_nat_end n _ h
#align turing.partrec_to_TM2.tr_pos_num_nat_end Turing.PartrecToTM2.trPosNum_natEnd
+-/
+#print Turing.PartrecToTM2.trNum_natEnd /-
theorem trNum_natEnd : ∀ (n), ∀ x ∈ trNum n, natEnd x = false
| Num.pos n, x, h => trPosNum_natEnd n x h
#align turing.partrec_to_TM2.tr_num_nat_end Turing.PartrecToTM2.trNum_natEnd
+-/
+#print Turing.PartrecToTM2.trNat_natEnd /-
theorem trNat_natEnd (n) : ∀ x ∈ trNat n, natEnd x = false :=
trNum_natEnd _
#align turing.partrec_to_TM2.tr_nat_nat_end Turing.PartrecToTM2.trNat_natEnd
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem trList_ne_cons : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.Cons
+#print Turing.PartrecToTM2.trList_ne_consₗ /-
+theorem trList_ne_consₗ : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.consₗ
| a::l, x, h => by
simp [tr_list] at h
obtain h | rfl | h := h
@@ -1385,8 +1606,10 @@ theorem trList_ne_cons : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.Cons
cases tr_nat_nat_end _ _ h
· rintro ⟨⟩
· exact tr_list_ne_Cons l _ h
-#align turing.partrec_to_TM2.tr_list_ne_Cons Turing.PartrecToTM2.trList_ne_cons
+#align turing.partrec_to_TM2.tr_list_ne_Cons Turing.PartrecToTM2.trList_ne_consₗ
+-/
+#print Turing.PartrecToTM2.head_main_ok /-
theorem head_main_ok {q s L} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (head main q), s, K'.elim (trList L) [] c d⟩
⟨some q, none, K'.elim (trList [L.headI]) [] c d⟩ :=
@@ -1403,13 +1626,15 @@ theorem head_main_ok {q s L} {c d : List Γ'} :
· exact fun x h => Bool.decide_false (tr_list_ne_Cons _ _ h)
convert unrev_ok; simp [List.reverseAux_eq]
#align turing.partrec_to_TM2.head_main_ok Turing.PartrecToTM2.head_main_ok
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.head_stack_ok /-
theorem head_stack_ok {q s L₁ L₂ L₃} :
Reaches₁ (TM2.step tr)
- ⟨some (head stack q), s, K'.elim (trList L₁) [] [] (trList L₂ ++ Γ'.Cons::L₃)⟩
+ ⟨some (head stack q), s, K'.elim (trList L₁) [] [] (trList L₂ ++ Γ'.consₗ::L₃)⟩
⟨some q, none, K'.elim (trList (L₂.headI::L₁)) [] [] L₃⟩ :=
by
cases' L₂ with a L₂
@@ -1437,9 +1662,11 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
convert unrev_ok
simp [List.reverseAux_eq]
#align turing.partrec_to_TM2.head_stack_ok Turing.PartrecToTM2.head_stack_ok
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.succ_ok /-
theorem succ_ok {q s n} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (Λ'.succ q), s, K'.elim (trList [n]) [] c d⟩
⟨some q, none, K'.elim (trList [n.succ]) [] c d⟩ :=
@@ -1481,6 +1708,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
simp
rfl
#align turing.partrec_to_TM2.succ_ok Turing.PartrecToTM2.succ_ok
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1489,6 +1717,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.pred_ok /-
theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
∃ s',
Reaches₁ (TM2.step tr) ⟨some (Λ'.pred q₁ q₂), s, K'.elim (trList v) [] c d⟩
@@ -1535,7 +1764,9 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') :
refine' ⟨Γ'.bit0::l₁, _, some a, rfl, trans_gen.single _⟩
simp [tr_pos_num, PosNum.succ, e, h, nat_end, show some Γ'.bit1 ≠ some Γ'.bit0 by decide]
#align turing.partrec_to_TM2.pred_ok Turing.PartrecToTM2.pred_ok
+-/
+#print Turing.PartrecToTM2.trNormal_respects /-
theorem trNormal_respects (c k v s) :
∃ b₂,
TrCfg (stepNormal c k v) b₂ ∧
@@ -1569,9 +1800,11 @@ theorem trNormal_respects (c k v s) :
exact ⟨_, h₁, h.trans h₂⟩
case fix f IH => apply IH
#align turing.partrec_to_TM2.tr_normal_respects Turing.PartrecToTM2.trNormal_respects
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Turing.PartrecToTM2.tr_ret_respects /-
theorem tr_ret_respects (k v s) :
∃ b₂,
TrCfg (stepRet k v) b₂ ∧
@@ -1627,22 +1860,30 @@ theorem tr_ret_respects (k v s) :
· exact fun x h => tr_nat_nat_end _ _ (List.tail_subset _ h)
· exact ⟨rfl, this.2⟩
#align turing.partrec_to_TM2.tr_ret_respects Turing.PartrecToTM2.tr_ret_respects
+-/
+#print Turing.PartrecToTM2.tr_respects /-
theorem tr_respects : Respects step (TM2.step tr) TrCfg
| cfg.ret k v, _, ⟨s, rfl⟩ => tr_ret_respects _ _ _
| cfg.halt v, _, rfl => rfl
#align turing.partrec_to_TM2.tr_respects Turing.PartrecToTM2.tr_respects
+-/
+#print Turing.PartrecToTM2.init /-
/-- The initial state, evaluating function `c` on input `v`. -/
def init (c : Code) (v : List ℕ) : Cfg' :=
⟨some (trNormal c Cont'.halt), none, K'.elim (trList v) [] [] []⟩
#align turing.partrec_to_TM2.init Turing.PartrecToTM2.init
+-/
+#print Turing.PartrecToTM2.tr_init /-
theorem tr_init (c v) :
∃ b, TrCfg (stepNormal c Cont.halt v) b ∧ Reaches₁ (TM2.step tr) (init c v) b :=
trNormal_respects _ _ _ _
#align turing.partrec_to_TM2.tr_init Turing.PartrecToTM2.tr_init
+-/
+#print Turing.PartrecToTM2.tr_eval /-
theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :=
by
obtain ⟨i, h₁, h₂⟩ := tr_init c v
@@ -1659,7 +1900,9 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
obtain ⟨_, ⟨⟩, h⟩ := this _ hv rfl
exact h
#align turing.partrec_to_TM2.tr_eval Turing.PartrecToTM2.tr_eval
+-/
+#print Turing.PartrecToTM2.trStmts₁ /-
/-- The set of machine states reachable via downward label jumps, discounting jumps via `ret`. -/
def trStmts₁ : Λ' → Finset Λ'
| Q@(Λ'.move p k₁ k₂ q) => insert Q <| tr_stmts₁ q
@@ -1671,7 +1914,9 @@ def trStmts₁ : Λ' → Finset Λ'
| Q@(Λ'.pred q₁ q₂) => insert Q <| tr_stmts₁ q₁ ∪ insert (unrev q₂) (tr_stmts₁ q₂)
| Q@(Λ'.ret k) => {Q}
#align turing.partrec_to_TM2.tr_stmts₁ Turing.PartrecToTM2.trStmts₁
+-/
+#print Turing.PartrecToTM2.trStmts₁_trans /-
theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trStmts₁ q :=
by
induction q <;>
@@ -1693,11 +1938,15 @@ theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trSt
· cases' Finset.mem_insert.1 h' with h' h' <;> simp [h', unrev]
· exact Or.inr (Or.inr <| Or.inr <| q_ih_q₂ h h')
#align turing.partrec_to_TM2.tr_stmts₁_trans Turing.PartrecToTM2.trStmts₁_trans
+-/
+#print Turing.PartrecToTM2.trStmts₁_self /-
theorem trStmts₁_self (q) : q ∈ trStmts₁ q := by
induction q <;> · first |apply Finset.mem_singleton_self|apply Finset.mem_insert_self
#align turing.partrec_to_TM2.tr_stmts₁_self Turing.PartrecToTM2.trStmts₁_self
+-/
+#print Turing.PartrecToTM2.codeSupp' /-
/-- The (finite!) set of machine states visited during the course of evaluation of `c`,
including the state `ret k` but not any states after that (that is, the states visited while
evaluating `k`). -/
@@ -1710,7 +1959,7 @@ def codeSupp' : Code → Cont' → Finset Λ'
(code_supp' f (Cont'.cons₁ fs k) ∪
(trStmts₁
(move₂ (fun _ => false) main aux <|
- move₂ (fun s => s = Γ'.Cons) stack main <|
+ move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)) ∪
(code_supp' fs (Cont'.cons₂ k) ∪ trStmts₁ (head stack <| Λ'.ret k))))
| c@(code.comp f g), k =>
@@ -1722,19 +1971,23 @@ def codeSupp' : Code → Cont' → Finset Λ'
(code_supp' f (Cont'.fix f k) ∪
(trStmts₁ (Λ'.clear natEnd main <| trNormal f (Cont'.fix f k)) ∪ {Λ'.ret k}))
#align turing.partrec_to_TM2.code_supp' Turing.PartrecToTM2.codeSupp'
+-/
+#print Turing.PartrecToTM2.codeSupp'_self /-
@[simp]
theorem codeSupp'_self (c k) : trStmts₁ (trNormal c k) ⊆ codeSupp' c k := by
cases c <;> first |rfl|exact Finset.subset_union_left _ _
#align turing.partrec_to_TM2.code_supp'_self Turing.PartrecToTM2.codeSupp'_self
+-/
+#print Turing.PartrecToTM2.contSupp /-
/-- The (finite!) set of machine states visited during the course of evaluation of a continuation
`k`, not including the initial state `ret k`. -/
def contSupp : Cont' → Finset Λ'
| cont'.cons₁ fs k =>
trStmts₁
(move₂ (fun _ => false) main aux <|
- move₂ (fun s => s = Γ'.Cons) stack main <|
+ move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)) ∪
(codeSupp' fs (Cont'.cons₂ k) ∪ (trStmts₁ (head stack <| Λ'.ret k) ∪ cont_supp k))
| cont'.cons₂ k => trStmts₁ (head stack <| Λ'.ret k) ∪ cont_supp k
@@ -1742,7 +1995,9 @@ def contSupp : Cont' → Finset Λ'
| cont'.fix f k => codeSupp' (Code.fix f) k ∪ cont_supp k
| cont'.halt => ∅
#align turing.partrec_to_TM2.cont_supp Turing.PartrecToTM2.contSupp
+-/
+#print Turing.PartrecToTM2.codeSupp /-
/-- The (finite!) set of machine states visited during the course of evaluation of `c` in
continuation `k`. This is actually closed under forward simulation (see `tr_supports`), and the
existence of this set means that the machine constructed in this section is in fact a proper
@@ -1750,34 +2005,46 @@ Turing machine, with a finite set of states. -/
def codeSupp (c : Code) (k : Cont') : Finset Λ' :=
codeSupp' c k ∪ contSupp k
#align turing.partrec_to_TM2.code_supp Turing.PartrecToTM2.codeSupp
+-/
+#print Turing.PartrecToTM2.codeSupp_self /-
@[simp]
theorem codeSupp_self (c k) : trStmts₁ (trNormal c k) ⊆ codeSupp c k :=
Finset.Subset.trans (codeSupp'_self _ _) (Finset.subset_union_left _ _)
#align turing.partrec_to_TM2.code_supp_self Turing.PartrecToTM2.codeSupp_self
+-/
+#print Turing.PartrecToTM2.codeSupp_zero /-
@[simp]
theorem codeSupp_zero (k) : codeSupp Code.zero' k = trStmts₁ (trNormal Code.zero' k) ∪ contSupp k :=
rfl
#align turing.partrec_to_TM2.code_supp_zero Turing.PartrecToTM2.codeSupp_zero
+-/
+#print Turing.PartrecToTM2.codeSupp_succ /-
@[simp]
theorem codeSupp_succ (k) : codeSupp Code.succ k = trStmts₁ (trNormal Code.succ k) ∪ contSupp k :=
rfl
#align turing.partrec_to_TM2.code_supp_succ Turing.PartrecToTM2.codeSupp_succ
+-/
+#print Turing.PartrecToTM2.codeSupp_tail /-
@[simp]
theorem codeSupp_tail (k) : codeSupp Code.tail k = trStmts₁ (trNormal Code.tail k) ∪ contSupp k :=
rfl
#align turing.partrec_to_TM2.code_supp_tail Turing.PartrecToTM2.codeSupp_tail
+-/
+#print Turing.PartrecToTM2.codeSupp_cons /-
@[simp]
theorem codeSupp_cons (f fs k) :
codeSupp (Code.cons f fs) k =
trStmts₁ (trNormal (Code.cons f fs) k) ∪ codeSupp f (Cont'.cons₁ fs k) :=
by simp [code_supp, code_supp', cont_supp, Finset.union_assoc]
#align turing.partrec_to_TM2.code_supp_cons Turing.PartrecToTM2.codeSupp_cons
+-/
+#print Turing.PartrecToTM2.codeSupp_comp /-
@[simp]
theorem codeSupp_comp (f g k) :
codeSupp (Code.comp f g) k =
@@ -1787,53 +2054,73 @@ theorem codeSupp_comp (f g k) :
rw [← Finset.union_assoc _ _ (cont_supp k),
Finset.union_eq_right_iff_subset.2 (code_supp'_self _ _)]
#align turing.partrec_to_TM2.code_supp_comp Turing.PartrecToTM2.codeSupp_comp
+-/
+#print Turing.PartrecToTM2.codeSupp_case /-
@[simp]
theorem codeSupp_case (f g k) :
codeSupp (Code.case f g) k =
trStmts₁ (trNormal (Code.case f g) k) ∪ (codeSupp f k ∪ codeSupp g k) :=
by simp [code_supp, code_supp', cont_supp, Finset.union_assoc, Finset.union_left_comm]
#align turing.partrec_to_TM2.code_supp_case Turing.PartrecToTM2.codeSupp_case
+-/
+#print Turing.PartrecToTM2.codeSupp_fix /-
@[simp]
theorem codeSupp_fix (f k) :
codeSupp (Code.fix f) k = trStmts₁ (trNormal (Code.fix f) k) ∪ codeSupp f (Cont'.fix f k) := by
simp [code_supp, code_supp', cont_supp, Finset.union_assoc, Finset.union_left_comm,
Finset.union_left_idem]
#align turing.partrec_to_TM2.code_supp_fix Turing.PartrecToTM2.codeSupp_fix
+-/
+/- warning: turing.partrec_to_TM2.cont_supp_cons₁ -> Turing.PartrecToTM2.contSupp_cons₁ is a dubious translation:
+lean 3 declaration is
+ forall (fs : Turing.ToPartrec.Code) (k : Turing.PartrecToTM2.Cont'), Eq.{1} (Finset.{0} Turing.PartrecToTM2.Λ') (Turing.PartrecToTM2.contSupp (Turing.PartrecToTM2.Cont'.cons₁ fs k)) (Union.union.{0} (Finset.{0} Turing.PartrecToTM2.Λ') (Finset.hasUnion.{0} Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b)) (Turing.PartrecToTM2.trStmts₁ (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.main Turing.PartrecToTM2.K'.aux (Turing.PartrecToTM2.move₂ (fun (s : Turing.PartrecToTM2.Γ') => Decidable.decide (Eq.{1} Turing.PartrecToTM2.Γ' s Turing.PartrecToTM2.Γ'.consₗ) (Turing.PartrecToTM2.Γ'.decidableEq s Turing.PartrecToTM2.Γ'.consₗ)) Turing.PartrecToTM2.K'.stack Turing.PartrecToTM2.K'.main (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.aux Turing.PartrecToTM2.K'.stack (Turing.PartrecToTM2.trNormal fs (Turing.PartrecToTM2.Cont'.cons₂ k)))))) (Turing.PartrecToTM2.codeSupp fs (Turing.PartrecToTM2.Cont'.cons₂ k)))
+but is expected to have type
+ forall (fs : Turing.ToPartrec.Code) (k : Turing.PartrecToTM2.Cont'), Eq.{1} (Finset.{0} Turing.PartrecToTM2.Λ') (Turing.PartrecToTM2.contSupp (Turing.PartrecToTM2.Cont'.cons₁ fs k)) (Union.union.{0} (Finset.{0} Turing.PartrecToTM2.Λ') (Finset.instUnionFinset.{0} Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b)) (Turing.PartrecToTM2.trStmts₁ (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.main Turing.PartrecToTM2.K'.aux (Turing.PartrecToTM2.move₂ (fun (s : Turing.PartrecToTM2.Γ') => Decidable.decide (Eq.{1} Turing.PartrecToTM2.Γ' s Turing.PartrecToTM2.Γ'.consₗ) (Turing.PartrecToTM2.instDecidableEqΓ' s Turing.PartrecToTM2.Γ'.consₗ)) Turing.PartrecToTM2.K'.stack Turing.PartrecToTM2.K'.main (Turing.PartrecToTM2.move₂ (fun (_x : Turing.PartrecToTM2.Γ') => Bool.false) Turing.PartrecToTM2.K'.aux Turing.PartrecToTM2.K'.stack (Turing.PartrecToTM2.trNormal fs (Turing.PartrecToTM2.Cont'.cons₂ k)))))) (Turing.PartrecToTM2.codeSupp fs (Turing.PartrecToTM2.Cont'.cons₂ k)))
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.cont_supp_cons₁ Turing.PartrecToTM2.contSupp_cons₁ₓ'. -/
@[simp]
theorem contSupp_cons₁ (fs k) :
contSupp (Cont'.cons₁ fs k) =
trStmts₁
(move₂ (fun _ => false) main aux <|
- move₂ (fun s => s = Γ'.Cons) stack main <|
+ move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)) ∪
codeSupp fs (Cont'.cons₂ k) :=
by simp [code_supp, code_supp', cont_supp, Finset.union_assoc]
#align turing.partrec_to_TM2.cont_supp_cons₁ Turing.PartrecToTM2.contSupp_cons₁
+#print Turing.PartrecToTM2.contSupp_cons₂ /-
@[simp]
theorem contSupp_cons₂ (k) :
contSupp (Cont'.cons₂ k) = trStmts₁ (head stack <| Λ'.ret k) ∪ contSupp k :=
rfl
#align turing.partrec_to_TM2.cont_supp_cons₂ Turing.PartrecToTM2.contSupp_cons₂
+-/
+#print Turing.PartrecToTM2.contSupp_comp /-
@[simp]
theorem contSupp_comp (f k) : contSupp (Cont'.comp f k) = codeSupp f k :=
rfl
#align turing.partrec_to_TM2.cont_supp_comp Turing.PartrecToTM2.contSupp_comp
+-/
+#print Turing.PartrecToTM2.contSupp_fix /-
theorem contSupp_fix (f k) : contSupp (Cont'.fix f k) = codeSupp f (Cont'.fix f k) := by
simp (config := { contextual := true }) [code_supp, code_supp', cont_supp, Finset.union_assoc,
Finset.subset_iff]
#align turing.partrec_to_TM2.cont_supp_fix Turing.PartrecToTM2.contSupp_fix
+-/
+#print Turing.PartrecToTM2.contSupp_halt /-
@[simp]
theorem contSupp_halt : contSupp Cont'.halt = ∅ :=
rfl
#align turing.partrec_to_TM2.cont_supp_halt Turing.PartrecToTM2.contSupp_halt
+-/
+#print Turing.PartrecToTM2.Λ'.Supports /-
/-- The statement `Λ'.supports S q` means that `cont_supp k ⊆ S` for any `ret k`
reachable from `q`.
(This is a technical condition used in the proof that the machine is supported.) -/
@@ -1847,7 +2134,9 @@ def Λ'.Supports (S : Finset Λ') : Λ' → Prop
| Q@(Λ'.pred q₁ q₂) => Λ'.supports q₁ ∧ Λ'.supports q₂
| Q@(Λ'.ret k) => contSupp k ⊆ S
#align turing.partrec_to_TM2.Λ'.supports Turing.PartrecToTM2.Λ'.Supports
+-/
+#print Turing.PartrecToTM2.Supports /-
/-- A shorthand for the predicate that we are proving in the main theorems `tr_stmts₁_supports`,
`code_supp'_supports`, `cont_supp_supports`, `code_supp_supports`. The set `S` is fixed throughout
the proof, and denotes the full set of states in the machine, while `K` is a subset that we are
@@ -1857,28 +2146,44 @@ stays entirely within `S`. -/
def Supports (K S : Finset Λ') :=
∀ q ∈ K, TM2.SupportsStmt S (tr q)
#align turing.partrec_to_TM2.supports Turing.PartrecToTM2.Supports
+-/
+#print Turing.PartrecToTM2.supports_insert /-
theorem supports_insert {K S q} :
Supports (insert q K) S ↔ TM2.SupportsStmt S (tr q) ∧ Supports K S := by simp [supports]
#align turing.partrec_to_TM2.supports_insert Turing.PartrecToTM2.supports_insert
+-/
+#print Turing.PartrecToTM2.supports_singleton /-
theorem supports_singleton {S q} : Supports {q} S ↔ TM2.SupportsStmt S (tr q) := by simp [supports]
#align turing.partrec_to_TM2.supports_singleton Turing.PartrecToTM2.supports_singleton
+-/
+#print Turing.PartrecToTM2.supports_union /-
theorem supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K₁ S ∧ Supports K₂ S := by
simp [supports, or_imp, forall_and]
#align turing.partrec_to_TM2.supports_union Turing.PartrecToTM2.supports_union
+-/
+/- warning: turing.partrec_to_TM2.supports_bUnion -> Turing.PartrecToTM2.supports_bunionᵢ is a dubious translation:
+lean 3 declaration is
+ forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.bunionᵢ.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (Option.fintype.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.Γ'.fintype)) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
+but is expected to have type
+ forall {K : (Option.{0} Turing.PartrecToTM2.Γ') -> (Finset.{0} Turing.PartrecToTM2.Λ')} {S : Finset.{0} Turing.PartrecToTM2.Λ'}, Iff (Turing.PartrecToTM2.Supports (Finset.bunionᵢ.{0, 0} (Option.{0} Turing.PartrecToTM2.Γ') Turing.PartrecToTM2.Λ' (fun (a : Turing.PartrecToTM2.Λ') (b : Turing.PartrecToTM2.Λ') => Turing.PartrecToTM2.Λ'.instDecidableEq a b) (Finset.univ.{0} (Option.{0} Turing.PartrecToTM2.Γ') (instFintypeOption.{0} Turing.PartrecToTM2.Γ' Turing.PartrecToTM2.instFintypeΓ')) K) S) (forall (a : Option.{0} Turing.PartrecToTM2.Γ'), Turing.PartrecToTM2.Supports (K a) S)
+Case conversion may be inaccurate. Consider using '#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_bunionᵢₓ'. -/
theorem supports_bunionᵢ {K : Option Γ' → Finset Λ'} {S} :
Supports (Finset.univ.bunionᵢ K) S ↔ ∀ a, Supports (K a) S := by
simp [supports] <;> apply forall_swap
#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_bunionᵢ
+#print Turing.PartrecToTM2.head_supports /-
theorem head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S := fun _ => by
dsimp only <;> split_ifs <;> exact H
#align turing.partrec_to_TM2.head_supports Turing.PartrecToTM2.head_supports
+-/
-theorem retSupports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (Λ'.ret k)) :=
+#print Turing.PartrecToTM2.ret_supports /-
+theorem ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (Λ'.ret k)) :=
by
have W := fun {q} => tr_stmts₁_self q
cases k
@@ -1892,8 +2197,10 @@ theorem retSupports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (Λ
intro s; dsimp only; cases nat_end s.iget
· refine' H₁ (R _ <| L _ <| R _ <| R _ <| L _ W)
· exact H₁ (R _ <| L _ <| R _ <| R _ <| R _ <| Finset.mem_singleton_self _)
-#align turing.partrec_to_TM2.ret_supports Turing.PartrecToTM2.retSupports
+#align turing.partrec_to_TM2.ret_supports Turing.PartrecToTM2.ret_supports
+-/
+#print Turing.PartrecToTM2.trStmts₁_supports /-
theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts₁ q ⊆ S) :
Supports (trStmts₁ q) S := by
have W := fun {q} => tr_stmts₁_self q
@@ -1925,14 +2232,18 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
-- ret
· exact supports_singleton.2 (ret_supports H₁)
#align turing.partrec_to_TM2.tr_stmts₁_supports Turing.PartrecToTM2.trStmts₁_supports
+-/
+#print Turing.PartrecToTM2.trStmts₁_supports' /-
theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStmts₁ q ∪ K ⊆ S)
(H₃ : K ⊆ S → Supports K S) : Supports (trStmts₁ q ∪ K) S :=
by
simp [Finset.union_subset_iff] at H₂
exact supports_union.2 ⟨tr_stmts₁_supports H₁ H₂.1, H₃ H₂.2⟩
#align turing.partrec_to_TM2.tr_stmts₁_supports' Turing.PartrecToTM2.trStmts₁_supports'
+-/
+#print Turing.PartrecToTM2.trNormal_supports /-
theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Supports S :=
by
induction c generalizing k <;> simp [Λ'.supports, head]
@@ -1948,7 +2259,9 @@ theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Sup
exact ⟨IHf Hk.2.1, IHg Hk.2.2⟩
case fix f IHf => apply IHf; rw [code_supp_fix] at Hk; exact Finset.union_subset_right Hk
#align turing.partrec_to_TM2.tr_normal_supports Turing.PartrecToTM2.trNormal_supports
+-/
+#print Turing.PartrecToTM2.codeSupp'_supports /-
theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp' c k) S :=
by
induction c generalizing k
@@ -1989,7 +2302,9 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
+-/
+#print Turing.PartrecToTM2.contSupp_supports /-
theorem contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S :=
by
induction k
@@ -2010,19 +2325,24 @@ theorem contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S
rw [cont_supp] at H
exact supports_union.2 ⟨code_supp'_supports H, IH (Finset.union_subset_right H)⟩
#align turing.partrec_to_TM2.cont_supp_supports Turing.PartrecToTM2.contSupp_supports
+-/
+#print Turing.PartrecToTM2.codeSupp_supports /-
theorem codeSupp_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp c k) S :=
supports_union.2 ⟨codeSupp'_supports H, contSupp_supports (Finset.union_subset_right H)⟩
#align turing.partrec_to_TM2.code_supp_supports Turing.PartrecToTM2.codeSupp_supports
+-/
+#print Turing.PartrecToTM2.tr_supports /-
/-- The set `code_supp c k` is a finite set that witnesses the effective finiteness of the `tr`
Turing machine. Starting from the initial state `tr_normal c k`, forward simulation uses only
states in `code_supp c k`, so this is a finite state machine. Even though the underlying type of
state labels `Λ'` is infinite, for a given partial recursive function `c` and continuation `k`,
only finitely many states are accessed, corresponding roughly to subterms of `c`. -/
-theorem trSupports (c k) : @TM2.Supports _ _ _ _ _ ⟨trNormal c k⟩ tr (codeSupp c k) :=
+theorem tr_supports (c k) : @TM2.Supports _ _ _ _ _ ⟨trNormal c k⟩ tr (codeSupp c k) :=
⟨codeSupp_self _ _ (trStmts₁_self _), fun l' => codeSupp_supports (Finset.Subset.refl _) _⟩
-#align turing.partrec_to_TM2.tr_supports Turing.PartrecToTM2.trSupports
+#align turing.partrec_to_TM2.tr_supports Turing.PartrecToTM2.tr_supports
+-/
end
mathlib commit https://github.com/leanprover-community/mathlib/commit/d11893b411025250c8e61ff2f12ccbd7ee35ab15
@@ -309,7 +309,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
a + b = n →
(n.succ::0::g
(n ::ᵥ
- Nat.elim (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ
+ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ
v.tail)::v.val.tail :
List ℕ) ∈
PFun.fix
@@ -318,7 +318,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
pure <|
if v = 0 then Sum.inl (v::v::x.headI::v : List ℕ)
else Sum.inr (v::v::x.headI::v))
- (a::b::Nat.elim (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a::v.val.tail)
+ (a::b::Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a::v.val.tail)
by
rw [(_ : PFun.fix _ _ = pure _)]
swap
@@ -330,7 +330,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
simp only [hg, ← e, pure_bind, List.tail_cons]
rfl
· refine' PFun.mem_fix_iff.2 (Or.inr ⟨_, _, IH (a + 1) (by rwa [add_right_comm])⟩)
- simp only [hg, eval, pure_bind, Nat.elim_succ, List.tail]
+ simp only [hg, eval, pure_bind, Nat.rec_add_one, List.tail]
exact Part.mem_some_iff.2 rfl
case comp m n f g hf hg IHf IHg => exact exists_code.comp IHf IHg
case rfind n f hf IHf =>
@@ -576,7 +576,7 @@ theorem stepNormal_then (c) (k k' : Cont) (v) :
induction c generalizing k v <;> simp only [cont.then, step_normal, cfg.then, *]
case cons c c' ih ih' => rw [← ih, cont.then]
case comp c c' ih ih' => rw [← ih', cont.then]
- · cases v.head <;> simp only [Nat.elim]
+ · cases v.head <;> simp only [Nat.rec]
case fix c ih => rw [← ih, cont.then]
#align turing.to_partrec.step_normal_then Turing.ToPartrec.stepNormal_then
@@ -620,7 +620,7 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
case cons f fs IHf IHfs => apply IHf
case comp f g IHf IHg => apply IHg
case case f g IHf IHg => rw [step_normal];
- cases v.head <;> simp only [Nat.elim] <;> [apply IHf, apply IHg]
+ cases v.head <;> simp only [Nat.rec] <;> [apply IHf, apply IHg]
case fix f IHf => apply IHf
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
@@ -722,7 +722,7 @@ theorem code_is_ok (c) : Code.Ok c :=
rw [reaches_eval]; swap; exact refl_trans_gen.single rfl
rw [step_ret, IHf]
case case f g IHf IHg => simp only [code.eval];
- cases v.head <;> simp only [Nat.elim, code.eval] <;> [apply IHf, apply IHg]
+ cases v.head <;> simp only [Nat.rec, code.eval] <;> [apply IHf, apply IHg]
case fix f IHf => rw [cont_eval_fix IHf]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce7e9d53d4bbc38065db3b595cd5bd73c323bc1d
@@ -1288,7 +1288,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
rw [e₃, split_at_pred] at e
cases e
simp [e₂]
- convert @IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
+ convert@IH (update (update S k₁ Sk) k₂ (a::S k₂)) _ _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
simp [Function.update_comm h₁.symm]
#align turing.partrec_to_TM2.move_ok Turing.PartrecToTM2.move_ok
@@ -1346,7 +1346,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
rw [e₃, split_at_pred] at e
cases e
simp [e₂]
- convert @IH (update S k Sk) _ _ using 2 <;> simp [e₃]
+ convert@IH (update S k Sk) _ _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
theorem copy_ok (q s a b c d) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -649,7 +649,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
obtain ⟨v'', h₁, h₂⟩ := this
rw [reaches_eval] at h₂
swap
- exact ReflTransGen.single rfl
+ · exact ReflTransGen.single rfl
cases Part.mem_unique h₂ (mem_eval.2 ⟨ReflTransGen.refl, rfl⟩)
refine' ⟨v', h₁, _⟩
rw [stepRet] at h
@@ -657,7 +657,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
by_cases he : v'.headI = 0 <;> simp only [exists_prop, if_pos, if_false, he] <;> intro h
· refine' ⟨_, Part.mem_some _, _⟩
rw [reaches_eval]
- exact h
+ · exact h
exact ReflTransGen.single rfl
· obtain ⟨k₀, v₀, e₀⟩ := stepNormal.is_ret f Cont.halt v'.tail
have e₁ := stepNormal_then f Cont.halt (Cont.fix f k) v'.tail
@@ -674,7 +674,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
· rintro ⟨v', he, hr⟩
rw [reaches_eval] at hr
swap
- exact ReflTransGen.single rfl
+ · exact ReflTransGen.single rfl
refine' PFun.fixInduction he fun v (he : v' ∈ f.fix.eval v) IH => _
rw [fok, Part.bind_eq_bind, Part.mem_bind_iff]
obtain he | ⟨v'', he₁', _⟩ := PFun.mem_fix_iff.1 he
@@ -683,7 +683,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
refine' ⟨_, he₁, _⟩
rw [reaches_eval]
swap
- exact ReflTransGen.single rfl
+ · exact ReflTransGen.single rfl
rwa [stepRet, if_pos h]
· obtain ⟨v₁, he₁, he₂⟩ := (Part.mem_map_iff _).1 he₁'
split_ifs at he₂ with h; cases he₂
@@ -691,7 +691,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
refine' ⟨_, he₁, _⟩
rw [reaches_eval]
swap
- exact ReflTransGen.single rfl
+ · exact ReflTransGen.single rfl
rw [stepRet, if_neg h]
exact IH v₁.tail ((Part.mem_map_iff _).2 ⟨_, he₁, if_neg h⟩)
#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fix
@@ -701,13 +701,15 @@ theorem code_is_ok (c) : Code.Ok c := by
| cons f fs IHf IHfs =>
rw [Code.eval, IHf]
simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
- rw [reaches_eval]; swap; exact ReflTransGen.single rfl
+ rw [reaches_eval]; swap
+ · exact ReflTransGen.single rfl
rw [stepRet, IHfs]; congr; funext v'
refine' Eq.trans _ (Eq.symm _) <;> try exact reaches_eval (ReflTransGen.single rfl)
| comp f g IHf IHg =>
rw [Code.eval, IHg]
simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
- rw [reaches_eval]; swap; exact ReflTransGen.single rfl
+ rw [reaches_eval]; swap
+ · exact ReflTransGen.single rfl
rw [stepRet, IHf]
| case f g IHf IHg =>
simp only [Code.eval]
@@ -728,13 +730,15 @@ theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
| cons₁ fs as k IH =>
rw [Cont.eval, stepRet, code_is_ok]
simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
- rw [reaches_eval]; swap; exact ReflTransGen.single rfl
+ rw [reaches_eval]; swap
+ · exact ReflTransGen.single rfl
rw [stepRet, IH, bind_pure_comp]
| cons₂ ns k IH => rw [Cont.eval, stepRet]; exact IH
| comp f k IH =>
rw [Cont.eval, stepRet, code_is_ok]
simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
- rw [reaches_eval]; swap; exact ReflTransGen.single rfl
+ rw [reaches_eval]; swap
+ · exact ReflTransGen.single rfl
rw [IH, bind_pure_comp]
| fix f k IH =>
rw [Cont.eval, stepRet]; simp only [bind_pure_comp]
@@ -1596,7 +1600,9 @@ theorem trNormal_respects (c k v s) :
| succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
| tail =>
let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
- refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
+ refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2
+ · simp; rfl
+ swap
refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
cases v <;> simp [o]
| cons f fs IHf _ =>
@@ -1632,8 +1638,10 @@ theorem tr_ret_respects (k v s) : ∃ b₂,
refine' (move₂_ok (by decide) _ (splitAtPred_false _)).trans _; · rfl
simp only [TM2.step, Option.mem_def, Option.elim, id_eq, elim_update_main, elim_main, elim_aux,
List.append_nil, elim_update_aux]
- refine' (move₂_ok (by decide) _ _).trans _; pick_goal 4; · rfl
- pick_goal 4;
+ refine' (move₂_ok (by decide) _ _).trans _
+ pick_goal 4
+ · rfl
+ pick_goal 4
· exact
splitAtPred_eq _ _ _ (some Γ'.consₗ) _
(fun x h => Bool.decide_false (trList_ne_consₗ _ _ h)) ⟨rfl, rfl⟩
@@ -1726,7 +1734,7 @@ theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trSt
induction' q with _ _ _ q q_ih _ _ q q_ih q q_ih _ _ q q_ih q q_ih q q_ih q₁ q₂ q₁_ih q₂_ih _ <;>
simp (config := { contextual := true }) only [trStmts₁, Finset.mem_insert, Finset.mem_union,
or_imp, Finset.mem_singleton, Finset.Subset.refl, imp_true_iff, true_and_iff]
- iterate 4 exact fun h => Finset.Subset.trans (q_ih h) (Finset.subset_insert _ _)
+ repeat exact fun h => Finset.Subset.trans (q_ih h) (Finset.subset_insert _ _)
· simp
intro s h x h'
simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_insert]
@@ -666,10 +666,10 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
obtain ⟨v₁, hv₁, v₂, hv₂, h₃⟩ :=
IH (stepRet (k₀.then (Cont.fix f k)) v₀) (by rw [stepRet, if_neg he, e₁]; rfl)
v'.tail _ stepRet_then (by apply ReflTransGen.single; rw [e₀]; rfl)
- · refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
- simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
- split_ifs at hv₂ ⊢ <;> [exact Or.inl (congr_arg Sum.inl (Part.mem_some_iff.1 hv₂));
- exact Or.inr ⟨_, rfl, hv₂⟩]
+ refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
+ simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
+ split_ifs at hv₂ ⊢ <;> [exact Or.inl (congr_arg Sum.inl (Part.mem_some_iff.1 hv₂));
+ exact Or.inr ⟨_, rfl, hv₂⟩]
· exact IH _ rfl _ _ stepRet_then (ReflTransGen.tail hr rfl)
· rintro ⟨v', he, hr⟩
rw [reaches_eval] at hr
@@ -1340,8 +1340,8 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
simp only [splitAtPred, Option.elim, List.head?, List.tail_cons, Option.iget_some] at e ⊢
revert e; cases p a <;> intro e <;>
simp only [cond_false, cond_true, Prod.mk.injEq, true_and, false_and] at e ⊢
- · simp only [e]
- rfl
+ simp only [e]
+ rfl
· refine' TransGen.head rfl _
simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim, ne_eq, List.reverseAux_cons]
cases' e₁ : S k₁ with a' Sk <;> rw [e₁, splitAtPred] at e
@@ -1398,8 +1398,8 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
simp only [splitAtPred, Option.elim, List.head?, List.tail_cons] at e ⊢
revert e; cases p a <;> intro e <;>
simp only [cond_false, cond_true, Prod.mk.injEq, true_and, false_and] at e ⊢
- · rcases e with ⟨e₁, e₂⟩
- rw [e₁, e₂]
+ rcases e with ⟨e₁, e₂⟩
+ rw [e₁, e₂]
· refine' TransGen.head rfl _
simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim]
cases' e₁ : S k with a' Sk <;> rw [e₁, splitAtPred] at e
@@ -1370,7 +1370,7 @@ theorem move₂_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k
⟨some q, none, update (update S k₁ (o.elim id List.cons L₂)) k₂ (L₁ ++ S k₂)⟩ := by
refine' (move_ok h₁.1 e).trans (TransGen.head rfl _)
simp only [TM2.step, Option.mem_def, TM2.stepAux, id_eq, ne_eq, Option.elim]
- cases o <;> simp only [Option.elim, id.def]
+ cases o <;> simp only [Option.elim, id]
· simp only [TM2.stepAux, Option.isSome, cond_false]
convert move_ok h₁.2.1.symm (splitAtPred_false _) using 2
simp only [Function.update_comm h₁.1, Function.update_idem]
These attributes are unused in Mathlib.
Many of them were workarounds for the now-resolved leanprover/lean4#2243; this also allows the lemmas themselves (hasFiniteIntegral_def
, integrable_def
, memℒp_def
, and integrableOn_def
) to be deleted.
We are currently experiencing problems with the @[eqns]
attribute on the Lean nightlies. I'm uncertain yet what the outcome is going to be there, but it seems prudent to reduce our unnecessary exposure to a language feature added in Mathlib.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -1240,8 +1240,7 @@ def K'.elim (a b c d : List Γ') : K' → List Γ'
| K'.stack => d
#align turing.partrec_to_TM2.K'.elim Turing.PartrecToTM2.K'.elim
-/- Porting note: The equation lemma of `elim` simplifies to `match` structures. To prevent this,
-we replace equation lemmas of `elim`. -/
+-- The equation lemma of `elim` simplifies to `match` structures.
theorem K'.elim_main (a b c d) : K'.elim a b c d K'.main = a := rfl
@@ -1251,7 +1250,6 @@ theorem K'.elim_aux (a b c d) : K'.elim a b c d K'.aux = c := rfl
theorem K'.elim_stack (a b c d) : K'.elim a b c d K'.stack = d := rfl
-attribute [eqns K'.elim_main K'.elim_rev K'.elim_aux K'.elim_stack] K'.elim
attribute [simp] K'.elim
@[simp]
@@ -1463,10 +1463,10 @@ theorem head_main_ok {q s L} {c d : List Γ'} :
(move_ok (by decide)
(splitAtPred_eq _ _ (trNat L.headI) o (trList L.tail) (trNat_natEnd _) _)).trans
(TransGen.head rfl (TransGen.head rfl _))
- · cases L <;> simp
+ · cases L <;> simp [o]
simp only [TM2.step, Option.mem_def, TM2.stepAux, elim_update_main, elim_rev, elim_update_rev,
Function.update_same, trList]
- rw [if_neg (show o ≠ some Γ'.consₗ by cases L <;> simp)]
+ rw [if_neg (show o ≠ some Γ'.consₗ by cases L <;> simp [o])]
refine' (clear_ok (splitAtPred_eq _ _ _ none [] _ ⟨rfl, rfl⟩)).trans _
· exact fun x h => Bool.decide_false (trList_ne_consₗ _ _ h)
convert unrev_ok using 2; simp [List.reverseAux_eq]
@@ -1600,7 +1600,7 @@ theorem trNormal_respects (c k v s) :
let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
- cases v <;> simp
+ cases v <;> simp [o]
| cons f fs IHf _ =>
obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
cases x with | ...
instead of cases x; case => ...
(#9321)
This converts usages of the pattern
cases h
case inl h' => ...
case inr h' => ...
which derive from mathported code, to the "structured cases
" syntax:
cases h with
| inl h' => ...
| inr h' => ...
The case where the subgoals are handled with ·
instead of case
is more contentious (and much more numerous) so I left those alone. This pattern also appears with cases'
, induction
, induction'
, and rcases
. Furthermore, there is a similar transformation for by_cases
:
by_cases h : cond
case pos => ...
case neg => ...
is replaced by:
if h : cond then
...
else
...
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -284,56 +284,57 @@ theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector
theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v := by
- induction' hf with n f hf
- induction hf
- case prim.zero => exact ⟨zero', fun ⟨[], _⟩ => rfl⟩
- case prim.succ => exact ⟨succ, fun ⟨[v], _⟩ => rfl⟩
- case prim.get n i =>
- refine' Fin.succRec (fun n => _) (fun n i IH => _) i
- · exact ⟨head, fun ⟨List.cons a as, _⟩ => by simp [Bind.bind]; rfl⟩
- · obtain ⟨c, h⟩ := IH
- exact ⟨c.comp tail, fun v => by simpa [← Vector.get_tail, Bind.bind] using h v.tail⟩
- case prim.comp m n f g hf hg IHf IHg =>
- simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg
- case prim.prec n f g _ _ IHf IHg =>
- obtain ⟨cf, hf⟩ := IHf
- obtain ⟨cg, hg⟩ := IHg
- simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
- refine' ⟨prec cf cg, fun v => _⟩
- rw [← v.cons_head_tail]
- specialize hf v.tail
- replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
- simp only [Vector.cons_val, Vector.tail_val] at hf hg
- simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons,
- PFun.coe_val, Vector.tail_val]
- simp only [← Part.pure_eq_some] at hf hg ⊢
- induction' v.head with n _ <;>
- simp [prec, hf, Part.bind_assoc, ← Part.bind_some_eq_map, Part.bind_some,
- show ∀ x, pure x = [x] from fun _ => rfl, Bind.bind, Functor.map]
- suffices ∀ a b, a + b = n →
- (n.succ :: 0 ::
- g (n ::ᵥ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ v.tail) ::
- v.val.tail : List ℕ) ∈
- PFun.fix
- (fun v : List ℕ => Part.bind (cg.eval (v.headI :: v.tail.tail))
- (fun x => Part.some (if v.tail.headI = 0
- then Sum.inl
- (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail : List ℕ)
- else Sum.inr
- (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail))))
- (a :: b :: Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a :: v.val.tail) by
- erw [Part.eq_some_iff.2 (this 0 n (zero_add n))]
- simp only [List.headI, Part.bind_some, List.tail_cons]
- intro a b e
- induction' b with b IH generalizing a
- · refine' PFun.mem_fix_iff.2 (Or.inl <| Part.eq_some_iff.1 _)
- simp only [hg, ← e, Part.bind_some, List.tail_cons, pure]
- rfl
- · refine' PFun.mem_fix_iff.2 (Or.inr ⟨_, _, IH (a + 1) (by rwa [add_right_comm])⟩)
- simp only [hg, eval, Part.bind_some, Nat.rec_add_one, List.tail_nil, List.tail_cons, pure]
- exact Part.mem_some_iff.2 rfl
- case comp m n f g _ _ IHf IHg => exact exists_code.comp IHf IHg
- case rfind n f _ IHf =>
+ induction hf with
+ | prim hf =>
+ induction hf with
+ | zero => exact ⟨zero', fun ⟨[], _⟩ => rfl⟩
+ | succ => exact ⟨succ, fun ⟨[v], _⟩ => rfl⟩
+ | get i =>
+ refine' Fin.succRec (fun n => _) (fun n i IH => _) i
+ · exact ⟨head, fun ⟨List.cons a as, _⟩ => by simp [Bind.bind]; rfl⟩
+ · obtain ⟨c, h⟩ := IH
+ exact ⟨c.comp tail, fun v => by simpa [← Vector.get_tail, Bind.bind] using h v.tail⟩
+ | comp g hf hg IHf IHg =>
+ simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg
+ | @prec n f g _ _ IHf IHg =>
+ obtain ⟨cf, hf⟩ := IHf
+ obtain ⟨cg, hg⟩ := IHg
+ simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg
+ refine' ⟨prec cf cg, fun v => _⟩
+ rw [← v.cons_head_tail]
+ specialize hf v.tail
+ replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail)
+ simp only [Vector.cons_val, Vector.tail_val] at hf hg
+ simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons,
+ Vector.head_cons, PFun.coe_val, Vector.tail_val]
+ simp only [← Part.pure_eq_some] at hf hg ⊢
+ induction' v.head with n _ <;>
+ simp [prec, hf, Part.bind_assoc, ← Part.bind_some_eq_map, Part.bind_some,
+ show ∀ x, pure x = [x] from fun _ => rfl, Bind.bind, Functor.map]
+ suffices ∀ a b, a + b = n →
+ (n.succ :: 0 ::
+ g (n ::ᵥ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ v.tail) ::
+ v.val.tail : List ℕ) ∈
+ PFun.fix
+ (fun v : List ℕ => Part.bind (cg.eval (v.headI :: v.tail.tail))
+ (fun x => Part.some (if v.tail.headI = 0
+ then Sum.inl
+ (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail : List ℕ)
+ else Sum.inr
+ (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail))))
+ (a :: b :: Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a :: v.val.tail) by
+ erw [Part.eq_some_iff.2 (this 0 n (zero_add n))]
+ simp only [List.headI, Part.bind_some, List.tail_cons]
+ intro a b e
+ induction' b with b IH generalizing a
+ · refine' PFun.mem_fix_iff.2 (Or.inl <| Part.eq_some_iff.1 _)
+ simp only [hg, ← e, Part.bind_some, List.tail_cons, pure]
+ rfl
+ · refine' PFun.mem_fix_iff.2 (Or.inr ⟨_, _, IH (a + 1) (by rwa [add_right_comm])⟩)
+ simp only [hg, eval, Part.bind_some, Nat.rec_add_one, List.tail_nil, List.tail_cons, pure]
+ exact Part.mem_some_iff.2 rfl
+ | comp g _ _ IHf IHg => exact exists_code.comp IHf IHg
+ | @rfind n f _ IHf =>
obtain ⟨cf, hf⟩ := IHf; refine' ⟨rfind cf, fun v => _⟩
replace hf := fun a => hf (a ::ᵥ v)
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, PFun.coe_val,
@@ -566,30 +567,30 @@ equality, not a simulation; the original and embedded machines move in lock-step
embedded machine reaches the halt state. -/
theorem stepNormal_then (c) (k k' : Cont) (v) :
stepNormal c (k.then k') v = (stepNormal c k v).then k' := by
- induction c generalizing k v <;> simp only [Cont.then, stepNormal, *] <;>
- try { simp only [Cfg.then]; done }
- case cons c c' ih _ => rw [← ih, Cont.then]
- case comp c c' _ ih' => rw [← ih', Cont.then]
- · cases v.headI <;> simp only [Nat.rec]
- case fix c ih => rw [← ih, Cont.then]
+ induction c generalizing k v with simp only [Cont.then, stepNormal, *]
+ | cons c c' ih _ => rw [← ih, Cont.then]
+ | comp c c' _ ih' => rw [← ih', Cont.then]
+ | case => cases v.headI <;> simp only [Nat.rec]
+ | fix c ih => rw [← ih, Cont.then]
+ | _ => simp only [Cfg.then]
#align turing.to_partrec.step_normal_then Turing.ToPartrec.stepNormal_then
/-- The `stepRet` function respects the `then k'` homomorphism. Note that this is an exact
equality, not a simulation; the original and embedded machines move in lock-step until the
embedded machine reaches the halt state. -/
theorem stepRet_then {k k' : Cont} {v} : stepRet (k.then k') v = (stepRet k v).then k' := by
- induction k generalizing v <;> simp only [Cont.then, stepRet, *] <;>
- try { simp only [Cfg.then]; done }
- case cons₁ =>
+ induction k generalizing v with simp only [Cont.then, stepRet, *]
+ | cons₁ =>
rw [← stepNormal_then]
rfl
- case comp =>
+ | comp =>
rw [← stepNormal_then]
- case fix _ k_ih =>
+ | fix _ _ k_ih =>
split_ifs
· rw [← k_ih]
· rw [← stepNormal_then]
rfl
+ | _ => simp only [Cfg.then]
#align turing.to_partrec.step_ret_then Turing.ToPartrec.stepRet_then
/-- This is a temporary definition, because we will prove in `code_is_ok` that it always holds.
@@ -611,15 +612,15 @@ theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zero
theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v' := by
- induction c generalizing k v
- iterate 3 exact ⟨_, _, rfl⟩
- case cons _f fs IHf _IHfs => apply IHf
- case comp f _g _IHf IHg => apply IHg
- case case f g IHf IHg =>
+ induction c generalizing k v with
+ | cons _f fs IHf _IHfs => apply IHf
+ | comp f _g _IHf IHg => apply IHg
+ | case f g IHf IHg =>
rw [stepNormal]
simp only []
cases v.headI <;> simp only [] <;> [apply IHf; apply IHg]
- case fix f IHf => apply IHf
+ | fix f IHf => apply IHf
+ | _ => exact ⟨_, _, rfl⟩
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
@@ -696,23 +697,23 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
#align turing.to_partrec.cont_eval_fix Turing.ToPartrec.cont_eval_fix
theorem code_is_ok (c) : Code.Ok c := by
- induction c <;> intro k v <;> rw [stepNormal]
- iterate 3 simp only [Code.eval, pure_bind]
- case cons f fs IHf IHfs =>
+ induction c with (intro k v; rw [stepNormal])
+ | cons f fs IHf IHfs =>
rw [Code.eval, IHf]
simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [stepRet, IHfs]; congr; funext v'
refine' Eq.trans _ (Eq.symm _) <;> try exact reaches_eval (ReflTransGen.single rfl)
- case comp f g IHf IHg =>
+ | comp f g IHf IHg =>
rw [Code.eval, IHg]
simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [stepRet, IHf]
- case case f g IHf IHg =>
+ | case f g IHf IHg =>
simp only [Code.eval]
cases v.headI <;> simp only [Code.eval] <;> [apply IHf; apply IHg]
- case fix f IHf => rw [cont_eval_fix IHf]
+ | fix f IHf => rw [cont_eval_fix IHf]
+ | _ => simp only [Code.eval, pure_bind]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
theorem stepNormal_eval (c v) : eval step (stepNormal c Cont.halt v) = Cfg.halt <$> c.eval v :=
@@ -720,22 +721,22 @@ theorem stepNormal_eval (c v) : eval step (stepNormal c Cont.halt v) = Cfg.halt
#align turing.to_partrec.step_normal_eval Turing.ToPartrec.stepNormal_eval
theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v := by
- induction k generalizing v
- case halt =>
+ induction k generalizing v with
+ | halt =>
simp only [mem_eval, Cont.eval, map_pure]
exact Part.eq_some_iff.2 (mem_eval.2 ⟨ReflTransGen.refl, rfl⟩)
- case cons₁ fs as k IH =>
+ | cons₁ fs as k IH =>
rw [Cont.eval, stepRet, code_is_ok]
simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [stepRet, IH, bind_pure_comp]
- case cons₂ ns k IH => rw [Cont.eval, stepRet]; exact IH
- case comp f k IH =>
+ | cons₂ ns k IH => rw [Cont.eval, stepRet]; exact IH
+ | comp f k IH =>
rw [Cont.eval, stepRet, code_is_ok]
simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [IH, bind_pure_comp]
- case fix f k IH =>
+ | fix f k IH =>
rw [Cont.eval, stepRet]; simp only [bind_pure_comp]
split_ifs; · exact IH
simp only [← bind_pure_comp, bind_assoc, cont_eval_fix (code_is_ok _)]
@@ -947,31 +948,9 @@ instance Λ'.instInhabited : Inhabited Λ' :=
#align turing.partrec_to_TM2.Λ'.inhabited Turing.PartrecToTM2.Λ'.instInhabited
instance Λ'.instDecidableEq : DecidableEq Λ' := fun a b => by
- induction a generalizing b <;> cases b <;> try apply Decidable.isFalse; rintro ⟨⟨⟩⟩; done
- case move.move _ _ _ _ I _ _ _ _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case clear.clear _ _ _ I _ _ _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case copy.copy _ I _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case push.push _ _ _ I _ _ _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case read.read _ I _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case succ.succ _ I _ =>
- letI := I
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case pred.pred _ _ I₁ I₂ _ _ =>
- letI := I₁
- letI := I₂
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
- case ret.ret _ _ =>
- exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
+ induction a generalizing b <;> cases b <;> first
+ | apply Decidable.isFalse; rintro ⟨⟨⟩⟩; done
+ | exact decidable_of_iff' _ (by simp [Function.funext_iff]; rfl)
#align turing.partrec_to_TM2.Λ'.decidable_eq Turing.PartrecToTM2.Λ'.instDecidableEq
/-- The type of TM2 statements used by this machine. -/
@@ -1614,16 +1593,15 @@ theorem trNormal_respects (c k v s) :
TrCfg (stepNormal c k v) b₂ ∧
Reaches₁ (TM2.step tr)
⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
- induction c generalizing k v s
- case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
- case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
- case tail =>
+ induction c generalizing k v s with
+ | zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
+ | succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
+ | tail =>
let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
cases v <;> simp
- case
- cons f fs IHf _ =>
+ | cons f fs IHf _ =>
obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
@@ -1631,8 +1609,8 @@ theorem trNormal_respects (c k v s) :
refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
convert h₂ using 2
simp [List.reverseAux_eq, trContStack]
- case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
- case case f g IHf IHg =>
+ | comp f _ _ IHg => exact IHg (Cont.comp f k) v s
+ | case f g IHf IHg =>
rw [stepNormal]
simp only
obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
@@ -1641,17 +1619,16 @@ theorem trNormal_respects (c k v s) :
exact ⟨_, h₁, h.trans h₂⟩
· obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
exact ⟨_, h₁, h.trans h₂⟩
- case fix f IH => apply IH
+ | fix f IH => apply IH
#align turing.partrec_to_TM2.tr_normal_respects Turing.PartrecToTM2.trNormal_respects
theorem tr_ret_respects (k v s) : ∃ b₂,
TrCfg (stepRet k v) b₂ ∧
Reaches₁ (TM2.step tr)
⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
- induction k generalizing v s
- case halt => exact ⟨_, rfl, TransGen.single rfl⟩
- case
- cons₁ fs as k _ =>
+ induction k generalizing v s with
+ | halt => exact ⟨_, rfl, TransGen.single rfl⟩
+ | cons₁ fs as k _ =>
obtain ⟨s', h₁, h₂⟩ := trNormal_respects fs (Cont.cons₂ v k) as none
refine' ⟨s', h₁, TransGen.head rfl _⟩; simp
refine' (move₂_ok (by decide) _ (splitAtPred_false _)).trans _; · rfl
@@ -1667,13 +1644,13 @@ theorem tr_ret_respects (k v s) : ∃ b₂,
List.append_nil, elim_update_main, id_eq, elim_update_aux, ne_eq, Function.update_noteq,
elim_aux, elim_stack]
exact h₂
- case cons₂ ns k IH =>
+ | cons₂ ns k IH =>
obtain ⟨c, h₁, h₂⟩ := IH (ns.headI :: v) none
exact ⟨c, h₁, TransGen.head rfl <| head_stack_ok.trans h₂⟩
- case comp f k _ =>
+ | comp f k _ =>
obtain ⟨s', h₁, h₂⟩ := trNormal_respects f k v s
exact ⟨_, h₁, TransGen.head rfl h₂⟩
- case fix f k IH =>
+ | fix f k IH =>
rw [stepRet]
have :
if v.headI = 0 then natEnd (trList v).head?.iget = true ∧ (trList v).tail = trList v.tail
@@ -1953,12 +1930,12 @@ theorem head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S
theorem ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (Λ'.ret k)) := by
have W := fun {q} => trStmts₁_self q
- cases k
- case halt => trivial
- case cons₁ => rw [contSupp_cons₁, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
- case cons₂ => rw [contSupp_cons₂, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
- case comp => rw [contSupp_comp] at H₁; exact fun _ => H₁ (codeSupp_self _ _ W)
- case fix =>
+ cases k with
+ | halt => trivial
+ | cons₁ => rw [contSupp_cons₁, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
+ | cons₂ => rw [contSupp_cons₂, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
+ | comp => rw [contSupp_comp] at H₁; exact fun _ => H₁ (codeSupp_self _ _ W)
+ | fix =>
rw [contSupp_fix] at H₁
have L := @Finset.mem_union_left; have R := @Finset.mem_union_right
intro s; dsimp only; cases natEnd s.iget
@@ -1998,27 +1975,24 @@ theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStm
#align turing.partrec_to_TM2.tr_stmts₁_supports' Turing.PartrecToTM2.trStmts₁_supports'
theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Supports S := by
- induction c generalizing k <;> simp [Λ'.Supports, head]
- case zero' => exact Finset.union_subset_right Hk
- case succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
- case tail => exact Finset.union_subset_right Hk
- case cons f fs IHf _ =>
+ induction c generalizing k with simp [Λ'.Supports, head]
+ | zero' => exact Finset.union_subset_right Hk
+ | succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
+ | tail => exact Finset.union_subset_right Hk
+ | cons f fs IHf _ =>
apply IHf
rw [codeSupp_cons] at Hk
exact Finset.union_subset_right Hk
- case comp f g _ IHg => apply IHg; rw [codeSupp_comp] at Hk; exact Finset.union_subset_right Hk
- case
- case f g IHf IHg =>
+ | comp f g _ IHg => apply IHg; rw [codeSupp_comp] at Hk; exact Finset.union_subset_right Hk
+ | case f g IHf IHg =>
simp only [codeSupp_case, Finset.union_subset_iff] at Hk
exact ⟨IHf Hk.2.1, IHg Hk.2.2⟩
- case fix f IHf => apply IHf; rw [codeSupp_fix] at Hk; exact Finset.union_subset_right Hk
+ | fix f IHf => apply IHf; rw [codeSupp_fix] at Hk; exact Finset.union_subset_right Hk
#align turing.partrec_to_TM2.tr_normal_supports Turing.PartrecToTM2.trNormal_supports
theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp' c k) S := by
- induction c generalizing k
- iterate 3
- exact trStmts₁_supports (trNormal_supports H) (Finset.Subset.trans (codeSupp_self _ _) H)
- case cons f fs IHf IHfs =>
+ induction c generalizing k with
+ | cons f fs IHf IHfs =>
have H' := H; simp only [codeSupp_cons, Finset.union_subset_iff] at H'
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
@@ -2031,7 +2005,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
exact
trStmts₁_supports (head_supports <| Finset.union_subset_right H)
(Finset.union_subset_right h)
- case comp f g IHf IHg =>
+ | comp f g IHf IHg =>
have H' := H; rw [codeSupp_comp] at H'; have H' := Finset.union_subset_right H'
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHg H', _⟩
@@ -2039,11 +2013,11 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
· simp only [codeSupp', codeSupp, Finset.union_subset_iff, contSupp] at h H ⊢
exact ⟨h.2.2, H.2⟩
exact IHf (Finset.union_subset_right H')
- case case f g IHf IHg =>
+ | case f g IHf IHg =>
have H' := H; simp only [codeSupp_case, Finset.union_subset_iff] at H'
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun _ => _
exact supports_union.2 ⟨IHf H'.2.1, IHg H'.2.2⟩
- case fix f IHf =>
+ | fix f IHf =>
have H' := H; simp only [codeSupp_fix, Finset.union_subset_iff] at H'
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
@@ -2052,24 +2026,25 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
Finset.insert_subset_iff] at h H ⊢
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
+ | _ => exact trStmts₁_supports (trNormal_supports H) (Finset.Subset.trans (codeSupp_self _ _) H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
theorem contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S := by
- induction k
- · simp [contSupp_halt, Supports]
- case cons₁ f k IH =>
+ induction k with
+ | halt => simp [contSupp_halt, Supports]
+ | cons₁ f k IH =>
have H₁ := H; rw [contSupp_cons₁] at H₁; have H₂ := Finset.union_subset_right H₁
refine' trStmts₁_supports' (trNormal_supports H₂) H₁ fun h => _
refine' supports_union.2 ⟨codeSupp'_supports H₂, _⟩
simp only [codeSupp, contSupp_cons₂, Finset.union_subset_iff] at H₂
exact trStmts₁_supports' (head_supports H₂.2.2) (Finset.union_subset_right h) IH
- case cons₂ k IH =>
+ | cons₂ k IH =>
have H' := H; rw [contSupp_cons₂] at H'
exact trStmts₁_supports' (head_supports <| Finset.union_subset_right H') H' IH
- case comp f k IH =>
+ | comp f k IH =>
have H' := H; rw [contSupp_comp] at H'; have H₂ := Finset.union_subset_right H'
exact supports_union.2 ⟨codeSupp'_supports H', IH H₂⟩
- case fix f k IH =>
+ | fix f k IH =>
rw [contSupp] at H
exact supports_union.2 ⟨codeSupp'_supports H, IH (Finset.union_subset_right H)⟩
#align turing.partrec_to_TM2.cont_supp_supports Turing.PartrecToTM2.contSupp_supports
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -341,9 +341,9 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
refine' Part.ext fun x => _
simp only [rfind, Part.bind_eq_bind, Part.pure_eq_some, Part.map_eq_map, Part.bind_some,
exists_prop, cons_eval, comp_eval, fix_eval, tail_eval, succ_eval, zero'_eval,
- List.headI_nil, List.headI_cons, pred_eval, Part.map_some, Bool.false_eq_decide_iff,
+ List.headI_nil, List.headI_cons, pred_eval, Part.map_some, false_eq_decide_iff,
Part.mem_bind_iff, List.length, Part.mem_map_iff, Nat.mem_rfind, List.tail_nil,
- List.tail_cons, Bool.true_eq_decide_iff, Part.mem_some_iff, Part.map_bind]
+ List.tail_cons, true_eq_decide_iff, Part.mem_some_iff, Part.map_bind]
constructor
· rintro ⟨v', h1, rfl⟩
suffices ∀ v₁ : List ℕ, v' ∈ PFun.fix
@@ -1545,7 +1545,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (trPosNum a ++ [Γ'.cons]) l₁ c d⟩
⟨some (unrev q), s', K'.elim (l₂' ++ [Γ'.cons]) l₁' c d⟩ by
obtain ⟨l₁', l₂', s', e, h⟩ := this []
- simp [List.reverseAux] at e
+ simp? [List.reverseAux] at e says simp only [List.reverseAux] at e
refine' h.trans _
convert unrev_ok using 2
simp [e, List.reverseAux_eq]
@@ -1590,7 +1590,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s',
⟨some (q₁.pred q₂), s, K'.elim (trPosNum a.succ ++ Γ'.cons :: trList v) l₁ c d⟩
⟨some (unrev q₂), s', K'.elim (l₂' ++ Γ'.cons :: trList v) l₁' c d⟩ by
obtain ⟨l₁', l₂', s', e, h⟩ := this []
- simp [List.reverseAux] at e
+ simp only [List.reverseAux] at e
refine' h.trans _
convert unrev_ok using 2
simp [e, List.reverseAux_eq]
@@ -1729,7 +1729,8 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
exact ⟨_, hv, hc₁.symm⟩
· rintro ⟨v', hv, rfl⟩
have := Turing.tr_eval (b₁ := Cfg.halt v') tr_respects h₁
- simp [stepNormal_eval, -TM2.step] at this
+ simp only [stepNormal_eval, Part.map_eq_map, Part.mem_map_iff, Cfg.halt.injEq,
+ exists_eq_right] at this
obtain ⟨_, ⟨⟩, h⟩ := this hv
exact h
#align turing.partrec_to_TM2.tr_eval Turing.PartrecToTM2.tr_eval
@@ -1992,7 +1993,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStmts₁ q ∪ K ⊆ S)
(H₃ : K ⊆ S → Supports K S) : Supports (trStmts₁ q ∪ K) S := by
- simp [Finset.union_subset_iff] at H₂
+ simp only [Finset.union_subset_iff] at H₂
exact supports_union.2 ⟨trStmts₁_supports H₁ H₂.1, H₃ H₂.2⟩
#align turing.partrec_to_TM2.tr_stmts₁_supports' Turing.PartrecToTM2.trStmts₁_supports'
I've also got a change to make this required, but I'd like to land this first.
@@ -1686,7 +1686,7 @@ theorem tr_ret_respects (k v s) : ∃ b₂,
· simp
rw [trList, List.headI, trNat, Nat.cast_succ, Num.add_one, Num.succ, List.tail]
cases (n : Num).succ' <;> exact ⟨rfl, rfl⟩
- by_cases v.headI = 0 <;> simp only [h, ite_true, ite_false] at this ⊢
+ by_cases h : v.headI = 0 <;> simp only [h, ite_true, ite_false] at this ⊢
· obtain ⟨c, h₁, h₂⟩ := IH v.tail (trList v).head?
refine' ⟨c, h₁, TransGen.head rfl _⟩
simp only [Option.mem_def, TM2.stepAux, trContStack, contStack, elim_main, this, cond_true,
This is the supremum of
along with some minor fixes from failures on nightly-testing as Mathlib master
is merged into it.
Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.
I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0
branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.
In particular this includes adjustments for the Lean PRs
We can get rid of all the
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)
macros across Mathlib (and in any projects that want to write natural number powers of reals).
Changes the default behaviour of simp
to (config := {decide := false})
. This makes simp
(and consequentially norm_num
) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp
or norm_num
to decide
or rfl
, or adding (config := {decide := true})
.
This changed the behaviour of simp
so that simp [f]
will only unfold "fully applied" occurrences of f
. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true })
. We may in future add a syntax for this, e.g. simp [!f]
; please provide feedback! In the meantime, we have made the following changes:
(config := { unfoldPartialApp := true })
in some places, to recover the old behaviour@[eqns]
to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp
and Function.flip
.This change in Lean may require further changes down the line (e.g. adding the !f
syntax, and/or upstreaming the special treatment for Function.comp
and Function.flip
, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>
@@ -1536,7 +1536,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
simp only [Option.mem_def, TM2.stepAux, elim_main, decide_False, elim_update_main, ne_eq,
Function.update_noteq, elim_rev, elim_update_rev, decide_True, Function.update_same,
cond_true, cond_false]
- convert unrev_ok using 2
+ convert unrev_ok using 1
simp only [elim_update_rev, elim_rev, elim_main, List.reverseAux_nil, elim_update_main]
rfl
simp only [trNum, Num.succ, Num.succ']
Removes nonterminal simps on lines looking like simp [...]
@@ -1375,7 +1375,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
rcases e₃ : splitAtPred p Sk with ⟨_, _, _⟩
rw [e₃] at e
cases e
- simp [e₂]
+ simp only [List.head?_cons, e₂, List.tail_cons, ne_eq, cond_false]
convert @IH _ (update (update S k₁ Sk) k₂ (a :: S k₂)) _ using 2 <;>
simp [Function.update_noteq, h₁, h₁.symm, e₃, List.reverseAux]
simp [Function.update_comm h₁.symm]
@@ -1433,7 +1433,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
rcases e₃ : splitAtPred p Sk with ⟨_, _, _⟩
rw [e₃] at e
cases e
- simp [e₂]
+ simp only [List.head?_cons, e₂, List.tail_cons, cond_false]
convert @IH _ (update S k Sk) _ using 2 <;> simp [e₃]
#align turing.partrec_to_TM2.clear_ok Turing.PartrecToTM2.clear_ok
@@ -1530,7 +1530,7 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
theorem succ_ok {q s n} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (Λ'.succ q), s, K'.elim (trList [n]) [] c d⟩
⟨some q, none, K'.elim (trList [n.succ]) [] c d⟩ := by
- simp [trNat, Num.add_one]
+ simp only [TM2.step, trList, trNat._eq_1, Nat.cast_succ, Num.add_one]
cases' (n : Num) with a
· refine' TransGen.head rfl _
simp only [Option.mem_def, TM2.stepAux, elim_main, decide_False, elim_update_main, ne_eq,
@@ -1539,7 +1539,7 @@ theorem succ_ok {q s n} {c d : List Γ'} :
convert unrev_ok using 2
simp only [elim_update_rev, elim_rev, elim_main, List.reverseAux_nil, elim_update_main]
rfl
- simp [Num.succ, trNum, Num.succ']
+ simp only [trNum, Num.succ, Num.succ']
suffices ∀ l₁, ∃ l₁' l₂' s',
List.reverseAux l₁ (trPosNum a.succ) = List.reverseAux l₁' l₂' ∧
Reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (trPosNum a ++ [Γ'.cons]) l₁ c d⟩
@@ -1573,7 +1573,8 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s',
· refine' ⟨some Γ'.cons, TransGen.single _⟩
simp
refine' ⟨none, _⟩
- simp [trNat, Num.add_one, Num.succ, trNum]
+ simp only [TM2.step, trList, trNat._eq_1, trNum, Nat.cast_succ, Num.add_one, Num.succ,
+ List.tail_cons, List.headI_cons]
cases' (n : Num) with a
· simp [trPosNum, trNum, show Num.zero.succ' = PosNum.one from rfl]
refine' TransGen.head rfl _
@@ -1582,7 +1583,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s',
elim_update_rev, natEnd, Function.update_same, cond_true, cond_false]
convert unrev_ok using 2
simp
- simp [trNum, Num.succ']
+ simp only [Num.succ']
suffices ∀ l₁, ∃ l₁' l₂' s',
List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
Reaches₁ (TM2.step tr)
@@ -1625,7 +1626,8 @@ theorem trNormal_respects (c k v s) :
cons f fs IHf _ =>
obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
- simp [stepNormal]
+ simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
+ Function.update_noteq, elim_main, elim_rev, elim_update_rev]
refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
convert h₂ using 2
simp [List.reverseAux_eq, trContStack]
@@ -1687,11 +1689,13 @@ theorem tr_ret_respects (k v s) : ∃ b₂,
by_cases v.headI = 0 <;> simp only [h, ite_true, ite_false] at this ⊢
· obtain ⟨c, h₁, h₂⟩ := IH v.tail (trList v).head?
refine' ⟨c, h₁, TransGen.head rfl _⟩
- simp [trCont, trContStack, this, -TM2.step, -natEnd]
+ simp only [Option.mem_def, TM2.stepAux, trContStack, contStack, elim_main, this, cond_true,
+ elim_update_main]
exact h₂
· obtain ⟨s', h₁, h₂⟩ := trNormal_respects f (Cont.fix f k) v.tail (some Γ'.cons)
refine' ⟨_, h₁, TransGen.head rfl <| TransGen.trans _ h₂⟩
- simp [trCont, this.1, -TM2.step, -natEnd]
+ simp only [Option.mem_def, TM2.stepAux, elim_main, this.1, cond_false, elim_update_main,
+ trCont]
convert clear_ok (splitAtPred_eq _ _ (trNat v.headI).tail (some Γ'.cons) _ _ _) using 2
· simp
convert rfl
@@ -1851,7 +1855,7 @@ theorem codeSupp_cons (f fs k) :
theorem codeSupp_comp (f g k) :
codeSupp (Code.comp f g) k =
trStmts₁ (trNormal (Code.comp f g) k) ∪ codeSupp g (Cont'.comp f k) := by
- simp [codeSupp, codeSupp', contSupp, Finset.union_assoc]
+ simp only [codeSupp, codeSupp', trNormal, Finset.union_assoc, contSupp]
rw [← Finset.union_assoc _ _ (contSupp k),
Finset.union_eq_right.2 (codeSupp'_self _ _)]
#align turing.partrec_to_TM2.code_supp_comp Turing.PartrecToTM2.codeSupp_comp
@@ -1356,7 +1356,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
· rw [Function.update_noteq h₁.symm]
rfl
refine' TransGen.head' rfl _
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim, ne_eq]
revert e; cases' S k₁ with a Sk <;> intro e
· cases e
rfl
@@ -1366,7 +1366,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
· simp only [e]
rfl
· refine' TransGen.head rfl _
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim, ne_eq, List.reverseAux_cons]
cases' e₁ : S k₁ with a' Sk <;> rw [e₁, splitAtPred] at e
· cases e
cases e₂ : p a' <;> simp only [e₂, cond] at e
@@ -1392,7 +1392,7 @@ theorem move₂_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k
Reaches₁ (TM2.step tr) ⟨some (move₂ p k₁ k₂ q), s, S⟩
⟨some q, none, update (update S k₁ (o.elim id List.cons L₂)) k₂ (L₁ ++ S k₂)⟩ := by
refine' (move_ok h₁.1 e).trans (TransGen.head rfl _)
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, id_eq, ne_eq, Option.elim]
cases o <;> simp only [Option.elim, id.def]
· simp only [TM2.stepAux, Option.isSome, cond_false]
convert move_ok h₁.2.1.symm (splitAtPred_false _) using 2
@@ -1414,7 +1414,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
Reaches₁ (TM2.step tr) ⟨some (Λ'.clear p k q), s, S⟩ ⟨some q, o, update S k L₂⟩ := by
induction' L₁ with a L₁ IH generalizing S s
· refine' TransGen.head' rfl _
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim]
revert e; cases' S k with a Sk <;> intro e
· cases e
rfl
@@ -1424,7 +1424,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p
· rcases e with ⟨e₁, e₂⟩
rw [e₁, e₂]
· refine' TransGen.head rfl _
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, Option.elim]
cases' e₁ : S k with a' Sk <;> rw [e₁, splitAtPred] at e
· cases e
cases e₂ : p a' <;> simp only [e₂, cond] at e
@@ -1444,7 +1444,9 @@ theorem copy_ok (q s a b c d) :
· refine' TransGen.single _
simp
refine' TransGen.head rfl _
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, elim_rev, List.head?_cons, Option.isSome_some,
+ List.tail_cons, elim_update_rev, ne_eq, Function.update_noteq, elim_main, elim_update_main,
+ elim_stack, elim_update_stack, cond_true, List.reverseAux_cons]
exact IH _ _ _
#align turing.partrec_to_TM2.copy_ok Turing.PartrecToTM2.copy_ok
@@ -1483,7 +1485,8 @@ theorem head_main_ok {q s L} {c d : List Γ'} :
(splitAtPred_eq _ _ (trNat L.headI) o (trList L.tail) (trNat_natEnd _) _)).trans
(TransGen.head rfl (TransGen.head rfl _))
· cases L <;> simp
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, elim_update_main, elim_rev, elim_update_rev,
+ Function.update_same, trList]
rw [if_neg (show o ≠ some Γ'.consₗ by cases L <;> simp)]
refine' (clear_ok (splitAtPred_eq _ _ _ none [] _ ⟨rfl, rfl⟩)).trans _
· exact fun x h => Bool.decide_false (trList_ne_consₗ _ _ h)
@@ -1500,7 +1503,9 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
(move_ok (by decide)
(splitAtPred_eq _ _ [] (some Γ'.consₗ) L₃ (by rintro _ ⟨⟩) ⟨rfl, rfl⟩))
(TransGen.head rfl (TransGen.head rfl _))
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, ite_true, id_eq, trList, List.nil_append,
+ elim_update_stack, elim_rev, List.reverseAux_nil, elim_update_rev, Function.update_same,
+ List.headI_nil, trNat_default]
convert unrev_ok using 2
simp
· refine'
@@ -1509,7 +1514,9 @@ theorem head_stack_ok {q s L₁ L₂ L₃} :
(splitAtPred_eq _ _ (trNat a) (some Γ'.cons) (trList L₂ ++ Γ'.consₗ :: L₃)
(trNat_natEnd _) ⟨rfl, by simp⟩))
(TransGen.head rfl (TransGen.head rfl _))
- simp
+ simp only [TM2.step, Option.mem_def, TM2.stepAux, ite_false, trList, List.append_assoc,
+ List.cons_append, elim_update_stack, elim_rev, elim_update_rev, Function.update_same,
+ List.headI_cons]
refine'
TransGen.trans
(clear_ok
@@ -1526,9 +1533,11 @@ theorem succ_ok {q s n} {c d : List Γ'} :
simp [trNat, Num.add_one]
cases' (n : Num) with a
· refine' TransGen.head rfl _
- simp
+ simp only [Option.mem_def, TM2.stepAux, elim_main, decide_False, elim_update_main, ne_eq,
+ Function.update_noteq, elim_rev, elim_update_rev, decide_True, Function.update_same,
+ cond_true, cond_false]
convert unrev_ok using 2
- simp
+ simp only [elim_update_rev, elim_rev, elim_main, List.reverseAux_nil, elim_update_main]
rfl
simp [Num.succ, trNum, Num.succ']
suffices ∀ l₁, ∃ l₁' l₂' s',
@@ -1548,7 +1557,8 @@ theorem succ_ok {q s n} {c d : List Γ'} :
simp [PosNum.succ, trPosNum]
rfl
· refine' ⟨l₁, _, some Γ'.bit0, rfl, TransGen.single _⟩
- simp
+ simp only [TM2.step, TM2.stepAux, elim_main, elim_update_main, ne_eq, Function.update_noteq,
+ elim_rev, elim_update_rev, Function.update_same, Option.mem_def, Option.some.injEq]
rfl
#align turing.partrec_to_TM2.succ_ok Turing.PartrecToTM2.succ_ok
@@ -1567,7 +1577,9 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s',
cases' (n : Num) with a
· simp [trPosNum, trNum, show Num.zero.succ' = PosNum.one from rfl]
refine' TransGen.head rfl _
- simp
+ simp only [Option.mem_def, TM2.stepAux, elim_main, List.head?_cons, Option.some.injEq,
+ decide_False, List.tail_cons, elim_update_main, ne_eq, Function.update_noteq, elim_rev,
+ elim_update_rev, natEnd, Function.update_same, cond_true, cond_false]
convert unrev_ok using 2
simp
simp [trNum, Num.succ']
@@ -1641,14 +1653,17 @@ theorem tr_ret_respects (k v s) : ∃ b₂,
obtain ⟨s', h₁, h₂⟩ := trNormal_respects fs (Cont.cons₂ v k) as none
refine' ⟨s', h₁, TransGen.head rfl _⟩; simp
refine' (move₂_ok (by decide) _ (splitAtPred_false _)).trans _; · rfl
- simp
+ simp only [TM2.step, Option.mem_def, Option.elim, id_eq, elim_update_main, elim_main, elim_aux,
+ List.append_nil, elim_update_aux]
refine' (move₂_ok (by decide) _ _).trans _; pick_goal 4; · rfl
pick_goal 4;
· exact
splitAtPred_eq _ _ _ (some Γ'.consₗ) _
(fun x h => Bool.decide_false (trList_ne_consₗ _ _ h)) ⟨rfl, rfl⟩
refine' (move₂_ok (by decide) _ (splitAtPred_false _)).trans _; · rfl
- simp
+ simp only [TM2.step, Option.mem_def, Option.elim, elim_update_stack, elim_main,
+ List.append_nil, elim_update_main, id_eq, elim_update_aux, ne_eq, Function.update_noteq,
+ elim_aux, elim_stack]
exact h₂
case cons₂ ns k IH =>
obtain ⟨c, h₁, h₂⟩ := IH (ns.headI :: v) none
@@ -1734,13 +1749,13 @@ theorem trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trSt
iterate 4 exact fun h => Finset.Subset.trans (q_ih h) (Finset.subset_insert _ _)
· simp
intro s h x h'
- simp
+ simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_insert]
exact Or.inr ⟨_, q_ih s h h'⟩
· constructor
· rintro rfl
apply Finset.subset_insert
· intro h x h'
- simp
+ simp only [Finset.mem_insert]
exact Or.inr (Or.inr <| q_ih h h')
· refine' ⟨fun h x h' => _, fun _ x h' => _, fun h x h' => _⟩ <;> simp
· exact Or.inr (Or.inr <| Or.inl <| q₁_ih h h')
And fix some names in comments where this revealed issues
@@ -50,7 +50,7 @@ output, with enough expressivity to write any partial recursive function. The pr
* `comp f g` calls `f` on the output of `g`:
* `comp f g v = f (g v)`
* `case f g` cases on the head of the input, calling `f` or `g` depending on whether it is zero or
- a successor (similar to `nat.cases_on`).
+ a successor (similar to `Nat.casesOn`).
* `case f g [] = f []`
* `case f g (0 :: v) = f v`
* `case f g (n+1 :: v) = g (n :: v)`
Set
/Finset
lemmas match lattice lemma names (#7378)
Rename union_eq_left_iff_subset
to union_eq_left
to match sup_eq_left
. Similarly for the right
and inter
versions.
@@ -1838,7 +1838,7 @@ theorem codeSupp_comp (f g k) :
trStmts₁ (trNormal (Code.comp f g) k) ∪ codeSupp g (Cont'.comp f k) := by
simp [codeSupp, codeSupp', contSupp, Finset.union_assoc]
rw [← Finset.union_assoc _ _ (contSupp k),
- Finset.union_eq_right_iff_subset.2 (codeSupp'_self _ _)]
+ Finset.union_eq_right.2 (codeSupp'_self _ _)]
#align turing.partrec_to_TM2.code_supp_comp Turing.PartrecToTM2.codeSupp_comp
@[simp]
@@ -1101,7 +1101,7 @@ def tr : Λ' → Stmt'
we replace equation lemmas of `tr`. -/
theorem tr_move (p k₁ k₂ q) : tr (Λ'.move p k₁ k₂ q) =
- pop' k₁ (branch (fun s => s.elim true p) (goto fun _ => q)
+ pop' k₁ (branch (fun s => s.elim true p) (goto fun _ => q)
(push' k₂ <| goto fun _ => Λ'.move p k₁ k₂ q)) := rfl
theorem tr_push (k f q) : tr (Λ'.push k f q) = branch (fun s => (f s).isSome)
@@ -1122,7 +1122,7 @@ theorem tr_succ (q) : tr (Λ'.succ q) = pop' main (branch (fun s => s = some Γ'
((push main fun _ => Γ'.bit1) <| goto fun _ => unrev q)) := rfl
theorem tr_pred (q₁ q₂) : tr (Λ'.pred q₁ q₂) = pop' main (branch (fun s => s = some Γ'.bit0)
- ((push rev fun _ => Γ'.bit1) <| goto fun _ => Λ'.pred q₁ q₂) <|
+ ((push rev fun _ => Γ'.bit1) <| goto fun _ => Λ'.pred q₁ q₂) <|
branch (fun s => natEnd s.iget) (goto fun _ => q₁)
(peek' main <|
branch (fun s => natEnd s.iget) (goto fun _ => unrev q₂)
@@ -1545,7 +1545,6 @@ theorem succ_ok {q s n} {c d : List Γ'} :
simp [trPosNum]
· obtain ⟨l₁', l₂', s', e, h⟩ := IH (Γ'.bit0 :: l₁)
refine' ⟨l₁', l₂', s', e, TransGen.head _ h⟩
- swap
simp [PosNum.succ, trPosNum]
rfl
· refine' ⟨l₁, _, some Γ'.bit0, rfl, TransGen.single _⟩
A linter that throws on seeing a colon at the start of a line, according to the style guideline that says these operators should go before linebreaks.
@@ -312,8 +312,8 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
show ∀ x, pure x = [x] from fun _ => rfl, Bind.bind, Functor.map]
suffices ∀ a b, a + b = n →
(n.succ :: 0 ::
- g (n ::ᵥ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ v.tail)
- :: v.val.tail : List ℕ) ∈
+ g (n ::ᵥ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ v.tail) ::
+ v.val.tail : List ℕ) ∈
PFun.fix
(fun v : List ℕ => Part.bind (cg.eval (v.headI :: v.tail.tail))
(fun x => Part.some (if v.tail.headI = 0
@@ -2,17 +2,14 @@
Copyright (c) 2020 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module computability.tm_to_partrec
-! leanprover-community/mathlib commit 6155d4351090a6fad236e3d2e4e0e4e7342668e8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
+#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8"
+
/-!
# Modelling partial recursive functions using Turing machines
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -609,7 +609,7 @@ def Code.Ok (c : Code) :=
theorem Code.Ok.zero {c} (h : Code.Ok c) {v} :
Turing.eval step (stepNormal c Cont.halt v) = Cfg.halt <$> Code.eval c v := by
- rw [h, ← bind_pure_comp]; congr ; funext v
+ rw [h, ← bind_pure_comp]; congr; funext v
exact Part.eq_some_iff.2 (mem_eval.2 ⟨ReflTransGen.single rfl, rfl⟩)
#align turing.to_partrec.code.ok.zero Turing.ToPartrec.Code.Ok.zero
@@ -703,13 +703,13 @@ theorem code_is_ok (c) : Code.Ok c := by
iterate 3 simp only [Code.eval, pure_bind]
case cons f fs IHf IHfs =>
rw [Code.eval, IHf]
- simp only [bind_assoc, Cont.eval, pure_bind]; congr ; funext v
+ simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
- rw [stepRet, IHfs]; congr ; funext v'
+ rw [stepRet, IHfs]; congr; funext v'
refine' Eq.trans _ (Eq.symm _) <;> try exact reaches_eval (ReflTransGen.single rfl)
case comp f g IHf IHg =>
rw [Code.eval, IHg]
- simp only [bind_assoc, Cont.eval, pure_bind]; congr ; funext v
+ simp only [bind_assoc, Cont.eval, pure_bind]; congr; funext v
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [stepRet, IHf]
case case f g IHf IHg =>
@@ -729,20 +729,20 @@ theorem stepRet_eval {k v} : eval step (stepRet k v) = Cfg.halt <$> k.eval v :=
exact Part.eq_some_iff.2 (mem_eval.2 ⟨ReflTransGen.refl, rfl⟩)
case cons₁ fs as k IH =>
rw [Cont.eval, stepRet, code_is_ok]
- simp only [← bind_pure_comp, bind_assoc]; congr ; funext v'
+ simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [stepRet, IH, bind_pure_comp]
case cons₂ ns k IH => rw [Cont.eval, stepRet]; exact IH
case comp f k IH =>
rw [Cont.eval, stepRet, code_is_ok]
- simp only [← bind_pure_comp, bind_assoc]; congr ; funext v'
+ simp only [← bind_pure_comp, bind_assoc]; congr; funext v'
rw [reaches_eval]; swap; exact ReflTransGen.single rfl
rw [IH, bind_pure_comp]
case fix f k IH =>
rw [Cont.eval, stepRet]; simp only [bind_pure_comp]
split_ifs; · exact IH
simp only [← bind_pure_comp, bind_assoc, cont_eval_fix (code_is_ok _)]
- congr ; funext; rw [bind_pure_comp, ← IH]
+ congr; funext; rw [bind_pure_comp, ← IH]
exact reaches_eval (ReflTransGen.single rfl)
#align turing.to_partrec.step_ret_eval Turing.ToPartrec.stepRet_eval
@@ -1360,7 +1360,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁
rfl
refine' TransGen.head' rfl _
simp
- revert e ; cases' S k₁ with a Sk <;> intro e
+ revert e; cases' S k₁ with a Sk <;> intro e
· cases e
rfl
simp only [splitAtPred, Option.elim, List.head?, List.tail_cons, Option.iget_some] at e ⊢
@@ -1984,7 +1984,7 @@ theorem trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStm
theorem trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Supports S := by
induction c generalizing k <;> simp [Λ'.Supports, head]
case zero' => exact Finset.union_subset_right Hk
- case succ => intro ; split_ifs <;> exact Finset.union_subset_right Hk
+ case succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
case tail => exact Finset.union_subset_right Hk
case cons f fs IHf _ =>
apply IHf
Currently, (for both Set
and Finset
) insert_subset
is an iff
lemma stating that insert a s ⊆ t
if and only if a ∈ t
and s ⊆ t
. For both types, this PR renames this lemma to insert_subset_iff
, and adds an insert_subset
lemma that gives the implication just in the reverse direction : namely theorem insert_subset (ha : a ∈ t) (hs : s ⊆ t) : insert a s ⊆ t
.
This both aligns the naming with union_subset
and union_subset_iff
, and removes the need for the awkward insert_subset.mpr ⟨_,_⟩
idiom. It touches a lot of files (too many to list), but in a trivial way.
@@ -1956,7 +1956,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
induction' q with _ _ _ q q_ih _ _ q q_ih q q_ih _ _ q q_ih q q_ih q q_ih q₁ q₂ q₁_ih q₂_ih _ <;>
simp [trStmts₁, -Finset.singleton_subset_iff] at HS₁ ⊢
any_goals
- cases' Finset.insert_subset.1 HS₁ with h₁ h₂
+ cases' Finset.insert_subset_iff.1 HS₁ with h₁ h₂
first | have h₃ := h₂ W | try simp [Finset.subset_iff] at h₂
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩ -- move
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₁⟩, q_ih H₁ h₂⟩ -- clear
@@ -2033,7 +2033,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' trStmts₁_supports' (trNormal_supports _) (Finset.union_subset_right h) fun _ => _
· simp only [codeSupp', codeSupp, Finset.union_subset_iff, contSupp, trStmts₁,
- Finset.insert_subset] at h H ⊢
+ Finset.insert_subset_iff] at h H ⊢
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
at
and goals (#5387)
Changes are of the form
some_tactic at h⊢
-> some_tactic at h ⊢
some_tactic at h
-> some_tactic at h
@@ -309,7 +309,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
simp only [Vector.cons_val, Vector.tail_val] at hf hg
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons,
PFun.coe_val, Vector.tail_val]
- simp only [← Part.pure_eq_some] at hf hg⊢
+ simp only [← Part.pure_eq_some] at hf hg ⊢
induction' v.head with n _ <;>
simp [prec, hf, Part.bind_assoc, ← Part.bind_some_eq_map, Part.bind_some,
show ∀ x, pure x = [x] from fun _ => rfl, Bind.bind, Functor.map]
@@ -340,7 +340,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
obtain ⟨cf, hf⟩ := IHf; refine' ⟨rfind cf, fun v => _⟩
replace hf := fun a => hf (a ::ᵥ v)
simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, PFun.coe_val,
- show ∀ x, pure x = [x] from fun _ => rfl] at hf⊢
+ show ∀ x, pure x = [x] from fun _ => rfl] at hf ⊢
refine' Part.ext fun x => _
simp only [rfind, Part.bind_eq_bind, Part.pure_eq_some, Part.map_eq_map, Part.bind_some,
exists_prop, cons_eval, comp_eval, fix_eval, tail_eval, succ_eval, zero'_eval,
@@ -2007,7 +2007,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' trStmts₁_supports' (trNormal_supports _) (Finset.union_subset_right h) fun h => _
- · simp only [codeSupp, Finset.union_subset_iff, contSupp] at h H⊢
+ · simp only [codeSupp, Finset.union_subset_iff, contSupp] at h H ⊢
exact ⟨h.2.2.1, h.2.2.2, H.2⟩
refine' supports_union.2 ⟨IHfs _, _⟩
· rw [codeSupp, contSupp_cons₁] at H'
@@ -2020,7 +2020,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
refine' trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => _
refine' supports_union.2 ⟨IHg H', _⟩
refine' trStmts₁_supports' (trNormal_supports _) (Finset.union_subset_right h) fun _ => _
- · simp only [codeSupp', codeSupp, Finset.union_subset_iff, contSupp] at h H⊢
+ · simp only [codeSupp', codeSupp, Finset.union_subset_iff, contSupp] at h H ⊢
exact ⟨h.2.2, H.2⟩
exact IHf (Finset.union_subset_right H')
case case f g IHf IHg =>
@@ -2033,7 +2033,7 @@ theorem codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp
refine' supports_union.2 ⟨IHf H'.2, _⟩
refine' trStmts₁_supports' (trNormal_supports _) (Finset.union_subset_right h) fun _ => _
· simp only [codeSupp', codeSupp, Finset.union_subset_iff, contSupp, trStmts₁,
- Finset.insert_subset] at h H⊢
+ Finset.insert_subset] at h H ⊢
exact ⟨h.1, ⟨H.1.1, h⟩, H.2⟩
exact supports_singleton.2 (ret_supports <| Finset.union_subset_right H)
#align turing.partrec_to_TM2.code_supp'_supports Turing.PartrecToTM2.codeSupp'_supports
@@ -371,7 +371,7 @@ theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) :
exact ⟨_, ⟨h, @(hm)⟩, rfl⟩
· refine' IH (n.succ::v.val) (by simp_all) _ rfl fun m h' => _
obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h'
- exacts[hm _ h, h]
+ exacts [hm _ h, h]
· rintro ⟨n, ⟨hn, hm⟩, rfl⟩
refine' ⟨n.succ::v.1, _, rfl⟩
have : (n.succ::v.1 : List ℕ) ∈
compile_inductive%
and compile_def%
commands (#4097)
Add a #compile inductive
command to compile the recursors of an inductive type, which works by creating a recursive definition and using @[csimp]
.
Co-authored-by: Parth Shastri <31370288+cppio@users.noreply.github.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -940,34 +940,10 @@ inductive Λ'
#align turing.partrec_to_TM2.Λ'.ret Turing.PartrecToTM2.Λ'.ret
-- Porting note: `Turing.PartrecToTM2.Λ'.rec` is noncomputable in Lean4, so we make it computable.
-
-/-- A computable version of `Turing.PartrecToTM2.Λ'.rec`.
-Workaround until Lean has native support for this. The compiler fails to check the termination,
-so this should be `unsafe`. -/
-@[elab_as_elim] private unsafe abbrev Λ'.recU.{u} {motive : Λ' → Sort u}
- (move : (p : Γ' → Bool) → (k₁ k₂ : K') → (q : Λ') → motive q → motive (Λ'.move p k₁ k₂ q))
- (clear : (p : Γ' → Bool) → (k : K') → (q : Λ') → motive q → motive (Λ'.clear p k q))
- (copy : (q : Λ') → motive q → motive (Λ'.copy q))
- (push : (k : K') → (s : Option Γ' → Option Γ') → (q : Λ') → motive q → motive (Λ'.push k s q))
- (read : (f : Option Γ' → Λ') → ((a : Option Γ') → motive (f a)) → motive (Λ'.read f))
- (succ : (q : Λ') → motive q → motive (Λ'.succ q))
- (pred : (q₁ q₂ : Λ') → motive q₁ → motive q₂ → motive (Λ'.pred q₁ q₂))
- (ret : (k : Cont') → motive (Λ'.ret k)) :
- (t : Λ') → motive t
- | Λ'.move p k₁ k₂ q => move p k₁ k₂ q (Λ'.recU move clear copy push read succ pred ret q)
- | Λ'.clear p k q => clear p k q (Λ'.recU move clear copy push read succ pred ret q)
- | Λ'.copy q => copy q (Λ'.recU move clear copy push read succ pred ret q)
- | Λ'.push k s q => push k s q (Λ'.recU move clear copy push read succ pred ret q)
- | Λ'.read f => read f (fun a => Λ'.recU move clear copy push read succ pred ret (f a))
- | Λ'.succ q => succ q (Λ'.recU move clear copy push read succ pred ret q)
- | Λ'.pred q₁ q₂ => pred q₁ q₂
- (Λ'.recU move clear copy push read succ pred ret q₁)
- (Λ'.recU move clear copy push read succ pred ret q₂)
- | Λ'.ret k => ret k
-
-@[elab_as_elim, implemented_by Λ'.recU] private abbrev Λ'.recC.{u} := @Λ'.rec.{u}
-
-@[csimp] private theorem Λ'.rec_eq_recC : @Λ'.rec = @Λ'.recC := rfl
+compile_inductive% Code
+compile_inductive% Cont'
+compile_inductive% K'
+compile_inductive% Λ'
instance Λ'.instInhabited : Inhabited Λ' :=
⟨Λ'.ret Cont'.halt⟩
fix-comments.py
on all files.@@ -18,7 +18,7 @@ import Mathlib.Tactic.DeriveFintype
This file defines a simplified basis for partial recursive functions, and a `Turing.TM2` model
Turing machine for evaluating these functions. This amounts to a constructive proof that every
-`partrec` function can be evaluated by a Turing machine.
+`Partrec` function can be evaluated by a Turing machine.
## Main definitions
@@ -752,7 +752,7 @@ end ToPartrec
## Simulating sequentialized partial recursive functions in TM2
At this point we have a sequential model of partial recursive functions: the `Cfg` type and
-`step : Cfg → option Cfg` function from the previous section. The key feature of this model is that
+`step : Cfg → Option Cfg` function from the previous section. The key feature of this model is that
it does a finite amount of computation (in fact, an amount which is statically bounded by the size
of the program) between each step, and no individual step can diverge (unlike the compositional
semantics, where every sub-part of the computation is potentially divergent). So we can utilize the
@@ -811,7 +811,7 @@ prove that only finitely many labels are accessible.) The labels are:
duplicate of the `push` instruction that is part of the TM2 model, but by having a subroutine
just for this purpose we can build up programs to execute inside a `goto` statement, where we
have the flexibility to be general recursive.
-* `read (f : option Γ' → Λ')`: go to state `f s` where `s` is the local store. Again this is only
+* `read (f : Option Γ' → Λ')`: go to state `f s` where `s` is the local store. Again this is only
here for convenience.
* `succ q`: perform a successor operation. Assuming `[n]` is encoded on `main` before,
`[n+1]` will be on main after. This implements successor for binary natural numbers.
The main breaking change is that tac <;> [t1, t2]
is now written tac <;> [t1; t2]
, to avoid clashing with tactics like cases
and use
that take comma-separated lists.
@@ -553,7 +553,7 @@ theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.
induction' k with _ _ _ _ _ _ _ _ _ k_ih _ _ k_ih generalizing v <;>
simp only [Cont.eval, Cont.then, bind_assoc, pure_bind, *]
· simp only [← k_ih]
- · split_ifs <;> [rfl, simp only [← k_ih, bind_assoc]]
+ · split_ifs <;> [rfl; simp only [← k_ih, bind_assoc]]
#align turing.to_partrec.cont.then_eval Turing.ToPartrec.Cont.then_eval
/-- The `then k` function is a "configuration homomorphism". Its operation on states is to append
@@ -621,7 +621,7 @@ theorem stepNormal.is_ret (c k v) : ∃ k' v', stepNormal c k v = Cfg.ret k' v'
case case f g IHf IHg =>
rw [stepNormal]
simp only []
- cases v.headI <;> simp only [] <;> [apply IHf, apply IHg]
+ cases v.headI <;> simp only [] <;> [apply IHf; apply IHg]
case fix f IHf => apply IHf
#align turing.to_partrec.step_normal.is_ret Turing.ToPartrec.stepNormal.is_ret
@@ -670,7 +670,7 @@ theorem cont_eval_fix {f k v} (fok : Code.Ok f) :
v'.tail _ stepRet_then (by apply ReflTransGen.single; rw [e₀]; rfl)
· refine' ⟨_, PFun.mem_fix_iff.2 _, h₃⟩
simp only [Part.eq_some_iff.2 hv₁, Part.map_some, Part.mem_some_iff]
- split_ifs at hv₂ ⊢ <;> [exact Or.inl (congr_arg Sum.inl (Part.mem_some_iff.1 hv₂)),
+ split_ifs at hv₂ ⊢ <;> [exact Or.inl (congr_arg Sum.inl (Part.mem_some_iff.1 hv₂));
exact Or.inr ⟨_, rfl, hv₂⟩]
· exact IH _ rfl _ _ stepRet_then (ReflTransGen.tail hr rfl)
· rintro ⟨v', he, hr⟩
@@ -714,7 +714,7 @@ theorem code_is_ok (c) : Code.Ok c := by
rw [stepRet, IHf]
case case f g IHf IHg =>
simp only [Code.eval]
- cases v.headI <;> simp only [Code.eval] <;> [apply IHf, apply IHg]
+ cases v.headI <;> simp only [Code.eval] <;> [apply IHf; apply IHg]
case fix f IHf => rw [cont_eval_fix IHf]
#align turing.to_partrec.code_is_ok Turing.ToPartrec.code_is_ok
This makes a mathlib4 version of mathlib3's tactic.basic
, now called Mathlib.Tactic.Common
, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.
This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -12,7 +12,6 @@ import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
-import Mathlib.Tactic.Eqns
/-!
# Modelling partial recursive functions using Turing machines
sSup
/iSup
(#3938)
As discussed on Zulip
supₛ
→ sSup
infₛ
→ sInf
supᵢ
→ iSup
infᵢ
→ iInf
bsupₛ
→ bsSup
binfₛ
→ bsInf
bsupᵢ
→ biSup
binfᵢ
→ biInf
csupₛ
→ csSup
cinfₛ
→ csInf
csupᵢ
→ ciSup
cinfᵢ
→ ciInf
unionₛ
→ sUnion
interₛ
→ sInter
unionᵢ
→ iUnion
interᵢ
→ iInter
bunionₛ
→ bsUnion
binterₛ
→ bsInter
bunionᵢ
→ biUnion
binterᵢ
→ biInter
Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>
@@ -1748,7 +1748,7 @@ theorem tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v :
def trStmts₁ : Λ' → Finset Λ'
| Q@(Λ'.move _ _ _ q) => insert Q <| trStmts₁ q
| Q@(Λ'.push _ _ q) => insert Q <| trStmts₁ q
- | Q@(Λ'.read q) => insert Q <| Finset.univ.bunionᵢ fun s => trStmts₁ (q s)
+ | Q@(Λ'.read q) => insert Q <| Finset.univ.biUnion fun s => trStmts₁ (q s)
| Q@(Λ'.clear _ _ q) => insert Q <| trStmts₁ q
| Q@(Λ'.copy q) => insert Q <| trStmts₁ q
| Q@(Λ'.succ q) => insert Q <| insert (unrev q) <| trStmts₁ q
@@ -1951,10 +1951,10 @@ theorem supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K
simp [Supports, or_imp, forall_and]
#align turing.partrec_to_TM2.supports_union Turing.PartrecToTM2.supports_union
-theorem supports_bunionᵢ {K : Option Γ' → Finset Λ'} {S} :
- Supports (Finset.univ.bunionᵢ K) S ↔ ∀ a, Supports (K a) S := by
+theorem supports_biUnion {K : Option Γ' → Finset Λ'} {S} :
+ Supports (Finset.univ.biUnion K) S ↔ ∀ a, Supports (K a) S := by
simp [Supports]; apply forall_swap
-#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_bunionᵢ
+#align turing.partrec_to_TM2.supports_bUnion Turing.PartrecToTM2.supports_biUnion
theorem head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S := fun _ => by
dsimp only; split_ifs <;> exact H
@@ -1988,7 +1988,7 @@ theorem trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts
· exact supports_insert.2 ⟨⟨fun _ => h₁, fun _ => h₃⟩, q_ih H₁ h₂⟩ -- copy
· exact supports_insert.2 ⟨⟨fun _ => h₃, fun _ => h₃⟩, q_ih H₁ h₂⟩ -- push
· refine' supports_insert.2 ⟨fun _ => h₂ _ W, _⟩ -- read
- exact supports_bunionᵢ.2 fun _ => q_ih _ (H₁ _) fun _ h => h₂ _ h
+ exact supports_biUnion.2 fun _ => q_ih _ (H₁ _) fun _ h => h₂ _ h
· refine' supports_insert.2 ⟨⟨fun _ => h₁, fun _ => h₂.1, fun _ => h₂.1⟩, _⟩ -- succ
exact supports_insert.2 ⟨⟨fun _ => h₂.2 _ W, fun _ => h₂.1⟩, q_ih H₁ h₂.2⟩
· refine' -- pred
The unported dependencies are