(* Title: HOL/Library/Z2.thy Author: Brian Huffman
*)
section‹The Field of Integers mod 2›
theory Z2 imports Main begin
text‹ Note that in most cases 🍋‹bool›is appropriate when a binary type is needed; the
type provided here, for historical reasons named 🚫‹bit›, is only needed if proper
field operations are required. ›
typedef bit = ‹UNIV :: bool set› ..
instantiation bit :: zero_neq_one begin
definition zero_bit :: bit where‹0 = Abs_bit False›
definition one_bit :: bit where‹1 = Abs_bit True›
instance by standard (simp add: zero_bit_def one_bit_def Abs_bit_inject)
end
free_constructors case_bit for‹0::bit› | ‹1::bit› proof - fix P :: bool fix a :: bit assume‹a = 0 ==> P›and‹a = 1 ==> P› thenshow P by (cases a) (auto simp add: zero_bit_def one_bit_def Abs_bit_inject) qed simp
lemma bit_not_zero_iff [simp]: ‹a ≠ 0 ⟷ a = 1›for a :: bit by (cases a) simp_all
lemma bit_not_one_iff [simp]: ‹a ≠ 1 ⟷ a = 0›for a :: bit by (cases a) simp_all
instantiation bit :: semidom_modulo begin
definition plus_bit :: ‹bit ==> bit ==> bit› where‹a + b = Abs_bit (Rep_bit a ≠ Rep_bit b)›
definition minus_bit :: ‹bit ==> bit ==> bit› where [simp]: ‹minus_bit = plus›
definition times_bit :: ‹bit ==> bit ==> bit› where‹a * b = Abs_bit (Rep_bit a ∧ Rep_bit b)›
definition divide_bit :: ‹bit ==> bit ==> bit› where [simp]: ‹divide_bit = times›
definition modulo_bit :: ‹bit ==> bit ==> bit› where‹a mod b = Abs_bit (Rep_bit a ∧¬ Rep_bit b)›
instance by standard
(auto simp flip: Rep_bit_inject
simp add: zero_bit_def one_bit_def plus_bit_def times_bit_def modulo_bit_def Abs_bit_inverse Rep_bit_inverse)
qualified lemma bit_eq_iff: ‹a = b ⟷ (even a ⟷ even b)›for a b :: bit by (cases a; cases b) simp_all
end
lemma modulo_bit_unfold [simp, code]: ‹a mod b = of_bool (odd a ∧ even b)›for a b :: bit by (simp add: modulo_bit_def Abs_bit_eq_of_bool Rep_bit_eq_odd)
lemma power_bit_unfold [simp]: ‹a ^ n = of_bool (odd a ∨ n = 0)›for a :: bit by (cases a) simp_all
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.