(* This file is generated by Why3's Coq driver *)
(* Beware! Only edit allowed sections below    *)
Require Import BuiltIn.
Require BuiltIn.
Require HighOrd.
Require int.Int.
Require int.Abs.
Require int.MinMax.
Require int.EuclideanDivision.
Require real.Real.
Require map.Map.

Axiom t : Type.
Parameter t_WhyType : WhyType t.
Existing Instance t_WhyType.

Parameter teq: t -> t -> Prop.

Axiom teq_spec : forall (x:t) (y:t), (teq x y) <-> (x = y).

Parameter tzero: t.

Parameter tone: t.

Parameter prefix_mndt: t -> t.

Parameter infix_pldt: t -> t -> t.

Parameter infix_asdt: t -> t -> t.

Axiom Assoc :
  forall (x:t) (y:t) (z:t),
  ((infix_pldt (infix_pldt x y) z) = (infix_pldt x (infix_pldt y z))).

Axiom Unit_def_l : forall (x:t), ((infix_pldt tzero x) = x).

Axiom Unit_def_r : forall (x:t), ((infix_pldt x tzero) = x).

Axiom Inv_def_l : forall (x:t), ((infix_pldt (prefix_mndt x) x) = tzero).

Axiom Inv_def_r : forall (x:t), ((infix_pldt x (prefix_mndt x)) = tzero).

Axiom Comm : forall (x:t) (y:t), ((infix_pldt x y) = (infix_pldt y x)).

Axiom Assoc1 :
  forall (x:t) (y:t) (z:t),
  ((infix_asdt (infix_asdt x y) z) = (infix_asdt x (infix_asdt y z))).

Axiom Mul_distr_l :
  forall (x:t) (y:t) (z:t),
  ((infix_asdt x (infix_pldt y z)) =
   (infix_pldt (infix_asdt x y) (infix_asdt x z))).

Axiom Mul_distr_r :
  forall (x:t) (y:t) (z:t),
  ((infix_asdt (infix_pldt y z) x) =
   (infix_pldt (infix_asdt y x) (infix_asdt z x))).

Axiom Comm1 : forall (x:t) (y:t), ((infix_asdt x y) = (infix_asdt y x)).

Axiom Unitary : forall (x:t), ((infix_asdt tone x) = x).

Axiom NonTrivialRing : ~ (tzero = tone).

Parameter inv: t -> t.

Axiom Inverse :
  forall (x:t), ~ (x = tzero) -> ((infix_asdt x (inv x)) = tone).

(* Why3 assumption *)
Definition infix_mn (x:t) (y:t) : t := infix_pldt x (prefix_mndt y).

(* Why3 assumption *)
Definition infix_sl (x:t) (y:t) : t := infix_asdt x (inv y).

Axiom add_div :
  forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
  ((infix_sl (infix_pldt x y) z) =
   (infix_pldt (infix_sl x z) (infix_sl y z))).

Axiom sub_div :
  forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
  ((infix_sl (infix_mn x y) z) = (infix_mn (infix_sl x z) (infix_sl y z))).

Axiom neg_div :
  forall (x:t) (y:t), ~ (y = tzero) ->
  ((infix_sl (prefix_mndt x) y) = (prefix_mndt (infix_sl x y))).

Axiom assoc_mul_div :
  forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
  ((infix_sl (infix_asdt x y) z) = (infix_asdt x (infix_sl y z))).

Axiom assoc_div_mul :
  forall (x:t) (y:t) (z:t), (~ (y = tzero) /\ ~ (z = tzero)) ->
  ((infix_sl (infix_sl x y) z) = (infix_sl x (infix_asdt y z))).

Axiom assoc_div_div :
  forall (x:t) (y:t) (z:t), (~ (y = tzero) /\ ~ (z = tzero)) ->
  ((infix_sl x (infix_sl y z)) = (infix_sl (infix_asdt x z) y)).

(* Why3 assumption *)
Definition infix_mndt (x:t) (y:t) : t := infix_pldt x (prefix_mndt y).

Parameter infix_sldt: t -> t -> t.

Axiom infix_sldt_spec :
  forall (x:t) (y:t), ~ (y = tzero) ->
  ((infix_sldt x y) = (infix_asdt x (inv y))).

Parameter infix_slas: R -> R -> R.

Axiom infix_slas_def :
  forall (x:R) (y:R), ~ (y = 0%R) -> ((infix_slas x y) = (x / y)%R).

Parameter infix_eqas: R -> R -> Prop.

Axiom infix_eqas_spec : forall (x:R) (y:R), (infix_eqas x y) <-> (x = y).

Parameter infix_lsgtas: R -> R -> Prop.

Axiom infix_lsgtas_spec :
  forall (x:R) (y:R), (infix_lsgtas x y) <-> ~ (x = y).

(* Why3 assumption *)
Definition infix_mnas (x:R) (y:R) : R := (x + (-y)%R)%R.

(* Why3 assumption *)
Definition infix_lsas (x:R) (y:R) : Prop := (x <= y)%R /\ (infix_lsgtas x y).

Parameter from_int: Z -> R.

Axiom Zero : ((from_int 0%Z) = 0%R).

Axiom One : ((from_int 1%Z) = 1%R).

Axiom Add :
  forall (x:Z) (y:Z),
  ((from_int (x + y)%Z) = ((from_int x) + (from_int y))%R).

Axiom Sub :
  forall (x:Z) (y:Z),
  ((from_int (x - y)%Z) = (infix_mnas (from_int x) (from_int y))).

Axiom Mul :
  forall (x:Z) (y:Z),
  ((from_int (x * y)%Z) = ((from_int x) * (from_int y))%R).

Axiom Neg : forall (x:Z), ((from_int (-x)%Z) = (-(from_int x))%R).

Axiom Injective :
  forall (x:Z) (y:Z), ((from_int x) = (from_int y)) -> (x = y).

Axiom Monotonic :
  forall (x:Z) (y:Z), (x <= y)%Z -> ((from_int x) <= (from_int y))%R.

Axiom r_zeroLessOne : (0%R <= 1%R)%R.

Axiom r_compatOrderAdd :
  forall (x:R) (y:R) (z:R), (x <= y)%R -> ((x + z)%R <= (y + z)%R)%R.

Axiom r_compatOrderMult :
  forall (x:R) (y:R) (z:R), (x <= y)%R -> (0%R <= z)%R ->
  ((x * z)%R <= (y * z)%R)%R.

Axiom Absorbing_zero :
  forall (a:t) (b:t),
  ((infix_asdt a b) = tzero) <-> (~ (a = tzero) -> (b = tzero)).

Axiom absorbing_zero :
  forall (a:t) (b:t), ((infix_asdt a b) = tzero) ->
  (~ (a = tzero) -> (b = tzero)) /\ (~ (b = tzero) -> (a = tzero)).

Axiom invol_neg : forall (a:t), ((prefix_mndt (prefix_mndt a)) = a).

Axiom mult_num :
  forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
  ((infix_sldt (infix_asdt a b) c) = (infix_asdt a (infix_sldt b c))).

Axiom mult_denom :
  forall (a:t) (b:t) (c:t), ~ (c = tzero) -> ~ (b = tzero) ->
  ((infix_sldt a (infix_asdt b c)) =
   (infix_asdt (infix_sldt a b) (infix_sldt tone c))).

Axiom mult_simpl :
  forall (a:t) (b:t) (c:t), ~ (c = tzero) -> ~ (b = tzero) ->
  ((infix_sldt (infix_asdt a b) (infix_asdt c b)) = (infix_sldt a c)).

Axiom non_zero_prod :
  forall (a:t) (b:t), ~ (a = tzero) -> ~ (b = tzero) ->
  ~ ((infix_asdt a b) = tzero).

Axiom minus_tone :
  forall (a:t), ((prefix_mndt a) = (infix_asdt (prefix_mndt tone) a)).

Axiom mult_neg_l :
  forall (a:t) (b:t),
  ((infix_asdt (prefix_mndt a) b) = (prefix_mndt (infix_asdt a b))).

Axiom mult_neg_r :
  forall (a:t) (b:t),
  ((infix_asdt a (prefix_mndt b)) = (prefix_mndt (infix_asdt a b))).

Axiom invadd :
  forall (i:t), ((prefix_mndt i) = (infix_asdt (prefix_mndt tone) i)).

Axiom notZeroAdd :
  forall (x:t) (y:t), ~ (x = tzero) -> ~ ((infix_pldt x y) = y).

Parameter im: t.

Axiom im_Def : ((infix_asdt im im) = (prefix_mndt tone)).

Parameter r_to_t: R -> t.

Axiom r_to_t_zero : ((r_to_t 0%R) = tzero).

Axiom r_to_t_one : ((r_to_t 1%R) = tone).

Axiom r_to_t_add :
  forall (i:R) (j:R),
  ((infix_pldt (r_to_t i) (r_to_t j)) = (r_to_t (i + j)%R)).

Axiom r_to_t_mult :
  forall (i:R) (j:R),
  ((infix_asdt (r_to_t i) (r_to_t j)) = (r_to_t (i * j)%R)).

Axiom r_to_t_sub :
  forall (i:R) (j:R),
  ((infix_mndt (r_to_t i) (r_to_t j)) = (r_to_t (infix_mnas i j))).

Axiom r_to_t_div :
  forall (i:R) (j:R), ~ (j = 0%R) ->
  ((infix_sldt (r_to_t i) (r_to_t j)) = (r_to_t (infix_slas i j))).

Parameter real_part: t -> R.

Parameter im_part: t -> R.

Axiom Real_part_add :
  forall (i:t) (j:t),
  ((real_part (infix_pldt i j)) = ((real_part i) + (real_part j))%R).

Axiom Im_part_add :
  forall (i:t) (j:t),
  ((im_part (infix_pldt i j)) = ((im_part i) + (im_part j))%R).

Axiom real_part_add :
  forall (i:t) (j:t),
  ((real_part (infix_pldt i j)) = ((real_part i) + (real_part j))%R).

Axiom im_part_add :
  forall (i:t) (j:t),
  ((im_part (infix_pldt i j)) = ((im_part i) + (im_part j))%R).

Axiom Complex_decomp :
  forall (i:t),
  (i =
   (infix_pldt (r_to_t (real_part i)) (infix_asdt im (r_to_t (im_part i))))).

Axiom Unic_decomp :
  forall (i:t), forall (x:R) (y:R),
  (i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
  (x = (real_part i)) /\ (y = (im_part i)).

Axiom injective_real_part :
  forall (i:t) (j:t), ~ ((real_part i) = (real_part j)) -> ~ (i = j).

Axiom injective_im_part :
  forall (i:t) (j:t), ~ ((im_part i) = (im_part j)) -> ~ (i = j).

Axiom complex_decomp :
  forall (i:t),
  (i =
   (infix_pldt (r_to_t (real_part i)) (infix_asdt im (r_to_t (im_part i))))).

Axiom unic_decomp :
  forall (i:t) (x:R) (y:R),
  (i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
  (x = (real_part i)) /\ (y = (im_part i)).

(* Why3 assumption *)
Definition real_ (x:t) : Prop := ((im_part x) = 0%R).

(* Why3 assumption *)
Definition pure_im_ (x:t) : Prop := ((real_part x) = 0%R).

Parameter pi: t.

Axiom pi_def : real_ pi.

Axiom r_to_t_real : forall (x:t), (real_ x) -> (x = (r_to_t (real_part x))).

Axiom real_r_to_t : forall (x:R), real_ (r_to_t x).

Axiom r_to_t_pure_im :
  forall (x:t), (pure_im_ x) -> (x = (infix_asdt im (r_to_t (im_part x)))).

Axiom simpl_frac :
  forall (x:t) (y:t), ~ (y = tzero) -> ((infix_sldt (infix_asdt x y) y) = x).

Axiom simpl_frac_ :
  forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
  ((infix_sldt (infix_asdt x y) (infix_asdt z y)) = (infix_sldt x z)).

Axiom fact_frac :
  forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
  ((infix_sldt (infix_asdt x y) z) = (infix_asdt x (infix_sldt y z))).

Axiom fact_frac_rev :
  forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
  ((infix_asdt x (infix_sldt y z)) = (infix_sldt (infix_asdt x y) z)).

Axiom inv_mult :
  forall (x:t) (y:t), ~ (x = tzero) -> ~ (y = tzero) ->
  ((infix_asdt (infix_sldt tone x) (infix_sldt tone y)) =
   (infix_sldt tone (infix_asdt x y))).

Axiom div_div :
  forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
  ((infix_sldt (infix_sldt x y) z) = (infix_sldt x (infix_asdt y z))).

Axiom div_div_rev :
  forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
  ((infix_sldt x (infix_asdt y z)) = (infix_sldt (infix_sldt x y) z)).

Axiom involutive_inv :
  forall (a:t), ~ (a = tzero) -> ((infix_sldt tone (infix_sldt tone a)) = a).

Parameter infix_lseqdt: t -> t -> Prop.

Axiom Inf_eq_def :
  forall (x:t) (y:t),
  (infix_lseqdt x y) <->
  (((real_ x) /\ ((real_ y) /\ ((real_part x) <= (real_part y))%R)) \/
   (x = y)).

Parameter infix_lsdt: t -> t -> Prop.

Parameter infix_gteqdt: t -> t -> Prop.

Parameter infix_gtdt: t -> t -> Prop.

Axiom inf_st :
  forall (x:t) (y:t), (infix_lsdt x y) <-> ((infix_lseqdt x y) /\ ~ (x = y)).

Axiom sup_eq : forall (x:t) (y:t), (infix_gteqdt x y) <-> (infix_lseqdt y x).

Axiom sup_st :
  forall (x:t) (y:t), (infix_gtdt x y) <-> ((infix_gteqdt x y) /\ ~ (x = y)).

Axiom Refl : forall (x:t), infix_lseqdt x x.

Axiom Trans :
  forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (infix_lseqdt y z) ->
  infix_lseqdt x z.

Axiom Antisymm :
  forall (x:t) (y:t), (infix_lseqdt x y) -> (infix_lseqdt y x) -> (x = y).

Axiom Refl1 : forall (x:t), infix_gteqdt x x.

Axiom Trans1 :
  forall (x:t) (y:t) (z:t), (infix_gteqdt x y) -> (infix_gteqdt y z) ->
  infix_gteqdt x z.

Axiom Antisymm1 :
  forall (x:t) (y:t), (infix_gteqdt x y) -> (infix_gteqdt y x) -> (x = y).

Axiom Trans2 :
  forall (x:t) (y:t) (z:t), (infix_lsdt x y) -> (infix_lsdt y z) ->
  infix_lsdt x z.

Axiom Asymm : forall (x:t) (y:t), (infix_lsdt x y) -> ~ (infix_lsdt y x).

Axiom Trans3 :
  forall (x:t) (y:t) (z:t), (infix_gtdt x y) -> (infix_gtdt y z) ->
  infix_gtdt x z.

Axiom Asymm1 : forall (x:t) (y:t), (infix_gtdt x y) -> ~ (infix_gtdt y x).

Axiom r_to_t_inf :
  forall (i:R) (j:R), (infix_lseqdt (r_to_t i) (r_to_t j)) <-> (i <= j)%R.

Axiom inf_eq_def :
  forall (x:t) (y:t),
  (infix_lseqdt x y) <->
  (((real_ x) /\ ((real_ y) /\ ((real_part x) <= (real_part y))%R)) \/
   (x = y)).

Axiom inf_def :
  forall (x:t) (y:t),
  (infix_lsdt x y) <->
  ((real_ x) /\ ((real_ y) /\ (infix_lsas (real_part x) (real_part y)))).

Axiom sup_eq_def :
  forall (x:t) (y:t),
  (infix_gteqdt x y) <->
  (((real_ x) /\ ((real_ y) /\ ((real_part y) <= (real_part x))%R)) \/
   (x = y)).

Axiom sup_def :
  forall (x:t) (y:t),
  (infix_gtdt x y) <->
  ((real_ x) /\ ((real_ y) /\ (infix_lsas (real_part y) (real_part x)))).

Axiom decomp_mult :
  forall (a:t) (b:t),
  ((infix_asdt a b) =
   (infix_pldt
    (infix_mndt (infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b)))
     (infix_asdt (r_to_t (im_part a)) (r_to_t (im_part b))))
    (infix_asdt im
     (infix_pldt (infix_asdt (r_to_t (real_part a)) (r_to_t (im_part b)))
      (infix_asdt (r_to_t (real_part b)) (r_to_t (im_part a))))))).

Axiom decomp_mult_real_part :
  forall (a:t) (b:t),
  ((real_part (infix_asdt a b)) =
   (infix_mnas ((real_part a) * (real_part b))%R
    ((im_part a) * (im_part b))%R)).

Axiom decomp_mult_im_part :
  forall (a:t) (b:t),
  ((im_part (infix_asdt a b)) =
   (((real_part a) * (im_part b))%R + ((real_part b) * (im_part a))%R)%R).

(* Why3 assumption *)
Definition t_real_part (x:t) : t := r_to_t (real_part x).

Axiom t_real_part_spec : forall (x:t), real_ (t_real_part x).

(* Why3 assumption *)
Definition t_im_part (x:t) : t := r_to_t (im_part x).

Axiom t_im_part_spec : forall (x:t), real_ (t_im_part x).

Axiom t_mult_real :
  forall (a:t) (b:t),
  ((t_real_part (infix_asdt a b)) =
   (infix_mndt (infix_asdt (t_real_part a) (t_real_part b))
    (infix_asdt (t_im_part a) (t_im_part b)))).

Axiom t_im_real :
  forall (a:t) (b:t),
  ((t_im_part (infix_asdt a b)) =
   (infix_pldt (infix_asdt (t_real_part a) (t_im_part b))
    (infix_asdt (t_im_part a) (t_real_part b)))).

Axiom t_decomp_mult :
  forall (a:t) (b:t),
  ((infix_asdt a b) =
   (infix_pldt
    (infix_mndt (infix_asdt (t_real_part a) (t_real_part b))
     (infix_asdt (t_im_part a) (t_im_part b)))
    (infix_asdt im
     (infix_pldt (infix_asdt (t_real_part a) (t_im_part b))
      (infix_asdt (t_im_part a) (t_real_part b)))))).

Axiom t_complex_decomp :
  forall (i:t),
  (i = (infix_pldt (t_real_part i) (infix_asdt im (t_im_part i)))).

Axiom t_unic_decomp :
  forall (i:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
  (i = (infix_pldt a (infix_asdt im b))) ->
  (a = (t_real_part i)) /\ (b = (t_im_part i)).

Axiom real_sum :
  forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_pldt x y).

Axiom real_diff :
  forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_mndt x y).

Axiom pure_im_sum :
  forall (x:t) (y:t), (pure_im_ x) -> (pure_im_ y) ->
  pure_im_ (infix_pldt x y).

Axiom pure_im_diff :
  forall (x:t) (y:t), (pure_im_ x) -> (pure_im_ y) ->
  pure_im_ (infix_mndt x y).

Axiom real_mult :
  forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_asdt x y).

Axiom real_inv :
  forall (x:t), (real_ x) -> ~ (x = tzero) -> real_ (infix_sldt tone x).

Axiom real_div :
  forall (x:t) (y:t), (real_ x) -> ~ (y = tzero) -> (real_ y) ->
  real_ (infix_sldt x y).

Axiom mult_real_real :
  forall (a:t) (b:t), (real_ a) -> (real_ b) ->
  (((infix_asdt a b) =
    (infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b)))) /\
   ((infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b))) =
    (r_to_t ((real_part a) * (real_part b))%R))) /\
  (((real_part (infix_asdt a b)) = ((real_part a) * (real_part b))%R) /\
   ((im_part (infix_asdt a b)) = 0%R)).

Axiom mult_im_im :
  forall (a:t) (b:t), (pure_im_ a) -> (pure_im_ b) ->
  ((infix_asdt a b) =
   (infix_asdt (infix_asdt im im)
    (infix_asdt (r_to_t (im_part a)) (r_to_t (im_part b))))) /\
  (((infix_asdt a b) = (prefix_mndt (r_to_t ((im_part a) * (im_part b))%R))) /\
   (((real_part (infix_asdt a b)) = (-((im_part a) * (im_part b))%R)%R) /\
    ((im_part (infix_asdt a b)) = 0%R))).

Axiom mult_real_im :
  forall (a:t) (b:t), (real_ a) -> (pure_im_ b) ->
  ((infix_asdt a b) =
   (infix_asdt im (infix_asdt (r_to_t (real_part a)) (r_to_t (im_part b))))) /\
  (((infix_asdt a b) =
    (infix_asdt im (r_to_t ((real_part a) * (im_part b))%R))) /\
   (((real_part (infix_asdt a b)) = 0%R) /\
    ((im_part (infix_asdt a b)) = ((real_part a) * (im_part b))%R))).

Axiom mult_im_real :
  forall (a:t) (b:t), (pure_im_ a) -> (real_ b) ->
  ((infix_asdt a b) =
   (infix_asdt im (infix_asdt (r_to_t (im_part a)) (r_to_t (real_part b))))) /\
  (((infix_asdt a b) =
    (infix_asdt im (r_to_t ((im_part a) * (real_part b))%R))) /\
   (((real_part (infix_asdt a b)) = 0%R) /\
    ((im_part (infix_asdt a b)) = ((im_part a) * (real_part b))%R))).

Axiom decomp_mult_gen :
  forall (a:t) (b:t),
  ((real_part (infix_asdt a b)) =
   (infix_mnas ((real_part a) * (real_part b))%R
    ((im_part a) * (im_part b))%R)) /\
  ((im_part (infix_asdt a b)) =
   (((real_part a) * (im_part b))%R + ((im_part a) * (real_part b))%R)%R).

Axiom inv_real :
  forall (a:t), ~ (a = tzero) -> (real_ a) ->
  ((real_part (infix_sldt tone a)) = (infix_slas 1%R (real_part a))) /\
  (real_ (infix_sldt tone a)).

Axiom zeroLessOne : infix_lseqdt tzero tone.

Axiom compatOrderAdd :
  forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (real_ x) -> (real_ y) ->
  (real_ z) -> infix_lseqdt (infix_pldt x z) (infix_pldt y z).

Axiom compat_order_mult :
  forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (real_ x) -> (real_ y) ->
  (real_ z) -> (infix_lseqdt tzero z) ->
  infix_lseqdt (infix_asdt x z) (infix_asdt y z).

Axiom strict_compat_order_mult :
  forall (x:t) (y:t) (z:t), (infix_lsdt x y) -> (real_ x) -> (real_ y) ->
  (real_ z) -> (infix_lsdt tzero z) ->
  infix_lsdt (infix_asdt x z) (infix_asdt y z).

Axiom inv_eqinf :
  forall (x:t) (y:t), (real_ x) -> (real_ y) ->
  ((infix_lsdt tzero x) /\ (infix_lseqdt x y)) ->
  infix_gteqdt (infix_sldt tone x) (infix_sldt tone y).

Axiom inv_inf :
  forall (x:t) (y:t), (real_ x) -> (real_ y) ->
  ((infix_lsdt tzero x) /\ (infix_lsdt x y)) ->
  infix_gtdt (infix_sldt tone x) (infix_sldt tone y).

Axiom inv_eqsup :
  forall (x:t) (y:t), (real_ x) -> (real_ y) ->
  ((infix_gteqdt x y) /\ (infix_gtdt y tzero)) ->
  infix_lseqdt (infix_sldt tone x) (infix_sldt tone y).

Axiom inv_sup :
  forall (x:t) (y:t), (real_ x) -> (real_ y) ->
  ((infix_gtdt x y) /\ (infix_gtdt y tzero)) ->
  infix_lsdt (infix_sldt tone x) (infix_sldt tone y).

Axiom inv_pos :
  forall (x:t), (real_ x) -> (infix_lsdt tzero x) ->
  infix_gtdt (infix_sldt tone x) tzero.

Axiom inv_neg :
  forall (x:t), (real_ x) -> (infix_gtdt tzero x) ->
  infix_lsdt (infix_sldt tone x) tzero.

Axiom zero_add_t :
  forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_pldt a1 a2) = a2).

Axiom add_zero_t :
  forall (a1:t) (a2:t), (a2 = tzero) -> ((infix_pldt a1 a2) = a1).

Axiom one_mult_t :
  forall (a1:t) (a2:t), (a1 = tone) -> ((infix_asdt a1 a2) = a2).

Axiom one_mult_t_const : forall (a:t), ((infix_asdt tone a) = a).

Axiom zero_mult_t_const : forall (a:t), ((infix_asdt tzero a) = tzero).

Axiom mult_zero_t_const : forall (a:t), ((infix_asdt a tzero) = tzero).

Axiom zero_mult_t :
  forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_asdt a1 a2) = tzero).

Axiom mult_zero_t :
  forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_asdt a2 a1) = tzero).

Axiom mult_one_t :
  forall (a1:t) (a2:t), (a2 = tone) -> ((infix_asdt a1 a2) = a1).

Axiom add_eq_t :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_pldt a1 b1) = (infix_pldt a2 b2)).

Axiom add_eq_t_rev :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_pldt a1 b1) = (infix_pldt b2 a2)).

Axiom mult_eq_t :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_asdt a1 b1) = (infix_asdt a2 b2)).

Axiom mult_eq_t_rev :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_asdt a1 b1) = (infix_asdt b2 a2)).

Axiom mult_comm : forall (a:t) (b:t), ((infix_asdt a b) = (infix_asdt b a)).

Axiom mult_assoc :
  forall (a:t) (b:t) (c:t),
  ((infix_asdt (infix_asdt a b) c) = (infix_asdt a (infix_asdt b c))).

Axiom mult_assoc_rev :
  forall (a:t) (b:t) (c:t),
  ((infix_asdt a (infix_asdt b c)) = (infix_asdt (infix_asdt a b) c)).

Axiom div_mult :
  forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
  ((infix_asdt a (infix_sldt b c)) = (infix_sldt (infix_asdt a b) c)).

Axiom div_mult_rev :
  forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
  ((infix_sldt (infix_asdt a b) c) = (infix_asdt a (infix_sldt b c))).

Axiom div_eq :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ~ (b1 = tzero) -> ((infix_sldt a1 b1) = (infix_sldt a2 b2)).

Axiom add_eq_inv_t :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_pldt a1 b1) = (infix_pldt b2 a2)).

Axiom mult_eq_inv_t :
  forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
  ((infix_asdt a1 b1) = (infix_asdt b2 a2)).

Axiom sum_frac :
  forall (a1:t) (a2:t) (b:t), ~ (b = tzero) ->
  ((infix_pldt (infix_sldt a1 b) (infix_sldt a2 b)) =
   (infix_sldt (infix_pldt a1 a2) b)).

Axiom sum_frac_rev :
  forall (a1:t) (a2:t) (b:t), ~ (b = tzero) ->
  ((infix_sldt (infix_pldt a1 a2) b) =
   (infix_pldt (infix_sldt a1 b) (infix_sldt a2 b))).

Axiom set : forall (a:Type), Type.
Parameter set_WhyType : forall (a:Type) {a_WT:WhyType a}, WhyType (set a).
Existing Instance set_WhyType.

Parameter mem: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> Prop.

Parameter infix_eqeq:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> Prop.

Axiom infix_eqeq_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a),
  (infix_eqeq s1 s2) <-> forall (x:a), (mem x s1) <-> (mem x s2).

Axiom extensionality :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), (infix_eqeq s1 s2) -> (s1 = s2).

Parameter subset:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> Prop.

Axiom subset_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a),
  (subset s1 s2) <-> forall (x:a), (mem x s1) -> mem x s2.

Axiom subset_refl :
  forall {a:Type} {a_WT:WhyType a}, forall (s:set a), subset s s.

Axiom subset_trans :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a) (s3:set a), (subset s1 s2) ->
  (subset s2 s3) -> subset s1 s3.

Parameter is_empty: forall {a:Type} {a_WT:WhyType a}, (set a) -> Prop.

Axiom is_empty_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (is_empty s) <-> forall (x:a), ~ (mem x s).

Parameter empty: forall {a:Type} {a_WT:WhyType a}, set a.

Axiom empty_def : forall {a:Type} {a_WT:WhyType a}, is_empty (empty : set a).

Parameter add: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> set a.

Axiom add_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a) (s:set a), forall (y:a),
  (mem y (add x s)) <-> ((y = x) \/ (mem y s)).

Parameter remove: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> set a.

Axiom remove_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a) (s:set a), forall (y:a),
  (mem y (remove x s)) <-> (~ (y = x) /\ (mem y s)).

Axiom add_remove :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a) (s:set a), (mem x s) -> ((add x (remove x s)) = s).

Axiom remove_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a) (s:set a), ((remove x (add x s)) = (remove x s)).

Axiom subset_remove :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a) (s:set a), subset (remove x s) s.

Parameter union:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.

Axiom union_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), forall (x:a),
  (mem x (union s1 s2)) <-> ((mem x s1) \/ (mem x s2)).

Parameter inter:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.

Axiom inter_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), forall (x:a),
  (mem x (inter s1 s2)) <-> ((mem x s1) /\ (mem x s2)).

Parameter diff:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.

Axiom diff_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), forall (x:a),
  (mem x (diff s1 s2)) <-> ((mem x s1) /\ ~ (mem x s2)).

Axiom subset_diff :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), subset (diff s1 s2) s1.

Parameter choose: forall {a:Type} {a_WT:WhyType a}, (set a) -> a.

Axiom choose_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ~ (is_empty s) -> mem (choose s) s.

Parameter cardinal: forall {a:Type} {a_WT:WhyType a}, (set a) -> Z.

Axiom cardinal_nonneg :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (0%Z <= (cardinal s))%Z.

Axiom cardinal_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ((cardinal s) = 0%Z) <-> (is_empty s).

Axiom cardinal_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a), forall (s:set a), ~ (mem x s) ->
  ((cardinal (add x s)) = (1%Z + (cardinal s))%Z).

Axiom cardinal_remove :
  forall {a:Type} {a_WT:WhyType a},
  forall (x:a), forall (s:set a), (mem x s) ->
  ((cardinal s) = (1%Z + (cardinal (remove x s)))%Z).

Axiom cardinal_subset :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), (subset s1 s2) ->
  ((cardinal s1) <= (cardinal s2))%Z.

Axiom subset_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a), (subset s1 s2) ->
  ((cardinal s1) = (cardinal s2)) -> infix_eqeq s1 s2.

Axiom cardinal1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ((cardinal s) = 1%Z) -> forall (x:a), (mem x s) ->
  (x = (choose s)).

Parameter filter:
  forall {a:Type} {a_WT:WhyType a}, (a -> bool) -> (set a) -> set a.

Axiom filter_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (p:a -> bool) (u:set a), forall (x:a),
  (mem x (filter p u)) <-> (((p x) = true) /\ (mem x u)).

Axiom filter_cardinal :
  forall {a:Type} {a_WT:WhyType a},
  forall (p:a -> bool) (u:set a), ((cardinal (filter p u)) <= (cardinal u))%Z.

Parameter map:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
  (set a) -> set b.

Axiom map_def1 :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (u:set a), forall (y:b),
  (mem y (map f u)) <-> exists x:a, (mem x u) /\ (y = (f x)).

Axiom map_def2 :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (u:set a), forall (x:a), (mem x u) -> mem (f x) (map f u).

Axiom map_cardinal :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (u:set a), ((cardinal (map f u)) <= (cardinal u))%Z.

Axiom assert_equal : True.

Axiom goal_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (b:a), (a1 = b) -> (b = a1).

Parameter fir:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a* b)%type ->
  a.

Parameter sec:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a* b)%type ->
  b.

Axiom projections :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (o:(a* b)%type), (o = (fir o, sec o)).

Axiom get_fir :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (b1:b), ((fir (a1, b1)) = a1).

Axiom get_sec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (b1:b), ((sec (a1, b1)) = b1).

(* Why3 assumption *)
Inductive ref (a:Type) :=
  | mk_ref : a -> ref a.
Axiom ref_WhyType : forall (a:Type) {a_WT:WhyType a}, WhyType (ref a).
Existing Instance ref_WhyType.
Arguments mk_ref {a}.

(* Why3 assumption *)
Definition contents {a:Type} {a_WT:WhyType a} (v:ref a) : a :=
  match v with
  | mk_ref x => x
  end.

Axiom union_exchange :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), ~ (is_empty s') ->
  ((union (add (choose s') s) (remove (choose s') s')) = (union s s')).

Axiom get_filter :
  forall {a:Type} {a_WT:WhyType a},
  forall (p:a -> bool) (s:set a) (x:a), (mem x (filter p s)) ->
  ((p x) = true) /\ (mem x s).

Axiom set_filter :
  forall {a:Type} {a_WT:WhyType a},
  forall (p:a -> bool) (s:set a) (x:a), ((p x) = true) -> (mem x s) ->
  mem x (filter p s).

Axiom inter_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (is_empty s) -> is_empty (inter s s').

Axiom inter_empty_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (is_empty s') -> is_empty (inter s s').

Axiom union_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (is_empty s) -> ((union s s') = s').

Axiom union_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (is_empty s') -> ((union s s') = s).

Axiom union_members :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a),
  (forall (a1:a), (mem a1 (union s s')) -> ~ (mem a1 s) -> mem a1 s') /\
  forall (a1:a), (mem a1 (union s s')) -> ~ (mem a1 s') -> mem a1 s.

Axiom union_alt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (e:a), (mem e (union s s')) -> ~ (mem e s) ->
  mem e s'.

Axiom union_empty_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (is_empty s') -> ((union s s') = s).

Axiom set_subset :
  forall {a:Type} {a_WT:WhyType a},
  forall (s':set a) (s:set a), (forall (e:a), (mem e s') -> mem e s) ->
  subset s' s.

Axiom set_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (forall (e:a), ~ (mem e s)) ->
  (s = (empty : set a)) /\ (is_empty s).

Axiom set_equal :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (forall (e:a), (mem e s) -> mem e s') ->
  (forall (e:a), (mem e s') -> mem e s) -> (s = s').

Axiom get_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (s = (empty : set a)) ->
  (forall (e:a), ~ (mem e s)) /\ (is_empty s).

Axiom get_non_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ~ (is_empty s) -> exists e:a, mem e s.

Axiom set_non_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (exists e:a, mem e s) ->
  ~ (is_empty s) /\ (0%Z < (cardinal s))%Z.

Axiom set_pos_card_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (a1:a), (mem a1 s) -> (0%Z < (cardinal s))%Z.

Axiom union_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (x:a), ~ (mem x s') ->
  ((union s (add x s')) = (add x (union s s'))).

Axiom union_add_mem :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (x:a) (y:a), (mem x (add y (union s s'))) ->
  ~ (mem x s') -> ~ (mem x s) -> (x = y).

Axiom union_add_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (x:a), ~ (mem x s') ->
  ((add x (union s s')) = (union s (add x s'))).

Axiom remove_add1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:a), ~ (mem x s) -> ((remove x (add x s)) = s).

Axiom add_remove1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:a), (mem x s) -> ((add x (remove x s)) = s).

(* Why3 assumption *)
Definition p_injective {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (f:a -> b) (s:set a) : Prop :=
  forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
  ~ ((f e) = (f e')).

Axiom set_map_mem :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (b1:b),
  (exists a1:a, (mem a1 s) /\ (b1 = (f a1))) -> mem b1 (map f s).

Axiom map_add :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (x:a), ~ (mem x s) ->
  ((map f (add x s)) = (add (f x) (map f s))).

Axiom map_eq :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:a -> b) (s:set a),
  (forall (e:a), (mem e s) -> ((f e) = (g e))) -> ((map f s) = (map g s)).

Axiom injective_map_cardinal :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), (p_injective f s) ->
  ((cardinal (map f s)) = (cardinal s)).

Axiom set_map_mem_el :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (b1:b) (a1:a), (mem a1 s) -> (b1 = (f a1)) ->
  mem b1 (map f s).

Axiom set_map_mem_el_gen :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (b1:b),
  (exists a1:a, (mem a1 s) /\ (b1 = (f a1))) -> mem b1 (map f s).

Axiom map_antec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (b1:b), (mem b1 (map f s)) ->
  exists a1:a, (mem a1 s) /\ (b1 = (f a1)).

Axiom map_antec_gen :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), forall (b1:b), (mem b1 (map f s)) ->
  exists a1:a, (mem a1 s) /\ (b1 = (f a1)).

Axiom map_remove_choose :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (f:a -> b), (p_injective f s) ->
  ((map f (remove (choose s) s)) = (remove (f (choose s)) (map f s))).

Parameter antec_set:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
  (a -> b) -> b -> set a.

Parameter result:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
  b -> a -> bool.

Axiom result_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (b1:b) (e:a), (((result f b1) e) = true) <-> ((f e) = b1).

Axiom antec_set_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
  ((antec_set s f b1) = (filter (result f b1) s)).

Parameter remove_s:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.

Parameter result1: forall {a:Type} {a_WT:WhyType a}, (set a) -> a -> bool.

Axiom result_def1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (s':set a) (e:a), (((result1 s') e) = true) <-> ~ (mem e s').

Axiom remove_s_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (subset s' s) ->
  ((remove_s s s') = (filter (result1 s') s)).

Axiom remove_s_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), (subset s' s) -> forall (e:a),
  (mem e (remove_s s s')) <-> ((mem e s) /\ ~ (mem e s')).

Parameter remove_antecs:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
  (a -> b) -> b -> set a.

Axiom remove_antecs_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
  ((remove_antecs s f b1) = (remove_s s (antec_set s f b1))).

Axiom remove_antecs_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
  (forall (e:a),
   (mem e (remove_antecs s f b1)) <-> ((mem e s) /\ ~ ((f e) = b1))) /\
  ((cardinal (remove_antecs s f b1)) < (cardinal s))%Z.

Axiom map_remove_antec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
  ((map f (remove_antecs s f b1)) = (remove b1 (map f s))).

Axiom map_non_empty :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), (0%Z < (cardinal s))%Z ->
  (0%Z < (cardinal (map f s)))%Z.

Axiom non_empty_map :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), (0%Z < (cardinal (map f s)))%Z ->
  (0%Z < (cardinal s))%Z.

Parameter right_injections:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, a -> (set b) ->
  set (a* b)%type.

Axiom right_injections_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (s:set b),
  ((is_empty s) -> ((right_injections a1 s) = (empty : set (a* b)%type))) /\
  (~ (is_empty s) ->
   ((right_injections a1 s) =
    (add (a1, choose s) (right_injections a1 (remove (choose s) s))))).

Axiom right_injections_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (s:set b),
  ((cardinal (right_injections a1 s)) = (cardinal s)) /\
  ((forall (a':a), forall (b1:b),
    (mem (a', b1) (right_injections a1 s)) <-> ((a' = a1) /\ (mem b1 s))) /\
   ((right_injections a1 s) = (map (fun (b1:b) => (a1, b1)) s))).

Parameter left_injections:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) -> b ->
  set (a* b)%type.

Axiom left_injections_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (b1:b),
  ((is_empty s) -> ((left_injections s b1) = (empty : set (a* b)%type))) /\
  (~ (is_empty s) ->
   ((left_injections s b1) =
    (add (choose s, b1) (left_injections (remove (choose s) s) b1)))).

Axiom left_injections_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (b1:b),
  (forall (a1:a), forall (b':b),
   (mem (a1, b') (left_injections s b1)) <-> ((mem a1 s) /\ (b' = b1))) /\
  (((cardinal (left_injections s b1)) = (cardinal s)) /\
   ((left_injections s b1) = (map (fun (a1:a) => (a1, b1)) s))).

Axiom right_injections_l :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (s:set b),
  ((cardinal (right_injections a1 s)) = (cardinal s)) /\
  ((forall (a':a), forall (b1:b),
    (mem (a', b1) (right_injections a1 s)) <-> ((a' = a1) /\ (mem b1 s))) /\
   ((right_injections a1 s) = (map (fun (b1:b) => (a1, b1)) s))).

Axiom left_injections_l :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (b1:b),
  (forall (a1:a), forall (b':b),
   (mem (a1, b') (left_injections s b1)) <-> ((mem a1 s) /\ (b' = b1))) /\
  (((cardinal (left_injections s b1)) = (cardinal s)) /\
   ((left_injections s b1) = (map (fun (a1:a) => (a1, b1)) s))).

Axiom disjoint_injections :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (b1:b) (c:b), ~ (b1 = c) ->
  (is_empty (inter (right_injections b1 s) (right_injections c s))) /\
  (is_empty (inter (left_injections s b1) (left_injections s c))).

Axiom induction :
  forall {a:Type} {a_WT:WhyType a},
  forall (p:(set a) -> bool) (t1:set a),
  (forall (s:set a), (is_empty s) -> ((p s) = true)) ->
  (forall (s:set a), ((p s) = true) -> forall (t2:a), ~ (mem t2 s) ->
   ((p (add t2 s)) = true)) ->
  ((p t1) = true).

Axiom cardinal_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a),
  ((cardinal (union s s')) =
   (((cardinal s) + (cardinal s'))%Z - (cardinal (inter s s')))%Z).

Axiom cardinal_sum_empty_inter :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a), ((inter s s') = (empty : set a)) ->
  ((cardinal (union s s')) = ((cardinal s) + (cardinal s'))%Z).

Parameter cartesian_product:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
  (set b) -> set (a* b)%type.

Axiom cartesian_product_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b),
  ((cardinal (cartesian_product s1 s2)) = ((cardinal s1) * (cardinal s2))%Z) /\
  ((forall (a1:a), forall (b1:b),
    (mem (a1, b1) (cartesian_product s1 s2)) <-> ((mem a1 s1) /\ (mem b1 s2))) /\
   forall (o:(a* b)%type),
   (mem o (cartesian_product s1 s2)) <->
   ((mem (fir o) s1) /\ (mem (sec o) s2))).

(* Why3 assumption *)
Definition commute {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (o:(a* b)%type) : (b* a)%type :=
  match o with
  | (a1, b1) => (b1, a1)
  end.

Axiom commute_inj :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (a':a) (b1:b) (b':b), ((a1 = a') -> ~ (b1 = b')) ->
  ~ ((commute (a1, b1)) = (commute (a', b'))).

Axiom mem_cartesian_product :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b) (a1:a) (b1:b), (mem a1 s1) -> (mem b1 s2) ->
  mem (a1, b1) (cartesian_product s1 s2).

Axiom commute_inj_gen :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b),
  p_injective (fun (y0:(a* b)%type) => (commute y0))
  (cartesian_product s1 s2).

(* Why3 assumption *)
Definition commute_product {a:Type} {a_WT:WhyType a}
    {b:Type} {b_WT:WhyType b} (s1:set a) (s2:set b) : set (b* a)%type :=
  map (fun (y0:(a* b)%type) => (commute y0)) (cartesian_product s1 s2).

Axiom commute_product_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b),
  ((commute_product s1 s2) = (cartesian_product s2 s1)).

(* Why3 assumption *)
Definition commute_product_el {a:Type} {a_WT:WhyType a}
    {b:Type} {b_WT:WhyType b} (s1:set a) (s2:set b) : set (b* a)%type :=
  map (fun (y0:(a* b)%type) => (commute y0)) (cartesian_product s1 s2).

Axiom commute_product_el_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b), forall (o:(a* b)%type),
  match o with
  | (a1, b1) =>
      ((mem o (cartesian_product s1 s2)) <-> ((mem a1 s1) /\ (mem b1 s2))) /\
      (((mem a1 s1) /\ (mem b1 s2)) <->
       (mem (b1, a1) (commute_product_el s1 s2)))
  end.

Axiom cartesian_product_union :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b) (s3:set b),
  ((cartesian_product s1 (union s2 s3)) =
   (union (cartesian_product s1 s2) (cartesian_product s1 s3))).

Axiom cartesian_union_product :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set a) (s3:set b),
  ((cartesian_product (union s1 s2) s3) =
   (union (cartesian_product s1 s3) (cartesian_product s2 s3))).

Axiom cartesian_product_cardone_r :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b), ((cardinal s1) = 1%Z) ->
  (infix_eqeq (cartesian_product s1 s2) (right_injections (choose s1) s2)) /\
  (infix_eqeq (cartesian_product s1 s2)
   (map (fun (e2:b) => (choose s1, e2)) s2)).

Axiom cartesian_product_cardone_l :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b), ((cardinal s2) = 1%Z) ->
  (infix_eqeq (cartesian_product s1 s2) (left_injections s1 (choose s2))) /\
  (infix_eqeq (cartesian_product s1 s2)
   (map (fun (e1:a) => (e1, choose s2)) s1)).

Axiom disjoint_cartesian_product_l :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set a) (s3:set b),
  ((inter s1 s2) = (empty : set a)) ->
  ((inter (cartesian_product s1 s3) (cartesian_product s2 s3)) =
   (empty : set (a* b)%type)).

Axiom disjoint_cartesian_product_r :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b) (s3:set b),
  ((inter s2 s3) = (empty : set b)) ->
  ((inter (cartesian_product s1 s2) (cartesian_product s1 s3)) =
   (empty : set (a* b)%type)).

Axiom to_set_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (e:a),
  ((cardinal (add e (empty : set a))) = 1%Z) /\
  forall (b:a), (mem b (add e (empty : set a))) -> (b = e).

Parameter to_fset: Z -> Z -> set Z.

Axiom to_fset_spec :
  forall (i:Z) (j:Z),
  ((i < j)%Z -> ((cardinal (to_fset i j)) = (j - i)%Z)) /\
  (((j <= i)%Z -> is_empty (to_fset i j)) /\
   forall (k:Z), (mem k (to_fset i j)) <-> ((i <= k)%Z /\ (k < j)%Z)).

Axiom to_fset_unit_ext :
  forall (i:Z) (j:Z), (i < j)%Z ->
  ((to_fset i j) = (add i (to_fset (i + 1%Z)%Z j))).

Axiom to_fset_ext :
  forall (i:Z) (i':Z) (j:Z), ((i <= i')%Z /\ (i' <= j)%Z) ->
  ((to_fset i j) = (union (to_fset i i') (to_fset i' j))).

Parameter element: forall {a:Type} {a_WT:WhyType a}, (set a) -> a.

Axiom element_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ((cardinal s) = 1%Z) -> ((element s) = (choose s)).

Axiom cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
  (0%Z < (cardinal s))%Z -> ((cardinal s) = 1%Z) /\ ((element s) = a1).

Axiom set_cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (0%Z < (cardinal s))%Z ->
  (exists a1:a, forall (b:a), (mem b s) <-> (b = a1)) -> ((cardinal s) = 1%Z).

Axiom get_cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), ((cardinal s) = 1%Z) ->
  exists a1:a, forall (b:a), (mem b s) <-> (b = a1).

Axiom set_cardone_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (a1:a), (0%Z < (cardinal s))%Z ->
  (forall (b:a), (mem b s) <-> (b = a1)) ->
  ((cardinal s) = 1%Z) /\ ((element s) = a1).

Axiom cardzero :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a), (forall (b:a), ~ (mem b s)) -> ((cardinal s) = 0%Z).

(* Why3 assumption *)
Definition p_injective_in {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (f:a -> b) (s:set a) (s':set b) : Prop :=
  forall (e:a), (mem e s) ->
  (mem (f e) s') /\
  forall (e1:a) (e':a), (mem e1 s) -> (mem e' s) -> ~ (e1 = e') ->
  ~ ((f e1) = (f e')).

(* Why3 assumption *)
Definition equal_func {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (f:a -> b) (g:a -> b) : Prop :=
  forall (e:a), ((f e) = (g e)).

Axiom set_equal_func :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:a -> b), (forall (e:a), ((f e) = (g e))) -> (f = g).

Axiom get_equal_func :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:a -> b), (equal_func f g) -> forall (e:a),
  ((f e) = (g e)).

Axiom set_injective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a),
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
   ~ ((f e) = (f e'))) ->
  p_injective f s.

Axiom image_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), forall (a1:b),
  (mem a1 (map f s)) <->
  exists antec_a:a, (mem antec_a s) /\ (a1 = (f antec_a)).

Axiom card_image :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), ((cardinal (map f s)) <= (cardinal s))%Z.

Axiom card_image_injective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), (p_injective f s) ->
  ((cardinal (map f s)) = (cardinal s)).

Axiom get_injective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), (p_injective f s) -> forall (e:a) (e':a),
  (mem e s) -> (mem e' s) -> ~ (e = e') -> ~ ((f e) = (f e')).

Axiom set_injective_in :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b),
  (forall (e:a), (mem e s) -> mem (f e) s') ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
   ~ ((f e) = (f e'))) ->
  p_injective f s.

Axiom get_injective_in :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_injective_in f s s') ->
  (forall (e:a), (mem e s) -> mem (f e) s') /\
  forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
  ~ ((f e) = (f e')).

(* Why3 assumption *)
Definition p_surjective {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (f:a -> b) (s:set a) (s':set b) : Prop :=
  (forall (e:a), (mem e s) -> mem (f e) s') /\
  forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e').

Axiom set_surjective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b),
  (forall (e:a), (mem e s) -> mem (f e) s') ->
  (forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
  p_surjective f s s'.

Axiom get_surjective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
  (forall (e:a), (mem e s) -> mem (f e) s') /\
  forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e').

Axiom image_surjective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
  ((map f s) = s').

(* Why3 assumption *)
Definition p_bijective {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    (f:a -> b) (s:set a) (s':set b) : Prop :=
  (p_injective_in f s s') /\ (p_surjective f s s').

Axiom bijective_is_injective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  p_injective f s.

Axiom bijective_is_surjective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  p_surjective f s s'.

Axiom set_bijective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b),
  (forall (e:a), (mem e s) -> mem (f e) s') ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
   ~ ((f e) = (f e'))) ->
  (forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
  (p_bijective f s s') /\ ((map f s) = s').

Axiom bijectivity_is_transitive :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {c:Type} {c_WT:WhyType c},
  forall (f:a -> b) (g:b -> c) (s:set a) (s':set b) (s'':set c),
  (p_bijective f s s') -> (p_bijective g s' s'') ->
  p_bijective (fun (k:a) => (g (f k))) s s''.

Axiom bijective_image :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> a) (s:set a) (s':set a), (p_bijective f s s') ->
  ((cardinal s) = (cardinal s')) /\ (s' = (map f s)).

Axiom get_bijective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  (forall (e:a), (mem e s) -> mem (f e) s') /\
  ((forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
    ~ ((f e) = (f e'))) /\
   ((forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) /\
    ((cardinal s) = (cardinal s')))).

Axiom bijective_eq :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  (forall (e:a), (mem e s) -> ((f e) = (g e))) -> p_bijective g s s'.

Axiom bijective_eq_gen :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  forall (g:a -> b), (forall (e:a), (mem e s) -> ((f e) = (g e))) ->
  p_bijective g s s'.

Axiom bij_equal_card :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a), ((cardinal s) = (cardinal (map f s))) ->
  p_bijective f s (map f s).

Axiom set_bijective_auto :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> a) (s:set a), (forall (e:a), (mem e s) -> mem (f e) s) ->
  (forall (e':a), (mem e' s) -> exists e:a, (mem e s) /\ ((f e) = e')) ->
  p_bijective f s s.

Parameter op: forall {im1:Type} {im1_WT:WhyType im1}, im1 -> im1 -> im1.

Parameter po: forall {im1:Type} {im1_WT:WhyType im1}, im1 -> im1 -> im1.

Parameter inver: forall {im1:Type} {im1_WT:WhyType im1}, im1 -> im1.

(* Why3 assumption *)
Definition op_neutral_left {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (neutral:im1) : Prop :=
  forall (e:im1), (((op1 neutral) e) = e).

(* Why3 assumption *)
Definition op_neutral_right {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (neutral:im1) : Prop :=
  forall (e:im1), (((op1 e) neutral) = e).

(* Why3 assumption *)
Definition op_assoc {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) :
    Prop :=
  forall (a:im1) (b:im1) (c:im1),
  (((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c))).

(* Why3 assumption *)
Definition op_neutral_left_comm {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (neutral:im1) : Prop :=
  forall (a:im1), (forall (b:im1), (((op1 a) b) = b)) -> (a = neutral).

(* Why3 assumption *)
Definition commut {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) :
    Prop :=
  forall (a:im1) (b:im1), (((op1 a) b) = ((op1 b) a)).

(* Why3 assumption *)
Definition assoc {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) :
    Prop :=
  forall (a:im1) (b:im1) (c:im1),
  (((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c))).

(* Why3 assumption *)
Definition opposite_n {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1)
    (po1:im1 -> im1 -> im1) (neutral:im1) : Prop :=
  forall (a:im1), (((po1 a) a) = neutral).

(* Why3 assumption *)
Definition inverse {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1)
    (po1:im1 -> im1 -> im1) (inver1:im1 -> im1) : Prop :=
  forall (a:im1) (b:im1), (((po1 a) b) = ((op1 a) (inver1 b))).

(* Why3 assumption *)
Definition opposite {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1)
    (po1:im1 -> im1 -> im1) : Prop :=
  forall (a:im1) (b:im1), (((op1 ((po1 a) b)) b) = a).

(* Why3 assumption *)
Definition opposite_com {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) : Prop :=
  forall (a:im1) (b:im1), (((po1 ((op1 a) b)) b) = a).

Axiom refl :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (a:im1) (b:im1), (commut op1) ->
  (((op1 a) b) = ((op1 b) a)).

(* Why3 assumption *)
Definition neutral {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1)
    (neut:im1) : Prop :=
  (op_neutral_left op1 neut) /\
  ((op_neutral_right op1 neut) /\ (op_assoc op1)).

Axiom set_neutral :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (neut:im1), (op_neutral_left op1 neut) ->
  (op_neutral_right op1 neut) -> (op_assoc op1) -> neutral op1 neut.

(* Why3 assumption *)
Definition has_neutral {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) : Prop :=
  exists e:im1, neutral op1 e.

(* Why3 assumption *)
Definition iterates {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1)
    (neutral1:im1) : Prop :=
  (op_neutral_left op1 neutral1) /\
  ((op_neutral_right op1 neutral1) /\ (op_assoc op1)).

(* Why3 assumption *)
Definition iterable {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) :
    Prop :=
  exists e:im1, iterates op1 e.

Axiom iterates_ :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (neutral1:im1),
  (op_neutral_left op1 neutral1) -> (op_neutral_right op1 neutral1) ->
  (op_assoc op1) -> (iterates op1 neutral1) /\ (iterable op1).

Parameter neutral_elt:
  forall {im1:Type} {im1_WT:WhyType im1}, (im1 -> im1 -> im1) -> im1.

Axiom neutral_elt_spec :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1), forall (e:im1),
  (neutral op1 e) <-> ((neutral_elt op1) = e).

(* Why3 assumption *)
Definition inverse_tuple {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) (neutral1:im1) : Prop :=
  (opposite_n op1 po1 neutral1) /\
  ((opposite op1 po1) /\ (opposite_com op1 po1)).

Parameter iterate:
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  (im1 -> im1 -> im1) -> (set a) -> (a -> im1) -> im1.

Axiom Iterate_def_empty :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1), forall (s:set a), forall (f:a -> im1),
  (commut op1) -> (iterable op1) -> (is_empty s) ->
  ((iterate op1 (empty : set a) f) = (neutral_elt op1)).

Axiom Iterate_one :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1), forall (s:set a), forall (f:a -> im1),
  forall (x:a), (is_empty s) -> (commut op1) ->
  ((iterate op1 (add x s) f) = (f x)).

Axiom Iterate_add :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1), forall (s:set a), forall (f:a -> im1),
  forall (x:a), (0%Z < (cardinal s))%Z -> (commut op1) -> ~ (mem x s) ->
  ((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).

Axiom minus_zero :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) (a:im1),
  (iterable op1) -> (inverse_tuple op1 po1 (neutral_elt op1)) ->
  (((po1 a) (neutral_elt op1)) = a).

Axiom unic :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) (a:im1) (b:im1)
    (c:im1),
  (iterable op1) -> (commut op1) -> (((op1 a) b) = ((op1 a) c)) ->
  (inverse_tuple op1 po1 (neutral_elt op1)) -> (b = c).

Axiom substract_comm :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) (a:im1) (b:im1)
    (c:im1),
  (iterable op1) -> (commut op1) ->
  (inverse_tuple op1 po1 (neutral_elt op1)) ->
  (((po1 ((op1 a) b)) a) = b) /\
  ((((po1 ((op1 b) a)) a) = b) /\
   ((((po1 a) ((po1 b) c)) = ((op1 ((po1 a) b)) c)) /\
    (((po1 ((op1 a) b)) c) = ((op1 a) ((po1 b) c))))).

Parameter int_iterate:
  forall {im1:Type} {im1_WT:WhyType im1}, (im1 -> im1 -> im1) ->
  (Z -> im1) -> Z -> Z -> im1.

Axiom int_iterate_def :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z),
  ((j <= i)%Z -> iterable op1) ->
  ((j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1))) /\
  (~ (j <= i)%Z ->
   ((j = (i + 1%Z)%Z) -> ((int_iterate op1 f i j) = (f i))) /\
   (~ (j = (i + 1%Z)%Z) ->
    ((int_iterate op1 f i j) =
     ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))))).

Axiom int_iterate_spec :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z),
  ((j <= i)%Z -> iterable op1) ->
  ((j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1))) /\
  ((j = (i + 1%Z)%Z) ->
   ((int_iterate op1 f i j) = ((op1 (f i)) (neutral_elt op1)))).

Parameter int_int_iterate:
  forall {im1:Type} {im1_WT:WhyType im1}, (im1 -> im1 -> im1) ->
  (Z -> Z -> im1) -> Z -> Z -> Z -> Z -> im1.

Axiom int_int_iterate_def :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (iterable op1) ->
  ((j <= i)%Z -> ((int_int_iterate op1 f i j k l) = (neutral_elt op1))) /\
  (~ (j <= i)%Z ->
   ((int_int_iterate op1 f i j k l) =
    ((op1 (int_iterate op1 (f i) k l))
     (int_int_iterate op1 f (i + 1%Z)%Z j k l)))).

Axiom iterate_empty :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (is_empty s) ->
  (commut op1) -> (iterable op1) -> ((iterate op1 s t1) = (neutral_elt op1)).

Axiom iterate_one :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1),
  ((cardinal s) = 1%Z) -> (commut op1) ->
  ((iterate op1 s t1) = (t1 (choose s))).

Axiom iterate_add :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1) (x:a),
  (commut op1) -> (iterable op1) -> ~ (mem x s) ->
  ((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).

Axiom iterate_add_ :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1) (x:a),
  (commut op1) -> ~ (mem x s) -> ~ (is_empty s) ->
  ((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).

Axiom iterate_remove :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1) (x:a),
  (commut op1) -> (iterable op1) ->
  (inverse_tuple op1 (fun (y0:im1) (y1:im1) => (po y0 y1)) (neutral_elt op1)) ->
  (mem x s) -> ((iterate op1 (remove x s) f) = (po (iterate op1 s f) (f x))).

Axiom iterate_def_choose :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1),
  (((cardinal s) = 1%Z) -> iterable op1) -> (commut op1) -> ~ (is_empty s) ->
  ((iterate op1 s f) =
   ((op1 (f (choose s))) (iterate op1 (remove (choose s) s) f))).

Axiom choose_any :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1) (t1:a),
  (iterable op1) -> (commut op1) -> (mem t1 s) ->
  ((iterate op1 s f) = ((op1 (f t1)) (iterate op1 (remove t1 s) f))).

Axiom iterate_comp_iterate :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s1:set a) (f:a -> im1) (g:a -> im1),
  (iterable op1) -> (commut op1) -> (assoc op1) ->
  ((iterate op1 s1 (fun (k:a) => ((op1 (f k)) (g k)))) =
   ((op1 (iterate op1 s1 (fun (k:a) => (f k))))
    (iterate op1 s1 (fun (k:a) => (g k))))).

Axiom iterate_comp_iterate_com :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s1:set a) (f:a -> im1) (g:a -> im1),
  (iterable op1) -> (commut op1) ->
  (((op1 (iterate op1 s1 (fun (k:a) => (f k))))
    (iterate op1 s1 (fun (k:a) => (g k))))
   = (iterate op1 s1 (fun (k:a) => ((op1 (f k)) (g k))))).

Axiom iterate_transitivity :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (po1:im1 -> im1 -> im1) (s1:set a)
    (s2:set a) (f:a -> im1),
  (iterable op1) -> (commut op1) ->
  (inverse_tuple op1 po1 (neutral_elt op1)) ->
  ((iterate op1 (union s1 s2) f) =
   ((po1 ((op1 (iterate op1 s1 f)) (iterate op1 s2 f)))
    (iterate op1 (inter s1 s2) f))).

Axiom iterate_disjoint_transitivity :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s1:set a) (s2:set a) (t1:a -> im1),
  (iterable op1) -> (commut op1) -> ((inter s1 s2) = (empty : set a)) ->
  ((iterate op1 (union s1 s2) t1) =
   ((op1 (iterate op1 s1 t1)) (iterate op1 s2 t1))).

Axiom iterate_eq :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f:a -> im1) (g:a -> im1),
  (forall (x:a), (mem x s) -> ((f x) = (g x))) -> (commut op1) ->
  ((is_empty s) -> iterable op1) -> ((iterate op1 s f) = (iterate op1 s g)).

Axiom iterate_map :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set b) (f:b -> a) (t1:a -> im1),
  ((is_empty s) -> iterable op1) -> (commut op1) -> (p_injective f s) ->
  ((iterate op1 (map f s) t1) = (iterate op1 s (fun (b1:b) => (t1 (f b1))))).

Axiom iterate_cardone :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
  (commut op1) -> ((cardinal s) = 1%Z) ->
  ((iterate op1 s t1) = (t1 (element s))).

Axiom iterate_cardzero :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
  (iterable op1) -> ((cardinal s) = 0%Z) ->
  ((iterate op1 s t1) = (neutral_elt op1)).

Axiom injec_iterate :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (a1:a) (s:set b) (f:a -> b -> im1),
  (iterable op1) -> (commut op1) ->
  ((iterate op1 s (f a1)) =
   (iterate op1 (cartesian_product (add a1 (empty : set a)) s)
    (fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).

Axiom iterate_cartesian_product :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s1:set a) (s2:set b) (f:a -> b -> im1),
  (iterable op1) -> (commut op1) ->
  ((iterate op1 s1 (fun (a1:a) => (iterate op1 s2 (f a1)))) =
   (iterate op1 (cartesian_product s1 s2)
    (fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).

Axiom iterate_eq_func :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (f1:a -> im1) (f2:a -> im1),
  (commut op1) -> (iterable op1) -> (p_injective f1 s) ->
  (p_injective f2 s) -> ((map f1 s) = (map f2 s)) ->
  ((iterate op1 s f1) = (iterate op1 s f2)).

Axiom int_iterate_def_empty :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z), (j <= i)%Z ->
  (iterable op1) -> ((int_iterate op1 f i j) = (neutral_elt op1)).

Axiom int_iterate_def_plus_one :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z), (i < j)%Z ->
  (((i + 1%Z)%Z = j) -> iterable op1) ->
  ((int_iterate op1 f i j) = ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))).

Axiom int_iterate_cardone :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z),
  (j = (i + 1%Z)%Z) -> ((int_iterate op1 f i j) = (f i)).

Axiom int_iterate_def_plus_one_com :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z), (i < j)%Z ->
  ((j = (i + 1%Z)%Z) -> iterable op1) ->
  (((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j)) = (int_iterate op1 f i j)).

Axiom int_iterate_to_iterate :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z),
  ((j <= i)%Z -> iterable op1) -> (commut op1) ->
  ((int_iterate op1 f i j) = (iterate op1 (to_fset i j) f)).

Axiom int_iterate_right_extension :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z), (iterable op1) ->
  (i < j)%Z ->
  ((int_iterate op1 f i j) =
   ((op1 (int_iterate op1 f i (j - 1%Z)%Z)) (f (j - 1%Z)%Z))).

Axiom int_iterate_right_extension_ :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z), (assoc op1) ->
  ((i + 1%Z)%Z < j)%Z ->
  ((int_iterate op1 f i j) =
   ((op1 (int_iterate op1 f i (j - 1%Z)%Z)) (f (j - 1%Z)%Z))).

Axiom int_iterate_transitivity :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (k:Z) (j:Z),
  (iterable op1) -> (iterable op1) ->
  (op_neutral_left op1 (neutral_elt op1)) -> ((i <= k)%Z /\ (k <= j)%Z) ->
  ((int_iterate op1 f i j) =
   ((op1 (int_iterate op1 f i k)) (int_iterate op1 f k j))).

Axiom int_iterate_transitivity_ :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (k:Z) (j:Z),
  (op_neutral_left op1 (neutral_elt op1)) -> ((i < k)%Z /\ (k < j)%Z) ->
  ((int_iterate op1 f i j) =
   ((op1 (int_iterate op1 f i k)) (int_iterate op1 f k j))).

Axiom int_iterate_comp_iterate :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (g:Z -> im1) (i:Z) (j:Z),
  (iterable op1) -> (op_neutral_right op1 (neutral_elt op1)) ->
  (commut op1) ->
  ((int_iterate op1 (fun (k:Z) => ((op1 (f k)) (g k))) i j) =
   ((op1 (int_iterate op1 f i j)) (int_iterate op1 g i j))).

Axiom int_iterate_attr_no_f :
  forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
  forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t1:Z -> im1)
    (t2:Z -> im2) (f:im1 -> im2) (i:Z) (j:Z),
  (forall (x:Z), forall (y:im1),
   (((op2 (t2 x)) (f y)) = (f ((op1 (t1 x)) y)))) ->
  ((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
  (iterable op2) -> (forall (i1:Z), ((f (t1 i1)) = (t2 i1))) ->
  ((int_iterate op2 t2 i j) = (f (int_iterate op1 t1 i j))).

Axiom int_iterate_attr :
  forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
  forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t1:Z -> im1)
    (f:im1 -> im2) (i:Z) (j:Z),
  (forall (x:Z), forall (y:im1),
   (((op2 (f (t1 x))) (f y)) = (f ((op1 (t1 x)) y)))) ->
  ((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
  (iterable op2) ->
  ((int_iterate op2 (fun (e:Z) => (f (t1 e))) i j) =
   (f (int_iterate op1 t1 i j))).

Axiom int_iterate_attr_comm :
  forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
  forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t1:Z -> im1)
    (f:im1 -> im2) (i:Z) (j:Z),
  (forall (x:Z), forall (y:im1),
   (((op2 (f (t1 x))) (f y)) = (f ((op1 (t1 x)) y)))) ->
  ((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
  (iterable op2) ->
  ((f (int_iterate op1 t1 i j)) =
   (int_iterate op2 (fun (e:Z) => (f (t1 e))) i j)).

Axiom int_iterate_eq :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (g:Z -> im1) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((j <= i)%Z -> iterable op1) ->
  ((int_iterate op1 f i j) = (int_iterate op1 g i j)).

Axiom int_iterate_left_right :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (l:Z) (k:Z) (h:Z),
  (iterable op1) -> (commut op1) -> ((l <= k)%Z /\ (k <= h)%Z) ->
  ((int_iterate op1 f l k) =
   (int_iterate op1 (fun (a:Z) => (f ((h - (a + 1%Z)%Z)%Z + l)%Z))
    ((h - k)%Z + l)%Z h)).

Axiom int_iterate_eq_func :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (i:Z) (j:Z) (f:Z -> im1) (g:Z -> im1),
  (iterable op1) -> (commut op1) -> (p_injective f (to_fset i j)) ->
  (p_injective g (to_fset i j)) ->
  ((map f (to_fset i j)) = (map g (to_fset i j))) ->
  ((int_iterate op1 f i j) = (int_iterate op1 g i j)).

Axiom int_iterate_map :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z)
    (t1:Z -> im1),
  ((j <= i)%Z -> iterable op1) -> (commut op1) ->
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((int_iterate op1 t1 k l) =
   (int_iterate op1 (fun (b:Z) => (t1 (f b))) i j)).

Axiom int_iterate_transl :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> im1) (i:Z) (j:Z) (k:Z),
  (iterable op1) ->
  ((int_iterate op1 f i j) =
   (int_iterate op1 (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).

Axiom int_iterate_map_auto :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (i:Z) (j:Z) (f:Z -> Z) (t1:Z -> im1),
  ((j <= i)%Z -> iterable op1) -> (commut op1) ->
  (p_bijective f (to_fset i j) (to_fset i j)) ->
  ((int_iterate op1 t1 i j) =
   (int_iterate op1 (fun (b:Z) => (t1 (f b))) i j)).

Parameter result2:
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  (im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.

Axiom result_def2 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
  (((result2 op1 t1) e) = true) <-> ~ (neutral op1 (t1 e)).

(* Why3 assumption *)
Definition nonn_part {a:Type} {a_WT:WhyType a}
    {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) (s:set a)
    (t1:a -> im1) : set a :=
  filter (result2 op1 t1) s.

Axiom nonn_part_spec :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
  (mem e (nonn_part op1 s t1)) <-> ((mem e s) /\ ~ (neutral op1 (t1 e))).

Parameter result3:
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  (im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.

Axiom result_def3 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
  (((result3 op1 t1) e) = true) <-> (neutral op1 (t1 e)).

(* Why3 assumption *)
Definition n_part {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1) : set a :=
  filter (result3 op1 t1) s.

Axiom n_part_spec :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
  (mem e (n_part op1 s t1)) <-> ((mem e s) /\ (neutral op1 (t1 e))).

Axiom nullity_partition :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
  (s = (union (nonn_part op1 s t1) (n_part op1 s t1))) /\
  ((inter (nonn_part op1 s t1) (n_part op1 s t1)) = (empty : set a)).

Axiom iterate_neutral :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
  (commut op1) ->
  (forall (a1:a), (mem a1 s) -> ((t1 a1) = (neutral_elt op1))) ->
  ((iterate op1 s t1) = (neutral_elt op1)).

Axiom iterate_nullity_partition :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
  (commut op1) ->
  ((iterate op1 s t1) = (iterate op1 (nonn_part op1 s t1) t1)).

(* Why3 assumption *)
Definition couple {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {im1:Type} {im1_WT:WhyType im1} (f:a -> b -> im1) (o:(a* b)%type) : im1 :=
  match o with
  | (a1, b1) => (f a1) b1
  end.

Axiom null_product :
  forall (a:t) (b:t), ((infix_asdt a b) = tzero) ->
  (a = tzero) \/ (b = tzero).

Axiom neutral_tzero :
  (neutral (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) tzero) /\
  (iterable (fun (y0:t) (y1:t) => (infix_pldt y0 y1))).

(* Why3 assumption *)
Definition sum {a:Type} {a_WT:WhyType a} (s:set a) (t1:a -> t) : t :=
  iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) s t1.

Axiom sum_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), (is_empty s) -> ((sum s t1) = tzero).

Axiom sum_one :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), ((cardinal s) = 1%Z) ->
  ((sum s t1) = (t1 (choose s))).

Axiom sum_add :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> t) (x:b), ~ (mem x s) ->
  ((sum (add x s) f) = (infix_pldt (f x) (sum s f))).

Axiom map_sum_eq :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> a) (t1:a -> t), (p_injective f s) ->
  ((sum (map f s) t1) = (sum s (fun (b1:b) => (t1 (f b1))))).

Axiom sum_comp :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> t) (g:b -> t),
  ((sum s (fun (k:b) => (infix_pldt (f k) (g k)))) =
   (infix_pldt (sum s f) (sum s g))).

Axiom sum_iter_ :
  (opposite_n (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
   (fun (y0:t) (y1:t) => (infix_mndt y0 y1)) tzero) /\
  ((opposite (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
    (fun (y0:t) (y1:t) => (infix_mndt y0 y1))) /\
   ((opposite_com (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
     (fun (y0:t) (y1:t) => (infix_mndt y0 y1))) /\
    (inverse_tuple (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
     (fun (y0:t) (y1:t) => (infix_mndt y0 y1)) tzero))).

Axiom neutral_zero :
  ((neutral_elt (fun (y0:t) (y1:t) => (infix_pldt y0 y1))) = tzero).

Axiom sum_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> t) (g:a -> t),
  (forall (x:a), (mem x s) -> ((f x) = (g x))) -> ((sum s f) = (sum s g)).

Axiom sum_eq_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (f:a -> t) (g:a -> t), (s = s') ->
  (forall (x:a), (mem x s) -> ((f x) = (g x))) -> ((sum s f) = (sum s' g)).

Axiom sum_disjoint_transitivity :
  forall {a:Type} {a_WT:WhyType a},
  forall (s1:set a) (s2:set a) (t1:a -> t),
  ((inter s1 s2) = (empty : set a)) ->
  ((sum (union s1 s2) t1) = (infix_pldt (sum s1 t1) (sum s2 t1))).

Axiom sum_to_cartesian_product :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b) (f:a -> b -> t),
  ((sum s1 (fun (a1:a) => (sum s2 (f a1)))) =
   (sum (cartesian_product s1 s2)
    (fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).

Axiom sum_from_cartesian_product :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s1:set a) (s2:set b) (f:a -> b -> t),
  ((sum (cartesian_product s1 s2)
    (fun (o:(a* b)%type) => ((f (fir o)) (sec o))))
   = (sum s1 (fun (a1:a) => (sum s2 (f a1))))).

(* Why3 assumption *)
Definition ind_sum (f:Z -> t) (i:Z) (j:Z) : t :=
  int_iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) f i j.

Axiom ind_sum_to_int_iterate :
  forall (f:Z -> t) (i:Z) (j:Z),
  ((ind_sum f i j) =
   (int_iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) f i j)).

Axiom ind_sum_cardone :
  forall (f:Z -> t) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((ind_sum f i j) = (f i)).

Axiom ind_sum_right_extension :
  forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_sum f i j) = (infix_pldt (ind_sum f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).

Axiom ind_sum_plus_one :
  forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_sum f i j) = (infix_pldt (f i) (ind_sum f (i + 1%Z)%Z j))).

Axiom ind_sum_eq :
  forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((ind_sum f i j) = (ind_sum g i j)).

Parameter fc: (Z -> t) -> t -> Z -> Z -> Z -> t.

Axiom fc_def :
  forall (f:Z -> t) (g:t) (i:Z) (j:Z) (k:Z),
  (((i <= k)%Z /\ (k < j)%Z) -> (((fc f g i j) k) = (f k))) /\
  (~ ((i <= k)%Z /\ (k < j)%Z) -> (((fc f g i j) k) = g)).

Axiom ind_sum_eq_del_bound :
  forall (f:Z -> t) (g:t) (i:Z) (j:Z),
  ((ind_sum (fc f g i j) i j) = (ind_sum f i j)).

Parameter fc1: (Z -> t) -> t -> Z -> Z -> Z -> t.

Axiom fc_def1 :
  forall (f:Z -> t) (g:t) (i:Z) (j:Z) (k:Z),
  (((i <= k)%Z /\ (k < j)%Z) -> (((fc1 f g i j) k) = (f k))) /\
  (~ ((i <= k)%Z /\ (k < j)%Z) -> (((fc1 f g i j) k) = g)).

Axiom ind_sum_eq_del_bound_rev :
  forall (f:Z -> t) (g:t) (i:Z) (j:Z),
  ((ind_sum f i j) = (ind_sum (fc1 f g i j) i j)).

Axiom ind_sum_eq_gen :
  forall (f:Z -> t) (g:Z -> t) (i1:Z) (j1:Z) (i2:Z) (j2:Z), (i1 = i2) ->
  (j1 = j2) ->
  (forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
  ((ind_sum f i1 j1) = (ind_sum g i2 j2)).

Axiom ind_sum_eq_bound :
  forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z), (i = j) ->
  (forall (k:Z), ((0%Z <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((ind_sum f 0%Z i) = (ind_sum g 0%Z j)).

Axiom ind_sum_comp :
  forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
  ((ind_sum (fun (k:Z) => (infix_pldt (f k) (g k))) i j) =
   (infix_pldt (ind_sum f i j) (ind_sum g i j))).

Axiom ind_sum_to_iterate :
  forall (f:Z -> t) (i:Z) (j:Z),
  ((ind_sum f i j) =
   (iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) (to_fset i j) f)).

Axiom ind_sum_to_sum :
  forall (f:Z -> t) (i:Z) (j:Z), ((ind_sum f i j) = (sum (to_fset i j) f)).

Axiom map_ind_sum_eq :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> t),
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((ind_sum t1 k l) = (ind_sum (fun (b:Z) => (t1 (f b))) i j)).

Axiom sum_scal :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> t) (s:set a) (c:t),
  ((sum s (fun (x:a) => (infix_asdt c (f x)))) = (infix_asdt c (sum s f))).

Axiom ind_sum_scal :
  forall (f:Z -> t) (i:Z) (j:Z) (a:t),
  ((ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j) =
   (infix_asdt a (ind_sum f i j))).

Axiom ind_sum_scal_rev :
  forall (f:Z -> t) (i:Z) (j:Z) (a:t),
  ((infix_asdt a (ind_sum f i j)) =
   (ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j)).

Axiom sum_scal_gen :
  forall (f:Z -> t) (s:set Z), forall (a:t),
  ((sum s (fun (i:Z) => (infix_asdt a (f i)))) = (infix_asdt a (sum s f))).

Axiom ind_sum_scal_gen :
  forall (f:Z -> t) (i:Z) (j:Z), forall (a:t),
  ((ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j) =
   (infix_asdt a (ind_sum f i j))).

Axiom int_int_iterate_def_empty :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (j <= i)%Z -> (iterable op1) ->
  ((int_int_iterate op1 f i j k l) = (neutral_elt op1)).

Axiom int_int_iterate_def_plus_one :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (i < j)%Z -> (iterable op1) ->
  ((int_int_iterate op1 f i j k l) =
   ((op1 (int_iterate op1 (fun (n:Z) => ((f i) n)) k l))
    (int_int_iterate op1 f (i + 1%Z)%Z j k l))).

Axiom int_int_iterate_to_int_iterate :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (i <= j)%Z -> (iterable op1) ->
  ((int_int_iterate op1 f i j k l) =
   (int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j)).

Axiom int_iterate_to_int_int_iterate :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (i <= j)%Z -> (iterable op1) ->
  ((int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j) =
   (int_int_iterate op1 f i j k l)).

Axiom int_int_iterate_to_iterate :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (i <= j)%Z -> (iterable op1) -> (commut op1) ->
  ((int_int_iterate op1 f i j k l) =
   (iterate op1 (cartesian_product (to_fset i j) (to_fset k l))
    (fun (o:(Z* Z)%type) => ((f (fir o)) (sec o))))).

Axiom iterate_commute :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s1:set a) (s2:set b) (f:a -> b -> im1),
  (iterable op1) -> (commut op1) ->
  ((iterate op1 (cartesian_product s1 s2)
    (fun (o:(a* b)%type) => ((f (fir o)) (sec o))))
   =
   (iterate op1 (cartesian_product s2 s1)
    (fun (o:(b* a)%type) => ((f (sec o)) (fir o))))).

Axiom int_int_iterate_commute :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (iterable op1) -> (commut op1) -> (i <= j)%Z -> (k <= l)%Z ->
  ((int_int_iterate op1 f i j k l) =
   (int_int_iterate op1 (fun (a:Z) (b:Z) => ((f b) a)) k l i j)).

Axiom int_iterate_commute :
  forall {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
  (iterable op1) -> (commut op1) -> (i <= j)%Z -> (k <= l)%Z ->
  ((int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j) =
   (int_iterate op1
    (fun (a:Z) => (int_iterate op1 (fun (b:Z) => ((f b) a)) i j)) k l)).

Axiom ind_sum_commute :
  forall (f:Z -> Z -> t) (i:Z) (j:Z) (k:Z) (l:Z), (i <= j)%Z -> (k <= l)%Z ->
  ((ind_sum (fun (k1:Z) => (ind_sum (f k1) k l)) i j) =
   (ind_sum (fun (k1:Z) => (ind_sum (fun (k2:Z) => ((f k2) k1)) i j)) k l)).

(* Why3 assumption *)
Definition non_tzero {a:Type} {a_WT:WhyType a} (s:set a) (t1:a -> t) : set a :=
  nonn_part (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) s t1.

Axiom non_tzero_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), forall (e:a),
  (mem e (non_tzero s t1)) <-> ((mem e s) /\ ~ ((t1 e) = tzero)).

Axiom get_non_tzero_member :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (e:a), (mem e (non_tzero s t1)) ->
  (mem e s) /\ ~ ((t1 e) = tzero).

Axiom set_non_tzero_member :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (e:a), (mem e s) -> ~ ((t1 e) = tzero) ->
  mem e (non_tzero s t1).

Axiom set_non_tzero_member_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), forall (e:a),
  ((mem e s) /\ ~ ((t1 e) = tzero)) -> mem e (non_tzero s t1).

Axiom set_non_tzero_member_gen_ :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), forall (e:a),
  ((mem e s) /\ ~ ((t1 e) = tzero)) -> mem e (non_tzero s t1).

Axiom sum_nullity_partition :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), ((sum s t1) = (sum (non_tzero s t1) t1)).

Axiom non_null_map :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> a) (t1:a -> t),
  ((non_tzero (map f s) t1) =
   (map f (non_tzero s (fun (b:a) => (t1 (f b)))))).

Axiom map_sum_eq_nonnull :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> a) (t1:a -> t),
  (p_bijective f (non_tzero s (fun (b:a) => (t1 (f b))))
   (non_tzero (map f s) t1)) ->
  ((sum (non_tzero (map f s) t1) t1) =
   (sum (non_tzero s (fun (b:a) => (t1 (f b)))) (fun (b:a) => (t1 (f b))))).

Axiom sum_null_but_one :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), ((cardinal (non_tzero s t1)) = 1%Z) ->
  ((sum s t1) = (t1 (element (non_tzero s t1)))).

Axiom sum_null :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t), ((cardinal (non_tzero s t1)) = 0%Z) ->
  ((sum s t1) = tzero).

Axiom ind_sum_null :
  forall (t1:Z -> t) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((t1 k) = tzero)) ->
  ((ind_sum t1 i j) = tzero).

Axiom sum_null_but_one_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (elt:a),
  ((mem elt s) /\ ~ ((t1 elt) = tzero)) ->
  (forall (a1:a), (mem a1 s) -> ~ (a1 = elt) -> ((t1 a1) = tzero)) ->
  ((sum s t1) = (t1 elt)).

Axiom sum_null_but_maybe_one_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (t1:a -> t) (s:set a) (elt:a), (mem elt s) ->
  (forall (k:a), (mem k s) -> ~ (k = elt) -> ((t1 k) = tzero)) ->
  ((sum s t1) = (t1 elt)).

Axiom ind_sum_null_but_maybe_one_elt :
  forall (t1:Z -> t) (i:Z) (j:Z) (ind:Z), ((i <= ind)%Z /\ (ind < j)%Z) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ~ (k = ind) ->
   ((t1 k) = tzero)) ->
  ((ind_sum t1 i j) = (t1 ind)).

Axiom neutral_tone :
  (neutral (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone) /\
  (iterable (fun (y0:t) (y1:t) => (infix_asdt y0 y1))).

Axiom product_iter :
  (op_neutral_left (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone) /\
  (((op_neutral_right (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone) /\
    (op_assoc (fun (y0:t) (y1:t) => (infix_asdt y0 y1)))) /\
   ((commut (fun (y0:t) (y1:t) => (infix_asdt y0 y1))) /\
    (iterates (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone))).

(* Why3 assumption *)
Definition product {a:Type} {a_WT:WhyType a} (s:set a) (t1:a -> t) : t :=
  iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) s t1.

Axiom product_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (t':a -> t),
  (forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
  ((product s t1) = (product s t')).

Axiom product_eq_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (t1:a -> t) (t':a -> t), (s = s') ->
  (forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
  ((product s t1) = (product s' t')).

Axiom product_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> t), (is_empty s) -> ((product s f) = tone).

Axiom product_iter_ : iterable (fun (y0:t) (y1:t) => (infix_asdt y0 y1)).

Axiom add_product :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> t) (x:a), ~ (mem x s) ->
  ((product (add x s) f) = (infix_asdt (f x) (product s f))).

Axiom product_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> t) (x:a), ~ (mem x s) ->
  ((product (add x s) f) = (infix_asdt (product s f) (f x))).

Axiom neutral_one :
  ((neutral_elt (fun (y0:t) (y1:t) => (infix_asdt y0 y1))) = tone).

(* Why3 assumption *)
Definition ind_product (f:Z -> t) (i:Z) (j:Z) : t :=
  int_iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) f i j.

Axiom ind_product_eq :
  forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((ind_product f i j) = (ind_product g i j)).

Axiom ind_product_cardone :
  forall (f:Z -> t) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((ind_product f i j) = (f i)).

Axiom ind_product_eq_gen :
  forall (f:Z -> t) (g:Z -> t) (i1:Z) (j1:Z) (i2:Z) (j2:Z),
  (forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
  (i1 = i2) -> (j1 = j2) -> ((ind_product f i1 j1) = (ind_product g i2 j2)).

Axiom ind_product_right_extension :
  forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_product f i j) =
   (infix_asdt (ind_product f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).

Axiom ind_product_left_extension :
  forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_product f i j) = (infix_asdt (f i) (ind_product f (i + 1%Z)%Z j))).

Axiom ind_product_to_product :
  forall (f:Z -> t) (i:Z) (j:Z),
  ((ind_product f i j) = (product (to_fset i j) f)).

Axiom map_product_eq :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> a) (t1:a -> t), (p_injective f s) ->
  ((product (map f s) t1) = (product s (fun (b1:b) => (t1 (f b1))))).

Axiom map_ind_product_eq :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> t),
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((ind_product t1 k l) = (ind_product (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_product_right_extension_comm :
  forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
  ((infix_asdt (ind_product f i (j - 1%Z)%Z) (f (j - 1%Z)%Z)) =
   (ind_product f i j)).

Axiom ind_product_eq_func :
  forall (i:Z) (j:Z) (f1:Z -> t) (f2:Z -> t),
  (p_injective f1 (to_fset i j)) -> (p_injective f2 (to_fset i j)) ->
  ((map f1 (to_fset i j)) = (map f2 (to_fset i j))) ->
  ((ind_product f1 i j) = (ind_product f2 i j)).

Axiom ind_product_trans :
  forall (f:Z -> t) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
  ((ind_product f i j) =
   (infix_asdt (ind_product f i k) (ind_product f k j))).

Axiom ind_product_zero_pre :
  forall (f:Z -> t) (i:Z) (t1:Z) (j:Z), ((i <= t1)%Z /\ (t1 < j)%Z) ->
  ((f t1) = tzero) -> ((ind_product f i j) = tzero).

Axiom ind_product_zero :
  forall (f:Z -> t) (i:Z) (j:Z), (i <= j)%Z ->
  (exists t1:Z, ((i <= t1)%Z /\ (t1 < j)%Z) /\ ((f t1) = tzero)) ->
  ((ind_product f i j) = tzero).

Axiom ind_product_zero_elt :
  forall (f:Z -> t) (i:Z) (j:Z) (t1:Z), (i <= j)%Z ->
  ((i <= t1)%Z /\ (t1 < j)%Z) -> ((f t1) = tzero) ->
  ((ind_product f i j) = tzero).

Axiom ind_product_const_tone :
  forall (f:Z -> t) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (t1:Z), ((i <= t1)%Z /\ (t1 < j)%Z) -> ((f t1) = tone)) ->
  ((ind_product f i j) = tone).

Axiom div_plus_one :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  (((int.EuclideanDivision.div i j) * j)%Z <= i)%Z /\
  (i < (((int.EuclideanDivision.div i j) + 1%Z)%Z * j)%Z)%Z.

Axiom zero_add : forall (a1:Z) (a2:Z), (a1 = 0%Z) -> ((a1 + a2)%Z = a2).

Axiom add_zero : forall (a1:Z) (a2:Z), (a2 = 0%Z) -> ((a1 + a2)%Z = a1).

Axiom one_mult : forall (a1:Z) (a2:Z), (a1 = 1%Z) -> ((a1 * a2)%Z = a2).

Axiom mult_one : forall (a1:Z) (a2:Z), (a2 = 1%Z) -> ((a1 * a2)%Z = a1).

Axiom add_eq :
  forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
  ((a1 + b1)%Z = (a2 + b2)%Z).

Axiom mult_eq :
  forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
  ((a1 * b1)%Z = (a2 * b2)%Z).

Axiom add_eq_inv :
  forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
  ((a1 + b1)%Z = (b2 + a2)%Z).

Axiom mult_eq_inv :
  forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
  ((a1 * b1)%Z = (b2 * a2)%Z).

Axiom bound_eq :
  forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < j)%Z) ->
  (i = (int.EuclideanDivision.mod1 i j)).

Axiom bound_eq_rev :
  forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < j)%Z) ->
  ((int.EuclideanDivision.mod1 i j) = i).

Axiom unicity_div_mod :
  forall (i:Z) (j:Z) (q:Z) (r:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z ->
  (0%Z <= r)%Z -> (0%Z < j)%Z -> (i = ((q * j)%Z + r)%Z) ->
  ((0%Z <= r)%Z /\ (r < j)%Z) ->
  (q = (int.EuclideanDivision.div i j)) /\
  (r = (int.EuclideanDivision.mod1 i j)).

Axiom unicity_div_gen :
  forall (j:Z) (q:Z), (0%Z <= q)%Z -> (0%Z < j)%Z ->
  (forall (i:Z), (0%Z <= i)%Z ->
   ((0%Z <= (i - (q * j)%Z)%Z)%Z /\ ((i - (q * j)%Z)%Z < j)%Z) ->
   (q = (int.EuclideanDivision.div i j))) /\
  forall (i:Z), (0%Z <= i)%Z ->
  ((0%Z <= (i - (q * j)%Z)%Z)%Z /\ ((i - (q * j)%Z)%Z < j)%Z) ->
  ((i - (j * q)%Z)%Z = (int.EuclideanDivision.mod1 i j)).

Axiom bound_mod :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  (0%Z <= (int.EuclideanDivision.mod1 i j))%Z /\
  ((int.EuclideanDivision.mod1 i j) < j)%Z.

Axiom mod_eq :
  forall (a:Z) (b:Z) (d:Z), (a = b) ->
  ((int.EuclideanDivision.mod1 a d) = (int.EuclideanDivision.mod1 b d)).

Axiom e_div_eq :
  forall (a:Z) (b:Z) (d:Z), (a = b) ->
  ((int.EuclideanDivision.div a d) = (int.EuclideanDivision.div b d)).

Axiom decomp :
  forall (i:Z) (j:Z), ~ (0%Z = j) ->
  (i =
   ((j * (int.EuclideanDivision.div i j))%Z +
    (int.EuclideanDivision.mod1 i j))%Z).

Axiom div_mod_eq :
  forall (i:Z) (j:Z) (q:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z -> (0%Z < q)%Z ->
  ((int.EuclideanDivision.div i q) = (int.EuclideanDivision.div j q)) ->
  ((int.EuclideanDivision.mod1 i q) = (int.EuclideanDivision.mod1 j q)) ->
  (i = j).

Axiom mod_zero :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  ((int.EuclideanDivision.mod1 i j) = 0%Z) ->
  (i = (j * (int.EuclideanDivision.div i j))%Z).

Axiom div_plus_quotient :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  ((int.EuclideanDivision.div (i + j)%Z j) =
   ((int.EuclideanDivision.div i j) + 1%Z)%Z).

Axiom div_plus_fact_gen_div :
  forall (i:Z) (j:Z) (k:Z), (0%Z < j)%Z ->
  ((int.EuclideanDivision.div (i + (k * j)%Z)%Z j) =
   ((int.EuclideanDivision.div i j) + k)%Z).

Axiom mod_plus_fact_gen_mod :
  forall (i:Z) (j:Z) (k:Z), (0%Z < j)%Z ->
  ((int.EuclideanDivision.mod1 ((k * j)%Z + i)%Z j) =
   (int.EuclideanDivision.mod1 i j)).

Axiom bound_div :
  forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
  (i < (f * q)%Z)%Z ->
  (0%Z <= (int.EuclideanDivision.div i q))%Z /\
  (((0%Z <= ((int.EuclideanDivision.div i q) * q)%Z)%Z /\
    ((((int.EuclideanDivision.div i q) * q)%Z <= i)%Z /\
     (i < (q * ((int.EuclideanDivision.div i q) + 1%Z)%Z)%Z)%Z)) /\
   ((int.EuclideanDivision.div i q) < f)%Z).

Axiom bound_div_gen :
  forall (q:Z) (f:Z), (0%Z <= q)%Z -> (0%Z <= f)%Z -> forall (i:Z),
  ((0%Z <= i)%Z /\ (i < (q * f)%Z)%Z) ->
  ((int.EuclideanDivision.div i q) < f)%Z.

Axiom mod_invariant :
  forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < q)%Z -> (0%Z < f)%Z ->
  ((int.EuclideanDivision.mod1
    ((q * (f * (int.EuclideanDivision.div i (q * f)%Z))%Z)%Z +
     (int.EuclideanDivision.mod1 i (q * f)%Z))%Z
    q)
   = (int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (q * f)%Z) q)).

Axiom mod_mod_left :
  forall (i:Z) (j:Z) (f:Z), (0%Z < j)%Z -> (0%Z < f)%Z ->
  ((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (f * j)%Z) j) =
   (int.EuclideanDivision.mod1 i j)).

Axiom mod_mod_i :
  forall (i:Z) (j:Z), (0%Z < j)%Z ->
  ((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i j) j) =
   (int.EuclideanDivision.mod1 i j)).

Axiom binary_prod :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  ((int.EuclideanDivision.mod1
    ((int.EuclideanDivision.mod1 i 2%Z) *
     (int.EuclideanDivision.mod1 j 2%Z))%Z
    2%Z)
   = (int.EuclideanDivision.mod1 (i * j)%Z 2%Z)).

Axiom add_mod :
  forall (a:Z) (b:Z) (c:Z), (0%Z < c)%Z ->
  ((int.EuclideanDivision.mod1
    ((int.EuclideanDivision.mod1 a c) + (int.EuclideanDivision.mod1 b c))%Z
    c)
   = (int.EuclideanDivision.mod1 (a + b)%Z c)).

Axiom mod_mod_right :
  forall (i:Z) (j:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < f)%Z ->
  ((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j * f)%Z) j) =
   (int.EuclideanDivision.mod1 i j)).

Axiom mod_mod_rev :
  forall (i:Z) (j:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < f)%Z ->
  ((int.EuclideanDivision.mod1 i j) =
   (int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j * f)%Z) j)) /\
  ((int.EuclideanDivision.mod1 i j) =
   (int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (f * j)%Z) j)).

Axiom mod_mod_plus :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  ((int.EuclideanDivision.mod1 i j) =
   (int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j + j)%Z) j)).

Axiom mult_assoc1 :
  forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < q)%Z -> (0%Z < f)%Z ->
  ((q * (f * (int.EuclideanDivision.div i (q * f)%Z))%Z)%Z =
   ((q * f)%Z * (int.EuclideanDivision.div i (q * f)%Z))%Z).

Axiom div_div1 :
  forall (i:Z) (j:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < k)%Z ->
  ((int.EuclideanDivision.div (int.EuclideanDivision.div i k) j) =
   (int.EuclideanDivision.div i (k * j)%Z)) /\
  ((int.EuclideanDivision.div (int.EuclideanDivision.div i k) j) =
   (int.EuclideanDivision.div i (j * k)%Z)).

Axiom mod_div :
  forall (i:Z) (j:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < k)%Z ->
  ((int.EuclideanDivision.div (int.EuclideanDivision.mod1 i (j * k)%Z) j) =
   (int.EuclideanDivision.mod1 (int.EuclideanDivision.div i j) k)).

Axiom inf_mul :
  forall (ia:Z) (ib:Z) (a:Z) (b:Z), ((0%Z <= ia)%Z /\ (ia < a)%Z) ->
  ((0%Z <= ib)%Z /\ (ib < b)%Z) ->
  (((a * ib)%Z + ia)%Z < (a * b)%Z)%Z /\ (((ib * a)%Z + ia)%Z < (b * a)%Z)%Z.

Axiom inf_mul_gen :
  forall (n:Z) (v:Z) (p:Z), ((0%Z <= p)%Z /\ (p < v)%Z) -> forall (k:Z),
  ((0%Z <= k)%Z /\ (k < n)%Z) -> (((k * v)%Z + p)%Z < (n * v)%Z)%Z.

Axiom inf_mul_gen_b :
  forall (n:Z) (v:Z) (p:Z), ((0%Z <= p)%Z /\ (p < n)%Z) -> forall (k:Z),
  ((0%Z <= k)%Z /\ (k < v)%Z) -> (((p * v)%Z + k)%Z < (n * v)%Z)%Z.

Axiom inf_mul_comm :
  forall (i:Z) (bi:Z) (quot:Z) (rest:Z), ((0%Z <= i)%Z /\ (i < bi)%Z) ->
  (0%Z < rest)%Z -> (0%Z < quot)%Z -> (bi = (quot * rest)%Z) ->
  ((int.EuclideanDivision.mod1 i rest) < rest)%Z.

Parameter result4:
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  (im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.

Axiom result_def4 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
  (((result4 op1 t1) e) = true) <-> ~ (neutral op1 (t1 e)).

(* Why3 assumption *)
Definition nonn_part1 {a:Type} {a_WT:WhyType a}
    {im1:Type} {im1_WT:WhyType im1} (op1:im1 -> im1 -> im1) (s:set a)
    (t1:a -> im1) : set a :=
  filter (result4 op1 t1) s.

Axiom nonn_part_spec1 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
  (mem e (nonn_part1 op1 s t1)) <-> ((mem e s) /\ ~ (neutral op1 (t1 e))).

Parameter result5:
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  (im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.

Axiom result_def5 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
  (((result5 op1 t1) e) = true) <-> (neutral op1 (t1 e)).

(* Why3 assumption *)
Definition n_part1 {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1}
    (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1) : set a :=
  filter (result5 op1 t1) s.

Axiom n_part_spec1 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
  (mem e (n_part1 op1 s t1)) <-> ((mem e s) /\ (neutral op1 (t1 e))).

Axiom nullity_partition1 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
  (s = (union (nonn_part1 op1 s t1) (n_part1 op1 s t1))) /\
  ((inter (nonn_part1 op1 s t1) (n_part1 op1 s t1)) = (empty : set a)).

Axiom iterate_neutral1 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
  (commut op1) ->
  (forall (a1:a), (mem a1 s) -> ((t1 a1) = (neutral_elt op1))) ->
  ((iterate op1 s t1) = (neutral_elt op1)).

Axiom iterate_nullity_partition1 :
  forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
  forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
  (commut op1) ->
  ((iterate op1 s t1) = (iterate op1 (nonn_part1 op1 s t1) t1)).

Parameter indic: forall {a:Type} {a_WT:WhyType a}, a -> a -> t.

Axiom indic_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (a':a),
  ((a1 = a') -> ((indic a1 a') = tone)) /\
  (~ (a1 = a') -> ((indic a1 a') = tzero)).

Axiom get_indic :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (a':a),
  ((a1 = a') -> ((indic a1 a') = tone)) /\
  (~ (a1 = a') -> ((indic a1 a') = tzero)).

Parameter indic_bool: forall {a:Type} {a_WT:WhyType a}, a -> a -> bool.

Axiom indic_bool_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (a':a),
  ((a1 = a') -> ((indic_bool a1 a') = true)) /\
  (~ (a1 = a') -> ((indic_bool a1 a') = false)).

Axiom indic_comm :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (a':a), ((indic a1 a') = (indic a' a1)).

Axiom indic_transl_r :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (b:a) (c:a), (b = c) -> ((indic a1 b) = (indic a1 c)).

Axiom indic_transl_l :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:a) (b:a) (c:a), (b = c) -> ((indic b a1) = (indic c a1)).

Parameter indic_2:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, a -> a -> b ->
  b -> t.

Axiom indic_2_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (a':a) (b1:b) (b':b),
  ((((indic_bool a1 a') = true) /\ ((indic_bool b1 b') = true)) ->
   ((indic_2 a1 a' b1 b') = tone)) /\
  (~ (((indic_bool a1 a') = true) /\ ((indic_bool b1 b') = true)) ->
   ((indic_2 a1 a' b1 b') = tzero)).

Axiom indic_2_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (a':a) (b1:b) (b':b),
  ((indic_2 a1 a' b1 b') = (infix_asdt (indic a1 a') (indic b1 b'))) /\
  ((indic_2 a1 a' b1 b') = (indic (a1, b1) (a', b'))).

Axiom indic_2_comm :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (a1:a) (a':a) (b1:b) (b':b),
  ((indic_2 a1 a' b1 b') = (indic_2 a' a1 b1 b')) /\
  (((indic_2 a1 a' b1 b') = (indic_2 a1 a' b' b1)) /\
   ((indic_2 a1 a' b1 b') = (indic_2 a' a1 b' b1))).

(* Why3 assumption *)
Definition sum_indic {a:Type} {a_WT:WhyType a} (s:set a) (t1:a -> t)
    (i:a) : t :=
  sum s (fun (e:a) => (infix_asdt (t1 e) (indic i e))).

Parameter ind_sum_indic: (Z -> t) -> Z -> Z -> Z -> t.

Axiom ind_sum_indic_def :
  forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), (l < h)%Z ->
  ((ind_sum_indic t1 l h i) =
   (ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h)).

Axiom ind_sum_indic_spec :
  forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), (l < h)%Z ->
  ((ind_sum_indic t1 l h i) = (sum_indic (to_fset l h) t1 i)).

Axiom sum_indic_t :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (i:a), (mem i s) ->
  ((sum_indic s t1 i) = (t1 i)).

Axiom sum_indic_ts :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> t) (i:a), (mem i s) ->
  ((sum s (fun (e:a) => (infix_asdt (t1 e) (indic i e)))) = (t1 i)).

Axiom ind_sum_indic_t :
  forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), ((l <= i)%Z /\ (i < h)%Z) ->
  ((ind_sum_indic t1 l h i) = (t1 i)) /\
  ((ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h) = (t1 i)).

Axiom ind_sum_indic_t_quant :
  forall (t1:Z -> t) (l:Z) (h:Z), forall (i:Z), ((l <= i)%Z /\ (i < h)%Z) ->
  ((ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h) = (t1 i)).

Axiom indic_div_mod :
  forall (i:Z) (j:Z) (q:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z -> (0%Z < q)%Z ->
  ((indic i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.mod1 i q) (int.EuclideanDivision.mod1 j q))
    (indic (int.EuclideanDivision.div i q) (int.EuclideanDivision.div j q)))).

Axiom indic_div_mod_gen :
  forall (q:Z), (0%Z < q)%Z -> forall (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (0%Z <= j)%Z) ->
  ((indic i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.mod1 i q) (int.EuclideanDivision.mod1 j q))
    (indic (int.EuclideanDivision.div i q) (int.EuclideanDivision.div j q)))).

Axiom set_inf : True.

Axiom set_infeq : True.

Axiom bounded_cycle :
  forall (a:Z) (b:Z) (c:Z) (d:Z), (0%Z <= a)%Z -> (0%Z < b)%Z ->
  ((0%Z <= d)%Z /\ (d < b)%Z) -> (0%Z < c)%Z ->
  ((int.EuclideanDivision.div ((a * b)%Z + d)%Z (b * c)%Z) =
   (int.EuclideanDivision.div a c)).

Axiom neutrals :
  (0%Z = (neutral_elt (fun (y0:Z) (y1:Z) => (y0 + y1)%Z))) /\
  ((1%Z = (neutral_elt (fun (y0:Z) (y1:Z) => (y0 * y1)%Z))) /\
   ((iterable (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)) /\
    (iterable (fun (y0:Z) (y1:Z) => (y0 * y1)%Z)))).

(* Why3 assumption *)
Definition isum {a:Type} {a_WT:WhyType a} (s:set a) (t1:a -> Z) : Z :=
  iterate (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) s t1.

Axiom isum_iter : iterates (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) 0%Z.

Axiom isum_iter__ : iterable (fun (y0:Z) (y1:Z) => (y0 + y1)%Z).

Axiom isum_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (t1:a -> Z) (t':a -> Z),
  (forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
  ((isum s t1) = (isum s t')).

Axiom isum_eq_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (t1:a -> Z) (t':a -> Z), (s = s') ->
  (forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
  ((isum s t1) = (isum s t')).

Axiom isum_add :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> Z) (x:b), ~ (mem x s) ->
  ((isum (add x s) f) = ((f x) + (isum s f))%Z).

Axiom mul_assoc :
  forall (a:Z) (b:Z) (c:Z), (((a * b)%Z * c)%Z = (a * (b * c)%Z)%Z).

Axiom mul_comm : forall (a:Z) (b:Z), ((a * b)%Z = (b * a)%Z).

Axiom mul_assoc_rev :
  forall (a:Z) (b:Z) (c:Z), ((a * (b * c)%Z)%Z = ((a * b)%Z * c)%Z).

Axiom mult_add_distr :
  forall (a:Z) (b:Z) (c:Z) (d:Z),
  (((a + b)%Z * (c + d)%Z)%Z =
   ((((a * c)%Z + (a * d)%Z)%Z + (b * c)%Z)%Z + (b * d)%Z)%Z).

Axiom mult_add_right :
  forall (a:Z) (b:Z) (c:Z), (((a + b)%Z * c)%Z = ((a * c)%Z + (b * c)%Z)%Z).

Axiom mult_add_right_rev :
  forall (a:Z) (b:Z) (c:Z), (((a * c)%Z + (b * c)%Z)%Z = ((a + b)%Z * c)%Z).

Axiom mult_add_left :
  forall (a:Z) (b:Z) (c:Z), ((a * (b + c)%Z)%Z = ((a * b)%Z + (a * c)%Z)%Z).

Axiom mult_add_left_rev :
  forall (a:Z) (b:Z) (c:Z), (((a * b)%Z + (a * c)%Z)%Z = (a * (b + c)%Z)%Z).

Axiom mult_add_distr_rev :
  forall (a:Z) (b:Z) (c:Z) (d:Z),
  (((((a * c)%Z + (a * d)%Z)%Z + (b * c)%Z)%Z + (b * d)%Z)%Z =
   ((a + b)%Z * (c + d)%Z)%Z).

Axiom mul_assoc_comm :
  forall (a:Z) (b:Z) (c:Z), (((a * b)%Z * c)%Z = (b * (a * c)%Z)%Z).

Axiom mul_assoc_rev_comm :
  forall (a:Z) (b:Z) (c:Z), ((a * (b * c)%Z)%Z = ((a * c)%Z * b)%Z).

Axiom add_assoc :
  forall (a:Z) (b:Z) (c:Z), (((a + b)%Z + c)%Z = (a + (b + c)%Z)%Z).

Axiom add_assoc_rev :
  forall (a:Z) (b:Z) (c:Z), ((a + (b + c)%Z)%Z = ((a + b)%Z + c)%Z).

Axiom isum_empty :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> Z), (is_empty s) -> ((isum s f) = 0%Z).

Axiom isum_iter_ :
  (opposite_n (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
   (fun (y0:Z) (y1:Z) => (y0 - y1)%Z) 0%Z) /\
  ((opposite (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
    (fun (y0:Z) (y1:Z) => (y0 - y1)%Z)) /\
   ((opposite_com (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
     (fun (y0:Z) (y1:Z) => (y0 - y1)%Z)) /\
    (inverse_tuple (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
     (fun (y0:Z) (y1:Z) => (y0 - y1)%Z) 0%Z))).

(* Why3 assumption *)
Definition ind_isum (f:Z -> Z) (i:Z) (j:Z) : Z :=
  int_iterate (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) f i j.

Axiom ind_isum_empty :
  forall (f:Z -> Z) (i:Z) (j:Z), (j <= i)%Z -> ((ind_isum f i j) = 0%Z).

Axiom ind_isum_one :
  forall (f:Z -> Z) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((ind_isum f i j) = (f i)).

Axiom ind_isum_plus_one :
  forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_isum f i j) = ((f i) + (ind_isum f (i + 1%Z)%Z j))%Z).

Axiom ind_isum_to_isum :
  forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_isum f i j) = (isum (to_fset i j) f)).

Axiom ind_isum_const :
  forall (k:Z) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_isum ((fun (y0:Z) (y1:Z) => y0) k) i j) = (k * (j - i)%Z)%Z).

Axiom ind_isum_right_extension :
  forall (f:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  ((ind_isum f i (j + 1%Z)%Z) = ((ind_isum f i j) + (f j))%Z).

Axiom ind_isum_eq :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((ind_isum f i j) = (ind_isum g i j)).

Parameter fc2: (Z -> Z) -> (Z -> Z) -> (Z -> bool) -> Z -> Z.

Axiom fc_def2 :
  forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (k:Z),
  (((p k) = true) -> (((fc2 f g p) k) = (f k))) /\
  (~ ((p k) = true) -> (((fc2 f g p) k) = (g k))).

Axiom ind_isum_to_guard :
  forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((p k) = true)) ->
  ((ind_isum (fc2 f g p) i j) = (ind_isum f i j)).

Parameter fc3: (Z -> Z) -> (Z -> Z) -> (Z -> bool) -> Z -> Z.

Axiom fc_def3 :
  forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (k:Z),
  (((p k) = true) -> (((fc3 f g p) k) = (g k))) /\
  (~ ((p k) = true) -> (((fc3 f g p) k) = (f k))).

Axiom ind_isum_no_guard :
  forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ~ ((p k) = true)) ->
  ((ind_isum (fc3 f g p) i j) = (ind_isum f i j)).

Axiom ind_isum_eq_gen :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (i1:Z) (j:Z) (j1:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) -> (i = i1) ->
  (j = j1) -> ((ind_isum f i j) = (ind_isum g i1 j1)).

Axiom ind_isum_func_const :
  forall (k:Z) (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (l:Z), ((i <= l)%Z /\ (l < j)%Z) -> ((f l) = k)) ->
  ((ind_isum f i j) = (k * (j - i)%Z)%Z).

Axiom ind_isum_pos :
  forall (f:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> (0%Z <= (f k))%Z) ->
  (0%Z <= (ind_isum f i j))%Z.

(* Why3 assumption *)
Definition ind_iproduct (f:Z -> Z) (i:Z) (j:Z) : Z :=
  int_iterate (fun (y0:Z) (y1:Z) => (y0 * y1)%Z) f i j.

Axiom ind_iproduct_eq :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((ind_iproduct f i j) = (ind_iproduct g i j)).

Axiom ind_iproduct_eq_gen :
  forall (f:Z -> Z) (g:Z -> Z) (i1:Z) (j1:Z) (i2:Z) (j2:Z),
  (forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
  (i1 = i2) -> (j1 = j2) -> ((ind_iproduct f i1 j1) = (ind_iproduct g i2 j2)).

Axiom iproduct_to_iterate :
  forall (f:Z -> Z) (i:Z) (j:Z),
  ((ind_iproduct f i j) =
   (int_iterate (fun (y0:Z) (y1:Z) => (y0 * y1)%Z) f i j)).

Axiom ind_isum_map_auto :
  forall (i:Z) (j:Z) (f:Z -> Z) (t1:Z -> Z),
  (p_bijective f (to_fset i j) (to_fset i j)) ->
  ((ind_isum t1 i j) = (ind_isum (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_isum_map :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> Z),
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((ind_isum t1 k l) = (ind_isum (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_isum_map_auto_bij :
  forall (i:Z) (j:Z) (f:Z -> Z) (t1:Z -> Z),
  (forall (e:Z), ((i <= e)%Z /\ (e < j)%Z) ->
   (i <= (f e))%Z /\ ((f e) < j)%Z) ->
  (forall (e:Z) (e':Z), ((i <= e)%Z /\ (e < j)%Z) ->
   ((i <= e')%Z /\ (e' < j)%Z) -> ~ (e = e') -> ~ ((f e) = (f e'))) ->
  (forall (e':Z), ((i <= e')%Z /\ (e' < j)%Z) ->
   exists e:Z, ((i <= e)%Z /\ (e < j)%Z) /\ ((f e) = e')) ->
  ((ind_isum t1 i j) = (ind_isum (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_isum_map_bij :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> Z),
  (forall (e:Z), ((i <= e)%Z /\ (e < j)%Z) ->
   (k <= (f e))%Z /\ ((f e) < l)%Z) ->
  (forall (e:Z) (e':Z), ((i <= e)%Z /\ (e < j)%Z) ->
   ((i <= e')%Z /\ (e' < j)%Z) -> ~ (e = e') -> ~ ((f e) = (f e'))) ->
  (forall (e':Z), ((k <= e')%Z /\ (e' < l)%Z) ->
   exists e:Z, ((i <= e)%Z /\ (e < j)%Z) /\ ((f e) = e')) ->
  ((ind_isum t1 k l) = (ind_isum (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_iproduct_empty :
  forall (f:Z -> Z) (i:Z) (j:Z), (j <= i)%Z -> ((ind_iproduct f i j) = 1%Z).

Axiom ind_iproduct_plus_one :
  forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_iproduct f i j) = ((f i) * (ind_iproduct f (i + 1%Z)%Z j))%Z).

Axiom ind_iproduct_right_extension :
  forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  ((ind_iproduct f i j) =
   ((ind_iproduct f i (j - 1%Z)%Z) * (f (j - 1%Z)%Z))%Z).

Axiom ind_iproduct_right_extension_comm :
  forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (((ind_iproduct f i (j - 1%Z)%Z) * (f (j - 1%Z)%Z))%Z =
   (ind_iproduct f i j)).

Axiom ind_iproduct_one :
  forall (f:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = 1%Z)) ->
  ((ind_iproduct f i j) = 1%Z).

Axiom positive_iproduct :
  forall (f:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> (0%Z < (f k))%Z) ->
  (0%Z < (ind_iproduct f i j))%Z.

Axiom ind_iproduct_left_right :
  forall (f:Z -> Z) (l:Z) (k:Z) (h:Z), ((l <= k)%Z /\ (k <= h)%Z) ->
  ((ind_iproduct f l k) =
   (ind_iproduct (fun (a:Z) => (f ((h - (a + 1%Z)%Z)%Z + l)%Z))
    ((h - k)%Z + l)%Z h)).

Axiom iterable_imult : iterable (fun (y0:Z) (y1:Z) => (y0 * y1)%Z).

Axiom ind_iproduct_map_auto :
  forall (i:Z) (j:Z) (f:Z -> Z) (t1:Z -> Z),
  (p_bijective f (to_fset i j) (to_fset i j)) ->
  ((ind_iproduct t1 i j) = (ind_iproduct (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_iproduct_map :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> Z),
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((ind_iproduct t1 k l) = (ind_iproduct (fun (b:Z) => (t1 (f b))) i j)).

Axiom ind_iproduct_trans :
  forall (f:Z -> Z) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
  ((ind_iproduct f i j) = ((ind_iproduct f i k) * (ind_iproduct f k j))%Z).

Axiom ind_isum_transl :
  forall (f:Z -> Z) (i:Z) (j:Z) (k:Z),
  ((ind_isum f i j) =
   (ind_isum (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).

Axiom ind_isum_transl_plus_one :
  forall (f:Z -> Z) (i:Z) (j:Z),
  ((ind_isum f i j) =
   (ind_isum (fun (b:Z) => (f (b - 1%Z)%Z)) (i + 1%Z)%Z (j + 1%Z)%Z)).

Axiom ind_isum_transl_minus_one :
  forall (f:Z -> Z) (i:Z) (j:Z),
  ((ind_isum f i j) =
   (ind_isum (fun (b:Z) => (f (b + 1%Z)%Z)) (i - 1%Z)%Z (j - 1%Z)%Z)).

Axiom ind_isum_scal :
  forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
  ((ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j) = (a * (ind_isum f i j))%Z).

Axiom ind_isum_scal_rev :
  forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
  ((a * (ind_isum f i j))%Z = (ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j)).

Axiom ind_isum_scal_rev_right :
  forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
  (((ind_isum f i j) * a)%Z = (ind_isum (fun (i1:Z) => ((f i1) * a)%Z) i j)).

Axiom ind_isum_scal_right :
  forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
  ((ind_isum (fun (i1:Z) => ((f i1) * a)%Z) i j) = ((ind_isum f i j) * a)%Z).

Axiom ind_isum_bound :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) < (g k))%Z) ->
  ((ind_isum f i j) < (ind_isum g i j))%Z.

Axiom comp_trans_equal_strict :
  forall (a:Z) (b:Z) (c:Z), (a <= b)%Z -> (b < c)%Z -> (a < c)%Z.

Axiom compeq_trans_sum :
  forall (a:Z) (b:Z) (c:Z), (b <= c)%Z -> ((a + b)%Z <= (a + c)%Z)%Z.

Axiom compeq_trans_sum_zero :
  forall (a:Z) (b:Z), (0%Z <= b)%Z -> (a <= (a + b)%Z)%Z.

Axiom comp_trans_sum :
  forall (a:Z) (b:Z) (c:Z), (b < c)%Z -> ((a + b)%Z < (a + c)%Z)%Z.

Axiom ind_isum_bound_eq :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) <= (g k))%Z) ->
  ((ind_isum f i j) <= (ind_isum g i j))%Z.

Axiom ind_isum_scal_gen :
  forall (f:Z -> Z) (i:Z) (j:Z), forall (a:Z), ((i <= a)%Z /\ (a < j)%Z) ->
  ((ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j) = (a * (ind_isum f i j))%Z).

Axiom ind_isum_trans :
  forall (f:Z -> Z) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
  ((ind_isum f i j) = ((ind_isum f i k) + (ind_isum f k j))%Z).

Parameter power: Z -> Z -> Z.

Axiom power_def :
  forall (e:Z) (i:Z), (0%Z <= i)%Z ->
  ((i = 0%Z) -> ((power e i) = 1%Z)) /\
  (~ (i = 0%Z) -> ((power e i) = (e * (power e (i - 1%Z)%Z))%Z)).

Axiom Power_zero : forall (i:Z), ((power i 0%Z) = 1%Z).

Axiom Power_one : forall (i:Z), ((power i 1%Z) = i).

Axiom Power_sum :
  forall (x:Z) (y:Z) (i:Z), (0%Z <= x)%Z -> (0%Z <= y)%Z ->
  ((power i (x + y)%Z) = ((power i x) * (power i y))%Z).

Axiom Power_mult :
  forall (x:Z) (y:Z) (i:Z), (0%Z <= x)%Z -> (0%Z <= y)%Z ->
  ((power i (x * y)%Z) = (power (power i x) y)).

Axiom power_plus_one :
  forall (e:Z) (i:Z), (0%Z <= i)%Z ->
  ((power e (i + 1%Z)%Z) = (e * (power e i))%Z).

Axiom power_to_ind_iproduct :
  forall (e:Z) (i:Z), (0%Z <= i)%Z ->
  ((power e i) = (ind_iproduct ((fun (y0:Z) (y1:Z) => y0) e) 0%Z i)).

Axiom power_transl :
  forall (e:Z) (k:Z) (i:Z), (0%Z <= i)%Z ->
  ((power e i) = (ind_iproduct ((fun (y0:Z) (y1:Z) => y0) e) k (k + i)%Z)).

Axiom ind_iproduct_to_power :
  forall (e:Z) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i <= j)%Z) ->
  ((ind_iproduct ((fun (y0:Z) (y1:Z) => y0) e) i j) = (power e (j - i)%Z)).

Axiom ind_iproduct_to_power_gen :
  forall (e:Z), forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i <= j)%Z) ->
  ((ind_iproduct ((fun (y0:Z) (y1:Z) => y0) e) i j) = (power e (j - i)%Z)).

Axiom power_sum :
  forall (x:Z) (n:Z) (m:Z), (0%Z <= n)%Z -> (0%Z <= m)%Z ->
  ((power x (n + m)%Z) = ((power x n) * (power x m))%Z).

Axiom power_sum_rev :
  forall (x:Z) (n:Z) (m:Z), (0%Z <= n)%Z -> (0%Z <= m)%Z ->
  (((power x n) * (power x m))%Z = (power x (n + m)%Z)).

Axiom power_eq :
  forall (x:Z) (n:Z) (m:Z), (n = m) -> ((power x n) = (power x m)).

Axiom power_eq_gen :
  forall (x:Z) (y:Z) (n:Z) (m:Z), (n = m) -> (x = y) ->
  ((power x n) = (power y m)).

Axiom power_decomp :
  forall (i:Z), (1%Z <= i)%Z ->
  ((ind_isum (fun (k:Z) => (power 2%Z (k + 1%Z)%Z)) 0%Z i) <
   (power 2%Z (i + 1%Z)%Z))%Z.

Parameter fc4: Z -> Z -> Z.

Axiom fc_def4 :
  forall (i:Z) (k:Z),
  (((1%Z <= k)%Z /\ (k < (i + 1%Z)%Z)%Z) ->
   (((fc4 i) k) = (power 2%Z (k - 1%Z)%Z))) /\
  (~ ((1%Z <= k)%Z /\ (k < (i + 1%Z)%Z)%Z) -> (((fc4 i) k) = 0%Z)).

Axiom power_decomp_minus_one :
  forall (i:Z), (1%Z <= i)%Z ->
  ((ind_isum (fc4 i) 1%Z i) < (power 2%Z (i - 1%Z)%Z))%Z.

Axiom power_decomp_ :
  forall (i:Z), (1%Z <= i)%Z ->
  ((ind_isum (fun (k:Z) => (power 2%Z k)) 0%Z i) < (power 2%Z i))%Z.

Axiom power_decomp_one :
  forall (i:Z), (1%Z <= i)%Z ->
  ((ind_isum (fun (k:Z) => (power 2%Z (k + 1%Z)%Z)) 1%Z i) <
   (power 2%Z (i + 1%Z)%Z))%Z.

Axiom power_decomp_one_ :
  forall (i:Z), (1%Z <= i)%Z ->
  ((ind_isum (fun (k:Z) => (power 2%Z k)) 1%Z i) < (power 2%Z i))%Z.

Axiom growing_mult :
  forall (n:Z) (m:Z), (0%Z <= n)%Z -> (1%Z <= m)%Z -> (n <= (n * m)%Z)%Z.

Axiom strict_growing_mult :
  forall (n:Z) (m:Z), (1%Z < n)%Z -> (1%Z < m)%Z -> (n < (n * m)%Z)%Z.

Axiom init_exp :
  forall (k:Z),
  ((power k 0%Z) = 1%Z) /\
  (((power k 1%Z) = k) /\ ((power k 2%Z) = (k * k)%Z)).

Axiom positive_int_exp :
  forall (k:Z) (n:Z), (1%Z <= k)%Z -> (0%Z <= n)%Z ->
  (1%Z <= (power k n))%Z /\
  ((0%Z < (power k n))%Z /\ ((power k n) <= (power k (n + 1%Z)%Z))%Z).

Axiom strict_positive_int_exp :
  forall (k:Z) (n:Z), (1%Z < k)%Z -> (0%Z < n)%Z ->
  (1%Z < (power k n))%Z /\
  (((power k (n - 1%Z)%Z) < (power k n))%Z /\
   ((power k n) < (power k (n + 1%Z)%Z))%Z).

Axiom power_minus_one :
  forall (i:Z), (0%Z <= i)%Z ->
  (((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((power (-1%Z)%Z i) = 1%Z)) /\
  (((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
   ((power (-1%Z)%Z i) = (-1%Z)%Z)).

Axiom growing_exp :
  forall (k:Z) (m:Z) (n:Z), (1%Z <= k)%Z -> ((0%Z <= m)%Z /\ (m <= n)%Z) ->
  ((power k m) <= (power k n))%Z.

Axiom strict_growing_exp :
  forall (k:Z) (m:Z) (n:Z), (1%Z < k)%Z -> ((0%Z <= m)%Z /\ (m < n)%Z) ->
  ((power k m) < (power k n))%Z.

Axiom unicity_exp :
  forall (k:Z) (m:Z) (n:Z), (1%Z < k)%Z -> (0%Z <= m)%Z -> (0%Z <= n)%Z ->
  ((power k m) = (power k n)) <-> (m = n).

Axiom bounded_sum_exp :
  forall (i:Z) (j:Z) (m:Z) (n:Z), (0%Z <= m)%Z -> (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  (((i * (power 2%Z n))%Z + j)%Z < (power 2%Z (m + n)%Z))%Z.

Axiom power_minus_one1 :
  forall (i:Z), (0%Z <= i)%Z ->
  (((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((power (-1%Z)%Z i) = 1%Z)) /\
  (((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
   ((power (-1%Z)%Z i) = (-1%Z)%Z)).

Parameter kth_right: Z -> Z -> Z -> (Z -> Z) -> Z.

Axiom kth_right_def :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
  (forall (l:Z), (((h - k)%Z <= l)%Z /\ (l < h)%Z) -> (0%Z < (f l))%Z) ->
  ((kth_right i k h f) =
   (int.EuclideanDivision.mod1
    (int.EuclideanDivision.div i (ind_iproduct f ((h - k)%Z + 1%Z)%Z h))
    (f (h - k)%Z))).

Axiom kth_right_spec :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
  (forall (l:Z), (((h - k)%Z <= l)%Z /\ (l < h)%Z) -> (0%Z < (f l))%Z) ->
  (0%Z <= (kth_right i k h f))%Z /\ ((kth_right i k h f) < (f (h - k)%Z))%Z.

Axiom kth_right_eq :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z) (g:Z -> Z), (0%Z <= i)%Z ->
  (1%Z <= k)%Z ->
  (forall (l:Z), (((h - k)%Z <= l)%Z /\ (l <= h)%Z) -> (0%Z < (f l))%Z) ->
  (forall (l:Z), (((h - k)%Z <= l)%Z /\ (l <= h)%Z) -> ((f l) = (g l))) ->
  ((kth_right i k h f) = (kth_right i k h g)).

Axiom kth_right_trans :
  forall (i:Z) (k:Z) (h:Z) (t1:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
  (forall (l:Z), (0%Z < (f l))%Z) -> (0%Z <= h)%Z -> (0%Z <= t1)%Z ->
  ((kth_right (int.EuclideanDivision.div i (ind_iproduct f h (h + t1)%Z)) k h
    f)
   = (kth_right i (k + t1)%Z (h + t1)%Z f)).

Parameter kth_left: Z -> Z -> Z -> Z -> (Z -> Z) -> Z.

Axiom kth_left_def :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
  ((kth_left i k l h f) = (kth_right i (((h - l)%Z - k)%Z + 1%Z)%Z h f)).

Axiom kth_left_spec :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
  ((kth_left i k l h f) =
   (int.EuclideanDivision.mod1
    (int.EuclideanDivision.div i (ind_iproduct f (l + k)%Z h))
    (f ((l + k)%Z - 1%Z)%Z))) /\
  ((0%Z <= (kth_left i k l h f))%Z /\
   ((kth_left i k l h f) < (f ((l + k)%Z - 1%Z)%Z))%Z).

Axiom kth_left_eq :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z) (g:Z -> Z), (0%Z <= i)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) -> (0%Z <= l)%Z ->
  (forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) ->
   ((f ind) = (g ind)) /\ (0%Z < (g ind))%Z) ->
  ((kth_left i k l h f) = (kth_left i k l h g)).

Axiom kth_left_to_mod_div :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (ind:Z), ((l <= ind)%Z /\ (ind <= h)%Z) -> (0%Z < (f ind))%Z) ->
  ((kth_left i k l h f) =
   (int.EuclideanDivision.mod1
    (int.EuclideanDivision.div i (ind_iproduct f (l + k)%Z h))
    (f ((l + k)%Z - 1%Z)%Z))).

Axiom kth_left_trans :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
  ((1%Z <= k)%Z /\ (k < (h - l)%Z)%Z) ->
  (forall (ind:Z), ((l <= ind)%Z /\ (ind <= h)%Z) -> (0%Z < (f ind))%Z) ->
  ((kth_left i k l h f) =
   (kth_left (int.EuclideanDivision.div i (f (h - 1%Z)%Z)) k l (h - 1%Z)%Z f)).

Axiom div_isum_exponents :
  forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
  (0%Z <= n)%Z -> (0%Z <= m)%Z ->
  ((power k (n + m)%Z) = ((power k n) * (power k m))%Z) /\
  (((power k (n + 1%Z)%Z) = ((power k n) * k)%Z) /\
   (((power k 1%Z) = k) /\
    (((int.EuclideanDivision.div (int.EuclideanDivision.div i (power k n))
       (power k m))
      = (int.EuclideanDivision.div i (power k (n + m)%Z))) /\
     ((int.EuclideanDivision.div (int.EuclideanDivision.div i (power k n)) k)
      = (int.EuclideanDivision.div i (power k (n + 1%Z)%Z)))))).

Parameter divp: Z -> Z -> Z.

Axiom divp_def :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  ((divp i j) = ((int.EuclideanDivision.div i j) * j)%Z).

Axiom divp_spec :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
  (i = ((divp i j) + (int.EuclideanDivision.mod1 i j))%Z) /\
  ((((divp i j) <= i)%Z /\ (i < (((divp i j) + 1%Z)%Z * j)%Z)%Z) /\
   ((j < i)%Z -> (0%Z < (divp i j))%Z)).

Axiom kth_right_div_mod :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((kth_right i k h f) =
   (int.EuclideanDivision.div
    (int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h))
    (ind_iproduct f ((h - k)%Z + 1%Z)%Z h))).

Axiom kth_head :
  forall (i:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= h)%Z ->
  (forall (k:Z), (0%Z < (f k))%Z) ->
  ((kth_right i 1%Z h f) = (int.EuclideanDivision.mod1 i (f (h - 1%Z)%Z))).

Parameter weighted_kth_right: Z -> Z -> Z -> (Z -> Z) -> Z.

Axiom weighted_kth_right_def :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z ->
  (forall (k1:Z), (0%Z < (f k1))%Z) -> (1%Z <= k)%Z ->
  ((weighted_kth_right i k h f) =
   ((kth_right i k h f) * (ind_iproduct f ((h - k)%Z + 1%Z)%Z h))%Z).

Axiom weighted_kth_right_ :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (1%Z <= k)%Z -> (0%Z <= i)%Z ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h)) =
   ((weighted_kth_right i k h f) +
    (int.EuclideanDivision.mod1 i (ind_iproduct f ((h - k)%Z + 1%Z)%Z h)))%Z).

Axiom kth_right_decomposition :
  forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h)) =
   (ind_isum (fun (a:Z) => (weighted_kth_right i a h f)) 1%Z (k + 1%Z)%Z)).

Axiom kth_left_div_mod :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z ->
  ((0%Z <= l)%Z /\ (l <= h)%Z) -> ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((kth_left i k l h f) =
   (int.EuclideanDivision.div
    (int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h))
    (ind_iproduct f (l + k)%Z h))).

Parameter weighted_kth_left: Z -> Z -> Z -> Z -> (Z -> Z) -> Z.

Axiom weighted_kth_left_def :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((weighted_kth_left i k l h f) =
   (weighted_kth_right i (((h - l)%Z - k)%Z + 1%Z)%Z h f)).

Axiom weighted_kth_left_ :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h)) =
   ((weighted_kth_left i k l h f) +
    (int.EuclideanDivision.mod1 i (ind_iproduct f (l + k)%Z h)))%Z).

Axiom bounded_kth_left_decomposition :
  forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
  ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
  (forall (k1:Z), (0%Z < (f k1))%Z) ->
  ((int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h)) =
   (ind_isum (fun (a:Z) => (weighted_kth_left i a l h f)) k
    ((h - l)%Z + 1%Z)%Z)).

Axiom kth_left_decomposition :
  forall (i:Z) (l:Z) (h:Z) (f:Z -> Z),
  ((0%Z <= i)%Z /\ (i < (ind_iproduct f l h))%Z) -> (l < h)%Z ->
  (forall (k:Z), (0%Z < (f k))%Z) ->
  (i =
   (ind_isum (fun (a:Z) => (weighted_kth_left i a l h f)) 1%Z
    ((h - l)%Z + 1%Z)%Z)).

(* Why3 assumption *)
Definition binary (t1:Z -> Z) : Prop :=
  forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z.

Axiom set_binary :
  forall (t1:Z -> Z),
  (forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) -> binary t1.

Axiom get_binary :
  forall (t1:Z -> Z), (binary t1) -> forall (k:Z),
  (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z.

(* Why3 assumption *)
Definition shift {a:Type} {a_WT:WhyType a} (f:Z -> a) (i:Z) (k:Z) : a :=
  f (k + i)%Z.

Axiom shift_value :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (i:Z) (k:Z), ((shift f i k) = (f (k + i)%Z)).

Axiom shiftz :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (k:Z), ((shift f 0%Z k) = (f k)).

Axiom shiftz_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (i:Z) (k:Z), (i = 0%Z) -> ((shift f i k) = (f k)).

Axiom shiftz_quant :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a),
  ((((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) 0%Z) = f).

Axiom shiftz_quant_rev :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a),
  (f = (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) 0%Z)).

Parameter concat_fun:
  forall {a:Type} {a_WT:WhyType a}, (Z -> a) -> (Z -> a) -> Z -> Z -> a.

Axiom concat_fun_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (g:Z -> a) (i:Z) (k:Z),
  ((k < i)%Z -> ((concat_fun f g i k) = (f k))) /\
  (~ (k < i)%Z -> ((concat_fun f g i k) = (g (k - i)%Z))).

Axiom shift_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (i:Z) (j:Z) (k:Z),
  ((shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) j) i k) =
   (shift f (i + j)%Z k)).

Axiom concat_fun_value :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (g:Z -> a) (i:Z) (k:Z),
  ((k < i)%Z -> ((concat_fun f g i k) = (f k))) /\
  (~ (k < i)%Z -> ((concat_fun f g i k) = (g (k - i)%Z))).

Axiom concat_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (f1:Z -> a) (g1:Z -> a) (f2:Z -> a) (g2:Z -> a) (i1:Z) (i2:Z) (k:Z),
  (forall (l:Z), (l < i1)%Z -> ((f1 l) = (f2 l))) ->
  (forall (l:Z), (0%Z <= l)%Z -> ((g1 l) = (g2 l))) -> (i1 = i2) ->
  ((concat_fun f1 g1 i1 k) = (concat_fun f2 g2 i2 k)).

Parameter mod_func:
  forall {a:Type} {a_WT:WhyType a}, (Z -> a) -> Z -> Z -> a.

Axiom mod_func_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (k:Z) (i:Z), (0%Z < k)%Z ->
  ((mod_func f k i) = (f (int.EuclideanDivision.mod1 i k))).

Axiom mod_func_inf :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (k:Z) (i:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < k)%Z) -> ((mod_func f k i) = (f i)).

Axiom shift_mod :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (k:Z) (i:Z), (0%Z < k)%Z ->
  ((mod_func f k i) =
   (shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k) k i)).

Axiom shift_mod_rev :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> a) (k:Z) (i:Z), (0%Z < k)%Z ->
  ((shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k) k i)
   = (mod_func f k i)).

Parameter head_bit: Z -> Z -> Z.

Axiom head_bit_def :
  forall (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((head_bit i k) = (int.EuclideanDivision.div i (power 2%Z (k - 1%Z)%Z))).

Axiom head_bit_spec :
  forall (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  (0%Z <= (head_bit i k))%Z /\ ((head_bit i k) <= 1%Z)%Z.

Parameter tail_bits: Z -> Z -> Z.

Axiom tail_bits_def :
  forall (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((tail_bits i k) = (int.EuclideanDivision.mod1 i (power 2%Z (k - 1%Z)%Z))).

Axiom tail_bits_spec :
  forall (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  (0%Z <= (tail_bits i k))%Z /\
  ((tail_bits i k) <= (power 2%Z (k - 1%Z)%Z))%Z.

Parameter ht_to_int: Z -> Z -> Z -> Z.

Axiom ht_to_int_def :
  forall (hi:Z) (ti:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= hi)%Z /\ (hi < 2%Z)%Z) ->
  ((0%Z <= ti)%Z /\ (ti < (power 2%Z (k - 1%Z)%Z))%Z) ->
  ((ht_to_int hi ti k) = ((hi * (power 2%Z (k - 1%Z)%Z))%Z + ti)%Z).

Axiom head_tail_inv :
  forall (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((ht_to_int (head_bit i k) (tail_bits i k) k) = i).

Axiom ht_to_int_head :
  forall (i:Z) (ti:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((0%Z <= ti)%Z /\ (ti < (power 2%Z (k - 1%Z)%Z))%Z) ->
  ((head_bit (ht_to_int (head_bit i k) ti k) k) = (head_bit i k)).

Axiom ht_to_int_tail :
  forall (hi:Z) (i:Z) (k:Z), (0%Z < k)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((0%Z <= hi)%Z /\ (hi < 2%Z)%Z) ->
  ((tail_bits (ht_to_int hi (tail_bits i k) k) k) = (tail_bits i k)).

Axiom concat_fun_bin_i :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z) (k:Z), (binary f) -> (binary g) ->
  (0%Z <= (concat_fun f g i k))%Z /\ ((concat_fun f g i k) < 2%Z)%Z.

Axiom shift_bin_i :
  forall (f:Z -> Z) (i:Z) (k:Z), (binary f) ->
  (0%Z <= (shift f i k))%Z /\ ((shift f i k) < 2%Z)%Z.

Axiom concat_fun_bin :
  forall (f:Z -> Z) (g:Z -> Z) (i:Z), (binary f) -> (binary g) ->
  binary
  ((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) => (concat_fun y0 y1 y2 y3))
     f)
    g)
   i).

Axiom mod_func_bin :
  forall (f:Z -> Z) (k:Z), (0%Z < k)%Z -> (binary f) ->
  binary (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k).

Axiom shift_bin :
  forall (f:Z -> Z) (i:Z), (binary f) ->
  binary (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) i).

Axiom binary_comp :
  forall (f:Z -> Z) (g:Z -> Z), (binary f) -> binary (fun (x:Z) => (f (g x))).

Axiom set_is_all_binary :
  forall (t1:Z -> Z),
  (forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) -> binary t1.

Parameter nary_length: Z -> Z -> Z.

Axiom nary_length_spec :
  forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z ->
  ((0%Z < i)%Z ->
   ((power n ((nary_length i n) - 1%Z)%Z) <= i)%Z /\
   (i < (power n (nary_length i n)))%Z) /\
  (((i < n)%Z -> ((nary_length i n) = 1%Z)) /\
   ((1%Z <= (nary_length i n))%Z /\
    (i = (int.EuclideanDivision.mod1 i (power n (nary_length i n)))))).

Parameter binary_length: Z -> Z.

Axiom binary_length_def :
  forall (i:Z), (0%Z <= i)%Z -> ((binary_length i) = (nary_length i 2%Z)).

Axiom binary_length_spec :
  forall (i:Z), (0%Z <= i)%Z ->
  ((0%Z < i)%Z ->
   ((power 2%Z ((binary_length i) - 1%Z)%Z) <= i)%Z /\
   (i < (power 2%Z (binary_length i)))%Z) /\
  (((i < 2%Z)%Z -> ((binary_length i) = 1%Z)) /\
   ((1%Z <= (binary_length i))%Z /\
    (i = (int.EuclideanDivision.mod1 i (power 2%Z (binary_length i)))))).

Axiom set_binary_length :
  forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z <= k)%Z ->
  ((0%Z < i)%Z -> ((power 2%Z (k - 1%Z)%Z) <= i)%Z /\ (i < (power 2%Z k))%Z) ->
  ((i < 2%Z)%Z -> (k = 1%Z)) -> (k = (binary_length i)).

Axiom set_binary_length_b :
  forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < k)%Z -> (i < (power 2%Z k))%Z ->
  ((binary_length i) <= k)%Z.

Axiom matrix : forall (a:Type), Type.
Parameter matrix_WhyType :
  forall (a:Type) {a_WT:WhyType a}, WhyType (matrix a).
Existing Instance matrix_WhyType.

Parameter elts: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a.

Parameter rows: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z.

Parameter columns: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z.

Axiom matrix'invariant :
  forall {a:Type} {a_WT:WhyType a},
  forall (self:matrix a), (0%Z < (rows self))%Z /\ (0%Z < (columns self))%Z.

(* Why3 assumption *)
Definition valid_index {a:Type} {a_WT:WhyType a} (a1:matrix a) (r:Z)
    (c:Z) : Prop :=
  ((0%Z <= r)%Z /\ (r < (rows a1))%Z) /\
  ((0%Z <= c)%Z /\ (c < (columns a1))%Z).

(* Why3 assumption *)
Definition equal_size {a:Type} {a_WT:WhyType a} (a1:matrix a) (b:matrix a) :
    Prop :=
  ((rows a1) = (rows b)) /\ ((columns a1) = (columns b)).

Parameter get: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a.

Axiom get_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z), ((get a1 r c) = (((elts a1) r) c)).

Parameter make: forall {a:Type} {a_WT:WhyType a}, Z -> Z -> a -> matrix a.

Axiom make_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (v:a), ((0%Z < r)%Z /\ (0%Z < c)%Z) ->
  ((rows (make r c v)) = r) /\
  (((columns (make r c v)) = c) /\
   forall (i:Z) (j:Z),
   (((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
   ((get (make r c v) i j) = v)).

Axiom make_value :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (i:Z) (j:Z) (v:a), ((0%Z < r)%Z /\ (0%Z < c)%Z) ->
  ((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
  ((get (make r c v) i j) = v).

(* Why3 assumption *)
Definition mat_indices {a:Type} {a_WT:WhyType a} (m:matrix a) :
    set (Z* Z)%type :=
  cartesian_product (to_fset 0%Z (rows m)) (to_fset 0%Z (columns m)).

Axiom mat_indices_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a), forall (i:Z) (j:Z),
  (valid_index m i j) <-> (mem (i, j) (mat_indices m)).

Parameter set1:
  forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a -> matrix a.

Axiom set_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
  ((rows (set1 a1 r c v)) = (rows a1)) /\
  (((columns (set1 a1 r c v)) = (columns a1)) /\
   ((forall (i:Z) (j:Z), (valid_index a1 i j) ->
     (((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = v)) /\
     (~ ((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = (get a1 i j)))) /\
    (((get (set1 a1 r c v) r c) = v) /\
     ((forall (i:Z) (j:Z), (valid_index (set1 a1 r c v) i j) -> ~ (i = r) ->
       ((get (set1 a1 r c v) i j) = (get a1 i j))) /\
      forall (i:Z) (j:Z), (valid_index (set1 a1 r c v) i j) -> ~ (j = c) ->
      ((get (set1 a1 r c v) i j) = (get a1 i j)))))).

Axiom set_valid_index :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows a1))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns a1))%Z) -> valid_index a1 i j.

Axiom get_valid_index :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z), ((rows a1) = r) -> ((columns a1) = c) ->
  (forall (i:Z) (j:Z), (valid_index a1 i j) -> (0%Z <= i)%Z /\ (i < r)%Z) /\
  forall (i:Z) (j:Z), (valid_index a1 i j) -> (0%Z <= j)%Z /\ (j < c)%Z.

Axiom set_values :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
  forall (i:Z) (j:Z), (valid_index a1 i j) ->
  (((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = v)) /\
  (~ ((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = (get a1 i j))).

Axiom set_rows :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
  ((rows (set1 a1 r c v)) = (rows a1)).

Axiom set_columns :
  forall {a:Type} {a_WT:WhyType a},
  forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
  ((columns (set1 a1 r c v)) = (columns a1)).

Parameter make_f:
  forall {a:Type} {a_WT:WhyType a}, Z -> Z -> (Z -> Z -> a) -> matrix a.

Axiom make_f_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a), (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((rows (make_f r c f)) = r) /\
  (((columns (make_f r c f)) = c) /\
   forall (i:Z) (j:Z), ((get (make_f r c f) i j) = ((f i) j))).

Axiom assert_make :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a) (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
  ((get (make_f r c f) i j) = ((f i) j)).

Axiom assert_make_r :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a), (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((rows (make_f r c f)) = r).

Axiom assert_make_c :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a), (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((columns (make_f r c f)) = c).

(* Why3 assumption *)
Definition to_indexes {a:Type} {a_WT:WhyType a} (m:matrix a) :
    set (Z* Z)%type :=
  cartesian_product (to_fset 0%Z (rows m)) (to_fset 0%Z (columns m)).

Axiom to_indexes_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a),
  ((cardinal (to_indexes m)) = ((rows m) * (columns m))%Z).

Axiom set_to_indexes_mem :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns m))%Z) -> mem (i, j) (to_indexes m).

Axiom get_to_indexes_mem :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (o:(Z* Z)%type), (mem o (to_indexes m)) ->
  ((0%Z <= (fir o))%Z /\ ((fir o) < (rows m))%Z) /\
  ((0%Z <= (sec o))%Z /\ ((sec o) < (columns m))%Z).

Parameter equal:
  forall {a:Type} {a_WT:WhyType a}, (matrix a) -> (matrix a) -> Prop.

Axiom equal_mat :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a),
  (equal m n) <->
  ((((rows m) = (rows n)) /\ ((columns m) = (columns n))) /\
   forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))).

Axiom equality :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a), (equal m n) <-> (m = n).

Axiom mat_equality :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  (forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))) ->
  equal m n.

Parameter square: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Prop.

Axiom square_mat :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a), (square m) <-> ((rows m) = (columns m)).

Axiom equal_sym :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a), (equal m n) <-> (equal n m).

Axiom equal_rex :
  forall {a:Type} {a_WT:WhyType a}, forall (m:matrix a), equal m m.

Axiom equal_trans :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a) (o:matrix a), (equal m n) ->
  (equal n o) -> equal m o.

Parameter equal_funct:
  forall {a:Type} {a_WT:WhyType a}, (Z -> matrix a) -> (Z -> matrix a) ->
  Prop.

Axiom equal_mat_funct :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> matrix a) (g:Z -> matrix a), forall (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (i < j)%Z) ->
  (equal_funct f g) <->
  forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> equal (f k) (g k).

Axiom set_equal_mat :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  (forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))) ->
  (m = n).

Axiom set_equal_mat_make :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a) (g:Z -> Z -> a), (0%Z < r)%Z ->
  (0%Z < c)%Z ->
  (forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
   ((0%Z <= j)%Z /\ (j < c)%Z) -> (((f i) j) = ((g i) j))) ->
  ((make_f r c f) = (make_f r c g)).

Axiom set_equal_mat_make_t :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (r':Z) (c:Z) (c':Z) (f:Z -> Z -> a) (g:Z -> Z -> a),
  (0%Z < r)%Z -> (0%Z < c)%Z -> (r = r') -> (c = c') ->
  (forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
   ((0%Z <= j)%Z /\ (j < c)%Z) -> (((f i) j) = ((g i) j))) ->
  ((make_f r c f) = (make_f r' c' g)).

Axiom get_equal_mat :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix a) (n:matrix a), (equal m n) ->
  ((rows m) = (rows n)) /\
  (((columns m) = (columns n)) /\
   forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))).

Axiom equal_functions :
  forall {a:Type} {a_WT:WhyType a},
  forall (r:Z) (c:Z) (f:Z -> Z -> a) (g:Z -> Z -> a), (0%Z < r)%Z ->
  (0%Z < c)%Z ->
  (forall (i:Z) (j:Z),
   (((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
   (((f i) j) = ((g i) j))) ->
  ((make_f r c f) = (make_f r c g)).

Axiom equal_functions_mat :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:Z -> Z -> a) (m:matrix a),
  (forall (i:Z) (j:Z),
   (((0%Z <= i)%Z /\ (i < (rows m))%Z) /\
    ((0%Z <= j)%Z /\ (j < (columns m))%Z)) ->
   (((f i) j) = (get m i j))) ->
  (m = (make_f (rows m) (columns m) f)).

(* Why3 assumption *)
Definition null_mat (a:matrix t) : Prop :=
  forall (i:Z) (j:Z), (valid_index a i j) -> ((get a i j) = tzero).

Axiom set_null_mat :
  forall (a:matrix t),
  (forall (i:Z) (j:Z), (valid_index a i j) -> ((get a i j) = tzero)) ->
  null_mat a.

Axiom get_null_mat :
  forall (a:matrix t), (null_mat a) -> forall (i:Z) (j:Z),
  (valid_index a i j) -> ((get a i j) = tzero).

Parameter kronecker_neutral: matrix t.

Axiom kronecker_neutral1 : (kronecker_neutral = (make 1%Z 1%Z tone)).

Parameter identity: Z -> matrix t.

Parameter result6: Z -> Z -> t.

Axiom result_def6 :
  forall (i:Z) (j:Z),
  ((i = j) -> (((result6 i) j) = tone)) /\
  (~ (i = j) -> (((result6 i) j) = tzero)).

Axiom identity_def :
  forall (n:Z), (0%Z <= n)%Z ->
  ((identity n) = (make_f (power 2%Z n) (power 2%Z n) result6)).

(* Why3 assumption *)
Definition kronecker (m:matrix t) (n:matrix t) : matrix t :=
  make_f ((rows m) * (rows n))%Z ((columns m) * (columns n))%Z
  (fun (i:Z) (j:Z) =>
   (infix_asdt
    (get m (int.EuclideanDivision.div i (rows n))
     (int.EuclideanDivision.div j (columns n)))
    (get n (int.EuclideanDivision.mod1 i (rows n))
     (int.EuclideanDivision.mod1 j (columns n))))).

Axiom kronecker_spec :
  forall (m:matrix t) (n:matrix t),
  ((rows (kronecker m n)) = ((rows m) * (rows n))%Z) /\
  (((columns (kronecker m n)) = ((columns m) * (columns n))%Z) /\
   forall (i:Z) (j:Z), (valid_index (kronecker m n) i j) ->
   ((get (kronecker m n) i j) =
    (infix_asdt
     (get m (int.EuclideanDivision.div i (rows n))
      (int.EuclideanDivision.div j (columns n)))
     (get n (int.EuclideanDivision.mod1 i (rows n))
      (int.EuclideanDivision.mod1 j (columns n)))))).

Axiom kronecker_eq :
  forall (m1:matrix t) (n1:matrix t) (m2:matrix t) (n2:matrix t),
  (m1 = m2) -> (n1 = n2) -> ((kronecker m1 n1) = (kronecker m2 n2)).

Axiom get_kronecker :
  forall (m:matrix t) (n:matrix t),
  ((kronecker m n) =
   (make_f ((rows m) * (rows n))%Z ((columns m) * (columns n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (get m (int.EuclideanDivision.div i (rows n))
       (int.EuclideanDivision.div j (columns n)))
      (get n (int.EuclideanDivision.mod1 i (rows n))
       (int.EuclideanDivision.mod1 j (columns n))))))).

Axiom kronecker_values :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  (valid_index (kronecker m n) i j) ->
  ((get (kronecker m n) i j) =
   (infix_asdt
    (get m (int.EuclideanDivision.div i (rows n))
     (int.EuclideanDivision.div j (columns n)))
    (get n (int.EuclideanDivision.mod1 i (rows n))
     (int.EuclideanDivision.mod1 j (columns n))))).

Axiom kronecker_values_gen :
  forall (m:matrix t) (n:matrix t), forall (i:Z) (j:Z),
  (valid_index (kronecker m n) i j) ->
  ((get (kronecker m n) i j) =
   (infix_asdt
    (get m (int.EuclideanDivision.div i (rows n))
     (int.EuclideanDivision.div j (columns n)))
    (get n (int.EuclideanDivision.mod1 i (rows n))
     (int.EuclideanDivision.mod1 j (columns n))))).

Axiom kronecker_mod_values :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  (valid_index (kronecker m n) i j) ->
  ((get (kronecker m n) i j) =
   (infix_asdt
    (get m
     (int.EuclideanDivision.div
      (int.EuclideanDivision.mod1 i (rows (kronecker m n))) (rows n))
     (int.EuclideanDivision.div
      (int.EuclideanDivision.mod1 j (columns (kronecker m n))) (columns n)))
    (get n
     (int.EuclideanDivision.mod1
      (int.EuclideanDivision.mod1 i (rows (kronecker m n))) (rows n))
     (int.EuclideanDivision.mod1
      (int.EuclideanDivision.mod1 j (columns (kronecker m n))) (columns n))))).

Axiom kronecker_indexes :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z) (k:Z) (l:Z),
  (valid_index m i j) -> (valid_index n k l) ->
  valid_index (kronecker m n) ((i * (rows n))%Z + k)%Z
  ((j * (columns n))%Z + l)%Z.

Axiom kronecker_indexes_com :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  (valid_index (kronecker m n) i j) ->
  (valid_index m (int.EuclideanDivision.div i (rows n))
   (int.EuclideanDivision.div j (columns n))) /\
  (valid_index n (int.EuclideanDivision.mod1 i (rows n))
   (int.EuclideanDivision.mod1 j (columns n))).

Axiom kronecker_assoc_pre :
  forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (i < (((rows m) * (rows n))%Z * (rows o))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < (((columns m) * (columns n))%Z * (columns o))%Z)%Z) ->
  ((get (kronecker (kronecker m n) o) i j) =
   (get (kronecker m (kronecker n o)) i j)).

Axiom kronecker_assoc :
  op_assoc (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)).

Axiom neutral_ :
  forall (m:matrix t),
  ((kronecker m kronecker_neutral) = m) /\
  ((kronecker kronecker_neutral m) = m).

Axiom neutral1 :
  (kronecker_neutral =
   (neutral_elt (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)))) /\
  ((has_neutral (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1))) /\
   (iterable (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)))).

Axiom kronecker_equal :
  forall (m:matrix t) (ml:matrix t) (n:matrix t) (nl:matrix t),
  (equal m ml) -> (equal n nl) -> equal (kronecker m n) (kronecker ml nl).

(* Why3 assumption *)
Definition frows (f:Z -> matrix t) (k:Z) : Z := rows (f k).

Axiom frows_spec : forall (f:Z -> matrix t) (k:Z), (0%Z < (frows f k))%Z.

(* Why3 assumption *)
Definition fcolumns (f:Z -> matrix t) (k:Z) : Z := columns (f k).

Axiom fcolumns_spec :
  forall (f:Z -> matrix t) (k:Z), (0%Z < (fcolumns f k))%Z.

Axiom const_fcol :
  forall (m:matrix t) (k:Z),
  ((fcolumns ((fun (y0:matrix t) (y1:Z) => y0) m) k) = (columns m)).

Axiom const_frows :
  forall (m:matrix t) (k:Z),
  ((frows ((fun (y0:matrix t) (y1:Z) => y0) m) k) = (rows m)).

Parameter mat_mult_no_bound: (matrix t) -> (matrix t) -> matrix t.

Axiom mat_mult_no_bound_def :
  forall (m:matrix t) (n:matrix t),
  (((columns m) = (rows n)) ->
   ((mat_mult_no_bound m n) =
    (make_f (rows m) (columns n)
     (fun (i:Z) (j:Z) =>
      (ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
       (columns m)))))) /\
  (~ ((columns m) = (rows n)) ->
   ((mat_mult_no_bound m n) = (make_f 1%Z 1%Z (fun (i:Z) (j:Z) => tzero)))).

Axiom mat_mult_no_bound_spec :
  forall (m:matrix t) (n:matrix t),
  (((columns m) = (rows n)) -> ((rows (mat_mult_no_bound m n)) = (rows m))) /\
  ((((columns m) = (rows n)) ->
    ((columns (mat_mult_no_bound m n)) = (columns n))) /\
   (((columns m) = (rows n)) -> forall (i:Z) (j:Z),
    (valid_index (mat_mult_no_bound m n) i j) ->
    ((get (mat_mult_no_bound m n) i j) =
     (ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
      (columns m))))).

Parameter mat_mult: (matrix t) -> (matrix t) -> matrix t.

Axiom mat_mult_def :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  ((mat_mult m n) = (mat_mult_no_bound m n)).

Axiom mat_mult_spec :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  ((rows (mat_mult m n)) = (rows m)) /\
  (((columns (mat_mult m n)) = (columns n)) /\
   forall (i:Z) (j:Z), (valid_index (mat_mult m n) i j) ->
   ((get (mat_mult m n) i j) =
    (ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
     (columns m)))).

Axiom mat_mult_values :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z), ((columns m) = (rows n)) ->
  (valid_index (mat_mult m n) i j) ->
  ((get (mat_mult m n) i j) =
   (ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
    (columns m))).

Axiom mat_mult_columns :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  ((columns (mat_mult m n)) = (columns n)).

Axiom mat_mult_rows :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  ((rows (mat_mult m n)) = (rows m)).

Axiom mat_mult_values_quant :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  forall (i:Z) (j:Z), (valid_index (mat_mult m n) i j) ->
  ((get (mat_mult m n) i j) =
   (ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
    (columns m))).

Parameter int_mat_prod: (Z -> matrix t) -> Z -> Z -> matrix t.

Axiom int_mat_prod_def :
  forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z) (k':Z),
   (((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
   ((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
  (((j - i)%Z = 0%Z) -> ((int_mat_prod f i j) = (f i))) /\
  (~ ((j - i)%Z = 0%Z) ->
   ((int_mat_prod f i j) =
    (mat_mult_no_bound (int_mat_prod f i (j - 1%Z)%Z) (f j)))).

Axiom int_mat_prod_spec :
  forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z) (k':Z),
   (((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
   ((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
  ((rows (int_mat_prod f i j)) = (rows (f i))) /\
  (((columns (int_mat_prod f i j)) = (columns (f i))) /\
   ((columns (int_mat_prod f i j)) = (rows (f i)))).

Axiom int_mat_prod_zero :
  forall (f:Z -> matrix t) (i:Z) (j:Z), ((rows (f i)) = (columns (f i))) ->
  (i = j) -> ((int_mat_prod f i j) = (f i)).

Parameter int_mat_prod_plus_one: (Z -> matrix t) -> Z -> Z -> unit.

Axiom int_mat_prod_plus_one_def :
  forall (f:Z -> matrix t) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z) (k':Z),
   (((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
   ((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
  ((int_mat_prod_plus_one f i j) = tt).

Axiom int_mat_prod_plus_one_spec :
  forall (f:Z -> matrix t) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z) (k':Z),
   (((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
   ((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
  ((int_mat_prod f i j) = (mat_mult (int_mat_prod f i (j - 1%Z)%Z) (f j))).

Axiom int_mat_prod_eq :
  forall (f:Z -> matrix t) (g:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z) (k':Z), ((i <= k)%Z /\ (k <= j)%Z) ->
   ((i <= k')%Z /\ (k' <= j)%Z) ->
   ((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
  (forall (k:Z), ((i <= k)%Z /\ (k <= j)%Z) -> ((f k) = (g k))) ->
  ((int_mat_prod f i j) = (int_mat_prod g i j)).

Parameter add_mat: (matrix t) -> (matrix t) -> matrix t.

Axiom add_mat_def :
  forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  ((add_mat m n) =
   (make_f (rows m) (columns m)
    (fun (i:Z) (j:Z) => (infix_pldt (get m i j) (get n i j))))).

Axiom add_mat_spec :
  forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  (((columns (add_mat m n)) = (columns m)) /\ ((columns m) = (columns n))) /\
  ((((rows (add_mat m n)) = (rows m)) /\ ((rows m) = (rows n))) /\
   forall (i:Z) (j:Z),
   ((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j)))).

Axiom add_mat_equal :
  forall (m:matrix t) (n:matrix t) (m':matrix t) (n':matrix t),
  ((rows m) = (rows n)) -> ((columns m) = (columns n)) -> (m = m') ->
  (n = n') -> ((add_mat m n) = (add_mat m' n')).

Axiom add_value :
  forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
  ((rows m) = (rows n)) -> ((columns m) = (columns n)) -> forall (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
  ((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j))).

Axiom add_values :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  ((columns m) = (columns n)) -> ((rows m) = (rows n)) ->
  ((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j))).

Axiom add_mat_null_left :
  forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
  ((rows m) = (rows n)) -> (null_mat m) -> ((add_mat m n) = n).

Axiom add_mat_null_right :
  forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
  ((rows m) = (rows n)) -> (null_mat n) -> ((add_mat m n) = m).

Axiom set_equal_columns_elt :
  forall (m:matrix t) (n:matrix t) (i:Z),
  (((columns m) = (columns n)) /\ ((columns n) = i)) ->
  ((columns m) = (columns n)).

Axiom set_equal_rows_elt :
  forall (m:matrix t) (n:matrix t) (i:Z),
  (((rows m) = (rows n)) /\ ((rows n) = i)) -> ((rows m) = (rows n)).

Axiom add_columns :
  forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
  ((rows m) = (rows n)) -> ((columns (add_mat m n)) = (columns m)).

Axiom add_rows :
  forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
  ((rows m) = (rows n)) -> ((rows (add_mat m n)) = (rows m)).

Axiom set_equal_dim_elt :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  (((rows m) = (rows n)) /\ ((rows n) = i)) ->
  (((columns m) = (columns n)) /\ ((columns n) = j)) ->
  ((columns m) = (columns n)) /\ ((rows m) = (rows n)).

Axiom set_dim_add :
  forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
  (((rows m) = (rows n)) /\ ((rows n) = i)) ->
  (((columns m) = (columns n)) /\ ((columns n) = j)) ->
  ((rows (add_mat m n)) = i) /\ ((columns (add_mat m n)) = j).

Axiom add_mat_eq :
  forall (m:matrix t) (m1:matrix t) (n:matrix t) (n1:matrix t),
  ((rows m) = (rows n)) -> ((columns m) = (columns n)) -> (m = m1) ->
  (n = n1) -> ((add_mat m n) = (add_mat m1 n1)).

Axiom add_mat_comm :
  forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) -> ((add_mat m n) = (add_mat n m)).

Parameter add_neutral: unit -> matrix t.

Axiom add_neutral_spec :
  forall (us:unit),
  (forall (i:Z) (j:Z), (valid_index (add_neutral us) i j) ->
   ((get (add_neutral us) i j) = tzero)) /\
  ((0%Z < (rows (add_neutral us)))%Z /\ (0%Z < (columns (add_neutral us)))%Z).

Axiom distr_1_pre :
  forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
  ((rows m) = (rows n)) -> ((columns m) = (columns n)) ->
  ((columns m) = (rows o)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns o))%Z) ->
  ((get (mat_mult (add_mat m n) o) i j) =
   (get (add_mat (mat_mult m o) (mat_mult n o)) i j)).

Axiom distr_l :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) -> ((columns m) = (rows o)) ->
  ((mat_mult (add_mat m n) o) = (add_mat (mat_mult m o) (mat_mult n o))).

Axiom distr_2_pre :
  forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
  ((rows n) = (rows o)) -> ((columns n) = (columns o)) ->
  ((columns m) = (rows n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
  (valid_index (mat_mult m (add_mat n o)) i j) /\
  ((get (mat_mult m (add_mat n o)) i j) =
   (get (add_mat (mat_mult m n) (mat_mult m o)) i j)).

Axiom distr_r :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows n) = (rows o)) ->
  ((columns n) = (columns o)) -> ((columns m) = (rows n)) ->
  ((mat_mult m (add_mat n o)) = (add_mat (mat_mult m n) (mat_mult m o))).

(* Why3 assumption *)
Definition infix_asdtdt (s:t) (m:matrix t) : matrix t :=
  make_f (rows m) (columns m) (fun (i:Z) (j:Z) => (infix_asdt s (get m i j))).

Axiom infix_asdtdt_spec :
  forall (s:t) (m:matrix t),
  ((columns (infix_asdtdt s m)) = (columns m)) /\
  (((rows (infix_asdtdt s m)) = (rows m)) /\
   ((forall (i:Z) (j:Z), (valid_index (infix_asdtdt s m) i j) ->
     ((get (infix_asdtdt s m) i j) = (infix_asdt s (get m i j)))) /\
    forall (i:Z) (j:Z),
    (valid_index (infix_asdtdt s m) i j) <-> (valid_index m i j))).

Axiom scalar_columns :
  forall (m:matrix t) (a:t), ((columns (infix_asdtdt a m)) = (columns m)).

Axiom scalar_values :
  forall (m:matrix t) (a:t) (i:Z) (j:Z),
  ((get (infix_asdtdt a m) i j) = (infix_asdt a (get m i j))).

Axiom scalar_rows :
  forall (m:matrix t) (a:t), ((rows (infix_asdtdt a m)) = (rows m)).

Axiom scalar_null : forall (m:matrix t), null_mat (infix_asdtdt tzero m).

Axiom scalar_tone : forall (m:matrix t), ((infix_asdtdt tone m) = m).

Axiom scalar_tone_gen :
  forall (m:matrix t) (a:t), (a = tone) -> ((infix_asdtdt a m) = m).

Axiom scalar_null_gen :
  forall (m:matrix t) (a:t), (a = tzero) -> null_mat (infix_asdtdt a m).

Axiom scalar_plus :
  forall (m:matrix t) (a:t) (b:t),
  ((infix_asdtdt (infix_pldt a b) m) =
   (add_mat (infix_asdtdt a m) (infix_asdtdt b m))).

Axiom scalar_plus_rev :
  forall (m:matrix t) (a:t) (b:t),
  ((add_mat (infix_asdtdt a m) (infix_asdtdt b m)) =
   (infix_asdtdt (infix_pldt a b) m)).

Axiom add_scal :
  forall (m:matrix t) (n:matrix t) (a:t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  ((infix_asdtdt a (add_mat m n)) =
   (add_mat (infix_asdtdt a m) (infix_asdtdt a n))).

Axiom mat_mult_scal_values_l :
  forall (m:matrix t) (n:matrix t) (a:t) (i:Z) (j:Z),
  ((rows n) = (columns m)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
  ((infix_asdt a (get (mat_mult m n) i j)) =
   (ind_sum
    (fun (k:Z) => (infix_asdt (infix_asdt a (get m i k)) (get n k j))) 0%Z
    (columns m))).

Axiom mat_mult_scal_values_r :
  forall (m:matrix t) (n:matrix t) (a:t) (i:Z) (j:Z),
  ((rows n) = (columns m)) -> ((rows m) = (columns n)) ->
  ((columns m) = (columns n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
  ((infix_asdt (get (mat_mult m n) i j) a) =
   (ind_sum
    (fun (k:Z) => (infix_asdt (infix_asdt a (get m i k)) (get n k j))) 0%Z
    (columns m))).

Axiom mat_mut_scal :
  forall (m:matrix t) (n:matrix t) (a:t), ((rows n) = (columns m)) ->
  ((mat_mult m (infix_asdtdt a n)) = (infix_asdtdt a (mat_mult m n))).

Axiom scal_mat_mut :
  forall (m:matrix t) (n:matrix t) (a:t), ((rows n) = (columns m)) ->
  ((mat_mult (infix_asdtdt a m) n) = (infix_asdtdt a (mat_mult m n))).

Axiom ind_sum_commute_scal_r :
  forall (f:Z -> Z -> t) (g:Z -> t) (i:Z) (j:Z) (k:Z) (l:Z), (i <= j)%Z ->
  (k <= l)%Z ->
  ((ind_sum (fun (k1:Z) => (infix_asdt (ind_sum (f k1) k l) (g k1))) i j) =
   (ind_sum
    (fun (k1:Z) =>
     (ind_sum (fun (k2:Z) => (infix_asdt ((f k2) k1) (g k2))) i j))
    k l)).

Axiom mat_mult_assoc_pre :
  forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
  ((columns m) = (rows n)) -> ((columns n) = (rows o)) ->
  ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns o))%Z) ->
  ((get (mat_mult (mat_mult m n) o) i j) =
   (get (mat_mult m (mat_mult n o)) i j)).

Axiom mat_mult_assoc :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((columns m) = (rows n)) ->
  ((columns n) = (rows o)) ->
  ((mat_mult (mat_mult m n) o) = (mat_mult m (mat_mult n o))).

Axiom mat_mult_assoc_quant :
  forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
  forall (o:matrix t), ((columns n) = (rows o)) ->
  ((mat_mult (mat_mult m n) o) = (mat_mult m (mat_mult n o))).

Axiom mat_mult_assoc_comm :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((columns m) = (rows n)) ->
  ((columns n) = (rows o)) ->
  ((mat_mult m (mat_mult n o)) = (mat_mult (mat_mult m n) o)).

Axiom scalar_eq :
  forall (m:matrix t) (n:matrix t) (a:t), (m = n) ->
  ((infix_asdtdt a m) = (infix_asdtdt a n)).

Axiom scalar_eq_gen :
  forall (m:matrix t) (n:matrix t) (a:t) (b:t), (m = n) -> (a = b) ->
  ((infix_asdtdt a m) = (infix_asdtdt b n)).

Axiom scalar_add :
  forall (m:matrix t) (a:t) (b:t),
  ((infix_asdtdt (infix_pldt a b) m) =
   (add_mat (infix_asdtdt a m) (infix_asdtdt b m))).

Axiom scalar_assoc :
  forall (m:matrix t) (a:t) (b:t),
  ((infix_asdtdt a (infix_asdtdt b m)) = (infix_asdtdt (infix_asdt a b) m)).

(* Why3 assumption *)
Definition constant_size {a:Type} {a_WT:WhyType a} (s:set a)
    (f:a -> matrix t) : Prop :=
  forall (e:a), (mem e s) ->
  ((rows (f e)) = (rows (f (choose s)))) /\
  ((columns (f e)) = (columns (f (choose s)))).

Axiom set_constant_size :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t),
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((rows (f e)) = (rows (f e')))) ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((columns (f e)) = (columns (f e')))) ->
  constant_size s f.

Axiom set_constant_size_t :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z),
  (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> constant_size s f.

Parameter fc5:
  forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (a -> bool) ->
  (matrix t) -> a -> matrix t.

Axiom fc_def5 :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (p:a -> bool) (m:matrix t) (j:a),
  (((p j) = true) -> (((fc5 f p m) j) = (f j))) /\
  (~ ((p j) = true) -> (((fc5 f p m) j) = m)).

Axiom guarded_set_constant_size :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (p:a -> bool) (m:matrix t),
  (constant_size s f) -> (forall (e:a), (mem e s) -> ((p e) = true)) ->
  constant_size s (fc5 f p m).

Axiom set_constant_size_set :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> t) (m:matrix t) (i:Z) (j:Z),
  (valid_index m i j) -> constant_size s (fun (e:a) => (set1 m i j (f e))).

Axiom get_constant_size :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((rows (f e)) = (rows (f e')))) /\
  forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
  ((columns (f e)) = (columns (f e'))).

Parameter s_rows:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z.

Axiom s_rows_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  ((s_rows s f) = (rows (f (choose s)))).

Axiom s_rows_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (0%Z < (s_rows s f))%Z /\
  ((forall (e:a), (mem e s) -> ((rows (f e)) = (s_rows s f))) /\
   forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((rows (f e)) = (rows (f e')))).

Parameter s_columns:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z.

Axiom s_columns_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  ((s_columns s f) = (columns (f (choose s)))).

Axiom s_columns_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (0%Z < (s_columns s f))%Z /\
  ((forall (e:a), (mem e s) -> ((columns (f e)) = (s_columns s f))) /\
   forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((columns (f e)) = (columns (f e')))).

Axiom set_s_rows :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z), (constant_size s f) ->
  ((rows (f (choose s))) = r) -> ((s_rows s f) = r).

Axiom set_s_rows_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (elt:a), (constant_size s f) ->
  (mem elt s) -> ((s_rows s f) = (rows (f elt))).

Axiom set_s_columns :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z), (constant_size s f) ->
  ((columns (f (choose s))) = r) -> ((s_columns s f) = r).

Axiom set_s_columns_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (elt:a), (constant_size s f) ->
  (mem elt s) -> ((s_columns s f) = (columns (f elt))).

Axiom s_rows_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
  (constant_size s f) -> (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> ((f e) = (g e))) ->
  ((s_rows s f) = (s_rows s g)).

Axiom s_columns_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
  (constant_size s f) -> (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> ((f e) = (g e))) ->
  ((s_columns s f) = (s_columns s g)).

Axiom subset_constant_size :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (f:a -> matrix t), (constant_size s f) ->
  ~ (is_empty s') -> (subset s' s) ->
  (constant_size s' f) /\
  (((s_rows s' f) = (s_rows s f)) /\ ((s_columns s' f) = (s_columns s f))).

Axiom set_s_rows_rem :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (1%Z < (cardinal s))%Z ->
  (constant_size s f) ->
  (constant_size (remove (choose s) s) f) /\
  ((s_rows (remove (choose s) s) f) = (rows (f (choose s)))).

Axiom set_s_columns_rem :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (1%Z < (cardinal s))%Z ->
  (constant_size s f) ->
  (constant_size (remove (choose s) s) f) /\
  ((s_columns (remove (choose s) s) f) = (columns (f (choose s)))).

Axiom set_s_rows_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (x:a), (0%Z < (cardinal s))%Z ->
  (constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
  ((rows (f x)) = (s_rows s f)) -> ((s_rows (add x s) f) = (s_rows s f)).

Axiom set_s_columns_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (x:a), (0%Z < (cardinal s))%Z ->
  (constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
  ((rows (f x)) = (s_rows s f)) ->
  ((s_columns (add x s) f) = (s_columns s f)).

Axiom set_s_rows_columns_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (x:a), (0%Z < (cardinal s))%Z ->
  (constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
  ((rows (f x)) = (s_rows s f)) ->
  ((s_columns (add x s) f) = (s_columns s f)) /\
  ((s_rows (add x s) f) = (s_rows s f)).

Parameter mat_sum:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.

Axiom mat_sum_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  (((cardinal s) = 1%Z) -> ((mat_sum s f) = (f (element s)))) /\
  (~ ((cardinal s) = 1%Z) ->
   ((mat_sum s f) =
    (add_mat (f (choose s)) (mat_sum (remove (choose s) s) f)))).

Axiom mat_sum_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  ((rows (mat_sum s f)) = (s_rows s f)) /\
  (((columns (mat_sum s f)) = (s_columns s f)) /\
   ((forall (e:a), (mem e s) -> ((rows (f e)) = (s_rows s f))) /\
    forall (e:a), (mem e s) -> ((columns (f e)) = (s_columns s f)))).

Axiom columns_mat_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (n:Z), ~ ((cardinal s) = 0%Z) ->
  (constant_size s f) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = n)) ->
  ((columns (mat_sum s f)) = n).

Axiom rows_mat_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (n:Z), ~ ((cardinal s) = 0%Z) ->
  (constant_size s f) -> (forall (e:a), (mem e s) -> ((rows (f e)) = n)) ->
  ((rows (mat_sum s f)) = n).

Axiom mat_sum_cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), ((cardinal s) = 1%Z) ->
  ((mat_sum s f) = (f (element s))).

Axiom mat_sum_to_sum_pre :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (i:Z) (j:Z), (constant_size s f) ->
  (0%Z < (cardinal s))%Z -> ((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
  ((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
  ((get (mat_sum s f) i j) = (sum s (fun (e:a) => (get (f e) i j)))).

Axiom mat_sum_to_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  ((mat_sum s f) =
   (make_f (s_rows s f) (s_columns s f)
    (fun (i:Z) (j:Z) => (sum s (fun (e:a) => (get (f e) i j)))))).

Axiom mat_sum_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (x:a), (0%Z < (cardinal s))%Z ->
  (constant_size s f) -> ((rows (f x)) = (s_rows s f)) ->
  ((columns (f x)) = (s_columns s f)) -> ~ (mem x s) ->
  ((mat_sum (add x s) f) = (add_mat (f x) (mat_sum s f))).

Axiom mat_sum_comp_pre :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (i:Z) (j:Z),
  (constant_size s f) -> (constant_size s g) ->
  ((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
  ((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
  ((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
  (0%Z < (cardinal s))%Z ->
  ((get (mat_sum s (fun (k:b) => (add_mat (f k) (g k)))) i j) =
   (get (add_mat (mat_sum s f) (mat_sum s g)) i j)).

Axiom mat_sum_comp :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t),
  (constant_size s f) -> (constant_size s g) ->
  ((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
  (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (k:b) => (add_mat (f k) (g k)))) =
   (add_mat (mat_sum s f) (mat_sum s g))).

Axiom mat_sum_comp_rec :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t),
  (constant_size s f) -> (constant_size s g) ->
  ((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
  (0%Z < (cardinal s))%Z ->
  ((add_mat (mat_sum s f) (mat_sum s g)) =
   (mat_sum s (fun (k:b) => (add_mat (f k) (g k))))).

Axiom mat_sum_to_sum_fun :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (s':set b) (f:a -> b -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z),
  (0%Z < (cardinal s))%Z -> (0%Z < (cardinal s'))%Z ->
  (forall (e:a), forall (e1:b), (mem e s) -> (mem e1 s') ->
   ((rows ((f e) e1)) = r)) ->
  (forall (e:a), forall (e1:b), (mem e s) -> (mem e1 s') ->
   ((columns ((f e) e1)) = c)) ->
  ((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
  ((sum s (fun (e:a) => (get (mat_sum s' (f e)) i j))) =
   (sum s (fun (e:a) => (sum s' (fun (e1:b) => (get ((f e) e1) i j)))))).

Axiom mat_sum_to_sum_double_pre :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (s':set b) (f:a -> b -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z),
  (forall (e:a) (e':b), (mem e s) -> (mem e' s') -> ((rows ((f e) e')) = r)) ->
  (forall (e:a) (e':b), (mem e s) -> (mem e' s') ->
   ((columns ((f e) e')) = c)) ->
  ((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
  (0%Z < (cardinal s))%Z -> (0%Z < (cardinal s'))%Z ->
  ((get (mat_sum s (fun (e:a) => (mat_sum s' (f e)))) i j) =
   (sum s (fun (e:a) => (sum s' (fun (e':b) => (get ((f e) e') i j)))))).

Parameter mat_sum_dim:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
  Z -> matrix t.

Axiom mat_sum_dim_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
  (0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  (((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (make r c tzero))) /\
  (~ ((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (mat_sum s f))).

Axiom mat_sum_dim_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
  (0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  ((0%Z < (cardinal s))%Z -> ((mat_sum_dim s f r c) = (mat_sum s f))) /\
  ((((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (make r c tzero))) /\
   (((rows (mat_sum_dim s f r c)) = r) /\
    ((columns (mat_sum_dim s f r c)) = c))).

Axiom mat_sum_dim_to_mat_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < (cardinal s))%Z ->
  (0%Z < r)%Z -> (0%Z < c)%Z ->
  (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  ((mat_sum_dim s f r c) = (mat_sum s f)).

Axiom mat_sum_dim_to_make_zero :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) = 0%Z) ->
  (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> (0%Z < r)%Z ->
  (0%Z < c)%Z -> ((mat_sum_dim s f r c) = (make r c tzero)).

Axiom mat_sum_dim_add :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (x:a) (r:Z) (c:Z),
  (0%Z <= (cardinal s))%Z -> ~ (mem x s) ->
  (forall (e:a), (mem e (add x s)) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e (add x s)) -> ((columns (f e)) = c)) ->
  (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((mat_sum_dim (add x s) f r c) = (add_mat (f x) (mat_sum_dim s f r c))).

Axiom mat_sum_scalar :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k)))) =
   (infix_asdtdt a1 (mat_sum s f))).

Axiom mat_sum_scalar_rev :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  ((infix_asdtdt a1 (mat_sum s f)) =
   (mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k))))).

Axiom real : forall (x:t), (real_ x) -> (x = (r_to_t (real_part x))).

Axiom pure_im :
  forall (x:t), (pure_im_ x) -> (x = (infix_asdt im (r_to_t (im_part x)))).

Axiom im_dec : ((real_part im) = 0%R) /\ ((im_part im) = 1%R).

Axiom tone_dec : ((real_part tone) = 1%R) /\ ((im_part tone) = 0%R).

Axiom tzero_dec : ((real_part tzero) = 0%R) /\ ((im_part tzero) = 0%R).

Axiom ttwo_dec :
  ((real_part (infix_pldt tone tone)) = 2%R) /\
  ((im_part (infix_pldt tone tone)) = 0%R).

(* Why3 assumption *)
Definition i_to_t (i:Z) : t := r_to_t (from_int i).

Axiom i_to_t_spec : forall (i:Z), real_ (i_to_t i).

Axiom i_to_t_zero : ((i_to_t 0%Z) = tzero).

Axiom i_to_t_eq : forall (i:Z) (j:Z), (i = j) -> ((i_to_t i) = (i_to_t j)).

Axiom i_to_t_nzero : forall (i:Z), ~ (i = 0%Z) -> ~ ((i_to_t i) = tzero).

Axiom i_to_t_one : ((i_to_t 1%Z) = tone).

Axiom i_to_t_add :
  forall (i:Z) (j:Z),
  ((infix_pldt (i_to_t i) (i_to_t j)) = (i_to_t (i + j)%Z)).

Axiom i_to_t_add_rev :
  forall (i:Z) (j:Z),
  ((i_to_t (i + j)%Z) = (infix_pldt (i_to_t i) (i_to_t j))).

Axiom i_to_t_ttwo : ((i_to_t 2%Z) = (infix_pldt tone tone)).

Axiom i_to_t_mult :
  forall (i:Z) (j:Z),
  ((infix_asdt (i_to_t i) (i_to_t j)) = (i_to_t (i * j)%Z)).

Axiom i_to_t_mult_rev :
  forall (i:Z) (j:Z),
  ((i_to_t (i * j)%Z) = (infix_asdt (i_to_t i) (i_to_t j))).

Axiom i_to_t_sub :
  forall (i:Z) (j:Z),
  ((infix_mndt (i_to_t i) (i_to_t j)) = (i_to_t (i - j)%Z)).

Axiom i_to_t_opp :
  forall (i:Z), ((i_to_t (-i)%Z) = (prefix_mndt (i_to_t i))).

Axiom i_to_t_div :
  forall (i:Z) (j:Z), ~ (j = 0%Z) ->
  ((infix_sldt (i_to_t (i * j)%Z) (i_to_t j)) = (i_to_t i)).

Axiom mat_sum_const :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:matrix t), (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (us:a) => x)) = (infix_asdtdt (i_to_t (cardinal s)) x)).

Axiom mat_sum_quot :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:matrix t), (0%Z < (cardinal s))%Z ->
  (x =
   (infix_asdtdt (infix_sldt tone (i_to_t (cardinal s)))
    (mat_sum s (fun (us:a) => x)))).

Axiom mat_sum_scalar_right :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t) (i:Z) (j:Z),
  (constant_size s f) -> (0%Z < (cardinal s))%Z ->
  ((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
  ((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
  ((infix_asdtdt (get (mat_sum s f) i j) m) =
   (mat_sum s (fun (k:a) => (infix_asdtdt (get (f k) i j) m)))).

Axiom mat_sum_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
  (0%Z < (cardinal s))%Z -> (constant_size s f) ->
  (forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
  ((mat_sum s f) = (mat_sum s g)).

Axiom mat_sum_eq_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t),
  (0%Z < (cardinal s))%Z -> (s = s') -> (constant_size s f) ->
  (forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
  ((mat_sum s f) = (mat_sum s' g)).

Axiom mat_sum_eq_gen_int :
  forall (i1:Z) (i2:Z) (o1:Z) (o2:Z) (f:Z -> matrix t) (g:Z -> matrix t),
  (i1 < o1)%Z -> (i1 = o1) -> (i2 = o2) ->
  (constant_size (to_fset i1 o1) f) ->
  (forall (a:Z), (mem a (to_fset i1 o1)) -> ((f a) = (g a))) ->
  ((mat_sum (to_fset i1 o1) f) = (mat_sum (to_fset i2 o2) g)).

Axiom mat_sum_comp_eq :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (h:b -> matrix t),
  (constant_size s f) -> (constant_size s g) -> (constant_size s h) ->
  (((s_rows s f) = (s_rows s g)) /\ ((s_rows s g) = (s_rows s h))) ->
  (((s_columns s f) = (s_columns s g)) /\
   ((s_columns s g) = (s_columns s h))) ->
  (0%Z < (cardinal s))%Z ->
  (forall (e:b), forall (i:Z) (j:Z), (mem e s) ->
   ((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
   ((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
   ((infix_pldt (get (f e) i j) (get (g e) i j)) = (get (h e) i j))) ->
  ((add_mat (mat_sum s f) (mat_sum s g)) = (mat_sum s h)).

Axiom mat_sum_dim_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (g:a -> matrix t) (r:Z) (c:Z),
  (0%Z < r)%Z -> (0%Z < c)%Z ->
  (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  (forall (e:a), (mem e s) -> ((f e) = (g e))) ->
  ((mat_sum_dim s f r c) = (mat_sum_dim s g r c)).

Axiom constant_size_map :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:b -> matrix t) (s:set a) (t1:a -> b),
  (constant_size s (fun (a1:a) => (f (t1 a1)))) -> constant_size (map t1 s) f.

Axiom map_mat_sum :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:b -> matrix t) (s:set a) (t1:a -> b), (0%Z < (cardinal s))%Z ->
  (constant_size s (fun (a1:a) => (f (t1 a1)))) -> (p_injective t1 s) ->
  ((mat_sum (map t1 s) f) = (mat_sum s (fun (a1:a) => (f (t1 a1))))).

Axiom map_mat_sum_rec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:b -> matrix t) (s:set a) (t1:a -> b), (0%Z < (cardinal s))%Z ->
  (constant_size s (fun (a1:a) => (f (t1 a1)))) -> (p_injective t1 s) ->
  ((mat_sum s (fun (a1:a) => (f (t1 a1)))) = (mat_sum (map t1 s) f)).

Axiom mat_sum_id :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a), (0%Z < (cardinal s))%Z ->
  (constant_size s f) ->
  (constant_size (map f s) (fun (y0:matrix t) => y0)) -> (p_injective f s) ->
  ((mat_sum (map f s) (fun (y0:matrix t) => y0)) = (mat_sum s f)).

Parameter nonn_mat_subset:
  forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (set a) -> set a.

Parameter result7:
  forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (set a) -> a -> bool.

Axiom result_def7 :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (e:a),
  (((result7 f s) e) = true) <->
  ~ (equal (f e) (make (s_rows s f) (s_columns s f) tzero)).

Axiom nonn_mat_subset_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
  ((nonn_mat_subset f s) = (filter (result7 f s) s)).

Axiom nonn_mat_subset_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
  (subset (nonn_mat_subset f s) s) /\
  ((forall (e:a), (mem e (nonn_mat_subset f s)) -> mem e s) /\
   ((constant_size (nonn_mat_subset f s) f) /\
    ((~ ((nonn_mat_subset f s) = (empty : set a)) ->
      ((s_rows (nonn_mat_subset f s) f) = (s_rows s f))) /\
     (~ ((nonn_mat_subset f s) = (empty : set a)) ->
      ((s_columns (nonn_mat_subset f s) f) = (s_columns s f)))))).

Axiom mat_subset_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a), (constant_size s f) -> forall (e:a),
  (mem e (nonn_mat_subset f s)) -> mem e s.

Axiom mat_subset_nonn_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a), (constant_size s f) -> forall (e:a),
  (mem e (nonn_mat_subset f s)) ->
  ~ ((f e) = (make (s_rows s f) (s_columns s f) tzero)).

Axiom nonn_mat_sum_cardzero :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) = 0%Z) ->
  (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).

Axiom nonn_mat_sum_cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) = 1%Z) ->
  (0%Z < r)%Z -> (0%Z < c)%Z -> ((rows (f (choose s))) = r) ->
  ((columns (f (choose s))) = c) ->
  ((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).

Axiom mat_sum_null_but_maybe_one_elt :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (e:a), (1%Z < (cardinal s))%Z ->
  (constant_size s f) -> (mem e s) ->
  (forall (e':a), (mem e' s) -> ~ (e = e') -> null_mat (f e')) ->
  ((mat_sum s f) = (f e)).

Axiom nonn_mat_sum_plus_one :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), (1%Z < (cardinal s))%Z ->
  (0%Z < r)%Z -> (0%Z < c)%Z ->
  (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  ((mat_sum_dim (remove (choose s) s) f r c) =
   (mat_sum_dim (nonn_mat_subset f (remove (choose s) s)) f r c)) ->
  ((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).

Axiom nonn_mat_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), (0%Z < r)%Z ->
  (0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
  (forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
  ((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).

Axiom mat_sum_map_map :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
    {c:Type} {c_WT:WhyType c},
  forall (s1:set a) (s2:set b) (t1:a -> c) (t2:b -> c) (f:c -> matrix t),
  (0%Z < (cardinal s1))%Z -> (p_injective t1 s1) ->
  (constant_size s1 (fun (a1:a) => (f (t1 a1)))) ->
  (0%Z < (cardinal s2))%Z -> (p_injective t2 s2) ->
  (constant_size s2 (fun (a1:b) => (f (t2 a1)))) ->
  ((map t1 s1) = (map t2 s2)) ->
  ((mat_sum (map t1 s1) f) = (mat_sum (map t2 s2) f)).

Axiom mat_sum_disjoint_transitivity :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s1:set a) (s2:set a) (f:a -> matrix t),
  (constant_size s f) -> ((inter s1 s2) = (empty : set a)) ->
  ((union s1 s2) = s) -> (0%Z < (cardinal s1))%Z ->
  (0%Z < (cardinal s2))%Z ->
  ((add_mat (mat_sum s1 f) (mat_sum s2 f)) = (mat_sum s f)).

Axiom map_add_mat_sum_t :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (s:set a) (s':set b) (f:b -> matrix t) (injz:a -> b) (injo:a -> b),
  (constant_size s' f) -> (0%Z < (cardinal s))%Z ->
  ((inter (map injz s) (map injo s)) = (empty : set b)) ->
  ((union (map injz s) (map injo s)) = s') -> (p_injective injo s) ->
  (p_injective injz s) ->
  ((mat_sum s (fun (e:a) => (add_mat (f (injz e)) (f (injo e))))) =
   (mat_sum s' f)).

Axiom map_add_mat_sum :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s1:set a) (s2:set a) (s':set a) (f:a -> matrix t)
    (g:a -> matrix t) (h:a -> matrix t),
  (constant_size s' h) -> (constant_size s f) -> (constant_size s g) ->
  (((s_rows s' h) = (s_rows s f)) /\ ((s_rows s f) = (s_rows s g))) ->
  (((s_columns s' h) = (s_columns s f)) /\
   ((s_columns s f) = (s_columns s g))) ->
  (0%Z < (cardinal s))%Z -> (p_injective f s) -> (p_injective g s) ->
  (p_injective h s') -> ((map f s) = (map h s1)) ->
  ((map g s) = (map h s2)) -> ((inter s1 s2) = (empty : set a)) ->
  ((union s1 s2) = s') ->
  ((mat_sum s (fun (e:a) => (add_mat (f e) (g e)))) =
   (mat_sum s' (fun (e:a) => (h e)))).

Parameter inv_func:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
  (set a) -> (set b) -> b -> a.

Axiom inv_func_def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b) (e':b), (p_bijective f s s') ->
  (mem e' s') ->
  ((inv_func f s s' e') =
   (element (filter (fun (e:a) => (indic_bool (f e) e')) s))).

Axiom inv_func_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b) (e':b), (p_bijective f s s') ->
  (mem e' s') ->
  (mem (inv_func f s s' e') s) /\ ((f (inv_func f s s' e')) = e').

Axiom inv_rec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b) (e:a), (p_bijective f s s') ->
  (mem e s) -> ((inv_func f s s' (f e)) = e).

Parameter inv_:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
  (set a) -> (set b) -> b -> a.

Axiom inv__def :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b) (e:b), (p_bijective f s s') ->
  (mem e s') -> ((inv_ f s s' e) = (inv_func f s s' e)).

Axiom inv__spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b) (e:b), (p_bijective f s s') ->
  (mem e s') -> (mem (inv_ f s s' e) s) /\ ((f (inv_ f s s' e)) = e).

Axiom inv_bijective :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  p_bijective
  ((((fun (y0:a -> b) (y1:set a) (y2:set b) (y3:b) => (inv_ y0 y1 y2 y3)) f)
    s)
   s')
  s' s.

Axiom set_bijective_inv :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:b -> a) (s:set a) (b1:b), (mem b1 (map f s)) ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
   ~ ((f e) = (f e'))) ->
  (forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
  (p_bijective f s (map f s)) /\ ((inv_func f s (map f s) b1) = (g b1)).

Axiom set_bij_inv :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (g:b -> a) (s:set a),
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
   ~ ((f e) = (f e'))) ->
  (forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
  (p_bijective f s (map f s)) /\
  ((p_bijective g (map f s) s) /\
   forall (b1:b), (mem b1 (map f s)) ->
   ((inv_func f s (map f s) b1) = (g b1))).

Parameter inv_f:
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
  (set a) -> (set b) -> b -> a.

Axiom inv_f_spec :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
  (forall (e:b), (mem e s') -> mem ((inv_f f s s') e) s) /\
  ((forall (e:b), (mem e s') -> ((f ((inv_f f s s') e)) = e)) /\
   (p_bijective (inv_f f s s') s' s)).

Axiom bitvec : Type.
Parameter bitvec_WhyType : WhyType bitvec.
Existing Instance bitvec_WhyType.

Parameter value: bitvec -> Z -> Z.

Parameter length: bitvec -> Z.

Axiom bitvec'invariant :
  forall (self:bitvec),
  (0%Z <= (length self))%Z /\
  ((forall (i:Z), ((0%Z <= i)%Z /\ (i < (length self))%Z) ->
    (0%Z <= ((value self) i))%Z /\ (((value self) i) < 2%Z)%Z) /\
   forall (i:Z), ~ ((0%Z <= i)%Z /\ (i < (length self))%Z) ->
   (((value self) i) = 0%Z)).

(* Why3 assumption *)
Definition bvlength (f:Z -> Z) (i:Z) : Prop :=
  forall (k:Z), ((0%Z <= k)%Z /\ (k < i)%Z) ->
  (0%Z <= (f k))%Z /\ ((f k) < 2%Z)%Z.

Axiom binary_mult :
  forall (a:Z) (b:Z),
  ((int.EuclideanDivision.mod1 (a * b)%Z 2%Z) =
   ((int.EuclideanDivision.mod1 a 2%Z) *
    (int.EuclideanDivision.mod1 b 2%Z))%Z).

Axiom getbv_spec : forall (a:bitvec), binary (value a).

Axiom getbv_bound :
  forall (bv:bitvec) (i:Z),
  (0%Z <= ((value bv) i))%Z /\ (((value bv) i) < 2%Z)%Z.

Axiom getbv_eq :
  forall (bvx:bitvec) (bvy:bitvec) (i:Z), (bvx = bvy) ->
  (((value bvx) i) = ((value bvy) i)).

Axiom getbv_eq_gen :
  forall (bvx:bitvec) (bvy:bitvec) (i:Z) (j:Z), (bvx = bvy) -> (i = j) ->
  (((value bvx) i) = ((value bvy) j)).

Parameter setbv: (Z -> Z) -> Z -> Z -> Z -> Z.

Axiom setbv_def :
  forall (bv:Z -> Z) (i:Z) (j:Z) (k:Z),
  ((k = i) -> (((setbv bv i j) k) = j)) /\
  (~ (k = i) -> (((setbv bv i j) k) = (bv k))).

Axiom setbv_spec :
  forall (bv:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ~ (k = i) -> (((setbv bv i j) k) = (bv k))) /\
  (((setbv bv i j) i) = j).

Parameter setbv_int: (Z -> Z) -> (Z -> Z) -> Z -> Z -> Z -> Z.

Axiom setbv_int_def :
  forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z) (k:Z),
  (((i < k)%Z /\ (k <= j)%Z) ->
   (((setbv_int bv1 bv2 i j) k) = (bv2 (k - i)%Z))) /\
  (~ ((i < k)%Z /\ (k <= j)%Z) -> (((setbv_int bv1 bv2 i j) k) = (bv1 k))).

Axiom setbv_int_spec :
  forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i < k)%Z /\ (k <= j)%Z) ->
   (((setbv_int bv1 bv2 i j) k) = (bv2 (k - i)%Z))) /\
  ((forall (k:Z), (k <= i)%Z -> (((setbv_int bv1 bv2 i j) k) = (bv1 k))) /\
   forall (k:Z), (j < k)%Z -> (((setbv_int bv1 bv2 i j) k) = (bv1 k))).

Axiom set_bvlength :
  forall (bv:bitvec) (i:Z),
  (forall (k:Z), ((1%Z <= k)%Z /\ (k < i)%Z) ->
   (0%Z <= ((value bv) k))%Z /\ (((value bv) k) < 2%Z)%Z) ->
  bvlength (value bv) i.

Axiom set_flength :
  forall (f:Z -> Z) (i:Z),
  (forall (k:Z), ((0%Z <= k)%Z /\ (k < i)%Z) ->
   (0%Z <= (f k))%Z /\ ((f k) < 2%Z)%Z) ->
  bvlength f i.

Axiom get_bvlength :
  forall (f:Z -> Z) (i:Z), (bvlength f i) -> forall (k:Z),
  ((0%Z <= k)%Z /\ (k < i)%Z) -> (0%Z <= (f k))%Z /\ ((f k) < 2%Z)%Z.

Axiom set_bv_to :
  forall (f:Z -> Z) (i:Z), (0%Z < i)%Z ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < i)%Z) ->
   (0%Z <= (f j))%Z /\ ((f j) <= 1%Z)%Z) ->
  bvlength f i.

Axiom set_in_range_val :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  (0%Z <= ((value bv) i))%Z /\ (((value bv) i) < 2%Z)%Z.

Axiom bvlengthm :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  bvlength (value bv) i.

(* Why3 assumption *)
Definition in_range (bv:bitvec) (r:Z) : Prop :=
  (0%Z <= r)%Z /\ (r < (length bv))%Z.

Axiom binary_bv :
  forall (bv:bitvec) (i:Z), (in_range bv i) ->
  (0%Z <= ((value bv) i))%Z /\ (((value bv) i) <= 1%Z)%Z.

Axiom equal_bv :
  forall (m:bitvec) (n:bitvec),
  (m = n) <->
  (((length m) = (length n)) /\
   forall (i:Z), (in_range m i) -> (((value m) i) = ((value n) i))).

Axiom set_equal_bv :
  forall (bv:bitvec) (bv':bitvec), ((length bv) = (length bv')) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
   (((value bv) i) = ((value bv') i))) ->
  (bv = bv').

Axiom get_equal_bv :
  forall (bv:bitvec) (bv':bitvec), (bv = bv') ->
  ((length bv) = (length bv')) /\
  forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  (((value bv) i) = ((value bv') i)).

Parameter make_bv: (Z -> Z) -> Z -> bitvec.

Axiom make_bv_spec :
  forall (f:Z -> Z) (s:Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
   (0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
  (0%Z <= s)%Z ->
  ((length (make_bv f s)) = s) /\
  ((forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
    (((value (make_bv f s)) i) = (f i))) /\
   forall (i:Z), ~ ((0%Z <= i)%Z /\ (i < s)%Z) ->
   (((value (make_bv f s)) i) = 0%Z)).

Parameter make_bv_m: (Z -> Z) -> Z -> bitvec.

Axiom make_bv_m_def :
  forall (f:Z -> Z) (s:Z), (0%Z <= s)%Z ->
  ((make_bv_m f s) =
   (make_bv (fun (k:Z) => (int.EuclideanDivision.mod1 (f k) 2%Z)) s)).

Axiom make_bv_m_spec :
  forall (f:Z -> Z) (s:Z), (0%Z <= s)%Z ->
  ((length (make_bv_m f s)) = s) /\
  ((forall (i:Z), bvlength (value (make_bv_m f s)) i) /\
   ((forall (k:Z), ((0%Z <= k)%Z /\ (k < s)%Z) ->
     (((value (make_bv_m f s)) k) = (int.EuclideanDivision.mod1 (f k) 2%Z))) /\
    forall (k:Z), ~ ((0%Z <= k)%Z /\ (k < s)%Z) ->
    (((value (make_bv_m f s)) k) = 0%Z))).

Axiom assert_make_bv_no_bound :
  forall (f:Z -> Z) (s:Z) (i:Z),
  (forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
   (0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
  ((1%Z <= i)%Z /\ (i <= s)%Z) -> (((value (make_bv f 0%Z)) i) = 0%Z).

Axiom make_bv_length :
  forall (f:Z -> Z) (s:Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
   (0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
  (0%Z <= s)%Z -> ((length (make_bv f s)) = s).

Axiom assert_make_bv :
  forall (f:Z -> Z) (s:Z) (i:Z),
  (forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
   (0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
  (0%Z <= s)%Z ->
  (((0%Z <= i)%Z /\ (i < s)%Z) -> (((value (make_bv f s)) i) = (f i))) /\
  (~ ((0%Z <= i)%Z /\ (i < s)%Z) -> (((value (make_bv f s)) i) = 0%Z)).

Axiom assert_make_m :
  forall (f:Z -> Z) (s:Z) (i:Z), (0%Z <= s)%Z ->
  (((0%Z <= i)%Z /\ (i < s)%Z) ->
   (((value (make_bv_m f s)) i) = (int.EuclideanDivision.mod1 (f i) 2%Z))) /\
  (~ ((0%Z <= i)%Z /\ (i < s)%Z) -> (((value (make_bv_m f s)) i) = 0%Z)).

Axiom assert_make_bv_b :
  forall (f:Z -> Z) (s:Z) (i:Z),
  (forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
   (0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
  ((0%Z <= i)%Z /\ (i < s)%Z) -> (((value (make_bv f s)) i) = (f i)).

Axiom assert_make_m_b :
  forall (f:Z -> Z) (s:Z) (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
  (0%Z <= s)%Z ->
  (((value (make_bv_m f s)) i) = (int.EuclideanDivision.mod1 (f i) 2%Z)).

Axiom make_m_bv_length :
  forall (f:Z -> Z) (s:Z) (i:Z), (0%Z <= s)%Z ->
  bvlength (value (make_bv_m f s)) i.

Axiom make_m_length :
  forall (f:Z -> Z) (s:Z), (0%Z <= s)%Z -> ((length (make_bv_m f s)) = s).

Axiom set_equal_bv_make :
  forall (f:Z -> Z) (g:Z -> Z) (s:Z),
  (forall (i:Z), (0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) -> (0%Z <= s)%Z ->
  (forall (i:Z), ((f i) = (g i))) -> ((make_bv f s) = (make_bv g s)).

Axiom set_equal_bv_m_make :
  forall (f:Z -> Z) (g:Z -> Z) (s:Z), (0%Z <= s)%Z ->
  (forall (i:Z),
   ((int.EuclideanDivision.mod1 (f i) 2%Z) =
    (int.EuclideanDivision.mod1 (g i) 2%Z))) ->
  ((make_bv_m f s) = (make_bv_m g s)).

Parameter head: bitvec -> Z.

Axiom head_def :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((head bv) = ((value bv) 0%Z)).

Axiom head_spec :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  (0%Z <= (head bv))%Z /\ ((head bv) <= 1%Z)%Z.

Parameter tail: bitvec -> bitvec.

Axiom tail_def :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((tail bv) =
   (make_bv (fun (i:Z) => ((value bv) (i + 1%Z)%Z)) ((length bv) - 1%Z)%Z)).

Axiom tail_spec :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((length (tail bv)) = ((length bv) - 1%Z)%Z) /\
  forall (i:Z), (in_range (tail bv) i) ->
  (((value (tail bv)) i) = ((value bv) (i + 1%Z)%Z)).

Parameter concat_l: bitvec -> Z -> bitvec.

Parameter result8: bitvec -> Z -> Z -> Z.

Axiom result_def8 :
  forall (bv:bitvec) (i:Z) (k:Z),
  ((k = 0%Z) -> (((result8 bv i) k) = i)) /\
  (~ (k = 0%Z) -> (((result8 bv i) k) = ((value bv) (k - 1%Z)%Z))).

Axiom concat_l_def :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
  ((concat_l bv i) = (make_bv (result8 bv i) ((length bv) + 1%Z)%Z)).

Axiom concat_l_spec :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
  ((length (concat_l bv i)) = ((length bv) + 1%Z)%Z) /\
  ((((value (concat_l bv i)) 0%Z) = i) /\
   forall (j:Z), (in_range bv j) ->
   (((value (concat_l bv i)) (j + 1%Z)%Z) = ((value bv) j))).

Axiom concat_l_value :
  forall (bv:bitvec) (i:Z) (k:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
  ((k = 0%Z) -> (((value (concat_l bv i)) k) = i)) /\
  (~ (k = 0%Z) ->
   (((0%Z < k)%Z /\ (k <= ((length bv) + 1%Z)%Z)%Z) ->
    (((value (concat_l bv i)) k) = ((value bv) (k - 1%Z)%Z))) /\
   (~ ((0%Z < k)%Z /\ (k <= ((length bv) + 1%Z)%Z)%Z) ->
    (((value (concat_l bv i)) k) = 0%Z))).

Axiom concat_l_value_b :
  forall (bv:bitvec) (i:Z) (k:Z),
  ((0%Z <= k)%Z /\ (k < ((length bv) + 1%Z)%Z)%Z) ->
  ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
  ((k = 0%Z) -> (((value (concat_l bv i)) k) = i)) /\
  (~ (k = 0%Z) -> (((value (concat_l bv i)) k) = ((value bv) (k - 1%Z)%Z))).

Axiom concat_ht :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  (bv = (concat_l (tail bv) (head bv))).

Axiom concat_ht_union :
  forall (bv:bitvec), (2%Z <= (length bv))%Z ->
  ~ (bv = (concat_l (tail bv) 0%Z)) -> (bv = (concat_l (tail bv) 1%Z)).

Parameter result9: bitvec -> Z -> Z.

Axiom result_def9 :
  forall (bv:bitvec) (k:Z),
  ((in_range bv k) ->
   (((result9 bv) k) =
    (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)) /\
  (~ (in_range bv k) -> (((result9 bv) k) = 1%Z)).

(* Why3 assumption *)
Definition bv_to_int (bv:bitvec) : Z :=
  ind_isum (result9 bv) 0%Z (length bv).

Axiom bv_to_int_spec :
  forall (bv:bitvec),
  ((bv_to_int bv) =
   (ind_isum
    (fun (k:Z) =>
     (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
    0%Z (length bv))) /\
  (0%Z <= (bv_to_int bv))%Z.

Axiom bv_to_int_eq :
  forall (bv1:bitvec) (bv2:bitvec), (bv1 = bv2) ->
  ((bv_to_int bv1) = (bv_to_int bv2)).

Axiom bv_to_int_sum :
  forall (bv:bitvec),
  ((bv_to_int bv) =
   (ind_isum
    (fun (k:Z) =>
     (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
    0%Z (length bv))).

Axiom bv_to_int_onebit :
  forall (bv:bitvec), ((length bv) = 1%Z) ->
  ((bv_to_int bv) = ((value bv) 0%Z)).

Axiom ind_isum_bv_rev :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= (length bv))%Z) ->
  ((ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    i (length bv))
   =
   (ind_isum
    (fun (l:Z) =>
     (((value bv) (((length bv) - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z)
    0%Z ((length bv) - i)%Z)).

Axiom ind_isum_bin_rev :
  forall (f:Z -> Z) (n:Z) (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> (binary f) ->
  ((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) i n)
   =
   (ind_isum (fun (l:Z) => ((f ((n - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z) 0%Z
    (n - i)%Z)).

Axiom ind_isum_bin_rev_z :
  forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
  ((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) 0%Z
    n)
   =
   (ind_isum (fun (l:Z) => ((f ((n - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z) 0%Z
    n)).

Axiom bv_to_int_sum_rev :
  forall (bv:bitvec),
  ((ind_isum
    (fun (k:Z) =>
     (((value bv) (((length bv) - 1%Z)%Z - k)%Z) * (power 2%Z k))%Z)
    0%Z (length bv))
   = (bv_to_int bv)).

Axiom ind_isum_bv_bound_growing :
  forall (bv:bitvec) (i:Z), ((0%Z < i)%Z /\ (i < (length bv))%Z) ->
  ((ind_isum (fun (l:Z) => (((value bv) l) * (power 2%Z l))%Z) 0%Z i) <
   (power 2%Z i))%Z.

Axiom ind_isum_bv_bound :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  ((ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    i (length bv))
   < (power 2%Z ((length bv) - i)%Z))%Z.

Axiom ind_isum_bin_bound :
  forall (f:Z -> Z) (n:Z) (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> (binary f) ->
  ((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) i n)
   < (power 2%Z (n - i)%Z))%Z.

Axiom bv_to_int_bound :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((bv_to_int bv) < (power 2%Z (length bv)))%Z.

Axiom abs_eqinf :
  forall (x:Z) (y:Z), ((x <= y)%Z /\ (y <= 0%Z)%Z) ->
  ((ZArith.BinInt.Z.abs y) <= (ZArith.BinInt.Z.abs x))%Z.

Axiom abs_inf :
  forall (x:Z) (y:Z), ((0%Z < x)%Z /\ ((x < y)%Z /\ (y <= 0%Z)%Z)) ->
  ((ZArith.BinInt.Z.abs y) < (ZArith.BinInt.Z.abs x))%Z.

Axiom abs_eqsup :
  forall (x:Z) (y:Z), ((x <= 0%Z)%Z /\ (y <= x)%Z) ->
  ((ZArith.BinInt.Z.abs x) <= (ZArith.BinInt.Z.abs y))%Z.

Axiom abs_sup :
  forall (x:Z) (y:Z), ((x <= 0%Z)%Z /\ (y < x)%Z) ->
  ((ZArith.BinInt.Z.abs x) < (ZArith.BinInt.Z.abs y))%Z.

Axiom inv_negeq :
  forall (x:Z), (x <= 0%Z)%Z -> (0%Z <= (ZArith.BinInt.Z.abs x))%Z.

Axiom inv_neg1 :
  forall (x:Z), (x < 0%Z)%Z -> (0%Z < (ZArith.BinInt.Z.abs x))%Z.

Parameter cpower: t -> Z -> t.

Axiom Cpower_zero : forall (i:t), ((cpower i 0%Z) = tone).

Axiom Cpower_one : forall (i:t), ((cpower i 1%Z) = i).

Axiom Cpower_sum :
  forall (i:t), forall (n:Z) (m:Z), ((i = tzero) -> ~ (n = (-m)%Z)) ->
  ((cpower i (n + m)%Z) = (infix_asdt (cpower i n) (cpower i m))).

Axiom zero_poower : forall (e:Z), ~ (e = 0%Z) -> ((cpower tzero e) = tzero).

Parameter squarert_two: t.

Axiom real_squarert_two : real_ squarert_two.

Axiom squarertTwo : ((cpower squarert_two 2%Z) = (infix_pldt tone tone)).

Axiom complete_rt_two :
  forall (a:t), (a = (infix_sldt squarert_two (infix_pldt tone tone))) ->
  ((infix_asdt squarert_two a) = tone).

Axiom cpower_sum :
  forall (x:t) (n:Z) (m:Z), ((x = tzero) -> ~ (n = (-m)%Z)) ->
  ((cpower x (n + m)%Z) = (infix_asdt (cpower x n) (cpower x m))).

Axiom cpower_one : forall (x:t) (n:Z), (n = 1%Z) -> ((cpower x n) = x).

Axiom cpower_sum_rev :
  forall (x:t) (n:Z) (m:Z), ((x = tzero) -> ~ (n = (-m)%Z)) ->
  ((infix_asdt (cpower x n) (cpower x m)) = (cpower x (n + m)%Z)).

Axiom cpower_plus_one :
  forall (e:t) (i:Z), ((e = tzero) -> ~ (i = (-1%Z)%Z)) ->
  ((cpower e (i + 1%Z)%Z) = (infix_asdt (cpower e i) e)).

Axiom cpower_zero : forall (e:t), ((cpower e 0%Z) = tone).

Axiom cpower_inv :
  forall (e:t) (i:Z), ~ (e = tzero) ->
  ((infix_asdt (cpower e i) (cpower e (-i)%Z)) = tone).

Axiom cpower_inv_rew :
  forall (e:t) (i:Z), ~ (e = tzero) ->
  ((cpower e i) = (infix_sldt tone (cpower e (-i)%Z))).

Axiom inv_cpower :
  forall (e:t) (i:Z), ~ ((cpower e i) = tzero) ->
  ((infix_sldt tone (cpower e i)) = (cpower e (-i)%Z)).

Axiom cpower_tone_pos :
  forall (m:Z), (0%Z <= m)%Z -> ((cpower tone m) = tone).

Axiom cpower_iterate :
  forall (e:t) (i:Z), (0%Z <= i)%Z ->
  ((cpower e i) =
   (int_iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1))
    ((fun (y0:t) (y1:Z) => y0) e) 0%Z i)).

Axiom cpower_mult_pre :
  forall (x:t) (n:Z) (m:Z), (0%Z <= m)%Z ->
  ((cpower x (n * m)%Z) = (cpower (cpower x n) m)).

Axiom cpower_mult :
  forall (x:t) (n:Z) (m:Z), ((cpower x (n * m)%Z) = (cpower (cpower x n) m)).

Axiom non_zero_cpower_pos :
  forall (i:t) (n:Z), ~ (i = tzero) -> (0%Z <= n)%Z ->
  ~ ((cpower i n) = tzero).

Axiom inv_cpower_ :
  forall (e:t) (i:Z), ~ (e = tzero) ->
  ((infix_sldt tone (cpower e i)) = (cpower e (-i)%Z)).

Axiom zero_cpower_pos :
  forall (n:Z), (0%Z < n)%Z -> ((cpower tzero n) = tzero).

Axiom zero_cpower : forall (n:Z), ~ (n = 0%Z) -> ((cpower tzero n) = tzero).

Axiom non_zero_cpower :
  forall (i:t) (n:Z), ~ (i = tzero) -> ~ ((cpower i n) = tzero).

Axiom real_cpower_pos :
  forall (elt:t) (i:Z), (real_ elt) -> (0%Z <= i)%Z -> real_ (cpower elt i).

Axiom real_cpower :
  forall (elt:t) (i:Z), (real_ elt) -> real_ (cpower elt i).

Axiom pre_cond_int_ :
  forall (a:t) (b:t) (c:t), (infix_lsdt a b) -> (infix_lsdt tzero c) ->
  infix_lsdt (infix_asdt a c) (infix_asdt b c).

Axiom growing_mult1 :
  forall (n:t) (m:t), (infix_lseqdt tzero n) -> (infix_lseqdt tone m) ->
  infix_lseqdt n (infix_asdt n m).

Axiom strict_growing_mult_pos :
  forall (n:t) (m:t), (infix_lsdt tone n) -> (infix_lsdt tone m) ->
  infix_lsdt n (infix_asdt n m).

Axiom init_exp1 :
  forall (k:t),
  ((cpower k 0%Z) = tone) /\
  (((cpower k 1%Z) = k) /\ ((cpower k 2%Z) = (infix_asdt k k))).

Axiom int_exp_pos :
  forall (k:t) (n:Z), (infix_lseqdt tone k) -> (0%Z <= n)%Z ->
  (infix_gteqdt (cpower k n) tone) /\
  ((infix_gtdt (cpower k n) tzero) /\
   (infix_lseqdt (cpower k n) (cpower k (n + 1%Z)%Z))).

Axiom strict_int_exp_pos :
  forall (k:t) (n:Z), (infix_lsdt tone k) -> (0%Z < n)%Z ->
  (infix_gtdt (cpower k n) tone) /\
  ((infix_lsdt (cpower k (n - 1%Z)%Z) (cpower k n)) /\
   (infix_lsdt (cpower k n) (cpower k (n + 1%Z)%Z))).

Axiom strict_int_exp_neg :
  forall (k:t) (n:Z), (infix_lsdt tone k) -> (n < 0%Z)%Z ->
  (infix_lsdt (cpower k n) tone) /\
  ((infix_lsdt (cpower k (n - 1%Z)%Z) (cpower k n)) /\
   (infix_lsdt (cpower k n) (cpower k (n + 1%Z)%Z))).

Axiom int_exp_neg :
  forall (k:t) (n:Z), (infix_lseqdt tone k) -> (n < 0%Z)%Z ->
  (infix_lseqdt (cpower k n) tone) /\
  ((infix_gtdt (cpower k n) tzero) /\
   (infix_lseqdt (cpower k n) (cpower k (n + 1%Z)%Z))).

Axiom positive_exp :
  forall (k:t) (m:Z), (infix_lseqdt tone k) -> infix_lsdt tzero (cpower k m).

Axiom growing_exp_pos :
  forall (k:t) (m:Z) (n:Z), (infix_lseqdt tone k) ->
  ((0%Z <= m)%Z /\ (m <= n)%Z) -> infix_lseqdt (cpower k m) (cpower k n).

Axiom growing_exp1 :
  forall (k:t) (m:Z) (n:Z), (infix_lseqdt tone k) -> (m <= n)%Z ->
  infix_lseqdt (cpower k m) (cpower k n).

Axiom strict_growing_exp1 :
  forall (k:t) (m:Z) (n:Z), (infix_lsdt tone k) -> (m < n)%Z ->
  infix_lsdt (cpower k m) (cpower k n).

Axiom cpower_comm_pos :
  forall (x:t) (y:t) (n:Z), (infix_lseqdt tone x) -> (infix_lseqdt tone y) ->
  (0%Z <= n)%Z ->
  ((cpower (infix_asdt x y) n) = (infix_asdt (cpower x n) (cpower y n))).

Axiom cpower_comm :
  forall (x:t) (y:t) (n:Z), (infix_lseqdt tone x) -> (infix_lseqdt tone y) ->
  ((cpower (infix_asdt x y) n) = (infix_asdt (cpower x n) (cpower y n))).

Axiom unicity_exp1 :
  forall (k:t) (m:Z) (n:Z), (infix_lsdt tone k) ->
  ((cpower k m) = (cpower k n)) <-> (m = n).

Parameter exp: t -> t.

Axiom e_diff_tzero : forall (x:t), ~ ((exp x) = tzero).

Axiom Exp_one : real_ (exp tone).

Axiom Exp_zero : ((exp tzero) = tone).

Axiom Exp_sum :
  forall (x:t) (y:t), ((exp (infix_pldt x y)) = (infix_asdt (exp x) (exp y))).

Axiom exp_one : real_ (exp tone).

Axiom exp_sum :
  forall (x:t) (y:t), ((exp (infix_pldt x y)) = (infix_asdt (exp x) (exp y))).

Axiom exp_eq : forall (t1:t) (t2:t), (t1 = t2) -> ((exp t1) = (exp t2)).

Axiom exp_sum_rev :
  forall (x:t) (y:t), ((infix_asdt (exp x) (exp y)) = (exp (infix_pldt x y))).

Axiom exp_inv :
  forall (i:t), ~ ((exp i) = tzero) ->
  ((exp (prefix_mndt i)) = (infix_sldt tone (exp i))).

Axiom exp_inv_rev :
  forall (i:t), ~ ((exp i) = tzero) ->
  ((infix_sldt tone (exp i)) = (exp (prefix_mndt i))).

Axiom exp_mult_pre :
  forall (x:t) (y:Z), (0%Z <= y)%Z ->
  ((exp (infix_asdt x (i_to_t y))) = (cpower (exp x) y)).

Axiom exp_mult :
  forall (x:t) (y:Z), ((exp (infix_asdt x (i_to_t y))) = (cpower (exp x) y)).

Axiom cpower_to_exp :
  forall (x:t) (y:Z), ((cpower (exp x) y) = (exp (infix_asdt x (i_to_t y)))).

Axiom Exp_quarter_pi :
  ((exp (infix_sldt (infix_asdt im pi) (i_to_t 4%Z))) =
   (infix_pldt (infix_sldt squarert_two (infix_pldt tone tone))
    (infix_asdt im (infix_sldt squarert_two (infix_pldt tone tone))))).

Axiom exp_h_pi :
  ((exp (infix_sldt (infix_asdt im pi) (infix_pldt tone tone))) = im).

Axiom exp_pi : ((exp (infix_asdt im pi)) = (prefix_mndt tone)).

Axiom exp_two_pi :
  ((exp (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))) = tone).

Axiom exp_two_pi_mul :
  forall (k:Z),
  ((exp
    (infix_asdt (i_to_t k)
     (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))))
   = tone).

Axiom exp_two_pi_mul_den :
  forall (k:Z) (l:Z), ~ (k = 0%Z) ->
  ((exp
    (infix_sldt
     (infix_asdt (i_to_t (k * l)%Z)
      (infix_asdt (infix_asdt im pi) (infix_pldt tone tone)))
     (i_to_t k)))
   = tone).

Axiom exp_two_pi_mul_den_add :
  forall (k:Z) (l:Z) (m:Z),
  ((exp
    (infix_asdt (i_to_t ((k * m)%Z + l)%Z)
     (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))))
   =
   (exp
    (infix_asdt (i_to_t l)
     (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))))).

Axiom comp_exp_cpower :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  ((cpower (exp (i_to_t i)) j) = (cpower (exp tone) (i * j)%Z)) /\
  ((cpower (exp (i_to_t i)) j) = (exp (i_to_t (i * j)%Z))).

Parameter unity_rt: Z -> t.

Axiom unity_rt_def :
  forall (n:Z), (0%Z < n)%Z ->
  ((unity_rt n) =
   (exp
    (infix_sldt (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))
     (i_to_t n)))).

Axiom unity_rt_spec :
  forall (n:Z), (0%Z < n)%Z ->
  ((cpower (unity_rt n) n) = tone) /\ ~ ((unity_rt n) = tzero).

Axiom exp_mod :
  forall (k:Z) (n:Z), (0%Z < n)%Z ->
  ((exp
    (infix_sldt
     (infix_asdt (i_to_t k)
      (infix_asdt (infix_asdt im pi) (infix_pldt tone tone)))
     (i_to_t n)))
   =
   (exp
    (infix_sldt
     (infix_asdt (i_to_t (int.EuclideanDivision.mod1 k n))
      (infix_asdt (infix_asdt im pi) (infix_pldt tone tone)))
     (i_to_t n)))).

Parameter p_unity: Z -> Z -> t.

Axiom p_unity_def :
  forall (n:Z) (k:Z), (0%Z < n)%Z ->
  ((p_unity n k) = (cpower (unity_rt n) k)).

Axiom p_unity_mod :
  forall (n:Z) (k:Z), (0%Z < n)%Z ->
  ((p_unity n k) = (p_unity n (int.EuclideanDivision.mod1 k n))).

Axiom cpower_mod :
  forall (n:Z) (k:Z), (0%Z < n)%Z ->
  ((cpower (unity_rt n) k) =
   (cpower (unity_rt n) (int.EuclideanDivision.mod1 k n))).

Axiom p_unity_sum :
  forall (n:Z) (k:Z) (k':Z), (0%Z < n)%Z ->
  ((p_unity n (k + k')%Z) = (infix_asdt (p_unity n k) (p_unity n k'))).

Axiom exp_p_unity :
  forall (n:Z) (k:Z), (0%Z < n)%Z ->
  ((p_unity n k) =
   (exp
    (infix_sldt
     (infix_asdt (i_to_t (int.EuclideanDivision.mod1 k n))
      (infix_asdt (infix_asdt im pi) (infix_pldt tone tone)))
     (i_to_t n)))).

Axiom unity_rt_trans :
  forall (n:Z) (k:Z), (0%Z < n)%Z -> (0%Z < k)%Z ->
  ((unity_rt n) = (cpower (unity_rt (n * k)%Z) k)).

Axiom unity_rt_two : ((unity_rt 2%Z) = (prefix_mndt tone)).

Axiom p_unity_neut :
  forall (n:Z) (k:Z), (0%Z < n)%Z -> (0%Z <= k)%Z ->
  ((p_unity n (n * k)%Z) = tone).

Parameter omega: Z -> t.

Axiom omega_def :
  forall (n:Z), (0%Z <= n)%Z -> ((omega n) = (unity_rt (power 2%Z n))).

Parameter p_omega: Z -> Z -> t.

Axiom p_omega_def :
  forall (n:Z) (k:Z), (0%Z <= n)%Z -> ((p_omega n k) = (cpower (omega n) k)).

Axiom p_omega_spec :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) = (p_unity (power 2%Z n) k)).

Axiom p_omega_to_omega :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) =
   (cpower (omega n) (int.EuclideanDivision.mod1 k (power 2%Z n)))).

Axiom p_omega_eq :
  forall (n:Z) (k:Z) (k':Z), (0%Z <= n)%Z -> (k = k') ->
  ((p_omega n k) = (p_omega n k')).

Axiom p_omega_eq_gen :
  forall (n:Z) (n':Z) (k:Z) (k':Z), (0%Z <= n)%Z -> (k = k') -> (n = n') ->
  ((p_omega n k) = (p_omega n' k')).

Axiom p_omega_unity :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) = (p_unity (power 2%Z n) k)).

Axiom p_unity_omega :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_unity (power 2%Z n) k) = (p_omega n k)).

Axiom exp_omega :
  forall (n:Z), (0%Z <= n)%Z ->
  ((omega n) =
   (exp
    (infix_sldt (infix_asdt (infix_asdt im pi) (infix_pldt tone tone))
     (i_to_t (power 2%Z n))))).

Axiom exp_p_omega :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) =
   (exp
    (infix_sldt
     (infix_asdt (i_to_t k)
      (infix_asdt (infix_asdt im pi) (infix_pldt tone tone)))
     (i_to_t (power 2%Z n))))).

Axiom p_omega_sum :
  forall (n:Z) (k:Z) (k':Z), (0%Z <= n)%Z ->
  ((p_omega n (k + k')%Z) = (infix_asdt (p_omega n k) (p_omega n k'))).

Axiom p_omega_sum_rev :
  forall (n:Z) (k:Z) (k':Z), (0%Z <= n)%Z ->
  ((infix_asdt (p_omega n k) (p_omega n k')) = (p_omega n (k + k')%Z)).

Axiom p_omega_sum_gen :
  forall (n:Z) (n':Z) (k:Z) (k':Z), (0%Z <= n)%Z -> (n = n') ->
  ((p_omega n (k + k')%Z) = (infix_asdt (p_omega n k) (p_omega n' k'))).

Axiom p_omega_sum_rev_gen :
  forall (n:Z) (n':Z) (k:Z) (k':Z), (0%Z <= n)%Z -> (n = n') ->
  ((infix_asdt (p_omega n k) (p_omega n' k')) = (p_omega n (k + k')%Z)).

Axiom p_omega_neut :
  forall (n:Z) (k:Z), (0%Z <= n)%Z -> (0%Z <= k)%Z ->
  ((p_omega n ((power 2%Z n) * k)%Z) = tone).

Axiom p_omega_neut_one :
  forall (n:Z) (k:Z), (0%Z <= n)%Z -> (0%Z <= k)%Z ->
  ((p_omega n (power 2%Z n)) = tone).

Axiom p_omega_mod :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) = (p_omega n (int.EuclideanDivision.mod1 k (power 2%Z n)))).

Axiom p_omega_mod_rest :
  forall (n:Z) (k:Z) (i:Z), (0%Z <= n)%Z ->
  ((p_omega n ((k * (power 2%Z n))%Z + i)%Z) = (p_omega n i)).

Axiom omega_transl :
  forall (n:Z) (n':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z -> (n <= n')%Z ->
  ((omega n) = (p_omega n' (power 2%Z (n' - n)%Z))).

Axiom p_omega_transl :
  forall (n:Z) (n':Z) (k:Z), (0%Z <= n)%Z -> (0%Z <= n')%Z -> (n <= n')%Z ->
  ((p_omega n k) = (p_omega n' (k * (power 2%Z (n' - n)%Z))%Z)).

Axiom p_omega_plus_one :
  forall (n:Z) (k:Z), (0%Z <= n)%Z ->
  ((p_omega n k) = (p_omega (n + 1%Z)%Z (k * 2%Z)%Z)).

Axiom p_omega_minus_one :
  forall (n:Z) (k:Z), (0%Z < n)%Z ->
  ((p_omega n k) = (p_omega (n + 1%Z)%Z (k * 2%Z)%Z)).

Axiom p_omega_rt_two :
  forall (n:Z), (0%Z < n)%Z ->
  ((p_omega n (power 2%Z (n - 1%Z)%Z)) = (prefix_mndt tone)).

Axiom p_omega_sum_units :
  forall (n:Z) (n':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z -> (n <= n')%Z ->
  ((infix_asdt (omega n) (omega n')) =
   (p_omega n' (1%Z + (power 2%Z (n' - n)%Z))%Z)).

Axiom p_omega_add_ord :
  forall (n:Z) (k:Z) (n':Z) (k':Z), ((n <= n')%Z /\ (0%Z <= n)%Z) ->
  ((infix_asdt (p_omega n k) (p_omega n' k')) =
   (p_omega n' (k' + (k * (power 2%Z (n' - n)%Z))%Z)%Z)).

Axiom p_omega_add :
  forall (n:Z) (k:Z) (n':Z) (k':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z ->
  ((n' <= n)%Z ->
   ((infix_asdt (p_omega n k) (p_omega n' k')) =
    (p_omega n (k + (k' * (power 2%Z (n - n')%Z))%Z)%Z))) /\
  (~ (n' <= n)%Z ->
   ((infix_asdt (p_omega n k) (p_omega n' k')) =
    (p_omega n' (k' + (k * (power 2%Z (n' - n)%Z))%Z)%Z))).

Axiom p_omega_equiv :
  forall (n:Z) (k:Z) (a:Z), (0%Z <= n)%Z ->
  ((p_omega n k) = (p_omega n (k + (a * (power 2%Z n))%Z)%Z)).

Axiom p_omega_equiv_rev :
  forall (n:Z) (k:Z) (a:Z), (0%Z <= n)%Z ->
  ((p_omega n (k + ((power 2%Z n) * a)%Z)%Z) = (p_omega n k)).

Axiom omega_sum_to_prod :
  forall {a:Type} {a_WT:WhyType a},
  forall (n:Z) (f:a -> Z) (s:set a), (0%Z <= n)%Z ->
  ((p_omega n (isum s f)) = (product s (fun (k:a) => (p_omega n (f k))))).

Parameter fc6: Z -> (Z -> Z) -> Z -> Z -> Z -> t.

Axiom fc_def6 :
  forall (n:Z) (f:Z -> Z) (i:Z) (j:Z) (k:Z),
  (((i <= k)%Z /\ (k < j)%Z) -> (((fc6 n f i j) k) = (p_omega n (f k)))) /\
  (~ ((i <= k)%Z /\ (k < j)%Z) -> (((fc6 n f i j) k) = tone)).

Axiom omega_ind_sum_to_prod :
  forall (n:Z) (f:Z -> Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (0%Z <= n)%Z ->
  ((p_omega n (ind_isum f i j)) = (ind_product (fc6 n f i j) i j)).

Parameter cos: t -> t.

Axiom cos_spec :
  forall (x:t), (real_ x) ->
  (real_ (cos x)) /\
  ((infix_lseqdt (prefix_mndt tone) (cos x)) /\ (infix_lseqdt (cos x) tone)).

Parameter sin: t -> t.

Axiom sin_spec :
  forall (x:t), (real_ x) ->
  (real_ (sin x)) /\
  ((infix_lseqdt (prefix_mndt tone) (sin x)) /\ (infix_lseqdt (sin x) tone)).

Axiom euler_real_r :
  forall (x:t), (real_ x) ->
  ((cos x) = (r_to_t (real_part (exp (infix_asdt im x))))).

Axiom euler_im_r :
  forall (x:t), (real_ x) ->
  ((sin x) = (r_to_t (im_part (exp (infix_asdt im x))))).

Axiom cos_zero : ((cos tzero) = tone).

Axiom cos_half_pi : ((cos (infix_sldt pi (infix_pldt tone tone))) = tzero).

Axiom cos_quarter_pi :
  ((cos (infix_sldt pi (i_to_t 4%Z))) =
   (infix_sldt squarert_two (infix_pldt tone tone))).

Axiom cos_pi : ((cos pi) = (prefix_mndt tone)).

Axiom euler_real :
  forall (x:t), (real_ x) ->
  ((cos x) = (t_real_part (exp (infix_asdt im x)))).

Axiom euler_im :
  forall (x:t), (real_ x) -> ((sin x) = (t_im_part (exp (infix_asdt im x)))).

Axiom d_frac : Type.
Parameter d_frac_WhyType : WhyType d_frac.
Existing Instance d_frac_WhyType.

Parameter value1: d_frac -> t.

Axiom d_frac'invariant : forall (self:d_frac), ~ ((value1 self) = tzero).

Axiom equal_d_frac :
  forall (d:d_frac) (d':d_frac), (d = d') <-> ((value1 d) = (value1 d')).

Parameter dyadic: Z -> Z -> d_frac.

Axiom dyadic_spec :
  forall (k:Z) (n:Z), (0%Z <= n)%Z -> ((value1 (dyadic k n)) = (p_omega n k)).

Parameter add1: d_frac -> d_frac -> d_frac.

Axiom add_spec1 :
  forall (d:d_frac) (d':d_frac),
  ((value1 (add1 d d')) = (infix_asdt (value1 d) (value1 d'))).

Parameter inv1: d_frac -> d_frac.

Axiom inv_spec :
  forall (d:d_frac), ((value1 (inv1 d)) = (infix_sldt tone (value1 d))).

Axiom dyadic_inv :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((inv1 (dyadic k n)) = (dyadic (-k)%Z n)).

Parameter div_two: d_frac -> d_frac.

Axiom div_two_spec :
  forall (d:d_frac),
  ((cpower (value1 (div_two d)) 2%Z) = (value1 d)) /\
  forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
  (0%Z <= n)%Z -> (d = (dyadic k n)) ->
  ((div_two d) = (dyadic k (n + 1%Z)%Z)).

Axiom value_zero : ((value1 (dyadic 0%Z 0%Z)) = tone).

Axiom value_eq :
  forall (o:d_frac) (o':d_frac), (o = o') -> ((value1 o) = (value1 o')).

Parameter d_mult_int: d_frac -> Z -> d_frac.

Axiom d_mult_int_spec :
  forall (d:d_frac) (i:Z),
  ((value1 (d_mult_int d i)) = (cpower (value1 d) i)).

Parameter phase_inv_pre: Z -> d_frac -> d_frac.

Axiom phase_inv_pre_def :
  forall (i:Z) (d:d_frac), (0%Z <= i)%Z ->
  ((i = 0%Z) -> ((phase_inv_pre i d) = d)) /\
  (~ (i = 0%Z) ->
   ((phase_inv_pre i d) = (inv1 (phase_inv_pre (i - 1%Z)%Z d)))).

Axiom phase_inv_pre_spec :
  forall (i:Z) (d:d_frac), (0%Z <= i)%Z ->
  (((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((phase_inv_pre i d) = d)) /\
  ((((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
    ((phase_inv_pre i d) = (inv1 d))) /\
   forall (k:Z) (n:Z), (0%Z <= n)%Z -> (d = (dyadic k n)) ->
   ((phase_inv_pre i d) = (dyadic ((power (-1%Z)%Z i) * k)%Z n))).

Parameter phase_inv: Z -> d_frac -> d_frac.

Axiom phase_inv_def :
  forall (i:Z) (d:d_frac),
  ((0%Z <= i)%Z -> ((phase_inv i d) = (phase_inv_pre i d))) /\
  (~ (0%Z <= i)%Z -> ((phase_inv i d) = (phase_inv_pre (-i)%Z d))).

Axiom phase_inv_spec :
  forall (i:Z) (d:d_frac),
  (((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((phase_inv i d) = d)) /\
  ((((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
    ((phase_inv i d) = (inv1 d))) /\
   ((forall (k:Z) (n:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
     (d = (dyadic k n)) ->
     ((phase_inv i d) = (dyadic ((power (-1%Z)%Z i) * k)%Z n))) /\
    forall (k:Z) (n:Z), (0%Z <= n)%Z -> (i < 0%Z)%Z -> (d = (dyadic k n)) ->
    ((phase_inv i d) = (dyadic ((power (-1%Z)%Z (-i)%Z) * k)%Z n)))).

(* Why3 assumption *)
Definition k_dyadic (i:Z) : d_frac := dyadic 1%Z (ZArith.BinInt.Z.abs i).

Axiom k_dyadic_spec :
  forall (i:Z), (0%Z <= i)%Z -> ((k_dyadic i) = (dyadic 1%Z i)).

Parameter d_sum: (Z -> d_frac) -> Z -> Z -> d_frac.

Axiom d_sum_def :
  forall (f:Z -> d_frac) (i:Z) (j:Z),
  ((j <= i)%Z -> ((d_sum f i j) = (dyadic 0%Z 0%Z))) /\
  (~ (j <= i)%Z ->
   ((d_sum f i j) =
    (int_iterate (fun (y0:d_frac) (y1:d_frac) => (add1 y0 y1)) f i j))).

Axiom Assoc2 :
  forall (x:d_frac) (y:d_frac) (z:d_frac),
  ((add1 (add1 x y) z) = (add1 x (add1 y z))).

Axiom Unit_def_l1 : forall (x:d_frac), ((add1 (dyadic 0%Z 0%Z) x) = x).

Axiom Unit_def_r1 : forall (x:d_frac), ((add1 x (dyadic 0%Z 0%Z)) = x).

Axiom Inv_def_l1 : forall (x:d_frac), ((add1 (inv1 x) x) = (dyadic 0%Z 0%Z)).

Axiom Inv_def_r1 : forall (x:d_frac), ((add1 x (inv1 x)) = (dyadic 0%Z 0%Z)).

Axiom Comm2 : forall (x:d_frac) (y:d_frac), ((add1 x y) = (add1 y x)).

Axiom Dyadic_inv :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((add1 (dyadic k n) (dyadic (-k)%Z n)) = (dyadic 0%Z 0%Z)).

Axiom Dyadic_add :
  forall (k:Z) (k':Z) (n:Z), (0%Z <= n)%Z ->
  ((add1 (dyadic k n) (dyadic k' n)) = (dyadic (k + k')%Z n)).

Axiom Dyadic_up :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic k n) = (dyadic (2%Z * k)%Z (n + 1%Z)%Z)).

Axiom Dyadic_cyclic :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic k n) = (dyadic (k + (power 2%Z n))%Z n)).

Axiom Zero_n :
  forall (n:Z), (0%Z <= n)%Z -> ((dyadic 0%Z n) = (dyadic 0%Z 0%Z)).

Axiom D_mult :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((d_mult_int (dyadic k n) i) = (dyadic (k * i)%Z n)).

Axiom Dyadic_value :
  forall (k:Z) (n:Z), (0%Z <= n)%Z -> ((value1 (dyadic k n)) = (p_omega n k)).

Axiom Dyadic_zero_n :
  forall (k:Z) (n:Z), (n = 0%Z) -> ((dyadic k n) = (dyadic 0%Z 0%Z)).

Axiom Dyadic_zero_k :
  forall (k:Z) (n:Z), (0%Z <= n)%Z -> (k = 0%Z) ->
  ((dyadic k n) = (dyadic 0%Z 0%Z)).

Axiom value_zero_ : ((value1 (dyadic 0%Z 0%Z)) = tone).

Axiom Div_two_dyadic :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
  ((div_two (dyadic k n)) = (dyadic k (n + 1%Z)%Z)).

Axiom Div_two : forall (d:d_frac), ((add1 (div_two d) (div_two d)) = d).

Axiom K_dyadic :
  forall (k:Z), (0%Z <= k)%Z -> ((k_dyadic k) = (dyadic 1%Z k)).

Axiom K_dyadic_plus_one :
  forall (k:Z), (0%Z < k)%Z ->
  ((add1 (k_dyadic k) (k_dyadic k)) = (k_dyadic (k - 1%Z)%Z)).

Axiom Even_phase_inv :
  forall (d:d_frac), forall (i:Z),
  ((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((phase_inv i d) = d).

Axiom Odd_phase_inv :
  forall (d:d_frac), forall (i:Z),
  ((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) -> ((phase_inv i d) = (inv1 d)).

Axiom Gen_phase_inv :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((phase_inv i (dyadic k n)) = (dyadic ((power (-1%Z)%Z i) * k)%Z n)).

Axiom Gen_phase_inv_neg :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (i < 0%Z)%Z ->
  ((phase_inv i (dyadic k n)) = (dyadic ((power (-1%Z)%Z (-i)%Z) * k)%Z n)).

Axiom d_mult_int_in :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((d_mult_int (dyadic k n) i) = (dyadic (i * k)%Z n)).

Axiom d_mult_int_out :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic (i * k)%Z n) = (d_mult_int (dyadic k n) i)).

Axiom dyadic_cycles :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((dyadic (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic k n)).

Axiom dyadic_cycles_neg :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (i <= 0%Z)%Z ->
  ((dyadic (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic k n)).

Axiom dyadic_cycles_gen :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((dyadic (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic k n)).

Axiom dyadic_cycles_zero :
  forall (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
  ((dyadic (power 2%Z n') n) = (dyadic 0%Z 0%Z)).

Axiom dyadic_cycles_zero_mult :
  forall (k:Z) (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
  ((dyadic (k * (power 2%Z n'))%Z n) = (dyadic 0%Z 0%Z)).

Axiom dyadic_eq :
  forall (k1:Z) (k2:Z) (n1:Z) (n2:Z), (k1 = k2) -> (n1 = n2) ->
  ((dyadic k1 n1) = (dyadic k2 n2)).

Axiom dyadicmod :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic k n) = (dyadic (int.EuclideanDivision.mod1 k (power 2%Z n)) n)).

Axiom dyadic_red :
  forall (k:Z) (n:Z), (1%Z <= n)%Z -> ~ (0%Z = k) ->
  ((int.EuclideanDivision.mod1 k 2%Z) = 0%Z) ->
  ((dyadic k n) = (dyadic (int.EuclideanDivision.div k 2%Z) (n - 1%Z)%Z)).

Axiom dyadic_up :
  forall (k:Z) (n:Z) (n':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z ->
  ((dyadic (k * (power 2%Z n'))%Z (n + n')%Z) = (dyadic k n)).

Axiom d_frac_simpl :
  forall (k:Z) (n1:Z) (n2:Z), (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
  ((dyadic (k * (power 2%Z n1))%Z (n2 + n1)%Z) = (dyadic k n2)).

Axiom add_eq1 :
  forall (d1:d_frac) (d2:d_frac) (e1:d_frac) (e2:d_frac), (d1 = e1) ->
  (d2 = e2) -> ((add1 d1 d2) = (add1 e1 e2)).

Axiom add_comm :
  forall (d1:d_frac) (d2:d_frac), ((add1 d1 d2) = (add1 d2 d1)).

Axiom add_eq_comm :
  forall (d1:d_frac) (d2:d_frac) (d3:d_frac) (d4:d_frac), (d1 = d3) ->
  (d2 = d4) -> ((add1 d1 d2) = (add1 d4 d3)).

Axiom d_div :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((dyadic k n) = (d_mult_int (dyadic k (n + i)%Z) (power 2%Z i))).

Axiom zero_d_add :
  forall (d':d_frac) (d:d_frac), (d' = (dyadic 0%Z 0%Z)) -> ((add1 d' d) = d).

Axiom add_zero_d :
  forall (d':d_frac) (d:d_frac), (d' = (dyadic 0%Z 0%Z)) -> ((add1 d d') = d).

Axiom d_sum__def :
  forall (f:Z -> d_frac), forall (i:Z) (j:Z),
  ((j <= i)%Z -> ((d_sum f i j) = (dyadic 0%Z 0%Z))) /\
  (~ (j <= i)%Z ->
   ((d_sum f i j) =
    (int_iterate (fun (y0:d_frac) (y1:d_frac) => (add1 y0 y1)) f i j))).

Axiom d_sum_to_int_iterate :
  forall (f:Z -> d_frac) (i:Z) (j:Z), (i < j)%Z ->
  ((d_sum f i j) =
   (int_iterate (fun (y0:d_frac) (y1:d_frac) => (add1 y0 y1)) f i j)).

Axiom d_sum_plus_one :
  forall (f:Z -> d_frac) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((d_sum f i j) = (add1 (f i) (d_sum f (i + 1%Z)%Z j))).

Axiom d_sum_cardone :
  forall (f:Z -> d_frac) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((d_sum f i j) = (f i)).

Axiom d_sum_neutral :
  forall (f:Z -> d_frac) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (dyadic 0%Z 0%Z))) ->
  ((d_sum f i j) = (dyadic 0%Z 0%Z)).

Axiom d_sum_def_plus_one_com :
  forall (f:Z -> d_frac) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((add1 (f i) (d_sum f (i + 1%Z)%Z j)) = (d_sum f i j)).

Axiom d_sum_right_extension :
  forall (f:Z -> d_frac) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((d_sum f i j) = (add1 (d_sum f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).

Axiom d_sum_transitivity :
  forall (f:Z -> d_frac) (i:Z) (k:Z) (j:Z), ((i < k)%Z /\ (k < j)%Z) ->
  ((d_sum f i j) = (add1 (d_sum f i k) (d_sum f k j))).

Axiom d_sum_eq :
  forall (f:Z -> d_frac) (g:Z -> d_frac) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((d_sum f i j) = (d_sum g i j)).

Axiom d_sum_cardzero :
  forall (f:Z -> d_frac) (i:Z) (j:Z), (j <= i)%Z ->
  ((d_sum f i j) = (dyadic 0%Z 0%Z)).

Axiom d_sum_eq_gen :
  forall (f:Z -> d_frac) (g:Z -> d_frac) (i:Z) (j:Z) (i':Z) (j':Z),
  (i < j)%Z -> (i = i') -> (j = j') ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((d_sum f i j) = (d_sum g i' j')).

Axiom d_sum_map :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> d_frac), (i < j)%Z ->
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((d_sum t1 k l) = (d_sum (fun (b:Z) => (t1 (f b))) i j)).

Axiom d_sum_break :
  forall (f:Z -> d_frac) (i:Z) (j:Z) (y:Z), ((i <= y)%Z /\ (y < j)%Z) ->
  ((d_sum f i j) = (add1 (d_sum f i y) (d_sum f y j))).

Axiom d_sum_break_param :
  forall (f:Z -> Z -> d_frac) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  ((d_sum (f y) i j) = (add1 (d_sum (f y) i y) (d_sum (f y) y j))).

Axiom d_sum_neutral_param_r :
  forall (f:Z -> Z -> d_frac) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  (forall (k:Z), ((y <= k)%Z /\ (k < j)%Z) -> (((f y) k) = (dyadic 0%Z 0%Z))) ->
  ((d_sum (f y) y j) = (dyadic 0%Z 0%Z)).

Axiom d_sum_neutral_param_l :
  forall (f:Z -> Z -> d_frac) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < y)%Z) -> (((f y) k) = (dyadic 0%Z 0%Z))) ->
  ((d_sum (f y) i y) = (dyadic 0%Z 0%Z)).

Axiom d_sum_transl :
  forall (f:Z -> d_frac) (i:Z) (j:Z) (k:Z), (i < j)%Z ->
  ((d_sum f i j) = (d_sum (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).

Axiom d_sum_transl_one :
  forall (f:Z -> d_frac) (i:Z) (j:Z), (i < j)%Z ->
  ((d_sum f i j) =
   (d_sum (fun (b:Z) => (f (b - 1%Z)%Z)) (i + 1%Z)%Z (j + 1%Z)%Z)).

Axiom value__eq :
  forall (o:d_frac) (o':d_frac), (o = o') -> ((value1 o) = (value1 o')).

Axiom d_sum_to_ind_isum :
  forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
  ((d_sum (fun (k:Z) => (dyadic (f k) n)) i j) = (dyadic (ind_isum f i j) n)).

Axiom ind_isum_to_d_sum :
  forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
  ((dyadic (ind_isum f i j) n) = (d_sum (fun (k:Z) => (dyadic (f k) n)) i j)).

Parameter min_set: (set Z) -> Z.

Axiom min_set_def :
  forall (s:set Z), (0%Z < (cardinal s))%Z ->
  (((cardinal s) = 1%Z) -> ((min_set s) = (choose s))) /\
  (~ ((cardinal s) = 1%Z) ->
   ((min_set s) =
    (ZArith.BinInt.Z.min (choose s) (min_set (remove (choose s) s))))).

Axiom min_set_spec :
  forall (s:set Z), (0%Z < (cardinal s))%Z ->
  (mem (min_set s) s) /\ forall (e:Z), (mem e s) -> ((min_set s) <= e)%Z.

Parameter max_set: (set Z) -> Z.

Axiom max_set_def :
  forall (s:set Z), (0%Z < (cardinal s))%Z ->
  (((cardinal s) = 1%Z) -> ((max_set s) = (choose s))) /\
  (~ ((cardinal s) = 1%Z) ->
   ((max_set s) =
    (ZArith.BinInt.Z.max (choose s) (max_set (remove (choose s) s))))).

Axiom max_set_spec :
  forall (s:set Z), (0%Z < (cardinal s))%Z ->
  (mem (max_set s) s) /\ forall (e:Z), (mem e s) -> (e <= (max_set s))%Z.

(* Why3 assumption *)
Definition max3 (a:Z) (b:Z) (c:Z) : Z :=
  (ZArith.BinInt.Z.max (ZArith.BinInt.Z.max a b) c).

Axiom max3_spec :
  forall (a:Z) (b:Z) (c:Z),
  ((max3 a b c) = (ZArith.BinInt.Z.max a (ZArith.BinInt.Z.max b c))).

Parameter complex_frac: Z -> Z -> t.

Axiom complex_frac_def :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((complex_frac k n) = (infix_sldt (i_to_t k) (i_to_t (power 2%Z n)))).

Axiom complex_frac_spec :
  forall (k:Z) (n:Z), (0%Z <= n)%Z -> real_ (complex_frac k n).

(* Why3 assumption *)
Definition d_cos (o:d_frac) : t := t_real_part (value1 o).

Axiom d_cos_spec : forall (o:d_frac), real_ (d_cos o).

(* Why3 assumption *)
Definition d_sin (o:d_frac) : t := t_im_part (value1 o).

Axiom d_sin_spec : forall (o:d_frac), real_ (d_sin o).

Axiom real_omega :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((d_cos (dyadic k n)) =
   (cos
    (infix_asdt (infix_asdt (infix_pldt tone tone) pi) (complex_frac k n)))).

Axiom im_omega :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((d_sin (dyadic k n)) =
   (sin
    (infix_asdt (infix_asdt (infix_pldt tone tone) pi) (complex_frac k n)))).

Axiom omega_decomp :
  forall (o:d_frac),
  ((value1 o) = (infix_pldt (d_cos o) (infix_asdt im (d_sin o)))).

Axiom d_cos_eq :
  forall (d1:d_frac) (d2:d_frac), ((value1 d1) = (value1 d2)) ->
  ((d_cos d1) = (d_cos d2)).

Axiom d_sin_eq :
  forall (d1:d_frac) (d2:d_frac), ((value1 d1) = (value1 d2)) ->
  ((d_sin d1) = (d_sin d2)).

Axiom a_circuit_ : Type.
Parameter a_circuit__WhyType : WhyType a_circuit_.
Existing Instance a_circuit__WhyType.

Parameter a_depth_: a_circuit_ -> Z.

Parameter a_sum_range_: a_circuit_ -> Z.

Parameter a_ket_part_: a_circuit_ -> (Z -> Z) -> (Z -> Z) -> Z -> Z.

Parameter a_phase_part_: a_circuit_ -> (Z -> Z) -> (Z -> Z) -> t.

Axiom Positive_a_depth_ : forall (c:a_circuit_), (0%Z < (a_depth_ c))%Z.

Axiom a_binary_ket_part_ :
  forall (c:a_circuit_), forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
  (binary bvy) ->
  binary
  ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
      (a_ket_part_ y0 y1 y2 y3))
     c)
    bvx)
   bvy).

Parameter a_phase_: d_frac -> a_circuit_.

Axiom a_phase__spec :
  forall (o:d_frac),
  ((a_sum_range_ (a_phase_ o)) = 0%Z) /\
  (((a_depth_ (a_phase_ o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_phase_ o)))%Z) ->
     ((a_ket_part_ (a_phase_ o) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (a_phase_ o) bvx bvy) = (value1 o)))).

Parameter a_rz_: d_frac -> a_circuit_.

Axiom a_rz__spec :
  forall (o:d_frac),
  ((a_sum_range_ (a_rz_ o)) = 0%Z) /\
  (((a_depth_ (a_rz_ o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_rz_ o)))%Z) ->
     ((a_ket_part_ (a_rz_ o) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (a_rz_ o) bvx bvy) =
     (value1 (phase_inv (1%Z - (bvx 0%Z))%Z o))))).

Parameter a_ry_: d_frac -> a_circuit_.

Axiom a_ry__spec :
  forall (o:d_frac),
  ((a_sum_range_ (a_ry_ o)) = 1%Z) /\
  (((a_depth_ (a_ry_ o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_ry_ o)))%Z) ->
     ((a_ket_part_ (a_ry_ o) bvx bvy i) = (bvy i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    (((bvx 0%Z) = (bvy 0%Z)) ->
     ((a_phase_part_ (a_ry_ o) bvx bvy) =
      (infix_asdt squarert_two (d_cos o)))) /\
    (~ ((bvx 0%Z) = (bvy 0%Z)) ->
     ((a_phase_part_ (a_ry_ o) bvx bvy) =
      (infix_asdt squarert_two
       (infix_asdt (cpower (prefix_mndt tone) (bvx 0%Z)) (d_sin o))))))).

Parameter a_rx_: d_frac -> a_circuit_.

Axiom a_rx__spec :
  forall (o:d_frac),
  ((a_sum_range_ (a_rx_ o)) = 1%Z) /\
  (((a_depth_ (a_rx_ o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_rx_ o)))%Z) ->
     ((a_ket_part_ (a_rx_ o) bvx bvy i) = (bvy i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    (((bvx 0%Z) = (bvy 0%Z)) ->
     ((a_phase_part_ (a_rx_ o) bvx bvy) =
      (infix_asdt squarert_two (d_cos o)))) /\
    (~ ((bvx 0%Z) = (bvy 0%Z)) ->
     ((a_phase_part_ (a_rx_ o) bvx bvy) =
      (infix_asdt squarert_two (infix_asdt (prefix_mndt im) (d_sin o))))))).

Parameter a_cnot_: unit -> a_circuit_.

Axiom a_cnot__spec :
  forall (us:unit),
  ((a_sum_range_ (a_cnot_ us)) = 0%Z) /\
  (((a_depth_ (a_cnot_ us)) = 2%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_cnot_ us)))%Z) ->
     ((i = 1%Z) ->
      ((a_ket_part_ (a_cnot_ us) bvx bvy i) =
       (int.EuclideanDivision.mod1 ((bvx 0%Z) + (bvx 1%Z))%Z 2%Z))) /\
     (~ (i = 1%Z) -> ((a_ket_part_ (a_cnot_ us) bvx bvy i) = (bvx i)))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (a_cnot_ us) bvx bvy) = tone))).

Parameter a_parallel_: a_circuit_ -> a_circuit_ -> a_circuit_.

Axiom a_parallel__spec :
  forall (d:a_circuit_) (e:a_circuit_),
  ((a_depth_ (a_parallel_ d e)) = ((a_depth_ d) + (a_depth_ e))%Z) /\
  (((a_sum_range_ (a_parallel_ d e)) =
    ((a_sum_range_ d) + (a_sum_range_ e))%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_parallel_ d e)))%Z) ->
     ((a_ket_part_ (a_parallel_ d e) bvx bvy i) =
      (concat_fun
       ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part_ y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part_ y0 y1 y2 y3))
          e)
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
          (a_depth_ d)))
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
         (a_sum_range_ d)))
       (a_depth_ d) i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (a_parallel_ d e) bvx bvy) =
     (infix_asdt (a_phase_part_ d bvx bvy)
      (a_phase_part_ e
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
        (a_depth_ d))
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        (a_sum_range_ d))))))).

Parameter a_sequence_: a_circuit_ -> a_circuit_ -> a_circuit_.

Axiom a_sequence__spec :
  forall (d:a_circuit_) (e:a_circuit_), ((a_depth_ d) = (a_depth_ e)) ->
  ((a_sum_range_ (a_sequence_ d e)) =
   ((a_sum_range_ d) + (a_sum_range_ e))%Z) /\
  (((a_depth_ (a_sequence_ d e)) = (a_depth_ d)) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_sequence_ d e)))%Z) ->
     ((a_ket_part_ (a_sequence_ d e) bvx bvy i) =
      (a_ket_part_ e
       ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part_ y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        (a_sum_range_ d))
       i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (a_sequence_ d e) bvx bvy) =
     (infix_asdt (a_phase_part_ d bvx bvy)
      (a_phase_part_ e
       ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part_ y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        (a_sum_range_ d))))))).

Parameter odd: Z -> bool.

Axiom odd_def :
  forall (n:Z),
  (((int.EuclideanDivision.mod1 n 2%Z) = 1%Z) -> ((odd n) = true)) /\
  (~ ((int.EuclideanDivision.mod1 n 2%Z) = 1%Z) -> ((odd n) = false)).

Axiom odd_spec :
  forall (n:Z),
  (((odd n) = true) ->
   (n = ((2%Z * (int.EuclideanDivision.div n 2%Z))%Z + 1%Z)%Z)) /\
  (((odd n) = false) -> (n = (2%Z * (int.EuclideanDivision.div n 2%Z))%Z)).

Parameter even: Z -> bool.

Axiom even_def :
  forall (n:Z),
  (((int.EuclideanDivision.mod1 n 2%Z) = 0%Z) -> ((even n) = true)) /\
  (~ ((int.EuclideanDivision.mod1 n 2%Z) = 0%Z) -> ((even n) = false)).

Axiom even_spec : forall (n:Z), ((even n) = true) <-> ~ ((odd n) = true).

Axiom even_or_odd : forall (n:Z), ((even n) = true) \/ ((odd n) = true).

Axiom not_null_powers_squarert_two :
  forall (i:Z), (0%Z <= i)%Z -> ~ ((cpower squarert_two i) = tzero).

Axiom coeffs :
  ((infix_sldt (prefix_mndt tone) squarert_two) =
   (prefix_mndt (infix_sldt tone squarert_two))).

Parameter mop: Z -> t.

Axiom mop_def :
  forall (i:Z), (0%Z <= i)%Z -> ((mop i) = (cpower (prefix_mndt tone) i)).

Axiom minus_one_power_values :
  forall (i:Z), (0%Z <= i)%Z ->
  (((even i) = true) -> ((mop i) = tone)) /\
  (((odd i) = true) -> ((mop i) = (prefix_mndt tone))).

Axiom factors_mop :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  ((mop (i + j)%Z) = (infix_asdt (mop i) (mop j))).

Axiom factors_mop_rev :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  ((infix_asdt (mop i) (mop j)) = (mop (i + j)%Z)).

Parameter pow_inv_sqrt_2: Z -> t.

Axiom pow_inv_sqrt_2_def :
  forall (i:Z), (0%Z <= i)%Z ->
  ((pow_inv_sqrt_2 i) = (cpower (infix_sldt tone squarert_two) i)).

Axiom pow_inv_sqrt_2_add :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  ((pow_inv_sqrt_2 (i + j)%Z) =
   (infix_asdt (pow_inv_sqrt_2 i) (pow_inv_sqrt_2 j))).

Parameter neg_pow_inv_sqrt_2: Z -> t.

Axiom neg_pow_inv_sqrt_2_def :
  forall (i:Z), (0%Z <= i)%Z ->
  ((neg_pow_inv_sqrt_2 i) =
   (cpower (infix_sldt (prefix_mndt tone) squarert_two) i)).

Axiom inv_pow_inv_sqrt_2 :
  ((infix_asdt (pow_inv_sqrt_2 1%Z) squarert_two) = tone).

Axiom pow_inv_sqrt_2_values :
  forall (i:Z), (0%Z <= i)%Z ->
  ((pow_inv_sqrt_2 i) = (infix_sldt tone (cpower squarert_two i))).

Axiom neg_pow_inv_sqrt_2_values :
  forall (i:Z), (0%Z <= i)%Z ->
  ((neg_pow_inv_sqrt_2 i) =
   (infix_asdt (mop i) (infix_sldt tone (cpower squarert_two i)))).

Axiom ppos_neg_coeff_values :
  forall (i:Z), (0%Z <= i)%Z ->
  (((even i) = true) -> ((pow_inv_sqrt_2 i) = (neg_pow_inv_sqrt_2 i))) /\
  ((((odd i) = true) ->
    ((pow_inv_sqrt_2 i) = (prefix_mndt (neg_pow_inv_sqrt_2 i)))) /\
   ((neg_pow_inv_sqrt_2 i) = (infix_asdt (mop i) (pow_inv_sqrt_2 i)))).

Parameter pow_inv_sqrt_2_neg: Z -> t.

Axiom pow_inv_sqrt_2_neg_def :
  forall (i:Z), (0%Z <= i)%Z ->
  ((pow_inv_sqrt_2_neg i) = (prefix_mndt (pow_inv_sqrt_2 i))).

Parameter a_flat_: a_circuit_ -> Prop.

Axiom a_flat__spec :
  forall (c:a_circuit_), (a_flat_ c) <-> ((a_sum_range_ c) = 0%Z).

Axiom seq_pres_a_flat_ :
  forall (d:a_circuit_) (e:a_circuit_), (a_flat_ d) -> (a_flat_ e) ->
  ((a_depth_ d) = (a_depth_ e)) -> a_flat_ (a_sequence_ d e).

Axiom par_pres_a_flat_ :
  forall (d:a_circuit_) (e:a_circuit_), (a_flat_ d) -> (a_flat_ e) ->
  a_flat_ (a_parallel_ d e).

Parameter a_flat_ket_: a_circuit_ -> (Z -> Z) -> Z -> Z.

Axiom a_flat_ket__spec :
  forall (c:a_circuit_) (bvx:Z -> Z) (i:Z), (a_flat_ c) ->
  (forall (bvy:Z -> Z), ((a_flat_ket_ c bvx i) = (a_ket_part_ c bvx bvy i))) /\
  ((a_flat_ket_ c bvx i) = (a_ket_part_ c bvx (fun (us:Z) => 0%Z) i)).

Parameter a_flat_phase_: a_circuit_ -> (Z -> Z) -> t.

Axiom a_flat_phase__spec :
  forall (c:a_circuit_) (bvx:Z -> Z), (a_flat_ c) ->
  (forall (bvy:Z -> Z), ((a_flat_phase_ c bvx) = (a_phase_part_ c bvx bvy))) /\
  ((a_flat_phase_ c bvx) = (a_phase_part_ c bvx (fun (us:Z) => 0%Z))).

Axiom a_ket_part_equiv_ :
  forall (c:a_circuit_),
  forall (bvx:Z -> Z) (bvx':Z -> Z) (bvy:Z -> Z) (bvy':Z -> Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < (a_sum_range_ c))%Z) ->
   ((bvy j) = (bvy' j))) ->
  (((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
       (a_ket_part_ y0 y1 y2 y3))
      c)
     bvx)
    bvy)
   =
   ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
       (a_ket_part_ y0 y1 y2 y3))
      c)
     bvx')
    bvy')).

Axiom a_phase_part_equiv_ :
  forall (c:a_circuit_),
  forall (bvx:Z -> Z) (bvx':Z -> Z) (bvy:Z -> Z) (bvy':Z -> Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < (a_sum_range_ c))%Z) ->
   ((bvy j) = (bvy' j))) ->
  ((a_phase_part_ c bvx bvy) = (a_phase_part_ c bvx' bvy')).

Axiom A_Flat_ket_equiv_ :
  forall (c:a_circuit_), forall (bvx:Z -> Z) (bvx':Z -> Z), (a_flat_ c) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  ((((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z) => (a_flat_ket_ y0 y1 y2)) c)
    bvx)
   =
   (((fun (y0:a_circuit_) (y1:Z -> Z) (y2:Z) => (a_flat_ket_ y0 y1 y2)) c)
    bvx')).

Axiom A_Flat_a_phase_part_equiv_ :
  forall (c:a_circuit_), forall (bvx:Z -> Z) (bvx':Z -> Z), (a_flat_ c) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  ((a_flat_phase_ c bvx) = (a_flat_phase_ c bvx')).

Parameter a_rzp_: Z -> a_circuit_.

Axiom a_rzp__spec :
  forall (n:Z), (0%Z <= n)%Z ->
  ((a_depth_ (a_rzp_ n)) = 1%Z) /\
  (((a_sum_range_ (a_rzp_ n)) = 0%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_rzp_ n)))%Z) ->
     ((a_ket_part_ (a_rzp_ n) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
    ((a_phase_part_ (a_rzp_ n) bvx bvy) = (value1 (dyadic (bvx 0%Z) n))))).

Axiom omega_d13 :
  ((value1 (dyadic 1%Z 3%Z)) =
   (infix_pldt (infix_sldt squarert_two (infix_pldt tone tone))
    (infix_asdt im (infix_sldt squarert_two (infix_pldt tone tone))))).

Axiom cos13 :
  ((d_cos (dyadic 1%Z 3%Z)) =
   (infix_sldt squarert_two (infix_pldt tone tone))).

Axiom sin13 :
  ((d_sin (dyadic 1%Z 3%Z)) =
   (infix_sldt squarert_two (infix_pldt tone tone))).

Axiom omega_d12 : ((value1 (dyadic 1%Z 2%Z)) = im).

Axiom cos12 : ((d_cos (dyadic 1%Z 2%Z)) = tzero).

Axiom sin12 : ((d_sin (dyadic 1%Z 2%Z)) = tone).

Axiom omega_d11 : ((value1 (dyadic 1%Z 1%Z)) = (prefix_mndt tone)).

Axiom cos11 : ((d_cos (dyadic 1%Z 1%Z)) = (prefix_mndt tone)).

Axiom sin11 : ((d_sin (dyadic 1%Z 1%Z)) = tzero).

Axiom omega_d10 : ((value1 (dyadic 1%Z 0%Z)) = tone).

Axiom cos10 : ((d_cos (dyadic 1%Z 0%Z)) = tone).

Axiom sin10 : ((d_sin (dyadic 1%Z 0%Z)) = tzero).

Axiom cos0n : forall (n:Z), (0%Z <= n)%Z -> ((d_cos (dyadic 0%Z n)) = tone).

Axiom sin0n : forall (n:Z), (0%Z <= n)%Z -> ((d_sin (dyadic 0%Z n)) = tzero).

Axiom omega_d0n :
  forall (n:Z), (0%Z <= n)%Z -> ((value1 (dyadic 0%Z n)) = tone).

Parameter a_hadamard_: unit -> a_circuit_.

Axiom a_hadamard__spec :
  forall (us:unit),
  ((a_depth_ (a_hadamard_ us)) = 1%Z) /\
  (((a_sum_range_ (a_hadamard_ us)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (a_hadamard_ us)))%Z) ->
     ((a_ket_part_ (a_hadamard_ us) bvx bvy i) = (bvy i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) -> (binary bvy) ->
    ((a_phase_part_ (a_hadamard_ us) bvx bvy) =
     (value1 (dyadic ((bvx 0%Z) * (bvy 0%Z))%Z 1%Z))))).

Axiom d_frac_ : Type.
Parameter d_frac__WhyType : WhyType d_frac_.
Existing Instance d_frac__WhyType.

Parameter inv_1: d_frac_ -> d_frac_.

Parameter add_: d_frac_ -> d_frac_ -> d_frac_.

Parameter value_: d_frac_ -> t.

Parameter zero_d_: d_frac_.

Axiom Assoc3 :
  forall (x:d_frac_) (y:d_frac_) (z:d_frac_),
  ((add_ (add_ x y) z) = (add_ x (add_ y z))).

Axiom Unit_def_l2 : forall (x:d_frac_), ((add_ zero_d_ x) = x).

Axiom Unit_def_r2 : forall (x:d_frac_), ((add_ x zero_d_) = x).

Axiom Inv_def_l2 : forall (x:d_frac_), ((add_ (inv_1 x) x) = zero_d_).

Axiom Inv_def_r2 : forall (x:d_frac_), ((add_ x (inv_1 x)) = zero_d_).

Axiom Comm3 : forall (x:d_frac_) (y:d_frac_), ((add_ x y) = (add_ y x)).

Parameter dyadic_: Z -> Z -> d_frac_.

Parameter d_mult_int_: d_frac_ -> Z -> d_frac_.

Axiom Dyadic_inv1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((add_ (dyadic_ k n) (dyadic_ (-k)%Z n)) = zero_d_).

Axiom Dyadic_add1 :
  forall (k:Z) (k':Z) (n:Z), (0%Z <= n)%Z ->
  ((add_ (dyadic_ k n) (dyadic_ k' n)) = (dyadic_ (k + k')%Z n)).

Axiom Dyadic_up1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic_ k n) = (dyadic_ (2%Z * k)%Z (n + 1%Z)%Z)).

Axiom Dyadic_cyclic1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic_ k n) = (dyadic_ (k + (power 2%Z n))%Z n)).

Axiom Zero_n1 : forall (n:Z), (0%Z <= n)%Z -> ((dyadic_ 0%Z n) = zero_d_).

Axiom D_mult1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((d_mult_int_ (dyadic_ k n) i) = (dyadic_ (k * i)%Z n)).

Axiom Dyadic_value1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((value_ (dyadic_ k n)) = (p_omega n k)).

Axiom Dyadic_zero_n1 :
  forall (k:Z) (n:Z), (n = 0%Z) -> ((dyadic_ k n) = zero_d_).

Axiom Dyadic_zero_k1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z -> (k = 0%Z) -> ((dyadic_ k n) = zero_d_).

Axiom value_zero_1 : ((value_ zero_d_) = tone).

Parameter div_two_: d_frac_ -> d_frac_.

Axiom Div_two_dyadic1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
  ((div_two_ (dyadic_ k n)) = (dyadic_ k (n + 1%Z)%Z)).

Axiom Div_two1 : forall (d:d_frac_), ((add_ (div_two_ d) (div_two_ d)) = d).

Parameter k_dyadic_: Z -> d_frac_.

Axiom K_dyadic1 :
  forall (k:Z), (0%Z <= k)%Z -> ((k_dyadic_ k) = (dyadic_ 1%Z k)).

Axiom K_dyadic_plus_one1 :
  forall (k:Z), (0%Z < k)%Z ->
  ((add_ (k_dyadic_ k) (k_dyadic_ k)) = (k_dyadic_ (k - 1%Z)%Z)).

Parameter phase_inv_: Z -> d_frac_ -> d_frac_.

Axiom Even_phase_inv1 :
  forall (d:d_frac_), forall (i:Z),
  ((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((phase_inv_ i d) = d).

Axiom Odd_phase_inv1 :
  forall (d:d_frac_), forall (i:Z),
  ((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
  ((phase_inv_ i d) = (inv_1 d)).

Axiom Gen_phase_inv1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((phase_inv_ i (dyadic_ k n)) = (dyadic_ ((power (-1%Z)%Z i) * k)%Z n)).

Axiom Gen_phase_inv_neg1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (i < 0%Z)%Z ->
  ((phase_inv_ i (dyadic_ k n)) =
   (dyadic_ ((power (-1%Z)%Z (-i)%Z) * k)%Z n)).

Axiom d_mult_int_in1 :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((d_mult_int_ (dyadic_ k n) i) = (dyadic_ (i * k)%Z n)).

Axiom d_mult_int_out1 :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic_ (i * k)%Z n) = (d_mult_int_ (dyadic_ k n) i)).

Axiom dyadic_cycles1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((dyadic_ (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic_ k n)).

Axiom dyadic_cycles_neg1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (i <= 0%Z)%Z ->
  ((dyadic_ (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic_ k n)).

Axiom dyadic_cycles_gen1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((dyadic_ (k + (i * (power 2%Z n))%Z)%Z n) = (dyadic_ k n)).

Axiom dyadic_cycles_zero1 :
  forall (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
  ((dyadic_ (power 2%Z n') n) = zero_d_).

Axiom dyadic_cycles_zero_mult1 :
  forall (k:Z) (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
  ((dyadic_ (k * (power 2%Z n'))%Z n) = zero_d_).

Axiom dyadic_eq1 :
  forall (k1:Z) (k2:Z) (n1:Z) (n2:Z), (k1 = k2) -> (n1 = n2) ->
  ((dyadic_ k1 n1) = (dyadic_ k2 n2)).

Axiom dyadicmod1 :
  forall (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((dyadic_ k n) = (dyadic_ (int.EuclideanDivision.mod1 k (power 2%Z n)) n)).

Axiom dyadic_red1 :
  forall (k:Z) (n:Z), (1%Z <= n)%Z -> ~ (0%Z = k) ->
  ((int.EuclideanDivision.mod1 k 2%Z) = 0%Z) ->
  ((dyadic_ k n) = (dyadic_ (int.EuclideanDivision.div k 2%Z) (n - 1%Z)%Z)).

Axiom dyadic_up1 :
  forall (k:Z) (n:Z) (n':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z ->
  ((dyadic_ (k * (power 2%Z n'))%Z (n + n')%Z) = (dyadic_ k n)).

Axiom d_frac_simpl1 :
  forall (k:Z) (n1:Z) (n2:Z), (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
  ((dyadic_ (k * (power 2%Z n1))%Z (n2 + n1)%Z) = (dyadic_ k n2)).

Axiom add_eq2 :
  forall (d1:d_frac_) (d2:d_frac_) (e1:d_frac_) (e2:d_frac_), (d1 = e1) ->
  (d2 = e2) -> ((add_ d1 d2) = (add_ e1 e2)).

Axiom add_comm1 :
  forall (d1:d_frac_) (d2:d_frac_), ((add_ d1 d2) = (add_ d2 d1)).

Axiom add_eq_comm1 :
  forall (d1:d_frac_) (d2:d_frac_) (d3:d_frac_) (d4:d_frac_), (d1 = d3) ->
  (d2 = d4) -> ((add_ d1 d2) = (add_ d4 d3)).

Axiom d_div1 :
  forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
  ((dyadic_ k n) = (d_mult_int_ (dyadic_ k (n + i)%Z) (power 2%Z i))).

Axiom zero_d_add1 :
  forall (d':d_frac_) (d:d_frac_), (d' = zero_d_) -> ((add_ d' d) = d).

Axiom add_zero_d1 :
  forall (d':d_frac_) (d:d_frac_), (d' = zero_d_) -> ((add_ d d') = d).

Parameter d_sum_: (Z -> d_frac_) -> Z -> Z -> d_frac_.

Axiom d_sum__def1 :
  forall (f:Z -> d_frac_), forall (i:Z) (j:Z),
  ((j <= i)%Z -> ((d_sum_ f i j) = zero_d_)) /\
  (~ (j <= i)%Z ->
   ((d_sum_ f i j) =
    (int_iterate (fun (y0:d_frac_) (y1:d_frac_) => (add_ y0 y1)) f i j))).

Axiom d_sum_to_int_iterate1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z ->
  ((d_sum_ f i j) =
   (int_iterate (fun (y0:d_frac_) (y1:d_frac_) => (add_ y0 y1)) f i j)).

Axiom d_sum_plus_one1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((d_sum_ f i j) = (add_ (f i) (d_sum_ f (i + 1%Z)%Z j))).

Axiom d_sum_cardone1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((d_sum_ f i j) = (f i)).

Axiom d_sum_neutral1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = zero_d_)) ->
  ((d_sum_ f i j) = zero_d_).

Axiom d_sum_def_plus_one_com1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((add_ (f i) (d_sum_ f (i + 1%Z)%Z j)) = (d_sum_ f i j)).

Axiom d_sum_right_extension1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  ((d_sum_ f i j) = (add_ (d_sum_ f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).

Axiom d_sum_transitivity1 :
  forall (f:Z -> d_frac_) (i:Z) (k:Z) (j:Z), ((i < k)%Z /\ (k < j)%Z) ->
  ((d_sum_ f i j) = (add_ (d_sum_ f i k) (d_sum_ f k j))).

Axiom d_sum_eq1 :
  forall (f:Z -> d_frac_) (g:Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((d_sum_ f i j) = (d_sum_ g i j)).

Axiom d_sum_cardzero1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), (j <= i)%Z ->
  ((d_sum_ f i j) = zero_d_).

Axiom d_sum_eq_gen1 :
  forall (f:Z -> d_frac_) (g:Z -> d_frac_) (i:Z) (j:Z) (i':Z) (j':Z),
  (i < j)%Z -> (i = i') -> (j = j') ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((d_sum_ f i j) = (d_sum_ g i' j')).

Axiom d_sum_map1 :
  forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> d_frac_), (i < j)%Z ->
  (p_bijective f (to_fset i j) (to_fset k l)) ->
  ((d_sum_ t1 k l) = (d_sum_ (fun (b:Z) => (t1 (f b))) i j)).

Axiom d_sum_break1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z) (y:Z), ((i <= y)%Z /\ (y < j)%Z) ->
  ((d_sum_ f i j) = (add_ (d_sum_ f i y) (d_sum_ f y j))).

Axiom d_sum_break_param1 :
  forall (f:Z -> Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  ((d_sum_ (f y) i j) = (add_ (d_sum_ (f y) i y) (d_sum_ (f y) y j))).

Axiom d_sum_neutral_param_r1 :
  forall (f:Z -> Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  (forall (k:Z), ((y <= k)%Z /\ (k < j)%Z) -> (((f y) k) = zero_d_)) ->
  ((d_sum_ (f y) y j) = zero_d_).

Axiom d_sum_neutral_param_l1 :
  forall (f:Z -> Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
  ((i <= y)%Z /\ (y < j)%Z) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < y)%Z) -> (((f y) k) = zero_d_)) ->
  ((d_sum_ (f y) i y) = zero_d_).

Axiom d_sum_transl1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z) (k:Z), (i < j)%Z ->
  ((d_sum_ f i j) =
   (d_sum_ (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).

Axiom d_sum_transl_one1 :
  forall (f:Z -> d_frac_) (i:Z) (j:Z), (i < j)%Z ->
  ((d_sum_ f i j) =
   (d_sum_ (fun (b:Z) => (f (b - 1%Z)%Z)) (i + 1%Z)%Z (j + 1%Z)%Z)).

Axiom value__eq1 :
  forall (o:d_frac_) (o':d_frac_), (o = o') -> ((value_ o) = (value_ o')).

Axiom d_sum_to_ind_isum1 :
  forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
  ((d_sum_ (fun (k:Z) => (dyadic_ (f k) n)) i j) =
   (dyadic_ (ind_isum f i j) n)).

Axiom ind_isum_to_d_sum1 :
  forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
  ((dyadic_ (ind_isum f i j) n) =
   (d_sum_ (fun (k:Z) => (dyadic_ (f k) n)) i j)).

Axiom a_circuit : Type.
Parameter a_circuit_WhyType : WhyType a_circuit.
Existing Instance a_circuit_WhyType.

Parameter a_depth: a_circuit -> Z.

Parameter a_sum_range: a_circuit -> Z.

Parameter a_ket_part: a_circuit -> (Z -> Z) -> (Z -> Z) -> Z -> Z.

Axiom a_ket_part_spec :
  forall (c:a_circuit) (us:Z -> Z) (us1:Z -> Z) (i:Z),
  ((i < 0%Z)%Z -> ((a_ket_part c us us1 i) = 0%Z)) /\
  (((a_depth c) <= i)%Z -> ((a_ket_part c us us1 i) = 0%Z)).

Parameter a_phase_part: a_circuit -> (Z -> Z) -> (Z -> Z) -> d_frac_.

Axiom a_binary_ket_part :
  forall (c:a_circuit), forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
  (binary bvy) ->
  binary
  ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
      (a_ket_part y0 y1 y2 y3))
     c)
    bvx)
   bvy).

Axiom Positive_depth : forall (c:a_circuit), (0%Z < (a_depth c))%Z.

Axiom Positive_sum_range : forall (c:a_circuit), (0%Z <= (a_sum_range c))%Z.

Parameter a_phase: d_frac_ -> a_circuit.

Axiom a_phase_spec :
  forall (o:d_frac_),
  ((a_sum_range (a_phase o)) = 0%Z) /\
  (((a_depth (a_phase o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_phase o)))%Z) ->
     ((a_ket_part (a_phase o) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_phase o) bvx bvy) = o))).

Parameter a_rz: d_frac_ -> a_circuit.

Axiom a_rz_spec :
  forall (o:d_frac_),
  ((a_sum_range (a_rz o)) = 0%Z) /\
  (((a_depth (a_rz o)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_rz o)))%Z) ->
     ((a_ket_part (a_rz o) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_rz o) bvx bvy) = (phase_inv_ (1%Z - (bvx 0%Z))%Z o)))).

Parameter a_hadamard: unit -> a_circuit.

Axiom a_hadamard_spec :
  forall (us:unit),
  ((a_sum_range (a_hadamard us)) = 1%Z) /\
  (((a_depth (a_hadamard us)) = 1%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_hadamard us)))%Z) ->
     ((a_ket_part (a_hadamard us) bvx bvy i) = (bvy i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_hadamard us) bvx bvy) =
     (dyadic_ ((bvx 0%Z) * (bvy 0%Z))%Z 1%Z)))).

Parameter a_cnot: unit -> a_circuit.

Axiom a_cnot_spec :
  forall (us:unit),
  ((a_sum_range (a_cnot us)) = 0%Z) /\
  (((a_depth (a_cnot us)) = 2%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_cnot us)))%Z) ->
     ((i = 1%Z) ->
      ((a_ket_part (a_cnot us) bvx bvy i) =
       (int.EuclideanDivision.mod1 ((bvx 0%Z) + (bvx 1%Z))%Z 2%Z))) /\
     (~ (i = 1%Z) -> ((a_ket_part (a_cnot us) bvx bvy i) = (bvx i)))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_cnot us) bvx bvy) = zero_d_))).

Parameter a_parallel: a_circuit -> a_circuit -> a_circuit.

Axiom a_parallel_spec :
  forall (d:a_circuit) (e:a_circuit),
  ((a_depth (a_parallel d e)) = ((a_depth d) + (a_depth e))%Z) /\
  (((a_sum_range (a_parallel d e)) = ((a_sum_range d) + (a_sum_range e))%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_parallel d e)))%Z) ->
     ((a_ket_part (a_parallel d e) bvx bvy i) =
      (concat_fun
       ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part y0 y1 y2 y3))
          e)
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
          (a_depth d)))
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
         (a_sum_range d)))
       (a_depth d) i))) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < (a_depth d))%Z) ->
      ((a_ket_part (a_parallel d e) bvx bvy i) = (a_ket_part d bvx bvy i))) /\
     ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
       (((a_depth d) <= i)%Z /\ (i < ((a_depth d) + (a_depth e))%Z)%Z) ->
       ((a_ket_part (a_parallel d e) bvx bvy i) =
        (a_ket_part e
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
          (a_depth d))
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
          (a_sum_range d))
         (i - (a_depth d))%Z))) /\
      forall (bvx:Z -> Z) (bvy:Z -> Z),
      ((a_phase_part (a_parallel d e) bvx bvy) =
       (add_ (a_phase_part d bvx bvy)
        (a_phase_part e
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
          (a_depth d))
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
          (a_sum_range d))))))))).

Parameter a_sequence: a_circuit -> a_circuit -> a_circuit.

Axiom a_sequence_spec :
  forall (d:a_circuit) (e:a_circuit), ((a_depth d) = (a_depth e)) ->
  ((a_sum_range (a_sequence d e)) = ((a_sum_range d) + (a_sum_range e))%Z) /\
  (((a_depth (a_sequence d e)) = (a_depth d)) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_sequence d e)))%Z) ->
     ((a_ket_part (a_sequence d e) bvx bvy i) =
      (a_ket_part e
       ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        (a_sum_range d))
       i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_sequence d e) bvx bvy) =
     (add_ (a_phase_part d bvx bvy)
      (a_phase_part e
       ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
           (a_ket_part y0 y1 y2 y3))
          d)
         bvx)
        bvy)
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        (a_sum_range d))))))).

Parameter a_flat: a_circuit -> Prop.

Axiom a_flat_spec :
  forall (c:a_circuit), (a_flat c) <-> ((a_sum_range c) = 0%Z).

Axiom seq_pres_flat :
  forall (d:a_circuit) (e:a_circuit), (a_flat d) -> (a_flat e) ->
  ((a_depth d) = (a_depth e)) -> a_flat (a_sequence d e).

Axiom par_pres_flat :
  forall (d:a_circuit) (e:a_circuit), (a_flat d) -> (a_flat e) ->
  a_flat (a_parallel d e).

Parameter a_flat_ket: a_circuit -> (Z -> Z) -> Z -> Z.

Axiom a_flat_ket_spec :
  forall (c:a_circuit) (bvx:Z -> Z) (i:Z), (a_flat c) ->
  (forall (bvy:Z -> Z), ((a_flat_ket c bvx i) = (a_ket_part c bvx bvy i))) /\
  ((a_flat_ket c bvx i) = (a_ket_part c bvx (fun (us:Z) => 0%Z) i)).

Parameter a_flat_phase: a_circuit -> (Z -> Z) -> d_frac_.

Axiom a_flat_phase_spec :
  forall (c:a_circuit) (bvx:Z -> Z), (a_flat c) ->
  (forall (bvy:Z -> Z), ((a_flat_phase c bvx) = (a_phase_part c bvx bvy))) /\
  ((a_flat_phase c bvx) = (a_phase_part c bvx (fun (us:Z) => 0%Z))).

Parameter a_rzp: Z -> a_circuit.

Axiom a_rzp_spec :
  forall (n:Z), (0%Z <= n)%Z ->
  ((a_depth (a_rzp n)) = 1%Z) /\
  (((a_sum_range (a_rzp n)) = 0%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (a_rzp n)))%Z) ->
     ((a_ket_part (a_rzp n) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) -> (binary bvy) ->
    ((a_phase_part (a_rzp n) bvx bvy) = (k_dyadic_ ((bvx 0%Z) * n)%Z)))).

Axiom a_ket_part_equiv :
  forall (c:a_circuit),
  forall (bvx:Z -> Z) (bvx':Z -> Z) (bvy:Z -> Z) (bvy':Z -> Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < (a_sum_range c))%Z) ->
   ((bvy j) = (bvy' j))) ->
  (((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
       (a_ket_part y0 y1 y2 y3))
      c)
     bvx)
    bvy)
   =
   ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
       (a_ket_part y0 y1 y2 y3))
      c)
     bvx')
    bvy')).

Axiom a_phase_part_equiv :
  forall (c:a_circuit),
  forall (bvx:Z -> Z) (bvx':Z -> Z) (bvy:Z -> Z) (bvy':Z -> Z),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < (a_sum_range c))%Z) ->
   ((bvy j) = (bvy' j))) ->
  ((a_phase_part c bvx bvy) = (a_phase_part c bvx' bvy')).

Axiom A_Flat_ket_equiv :
  forall (c:a_circuit), forall (bvx:Z -> Z) (bvx':Z -> Z), (a_flat c) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z) => (a_flat_ket y0 y1 y2)) c) bvx)
   =
   (((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z) => (a_flat_ket y0 y1 y2)) c)
    bvx')).

Axiom A_Flat_phase_equiv :
  forall (c:a_circuit), forall (bvx:Z -> Z) (bvx':Z -> Z), (a_flat c) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
   ((bvx i) = (bvx' i))) ->
  ((a_flat_phase c bvx) = (a_flat_phase c bvx')).

Parameter a_to_gen_circuit: a_circuit -> a_circuit_.

Axiom a_to_gen_circuit_spec :
  forall (c:a_circuit),
  ((a_depth_ (a_to_gen_circuit c)) = (a_depth c)) /\
  (((a_sum_range_ (a_to_gen_circuit c)) = (a_sum_range c)) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((a_ket_part_ (a_to_gen_circuit c) bvx bvy i) =
      (a_ket_part c bvx bvy i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) -> (binary bvy) ->
    ((a_phase_part_ (a_to_gen_circuit c) bvx bvy) =
     (value_ (a_phase_part c bvx bvy))))).

Axiom Parallel_to_gen :
  forall (d:a_circuit) (e:a_circuit),
  ((a_to_gen_circuit (a_parallel d e)) =
   (a_parallel_ (a_to_gen_circuit d) (a_to_gen_circuit e))).

Axiom Sequence_to_gen :
  forall (d:a_circuit) (e:a_circuit), ((a_depth d) = (a_depth e)) ->
  ((a_to_gen_circuit (a_sequence d e)) =
   (a_sequence_ (a_to_gen_circuit d) (a_to_gen_circuit e))).

Axiom Phase_to_gen :
  forall (o:d_frac), forall (o':d_frac_), ((value1 o) = (value_ o')) ->
  ((a_to_gen_circuit (a_phase o')) = (a_phase_ o)).

Axiom Rz_to_gen :
  forall (o:d_frac), forall (o':d_frac_), ((value1 o) = (value_ o')) ->
  ((a_to_gen_circuit (a_rz o')) = (a_rz_ o)).

Axiom Hadamard_to_gen :
  ((a_to_gen_circuit (a_hadamard tt)) = (a_hadamard_ tt)).

Axiom Cnot_to_gen : ((a_to_gen_circuit (a_cnot tt)) = (a_cnot_ tt)).

Axiom Flat_to_gen :
  forall (c:a_circuit), (a_flat c) -> a_flat_ (a_to_gen_circuit c).

Axiom Flat_ket_to_gen :
  forall (c:a_circuit), (a_flat c) -> forall (bvx:Z -> Z), forall (i:Z),
  ((a_flat_ket c bvx i) = (a_flat_ket_ (a_to_gen_circuit c) bvx i)).

Axiom Flat_phase_to_gen :
  forall (c:a_circuit), (a_flat c) -> forall (bvx:Z -> Z), (binary bvx) ->
  ((value_ (a_flat_phase c bvx)) = (a_flat_phase_ (a_to_gen_circuit c) bvx)).

Axiom flat_phase_to_gen_rev :
  forall (c:a_circuit) (bvx:Z -> Z), (binary bvx) -> (a_flat c) ->
  ((a_flat_phase_ (a_to_gen_circuit c) bvx) = (value_ (a_flat_phase c bvx))).

Axiom ind_isum_mod_div :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  ((int.EuclideanDivision.mod1
    (ind_isum
     (fun (k:Z) =>
      (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
     0%Z (length bv))
    (power 2%Z ((length bv) - i)%Z))
   =
   (ind_isum
    (fun (k:Z) =>
     (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
    i (length bv))) /\
  ((int.EuclideanDivision.div
    (ind_isum
     (fun (k:Z) =>
      (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
     0%Z (length bv))
    (power 2%Z ((length bv) - i)%Z))
   =
   (ind_isum
    (fun (k:Z) => (((value bv) k) * (power 2%Z ((i - 1%Z)%Z - k)%Z))%Z) 0%Z
    i)).

Axiom mod_ind_isum :
  forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
  (binary f) ->
  ((int.EuclideanDivision.mod1
    (ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
     l)
    (power 2%Z i))
   =
   (ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z)
    (l - i)%Z l)).

Axiom mod_ind_isum_z :
  forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
  (binary f) ->
  ((int.EuclideanDivision.mod1
    (ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
     l)
    (power 2%Z i))
   =
   (ind_isum
    (fun (k:Z) =>
     ((f ((k + l)%Z - i)%Z) * (power 2%Z ((i - 1%Z)%Z - k)%Z))%Z)
    0%Z i)).

Axiom div_ind_isum :
  forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
  (binary f) ->
  ((int.EuclideanDivision.div
    (ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
     l)
    (power 2%Z i))
   =
   (ind_isum
    (fun (k:Z) => ((f k) * (power 2%Z (((l - 1%Z)%Z - k)%Z - i)%Z))%Z) 0%Z
    (l - i)%Z)).

Axiom ind_isum_mod :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
  ((int.EuclideanDivision.mod1
    (ind_isum (fun (l:Z) => (((value bv) l) * (power 2%Z (i - l)%Z))%Z) 0%Z
     (i + 1%Z)%Z)
    2%Z)
   = ((value bv) i)).

Axiom bv_to_int_kth_pre :
  forall (bv:bitvec) (k:Z),
  ((0%Z <= k)%Z /\ (k < ((length bv) - 1%Z)%Z)%Z) ->
  (((value bv) k) =
   (int.EuclideanDivision.mod1
    (int.EuclideanDivision.div
     (ind_isum
      (fun (l:Z) =>
       (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
      0%Z (length bv))
     (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))
    2%Z)) /\
  (((value bv) k) =
   (int.EuclideanDivision.div
    (int.EuclideanDivision.mod1
     (ind_isum
      (fun (l:Z) =>
       (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
      0%Z (length bv))
     (power 2%Z ((length bv) - k)%Z))
    (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))).

Parameter int_to_bv: Z -> Z -> bitvec.

Parameter result10: Z -> Z -> Z -> Z.

Axiom result_def10 :
  forall (i:Z) (n:Z) (k:Z),
  (((0%Z <= k)%Z /\ (k < n)%Z) ->
   (((result10 i n) k) =
    (int.EuclideanDivision.div
     (int.EuclideanDivision.mod1 i (power 2%Z (n - k)%Z))
     (power 2%Z ((n - k)%Z - 1%Z)%Z)))) /\
  (~ ((0%Z <= k)%Z /\ (k < n)%Z) -> (((result10 i n) k) = 0%Z)).

Axiom int_to_bv_def :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((int_to_bv i n) = (make_bv (result10 i n) n)).

Axiom int_to_bv_spec :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((length (int_to_bv i n)) = n) /\
  ((int_to_bv i n) =
   (make_bv
    (fun (k:Z) =>
     (int.EuclideanDivision.div
      (int.EuclideanDivision.mod1 i (power 2%Z (n - k)%Z))
      (power 2%Z ((n - k)%Z - 1%Z)%Z)))
    n)).

Axiom int_to_bv_sum_pre :
  forall (i:Z) (n:Z) (k:Z), ((k <= n)%Z /\ (0%Z <= k)%Z) ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((int.EuclideanDivision.mod1 i (power 2%Z k)) =
   (ind_isum
    (fun (l:Z) =>
     (((value (int_to_bv i n)) l) * (power 2%Z ((n - l)%Z - 1%Z)%Z))%Z)
    (n - k)%Z n)).

Axiom int_to_bv_sum :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  (i =
   (ind_isum
    (fun (k:Z) =>
     (((value (int_to_bv i n)) k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z)
    0%Z n)).

Axiom int_to_bv_mod_div :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((int_to_bv i n) =
   (make_bv
    (fun (k:Z) =>
     (int.EuclideanDivision.mod1
      (int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z))
    n)).

Axiom mod_isum :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  ((int.EuclideanDivision.mod1 i (power 2%Z k)) =
   (ind_isum
    (fun (l:Z) =>
     (((value (int_to_bv i n)) l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z)
    (n - k)%Z n)).

Axiom mod_isum_z :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  ((int.EuclideanDivision.mod1 i (power 2%Z k)) =
   (ind_isum
    (fun (l:Z) =>
     (((value (int_to_bv i n)) (l + (n - k)%Z)%Z) *
      (power 2%Z ((k - l)%Z - 1%Z)%Z))%Z)
    0%Z k)).

Axiom div_isum :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  ((int.EuclideanDivision.div i (power 2%Z k)) =
   (ind_isum
    (fun (l:Z) =>
     (((value (int_to_bv i n)) l) *
      (power 2%Z (((n - 1%Z)%Z - k)%Z - l)%Z))%Z)
    0%Z (n - k)%Z)).

Axiom int_to_bv_div_mod :
  forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  ((int_to_bv i n) =
   (make_bv
    (fun (k1:Z) =>
     (int.EuclideanDivision.div
      (int.EuclideanDivision.mod1 i (power 2%Z (n - k1)%Z))
      (power 2%Z ((n - k1)%Z - 1%Z)%Z)))
    n)).

Axiom int_to_bv_value :
  forall (i:Z) (n:Z) (k:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  (((value (int_to_bv i n)) k) =
   (int.EuclideanDivision.mod1
    (int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z)).

Axiom int_to_bv_zero :
  forall (n:Z), forall (k:Z), ((1%Z <= k)%Z /\ (k <= n)%Z) ->
  (((value (int_to_bv 0%Z n)) k) = 0%Z).

Axiom int_to_sum :
  forall (i:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  (i =
   (ind_isum
    (fun (k:Z) =>
     (((value (int_to_bv i n)) k) * (power 2%Z ((n - k)%Z - 1%Z)%Z))%Z)
    0%Z n)).

Axiom int_to_bv_transl :
  forall (i:Z) (k:Z) (n:Z) (t1:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= k)%Z /\ (k < (n - t1)%Z)%Z) -> ((0%Z < t1)%Z /\ (t1 <= n)%Z) ->
  (((value
     (int_to_bv (int.EuclideanDivision.mod1 i (power 2%Z (n - t1)%Z))
      (n - t1)%Z))
    k)
   = ((value (int_to_bv i n)) (k + t1)%Z)).

Parameter bin_to_int: (Z -> Z) -> Z -> Z.

Axiom bin_to_int_def :
  forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
  ((bin_to_int f n) = (bv_to_int (make_bv f n))).

Axiom bin_to_int_spec :
  forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
  ((bin_to_int f n) =
   (ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z) 0%Z
    n)) /\
  (0%Z <= (bin_to_int f n))%Z.

Parameter int_to_bin: Z -> Z -> Z -> Z.

Axiom int_to_bin_def :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((int_to_bin i n) = (value (int_to_bv i n))).

Axiom int_to_bin_spec :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  (i =
   (ind_isum
    (fun (k:Z) => (((int_to_bin i n) k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z)
    0%Z n)) /\
  ((binary (int_to_bin i n)) /\
   forall (k:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
   (((int_to_bin i n) k) =
    (int.EuclideanDivision.mod1
     (int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z))).

Axiom int_to_bv_tail :
  forall (i:Z) (n:Z), (1%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((int_to_bv (tail_bits i n) (n - 1%Z)%Z) = (tail (int_to_bv i n))).

Axiom bound_sum_dec :
  forall (bv:bitvec) (i:Z), ((1%Z <= i)%Z /\ (i <= (length bv))%Z) ->
  ((ind_isum
    (fun (l:Z) => (((value bv) l) * (power 2%Z ((length bv) - l)%Z))%Z) i
    ((length bv) + 1%Z)%Z)
   < (power 2%Z (((length bv) - i)%Z + 1%Z)%Z))%Z.

Axiom bv_to_int_to_bv :
  forall (i:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((bv_to_int (int_to_bv i n)) = i).

Axiom tail_bits_sum :
  forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((tail_bits i n) =
   (ind_isum
    (fun (l:Z) =>
     (((value (int_to_bv i n)) l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z)
    1%Z n)).

Axiom int_to_bv_to_int :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((int_to_bv (bv_to_int bv) (length bv)) = bv).

Axiom concat_to_int :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
  ((bv_to_int (concat_l bv i)) =
   ((bv_to_int bv) + (i * (power 2%Z (length bv)))%Z)%Z).

Axiom bounded_to_int :
  forall (bv:bitvec), ((bv_to_int bv) < (power 2%Z (length bv)))%Z.

Axiom int_to_bv_to_int_value :
  forall (bv:bitvec) (i:Z), (1%Z <= (length bv))%Z ->
  (((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
   (((value (int_to_bv (bv_to_int bv) (length bv))) i) = ((value bv) i))) /\
  (~ ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
   (((value (int_to_bv (bv_to_int bv) (length bv))) i) = 0%Z)).

Axiom int_to_bv_to_int_gen :
  forall (bv:bitvec) (n:Z), (1%Z <= (length bv))%Z -> (n = (length bv)) ->
  ((int_to_bv (bv_to_int bv) n) = bv).

Axiom bv_to_int_mod :
  forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
  ((int.EuclideanDivision.mod1 (bv_to_int bv)
    (power 2%Z ((length bv) - k)%Z))
   =
   (ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    k (length bv))).

Axiom bv_to_int_mod_rev :
  forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
  ((ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    k (length bv))
   =
   (int.EuclideanDivision.mod1 (bv_to_int bv)
    (power 2%Z ((length bv) - k)%Z))).

Axiom bv_to_int_mod_gen :
  forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) -> forall (bv:bitvec),
  ((length bv) = n) ->
  ((int.EuclideanDivision.mod1 (bv_to_int bv)
    (power 2%Z ((length bv) - k)%Z))
   =
   (ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    k (length bv))).

Axiom to_int_head_tail :
  forall (bv:bitvec), (1%Z <= (length bv))%Z ->
  ((bv_to_int bv) =
   ((bv_to_int (tail bv)) +
    ((head bv) * (power 2%Z ((length bv) - 1%Z)%Z))%Z)%Z) /\
  ((bv_to_int (tail bv)) =
   (int.EuclideanDivision.mod1 (bv_to_int bv)
    (power 2%Z ((length bv) - 1%Z)%Z))).

Axiom not_disj :
  forall (a:bool) (b:bool), ~ (a = true) -> ~ (b = true) ->
  ~ ((a = true) \/ (b = true)).

Parameter n_bvs: Z -> set bitvec.

Axiom n_bvs_def :
  forall (n:Z), (0%Z <= n)%Z ->
  ((n = 0%Z) ->
   ((n_bvs n) = (add (make_bv (fun (i:Z) => 0%Z) 0%Z) (empty : set bitvec)))) /\
  (~ (n = 0%Z) ->
   ((n_bvs n) =
    (union (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
     (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z))))).

Axiom n_bvs_spec :
  forall (n:Z), (0%Z <= n)%Z ->
  (forall (f:bitvec), (mem f (n_bvs n)) -> ((length f) = n)) /\
  ((forall (f:bitvec), (mem f (n_bvs n)) <-> ((length f) = n)) /\
   (0%Z < (cardinal (n_bvs n)))%Z).

Axiom n_bvs_node :
  forall (n:Z), (0%Z < n)%Z ->
  ((inter (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
    (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))
   = (empty : set bitvec)) /\
  ((union (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
    (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))
   = (n_bvs n)).

Axiom injective_node :
  forall (n:Z), (0%Z <= n)%Z ->
  (p_injective (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs n)) /\
  (p_injective (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs n)).

Axiom mat_sum_n_bvs_pos :
  forall (n:Z) (f:bitvec -> matrix t), (0%Z < n)%Z ->
  (constant_size (n_bvs n) f) ->
  ((mat_sum (n_bvs n) f) =
   (add_mat
    (mat_sum (n_bvs (n - 1%Z)%Z) (fun (bv:bitvec) => (f (concat_l bv 0%Z))))
    (mat_sum (n_bvs (n - 1%Z)%Z) (fun (bv:bitvec) => (f (concat_l bv 1%Z)))))).

Axiom mat_sum_n_bvs_null :
  forall (f:bitvec -> matrix t),
  ((mat_sum (n_bvs 0%Z) f) =
   (f (make_bv ((fun (y0:Z) (y1:Z) => y0) 0%Z) 0%Z))).

Axiom mat_sum_n_bvs_null_eq :
  forall (f:bitvec -> matrix t) (x:matrix t),
  (x = (f (make_bv ((fun (y0:Z) (y1:Z) => y0) 0%Z) 0%Z))) ->
  ((mat_sum (n_bvs 0%Z) f) = x).

Axiom get_n_bvs : forall (bv:bitvec), mem bv (n_bvs (length bv)).

Axiom get_n_bvs_gen :
  forall (bv:bitvec) (l:Z), (l = (length bv)) -> mem bv (n_bvs l).

Axiom set_n_bvs :
  forall (bv:bitvec), (mem bv (n_bvs (length bv))) -> forall (i:Z),
  ~ ((0%Z <= i)%Z /\ (i < (length bv))%Z) -> (((value bv) i) = 0%Z).

Axiom int_to_bv_n_bvs :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> mem (int_to_bv i n) (n_bvs n).

Axiom n_bvs_def_pos :
  forall (n:Z), (0%Z < n)%Z ->
  ((n_bvs n) =
   (union (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
    (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))).

Axiom map_n_bvs :
  forall (n:Z), (0%Z < n)%Z ->
  ((to_fset 0%Z (power 2%Z n)) =
   (map (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n))).

Parameter first_div: bitvec -> bitvec -> Z.

Axiom first_div_spec :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2) ->
  (forall (j:Z), ((0%Z <= j)%Z /\ (j < (first_div bv1 bv2))%Z) ->
   (((value bv1) j) = ((value bv2) j))) /\
  ((((first_div bv1 bv2) < (length bv1))%Z ->
    ~ (((value bv1) (first_div bv1 bv2)) = ((value bv2) (first_div bv1 bv2)))) /\
   ((0%Z <= (first_div bv1 bv2))%Z /\ ((first_div bv1 bv2) < (length bv1))%Z)).

Axiom injective_concat :
  forall (i:Z) (n:Z), (0%Z <= n)%Z -> ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
  p_injective (fun (bv:bitvec) => (concat_l bv i)) (n_bvs n).

Axiom inf_first_div :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2) -> forall (j:Z), (1%Z <= j)%Z ->
  ~ (((value bv1) j) = ((value bv2) j)) -> ((first_div bv1 bv2) <= j)%Z.

Axiom first_div_diff :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2) ->
  ~ (((value bv1) (first_div bv1 bv2)) = ((value bv2) (first_div bv1 bv2))).

Axiom exists_first_div :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2) ->
  exists i:Z,
  ((0%Z <= i)%Z /\ (i < (length bv1))%Z) /\ (i = (first_div bv1 bv2)).

Axiom set_diff_length :
  forall (bv1:bitvec) (bv2:bitvec), ~ ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2).

Axiom set_diff_val :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z), ((length bv1) = (length bv2)) ->
  ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
  ~ (((value bv1) i) = ((value bv2) i)) -> ~ (bv1 = bv2).

Parameter fc7: bitvec -> Z -> Z.

Parameter fc8: bitvec -> Z -> Z.

Axiom fc_def7 :
  forall (bv:bitvec) (l:Z),
  ((l < (length bv))%Z ->
   (((fc7 bv) l) =
    (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)) /\
  (~ (l < (length bv))%Z -> (((fc7 bv) l) = 0%Z)).

Axiom fc_def8 :
  forall (bv:bitvec) (l:Z),
  ((l < (length bv))%Z ->
   (((fc8 bv) l) =
    (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)) /\
  (~ (l < (length bv))%Z -> (((fc8 bv) l) = 0%Z)).

Axiom kth_decomp :
  forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
  ((bv_to_int bv) =
   (((ind_isum (fc7 bv) 0%Z k) +
     (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)%Z
    + (ind_isum (fc8 bv) (k + 1%Z)%Z (length bv)))%Z) /\
  ((bv_to_int bv) =
   (((ind_isum
      (fun (l:Z) =>
       (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
      0%Z k)
     + (((value bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)%Z
    +
    (ind_isum
     (fun (l:Z) =>
      (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
     (k + 1%Z)%Z (length bv)))%Z).

Axiom int_to_bv_prod :
  forall (i:Z) (j:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((ind_product
    (fun (k:Z) =>
     (indic ((value (int_to_bv i n)) k) ((value (int_to_bv j n)) k)))
    0%Z n)
   = (indic i j)).

Axiom int_to_bv_prod_gen :
  forall (i:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((ind_product
    (fun (k:Z) =>
     (indic ((value (int_to_bv i n)) k) ((value (int_to_bv j n)) k)))
    0%Z n)
   = (indic i j)).

Axiom kth_decomp_bound_zero :
  forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
  (((value bv) k) = 0%Z) ->
  ((ind_isum
    (fun (l:Z) =>
     (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
    0%Z k)
   <= (bv_to_int bv))%Z /\
  ((bv_to_int bv) <
   ((ind_isum
     (fun (l:Z) =>
      (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
     0%Z k)
    + (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))%Z)%Z.

Axiom kth_decomp_bound_one :
  forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
  (((value bv) k) = 1%Z) ->
  (((ind_isum
     (fun (l:Z) =>
      (((value bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
     0%Z k)
    + (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))%Z
   <= (bv_to_int bv))%Z /\
  ((bv_to_int bv) <
   ((ind_isum
     (fun (l:Z) =>
      (((value bv) l) * (power 2%Z (((length bv) - l)%Z - 1%Z)%Z))%Z)
     0%Z k)
    + (power 2%Z ((length bv) - k)%Z))%Z)%Z.

Axiom pre_injective_bv_to_int :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ~ (bv1 = bv2) -> ~ ((bv_to_int bv1) = (bv_to_int bv2)).

Axiom injective_bv_to_int :
  forall (n:Z), (0%Z <= n)%Z ->
  p_injective (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n).

Axiom bijective_to_int :
  forall (n:Z), (0%Z < n)%Z ->
  p_bijective (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n)
  (to_fset 0%Z (power 2%Z n)).

Axiom n_bvs_card :
  forall (n:Z), (0%Z <= n)%Z -> ((cardinal (n_bvs n)) = (power 2%Z n)).

Axiom concat_first_term_zero :
  forall (e:bitvec) (i:Z), (0%Z <= i)%Z ->
  (mem e (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs i))) ->
  (((value e) 0%Z) = 0%Z).

Axiom concat_first_term_one :
  forall (e:bitvec) (i:Z), (0%Z <= i)%Z ->
  (mem e (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs i))) ->
  (((value e) 0%Z) = 1%Z).

Axiom sum_concat :
  forall (f:bitvec -> matrix t) (i:Z) (r:Z) (c:Z), (0%Z < i)%Z ->
  (forall (bv:bitvec), ((rows (f bv)) = r)) ->
  (forall (bv:bitvec), ((columns (f bv)) = c)) ->
  ((mat_sum (n_bvs i)
    (fun (bv:bitvec) =>
     (add_mat (f (concat_l bv 0%Z)) (f (concat_l bv 1%Z)))))
   = (mat_sum (n_bvs (i + 1%Z)%Z) f)).

Parameter repeat_: a_circuit_ -> Z -> a_circuit_.

Axiom repeat__def :
  forall (c:a_circuit_) (k:Z), (1%Z <= k)%Z ->
  ((k = 1%Z) -> ((repeat_ c k) = c)) /\
  (~ (k = 1%Z) -> ((repeat_ c k) = (a_parallel_ (repeat_ c (k - 1%Z)%Z) c))).

Axiom repeat__spec :
  forall (c:a_circuit_) (k:Z), (1%Z <= k)%Z ->
  ((a_depth_ (repeat_ c k)) = ((a_depth_ c) * k)%Z) /\
  (((a_sum_range_ (repeat_ c k)) = (k * (a_sum_range_ c))%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ (repeat_ c k)))%Z) ->
     ((a_ket_part_ (repeat_ c k) bvx bvy i) =
      (a_ket_part_ c
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
        ((a_depth_ c) * (int.EuclideanDivision.div i (a_depth_ c)))%Z)
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
        ((a_sum_range_ c) * (int.EuclideanDivision.div i (a_depth_ c)))%Z)
       (int.EuclideanDivision.mod1 i (a_depth_ c))))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part_ (repeat_ c k) bvx bvy) =
     (ind_product
      (fun (k1:Z) =>
       (a_phase_part_ c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
         (k1 * (a_depth_ c))%Z)
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
         (k1 * (a_sum_range_ c))%Z)))
      0%Z k)))).

Parameter bin_and: Z -> Z -> Z.

Axiom bin_and_def :
  forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < 2%Z)%Z) ->
  (((i = 1%Z) /\ (j = 1%Z)) -> ((bin_and i j) = 1%Z)) /\
  (~ ((i = 1%Z) /\ (j = 1%Z)) -> ((bin_and i j) = 0%Z)).

Axiom bin_and_spec :
  forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < 2%Z)%Z) ->
  ((0%Z <= (bin_and i j))%Z /\ ((bin_and i j) < 2%Z)%Z) /\
  ((((bin_and i j) = 1%Z) <-> ((i = 1%Z) /\ (j = 1%Z))) /\
   (((bin_and i j) = 0%Z) <-> ((i = 0%Z) \/ (j = 0%Z)))).

Parameter bin_andv: bitvec -> bitvec -> bitvec.

Parameter result11: bitvec -> bitvec -> Z -> Z.

Axiom result_def11 :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  (((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((result11 bv1 bv2) i) = (bin_and ((value bv1) i) ((value bv2) i)))) /\
  (~ ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((result11 bv1 bv2) i) = 0%Z)).

Axiom bin_andv_def :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ((bin_andv bv1 bv2) = (make_bv (result11 bv1 bv2) (length bv1))).

Axiom bin_andv_spec :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  ((length (bin_andv bv1 bv2)) = (length bv1)) /\
  (((bin_andv bv1 bv2) =
    (make_bv (fun (i:Z) => (bin_and ((value bv1) i) ((value bv2) i)))
     (length bv1))) /\
   ((bvlength (value (bin_andv bv1 bv2)) (length bv1)) /\
    forall (i:Z), ((0%Z <= i)%Z /\ (i < (length (bin_andv bv1 bv2)))%Z) ->
    (((((value bv1) i) = 1%Z) /\ (((value bv2) i) = 1%Z)) ->
     (((value (bin_andv bv1 bv2)) i) = 1%Z)) /\
    (~ ((((value bv1) i) = 1%Z) /\ (((value bv2) i) = 1%Z)) ->
     (((value (bin_andv bv1 bv2)) i) = 0%Z)))).

Axiom bin_andv_values :
  forall (bv1:bitvec) (bv2:bitvec) (k:Z), ((length bv1) = (length bv2)) ->
  ((0%Z <= k)%Z /\ (k < (length bv1))%Z) ->
  (((value (bin_andv bv1 bv2)) k) =
   (bin_and ((value bv1) k) ((value bv2) k))).

Parameter int_bin_and_seq: Z -> Z -> Z -> bitvec.

Axiom int_bin_and_seq_def :
  forall (i:Z) (j:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((int_bin_and_seq i j n) = (bin_andv (int_to_bv i n) (int_to_bv j n))).

Axiom int_bin_and_seq_spec :
  forall (i:Z) (j:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  (forall (k:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
   (((value (int_bin_and_seq i j n)) k) =
    (bin_and ((value (int_to_bv i n)) k) ((value (int_to_bv j n)) k)))) /\
  (bvlength (value (int_bin_and_seq i j n)) n).

Axiom int_bin_and_seq_inst :
  forall (i:Z) (j:Z) (n:Z) (k:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
  (((value (int_bin_and_seq i j n)) k) =
   (bin_and ((value (int_to_bv i n)) k) ((value (int_to_bv j n)) k))).

Axiom int_bin_and_seq_zero :
  forall (i:Z) (j:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> (~ (0%Z = i) -> (j = 0%Z)) ->
  forall (k:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
  (((value (int_bin_and_seq i j n)) k) = 0%Z).

Parameter popcount: (Z -> Z) -> Z -> Z -> Z.

Axiom popcount_def :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  ((j = i) -> ((popcount t1 i j) = (t1 i))) /\
  (~ (j = i) ->
   ((popcount t1 i j) = ((t1 i) + (popcount t1 (i + 1%Z)%Z j))%Z)).

Axiom popcount_spec :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  ((popcount t1 i j) = (ind_isum t1 i (j + 1%Z)%Z)) /\
  (0%Z <= (popcount t1 i j))%Z.

Parameter and_bin: (Z -> Z) -> (Z -> Z) -> Z -> Z.

Axiom and_bin_def :
  forall (t1:Z -> Z) (t2:Z -> Z) (i:Z), (binary t1) -> (binary t2) ->
  ((and_bin t1 t2 i) = ((t1 i) * (t2 i))%Z).

Axiom positive_popcount :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  (0%Z <= (popcount t1 i j))%Z.

Axiom popcount_right_extension :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  ((popcount t1 i j) = ((popcount t1 i (j - 1%Z)%Z) + (t1 j))%Z).

Axiom popcount_left_extension :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  ((popcount t1 i j) = ((popcount t1 (i + 1%Z)%Z j) + (t1 i))%Z).

Axiom popcount_zero :
  forall (t1:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k <= j)%Z) -> ((t1 k) = 0%Z)) ->
  (i <= j)%Z -> ((popcount t1 i j) = 0%Z).

Axiom popcount_one :
  forall (t1:Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  (j = i) -> ((popcount t1 i j) = (t1 i)).

Axiom popcount_right_extension_comm :
  forall (t1:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  (((popcount t1 i (j - 1%Z)%Z) + (t1 j))%Z = (popcount t1 i j)).

Axiom popcount_eq :
  forall (t1:Z -> Z) (t':Z -> Z) (i:Z) (j:Z),
  (forall (k:Z), ((i <= k)%Z /\ (k <= j)%Z) -> ((t1 k) = (t' k))) ->
  (i <= j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < (j + 1%Z)%Z)%Z) ->
   (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) ->
  ((popcount t1 i j) = (popcount t' i j)).

Axiom repeat_one : forall (c:a_circuit_), ((repeat_ c 1%Z) = c).

Axiom repeat_plus_one :
  forall (c:a_circuit_) (k:Z), (2%Z <= k)%Z ->
  ((repeat_ c k) = (a_parallel_ (repeat_ c (k - 1%Z)%Z) c)).

Parameter repeat: a_circuit -> Z -> a_circuit.

Axiom repeat_def :
  forall (c:a_circuit) (k:Z), (1%Z <= k)%Z ->
  ((k = 1%Z) -> ((repeat c k) = c)) /\
  (~ (k = 1%Z) -> ((repeat c k) = (a_parallel (repeat c (k - 1%Z)%Z) c))).

Axiom repeat_spec :
  forall (c:a_circuit) (k:Z), (1%Z <= k)%Z ->
  ((a_to_gen_circuit (repeat c k)) = (repeat_ (a_to_gen_circuit c) k)) /\
  (((a_depth (repeat c k)) = ((a_depth c) * k)%Z) /\
   (((a_sum_range (repeat c k)) = (k * (a_sum_range c))%Z) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < (a_depth (repeat c k)))%Z) ->
      ((a_ket_part (repeat c k) bvx bvy i) =
       (a_ket_part c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
         ((a_depth c) * (int.EuclideanDivision.div i (a_depth c)))%Z)
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
         ((a_sum_range c) * (int.EuclideanDivision.div i (a_depth c)))%Z)
        (int.EuclideanDivision.mod1 i (a_depth c))))) /\
     forall (bvx:Z -> Z) (bvy:Z -> Z),
     ((a_phase_part (repeat c k) bvx bvy) =
      (d_sum_
       (fun (k1:Z) =>
        (a_phase_part c
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
          (k1 * (a_depth c))%Z)
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvy)
          (k1 * (a_sum_range c))%Z)))
       0%Z k))))).

Axiom id_one_spec :
  ((a_depth (a_phase zero_d_)) = 1%Z) /\
  (((a_sum_range (a_phase zero_d_)) = 0%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < 1%Z)%Z) ->
     ((a_ket_part (a_phase zero_d_) bvx bvy i) = (bvx i))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (a_phase zero_d_) bvx bvy) = zero_d_))).

Axiom id_one__spec :
  ((a_to_gen_circuit (a_phase zero_d_)) = (a_phase_ (dyadic 0%Z 0%Z))) /\
  (((a_depth_ (a_to_gen_circuit (a_phase zero_d_))) = 1%Z) /\
   (((a_sum_range_ (a_to_gen_circuit (a_phase zero_d_))) = 0%Z) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < 1%Z)%Z) ->
      ((a_ket_part_ (a_to_gen_circuit (a_phase zero_d_)) bvx bvy i) =
       (bvx i))) /\
     forall (bvx:Z -> Z) (bvy:Z -> Z),
     ((a_phase_part_ (a_to_gen_circuit (a_phase zero_d_)) bvx bvy) =
      (value1 (dyadic 0%Z 0%Z)))))).

(* Why3 assumption *)
Definition a_diag_ (c:a_circuit_) : Prop :=
  (a_flat_ c) /\
  forall (bvx:Z -> Z), forall (i:Z),
  ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) -> ((a_flat_ket_ c bvx i) = (bvx i)).

(* Why3 assumption *)
Definition a_diag (c:a_circuit) : Prop :=
  (a_flat c) /\
  forall (bvx:Z -> Z), forall (i:Z), ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
  ((a_flat_ket c bvx i) = (bvx i)).

Axiom diag_to_gen :
  forall (c:a_circuit), (a_diag c) -> a_diag_ (a_to_gen_circuit c).

Axiom diag_to_flat : forall (c:a_circuit), (a_diag c) -> a_flat c.

Axiom ket_to_flat_ :
  forall (c:a_circuit_) (bvx:Z -> Z) (bvy:Z -> Z) (i:Z), (a_flat_ c) ->
  ((a_ket_part_ c bvx bvy i) = (a_flat_ket_ c bvx i)).

Axiom ket_to_flat :
  forall (c:a_circuit) (bvx:Z -> Z) (bvy:Z -> Z) (i:Z), (a_flat c) ->
  ((a_ket_part c bvx bvy i) = (a_flat_ket c bvx i)).

Axiom flat_to_ket_ :
  forall (c:a_circuit_) (bvx:Z -> Z) (i:Z), (a_flat_ c) ->
  forall (bvy:Z -> Z), ((a_flat_ket_ c bvx i) = (a_ket_part_ c bvx bvy i)).

Axiom flat_to_ketz_ :
  forall (c:a_circuit_) (bvx:Z -> Z) (i:Z), (a_flat_ c) ->
  ((a_flat_ket_ c bvx i) = (a_ket_part_ c bvx (fun (us:Z) => 0%Z) i)).

Axiom flat_to_ket :
  forall (c:a_circuit) (bvx:Z -> Z) (i:Z), (a_flat c) -> forall (bvy:Z -> Z),
  ((a_flat_ket c bvx i) = (a_ket_part c bvx bvy i)).

Axiom flat_to_ketz :
  forall (c:a_circuit) (bvx:Z -> Z) (i:Z), (a_flat c) ->
  ((a_flat_ket c bvx i) = (a_ket_part c bvx (fun (us:Z) => 0%Z) i)).

Axiom phase_to_flat_ :
  forall (c:a_circuit_) (bvx:Z -> Z) (bvy:Z -> Z), (a_flat_ c) ->
  ((a_phase_part_ c bvx bvy) = (a_flat_phase_ c bvx)).

Axiom phase_to_flat :
  forall (c:a_circuit) (bvx:Z -> Z) (bvy:Z -> Z), (a_flat c) ->
  ((a_phase_part c bvx bvy) = (a_flat_phase c bvx)).

Axiom flat_to_phase_ :
  forall (c:a_circuit_) (bvx:Z -> Z), (a_flat_ c) -> forall (bvy:Z -> Z),
  ((a_flat_phase_ c bvx) = (a_phase_part_ c bvx bvy)).

Axiom flat_to_phasez_ :
  forall (c:a_circuit_) (bvx:Z -> Z), (a_flat_ c) ->
  ((a_flat_phase_ c bvx) = (a_phase_part_ c bvx (fun (us:Z) => 0%Z))).

Axiom flat_to_phase :
  forall (c:a_circuit) (bvx:Z -> Z), (a_flat c) -> forall (bvy:Z -> Z),
  ((a_flat_phase c bvx) = (a_phase_part c bvx bvy)).

Axiom flat_to_phasez :
  forall (c:a_circuit) (bvx:Z -> Z), (a_flat c) ->
  ((a_flat_phase c bvx) = (a_phase_part c bvx (fun (us:Z) => 0%Z))).

Axiom ket_diag :
  forall (c:a_circuit), (a_flat c) ->
  (forall (i:Z), forall (bvx:Z -> Z) (bvy:Z -> Z),
   ((a_ket_part c bvx bvy i) = (bvx i))) ->
  a_diag c.

Axiom diag_ket_ :
  forall (c:a_circuit_), (a_diag_ c) -> forall (i:Z),
  ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) -> forall (bvx:Z -> Z) (bvy:Z -> Z),
  ((a_ket_part_ c bvx bvy i) = (bvx i)).

Axiom diag_ket :
  forall (c:a_circuit), (a_diag c) -> forall (i:Z),
  ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) -> forall (bvx:Z -> Z) (bvy:Z -> Z),
  ((a_ket_part c bvx bvy i) = (bvx i)).

Axiom diag_phase_spec :
  forall (o:d_frac_),
  ((a_depth (a_phase o)) = 1%Z) /\
  ((a_diag (a_phase o)) /\
   forall (bvx:Z -> Z), ((a_flat_phase (a_phase o) bvx) = o)).

Axiom diag_rz_spec :
  forall (o:d_frac_),
  ((a_depth (a_rz o)) = 1%Z) /\
  ((a_diag (a_rz o)) /\
   forall (bvx:Z -> Z),
   ((a_flat_phase (a_rz o) bvx) = (phase_inv_ (1%Z - (bvx 0%Z))%Z o))).

Parameter diag_sequence: a_circuit -> a_circuit -> a_circuit.

Axiom diag_sequence_def :
  forall (d:a_circuit) (e:a_circuit), ((a_depth d) = (a_depth e)) ->
  (a_diag d) -> (a_diag e) -> ((diag_sequence d e) = (a_sequence d e)).

Axiom diag_sequence_spec :
  forall (d:a_circuit) (e:a_circuit), ((a_depth d) = (a_depth e)) ->
  (a_diag d) -> (a_diag e) ->
  (a_diag (diag_sequence d e)) /\
  (((a_depth (diag_sequence d e)) = (a_depth d)) /\
   forall (bvx:Z -> Z),
   ((a_flat_phase (diag_sequence d e) bvx) =
    (add_ (a_flat_phase d bvx)
     (a_flat_phase e
      (((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z) => (a_flat_ket y0 y1 y2)) d)
       bvx))))).

Parameter diag_parallel: a_circuit -> a_circuit -> a_circuit.

Axiom diag_parallel_def :
  forall (d:a_circuit) (e:a_circuit), (a_diag d) -> (a_diag e) ->
  ((diag_parallel d e) = (a_parallel d e)).

Axiom diag_parallel_spec :
  forall (d:a_circuit) (e:a_circuit), (a_diag d) -> (a_diag e) ->
  ((a_depth (diag_parallel d e)) = ((a_depth d) + (a_depth e))%Z) /\
  ((a_diag (diag_parallel d e)) /\
   forall (bvx:Z -> Z),
   ((a_flat_phase (diag_parallel d e) bvx) =
    (add_ (a_flat_phase d bvx)
     (a_flat_phase e
      (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) (a_depth d)))))).

Parameter repeat_diag: a_circuit -> Z -> a_circuit.

Axiom repeat_diag_def :
  forall (c:a_circuit) (k:Z), (1%Z <= k)%Z -> (a_diag c) ->
  ((k = 1%Z) -> ((repeat_diag c k) = c)) /\
  (~ (k = 1%Z) ->
   ((repeat_diag c k) = (diag_parallel (repeat_diag c (k - 1%Z)%Z) c))).

Axiom repeat_diag_spec :
  forall (c:a_circuit) (k:Z), (1%Z <= k)%Z -> (a_diag c) ->
  (a_diag (repeat_diag c k)) /\
  (((repeat_diag c k) = (repeat c k)) /\
   (((a_depth (repeat_diag c k)) = ((a_depth c) * k)%Z) /\
    forall (bvx:Z -> Z),
    ((a_flat_phase (repeat_diag c k) bvx) =
     (d_sum_
      (fun (i:Z) =>
       (a_flat_phase c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx)
         ((a_depth c) * i)%Z)))
      0%Z k)))).

Parameter circ_ident: Z -> a_circuit.

Axiom circ_ident_def :
  forall (k:Z), (0%Z < k)%Z ->
  ((circ_ident k) = (repeat_diag (a_phase zero_d_) k)).

Axiom circ_ident_spec :
  forall (k:Z), (0%Z < k)%Z ->
  (a_diag (circ_ident k)) /\
  (((circ_ident k) = (repeat (a_phase zero_d_) k)) /\
   (((a_depth (circ_ident k)) = k) /\
    forall (bvx:Z -> Z), ((a_flat_phase (circ_ident k) bvx) = zero_d_))).

Parameter circ_ident_: Z -> a_circuit_.

Axiom circ_ident__def :
  forall (k:Z), (0%Z < k)%Z ->
  ((circ_ident_ k) = (a_to_gen_circuit (circ_ident k))).

Axiom circ_ident__spec :
  forall (k:Z), (0%Z < k)%Z ->
  (a_diag_ (circ_ident_ k)) /\
  (((circ_ident_ k) = (repeat_ (a_to_gen_circuit (a_phase zero_d_)) k)) /\
   (((a_depth_ (circ_ident_ k)) = k) /\
    forall (bvx:Z -> Z), (binary bvx) ->
    ((a_flat_phase_ (circ_ident_ k) bvx) = tone))).

Parameter diag_seq_prod: (Z -> a_circuit) -> Z -> Z -> Z -> a_circuit.

Axiom diag_seq_prod_def :
  forall (f:Z -> a_circuit) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((a_depth (f k)) = d)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> a_diag (f k)) ->
  ((j = (i + 1%Z)%Z) -> ((diag_seq_prod f d i j) = (f i))) /\
  (~ (j = (i + 1%Z)%Z) ->
   ((diag_seq_prod f d i j) =
    (diag_sequence (diag_seq_prod f d i (j - 1%Z)%Z) (f (j - 1%Z)%Z)))).

Axiom diag_seq_prod_spec :
  forall (f:Z -> a_circuit) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((a_depth (f k)) = d)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> a_diag (f k)) ->
  (a_diag (diag_seq_prod f d i j)) /\
  (((a_depth (diag_seq_prod f d i j)) = d) /\
   forall (bvx:Z -> Z),
   ((a_flat_phase (diag_seq_prod f d i j) bvx) =
    (d_sum_ (fun (k:Z) => (a_flat_phase (f k) bvx)) i j))).

Axiom diag_seq_prod_cardone :
  forall (f:Z -> a_circuit) (d:Z) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
  ((a_depth (f i)) = d) -> (a_diag (f i)) ->
  ((diag_seq_prod f d i j) = (f i)).

Parameter diag_seq_prod_plus_one: (Z -> a_circuit) -> Z -> Z -> Z -> unit.

Axiom diag_seq_prod_plus_one_def :
  forall (f:Z -> a_circuit) (d:Z) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((a_depth (f k)) = d)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> a_diag (f k)) ->
  ((diag_seq_prod_plus_one f d i j) = tt).

Axiom diag_seq_prod_plus_one_spec :
  forall (f:Z -> a_circuit) (d:Z) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((a_depth (f k)) = d)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> a_diag (f k)) ->
  ((diag_seq_prod f d i j) =
   (diag_sequence (diag_seq_prod f d i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).

Axiom diag_seq_prod_eq :
  forall (f:Z -> a_circuit) (g:Z -> a_circuit) (d:Z) (i:Z) (j:Z),
  (i < j)%Z ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((a_depth (f k)) = d)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> a_diag (f k)) ->
  (forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
  ((diag_seq_prod f d i j) = (diag_seq_prod g d i j)).

Parameter is_a_ket: (matrix t) -> Prop.

Axiom Is_a_ket :
  forall (m:matrix t),
  (is_a_ket m) <->
  (((columns m) = 1%Z) /\
   exists s:Z, (0%Z <= s)%Z /\ ((rows m) = (power 2%Z s))).

Parameter is_a_ket_l: (matrix t) -> Z -> Prop.

Axiom Is_a_ket_l :
  forall (m:matrix t), forall (l:Z),
  (is_a_ket_l m l) <->
  ((0%Z <= l)%Z /\ (((columns m) = 1%Z) /\ ((rows m) = (power 2%Z l)))).

Parameter ket_valid_index: (matrix t) -> Z -> Prop.

Axiom Ket_valid_index :
  forall (m:matrix t), forall (i:Z),
  (ket_valid_index m i) <-> (valid_index m i 0%Z).

Parameter ket_length: (matrix t) -> Z.

Axiom ket_length_def :
  forall (m:matrix t), (is_a_ket m) ->
  ((ket_length m) = ((binary_length (rows m)) - 1%Z)%Z).

Axiom ket_length_spec :
  forall (m:matrix t), (is_a_ket m) ->
  (0%Z <= (ket_length m))%Z /\ ((rows m) = (power 2%Z (ket_length m))).

Axiom assert_make_ket :
  forall (r:Z) (c:Z) (f:Z -> Z -> t) (i:Z), (c = 1%Z) ->
  ((0%Z <= i)%Z /\ (i < r)%Z) -> ((get (make_f r c f) i 0%Z) = ((f i) 0%Z)).

Axiom ket_kronecker_values :
  forall (m:matrix t) (n:matrix t) (i:Z), (is_a_ket m) -> (is_a_ket n) ->
  ((0%Z <= i)%Z /\ (i < ((rows m) * (rows n))%Z)%Z) ->
  ((get (kronecker m n) i 0%Z) =
   (infix_asdt (get m (int.EuclideanDivision.div i (rows n)) 0%Z)
    (get n (int.EuclideanDivision.mod1 i (rows n)) 0%Z))).

Axiom ket_l_to_ket :
  forall (m:matrix t) (l:Z), (is_a_ket_l m l) ->
  (is_a_ket m) /\ ((ket_length m) = l).

Axiom ket_l_to_ket_gen :
  forall (m:matrix t), (exists l:Z, is_a_ket_l m l) -> is_a_ket m.

Axiom ket_to_ket_l :
  forall (m:matrix t), (is_a_ket m) -> is_a_ket_l m (ket_length m).

Axiom set_ket_valid_index :
  forall (m:matrix t) (i:Z), (is_a_ket m) ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) -> ket_valid_index m i.

Axiom ket_to_ket_l_l :
  forall (m:matrix t) (i:Z), (is_a_ket m) -> ((ket_length m) = i) ->
  is_a_ket_l m i.

Axiom set_constant_size_ket :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t),
  (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
   ((ket_length (f e)) = (ket_length (f e')))) ->
  constant_size s f.

Parameter add_ket: (matrix t) -> (matrix t) -> matrix t.

Axiom add_ket_def :
  forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
  ((ket_length m) = (ket_length n)) -> ((add_ket m n) = (add_mat m n)).

Axiom add_ket_spec :
  forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
  ((ket_length m) = (ket_length n)) ->
  (is_a_ket (add_ket m n)) /\
  (((ket_length (add_ket m n)) = (ket_length m)) /\
   forall (i:Z), (ket_valid_index (add_ket m n) i) ->
   ((get (add_ket m n) i 0%Z) = (infix_pldt (get m i 0%Z) (get n i 0%Z)))).

Parameter add_ket_l: (matrix t) -> (matrix t) -> Z -> matrix t.

Axiom add_ket_l_def :
  forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
  (is_a_ket_l n l) -> ((add_ket_l m n l) = (add_ket m n)).

Axiom add_ket_l_spec :
  forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
  (is_a_ket_l n l) ->
  (is_a_ket_l (add_ket_l m n l) l) /\
  forall (i:Z), (ket_valid_index (add_ket_l m n l) i) ->
  ((get (add_ket_l m n l) i 0%Z) = (infix_pldt (get m i 0%Z) (get n i 0%Z))).

Axiom set_equal_ket :
  forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
  ((ket_length m) = (ket_length n)) ->
  (forall (i:Z), (ket_valid_index m i) -> ((get m i 0%Z) = (get n i 0%Z))) ->
  (m = n).

Axiom set_equal_ket_l :
  forall (m:matrix t) (n:matrix t),
  (exists l:Z, (is_a_ket_l m l) /\ (is_a_ket_l n l)) ->
  (forall (i:Z), (ket_valid_index m i) -> ((get m i 0%Z) = (get n i 0%Z))) ->
  (m = n).

Axiom get_ket_length :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
  ((rows m) = (power 2%Z n)) -> ((ket_length m) = n).

Axiom set_ket_length :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
  ((ket_length m) = n) -> ((rows m) = (power 2%Z n)).

Axiom scalar_ket :
  forall (x:matrix t) (a:t), (is_a_ket x) -> is_a_ket (infix_asdtdt a x).

Axiom scalar_ket_length :
  forall (m:matrix t) (a:t), (is_a_ket m) ->
  ((ket_length (infix_asdtdt a m)) = (ket_length m)).

Axiom scalar_ket_valid_index :
  forall (m:matrix t) (a:t) (i:Z), (ket_valid_index m i) -> (is_a_ket m) ->
  ket_valid_index (infix_asdtdt a m) i.

Axiom scalar_ket_l :
  forall (x:matrix t) (l:Z) (a:t), (is_a_ket_l x l) ->
  is_a_ket_l (infix_asdtdt a x) l.

Axiom scalar_ket_value :
  forall (x:matrix t) (i:Z) (a:t), (is_a_ket x) -> (ket_valid_index x i) ->
  ((get (infix_asdtdt a x) i 0%Z) = (infix_asdt a (get x i 0%Z))).

Axiom scalar_ket_value_rev :
  forall (x:matrix t) (i:Z) (a:t), (is_a_ket x) -> (ket_valid_index x i) ->
  ((infix_asdt a (get x i 0%Z)) = (get (infix_asdtdt a x) i 0%Z)).

Axiom add_ket_is_a_ket :
  forall (x:matrix t) (y:matrix t), (is_a_ket x) -> (is_a_ket y) ->
  ((ket_length x) = (ket_length y)) -> is_a_ket (add_mat x y).

Axiom set_ket_length_gen :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
  ((power 2%Z (ket_length m)) = n) -> ((rows m) = n).

Axiom set_is_a_ket :
  forall (m:matrix t), ((columns m) = 1%Z) ->
  (exists s:Z, (0%Z <= s)%Z /\ ((rows m) = (power 2%Z s))) -> is_a_ket m.

Axiom set_is_a_ket_l :
  forall (m:matrix t) (l:Z), (0%Z <= l)%Z -> ((columns m) = 1%Z) ->
  ((rows m) = (power 2%Z l)) -> is_a_ket_l m l.

Axiom get_is_a_ket :
  forall (m:matrix t), (is_a_ket m) ->
  ((columns m) = 1%Z) /\ ((rows m) = (power 2%Z (ket_length m))).

Axiom get_ket_columns :
  forall (m:matrix t), (is_a_ket m) -> ((columns m) = 1%Z).

Axiom get_ket_rows :
  forall (m:matrix t), (is_a_ket m) ->
  ((rows m) = (power 2%Z (ket_length m))).

Axiom get_ket_rows_gen :
  forall (m:matrix t) (i:Z), (is_a_ket m) ->
  (i = (power 2%Z (ket_length m))) -> ((rows m) = i).

Axiom get_ket_rows_length :
  forall (m:matrix t) (l:Z), (is_a_ket m) -> ((ket_length m) = l) ->
  ((rows m) = (power 2%Z l)).

Axiom ket_kronecker :
  forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
  (is_a_ket (kronecker m n)) /\
  ((ket_length (kronecker m n)) = ((ket_length m) + (ket_length n))%Z).

Parameter ket: Z -> Z -> matrix t.

Axiom ket_def :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
   ((ket n i) = (set1 (make (power 2%Z n) 1%Z tzero) i 0%Z tone))) /\
  (~ ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
   ((ket n i) = (make 1%Z 1%Z tzero))).

Axiom ket_spec :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  (is_a_ket (ket n i)) /\
  ((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((ket_length (ket n i)) = n)) /\
   (((columns (ket n i)) = 1%Z) /\
    ((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
      ((rows (ket n i)) = (power 2%Z n))) /\
     ((forall (j:Z), (valid_index (ket n i) j 0%Z) ->
       ((get (ket n i) j 0%Z) = (indic j i))) /\
      ((forall (j:Z), (valid_index (ket n i) j 0%Z) -> ~ (i = j) ->
        ((get (ket n i) j 0%Z) = tzero)) /\
       (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
        ((get (ket n i) i 0%Z) = tone))))))).

Axiom ket_l :
  forall (n:Z) (m:Z) (i:Z), (0%Z <= n)%Z -> (n = m) ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_ket_l (ket n i) m.

Axiom ket_eq :
  forall (n1:Z) (n2:Z) (i1:Z) (i2:Z), (0%Z <= n1)%Z -> (n1 = n2) ->
  (i1 = i2) -> ((ket n1 i1) = (ket n2 i2)).

Axiom ket_rows :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((rows (ket n i)) = (power 2%Z n)).

Axiom ket_columns :
  forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((columns (ket n i)) = 1%Z).

Axiom get_ket_ :
  forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  (is_a_ket m) /\
  (((ket_length m) = n) /\
   (((columns m) = 1%Z) /\
    (((rows m) = (power 2%Z n)) /\
     ((forall (j:Z), (valid_index m j 0%Z) -> ((get m j 0%Z) = (indic j i))) /\
      ((forall (j:Z), (valid_index m j 0%Z) -> ~ (i = j) ->
        ((get m j 0%Z) = tzero)) /\
       ((get m i 0%Z) = tone)))))).

Axiom get_ket_value :
  forall (i:Z) (n:Z) (j:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((get (ket n i) j 0%Z) = (indic j i)).

Axiom get_ket_value_z :
  forall (i:Z) (n:Z) (j:Z) (z:Z), (z = 0%Z) -> (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((get (ket n i) j z) = (indic j i)).

Axiom get__ket_value :
  forall (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
  ((get (ket n i) j 0%Z) = (indic j i)).

Axiom set_ket :
  forall (m:matrix t) (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((columns m) = 1%Z) ->
  ((rows m) = (power 2%Z n)) ->
  (forall (j:Z), (valid_index m j 0%Z) -> ((get m j 0%Z) = (indic j i))) ->
  (m = (ket n i)).

Axiom kronecker_kets :
  forall (i1:Z) (i2:Z) (n1:Z) (n2:Z), (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
  ((0%Z <= i1)%Z /\ (i1 < (power 2%Z n1))%Z) ->
  ((0%Z <= i2)%Z /\ (i2 < (power 2%Z n2))%Z) ->
  ((kronecker (ket n1 i1) (ket n2 i2)) =
   (ket (n1 + n2)%Z ((i1 * (power 2%Z n2))%Z + i2)%Z)).

Axiom kronecker_kets_bin_to_int :
  forall (f1:Z -> Z) (f2:Z -> Z) (n1:Z) (n2:Z), (binary f1) -> (binary f2) ->
  (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
  ((kronecker (ket n1 (bin_to_int f1 n1)) (ket n2 (bin_to_int f2 n2))) =
   (ket (n1 + n2)%Z
    (((bin_to_int f1 n1) * (power 2%Z n2))%Z + (bin_to_int f2 n2))%Z)).

Parameter result12: bitvec -> bitvec -> Z -> Z.

Axiom result_def12 :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  ((((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
   (((result12 bv1 bv2) i) = ((value bv2) (i - (length bv1))%Z))) /\
  (~ (((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
   (((result12 bv1 bv2) i) = ((value bv1) i))).

(* Why3 assumption *)
Definition concat (bv1:bitvec) (bv2:bitvec) : bitvec :=
  make_bv (result12 bv1 bv2) ((length bv1) + (length bv2))%Z.

Axiom concat_spec :
  forall (bv1:bitvec) (bv2:bitvec),
  ((length (concat bv1 bv2)) = ((length bv1) + (length bv2))%Z) /\
  ((forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
    (((value (concat bv1 bv2)) i) = ((value bv1) i))) /\
   ((forall (i:Z), ((length (concat bv1 bv2)) <= i)%Z ->
     (((value (concat bv1 bv2)) i) = ((value bv1) i))) /\
    forall (i:Z),
    (((length bv1) <= i)%Z /\ (i < (length (concat bv1 bv2)))%Z) ->
    (((value (concat bv1 bv2)) i) = ((value bv2) (i - (length bv1))%Z)))).

Axiom concat_length :
  forall (bv1:bitvec) (bv2:bitvec),
  ((length (concat bv1 bv2)) = ((length bv1) + (length bv2))%Z).

Parameter hpart: bitvec -> Z -> bitvec.

Axiom hpart_def :
  forall (bv:bitvec) (m:Z), (0%Z <= m)%Z ->
  ((hpart bv m) = (make_bv (value bv) m)).

Axiom hpart_spec :
  forall (bv:bitvec) (m:Z), (0%Z <= m)%Z ->
  ((length (hpart bv m)) = m) /\
  ((forall (k:Z), ((0%Z <= k)%Z /\ (k < m)%Z) ->
    (((value (hpart bv m)) k) = ((value bv) k))) /\
   forall (k:Z), ~ ((0%Z <= k)%Z /\ (k < m)%Z) ->
   (((value (hpart bv m)) k) = 0%Z)).

Axiom hpart_value :
  forall (bv:bitvec) (m:Z) (i:Z), (0%Z <= m)%Z ->
  (((0%Z <= i)%Z /\ (i < m)%Z) ->
   (((value (hpart bv m)) i) = ((value bv) i))) /\
  (~ ((0%Z <= i)%Z /\ (i < m)%Z) -> (((value (hpart bv m)) i) = 0%Z)).

Parameter tpart: bitvec -> Z -> bitvec.

Axiom tpart_def :
  forall (bv:bitvec) (m:Z), (0%Z <= m)%Z ->
  ((m <= (length bv))%Z ->
   ((tpart bv m) =
    (make_bv (fun (k:Z) => ((value bv) (k + m)%Z)) ((length bv) - m)%Z))) /\
  (~ (m <= (length bv))%Z ->
   ((tpart bv m) = (make_bv (fun (k:Z) => ((value bv) (k + m)%Z)) 0%Z))).

Axiom tpart_spec :
  forall (bv:bitvec) (m:Z), (0%Z <= m)%Z ->
  ((m <= (length bv))%Z -> ((length (tpart bv m)) = ((length bv) - m)%Z)) /\
  ((((length bv) < m)%Z -> ((length (tpart bv m)) = 0%Z)) /\
   forall (k:Z), ((0%Z <= k)%Z /\ (k < (length (tpart bv m)))%Z) ->
   (((value (tpart bv m)) k) = ((value bv) (k + m)%Z))).

Axiom tpart_value :
  forall (bv:bitvec) (m:Z) (i:Z), (0%Z <= m)%Z ->
  (((0%Z <= i)%Z /\ (i < ((length bv) - m)%Z)%Z) ->
   (((value (tpart bv m)) i) = ((value bv) (i + m)%Z))) /\
  (~ ((0%Z <= i)%Z /\ (i < ((length bv) - m)%Z)%Z) ->
   (((value (tpart bv m)) i) = 0%Z)).

Axiom tpart_length :
  forall (bv:bitvec) (m:Z), ((0%Z <= m)%Z /\ (m <= (length bv))%Z) ->
  ((length (tpart bv m)) = ((length bv) - m)%Z).

Axiom tpart_length_gen :
  forall (bv:bitvec) (m:Z) (l:Z), ((0%Z <= m)%Z /\ (m <= (length bv))%Z) ->
  (l = ((length bv) - m)%Z) -> ((length (tpart bv m)) = l).

Axiom concat_value_left :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
  (((value (concat bv1 bv2)) i) = ((value bv1) i)).

Axiom concat_value :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  ((((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
   (((value (concat bv1 bv2)) i) = ((value bv2) (i - (length bv1))%Z))) /\
  (~ (((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
   (((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
    (((value (concat bv1 bv2)) i) = ((value bv1) i))) /\
   (~ ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
    (((value (concat bv1 bv2)) i) = 0%Z))).

Axiom concat_value_right :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  (((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
  (((value (concat bv1 bv2)) i) = ((value bv2) (i - (length bv1))%Z)).

Axiom concat_value_out :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  (((length bv1) + (length bv2))%Z < i)%Z ->
  (((value (concat bv1 bv2)) i) = ((value bv1) i)).

Axiom concat_value_tpart :
  forall (bv1:bitvec) (bv2:bitvec) (i:Z),
  (((length bv1) <= i)%Z /\ (i < (length bv2))%Z) ->
  (((value (concat bv1 (tpart bv2 (length bv1)))) i) = ((value bv2) i)).

Axiom concat_value_ht :
  forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
  ((0%Z <= i)%Z /\ (i < (length bv3))%Z) ->
  (((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((value bv1) i) = ((value bv4) i))) ->
  (((length bv1) <= i)%Z -> (((value bv3) i) = ((value bv4) i))) ->
  (bv2 = (tpart bv3 (length bv1))) ->
  (((value (concat bv1 bv2)) i) = ((value bv4) i)).

Axiom concat_ht1 :
  forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((value bv1) i) = ((value bv4) i))) ->
  (forall (i:Z), ((length bv1) <= i)%Z ->
   (((value bv3) i) = ((value bv4) i))) ->
  ((length bv4) = ((length bv1) + (length bv2))%Z) ->
  (((length bv1) + (length bv2))%Z <= (length bv3))%Z ->
  (bv2 = (tpart bv3 (length bv1))) -> ((concat bv1 bv2) = bv4).

Axiom set_concat :
  forall (bv1:bitvec) (bv2:bitvec) (bv4:bitvec),
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((value bv1) i) = ((value bv4) i))) ->
  (forall (i:Z), ((length bv1) <= i)%Z ->
   (((value bv2) (i - (length bv1))%Z) = ((value bv4) i))) ->
  ((length bv4) = ((length bv1) + (length bv2))%Z) ->
  ((concat bv1 bv2) = bv4).

Axiom concat_m :
  forall (bv1:bitvec) (bv2:bitvec) (i1:Z) (i2:Z), (0%Z < i1)%Z ->
  (0%Z < i2)%Z -> ((length bv1) = i1) -> ((length bv2) = i2) ->
  ((concat (make_bv_m (value bv1) i1) (make_bv_m (value bv2) i2)) =
   (make_bv_m (value (concat bv1 bv2)) (i1 + i2)%Z)).

Axiom concat_comm :
  forall (bv1:bitvec) (bv2:bitvec),
  ((hpart (concat bv1 bv2) (length bv1)) = bv1) /\
  ((tpart (concat bv1 bv2) (length bv1)) = bv2).

Axiom concat_and_rec :
  forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= (length bv))%Z) ->
  ((concat (hpart bv i) (tpart bv i)) = bv).

Parameter concat_int_bv: bitvec -> Z -> Z -> bitvec.

Axiom concat_int_bv_def :
  forall (bv:bitvec) (i:Z) (n:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((concat_int_bv bv i n) = (concat bv (int_to_bv i n))).

Axiom concat_int_to_bv_value :
  forall (bv:bitvec) (i:Z) (n:Z) (j:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (length (concat_int_bv bv i n)))%Z) ->
  (j < (length bv))%Z ->
  (((value (concat_int_bv bv i n)) j) = ((value bv) j)).

Axiom bv_to_int_concat :
  forall (bvx:bitvec) (bvy:bitvec),
  ((bv_to_int (concat bvx bvy)) =
   (((power 2%Z (length bvy)) * (bv_to_int bvx))%Z + (bv_to_int bvy))%Z).

Axiom concat_fin :
  forall (f1:Z -> Z) (f2:Z -> Z) (l1:Z) (l2:Z), (0%Z <= l1)%Z ->
  (0%Z <= l2)%Z -> (binary f1) -> (binary f2) ->
  ((make_bv
    ((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
        (concat_fun y0 y1 y2 y3))
       f1)
      f2)
     l1)
    (l1 + l2)%Z)
   = (concat (make_bv f1 l1) (make_bv f2 l2))).

Axiom bin_to_int_concat :
  forall (f1:Z -> Z) (f2:Z -> Z) (l1:Z) (l2:Z), (0%Z <= l1)%Z ->
  (0%Z <= l2)%Z -> (binary f1) -> (binary f2) ->
  ((bin_to_int
    ((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
        (concat_fun y0 y1 y2 y3))
       f1)
      f2)
     l1)
    (l1 + l2)%Z)
   = (((power 2%Z l2) * (bin_to_int f1 l1))%Z + (bin_to_int f2 l2))%Z).

Axiom bijective_concat :
  forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  (p_bijective (fun (o:(bitvec* bitvec)%type) => (concat (fir o) (sec o)))
   (cartesian_product (n_bvs i) (n_bvs j)) (n_bvs (i + j)%Z)) /\
  (p_bijective (fun (x:bitvec) => (hpart x i, tpart x i)) (n_bvs (i + j)%Z)
   (cartesian_product (n_bvs i) (n_bvs j))).

Axiom bv_to_int_hpart :
  forall (bv:bitvec) (l:Z), ((0%Z <= l)%Z /\ (l < (length bv))%Z) ->
  ((bv_to_int (hpart bv l)) =
   (int.EuclideanDivision.div (bv_to_int bv) (power 2%Z ((length bv) - l)%Z))).

Axiom bv_to_int_tpart :
  forall (bv:bitvec) (l:Z), ((0%Z <= l)%Z /\ (l < (length bv))%Z) ->
  ((bv_to_int (tpart bv l)) =
   (int.EuclideanDivision.mod1 (bv_to_int bv)
    (power 2%Z ((length bv) - l)%Z))).

Parameter ind_basis_mat: Z -> Z -> Z -> Z -> matrix t.

Axiom ind_basis_mat_def :
  forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
  ((0%Z <= j)%Z /\ (j < c)%Z) ->
  ((ind_basis_mat i j r c) =
   (make_f r c (fun (k:Z) (l:Z) => (indic_2 k i l j)))).

Parameter fc9: Z -> Z -> Z -> Z -> (Z* Z)%type -> bool.

Axiom fc_def9 :
  forall (i:Z) (j:Z) (r:Z) (c:Z) (x:(Z* Z)%type),
  (((fc9 i j r c) x) = true) <->
  ((get (ind_basis_mat i j r c) (fir x) (sec x)) = tone).

Axiom ind_basis_mat_spec :
  forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
  ((0%Z <= j)%Z /\ (j < c)%Z) ->
  ((rows (ind_basis_mat i j r c)) = r) /\
  (((columns (ind_basis_mat i j r c)) = c) /\
   ((forall (k:Z) (l:Z), (valid_index (ind_basis_mat i j r c) k l) ->
     ((get (ind_basis_mat i j r c) k l) = (indic_2 k i l j))) /\
    ((cardinal (filter (fc9 i j r c) (mat_indices (ind_basis_mat i j r c))))
     = 1%Z))).

Axiom ind_basis_mat_values :
  forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
  ((0%Z <= j)%Z /\ (j < c)%Z) -> forall (i1:Z) (j1:Z),
  ((0%Z <= i1)%Z /\ (i1 < r)%Z) -> ((0%Z <= j1)%Z /\ (j1 < c)%Z) ->
  ((get (ind_basis_mat i j r c) i1 j1) = (indic_2 i i1 j j1)).

Axiom unic_ind_basis_mat :
  forall (i1:Z) (j1:Z) (i2:Z) (j2:Z) (r:Z) (c:Z),
  ((0%Z <= i1)%Z /\ (i1 < r)%Z) -> ((0%Z <= j1)%Z /\ (j1 < c)%Z) ->
  ((0%Z <= i2)%Z /\ (i2 < r)%Z) -> ((0%Z <= j2)%Z /\ (j2 < c)%Z) ->
  ((ind_basis_mat i1 j1 r c) = (ind_basis_mat i2 j2 r c)) ->
  ((i1, j1) = (i2, j2)).

Parameter basis_mat: Z -> Z -> set (matrix t).

Parameter result13: Z -> Z -> (Z* Z)%type -> matrix t.

Axiom result_def13 :
  forall (r:Z) (c:Z) (o:(Z* Z)%type),
  match o with
  | (i, j) =>
      ((((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
       (((result13 r c) o) = (ind_basis_mat i j r c))) /\
      (~ (((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
       (((result13 r c) o) = (make r c tzero)))
  end.

Axiom basis_mat_def :
  forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
  ((basis_mat r c) =
   (map (result13 r c) (cartesian_product (to_fset 0%Z r) (to_fset 0%Z c)))).

Parameter fc10: (matrix t) -> (Z* Z)%type -> bool.

Axiom fc_def10 :
  forall (m:matrix t) (x:(Z* Z)%type),
  (((fc10 m) x) = true) <-> ((get m (fir x) (sec x)) = tone).

Axiom basis_mat_spec :
  forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
  (forall (m:matrix t),
   (mem m (basis_mat r c)) <->
   exists i:Z, exists j:Z,
   ((0%Z <= i)%Z /\ (i < r)%Z) /\
   (((0%Z <= j)%Z /\ (j < c)%Z) /\ (m = (ind_basis_mat i j r c)))) /\
  (((basis_mat r c) =
    (map (fun (o:(Z* Z)%type) => (ind_basis_mat (fir o) (sec o) r c))
     (cartesian_product (to_fset 0%Z r) (to_fset 0%Z c)))) /\
   ((constant_size (basis_mat r c) (fun (y0:matrix t) => y0)) /\
    (((s_columns (basis_mat r c) (fun (y0:matrix t) => y0)) = c) /\
     (((s_rows (basis_mat r c) (fun (y0:matrix t) => y0)) = r) /\
      forall (m:matrix t), (mem m (basis_mat r c)) ->
      ((cardinal (filter (fc10 m) (mat_indices m))) = 1%Z))))).

Parameter basis_mat_indexes: (matrix t) -> (Z* Z)%type.

Parameter result14: (matrix t) -> (Z* Z)%type -> bool.

Axiom result_def14 :
  forall (m:matrix t) (x:(Z* Z)%type),
  (((result14 m) x) = true) <->
  ((mem x (mat_indices m)) /\
   (equal m (ind_basis_mat (fir x) (sec x) (rows m) (columns m)))).

Axiom basis_mat_indexes_def :
  forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
  ((basis_mat_indexes m) = (element (filter (result14 m) (mat_indices m)))).

Axiom basis_mat_indexes_spec :
  forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
  (m =
   (ind_basis_mat (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))
    (rows m) (columns m))) /\
  ((m =
    (make_f (rows m) (columns m)
     (fun (i:Z) (j:Z) =>
      (indic_2 (fir (basis_mat_indexes m)) i (sec (basis_mat_indexes m)) j)))) /\
   (((get m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))) = tone) /\
    ((forall (i:Z) (j:Z), (valid_index m i j) ->
      (i = (fir (basis_mat_indexes m))) ->
      ~ (j = (sec (basis_mat_indexes m))) -> ((get m i j) = tzero)) /\
     (valid_index m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m)))))).

Axiom get_basis_mat_indexes :
  forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
  (m =
   (ind_basis_mat (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))
    (rows m) (columns m))) /\
  ((m =
    (make_f (rows m) (columns m)
     (fun (i:Z) (j:Z) =>
      (indic_2 (fir (basis_mat_indexes m)) i (sec (basis_mat_indexes m)) j)))) /\
   (((get m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))) = tone) /\
    forall (i:Z) (j:Z), (valid_index m i j) ->
    ~ ((basis_mat_indexes m) = (i, j)) -> ((get m i j) = tzero))).

Axiom set_basis_mat_indexes :
  forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
  (mem m (basis_mat (rows m) (columns m))) -> ((get m i j) = tone) ->
  ((basis_mat_indexes m) = (i, j)) /\
  ((m = (ind_basis_mat i j (rows m) (columns m))) /\
   ((m =
     (make_f (rows m) (columns m) (fun (i1:Z) (j1:Z) => (indic_2 i i1 j j1)))) /\
    forall (i1:Z) (j1:Z), (valid_index m i1 j1) -> (i1 = i) -> ~ (j1 = j) ->
    ((get m i1 j1) = tzero))).

Parameter basis_projection: (matrix t) -> Z -> Z -> matrix t.

Axiom basis_projection_def :
  forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
  ((basis_projection m i j) =
   (infix_asdtdt (get m i j) (ind_basis_mat i j (rows m) (columns m)))).

Axiom basis_projection_spec :
  forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
  ((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
  ((rows (basis_projection m i j)) = (rows m)) /\
  (((columns (basis_projection m i j)) = (columns m)) /\
   (((basis_projection m i j) =
     (make_f (rows m) (columns m)
      (fun (k:Z) (l:Z) => (infix_asdt (get m i j) (indic_2 k i l j))))) /\
    (((get (basis_projection m i j) i j) = (get m i j)) /\
     ((forall (i':Z) (j':Z), (valid_index (basis_projection m i j) i' j') ->
       ~ (i' = i) -> ((get (basis_projection m i j) i' j') = tzero)) /\
      forall (i':Z) (j':Z), (valid_index (basis_projection m i j) i' j') ->
      ~ (j' = j) -> ((get (basis_projection m i j) i' j') = tzero))))).

Axiom basis_projection_null :
  forall (m:matrix t) (i:Z) (j:Z) (k:Z) (l:Z), (valid_index m i j) ->
  (valid_index m k l) -> ((i = k) -> ~ (j = l)) ->
  ((get (basis_projection m i j) k l) = tzero).

Parameter result15: (matrix t) -> (Z* Z)%type -> matrix t.

Axiom result_def15 :
  forall (m:matrix t) (o:(Z* Z)%type),
  ((valid_index m (fir o) (sec o)) ->
   (((result15 m) o) = (basis_projection m (fir o) (sec o)))) /\
  (~ (valid_index m (fir o) (sec o)) -> (((result15 m) o) = m)).

(* Why3 assumption *)
Definition basis_projections (m:matrix t) : set (matrix t) :=
  map (result15 m) (to_indexes m).

Axiom basis_projections_spec :
  forall (m:matrix t),
  ((basis_projections m) =
   (map
    ((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
     ((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
    (to_indexes m))) /\
  ((forall (e:matrix t), (mem e (basis_projections m)) ->
    ((rows e) = (rows m))) /\
   ((forall (e:matrix t), (mem e (basis_projections m)) ->
     ((columns e) = (columns m))) /\
    (constant_size (basis_projections m) (fun (y0:matrix t) => y0)))).

Parameter fc11: (matrix t) -> (Z* Z)%type -> matrix t.

Axiom fc_def11 :
  forall (m:matrix t) (o:(Z* Z)%type),
  ((valid_index m (fir o) (sec o)) ->
   (((fc11 m) o) = (basis_projection m (fir o) (sec o)))) /\
  (~ (valid_index m (fir o) (sec o)) -> (((fc11 m) o) = m)).

Axiom rewrite_basis_projections :
  forall (m:matrix t),
  ((basis_projections m) = (map (fc11 m) (to_indexes m))).

Parameter result16: (matrix t) -> (Z* Z)%type -> matrix t.

Axiom result_def16 :
  forall (m:matrix t) (o:(Z* Z)%type),
  ((mem o (to_indexes m)) ->
   (((result16 m) o) = (basis_projection m (fir o) (sec o)))) /\
  (~ (mem o (to_indexes m)) -> (((result16 m) o) = m)).

(* Why3 assumption *)
Definition indexes_decomp (m:matrix t) : matrix t :=
  mat_sum (to_indexes m) (result16 m).

Axiom indexes_decomp_spec :
  forall (m:matrix t),
  ((rows (indexes_decomp m)) = (rows m)) /\
  ((columns (indexes_decomp m)) = (columns m)).

Axiom rewrite_indexes_decomp :
  forall (m:matrix t),
  ((indexes_decomp m) =
   (mat_sum (to_indexes m)
    (fun (o:(Z* Z)%type) => (basis_projection m (fir o) (sec o))))).

Axiom indexes_decomp_pre :
  forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
  ((get m i j) =
   (sum (to_indexes m)
    (fun (o:(Z* Z)%type) => (get (basis_projection m (fir o) (sec o)) i j)))).

Axiom indexes_decomp_pre_gen :
  forall (m:matrix t), forall (i:Z) (j:Z), (valid_index m i j) ->
  ((get m i j) =
   (sum (to_indexes m)
    (fun (o:(Z* Z)%type) => (get (basis_projection m (fir o) (sec o)) i j)))).

Axiom mat_to_indexes_decomp : forall (m:matrix t), (m = (indexes_decomp m)).

(* Why3 assumption *)
Definition basis_decomp (m:matrix t) : matrix t :=
  mat_sum (basis_projections m) (fun (y0:matrix t) => y0).

Axiom basis_decomp_spec :
  forall (m:matrix t),
  ((rows (basis_decomp m)) = (rows m)) /\
  ((columns (basis_decomp m)) = (columns m)).

Axiom indexes_basis_decomp_equal_pre :
  forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
  ((get (indexes_decomp m) i j) = (get (basis_decomp m) i j)).

Axiom indexes_basis_decomp_equal :
  forall (m:matrix t), ((indexes_decomp m) = (basis_decomp m)).

Axiom mat_to_basis_decomp : forall (m:matrix t), (m = (indexes_decomp m)).

Parameter fc12:
  forall {a:Type} {a_WT:WhyType a}, (matrix t) -> (set a) ->
  (a -> matrix t) -> a -> matrix t.

Axiom fc_def12 :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix t) (s:set a) (f:a -> matrix t) (a1:a),
  ((mem a1 s) -> (((fc12 m s f) a1) = (mat_mult m (f a1)))) /\
  (~ (mem a1 s) -> (((fc12 m s f) a1) = m)).

Axiom product_mat_sum_r_pre :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
  (constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
  (0%Z < (cardinal s'))%Z ->
  ((mat_mult m (mat_sum s' f)) = (mat_sum s' (fc12 m s f))) /\
  (((mat_mult m (mat_sum s' f)) =
    (mat_sum s' (fun (a1:a) => (mat_mult m (f a1))))) /\
   (((rows (mat_sum s' f)) = (s_rows s f)) /\
    (((columns (mat_sum s' f)) = (s_columns s f)) /\
     (((rows (mat_mult m (mat_sum s' f))) = (rows m)) /\
      ((columns (mat_mult m (mat_sum s' f))) = (s_columns s f)))))).

Axiom product_mat_sum_r :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix t) (s:set a) (f:a -> matrix t), (constant_size s f) ->
  ((columns m) = (s_rows s f)) -> (0%Z < (cardinal s))%Z ->
  ((mat_mult m (mat_sum s f)) =
   (mat_sum s (fun (a1:a) => (mat_mult m (f a1))))).

Axiom product_mat_sum_r_rev :
  forall {a:Type} {a_WT:WhyType a},
  forall (m:matrix t) (s:set a) (f:a -> matrix t), (constant_size s f) ->
  ((columns m) = (s_rows s f)) -> (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (a1:a) => (mat_mult m (f a1)))) =
   (mat_mult m (mat_sum s f))).

Axiom p_injective_proj :
  forall (m:matrix t),
  p_injective
  ((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
   ((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
  (nonn_mat_subset
   ((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
    ((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
   (to_indexes m)).

Axiom mat_decomp_equal_indexes :
  forall (m:matrix t), (m = (indexes_decomp m)).

Parameter ket_basis: Z -> set (matrix t).

Axiom ket_basis_def :
  forall (n:Z), (0%Z <= n)%Z ->
  ((ket_basis n) = (basis_mat (power 2%Z n) 1%Z)).

Axiom ket_basis_spec :
  forall (n:Z), (0%Z <= n)%Z ->
  ((ket_basis n) =
   (map
    (fun (o:(Z* Z)%type) =>
     (ind_basis_mat (fir o) (sec o) (power 2%Z n) 1%Z))
    (cartesian_product (to_fset 0%Z (power 2%Z n)) (to_fset 0%Z 1%Z)))) /\
  (((ket_basis n) = (basis_mat (power 2%Z n) 1%Z)) /\
   ((forall (mat:matrix t), (mem mat (ket_basis n)) ->
     ((rows mat) = (power 2%Z n))) /\
    ((forall (mat:matrix t), (mem mat (ket_basis n)) ->
      ((columns mat) = 1%Z)) /\
     forall (mat:matrix t), (mem mat (ket_basis n)) ->
     ((rows mat) = (power 2%Z n)) /\
     (((columns mat) = 1%Z) /\
      exists i:Z,
      (valid_index mat i 0%Z) /\ ((basis_mat_indexes mat) = (i, 0%Z)))))).

Axiom unary_ket_basis :
  forall (n:Z), (0%Z <= n)%Z ->
  ((ket_basis n) =
   (map (fun (i:Z) => (ind_basis_mat i 0%Z (power 2%Z n) 1%Z))
    (to_fset 0%Z (power 2%Z n)))).

Axiom to_ket_basis :
  forall (i:Z) (n:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  mem (ind_basis_mat i 0%Z (power 2%Z n) 1%Z) (ket_basis n).

Parameter ket_basis_index: (matrix t) -> Z -> Z.

Axiom ket_basis_index_def :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
  ((ket_basis_index m n) = (fir (basis_mat_indexes m))).

Axiom ket_basis_index_spec :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
  (mem (ind_basis_mat (ket_basis_index m n) 0%Z (power 2%Z n) 1%Z)
   (ket_basis n)) /\
  ((m =
    (make_f (rows m) 1%Z
     (fun (i:Z) (us:Z) => (indic (ket_basis_index m n) i)))) /\
   ((forall (i:Z), (valid_index m i 0%Z) -> ~ (i = (ket_basis_index m n)) ->
     ((get m i 0%Z) = tzero)) /\
    (valid_index m (ket_basis_index m n) 0%Z))).

Axiom set_ket_basis :
  forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (mem m (ket_basis n)) ->
  ((get m i 0%Z) = tone) ->
  ((ket_basis_index m n) = i) /\
  ((forall (i1:Z), (valid_index m i1 0%Z) -> ~ (i1 = i) ->
    ((get m i1 0%Z) = tzero)) /\
   ((mem m (ket_basis n)) /\
    (m = (make_f (rows m) (columns m) (fun (i1:Z) (us:Z) => (indic i i1)))))).

Axiom from_ket_basis :
  forall (n:Z) (m:matrix t), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
  exists i:Z,
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
  (m = (ind_basis_mat i 0%Z (power 2%Z n) 1%Z)).

Axiom int_to_ket_basis :
  forall (n:Z) (i:Z), (0%Z < n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> mem (ket n i) (ket_basis n).

(* Why3 assumption *)
Definition is_a_ket_basis_elt (m:matrix t) : Prop :=
  (is_a_ket m) /\ (mem m (ket_basis (ket_length m))).

Axiom ket_basis_elt_are_kets :
  forall (m:matrix t), (is_a_ket_basis_elt m) -> is_a_ket m.

Axiom get_is_a_ket_basis_elt :
  forall (m:matrix t), (is_a_ket_basis_elt m) ->
  (is_a_ket m) /\
  ((mem m (ket_basis (ket_length m))) /\
   ((exists i:Z,
     ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
     (m = (ket (ket_length m) i))) /\
    ((exists i:Z,
      ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
      (((get m i 0%Z) = tone) /\
       forall (j:Z),
       (((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
        ~ ((get m j 0%Z) = tzero)) ->
       (i = j))) /\
     forall (i:Z),
     (((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
      ((get m i 0%Z) = tone)) ->
     forall (j:Z),
     (((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
      ~ ((get m j 0%Z) = tzero)) ->
     (i = j)))).

Axiom set_is_a_ket_basis_elt :
  forall (m:matrix t), (is_a_ket m) ->
  (exists i:Z,
   ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
   (m = (ket (ket_length m) i))) ->
  (mem m (ket_basis (ket_length m))) -> is_a_ket_basis_elt m.

Axiom set_is_a_ket_basis_elt_exists :
  forall (m:matrix t), (is_a_ket m) ->
  (exists j:Z,
   ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
   (m =
    (make_f (power 2%Z (ket_length m)) 1%Z (fun (i:Z) (us:Z) => (indic i j))))) ->
  is_a_ket_basis_elt m.

Axiom ket_func_sets_ket_basis_elts :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  (is_a_ket_basis_elt (ket n i)) /\ ((ket_length (ket n i)) = n).

Axiom kronecker_is_a_ket_basis_elt :
  forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
  (is_a_ket_basis_elt y) -> is_a_ket_basis_elt (kronecker x y).

Axiom ket_is_a_ket_basis_elt :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_ket_basis_elt (ket n i).

Axiom ket_basis_non_null_val :
  forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (is_a_ket_basis_elt m) ->
  ((ket_length m) = n) -> ~ ((get m i 0%Z) = tzero) -> (m = (ket n i)).

Parameter ket_to_int: (matrix t) -> Z.

Axiom ket_to_int_spec :
  forall (m:matrix t), (is_a_ket_basis_elt m) ->
  ((0%Z <= (ket_to_int m))%Z /\
   ((ket_to_int m) < (power 2%Z (ket_length m)))%Z) /\
  (((get m (ket_to_int m) 0%Z) = tone) /\
   ((m = (ket (ket_length m) (ket_to_int m))) /\
    forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
    (m = (ket (ket_length m) i)) -> (i = (ket_to_int m)))).

Axiom ket_to_int_ket :
  forall (n:Z) (i:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((ket_to_int (ket n i)) = i).

Parameter bin_to_ket: Z -> (Z -> Z) -> matrix t.

Axiom bin_to_ket_def :
  forall (n:Z) (bvx:Z -> Z), (0%Z <= n)%Z -> (binary bvx) ->
  ((bin_to_ket n bvx) = (ket n (bin_to_int bvx n))).

Axiom bin_to_ket_spec :
  forall (n:Z) (bvx:Z -> Z), (0%Z <= n)%Z -> (binary bvx) ->
  (is_a_ket_basis_elt (bin_to_ket n bvx)) /\
  (((ket_length (bin_to_ket n bvx)) = n) /\
   (((ket_to_int (bin_to_ket n bvx)) = (bin_to_int bvx n)) /\
    (((rows (bin_to_ket n bvx)) = (power 2%Z n)) /\
     (((columns (bin_to_ket n bvx)) = 1%Z) /\
      ((is_a_ket (bin_to_ket n bvx)) /\ (is_a_ket_l (bin_to_ket n bvx) n)))))).

Axiom bin_to_ket_eq :
  forall (n1:Z) (n2:Z) (bvx1:Z -> Z) (bvx2:Z -> Z), (0%Z <= n1)%Z ->
  (binary bvx1) -> (binary bvx2) -> (n2 = n1) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < n1)%Z) -> ((bvx1 i) = (bvx2 i))) ->
  ((bin_to_ket n1 bvx1) = (bin_to_ket n2 bvx2)).

Axiom kronecker_kets_bin_to_ket :
  forall (f1:Z -> Z) (f2:Z -> Z) (n1:Z) (n2:Z), (binary f1) -> (binary f2) ->
  (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
  ((kronecker (bin_to_ket n1 f1) (bin_to_ket n2 f2)) =
   (bin_to_ket (n1 + n2)%Z
    ((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
        (concat_fun y0 y1 y2 y3))
       f1)
      f2)
     n1))).

Axiom kronecker_ket_to_int :
  forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
  (is_a_ket_basis_elt y) ->
  (is_a_ket_basis_elt (kronecker x y)) /\
  (((ket_length (kronecker x y)) = ((ket_length x) + (ket_length y))%Z) /\
   (((kronecker x y) =
     (ket ((ket_length x) + (ket_length y))%Z
      (((ket_to_int x) * (power 2%Z (ket_length y)))%Z + (ket_to_int y))%Z)) /\
    ((ket_to_int (kronecker x y)) =
     (((ket_to_int x) * (power 2%Z (ket_length y)))%Z + (ket_to_int y))%Z))).

Axiom ket_ket_to_int :
  forall (x:matrix t), (is_a_ket_basis_elt x) ->
  ((ket (ket_length x) (ket_to_int x)) = x).

Axiom ket_ket_to_int_values :
  forall (x:matrix t), (is_a_ket_basis_elt x) -> forall (i:Z) (j:Z),
  (valid_index x i j) -> ((get x i j) = (indic i (ket_to_int x))).

Parameter ket_basis_projection: (matrix t) -> Z -> matrix t.

Axiom ket_basis_projection_def :
  forall (m:matrix t) (j:Z), (is_a_ket m) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
  ((ket_basis_projection m j) =
   (infix_asdtdt (get m j 0%Z) (ket (ket_length m) j))).

Axiom ket_basis_projection_spec :
  forall (m:matrix t) (j:Z), (is_a_ket m) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
  ((ket_basis_projection m j) = (basis_projection m j 0%Z)).

Axiom ket_basis_projection_columns :
  forall (m:matrix t) (j:Z), (is_a_ket m) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
  ((columns (ket_basis_projection m j)) = 1%Z).

Axiom ket_basis_projection_rows :
  forall (m:matrix t) (j:Z), (is_a_ket m) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
  ((rows (ket_basis_projection m j)) = (rows m)).

Parameter ket_basis_projections: (matrix t) -> set (matrix t).

Parameter result17: (matrix t) -> Z -> matrix t.

Axiom result_def17 :
  forall (m:matrix t) (j:Z),
  ((mem j (to_fset 0%Z (power 2%Z (ket_length m)))) ->
   (((result17 m) j) = (ket_basis_projection m j))) /\
  (~ (mem j (to_fset 0%Z (power 2%Z (ket_length m)))) ->
   (((result17 m) j) = m)).

Axiom ket_basis_projections_def :
  forall (m:matrix t), (is_a_ket m) ->
  ((ket_basis_projections m) =
   (map (result17 m) (to_fset 0%Z (power 2%Z (ket_length m))))).

Axiom ket_basis_projections_spec :
  forall (m:matrix t), (is_a_ket m) ->
  ((ket_basis_projections m) = (basis_projections m)).

Parameter ket_basis_projections_antec: (matrix t) -> unit.

Axiom ket_basis_projections_antec_def :
  forall (m:matrix t), (is_a_ket m) -> ((ket_basis_projections_antec m) = tt).

Axiom ket_basis_projections_antec_spec :
  forall (m:matrix t), (is_a_ket m) ->
  (forall (e:matrix t),
   (mem e (ket_basis_projections m)) <->
   exists j:Z,
   ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
   (e = (ket_basis_projection m j))) /\
  forall (e:matrix t),
  (mem e (ket_basis_projections m)) <->
  exists j:Z, exists i:Z,
  (valid_index m j i) /\ (e = (basis_projection m j i)).

Parameter ket_sum:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.

Axiom ket_sum_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists l:Z, forall (e:a), (mem e s) -> ((ket_length (f e)) = l)) ->
  ((ket_sum s f) = (mat_sum s f)).

Axiom ket_sum_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t), (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists l:Z, forall (e:a), (mem e s) -> ((ket_length (f e)) = l)) ->
  (forall (i:Z), (ket_valid_index (ket_sum s f) i) ->
   ((get (ket_sum s f) i 0%Z) = (sum s (fun (e:a) => (get (f e) i 0%Z))))) /\
  ((is_a_ket (ket_sum s f)) /\
   forall (e:a), (mem e s) ->
   ((ket_length (ket_sum s f)) = (ket_length (f e)))).

Parameter ket_sum_l:
  forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
  matrix t.

Axiom ket_sum_l_def :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (l:Z), (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  ((ket_sum_l s f l) = (mat_sum s f)).

Axiom ket_sum_l_spec :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (l:Z), (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (forall (i:Z), (ket_valid_index (ket_sum_l s f l) i) ->
   ((get (ket_sum_l s f l) i 0%Z) = (sum s (fun (e:a) => (get (f e) i 0%Z))))) /\
  ((is_a_ket_l (ket_sum_l s f l) l) /\ ((ket_length (ket_sum_l s f l)) = l)).

Axiom ket_sum_comp_l :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
  (0%Z < (cardinal s))%Z ->
  (forall (e:b), (mem e s) -> is_a_ket_l (f e) l) ->
  (forall (e:b), (mem e s) -> is_a_ket_l (g e) l) ->
  ((ket_sum_l s (fun (k:b) => (add_ket_l (f k) (g k) l)) l) =
   (add_ket_l (ket_sum_l s f l) (ket_sum_l s g l) l)).

Axiom ket_sum_comp_l_rev :
  forall {b:Type} {b_WT:WhyType b},
  forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
  (0%Z < (cardinal s))%Z ->
  (forall (e:b), (mem e s) -> is_a_ket_l (f e) l) ->
  (forall (e:b), (mem e s) -> is_a_ket_l (g e) l) ->
  ((add_ket_l (ket_sum_l s f l) (ket_sum_l s g l) l) =
   (ket_sum_l s (fun (k:b) => (add_ket_l (f k) (g k) l)) l)).

Axiom ket_sum_scalar_l :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (0%Z < (cardinal s))%Z ->
  ((ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
   (infix_asdtdt a1 (ket_sum_l s f l))).

Axiom ket_sum_scalar_rev_l :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (0%Z < (cardinal s))%Z ->
  ((infix_asdtdt a1 (ket_sum_l s f l)) =
   (ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l)).

Axiom ket_sum_eq :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l:Z),
  (0%Z < (cardinal s))%Z -> (s = s') ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
  ((ket_sum_l s f l) = (ket_sum_l s' g l)).

Axiom ket_sum_eq_gen :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l1:Z)
    (l2:Z),
  (0%Z < (cardinal s))%Z -> (s = s') -> (l1 = l2) ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l1) ->
  (forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
  ((ket_sum_l s f l1) = (ket_sum_l s' g l2)).

Axiom ket_sum_l_cardone :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) = 1%Z) ->
  (is_a_ket_l (f (choose s)) l) -> ((ket_sum_l s f l) = (f (choose s))).

Axiom ket_sum_l_plus_one :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (e:a) (f:a -> matrix t) (l:Z), (0%Z < (cardinal s))%Z ->
  ~ (mem e s) -> (forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
  (is_a_ket_l (f e) l) ->
  ((ket_sum_l (add e s) f l) = (add_ket_l (ket_sum_l s f l) (f e) l)).

Axiom ket_sum_l_valid_index :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z), (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (forall (e:a), (mem e s) -> ket_valid_index (f e) i) ->
  ket_valid_index (ket_sum_l s f l) i.

Axiom ket_sum_const :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:matrix t) (l:Z), (0%Z < (cardinal s))%Z ->
  (is_a_ket_l x l) ->
  ((ket_sum_l s (fun (us:a) => x) l) =
   (infix_asdtdt (i_to_t (cardinal s)) x)).

Axiom ket_sum_const_w :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (x:matrix t) (l:Z), (0%Z < (cardinal s))%Z ->
  (is_a_ket_l x l) ->
  ((infix_asdtdt (infix_sldt tone (i_to_t (cardinal s)))
    (ket_sum_l s (fun (us:a) => x) l))
   = x).

Axiom map_ket_sum_l :
  forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
  forall (f:b -> matrix t) (s:set a) (t1:a -> b) (n:Z),
  (0%Z < (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket_l (f (t1 e)) n) ->
  (p_injective t1 s) ->
  ((ket_sum_l (map t1 s) f n) = (ket_sum_l s (fun (a1:a) => (f (t1 a1))) n)).

Axiom ket_decomp :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
  ((ket_length m) = n) ->
  (m =
   (mat_sum (to_fset 0%Z (power 2%Z n))
    (fun (j:Z) => (infix_asdtdt (get m j 0%Z) (ket n j))))).

Axiom ket_decomp_bv :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
  ((ket_length m) = n) ->
  (m =
   (ket_sum_l (n_bvs n)
    (fun (bvx:bitvec) =>
     (infix_asdtdt (get m (bv_to_int bvx) 0%Z) (ket n (bv_to_int bvx))))
    n)).

Axiom ket_recomp :
  forall (f:Z -> t) (n:Z), (0%Z <= n)%Z ->
  ((mat_sum (to_fset 0%Z (power 2%Z n))
    (fun (j:Z) => (infix_asdtdt (f j) (ket n j))))
   = (make_f (power 2%Z n) 1%Z (fun (x:Z) (us:Z) => (f x)))).

Axiom ket_decomp_quant :
  forall (m:matrix t), (is_a_ket m) ->
  (m =
   (mat_sum (to_fset 0%Z (power 2%Z (ket_length m)))
    (fun (j:Z) => (infix_asdtdt (get m j 0%Z) (ket (ket_length m) j))))).

Axiom mat_mult_ket_basis :
  forall (m:matrix t) (x:matrix t), (is_a_ket_basis_elt x) ->
  (((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
  ((mat_mult m x) =
   (mat_sum (to_fset 0%Z (rows x))
    (fun (k:Z) =>
     (infix_asdtdt (get m k (ket_to_int x)) (ket (ket_length x) k))))).

Axiom ket_mult_diag :
  forall (m:matrix t) (x:matrix t), (1%Z <= (ket_length x))%Z ->
  (is_a_ket_basis_elt x) -> ((rows m) = (power 2%Z (ket_length x))) ->
  ((columns m) = (power 2%Z (ket_length x))) ->
  (forall (i:Z) (j:Z),
   ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length x)))%Z) -> ~ (i = j) ->
   ((get m i j) = tzero)) ->
  ((mat_mult m x) =
   (infix_asdtdt (get m (ket_to_int x) (ket_to_int x))
    (ket (ket_length x) (ket_to_int x)))).

Axiom mat_mult_ket_basis_bv :
  forall (m:matrix t) (x:matrix t) (n:Z), ((ket_length x) = n) ->
  (is_a_ket_basis_elt x) ->
  (((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
  ((mat_mult m x) =
   (ket_sum_l (n_bvs n)
    (fun (bvx:bitvec) =>
     (infix_asdtdt (get m (bv_to_int bvx) (ket_to_int x))
      (ket n (bv_to_int bvx))))
    n)).

Axiom mat_mult_ket_basis_bv_gen :
  forall (m:matrix t) (x:matrix t), (is_a_ket_basis_elt x) ->
  (((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
  ((mat_mult m x) =
   (ket_sum_l (n_bvs (ket_length x))
    (fun (bvx:bitvec) =>
     (infix_asdtdt (get m (bv_to_int bvx) (ket_to_int x))
      (ket (ket_length x) (bv_to_int bvx))))
    (ket_length x))).

Axiom mat_mult_ket_bv :
  forall (m:matrix t) (x:matrix t) (n:Z), (is_a_ket_l x n) ->
  (((columns m) = (rows m)) /\
   (((rows m) = (rows x)) /\ ((rows x) = (power 2%Z n)))) ->
  ((mat_mult m x) =
   (ket_sum_l (n_bvs n)
    (fun (bvx:bitvec) =>
     (infix_asdtdt (get x (bv_to_int bvx) 0%Z)
      (mat_mult m (ket n (bv_to_int bvx)))))
    n)).

Axiom mat_mult_ket_bv_gen :
  forall (m:matrix t) (x:matrix t), (is_a_ket x) ->
  (((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
  ((mat_mult m x) =
   (ket_sum_l (n_bvs (ket_length x))
    (fun (bvx:bitvec) =>
     (infix_asdtdt (get x (bv_to_int bvx) 0%Z)
      (mat_mult m (ket (ket_length x) (bv_to_int bvx)))))
    (ket_length x))).

Axiom fun_inversion_pre :
  forall (f:Z -> Z) (s:set Z) (s':set Z) (a:Z -> t) (n:Z), (0%Z <= n)%Z ->
  (0%Z < (cardinal s))%Z -> (p_bijective f s s') ->
  (subset s (to_fset 0%Z n)) -> (subset s' (to_fset 0%Z n)) ->
  ((mat_sum s
    (fun (j:Z) =>
     (infix_asdtdt (a j) (set1 (make n 1%Z tzero) (f j) 0%Z tone))))
   =
   (mat_sum s'
    (fun (j:Z) =>
     (infix_asdtdt (a (inv_func f s s' j))
      (set1 (make n 1%Z tzero) j 0%Z tone))))).

Axiom ket_fun_inversion :
  forall (f:Z -> Z) (a:Z -> t) (m:matrix t) (pow_2_n:Z),
  (pow_2_n = (power 2%Z (ket_length m))) -> (is_a_ket m) ->
  (0%Z < pow_2_n)%Z ->
  (p_bijective f (to_fset 0%Z pow_2_n) (to_fset 0%Z pow_2_n)) ->
  (m =
   (mat_sum (to_fset 0%Z pow_2_n)
    (fun (j:Z) => (infix_asdtdt (a j) (ket (ket_length m) (f j)))))) ->
  (m =
   (mat_sum (to_fset 0%Z pow_2_n)
    (fun (j:Z) =>
     (infix_asdtdt (a (inv_ f (to_fset 0%Z pow_2_n) (to_fset 0%Z pow_2_n) j))
      (ket (ket_length m) j))))).

Parameter ket_to_bv: (matrix t) -> bitvec.

Axiom ket_to_bv_def :
  forall (x:matrix t), (is_a_ket_basis_elt x) ->
  ((ket_to_bv x) = (int_to_bv (ket_to_int x) (ket_length x))).

Axiom ket_to_bv_spec :
  forall (x:matrix t), (is_a_ket_basis_elt x) ->
  ((bv_to_int (ket_to_bv x)) = (ket_to_int x)) /\
  (((length (ket_to_bv x)) = (ket_length x)) /\
   (mem (ket_to_bv x) (n_bvs (ket_length x)))).

(* Why3 assumption *)
Definition bv_to_ket (bv:bitvec) : matrix t :=
  ket (length bv) (bv_to_int bv).

Axiom bv_to_ket_spec :
  forall (bv:bitvec),
  (is_a_ket_basis_elt (bv_to_ket bv)) /\
  (((ket_to_int (bv_to_ket bv)) = (bv_to_int bv)) /\
   (((ket_length (bv_to_ket bv)) = (length bv)) /\
    (((rows (bv_to_ket bv)) = (power 2%Z (length bv))) /\
     (((columns (bv_to_ket bv)) = 1%Z) /\
      ((bv_to_ket bv) = (bin_to_ket (length bv) (value bv))))))).

Axiom bin_to_ket_to_bv_to_ket :
  forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
  ((bin_to_ket n f) = (bv_to_ket (make_bv f n))).

Axiom bv_to_ket_length :
  forall (bv:bitvec), ((ket_length (bv_to_ket bv)) = (length bv)).

Axiom ket_to_bv_concat :
  forall (x:bitvec) (y:bitvec),
  ((bv_to_ket (concat x y)) = (kronecker (bv_to_ket x) (bv_to_ket y))).

Axiom bv_to_ket_concat_rev :
  forall (x:bitvec) (y:bitvec),
  ((kronecker (bv_to_ket x) (bv_to_ket y)) = (bv_to_ket (concat x y))).

Axiom bv_to_ket_to_bv :
  forall (bv:bitvec), ((ket_to_bv (bv_to_ket bv)) = bv).

Axiom ket_to_bv_to_ket :
  forall (x:matrix t), (is_a_ket_basis_elt x) ->
  ((bv_to_ket (ket_to_bv x)) = x).

Axiom bv_to_ket_eq :
  forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
   (((value bv1) i) = ((value bv2) i))) ->
  ((bv_to_ket bv1) = (bv_to_ket bv2)).

Axiom ket_to_bv_kronecker :
  forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
  (is_a_ket_basis_elt y) ->
  ((ket_to_bv (kronecker x y)) = (concat (ket_to_bv x) (ket_to_bv y))).

Parameter semantics: a_circuit -> (matrix t) -> (matrix t) -> Prop.

Parameter equiv_circ: a_circuit -> a_circuit -> Prop.

Parameter path_semantics: a_circuit -> (matrix t) -> matrix t.

Axiom path_semantics_spec :
  forall (c:a_circuit) (x:matrix t), (is_a_ket x) ->
  ((ket_length x) = (a_depth c)) ->
  is_a_ket_l (path_semantics c x) (a_depth c).

Parameter mat_semantics: a_circuit -> matrix t.

Axiom mat_semantics_spec :
  forall (c:a_circuit),
  ((rows (mat_semantics c)) = (power 2%Z (a_depth c))) /\
  ((columns (mat_semantics c)) = (power 2%Z (a_depth c))).

Axiom abs_path_sem_length :
  forall (c:a_circuit) (x:matrix t), (is_a_ket x) ->
  ((ket_length x) = (a_depth c)) ->
  ((ket_length (path_semantics c x)) = (a_depth c)).

Axiom Add_path_semantics :
  forall (c:a_circuit), forall (x:matrix t) (x':matrix t),
  (is_a_ket_l x (a_depth c)) -> (is_a_ket_l x' (a_depth c)) ->
  ((add_ket_l (path_semantics c x) (path_semantics c x') (a_depth c)) =
   (path_semantics c (add_ket_l x x' (a_depth c)))).

Axiom Scal_path_semantics :
  forall (c:a_circuit), forall (x:matrix t), forall (a:t),
  (is_a_ket_l x (a_depth c)) ->
  ((infix_asdtdt a (path_semantics c x)) =
   (path_semantics c (infix_asdtdt a x))).

Axiom Sequence_path_semantics :
  forall (d:a_circuit) (e:a_circuit), forall (x:matrix t),
  (is_a_ket_l x (a_depth d)) -> ((a_depth d) = (a_depth e)) ->
  ((path_semantics (a_sequence d e) x) =
   (path_semantics e (path_semantics d x))).

Axiom Parallel_path_semantics :
  forall (d:a_circuit) (e:a_circuit), forall (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth d)) -> (is_a_ket_l y (a_depth e)) ->
  ((path_semantics (a_parallel d e) (kronecker x y)) =
   (kronecker (path_semantics d x) (path_semantics e y))).

Axiom Equal_semantics :
  forall (c:a_circuit), forall (x:matrix t), (is_a_ket_l x (a_depth c)) ->
  ((path_semantics c x) = (mat_mult (mat_semantics c) x)).

Axiom Abs_semantics :
  forall (c:a_circuit), forall (x:matrix t) (y:matrix t),
  ((is_a_ket x) /\
   ((is_a_ket y) /\
    ((((ket_length x) = (ket_length y)) /\ ((ket_length y) = (a_depth c))) /\
     ((path_semantics c x) = y)))) <->
  (semantics c x y).

Axiom set_semantics_mat :
  forall (c:a_circuit) (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth c)) -> (is_a_ket_l y (a_depth c)) ->
  ((mat_mult (mat_semantics c) x) = y) -> semantics c x y.

Axiom set_semantics_path :
  forall (c:a_circuit) (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth c)) -> (is_a_ket_l y (a_depth c)) ->
  ((path_semantics c x) = y) -> semantics c x y.

Axiom get_semantics :
  forall (c:a_circuit) (x:matrix t) (y:matrix t), (semantics c x y) ->
  (is_a_ket_l x (a_depth c)) /\
  ((is_a_ket_l y (a_depth c)) /\
   (((path_semantics c x) = y) /\ ((mat_mult (mat_semantics c) x) = y))).

Axiom functional_sem :
  forall (c:a_circuit) (x:matrix t) (y:matrix t) (y':matrix t),
  (semantics c x y) -> (semantics c x y') -> (y = y').

Axiom functional_sem_ex :
  forall (y:matrix t) (y':matrix t),
  (exists c:a_circuit,
   exists x:matrix t, (semantics c x y) /\ (semantics c x y')) ->
  (y = y').

Axiom scal_semantics :
  forall (c:a_circuit) (x:matrix t) (y:matrix t) (a:t), (semantics c x y) ->
  semantics c (infix_asdtdt a x) (infix_asdtdt a y).

Axiom add_semantics :
  forall (c:a_circuit) (x:matrix t) (x':matrix t) (y:matrix t) (y':matrix t),
  (semantics c x y) -> (semantics c x' y') ->
  ((ket_length x) = (ket_length y)) ->
  semantics c (add_mat x x') (add_mat y y').

Axiom comp_semantics :
  forall (d:a_circuit) (e:a_circuit) (x:matrix t) (y:matrix t) (z:matrix t),
  (semantics d x y) -> (semantics e y z) -> semantics (a_sequence d e) x z.

Axiom parallel_semantics :
  forall (d:a_circuit) (e:a_circuit) (x:matrix t) (y:matrix t) (z:matrix t)
    (t1:matrix t),
  (semantics d x y) -> (semantics e z t1) ->
  semantics (a_parallel d e) (kronecker x z) (kronecker y t1).

Axiom sum_scal_semantics_s :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit) (s:set a) (f:a -> matrix t) (h:a -> matrix t)
    (g:a -> t) (size:Z),
  (0%Z <= size)%Z -> (1%Z <= (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics c (f e) (h e)) ->
  semantics c (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (f e))))
  (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (h e)))).

Axiom sum_scal_semantics :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit) (s:set a) (f:a -> matrix t) (h:a -> matrix t)
    (g:a -> t),
  (1%Z <= (cardinal s))%Z -> (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists size:Z,
   (0%Z <= size)%Z /\ forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics c (f e) (h e)) ->
  semantics c (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (f e))))
  (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (h e)))).

Axiom sum_semantics :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit) (s:set a) (f:a -> matrix t) (h:a -> matrix t),
  (1%Z <= (cardinal s))%Z -> (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists size:Z,
   (0%Z <= size)%Z /\ forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics c (f e) (h e)) ->
  semantics c (mat_sum s f) (mat_sum s h).

Axiom decomp_semantics :
  forall (c:a_circuit) (x:matrix t) (f:Z -> matrix t), (is_a_ket x) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   is_a_ket (f i)) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   ((ket_length (f i)) = (ket_length x))) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   semantics c (ket (ket_length x) i) (f i)) ->
  semantics c x
  (mat_sum (to_fset 0%Z (power 2%Z (ket_length x)))
   (fun (j:Z) => (infix_asdtdt (get x j 0%Z) (f j)))).

Axiom Equiv_circ :
  forall (c:a_circuit) (c':a_circuit),
  (equiv_circ c c') <->
  forall (x:matrix t) (x':matrix t),
  (semantics c x x') <-> (semantics c' x x').

Axiom set_equiv_cir_pre :
  forall (c:a_circuit) (c':a_circuit) (x:matrix t) (x':matrix t),
  ((a_depth c) = (a_depth c')) -> (is_a_ket_l x (a_depth c)) ->
  (is_a_ket_l x' (a_depth c)) ->
  (forall (bvi:bitvec), forall (y:matrix t), (mem bvi (n_bvs (a_depth c))) ->
   (semantics c (bv_to_ket bvi) y) <-> (semantics c' (bv_to_ket bvi) y)) ->
  (semantics c x x') <-> (semantics c' x x').

Axiom set_equiv_circ :
  forall (c:a_circuit) (c':a_circuit), ((a_depth c) = (a_depth c')) ->
  (forall (bvi:bitvec), forall (y:matrix t), (mem bvi (n_bvs (a_depth c))) ->
   (semantics c (bv_to_ket bvi) y) <-> (semantics c' (bv_to_ket bvi) y)) ->
  equiv_circ c c'.

Axiom set_equiv_path :
  forall (c:a_circuit) (c':a_circuit), ((a_depth c) = (a_depth c')) ->
  (forall (bvi:bitvec), (mem bvi (n_bvs (a_depth c))) ->
   ((path_semantics c (bv_to_ket bvi)) = (path_semantics c' (bv_to_ket bvi)))) ->
  equiv_circ c c'.

Axiom unit_path_sem :
  forall (c:a_circuit), forall (x:matrix t), (is_a_ket_l x (a_depth c)) ->
  (is_a_ket_basis_elt x) ->
  ((path_semantics c x) =
   (infix_asdtdt (pow_inv_sqrt_2 (a_sum_range c))
    (ket_sum_l (n_bvs (a_sum_range c))
     (fun (bvy:bitvec) =>
      (infix_asdtdt
       (value_ (a_phase_part c (value (ket_to_bv x)) (value bvy)))
       (bin_to_ket (a_depth c)
        ((((fun (y0:a_circuit) (y1:Z -> Z) (y2:Z -> Z) (y3:Z) =>
            (a_ket_part y0 y1 y2 y3))
           c)
          (value (ket_to_bv x)))
         (value bvy)))))
     (a_depth c)))).

Axiom set_equiv_circ_d :
  forall (c:a_circuit) (c':a_circuit), ((a_depth c) = (a_depth c')) ->
  ((a_sum_range c) = (a_sum_range c')) ->
  (forall (bvx:Z -> Z) (bvy:Z -> Z) (i:Z),
   ((a_ket_part c bvx bvy i) = (a_ket_part c' bvx bvy i))) ->
  (forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvy) ->
   ((a_phase_part c bvx bvy) = (a_phase_part c' bvx bvy))) ->
  equiv_circ c c'.

Parameter semantics_: a_circuit_ -> (matrix t) -> (matrix t) -> Prop.

Parameter equiv_circ_: a_circuit_ -> a_circuit_ -> Prop.

Parameter path_semantics_: a_circuit_ -> (matrix t) -> matrix t.

Axiom path_semantics__spec :
  forall (c:a_circuit_) (x:matrix t), (is_a_ket x) ->
  ((ket_length x) = (a_depth_ c)) ->
  is_a_ket_l (path_semantics_ c x) (a_depth_ c).

Parameter mat_semantics_: a_circuit_ -> matrix t.

Axiom mat_semantics__spec :
  forall (c:a_circuit_),
  ((rows (mat_semantics_ c)) = (power 2%Z (a_depth_ c))) /\
  ((columns (mat_semantics_ c)) = (power 2%Z (a_depth_ c))).

Axiom abs_path_sem_length1 :
  forall (c:a_circuit_) (x:matrix t), (is_a_ket x) ->
  ((ket_length x) = (a_depth_ c)) ->
  ((ket_length (path_semantics_ c x)) = (a_depth_ c)).

Axiom Add_path_semantics1 :
  forall (c:a_circuit_), forall (x:matrix t) (x':matrix t),
  (is_a_ket_l x (a_depth_ c)) -> (is_a_ket_l x' (a_depth_ c)) ->
  ((add_ket_l (path_semantics_ c x) (path_semantics_ c x') (a_depth_ c)) =
   (path_semantics_ c (add_ket_l x x' (a_depth_ c)))).

Axiom Scal_path_semantics1 :
  forall (c:a_circuit_), forall (x:matrix t), forall (a:t),
  (is_a_ket_l x (a_depth_ c)) ->
  ((infix_asdtdt a (path_semantics_ c x)) =
   (path_semantics_ c (infix_asdtdt a x))).

Axiom Sequence_path_semantics1 :
  forall (d:a_circuit_) (e:a_circuit_), forall (x:matrix t),
  (is_a_ket_l x (a_depth_ d)) -> ((a_depth_ d) = (a_depth_ e)) ->
  ((path_semantics_ (a_sequence_ d e) x) =
   (path_semantics_ e (path_semantics_ d x))).

Axiom Parallel_path_semantics1 :
  forall (d:a_circuit_) (e:a_circuit_), forall (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth_ d)) -> (is_a_ket_l y (a_depth_ e)) ->
  ((path_semantics_ (a_parallel_ d e) (kronecker x y)) =
   (kronecker (path_semantics_ d x) (path_semantics_ e y))).

Axiom Equal_semantics1 :
  forall (c:a_circuit_), forall (x:matrix t), (is_a_ket_l x (a_depth_ c)) ->
  ((path_semantics_ c x) = (mat_mult (mat_semantics_ c) x)).

Axiom Abs_semantics1 :
  forall (c:a_circuit_), forall (x:matrix t) (y:matrix t),
  ((is_a_ket x) /\
   ((is_a_ket y) /\
    ((((ket_length x) = (ket_length y)) /\ ((ket_length y) = (a_depth_ c))) /\
     ((path_semantics_ c x) = y)))) <->
  (semantics_ c x y).

Axiom set_semantics_mat1 :
  forall (c:a_circuit_) (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth_ c)) -> (is_a_ket_l y (a_depth_ c)) ->
  ((mat_mult (mat_semantics_ c) x) = y) -> semantics_ c x y.

Axiom set_semantics_path1 :
  forall (c:a_circuit_) (x:matrix t) (y:matrix t),
  (is_a_ket_l x (a_depth_ c)) -> (is_a_ket_l y (a_depth_ c)) ->
  ((path_semantics_ c x) = y) -> semantics_ c x y.

Axiom get_semantics1 :
  forall (c:a_circuit_) (x:matrix t) (y:matrix t), (semantics_ c x y) ->
  (is_a_ket_l x (a_depth_ c)) /\
  ((is_a_ket_l y (a_depth_ c)) /\
   (((path_semantics_ c x) = y) /\ ((mat_mult (mat_semantics_ c) x) = y))).

Axiom functional_sem1 :
  forall (c:a_circuit_) (x:matrix t) (y:matrix t) (y':matrix t),
  (semantics_ c x y) -> (semantics_ c x y') -> (y = y').

Axiom functional_sem_ex1 :
  forall (y:matrix t) (y':matrix t),
  (exists c:a_circuit_,
   exists x:matrix t, (semantics_ c x y) /\ (semantics_ c x y')) ->
  (y = y').

Axiom scal_semantics1 :
  forall (c:a_circuit_) (x:matrix t) (y:matrix t) (a:t),
  (semantics_ c x y) -> semantics_ c (infix_asdtdt a x) (infix_asdtdt a y).

Axiom add_semantics1 :
  forall (c:a_circuit_) (x:matrix t) (x':matrix t) (y:matrix t) (y':matrix t),
  (semantics_ c x y) -> (semantics_ c x' y') ->
  ((ket_length x) = (ket_length y)) ->
  semantics_ c (add_mat x x') (add_mat y y').

Axiom comp_semantics1 :
  forall (d:a_circuit_) (e:a_circuit_) (x:matrix t) (y:matrix t) (z:matrix t),
  (semantics_ d x y) -> (semantics_ e y z) ->
  semantics_ (a_sequence_ d e) x z.

Axiom parallel_semantics1 :
  forall (d:a_circuit_) (e:a_circuit_) (x:matrix t) (y:matrix t) (z:matrix t)
    (t1:matrix t),
  (semantics_ d x y) -> (semantics_ e z t1) ->
  semantics_ (a_parallel_ d e) (kronecker x z) (kronecker y t1).

Axiom sum_scal_semantics_s1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit_) (s:set a) (f:a -> matrix t) (h:a -> matrix t)
    (g:a -> t) (size:Z),
  (0%Z <= size)%Z -> (1%Z <= (cardinal s))%Z ->
  (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics_ c (f e) (h e)) ->
  semantics_ c (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (f e))))
  (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (h e)))).

Axiom sum_scal_semantics1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit_) (s:set a) (f:a -> matrix t) (h:a -> matrix t)
    (g:a -> t),
  (1%Z <= (cardinal s))%Z -> (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists size:Z,
   (0%Z <= size)%Z /\ forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics_ c (f e) (h e)) ->
  semantics_ c (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (f e))))
  (mat_sum s (fun (e:a) => (infix_asdtdt (g e) (h e)))).

Axiom sum_semantics1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (c:a_circuit_) (s:set a) (f:a -> matrix t) (h:a -> matrix t),
  (1%Z <= (cardinal s))%Z -> (forall (e:a), (mem e s) -> is_a_ket (f e)) ->
  (exists size:Z,
   (0%Z <= size)%Z /\ forall (e:a), (mem e s) -> ((ket_length (f e)) = size)) ->
  (forall (e:a), (mem e s) -> semantics_ c (f e) (h e)) ->
  semantics_ c (mat_sum s f) (mat_sum s h).

Axiom decomp_semantics1 :
  forall (c:a_circuit_) (x:matrix t) (f:Z -> matrix t), (is_a_ket x) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   is_a_ket (f i)) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   ((ket_length (f i)) = (ket_length x))) ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
   semantics_ c (ket (ket_length x) i) (f i)) ->
  semantics_ c x
  (mat_sum (to_fset 0%Z (power 2%Z (ket_length x)))
   (fun (j:Z) => (infix_asdtdt (get x j 0%Z) (f j)))).

Axiom Equiv_circ1 :
  forall (c:a_circuit_) (c':a_circuit_),
  (equiv_circ_ c c') <->
  forall (x:matrix t) (x':matrix t),
  (semantics_ c x x') <-> (semantics_ c' x x').

Axiom set_equiv_cir_pre1 :
  forall (c:a_circuit_) (c':a_circuit_) (x:matrix t) (x':matrix t),
  ((a_depth_ c) = (a_depth_ c')) -> (is_a_ket_l x (a_depth_ c)) ->
  (is_a_ket_l x' (a_depth_ c)) ->
  (forall (bvi:bitvec), forall (y:matrix t),
   (mem bvi (n_bvs (a_depth_ c))) ->
   (semantics_ c (bv_to_ket bvi) y) <-> (semantics_ c' (bv_to_ket bvi) y)) ->
  (semantics_ c x x') <-> (semantics_ c' x x').

Axiom set_equiv_circ1 :
  forall (c:a_circuit_) (c':a_circuit_), ((a_depth_ c) = (a_depth_ c')) ->
  (forall (bvi:bitvec), forall (y:matrix t),
   (mem bvi (n_bvs (a_depth_ c))) ->
   (semantics_ c (bv_to_ket bvi) y) <-> (semantics_ c' (bv_to_ket bvi) y)) ->
  equiv_circ_ c c'.

Axiom set_equiv_path1 :
  forall (c:a_circuit_) (c':a_circuit_), ((a_depth_ c) = (a_depth_ c')) ->
  (forall (bvi:bitvec), (mem bvi (n_bvs (a_depth_ c))) ->
   ((path_semantics_ c (bv_to_ket bvi)) =
    (path_semantics_ c' (bv_to_ket bvi)))) ->
  equiv_circ_ c c'.

Parameter id_par_: a_circuit_ -> Z -> a_circuit_.

Axiom id_par__def :
  forall (c:a_circuit_) (k:Z), (0%Z <= k)%Z ->
  ((k = 0%Z) -> ((id_par_ c k) = c)) /\
  (~ (k = 0%Z) -> ((id_par_ c k) = (a_parallel_ (circ_ident_ k) c))).

Axiom id_par__spec :
  forall (c:a_circuit_) (k:Z), (0%Z <= k)%Z ->
  ((a_sum_range_ (id_par_ c k)) = (a_sum_range_ c)) /\
  (((a_depth_ (id_par_ c k)) = ((a_depth_ c) + k)%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < k)%Z) ->
     ((a_ket_part_ (id_par_ c k) bvx bvy i) = (bvx i))) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((k <= i)%Z /\ (i < ((a_depth_ c) + k)%Z)%Z) ->
      ((a_ket_part_ (id_par_ c k) bvx bvy i) =
       (a_ket_part_ c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
        (i - k)%Z))) /\
     forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
     ((a_phase_part_ (id_par_ c k) bvx bvy) =
      (a_phase_part_ c
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy))))).

Parameter par_id_: a_circuit_ -> Z -> a_circuit_.

Axiom par_id__def :
  forall (c:a_circuit_) (k:Z), (0%Z <= k)%Z ->
  ((k = 0%Z) -> ((par_id_ c k) = c)) /\
  (~ (k = 0%Z) -> ((par_id_ c k) = (a_parallel_ c (circ_ident_ k)))).

Axiom par_id__spec :
  forall (c:a_circuit_) (k:Z), (0%Z <= k)%Z ->
  ((a_sum_range_ (par_id_ c k)) = (a_sum_range_ c)) /\
  (((a_depth_ (par_id_ c k)) = ((a_depth_ c) + k)%Z) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth_ c))%Z) ->
     ((a_ket_part_ (par_id_ c k) bvx bvy i) = (a_ket_part_ c bvx bvy i))) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      (((a_depth_ c) <= i)%Z /\ (i < ((a_depth_ c) + k)%Z)%Z) ->
      ((a_ket_part_ (par_id_ c k) bvx bvy i) = (bvx i))) /\
     forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
     ((a_phase_part_ (par_id_ c k) bvx bvy) = (a_phase_part_ c bvx bvy))))).

Parameter place_: a_circuit_ -> Z -> Z -> a_circuit_.

Axiom place__def :
  forall (c:a_circuit_) (k:Z) (n:Z), (0%Z <= k)%Z ->
  (((a_depth_ c) + k)%Z <= n)%Z ->
  ((place_ c k n) = (id_par_ (par_id_ c ((n - (a_depth_ c))%Z - k)%Z) k)).

Axiom place__spec :
  forall (c:a_circuit_) (k:Z) (n:Z), (0%Z <= k)%Z ->
  (((a_depth_ c) + k)%Z <= n)%Z ->
  ((a_sum_range_ (place_ c k n)) = (a_sum_range_ c)) /\
  (((a_depth_ (place_ c k n)) = n) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((k <= i)%Z /\ (i < (k + (a_depth_ c))%Z)%Z) ->
     ((a_ket_part_ (place_ c k n) bvx bvy i) =
      (a_ket_part_ c
       (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
       (i - k)%Z))) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < k)%Z) ->
      ((a_ket_part_ (place_ c k n) bvx bvy i) = (bvx i))) /\
     ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
       (((k + (a_depth_ c))%Z <= i)%Z /\ (i < n)%Z) ->
       ((a_ket_part_ (place_ c k n) bvx bvy i) = (bvx i))) /\
      ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
        (((k + (a_depth_ c))%Z <= i)%Z /\ (i < n)%Z) ->
        (((k <= i)%Z /\ (i < (k + (a_depth_ c))%Z)%Z) ->
         ((a_ket_part_ (place_ c k n) bvx bvy i) =
          (a_ket_part_ c
           (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
           (i - k)%Z))) /\
        (~ ((k <= i)%Z /\ (i < (k + (a_depth_ c))%Z)%Z) ->
         ((a_ket_part_ (place_ c k n) bvx bvy i) = (bvx i)))) /\
       forall (bvx:Z -> Z) (bvy:Z -> Z), (binary bvx) ->
       ((a_phase_part_ (place_ c k n) bvx bvy) =
        (a_phase_part_ c
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy))))))).

Parameter id_cont_: a_circuit_ -> Z -> Z -> Z -> a_circuit_.

Axiom id_cont__spec :
  forall (circ:a_circuit_) (c:Z) (ft:Z) (n:Z), ((0%Z <= c)%Z /\ (c < n)%Z) ->
  ((0%Z <= ft)%Z /\ (ft <= (n - (a_depth_ circ))%Z)%Z) ->
  ((ft <= c)%Z -> ((ft + (a_depth_ circ))%Z <= c)%Z) ->
  (forall (bv:bitvec), (mem bv (n_bvs n)) -> (((value bv) c) = 0%Z) ->
   semantics_ (id_cont_ circ c ft n) (bv_to_ket bv) (bv_to_ket bv)) /\
  ((forall (bv:bitvec), (mem bv (n_bvs n)) -> (((value bv) c) = 1%Z) ->
    semantics_ (id_cont_ circ c ft n) (bv_to_ket bv)
    (path_semantics_ (place_ circ ft n) (bv_to_ket bv))) /\
   ((a_depth_ (id_cont_ circ c ft n)) = n)).

Parameter reverse_: a_circuit_ -> a_circuit_.

Axiom Reverse_phase :
  forall (o:d_frac), ((reverse_ (a_phase_ o)) = (a_phase_ (inv1 o))).

Axiom Reverse_rx :
  forall (o:d_frac), ((reverse_ (a_rx_ o)) = (a_rx_ (inv1 o))).

Axiom Reverse_ry :
  forall (o:d_frac), ((reverse_ (a_ry_ o)) = (a_ry_ (inv1 o))).

Axiom Reverse_rz :
  forall (o:d_frac), ((reverse_ (a_rz_ o)) = (a_rz_ (inv1 o))).

Axiom Reverse_cnot : ((reverse_ (a_cnot_ tt)) = (a_cnot_ tt)).

Axiom Reverse_sequence :
  forall (d:a_circuit_) (e:a_circuit_),
  ((reverse_ (a_sequence_ d e)) = (a_sequence_ (reverse_ e) (reverse_ d))).

Axiom Reverse_parallel :
  forall (d:a_circuit_) (e:a_circuit_),
  ((reverse_ (a_parallel_ d e)) = (a_parallel_ (reverse_ e) (reverse_ d))).

Parameter id_par: a_circuit -> Z -> a_circuit.

Axiom id_par_def :
  forall (c:a_circuit) (k:Z), (0%Z <= k)%Z ->
  ((k = 0%Z) -> ((id_par c k) = c)) /\
  (~ (k = 0%Z) -> ((id_par c k) = (a_parallel (circ_ident k) c))).

Axiom id_par_spec :
  forall (c:a_circuit) (k:Z), (0%Z <= k)%Z ->
  ((a_to_gen_circuit (id_par c k)) = (id_par_ (a_to_gen_circuit c) k)) /\
  (((a_sum_range (id_par c k)) = (a_sum_range c)) /\
   (((a_depth (id_par c k)) = ((a_depth c) + k)%Z) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < k)%Z) ->
      ((a_ket_part (id_par c k) bvx bvy i) = (bvx i))) /\
     ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
       ((k <= i)%Z /\ (i < ((a_depth c) + k)%Z)%Z) ->
       ((a_ket_part (id_par c k) bvx bvy i) =
        (a_ket_part c
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
         (i - k)%Z))) /\
      forall (bvx:Z -> Z) (bvy:Z -> Z),
      ((a_phase_part (id_par c k) bvx bvy) =
       (a_phase_part c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy)))))).

Axiom circ_ident_id :
  forall (k:Z), (0%Z < k)%Z ->
  (forall (x:matrix t), (is_a_ket_basis_elt x) -> ((ket_length x) = k) ->
   semantics (circ_ident k) x x) /\
  forall (x:matrix t), (is_a_ket_l x k) -> semantics (circ_ident k) x x.

Axiom id_par_k :
  forall (c:a_circuit) (k:Z) (x:matrix t) (y:matrix t) (z:matrix t),
  (1%Z <= k)%Z -> (is_a_ket_l x k) -> (semantics c y z) ->
  semantics (id_par c k) (kronecker x y) (kronecker x z).

Parameter par_id: a_circuit -> Z -> a_circuit.

Axiom par_id_def :
  forall (c:a_circuit) (k:Z), (0%Z <= k)%Z ->
  ((k = 0%Z) -> ((par_id c k) = c)) /\
  (~ (k = 0%Z) -> ((par_id c k) = (a_parallel c (circ_ident k)))).

Axiom par_id_spec :
  forall (c:a_circuit) (k:Z), (0%Z <= k)%Z ->
  ((a_to_gen_circuit (par_id c k)) = (par_id_ (a_to_gen_circuit c) k)) /\
  (((a_sum_range (par_id c k)) = (a_sum_range c)) /\
   (((a_depth (par_id c k)) = ((a_depth c) + k)%Z) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((0%Z <= i)%Z /\ (i < (a_depth c))%Z) ->
      ((a_ket_part (par_id c k) bvx bvy i) = (a_ket_part c bvx bvy i))) /\
     ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
       (((a_depth c) <= i)%Z /\ (i < ((a_depth c) + k)%Z)%Z) ->
       ((a_ket_part (par_id c k) bvx bvy i) = (bvx i))) /\
      forall (bvx:Z -> Z) (bvy:Z -> Z),
      ((a_phase_part (par_id c k) bvx bvy) = (a_phase_part c bvx bvy)))))).

Axiom par_id_k :
  forall (c:a_circuit) (k:Z) (x:matrix t) (y:matrix t) (z:matrix t),
  (1%Z <= k)%Z -> (is_a_ket_l y k) -> (semantics c x z) ->
  semantics (par_id c k) (kronecker x y) (kronecker z y).

Parameter place: a_circuit -> Z -> Z -> a_circuit.

Axiom place_def :
  forall (c:a_circuit) (k:Z) (n:Z), (0%Z <= k)%Z ->
  (((a_depth c) + k)%Z <= n)%Z ->
  ((place c k n) = (id_par (par_id c ((n - (a_depth c))%Z - k)%Z) k)).

Axiom place_spec :
  forall (c:a_circuit) (k:Z) (n:Z), (0%Z <= k)%Z ->
  (((a_depth c) + k)%Z <= n)%Z ->
  ((a_to_gen_circuit (place c k n)) = (place_ (a_to_gen_circuit c) k n)) /\
  (((a_sum_range (place c k n)) = (a_sum_range c)) /\
   (((a_depth (place c k n)) = n) /\
    ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
      ((k <= i)%Z /\ (i < (k + (a_depth c))%Z)%Z) ->
      ((a_ket_part (place c k n) bvx bvy i) =
       (a_ket_part c
        (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
        (i - k)%Z))) /\
     ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
       ((0%Z <= i)%Z /\ (i < k)%Z) ->
       ((a_ket_part (place c k n) bvx bvy i) = (bvx i))) /\
      ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
        (((k + (a_depth c))%Z <= i)%Z /\ (i < n)%Z) ->
        ((a_ket_part (place c k n) bvx bvy i) = (bvx i))) /\
       forall (bvx:Z -> Z) (bvy:Z -> Z),
       ((a_phase_part (place c k n) bvx bvy) =
        (a_phase_part c
         (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy))))))).

Axiom place_ket :
  forall (c:a_circuit) (k:Z) (n:Z) (bvx:Z -> Z) (bvy:Z -> Z) (i:Z),
  (0%Z <= k)%Z -> (((a_depth c) + k)%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < n)%Z) ->
  (((k <= i)%Z /\ (i < (k + (a_depth c))%Z)%Z) ->
   ((a_ket_part (place c k n) bvx bvy i) =
    (a_ket_part c
     (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) bvx) k) bvy
     (i - k)%Z))) /\
  (~ ((k <= i)%Z /\ (i < (k + (a_depth c))%Z)%Z) ->
   ((a_ket_part (place c k n) bvx bvy i) = (bvx i))).

Axiom place_diag :
  forall (c:a_circuit) (k:Z) (n:Z), (0%Z <= k)%Z ->
  (((a_depth c) + k)%Z <= n)%Z -> (a_diag c) -> a_diag (place c k n).

Parameter id_cont: a_circuit -> Z -> Z -> Z -> a_circuit.

Axiom id_cont_spec :
  forall (circ:a_circuit) (c:Z) (ft:Z) (n:Z), ((0%Z <= c)%Z /\ (c < n)%Z) ->
  ((0%Z <= ft)%Z /\ (ft <= (n - (a_depth circ))%Z)%Z) ->
  ((ft <= c)%Z -> ((ft + (a_depth circ))%Z <= c)%Z) ->
  ((a_depth (id_cont circ c ft n)) = n) /\
  (((a_sum_range (id_cont circ c ft n)) = (a_sum_range circ)) /\
   (((a_to_gen_circuit (id_cont circ c ft n)) =
     (id_cont_ (a_to_gen_circuit circ) c ft n)) /\
    ((forall (x:matrix t), (is_a_ket_l x n) ->
      (((value (ket_to_bv x)) c) = 0%Z) ->
      semantics (id_cont circ c ft n) x x) /\
     forall (x:matrix t), (is_a_ket_l x n) ->
     (((value (ket_to_bv x)) c) = 1%Z) ->
     semantics (id_cont circ c ft n) x (path_semantics (place circ ft n) x)))).

Parameter param_cnot: Z -> Z -> Z -> a_circuit.

Axiom param_cnot_spec :
  forall (c:Z) (t1:Z) (n:Z), ((0%Z <= c)%Z /\ (c < n)%Z) ->
  ((0%Z <= t1)%Z /\ (t1 < n)%Z) -> ~ (c = t1) ->
  ((a_sum_range (param_cnot c t1 n)) = 0%Z) /\
  (((a_depth (param_cnot c t1 n)) = n) /\
   ((forall (bvx:Z -> Z) (bvy:Z -> Z), forall (i:Z),
     ((0%Z <= i)%Z /\ (i < (a_depth (param_cnot c t1 n)))%Z) ->
     ((i = t1) ->
      ((a_ket_part (param_cnot c t1 n) bvx bvy i) =
       (int.EuclideanDivision.mod1 ((bvx c) + (bvx t1))%Z 2%Z))) /\
     (~ (i = t1) -> ((a_ket_part (param_cnot c t1 n) bvx bvy i) = (bvx i)))) /\
    forall (bvx:Z -> Z) (bvy:Z -> Z),
    ((a_phase_part (param_cnot c t1 n) bvx bvy) = zero_d_))).

Parameter diag_mat: Z -> (Z -> t) -> matrix t.

Axiom diag_mat_def :
  forall (n:Z) (f:Z -> t), (0%Z < n)%Z ->
  ((diag_mat n f) =
   (make_f n n (fun (i:Z) (j:Z) => (infix_asdt (f i) (indic i j))))).

Axiom diag_mat_spec :
  forall (n:Z) (f:Z -> t), (0%Z < n)%Z ->
  (forall (i:Z) (j:Z),
   (((0%Z <= i)%Z /\ (i < n)%Z) /\ ((0%Z <= j)%Z /\ (j < n)%Z)) ->
   ~ (i = j) -> ((get (diag_mat n f) i j) = tzero)) /\
  forall (i:Z) (j:Z),
  (((0%Z <= i)%Z /\ (i < n)%Z) /\ ((0%Z <= j)%Z /\ (j < n)%Z)) -> (i = j) ->
  ((get (diag_mat n f) i j) = (f i)).

Axiom diag_mat_values :
  forall (n:Z) (f:Z -> t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < n)%Z) ->
  ((0%Z <= j)%Z /\ (j < n)%Z) ->
  ((get (diag_mat n f) i j) = (infix_asdt (f i) (indic i j))).

Axiom diag_mat_eq :
  forall (f:Z -> t) (g:Z -> t) (n:Z), (0%Z < n)%Z ->
  (forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> ((f i) = (g i))) ->
  ((diag_mat n f) = (diag_mat n g)).

Axiom mat_mult_diag :
  forall (m:matrix t) (f:Z -> t),
  ((mat_mult m (diag_mat (columns m) f)) =
   (make_f (rows m) (columns m)
    (fun (i:Z) (j:Z) => (infix_asdt (get m i j) (f j))))).

Axiom diag_mult_mat :
  forall (m:matrix t) (f:Z -> t),
  ((mat_mult (diag_mat (rows m) f) m) =
   (make_f (rows m) (columns m)
    (fun (i:Z) (j:Z) => (infix_asdt (get m i j) (f i))))).

Axiom diag_mult_diag :
  forall (f:Z -> t) (g:Z -> t) (n:Z), (0%Z < n)%Z ->
  ((mat_mult (diag_mat n f) (diag_mat n g)) =
   (diag_mat n (fun (i:Z) => (infix_asdt (f i) (g i))))).

Axiom ind_product_re :
  forall (f:Z -> Z -> t) (i:Z) (j:Z) (n:Z), (i < j)%Z -> forall (k:Z),
  ((0%Z <= k)%Z /\ (k < n)%Z) ->
  ((ind_product (fun (i1:Z) => ((f i1) k)) i (j + 1%Z)%Z) =
   (infix_asdt (ind_product (fun (i1:Z) => ((f i1) k)) i j) ((f j) k))).

Axiom int_mat_diag_prod :
  forall (f:Z -> Z -> t) (i:Z) (j:Z) (n:Z), (0%Z < n)%Z -> (i <= j)%Z ->
  ((int_mat_prod (fun (k:Z) => (diag_mat n (f k))) i j) =
   (diag_mat n
    (fun (k:Z) => (ind_product (fun (l:Z) => ((f l) k)) i (j + 1%Z)%Z)))).

Parameter diag_two_mat: Z -> (Z -> Z -> Z -> t) -> matrix t.

Parameter result18: Z -> (Z -> Z -> Z -> t) -> Z -> Z -> t.

Axiom result_def18 :
  forall (n:Z) (f:Z -> Z -> Z -> t) (i:Z) (j:Z),
  ((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
    ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
   ((((result18 n f) i) j) =
    (infix_asdt (indic (tail_bits i n) (tail_bits j n))
     (((f (head_bit i n)) (head_bit j n)) (tail_bits i n))))) /\
  (~ (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
      ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
   ((((result18 n f) i) j) = tzero)).

Axiom diag_two_mat_def :
  forall (n:Z) (f:Z -> Z -> Z -> t), (2%Z <= n)%Z ->
  ((diag_two_mat n f) = (make_f (power 2%Z n) (power 2%Z n) (result18 n f))).

Axiom diag_two_mat_spec :
  forall (n:Z) (f:Z -> Z -> Z -> t), (2%Z <= n)%Z ->
  ((rows (diag_two_mat n f)) = (power 2%Z n)) /\
  (((columns (diag_two_mat n f)) = (power 2%Z n)) /\
   ((diag_two_mat n f) =
    (make_f (power 2%Z n) (power 2%Z n)
     (fun (i:Z) (j:Z) =>
      (infix_asdt (indic (tail_bits i n) (tail_bits j n))
       (((f (head_bit i n)) (head_bit j n)) (tail_bits i n))))))).

Parameter two_bloc_diag_mat: Z -> (Z -> Z -> Z -> t) -> matrix t.

Parameter result19: Z -> (Z -> Z -> Z -> t) -> Z -> Z -> t.

Axiom result_def19 :
  forall (n:Z) (f:Z -> Z -> Z -> t) (i:Z) (j:Z),
  ((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
    ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
   ((((result19 n f) i) j) =
    (infix_asdt (indic (head_bit i n) (head_bit j n))
     (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))))) /\
  (~ (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
      ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
   ((((result19 n f) i) j) = tzero)).

Axiom two_bloc_diag_mat_def :
  forall (n:Z) (f:Z -> Z -> Z -> t), (2%Z <= n)%Z ->
  ((two_bloc_diag_mat n f) =
   (make_f (power 2%Z n) (power 2%Z n) (result19 n f))).

Axiom two_bloc_diag_mat_spec :
  forall (n:Z) (f:Z -> Z -> Z -> t), (2%Z <= n)%Z ->
  ((rows (two_bloc_diag_mat n f)) = (power 2%Z n)) /\
  (((columns (two_bloc_diag_mat n f)) = (power 2%Z n)) /\
   ((two_bloc_diag_mat n f) =
    (make_f (power 2%Z n) (power 2%Z n)
     (fun (i:Z) (j:Z) =>
      (infix_asdt (indic (head_bit i n) (head_bit j n))
       (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))))))).

Axiom two_bloc_diag_two_val :
  forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> Z -> Z -> t) (i:Z) (j:Z),
  ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
  ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> (2%Z <= n)%Z ->
  ((get (mat_mult (two_bloc_diag_mat n f) (diag_two_mat n g)) i j) =
   (infix_asdt (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))
    (((g (head_bit i n)) (head_bit j n)) (tail_bits j n)))).

Axiom two_bloc_diag_two :
  forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> Z -> Z -> t), (2%Z <= n)%Z ->
  ((mat_mult (two_bloc_diag_mat n f) (diag_two_mat n g)) =
   (make_f (power 2%Z n) (power 2%Z n)
    (fun (i:Z) (j:Z) =>
     (infix_asdt (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))
      (((g (head_bit i n)) (head_bit j n)) (tail_bits j n)))))).

Axiom two_bloc_mult_diag :
  forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> t), (2%Z <= n)%Z ->
  ((mat_mult (two_bloc_diag_mat n f) (diag_mat (power 2%Z n) g)) =
   (two_bloc_diag_mat n
    (fun (hi:Z) (ti:Z) (tj:Z) =>
     (infix_asdt (((f hi) ti) tj) (g (ht_to_int hi tj n)))))).

Axiom kronecker_scalar_distr :
  forall (m:matrix t) (n:matrix t) (a:t),
  ((kronecker (infix_asdtdt a m) n) = (infix_asdtdt a (kronecker m n))).

Axiom kronecker_scalar_distr_r :
  forall (m:matrix t) (n:matrix t) (a:t),
  ((kronecker m (infix_asdtdt a n)) = (infix_asdtdt a (kronecker m n))).

Axiom kronecker_scalars :
  forall (m:matrix t) (n:matrix t) (a:t) (b:t),
  ((kronecker (infix_asdtdt a m) (infix_asdtdt b n)) =
   (infix_asdtdt (infix_asdt a b) (kronecker m n))).

Parameter mat_k_id: (matrix t) -> Z -> matrix t.

Axiom mat_k_id_def :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((mat_k_id m n) = (kronecker m (identity n))).

Axiom mat_k_id_spec :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((mat_k_id m n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns m) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.mod1 i (power 2%Z n))
       (int.EuclideanDivision.mod1 j (power 2%Z n)))
      (get m (int.EuclideanDivision.div i (power 2%Z n))
       (int.EuclideanDivision.div j (power 2%Z n))))))).

Axiom mat_k_id_values :
  forall (m:matrix t) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((columns m) * (power 2%Z n))%Z)%Z) ->
  ((get (mat_k_id m n) i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.mod1 i (power 2%Z n))
     (int.EuclideanDivision.mod1 j (power 2%Z n)))
    (get m (int.EuclideanDivision.div i (power 2%Z n))
     (int.EuclideanDivision.div j (power 2%Z n))))).

Axiom mat_k_id_rows :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((rows (mat_k_id m n)) = ((rows m) * (power 2%Z n))%Z).

Axiom mat_k_id_columns :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns (mat_k_id m n)) = ((columns m) * (power 2%Z n))%Z).

Parameter id_k_mat: (matrix t) -> Z -> matrix t.

Axiom id_k_mat_def :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((id_k_mat m n) = (kronecker (identity n) m)).

Axiom id_k_mat_spec :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((id_k_mat m n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns m) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.div i (rows m))
       (int.EuclideanDivision.div j (columns m)))
      (get m (int.EuclideanDivision.mod1 i (rows m))
       (int.EuclideanDivision.mod1 j (columns m))))))).

Axiom id_k_mat_values :
  forall (m:matrix t) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
  ((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((columns m) * (power 2%Z n))%Z)%Z) ->
  ((get (id_k_mat m n) i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.div i (rows m))
     (int.EuclideanDivision.div j (columns m)))
    (get m (int.EuclideanDivision.mod1 i (rows m))
     (int.EuclideanDivision.mod1 j (columns m))))).

Axiom id_k_mat_rows :
  forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((rows (id_k_mat m n)) = ((rows m) * (power 2%Z n))%Z).

Axiom id_k_mat_columns :
  forall (m:matrix t) (n:Z), (0%Z < n)%Z ->
  ((columns (id_k_mat m n)) = ((columns m) * (power 2%Z n))%Z).

Parameter mat_prod_k_id: (matrix t) -> (matrix t) -> Z -> matrix t.

Axiom mat_prod_k_id_def :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((mat_prod_k_id m o n) = (kronecker (mat_mult m o) (identity n))).

Axiom mat_prod_k_id_spec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((mat_prod_k_id m o n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.mod1 i (power 2%Z n))
       (int.EuclideanDivision.mod1 j (power 2%Z n)))
      (ind_sum
       (fun (k:Z) =>
        (infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
         (get o k (int.EuclideanDivision.div j (power 2%Z n)))))
       0%Z (columns m)))))).

Parameter id_k_mat_prod: (matrix t) -> (matrix t) -> Z -> matrix t.

Axiom id_k_mat_prod_def :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((id_k_mat_prod m o n) = (kronecker (identity n) (mat_mult m o))).

Axiom id_k_mat_prod_spec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((id_k_mat_prod m o n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.div i (rows m))
       (int.EuclideanDivision.div j (columns o)))
      (ind_sum
       (fun (k:Z) =>
        (infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
         (get o k (int.EuclideanDivision.mod1 j (columns o)))))
       0%Z (columns m)))))).

Axiom filter_sum_mod_indic :
  forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (0%Z < n)%Z -> (0%Z < v)%Z ->
  ((0%Z <= p)%Z /\ (p < v)%Z) ->
  ((sum (to_fset 0%Z (v * n)%Z)
    (fun (k:Z) =>
     (infix_asdt (indic (int.EuclideanDivision.mod1 k v) p)
      (g (int.EuclideanDivision.div k v)))))
   = (sum (to_fset 0%Z n) g)).

Axiom filter_sum_indic_div :
  forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (0%Z < n)%Z -> (0%Z < v)%Z ->
  ((0%Z <= p)%Z /\ (p < n)%Z) ->
  ((sum (to_fset 0%Z (v * n)%Z)
    (fun (k:Z) =>
     (infix_asdt (g (int.EuclideanDivision.mod1 k v))
      (indic (int.EuclideanDivision.div k v) p))))
   = (sum (to_fset 0%Z v) g)).

Axiom filtered_ind_sum_mod_indic :
  forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (0%Z < n)%Z -> (0%Z < v)%Z ->
  ((0%Z <= p)%Z /\ (p < v)%Z) ->
  ((ind_sum
    (fun (k:Z) =>
     (infix_asdt (indic (int.EuclideanDivision.mod1 k v) p)
      (g (int.EuclideanDivision.div k v))))
    0%Z (v * n)%Z)
   = (ind_sum g 0%Z n)).

Axiom filtered_ind_sum_indic_div :
  forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (0%Z < n)%Z -> (0%Z < v)%Z ->
  ((0%Z <= p)%Z /\ (p < n)%Z) ->
  ((ind_sum
    (fun (k:Z) =>
     (infix_asdt (g (int.EuclideanDivision.mod1 k v))
      (indic (int.EuclideanDivision.div k v) p)))
    0%Z (v * n)%Z)
   = (ind_sum g 0%Z v)).

Axiom prod_mat_k_id_pre :
  forall (m:matrix t) (o:matrix t) (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((columns o) * (power 2%Z n))%Z)%Z) ->
  ((get (mat_mult (mat_k_id m n) (mat_k_id o n)) i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.mod1 i (power 2%Z n))
     (int.EuclideanDivision.mod1 j (power 2%Z n)))
    (ind_sum
     (fun (k:Z) =>
      (infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
       (get o k (int.EuclideanDivision.div j (power 2%Z n)))))
     0%Z (columns m)))).

Parameter prod_mat_k_id: (matrix t) -> (matrix t) -> Z -> matrix t.

Axiom prod_mat_k_id_def :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((prod_mat_k_id m o n) = (mat_mult (mat_k_id m n) (mat_k_id o n))).

Axiom prod_mat_k_id_spec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((prod_mat_k_id m o n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.mod1 i (power 2%Z n))
       (int.EuclideanDivision.mod1 j (power 2%Z n)))
      (ind_sum
       (fun (k:Z) =>
        (infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
         (get o k (int.EuclideanDivision.div j (power 2%Z n)))))
       0%Z (columns m)))))).

Axiom prod_mat_k_id_dec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) -> ((prod_mat_k_id m o n) = (mat_prod_k_id m o n)).

Axiom k_id_prod_mat_pre :
  forall (m:matrix t) (o:matrix t) (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((columns o) * (power 2%Z n))%Z)%Z) ->
  ((get (mat_mult (id_k_mat m n) (id_k_mat o n)) i j) =
   (infix_asdt
    (indic (int.EuclideanDivision.div i (rows m))
     (int.EuclideanDivision.div j (columns o)))
    (ind_sum
     (fun (k:Z) =>
      (infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
       (get o k (int.EuclideanDivision.mod1 j (columns o)))))
     0%Z (columns m)))).

Parameter k_id_prod_mat: (matrix t) -> (matrix t) -> Z -> matrix t.

Axiom k_id_prod_mat_def :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((k_id_prod_mat m o n) = (mat_mult (id_k_mat m n) (id_k_mat o n))).

Axiom k_id_prod_mat_spec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) ->
  ((k_id_prod_mat m o n) =
   (make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
    (fun (i:Z) (j:Z) =>
     (infix_asdt
      (indic (int.EuclideanDivision.div i (rows m))
       (int.EuclideanDivision.div j (columns o)))
      (ind_sum
       (fun (k:Z) =>
        (infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
         (get o k (int.EuclideanDivision.mod1 j (columns o)))))
       0%Z (columns m)))))).

Axiom k_id_prod_mat_dec :
  forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
  ((columns m) = (rows o)) -> ((k_id_prod_mat m o n) = (id_k_mat_prod m o n)).

Axiom split_ne_pre :
  forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z)
    (i:Z) (j:Z),
  (0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
  ((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
  ((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
  ((0%Z <= i)%Z /\ (i < ((power 2%Z nr1) * (power 2%Z nr2))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((power 2%Z nc1) * (power 2%Z nc2))%Z)%Z) ->
  ((get (mat_mult (id_k_mat m1 nr2) (mat_k_id m2 nc1)) i j) =
   (get (kronecker m2 m1) i j)).

Axiom split_nw_pre :
  forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z)
    (i:Z) (j:Z),
  (0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
  ((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
  ((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
  ((0%Z <= i)%Z /\ (i < ((power 2%Z nr1) * (power 2%Z nr2))%Z)%Z) ->
  ((0%Z <= j)%Z /\ (j < ((power 2%Z nc1) * (power 2%Z nc2))%Z)%Z) ->
  ((get (mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) i j) =
   (get (kronecker m1 m2) i j)).

Axiom split_ne :
  forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
  (0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
  ((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
  ((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
  ((mat_mult (id_k_mat m1 nr2) (mat_k_id m2 nc1)) = (kronecker m2 m1)).

Axiom split_nw :
  forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
  (0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
  ((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
  ((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
  ((mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) = (kronecker m1 m2)).

Axiom shift_k_id :
  forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
  (0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
  ((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
  ((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
  ((mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) =
   (mat_mult (id_k_mat m2 nr1) (mat_k_id m1 nc2))).

Axiom kronecker_mult_commut :
  forall (a:matrix t) (b:matrix t) (c:matrix t) (d:matrix t) (ra:Z) (ca:Z)
    (cc:Z) (rb:Z) (cb:Z) (cd:Z),
  (0%Z <= ra)%Z -> (0%Z <= ca)%Z -> (0%Z <= cc)%Z -> (0%Z <= rb)%Z ->
  (0%Z <= cb)%Z -> (0%Z <= cd)%Z -> ((rows a) = (power 2%Z ra)) ->
  ((columns a) = (power 2%Z ca)) -> ((rows c) = (power 2%Z ca)) ->
  ((columns c) = (power 2%Z cc)) -> ((rows b) = (power 2%Z rb)) ->
  ((columns b) = (power 2%Z cb)) -> ((rows d) = (power 2%Z cb)) ->
  ((columns d) = (power 2%Z cd)) ->
  ((mat_mult (kronecker a b) (kronecker c d)) =
   (kronecker (mat_mult a c) (mat_mult b d))).

(* Why3 assumption *)
Definition isa_square (m:matrix t) : Prop := ((rows m) = (columns m)).

(* Why3 assumption *)
Definition pow2dim (m:matrix t) : Prop :=
  exists i:Z, exists j:Z,
  ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j)).

(* Why3 assumption *)
Definition pow2dim_square (m:matrix t) : Prop :=
  exists i:Z, ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z i)).

Axiom pow_2dim_kets : forall (m:matrix t), (is_a_ket m) -> pow2dim m.

Parameter lnr: (matrix t) -> Z.

Axiom lnr_spec :
  forall (m:matrix t), (pow2dim m) ->
  ((rows m) = (power 2%Z (lnr m))) /\ (0%Z <= (lnr m))%Z.

Parameter lnc: (matrix t) -> Z.

Axiom lnc_spec :
  forall (m:matrix t), (pow2dim m) ->
  ((columns m) = (power 2%Z (lnc m))) /\ (0%Z <= (lnc m))%Z.

Axiom get_pow2dim :
  forall (m:matrix t), (pow2dim m) ->
  exists i:Z, exists j:Z,
  ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j)).

Axiom set_pow2dim :
  forall (m:matrix t),
  (exists i:Z, exists j:Z,
   ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j))) ->
  pow2dim m.

Axiom get_pow2dim_elt :
  forall (m:matrix t) (i:Z) (j:Z), (pow2dim m) -> ((lnr m) = i) ->
  ((lnc m) = j) ->
  ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j)).

Axiom set_pow2dim_elt :
  forall (m:matrix t) (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
  ((rows m) = (power 2%Z i)) -> ((columns m) = (power 2%Z j)) ->
  (pow2dim m) /\ (((lnr m) = i) /\ ((lnc m) = j)).

Parameter mat_size: (matrix t) -> Z.

Axiom mat_size_def :
  forall (m:matrix t), (isa_square m) -> ((mat_size m) = (rows m)).

Axiom mat_size_spec :
  forall (m:matrix t), (isa_square m) ->
  ((mat_size m) = (rows m)) /\ ((mat_size m) = (columns m)).

Axiom get_square :
  forall (m:matrix t), (isa_square m) -> ((rows m) = (columns m)).

Axiom set_square :
  forall (m:matrix t), ((rows m) = (columns m)) -> isa_square m.

Axiom set_square_elt :
  forall (m:matrix t) (i:Z), ((rows m) = i) -> ((columns m) = i) ->
  (isa_square m) /\ ((mat_size m) = i).

Axiom get_square_elt :
  forall (m:matrix t) (i:Z), (isa_square m) -> ((mat_size m) = i) ->
  ((rows m) = i) /\ ((columns m) = i).

Axiom pow2dim_square_dec :
  forall (m:matrix t), (isa_square m) -> (pow2dim m) -> pow2dim_square m.

Axiom dec_pow2dim_square :
  forall (m:matrix t), (pow2dim_square m) -> (isa_square m) /\ (pow2dim m).

Parameter ln_size: (matrix t) -> Z.

Axiom ln_size_def :
  forall (m:matrix t), (pow2dim_square m) -> ((ln_size m) = (lnr m)).

Axiom ln_size_spec :
  forall (m:matrix t), (pow2dim_square m) ->
  ((ln_size m) = (lnc m)) /\
  (((rows m) = (power 2%Z (ln_size m))) /\
   ((columns m) = (power 2%Z (ln_size m)))).

Axiom set_ln_size_lnc :
  forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((lnc m) = i) ->
  ((ln_size m) = i).

Axiom set_ln_size_lnr :
  forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((lnr m) = i) ->
  ((ln_size m) = i).

Axiom set_ln_size_columns :
  forall (m:matrix t) (i:Z), (0%Z <= i)%Z -> (pow2dim_square m) ->
  ((columns m) = (power 2%Z i)) -> ((ln_size m) = i).

Axiom set_ln_size_rows :
  forall (m:matrix t) (i:Z), (0%Z <= i)%Z -> (pow2dim_square m) ->
  ((rows m) = (power 2%Z i)) -> ((ln_size m) = i).

Axiom set_pow2dim_square :
  forall (m:matrix t),
  (exists i:Z, ((rows m) = (columns m)) /\ ((columns m) = (power 2%Z i))) ->
  pow2dim_square m.

Axiom set_pow2dim_square_elt :
  forall (m:matrix t) (i:Z), (0%Z <= i)%Z ->
  (((rows m) = (columns m)) /\ ((columns m) = (power 2%Z i))) ->
  (pow2dim_square m) /\ ((ln_size m) = i).

Axiom get_pow2dim_square_elt :
  forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((ln_size m) = i) ->
  ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z i)).

Axiom kronecker_mult_commut_p :
  forall (a:matrix t) (b:matrix t) (c:matrix t) (d:matrix t),
  ((columns a) = (rows c)) -> ((columns b) = (rows d)) -> (pow2dim a) ->
  (pow2dim b) -> (pow2dim c) -> (pow2dim d) ->
  ((mat_mult (kronecker a b) (kronecker c d)) =
   (kronecker (mat_mult a c) (mat_mult b d))).

Axiom kronecker_mult_commut_p_quant :
  forall (a:matrix t) (b:matrix t), (pow2dim a) -> (pow2dim b) ->
  forall (c:matrix t) (d:matrix t), ((columns a) = (rows c)) ->
  ((columns b) = (rows d)) -> (pow2dim c) -> (pow2dim d) ->
  ((mat_mult (kronecker a b) (kronecker c d)) =
   (kronecker (mat_mult a c) (mat_mult b d))).

Axiom kronecker_add_distr_l :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  ((rows (kronecker (add_mat m n) o)) = ((rows m) * (rows o))%Z) /\
  (((columns (kronecker (add_mat m n) o)) = ((columns m) * (columns o))%Z) /\
   ((kronecker (add_mat m n) o) = (add_mat (kronecker m o) (kronecker n o)))).

Axiom kronecker_add_distr_r :
  forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
  ((columns m) = (columns n)) ->
  ((kronecker o (add_mat m n)) = (add_mat (kronecker o m) (kronecker o n))) /\
  (((rows (kronecker o (add_mat m n))) = ((rows m) * (rows o))%Z) /\
   ((columns (kronecker o (add_mat m n))) = ((columns m) * (columns o))%Z)).

Axiom kronecker_sum_distr_l :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  (((columns (mat_sum s (fun (k:a) => (kronecker (f k) m)))) =
    (columns ((fun (k:a) => (kronecker (f k) m)) (choose s)))) /\
   ((columns ((fun (k:a) => (kronecker (f k) m)) (choose s))) =
    ((columns m) * (columns (f (choose s))))%Z)) /\
  ((((rows (mat_sum s (fun (k:a) => (kronecker (f k) m)))) =
     (rows ((fun (k:a) => (kronecker (f k) m)) (choose s)))) /\
    ((rows ((fun (k:a) => (kronecker (f k) m)) (choose s))) =
     ((rows m) * (rows (f (choose s))))%Z)) /\
   ((kronecker (mat_sum s f) m) =
    (mat_sum s (fun (k:a) => (kronecker (f k) m))))).

Axiom kronecker_sum_distr_r :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  (((columns (mat_sum s (fun (k:a) => (kronecker m (f k))))) =
    (columns ((fun (k:a) => (kronecker m (f k))) (choose s)))) /\
   ((columns ((fun (k:a) => (kronecker m (f k))) (choose s))) =
    ((columns m) * (columns (f (choose s))))%Z)) /\
  ((((rows (mat_sum s (fun (k:a) => (kronecker m (f k))))) =
     (rows ((fun (k:a) => (kronecker m (f k))) (choose s)))) /\
    ((rows ((fun (k:a) => (kronecker m (f k))) (choose s))) =
     ((rows m) * (rows (f (choose s))))%Z)) /\
   ((kronecker m (mat_sum s f)) =
    (mat_sum s (fun (k:a) => (kronecker m (f k)))))).

Axiom mat_sum_scalar1 :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
  (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k)))) =
   (infix_asdtdt a1 (mat_sum s f))).

Axiom kronecker_sum_distr_sc :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t) (a1:t),
  (constant_size s f) -> (0%Z < (cardinal s))%Z ->
  ((mat_sum s (fun (k:a) => (kronecker (infix_asdtdt a1 (f k)) m))) =
   (infix_asdtdt a1 (mat_sum s (fun (k:a) => (kronecker (f k) m))))).

Axiom kronecker_ket_sum_distr_l :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l1) -> (is_a_ket_l m l2) ->
  (0%Z < (cardinal s))%Z ->
  (is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z)
   (l1 + l2)%Z) /\
  ((kronecker (ket_sum_l s f l1) m) =
   (ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z)).

Axiom kronecker_ket_sum_distr_r :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l1) -> (is_a_ket_l m l2) ->
  (0%Z < (cardinal s))%Z ->
  (is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z)
   (l1 + l2)%Z) /\
  ((kronecker m (ket_sum_l s f l1)) =
   (ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z)).

Axiom ket_sum_scalar :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l) ->
  (0%Z < (cardinal s))%Z ->
  ((ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
   (infix_asdtdt a1 (ket_sum_l s f l))).

Axiom kronecker_ket_sum_distr_sc :
  forall {a:Type} {a_WT:WhyType a},
  forall (s:set a) (f:a -> matrix t) (m:matrix t) (a1:t) (l1:Z) (l2:Z),
  (forall (e:a), (mem e s) -> is_a_ket_l (f e) l1) -> (is_a_ket_l m l2) ->
  (0%Z < (cardinal s))%Z ->
  ((ket_sum_l s (fun (k:a) => (kronecker (infix_asdtdt a1 (f k)) m))
    (l1 + l2)%Z)
   =
   (infix_asdtdt a1
    (ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z))).

Axiom place_k_z :
  forall (circ:a_circuit) (bv:bitvec) (c:Z) (ft:Z) (n:Z) (y:matrix t),
  ((0%Z <= c)%Z /\ (c < n)%Z) -> (mem bv (n_bvs ft)) ->
  (is_a_ket_l y (a_depth circ)) ->
  ((0%Z <= ft)%Z /\ (ft = (n - (a_depth circ))%Z)) ->
  ((ft <= c)%Z -> ((ft + (a_depth circ))%Z <= c)%Z) ->
  ((((value bv) c) = 0%Z) ->
   ((path_semantics (id_cont circ c ft n) (kronecker (bv_to_ket bv) y)) =
    (kronecker (bv_to_ket bv) y))) /\
  ((((value bv) c) = 1%Z) ->
   ((path_semantics (id_cont circ c ft n) (kronecker (bv_to_ket bv) y)) =
    (kronecker (bv_to_ket bv) (path_semantics circ y)))).

Axiom path_semantics_id_cont :
  forall (circ:a_circuit) (c:Z) (ft:Z) (n:Z), ((0%Z <= c)%Z /\ (c < n)%Z) ->
  ((0%Z <= ft)%Z /\ (ft <= (n - (a_depth circ))%Z)%Z) ->
  ((ft <= c)%Z -> ((ft + (a_depth circ))%Z <= c)%Z) -> forall (bv:bitvec),
  (mem bv (n_bvs n)) ->
  ((((value bv) c) = 0%Z) ->
   ((path_semantics (id_cont circ c ft n) (bv_to_ket bv)) = (bv_to_ket bv))) /\
  (~ (((value bv) c) = 0%Z) ->
   ((path_semantics (id_cont circ c ft n) (bv_to_ket bv)) =
    (path_semantics (place circ ft n) (bv_to_ket bv)))).

Axiom Equiv_sem :
  forall (c:a_circuit), forall (x:matrix t) (x':matrix t),
  (semantics c x x') <-> (semantics_ (a_to_gen_circuit c) x x').

Axiom ident_sem :
  forall (n:Z) (x:matrix t), (is_a_ket_l x n) -> (0%Z < n)%Z ->
  semantics (circ_ident n) x x.

Axiom ident_sem_ :
  forall (n:Z) (x:matrix t), (is_a_ket_l x n) -> (0%Z < n)%Z ->
  semantics_ (circ_ident_ n) x x.

Axiom equiv_sem :
  forall (c:a_circuit) (x:matrix t) (x':matrix t),
  (semantics_ (a_to_gen_circuit c) x x') -> semantics c x x'.

Axiom equiv_sem_rev :
  forall (c:a_circuit) (x:matrix t) (x':matrix t), (semantics c x x') ->
  semantics_ (a_to_gen_circuit c) x x'.

Axiom id_cont_kron_pre :
  forall (circ:a_circuit) (c:Z) (ft:Z) (n:Z) (x:matrix t) (y:matrix t)
    (z:matrix t),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (a_depth circ))%Z) ->
  (semantics circ y z) -> (is_a_ket_basis_elt x) -> (is_a_ket_basis_elt y) ->
  (is_a_ket_l x ft) ->
  ((((value (ket_to_bv x)) c) = 0%Z) ->
   semantics (id_cont circ c ft n) (kronecker x y) (kronecker x y)) /\
  ((((value (ket_to_bv x)) c) = 1%Z) ->
   semantics (id_cont circ c ft n) (kronecker x y) (kronecker x z)).

Axiom id_cont_kron :
  forall (circ:a_circuit) (c:Z) (ft:Z) (n:Z) (x:matrix t) (y:matrix t)
    (z:matrix t),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (a_depth circ))%Z) ->
  (semantics circ y z) -> (is_a_ket_basis_elt x) -> (is_a_ket_l x ft) ->
  ((((value (ket_to_bv x)) c) = 0%Z) ->
   semantics (id_cont circ c ft n) (kronecker x y) (kronecker x y)) /\
  ((((value (ket_to_bv x)) c) = 1%Z) ->
   semantics (id_cont circ c ft n) (kronecker x y) (kronecker x z)).

Parameter reverse: a_circuit -> a_circuit.

Axiom reverse_spec :
  forall (c:a_circuit),
  ((mat_mult (mat_semantics c) (mat_semantics (reverse c))) =
   (identity (a_depth c))) /\
  (((rows (mat_semantics (reverse c))) = (rows (mat_semantics c))) /\
   (((columns (mat_semantics (reverse c))) = (columns (mat_semantics c))) /\
    forall (x:matrix t) (x':matrix t), (semantics c x x') ->
    semantics (reverse c) x' x)).

Axiom Reverse_phase1 :
  forall (o:d_frac_), ((reverse (a_phase o)) = (a_phase (inv_1 o))).

Axiom Reverse_rz1 :
  forall (o:d_frac_), ((reverse (a_rz o)) = (a_rz (inv_1 o))).

Axiom Reverse_had : ((reverse (a_hadamard tt)) = (a_hadamard tt)).

Axiom Reverse_cnot1 : ((reverse (a_cnot tt)) = (a_cnot tt)).

Axiom Reverse_sequence1 :
  forall (d:a_circuit) (e:a_circuit),
  ((reverse (a_sequence d e)) = (a_sequence (reverse e) (reverse d))).

Axiom Reverse_parallel1 :
  forall (d:a_circuit) (e:a_circuit),
  ((reverse (a_parallel d e)) = (a_parallel (reverse e) (reverse d))).

(* Why3 assumption *)
Definition eigen (c:a_circuit) (x:matrix t) (o:d_frac) : Prop :=
  semantics c x (infix_asdtdt (value1 o) x).

Axiom eigen_depth :
  forall (c:a_circuit) (x:matrix t) (o:d_frac), (eigen c x o) ->
  ((a_depth c) = (ket_length x)).

Axiom eigen_scal :
  forall (c:a_circuit) (a:d_frac) (x:matrix t) (o:d_frac), (eigen c x o) ->
  eigen c (infix_asdtdt (value1 a) x) o.

Parameter eigen_comp:
  a_circuit -> a_circuit -> (matrix t) -> d_frac -> d_frac -> a_circuit.

Axiom eigen_comp_def :
  forall (c:a_circuit) (c':a_circuit) (x:matrix t) (o:d_frac) (o':d_frac),
  ((a_depth c) = (a_depth c')) -> (eigen c x o) -> (eigen c' x o') ->
  ((eigen_comp c c' x o o') = (a_sequence c c')).

Axiom eigen_comp_spec :
  forall (c:a_circuit) (c':a_circuit) (x:matrix t) (o:d_frac) (o':d_frac),
  ((a_depth c) = (a_depth c')) -> (eigen c x o) -> (eigen c' x o') ->
  ((a_depth (eigen_comp c c' x o o')) = (a_depth c)) /\
  (eigen (eigen_comp c c' x o o') x (add1 o o')).

Parameter eigen_square: a_circuit -> (matrix t) -> d_frac -> a_circuit.

Axiom eigen_square_def :
  forall (c:a_circuit) (x:matrix t) (o:d_frac), (eigen c x o) ->
  ((eigen_square c x o) = (eigen_comp c c x o o)).

Axiom eigen_square_spec :
  forall (c:a_circuit) (x:matrix t) (o:d_frac), (eigen c x o) ->
  ((a_depth (eigen_square c x o)) = (a_depth c)) /\
  ((eigen (eigen_square c x o) x (add1 o o)) /\
   ((eigen_square c x o) = (a_sequence c c))).

Parameter pow_pow_2: a_circuit -> Z -> (matrix t) -> Z -> Z -> a_circuit.

Axiom pow_pow_2_def :
  forall (c:a_circuit) (p:Z) (x:matrix t) (k:Z) (n:Z), (0%Z <= n)%Z ->
  (0%Z <= p)%Z -> (eigen c x (dyadic k n)) ->
  ((p = 0%Z) -> ((pow_pow_2 c p x k n) = c)) /\
  (~ (p = 0%Z) ->
   ((pow_pow_2 c p x k n) =
    (eigen_square (pow_pow_2 c (p - 1%Z)%Z x k n) x
     (dyadic (k * (power 2%Z (p - 1%Z)%Z))%Z n)))).

Axiom pow_pow_2_spec :
  forall (c:a_circuit) (p:Z) (x:matrix t) (k:Z) (n:Z), (0%Z <= n)%Z ->
  (0%Z <= p)%Z -> (eigen c x (dyadic k n)) ->
  ((a_depth (pow_pow_2 c p x k n)) = (a_depth c)) /\
  (eigen (pow_pow_2 c p x k n) x (dyadic (k * (power 2%Z p))%Z n)).

Parameter control_eigen:
  a_circuit -> (matrix t) -> (matrix t) -> d_frac -> Z -> Z -> Z ->
  a_circuit.

Axiom control_eigen_def :
  forall (circ:a_circuit) (x:matrix t) (y:matrix t) (o:d_frac) (c:Z)
    (ft:Z) (n:Z),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (a_depth circ))%Z) ->
  (eigen circ y o) -> (is_a_ket_l x ft) ->
  ((control_eigen circ x y o c ft n) = (id_cont circ c ft n)).

Axiom control_eigen_spec :
  forall (circ:a_circuit) (x:matrix t) (y:matrix t) (o:d_frac) (c:Z)
    (ft:Z) (n:Z),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (a_depth circ))%Z) ->
  (eigen circ y o) -> (is_a_ket_l x ft) ->
  ((a_depth (control_eigen circ x y o c ft n)) = (ft + (a_depth circ))%Z) /\
  (((is_a_ket_basis_elt x) -> (((value (ket_to_bv x)) c) = 0%Z) ->
    semantics (control_eigen circ x y o c ft n) (kronecker x y)
    (kronecker x y)) /\
   ((is_a_ket_basis_elt x) -> (((value (ket_to_bv x)) c) = 1%Z) ->
    semantics (control_eigen circ x y o c ft n) (kronecker x y)
    (kronecker x (infix_asdtdt (value1 o) y)))).

Parameter control_eigen_dyadic:
  a_circuit -> (matrix t) -> (matrix t) -> Z -> Z -> Z -> Z -> a_circuit.

Axiom control_eigen_dyadic_def :
  forall (circ:a_circuit) (x:matrix t) (y:matrix t) (k:Z) (n:Z) (c:Z) (ft:Z),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (0%Z <= n)%Z ->
  (eigen circ y (dyadic k n)) -> (is_a_ket_l x ft) ->
  ((control_eigen_dyadic circ x y k n c ft) =
   (control_eigen circ x y (dyadic k n) c ft (ft + (a_depth circ))%Z)).

Axiom control_eigen_dyadic_spec :
  forall (circ:a_circuit) (x:matrix t) (y:matrix t) (k:Z) (n:Z) (c:Z) (ft:Z),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (0%Z <= n)%Z ->
  (eigen circ y (dyadic k n)) -> (is_a_ket_l x ft) ->
  ((a_depth (control_eigen_dyadic circ x y k n c ft)) =
   (ft + (a_depth circ))%Z) /\
  ((is_a_ket_basis_elt x) ->
   semantics (control_eigen_dyadic circ x y k n c ft) (kronecker x y)
   (kronecker x
    (infix_asdtdt (value1 (dyadic (k * ((value (ket_to_bv x)) c))%Z n)) y))).

Axiom control_eigen_scal :
  forall (circ:a_circuit) (x:matrix t) (y:matrix t) (k:Z) (n:Z) (c:Z)
    (ft:Z) (t1:t),
  ((0%Z <= c)%Z /\ (c < ft)%Z) -> (0%Z <= n)%Z ->
  (eigen circ y (dyadic k n)) -> (is_a_ket_l x ft) ->
  (is_a_ket_basis_elt x) ->
  semantics (control_eigen_dyadic circ x y k n c ft)
  (kronecker x (infix_asdtdt t1 y))
  (kronecker x
   (infix_asdtdt
    (infix_asdt t1 (value1 (dyadic (k * ((value (ket_to_bv x)) c))%Z n))) y)).

Parameter fcirc: Z -> a_circuit.

Parameter x: matrix t.

Parameter y: matrix t.

Parameter fk: Z -> Z.

Parameter n: Z.

Parameter fc13: Z -> Z.

Parameter ft: Z.

Parameter bound: Z.

Parameter size: Z.

Axiom H :
  forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
  (0%Z <= (fc13 i))%Z /\ ((fc13 i) < ft)%Z.

Axiom H1 : (0%Z < bound)%Z.

Axiom H2 : (bound <= ft)%Z.

Axiom H3 : (0%Z <= n)%Z.

Axiom H4 :
  forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
  eigen (fcirc i) y (dyadic (fk i) n).

Axiom H5 : forall (i:Z), ((a_depth (fcirc i)) = size).

Axiom H6 : is_a_ket_l x ft.

Axiom H7 : is_a_ket_l y size.

Axiom H8 : ~ (bound = 1%Z).

Parameter res_pre: a_circuit.

Axiom H9 : ((a_depth res_pre) = (ft + size)%Z).

Axiom H10 :
  (is_a_ket_basis_elt x) ->
  semantics res_pre (kronecker x y)
  (infix_asdtdt
   (value1
    (d_sum
     (fun (i:Z) => (dyadic ((fk i) * ((value (ket_to_bv x)) (fc13 i)))%Z n))
     0%Z (bound - 1%Z)%Z))
   (kronecker x y)).

Axiom H11 : is_a_ket_basis_elt x.

(* Why3 goal *)
Theorem VC_control_eigen_cont_seq : is_a_ket_basis_elt x.
Proof.

Qed.