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

Matrix 伊莎贝尔:莱布尼兹公式的问题,matrix,isabelle,Matrix,Isabelle,据我所知,Isabelle中的矩阵本质上是函数和任意维。在此设置中,定义平方矩阵(nxn矩阵)并不容易。此外,在纸上证明中,可以使用平方的尺寸“n”进行证明。但在伊莎贝尔身上我该怎么做 莱布尼兹公式: 我的书面证明: 以下是我的伊莎贝尔证据的相关摘录: (* tested with Isabelle2013-2 (and also Isabelle2013-1) *) theory Notepad imports Main "~~/src/HOL/Library/Polynomial

据我所知,Isabelle中的矩阵本质上是函数和任意维。在此设置中,定义平方矩阵(nxn矩阵)并不容易。此外,在纸上证明中,可以使用平方的尺寸“n”进行证明。但在伊莎贝尔身上我该怎么做

莱布尼兹公式:

我的书面证明:

以下是我的伊莎贝尔证据的相关摘录:

(* 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)的受限版本,似乎是>您的自定义类型,因为我在尝试使用它时出错,即使在导入>polymone.thy之后也是如此。但也许它是在其他理论中定义的

不幸的是,我没有在我的代码示例中编写include,请参阅更新的示例。但它不是一个自定义类型,导入“polymonal.thy”和“determinators”就足够了。(我测试了伊莎贝尔2013-1版和2013-2版。)

如果您使用的是矩阵的自定义定义,那么很有可能 大部分情况下,你只能靠自己

我不相信我在使用矩阵的自定义定义。 库
行列式
(~~~/src/HOL/multivariable\u Analysis/determinaters)具有以下行列式定义:
定义数据::“'a::通信环1^'n^'n⇒ '一个“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 }"

有限集
中定义

更新140107\u 2040

在这里很难做出简短的回答。我只为向量工作,因为这一切都非常复杂。我试着尽可能快地给出向量长度的函数。然后我会详细解释我是如何理解向量类型的,但如果你不需要的话,不一定要解释给你

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

一切都需要根据向量的定义来理解,向量的定义如下:

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

函数的密码域可以是任何类型,但让它成为一组常量
{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\n v)i
\

在下面的示例中,
simp
方法很容易生成一个目标
卡(t123)=(3::nat)
,其中
t123
是我定义的一个类型,其中包含3个元素。我过不了那关

任何想要了解详细信息的人都需要了解使用
typedef
创建类型
t
时创建的
Rep\u t
Abs\u t
函数的用法。在
vec
的情况下,函数应该是
Rep_-vec
Abs_-vec
,但它们被重命名为
morphisms
vec-nth
vec-lambda

请将非特定矢量的矢量长度向前一步 更新140111

这应该是我的最后一次更新,因为为了完全满足我的要求,我需要更多地了解一般类型类的实例化,以及如何具体实例化类型类,以便我的具体示例,
UNIV::t123 set
,是有限的

我非常欢迎在我可能错的地方被纠正。我宁愿在教科书中阅读有关多元分析的内容,也不愿像这样学习如何使用Isar和Isabelle/HOL

显然,类型为
('a,'b)vec
的向量长度的概念非常简单。它是
'b::finite
类型的通用集的基数

直觉上,这是有道理的,所以我过早地对这个想法做出承诺,但我不会永久地做出承诺,因为我无法完成我的示例

我在下面的“调查”理论末尾添加了一个更新

我以前没有做的是实例化我的示例类型
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"
(*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