coq

How to disable my custom notation in Coq?

自闭症网瘾萝莉.ら 提交于 2019-12-08 16:10:30
问题 I've defined a notation to simulate imperative style programming by Notation "a >> b" := (b a) (at level 50). However after that, all function-application expression are represented as '>>' style. For example, in proof mode of Coq Toplevel, I can see bs' : nat >> list while actually it should be bs' : list nat Why does Coq aggressively rewrite all function application styled expression into my customized '>>' representation? How can I restore everything back to normal, I mean I want to see 'a

Defining subtype relation in Coq

情到浓时终转凉″ 提交于 2019-12-08 07:16:46
问题 Is there a way to define subtype relationship in Coq? I read about subset typing, in which a predicate is used to determine what goes into the subtype, but this is not what I am aiming for. I just want to define a theory in which there is a type (U) and another type (I), which is subtype of (U). 回答1: There is no true subtyping in Coq (except for universe subtyping, which is probably not what you want). The closest alternative is to use coercions, which are functions that the Coq type checker

Lexicographical comparison of tuples of nats

一笑奈何 提交于 2019-12-08 05:18:00
问题 I'm working with tuples of nat s (specifically triples, nat*nat*nat ) and would like a way to lexicographically compare tuples. Something equivalent to this: Inductive lt3 : nat*nat*nat -> nat*nat*nat -> Prop := | lt3_1 : forall n1 n2 n3 m1 m2 m3, n1 < m1 -> lt3 (n1,n2,n3) (m1,m2,m3) | lt3_2 : forall n1 n2 n3 m2 m3, n2 < m2 -> lt3 (n1,n2,n3) (n1,m2,m3) | lt3_3 : forall n1 n2 n3 m3, n3 < m3 -> lt3 (n1,n2,n3) (n1,n2,m3). I would like to have proofs of basic properties such as transitivity and

How to understand Coq type constructor var (t: T)

心不动则不痛 提交于 2019-12-08 03:11:58
问题 I am reading about mechanization of linear logic in Coq http://www.cs.cmu.edu/~iliano/projects/metaCLF2/inc/dl/papers/lsfa17.pdf and https://github.com/brunofx86/LL and I have trouble to understand the type constructors of the inductive type term from https://github.com/brunofx86/LL/blob/master/FOLL/LL/SyntaxLL.v: Inductive term := |var (t: T) (* variables *) |cte (e:A) (* constants from the domain DT.A *) |fc1 (n:nat) (t: term) (* family of functions of 1 argument *) |fc2 (n:nat) (t1 t2:

Proving equality on coinductive lazy lists in Coq

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 23:14:27
问题 I am experimenting with Coq Coinductive types. I use the lazy list type form the Coq'Art book (sect. 13.1.4): Set Implicit Arguments. CoInductive LList (A:Set) : Set := | LNil : LList A | LCons : A -> LList A -> LList A. Implicit Arguments LNil [A]. CoFixpoint LAppend (A:Set) (u v:LList A) : LList A := match u with | LNil => v | LCons a u' => LCons a (LAppend u' v) end. In order to match the guard condition I also use the following decomposition functions form this book: Definition LList

Combining two Coq hypotheses

▼魔方 西西 提交于 2019-12-07 21:54:52
问题 So I have two hypotheses, one that is h : A -> B , and the other which is h2 : A . How can I get h3 : B to appear in my hypotheses? 回答1: pose proof (h h2) as h3. introduces h3 : B as a new hypothesis, specialize (h h2). modifies h : A -> B into h : B -- this can be useful if you won't need h later, and symmetrically, apply h in h2. converts h2 : A into h2 : B . Another (not very convenient) way would be to assert B as h3 by exact (h h2). That's what the pose proof variant is equivalent to.

Coq: Defining a subtype

蓝咒 提交于 2019-12-07 20:21:08
问题 I have a type, say Inductive Tt := a | b | c. What's the easiest and/or best way to define a subtype of it? Suppose I want the subtype to contain only constructors a and b . A way would be to parametrize on a two-element type, e.g. bool: Definition filt (x:bool): Tt := match x with | true => a | false => b end. Check filt true: Tt. This works but is very awkward if your expression has several (possibly interdependent) subtypes defined this way. Besides, it works only half way, as no subtype

Modus Ponens and Modus Tollens in Coq

情到浓时终转凉″ 提交于 2019-12-07 14:53:00
问题 I would like to have Ltac tactics for these simple inference rules. In Modus Ponens, if I have H:P->Q and H1:P , Ltac mp H H1 will add Q to the context as H2 : Q . In Modus Tollens, if I have H:P->Q and H1:~Q , then Ltac mt H H1 will add H2:~P to the context. I have written one for the modus ponens, but it does not work in the complicated cases where the precedent is also an implication. Ltac mp H0 H1 := let H := fresh "H" in apply H0 in H1 as H. Edit : I have found the answer to Modus Ponens

Convert ~exists to forall in hypothesis

扶醉桌前 提交于 2019-12-07 13:46:58
问题 I'm stuck in situation where I have hypothesis ~ (exists k, k <= n+1 /\ f k = f (n+2)) and wish to convert it into equivalent (I hope so) hypothesis forall k, k <= n+1 -> f k <> f (n+2) . Here is little example: Require Import Coq.Logic.Classical_Pred_Type. Require Import Omega. Section x. Variable n : nat. Variable f : nat -> nat. Hypothesis Hf : forall i, f i <= n+1. Variable i : nat. Hypothesis Hi : i <= n+1. Hypothesis Hfi: f i = n+1. Hypothesis H_nex : ~ (exists k, k <= n+1 /\ f k = f (n

Set theory notation with whitespaces and curly braces in Coq

和自甴很熟 提交于 2019-12-07 13:17:27
问题 I'd like to have standard notation like "x ∈ { x }" in Coq. But there are problems: 1) Curly braces has special meaning in Coq, so the following happens: Notation " x ∈ y " :=(tin x y) (at level 50). Notation " { x } ":=(Sing x). Check fun x => (x ∈ { x }). (*error: Unknown interpretation for notation "_ ∈ { _ }". *) How to define this notation correctly? 2) If the first problem cannot be solved, there is another. (Here I decided to use the additional symbol '`' in the notation.) Notation " {