Section completeness.
(* We assume an interpreted and finite model *)
Variable (X : Type) (M : fo_model Σbpcp X)
(HM : finite X)
(He : forall x y, fom_rels M Σbpcp_eq (x##y##ø) <-> x = y)
.
Notation sem_sym := (fom_syms M).
Notation sem_pred := (fom_rels M).
Notation "⟦ t ⟧" := (fun φ => fo_term_sem M φ t).
Notation "⟪ A ⟫" := (fun φ => fol_sem M φ A).
Let fot_sem_lb_app l t φ : ⟦l⤜t⟧ φ = ⟦l⤜£0⟧ (⟦t⟧φ)·φ.
Variable (φ : nat -> X) (model : ⟪ Σbpcp_encode ⟫ φ).
Notation ε := (@sem_sym Σbpcp_unit ø).
Notation "⋇" := (@sem_sym Σbpcp_undef ø).
Let f b x := (@sem_sym (Σbpcp_bool b) (x##ø)).
Let P x y := @sem_pred Σbpcp_hand (x##y##ø).
Notation "x ⪡ y" := (@sem_pred Σbpcp_ssfx (x##y##ø)) (at level 70).
Notation "x ≅ y" := (@sem_pred Σbpcp_eq (x##y##ø)) (at level 70).
Let lt_pair u v x y := (  u ⪡ x /\ v ≅ y
\/ v ⪡ y /\ u ≅ x
\/ u ⪡ x /\ v ⪡ y ).
(* The axiom interpreted directly gives us properties of the model *)
Let HP x y : P x y -> x <> ⋇ /\ y <> ⋇.
Let Hlt_irrefl x : ~ x ⪡ x.
Let P_refl : exists x, P x x.
Let sb_app_congr l m x y z : x = sb_app l y -> y = sb_app m z -> x = sb_app (l++m) z.
Ltac mysolve :=
match goal with
| H1 : ?x ⪡ ?y, H2 : ?y ⪡ ?z |- ?x ⪡ ?z => revert H2; apply Hlt_trans
| H1 : ?x = ?y, H2 : ?y ⪡ ?z |- ?x ⪡ ?z => rewrite H1; apply H2
| H1 : ?x ⪡ ?y, H2 : ?y = ?z |- ?x ⪡ ?z => rewrite <- H2; apply H1
| H1 : ?x = ?y, H2 : ?y = ?z |- ?x = ?z => rewrite H1; apply H2
end; auto.
Let Hlt_wf : well_founded (fun p q => match p, q with (u,v), (x,y) => lt_pair u v x y end).
Let P_implies_pcp_hand (c : X*X) :
let (x,y) := c
in   P x y
-> exists s t, x = sb_app s ε
/\ y = sb_app t ε
/\ lc ⊳ s∕t.
Local Theorem completeness : exists s, lc ⊳ s∕s.
End completeness.
Hint Resolve finite_t_finite : core.

Theorem Sig_bpcp_encode_complete :
@fo_form_fin_dec_eq_SAT Σbpcp Σbpcp_eq eq_refl Σbpcp_encode
-> exists l, lc ⊳ l∕l.