coq

Different induction principles for Prop and Type

╄→гoц情女王★ 提交于 2019-12-03 17:02:32
I noticed that Coq synthesizes different induction principles on equality for Prop and Type. Does anybody have an explanation for that? Equality is defined as Inductive eq (A : Type) (x : A) : A -> Prop := eq_refl : x = x And the associated induction principle has the following type: eq_ind : forall (A : Type) (x : A) (P : A -> Prop), P x -> forall y : A, x = y -> P y Now let's define a Type pendant of eq: Inductive eqT {A:Type}(x:A):A->Type:= eqT_refl: eqT x x. The automatically generated induction principle is eqT_ind : forall (A : Type) (x : A) (P : forall a : A, eqT x a -> Prop), P x (eqT

Overloading notation for different types in Coq

旧时模样 提交于 2019-12-03 14:58:19
I would like to be able to define the same Coq notations for different inductive definitions, and distinguish the notations based on the types of their arguments. Here is a minimal example: Inductive type : Type := | TBool : type. Inductive term1 : Type := | tvar1 : term1. Inductive term2 : Type := | tvar2 : term2. Definition context := nat -> (option type). Reserved Notation "G '⊢' t '::' T" (at level 40, t at level 59). Inductive typing1 : context -> term1 -> type -> Prop := | T_Var1 : forall G T, G ⊢ tvar1 :: T where "G '⊢' t1 '::' T" := (typing1 G t1 T) with typing2 : context -> term2 ->

Coq: Prop versus Set in Type(n)

点点圈 提交于 2019-12-03 12:10:42
I want to consider the following three (related?) Coq definitions. Inductive nat1: Prop := | z1 : nat1 | s1 : nat1 -> nat1. Inductive nat2 : Set := | z2 : nat2 | s2 : nat2 -> nat2. Inductive nat3 : Type := | z3 : nat3 | s3 : nat3 -> nat3. All three types give induction principles to prove a proposition holds. nat1_ind : forall P : Prop, P -> (nat1 -> P -> P) -> nat1 -> P nat2_ind : forall P : nat2 -> Prop, P z2 -> (forall n : nat2, P n -> P (s2 n)) -> forall n : nat2, P n nat3_ind : forall P : nat3 -> Prop, P z3 -> (forall n : nat3, P n -> P (s3 n)) -> forall n : nat3, P n The set and type

Prove equality on Sigma-types

泪湿孤枕 提交于 2019-12-03 09:11:35
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? 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 Coq. According to common mathematical practice, we expect two functions to be equal if they yield equal

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

早过忘川 提交于 2019-12-03 08:33:36
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 is apply t2 to every subgoal produced by the execution of t1 in the current proof context, and I

What's the difference between Program Fixpoint and Function in Coq?

时光怂恿深爱的人放手 提交于 2019-12-03 08:15:21
They seem to serve similar purposes. The one difference I've noticed so far is that while Program Fixpoint will accept a compound measure like {measure (length l1 + length l2) } , Function seems to reject this and will only allow {measure length l1} . Is Program Fixpoint strictly more powerful than Function , or are they better suited for different use cases? This may not be a complete list, but it is what I have found so far: As you already mentioned, Program Fixpoint allows the measure to look at more than one argument. Function creates a foo_equation lemma that can be used to rewrite calls

Can Coq be used (easily) as a model checker?

て烟熏妆下的殇ゞ 提交于 2019-12-03 05:46:19
问题 As the title says, can Coq be used as a model checker? Can I mix model checking with Coq proving? Is this usual? Google talks about a "µ-calculus", does anyone have experience with this or something similar? Is it advised to use Coq in this way, or should I look for another tool? 回答1: A proof assistant like Coq will verify that your proof is sound and that any theorems you propose can (or cannot) be derived using axioms and previously proven results. It will also provide you with support in

Why haven't newer dependently typed languages adopted SSReflect's approach?

最后都变了- 提交于 2019-12-03 04:14:57
问题 There are two conventions I've found in Coq's SSReflect extension that seem particularly useful but which I haven't seen widely adopted in newer dependently-typed languages (Lean, Agda, Idris). Firstly, where possible predicates are expressed as boolean-returning functions rather than inductively defined datatypes. This brings decidability by default, opens up more opportunities for proof by computation, and improves checking performance by avoiding the need for the proof engine to carry

Can I extract a Coq proof as a Haskell function?

自闭症网瘾萝莉.ら 提交于 2019-12-03 02:20:45
问题 Ever since I learned a little bit of Coq I wanted to learn to write a Coq proof of the so-called division algorithm that is actually a logical proposition: forall n m : nat, exists q : nat, exists r : nat, n = q * m + r I recently accomplished that task using what I learned from Software Foundations. Coq being a system for developing constructive proofs, my proof is in effect a method to construct suitable values q and r from values m and n . Coq has an intriguing facility for "extracting" an

How to prove excluded middle is irrefutable in Coq?

烈酒焚心 提交于 2019-12-03 00:20:54
I was trying to prove the following simple theorem from an online course that excluded middle is irrefutable, but got stuck pretty much at step 1: Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P). Proof. intros P. unfold not. intros H. Now I get: 1 subgoals P : Prop H : P \/ (P -> False) -> False ______________________________________(1/1) False If I apply H , then the goal would be P \/ ~P , which is excluded middle and can't be proven constructively. But other than apply , I don't know what can be done about the hypothesis P \/ (P -> False) -> False : implication -> is