1 (* Title: HOL/SPARK/Examples/Gcd/Greatest_Common_Divisor.thy
2 Author: Stefan Berghofer
3 Copyright: secunet Security Networks AG
6 theory Greatest_Common_Divisor
7 imports "HOL-SPARK.SPARK"
11 gcd = "gcd :: int \<Rightarrow> int \<Rightarrow> int"
13 spark_open \<open>greatest_common_divisor/g_c_d\<close> (*..from 3 files
14 ./greatest_common_divisor/g_c_d.siv, *.fdl, *.rls open *.siv and
15 find the following 2 open verification conditions (VC): *)
17 spark_vc procedure_g_c_d_4 (*..select 1st VC for proof: *)
19 from \<open>0 < d\<close> have "0 \<le> c mod d" by (rule pos_mod_sign)
20 with \<open>0 \<le> c\<close> \<open>0 < d\<close> \<open>c - c sdiv d * d \<noteq> 0\<close> show ?C1
21 by (simp add: sdiv_pos_pos minus_div_mult_eq_mod [symmetric])
23 from \<open>0 \<le> c\<close> \<open>0 < d\<close> \<open>gcd c d = gcd m n\<close> show ?C2
24 by (simp add: sdiv_pos_pos minus_div_mult_eq_mod [symmetric] gcd_non_0_int)
27 spark_vc procedure_g_c_d_11 (*..select 2nd VC for proof: *)
29 from \<open>0 \<le> c\<close> \<open>0 < d\<close> \<open>c - c sdiv d * d = 0\<close>
31 by (auto simp add: sdiv_pos_pos dvd_def ac_simps)
32 with \<open>0 < d\<close> \<open>gcd c d = gcd m n\<close> show ?C1