src/HOL/SPARK/Examples/RIPEMD-160/RMD_Lemmas.thy
author haftmann
Fri, 02 Mar 2012 21:45:45 +0100
changeset 46767 807a5d219c23
parent 41561 d1318f3c86ba
permissions -rw-r--r--
more fundamental pred-to-set conversions for range and domain by means of inductive_set
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41561
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/SPARK/Examples/RIPEMD-160/RMD_Lemmas.thy
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     2
    Author:     Fabian Immler, TU Muenchen
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     3
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     4
Verification of the RIPEMD-160 hash function
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     5
*)
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     6
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     7
theory RMD_Lemmas
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     8
imports Main
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
     9
begin
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    10
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    11
definition "fun_of_list i xs g j =
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    12
  (if j < i \<or> i + int (length xs) \<le> j then g j else xs ! nat (j - i))"
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    13
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    14
lemma fun_of_list_Nil [simp]: "fun_of_list i [] g = g"
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    15
  by (auto simp add: fun_eq_iff fun_of_list_def)
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    16
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    17
lemma fun_of_list_Cons [simp]:
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    18
  "fun_of_list i (x # xs) g = fun_of_list (i + 1) xs (g(i:=x))"
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    19
  by (auto simp add: fun_eq_iff fun_of_list_def nth_Cons'
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    20
    nat_diff_distrib [of "int (Suc 0)", simplified, symmetric]
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    21
    diff_diff_eq)
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    22
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    23
lemma nth_fun_of_list_eq:
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    24
  "0 \<le> i \<Longrightarrow> i < int (length xs) \<Longrightarrow> xs ! nat i = fun_of_list 0 xs g i"
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    25
  by (simp add: fun_of_list_def)
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    26
d1318f3c86ba Added new SPARK verification environment.
berghofe
parents:
diff changeset
    27
end