locale logic_def = fixes land (infixl‹&&› 55) and lor (infixl‹||› 50) and lnot (‹-- _› [60] 60) assumes assoc: ‹(x && y) && z = x && (y && z)› and notnot: ‹-- (-- x) = x› defines‹x || y == --(-- x && -- y)› begin
thm lor_def
lemma‹x || y = --(-- x && --y)› by (unfold lor_def) (rule refl)
end
(* Inheritance of defines *)
locale logic_def2 = logic_def begin
lemma‹x || y = --(-- x && --y)› by (unfold lor_def) (rule refl)
end
section‹Notes›
(* A somewhat arcane homomorphism example *)
definition semi_hom where ‹semi_hom(prod, sum, h) ⟷ (∀x y. h(prod(x, y)) = sum(h(x), h(y)))›
locale semi_hom_loc = prod: semi ‹prod› + sum: semi ‹sum› for prod and sum and h + assumes semi_homh: ‹semi_hom(prod, sum, h)› notes semi_hom_mult = semi_hom_mult [OF semi_homh]
thm semi_hom_loc.semi_hom_mult (* unspecified, attribute not applied in background theory !!! *)
lemma (in semi_hom_loc) ‹h(prod(x, y)) = sum(h(x), h(y))› by (rule semi_hom_mult)
(* Referring to facts from within a context specification *)
lemma assumes x: ‹P ⟷ P› notes y = x shows‹True› ..
section‹Theorem statements›
lemma (in lgrp) lcancel: ‹x ** y = x ** z ⟷ y = z› proof assume‹x ** y = x ** z› thenhave‹inv(x) ** x ** y = inv(x) ** x ** z›by (simp add: assoc) thenshow‹y = z›by (simp add: lone linv) qed simp print_locale! lgrp
locale rgrp = semi + fixes one and inv assumes rone: ‹x ** one = x› and rinv: ‹x ** inv(x) = one› begin
lemma rcancel: ‹y ** x = z ** x ⟷ y = z› proof assume‹y ** x = z ** x› thenhave‹y ** (x ** inv(x)) = z ** (x ** inv(x))› by (simp add: assoc [symmetric]) thenshow‹y = z›by (simp add: rone rinv) qed simp
end print_locale! rgrp
subsection‹Patterns›
lemma (in rgrp) assumes‹y ** x = z ** x› (is‹?a›) shows‹y = z› (is‹?t›) proof - txt‹Weird proof involving patterns fromcontext element and conclusion.›
{ assume‹?a› thenhave‹y ** (x ** inv(x)) = z ** (x ** inv(x))› by (simp add: assoc [symmetric]) thenhave‹?t›by (simp add: rone rinv)
} note x = this show‹?t›by (rule x [OF ‹?a›]) qed
section‹Interpretation between locales: sublocales›
sublocale lgrp < right?: rgrp print_facts proof unfold_locales
{ fix x have‹inv(x) ** x ** one = inv(x) ** x›by (simp add: linv lone) thenshow‹x ** one = x›by (simp add: assoc lcancel)
} note rone = this
{ fix x have‹inv(x) ** x ** inv(x) = inv(x) ** one› by (simp add: linv lone rone) thenshow‹x ** inv(x) = one›by (simp add: assoc lcancel)
} qed
(* effect on printed locale *)
print_locale! lgrp
(* use of derived theorem *)
lemma (in lgrp) ‹y ** x = z ** x ⟷ y = z› apply (rule rcancel) done
(* circular interpretation *)
sublocale rgrp < left: lgrp proof unfold_locales
{ fix x have‹one ** (x ** inv(x)) = x ** inv(x)›by (simp add: rinv rone) thenshow‹one ** x = x›by (simp add: assoc [symmetric] rcancel)
} note lone = this
{ fix x have‹inv(x) ** (x ** inv(x)) = one ** inv(x)› by (simp add: rinv lone rone) thenshow‹inv(x) ** x = one›by (simp add: assoc [symmetric] rcancel)
} qed
(* effect on printed locale *)
print_locale! rgrp print_locale! lgrp
(* Duality *)
locale order = fixes less :: ‹'a => 'a => o› (infix‹<<› 50) assumes refl: ‹x << x› and trans: ‹[| x << y; y << z |] ==> x << z›
sublocale order < dual: order ‹%x y. y << x› apply unfold_locales apply (rule refl) apply (blast intro: trans) done
print_locale! order (* Only two instances of order. *)
locale order' = fixes less :: ‹'a => 'a => o› (infix‹<<› 50) assumes refl: ‹x << x› and trans: ‹[| x << y; y << z |] ==> x << z›
locale order_with_def = order' begin
definition greater :: ‹'a => 'a => o› (infix‹>>› 50) where ‹x >> y ⟷ y << x›
text‹Simulate a specification of left groups where unit and inverse are defined
rather than specified. This is possible, but not in FOL, due to the lack of a
selection operator.›
axiomatization glob_one and glob_inv where glob_lone: ‹prod(glob_one(prod), x) = x› and glob_linv: ‹prod(glob_inv(prod, x), x) = glob_one(prod)›
locale dgrp = semi begin
definition one where‹one = glob_one(prod)›
lemma lone: ‹one ** x = x› unfolding one_def by (rule glob_lone)
definition inv where‹inv(x) = glob_inv(prod, x)›
lemma linv: ‹inv(x) ** x = one› unfolding one_def inv_def by (rule glob_linv)
locale container begin interpretation"private": roundup ‹True›by unfold_locales rule lemmas true_copy = private.true end
context container begin
ML ‹(Context.>> (fn generic => let val context = Context.proof_of generic
val _ = Proof_Context.get_thms context"private.true"in generic end);
raise Fail "thm private.true was persisted")
handle ERROR _ => ([]:thm list);› thm true_copy end
section‹Interpretationin proofs›
notepad begin interpret"local": lgrp ‹(+)›‹0›‹minus› by unfold_locales (* subsumed *)
{ fix zero :: ‹int› assume‹!!x. zero + x = x›‹!!x. (-x) + x = zero› theninterpret local_fixed: lgrp ‹(+)›‹zero›‹minus› by unfold_locales thm local_fixed.lone
} assume‹!!x zero. zero + x = x›‹!!x zero. (-x) + x = zero› theninterpret local_free: lgrp ‹(+)›‹zero›‹minus›for zero by unfold_locales thm local_free.lone [where ?zero = ‹0›] end
notepad begin
{ fix pand and pnot and por assume passoc: ‹∧x y z. pand(pand(x, y), z) ⟷ pand(x, pand(y, z))› and pnotnot: ‹∧x. pnot(pnot(x)) ⟷ x› and por_def: ‹∧x y. por(x, y) ⟷ pnot(pand(pnot(x), pnot(y)))› interpret loc: logic_o ‹pand›‹pnot›
rewrites por_eq: ‹∧x y. logic_o.lor_o(pand, pnot, x, y) ⟷ por(x, y)›(* FIXME *) proof - show logic_o: ‹PROP logic_o(pand, pnot)›using passoc pnotnot by unfold_locales fix x y show‹logic_o.lor_o(pand, pnot, x, y) ⟷ por(x, y)› by (unfold logic_o.lor_o_def [OF logic_o]) (rule por_def [symmetric]) qed print_interps logic_o have‹∧x y. por(x, y) ⟷ pnot(pand(pnot(x), pnot(y)))›by (rule loc.lor_o_def)
} end
end
Messung V0.5
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.