src/HOL/ex/Conditional_Parametricity_Examples.thy
changeset 67224 341fbce5b26d
child 67399 eab6ce8368fa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/ex/Conditional_Parametricity_Examples.thy	Mon Dec 18 16:58:13 2017 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +(*  Title:    HOL/ex/Conditional_Parametricity_Examples.thy
     1.5 +    Author:   Jan Gilcher, Andreas Lochbihler, Dmitriy Traytel, ETH Z├╝rich
     1.6 +
     1.7 +Examples for the parametric_constant command
     1.8 +*)
     1.9 +
    1.10 +theory Conditional_Parametricity_Examples
    1.11 +  imports "HOL-Library.Conditional_Parametricity"
    1.12 +begin
    1.13 +
    1.14 +definition "bar x xs = rev (x # xs)"
    1.15 +parametric_constant bar_def
    1.16 +
    1.17 +definition bar2 where "bar2 = bar"
    1.18 +parametric_constant bar2_def
    1.19 +
    1.20 +parametric_constant bar_thm[transfer_rule]: bar_def
    1.21 +parametric_constant bar2_thm1: bar2_def
    1.22 +
    1.23 +definition "t1 y x = zip x y"
    1.24 +parametric_constant t1_thm: t1_def
    1.25 +
    1.26 +definition "t2 f x = f (rev x)"
    1.27 +parametric_constant t2_thm: t2_def
    1.28 +
    1.29 +definition "t3 xs = rev (rev (xs :: 'b list))"
    1.30 +parametric_constant t3_thm: t3_def
    1.31 +
    1.32 +definition "t4 f x = rev (f x (f x (rev x)))"
    1.33 +parametric_constant t4_thm: t4_def
    1.34 +
    1.35 +definition "t5 x y = zip x (rev y)"
    1.36 +parametric_constant t5_thm: t5_def
    1.37 +
    1.38 +(* Conditional Parametricity*)
    1.39 +
    1.40 +definition "t6_1 x y = inf y x"
    1.41 +parametric_constant t6_1_thm: t6_1_def
    1.42 +
    1.43 +definition "t6_2 x y = sup y x"
    1.44 +parametric_constant t6_2_thm: t6_2_def
    1.45 +
    1.46 +definition "t6_3 x z y = sup (inf x y) z"
    1.47 +parametric_constant t6_3_thm: t6_3_def
    1.48 +
    1.49 +definition "t6_4 x xs y = map (sup (inf y x)) xs"
    1.50 +parametric_constant t6_4_thm: t6_4_def
    1.51 +
    1.52 +definition "t7 x y = (y = x)"
    1.53 +parametric_constant t7_thm: t7_def
    1.54 +
    1.55 +definition "t8 x y = ((x=y) \<and> (y=x))"
    1.56 +parametric_constant t8_thm: t8_def
    1.57 +
    1.58 +(* Definition via primrec*)
    1.59 +primrec delete where
    1.60 +  "delete _ [] = []"
    1.61 +| "delete x (y # ys) = (if x = y then ys else y # (delete x ys))"
    1.62 +parametric_constant delete_thm: delete_def
    1.63 +
    1.64 +definition "foo f x y = (if f x = f y then x else sup y x)"
    1.65 +parametric_constant foo_parametricity: foo_def
    1.66 +
    1.67 +end
    1.68 \ No newline at end of file