Isabelle: degree of polynomial multiplied with constant

一笑奈何 提交于 2019-12-10 12:13:02

问题


I am working with the library HOL/Library/Polynomial.thy.

A simple property didn't work. E.g., the degree of 2x *2 is equal to the degree of 2x-

How can I prove the lemmas (i.e., remove "sorry"):

lemma mylemma:
    fixes y ::  "('a::comm_ring_1 poly)" and x ::  "('a::comm_ring_1)"
    shows "1 = 1" (* dummy *)
 proof- 
 have "⋀ x. degree [: x :] = 0" by simp

 from this have "⋀ x y. degree (y * [: x :] ) = degree y" sorry

 (* different notation: *)
 from this have "⋀ x y. degree (y * (CONST pCons x 0)) = degree y" sorry

.

From Manuel's answer, the solution I was looking for:

 have 1: "⋀ x. degree [: x :] = 0" by simp
 {
   fix y :: "('a::comm_ring_1 poly)" and x :: "('a::comm_ring_1)"
   from 1 have "degree (y * [: x :]) ≤ degree y"
   by (metis Nat.add_0_right degree_mult_le)
 } 

回答1:


There are a number of issues here.

First of all, the statement you are trying to show simply does not hold for all x. If x = 0 and y is nonconstant, e.g. y = [:0,1:], you have

degree (y * [: x :]) = degree 0 = 0 ≠ 1 = degree y

The obvious way to fix this is to assume x ≠ 0.

However, this is not sufficient either, since you only assumed 'a to be a commutative ring. However, in a commutative ring, in general, you can have zero divisors. Consider the commutative ring ℤ/4ℤ. Let x = 2 and y = [:0,2:]. Then y * [:x:] = [:0,4:], but 4 = 0 in ℤ/4ℤ. Therefore y * [:x:] = 0, and therefore, again,

degree (y * [: x :]) = degree 0 = 0 ≠ 1 = degree y

So, what you really need is one of the following two:

  1. the assumption x ≠ 0 and 'a::idom instead of 'a::comm_ring. idom stands for “integral domain” and, that is simply a commutative ring with a 1 and without zero divisors
  2. more generally, the assumption that x is not a zero divisor
  3. even more generally, the assumption that x * y ≠ 0 or, equivalently, x times the leading coefficient of y is not 0

Also, the usage of ⋀ in Isar proofs is somewhat problematic at times. The “proper“ Isar way of doing this would be:

fix x :: "'a::idom" and y :: "'a poly"
assume "x ≠ 0"
hence "degree (y * [:x:]) = degree y" by simp

The relevant lemmas are degree_mult_eq and degree_smult_eq, you will see that they require the coefficient type to be an idom. This works for the first case I described above, the other two will require some more manual reasoning, I think.

EDIT: just a small hint: you can find theorems like this by typing

find_theorems "degree (_ * _)"

If you try to apply the degree_mult_eq it shows to your situation (with comm_ring), you will find that it fails, even though the terms seem to match. If that is the case, it is usually a type issue, so you can write something like

from [[show_sorts]] degree_mult_eq

to see what the types and sorts required by the lemma are, and it says idom.



来源:https://stackoverflow.com/questions/20129018/isabelle-degree-of-polynomial-multiplied-with-constant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!