Git Product home page Git Product logo

paco's Introduction

Paco: Coq library for Parametric Coinduction

Build Status License

Paco is a Coq library for parametric coinduction. For more information, please see:

Paco also supports upto techniques using "companion". See:

Minki Cho refactored the implementation to speed up the compilation time.

The current version is v4.1.2, and it's compatible with Coq 8.13 - 8.15.

Installation

# from opam
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-paco

# from source
cd src; make; make install          # for library files
cd webpage; make                    # for documentation

Examples

See /src/examples.v and /src/tutorial.v for examples.

paco's People

Contributors

alxest avatar gilhur avatar jeehoonkang avatar liyishuai avatar lysxia avatar minkiminki avatar quinn-dougherty avatar skyskimmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paco's Issues

Install Paco with Coq 8.4 and opam

It seems to me that the opam package for Paco 1.2.8 does not install with Coq 8.4, while it asserts compatibility with Coq 8.3 onwards:

- "coqc"  -q  -R . Paco   paco12
- "coqc"  -q  -R . Paco   paco13
- "coqc"  -q  -R . Paco   paco14
- "coqc"  -q  -R . Paco   paco15
- "coqc"  -q  -R . Paco   paco
- "coqc"  -q  -R . Paco   tutorial
- "coqc"  -q  -R . Paco   examples
- File "/home/bench/.opam/ocaml-base-compiler.4.02.3/.opam-switch/build/coq-paco.1.2.8/src/tutorial.v", line 376, characters 0-4:
- Error: Attempt to save an incomplete proof
- Makefile.coq:220: recipe for target 'tutorial.vo' failed
- make[1]: *** [tutorial.vo] Error 1
- make[1]: *** Waiting for unfinished jobs....
- File "/home/bench/.opam/ocaml-base-compiler.4.02.3/.opam-switch/build/coq-paco.1.2.8/src/examples.v", line 80, characters 31-40:
- In nested Ltac calls to "punfold", "paco_class" and
- "set (CLS := method _ (get_paco_cls X))" (expanded to
- "set (_CLS_ := pacounfold)"), last call failed.
- Error:
- 
- Could not find an instance for "paco_class
-                                   (paco2 seq_step bot2 s1 s2 \/ bot2 s1 s2)" in environment:
- 
- r : stream nat -> stream nat -> Prop
- CIH : forall s1 s2 : stream nat, seq s1 s2 -> r s2 s1
- s1 : stream nat
- s2 : stream nat
- n : nat
- R : paco2 seq_step bot2 s1 s2 \/ bot2 s1 s2
- _typ_ := ?869 : Type
- _lem_ := ?872 : _typ_
- _X_ : paco2 seq_step bot2 s1 s2 \/ bot2 s1 s2
- 
- 
- Makefile.coq:220: recipe for target 'examples.vo' failed
- make[1]: *** [examples.vo] Error 1

Question:

  • is there something I am missing (sometimes makefiles are sensitive to the compilation order)?
  • should the package bounds be changed?

Warning messages in Coq 8.10.0

Compiling paco with Coq 8.10.0 leads to many warning messages like this:

File ".\paco/src/paco14.v", line 298, characters 0-20:
Warning: Adding and removing hints in the core database implicitly is
deprecated. Please specify a hint database.

You can easily fix this by adding :core to the end of your Hint commands (which is backward compatible to Coq 8.9 and 8.8).

Release for Coq 8.18?

I just upgraded to Coq 8.18 and now I realized that this has uninstalled coq-paco, since the latest version of coq-paco says

depends      "coq" {>= "8.13" & < "8.18~"}

Would be great to get a release that is compatible with Coq 8.18. :)

Update README

  • The version number is incorrect.
  • Add 8.5 to the supported Coq versions.

pmonauto with custom hint database

It looks like Coq 8.10 is starting to discourage dumping hints into the core hint database. The paco tactic pmonauto uses auto, so it would be nice if there were a variant which can accept custom hint databases.

<N= notation이 파싱에만 사용됨

프린트 찍었을 때에도 저 notation으로 나오면 좋겠습니다. (가독성)

Notation
"p <1= q" := forall x0 (PR : p x0 : Prop), q x0 : Prop (default interpretation)

지금은 위와 같이 되어있는데 아래처럼 바꾸면 가능하기는 함.

Definition less1 X0 (p q: X0 -> Prop) := (forall x0 (PR: p x0 : Prop), q x0 : Prop).
Hint Unfold less1.
Notation "p <1= q" := (less1 p q) (at level 50).

Definition이 한겹 생기는거라, backward compatible 하지 않을 수 있음.

Notation 추가

아래 Notation 들을 정의해서 쓰고 있는데 paconotation 에 넣는건 어떨까요?

top2 = (fun _ _ => True)
~2 p = (fun x0 x1 => ~ (p x0 x1))
p /2\ q = (fun x0 x1 => p x0 x1 /\ q x0 x1)

test CI

In order to claim that paco supports Coq 8.3-8.6, we need a test CI.

pcofix/gcofix tactic not working

The following code shows the problem.

From Paco Require Import paco.

Goal forall (xxx: (forall S, S -> Prop) -> (forall S, S -> Prop)), paco2 xxx bot2 nat 5%nat.
Proof.
  intros. Fail pcofix CIH.
Abort.

Below gives slightly better error message:

Goal forall (xxx: (rel2 Type id) -> (rel2 Type id)), paco2 xxx bot2 nat 5%nat.
Proof.
  intros. Fail pcofix CIH.
Abort.

Update opam for 8.19

Hi there! It looks like the release on opam doesn't include Coq 8.19 in the dependencies.

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      4.2.0
repository   coq-released
url.src      "https://github.com/snu-sf/paco/archive/v4.2.0.tar.gz"
url.checksum "md5=b714319091ae46212dd5a70446865d72"
homepage     "https://github.com/snu-sf/paco/"
bug-reports  "https://github.com/snu-sf/paco/issues/"
dev-repo     "git+https://github.com/snu-sf/paco.git"
authors      "Chung-Kil Hur <[email protected]>"
             "Georg Neis <[email protected]>"
             "Derek Dreyer <[email protected]>"
             "Viktor Vafeiadis <[email protected]>"
             "Minki Cho <[email protected]>"
maintainer   "[email protected]"
license      "BSD-3-Clause"
tags         "date:2023-03-13"
             "category:Computer Science/Programming Languages/Formal Definitions and Theory"
             "category:Mathematics/Logic"
             "keyword:co-induction"
             "keyword:simulation"
             "keyword:parameterized greatest fixed point"
             "logpath:Paco"
depends      "coq" {>= "8.13" & < "8.19~"}
synopsis     Coq library implementing parameterized coinduction

Would it be possible to bump the version? Thanks!

-Q instead of -R

It would be ideal if Paco could be built with '-Q . Paco" instead of "-R . Paco".
To do this would not be difficult, it takes 5 minutes to change every Require statement to use the fully qualified name, Paco.foo instead of foo.

Then, when I include Paco in other developments such as VST, I can write "-Q paco/src Paco" instead of "-R paco/src Paco", where I am using the git submodule "paco". (One could also do this via opam, but I like to have the option to build VST without opam.) I want to use -Q so that Paco does not accidentally shadow things in the VST namespace.

You might argue, "But you can already do "-Q paco/src Paco" to compile clients of Paco, even Paco is internally built with -R." This is mostly true, but for simplicity in my Makefile I would like to have just one global _CoqProject with just a single entry for Paco, and that entry should be -Q so that Paco does not accidentally overshadow things in the namespace.

It's easy to make this change in the Paco sources, and none of the existing clients of Paco will be broken by this.

pcofix works while gcofix doesn't?

In the example below, pcofix tactic works while gcofix doesn't.

Require Import Coq.Relations.Relation_Definitions.
From Paco Require Import paco.
Let __add_constraint__: relation (rel2 unit (fun _ => unit)) := bot2.
Variable f: (forall R, relation R -> Prop) -> (forall R, relation R -> Prop).
Goal forall R (RR: relation R), (paco2 f bot2 R RR). Proof. pcofix CIH. Abort.
Goal forall R (RR: relation R), (gpaco2 f (cpn2 f) bot2 bot2 R RR). Proof. Fail gcofix CIH. Abort.

It seems like gcofix is somewhat universe-sensitive while pcofix isn't.
Related issue: DeepSpec/InteractionTrees#193

Coq 8.14

Do you have plans to update paco to compile with coq 8.14 without warnings?

gcofix failing in 4.1

Hello,

The latest release of gpaco broke a script in Vellvm. It appears to be a side effect to the "fix" in gcofix from issue #37, but I haven't looked close enough to figure out what is happening exactly.

The proof failing is the following (it is in the Vellvm repo, but is a purely itree-based thing, it only depends on Utils/NoEvents.v ): https://github.com/vellvm/vellvm/blob/master/src/coq/Utils/Commutation.v#L36

We get Error: Proof is not complete. when calling ecofix CIH where it used to work on the previous version. Unfolding the definition of ecofix, it happens when calling paco_post2 CIH with gL..

Am I missing a reason for which it indeed should fail, or did the fix from #37 introduce another bug by side effect?

Best,
Yannick

Code duplication

It seems paco's code is actually generated by the python scripts, and the code duplication leads to somwhat long compile times. Instead of copying mostly the same code for each arity, have you considered a generalization in pure Coq (say, indexing predicates by the arity as a nat)? What are the difficulties with that approach?

pcofix fails on some relations between unfolded values with explicit cofix

Here is a minimized example. The unfold on the penultimate line somehow prevent the pcofix on the last line from going through. This is quite surprising as I wouldn't expect unfold to affect pcofix. I'm quite uncertain of the cause, this may very well be a bug in Coq, in a standard tactic that pcofix uses.

Require Import Paco.paco.

Set Implicit Arguments.
Set Contextual Implicit.


CoInductive stream (A:Type) :=
| snil : stream A
| scons : A -> stream A -> stream A
.

Arguments scons {_} _ _.

Inductive seq_step (seq : stream nat -> stream nat -> Prop) :
  stream nat -> stream nat -> Prop :=
.
Hint Constructors seq_step.

Definition seq (s t : stream nat) := paco2 seq_step bot2 s t .
Hint Unfold seq.

Definition app (a : nat) : stream nat :=
  (cofix app := scons a snil).

Lemma seq_app : forall a, seq (app a) (app a).
Proof.
  unfold app. (* removing this line makes pcofix below succeed *)
  pcofix CH.

paco <= gpaco lemma?

I found the following lemma useful during the proof. Maybe we can add it to the library?

  Lemma gpaco4_paco4
        clo r rg
    :
      paco4 gf r <4= gpaco4 gf clo r rg
  .
  Proof.
    intros.
    econstructor. econstructor. left.
    eapply paco4_mon; eauto.
    unfold Basics.compose.
    eapply paco4_mon_gen; eauto. intros.
    eapply gf_mon; eauto. intros. econstructor. eauto.
  Qed.

Add paco to Coq CI

The Coq team strongly encourages Coq projects to be added to Coq CI. This allows changes in Coq that break your library to be detected as they happen, so Coq developers may proactively submit pull requests to patch your library. The process is documented here: https://github.com/coq/coq/blob/master/dev/ci/README-users.md

Adding paco to Coq CI would then enable adding itree to Coq CI as well.

Question about respectful functions

The new tactics pupto_init and pupto_final allow us to go back and forth between paco bot gf and paco bot (gf o gres gf). Is there ever a reason to stay in paco bot gf? Would it be reasonable to make paco bot (gf o gres gf) the default way for users of paco to define greatest fixpoints in the first place?

Avoid use of JMeq_eq

Paco uses the JMeq_eq axiom (JMeq x y -> x = y) in the pcofix tactic (in pacotac_internal.v). The gist of what it's doing is to reshape the goal into a form where the pacoN_acc lemma can be applied, and JMeq_eq is used somewhere in this transformation. I'm wondering whether this can be simplified, in a way that doesn't use JMeq_eq.

As I understand it, pcofix needs to do the following.

Initial goal:

===================
forall x y z, hyps -> paco2 gf bot2 (f x y) (g z)

"uncurry" the goal

===================
forall a b, (exists x y z, hyps /\ existT _ a b = existT _ (f x y) (g z)) -> paco2 gf bot2 a b

apply paco2_acc

r : forall a b, Prop
COFIX : forall a b, (exists x y z, hyps /\ existT _ a b = existT _ (f x y) (g z)) -> r a b
===================
forall a b, (exists x y z, hyps /\ existT _ a b = existT _ (f x y) (g z)) -> paco2 gf r a b

"curry" the goal

r : forall a b, Prop
COFIX : forall a b, (exists x y z, hyps /\ existT _ a b = existT _ (f x y) (g z)) -> r a b
===================
forall x y z, hyps -> paco2 gf r (f x y) (g z)

"curry" the hypothesis

r : forall a b, Prop
COFIX : forall x y z, hyps -> r (f x y) (g z)
===================
forall x y z, hyps -> paco2 gf r (f x y) (g z)

JMeq_eq may seem necessary to rewrite between R a b and R (f x y) (g z) given only existT _ a b = existT _ (f x y) (g z), but this can actually be done without axioms by simply converting R a b to R (projT1 (existT _ a b)) (projT2 (existT _ a b)), and then rewriting with the above.

I think all of these steps are relatively straightforward (in fact I've already done most of the work once

paco/metasrc/paco_sigma.v

Lines 309 to 373 in fb5be10

Ltac uncurry_hyp OBG :=
let t := fresh "t" in
unshelve refine (let t : telescope := _ in _);
[ repeat lazymatch type of OBG with
| forall x : ?A, _ =>
apply (@tscp A);
let x := fresh x in
intros x;
specialize (OBG x)
| ?T => apply (tscp0 T)
end
| cut (forall x, teleprop t x); subst t; cbv [telesig teleprop];
[ clear OBG; intros OBG
| intros x;
let rec go t := assumption + specialize (OBG (paco_projT1 t)); go (paco_projT2 t) in
go x
]
].
Ltac curry_hyp OBG :=
let t := fresh "t" in
unshelve refine (let t : telescope := _ in _);
[ repeat lazymatch type of OBG with
| forall _ : paco_sigT (fun x : ?A => _), _ =>
apply (@tscp A);
let x := fresh x in
intros x;
let OBG' := fresh OBG in
rename OBG into OBG';
pose proof (paco_sigT_curry_ OBG' x) as OBG; clear OBG';
cbn [paco_projT1 paco_projT2] in OBG
| True -> ?T => apply (tscp0 T)
end
| cbv zeta beta in t;
cut (teleforall t); subst t; cbv [ teleforall ];
[ clear OBG; intros OBG
| repeat lazymatch goal with
| [ |- forall x : _, _ ] =>
let x := fresh x in
intros x;
let OBG' := fresh OBG in
rename OBG into OBG';
pose proof (paco_sigT_curry_ OBG' x) as OBG; clear OBG';
cbn [paco_projT1 paco_projT2] in OBG
end;
exact (OBG I)
]
].
Section TEST.
Context (hyp : forall (x y z : nat), Prop).
Context (goal : forall (u v w : bool), Prop).
Lemma TEST
(H : forall x y z : nat, x < z -> hyp x y z) :
forall u v w, u = true -> goal u v w.
Proof.
uncurry_hyp H.
curry_hyp H.
uncurry_goal.
curry_goal.
Abort.
End TEST.
, it is currently commented out because of definitions that no longer exist, but I can restore and polish the whole thing), that's why I'm a bit surprised at the complexity of the existing definition of the pcofix tactic. Am I missing some nuance about what pcofix needs to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.