# HG changeset patch # User Cezary Kaliszyk # Date 1265622439 -3600 # Node ID f8029d8c88a970b16bece2962cccd0af923c60eb # Parent 11895d5e3d494e129150dc0b68e9928115b64012 Fixed the context import/export and simplified LFex. diff -r 11895d5e3d49 -r f8029d8c88a9 Quot/Nominal/LFex.thy --- a/Quot/Nominal/LFex.thy Mon Feb 08 06:27:20 2010 +0100 +++ b/Quot/Nominal/LFex.thy Mon Feb 08 10:47:19 2010 +0100 @@ -380,40 +380,10 @@ by (simp add: alpha_rfv) thm kind_ty_trm.induct - -lemma KIND_TY_TRM_induct: - fixes P10 :: "KIND \ bool" and P20 :: "TY \ bool" and P30 :: "TRM \ bool" - shows -"\P10 TYP; \ty name kind. \P20 ty; P10 kind\ \ P10 (KPI ty name kind); \ident. P20 (TCONST ident); - \ty trm. \P20 ty; P30 trm\ \ P20 (TAPP ty trm); - \ty1 name ty2. \P20 ty1; P20 ty2\ \ P20 (TPI ty1 name ty2); \ident. P30 (CONS ident); - \name. P30 (VAR name); \trm1 trm2. \P30 trm1; P30 trm2\ \ P30 (APP trm1 trm2); - \ty name trm. \P20 ty; P30 trm\ \ P30 (LAM ty name trm)\ -\ P10 kind \ P20 ty \ P30 trm" -by (lifting kind_ty_trm.induct) +lemmas KIND_TY_TRM_induct = kind_ty_trm.induct[quot_lifted] thm kind_ty_trm.inducts - -lemma KIND_TY_TRM_inducts: -"\P10 TYP; \ty name kind. \P20 ty; P10 kind\ \ P10 (KPI ty name kind); \ident. P20 (TCONST ident); - \ty trm. \P20 ty; P30 trm\ \ P20 (TAPP ty trm); - \ty1 name ty2. \P20 ty1; P20 ty2\ \ P20 (TPI ty1 name ty2); \ident. P30 (CONS ident); - \name. P30 (VAR name); \trm1 trm2. \P30 trm1; P30 trm2\ \ P30 (APP trm1 trm2); - \ty name trm. \P20 ty; P30 trm\ \ P30 (LAM ty name trm)\ -\ P10 kind" -"\P10 TYP; \ty name kind. \P20 ty; P10 kind\ \ P10 (KPI ty name kind); \ident. P20 (TCONST ident); - \ty trm. \P20 ty; P30 trm\ \ P20 (TAPP ty trm); - \ty1 name ty2. \P20 ty1; P20 ty2\ \ P20 (TPI ty1 name ty2); \ident. P30 (CONS ident); - \name. P30 (VAR name); \trm1 trm2. \P30 trm1; P30 trm2\ \ P30 (APP trm1 trm2); - \ty name trm. \P20 ty; P30 trm\ \ P30 (LAM ty name trm)\ -\ P20 ty" -"\P10 TYP; \ty name kind. \P20 ty; P10 kind\ \ P10 (KPI ty name kind); \ident. P20 (TCONST ident); - \ty trm. \P20 ty; P30 trm\ \ P20 (TAPP ty trm); - \ty1 name ty2. \P20 ty1; P20 ty2\ \ P20 (TPI ty1 name ty2); \ident. P30 (CONS ident); - \name. P30 (VAR name); \trm1 trm2. \P30 trm1; P30 trm2\ \ P30 (APP trm1 trm2); - \ty name trm. \P20 ty; P30 trm\ \ P30 (LAM ty name trm)\ -\ P30 trm" -by (lifting kind_ty_trm.inducts) +lemmas KIND_TY_TRM_inducts = kind_ty_trm.inducts[quot_lifted] instantiation KIND and TY and TRM :: pt begin @@ -433,30 +403,17 @@ as "permute :: perm \ trm \ trm" -lemma permute_ktt[simp]: -shows "pi \ TYP = TYP" -and "pi \ (KPI t n k) = KPI (pi \ t) (pi \ n) (pi \ k)" -and "pi \ (TCONST i) = TCONST (pi \ i)" -and "pi \ (TAPP A M) = TAPP (pi \ A) (pi \ M)" -and "pi \ (TPI A x B) = TPI (pi \ A) (pi \ x) (pi \ B)" -and "pi \ (CONS i) = CONS (pi \ i)" -and "pi \ (VAR x) = VAR (pi \ x)" -and "pi \ (APP M N) = APP (pi \ M) (pi \ N)" -and "pi \ (LAM A x M) = LAM (pi \ A) (pi \ x) (pi \ M)" -apply (lifting permute_kind_permute_ty_permute_trm.simps) +lemma perm_zero_ok: "0 \ (x :: KIND) = x \ 0 \ (y :: TY) = y \ 0 \ (z :: TRM) = z" +apply (induct rule: KIND_TY_TRM_induct) +apply (simp_all add: permute_kind_permute_ty_permute_trm.simps[quot_lifted]) done -lemma perm_zero_ok: "0 \ (x :: KIND) = x \ 0 \ (y :: TY) = y \ 0 \ (z :: TRM) = z" -apply (induct rule: KIND_TY_TRM_induct) -apply simp_all -done - -lemma perm_add_ok: +lemma perm_add_ok: "((p + q) \ (x1 :: KIND) = (p \ q \ x1))" "((p + q) \ (x2 :: TY) = p \ q \ x2)" "((p + q) \ (x3 :: TRM) = p \ q \ x3)" -apply(induct x1 and x2 and x3 rule: KIND_TY_TRM_inducts) -apply (simp_all) +apply (induct x1 and x2 and x3 rule: KIND_TY_TRM_inducts) +apply (simp_all add: permute_kind_permute_ty_permute_trm.simps[quot_lifted]) done instance @@ -466,126 +423,15 @@ end -lemma AKIND_ATY_ATRM_inducts: -"\z1 = z2; P1 TYP TYP; - \A A' a K b K'. - \A = A'; P2 A A'; - \pi. ({atom a}, - K) \gen (\x1 x2. - x1 = x2 \ P1 x1 x2) fv_kind pi ({atom b}, K')\ - \ P1 (KPI A a K) (KPI A' b K'); - \i j. i = j \ P2 (TCONST i) (TCONST j); - \A A' M M'. - \A = A'; P2 A A'; M = M'; P3 M M'\ - \ P2 (TAPP A M) (TAPP A' M'); - \A A' a B b B'. - \A = A'; P2 A A'; - \pi. ({atom a}, - B) \gen (\x1 x2. x1 = x2 \ P2 x1 x2) fv_ty pi ({atom b}, B')\ - \ P2 (TPI A a B) (TPI A' b B'); - \i j. i = j \ P3 (CONS i) (CONS j); - \x y. x = y \ P3 (VAR x) (VAR y); - \M M' N N'. - \M = M'; P3 M M'; N = N'; P3 N N'\ - \ P3 (APP M N) (APP M' N'); - \A A' a M b M'. - \A = A'; P2 A A'; - \pi. ({atom a}, - M) \gen (\x1 x2. - x1 = x2 \ P3 x1 x2) fv_trm pi ({atom b}, M')\ - \ P3 (LAM A a M) (LAM A' b M')\ -\ P1 z1 z2" -"\z3 = z4; P1 TYP TYP; - \A A' a K b K'. - \A = A'; P2 A A'; - \pi. ({atom a}, - K) \gen (\x1 x2. - x1 = x2 \ P1 x1 x2) fv_kind pi ({atom b}, K')\ - \ P1 (KPI A a K) (KPI A' b K'); - \i j. i = j \ P2 (TCONST i) (TCONST j); - \A A' M M'. - \A = A'; P2 A A'; M = M'; P3 M M'\ - \ P2 (TAPP A M) (TAPP A' M'); - \A A' a B b B'. - \A = A'; P2 A A'; - \pi. ({atom a}, - B) \gen (\x1 x2. x1 = x2 \ P2 x1 x2) fv_ty pi ({atom b}, B')\ - \ P2 (TPI A a B) (TPI A' b B'); - \i j. i = j \ P3 (CONS i) (CONS j); - \x y. x = y \ P3 (VAR x) (VAR y); - \M M' N N'. - \M = M'; P3 M M'; N = N'; P3 N N'\ - \ P3 (APP M N) (APP M' N'); - \A A' a M b M'. - \A = A'; P2 A A'; - \pi. ({atom a}, - M) \gen (\x1 x2. - x1 = x2 \ P3 x1 x2) fv_trm pi ({atom b}, M')\ - \ P3 (LAM A a M) (LAM A' b M')\ -\ P2 z3 z4" -"\z5 = z6; P1 TYP TYP; - \A A' a K b K'. - \A = A'; P2 A A'; - \pi. ({atom a}, - K) \gen (\x1 x2. - x1 = x2 \ P1 x1 x2) fv_kind pi ({atom b}, K')\ - \ P1 (KPI A a K) (KPI A' b K'); - \i j. i = j \ P2 (TCONST i) (TCONST j); - \A A' M M'. - \A = A'; P2 A A'; M = M'; P3 M M'\ - \ P2 (TAPP A M) (TAPP A' M'); - \A A' a B b B'. - \A = A'; P2 A A'; - \pi. ({atom a}, - B) \gen (\x1 x2. x1 = x2 \ P2 x1 x2) fv_ty pi ({atom b}, B')\ - \ P2 (TPI A a B) (TPI A' b B'); - \i j. i = j \ P3 (CONS i) (CONS j); - \x y. x = y \ P3 (VAR x) (VAR y); - \M M' N N'. - \M = M'; P3 M M'; N = N'; P3 N N'\ - \ P3 (APP M N) (APP M' N'); - \A A' a M b M'. - \A = A'; P2 A A'; - \pi. ({atom a}, - M) \gen (\x1 x2. - x1 = x2 \ P3 x1 x2) fv_trm pi ({atom b}, M')\ - \ P3 (LAM A a M) (LAM A' b M')\ -\ P3 z5 z6" -unfolding alpha_gen -apply (lifting akind_aty_atrm.inducts[unfolded alpha_gen]) -done +lemmas permute_ktt[simp] = permute_kind_permute_ty_permute_trm.simps[quot_lifted] + +lemmas AKIND_ATY_ATRM_inducts = akind_aty_atrm.inducts[unfolded alpha_gen, quot_lifted, folded alpha_gen] -thm akind_aty_atrm_inj -lemma KIND_TY_TRM_INJECT: - "(TYP) = (TYP) = True" - "(KPI A x K) = (KPI A' x' K') = (A = A' \ (\pi. ({atom x}, K) \gen (op =) fv_kind pi ({atom x'}, K')))" - "(TCONST i) = (TCONST j) = (i = j)" - "(TAPP A M) = (TAPP A' M') = (A = A' \ M = M')" - "(TPI A x B) = (TPI A' x' B') = (A = A' \ (\pi. ({atom x}, B) \gen (op =) fv_ty pi ({atom x'}, B')))" - "(CONS i) = (CONS j) = (i = j)" - "(VAR x) = (VAR y) = (x = y)" - "(APP M N) = (APP M' N') = (M = M' \ N = N')" - "(LAM A x M) = (LAM A' x' M') = (A = A' \ (\pi. ({atom x}, M) \gen (op =) fv_trm pi ({atom x'}, M')))" -unfolding alpha_gen -by (lifting akind_aty_atrm_inj[unfolded alpha_gen]) +lemmas KIND_TY_TRM_INJECT = akind_aty_atrm_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen] -lemma fv_kind_ty_trm: - "fv_kind TYP = {}" - "fv_kind (KPI A x K) = fv_ty A \ (fv_kind K - {atom x})" - "fv_ty (TCONST i) = {atom i}" - "fv_ty (TAPP A M) = fv_ty A \ fv_trm M" - "fv_ty (TPI A x B) = fv_ty A \ (fv_ty B - {atom x})" - "fv_trm (CONS i) = {atom i}" - "fv_trm (VAR x) = {atom x}" - "fv_trm (APP M N) = fv_trm M \ fv_trm N" - "fv_trm (LAM A x M) = fv_ty A \ (fv_trm M - {atom x})" -by(lifting rfv_kind_rfv_ty_rfv_trm.simps) +lemmas fv_kind_ty_trm = rfv_kind_rfv_ty_rfv_trm.simps[quot_lifted] -lemma fv_eqvt: - "(p \ fv_kind t1) = fv_kind (p \ t1)" - "(p \ fv_ty t2) = fv_ty (p \ t2)" - "(p \ fv_trm t3) = fv_trm (p \ t3)" -by(lifting rfv_eqvt) +lemmas fv_eqvt = rfv_eqvt[quot_lifted] lemma supp_kind_ty_trm_easy: "supp TYP = {}" diff -r 11895d5e3d49 -r f8029d8c88a9 Quot/quotient_tacs.ML --- a/Quot/quotient_tacs.ML Mon Feb 08 06:27:20 2010 +0100 +++ b/Quot/quotient_tacs.ML Mon Feb 08 10:47:19 2010 +0100 @@ -649,16 +649,15 @@ end (* An Attribute which automatically constructs the qthm *) -(* FIXME: Logic.unvarify needs to be replaced by propper Isar constructions *) fun lifted_attrib_aux context thm = let val ctxt = Context.proof_of context - val goal = (quotient_lift_all ctxt o Logic.unvarify o prop_of) thm - val goal_chk = Syntax.check_term ctxt goal - val frees = Term.add_free_names goal_chk [] + val ((_, [thm']), ctxt') = Variable.import false [thm] ctxt + val goal = (quotient_lift_all ctxt o prop_of) thm' + val nthm = Goal.prove ctxt [] [] goal (fn x => lift_tac ctxt [thm] 1) + val [nthm1] = ProofContext.export ctxt' ctxt [nthm] in - Goal.prove ctxt frees [] goal_chk - (fn x => lift_tac (#context x) [thm] 1) + nthm1 end; val lifted_attrib = Thm.rule_attribute lifted_attrib_aux