src/HOL/Library/Conditional_Parametricity.thy
 author wenzelm Tue May 15 13:57:39 2018 +0200 (16 months ago) changeset 68189 6163c90694ef parent 67399 eab6ce8368fa child 69605 a96320074298 permissions -rw-r--r--
1 (*  Title:    HOL/Library/Conditional_Parametricity.thy
2     Author:   Jan Gilcher, Andreas Lochbihler, Dmitriy Traytel, ETH Zürich
4 A conditional parametricity prover
5 *)
7 theory Conditional_Parametricity
8 imports Main
9 keywords "parametric_constant" :: thy_decl
10 begin
12 context includes lifting_syntax begin
14 qualified definition Rel_match :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" where
15   "Rel_match R x y = R x y"
17 named_theorems parametricity_preprocess
19 lemma bi_unique_Rel_match [parametricity_preprocess]:
20   "bi_unique A = Rel_match (A ===> A ===> (=)) (=) (=)"
21   unfolding bi_unique_alt_def2 Rel_match_def ..
23 lemma bi_total_Rel_match [parametricity_preprocess]:
24   "bi_total A = Rel_match ((A ===> (=)) ===> (=)) All All"
25   unfolding bi_total_alt_def2 Rel_match_def ..
27 lemma is_equality_Rel: "is_equality A \<Longrightarrow> Transfer.Rel A t t"
28   by (fact transfer_raw)
30 lemma Rel_Rel_match: "Transfer.Rel R x y \<Longrightarrow> Rel_match R x y"
31   unfolding Rel_match_def Rel_def .
33 lemma Rel_match_Rel: "Rel_match R x y \<Longrightarrow> Transfer.Rel R x y"
34   unfolding Rel_match_def Rel_def .
36 lemma Rel_Rel_match_eq: "Transfer.Rel R x y = Rel_match R x y"
37   using Rel_Rel_match Rel_match_Rel by fast
39 lemma Rel_match_app:
40   assumes "Rel_match (A ===> B) f g" and "Transfer.Rel A x y"
41   shows "Rel_match B (f x) (g y)"
42   using assms Rel_match_Rel Rel_app Rel_Rel_match by fast
44 end
46 ML_file "conditional_parametricity.ML"
48 end