src/HOL/Library/Topology_Euclidean_Space.thy
changeset 31343 9983f648f9bb
parent 31342 b7941738e3a1
child 31344 fc09ec06b89b
equal deleted inserted replaced
31342:b7941738e3a1 31343:9983f648f9bb
  1159 lemma not_eventually: "(\<forall>x. \<not> P x ) \<Longrightarrow> ~(trivial_limit net) ==> ~(eventually P net)"
  1159 lemma not_eventually: "(\<forall>x. \<not> P x ) \<Longrightarrow> ~(trivial_limit net) ==> ~(eventually P net)"
  1160   by (auto simp add: eventually_def)
  1160   by (auto simp add: eventually_def)
  1161 
  1161 
  1162 subsection{* Limits, defined as vacuously true when the limit is trivial. *}
  1162 subsection{* Limits, defined as vacuously true when the limit is trivial. *}
  1163 
  1163 
  1164 definition tendsto:: "('a \<Rightarrow> real ^'n::finite) \<Rightarrow> real ^'n \<Rightarrow> 'a net \<Rightarrow> bool" (infixr "--->" 55) where
  1164 definition tendsto:: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'b \<Rightarrow> 'a net \<Rightarrow> bool" (infixr "--->" 55) where
  1165   tendsto_def: "(f ---> l) net  \<longleftrightarrow> (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)"
  1165   tendsto_def: "(f ---> l) net  \<longleftrightarrow> (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)"
  1166 
  1166 
  1167 lemma tendstoD: "(f ---> l) net \<Longrightarrow> e>0 \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net"
  1167 lemma tendstoD: "(f ---> l) net \<Longrightarrow> e>0 \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net"
  1168   unfolding tendsto_def by auto
  1168   unfolding tendsto_def by auto
  1169 
  1169 
  1323 qed
  1323 qed
  1324 
  1324 
  1325 lemma Lim_const: "((\<lambda>x. a) ---> a) net"
  1325 lemma Lim_const: "((\<lambda>x. a) ---> a) net"
  1326   by (auto simp add: Lim trivial_limit_def)
  1326   by (auto simp add: Lim trivial_limit_def)
  1327 
  1327 
  1328 lemma Lim_cmul: "(f ---> l) net ==> ((\<lambda>x. c *s f x) ---> c *s l) net"
  1328 lemma Lim_cmul:
       
  1329   fixes f :: "'a \<Rightarrow> real ^ 'n::finite"
       
  1330   shows "(f ---> l) net ==> ((\<lambda>x. c *s f x) ---> c *s l) net"
  1329   apply (rule Lim_linear[where f = f])
  1331   apply (rule Lim_linear[where f = f])
  1330   apply simp
  1332   apply simp
  1331   apply (rule linear_compose_cmul)
  1333   apply (rule linear_compose_cmul)
  1332   apply (rule linear_id[unfolded id_def])
  1334   apply (rule linear_id[unfolded id_def])
  1333   done
  1335   done
  1334 
  1336 
  1335 lemma Lim_neg: "(f ---> l) net ==> ((\<lambda>x. -(f x)) ---> -l) net"
  1337 lemma Lim_neg:
       
  1338   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
       
  1339   shows "(f ---> l) net ==> ((\<lambda>x. -(f x)) ---> -l) net"
  1336   apply (simp add: Lim dist_norm  group_simps)
  1340   apply (simp add: Lim dist_norm  group_simps)
  1337   apply (subst minus_diff_eq[symmetric])
  1341   apply (subst minus_diff_eq[symmetric])
  1338   unfolding norm_minus_cancel by simp
  1342   unfolding norm_minus_cancel by simp
  1339 
  1343 
  1340 lemma Lim_add: fixes f :: "'a \<Rightarrow> real^'n::finite" shows
  1344 lemma Lim_add: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" shows
  1341  "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) + g(x)) ---> l + m) net"
  1345  "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) + g(x)) ---> l + m) net"
  1342 proof-
  1346 proof-
  1343   assume as:"(f ---> l) net" "(g ---> m) net"
  1347   assume as:"(f ---> l) net" "(g ---> m) net"
  1344   { fix e::real
  1348   { fix e::real
  1345     assume "e>0"
  1349     assume "e>0"
  1364     qed
  1368     qed
  1365   }
  1369   }
  1366   thus ?thesis unfolding tendsto_def by auto
  1370   thus ?thesis unfolding tendsto_def by auto
  1367 qed
  1371 qed
  1368 
  1372 
  1369 lemma Lim_sub: "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) - g(x)) ---> l - m) net"
  1373 lemma Lim_sub:
       
  1374   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
       
  1375   shows "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) - g(x)) ---> l - m) net"
  1370   unfolding diff_minus
  1376   unfolding diff_minus
  1371   by (simp add: Lim_add Lim_neg)
  1377   by (simp add: Lim_add Lim_neg)
  1372 
  1378 
  1373 lemma Lim_null: "(f ---> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) ---> 0) net" by (simp add: Lim dist_norm)
  1379 lemma Lim_null:
  1374 lemma Lim_null_norm: "(f ---> 0) net \<longleftrightarrow> ((\<lambda>x. vec1(norm(f x))) ---> 0) net"
  1380   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
       
  1381   shows "(f ---> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) ---> 0) net" by (simp add: Lim dist_norm)
       
  1382 
       
  1383 lemma Lim_null_norm:
       
  1384   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
       
  1385   shows "(f ---> 0) net \<longleftrightarrow> ((\<lambda>x. vec1(norm(f x))) ---> 0) net"
  1375   by (simp add: Lim dist_norm norm_vec1)
  1386   by (simp add: Lim dist_norm norm_vec1)
  1376 
  1387 
  1377 lemma Lim_null_comparison:
  1388 lemma Lim_null_comparison:
       
  1389   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
  1378   assumes "eventually (\<lambda>x. norm(f x) <= g x) net" "((\<lambda>x. vec1(g x)) ---> 0) net"
  1390   assumes "eventually (\<lambda>x. norm(f x) <= g x) net" "((\<lambda>x. vec1(g x)) ---> 0) net"
  1379   shows "(f ---> 0) net"
  1391   shows "(f ---> 0) net"
  1380 proof(simp add: tendsto_def, rule+)
  1392 proof(simp add: tendsto_def, rule+)
  1381   fix e::real assume "0<e"
  1393   fix e::real assume "0<e"
  1382   { fix x
  1394   { fix x
  1401   apply (rule order_le_less_trans)
  1413   apply (rule order_le_less_trans)
  1402   apply (rule component_le_norm)
  1414   apply (rule component_le_norm)
  1403   by auto
  1415   by auto
  1404 
  1416 
  1405 lemma Lim_transform_bound:
  1417 lemma Lim_transform_bound:
       
  1418   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
       
  1419   fixes g :: "'a \<Rightarrow> 'c::real_normed_vector"
  1406   assumes "eventually (\<lambda>n. norm(f n) <= norm(g n)) net"  "(g ---> 0) net"
  1420   assumes "eventually (\<lambda>n. norm(f n) <= norm(g n)) net"  "(g ---> 0) net"
  1407   shows "(f ---> 0) net"
  1421   shows "(f ---> 0) net"
  1408 proof(simp add: tendsto_def, rule+)
  1422 proof(simp add: tendsto_def, rule+)
  1409   fix e::real assume "e>0"
  1423   fix e::real assume "e>0"
  1410   { fix x
  1424   { fix x
  1411     assume "norm (f x) \<le> norm (g x)" "dist (g x) 0 < e"
  1425     assume "norm (f x) \<le> norm (g x)" "dist (g x) 0 < e"
  1412     hence "dist (f x) 0 < e" by norm}
  1426     hence "dist (f x) 0 < e" by (simp add: dist_norm)}
  1413   thus "eventually (\<lambda>x. dist (f x) 0 < e) net"
  1427   thus "eventually (\<lambda>x. dist (f x) 0 < e) net"
  1414     using eventually_and[of "\<lambda>x. norm (f x) \<le> norm (g x)" "\<lambda>x. dist (g x) 0 < e" net]
  1428     using eventually_and[of "\<lambda>x. norm (f x) \<le> norm (g x)" "\<lambda>x. dist (g x) 0 < e" net]
  1415     using eventually_mono[of "\<lambda>x. norm (f x) \<le> norm (g x) \<and> dist (g x) 0 < e" "\<lambda>x. dist (f x) 0 < e" net]
  1429     using eventually_mono[of "\<lambda>x. norm (f x) \<le> norm (g x) \<and> dist (g x) 0 < e" "\<lambda>x. dist (f x) 0 < e" net]
  1416     using assms `e>0` unfolding tendsto_def by blast
  1430     using assms `e>0` unfolding tendsto_def by blast
  1417 qed
  1431 qed
  1436 qed
  1450 qed
  1437 
  1451 
  1438 text{* Need to prove closed(cball(x,e)) before deducing this as a corollary. *}
  1452 text{* Need to prove closed(cball(x,e)) before deducing this as a corollary. *}
  1439 
  1453 
  1440 lemma Lim_norm_ubound:
  1454 lemma Lim_norm_ubound:
       
  1455   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
  1441   assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. norm(f x) <= e) net"
  1456   assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. norm(f x) <= e) net"
  1442   shows "norm(l) <= e"
  1457   shows "norm(l) <= e"
  1443 proof-
  1458 proof-
  1444   obtain y where y: "\<exists>x. netord net x y"  "\<forall>x. netord net x y \<longrightarrow> norm (f x) \<le> e" using assms(1,3) unfolding eventually_def by auto
  1459   obtain y where y: "\<exists>x. netord net x y"  "\<forall>x. netord net x y \<longrightarrow> norm (f x) \<le> e" using assms(1,3) unfolding eventually_def by auto
  1445   show ?thesis
  1460   show ?thesis
  1447     assume "\<not> norm l \<le> e"
  1462     assume "\<not> norm l \<le> e"
  1448     then obtain z where z: "\<exists>x. netord net x z"  "\<forall>x. netord net x z \<longrightarrow> dist (f x) l < norm l - e"
  1463     then obtain z where z: "\<exists>x. netord net x z"  "\<forall>x. netord net x z \<longrightarrow> dist (f x) l < norm l - e"
  1449       using assms(2)[unfolded Lim] using assms(1) apply simp apply(erule_tac x="norm l - e" in allE) by auto
  1464       using assms(2)[unfolded Lim] using assms(1) apply simp apply(erule_tac x="norm l - e" in allE) by auto
  1450     obtain w where w:"netord net w z"  "netord net w y" using net[of net] using z(1) y(1) by blast
  1465     obtain w where w:"netord net w z"  "netord net w y" using net[of net] using z(1) y(1) by blast
  1451     hence "dist (f w) l < norm l - e \<and> norm (f w) <= e" using z(2) y(2) by auto
  1466     hence "dist (f w) l < norm l - e \<and> norm (f w) <= e" using z(2) y(2) by auto
  1452     thus False using `\<not> norm l \<le> e` by norm
  1467     hence "norm (f w - l) < norm l - e" "norm (f w) \<le> e" by (simp_all add: dist_norm)
       
  1468     hence "norm (f w - l) + norm (f w) < norm l" by simp
       
  1469     hence "norm (f w - l - f w) < norm l" by (rule le_less_trans [OF norm_triangle_ineq4])
       
  1470     thus False using `\<not> norm l \<le> e` by simp
  1453   qed
  1471   qed
  1454 qed
  1472 qed
  1455 
  1473 
  1456 lemma Lim_norm_lbound:
  1474 lemma Lim_norm_lbound:
       
  1475   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
  1457   assumes "\<not> (trivial_limit net)"  "(f ---> l) net"  "eventually (\<lambda>x. e <= norm(f x)) net"
  1476   assumes "\<not> (trivial_limit net)"  "(f ---> l) net"  "eventually (\<lambda>x. e <= norm(f x)) net"
  1458   shows "e \<le> norm l"
  1477   shows "e \<le> norm l"
  1459 proof-
  1478 proof-
  1460   obtain y where y: "\<exists>x. netord net x y"  "\<forall>x. netord net x y \<longrightarrow> e \<le> norm (f x)" using assms(1,3) unfolding eventually_def by auto
  1479   obtain y where y: "\<exists>x. netord net x y"  "\<forall>x. netord net x y \<longrightarrow> e \<le> norm (f x)" using assms(1,3) unfolding eventually_def by auto
  1461   show ?thesis
  1480   show ?thesis
  1463     assume "\<not> e \<le> norm l"
  1482     assume "\<not> e \<le> norm l"
  1464     then obtain z where z: "\<exists>x. netord net x z"  "\<forall>x. netord net x z \<longrightarrow> dist (f x) l < e - norm l"
  1483     then obtain z where z: "\<exists>x. netord net x z"  "\<forall>x. netord net x z \<longrightarrow> dist (f x) l < e - norm l"
  1465       using assms(2)[unfolded Lim] using assms(1) apply simp apply(erule_tac x="e - norm l" in allE) by auto
  1484       using assms(2)[unfolded Lim] using assms(1) apply simp apply(erule_tac x="e - norm l" in allE) by auto
  1466     obtain w where w:"netord net w z"  "netord net w y" using net[of net] using z(1) y(1) by blast
  1485     obtain w where w:"netord net w z"  "netord net w y" using net[of net] using z(1) y(1) by blast
  1467     hence "dist (f w) l < e - norm l \<and> e \<le> norm (f w)" using z(2) y(2) by auto
  1486     hence "dist (f w) l < e - norm l \<and> e \<le> norm (f w)" using z(2) y(2) by auto
  1468     thus False using `\<not> e \<le> norm l` by norm
  1487     hence "norm (f w - l) + norm l < e" "e \<le> norm (f w)" by (simp_all add: dist_norm)
       
  1488     hence "norm (f w - l) + norm l < norm (f w)" by (rule less_le_trans)
       
  1489     hence "norm (f w - l + l) < norm (f w)" by (rule le_less_trans [OF norm_triangle_ineq])
       
  1490     thus False by simp
  1469   qed
  1491   qed
  1470 qed
  1492 qed
  1471 
  1493 
  1472 text{* Uniqueness of the limit, when nontrivial. *}
  1494 text{* Uniqueness of the limit, when nontrivial. *}
  1473 
  1495 
  1486   hence "l = l'" using norm_ge_zero[of "l - l'"] unfolding le_less and dist_nz[of l l', unfolded dist_norm, THEN sym] by auto
  1508   hence "l = l'" using norm_ge_zero[of "l - l'"] unfolding le_less and dist_nz[of l l', unfolded dist_norm, THEN sym] by auto
  1487   thus ?thesis using assms using Lim_sub[of f l net f l'] by simp
  1509   thus ?thesis using assms using Lim_sub[of f l net f l'] by simp
  1488 qed
  1510 qed
  1489 
  1511 
  1490 lemma tendsto_Lim:
  1512 lemma tendsto_Lim:
  1491  "~(trivial_limit (net::('b::zero_neq_one net))) \<Longrightarrow> (f ---> l) net ==> Lim net f = l"
  1513   fixes f :: "'a::zero_neq_one \<Rightarrow> real ^ 'n::finite"
       
  1514   shows "~(trivial_limit net) \<Longrightarrow> (f ---> l) net ==> Lim net f = l"
  1492   unfolding Lim_def using Lim_unique[of net f] by auto
  1515   unfolding Lim_def using Lim_unique[of net f] by auto
  1493 
  1516 
  1494 text{* Limit under bilinear function (surprisingly tedious, but important) *}
  1517 text{* Limit under bilinear function (surprisingly tedious, but important) *}
  1495 
  1518 
  1496 lemma norm_bound_lemma:
  1519 lemma norm_bound_lemma:
  1612   using netlimit_within[of a UNIV]
  1635   using netlimit_within[of a UNIV]
  1613   by (simp add: trivial_limit_at within_UNIV)
  1636   by (simp add: trivial_limit_at within_UNIV)
  1614 
  1637 
  1615 text{* Transformation of limit. *}
  1638 text{* Transformation of limit. *}
  1616 
  1639 
  1617 lemma Lim_transform: assumes "((\<lambda>x. f x - g x) ---> 0) net" "(f ---> l) net"
  1640 lemma Lim_transform:
       
  1641   fixes f g :: "'a::type \<Rightarrow> 'b::real_normed_vector"
       
  1642   assumes "((\<lambda>x. f x - g x) ---> 0) net" "(f ---> l) net"
  1618   shows "(g ---> l) net"
  1643   shows "(g ---> l) net"
  1619 proof-
  1644 proof-
  1620   from assms have "((\<lambda>x. f x - g x - f x) ---> 0 - l) net" using Lim_sub[of "\<lambda>x. f x - g x" 0 net f l] by auto
  1645   from assms have "((\<lambda>x. f x - g x - f x) ---> 0 - l) net" using Lim_sub[of "\<lambda>x. f x - g x" 0 net f l] by auto
  1621   thus "?thesis" using Lim_neg [of "\<lambda> x. - g x" "-l" net] by auto
  1646   thus "?thesis" using Lim_neg [of "\<lambda> x. - g x" "-l" net] by auto
  1622 qed
  1647 qed
  1623 
  1648 
  1624 lemma Lim_transform_eventually:  "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net ==> (g ---> l) net"
  1649 lemma Lim_transform_eventually:
       
  1650   fixes f g :: "'a::type \<Rightarrow> 'b::real_normed_vector"
       
  1651   shows "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net ==> (g ---> l) net"
  1625   using Lim_eventually[of "\<lambda>x. f x - g x" 0 net] Lim_transform[of f g net l] by auto
  1652   using Lim_eventually[of "\<lambda>x. f x - g x" 0 net] Lim_transform[of f g net l] by auto
  1626 
  1653 
  1627 lemma Lim_transform_within:
  1654 lemma Lim_transform_within:
       
  1655   fixes f g :: "real ^ 'n::finite \<Rightarrow> 'b::real_normed_vector"
  1628   fixes x :: "real ^ 'n::finite"
  1656   fixes x :: "real ^ 'n::finite"
  1629   assumes "0 < d" "(\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x')"
  1657   assumes "0 < d" "(\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x')"
  1630           "(f ---> l) (at x within S)"
  1658           "(f ---> l) (at x within S)"
  1631   shows   "(g ---> l) (at x within S)"
  1659   shows   "(g ---> l) (at x within S)"
  1632 proof-
  1660 proof-
  1633   have "((\<lambda>x. f x - g x) ---> 0) (at x within S)" unfolding Lim_within[of "\<lambda>x. f x - g x" 0 x S] using assms(1,2) by auto
  1661   have "((\<lambda>x. f x - g x) ---> 0) (at x within S)" unfolding Lim_within[of "\<lambda>x. f x - g x" 0 x S] using assms(1,2) by auto
  1634   thus ?thesis using Lim_transform[of f g "at x within S" l] using assms(3) by auto
  1662   thus ?thesis using Lim_transform[of f g "at x within S" l] using assms(3) by auto
  1635 qed
  1663 qed
  1636 
  1664 
  1637 lemma Lim_transform_at: "0 < d \<Longrightarrow> (\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x') \<Longrightarrow>
  1665 lemma Lim_transform_at:
       
  1666   fixes f g :: "real ^ 'n::finite \<Rightarrow> 'b::real_normed_vector"
       
  1667   shows "0 < d \<Longrightarrow> (\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x') \<Longrightarrow>
  1638   (f ---> l) (at x) ==> (g ---> l) (at x)"
  1668   (f ---> l) (at x) ==> (g ---> l) (at x)"
  1639   apply (subst within_UNIV[symmetric])
  1669   apply (subst within_UNIV[symmetric])
  1640   using Lim_transform_within[of d UNIV x f g l]
  1670   using Lim_transform_within[of d UNIV x f g l]
  1641   by (auto simp add: within_UNIV)
  1671   by (auto simp add: within_UNIV)
  1642 
  1672 
  1643 text{* Common case assuming being away from some crucial point like 0. *}
  1673 text{* Common case assuming being away from some crucial point like 0. *}
  1644 
  1674 
  1645 lemma Lim_transform_away_within:
  1675 lemma Lim_transform_away_within:
  1646   fixes f:: "real ^'m::finite \<Rightarrow> real ^'n::finite"
  1676   fixes f:: "real ^'m::finite \<Rightarrow> 'b::real_normed_vector"
  1647   assumes "a\<noteq>b" "\<forall>x\<in> S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x"
  1677   assumes "a\<noteq>b" "\<forall>x\<in> S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x"
  1648   and "(f ---> l) (at a within S)"
  1678   and "(f ---> l) (at a within S)"
  1649   shows "(g ---> l) (at a within S)"
  1679   shows "(g ---> l) (at a within S)"
  1650 proof-
  1680 proof-
  1651   have "\<forall>x'\<in>S. 0 < dist x' a \<and> dist x' a < dist a b \<longrightarrow> f x' = g x'" using assms(2)
  1681   have "\<forall>x'\<in>S. 0 < dist x' a \<and> dist x' a < dist a b \<longrightarrow> f x' = g x'" using assms(2)
  1652     apply auto apply(erule_tac x=x' in ballE) by (auto simp add: dist_commute)
  1682     apply auto apply(erule_tac x=x' in ballE) by (auto simp add: dist_commute)
  1653   thus ?thesis using Lim_transform_within[of "dist a b" S a f g l] using assms(1,3) unfolding dist_nz by auto
  1683   thus ?thesis using Lim_transform_within[of "dist a b" S a f g l] using assms(1,3) unfolding dist_nz by auto
  1654 qed
  1684 qed
  1655 
  1685 
  1656 lemma Lim_transform_away_at:
  1686 lemma Lim_transform_away_at:
  1657   fixes f:: "real ^'m::finite \<Rightarrow> real ^'n::finite"
  1687   fixes f:: "real ^'m::finite \<Rightarrow> 'b::real_normed_vector"
  1658   assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x"
  1688   assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x"
  1659   and fl: "(f ---> l) (at a)"
  1689   and fl: "(f ---> l) (at a)"
  1660   shows "(g ---> l) (at a)"
  1690   shows "(g ---> l) (at a)"
  1661   using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl
  1691   using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl
  1662   by (auto simp add: within_UNIV)
  1692   by (auto simp add: within_UNIV)
  1663 
  1693 
  1664 text{* Alternatively, within an open set. *}
  1694 text{* Alternatively, within an open set. *}
  1665 
  1695 
  1666 lemma Lim_transform_within_open:
  1696 lemma Lim_transform_within_open:
  1667   fixes f:: "real ^'m::finite \<Rightarrow> real ^'n::finite"
  1697   fixes f:: "real ^'m::finite \<Rightarrow> 'b::real_normed_vector"
  1668   assumes "open S"  "a \<in> S"  "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x"  "(f ---> l) (at a)"
  1698   assumes "open S"  "a \<in> S"  "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x"  "(f ---> l) (at a)"
  1669   shows "(g ---> l) (at a)"
  1699   shows "(g ---> l) (at a)"
  1670 proof-
  1700 proof-
  1671   from assms(1,2) obtain e::real where "e>0" and e:"ball a e \<subseteq> S" unfolding open_contains_ball by auto
  1701   from assms(1,2) obtain e::real where "e>0" and e:"ball a e \<subseteq> S" unfolding open_contains_ball by auto
  1672   hence "\<forall>x'. 0 < dist x' a \<and> dist x' a < e \<longrightarrow> f x' = g x'" using assms(3)
  1702   hence "\<forall>x'. 0 < dist x' a \<and> dist x' a < e \<longrightarrow> f x' = g x'" using assms(3)
  2383     then obtain l where "(f ---> l) sequentially" using complete_univ[unfolded complete_def, THEN spec[where x=f]] by auto
  2413     then obtain l where "(f ---> l) sequentially" using complete_univ[unfolded complete_def, THEN spec[where x=f]] by auto
  2384     hence "\<exists>l\<in>s. (f ---> l) sequentially" using `?rhs`[unfolded closed_sequential_limits, THEN spec[where x=f], THEN spec[where x=l]] using as(1) by auto  }
  2414     hence "\<exists>l\<in>s. (f ---> l) sequentially" using `?rhs`[unfolded closed_sequential_limits, THEN spec[where x=f], THEN spec[where x=l]] using as(1) by auto  }
  2385   thus ?lhs unfolding complete_def by auto
  2415   thus ?lhs unfolding complete_def by auto
  2386 qed
  2416 qed
  2387 
  2417 
  2388 lemma convergent_eq_cauchy: "(\<exists>l. (s ---> l) sequentially) \<longleftrightarrow> Cauchy s" (is "?lhs = ?rhs")
  2418 lemma convergent_eq_cauchy:
       
  2419   fixes s :: "nat \<Rightarrow> real ^ 'n::finite"
       
  2420   shows "(\<exists>l. (s ---> l) sequentially) \<longleftrightarrow> Cauchy s" (is "?lhs = ?rhs")
  2389 proof
  2421 proof
  2390   assume ?lhs then obtain l where "(s ---> l) sequentially" by auto
  2422   assume ?lhs then obtain l where "(s ---> l) sequentially" by auto
  2391   thus ?rhs using convergent_imp_cauchy by auto
  2423   thus ?rhs using convergent_imp_cauchy by auto
  2392 next
  2424 next
  2393   assume ?rhs thus ?lhs using complete_univ[unfolded complete_def, THEN spec[where x=s]] by auto
  2425   assume ?rhs thus ?lhs using complete_univ[unfolded complete_def, THEN spec[where x=s]] by auto
  3168 qed
  3200 qed
  3169 
  3201 
  3170 text{* The usual transformation theorems. *}
  3202 text{* The usual transformation theorems. *}
  3171 
  3203 
  3172 lemma continuous_transform_within:
  3204 lemma continuous_transform_within:
       
  3205   fixes f g :: "real ^ 'n::finite \<Rightarrow> 'b::real_normed_vector"
  3173   assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'"
  3206   assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'"
  3174           "continuous (at x within s) f"
  3207           "continuous (at x within s) f"
  3175   shows "continuous (at x within s) g"
  3208   shows "continuous (at x within s) g"
  3176 proof-
  3209 proof-
  3177   { fix e::real assume "e>0"
  3210   { fix e::real assume "e>0"
  3183   hence "(f ---> g x) (at x within s)" unfolding Lim_within using assms(1) by auto
  3216   hence "(f ---> g x) (at x within s)" unfolding Lim_within using assms(1) by auto
  3184   thus ?thesis unfolding continuous_within using Lim_transform_within[of d s x f g "g x"] using assms by blast
  3217   thus ?thesis unfolding continuous_within using Lim_transform_within[of d s x f g "g x"] using assms by blast
  3185 qed
  3218 qed
  3186 
  3219 
  3187 lemma continuous_transform_at:
  3220 lemma continuous_transform_at:
       
  3221   fixes f g :: "real ^ 'n::finite \<Rightarrow> 'b::real_normed_vector"
  3188   assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'"
  3222   assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'"
  3189           "continuous (at x) f"
  3223           "continuous (at x) f"
  3190   shows "continuous (at x) g"
  3224   shows "continuous (at x) g"
  3191 proof-
  3225 proof-
  3192   { fix e::real assume "e>0"
  3226   { fix e::real assume "e>0"
  3202 qed
  3236 qed
  3203 
  3237 
  3204 text{* Combination results for pointwise continuity. *}
  3238 text{* Combination results for pointwise continuity. *}
  3205 
  3239 
  3206 lemma continuous_const: "continuous net (\<lambda>x::'a::zero_neq_one. c)"
  3240 lemma continuous_const: "continuous net (\<lambda>x::'a::zero_neq_one. c)"
  3207   by(auto simp add: continuous_def Lim_const)
  3241   by (auto simp add: continuous_def Lim_const)
  3208 
  3242 
  3209 lemma continuous_cmul:
  3243 lemma continuous_cmul:
  3210  "continuous net f ==> continuous net (\<lambda>x. c *s f x)"
  3244   fixes f :: "'a \<Rightarrow> real ^ 'n::finite"
  3211  by(auto simp add: continuous_def Lim_cmul)
  3245   shows "continuous net f ==> continuous net (\<lambda>x. c *s f x)"
       
  3246   by (auto simp add: continuous_def Lim_cmul)
  3212 
  3247 
  3213 lemma continuous_neg:
  3248 lemma continuous_neg:
  3214  "continuous net f ==> continuous net (\<lambda>x. -(f x))"
  3249   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
  3215  by(auto simp add: continuous_def Lim_neg)
  3250   shows "continuous net f ==> continuous net (\<lambda>x. -(f x))"
       
  3251   by (auto simp add: continuous_def Lim_neg)
  3216 
  3252 
  3217 lemma continuous_add:
  3253 lemma continuous_add:
  3218  "continuous net f \<Longrightarrow> continuous net g
  3254   fixes f g :: "'a \<Rightarrow> 'b::real_normed_vector"
  3219            ==> continuous net (\<lambda>x. f x + g x)"
  3255   shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x + g x)"
  3220  by(auto simp add: continuous_def Lim_add)
  3256   by (auto simp add: continuous_def Lim_add)
  3221 
  3257 
  3222 lemma continuous_sub:
  3258 lemma continuous_sub:
  3223  "continuous net f \<Longrightarrow> continuous net g
  3259   fixes f g :: "'a \<Rightarrow> 'b::real_normed_vector"
  3224            ==> continuous net (\<lambda>x. f(x) - g(x))"
  3260   shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x - g x)"
  3225  by(auto simp add: continuous_def Lim_sub)
  3261   by (auto simp add: continuous_def Lim_sub)
  3226 
  3262 
  3227 text{* Same thing for setwise continuity. *}
  3263 text{* Same thing for setwise continuity. *}
  3228 
  3264 
  3229 lemma continuous_on_const:
  3265 lemma continuous_on_const:
  3230  "continuous_on s (\<lambda>x. c)"
  3266  "continuous_on s (\<lambda>x. c)"
  3774   using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto
  3810   using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto
  3775 
  3811 
  3776 text{* Also bilinear functions, in composition form.                             *}
  3812 text{* Also bilinear functions, in composition form.                             *}
  3777 
  3813 
  3778 lemma bilinear_continuous_at_compose:
  3814 lemma bilinear_continuous_at_compose:
  3779  "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bilinear h
  3815   fixes f :: "real ^ _ \<Rightarrow> real ^ _"
       
  3816   shows "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bilinear h
  3780         ==> continuous (at x) (\<lambda>x. h (f x) (g x))"
  3817         ==> continuous (at x) (\<lambda>x. h (f x) (g x))"
  3781   unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto
  3818   unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto
  3782 
  3819 
  3783 lemma bilinear_continuous_within_compose:
  3820 lemma bilinear_continuous_within_compose:
  3784  "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bilinear h
  3821   fixes f :: "real ^ _ \<Rightarrow> real ^ _"
       
  3822   shows "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bilinear h
  3785         ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))"
  3823         ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))"
  3786   unfolding continuous_within using Lim_bilinear[of f "f x"] by auto
  3824   unfolding continuous_within using Lim_bilinear[of f "f x"] by auto
  3787 
  3825 
  3788 lemma bilinear_continuous_on_compose:
  3826 lemma bilinear_continuous_on_compose:
  3789  "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bilinear h
  3827  "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bilinear h
  3810             --> x \<in> s)"
  3848             --> x \<in> s)"
  3811   unfolding closed_limpt islimpt_approachable forall_vec1 apply simp
  3849   unfolding closed_limpt islimpt_approachable forall_vec1 apply simp
  3812   unfolding dist_vec1 vec1_in_image_vec1 abs_minus_commute by auto
  3850   unfolding dist_vec1 vec1_in_image_vec1 abs_minus_commute by auto
  3813 
  3851 
  3814 lemma continuous_at_vec1_range:
  3852 lemma continuous_at_vec1_range:
  3815  "continuous (at x) (vec1 o f) \<longleftrightarrow> (\<forall>e>0. \<exists>d>0.
  3853   fixes f :: "real ^ _ \<Rightarrow> real"
       
  3854   shows "continuous (at x) (vec1 o f) \<longleftrightarrow> (\<forall>e>0. \<exists>d>0.
  3816         \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)"
  3855         \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)"
  3817   unfolding continuous_at unfolding Lim_at apply simp unfolding dist_vec1 unfolding dist_nz[THEN sym] unfolding dist_norm apply auto
  3856   unfolding continuous_at unfolding Lim_at apply simp unfolding dist_vec1 unfolding dist_nz[THEN sym] unfolding dist_norm apply auto
  3818   apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto
  3857   apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto
  3819   apply(erule_tac x=e in allE) by auto
  3858   apply(erule_tac x=e in allE) by auto
  3820 
  3859 
  3935 qed
  3974 qed
  3936 
  3975 
  3937 subsection{* We can now extend limit compositions to consider the scalar multiplier.   *}
  3976 subsection{* We can now extend limit compositions to consider the scalar multiplier.   *}
  3938 
  3977 
  3939 lemma Lim_mul:
  3978 lemma Lim_mul:
       
  3979   fixes f :: "'a \<Rightarrow> real ^ _"
  3940   assumes "((vec1 o c) ---> vec1 d) net"  "(f ---> l) net"
  3980   assumes "((vec1 o c) ---> vec1 d) net"  "(f ---> l) net"
  3941   shows "((\<lambda>x. c(x) *s f x) ---> (d *s l)) net"
  3981   shows "((\<lambda>x. c(x) *s f x) ---> (d *s l)) net"
  3942 proof-
  3982 proof-
  3943   have "bilinear (\<lambda>x. op *s (dest_vec1 (x::real^1)))" unfolding bilinear_def linear_def
  3983   have "bilinear (\<lambda>x. op *s (dest_vec1 (x::real^1)))" unfolding bilinear_def linear_def
  3944     unfolding dest_vec1_add dest_vec1_cmul
  3984     unfolding dest_vec1_add dest_vec1_cmul
  3945     apply vector apply auto unfolding semiring_class.right_distrib semiring_class.left_distrib by auto
  3985     apply vector apply auto unfolding semiring_class.right_distrib semiring_class.left_distrib by auto
  3946   thus ?thesis using Lim_bilinear[OF assms, of "\<lambda>x y. (dest_vec1 x) *s y"] by auto
  3986   thus ?thesis using Lim_bilinear[OF assms, of "\<lambda>x y. (dest_vec1 x) *s y"] by auto
  3947 qed
  3987 qed
  3948 
  3988 
  3949 lemma Lim_vmul:
  3989 lemma Lim_vmul:
  3950  "((vec1 o c) ---> vec1 d) net ==> ((\<lambda>x. c(x) *s v) ---> d *s v) net"
  3990   fixes c :: "'a \<Rightarrow> real"
       
  3991   shows "((vec1 o c) ---> vec1 d) net ==> ((\<lambda>x. c(x) *s v) ---> d *s v) net"
  3951   using Lim_mul[of c d net "\<lambda>x. v" v] using Lim_const[of v] by auto
  3992   using Lim_mul[of c d net "\<lambda>x. v" v] using Lim_const[of v] by auto
  3952 
  3993 
  3953 lemma continuous_vmul:
  3994 lemma continuous_vmul:
  3954  "continuous net (vec1 o c) ==> continuous net (\<lambda>x. c(x) *s v)"
  3995   fixes c :: "'a \<Rightarrow> real"
       
  3996   shows "continuous net (vec1 o c) ==> continuous net (\<lambda>x. c(x) *s v)"
  3955   unfolding continuous_def using Lim_vmul[of c] by auto
  3997   unfolding continuous_def using Lim_vmul[of c] by auto
  3956 
  3998 
  3957 lemma continuous_mul:
  3999 lemma continuous_mul:
  3958  "continuous net (vec1 o c) \<Longrightarrow> continuous net f
  4000   fixes c :: "'a \<Rightarrow> real"
       
  4001   shows "continuous net (vec1 o c) \<Longrightarrow> continuous net f
  3959              ==> continuous net (\<lambda>x. c(x) *s f x) "
  4002              ==> continuous net (\<lambda>x. c(x) *s f x) "
  3960   unfolding continuous_def using Lim_mul[of c] by auto
  4003   unfolding continuous_def using Lim_mul[of c] by auto
  3961 
  4004 
  3962 lemma continuous_on_vmul:
  4005 lemma continuous_on_vmul:
  3963  "continuous_on s (vec1 o c) ==> continuous_on s (\<lambda>x. c(x) *s v)"
  4006  "continuous_on s (vec1 o c) ==> continuous_on s (\<lambda>x. c(x) *s v)"
  3969   unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto
  4012   unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto
  3970 
  4013 
  3971 text{* And so we have continuity of inverse.                                     *}
  4014 text{* And so we have continuity of inverse.                                     *}
  3972 
  4015 
  3973 lemma Lim_inv:
  4016 lemma Lim_inv:
       
  4017   fixes f :: "'a \<Rightarrow> real"
  3974   assumes "((vec1 o f) ---> vec1 l) (net::'a net)"  "l \<noteq> 0"
  4018   assumes "((vec1 o f) ---> vec1 l) (net::'a net)"  "l \<noteq> 0"
  3975   shows "((vec1 o inverse o f) ---> vec1(inverse l)) net"
  4019   shows "((vec1 o inverse o f) ---> vec1(inverse l)) net"
  3976 proof(cases "trivial_limit net")
  4020 proof(cases "trivial_limit net")
  3977   case True thus ?thesis unfolding tendsto_def unfolding eventually_def by auto
  4021   case True thus ?thesis unfolding tendsto_def unfolding eventually_def by auto
  3978 next
  4022 next
  4005       using y1 by auto  }
  4049       using y1 by auto  }
  4006   thus ?thesis unfolding tendsto_def eventually_def by auto
  4050   thus ?thesis unfolding tendsto_def eventually_def by auto
  4007 qed
  4051 qed
  4008 
  4052 
  4009 lemma continuous_inv:
  4053 lemma continuous_inv:
  4010  "continuous net (vec1 o f) \<Longrightarrow> f(netlimit net) \<noteq> 0
  4054   fixes f :: "'a \<Rightarrow> real"
       
  4055   shows "continuous net (vec1 o f) \<Longrightarrow> f(netlimit net) \<noteq> 0
  4011            ==> continuous net (vec1 o inverse o f)"
  4056            ==> continuous net (vec1 o inverse o f)"
  4012   unfolding continuous_def using Lim_inv by auto
  4057   unfolding continuous_def using Lim_inv by auto
  4013 
  4058 
  4014 lemma continuous_at_within_inv:
  4059 lemma continuous_at_within_inv:
       
  4060   fixes f :: "real ^ _ \<Rightarrow> real"
  4015   assumes "continuous (at a within s) (vec1 o f)" "f a \<noteq> 0"
  4061   assumes "continuous (at a within s) (vec1 o f)" "f a \<noteq> 0"
  4016   shows "continuous (at a within s) (vec1 o inverse o f)"
  4062   shows "continuous (at a within s) (vec1 o inverse o f)"
  4017 proof(cases "trivial_limit (at a within s)")
  4063 proof(cases "trivial_limit (at a within s)")
  4018   case True thus ?thesis unfolding continuous_def tendsto_def eventually_def by auto
  4064   case True thus ?thesis unfolding continuous_def tendsto_def eventually_def by auto
  4019 next
  4065 next
  4020   case False note cs = this
  4066   case False note cs = this
  4021   thus ?thesis using netlimit_within[OF cs] assms(2) continuous_inv[OF assms(1)] by auto
  4067   thus ?thesis using netlimit_within[OF cs] assms(2) continuous_inv[OF assms(1)] by auto
  4022 qed
  4068 qed
  4023 
  4069 
  4024 lemma continuous_at_inv:
  4070 lemma continuous_at_inv:
  4025  "continuous (at a) (vec1 o f) \<Longrightarrow> f a \<noteq> 0
  4071   fixes f :: "real ^ _ \<Rightarrow> real"
       
  4072   shows "continuous (at a) (vec1 o f) \<Longrightarrow> f a \<noteq> 0
  4026          ==> continuous (at a) (vec1 o inverse o f) "
  4073          ==> continuous (at a) (vec1 o inverse o f) "
  4027   using within_UNIV[THEN sym, of a] using continuous_at_within_inv[of a UNIV] by auto
  4074   using within_UNIV[THEN sym, of a] using continuous_at_within_inv[of a UNIV] by auto
  4028 
  4075 
  4029 subsection{* Preservation properties for pasted sets.                                  *}
  4076 subsection{* Preservation properties for pasted sets.                                  *}
  4030 
  4077