primrec
integ_of_Pls: "integ_of (Pls) = $# 0"
integ_of_Min: "integ_of (Min) = $-($#1)"
integ_of_BIT: "integ_of (w BIT b) = $#b $+ integ_of(w) $+ integ_of(w)"
(** recall that cond(1,b,c)=b and cond(0,b,c)=0 **)
primrec(*NCons adds a bit, suppressing leading 0s and 1s*)
NCons_Pls: "NCons (Pls,b) = cond(b,Pls BIT b,Pls)"
NCons_Min: "NCons (Min,b) = cond(b,Min,Min BIT b)"
NCons_BIT: "NCons (w BIT c,b) = w BIT c BIT b"
primrec(*successor. If a BIT, can change a 0 to a 1 without recursion.*)
bin_succ_Pls: "bin_succ (Pls) = Pls BIT 1"
bin_succ_Min: "bin_succ (Min) = Pls"
bin_succ_BIT: "bin_succ (w BIT b) = cond(b, bin_succ(w) BIT 0, NCons(w,1))"
primrec(*predecessor*)
bin_pred_Pls: "bin_pred (Pls) = Min"
bin_pred_Min: "bin_pred (Min) = Min BIT 0"
bin_pred_BIT: "bin_pred (w BIT b) = cond(b, NCons(w,0), bin_pred(w) BIT 1)"
primrec(*unary negation*)
bin_minus_Pls: "bin_minus (Pls) = Pls"
bin_minus_Min: "bin_minus (Min) = Pls BIT 1"
bin_minus_BIT: "bin_minus (w BIT b) = cond(b, bin_pred(NCons(bin_minus(w),0)), bin_minus(w) BIT 0)"
primrec(*sum*)
bin_adder_Pls: "bin_adder (Pls) = (λw∈bin. w)"
bin_adder_Min: "bin_adder (Min) = (λw∈bin. bin_pred(w))"
bin_adder_BIT: "bin_adder (v BIT x) = (λw∈bin. bin_case (v BIT x, bin_pred(v BIT x), λw y. NCons(bin_adder (v) ` cond(x and y, bin_succ(w), w), x xor y), w))"
(*The bin_case above replaces the following mutually recursive function: primrec "adding(v,x,Pls)=vBITx" "adding(v,x,Min)=bin_pred(vBITx)" "adding(v,x,wBITy)=NCons(bin_adder(v,cond(xandy,bin_succ(w),w)), xxory)"
*)
primrec
bin_mult_Pls: "bin_mult (Pls,w) = Pls"
bin_mult_Min: "bin_mult (Min,w) = bin_minus(w)"
bin_mult_BIT: "bin_mult (v BIT b,w) = cond(b, bin_add(NCons(bin_mult(v,w),0),w), NCons(bin_mult(v,w),0))"
syntax "_Int0" :: i (‹#()0›) "_Int1" :: i (‹#()1›) "_Int2" :: i (‹#()2›) "_Neg_Int1" :: i (‹#-()1›) "_Neg_Int2" :: i (‹#-()2›) translations "#0"⇌"CONST integ_of(CONST Pls)" "#1"⇌"CONST integ_of(CONST Pls BIT 1)" "#2"⇌"CONST integ_of(CONST Pls BIT 1 BIT 0)" "#-1"⇌"CONST integ_of(CONST Min)" "#-2"⇌"CONST integ_of(CONST Min BIT 0)"
lemma NCons_type [TC]: "[w ∈ bin; b ∈ bool]==> NCons(w,b) ∈ bin" by (induct_tac "w", auto)
lemma bin_succ_type [TC]: "w ∈ bin ==> bin_succ(w) ∈ bin" by (induct_tac "w", auto)
lemma bin_pred_type [TC]: "w ∈ bin ==> bin_pred(w) ∈ bin" by (induct_tac "w", auto)
lemma bin_minus_type [TC]: "w ∈ bin ==> bin_minus(w) ∈ bin" by (induct_tac "w", auto)
(*This proof is complicated by the mutual recursion*) lemma bin_add_type [rule_format]: "v ∈ bin ==>∀w∈bin. bin_add(v,w) ∈ bin" unfolding bin_add_def apply (induct_tac "v") apply (rule_tac [3] ballI) apply (rename_tac [3] "w'") apply (induct_tac [3] "w'") apply (simp_all add: NCons_type) done
declare bin_add_type [TC]
lemma bin_mult_type [TC]: "[v ∈ bin; w ∈ bin]==> bin_mult(v,w) ∈ bin" by (induct_tac "v", auto)
subsubsection‹The Carry and Borrow Functions, term‹bin_succ› and term‹bin_pred››
(*NCons preserves the integer value of its argument*) lemma integ_of_NCons [simp]: "[w ∈ bin; b ∈ bool]==> integ_of(NCons(w,b)) = integ_of(w BIT b)" apply (erule bin.cases) apply (auto elim!: boolE) done
lemma bin_add_BIT_Pls [simp]: "bin_add(v BIT x,Pls) = v BIT x" by (unfold bin_add_def, simp)
lemma bin_add_BIT_Min [simp]: "bin_add(v BIT x,Min) = bin_pred(v BIT x)" by (unfold bin_add_def, simp)
lemma bin_add_BIT_BIT [simp]: "[w ∈ bin; y ∈ bool] ==> bin_add(v BIT x, w BIT y) = NCons(bin_add(v, cond(x and y, bin_succ(w), w)), x xor y)" by (unfold bin_add_def, simp)
(*For making a minimal simpset, one must include these default simprules
of thy. Also include simp_thms, or at least (\<not>False)=True*) lemmas bin_arith_simps =
bin_pred_Pls bin_pred_Min
bin_succ_Pls bin_succ_Min
bin_add_Pls bin_add_Min
bin_minus_Pls bin_minus_Min
bin_mult_Pls bin_mult_Min
bin_arith_extra_simps
(*This simprule cannot be added unless we can find a way to make eq_integ_of_eq unconditional! [Thecondition"True"isahacktopreventlooping. Conditionalrewriterulesaretriedafterunconditionalones,soarule likeeq_nat_number_ofwillbetriedfirsttoeliminate#mm=#nn.] lemmainteg_of_reorient[simp]: "True\<Longrightarrow>(integ_of(w)=x)\<longleftrightarrow>(x=integ_of(w))" byauto
*)
lemma integ_of_minus_reorient [simp]: "(integ_of(w) = $- x) ⟷ ($- x = integ_of(w))" by auto
lemma integ_of_add_reorient [simp]: "(integ_of(w) = x $+ y) ⟷ (x $+ y = integ_of(w))" by auto
lemma integ_of_diff_reorient [simp]: "(integ_of(w) = x $- y) ⟷ (x $- y = integ_of(w))" by auto
lemma integ_of_mult_reorient [simp]: "(integ_of(w) = x $* y) ⟷ (x $* y = integ_of(w))" by auto
(** To simplify inequalities involving integer negation and literals, suchas-x=#3
**)
lemmas [simp] =
zminus_equation [where y = "integ_of(w)"]
equation_zminus [where x = "integ_of(w)"] for w
lemmas [iff] =
zminus_zless [where y = "integ_of(w)"]
zless_zminus [where x = "integ_of(w)"] for w
lemmas [iff] =
zminus_zle [where y = "integ_of(w)"]
zle_zminus [where x = "integ_of(w)"] for w
lemmas [simp] =
Let_def [where s = "integ_of(w)"] for w
(*** Simprocs for numeric literals ***)
(** Combining of literal coefficients in sums of products **)
lemmas rel_iff_rel_0_rls =
zless_iff_zdiff_zless_0 [where y = "u $+ v"]
eq_iff_zdiff_eq_0 [where y = "u $+ v"]
zle_iff_zdiff_zle_0 [where y = "u $+ v"]
zless_iff_zdiff_zless_0 [where y = n]
eq_iff_zdiff_eq_0 [where y = n]
zle_iff_zdiff_zle_0 [where y = n] for u v
text‹‹combine_numerals_prod› (products of separate literals)› lemma"#5 $* x $* #3 = y"apply simp oops
schematic_goal "y2 $+ ?x42 = y $+ y2"apply simp oops
lemma"oo : int ==> l $+ (l $+ #2) $+ oo = oo"apply simp oops
lemma"#9$*x $+ y = x$*#23 $+ z"apply simp oops lemma"y $+ x = x $+ z"apply simp oops
lemma"x : int ==> x $+ y $+ z = x $+ z"apply simp oops lemma"x : int ==> y $+ (z $+ x) = z $+ x"apply simp oops lemma"z : int ==> x $+ y $+ z = (z $+ y) $+ (x $+ w)"apply simp oops lemma"z : int ==> x$*y $+ z = (z $+ y) $+ (y$*x $+ w)"apply simp oops
lemma"#-3 $* x $+ y $≤ x $* #2 $+ z"apply simp oops lemma"y $+ x $≤ x $+ z"apply simp oops lemma"x $+ y $+ z $≤ x $+ z"apply simp oops
lemma"y $+ (z $+ x) $< z $+ x"apply simp oops lemma"x $+ y $+ z $< (z $+ y) $+ (x $+ w)"apply simp oops lemma"x$*y $+ z $< (z $+ y) $+ (y$*x $+ w)"apply simp oops
lemma"y $- b $< b"apply simp oops lemma"y $- (#3 $* b $+ c) $< b $- #2 $* c"apply simp oops
lemma"(#2 $* x $- (u $* v) $+ y) $- v $* #3 $* u = w"apply simp oops lemma"(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u $* #4 = w"apply simp oops lemma"(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u = w"apply simp oops lemma"u $* v $- (x $* u $* v $+ (u $* v) $* #4 $+ y) = w"apply simp oops
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.