author | haftmann |
Sat, 05 Jul 2014 11:01:53 +0200 | |
changeset 57514 | bdc2c6b40bf2 |
parent 56798 | 939e88e79724 |
child 58130 | 5e9170812356 |
permissions | -rw-r--r-- |
41561 | 1 |
(* Title: HOL/SPARK/Examples/Gcd/Greatest_Common_Divisor.thy |
2 |
Author: Stefan Berghofer |
|
3 |
Copyright: secunet Security Networks AG |
|
4 |
*) |
|
5 |
||
6 |
theory Greatest_Common_Divisor |
|
7 |
imports SPARK GCD |
|
8 |
begin |
|
9 |
||
10 |
spark_proof_functions |
|
11 |
gcd = "gcd :: int \<Rightarrow> int \<Rightarrow> int" |
|
12 |
||
56798
939e88e79724
Discontinued old spark_open; spark_open_siv is now spark_open
berghofe
parents:
41561
diff
changeset
|
13 |
spark_open "greatest_common_divisor/g_c_d" |
41561 | 14 |
|
15 |
spark_vc procedure_g_c_d_4 |
|
16 |
proof - |
|
17 |
from `0 < d` have "0 \<le> c mod d" by (rule pos_mod_sign) |
|
18 |
with `0 \<le> c` `0 < d` `c - c sdiv d * d \<noteq> 0` show ?C1 |
|
19 |
by (simp add: sdiv_pos_pos zmod_zdiv_equality') |
|
20 |
next |
|
21 |
from `0 \<le> c` `0 < d` `gcd c d = gcd m n` show ?C2 |
|
22 |
by (simp add: sdiv_pos_pos zmod_zdiv_equality' gcd_non_0_int) |
|
23 |
qed |
|
24 |
||
25 |
spark_vc procedure_g_c_d_11 |
|
26 |
proof - |
|
27 |
from `0 \<le> c` `0 < d` `c - c sdiv d * d = 0` |
|
28 |
have "d dvd c" |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
56798
diff
changeset
|
29 |
by (auto simp add: sdiv_pos_pos dvd_def ac_simps) |
41561 | 30 |
with `0 < d` `gcd c d = gcd m n` show ?C1 |
31 |
by simp |
|
32 |
qed |
|
33 |
||
34 |
spark_end |
|
35 |
||
36 |
end |