(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Definition var (cfg : BDDconfig) (node : ad) :=
match MapGet _ (fst cfg) node with
| None => (* Error *)  BDDzero
| Some (x, (l, r)) => x
end.
Definition low (cfg : BDDconfig) (node : ad) :=
match MapGet _ (fst cfg) node with
| None => (* Error *)  N0
| Some (x, (l, r)) => l
end.
Definition high (cfg : BDDconfig) (node : ad) :=
match MapGet _ (fst cfg) node with
| None => (* Error *)  N0
| Some (x, (l, r)) => r
end.
Definition config_node_OK (cfg : BDDconfig) := node_OK (fst cfg).
Definition is_internal_node (cfg : BDDconfig) (node : ad) :=
exists x : BDDvar,
(exists l : ad,
(exists r : ad, MapGet _ (fst cfg) node = Some (x, (l, r)))).

(* Specifications: *)
Lemma BDDvar_ordered_low :
forall (cfg : BDDconfig) (node : ad),
BDDconfig_OK cfg ->
is_internal_node cfg node ->
is_internal_node cfg (low cfg node) ->
BDDcompare (var cfg (low cfg node)) (var cfg node) = Datatypes.Lt.
Lemma BDDvar_ordered_high :
forall (cfg : BDDconfig) (node : ad),
BDDconfig_OK cfg ->
is_internal_node cfg node ->
is_internal_node cfg (high cfg node) ->
BDDcompare (var cfg (high cfg node)) (var cfg node) = Datatypes.Lt.