伊莎贝尔:莱布尼兹公式的问题

时间:2014-01-04 13:23:46

标签: matrix isabelle

据我了解,伊莎贝尔的矩阵本质上是功能和维度。在此设置中,定义平方矩阵( n x n 矩阵)并不容易。此外,在纸上的证明中,平方的尺寸“n”可用于证明。但我怎么在伊莎贝尔那样做呢?

莱布尼兹公式:

Leibniz formula

我在纸上的证明:

以下是我的Isabelle证明的相关摘录:

(* tested with Isabelle2013-2 (and also Isabelle2013-1) *)
theory Notepad
imports
  Main
  "~~/src/HOL/Library/Polynomial"
  "~~/src/HOL/Multivariate_Analysis/Determinants"
begin

notepad
begin
  fix C :: "('a::comm_ring_1 poly)^'n∷finite^'n∷finite"

  (* Definition Determinant (from the HOL Library, shown for reference
     see: "~~/src/HOL/Multivariate_Analysis/Determinants") *)
 have "det C =
      setsum (λp. of_int (sign p) * 
             setprod (λi. C$i$p i) (UNIV :: 'n set))
             {p. p permutes (UNIV :: 'n set)}" unfolding det_def by simp 

  (* assumtions *)
  have 1: "∀ i j. degree (C $ i $ j) ≤ 1" sorry (* from assumtions, not shown *)
  have 2: "∀ i. degree (C $ i $ i) = 1" sorry (* from assumtions, not shown *)

  (* don't have "n", that is the dimension of the squared matrix *)
  have "∀p∈{p. p permutes (UNIV :: 'n set)}. degree (setprod (λi. C$i$p i) (UNIV :: 'n set)) ≤ n" sorry (* no n! *)
end

在这种情况下我该怎么办?


更新

  

C的类型,('a ^'n ^'n)的受限制版本,似乎是>的自定义类型。你的,因为我在尝试使用它时遇到错误,即使在导入>之后Polynomial.thy。但也许它是在其他一些HOL理论中定义的。

不幸的是我没有在我的代码示例中编写包含,请参阅更新的示例。但它不是自定义类型,导入“Polynomial.thy”和“Determinants”就足够了。 (我测试了Isabelle版本2013-1和2013-2。)

  

如果您正在使用矩阵的自定义定义,那么很有可能   在大多数情况下,你是独立的。

我不相信我正在使用矩阵的自定义定义。 库Determinants(~~ / src / HOL / Multivariate_Analysis / Determinants)具有以下行列式定义:
definition det:: "'a::comm_ring_1^'n^'n ⇒ 'a" where ...。因此,库使用矩阵的概念作为向量的向量。如果我的戒指超过多项式,那么我的眼睛就不会有所作为。

  

无论如何,对于像('a ^'n ^'n)这样的类型,在我看来,你   应该能够写一个函数来返回一个大小的值   矩阵。因此,如果(p ^ n ^ n)是一个矩阵,其中n是一个集合,那么   也许n的基数是你想要的n。

这让我走上了正确的道路。我目前的猜测是以下定义是有用的:

definition card_diagonal :: "('a::zero poly)^'n^'n ⇒ nat" where "card_diagonal A = card { (A $ i $ i) | i . True }"

cardFinite_Set中定义。

2 个答案:

答案 0 :(得分:3)

更新140107_2040

这里很难做出简短的回答。我只为矢量工作,因为这一切都非常复杂。我尽可能快地给你一个矢量长度的函数。然后,我对我所做的事情进行了重大解释,以便对矢量类型有一个正确的理解,但不一定适合你,如果你不需要它。

由名称Finite_Cartesian_Product.thy反映,Amine Chaieb定义了广义有限笛卡尔积。所以,当然,我们也得到了向量和n元组的定义。它是一个广义的笛卡尔积,是需要大量解释的东西,也是我花了很长时间才能认识到并完成的。话虽如此,我将其称为向量,因为他将类型命名为vec

关于向量是什么需要理解一切,这是由这个定义定义的:

typedef ('a, 'b) vec = "UNIV :: (('b::finite) => 'a) set"

这告诉我们一个向量是一个函数f::('b::finite) => 'a。函数的域是UNIV::'b set,它是有限的,称为索引集。例如,让索引集定义为typedef{1,2,3}

函数的codomain可以是任何类型,但是它是一组常量{a,b},由typedef定义。由于HOL函数是完全的,{1,2,3}的每个元素都必须映射到{a,b}的元素。

现在,考虑将{1,2,3}中的元素映射到{a,b}的所有此类函数的集合。会有2^3 = 8个这样的功能。我现在使用ZFC函数表示法,以及n元组表示法:

f_1: {1,2,3} --> {a,b} == {(1,a),(2,a),(3,a)} == (a,a,a)
f_2 == {(1,a),(2,a),(3,b)} == (a,a,b)
f_3 == {(1,a),(2,b),(3,a)} == (a,b,a)
f_4 == {(1,a),(2,b),(3,b)} == (a,b,b)
f_5 to f_8 == (b,a,a), (b,a,b), (b,b,a), (b,b,b)

然后对于任何向量f_i,它又是一个函数,向量的长度将是f_i域的基数,它将是3。

我很确定你的函数card_diagonal是函数范围的基数,我测试了它的矢量版本,但它基本上向我展示了如何获得基数域名。

以下是矢量长度的函数:

definition vec_length :: "('a, 'b::finite) vec => nat" where
  "vec_length v = card {i. ? c. c = (vec_nth v) i}"
declare
  vec_length_def [simp add]

您可能希望将v $ i替换为(vec_nth v) i?\<exists>

在下面的示例中,simp方法很容易产生目标CARD(t123) = (3::nat),其中t123是我定义的类型,其中包含3个元素。我无法超越那个。

任何想要了解详细信息的人都需要了解在Rep_t创建类型Abs_t时创建的typedeft函数的使用情况。如果是vec,则函数将为Rep_vecAbs_vec,但会将morphisms重命名为vec_nthvec_lambda

非矢量特定矢量长度是否会前进

更新140111

这应该是我的最后更新,因为为了让我完全满意,我需要了解更多关于实例化类型类的更多信息,以及如何专门实例化类型类以便我的具体示例{{1} },是有限的。

我非常欢迎在我可能出错的地方纠正。我更愿意在教科书中阅读UNIV::t123 set,而不是像这样学习如何使用Isar和Isabelle / HOL。

从各方面来看,类型Multivariate_Analysis的向量长度的概念非常简单。它是('a, 'b) vec类型的通用集的基数。

直观地说,这是有道理的,所以我过早地承诺这个想法,但我不会永久承诺,因为我无法完成我的榜样。

我在我的调查结果中添加了更新&#34;理论如下。

我之前没有做过的是将我的示例类型'b::finite实例化,这是一个使用集合t123定义的类型,类型为类{c1,c2,c3}

较短的故事是,在追求top时,top向我提示我所涉及的类型类value,其中card_UNIV基于card_UNIV。同样,描述性标识符看起来如果我的类型finite_UNIV属于类t123,那么我可以使用finite_UNIV来计算它的基数,这将是任何向量的长度使用类型card作为索引集。

我在这里显示了一些术语,表明了所涉及的内容,如果你加载了我的示例理论,通常可以通过cntl点击各种标识符来调查这些术语。我的调查来源中有更多细节。

t123

(更新结束。)

140112 最终更新的最终更新

它付出了不是永久性的承诺,虽然回答问题是一种很好的学习方式,但在这种情况下也存在不利因素。

对于矢量类型,定义的唯一类型类是term "UNIV::t123 set" term "top::t123 set" term "card (UNIV::t123 set)" (*OUTPUT PANEL: CARD(t123)::nat.*) term "card (top::t123 set)" (*OUTPUT PANEL: CARD(t123)::nat.*) value "card (top::t123 set)" (*ERROR: Type t123 not of sort card_UNIV.*) term "card_UNIV" term "finite_UNIV" ,但在上面,我所做的涉及类型类finite,在finite_UNIV

尝试使用src/HOL/Library/Cardinality.thy,与card一样,不能使用card (UNIV::t123 set)类型,因为您无法假设类型类vec具有已针对索引集类型进行实例化。如果我现在对于现在看似显而易见的事情不对,我想知道。

好吧,即使我定义的函数finite_UNIV没有尝试直接取vector_length的基数,我的例子中,简化器生成目标UNIV::'b set

我推测这对我自己意味着什么,但我还没有找到CARD(t123) = (3::nat),所以我把自己的推测留给自己。

(更新结束。)

140117 决赛决赛

尝试使用CARD来了解value的使用让我误入歧途。 card命令基于代码生成器,value将具有一般不需要的类型类要求。

不要求为类型类value实例化索引集。只是能够使用finite_UNIV所需的逻辑必须到位。

对于我所做的任何事情,card (UNIV::('b::finite set))似乎已经存在逻辑。我所说的任何内容都会出错。

(更新结束。)

结论关于我的经验这里有多变量分析中的Multivariate_Analysis

使用广义索引集似乎过于复杂,至少对我而言。作为列表的矢量看起来像我想要的,就像Matrix.thy一样,但也许事情有时需要复杂。

最大的痛苦是使用vec创建一个具有有限通用集的类型。我不知道如何轻松创建有限集。我在过去看到一条评论说最好远离typedef。一开始听起来不错,它创建了一个基于集合的类型,但最终却很难处理。

[我在这里进一步评论typedef中使用的有限广义索引集。我不得不求助于ZFC定义,因为我不知道教科书在哪里用类型理论形式化普通数学。这篇wiki文章展示了一个广义的笛卡尔积:

Wiki: Infinite product definition using a finite or infinite index set

定义的关键是无限集可以用作索引集,例如实数。

至于使用有限集作为索引集,任何有限的基数集vec都可以与自然数n一对一,并且有限,自然数字排序通常是我们如何使用矢量。

并不是说我不相信有人,某个地方需要有限指数集的向量不是自然数,而是我在向量中看到的所有数学和矩阵是长度为1...nn::nat矩阵的向量。

对于我自己,我认为最好的向量和矩阵将基于n::nat x m::nat,因为列表的组件位置基于自然数。使用Isabelle / HOL list会带来很多计算魔法。]

我通过什么来获得上述

我花了很多时间来完成这项工作。我对如何使用Isabelle知之甚少。

list

我的答案的第一部分

(因为没有为来源显示进口,所以任何运营商的来源都不明显。还有Matrix AFP entry混淆了一些东西。除了HOL中的原子常数和变量之外,大多数东西都是函数,因此将某些东西归类为函数并不能在没有某些上下文的情况下澄清任何内容。提供不会产生错误的源会有所帮助。正常的切入点是(*It's much faster to start jEdit with Multivariate_Analysis as the logic.*) theory i140107a__Multvariate_Ana_vec_length imports Complex_Main Multivariate_Analysis (*"../../../iHelp/i"*) begin declare[[show_sorts=true]] (*Set false if you don't want typing shown.*) declare[[show_brackets=true]] (*---FINITE UNIVERSAL SET, NOT FINITE SET *) (* First, we need to understand what `x::('a::finite)` means. It means that `x` is a type for which the universal set of it's type is finite, where the universal set is `UNIV::('a set)`. It does not mean that terms of type `'a::finite` are finite sets. The use of `typedef` below will hopefully make this clear. The following are related to all of this, cntl-click on them to investigate them. *) term "x::('a::finite)" term "finite::('a set => bool)" (*the finite predicate*) term "UNIV::('a set) == top" (*UNIV is designated universal set in Set.thy.*) term "finite (UNIV :: 'a set)" term "finite (top :: 'a set)" (* It happens to be that the `finite` predicate is used in the definition of type class `finite`. Here are some pertinent snippets, after which I comment on them: class top = fixes top :: 'a ("⊤") abbreviation UNIV :: "'a set" where "UNIV == top" class finite = assumes finite_UNIV: "finite (UNIV :: 'a set)" The `assumes` in the `finite` type-class specifies that constant `top::'a set` is finite, where `top` can be seen as defined in type-class `top`. Thus, any type of type-class `top` must have a `top` constant. The constant `top` is in Orderings.thy, and the Orderings theory comes next after HOL.thy, which is fundamental. As to why this use of the constant `top` by type-class `finite` can make the universe of a type finite, I don't know. *) (*---DISCOVERING LOWER LEVEL SYNTAX TO WORK WITH *) (* From the output panel, I copied the type shown for `term "v::('a ^ 'b)"`. I then cntl-clicked on `vec` to take me to the `vec` definition. *) term "v::('a ^ 'b)" term "v::('a,'b::finite) vec" (* The `typedef` command defines the `('a, 'b) vec` type as an element of a particular set, in particular, as an element in the set of all functions of type `('b::finite) => 'a`. I rename `vec` to `vec2` so I can experiment with `vec2`. *) typedef ('a, 'b) vec2 = "UNIV :: (('b::finite) => 'a) set" by(auto) notation Rep_vec2 (infixl "$$" 90) (* The `morphisms` command renamed `Rep_vec` and `Abs_vec` to `vec_nth` and `vec_lambda`, but I don't rename them for `vec2`. To create the `vec_length` function, I'll be using the `Rep` function, which is `vec_nth` for `vec`. However, the `Abs` function comes into play further down with the concrete examples. It's used to coerce a function into a type that uses the type construcor `vec`. *) term "Rep_vec2::(('a, 'b::finite) vec2 => ('b::finite => 'a))" term "Abs_vec2::(('a::finite => 'b) => ('b, 'a::finite) vec2)" (*---FIGURING OUT HOW THE REP FUNCTION WORKS WITH 0, 1, OR 2 ARGS *) (* To figure it all out, I need to study these Rep_t function types. The type of terms without explicit typing have the type shown below them, with the appropriate `vec` or `vec2`. *) term "op $" term "vec_nth" term "op $$" term "Rep_vec2::(('a, 'b::finite) vec2 => ('b::finite => 'a))" term "op $ x" term "vec_nth x" term "op $$ x" term "(Rep_vec2 x)::('b::finite => 'a)" term "x $ i" term "op $ x i" term "vec_nth x i" term "x $$ i" term "op $$ x i" term "(Rep_vec2 (x::('a, 'b::finite) vec2) (i::('b::finite))) :: 'a" (* No brackets shows more clearly that `x $$ i` is the curried function `Rep_vec2` taking the arguments `x::(('a, 'b::finite) vec2)` and `i::('b::finite)`. *) term "Rep_vec2::('a, 'b::finite) vec2 => 'b::finite => 'a" (*---THE FUNCTION FOR THE LENGTH OF A VECTOR*) (* This is based on your `card_diagonal`, but it's `card` of the range of `vec_nth v`. You want `card` of the domain. *) theorem "{ (v $ i) | i. True } = {c. ? i. c = (v $ i)}" by(simp) definition range_size :: "('a, 'b::finite) vec => nat" where "range_size v = card {c. ? i. c = (v $ i)}" declare range_size_def [simp add] (* This is the card of the domain of `(vec_nth v)::('b::finite => 'a)`. I use `vec_nth v` just to emphasize that what we want is `card` of the domain. *) theorem "(vec_nth v) i = (v $ i)" by(simp) definition vec_length :: "('a, 'b::finite) vec => nat" where "vec_length v = card {i. ? c. c = (vec_nth v) i}" declare vec_length_def [simp add] theorem "∀x y. vec_length (x::('a, 'b) vec) = vec_length (y::('a, 'b::finite) vec)" by(simp) (*---EXAMPLES TO TEST THINGS OUT *) (* Creating some constants. *) typedecl cT consts c1::cT c2::cT c3::cT (* Creating a type using the set {c1,c2,c3}. *) typedef t123 = "{c1,c2,c3}" by(auto) (* The functions Abs_t123 and Rep_t123 are created. I have to use Abs_t123 below to coerce the type of `cT` to `t123`. Here, I show the type of `Abs_t123`. *) term "Abs_t123 :: (cT => t123)" term "Abs_t123 c1 :: t123" (* Use these `declare` commands to do automatic `Abs` coercion. I comment them out to show how I do coercions explicitly. *) (*declare [[coercion_enabled]]*) (*declare [[coercion Abs_t123]]*) (* I have to instantiate type `t123` as type-class `finite`. It seems it should be simple to prove, but I can't prove it, so I use `sorry`. *) instantiation t123 :: finite begin instance sorry end term "UNIV::t123 set" term "card (UNIV::t123 set)" theorem "card (UNIV::t123 set) = 3" try0 oops (* Generalized vectors use an index set, in this case `{c1,c2,c3}`. A vector is an element from the set `(('b::finite) => 'a) set`. Concretely, my vectors are going to be from the set `(t123 => nat) set`. I define a vector by defining a function `t123_to_0`. Using normal vector notation, it is the vector `<0,0,0>`. Using ZFC ordered pair function notation, it is the set {(c1,0),(c2,0),(c3,0)}. *) definition t123_to_0 :: "t123 => nat" where "t123_to_0 x = 0" declare t123_to_0_def [simp add] (* I'm going to have to use `vec_lambda`, `vec_nth`, and `Abs_t123`, so I create some `term` variations to look at types in the output panel, to try to figure out how to mix and match functions and arguments. *) term "vec_lambda (f::('a::finite => 'b)) :: ('b, 'a::finite) vec" term "vec_lambda t123_to_0 :: (nat, t123) vec" term "vec_nth (vec_lambda t123_to_0)" term "vec_nth (vec_lambda t123_to_0) (Abs_t123 c1)" (* The function `vec_length` seems to work. You'd think that `CARD(t123) = 3` would be true. I try to cntl-click on `CARD`, but it doesn't work. *) theorem "vec_length (vec_lambda t123_to_0) = (3::nat)" apply(simp) (*GOAL: (CARD(t123) = (3::nat))*) oops theorem "(vec_nth (vec_lambda t123_to_0) (Abs_t123 c1)) = (0::nat)" by(auto) theorem "range_size (vec_lambda t123_to_0) = (1::nat)" by(auto) definition t123_to_x :: "t123 => t123" where "t123_to_x x = x" declare t123_to_x_def [simp add] theorem "(vec_nth (vec_lambda t123_to_x) (Abs_t123 c1)) = (Abs_t123 c1)" by(auto) theorem "(vec_nth (vec_lambda t123_to_x) (Abs_t123 c2)) = (Abs_t123 c2)" by(auto) (*THE LENGTH BASED SOLELY ON THE TYPE, NOT ON A PARTICULAR VECTOR *) (*Update 140111: The length of a vector is going to be the cardinality of the universal set of the type, `UNIV::('a::finite set)`. For `t123`, the following terms are involved. *) term "UNIV::t123 set" term "top::t123 set" term "card (UNIV::t123 set)" (*OUTPUT PANEL: CARD(t123)::nat.*) term "card (top::t123 set)" (*OUTPUT PANEL: CARD(t123)::nat.*) (* It can be seen that `card (top::t123 set)` is the same as the theorem above with the goal `CARD(t123) = (3::nat)`. What I didn't do above is instantiate type `t123` for type-class `top`. I try to define `top_t123`, but it gives me an error. *) instantiation t123 :: top begin definition top_t123 :: "t123 set" where "top_t123 = {Abs_t123 c1, Abs_t123 c2, Abs_t123 c3}" (*ERROR Clash of specifications "i140107a__Multvariate_Ana_vec_length.top_set_inst.top_set_def" and "Set.top_set_inst.top_set_def" for constant "Orderings.top_class.top" *) instance sorry end (*To define the cardinality of type `t123` appears to be an involved process, but maybe there's one easy type-class that can be instantiated that gives me everything I need. The use of `value` shows that type `t123` needs to be type-class `card_UNIV`, but `card_UNIV` is based on class `finite_UNIV`. Understanding it all is involved enough to give job security to a person who does understand it. *) value "card (top::t123 set)" (*ERROR: Type t123 not of sort card_UNIV.*) term "card_UNIV" term "finite_UNIV" (******************************************************************************) end 。这总结了我在这里所说的大部分内容。)

相关问题的链接

[13-05-27] Isabelle: how to work with matrices

[13-05-30] Isabelle: transpose a matrix that includes a constant factor

[13-06-25] Isabelle matrix arithmetic: det_linear_row_setsum in library with different notation

[13-08-12] Isabelle: maximum value in a vector

[13-09-12] Degree of polynomial smaller than a number

[13-11-21] Isabelle: degree of polynomial multiplied with constant

[13-11-26] Isabelle: Power of a matrix (A^n)?

[13-12-01] Isabelle: difference between A * 1 and A ** mat 1

[14-01-17] Isabelle: Issue with setprod

答案 1 :(得分:3)

在我看来,这个问题的本质是如何从给定的n×n矩阵A中获得整数n。这里的难点是这个整数用A的类型编码。然而,我似乎很清楚,n实际上是问题的一个参数。虽然我们可以想象矩阵的表示以某种方式在内部存储维度,但从数学的角度来看,通过声明“让n为正整数”来开始整个开发是很自然的。