proof

Applying hypotesis to a variable

孤者浪人 提交于 2019-12-11 11:48:11
问题 Let's say I'm in the middle of a proof and I have hypotheses like these: a : nat b : nat c : nat H : somePred a b and the definition of somePred says: Definition somePred (p:nat) (q:nat) : Prop := forall (x : nat), P(x, p, q). How do I apply H to c and to get P(c, a, b) ? 回答1: The answer is: specialize H with c. 来源: https://stackoverflow.com/questions/29316168/applying-hypotesis-to-a-variable

Proven correct receipt module

匆匆过客 提交于 2019-12-11 08:21:40
问题 I'm working on a register which produces receipts when customers buy articles. As an exercise, I'm thinking about making a receipt module in Coq which cannot produce erroneous receipts. In short, the articles and the payments on the receipt should always sum to 0 (where articles have price > 0 and payments have amount < 0). Is this doable, or sensible? To do a quick sketch, a receipt would consist of receipt items and payments, like type receipt = { items : item list; payments : payment list

Z3Py: Generating Abstract Formulas From A System Of Equations

喜欢而已 提交于 2019-12-11 07:32:40
问题 My Example: system of equations Pseudo-Code Constraint Base a = b+c ∧ e = a*c ∧ a = +2 ; some replaceable concrete values ∧ c = +18 Solution b = -16 ∧ e = -32 The Information I Want In a system of equations, I want to get the following knowledge: Abstract formulas which I can use to compute the variable values (the solution) from the given values (in the constraint base). (Like in high school where the teacher don't just wanted the see the result, but also such an transformated abstract

How could I prove this type level Haskell theorem?

北城以北 提交于 2019-12-11 04:13:30
问题 With respect to Listing 1 , how would I go about proving the type level axiom (t a) = (t (getUI (t a))) holds? Listing 1 data Continuant a = Continuant a deriving (Show,Eq) class UI a where instance UI Int where class Category t where getUI :: (UI a) => (t a) -> a instance Category Continuant where getUI (Continuant a) = a -- Does axiom (t a) = (t (getUI(t a))) holds for given types? test :: Int -> Bool test x = (Continuant x) == (Continuant (getUI (Continuant x))) The code is based on a

How does agda's inspect function work?

半世苍凉 提交于 2019-12-11 02:58:03
问题 I've seen an example of the inspect function in my last question Using the value of a computed function for a proof in agda , but I'm still having trouble wrapping my head around that. Here's a simple example: Given the function crazy , crazy : ℕ -> ℕ crazy 0 = 10 crazy 1 = 0 crazy 2 = 0 crazy 3 = 1 crazy 4 = 0 crazy xxx = xxx I want to create a safe function such that safe : {nn : ℕ} -> (id nn) ≢ 0 -> Fin (id nn) . In other words it will return one number mod crazy, if you give it a proof

Proving if n = m and m = o, then n + m = m + o in Idris?

吃可爱长大的小学妹 提交于 2019-12-11 02:23:32
问题 I am trying to improve my Idris skill by looking at some of the exercises Software Foundations (originally for Coq, but I am hoping the translation to Idris not too bad). I am having trouble with the "Exercise: 1 star (plus_id_exercise)" which reads: Remove "Admitted." and fill in the proof. Theorem plus_id_exercise : ∀ n m o : nat, n = m → m = o → n + m = m + o. Proof. (* FILL IN HERE *) Admitted. I have translated to the following problem in Idris: plusIdExercise : (n : Nat) -> (m : Nat) ->

How to prove False from obviously contradictory assumptions

廉价感情. 提交于 2019-12-10 12:48:29
问题 Suppose I want to prove following Theorem: Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False. This one is trivial since m cannot be both successor and zero, as assumed. However I found it quite tricky to prove it, and I don't know how to make it without an auxiliary lemma: Lemma succ_neq_zero_lemma : forall n : nat, O = S n -> False. Proof. intros. inversion H. Qed. Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False. Proof. intros. symmetry in H. apply (succ

Proof of induction on pseudocode

不问归期 提交于 2019-12-10 12:08:36
问题 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) Let x(n) and y(n) denote the value of x and y after the while loop has run n times. I have to show by the proof of induction that x(n) + b*y(n) = a What I've done: P(n): x(n) + by(n) = a Let a and b be arbitrary numbers then the first loop will give x(1) = a - b and y(1) = 0 + 1 = 1 P(1): x(1) + by(1) = a <=> a = a so P(1) is true. Assume P(n) is true. We want to show that P(n+1) is

Can a red node have just 1 black child in a red-black tree?

痞子三分冷 提交于 2019-12-10 11:31:51
问题 The rules for a Red-Black Tree: Every node is either red or black. The root is black. Every leaf (NIL) is black. If a node is red, then both its children are black. For each node, all simple paths from the node to descendant leaves contain the same number of black nodes. Rule 4 mentions that red nodes need both black childs but what if there is just one child to begin with? Is there an argument to prove or disprove this? 回答1: No,a red node cannot have one child,consider the following cases:-

Struggling with functional extensionality

时间秒杀一切 提交于 2019-12-10 10:45:10
问题 I've been programming in Coq for a few months now. Particularly, I'm interested in functional programming proofs where functions arise everywhere ( optics , state monad , etc.). In this sense, dealing with functional extensionality has become essential, though extremely annoying. To illustrate the situation, let us assume a simplication of Monad (just one law defined): Class Monad (m : Type -> Type) := { ret : forall {X}, X -> m X ; bind : forall {A B}, m A -> (A -> m B) -> m B }. Notation