(**************************************************************)
(*   Copyright Dominique Larchey-Wendling [*]                 *)
(*                                                            *)
(*                             [*] Affiliation LORIA -- CNRS  *)
(**************************************************************)
(*      This file is distributed under the terms of the       *)
(*         CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT          *)
(**************************************************************)
From Undecidability.MinskyMachines
From Undecidability.ILL
From Undecidability.Shared.Libs.DLW
From Undecidability.Synthetic
Set Implicit Arguments.
Local Infix "~p" := (@Permutation _) (at level 70).
Local Notation "X ⊆ Y" := (forall a, X a -> Y a : Prop) (at level 70).
Local Infix "∊" := In (at level 70).
Local Reserved Notation "'⟦' A '⟧'" (at level 1, format "⟦ A ⟧").
Local Fact pair_plus x1 y1 x2 y2 :
vec_plus (x1##y1##vec_nil) (x2##y2##vec_nil)
= (x1+x2)##(y1+y2)##vec_nil.
Notation "Γ ⊢ A" := (S_imsell bang_le U Γ A) (at level 70).
Notation "Σ // a ⊕ b ⊦ p" := (ndmm2_accept Σ a b p) (at level 70, no associativity).
Variable Σ : list (ndmm2_instr nat).
Let sem p (w : vec nat 2) :=
let x := vec_head w in
let y := vec_head (vec_tail w)
in match p with
| 0 => x = 1 /\ y = 0
| 1 => x = 0 /\ y = 1
| S (S i) => Σ // x ⊕ y ⊦ i
end.
Local Fact sem_0 x y : sem 0 (x##y##vec_nil) <-> x = 1 /\ y = 0.
Local Fact HK2 : forall u, K u ø.
Local Fact HK4 u : U u -> forall x, K u x -> x = ø.
Local Fact HKa x y : K a (x##y##vec_nil) <-> y = 0.
Local Fact HKb x y : K b (x##y##vec_nil) <-> x = 0.
Local Fact HKi : forall x, K ∞ x -> x = ø.
Local Lemma sem_Σ c : c ∊ Σ -> ⟦ndmm2_imsell_form c⟧ ø.
Hint Resolve HK1 HK2 HK3 HK4 HKa HKb HKi sem_Σ : core.
Local Fact sem_Σ_zero : ⟪map (fun c => ![∞](ndmm2_imsell_form c)) Σ⟫ ø.

Theorem ndmm2_imsell_complete p x y :
ndmm2_imsell_ctx Σ x y ⊢ £ (2+p)
-> Σ // x ⊕ y ⊦ p.