coq

Defining recursive function over product type

和自甴很熟 提交于 2021-02-20 09:07:11
问题 I'm trying to formalize each integer as an equivalence class of pairs of natural numbers, where the first component is the positive part, and the second component is the negative part. Definition integer : Type := prod nat nat. I want to define a normalization function where positives and negatives cancel as much as possible. Fixpoint normalize (i : integer) : integer := let (a, b) := i in match a with | 0 => (0, b) | S a' => match b with | 0 => (S a', 0) | S b' => normalize (a', b') end end.

Defining recursive function over product type

谁说我不能喝 提交于 2021-02-20 09:06:13
问题 I'm trying to formalize each integer as an equivalence class of pairs of natural numbers, where the first component is the positive part, and the second component is the negative part. Definition integer : Type := prod nat nat. I want to define a normalization function where positives and negatives cancel as much as possible. Fixpoint normalize (i : integer) : integer := let (a, b) := i in match a with | 0 => (0, b) | S a' => match b with | 0 => (S a', 0) | S b' => normalize (a', b') end end.

Abstracting leads to a term ill-typed… yet well-typed

和自甴很熟 提交于 2021-02-19 12:46:20
问题 I was stuck on a problem for a while, for which I derived a smaller standalone example: Axiom f : nat -> Set. Goal forall (n : nat) (e : n = n) (x : f n), match e in _ = _n return f _n -> Prop with | Logic.eq_refl => fun v : f n => v = x end x. Now, if you try to destruct e , you get the following error message: Error: Abstracting over the terms "n0" and "e" leads to a term "fun (n0 : nat) (e : n0 = n0) => forall x : f n0, match e in (_ = _n) return (f _n -> Prop) with | Logic.eq_refl => fun

Redundant clause in match

风流意气都作罢 提交于 2021-02-19 05:51:43
问题 When I run the following script: Definition inv (a: Prop): Prop := match a with | False => True | True => False end. I get "Error: This clause is redundant." Any idea why this happens? Thanks, Marcus. 回答1: There are quite a few wrong things about this. False is not a data constructor, and since there is no syntactic difference between data constructors and variable names in Coq, it understands your | False => as a pattern matching anything and giving it the name False , in the same way as you

How does one implement Coq?

狂风中的少年 提交于 2021-02-18 17:42:10
问题 If one wishes to re-implement the calculus of inductive constructions, what is the "shortest" path towards this? In particular, what actually goes on inside the kernel? My mental model says that we need two things: ability to compute / reduce terms to values. ability to type check to ensure that proofs are correct. However, since the language is dependently typed, the type-checker will most likely depend on the ability to compute when deciding two types are equal. So, really, what is the

How does one implement Coq?

为君一笑 提交于 2021-02-18 17:42:04
问题 If one wishes to re-implement the calculus of inductive constructions, what is the "shortest" path towards this? In particular, what actually goes on inside the kernel? My mental model says that we need two things: ability to compute / reduce terms to values. ability to type check to ensure that proofs are correct. However, since the language is dependently typed, the type-checker will most likely depend on the ability to compute when deciding two types are equal. So, really, what is the

why does `make` using _CoqProject in coqide differ from `coqc` on the commandline?

喜你入骨 提交于 2021-02-09 11:12:21
问题 I have two short files: cc_test is given by Lemma cc: 4 = 4. Proof. auto. Qed. and libtest is given by Require Import cc_test. Check cc. When I execute coqc -R . ClosureLib -top ClosureLib cc_test in directory "/home/barry/svn/Coq/Closure_Calculus" and coqc -R "/home/barry/svn/Coq/Closure_Calculus" ClosureLib libtest in its directory, I get the expected output cc: 4 = 4 However, when the arguments to coqc above (from -R to the end) are placed in _CoqProject files, and I call Make makefile and

why does `make` using _CoqProject in coqide differ from `coqc` on the commandline?

给你一囗甜甜゛ 提交于 2021-02-09 11:12:21
问题 I have two short files: cc_test is given by Lemma cc: 4 = 4. Proof. auto. Qed. and libtest is given by Require Import cc_test. Check cc. When I execute coqc -R . ClosureLib -top ClosureLib cc_test in directory "/home/barry/svn/Coq/Closure_Calculus" and coqc -R "/home/barry/svn/Coq/Closure_Calculus" ClosureLib libtest in its directory, I get the expected output cc: 4 = 4 However, when the arguments to coqc above (from -R to the end) are placed in _CoqProject files, and I call Make makefile and

How to import theorems from Coq.Numbers.NatInt.NZDiv?

…衆ロ難τιáo~ 提交于 2021-01-29 11:34:29
问题 In this doc link there are useful theorems about division. I tried importing it using Require Import in CoqIDE 8.9.0, however while the import succeeds, the following code fails with The reference div_lt_upper_bound was not found in the current environment. Require Import Coq.Numbers.NatInt.NZDiv. Check div_lt_upper_bound. I tried downloading the source code for the file and manually importing it via Load , but then I get the following message with no further explanation (the first line is in

Removing tcast for tuples

自作多情 提交于 2021-01-29 09:16:15
问题 I'm in a bind with a goal equality like this (the details don't matter, I think): tcast tc0 [tuple of take i (s_bs bs) ++ drop i.+1 (s_bs bs) ++ [:: [ffun⇒ 0]]] = ... How do I get rid of the tcast and tuple to go back to simple seq (I tried the val_inj trick, but this didn't seem to remove the type cast)? Thanks in advance. Bye, Pierre 回答1: Giving a precise answer is a bit difficult, since you did not provide any reproducible testcase. But you could try rewriting your goal using the following