coq

Subset parameter

拟墨画扇 提交于 2019-12-04 21:06:10
问题 I have a set as a parameter: Parameter Q:Set. Now I want to define another parameter that is a subset of Q. Something like: Parameter F: subset Q. How I can define that? I guess I can add the restriction later as an axiom, but seems more natural to express it directly in the type of F. 回答1: You can't express it directly. It's misleading to think of objects in Set as mathematical sets. Set is the sort of datatypes, the same kinds of types that you find in programming languages (except that Coq

Require, Import, Require Import

a 夏天 提交于 2019-12-04 19:41:28
问题 In Coq, what's the difference between ... ? Require X. Import X. Require Import X. I have basically memorized some common patterns. I usually see code using Require Import X. Then there's Import ListNotation. And I just noticed it's also possible to write just Require X. What's the difference? Some practical examples would be appreciated. 回答1: Require loads a library whereas Import brings its definitions into scope. Require Import does both. If you only have the library loaded, you'll need to

Prove equality on Sigma-types

不羁的心 提交于 2019-12-04 16:01:19
问题 I have defined a Sygma-Type that looks like: { R : nat -> nat -> bool | Reflexive R } I have two elements r1 r2 : { R : nat -> nat -> bool | Reflexive R } and I am to prove r1 = r2 . How can I do that? 回答1: If you want to show such an equality, you need to (1) show that the underlying functions are equal (i.e., the R component of your sigma type), and (2) show that the corresponding proofs are equal. There are two problems, however. The first one is that equality of functions is too weak in

Teach coq to check termination

て烟熏妆下的殇ゞ 提交于 2019-12-04 13:55:35
问题 Coq, unlike many others, accepts an optional explicit parameter,which can be used to indicate the decreasing structure of a fixpoint definition. From Gallina specification, 1.3.4, Fixpoint ident params {struct ident0 } : type0 := term0 defines the syntax. but from it, we've known that it must be an identifier, instead of a general measure. However, in general, there are recursive functions, that the termination is not quite obvious,or it in fact is, but just difficult for the termination

Coq can't compute a well-founded function on Z, but it works on nat

╄→尐↘猪︶ㄣ 提交于 2019-12-04 13:34:47
问题 I'm writing (for myself) an explanation of how to do well-founded recursion in Coq. (see i.e. the Coq'Art book, chapter 15.2). First I made an example function based on nat and that worked fine, but then I did it again for Z , and when I use Compute to evaluate it, it doesn't reduce all the way down to a Z value. Why? Here is my example (I put the text inside comments so one can copy-paste the whole thing into your editor): (* Test of well-founded recursion *) (* TL;DR: To do well-founded

How do you selectively simplify arguments to each time a function is called, without evaluating the function itself?

笑着哭i 提交于 2019-12-04 12:32:06
I'm using Coq 8.5pl1. To make a contrived but illustrative example, (* fix so simpl will automatically unfold. *) Definition double := fix f n := 2*n. Theorem contrived n : double (2 + n) = 2 + double (1 + n). Now, I only want to simplify the arguments to double, and not any part outside of it. (For example, because the rest has already carefully been put into the correct form.) simpl. S (S (n + S (S (n + 0)))) = S (S (S (n + S (n + 0)))) This converted the outside (2 + ...) to (S (S ...)) as well as unfolding double. I can match one of them by doing: match goal with | |- (double ?A) = _ =>

Coq execution difference between semicolon “;” and period “.”

邮差的信 提交于 2019-12-04 12:13:53
问题 Given a valid Coq proof using the ; tactical, is there a general formula for converting it to a valid equivalent proof with . substituted for ; ? Many Coq proofs use the ; or tactic sequencing tactical. As a beginner, I want to watch the individual steps execute, so I want to substitute . for ; , but to my surprise I find that this may break the proof. Documentation on ; is sparse, and I haven't found an explicit discussion of . anywhere. I did see a paper that says informal meaning of t1; t2

Are constructors in the plain calculus of constructions disjoint and injective?

走远了吗. 提交于 2019-12-04 12:06:05
Based on this answer , it looks like the calculus of inductive constructions, as used in Coq, has disjoint, injective constructors for inductive types. In the plain calculus of constructions (i.e., without primitive inductive types), which uses impredicative encodings for types (e.g., ∏(Nat: *).∏(Succ: Nat → Nat).∏(Zero: Nat).Nat ), is this still true? Can I always find out which "constructor" was used? Also, is injectivity (as in ∀a b.I a = I b → a = b ) provable in Coq with Prop or impredicative Set? This seems to cause trouble in Idris . Arthur Azevedo De Amorim (I am not sure about all the

Finite map example

为君一笑 提交于 2019-12-04 10:44:40
问题 For my application, I need to use and reason about finite maps in Coq. Googling around I've found about FMapAVL which seems to be a perfect fit for my needs. The problem is that the documentation is scarce, and I haven't figured out how I am supposed to use it. As a trivial example, consider the following silly implementation of a finite map using a list of pairs. Require Export Bool. Require Export List. Require Export Arith.EqNat. Definition map_nat_nat: Type := list (nat * nat). Fixpoint

Defining different equality types as inductive types in Coq

穿精又带淫゛_ 提交于 2019-12-04 10:41:38
I am trying to define in Coq different types of equalities. During an university course my professor gave us the rules of four different types, as follows (I provide just the links to the rules): Gentzen : https://ibb.co/imQOCF Leibniz : https://ibb.co/n0uBzv Martin-Lof : https://ibb.co/fALZKv Path Induction : https://ibb.co/esZuKv The difference among these four types relies on the type C. I am trying to prove the isomorphism among them. Unfortunately I have some troubles in declaring as inductive types the first and the second, because I cannot find a way to specify the type C. I have a