theory limits_uniqueness imports Main begin locale abs_field = fixes zero :: "'r" and one :: "'r" and add :: "'r \ 'r \ 'r" (infixl "+R" 65) and mul :: "'r \ 'r \ 'r" (infixl "*R" 70) and opp :: "'r \ 'r" and absV :: "'r \ 'r" and le :: "'r \ 'r \ bool" (infix "\" 50) and lt :: "'r \ 'r \ bool" (infix "\" 50) and natLe :: "'n \ 'n \ bool" and natMax :: "'n \ 'n \ 'n" assumes le_max_left : "\x y. natLe x (natMax x y)" and le_max_right : "\x y. natLe y (natMax x y)" and add_comm : "\x y. x +R y = y +R x" and add_assoc : "\x y z. (x +R y) +R z = x +R (y +R z)" and add_zero : "\x. x +R zero = x" and add_opp : "\x. x +R opp x = zero" and opp_add : "\x y. opp (x +R y) = opp x +R opp y" and le_refl : "\x. x \ x" and le_trans : "\x y z. x \ y \ y \ z \ x \ z" and add_le_add : "\a b c d. a \ b \ c \ d \ a +R c \ b +R d" and abs_nonneg : "\x. zero \ absV x" and abs_triangle : "\x y. absV (x +R y) \ absV x +R absV y" and abs_sub_symm : "\x y. absV (x +R opp y) = absV (y +R opp x)" and sub_decomp : "\x y z. x +R opp z = (x +R opp y) +R (y +R opp z)" and sub_eq_zero : "\x y. x +R opp y = zero \ x = y" and eq_of_forall_eps2 : "\x. (\eps. zero \ eps \ absV x \ eps +R eps) \ x = zero" begin definition sub :: "'r \ 'r \ 'r" where "sub x y \ x +R opp y" definition limit :: "('n \ 'r) \ 'r \ bool" where "limit u l \ \eps. zero \ eps \ (\N. \n. natLe N n \ absV (sub (u n) l) \ eps)" lemma sub_self_zero: "sub x x = zero" unfolding sub_def by (rule add_opp) lemma sub_decomp_lem: "sub x z = (sub x y) +R (sub y z)" unfolding sub_def by (rule sub_decomp) lemma abs_sub_triangle: "absV (sub x z) \ absV (sub x y) +R absV (sub y z)" proof - have "sub x z = sub x y +R sub y z" by (rule sub_decomp_lem) hence "absV (sub x z) = absV (sub x y +R sub y z)" by simp also have "\ \ absV (sub x y) +R absV (sub y z)" by (rule abs_triangle) finally show ?thesis . qed lemma abs_sub_symm_lem: "absV (sub x y) = absV (sub y x)" unfolding sub_def by (rule abs_sub_symm) theorem limit_unique: assumes Hl: "limit u l" and Hm: "limit u m" shows "l = m" proof - have Hbound: "\eps. zero \ eps \ absV (sub l m) \ eps +R eps" proof (intro allI impI) fix eps assume Heps: "zero \ eps" from Hl Heps obtain N1 where HN1: "\n. natLe N1 n \ absV (sub (u n) l) \ eps" unfolding limit_def by blast from Hm Heps obtain N2 where HN2: "\n. natLe N2 n \ absV (sub (u n) m) \ eps" unfolding limit_def by blast define N where "N \ natMax N1 N2" have H1 : "absV (sub (u N) l) \ eps" using HN1 le_max_left unfolding N_def by blast have H2 : "absV (sub (u N) m) \ eps" using HN2 le_max_right unfolding N_def by blast have Htri : "absV (sub l m) \ absV (sub l (u N)) +R absV (sub (u N) m)" by (rule abs_sub_triangle) have H1' : "absV (sub l (u N)) \ eps" using H1 by (simp add: abs_sub_symm_lem) show "absV (sub l m) \ eps +R eps" using le_trans[OF Htri] add_le_add[OF H1' H2] by blast qed have Hz : "sub l m = zero" using Hbound by (rule eq_of_forall_eps2) show "l = m" using sub_eq_zero[OF Hz[unfolded sub_def]] . qed end end