proof

In Coq, which tactic to change the goal from `S x = S y` to `x = y`

こ雲淡風輕ζ 提交于 2020-01-02 07:03:10
问题 I want to change the goal from S x = S y to x = y . It's like inversion , but for the goal instead of a hypothesis. Such a tactic seems legit, because when we have x = y , we can simply use rewrite and reflexivity to prove the goal. Currently I always find myself using assert (x = y) to introduce a new subgoal, but it's tedious to write when x and y are complex expression. 回答1: The tactic apply f_equal. will do what you want, for any constructor or function. The lema f_equal shows that for

Proof that a binary tree with n leaves has a height of at least log n

≡放荡痞女 提交于 2020-01-01 03:34:08
问题 I've been able to create a proof that shows the maximum total nodes in a tree is equal to n = 2^(h+1) - 1 and logically I know that the height of a binary tree is log n (can draw it out to see) but I'm having trouble constructing a formal proof to show that a tree with n leaves has "at least" log n. Every proof I've come across or been able to put together always deals with perfect binary trees, but I need something for any situation. Any tips to lead me in the right direction? 回答1: Lemma :

Should code be short/concise? [closed]

ぐ巨炮叔叔 提交于 2019-12-31 10:41:51
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . When writing a mathematical proof, one goal is to continue compressing the proof. The proof gets more elegant but not necessarily more readable. Compression translates to better understanding, as you weed out unnecessary characters and verbosity. I often hear developers say

How or is that possible to prove or falsify `forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q.` in Coq?

眉间皱痕 提交于 2019-12-28 18:04:06
问题 I want to prove or falsify forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq. Here is my approach. Inductive True2 : Prop := | One : True2 | Two : True2. Lemma True_has_one : forall (t0 t1 : True), t0 = t1. Proof. intros. destruct t0. destruct t1. reflexivity. Qed. Lemma not_True2_has_one : (forall (t0 t1 : True2), t0 = t1) -> False. Proof. intros. specialize (H One Two). inversion H. But, inversion H does nothing. I think maybe it's because the coq's proof independence (I'm not a

Prove how the algorithm works

孤者浪人 提交于 2019-12-25 20:49:11
问题 Given the pseudocode MUL(a,b) x=a y=0 WHILE x>=b DO x=x-b y=y+1 IF x=0 THEN RETURN(true) ELSE RETURN(false) I have to prove how the algorithm works. So far I have only explained how it works, but I am not sure how you are supposed to prove how it works. Edit: Just to clarify. I did ask this question on another thread. But the two questions are separate. The assignment I am working on consists of 3 questions. The 1st question is where I explained how the algorithm works. The 2nd question is on

Failed to refine any pending goal

让人想犯罪 __ 提交于 2019-12-24 11:44:33
问题 I am trying to prove a theorem in Isabelle and I am stuck in this step: theorem exists_prime_factor: " (n > Suc 0) ⟶ (∃xs::nat list. prod_list xs = n ∧ all_prime xs)" proof (induct n rule: less_induct) case (less k) assume HI: "⋀y::nat. (y < k ⟹ Suc 0 < y ⟶ (∃xs. prod_list xs = y ∧ all_prime xs))" then show ?case proof - show "(Suc 0 < k) ⟶ (∃xs. prod_list xs = k ∧ all_prime xs)" proof - assume "Suc 0 < k" then show "(∃xs. prod_list xs = k ∧ all_prime xs)" sorry In the last goal I need to

Proof time complexity

心已入冬 提交于 2019-12-24 09:29:08
问题 I'm trying to determine the complexity of this two functions, where D in an integer and list is a list of integers: def solve(D, list): for element in List: doFunc(element, D, list) def doFunc(element, D, list): quantityx = 0 if(D > 0): for otherElement in list: if otherElement == element: quantityx += 1 return quantityx + (doFunc ((element+1), (D-1), list)) return 0 Intuitively, I think it has a O(n²) where n is the quantity of elements of list, but I'd like to proof it in a formal way. 回答1:

isabelle proving commutativity for add

被刻印的时光 ゝ 提交于 2019-12-23 14:56:11
问题 Im trying to prove commutativity in Isabelle/HOL for a self-defined add function. I managed to prove associativity but I'm stuck on this. The definition of add : fun add :: "nat ⇒ nat ⇒ nat" where "add 0 n = n" | "add (Suc m) n = Suc(add m n)" The proof of associativity: lemma add_Associative: "add(add k m) z = add k (add m z)" apply(induction k) apply(auto) done The proof of commutativity: theorem add_commutativity: "add k m = add m k" apply(induction k) apply(induction m) apply(auto) I get

String to string correction problem np-completeness proof

﹥>﹥吖頭↗ 提交于 2019-12-23 05:08:19
问题 I have this assignment to prove that this problem: Finite alphabet £, two strings x,y € £*, and a positive integer K. Is there a way to derive the string y from the string x by a sequence of K or fewer operations of single symbol deletion or adjacent symbol interchange? is np-complete. I already figured out I have to make transformation from decision version of set covering problem, but I have no clue how to do this. Any help would be appreciated. 回答1: It looks like modified Levenshtein

Membership proofs for AVL trees

北战南征 提交于 2019-12-23 03:44:09
问题 I'm struggling a little to come up with a notion of membership proof for Data.AVL trees. I would like to be able to pass around a value of type n ∈ m , to mean that n appears as a key in in the AVL tree, so that given such a proof, get n m can always successfully yield a value associated with n. You can assume my AVL trees always contain values drawn from a join semilattice (A, ∨, ⊥) over a setoid (A, ≈), although below the idempotence is left implicit. module Temp where open import Algebra