totality

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

How to indicate decreasing in size of two Coq inductive types

蓝咒 提交于 2019-12-01 11:04:10
I'm trying to define the game inductive type for combinatorial games. I want a comparison method which tells if two games are lessOrEq , greatOrEq , lessOrConf or greatOrConf . Then I can check if two games are equal if they are both lessOrEq and greatOrEq . But when I try defining the mutually recursive methods for making this check, I get: Error: Cannot guess decreasing argument of fix . I think this is because only one game or the other decreases in size with each recursive call (but not both). How can I indicate this to Coq? Here's my code. The part that fails is the mutually recursive

How to indicate decreasing in size of two Coq inductive types

馋奶兔 提交于 2019-12-01 07:28:15
问题 I'm trying to define the game inductive type for combinatorial games. I want a comparison method which tells if two games are lessOrEq , greatOrEq , lessOrConf or greatOrConf . Then I can check if two games are equal if they are both lessOrEq and greatOrEq . But when I try defining the mutually recursive methods for making this check, I get: Error: Cannot guess decreasing argument of fix . I think this is because only one game or the other decreases in size with each recursive call (but not

Coq simpl for Program Fixpoint

我与影子孤独终老i 提交于 2019-12-01 03:57:27
is there anything like the tactic simpl for Program Fixpoint s? In particular, how can one proof the following trivial statement? Program Fixpoint bla (n:nat) {measure n} := match n with | 0 => 0 | S n' => S (bla n') end. Lemma obvious: forall n, bla n = n. induction n. reflexivity. (* I'm stuck here. For a normal fixpoint, I could for instance use simpl. rewrite IHn. reflexivity. But here, I couldn't find a tactic transforming bla (S n) to S (bla n).*) Obviously, there is no Program Fixpoint necessary for this toy example, but I'm facing the same problem in a more complicated setting where I

Error in defining Ackermann in Coq

牧云@^-^@ 提交于 2019-12-01 03:50:56
I am trying to define the Ackermann-Peters function in Coq, and I'm getting an error message that I don't understand. As you can see, I'm packaging the arguments a, b of Ackermann in a pair ab ; I provide an ordering defining an ordering function for the arguments. Then I use the Function form to define Ackermann itself, providing it with the ordering function for the ab argument. Require Import Recdef. Definition ack_ordering (ab1 ab2 : nat * nat) := match (ab1, ab2) with |((a1, b1), (a2, b2)) => (a1 > a2) \/ ((a1 = a2) /\ (b1 > b2)) end. Function ack (ab : nat * nat) {wf ack_ordering} : nat

Coq simpl for Program Fixpoint

有些话、适合烂在心里 提交于 2019-11-30 03:37:27
问题 is there anything like the tactic simpl for Program Fixpoint s? In particular, how can one proof the following trivial statement? Program Fixpoint bla (n:nat) {measure n} := match n with | 0 => 0 | S n' => S (bla n') end. Lemma obvious: forall n, bla n = n. induction n. reflexivity. (* I'm stuck here. For a normal fixpoint, I could for instance use simpl. rewrite IHn. reflexivity. But here, I couldn't find a tactic transforming bla (S n) to S (bla n).*) Obviously, there is no Program Fixpoint