Section ZCGevalDef.
Variable rho : ad -> Z.
Fixpoint ZCGeval (f : ZCGForm) : Prop :=
match f with
| ZCGle x y => (rho x <= rho y)%Z
| ZCGge x y => (rho x >= rho y)%Z
| ZCGlt x y => (rho x < rho y)%Z
| ZCGgt x y => (rho x > rho y)%Z
| ZCGlep x y k => (rho x <= rho y + k)%Z
| ZCGgep x y k => (rho x >= rho y + k)%Z
| ZCGltp x y k => (rho x < rho y + k)%Z
| ZCGgtp x y k => (rho x > rho y + k)%Z
| ZCGlem x y k => (rho x + k <= rho y)%Z
| ZCGgem x y k => (rho x + k >= rho y)%Z
| ZCGltm x y k => (rho x + k < rho y)%Z
| ZCGgtm x y k => (rho x + k > rho y)%Z
| ZCGlepm x y k k' => (rho x + k <= rho y + k')%Z
| ZCGgepm x y k k' => (rho x + k >= rho y + k')%Z
| ZCGltpm x y k k' => (rho x + k < rho y + k')%Z
| ZCGgtpm x y k k' => (rho x + k > rho y + k')%Z
| ZCGeq x y => rho x = rho y
| ZCGeqp x y k => rho x = (rho y + k)%Z
| ZCGeqm x y k => (rho x + k)%Z = rho y
| ZCGeqpm x y k k' => (rho x + k)%Z = (rho y + k')%Z
| ZCGzylem y k => (k <= rho y)%Z
| ZCGzygem y k => (k >= rho y)%Z
| ZCGzyltm y k => (k < rho y)%Z
| ZCGzygtm y k => (k > rho y)%Z
| ZCGzylepm y k k' => (k <= rho y + k')%Z
| ZCGzygepm y k k' => (k >= rho y + k')%Z
| ZCGzyltpm y k k' => (k < rho y + k')%Z
| ZCGzygtpm y k k' => (k > rho y + k')%Z
| ZCGzyeqm y k => k = rho y
| ZCGzyeqpm y k k' => k = (rho y + k')%Z
| ZCGxzlep x k => (rho x <= k)%Z
| ZCGxzgep x k => (rho x >= k)%Z
| ZCGxzltp x k => (rho x < k)%Z
| ZCGxzgtp x k => (rho x > k)%Z
| ZCGxzlepm x k k' => (rho x + k <= k')%Z
| ZCGxzgepm x k k' => (rho x + k >= k')%Z
| ZCGxzltpm x k k' => (rho x + k < k')%Z
| ZCGxzgtpm x k k' => (rho x + k > k')%Z
| ZCGxzeqp x k => rho x = k
| ZCGxzeqpm x k k' => (rho x + k)%Z = k'
| ZCGzzlep k k' => (k <= k')%Z
| ZCGzzltp k k' => (k < k')%Z
| ZCGzzgep k k' => (k >= k')%Z
| ZCGzzgtp k k' => (k > k')%Z
| ZCGzzeq k k' => k = k'
| ZCGand f0 f1 => ZCGeval f0 /\ ZCGeval f1
| ZCGor f0 f1 => ZCGeval f0 \/ ZCGeval f1
| ZCGimp f0 f1 => ZCGeval f0 -> ZCGeval f1
| ZCGnot f0 => ~ ZCGeval f0
| ZCGiff f0 f1 => ZCGeval f0 <-> ZCGeval f1
end.
Variable Zrho_zero : rho N0 = 0%Z.
End ZCGevalDef.
Definition ZCG_solve (f : ZCGForm) :=
CG_solve Z 0%Z Zplus Z.opp Zle_bool 1%Z (ZCGtranslate f).

Theorem ZCG_solve_correct :
forall f : ZCGForm,
ZCG_solve f = true -> {rho : ad -> Z | ZCGeval rho f /\ rho N0 = 0%Z}.