Fact mm_steps_DEC_1_inv k P i x p v u st :
(i,DEC x p::nil) <sc P
-> k <> 0
-> v#>x = S u
-> P // (i,v) -[k]-> st
-> exists k', k' < k /\ P // (1+i,v[u/x]) -[k']-> st.
End Minsky_Machine.
Local Notation "P // s -[ k ]-> t" := (sss_steps (@mm_sss _) P k s t).
Local Notation "P // s -+> t" := (sss_progress (@mm_sss _) P s t).
Local Notation "P // s ->> t" := (sss_compute (@mm_sss _) P s t).
Tactic Notation "mm" "sss" "INC" "with" uconstr(a) :=
match goal with
| |- _ // _ -+> _ => apply mm_progress_INC with (x := a)
| |- _ // _ ->> _ => apply mm_compute_INC with (x := a)
end; auto.
Tactic Notation "mm" "sss" "DEC" "0" "with" uconstr(a) uconstr(b) :=
match goal with
| |- _ // _ -+> _ => apply mm_progress_DEC_0 with (x := a) (k := b)
| |- _ // _ ->> _ => apply mm_compute_DEC_0 with (x := a) (k := b)
end; auto.
Tactic Notation "mm" "sss" "DEC" "S" "with" uconstr(a) uconstr(b) uconstr(c) :=
match goal with
| |- _ // _ -+> _ => apply mm_progress_DEC_S with (x := a) (k := b) (u := c)
| |- _ // _ ->> _ => apply mm_compute_DEC_S with (x := a) (k := b) (u := c)
end; auto.
Tactic Notation "mm" "sss" "stop" := exists 0; apply sss_steps_0; auto.
(* The Halting problem for MM, for linear logic encoding, we restrict to a very specific halting problem. Starting from (1,v), does the MM halt at state (0,vec_zero) *)
Definition MM_PROBLEM := { n : nat & { P : list (mm_instr n) & vec nat n } }.
Local Notation "i // s -1> t" := (@mm_sss _ i s t).
Local Notation "P // s ~~> t" := (sss_output (@mm_sss _) P s t).
Local Notation "P // s ↓" := (sss_terminates (@mm_sss _) P s).
Definition MM_HALTS_ON_ZERO (P : MM_PROBLEM) :=
match P with existT _ n (existT _ P v) => (1,P) // (1,v) ~~> (0,vec_zero) end.
Definition MM_HALTING (P : MM_PROBLEM) :=
match P with existT _ n (existT _ P v) => (1, P) // (1, v) ↓ end.
Section mm_special_ind.
Variables (n : nat) (P : nat*list (mm_instr n)) (se : nat * vec nat n)
(Q : nat * vec nat n -> Prop).
Hypothesis (HQ0 : Q se)
(HQ1 : forall i ρ v j w,   (i,ρ::nil) <sc P
-> ρ // (i,v) -1> (j,w)
-> P // (j,w) ->> se
-> Q (j,w)
-> Q (i,v)).

Theorem mm_special_ind s : P // s ->> se -> Q s.
End mm_special_ind.