Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inductive inductive types #12464

Closed
wants to merge 2 commits into from

Conversation

mattam82
Copy link
Member

@mattam82 mattam82 commented Jun 5, 2020

Kind: feature

Fixes / closes #???? (certainly some wishes are related)

This is an extraction and rebase of the "reasonable part" of my old induction-recursion/induction-recursion branch. I think inductive recursive types should rather be handled using a global fixpoint notion, but inductive-inductives pose no such problem (almost).

This both allows inductives to depend on previous ones in the same block (and their constructors) and mutual fixpoints to depend on each other in their types.

CAUTION: the guard checking is currently disabled in match predicates for this to work currently. No guarantees about consistency, decidability of typechecking or subject reduction are made.

This is all done by generalizing inductive blocks to have dependencies betwee arities and for constructors to be typed in a context with the previous arities and constructors available (i.e. we are really building a signature). This can give rise to name clashes in existing definitions but it should be quite rare (none in the stdlib or test-suite).

Positivity checking is not verifying anything about the use of constructors, it might have to.

For recursive-recursive fixpoints, tying the know is not easy and there are two more hacky parts in pretyping and more importantly in the kernel where we might be calling reduction on ill-typed or at least not guarded terms, but I think that's avoidable by having a notion of partial fixpoint definition (where some bodies are not reducible): to typecheck fixpoint n ones needs the computational content of the n-1 previous fixpoints only, but the way fixpoints are encoded in blocks does not allow to express that.

A few parts of the system are not adapted yet, e.g. some elaboration code which does not allow for the dependencies available in the kernel calculus. For uniformity I allowed mutual dependent cofixpoints, but I'm not sure they are of any use (yet?), or maybe could cause trouble. So, many questions remain :) But one can play with it to interpret a small type-theory in type theory, for example.

Anyway, I'll write more about this here when we figure out how to make progress with @herbelin and @Alizter.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Aug 24, 2020
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 6, 2020
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Oct 7, 2020

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Oct 7, 2020

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@SkySkimmer
Copy link
Contributor

SkySkimmer commented Oct 7, 2020

I updated the part of hottclasses which uses II to this branch + hott master.
I get Anomaly "make_resolve_hyp." on https://github.com/SkySkimmer/HoTTClasses/blob/c3e809bdc2f75f7b2c9f3e0664cdf1ce6d450fed/theories/partiality.v#L355
See log https://travis-ci.org/github/SkySkimmer/HoTTClasses/builds/748640810

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 12, 2020
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jun 23, 2021
@SkySkimmer
Copy link
Contributor

Attempted rebase, let's see how it goes (note FIXME in cclosure norm_head)

@Alizter
Copy link
Contributor

Alizter commented Jun 26, 2021

@SkySkimmer Why did the windows job succeed if the others failed?

@SkySkimmer
Copy link
Contributor

Because the windows job builds nothing (see #14561)

@SkySkimmer SkySkimmer force-pushed the inductive-inductive-types branch 3 times, most recently from b277bfa to 182c694 Compare June 28, 2021 13:40
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Jun 28, 2021

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@Alizter Alizter linked an issue Jul 7, 2021 that may be closed by this pull request
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jul 18, 2021
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jul 19, 2021
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Jul 19, 2021

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@Alizter
Copy link
Contributor

Alizter commented Jul 20, 2021

Here is something that gives a nonsense error message:

Inductive nat : Set :=
| zero : nat
| succ : nat
with iseven : nat -> Prop :=
| iseven_zero : iseven zero
| iseven_succ_isodd x
  : isodd x -> iseven (succ x)
with isodd : nat -> Prop :=
| isodd_succ_iseven x
  : iseven x -> isodd (succ x)
.
Illegal application (Non-functional construction): 
The expression "succ" of type 
"nat"
cannot be applied to the term
 "x" : "nat"

@SkySkimmer
Copy link
Contributor

That looks fine to me (did you really intend to write succ : nat on line 3?)

@Alizter
Copy link
Contributor

Alizter commented Jul 20, 2021

No but I am still getting a weird message after fixing it to succ : nat -> nat:

In environment
P : nat -> Prop
f : P zero
f0 :
forall x : nat,
isodd x -> P (succ x)
n : nat
i : iseven n
The term "i" has type "iseven n"
which should be Set, Prop or Type.
nat, iseven, isodd are defined
nat_rect is defined
nat_ind is defined
nat_rec is defined
nat_sind is defined

Those things shouldn't be defined right?

@ppedrot
Copy link
Member

ppedrot commented Jul 20, 2021

@Alizter this looks like a failure of some scheme generation, so it's not so surprising.

@Alizter
Copy link
Contributor

Alizter commented Jul 20, 2021

Here is an example (I don't know if we want to accept this) that shows mutual fixpoints aren't sharing bodies correctly:

Fixpoint foo (A : Type) (a : A) (n : nat) : Type :=
  match n with
  | 0   => False
  | S k => True + {x : foo A a k & bar x = a}
  end
with bar (A : Type) (x : A) (n : nat) : foo A x n -> A :=
  match n with
  | 0   => fun _ => x
  | S k => fun t => foo k (projT1 t)
  end.
The reference foo
was not found in the current
environment.

(* Ali: The environment being the type of bar *)

Also there is the question of universes for these kinds of things. If I were to bundle up this definition as a recursion into a sigma type for example, I would need a larger universe for that sigma type to live in. But then projecting out, I no longer need the larger universe but I am forced to carry it around anyway. At the moment, I can't write @{u+1} I believe, which is a separate project.

If we can directly write these recursive-recursive definitions then we can probably avoid this extra universe, but I have no idea if that is a sensible thing to do.

@Alizter
Copy link
Contributor

Alizter commented Jul 20, 2021

@ppedrot Do you think the printing of "defined" messages after the scheme generation failure is a bug from this PR or a bug in general?

@ppedrot
Copy link
Member

ppedrot commented Jul 20, 2021

@Alizter it's a general bug, I think we even have an open issue about it already.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Aug 5, 2021
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Sep 3, 2021
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Sep 3, 2021

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Sep 20, 2021
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Oct 20, 2021

The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed.

@coqbot-app coqbot-app bot added the stale This PR will be closed unless it is rebased. label Oct 20, 2021
@coqbot-app coqbot-app bot removed needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. stale This PR will be closed unless it is rebased. labels Oct 22, 2021
@mattam82 mattam82 force-pushed the inductive-inductive-types branch 2 times, most recently from d8bcc1f to 5d832fe Compare October 22, 2021 12:28
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 15, 2021
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Dec 15, 2021

The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed.

@coqbot-app coqbot-app bot added the stale This PR will be closed unless it is rebased. label Dec 15, 2021
@coqbot-app coqbot-app bot removed needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. stale This PR will be closed unless it is rebased. labels Dec 15, 2021
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 5, 2022
… and same for coinductives

Adapt to change of case representation (substitution missing)
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 25, 2022
@Alizter
Copy link
Contributor

Alizter commented Jan 25, 2022

@mattam82 At some point the guard checker got worse. Having trouble getting

File "./theories/micromega/ZMicromega.v", line 1049, characters 0-497:

accepted.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Feb 2, 2022
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 4, 2022

The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed.

@coqbot-app coqbot-app bot added the stale This PR will be closed unless it is rebased. label Mar 4, 2022
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Apr 4, 2022

This PR was not rebased after 30 days despite the warning, it is now closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. stale This PR will be closed unless it is rebased.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Induction-Induction
4 participants