Section CGWithOne.
Variable Done : D.
Variable Done_pos : Dle Done Dz = false.
Variable
Done_min_pos : forall d : D, Dle d Dz = false -> Dle Done d = true.
(*s Defining the negation of a formula : $\neg x \leq y+d \Leftrightarrow x>y+d \Leftrightarrow x \geq y+d+1$ *)
Fixpoint CGSnot (fs : CGSForm) : CGSForm :=
match fs with
| CGSleq x y d => CGSleq y x (Dneg (Dplus d Done))
| CGSand f0 f1 => CGSor (CGSnot f0) (CGSnot f1)
| CGSor f0 f1 => CGSand (CGSnot f0) (CGSnot f1)
end.
(*s Interpreting formula as simplified formula *)
Fixpoint CGFormSimplify (f : CGForm) : CGSForm :=
match f with
| CGleq x y d => CGSleq x y d
| CGeq x y d => CGSeq x y d
| CGand f0 f1 => CGSand (CGFormSimplify f0) (CGFormSimplify f1)
| CGor f0 f1 => CGSor (CGFormSimplify f0) (CGFormSimplify f1)
| CGimp f0 f1 => CGSor (CGSnot (CGFormSimplify f0)) (CGFormSimplify f1)
| CGnot f0 => CGSnot (CGFormSimplify f0)
end.
(*s Formula are solved by looking at their simplified form *)
Definition CG_solve (f : CGForm) := CGS_solve false (CGFormSimplify f).

Theorem CG_solve_correct_anchored :
forall (anchor : ad) (anchor_value : D) (f : CGForm),
CG_solve f = true ->
{rho : ad -> D | CGeval rho f /\ rho anchor = anchor_value}.