1 (* This file is generated by Why3
's Coq driver *)
2 (* Beware! Only edit allowed sections below *)
8 Require int.ComputerDivision.
10 Parameter sum_multiple_3_5_lt: Z -> Z.
12 Axiom SumEmpty : ((sum_multiple_3_5_lt 0%Z) = 0%Z).
14 Axiom SumNo : forall (n:Z), (0%Z <= n)%Z -> (((~ ((ZOmod n 3%Z) = 0%Z)) /\
15 ~ ((ZOmod n 5%Z) = 0%Z)) ->
16 ((sum_multiple_3_5_lt (n + 1%Z)%Z) = (sum_multiple_3_5_lt n))).
18 Axiom SumYes : forall (n:Z), (0%Z <= n)%Z -> ((((ZOmod n 3%Z) = 0%Z) \/
19 ((ZOmod n 5%Z) = 0%Z)) ->
20 ((sum_multiple_3_5_lt (n + 1%Z)%Z) = ((sum_multiple_3_5_lt n) + n)%Z)).
22 Axiom div2 : forall (x:Z), exists y:Z, (x = (2%Z * y)%Z) \/
23 (x = ((2%Z * y)%Z + 1%Z)%Z).
25 Axiom mod_div_unique : forall (x:Z) (y:Z) (q:Z) (r:Z), ((0%Z <= x)%Z /\
26 ((0%Z < y)%Z /\ ((x = ((q * y)%Z + r)%Z) /\ ((0%Z <= r)%Z /\
27 (r < y)%Z)))) -> ((q = (ZOdiv x y)) /\ (r = (ZOmod x y))).
29 Axiom mod_succ_1 : forall (x:Z) (y:Z), ((0%Z <= x)%Z /\ (0%Z < y)%Z) ->
30 ((~ ((ZOmod (x + 1%Z)%Z y) = 0%Z)) ->
31 ((ZOmod (x + 1%Z)%Z y) = ((ZOmod x y) + 1%Z)%Z)).
33 Axiom mod_succ_2 : forall (x:Z) (y:Z), ((0%Z <= x)%Z /\ (0%Z < y)%Z) ->
34 (((ZOmod (x + 1%Z)%Z y) = 0%Z) -> ((ZOmod x y) = (y - 1%Z)%Z)).
36 Axiom div_succ_1 : forall (x:Z) (y:Z), ((0%Z <= x)%Z /\ (0%Z < y)%Z) ->
37 (((ZOmod (x + 1%Z)%Z y) = 0%Z) ->
38 ((ZOdiv (x + 1%Z)%Z y) = ((ZOdiv x y) + 1%Z)%Z)).
40 Axiom div_succ_2 : forall (x:Z) (y:Z), ((0%Z <= x)%Z /\ (0%Z < y)%Z) ->
41 ((~ ((ZOmod (x + 1%Z)%Z y) = 0%Z)) ->
42 ((ZOdiv (x + 1%Z)%Z y) = (ZOdiv x y))).
44 Axiom mod2_mul2 : forall (x:Z), ((ZOmod (2%Z * x)%Z 2%Z) = 0%Z).
46 Axiom mod2_mul2_aux : forall (x:Z) (y:Z),
47 ((ZOmod (y * (2%Z * x)%Z)%Z 2%Z) = 0%Z).
49 Axiom mod2_mul2_aux2 : forall (x:Z) (y:Z) (z:Z) (t:Z),
50 ((ZOmod ((y * (2%Z * x)%Z)%Z + (z * (2%Z * t)%Z)%Z)%Z 2%Z) = 0%Z).
52 Axiom div2_mul2 : forall (x:Z), ((ZOdiv (2%Z * x)%Z 2%Z) = x).
54 Axiom div2_mul2_aux : forall (x:Z) (y:Z),
55 ((ZOdiv (y * (2%Z * x)%Z)%Z 2%Z) = (y * x)%Z).
57 Axiom div2_add : forall (x:Z) (y:Z), (((ZOmod x 2%Z) = 0%Z) /\
58 ((ZOmod y 2%Z) = 0%Z)) ->
59 ((ZOdiv (x + y)%Z 2%Z) = ((ZOdiv x 2%Z) + (ZOdiv y 2%Z))%Z).
61 Axiom div2_sub : forall (x:Z) (y:Z), (((ZOmod x 2%Z) = 0%Z) /\
62 ((ZOmod y 2%Z) = 0%Z)) ->
63 ((ZOdiv (x - y)%Z 2%Z) = ((ZOdiv x 2%Z) - (ZOdiv y 2%Z))%Z).
65 Axiom tr_mod_2 : forall (n:Z), (0%Z <= n)%Z ->
66 ((ZOmod (n * (n + 1%Z)%Z)%Z 2%Z) = 0%Z).
69 Definition tr(n:Z): Z := (ZOdiv (n * (n + 1%Z)%Z)%Z 2%Z).
71 Axiom tr_repr : forall (n:Z), (0%Z <= n)%Z ->
72 ((n * (n + 1%Z)%Z)%Z = (2%Z * (tr n))%Z).
74 Axiom tr_succ : forall (n:Z), (0%Z <= n)%Z ->
75 ((tr (n + 1%Z)%Z) = (((tr n) + n)%Z + 1%Z)%Z).
78 Definition closed_formula_aux(n:Z): Z := let n3 := (ZOdiv n 3%Z) in let n5 :=
79 (ZOdiv n 5%Z) in let n15 := (ZOdiv n 15%Z) in
80 (((3%Z * (tr n3))%Z + (5%Z * (tr n5))%Z)%Z - (15%Z * (tr n15))%Z)%Z.
83 Definition p(n:Z): Prop :=
84 ((sum_multiple_3_5_lt (n + 1%Z)%Z) = (closed_formula_aux n)).
86 Axiom mod_15 : forall (n:Z), ((ZOmod n 15%Z) = 0%Z) <->
87 (((ZOmod n 3%Z) = 0%Z) /\ ((ZOmod n 5%Z) = 0%Z)).
89 Axiom Closed_formula_0 : (p 0%Z).
91 Axiom Closed_formula_n : forall (n:Z), (0%Z < n)%Z -> ((p (n - 1%Z)%Z) ->
92 (((~ ((ZOmod n 3%Z) = 0%Z)) /\ ~ ((ZOmod n 5%Z) = 0%Z)) -> (p n))).
94 Axiom Closed_formula_n_3 : forall (n:Z), (0%Z < n)%Z -> ((p (n - 1%Z)%Z) ->
95 ((((ZOmod n 3%Z) = 0%Z) /\ ~ ((ZOmod n 5%Z) = 0%Z)) -> (p n))).
97 Axiom Closed_formula_n_5 : forall (n:Z), (0%Z < n)%Z -> ((p (n - 1%Z)%Z) ->
98 (((~ ((ZOmod n 3%Z) = 0%Z)) /\ ((ZOmod n 5%Z) = 0%Z)) -> (p n))).
100 Axiom Closed_formula_n_15 : forall (n:Z), (0%Z < n)%Z -> ((p (n - 1%Z)%Z) ->
101 ((((ZOmod n 3%Z) = 0%Z) /\ ((ZOmod n 5%Z) = 0%Z)) -> (p n))).
103 Axiom Induction : (forall (n:Z), (0%Z <= n)%Z -> ((forall (k:Z),
104 ((0%Z <= k)%Z /\ (k < n)%Z) -> (p k)) -> (p n))) -> forall (n:Z),
105 (0%Z <= n)%Z -> (p n).
107 Axiom Induction_bound : (forall (n:Z), (0%Z <= n)%Z -> ((forall (k:Z),
108 ((0%Z <= k)%Z /\ (k < n)%Z) -> (p k)) -> (p n))) -> forall (n:Z),
109 (0%Z <= n)%Z -> (p n).
111 Axiom Closed_formula_ind : forall (n:Z), (0%Z <= n)%Z -> (p n).
113 (* Why3 assumption *)
114 Definition closed_formula(n:Z): Z := let n3 := (ZOdiv n 3%Z) in let n5 :=
115 (ZOdiv n 5%Z) in let n15 := (ZOdiv n 15%Z) in
116 (ZOdiv (((3%Z * (n3 * (n3 + 1%Z)%Z)%Z)%Z + (5%Z * (n5 * (n5 + 1%Z)%Z)%Z)%Z)%Z - (15%Z * (n15 * (n15 + 1%Z)%Z)%Z)%Z)%Z 2%Z).
118 Axiom div_15 : forall (n:Z), (0%Z <= n)%Z -> (0%Z <= (ZOdiv n 15%Z))%Z.
120 Axiom div_5 : forall (n:Z), (0%Z <= n)%Z -> (0%Z <= (ZOdiv n 5%Z))%Z.
122 Axiom div_3 : forall (n:Z), (0%Z <= n)%Z -> (0%Z <= (ZOdiv n 3%Z))%Z.
125 Theorem Closed_Formula : forall (n:Z), (0%Z <= n)%Z ->
126 ((sum_multiple_3_5_lt (n + 1%Z)%Z) = (closed_formula n)).
128 rewrite Closed_formula_ind; auto.
129 unfold closed_formula_aux, closed_formula.
130 repeat rewrite tr_repr.
132 rewrite div2_mul2_aux.
134 do 2 rewrite div2_mul2_aux.
136 repeat rewrite mod2_mul2_aux; auto.
137 rewrite mod2_mul2_aux; auto.
138 rewrite mod2_mul2_aux2; auto.