Section EncodingLemmas.
Variable (C: list X) (n: nat).
Hypothesis (O: ord' (map (ctype X) C) < n).
Global Instance enc_proper:
Proper (equiv (@step X) ++> equiv (@step Y)) (enc_term C).
Global Instance inv_proper:
Proper (equiv (@step Y) ++> equiv (@step X)) (inv_term C).
End EncodingLemmas.
Definition iConsts {n} (I: orduni n X) :=
filter (fun x => if R' x == None then true else false)
(Consts [s₀; t₀]).
Program Instance remove_constants n (I: orduni n X)
(H: ord' (map (ctype X) (iConsts I)) < n) : orduni n Y :=
{
s₀ := enc_term (iConsts I) s₀;
t₀ := enc_term (iConsts I) t₀;
A₀ := enc_type (iConsts I) A₀;
Gamma₀ := enc_ctx (iConsts I) Gamma₀;
}.
Next Obligation.
eapply remove_constants_ordertyping; eauto using H1₀.
cbn; simplify; intuition.
eapply filter_In; destruct eq_dec; intuition.
Qed.
Next Obligation.
eapply remove_constants_ordertyping; eauto using H2₀.
cbn; simplify; intuition.
eapply filter_In; destruct eq_dec; intuition.
Qed.
End RemoveConstants.
(* ** Goldfarb sharp *)
From Undecidability.HOU Require Import
second_order.diophantine_equations second_order.goldfarb.reduction.
Definition gonly : Const :=
{|
const_type := option False;
ctype := fun o => match o with
| None => alpha → alpha → alpha
| Some f => match f with end
end
|}.
Program Instance RE_ag_gonly : retract gonly ag :=
{|
I := fun _ => None;
R := fun x => match x with None => Some None | _ => None end
|}.
Next Obligation.
now destruct x as [[]|].
Qed.

Lemma Goldfarb_sharp (C: Const) (re: retract gonly C):
ctype C (I None) = alpha → alpha → alpha -> OU 2 gonly ⪯ OU 2 C.