I was wondering whether Coq defined the real numbers as Cauchy sequences or Dedekind cuts, so I checked Coq.Reals.Raxioms and... none of these two. The real numbers are axiomatized, along with their operations (as Parameter
s and Axiom
s). Why is it so?
Also, the real numbers tightly rely on the notion of subset, since one of their defining properties is that is every upper bounded subset has a least upper bound. The Axiom completeness
encodes those subsets as Prop …
在https://www.cs.umd.edu/~rrand/vqc/Real.html#lab1中可以阅读:
\n\n\nCoq 的标准库对实数采用了一种非常不同的方法:公理化方法。
\n
并且可以找到以下公理:
\nAxiom\n completeness :\n \xe2\x88\x80E:R \xe2\x86\x92 Prop,\n bound E \xe2\x86\x92 (\xe2\x88\x83x : R, E x) \xe2\x86\x92 { m:R | is_lub E m }.\n
Run Code Online (Sandbox Code Playgroud)\n但在《为什么实数在 Coq 中公理化?》中没有提到该库。人们可以找到相同的描述:
\n\n\n我想知道 Coq 是否将实数定义为柯西序列或 Dedekind 切割,所以我检查了 Coq.Reals.Raxioms ......这两个都不是。实数及其运算(作为参数和公理)被公理化。为什么会这样呢?
\n
\n\n此外,实数紧密依赖于子集的概念,因为它们的定义属性之一是每个上界子集都有一个最小上限。Axiom 完整性将这些子集编码为 Props。”
\n
尽管如此,每当我查看https://coq.inria.fr/library/Coq.Reals.Raxioms.html时,我都没有看到任何公理化方法,特别是我们有以下引理:
\nLemma completeness :\n forall E:R -> Prop,\n bound E -> (exists x : R, E x) …
Run Code Online (Sandbox Code Playgroud) 我只是想知道如何为实数定义"小于"关系.
我理解,对于自然数(nat
),<
可以用一个数字作为另一个数字的(1+
)后继者递归地定义S
.我听说很多关于实数的事情在Coq中是公理化的而且没有计算.
但我想知道Coq中的实数是否存在最小公理集,基于哪些属性/关系可以导出.(例如 Coq.Reals.RIneq让它Rplus_0_r : forall r, r + 0 = r.
成为公理,等等)
特别是,我很感兴趣,是否如关系<
或<=
可以在平等关系的顶部进行定义.例如,我可以想象在常规数学中,给出两个数字r1 r2
:
r1 < r2 <=> exists s, s > 0 /\ r1 + s = r2.
Run Code Online (Sandbox Code Playgroud)
但这是否符合Coq的建设性逻辑?我是否可以用它来至少对不平等做一些推理(而不是一直重写公理)?
我不太确定什么是 Java 时期的正确正则表达式。这是我的一些尝试。可悲的是,它们都意味着任何角色。
String regex = "[0-9]*[.]?[0-9]*";
String regex = "[0-9]*['.']?[0-9]*";
String regex = "[0-9]*["."]?[0-9]*";
String regex = "[0-9]*[\.]?[0-9]*";
String regex = "[0-9]*[\\.]?[0-9]*";
String regex = "[0-9]*.?[0-9]*";
String regex = "[0-9]*\.?[0-9]*";
String regex = "[0-9]*\\.?[0-9]*";
Run Code Online (Sandbox Code Playgroud)
但我想要的是实际的“。” 性格本身。有人有想法吗?
我实际上想要做的是写出非负实数(允许小数)的正则表达式。所以可能性是:12.2, 3.7, 2., 0.3, .89, 19
String regex = "[0-9]*['.']?[0-9]*";
Pattern pattern = Pattern.compile(regex);
String x = "5p4";
Matcher matcher = pattern.matcher(x);
System.out.println(matcher.find());
Run Code Online (Sandbox Code Playgroud)
最后一行应该打印 false 但无论如何打印 true。我认为我的正则表达式是错误的。
我正在读一本书.在书中写道 -
浮点加法满足以下单调特性:
如果a>=b
再(x + a) >= (x+b)
对任何价值a
,b
和x
其他比NaN
.无符号或二进制补码的加法不符合实数(和整数)加法的这一性质.
浮点如何服从它?
为什么无符号或两个补码不符合它?
c floating-point twos-complement unsigned-integer real-number
有没有办法自动证明简单的不等式,例如1/2 >= 0
?,即
Require Export Coq.Reals.RIneq.
Local Open Scope Z_scope.
Local Open Scope R_scope.
Example test: /2 >= 0.
Run Code Online (Sandbox Code Playgroud)
ring
我对或没有太多经验field
,甚至在证明诸如 之类的简单等式时都遇到困难1/2 = 2/4
。
我正在寻找类似omega
但适用于实数和不等式的东西。
假设我们有这样的事情:
假设x是实数.证明如果存在实数y,使得(y + 1)/(y-2)= x,则x <> 1".
如果以一种显而易见的方式制定它:forall x : R, (exists y, ((y + 1) * / (y - 2)) = x) -> x <> 1
一个人很快遇到问题.
我们假设存在y
这样的情况((y + 1) * / (y - 2)) = x)
.我错误地认为这也应该暗示这一点y <> 2
吗?有没有办法在Coq中恢复这些信息?
当然,如果y
存在,那么它不是2.如何在Coq中恢复这些信息 - 我是否需要明确地假设它(也就是说,无法以某种方式通过存在实例化来恢复它?).
当然,destruct H as [y]
只是给我们((y + 1) * / (y - 2)) = x)
了y : R
,但现在我们不知道y <> 2
.
我需要在小数点之前的整数部分中使用前导零格式化实数.我知道如何使用整数实现这一点,但实际的语法让我感到厌烦.
Number := 1.234 ;
SNumber := Format ('%2.3f', [Number]) ;
Run Code Online (Sandbox Code Playgroud)
这给了SNumber = ' 1.234'
但我想要'01.234'
. Number
永远是0..99.999
这是Coq标准库中定义的完整性公理.
Definition is_upper_bound (E:R -> Prop) (m:R) := forall x:R, E x -> x <= m.
Definition bound (E:R -> Prop) := exists m : R, is_upper_bound E m.
Definition is_lub (E:R -> Prop) (m:R) :=
is_upper_bound E m /\ (forall b:R, is_upper_bound E b -> m <= b).
Axiom completeness :
forall E:R -> Prop,
bound E -> (exists x : R, E x) -> { m:R | is_lub E m }.
Run Code Online (Sandbox Code Playgroud)
假设我加入
Axiom supremum :forall E:R -> Prop, …
Run Code Online (Sandbox Code Playgroud) 我已经安装了虞美人上mathcomp/SSreflect的顶部.
即使我还没有掌握标准Coq,我想用它进行非常基本的实际分析.
这是我的第一个引理:
Definition fsquare (x : R) : R := x ^ 2.
Lemma deriv_x2 : forall y, is_derive (fsquare) y (2 * y).
Run Code Online (Sandbox Code Playgroud)
is_derive f x0 f'
是一个Coquelicot Prop,它说明了函数的导数f at x0 is f'
.
由于auto_derive
Coquelicot提供的策略,我已经证明了这个引理.
如果我想让我的手有点脏,这是我的尝试没有auto_derive
:
Lemma deriv_x2 : forall y, is_derive (fsquare) y (2 * y).
Proof.
move => y.
unfold fsquare.
evar_last.
apply is_derive_pow.
apply is_derive_id.
simpl.
Run Code Online (Sandbox Code Playgroud)
而现在我对这个未决的判决感到困惑:
1 subgoal
y : R_AbsRing
______________________________________(1/1)
2 * one * (y …
Run Code Online (Sandbox Code Playgroud) 我正在尝试检查字符串变量的值是否为双精度。
\n\n我已经看到这个现有问题(检查变量是否为双精度数据类型)及其答案,它们很棒,但我有一个不同的问题。
\n\npublic static bool IsDouble(string ValueToTest) \n {\n double Test;\n bool OutPut;\n OutPut = double.TryParse(ValueToTest, out Test);\n return OutPut;\n }\n
Run Code Online (Sandbox Code Playgroud)\n\n从上面的代码中,当 ValueToTest 为“-\xe2\x88\x9e”时,变量 Test 中得到的输出为“-Infinity”,并且该方法返回 true。
\n\n当 ValueToTest 为“NaN”时,我得到的输出为“NaN”。
\n\n它们都是 C# 中的“-\xe2\x88\x9e”和“NaN”双精度值吗?
\n\n还有一种方法可以仅检查实数(https://en.wikipedia.org/wiki/Real_number)并排除无穷大和 NaN?
\nreal-number ×11
coq ×7
automation ×1
c ×1
c# ×1
delphi ×1
double ×1
formatting ×1
inequality ×1
java ×1
regex ×1
string ×1