proof

Prove map id = id in idris?

落花浮王杯 提交于 2019-12-01 14:35:57
问题 I'm just starting playing with idris and theorem proving in general. I can follow most of the examples of proofs of basic facts on the internet, so I wanted to try something arbitrary by my own. So, I want to write a proof term for the following basic property of map: map : (a -> b) -> List a -> List b prf : map id = id Intuitively, I can imagine how the proof should work: Take an arbitrary list l and analyze the possibilities for map id l. When l is empty, it's obvious; when l is non-empty

Coq rewriting using lambda arguments

早过忘川 提交于 2019-12-01 13:00:29
We have a function that inserts an element into a specific index of a list. Fixpoint inject_into {A} (x : A) (l : list A) (n : nat) : option (list A) := match n, l with | 0, _ => Some (x :: l) | S k, [] => None | S k, h :: t => let kwa := inject_into x t k in match kwa with | None => None | Some l' => Some (h :: l') end end. The following property of the aforementioned function is of relevance to the problem (proof omitted, straightforward induction on l with n not being fixed): Theorem inject_correct_index : forall A x (l : list A) n, n <= length l -> exists l', inject_into x l n = Some l'.

Coq rewriting using lambda arguments

丶灬走出姿态 提交于 2019-12-01 07:30:11
问题 We have a function that inserts an element into a specific index of a list. Fixpoint inject_into {A} (x : A) (l : list A) (n : nat) : option (list A) := match n, l with | 0, _ => Some (x :: l) | S k, [] => None | S k, h :: t => let kwa := inject_into x t k in match kwa with | None => None | Some l' => Some (h :: l') end end. The following property of the aforementioned function is of relevance to the problem (proof omitted, straightforward induction on l with n not being fixed): Theorem

Which vector library to use in coq?

若如初见. 提交于 2019-12-01 06:13:20
I'm wondering, is there a commonly used library for vectors in coq, I.e. lists indexed by their length in their type. Some tutorials reference Bvector, but it's not found when I try to import it. There's Coq.Vectors.Vectordef, but the type defined there is just named t which makes me think it's intended for internal use. What is the best or most common practice for someone who doesn't want to roll their own library? Am I wrong about the vectors in the standard library? Or is there another Lib I'm missing? Or do people just use lists, paired with proofs of their length? There are generally

Which vector library to use in coq?

好久不见. 提交于 2019-12-01 05:12:07
问题 I'm wondering, is there a commonly used library for vectors in coq, I.e. lists indexed by their length in their type. Some tutorials reference Bvector, but it's not found when I try to import it. There's Coq.Vectors.Vectordef, but the type defined there is just named t which makes me think it's intended for internal use. What is the best or most common practice for someone who doesn't want to roll their own library? Am I wrong about the vectors in the standard library? Or is there another Lib

Using Ogden’s Lemma versus regular Pumping Lemma for Context-Free Grammars

落花浮王杯 提交于 2019-12-01 01:35:34
问题 I'm learning the difference between the lemmata in the question. Every reference I can find uses the example: {(a^i)(b^j)(c^k)(d^l) : i = 0 or j = k = l} to show the difference between the two. I can find an example using the regular lemma to "disprove" it. Select w = uvxyz, s.t. |vy| > 0, |vxy| <= p. Suppose w contains an equal number of b's, c's, d's. I selected: u,v,x = ε y = (the string of a's) z = (the rest of the string w) Pumping y will just add to the number of a's, and if |b|=|c|=|d|

Context Free Language Question (Pumping Lemma)

风格不统一 提交于 2019-12-01 00:57:00
问题 I know this isn't directly related to programming, but I was wondering if anyone know how to apply the pumping lemma to the following proof: Show that L={(a^n)(b^n)(c^m) : n!=m} is not a context free language I'm pretty confident with applying pumping lemmas, but this one is really irking me. What do you think? 回答1: Edit: I was totally leading you down the wrong track. That's what happens when I try to help out when I haven't completely solved the problem myself. Ogden's Lemma Suppose L is

Why Coq doesn't allow inversion, destruct, etc. when the goal is a Type?

若如初见. 提交于 2019-11-30 14:07:06
When refine ing a program, I tried to end proof by inversion on a False hypothesis when the goal was a Type . Here is a reduced version of the proof I tried to do. Lemma strange1: forall T:Type, 0>0 -> T. intros T H. inversion H. (* Coq refuses inversion on 'H : 0 > 0' *) Coq complained Error: Inversion would require case analysis on sort Type which is not allowed for inductive definition le However, since I do nothing with T , it shouldn't matter, ... or ? I got rid of the T like this, and the proof went through: Lemma ex_falso: forall T:Type, False -> T. inversion 1. Qed. Lemma strange2:

I need help proving that if f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n)))

我的梦境 提交于 2019-11-30 07:04:54
In a previous problem, I showed (hopefully correctly) that f(n) = O(g(n)) implies lg(f(n)) = O(lg(g(n))) with sufficient conditions (e.g., lg(g(n)) >= 1, f(n) >= 1 , and sufficiently large n). Now, I need to prove OR disprove that f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n))) . Intuitively, this makes sense, so I figured I could prove it with help from the previous theorem. I noticed that f(n) can be rewritten as lg(2^f(n)) and that g(n) is just lg(2^g(n)) , which got me excited...this is taking the log base 2 of both sides of what I want to prove, and it simplifies things a lot! But I'm pretty

I need help proving that if f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n)))

China☆狼群 提交于 2019-11-29 08:40:23
问题 In a previous problem, I showed (hopefully correctly) that f(n) = O(g(n)) implies lg(f(n)) = O(lg(g(n))) with sufficient conditions (e.g., lg(g(n)) >= 1, f(n) >= 1 , and sufficiently large n). Now, I need to prove OR disprove that f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n))) . Intuitively, this makes sense, so I figured I could prove it with help from the previous theorem. I noticed that f(n) can be rewritten as lg(2^f(n)) and that g(n) is just lg(2^g(n)) , which got me excited...this is