diff -r db158e995bfc -r 9df6144e281b Attic/Quot/Examples/SigmaEx.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Attic/Quot/Examples/SigmaEx.thy Thu Feb 25 07:57:17 2010 +0100 @@ -0,0 +1,253 @@ +theory SigmaEx +imports Nominal "../Quotient" "../Quotient_List" "../Quotient_Product" +begin + +atom_decl name + +datatype robj = + rVar "name" +| rObj "(string \ rmethod) list" +| rInv "robj" "string" +| rUpd "robj" "string" "rmethod" +and rmethod = + rSig "name" "robj" + +inductive + alpha_obj :: "robj \ robj \ bool" ("_ \o _" [100, 100] 100) +and alpha_method :: "rmethod \ rmethod \ bool" ("_ \m _" [100, 100] 100) +where + a1: "a = b \ (rVar a) \o (rVar b)" +| a2: "rObj [] \o rObj []" +| a3: "rObj t1 \o rObj t2 \ m1 \m r2 \ rObj ((l1, m1) # t1) \o rObj ((l2, m2) # t2)" +| a4: "x \o y \ rInv x l1 \o rInv y l2" +| a5: "\pi::name prm. (rfv t - {a} = rfv s - {b} \ (rfv t - {a})\* pi \ (pi \ t) \o s \ (pi \ a) = b) + \ rSig a t \m rSig b s" + +lemma alpha_equivps: + shows "equivp alpha_obj" + and "equivp alpha_method" +sorry + +quotient_type + obj = robj / alpha_obj +and method = rmethod / alpha_method + by (auto intro: alpha_equivps) + +quotient_definition + "Var :: name \ obj" +is + "rVar" + +quotient_definition + "Obj :: (string \ method) list \ obj" +is + "rObj" + +quotient_definition + "Inv :: obj \ string \ obj" +is + "rInv" + +quotient_definition + "Upd :: obj \ string \ method \ obj" +is + "rUpd" + +quotient_definition + "Sig :: name \ obj \ method" +is + "rSig" + +overloading + perm_obj \ "perm :: 'x prm \ obj \ obj" (unchecked) + perm_method \ "perm :: 'x prm \ method \ method" (unchecked) +begin + +quotient_definition + "perm_obj :: 'x prm \ obj \ obj" +is + "(perm::'x prm \ robj \ robj)" + +quotient_definition + "perm_method :: 'x prm \ method \ method" +is + "(perm::'x prm \ rmethod \ rmethod)" + +end + + + +lemma tolift: +"\ fvar. + \ fobj\Respects (op = ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnvk\Respects (op = ===> alpha_obj ===> op =). + \ fupd\Respects (op = ===> op = ===> alpha_obj ===> op = ===> alpha_method ===> op =). + \ fcns\Respects (op = ===> op = ===> prod_rel (op =) alpha_method ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnil. + \ fpar\Respects (op = ===> op = ===> alpha_method ===> op =). + \ fsgm\Respects (op = ===> (op = ===> alpha_obj) ===> op =). + + Ex1 (\x. +(x \ (Respects (prod_rel (alpha_obj ===> op =) + (prod_rel (list_rel (prod_rel (op =) alpha_method) ===> op =) + (prod_rel ((prod_rel (op =) alpha_method) ===> op =) + (alpha_method ===> op =) + ) + )))) \ +(\ (hom_o\robj \ 'a, hom_d\(char list \ rmethod) list \ 'b, hom_e\char list \ rmethod \ 'c, hom_m\rmethod \ 'd). + +((\x. hom_o (rVar x) = fvar x) \ + (\d. hom_o (rObj d) = fobj (hom_d d) d) \ + (\a l. hom_o (rInv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (rUpd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (rSig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +)) x) " +sorry + +lemma test_to: "Ex1 (\x. (x \ (Respects alpha_obj)) \ P x)" +ML_prf {* prop_of (#goal (Isar.goal ())) *} +sorry +lemma test_tod: "Ex1 (P :: obj \ bool)" +apply (lifting test_to) +done + + + + +(*syntax + "_expttrn" :: "pttrn => bool => bool" ("(3\\ _./ _)" [0, 10] 10) + +translations + "\\ x. P" == "Ex (%x. P)" +*) + +lemma rvar_rsp[quot_respect]: "(op = ===> alpha_obj) rVar rVar" + by (simp add: a1) + +lemma robj_rsp[quot_respect]: "(list_rel (prod_rel op = alpha_method) ===> alpha_obj) rObj rObj" +sorry +lemma rinv_rsp[quot_respect]: "(alpha_obj ===> op = ===> alpha_obj) rInv rInv" +sorry +lemma rupd_rsp[quot_respect]: "(alpha_obj ===> op = ===> alpha_method ===> alpha_obj) rUpd rUpd" +sorry +lemma rsig_rsp[quot_respect]: "(op = ===> alpha_obj ===> alpha_method) rSig rSig" +sorry +lemma operm_rsp[quot_respect]: "(op = ===> alpha_obj ===> alpha_obj) op \ op \" +sorry + + +lemma bex1_bex1reg: "(\!x\Respects R. P x) \ (Bex1_rel R (\x. P x))" +apply (simp add: Ex1_def Bex1_rel_def in_respects) +apply clarify +apply auto +apply (rule bexI) +apply assumption +apply (simp add: in_respects) +apply (simp add: in_respects) +apply auto +done + +lemma liftd: " +Ex1 (\(hom_o, hom_d, hom_e, hom_m). + + (\x. hom_o (Var x) = fvar x) \ + (\d. hom_o (Obj d) = fobj (hom_d d) d) \ + (\a l. hom_o (Inv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (Upd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (Sig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +)" +apply (lifting tolift) +done + +lemma tolift': +"\ fvar. + \ fobj\Respects (op = ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnvk\Respects (op = ===> alpha_obj ===> op =). + \ fupd\Respects (op = ===> op = ===> alpha_obj ===> op = ===> alpha_method ===> op =). + \ fcns\Respects (op = ===> op = ===> prod_rel (op =) alpha_method ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnil. + \ fpar\Respects (op = ===> op = ===> alpha_method ===> op =). + \ fsgm\Respects (op = ===> (op = ===> alpha_obj) ===> op =). + + \ hom_o\robj \ 'a \ Respects (alpha_obj ===> op =). + \ hom_d\(char list \ rmethod) list \ 'b \ Respects (list_rel (prod_rel (op =) alpha_method) ===> op =). + \ hom_e\char list \ rmethod \ 'c \ Respects ((prod_rel (op =) alpha_method) ===> op =). + \ hom_m\rmethod \ 'd \ Respects (alpha_method ===> op =). +( + (\x. hom_o (rVar x) = fvar x) \ + (\d. hom_o (rObj d) = fobj (hom_d d) d) \ + (\a l. hom_o (rInv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (rUpd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (rSig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +)" +sorry + +lemma liftd': " +\hom_o. \hom_d. \hom_e. \hom_m. +( + (\x. hom_o (Var x) = fvar x) \ + (\d. hom_o (Obj d) = fobj (hom_d d) d) \ + (\a l. hom_o (Inv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (Upd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (Sig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +)" +apply (lifting tolift') +done + +lemma tolift'': +"\ fvar. + \ fobj\Respects (op = ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnvk\Respects (op = ===> alpha_obj ===> op =). + \ fupd\Respects (op = ===> op = ===> alpha_obj ===> op = ===> alpha_method ===> op =). + \ fcns\Respects (op = ===> op = ===> prod_rel (op =) alpha_method ===> list_rel (prod_rel (op =) alpha_method) ===> op =). + \ fnil. + \ fpar\Respects (op = ===> op = ===> alpha_method ===> op =). + \ fsgm\Respects (op = ===> (op = ===> alpha_obj) ===> op =). + + Bex1_rel (alpha_obj ===> op =) (\hom_o\robj \ 'a . + Bex1_rel (list_rel (prod_rel (op =) alpha_method) ===> op =) (\hom_d\(char list \ rmethod) list \ 'b. + Bex1_rel ((prod_rel (op =) alpha_method) ===> op =) (\hom_e\char list \ rmethod \ 'c. + Bex1_rel (alpha_method ===> op =) (\hom_m\rmethod \ 'd. +( + (\x. hom_o (rVar x) = fvar x) \ + (\d. hom_o (rObj d) = fobj (hom_d d) d) \ + (\a l. hom_o (rInv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (rUpd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (rSig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +) +))))" +sorry + +lemma liftd'': " +\!hom_o. \!hom_d. \!hom_e. \!hom_m. +( + (\x. hom_o (Var x) = fvar x) \ + (\d. hom_o (Obj d) = fobj (hom_d d) d) \ + (\a l. hom_o (Inv a l) = fnvk (hom_o a) a l) \ + (\a l m. hom_o (Upd a l m) = fupd (hom_o a) (hom_m m) a l m) \ + (\e d. hom_d (e # d) = fcns (hom_e e) (hom_d d) e d) \ + (hom_d [] = fnil) \ + (\l m. hom_e (l, m) = fpar (hom_m m) l m) \ + (\x a. hom_m (Sig x a) = fsgm (\y. hom_o ([(x, y)] \ a)) (\y. [(x, y)] \ a)) +)" +apply (lifting tolift'') +done + + +end +