(* 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                                                     *)
Set Asymmetric Patterns.
Unset Standard Proposition Elimination Names.
Require Export ZArith.
Require Export Omega.
(**********************************************************************  CONFIGURATION  **********************************************************************)
Section CONFIGURATION.
Definition counter := Z.
Record Config : Set := mkconfig {co : counter}.
Variable x : Z.
Definition mk_init_config := mkconfig x.
End CONFIGURATION.
(**********************************************************************  TRANSITIONS  **********************************************************************)
Section TRANSITIONS.
Definition decrement_trans (c : Config) := mkconfig (co c - 1)%Z.
Definition divide_trans (c : Config) := mkconfig (Zeven.Zdiv2 (co c)).
Inductive transition (c : Config) : Set :=
| decrement : (co c > 0)%Z -> Zeven.Zodd (co c) -> transition c
| divide : (co c > 0)%Z -> Zeven.Zeven (co c) -> transition c.
Definition next_config (c : Config) (t : transition c) :=
match t with
| decrement h1 h2 => decrement_trans c
| divide h1 h2 => divide_trans c
end.
Variable x : Z.
Inductive legal : Config -> Prop :=
| begin : legal (mk_init_config x)
| after :
forall (c : Config) (t : transition c),
legal c -> legal (next_config c t).
End TRANSITIONS.
(* positive *)

Lemma rec2_princ :
forall P : Z -> Prop,
P 0%Z ->
(forall x : Z, Zeven.Zeven x -> (x > 0)%Z -> P (Zeven.Zdiv2 x) -> P x) ->
(forall x : Z, Zeven.Zodd x -> (x > 0)%Z -> P (x - 1)%Z -> P x) ->
forall x : Z, (x >= 0)%Z -> P x.