Section ListFacts.
Definition sat φ l := Forall (h10uc_sem φ) l.
(* needs 2 fresh variables *)
(* x is 0 if 1 + x + x * x = y and 1 + x + y * y = z and 1 + y + x * x = z *)
Definition express_0 (x: nat) (f: nat -> nat) := [(x, x, f 0); (x, f 0, f 1); (f 0, x, f 1)].
Definition express_0f := [1; 2].
(* needs 2 fresh variables *)
(* x is 1 if 1 + y + y * y = x and 1 + y + x * x = z and 1 + x + y * y = z *)
Definition express_1 (x: nat) (f: nat -> nat) := [(f 0, f 0, x); (f 0, x, f 1); (x, f 0, f 1)].
Definition express_1f := [0; 2].
(* needs 3 fresh variables *)
(* x is 1 + y if 1 + y + 0 * 0 = x *)
Definition express_succ (x y: nat) (f: nat -> nat) := (express_0 (f 2) f) ++ [(y, f 2, x)].
Definition express_succf := express_0f ++ [0].
(* needs 7 fresh variables *)
(* x = y * y if 1 + 0 + y * y = 1 + x *)
Definition express_square (x y: nat) (f: nat -> nat) :=
(express_0 (f 5) f) ++ (express_succ (f 6) x (fun i => f (2+i))) ++ [(f 5, y, f 6)].
Definition express_squaref φx :=
express_0f ++ express_succf ++ [0; 1 + φx].
(* needs 35 fresh variables *)
(* x = x + z if 1 + (y + y) + (1 + z) * (1 + z) = 1 + (1 + (x + x)) + z * z *)
Definition express_sum (x y z: nat) (f: nat -> nat) :=
(express_succ (f 33) z f) ++
(express_double (f 32) y (fun i => f (3+i))) ++
(express_double (f 31) x (fun i => f (15+i))) ++
(express_succ (f 34) (f 31) (fun i => f (27+i))) ++
[((f 32), (f 33), (f 30)); ((f 34), z, (f 30))].
Definition express_sumf φx φy φz :=
express_succf ++
(express_doublef φy) ++
(express_doublef φx) ++
express_succf ++
[1 + (φy + φy) + (1 + φz) * (1 + φz); φx + φx ; φy + φy; 1 + φz; 1 + φx + φx].

Lemma express_sumI' x y z f φ φx φy φz: compatible f φ (express_sumf φx φy φz) -> φ x = φ y + φ z -> φ x = φx -> φ y = φy -> φ z = φz ->
sat φ (express_sum x y z f).