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

Definition of weak-head-reduction and proof of unicity of derivations #543

Draft
wants to merge 208 commits into
base: coq-8.11
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
8434f9f
WIP
jakobbotsch Dec 11, 2020
316f303
WIP
jakobbotsch Dec 12, 2020
94fe9bf
Updated template-coq to new case representation
mattam82 Dec 14, 2020
0abf8ec
Started updating PCUIC
mattam82 Dec 14, 2020
9c742bb
WIP in lift_subst. Needs better solve_all
mattam82 Dec 14, 2020
1657d71
Extend All_Forall with OnOne2i theory
mattam82 Dec 15, 2020
67e2469
Update typing and reduction to new branch representation. Also factor…
mattam82 Dec 15, 2020
ef2f53c
Generalize map_predicate to take a universe instance mapping function.
mattam82 Dec 16, 2020
1b73236
WP in PCUIC
mattam82 Dec 16, 2020
84c53b3
WIP in reduction
mattam82 Dec 17, 2020
f502f79
New PCUICCases file with context building predicates. Finished updati…
mattam82 Dec 19, 2020
533bef5
Improve predicate equality to take care of binder relevance annotations
mattam82 Dec 19, 2020
bae4d15
Finished (partial) PCUICNameless proof
mattam82 Dec 19, 2020
a9c5ab8
WIP in PCUICClosed
mattam82 Dec 19, 2020
50f153d
Finished PCUICClosed
mattam82 Dec 19, 2020
49909c5
In PCUICNormal. will need to rely on wf environment
mattam82 Dec 19, 2020
b1f09a6
Trying to find the right hypotheses on reduction: everything gets ugl…
mattam82 Dec 21, 2020
30c94e2
Bite the bullet and cleanup the representation of constructors of ind…
mattam82 Dec 21, 2020
a3d5866
WIP with cleaned-up inductive and constructor representation
mattam82 Dec 21, 2020
0f21b68
WIP renaming
mattam82 Dec 21, 2020
7a73d53
Done up to TypingWf
mattam82 Dec 21, 2020
e4aae53
Updated upto PCUICTyping
mattam82 Dec 21, 2020
54ed6d4
PCUICNormal working now
mattam82 Dec 21, 2020
ebc9216
Directly map on constructor list in case reduction
mattam82 Dec 21, 2020
138ca1f
Now in sigmacalculus. Need to cleanup substitution/lifting lemmas for…
mattam82 Dec 21, 2020
a9f14aa
WIP proviing renaming lemma
mattam82 Dec 22, 2020
676f1b2
Cleanup PCUICClosed to use the right unfolding behaviors
mattam82 Dec 22, 2020
c61c55c
Almost complete nameless proof
mattam82 Dec 23, 2020
be5f608
De bruijn bug in map_constructor_body...
mattam82 Dec 23, 2020
528de5b
Cleaning up sigma calculus proofs
mattam82 Dec 23, 2020
6714426
Fix replace.sh
mattam82 Dec 23, 2020
4f55189
Switched arguments of declared_inductive
mattam82 Dec 23, 2020
ff845cc
Fic declared_constructor argument order
mattam82 Dec 23, 2020
c294bd7
Change declared_projection argument order
mattam82 Dec 23, 2020
bd32ff3
Big refactoring / cleanup of sigma calculus
mattam82 Dec 23, 2020
289b8b5
SigmaCalculus is now self-contained and does not depend on Closed
mattam82 Dec 23, 2020
0a205ee
Better induction principle for "generated" contexts (fix/case/branches)
mattam82 Dec 24, 2020
fbd5584
Refactoring and proving renaming theorem
mattam82 Dec 24, 2020
d18eb24
Completed renaming proof with new case.
mattam82 Dec 24, 2020
dc507c2
Prove weakening... from instantiation
mattam82 Dec 24, 2020
f7a3612
Strenghten renaming theorem for exchange and strengthening.
mattam82 Dec 26, 2020
bc2366b
WIP finishing strengthening
mattam82 Dec 26, 2020
8a5c296
WIP on renaming proofs carrying variable information
mattam82 Dec 26, 2020
2f37033
Finished proof that reduction preserves free variables
mattam82 Dec 27, 2020
78881fd
Need to think about how to state the exchange lemma
mattam82 Dec 27, 2020
537b9d3
Proven renaming for shiftnP predicate
mattam82 Dec 27, 2020
d2df801
Play with strengthening: not provable inductively as conversions can …
mattam82 Dec 28, 2020
5dd9644
Verified proof idea for strengthening (will have to come after subjec…
mattam82 Dec 28, 2020
2a53557
Cleanup Weakening, move on_free_vars to a separate library
mattam82 Jan 4, 2021
82c7d4e
WIP in instantiation theorem
mattam82 Jan 4, 2021
eb7f0b4
Only instantiation for cumulativity remaining
mattam82 Jan 5, 2021
80c662c
Only eq_term upto instantiation remains
mattam82 Jan 5, 2021
1e119c6
Finished instantiation proof
mattam82 Jan 5, 2021
81aa326
Updating substitution and universe instantiation
mattam82 Jan 6, 2021
6f8fdd9
Before moving to overloaded subst_instance operation everywhere
mattam82 Jan 6, 2021
24e6b2c
Use overloaded subst_instance in template-coq
mattam82 Jan 6, 2021
43c13cc
Cleanup name of subst_instance lemmatas
mattam82 Jan 6, 2021
3da3351
Half of universe instantiation done
mattam82 Jan 6, 2021
9e58182
Updated univ substitution
mattam82 Jan 7, 2021
50190ca
Finished implementing substitution through instantiation. substitutio…
mattam82 Jan 7, 2021
3f6d0b8
WIP in substitution lemmas
mattam82 Jan 7, 2021
c2be5a1
Finished substitution
mattam82 Jan 8, 2021
bb61a04
Updating Parallel Reduction to carry well-formedness predicates
mattam82 Jan 8, 2021
fe9dfa2
Try a simpler solution for pred allowing reflexivity on case
mattam82 Jan 8, 2021
ec88526
WIP
mattam82 Jan 8, 2021
a891b73
Move to PCUIC having expanded contexts in Case nodes
mattam82 Jan 9, 2021
f954b2c
Template <-> PCUIC translations defined
mattam82 Jan 11, 2021
dc07622
Main infrastructure lemmas on contexts in cases proven
mattam82 Jan 11, 2021
2fe7460
Updated SigmaCalculus proofs
mattam82 Jan 12, 2021
5cca998
WIP in equality, now needing context equality
mattam82 Jan 12, 2021
13d4718
Updated Equality
mattam82 Jan 12, 2021
cafa9de
WIP in simplifying reduction
mattam82 Jan 12, 2021
dd0481f
Updated Typing to add new context conversion premisses
mattam82 Jan 13, 2021
7db4e9b
WeakeningEnv and Nameless updated
mattam82 Jan 13, 2021
c2be4d0
Move EqDec instance for Ast.term away from Reflect, so as not to poll…
mattam82 Jan 13, 2021
e803b97
Fix module includes to avoid growing rewrite databases for nothing
mattam82 Jan 13, 2021
e358ebe
Adapted PCUICNormal
mattam82 Jan 13, 2021
51005a2
WIP in PCUICClosed
mattam82 Jan 14, 2021
0df06e7
Updated Closed
mattam82 Jan 14, 2021
5d44820
Fully adapted PCUICNameless
mattam82 Jan 14, 2021
1173229
Adapted OnFreeVars
mattam82 Jan 14, 2021
dd68d3c
Adapt PCUICUnivSubstitution
mattam82 Jan 14, 2021
1a304a5
Adapted PCUICRename
mattam82 Jan 15, 2021
02827eb
Updated instantiation and substitution
mattam82 Jan 15, 2021
8dbf957
Need a new reduction rule on contexts as expected
mattam82 Jan 15, 2021
94bab92
WIP adapting Reduction to new reduction rules on contexts in cases
mattam82 Jan 15, 2021
8d10ecc
Updating UnivSubstitution
mattam82 Jan 16, 2021
3474c64
WIP in reduction is good
mattam82 Jan 16, 2021
a4f294a
Complete the theory of context reduction
mattam82 Jan 17, 2021
af59042
Updated upto instantiation and normal
mattam82 Jan 17, 2021
1b8909d
WIP lifting parallel reduction to new case context reductions
mattam82 Jan 17, 2021
beae36c
Substitutivity of parallel reduction
mattam82 Jan 17, 2021
f9135de
WIP adapting rho function
mattam82 Jan 17, 2021
c6b25ea
WIP in confluence proof
mattam82 Jan 18, 2021
289abdb
Showing that rho_ctx is stable under renaming
mattam82 Jan 19, 2021
fd4193a
WIP in parallel reduction confluence
mattam82 Jan 19, 2021
12a894a
rho match case finished
mattam82 Jan 20, 2021
87c754e
Finished updating confluence proof
mattam82 Jan 20, 2021
1771da3
WIP in finishing confluence proof
mattam82 Jan 20, 2021
f13b508
Move eq_predicate Equivalence instances in separate lemmas
mattam82 Jan 20, 2021
967bd80
Shown commnutation of eq_term and reduction
mattam82 Jan 20, 2021
dfc0c54
Need to fix problem of name preservation missing from All2_local_env
mattam82 Jan 20, 2021
8c05bb7
Before replacing All2_local_env
mattam82 Jan 20, 2021
1e33a4f
Factorize similar context relations into a general one
mattam82 Jan 21, 2021
1484164
Adapted confluence proof to new, correct context relation structure
mattam82 Jan 21, 2021
b16284a
Back in confluence with the right definitions
mattam82 Jan 21, 2021
b60ac24
Refine RedTypeIrrelevance: only body reduction matters
mattam82 Jan 21, 2021
1ba2a31
Finish confluence proofs (up to alpha-equivalence as well)
mattam82 Jan 21, 2021
3be9be0
Refine red type irrelevance: it preserves the step number
mattam82 Jan 21, 2021
6426108
WIP in Context Conversion
mattam82 Jan 21, 2021
692473a
Context Cumulativity/Conversion done
mattam82 Jan 21, 2021
e67b09a
Now in the safe zone :) Adapting conversion lemmas
mattam82 Jan 21, 2021
8ee93d4
Fix definition of comparison of declarations
mattam82 Jan 21, 2021
60a73ed
Finished conversion (one todo left)
mattam82 Jan 22, 2021
2f6fb43
In inversion
mattam82 Jan 22, 2021
4bc6923
TODOs in PCUICToTemplate
mattam82 Jan 22, 2021
f8d1a0c
Remove unused PCUICtxShape
mattam82 Jan 22, 2021
2f220ef
Before renaming fold_context
mattam82 Jan 22, 2021
61b6bb8
WIP renaming fold_context to fold_context_k
mattam82 Jan 22, 2021
45706c5
TODOs
mattam82 Jan 22, 2021
c805902
Adapted Inductives (rather easily!)
mattam82 Jan 22, 2021
3dae729
WIP in InductiveInversion
mattam82 Jan 23, 2021
801b5ad
Finished updating InductiveInversion!
mattam82 Jan 23, 2021
b1c14d4
Adapted SR (todos for Case)
mattam82 Jan 23, 2021
710919d
Adapted TemplateToPCUIC (most is todo, corrected statement of transla…
mattam82 Jan 23, 2021
d328f95
Updated Alpha conversion proof. Could be derivable from nameless (or …
mattam82 Jan 23, 2021
f7b4c00
Adapted WcbvEval entirely
mattam82 Jan 23, 2021
fad7667
Adapted SafeLemmatas, some todos on stacks left
mattam82 Jan 23, 2021
5684127
SN and cumulprop done (some todos left)
mattam82 Jan 23, 2021
888f66b
Principality with todos (does not look too hard :)
mattam82 Jan 23, 2021
00147fa
Fixed elimination (little change in statements)
mattam82 Jan 23, 2021
ca6542e
Canonicity and ConvCumInversion (with some admits)
mattam82 Jan 23, 2021
6c81863
Updated WfReduction (no todos)
mattam82 Jan 24, 2021
b6bc547
PCUICErrors updated
mattam82 Jan 24, 2021
c60a54f
Adapted EqualityDec
mattam82 Jan 24, 2021
b5950b2
Fix weird bug with make vos in WcbvEval
mattam82 Jan 24, 2021
0d696d4
Updated EqualityDec
mattam82 Jan 24, 2021
1811999
Safe Reduce updated (with todos)
mattam82 Jan 24, 2021
63cca49
Fix definitions of predicate/branch conversion
mattam82 Jan 24, 2021
2a0b944
In Safe Retyping
mattam82 Jan 24, 2021
5d01f18
Updated SafeConversion
mattam82 Jan 24, 2021
7821f3f
Finished updating safechecker (some todos left)
mattam82 Jan 25, 2021
3d8a8e8
Finished with the checker
mattam82 Jan 25, 2021
744d46d
Updated erasure (with some todos)
mattam82 Jan 25, 2021
8beb451
Update PCUICConversion, PCUICNormal, PCUICConvCumInversion
jakobbotsch Jan 26, 2021
d684cce
Update safe reduction soundness, still missing completeness
jakobbotsch Jan 27, 2021
ad72f4a
Remove unneeded file
mattam82 Jan 25, 2021
3d5c348
Update reification/quoting of inductives and cases
mattam82 Jan 27, 2021
675fbda
Remove spurious Locate command
mattam82 Jan 27, 2021
309a3f5
Add a utility function in AstUtils to go from the old representation …
mattam82 Jan 27, 2021
22cfd3f
All plugins compile
mattam82 Jan 27, 2021
fcae1e0
Add monad_utils as a dependency to the template monad plugin (useful …
mattam82 Jan 27, 2021
4a97025
Adapted translations (todo in param_original, wrong on case and induc…
mattam82 Jan 27, 2021
16c25e5
Add convenience constructors in AstUtils for building inductive and c…
mattam82 Jan 27, 2021
ccecc44
Fix the test-suite, and improve Pretty to print environments
mattam82 Jan 27, 2021
6f81b2c
Fix test-suite scripts
mattam82 Jan 27, 2021
ebde62a
A bug revealed by the safe checker, probably in reification
mattam82 Jan 27, 2021
fdbb0c6
Fix an order bug in iota_red! The arguments where substituted in the …
mattam82 Jan 28, 2021
c34dbb8
Params were substituted in the wrong order in case contexts too, fixed
mattam82 Jan 28, 2021
f571a5e
Better printer for type-checking/conversion errors
mattam82 Jan 28, 2021
dfb9f4a
SafeChecker tests passing again
mattam82 Jan 28, 2021
51ba714
Finally everything compiles
mattam82 Jan 28, 2021
a3c3a5f
Finish safe reduction
jakobbotsch Jan 28, 2021
fc66073
New ctx_inst hypothesis in Typing
mattam82 Jan 28, 2021
6151fe9
Finished validity proof
mattam82 Jan 29, 2021
cabe334
Also include the (derivable) consistent_instance_ext hyp in cases for…
mattam82 Jan 29, 2021
f8ddf7c
Renaming of validity_term to validity
mattam82 Jan 29, 2021
19eae80
Update PCUICSafeLemmata, various refactorings
jakobbotsch Feb 1, 2021
6866edc
Add a lemma relating typing_spine and ctx_inst
mattam82 Feb 1, 2021
836228f
Prove lemmas showing ctx_inst plays well with cumulativity of inducti…
mattam82 Feb 2, 2021
68cff52
Update safe conversion for new representation
jakobbotsch Feb 5, 2021
269313f
Some cleanup
jakobbotsch Feb 8, 2021
9e5392d
Fix error
jakobbotsch Feb 8, 2021
3a6d451
Update case inversion data and fix some todos
jakobbotsch Feb 9, 2021
54b814b
Shorten some lemmas in Sigma-Calculus using the algebraic identities
mattam82 Feb 3, 2021
3487e11
Move subst_consn_lt' to sigma calculus
mattam82 Feb 3, 2021
ed91b57
Simplify closed_subst_map_lift proof using sigma-calculus instead of …
mattam82 Feb 3, 2021
fabaaed
Minor refactorings in sigma-calculus proofs
mattam82 Feb 3, 2021
223b5f2
WIP in inductive inversion
mattam82 Feb 6, 2021
8e88469
WIP in typing of branches still.
mattam82 Feb 9, 2021
8560127
Fix duplication in conversion, and add missing injectivity of product…
mattam82 Feb 9, 2021
ce09486
Finally finished build_branches_types_wt proof, using more general le…
mattam82 Feb 9, 2021
6ccd915
PCUICEqualityDec moved to PCUIC for now
mattam82 Feb 9, 2021
a9fc669
finish aux lemma and cleanup PCUICInductiveInversion
mattam82 Feb 9, 2021
364f8ee
Fix broken install of template-coq as some files are no longer needed
mattam82 Feb 9, 2021
5fbcc40
More fixes for the safechecker and erasure plugins
mattam82 Feb 9, 2021
5daa2f6
WIP in SR, much simpler now
mattam82 Feb 10, 2021
31ca371
Before trying subst_app_simpl instead
mattam82 Feb 10, 2021
c3e2da3
Finished and cleaned up iota reduction type preservation
mattam82 Feb 11, 2021
75393b0
Checked that congruence for params can be proved without changing the…
mattam82 Feb 11, 2021
bb333db
Fix typing rule for SR (equivalent under context conversion)
mattam82 Feb 11, 2021
48e75f8
Almost done in SR, only a refactoring is needed to avoid duplication,…
mattam82 Feb 12, 2021
fab0cae
Refactored wf_case_branches_types for reuse in SR proof
mattam82 Feb 12, 2021
8d1c85d
Finished Subject Reduction for cases!
mattam82 Feb 12, 2021
8b06578
Admit free subject reduction proof
mattam82 Feb 13, 2021
f748140
Refactorings to finish PCUICAlpha
mattam82 Feb 13, 2021
c2167f0
Refactor proofs so that alpha-conversion is not needed for PCUICInduc…
mattam82 Feb 13, 2021
aeab3a6
Complete alpha-conversion proof
mattam82 Feb 14, 2021
5c3255f
Cleaned up notations in PCUICAlpha, move generic lemmas up
mattam82 Feb 14, 2021
32b9b75
More move of generic lemmas back in the prelude
mattam82 Feb 14, 2021
69f7030
Minor refactorings
mattam82 Feb 15, 2021
9e4600e
Fill TODOs in CumulProp and Principality.
mattam82 Feb 15, 2021
7547aac
Remove all TODOs in WfUniverse
mattam82 Feb 16, 2021
853b6c5
No more todos in PCUIC except for the correctness proofs of translations
mattam82 Feb 16, 2021
876c0aa
Cleanup PCUICElimination, removing old proofs
mattam82 Feb 16, 2021
01dcee1
Fix script in canonicity, len is more robust now
mattam82 Feb 16, 2021
f936a16
Fix script
mattam82 Feb 16, 2021
06f8089
Definition of weak-head-reduction and proof of unicity of derivations
mattam82 Feb 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,6 @@ erasure/src/pCUICTypeChecker.ml
erasure/src/pCUICTypeChecker.mli
erasure/src/pCUICPrimitive.ml
erasure/src/pCUICPrimitive.mli
erasure/src/pCUICCases.ml
erasure/src/pCUICCases.mli
template-coq/gen-src/specFloat.ml.rej
12 changes: 11 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
"label": "make",
"type": "shell",
"command": "make",
"problemMatcher": []
},
{
"label": "makevos",
"type": "shell",
"options": {
"cwd" : "pcuic",
},
"command": "opam exec -- make -f Makefile.pcuic vos",
"group": {
"kind": "build",
"isDefault": true
}
},
"problemMatcher": []
}
]
}
10 changes: 10 additions & 0 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ Quoting always produce fully qualified names. On the converse, unquoting allow t
have only partially qualified names and rely on Coq to resolve them. The commands
of the TemplateMonad also allow partially qualified names.

## Hint databases

The development uses three main hint databases:

- The "len" databases which gathers all relevant length lemmas (mainly list length lemmas
relevant to the operations). This database is large (> 100 lemmas) for a given theory
(PCUIC or Template-Coq) and it is advisable to not mix together both databases,
as autorewrite would become very slow.
BEWARE: If working in the PCUIC theory, do not require anything besides the BasicAst and utils modules from the Template-Coq module.
- The "pcuic" rewrite and auto database gathers lemmas helping solving side-conditions
of typing judgements.

## Options

Expand Down
18 changes: 14 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@
- Change Template-PCUIC translations to translate casts to applications of
identity functions (vm_cast, default_cast etc) to make the back and forth
the identity and derive weakening/substitution/etc.. from the PCUIC theorems.
Is that really better than identity functions?
Template -> PCUIC -> Template (in an environment extended with the identity functions)
becomes the identity, by translating back the cast function applications.
PCUIC -> Template -> PCUIC is also the identity, even by special casing on cast functions

# Big projects

- Cleaner version of the system for writing term manipulation and prooofs about them.
- Develop a cleaned-up syntax profiting from Coq's type system, e.g.:
- HOAS representation of binding or first-order well-scoped binding representation (using `fin` for example)
- Well-bounded global references?
- Using vectors and fin for fixpoint bodies lists and index (no ill-formed
fixpoints by construction)
- Develop a proof mode for MetaCoq typing, à la Iris proof mode

- Refine the longest-simple-path algorithm on universes with the
Bender & al algorithm used in Coq, extended with edges of negative weight.
Alternatively prove the spec for that algorithm. Refinement might be easier:
Expand All @@ -49,14 +60,13 @@

- Verify parsing and printing of terms / votour

- Primivite projections: we could be more relaxed on the elimination sort of the
- Primitive projections: we could be more relaxed on the elimination sort of the
inductive. If it is e.g. InProp, then all projections to types in Prop should
be definable. Probably not very useful though because if the elimination is
restricted then it means some Type is in the constructor and won't be projectable.

- Verify the substitution calculus of P.M Pédrot using skewed lists at
https://github.com/coq/coq/pull/13537 and try to use it to implement efficient explicit
substitutions.
https://github.com/coq/coq/pull/13537 and try to use it to implement efficient explicit substitutions.

## Website

Expand Down
12 changes: 2 additions & 10 deletions erasure/_PluginProject.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
-Q src MetaCoq.Erasure
-R theories MetaCoq.Erasure

src/init.mli
src/init.ml
# src/classes0.mli
# src/classes0.ml

Expand All @@ -17,8 +15,6 @@ src/orderedTypeAlt.ml

src/ssrbool.ml
src/ssrbool.mli
src/monad_utils.ml
src/monad_utils.mli
src/uGraph0.ml
src/uGraph0.mli
src/wGraph.ml
Expand All @@ -35,20 +31,16 @@ src/pCUICPrimitive.mli
src/pCUICPrimitive.ml
src/pCUICAst.ml
src/pCUICAst.mli
src/pCUICCases.mli
src/pCUICCases.ml
src/pCUICAstUtils.ml
src/pCUICAstUtils.mli
src/pCUICLiftSubst.ml
src/pCUICLiftSubst.mli
# src/eqDecInstances.ml
# src/eqDecInstances.mli
src/pCUICReduction.ml
src/pCUICReduction.mli
src/pCUICTyping.ml
src/pCUICTyping.mli
src/pCUICUnivSubst.ml
src/pCUICUnivSubst.mli
# src/pCUICCumulativity.mli
# src/pCUICCumulativity.ml
src/pCUICPosition.mli
src/pCUICPosition.ml
src/pCUICNormal.mli
Expand Down
5 changes: 1 addition & 4 deletions erasure/src/metacoq_erasure_plugin.mlpack
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Monad_utils
MSetWeakList
EqdepFacts
Ssrbool
Expand All @@ -9,16 +8,14 @@ UGraph0
OrderedTypeAlt
Kernames

Init
Classes0
Logic1
Relation
Relation_Properties
PCUICPrimitive
PCUICAst
PCUICCases
PCUICAstUtils
PCUICUnivSubst
PCUICLiftSubst
EqDecInstances
PCUICEquality
PCUICTyping
Expand Down
46 changes: 22 additions & 24 deletions erasure/theories/EArities.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Qed.

Lemma isArity_ind_type (Σ : global_env_ext) mind ind idecl :
wf Σ ->
declared_inductive (fst Σ) mind ind idecl ->
declared_inductive (fst Σ) ind mind idecl ->
isArity (ind_type idecl).
Proof.
intros.
Expand Down Expand Up @@ -92,21 +92,21 @@ Proof.
Qed.

Lemma typing_spine_red :
forall (Σ : PCUICAst.global_env_ext) Γ (args args' : list PCUICAst.term) (X : All2 (red Σ Γ) args args') (bla : wf Σ)
forall (Σ : global_env_ext) Γ (args args' : list PCUICAst.term) (X : All2 (red Σ Γ) args args') (bla : wf Σ)
(T x x0 : PCUICAst.term) (t0 : typing_spine Σ Γ x args x0) (c : Σ;;; Γ |- x0 <= T) (x1 : PCUICAst.term)
(c0 : Σ;;; Γ |- x1 <= x), isType Σ Γ T -> typing_spine Σ Γ x1 args' T.
Proof.
intros Σ Γ args args' X wf T x x0 t0 c x1 c0 ?. revert args' X.
dependent induction t0; intros.
- inv X. econstructor. eauto. eapply PCUICConversion.cumul_trans. assumption.
eauto. eapply PCUICConversion.cumul_trans. assumption. eauto. eauto.
- inv X. econstructor. eauto. eapply cumul_trans. assumption.
eauto. eapply cumul_trans. assumption. eauto. eauto.
- inv X. econstructor.
+ eauto.
+ eapply PCUICConversion.cumul_trans ; eauto.
+ eapply cumul_trans ; eauto.
+ eapply subject_reduction; eauto.
+ eapply IHt0; eauto.
eapply PCUICCumulativity.red_cumul_inv.
unfold PCUICLiftSubst.subst1.
unfold subst1.
eapply (red_red Σ Γ [_] [] [_] [_]).
eauto. econstructor. eauto. econstructor. econstructor. econstructor.
Grab Existential Variables. all: repeat econstructor.
Expand Down Expand Up @@ -199,9 +199,8 @@ Proof.
revert c0 t0 i. generalize x at 1 3.
intros x2 c0 t0 i.
assert (HWF : isType Σ Γ x2).
{ eapply PCUICValidity.validity.
- eauto.
- eapply type_mkApps. 2:eauto. eauto.
{ eapply PCUICValidity.validity; tea.
eapply type_mkApps. 2:eauto. eauto.
}
eapply inversion_Construct in t as (? & ? & ? & ? & ? & ? & ?) ; auto. (* destruct x5. destruct p. cbn in *. *)
assert (HL : #|ind_bodies x3| > 0).
Expand All @@ -212,24 +211,24 @@ Proof.
(* eapply isArity_typing_spine_inv in t0; eauto. *)
(* destruct t0 as (? & [] & ?). *)
(* eapply PCUICCumulativity.red_cumul in X. *)
destruct (PCUICWeakeningEnv.on_declared_constructor _ d) as [XX [s [XX1 Ht]]].
destruct x5 as [[? ?] ?]; cbn in *; subst.
destruct Ht. unfold cdecl_type in cstr_eq. simpl in cstr_eq. subst.
destruct (PCUICWeakeningEnv.on_declared_constructor d) as [XX [s [XX1 Ht]]].
destruct x5 as []; cbn in *; subst.
destruct Ht; cbn in *. subst.
change PCUICEnvironment.it_mkProd_or_LetIn with it_mkProd_or_LetIn in c2.
change PCUICEnvironment.ind_params with ind_params in *.
change PCUICEnvironment.to_extended_list_k with to_extended_list_k in *.
rewrite <- it_mkProd_or_LetIn_app in c2.
rewrite PCUICUnivSubst.subst_instance_constr_it_mkProd_or_LetIn in c2.
rewrite PCUICUnivSubst.subst_instance_constr_mkApps in c2.
rewrite PCUICSubstitution.subst_it_mkProd_or_LetIn in c2.
rewrite PCUICUnivSubst.subst_instance_it_mkProd_or_LetIn in c2.
rewrite PCUICUnivSubst.subst_instance_mkApps in c2.
rewrite subst_it_mkProd_or_LetIn in c2.
rewrite subst_mkApps in c2.
cbn in c2.
rewrite PCUICUnivSubst.subst_instance_context_length in c2.
rewrite subst_instance_length in c2.
rewrite app_length in c2.
destruct (Nat.leb_spec (#|cshape_args s| + #|ind_params x3| + 0) (#|ind_bodies x3| - S (inductive_ind ind) + #|ind_params x3| + #|cshape_args s|)). 2:lia.
destruct (Nat.leb_spec (#|cstr_args0| + #|ind_params x3| + 0) (#|ind_bodies x3| - S (inductive_ind ind) + #|ind_params x3| + #|cstr_args0|)). 2:lia.
clear H.
assert ((#|ind_bodies x3| - S (inductive_ind ind) + #|ind_params x3| +
#|cshape_args s| - (#|cshape_args s| + #|ind_params x3| + 0)) < #|inds (inductive_mind ind) u (ind_bodies x3)|).
#|cstr_args0| - (#|cstr_args0| + #|ind_params x3| + 0)) < #|inds (inductive_mind ind) u (ind_bodies x3)|).
{ rewrite inds_length. lia. }
eapply nth_error_Some in H.
destruct (nth_error (inds _ _ _) _) eqn:Heq; try congruence.
Expand Down Expand Up @@ -291,8 +290,7 @@ Proof.
intros x2 c0 t0 i.
assert (HWF : isType Σ Γ x2).
{ eapply PCUICValidity.validity.
- eauto.
- eapply type_mkApps. 2:eauto. eauto.
eapply type_mkApps. 2:eauto. eauto.
}
eapply inversion_CoFix in t as (? & ? & ? & ? & ? & ? & ?) ; auto.
eapply invert_cumul_arity_r in c0; eauto.
Expand All @@ -304,10 +302,10 @@ Proof.
eapply invert_cumul_arity_r_gen in c0; eauto.
destruct c0. destruct H as [[r] isA].
move: r; rewrite subst_it_mkProd_or_LetIn eqT; autorewrite with len.
rewrite expand_lets_mkApps subst_mkApps /=.
rewrite PCUICSigmaCalculus.expand_lets_mkApps subst_mkApps /=.
move/red_it_mkProd_or_LetIn_mkApps_Ind => [ctx' [args' eq]].
subst x4. now eapply it_mkProd_arity, isArity_mkApps in isA.
move: cum => [] Hx1; rewrite eqT expand_lets_mkApps subst_mkApps /= => cum.
move: cum => [] Hx1; rewrite eqT PCUICSigmaCalculus.expand_lets_mkApps subst_mkApps /= => cum.
eapply invert_cumul_arity_r_gen in c0; eauto.
destruct c0 as [? [[r] isA]].
eapply red_mkApps_tInd in r as [args' [eq _]]; auto.
Expand Down Expand Up @@ -445,7 +443,7 @@ Proof.
eapply PCUICCumulativity.red_cumul_inv in X.

eapply invert_cumul_arity_l in H0 as (? & ? & ?).
2: eapply PCUICConversion.cumul_trans; eauto.
2: eapply cumul_trans; eauto.
destruct H.
eapply typing_spine_red in t1. 2:{ eapply All_All2_refl.
clear. induction L; eauto. }
Expand Down Expand Up @@ -592,7 +590,7 @@ Lemma nIs_conv_to_Arity_isWfArity_elim {Σ : global_env_ext} {Γ x} :
Proof.
intros nis [isTy [ctx [s da]]]. apply nis.
red. exists (it_mkProd_or_LetIn ctx (tSort s)).
split. sq. apply PCUICArities.destArity_spec_Some in da.
split. sq. apply destArity_spec_Some in da.
simpl in da. subst x.
reflexivity.
now eapply it_mkProd_isArity.
Expand Down
Loading