From: Ferruccio Guidi Date: Fri, 3 Jun 2005 21:03:39 +0000 (+0000) Subject: contribution about \lambda-\delta X-Git-Tag: PRE_INDEX_1~72 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=1b21075e987872a2e3103203b4e67c939e4a9f6a;p=helm.git contribution about \lambda-\delta --- diff --git a/helm/coq-contribs/LAMBDA-TYPES.tgz b/helm/coq-contribs/LAMBDA-TYPES.tgz deleted file mode 100644 index 35fa962dd..000000000 Binary files a/helm/coq-contribs/LAMBDA-TYPES.tgz and /dev/null differ diff --git a/helm/coq-contribs/LAMBDA-TYPES/.cvsignore b/helm/coq-contribs/LAMBDA-TYPES/.cvsignore new file mode 100644 index 000000000..419956872 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/.cvsignore @@ -0,0 +1 @@ +*.vo diff --git a/helm/coq-contribs/LAMBDA-TYPES/.depend b/helm/coq-contribs/LAMBDA-TYPES/.depend new file mode 100644 index 000000000..881798e10 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/.depend @@ -0,0 +1,65 @@ +LambdaDelta.vo: LambdaDelta.v terms_defs.vo tlt_defs.vo contexts_defs.vo lift_defs.vo lift_gen.vo lift_props.vo lift_tlt.vo subst0_defs.vo subst0_gen.vo subst0_lift.vo subst0_subst0.vo subst0_confluence.vo subst0_tlt.vo subst1_defs.vo subst1_gen.vo subst1_lift.vo subst1_subst1.vo subst1_confluence.vo drop_defs.vo drop_props.vo csubst0_defs.vo csubst1_defs.vo pr0_defs.vo pr0_lift.vo pr0_gen.vo pr0_subst0.vo pr0_confluence.vo pr0_subst1.vo pr1_defs.vo pr1_confluence.vo pr2_defs.vo pr2_lift.vo pr2_gen.vo pr2_confluence.vo pr2_subst1.vo pr2_gen_context.vo pr3_defs.vo pr3_props.vo pr3_gen.vo pr3_confluence.vo pr3_subst1.vo pr3_gen_context.vo cpr0_defs.vo cpr0_props.vo pc1_defs.vo pc3_defs.vo pc3_props.vo pc3_gen.vo pc3_subst0.vo pc3_gen_context.vo ty0_defs.vo ty0_lift.vo ty0_props.vo ty0_subst0.vo ty0_gen_context.vo csub0_defs.vo ty0_sred.vo ty0_sred_props.vo +ty0_sred_props.vo: ty0_sred_props.v lift_props.vo drop_props.vo pc3_props.vo pc3_gen.vo ty0_defs.vo ty0_props.vo ty0_sred.vo +ty0_sred.vo: ty0_sred.v lift_gen.vo subst1_gen.vo csubst1_defs.vo pr0_lift.vo pr0_subst1.vo cpr0_defs.vo cpr0_props.vo pc3_props.vo pc3_gen.vo ty0_defs.vo ty0_lift.vo ty0_props.vo ty0_subst0.vo ty0_gen_context.vo csub0_defs.vo +csub0_defs.vo: csub0_defs.v ty0_defs.vo +ty0_gen_context.vo: ty0_gen_context.v lift_gen.vo lift_props.vo subst1_defs.vo subst1_lift.vo subst1_confluence.vo drop_props.vo csubst1_defs.vo pc3_gen.vo pc3_gen_context.vo ty0_defs.vo ty0_lift.vo +ty0_subst0.vo: ty0_subst0.v drop_props.vo csubst0_defs.vo pc3_props.vo pc3_subst0.vo ty0_defs.vo ty0_lift.vo ty0_props.vo +ty0_props.vo: ty0_props.v drop_props.vo pc3_props.vo ty0_defs.vo ty0_lift.vo +ty0_lift.vo: ty0_lift.v lift_props.vo drop_props.vo pc3_props.vo ty0_defs.vo +ty0_defs.vo: ty0_defs.v pc3_defs.vo +pc3_gen_context.vo: pc3_gen_context.v subst1_confluence.vo csubst1_defs.vo pr3_gen_context.vo pc3_defs.vo pc3_props.vo +pc3_subst0.vo: pc3_subst0.v subst0_subst0.vo csubst0_defs.vo pr0_subst0.vo pc3_defs.vo +pc3_gen.vo: pc3_gen.v lift_gen.vo pr3_props.vo pr3_gen.vo pc3_defs.vo pc3_props.vo +pc3_props.vo: pc3_props.v subst0_subst0.vo pr0_subst0.vo pr3_defs.vo pr3_props.vo pr3_confluence.vo cpr0_defs.vo cpr0_props.vo pc3_defs.vo +pc3_defs.vo: pc3_defs.v pr2_defs.vo pr3_defs.vo pc1_defs.vo +pc1_defs.vo: pc1_defs.v pr0_defs.vo +cpr0_props.vo: cpr0_props.v pr0_subst0.vo pr3_defs.vo pr3_props.vo cpr0_defs.vo +cpr0_defs.vo: cpr0_defs.v contexts_defs.vo pr0_defs.vo +pr3_gen_context.vo: pr3_gen_context.v csubst1_defs.vo pr2_gen_context.vo pr3_defs.vo +pr3_subst1.vo: pr3_subst1.v subst1_defs.vo pr2_subst1.vo pr3_defs.vo +pr3_confluence.vo: pr3_confluence.v pr2_confluence.vo pr3_defs.vo +pr3_gen.vo: pr3_gen.v pr2_gen.vo pr3_defs.vo pr3_props.vo +pr3_props.vo: pr3_props.v subst0_subst0.vo pr0_subst0.vo pr2_lift.vo pr3_defs.vo +pr3_defs.vo: pr3_defs.v pr1_defs.vo pr2_defs.vo +pr2_gen_context.vo: pr2_gen_context.v drop_props.vo subst1_gen.vo subst1_subst1.vo subst1_confluence.vo csubst1_defs.vo pr0_gen.vo pr0_subst1.vo pr2_defs.vo pr2_subst1.vo +pr2_subst1.vo: pr2_subst1.v subst1_defs.vo subst1_confluence.vo drop_props.vo pr0_subst1.vo pr2_defs.vo +pr2_confluence.vo: pr2_confluence.v subst0_confluence.vo drop_props.vo pr0_subst0.vo pr0_confluence.vo pr2_defs.vo +pr2_gen.vo: pr2_gen.v subst0_gen.vo drop_props.vo pr0_gen.vo pr2_defs.vo +pr2_lift.vo: pr2_lift.v subst0_lift.vo drop_props.vo pr0_lift.vo pr2_defs.vo +pr2_defs.vo: pr2_defs.v drop_defs.vo pr0_defs.vo +pr1_confluence.vo: pr1_confluence.v pr0_confluence.vo pr1_defs.vo +pr1_defs.vo: pr1_defs.v pr0_defs.vo +pr0_subst1.vo: pr0_subst1.v subst1_defs.vo pr0_defs.vo pr0_subst0.vo +pr0_confluence.vo: pr0_confluence.v tlt_defs.vo lift_gen.vo lift_tlt.vo subst0_gen.vo subst0_confluence.vo pr0_defs.vo pr0_lift.vo pr0_gen.vo pr0_subst0.vo +pr0_subst0.vo: pr0_subst0.v subst0_gen.vo subst0_lift.vo subst0_subst0.vo subst0_confluence.vo pr0_defs.vo pr0_lift.vo +pr0_gen.vo: pr0_gen.v lift_gen.vo lift_props.vo subst0_gen.vo pr0_defs.vo pr0_lift.vo +pr0_lift.vo: pr0_lift.v lift_props.vo subst0_lift.vo pr0_defs.vo +pr0_defs.vo: pr0_defs.v subst0_defs.vo +csubst1_defs.vo: csubst1_defs.v subst1_defs.vo csubst0_defs.vo +csubst0_defs.vo: csubst0_defs.v contexts_defs.vo subst0_defs.vo drop_defs.vo +drop_props.vo: drop_props.v lift_gen.vo drop_defs.vo +drop_defs.vo: drop_defs.v contexts_defs.vo lift_defs.vo +subst1_confluence.vo: subst1_confluence.v lift_gen.vo subst0_gen.vo subst0_confluence.vo subst1_defs.vo subst1_gen.vo +subst1_subst1.vo: subst1_subst1.v subst0_subst0.vo subst1_defs.vo +subst1_lift.vo: subst1_lift.v lift_props.vo subst0_lift.vo subst1_defs.vo +subst1_gen.vo: subst1_gen.v subst0_gen.vo subst1_defs.vo +subst1_defs.vo: subst1_defs.v subst0_defs.vo +subst0_tlt.vo: subst0_tlt.v tlt_defs.vo lift_tlt.vo subst0_defs.vo +subst0_confluence.vo: subst0_confluence.v lift_gen.vo subst0_gen.vo subst0_defs.vo +subst0_subst0.vo: subst0_subst0.v subst0_defs.vo subst0_gen.vo subst0_lift.vo +subst0_lift.vo: subst0_lift.v lift_props.vo subst0_defs.vo +subst0_gen.vo: subst0_gen.v lift_props.vo subst0_defs.vo +subst0_defs.vo: subst0_defs.v lift_defs.vo +lift_tlt.vo: lift_tlt.v tlt_defs.vo lift_defs.vo +lift_props.vo: lift_props.v lift_defs.vo +lift_gen.vo: lift_gen.v lift_defs.vo +lift_defs.vo: lift_defs.v terms_defs.vo +contexts_defs.vo: contexts_defs.v terms_defs.vo +tlt_defs.vo: tlt_defs.v terms_defs.vo +terms_defs.vo: terms_defs.v Base.vo +Base.vo: Base.v base_tactics.vo base_hints.vo base_types.vo base_blt.vo base_rewrite.vo +base_rewrite.vo: base_rewrite.v +base_blt.vo: base_blt.v base_tactics.vo base_hints.vo +base_types.vo: base_types.v base_tactics.vo base_hints.vo +base_hints.vo: base_hints.v base_tactics.vo +base_tactics.vo: base_tactics.v diff --git a/helm/coq-contribs/LAMBDA-TYPES/Base.v b/helm/coq-contribs/LAMBDA-TYPES/Base.v new file mode 100644 index 000000000..6015c1774 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/Base.v @@ -0,0 +1,7 @@ +Require Export Arith. +Require Export Wf_nat. +Require Export base_tactics. +Require Export base_hints. +Require Export base_types. +Require Export base_blt. +Require Export base_rewrite. diff --git a/helm/coq-contribs/LAMBDA-TYPES/LambdaDelta.v b/helm/coq-contribs/LAMBDA-TYPES/LambdaDelta.v new file mode 100644 index 000000000..ef5b4afbc --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/LambdaDelta.v @@ -0,0 +1,58 @@ +Require Export terms_defs. +Require Export tlt_defs. +Require Export contexts_defs. +Require Export lift_defs. +Require Export lift_gen. +Require Export lift_props. +Require Export lift_tlt. +Require Export subst0_defs. +Require Export subst0_gen. +Require Export subst0_lift. +Require Export subst0_subst0. +Require Export subst0_confluence. +Require Export subst0_tlt. +Require Export subst1_defs. +Require Export subst1_gen. +Require Export subst1_lift. +Require Export subst1_subst1. +Require Export subst1_confluence. +Require Export drop_defs. +Require Export drop_props. +Require Export csubst0_defs. +Require Export csubst1_defs. +Require Export pr0_defs. +Require Export pr0_lift. +Require Export pr0_gen. +Require Export pr0_subst0. +Require Export pr0_confluence. +Require Export pr0_subst1. +Require Export pr1_defs. +Require Export pr1_confluence. +Require Export pr2_defs. +Require Export pr2_lift. +Require Export pr2_gen. +Require Export pr2_confluence. +Require Export pr2_subst1. +Require Export pr2_gen_context. +Require Export pr3_defs. +Require Export pr3_props. +Require Export pr3_gen. +Require Export pr3_confluence. +Require Export pr3_subst1. +Require Export pr3_gen_context. +Require Export cpr0_defs. +Require Export cpr0_props. +Require Export pc1_defs. +Require Export pc3_defs. +Require Export pc3_props. +Require Export pc3_gen. +Require Export pc3_subst0. +Require Export pc3_gen_context. +Require Export ty0_defs. +Require Export ty0_lift. +Require Export ty0_props. +Require Export ty0_subst0. +Require Export ty0_gen_context. +Require Export csub0_defs. +Require Export ty0_sred. +Require Export ty0_sred_props. diff --git a/helm/coq-contribs/LAMBDA-TYPES/Make b/helm/coq-contribs/LAMBDA-TYPES/Make new file mode 100644 index 000000000..0a3e0514c --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/Make @@ -0,0 +1,66 @@ +# List of vernac files to compile +base_tactics.v +base_hints.v +base_types.v +base_blt.v +base_rewrite.v +Base.v +terms_defs.v +tlt_defs.v +contexts_defs.v +lift_defs.v +lift_gen.v +lift_props.v +lift_tlt.v +subst0_defs.v +subst0_gen.v +subst0_lift.v +subst0_subst0.v +subst0_confluence.v +subst0_tlt.v +subst1_defs.v +subst1_gen.v +subst1_lift.v +subst1_subst1.v +subst1_confluence.v +drop_defs.v +drop_props.v +csubst0_defs.v +csubst1_defs.v +pr0_defs.v +pr0_lift.v +pr0_gen.v +pr0_subst0.v +pr0_confluence.v +pr0_subst1.v +pr1_defs.v +pr1_confluence.v +pr2_defs.v +pr2_lift.v +pr2_gen.v +pr2_confluence.v +pr2_subst1.v +pr2_gen_context.v +pr3_defs.v +pr3_props.v +pr3_gen.v +pr3_confluence.v +pr3_subst1.v +pr3_gen_context.v +cpr0_defs.v +cpr0_props.v +pc1_defs.v +pc3_defs.v +pc3_props.v +pc3_gen.v +pc3_subst0.v +pc3_gen_context.v +ty0_defs.v +ty0_lift.v +ty0_props.v +ty0_subst0.v +ty0_gen_context.v +csub0_defs.v +ty0_sred.v +ty0_sred_props.v +LambdaDelta.v diff --git a/helm/coq-contribs/LAMBDA-TYPES/Makefile b/helm/coq-contribs/LAMBDA-TYPES/Makefile new file mode 100644 index 000000000..b3936376b --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/Makefile @@ -0,0 +1,352 @@ +############################################################################## +## The Calculus of Inductive Constructions ## +## ## +## Projet Coq ## +## ## +## INRIA ENS-CNRS ## +## Rocquencourt Lyon ## +## ## +## Coq V7 ## +## ## +## ## +############################################################################## + +# WARNING +# +# This Makefile has been automagically generated by coq_makefile +# Edit at your own risks ! +# +# END OF WARNING + +# +# This Makefile was generated by the command line : +# coq_makefile -f Make -o Makefile +# + +########################## +# # +# Variables definitions. # +# # +########################## + +CAMLP4LIB=`camlp4 -where` +COQSRC=-I $(COQTOP)/kernel -I $(COQTOP)/lib \ + -I $(COQTOP)/library -I $(COQTOP)/parsing -I $(COQTOP)/pretyping \ + -I $(COQTOP)/proofs -I $(COQTOP)/syntax -I $(COQTOP)/tactics \ + -I $(COQTOP)/toplevel -I $(CAMLP4LIB) +ZFLAGS=$(OCAMLLIBS) $(COQSRC) +OPT= +COQFLAGS=-q $(OPT) $(COQLIBS) +COQC=$(COQBIN)coqc +GALLINA=gallina +COQWEB=coqweb +CAMLC=ocamlc -c +CAMLOPTC=ocamlopt -c +CAMLLINK=ocamlc +CAMLOPTLINK=ocamlopt +COQDEP=$(COQBIN)coqdep -c +COQVO2XML=coq_vo2xml + +######################### +# # +# Libraries definition. # +# # +######################### + +OCAMLLIBS=-I . +COQLIBS=-I . + +################################### +# # +# Definition of the "all" target. # +# # +################################### + +VFILES=base_tactics.v\ + base_hints.v\ + base_types.v\ + base_blt.v\ + base_rewrite.v\ + Base.v\ + terms_defs.v\ + tlt_defs.v\ + contexts_defs.v\ + lift_defs.v\ + lift_gen.v\ + lift_props.v\ + lift_tlt.v\ + subst0_defs.v\ + subst0_gen.v\ + subst0_lift.v\ + subst0_subst0.v\ + subst0_confluence.v\ + subst0_tlt.v\ + subst1_defs.v\ + subst1_gen.v\ + subst1_lift.v\ + subst1_subst1.v\ + subst1_confluence.v\ + drop_defs.v\ + drop_props.v\ + csubst0_defs.v\ + csubst1_defs.v\ + pr0_defs.v\ + pr0_lift.v\ + pr0_gen.v\ + pr0_subst0.v\ + pr0_confluence.v\ + pr0_subst1.v\ + pr1_defs.v\ + pr1_confluence.v\ + pr2_defs.v\ + pr2_lift.v\ + pr2_gen.v\ + pr2_confluence.v\ + pr2_subst1.v\ + pr2_gen_context.v\ + pr3_defs.v\ + pr3_props.v\ + pr3_gen.v\ + pr3_confluence.v\ + pr3_subst1.v\ + pr3_gen_context.v\ + cpr0_defs.v\ + cpr0_props.v\ + pc1_defs.v\ + pc3_defs.v\ + pc3_props.v\ + pc3_gen.v\ + pc3_subst0.v\ + pc3_gen_context.v\ + ty0_defs.v\ + ty0_lift.v\ + ty0_props.v\ + ty0_subst0.v\ + ty0_gen_context.v\ + csub0_defs.v\ + ty0_sred.v\ + ty0_sred_props.v\ + LambdaDelta.v +VOFILES=$(VFILES:.v=.vo) +VIFILES=$(VFILES:.v=.vi) +GFILES=$(VFILES:.v=.g) +HTMLFILES=$(VFILES:.v=.html) +GHTMLFILES=$(VFILES:.v=.g.html) + +all: base_tactics.vo\ + base_hints.vo\ + base_types.vo\ + base_blt.vo\ + base_rewrite.vo\ + Base.vo\ + terms_defs.vo\ + tlt_defs.vo\ + contexts_defs.vo\ + lift_defs.vo\ + lift_gen.vo\ + lift_props.vo\ + lift_tlt.vo\ + subst0_defs.vo\ + subst0_gen.vo\ + subst0_lift.vo\ + subst0_subst0.vo\ + subst0_confluence.vo\ + subst0_tlt.vo\ + subst1_defs.vo\ + subst1_gen.vo\ + subst1_lift.vo\ + subst1_subst1.vo\ + subst1_confluence.vo\ + drop_defs.vo\ + drop_props.vo\ + csubst0_defs.vo\ + csubst1_defs.vo\ + pr0_defs.vo\ + pr0_lift.vo\ + pr0_gen.vo\ + pr0_subst0.vo\ + pr0_confluence.vo\ + pr0_subst1.vo\ + pr1_defs.vo\ + pr1_confluence.vo\ + pr2_defs.vo\ + pr2_lift.vo\ + pr2_gen.vo\ + pr2_confluence.vo\ + pr2_subst1.vo\ + pr2_gen_context.vo\ + pr3_defs.vo\ + pr3_props.vo\ + pr3_gen.vo\ + pr3_confluence.vo\ + pr3_subst1.vo\ + pr3_gen_context.vo\ + cpr0_defs.vo\ + cpr0_props.vo\ + pc1_defs.vo\ + pc3_defs.vo\ + pc3_props.vo\ + pc3_gen.vo\ + pc3_subst0.vo\ + pc3_gen_context.vo\ + ty0_defs.vo\ + ty0_lift.vo\ + ty0_props.vo\ + ty0_subst0.vo\ + ty0_gen_context.vo\ + csub0_defs.vo\ + ty0_sred.vo\ + ty0_sred_props.vo\ + LambdaDelta.vo + +spec: $(VIFILES) + +gallina: $(GFILES) + +html: $(HTMLFILES) + +gallinahtml: $(GHTMLFILES) + +all.ps: $(VFILES) + $(COQWEB) -ps -o $@ `$(COQDEP) -sort -suffix .v $(VFILES)` + +all-gal.ps: $(GFILES) + $(COQWEB) -ps -o $@ `$(COQDEP) -sort -suffix .g $(VFILES)` + +xml:: .xml_time_stamp +.xml_time_stamp: base_tactics.vo\ + base_hints.vo\ + base_types.vo\ + base_blt.vo\ + base_rewrite.vo\ + Base.vo\ + terms_defs.vo\ + tlt_defs.vo\ + contexts_defs.vo\ + lift_defs.vo\ + lift_gen.vo\ + lift_props.vo\ + lift_tlt.vo\ + subst0_defs.vo\ + subst0_gen.vo\ + subst0_lift.vo\ + subst0_subst0.vo\ + subst0_confluence.vo\ + subst0_tlt.vo\ + subst1_defs.vo\ + subst1_gen.vo\ + subst1_lift.vo\ + subst1_subst1.vo\ + subst1_confluence.vo\ + drop_defs.vo\ + drop_props.vo\ + csubst0_defs.vo\ + csubst1_defs.vo\ + pr0_defs.vo\ + pr0_lift.vo\ + pr0_gen.vo\ + pr0_subst0.vo\ + pr0_confluence.vo\ + pr0_subst1.vo\ + pr1_defs.vo\ + pr1_confluence.vo\ + pr2_defs.vo\ + pr2_lift.vo\ + pr2_gen.vo\ + pr2_confluence.vo\ + pr2_subst1.vo\ + pr2_gen_context.vo\ + pr3_defs.vo\ + pr3_props.vo\ + pr3_gen.vo\ + pr3_confluence.vo\ + pr3_subst1.vo\ + pr3_gen_context.vo\ + cpr0_defs.vo\ + cpr0_props.vo\ + pc1_defs.vo\ + pc3_defs.vo\ + pc3_props.vo\ + pc3_gen.vo\ + pc3_subst0.vo\ + pc3_gen_context.vo\ + ty0_defs.vo\ + ty0_lift.vo\ + ty0_props.vo\ + ty0_subst0.vo\ + ty0_gen_context.vo\ + csub0_defs.vo\ + ty0_sred.vo\ + ty0_sred_props.vo\ + LambdaDelta.vo + $(COQVO2XML) $(COQFLAGS) $(?:%.o=%) + touch .xml_time_stamp + +#################### +# # +# Special targets. # +# # +#################### + +.PHONY: all opt byte archclean clean install depend xml + +.SUFFIXES: .v .vo .vi .g .html .tex .g.tex .g.html + +.v.vo: + $(COQC) $(COQDEBUG) $(COQFLAGS) $* + +.v.vi: + $(COQC) -i $(COQDEBUG) $(COQFLAGS) $* + +.v.g: + $(GALLINA) $< + +.v.tex: + $(COQWEB) $< -o $@ + +.v.html: + $(COQWEB) -html $< -o $@ + +.g.g.tex: + $(COQWEB) $< -o $@ + +.g.g.html: + $(COQWEB) -html $< -o $@ + +byte: + $(MAKE) all "OPT=" + +opt: + $(MAKE) all "OPT=-opt" + +include .depend + +depend: + rm .depend + $(COQDEP) -i $(COQLIBS) *.v *.ml *.mli >.depend + $(COQDEP) $(COQLIBS) -suffix .html *.v >>.depend + +xml:: + +install: + mkdir -p `$(COQC) -where`/user-contrib + cp -f *.vo `$(COQC) -where`/user-contrib + +Makefile: Make + mv -f Makefile Makefile.bak + $(COQBIN)coq_makefile -f Make -o Makefile + +clean: + rm -f *.cmo *.cmi *.cmx *.o *.vo *.vi *.g *~ + rm -f all.ps all-gal.ps $(HTMLFILES) $(GHTMLFILES) + +archclean: + rm -f *.cmx *.o + +# WARNING +# +# This Makefile has been automagically generated by coq_makefile +# Edit at your own risks ! +# +# END OF WARNING + diff --git a/helm/coq-contribs/LAMBDA-TYPES/README b/helm/coq-contribs/LAMBDA-TYPES/README new file mode 100644 index 000000000..d35c2dd39 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/README @@ -0,0 +1,61 @@ + + Contribution Bologna/LAMBDA-TYPES + ================================== + +This directory contains a formalization in Coq of "lambda-delta", a +lambda-typed lambda-calculus with abbreviations. + +Author & Date: Ferruccio Guidi + Department of Computer Science, University of Bologna + March 2005 +E-mail : fguidi@cs.unibo.it +WWW : http://www.cs.unibo.it/~fguidi + +Installation procedure: +----------------------- + + To get this contribution compiled, type + + make + + or + + make opt + + The main modules produced by the compilation are: + + LambdaDelta provides the theory of the "lambda-delta" calculus + and its prerequisites + + Base provides just the prerequisites (mainly some arithmetic + properties missing in the standard library of Coq) + +Description: +------------ + + The present work, which is meant to be improved in the future, contains + a formalization of the "lambda-delta" calculus, defined in "item notation" + and with De Bruijn indices, and includes the proofs of some standard + properties of this calculus. In particular the user will find: + + - Confluence of reduction + - Generation lemma + - Thinning lemma + - Substitution lemma + - Type Correctness + - Type Uniqueness + - Subject Reduction + + Other properties to be added in the future versions of this contribution + include (but are not limited to): + + - Strong Normalization + - Decidability of Type Inference and Type Checking + +Further information on this contribution: +----------------------------------------- + + The latest version of this development is maintained in the CVS repository + of the HELM project and can be downloaded at: + + www.cs.unibo.it/cgi-bin/viewcvs.cgi/helm/coq-contribs/LAMBDA-TYPES.tgz diff --git a/helm/coq-contribs/LAMBDA-TYPES/base_blt.v b/helm/coq-contribs/LAMBDA-TYPES/base_blt.v new file mode 100644 index 000000000..ae00365c6 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/base_blt.v @@ -0,0 +1,33 @@ +Require Arith. +Require base_tactics. +Require base_hints. + +(*#* #stop file *) + + Fixpoint blt [m,n: nat] : bool := Cases n m of + | (0) m => false + | (S n) (0) => true + | (S n) (S m) => (blt m n) + end. + + Section blt_props. (******************************************************) + + Theorem lt_blt: (x,y:?) (lt y x) -> (blt y x) = true. + XElim x; [ Intros; Inversion H | XElim y; Simpl; XAuto ]. + Qed. + + Theorem le_bge: (x,y:?) (le x y) -> (blt y x) = false. + XElim x; [ XAuto | XElim y; Intros; [ Inversion H0 | Simpl; XAuto ] ]. + Qed. + + Theorem blt_lt: (x,y:?) (blt y x) = true -> (lt y x). + XElim x; [ Intros; Inversion H | XElim y; Simpl; XAuto ]. + Qed. + + Theorem bge_le: (x,y:?) (blt y x) = false -> (le x y). + XElim x; [ XAuto | XElim y; Intros; [ Inversion H0 | Simpl; XAuto ] ]. + Qed. + + End blt_props. + + Hints Resolve lt_blt le_bge : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/base_hints.v b/helm/coq-contribs/LAMBDA-TYPES/base_hints.v new file mode 100644 index 000000000..a364406a3 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/base_hints.v @@ -0,0 +1,262 @@ +(*#* #stop file *) + +Require Arith. +Require base_tactics. + +(* eq ***********************************************************************) + +Hint eq : ltlc := Constructors eq. + +Hint f1N : ltlc := Resolve (f_equal nat). + +Hint f2NN : ltlc := Resolve (f_equal2 nat nat). + +Hints Resolve sym_equal : ltlc. + +Hints Resolve plus_sym plus_n_Sm plus_assoc_r simpl_plus_l : ltlc. + +Hints Resolve minus_n_O : ltlc. + +(* le ***********************************************************************) + +Hint le : ltlc := Constructors le. + +Hints Resolve le_O_n le_n_S le_S_n le_trans : ltlc. + +Hints Resolve lt_le_S : ltlc. + +Hints Resolve le_plus_plus le_plus_trans le_plus_l le_plus_r : ltlc. + +(* lt ***********************************************************************) + +Hints Resolve lt_trans : ltlc. + +Hints Resolve lt_le_trans le_lt_n_Sm : ltlc. + +Hints Resolve lt_reg_r lt_le_plus_plus le_lt_plus_plus : ltlc. + +(* not **********************************************************************) + +Hints Resolve sym_not_equal : ltlc. + +(* missing in the standard library ******************************************) + + Theorem simpl_plus_r: (n,m,p:?) (plus m n) = (plus p n) -> m = p. + Intros. + Apply (simpl_plus_l n). + Rewrite plus_sym. + Rewrite H; XAuto. + Qed. + + Theorem minus_plus_r: (m,n:?) (minus (plus m n) n) = m. + Intros. + Rewrite plus_sym. + Apply minus_plus. + Qed. + + Theorem plus_permute_2_in_3: (x,y,z:?) (plus (plus x y) z) = (plus (plus x z) y). + Intros. + Rewrite plus_assoc_r. + Rewrite (plus_sym y z). + Rewrite <- plus_assoc_r; XAuto. + Qed. + + Theorem plus_permute_2_in_3_assoc: (n,h,k:?) (plus (plus n h) k) = (plus n (plus k h)). + Intros. + Rewrite plus_permute_2_in_3; Rewrite plus_assoc_l; XAuto. + Qed. + + Theorem plus_O: (x,y:?) (plus x y) = (0) -> x = (O) /\ y = (O). + XElim x; [ XAuto | Intros; Inversion H0 ]. + Qed. + + Theorem minus_Sx_SO: (x:?) (minus (S x) (1)) = x. + Intros; Simpl; Rewrite <- minus_n_O; XAuto. + Qed. + + Theorem eq_nat_dec: (i,j:nat) ~i=j \/ i=j. + XElim i; XElim j; Intros; XAuto. + Elim (H n0); XAuto. + Qed. + + Theorem neq_eq_e: (i,j:nat; P:Prop) (~i=j -> P) -> (i=j -> P) -> P. + Intros. + Pose (eq_nat_dec i j). + XElim o; XAuto. + Qed. + + Theorem le_false: (m,n:?; P:Prop) (le m n) -> (le (S n) m) -> P. + XElim m. +(* case 1 : m = 0 *) + Intros; Inversion H0. +(* case 2 : m > 0 *) + XElim n0; Intros. +(* case 2.1 : n = 0 *) + Inversion H0. +(* case 2.2 : n > 0 *) + Simpl in H1. + Apply (H n0); XAuto. + Qed. + + Theorem le_plus_minus_sym: (n,m:?) (le n m) -> m = (plus (minus m n) n). + Intros. + Rewrite plus_sym; Apply le_plus_minus; XAuto. + Qed. + + Theorem le_minus_minus: (x,y:?) (le x y) -> (z:?) (le y z) -> + (le (minus y x) (minus z x)). + Intros. + EApply simpl_le_plus_l. + Rewrite le_plus_minus_r; [ Idtac | XAuto ]. + Rewrite le_plus_minus_r; XEAuto. + Qed. + + Theorem le_minus_plus: (z,x:?) (le z x) -> (y:?) + (minus (plus x y) z) = (plus (minus x z) y). + XElim z. +(* case 1 : z = 0 *) + Intros x H; Inversion H; XAuto. +(* case 2 : z > 0 *) + Intros z; XElim x; Intros. +(* case 2.1 : x = 0 *) + Inversion H0. +(* case 2.2 : x > 0 *) + Simpl; XAuto. + Qed. + + Theorem le_minus: (x,z,y:?) (le (plus x y) z) -> (le x (minus z y)). + Intros. + Rewrite <- (minus_plus_r x y); XAuto. + Apply le_minus_minus; XAuto. + Qed. + + Theorem le_trans_plus_r: (x,y,z:?) (le (plus x y) z) -> (le y z). + Intros. + EApply le_trans; [ EApply le_plus_r | Idtac ]; XEAuto. + Qed. + + Theorem le_gen_S: (m,x:?) (le (S m) x) -> + (EX n | x = (S n) & (le m n)). + Intros; Inversion H; XEAuto. + Qed. + + Theorem lt_x_plus_x_Sy: (x,y:?) (lt x (plus x (S y))). + Intros; Rewrite plus_sym; Simpl; XAuto. + Qed. + + Theorem simpl_lt_plus_r: (p,n,m:?) (lt (plus n p) (plus m p)) -> (lt n m). + Intros. + EApply simpl_lt_plus_l. + Rewrite plus_sym in H; Rewrite (plus_sym m p) in H; Apply H. + Qed. + + Theorem minus_x_Sy: (x,y:?) (lt y x) -> + (minus x y) = (S (minus x (S y))). + XElim x. +(* case 1 : x = 0 *) + Intros; Inversion H. +(* case 2 : x > 0 *) + XElim y; Intros; Simpl. +(* case 2.1 : y = 0 *) + Rewrite <- minus_n_O; XAuto. +(* case 2.2 : y > 0 *) + Cut (lt n0 n); XAuto. + Qed. + + Theorem lt_plus_minus: (x,y:?) (lt x y) -> + y = (S (plus x (minus y (S x)))). + Intros. + Apply (le_plus_minus (S x) y); XAuto. + Qed. + + Theorem lt_plus_minus_r: (x,y:?) (lt x y) -> + y = (S (plus (minus y (S x)) x)). + Intros. + Rewrite plus_sym; Apply lt_plus_minus; XAuto. + Qed. + + Theorem minus_x_SO: (x:?) (lt (0) x) -> x = (S (minus x (1))). + Intros. + Rewrite <- minus_x_Sy; [ Rewrite <- minus_n_O; XEAuto | XEAuto ]. + Qed. + + Theorem lt_le_minus: (x,y:?) (lt x y) -> (le x (minus y (1))). + Intros; Apply le_minus; Rewrite plus_sym; Simpl; XAuto. + Qed. + + Theorem lt_le_e: (n,d:?; P:Prop) + ((lt n d) -> P) -> ((le d n) -> P) -> P. + Intros. + Cut (le d n) \/ (lt n d); [ Intros H1; XElim H1; XAuto | Apply le_or_lt ]. + Qed. + + Theorem lt_eq_e: (x,y:?; P:Prop) ((lt x y) -> P) -> + (x = y -> P) -> (le x y) -> P. + Intros. + LApply (le_lt_or_eq x y); [ Clear H1; Intros H1 | XAuto ]. + XElim H1; XAuto. + Qed. + + Theorem lt_eq_gt_e: (x,y:?; P:Prop) ((lt x y) -> P) -> + (x = y -> P) -> ((lt y x) -> P) -> P. + Intros. + Apply (lt_le_e x y); [ XAuto | Intros ]. + Apply (lt_eq_e y x); XAuto. + Qed. + + Theorem lt_gen_S': (x,n:?) (lt x (S n)) -> + x = (0) \/ (EX m | x = (S m) & (lt m n)). + XElim x; XEAuto. + Qed. + +Hints Resolve le_lt_trans : ltlc. + +Hints Resolve simpl_plus_r minus_plus_r minus_x_Sy + plus_permute_2_in_3 plus_permute_2_in_3_assoc : ltlc. + +Hints Resolve le_minus_minus le_minus_plus le_minus le_trans_plus_r : ltlc. + +Hints Resolve lt_x_plus_x_Sy simpl_lt_plus_r lt_le_minus lt_plus_minus + lt_plus_minus_r : ltlc. + + Theorem lt_neq: (x,y:?) (lt x y) -> ~x=y. + Unfold not; Intros; Rewrite H0 in H; Clear H0 x. + LApply (lt_n_n y); XAuto. + Qed. + +Hints Resolve lt_neq : ltlc. + + Theorem arith0: (h2,d2,n:?) (le (plus d2 h2) n) -> + (h1:?) (le (plus d2 h1) (minus (plus n h1) h2)). + Intros. + Rewrite <- (minus_plus h2 (plus d2 h1)). + Apply le_minus_minus; [ XAuto | Idtac ]. + Rewrite plus_assoc_l; Rewrite (plus_sym h2 d2); XAuto. + Qed. + +Hints Resolve arith0 : ltlc. + + Tactic Definition EqFalse := + Match Context With + [ H: ~?1=?1 |- ? ] -> + LApply H; [ Clear H; Intros H; Inversion H | XAuto ]. + + Tactic Definition PlusO := + Match Context With + | [ H: (plus ?0 ?1) = (0) |- ? ] -> + LApply (plus_O ?0 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Tactic Definition SymEqual := + Match Context With + | [ H: ?1 = ?2 |- ? ] -> + Cut ?2 = ?1; [ Clear H; Intros H | Apply sym_equal; XAuto ]. + + Tactic Definition LeLtGen := + Match Context With + | [ H: (le (S ?1) ?2) |- ? ] -> + LApply (le_gen_S ?1 ?2); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (lt ?1 (S ?2)) |- ? ] -> + LApply (lt_gen_S' ?1 ?2); [ Clear H; Intros H | XAuto ]; + XElim H; [ Intros | Intros H; XElim H; Intros ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/base_rewrite.v b/helm/coq-contribs/LAMBDA-TYPES/base_rewrite.v new file mode 100644 index 000000000..68490ee3f --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/base_rewrite.v @@ -0,0 +1,76 @@ +(*#* #stop file *) + +Require Arith. + + Tactic Definition Arith0 x := + Replace (S x) with (plus (1) x); XAuto. + + Tactic Definition Arith1 x := + Replace x with (plus x (0)); [XAuto | Auto with arith]. + + Tactic Definition Arith1In H x := + XReplaceIn H x '(plus x (0)). + + Tactic Definition Arith2 x := + Replace x with (plus (0) x); XAuto. + + Tactic Definition Arith3 x := + Replace (S x) with (S (plus (0) x)); XAuto. + + Tactic Definition Arith3In H x := + XReplaceIn H '(S x) '(S (plus (0) x)). + + Tactic Definition Arith4 x y := + Replace (S (plus x y)) with (plus (S x) y); XAuto. + + Tactic Definition Arith4In H x y := + XReplaceIn H '(S (plus x y)) '(plus (S x) y). + + Tactic Definition Arith4c x y := + Arith4 x y; Rewrite plus_sym. + + Tactic Definition Arith5 x y := + Replace (S (plus x y)) with (plus x (S y)); Auto with arith. + + Tactic Definition Arith5In H x y := + XReplaceIn H '(S (plus x y)) '(plus x (S y)); Auto with arith. + + Tactic Definition Arith5' x y := + Replace (plus x (S y)) with (S (plus x y)); Auto with arith. + + Tactic Definition Arith5'In H x y := + XReplaceIn H '(plus x (S y)) '(S (plus x y)); Auto with arith. + + Tactic Definition Arith5'c x y := + Arith5' x y; Rewrite plus_sym. + + Tactic Definition Arith6In H x y := + XReplaceIn H '(plus x (S y)) '(plus (1) (plus x y)); + [ Idtac | Simpl; Auto with arith ]. + + Tactic Definition Arith7 x := + Replace (S x) with (plus x (1)); + [ Idtac | Rewrite plus_sym; Auto with arith ]. + + Tactic Definition Arith7In H x := + XReplaceIn H '(S x) '(plus x (1)) ; + [ Idtac | Rewrite plus_sym; Auto with arith ]. + + Tactic Definition Arith7' x := + Replace (plus x (1)) with (S x); + [ Idtac | Rewrite plus_sym; Auto with arith ]. + + Tactic Definition Arith8 x y := + Replace x with (plus y (minus x y)); + [ Idtac | Auto with arith ]. + + Tactic Definition Arith8' x y := + Replace (plus y (minus x y)) with x; + [ Idtac | Auto with arith ]. + + Tactic Definition Arith9'In H x := + XReplaceIn H '(S (plus x (0))) '(S x). + + Tactic Definition Arith10 x := + Replace x with (minus (S x) (1)); + [ Idtac | Simpl; Rewrite <- minus_n_O; Auto with arith ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/base_tactics.v b/helm/coq-contribs/LAMBDA-TYPES/base_tactics.v new file mode 100644 index 000000000..daa6facca --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/base_tactics.v @@ -0,0 +1,45 @@ +(*#* #stop file *) + + Tactic Definition XAuto := Auto with ltlc. + + Tactic Definition XEAuto := EAuto with ltlc. + + Tactic Definition XDEAuto d := EAuto d with ltlc. + + Tactic Definition XElimUsing e v := + Try Intros until v; Elim v using e; Try Clear v. + + Tactic Definition XElim v := Try Intros until v; Elim v; Try Clear v. + + Tactic Definition XCase v := Try Intros until v; Case v; Try Clear v. + + Tactic Definition XReplaceIn Z0 y1 y2 := + Cut y1=y2; [ Intros Z; Rewrite Z in Z0; Clear Z | XAuto ]. + + Theorem insert_eq: (S:Set; x:S; P:S->Prop; G:Prop) + ((y:S) (P y) -> y = x -> G) -> (P x) -> G. + EAuto. Qed. + + Tactic Definition InsertEq H y := + Pattern 1 y in H; Match Context With [ _: (?1 y) |- ? ] -> + Apply insert_eq with x:=y P:=?1; + [ Clear H; Intros until 1 | Pattern y; Apply H ]. + + Theorem unintro : (A:Set; a:A; P:A->Prop) ((x:A) (P x)) -> (P a). + Auto. + Qed. + + Tactic Definition UnIntro Last H := + Move H after Last; + Match Context With [ y: ?1 |- ?2 ] -> + Apply (unintro ?1 y); Clear y. + + Tactic Definition NonLinear := + Match Context With + [ H: ?1 |- ? ] -> Cut ?1; [ Intros | XAuto ]. + + Tactic Definition XRewrite x := + Match Context With + | [ H0: x = ? |- ? ] -> Try Rewrite H0 + | [ H0: ? = x |- ? ] -> Try Rewrite <- H0 + | _ -> Idtac. diff --git a/helm/coq-contribs/LAMBDA-TYPES/base_types.v b/helm/coq-contribs/LAMBDA-TYPES/base_types.v new file mode 100644 index 000000000..0b1c870f3 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/base_types.v @@ -0,0 +1,159 @@ +(* This file was generated by coqgen *) + +Require base_tactics. +Require base_hints. + +(*#* #stop file *) + +(* extensions for ex2 *) + +Syntactic Definition ex2_intro := ex_intro2. + +Theorem ex2_sym: (A:Set; P,Q:A->Prop) + (EX x | (P x) & (Q x)) -> (EX x | (Q x) & (P x)). + Intros; XElim H; XEAuto. + Qed. + +Hints Resolve ex2_sym : ltlc. + +(* or3 *) + +Inductive or3 [P0,P1,P2:Prop] : Prop := + | or3_intro0 : P0 -> (or3 P0 P1 P2) + | or3_intro1 : P1 -> (or3 P0 P1 P2) + | or3_intro2 : P2 -> (or3 P0 P1 P2). + +Hint or3 : ltlc := Constructors or3. + +Grammar constr constr10 := + | or3 + [ "OR" constr($c0) "|" constr($c1) "|" constr($c2) ] -> + [ (or3 $c0 $c1 $c2) ]. + +(* or4 *) + +Inductive or4 [P0,P1,P2,P3:Prop] : Prop := + | or4_intro0 : P0 -> (or4 P0 P1 P2 P3) + | or4_intro1 : P1 -> (or4 P0 P1 P2 P3) + | or4_intro2 : P2 -> (or4 P0 P1 P2 P3) + | or4_intro3 : P3 -> (or4 P0 P1 P2 P3). + +Hint or4 : ltlc := Constructors or4. + +Grammar constr constr10 := + | or4 + [ "OR" constr($c0) "|" constr($c1) "|" constr($c2) "|" constr($c3) ] -> + [ (or4 $c0 $c1 $c2 $c3) ]. + +(* ex2_2 *) + +Inductive ex2_2 [A0,A1:Set; P0,P1:A0->A1->Prop] : Prop := + ex2_2_intro : (x0:A0; x1:A1)(P0 x0 x1)->(P1 x0 x1)->(ex2_2 A0 A1 P0 P1). + +Hint ex2_2 : ltlc := Constructors ex2_2. + +Syntactic Definition Ex2_2 := ex2_2 | 1. + +Grammar constr constr10 := + | ex2_2implicit + [ "EX" ident($v0) ident($v1) "|" constr($c0) "&" constr($c1) ] -> + [ (ex2_2 ? ? [$v0;$v1]$c0 [$v0;$v1]$c1) ]. + +(* ex3_2 *) + +Inductive ex3_2 [A0,A1:Set; P0,P1,P2:A0->A1->Prop] : Prop := + ex3_2_intro : (x0:A0; x1:A1)(P0 x0 x1)->(P1 x0 x1)->(P2 x0 x1)->(ex3_2 A0 A1 P0 P1 P2). + +Hint ex3_2 : ltlc := Constructors ex3_2. + +Syntactic Definition Ex3_2 := ex3_2 | 1. + +Grammar constr constr10 := + | ex3_2implicit + [ "EX" ident($v0) ident($v1) "|" constr($c0) "&" constr($c1) "&" constr($c2) ] -> + [ (ex3_2 ? ? [$v0;$v1]$c0 [$v0;$v1]$c1 [$v0;$v1]$c2) ]. + +(* ex3_3 *) + +Inductive ex3_3 [A0,A1,A2:Set; P0,P1,P2:A0->A1->A2->Prop] : Prop := + ex3_3_intro : (x0:A0; x1:A1; x2:A2)(P0 x0 x1 x2)->(P1 x0 x1 x2)->(P2 x0 x1 x2)->(ex3_3 A0 A1 A2 P0 P1 P2). + +Hint ex3_3 : ltlc := Constructors ex3_3. + +Syntactic Definition Ex3_3 := ex3_3 | 1. + +Grammar constr constr10 := + | ex3_3implicit + [ "EX" ident($v0) ident($v1) ident($v2) "|" constr($c0) "&" constr($c1) "&" constr($c2) ] -> + [ (ex3_3 ? ? ? [$v0;$v1;$v2]$c0 [$v0;$v1;$v2]$c1 [$v0;$v1;$v2]$c2) ]. + +(* ex4_3 *) + +Inductive ex4_3 [A0,A1,A2:Set; P0,P1,P2,P3:A0->A1->A2->Prop] : Prop := + ex4_3_intro : (x0:A0; x1:A1; x2:A2)(P0 x0 x1 x2)->(P1 x0 x1 x2)->(P2 x0 x1 x2)->(P3 x0 x1 x2)->(ex4_3 A0 A1 A2 P0 P1 P2 P3). + +Hint ex4_3 : ltlc := Constructors ex4_3. + +Syntactic Definition Ex4_3 := ex4_3 | 1. + +Grammar constr constr10 := + | ex4_3implicit + [ "EX" ident($v0) ident($v1) ident($v2) "|" constr($c0) "&" constr($c1) "&" constr($c2) "&" constr($c3) ] -> + [ (ex4_3 ? ? ? [$v0;$v1;$v2]$c0 [$v0;$v1;$v2]$c1 [$v0;$v1;$v2]$c2 [$v0;$v1;$v2]$c3) ]. + +(* ex3_4 *) + +Inductive ex3_4 [A0,A1,A2,A3:Set; P0,P1,P2:A0->A1->A2->A3->Prop] : Prop := + ex3_4_intro : (x0:A0; x1:A1; x2:A2; x3:A3)(P0 x0 x1 x2 x3)->(P1 x0 x1 x2 x3)->(P2 x0 x1 x2 x3)->(ex3_4 A0 A1 A2 A3 P0 P1 P2). + +Hint ex3_4 : ltlc := Constructors ex3_4. + +Syntactic Definition Ex3_4 := ex3_4 | 1. + +Grammar constr constr10 := + | ex3_4implicit + [ "EX" ident($v0) ident($v1) ident($v2) ident($v3) "|" constr($c0) "&" constr($c1) "&" constr($c2) ] -> + [ (ex3_4 ? ? ? ? [$v0;$v1;$v2;$v3]$c0 [$v0;$v1;$v2;$v3]$c1 [$v0;$v1;$v2;$v3]$c2) ]. + +(* ex4_4 *) + +Inductive ex4_4 [A0,A1,A2,A3:Set; P0,P1,P2,P3:A0->A1->A2->A3->Prop] : Prop := + ex4_4_intro : (x0:A0; x1:A1; x2:A2; x3:A3)(P0 x0 x1 x2 x3)->(P1 x0 x1 x2 x3)->(P2 x0 x1 x2 x3)->(P3 x0 x1 x2 x3)->(ex4_4 A0 A1 A2 A3 P0 P1 P2 P3). + +Hint ex4_4 : ltlc := Constructors ex4_4. + +Syntactic Definition Ex4_4 := ex4_4 | 1. + +Grammar constr constr10 := + | ex4_4implicit + [ "EX" ident($v0) ident($v1) ident($v2) ident($v3) "|" constr($c0) "&" constr($c1) "&" constr($c2) "&" constr($c3) ] -> + [ (ex4_4 ? ? ? ? [$v0;$v1;$v2;$v3]$c0 [$v0;$v1;$v2;$v3]$c1 [$v0;$v1;$v2;$v3]$c2 [$v0;$v1;$v2;$v3]$c3) ]. + +(* ex4_5 *) + +Inductive ex4_5 [A0,A1,A2,A3,A4:Set; P0,P1,P2,P3:A0->A1->A2->A3->A4->Prop] : Prop := + ex4_5_intro : (x0:A0; x1:A1; x2:A2; x3:A3; x4:A4)(P0 x0 x1 x2 x3 x4)->(P1 x0 x1 x2 x3 x4)->(P2 x0 x1 x2 x3 x4)->(P3 x0 x1 x2 x3 x4)->(ex4_5 A0 A1 A2 A3 A4 P0 P1 P2 P3). + +Hint ex4_5 : ltlc := Constructors ex4_5. + +Syntactic Definition Ex4_5 := ex4_5 | 1. + +Grammar constr constr10 := + | ex4_5implicit + [ "EX" ident($v0) ident($v1) ident($v2) ident($v3) ident($v4) "|" constr($c0) "&" constr($c1) "&" constr($c2) "&" constr($c3) ] -> + [ (ex4_5 ? ? ? ? ? [$v0;$v1;$v2;$v3;$v4]$c0 [$v0;$v1;$v2;$v3;$v4]$c1 [$v0;$v1;$v2;$v3;$v4]$c2 [$v0;$v1;$v2;$v3;$v4]$c3) ]. + +(* ex6_6 *) + +Inductive ex6_6 [A0,A1,A2,A3,A4,A5:Set; P0,P1,P2,P3,P4,P5:A0->A1->A2->A3->A4->A5->Prop] : Prop := + ex6_6_intro : (x0:A0; x1:A1; x2:A2; x3:A3; x4:A4; x5:A5)(P0 x0 x1 x2 x3 x4 x5)->(P1 x0 x1 x2 x3 x4 x5)->(P2 x0 x1 x2 x3 x4 x5)->(P3 x0 x1 x2 x3 x4 x5)->(P4 x0 x1 x2 x3 x4 x5)->(P5 x0 x1 x2 x3 x4 x5)->(ex6_6 A0 A1 A2 A3 A4 A5 P0 P1 P2 P3 P4 P5). + +Hint ex6_6 : ltlc := Constructors ex6_6. + +Syntactic Definition Ex6_6 := ex6_6 | 1. + +Grammar constr constr10 := + | ex6_6implicit + [ "EX" ident($v0) ident($v1) ident($v2) ident($v3) ident($v4) ident($v5) "|" constr($c0) "&" constr($c1) "&" constr($c2) "&" constr($c3) "&" constr($c4) "&" constr($c5) ] -> + [ (ex6_6 ? ? ? ? ? ? [$v0;$v1;$v2;$v3;$v4;$v5]$c0 [$v0;$v1;$v2;$v3;$v4;$v5]$c1 [$v0;$v1;$v2;$v3;$v4;$v5]$c2 [$v0;$v1;$v2;$v3;$v4;$v5]$c3 [$v0;$v1;$v2;$v3;$v4;$v5]$c4 [$v0;$v1;$v2;$v3;$v4;$v5]$c5) ]. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/contexts_defs.v b/helm/coq-contribs/LAMBDA-TYPES/contexts_defs.v new file mode 100644 index 000000000..ec1f9e758 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/contexts_defs.v @@ -0,0 +1,71 @@ +(*#* #stop file *) + +Require Export terms_defs. + + Inductive Set C := CSort : nat -> C + | CTail : C -> K -> T -> C. + + Hint f3CKT : ltlc := Resolve (f_equal3 C K T). + + Definition r: K -> nat -> nat := [k;i] Cases k of + | (Bind _) => i + | (Flat _) => (S i) + end. + + Fixpoint app [c:C] : nat -> T -> T := [j;t]Cases j c of + | (0) _ => t + | _ (CSort _) => t + | (S i) (CTail c k u) => (app c (r k i) (TTail k u t)) + end. + + Section r_props. (********************************************************) + + Theorem r_S: (k:?; i:?) (r k (S i)) = (S (r k i)). + XElim k; XAuto. + Qed. + + Theorem r_plus_sym: (k:?; i,j:?) (r k (plus i j)) = (plus i (r k j)). + XElim k; Intros; Simpl; XAuto. + Qed. + + Theorem r_minus: (i,n:?) (lt n i) -> + (k:?) (minus (r k i) (S n)) = (r k (minus i (S n))). + XElim k; Intros; Simpl; XEAuto. + Qed. + + Theorem r_dis: (k:?; P:Prop) + (((i:?) (r k i) = i) -> P) -> + (((i:?) (r k i) = (S i)) -> P) -> P. + XElim k; XAuto. + Qed. + + End r_props. + + Tactic Definition RRw := + Repeat (Rewrite r_S Orelse Rewrite r_plus_sym). + + Section r_arith. (********************************************************) + + Theorem r_arith0: (k:?; i:?) (minus (r k (S i)) (1)) = (r k i). + Intros; RRw; Rewrite minus_Sx_SO; XAuto. + Qed. + + Theorem r_arith1: (k:?; i,j:?) (minus (r k (S i)) (S j)) = (minus (r k i) j). + Intros; RRw; XAuto. + Qed. + + End r_arith. + + Section app_props. (******************************************************) + + Theorem app_csort : (t:?; i,n:?) (app (CSort n) i t) = t. + XElim i; Intros; Simpl; XAuto. + Qed. + + Theorem app_O : (c:?; t:?) (app c (0) t) = t. + XElim c; XAuto. + Qed. + + End app_props. + + Hints Resolve app_csort app_O : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/cpr0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/cpr0_defs.v new file mode 100644 index 000000000..ce6faccba --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/cpr0_defs.v @@ -0,0 +1,11 @@ +(*#* #stop file *) + +Require Export contexts_defs. +Require Export pr0_defs. + + Inductive cpr0 : C -> C -> Prop := + | cpr0_refl : (c:?) (cpr0 c c) + | cpr0_cont : (c1,c2:?) (cpr0 c1 c2) -> (u1,u2:?) (pr0 u1 u2) -> + (k:?) (cpr0 (CTail c1 k u1) (CTail c2 k u2)). + + Hint cpr0 : ltlc := Constructors cpr0. diff --git a/helm/coq-contribs/LAMBDA-TYPES/cpr0_props.v b/helm/coq-contribs/LAMBDA-TYPES/cpr0_props.v new file mode 100644 index 000000000..1050288ee --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/cpr0_props.v @@ -0,0 +1,103 @@ +(*#* #stop file *) + +Require pr0_subst0. +Require pr3_defs. +Require pr3_props. +Require cpr0_defs. + + Section cpr0_drop. (******************************************************) + + Theorem cpr0_drop : (c1,c2:?) (cpr0 c1 c2) -> (h:?; e1:?; u1:?; k:?) + (drop h (0) c1 (CTail e1 k u1)) -> + (EX e2 u2 | (drop h (0) c2 (CTail e2 k u2)) & + (cpr0 e1 e2) & (pr0 u1 u2) + ). + Intros until 1; XElim H. +(* case 1 : cpr0_refl *) + XEAuto. +(* case 2 : cpr0_cont *) + XElim h. +(* case 2.1 : h = 0 *) + Intros; DropGenBase. + Inversion H2; Rewrite H6 in H1; Rewrite H4 in H; XEAuto. +(* case 2.2 : h > 0 *) + XElim k; Intros; DropGenBase. +(* case 2.2.1 : Bind *) + LApply (H0 n e1 u0 k); [ Clear H0 H3; Intros H0 | XAuto ]. + XElim H0; XEAuto. +(* case 2.2.2 : Flat *) + LApply (H0 (S n) e1 u0 k); [ Clear H0 H3; Intros H0 | XAuto ]. + XElim H0; XEAuto. + Qed. + + Theorem cpr0_drop_back : (c1,c2:?) (cpr0 c2 c1) -> (h:?; e1:?; u1:?; k:?) + (drop h (0) c1 (CTail e1 k u1)) -> + (EX e2 u2 | (drop h (0) c2 (CTail e2 k u2)) & + (cpr0 e2 e1) & (pr0 u2 u1) + ). + Intros until 1; XElim H. +(* case 1 : cpr0_refl *) + XEAuto. +(* case 2 : cpr0_cont *) + XElim h. +(* case 2.1 : h = 0 *) + Intros; DropGenBase. + Inversion H2; Rewrite H6 in H1; Rewrite H4 in H; XEAuto. +(* case 2.2 : h > 0 *) + XElim k; Intros; DropGenBase. +(* case 2.2.1 : Bind *) + LApply (H0 n e1 u0 k); [ Clear H0 H3; Intros H0 | XAuto ]. + XElim H0; XEAuto. +(* case 2.2.2 : Flat *) + LApply (H0 (S n) e1 u0 k); [ Clear H0 H3; Intros H0 | XAuto ]. + XElim H0; XEAuto. + Qed. + + End cpr0_drop. + + Tactic Definition Cpr0Drop := + Match Context With + | [ _: (drop ?1 (0) ?2 (CTail ?3 ?4 ?5)); + _: (cpr0 ?2 ?6) |- ? ] -> + LApply (cpr0_drop ?2 ?6); [ Intros H_x | XAuto ]; + LApply (H_x ?1 ?3 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ _: (drop ?1 (0) ?2 (CTail ?3 ?4 ?5)); + _: (cpr0 ?6 ?2) |- ? ] -> + LApply (cpr0_drop_back ?2 ?6); [ Intros H_x | XAuto ]; + LApply (H_x ?1 ?3 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ _: (drop ?1 (0) (CTail ?2 ?7 ?8) (CTail ?3 ?4 ?5)); + _: (cpr0 ?2 ?6) |- ? ] -> + LApply (cpr0_drop (CTail ?2 ?7 ?8) (CTail ?6 ?7 ?8)); [ Intros H_x | XAuto ]; + LApply (H_x ?1 ?3 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ _: (drop ?1 (0) (CTail ?2 ?7 ?8) (CTail ?3 ?4 ?5)); + _: (cpr0 ?6 ?2) |- ? ] -> + LApply (cpr0_drop_back (CTail ?2 ?7 ?8) (CTail ?6 ?7 ?8)); [ Intros H_x | XAuto ]; + LApply (H_x ?1 ?3 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros. + + Section cpr0_pr3. (*******************************************************) + + Theorem cpr0_pr3_t : (c1,c2:?) (cpr0 c2 c1) -> (t1,t2:?) (pr3 c1 t1 t2) -> + (pr3 c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : cpr0_refl *) + XAuto. +(* case 2 : cpr0_cont *) + Pr3Context. + XElim H1; Intros. +(* case 2.1 : pr3_r *) + XAuto. +(* case 2.2 : pr3_u *) + EApply pr3_t; [ Idtac | XEAuto ]. Clear H2 H3 c1 c2 t1 t2 t4 u2. + Inversion_clear H1. +(* case 2.2.1 : pr2_pr0 *) + XAuto. +(* case 2.2.1 : pr2_delta *) + Cpr0Drop; Pr0Subst0. + EApply pr3_u; [ EApply pr2_delta; XEAuto | XAuto ]. + Qed. + + End cpr0_pr3. diff --git a/helm/coq-contribs/LAMBDA-TYPES/csub0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/csub0_defs.v new file mode 100644 index 000000000..7aa8a2c9b --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/csub0_defs.v @@ -0,0 +1,186 @@ +(*#* #stop file *) + +Require Export ty0_defs. + + Inductive csub0 [g:G] : C -> C -> Prop := +(* structural rules *) + | csub0_sort : (n:?) (csub0 g (CSort n) (CSort n)) + | csub0_tail : (c1,c2:?) (csub0 g c1 c2) -> (k,u:?) + (csub0 g (CTail c1 k u) (CTail c2 k u)) +(* axioms *) + | csub0_void : (c1,c2:?) (csub0 g c1 c2) -> (b:?) ~b=Void -> (u1,u2:?) + (csub0 g (CTail c1 (Bind Void) u1) (CTail c2 (Bind b) u2)) + | csub0_abst : (c1,c2:?) (csub0 g c1 c2) -> (u,t:?) (ty0 g c2 u t) -> + (csub0 g (CTail c1 (Bind Abst) t) (CTail c2 (Bind Abbr) u)). + + Hint csub0 : ltlc := Constructors csub0. + + Section csub0_props. (****************************************************) + + Theorem csub0_refl : (g:?; c:?) (csub0 g c c). + XElim c; XAuto. + Qed. + + End csub0_props. + + Hints Resolve csub0_refl : ltlc. + + Section csub0_drop. (*****************************************************) + + Theorem csub0_drop_abbr : (g:?; n:?; c1,c2:?) (csub0 g c1 c2) -> (d1,u:?) + (drop n (0) c1 (CTail d1 (Bind Abbr) u)) -> + (EX d2 | (csub0 g d1 d2) & + (drop n (0) c2 (CTail d2 (Bind Abbr) u)) + ). + XElim n. +(* case 1 : n = 0 *) + Intros; DropGenBase; Rewrite H0 in H; Inversion H; XEAuto. +(* case 2 : n > 0 *) + Intros until 2; XElim H0. +(* case 2.1 : csub0_sort *) + Intros; Inversion H0. +(* case 2.2 : csub0_tail *) + XElim k; Intros; DropGenBase. +(* case 2.2.1 : Bind *) + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 u0); [ Clear H; Intros H | XAuto ]. + XElim H; XEAuto. +(* case 2.2.2 : Flat *) + LApply (H1 d1 u0); [ Clear H1; Intros H1 | XAuto ]. + XElim H1; XEAuto. +(* case 2.3 : csub0_void *) + Intros; DropGenBase. + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 u); [ Clear H; Intros H | XAuto ]. + XElim H; XEAuto. +(* case 2.4 : csub0_abst *) + Intros; DropGenBase. + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 u0); [ Clear H; Intros H | XAuto ]. + XElim H; XEAuto. + Qed. + + Theorem csub0_drop_abst : (g:?; n:?; c1,c2:?) (csub0 g c1 c2) -> (d1,t:?) + (drop n (0) c1 (CTail d1 (Bind Abst) t)) -> + (EX d2 | (csub0 g d1 d2) & + (drop n (0) c2 (CTail d2 (Bind Abst) t)) + + ) \/ + (EX d2 u | (csub0 g d1 d2) & + (drop n (0) c2 (CTail d2 (Bind Abbr) u)) & + (ty0 g d2 u t) + ). + XElim n. +(* case 1 : n = 0 *) + Intros; DropGenBase; Rewrite H0 in H; Inversion H; XEAuto. +(* case 2 : n > 0 *) + Intros until 2; XElim H0. +(* case 2.1 : csub0_sort *) + Intros; Inversion H0. +(* case 2.2 : csub0_tail *) + XElim k; Intros; DropGenBase. +(* case 2.2.1 : Bind *) + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 t); [ Clear H; Intros H | XAuto ]. + XElim H; Intros; XElim H; XEAuto. +(* case 2.2.2 : Flat *) + LApply (H1 d1 t); [ Clear H1; Intros H1 | XAuto ]. + XElim H1; Intros; XElim H1; XEAuto. +(* case 2.3 : csub0_void *) + Intros; DropGenBase. + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 t); [ Clear H; Intros H | XAuto ]. + XElim H; Intros; XElim H; XEAuto. +(* case 2.4 : csub0_abst *) + Intros; DropGenBase. + LApply (H c0 c3); [ Clear H; Intros H | XAuto ]. + LApply (H d1 t0); [ Clear H; Intros H | XAuto ]. + XElim H; Intros; XElim H; XEAuto. + Qed. + + End csub0_drop. + + Tactic Definition CSub0Drop := + Match Context With + | [ H1: (csub0 ?1 ?2 ?3); + H2: (drop ?4 (0) ?2 (CTail ?5 (Bind Abbr) ?6)) |- ? ] -> + LApply (csub0_drop_abbr ?1 ?4 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (csub0 ?1 ?2 ?3); + H2: (drop ?4 (0) ?2 (CTail ?5 (Bind Abst) ?6)) |- ? ] -> + LApply (csub0_drop_abst ?1 ?4 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros H1; XElim H1; Intros. + + Section csub0_pc3. (*****************************************************) + + Theorem csub0_pr2 : (g:?; c1:?; t1,t2:?) (pr2 c1 t1 t2) -> + (c2:?) (csub0 g c1 c2) -> (pr2 c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pr2_pr0 *) + XAuto. +(* case 2 : pr2_delta *) + CSub0Drop; XEAuto. + Qed. + + Theorem csub0_pc2 : (g:?; c1:?; t1,t2:?) (pc2 c1 t1 t2) -> + (c2:?) (csub0 g c1 c2) -> (pc2 c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pc2_r *) + Apply pc2_r; EApply csub0_pr2; XEAuto. +(* case 2 : pc2_x *) + Apply pc2_x; EApply csub0_pr2; XEAuto. + Qed. + + Theorem csub0_pc3 : (g:?; c1:?; t1,t2:?) (pc3 c1 t1 t2) -> + (c2:?) (csub0 g c1 c2) -> (pc3 c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pc3_r *) + XAuto. +(* case 2 : pc3_u *) + EApply pc3_u; [ EApply csub0_pc2; XEAuto | XAuto ]. + Qed. + + End csub0_pc3. + + Hints Resolve csub0_pc3 : ltlc. + + Section csub0_ty0. (*****************************************************) + + Theorem csub0_ty0 : (g:?; c1:?; t1,t2:?) (ty0 g c1 t1 t2) -> + (c2:?) (wf0 g c2) -> (csub0 g c1 c2) -> + (ty0 g c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + EApply ty0_conv; XEAuto. +(* case 2 : ty0_sort *) + XEAuto. +(* case 3 : ty0_abbr *) + CSub0Drop; EApply ty0_abbr; XEAuto. +(* case 4 : ty0_abst *) + CSub0Drop; [ EApply ty0_abst | EApply ty0_abbr ]; XEAuto. +(* case 5 : ty0_bind *) + EApply ty0_bind; XEAuto. +(* case 6 : ty0_appl *) + EApply ty0_appl; XEAuto. +(* case 7 : ty0_cast *) + EApply ty0_cast; XAuto. + Qed. + + Theorem csub0_ty0_ld : (g:?; c:?; u,v:?) (ty0 g c u v) -> (t1,t2:?) + (ty0 g (CTail c (Bind Abst) v) t1 t2) -> + (ty0 g (CTail c (Bind Abbr) u) t1 t2). + Intros; EApply csub0_ty0; XEAuto. + Qed. + + End csub0_ty0. + + Hints Resolve csub0_ty0 csub0_ty0_ld : ltlc. + + Tactic Definition CSub0Ty0 := + Match Context With + [ _: (ty0 ?1 ?2 ?4 ?); _: (ty0 ?1 ?2 ?3 ?7); _: (pc3 ?2 ?4 ?7); + H: (ty0 ?1 (CTail ?2 (Bind Abst) ?4) ?5 ?6) |- ? ] -> + LApply (csub0_ty0_ld ?1 ?2 ?3 ?4); [ Intros H_x | EApply ty0_conv; XEAuto ]; + LApply (H_x ?5 ?6); [ Clear H_x H; Intros | XAuto ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/csubst0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/csubst0_defs.v new file mode 100644 index 000000000..a452fd3f0 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/csubst0_defs.v @@ -0,0 +1,198 @@ +(*#* #stop file *) + +Require Export contexts_defs. +Require Export subst0_defs. +Require Export drop_defs. + + Inductive csubst0 : nat -> T -> C -> C -> Prop := + | csubst0_fst : (k:?; i:?; u,v,w:?) (subst0 (r k i) v u w) -> (c:?) + (csubst0 (S i) v (CTail c k u) (CTail c k w)) + | csubst0_snd : (k:?; i:?; c1,c2:?; v:?) (csubst0 (r k i) v c1 c2) -> + (u:?) (csubst0 (S i) v (CTail c1 k u) (CTail c2 k u)) + | csubst0_both : (k:?; i:?; u,v,w:?) (subst0 (r k i) v u w) -> + (c1,c2:?) (csubst0 (r k i) v c1 c2) -> + (csubst0 (S i) v (CTail c1 k u) (CTail c2 k w)). + + Hint csubst0 : ltlc := Constructors csubst0. + + Inductive fsubst0 [i:nat; v:T; c1:C; t1:T] : C -> T -> Prop := + | fsubst0_t : (t2:?) (subst0 i v t1 t2) -> (fsubst0 i v c1 t1 c1 t2) + | fsubst0_c : (c2:?) (csubst0 i v c1 c2) -> (fsubst0 i v c1 t1 c2 t1) + | fsubst0_b : (t2:?) (subst0 i v t1 t2) -> + (c2:?) (csubst0 i v c1 c2) -> (fsubst0 i v c1 t1 c2 t2). + + Hint fsubst0 : ltlc := Constructors fsubst0. + + Section csubst0_gen_base. (***********************************************) + + Theorem csubst0_gen_tail: (k:?; c1,x:?; u1,v:?; i:?) + (csubst0 (S i) v (CTail c1 k u1) x) -> (OR + (EX u2 | x = (CTail c1 k u2) & + (subst0 (r k i) v u1 u2) + ) | + (EX c2 | x = (CTail c2 k u1) & + (csubst0 (r k i) v c1 c2) + ) | + (EX u2 c2 | x = (CTail c2 k u2) & + (subst0 (r k i) v u1 u2) & + (csubst0 (r k i) v c1 c2) + )). + Intros until 1; InsertEq H '(S i); InsertEq H '(CTail c1 k u1). + XCase H; Clear x v y y0; Intros; Inversion H1. +(* case 1: csubst0_fst *) + Inversion H0; Rewrite H3 in H; Rewrite H5 in H; Rewrite H6 in H; XEAuto. +(* case 2: csubst0_snd *) + Inversion H0; Rewrite H3 in H; Rewrite H4 in H; Rewrite H5 in H; XEAuto. +(* case 2: csubst0_both *) + Inversion H2; Rewrite H5 in H; Rewrite H6 in H; Rewrite H7 in H; + Rewrite H4 in H0; Rewrite H5 in H0; Rewrite H7 in H0; XEAuto. + Qed. + + End csubst0_gen_base. + + Tactic Definition CSubst0GenBase := + Match Context With + | [ H: (csubst0 (S ?1) ?2 (CTail ?3 ?4 ?5) ?6) |- ? ] -> + LApply (csubst0_gen_tail ?4 ?3 ?6 ?5 ?2 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros H; XElim H; Intros. + + Section csubst0_drop. (***************************************************) + + Theorem csubst0_drop_ge : (i,n:?) (le i n) -> + (c1,c2:?; v:?) (csubst0 i v c1 c2) -> + (e:?) (drop n (0) c1 e) -> + (drop n (0) c2 e). + XElim i. +(* case 1: i = 0 *) + Intros; Inversion H0. +(* case 2: i > 0 *) + Intros i; XElim n. +(* case 2.1: n = 0 *) + Intros; Inversion H0. +(* case 2.2: n > 0 *) + Intros until 3; Clear H0; InsertEq H2 '(S i); XElim H0; Intros. + DropGenBase. +(* case 2.2.1: csubst0_fst *) + XAuto. +(* case 2.2.2: csubst0_snd *) + XReplaceIn H0 i0 i; DropGenBase; NewInduction k; XEAuto. +(* case 2.2.3: csubst0_both *) + XReplaceIn H0 i0 i; XReplaceIn H2 i0 i. + DropGenBase; NewInduction k; XEAuto. + Qed. + + Tactic Definition IH := + Match Context With + | [ H0: (n:?) (lt n ?1) -> (c1,c2:?; v:?) (csubst0 ?1 v c1 c2) -> (e:C) (drop n (0) c1 e) -> ?; + H1: (csubst0 ?1 ?2 ?3 ?4); H2: (drop ?5 (0) ?3 ?6) |- ? ] -> + LApply (H0 ?5); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?3 ?4 ?2); [ Clear H0 H1; Intros H0 | XAuto ]; + LApply (H0 ?6); [ Clear H0 H2; Intros H0 | XAuto ]; + XElim H0; Intros H0; [ Idtac | XElim H0 | XElim H0 | XElim H0 ]; Intros + | [ H0: (r ? ?1) = (S ?1) -> (e:?) (drop (S ?2) (0) ?3 e) -> ?; + H1: (drop (S ?2) (0) ?3 ?4) |- ? ] -> + LApply H0; [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?4); [ Clear H0 H1; Intros H0 | XAuto ]; + XElim H0; Intros H0; [ Idtac | XElim H0 | XElim H0 | XElim H0 ]; Intros. + + Theorem csubst0_drop_lt : (i,n:?) (lt n i) -> + (c1,c2:?; v:?) (csubst0 i v c1 c2) -> + (e:?) (drop n (0) c1 e) -> (OR + (drop n (0) c2 e) | + (EX k e0 u w | e = (CTail e0 k u) & + (drop n (0) c2 (CTail e0 k w)) & + (subst0 (minus (r k i) (S n)) v u w) + ) | + (EX k e1 e2 u | e = (CTail e1 k u) & + (drop n (0) c2 (CTail e2 k u)) & + (csubst0 (minus (r k i) (S n)) v e1 e2) + ) | + (EX k e1 e2 u w | e = (CTail e1 k u) & + (drop n (0) c2 (CTail e2 k w)) & + (subst0 (minus (r k i) (S n)) v u w) & + (csubst0 (minus (r k i) (S n)) v e1 e2) + )). + XElim i. +(* case 1: i = 0 *) + Intros; Inversion H. +(* case 2: i > 0 *) + Intros i; XElim n. +(* case 2.1: n = 0 *) + Intros H0; Clear H0; Intros until 1; InsertEq H0 '(S i); XElim H0; + Clear H c1 c2 v y; Intros; DropGenBase; XRewrite e; + Rewrite <- r_arith0 in H; Try Rewrite <- r_arith0 in H0; Replace i with i0; XEAuto. +(* case 2.2: n > 0 *) + Intros until 3; Clear H0; InsertEq H2 '(S i); XElim H0; Clear c1 c2 v y; + Intros; DropGenBase. +(* case 2.2.1: csubst0_fst *) + XEAuto. +(* case 2.2.2: csubst0_snd *) + Replace i0 with i; XAuto; XReplaceIn H0 i0 i; XReplaceIn H2 i0 i; Clear H3 i0. + Apply (r_dis k); Intros; Rewrite (H3 i) in H0; Rewrite (H3 n) in H4. +(* case 2.2.2.1: bind *) + IH; XRewrite e; Try Rewrite <- (H3 n) in H; Try Rewrite <- (H3 n) in H0; + Try Rewrite <- r_arith1 in H4; Try Rewrite <- r_arith1 in H5; XEAuto. +(* case 2.2.2.2: flat *) + IH; XRewrite e; Try Rewrite <- (H3 n) in H2; Try Rewrite <- (H3 n) in H4; XEAuto. +(* case 2.2.3: csubst0_both *) + Replace i0 with i; XAuto; XReplaceIn H0 i0 i; XReplaceIn H2 i0 i; XReplaceIn H3 i0 i; Clear H4 i0. + Apply (r_dis k); Intros; Rewrite (H4 i) in H2; Rewrite (H4 n) in H5. +(* case 2.2.2.1: bind *) + IH; XRewrite e; Try Rewrite <- (H4 n) in H; Try Rewrite <- (H4 n) in H2; + Try Rewrite <- r_arith1 in H5; Try Rewrite <- r_arith1 in H6; XEAuto. +(* case 2.2.3.2: flat *) + IH; XRewrite e; Try Rewrite <- (H4 n) in H3; Try Rewrite <- (H4 n) in H5; XEAuto. + Qed. + + Theorem csubst0_drop_ge_back : (i,n:?) (le i n) -> + (c1,c2:?; v:?) (csubst0 i v c1 c2) -> + (e:?) (drop n (0) c2 e) -> + (drop n (0) c1 e). + XElim i. +(* case 1 : i = 0 *) + Intros; Inversion H0. +(* case 2 : i > 0 *) + Intros i; XElim n. +(* case 2.1 : n = 0 *) + Intros; Inversion H0. +(* case 2.2 : n > 0 *) + Intros until 3; Clear H0; InsertEq H2 '(S i); XElim H0; Intros; + DropGenBase. +(* case 2.2.1 : csubst0_fst *) + XAuto. +(* case 2.2.2 : csubst0_snd *) + XReplaceIn H0 i0 i; NewInduction k; XEAuto. +(* case 2.2.3 : csubst0_both *) + XReplaceIn H0 i0 i; XReplaceIn H2 i0 i; NewInduction k; XEAuto. + Qed. + + End csubst0_drop. + + Tactic Definition CSubst0Drop := + Match Context With + | [ H1: (lt ?2 ?1); + H2: (csubst0 ?1 ?3 ?4 ?5); H3: (drop ?2 (0) ?4 ?6) |- ? ] -> + LApply (csubst0_drop_lt ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros H3 | XAuto ]; + XElim H3; + [ Intros | Intros H3; XElim H3; Intros + | Intros H3; XElim H3; Intros | Intros H3; XElim H3; Intros ] + | [ H1: (le ?1 ?2); + H2: (csubst0 ?1 ?3 ?4 ?5); H3: (drop ?2 (0) ?4 ?6) |- ? ] -> + LApply (csubst0_drop_ge ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros | XAuto ] + | [H2: (csubst0 ?1 ?3 ?4 ?5); H3: (drop ?1 (0) ?4 ?6) |- ? ] -> + LApply (csubst0_drop_ge ?1 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x H2; Intros H2 | XAuto ]; + LApply (H2 ?6); [ Clear H2 H3; Intros | XAuto ] + | [H2: (csubst0 ?1 ?3 ?4 ?5); H3: (drop ?1 (0) ?5 ?6) |- ? ] -> + LApply (csubst0_drop_ge_back ?1 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros | XAuto ] + | [H2: (csubst0 ?1 ?3 ?4 ?5); H3: (drop ?2 (0) ?5 ?6) |- ? ] -> + LApply (csubst0_drop_ge_back ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros | XAuto ]. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/csubst1_defs.v b/helm/coq-contribs/LAMBDA-TYPES/csubst1_defs.v new file mode 100644 index 000000000..8d1e570b5 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/csubst1_defs.v @@ -0,0 +1,101 @@ +(*#* #stop file *) + +Require Export subst1_defs. +Require Export csubst0_defs. + + Inductive csubst1 [i:nat; v:T; c1:C] : C -> Prop := + | csubst1_refl : (csubst1 i v c1 c1) + | csubst1_single : (c2:?) (csubst0 i v c1 c2) -> (csubst1 i v c1 c2). + + Hint csubst1 : ltlc := Constructors csubst1. + + Section csubst1_props. (**************************************************) + + Theorem csubst1_tail: (k:?; i:?; v,u1,u2:?) (subst1 (r k i) v u1 u2) -> + (c1,c2:?) (csubst1 (r k i) v c1 c2) -> + (csubst1 (S i) v (CTail c1 k u1) (CTail c2 k u2)). + Intros until 1; XElim H; Clear u2. +(* case 1: csubst1_refl *) + Intros until 1; XElim H; Clear c2; XAuto. +(* case 2: csubst1_single *) + Intros until 2; XElim H0; Clear c2; XAuto. + Qed. + + End csubst1_props. + + Hints Resolve csubst1_tail : ltlc. + + Section csubst1_gen_base. (***********************************************) + + Theorem csubst1_gen_tail: (k:?; c1,x:?; u1,v:?; i:?) + (csubst1 (S i) v (CTail c1 k u1) x) -> + (EX u2 c2 | x = (CTail c2 k u2) & + (subst1 (r k i) v u1 u2) & + (csubst1 (r k i) v c1 c2) + ). + Intros; InsertEq H '(CTail c1 k u1); InsertEq H '(S i); + XElim H; Clear x; Intros. +(* case 1: csubst1_refl *) + Rewrite H0; XEAuto. +(* case 2: csubst1_single *) + Rewrite H0 in H; Rewrite H1 in H; Clear H0 H1 y y0. + CSubst0GenBase; Rewrite H; XEAuto. + Qed. + + End csubst1_gen_base. + + Tactic Definition CSubst1GenBase := + Match Context With + | [ H: (csubst1 (S ?1) ?2 (CTail ?3 ?4 ?5) ?6) |- ? ] -> + LApply (csubst1_gen_tail ?4 ?3 ?6 ?5 ?2 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section csubst1_drop. (***************************************************) + + Theorem csubst1_drop_ge : (i,n:?) (le i n) -> + (c1,c2:?; v:?) (csubst1 i v c1 c2) -> + (e:?) (drop n (0) c1 e) -> + (drop n (0) c2 e). + Intros until 2; XElim H0; Intros; + Try CSubst0Drop; XAuto. + Qed. + + Theorem csubst1_drop_lt : (i,n:?) (lt n i) -> + (c1,c2:?; v:?) (csubst1 i v c1 c2) -> + (e1:?) (drop n (0) c1 e1) -> + (EX e2 | (csubst1 (minus i n) v e1 e2) & + (drop n (0) c2 e2) + ). + Intros until 2; XElim H0; Intros; + Try ( + CSubst0Drop; Try Rewrite H1; Try Rewrite minus_x_Sy; + Try Rewrite r_minus in H3; Try Rewrite r_minus in H4 + ); XEAuto. + Qed. + + Theorem csubst1_drop_ge_back : (i,n:?) (le i n) -> + (c1,c2:?; v:?) (csubst1 i v c1 c2) -> + (e:?) (drop n (0) c2 e) -> + (drop n (0) c1 e). + Intros until 2; XElim H0; Intros; + Try CSubst0Drop; XAuto. + Qed. + + End csubst1_drop. + + Tactic Definition CSubst1Drop := + Match Context With + | [ H1: (lt ?2 ?1); + H2: (csubst1 ?1 ?3 ?4 ?5); H3: (drop ?2 (0) ?4 ?6) |- ? ] -> + LApply (csubst1_drop_lt ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros H3 | XAuto ]; + XElim H3; Intros + | [H2: (csubst1 ?1 ?3 ?4 ?5); H3: (drop ?1 (0) ?4 ?6) |- ? ] -> + LApply (csubst1_drop_ge ?1 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x H2; Intros H2 | XAuto ]; + LApply (H2 ?6); [ Clear H2 H3; Intros | XAuto ] + | [ H2: (csubst1 ?1 ?3 ?4 ?5); H3: (drop ?2 (0) ?4 ?6) |- ? ] -> + LApply (csubst1_drop_ge ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H3; Intros | XAuto ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/description b/helm/coq-contribs/LAMBDA-TYPES/description new file mode 100644 index 000000000..06f662322 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/description @@ -0,0 +1,13 @@ +Name: lambda-delta +Title: A formalization of a lambda-typed lambda-calculus with abbreviations +Author: Ferruccio Guidi +Email: fguidi@cs.unibo.it +Homepage: http://www.cs.unibo.it/~fguidi +Institution: Department of Computer Science, University of Bologna +Address: Mura Anteo Zamboni 7, 40127 Bologna, ITALY +Date: March 31, 2005 +Description: +Url: +Keywords: lambda-types, lambda-calculus, abbreviations +Version: 7.3.1 +Require: diff --git a/helm/coq-contribs/LAMBDA-TYPES/drop_defs.v b/helm/coq-contribs/LAMBDA-TYPES/drop_defs.v new file mode 100644 index 000000000..e1576c504 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/drop_defs.v @@ -0,0 +1,125 @@ +(*#* #stop file *) + +Require Export contexts_defs. +Require Export lift_defs. + + Inductive drop : nat -> nat -> C -> C -> Prop := + | drop_sort : (h,d,n:?) (drop h d (CSort n) (CSort n)) + | drop_tail : (c,e:?) (drop (0) (0) c e) -> + (k:?; u:?) (drop (0) (0) (CTail c k u) (CTail e k u)) + | drop_drop : (k:?; h:?; c,e:?) (drop (r k h) (0) c e) -> + (u:?) (drop (S h) (0) (CTail c k u) e) + | drop_skip : (k:?; h,d:?; c,e:?) (drop h (r k d) c e) -> (u:?) + (drop h (S d) (CTail c k (lift h (r k d) u)) (CTail e k u)). + + Hint drop : ltlc := Constructors drop. + + Hint discr : ltlc := Extern 4 (drop ? ? ? ?) Simpl. + + Section drop_gen_base. (**************************************************) + + Theorem drop_gen_sort : (n,h,d:?; x:?) + (drop h d (CSort n) x) -> x = (CSort n). + Intros until 1; InsertEq H '(CSort n); XElim H; Intros; + Try Inversion H1; XAuto. + Qed. + + Theorem drop_gen_refl : (x,e:?) (drop (0) (0) x e) -> x = e. + Intros until 1; Repeat InsertEq H '(0); XElim H; Intros. +(* case 1 : drop_sort *) + XAuto. +(* case 2 : drop_tail *) + Rewrite H0; XAuto. +(* case 3 : drop_drop *) + Inversion H2. +(* case 4 : drop_skip *) + Inversion H1. + Qed. + + Theorem drop_gen_drop : (k:?; c,x:?; u:?; h:?) + (drop (S h) (0) (CTail c k u) x) -> + (drop (r k h) (0) c x). + Intros until 1; + InsertEq H '(CTail c k u); InsertEq H '(0); InsertEq H '(S h); + XElim H; Intros. +(* case 1 : drop_sort *) + Inversion H1. +(* case 2 : drop_tail *) + Inversion H1. +(* case 3 : drop_drop *) + Inversion H1; Inversion H3. + Rewrite <- H5; Rewrite <- H6; Rewrite <- H7; XAuto. +(* case 4 : drop_skip *) + Inversion H2. + Qed. + + Theorem drop_gen_skip_r : (c,x:?; u:?; h,d:?; k:?) + (drop h (S d) x (CTail c k u)) -> + (EX e | x = (CTail e k (lift h (r k d) u)) & (drop h (r k d) e c)). + Intros; Inversion_clear H; XEAuto. + Qed. + + Theorem drop_gen_skip_l : (c,x:?; u:?; h,d:?; k:?) + (drop h (S d) (CTail c k u) x) -> + (EX e v | x = (CTail e k v) & + u = (lift h (r k d) v) & + (drop h (r k d) c e) + ). + Intros; Inversion_clear H; XEAuto. + Qed. + + End drop_gen_base. + + Hints Resolve drop_gen_refl : ltlc. + + Tactic Definition DropGenBase := + Match Context With + | [ H: (drop (0) (0) ?0 ?1) |- ? ] -> + LApply (drop_gen_refl ?0 ?1); [ Clear H; Intros | XAuto ] + | [ H: (drop ?0 ?1 (CSort ?2) ?3) |- ? ] -> + LApply (drop_gen_sort ?2 ?0 ?1 ?3); [ Clear H; Intros | XAuto ] + | [ H: (drop (S ?0) (0) (CTail ?1 ?2 ?3) ?4) |- ? ] -> + LApply (drop_gen_drop ?2 ?1 ?4 ?3 ?0); [ Clear H; Intros | XAuto ] + | [ H: (drop ?1 (S ?2) ?3 (CTail ?4 ?5 ?6)) |- ? ] -> + LApply (drop_gen_skip_r ?4 ?3 ?6 ?1 ?2 ?5); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (drop ?1 (S ?2) (CTail ?4 ?5 ?6) ?3) |- ? ] -> + LApply (drop_gen_skip_l ?4 ?3 ?6 ?1 ?2 ?5); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section drop_props. (*****************************************************) + + Theorem drop_skip_bind: (h,d:?; c,e:?) (drop h d c e) -> (b:?; u:?) + (drop h (S d) (CTail c (Bind b) (lift h d u)) (CTail e (Bind b) u)). + Intros; Pattern 2 d; Replace d with (r (Bind b) d); XAuto. + Qed. + + Theorem drop_refl: (c:?) (drop (0) (0) c c). + XElim c; XAuto. + Qed. + + Hints Resolve drop_refl : ltlc. + + Theorem drop_S : (b:?; c,e:?; u:?; h:?) + (drop h (0) c (CTail e (Bind b) u)) -> + (drop (S h) (0) c e). + XElim c. +(* case 1: CSort *) + Intros; DropGenBase; Inversion H. +(* case 2: CTail *) + XElim h; Intros; DropGenBase. +(* case 2.1: h = 0 *) + Inversion H0; XAuto. +(* case 2.1: h > 0 *) + Apply drop_drop; RRw; XEAuto. (**) (* explicit constructor *) + Qed. + + End drop_props. + + Hints Resolve drop_skip_bind drop_refl drop_S : ltlc. + + Tactic Definition DropS := + Match Context With + [ _: (drop ?1 (0) ?2 (CTail ?3 (Bind ?4) ?5)) |- ? ] -> + LApply (drop_S ?4 ?2 ?3 ?5 ?1); [ Intros | XAuto ]. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/drop_props.v b/helm/coq-contribs/LAMBDA-TYPES/drop_props.v new file mode 100644 index 000000000..c9d3ef294 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/drop_props.v @@ -0,0 +1,259 @@ +Require lift_gen. +Require drop_defs. + +(*#* #caption "main properties of drop" #clauses *) + + Section confluence. (*****************************************************) + +(*#* #stop macro *) + + Tactic Definition IH := + Match Context With + [ H1: (drop ?1 ?2 c ?3); H2: (drop ?1 ?2 c ?4) |- ? ] -> + LApply (H ?4 ?2 ?1); [ Clear H H2; Intros H | XAuto ]; + LApply (H ?3); [ Clear H H1; Intros | XAuto ]. + +(*#* #start macro *) + +(*#* #caption "confluence, first case" *) +(*#* #cap #alpha c in C, x1 in C1, x2 in C2, d in i *) + + Theorem drop_mono : (c,x1:?; d,h:?) (drop h d c x1) -> + (x2:?) (drop h d c x2) -> x1 = x2. + +(*#* #stop proof *) + + XElim c. +(* case 1: CSort *) + Intros; Repeat DropGenBase; Rewrite H0; XAuto. +(* case 2: CTail k *) + XElim d. +(* case 2.1: d = 0 *) + XElim h; Intros; Repeat DropGenBase; Try Rewrite <- H0; XEAuto. +(* case 2.2: d > 0 *) + Intros; Repeat DropGenBase; Rewrite H1; Rewrite H2; Rewrite H5 in H3; + LiftGen; IH; XAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "confluence, second case" *) +(*#* #cap #alpha c in C1, c0 in E1, e in C2, e0 in E2, u in V1, v in V2, i in k, d in i *) + + Theorem drop_conf_lt: (b:?; i:?; u:?; c0,c:?) + (drop i (0) c (CTail c0 (Bind b) u)) -> + (e:?; h,d:?) (drop h (S (plus i d)) c e) -> + (EX v e0 | u = (lift h d v) & + (drop i (0) e (CTail e0 (Bind b) v)) & + (drop h d c0 e0) + ). + +(*#* #stop proof *) + + XElim i. +(* case 1 : i = 0 *) + Intros until 1. + DropGenBase. + Rewrite H in H0; Clear H. + Inversion H0; XEAuto. +(* case 2 : i > 0 *) + Intros i; XElim c. +(* case 2.1 : CSort *) + Intros; Inversion H0. +(* case 2.2 : CTail k *) + XElim k; Intros; Repeat DropGenBase; Rewrite H2; Clear H2 H3 e t. +(* case 2.2.1 : Bind *) + LApply (H u c0 c); [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H x0 h d); [ Clear H H9; Intros H | XAuto ]. + XElim H; XEAuto. +(* case 2.2.2 : Flat *) + LApply H0; [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H x0 h d); [ Clear H H9; Intros H | XAuto ]. + XElim H; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "confluence, third case" *) +(*#* #cap #alpha c in C, a in C1, e in C2, i in k, d in i *) + + Theorem drop_conf_ge: (i:?; a,c:?) (drop i (0) c a) -> + (e:?; h,d:?) (drop h d c e) -> (le (plus d h) i) -> + (drop (minus i h) (0) e a). + +(*#* #stop proof *) + + XElim i. +(* case 1 : i = 0 *) + Intros until 1. + DropGenBase; Rewrite H in H0; Clear H c. + Inversion H1; Rewrite H2; Simpl; Clear H1. + PlusO; Rewrite H in H0; Rewrite H1 in H0; Clear H H1 d h. + DropGenBase; Rewrite <- H; XAuto. +(* case 2 : i > 0 *) + Intros i; XElim c. +(* case 2.1 : CSort *) + Intros; Repeat DropGenBase; Rewrite H1; Rewrite H0; XAuto. +(* case 2.2 : CTail k *) + XElim k; Intros; DropGenBase; + ( NewInduction d; + [ NewInduction h; DropGenBase; + [ Rewrite <- H2; Simpl; XAuto | Clear IHh ] + | DropGenBase; Rewrite H2; Clear IHd H2 H4 e t ] ). +(* case 2.2.1 : Bind, d = 0, h > 0 *) + LApply (H a c); [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H e h (0)); XAuto. +(* case 2.2.2 : Bind, d > 0 *) + LApply (H a c); [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H x0 h d); [ Clear H H4; Intros H | XAuto ]. + LApply H; [ Clear H; Simpl in H3; Intros H | XAuto ]. + Rewrite <- minus_Sn_m; XEAuto. +(* case 2.2.3 : Flat, d = 0, h > 0 *) + LApply H0; [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H e (S h) (0)); XAuto. +(* case 2.2.4 : Flat, d > 0 *) + LApply H0; [ Clear H H0 H1; Intros H | XAuto ]. + LApply (H x0 h (S d)); [ Clear H H4; Intros H | XAuto ]. + LApply H; [ Clear H; Simpl in H3; Intros H | XAuto ]. + Rewrite <- minus_Sn_m in H; [ Idtac | XEAuto ]. + Rewrite <- minus_Sn_m; XEAuto. + Qed. + +(*#* #start proof *) + + End confluence. + + Section transitivity. (***************************************************) + +(*#* #caption "transitivity, first case" *) +(*#* #cap #alpha c1 in C1, c2 in C2, e1 in D1, e2 in D2, d in i, i in k *) + + Theorem drop_trans_le : (i,d:?) (le i d) -> + (c1,c2:?; h:?) (drop h d c1 c2) -> + (e2:?) (drop i (0) c2 e2) -> + (EX e1 | (drop i (0) c1 e1) & (drop h (minus d i) e1 e2)). + +(*#* #stop proof *) + + XElim i. +(* case 1 : i = 0 *) + Intros. + DropGenBase; Rewrite H1 in H0. + Rewrite <- minus_n_O; XEAuto. +(* case 2 : i > 0 *) + Intros i IHi; XElim d. +(* case 2.1 : d = 0 *) + Intros; Inversion H. +(* case 2.2 : d > 0 *) + Intros d IHd; XElim c1. +(* case 2.2.1 : CSort *) + Intros. + DropGenBase; Rewrite H0 in H1. + DropGenBase; Rewrite H1; XEAuto. +(* case 2.2.2 : CTail k *) + Intros c1 IHc; XElim k; Intros; + DropGenBase; Rewrite H0 in H1; Rewrite H2; Clear IHd H0 H2 c2 t; + DropGenBase. +(* case 2.2.2.1 : Bind *) + LApply (IHi d); [ Clear IHi; Intros IHi | XAuto ]. + LApply (IHi c1 x0 h); [ Clear IHi H8; Intros IHi | XAuto ]. + LApply (IHi e2); [ Clear IHi H0; Intros IHi | XAuto ]. + XElim IHi; XEAuto. +(* case 2.2.2.2 : Flat *) + LApply (IHc x0 h); [ Clear IHc H8; Intros IHc | XAuto ]. + LApply (IHc e2); [ Clear IHc H0; Intros IHc | XAuto ]. + XElim IHc; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "transitivity, second case" *) +(*#* #cap #alpha c1 in C1, c2 in C, e2 in C2, d in i, i in k *) + + Theorem drop_trans_ge : (i:?; c1,c2:?; d,h:?) (drop h d c1 c2) -> + (e2:?) (drop i (0) c2 e2) -> (le d i) -> + (drop (plus i h) (0) c1 e2). + +(*#* #stop proof *) + + XElim i. +(* case 1: i = 0 *) + Intros. + DropGenBase; Rewrite <- H0. + Inversion H1; Rewrite H2 in H; XAuto. +(* case 2 : i > 0 *) + Intros i IHi; XElim c1; Simpl. +(* case 2.1: CSort *) + Intros. + DropGenBase; Rewrite H in H0. + DropGenBase; Rewrite H0; XAuto. +(* case 2.2: CTail *) + Intros c1 IHc; XElim d. +(* case 2.2.1: d = 0 *) + XElim h; Intros. +(* case 2.2.1.1: h = 0 *) + DropGenBase; Rewrite <- H in H0; + DropGenBase; Rewrite <- plus_n_O; XAuto. +(* case 2.2.1.2: h > 0 *) + DropGenBase; Rewrite <- plus_n_Sm. + Apply drop_drop; RRw; XEAuto. (**) (* explicit constructor *) +(* case 2.2.2: d > 0 *) + Intros d IHd; Intros. + DropGenBase; Rewrite H in IHd; Rewrite H in H0; Rewrite H2 in IHd; Rewrite H2; Clear IHd H H2 c2 t; + DropGenBase; Apply drop_drop; NewInduction k; Simpl; XEAuto. (**) (* explicit constructor *) + Qed. + +(*#* #start proof *) + + End transitivity. + +(*#* #stop macro *) + + Tactic Definition DropDis := + Match Context With + [ H1: (drop ?1 ?2 ?3 ?4); H2: (drop ?1 ?2 ?3 ?5) |- ? ] -> + LApply (drop_mono ?3 ?5 ?2 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?4); [ Clear H_x H1; Intros H1; Rewrite H1 in H2 | XAuto ] + | [ H1: (drop ?0 (0) ?1 (CTail ?2 (Bind ?3) ?4)); + H2: (drop ?5 (S (plus ?0 ?6)) ?1 ?7) |- ? ] -> + LApply (drop_conf_lt ?3 ?0 ?4 ?2 ?1); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?7 ?5 ?6); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ _: (drop ?0 (0) ?1 ?2); _: (drop ?5 (0) ?1 ?7); + _: (lt ?5 ?0) |- ? ] -> + LApply (drop_conf_ge ?0 ?2 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?7 ?5 (0)); [ Clear H_x; Intros H_x | XAuto ]; + Simpl in H_x; LApply H_x; [ Clear H_x; Intros | XAuto ] + | [ _: (drop ?1 (0) ?2 (CTail ?3 (Bind ?) ?)); + _: (drop (1) ?1 ?2 ?4) |- ? ] -> + LApply (drop_conf_ge (S ?1) ?3 ?2); [ Intros H_x | XEAuto ]; + LApply (H_x ?4 (1) ?1); [ Clear H_x; Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros | Rewrite plus_sym; XAuto ]; ( + Match Context With + [ H: (drop (minus (S ?1) (1)) (0) ?4 ?3) |- ? ] -> + Simpl in H; Rewrite <- minus_n_O in H ) + | [ H0: (drop ?0 (0) ?1 ?2); H2: (lt ?6 ?0); + H1: (drop (1) ?6 ?1 ?7) |- ? ] -> + LApply (drop_conf_ge ?0 ?2 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?7 (1) ?6); [ Clear H_x; Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros | Rewrite plus_sym; XAuto ] + | [ H0: (drop ?0 (0) ?1 ?2); + H1: (drop ?5 ?6 ?1 ?7) |- ? ] -> + LApply (drop_conf_ge ?0 ?2 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?7 ?5 ?6); [ Clear H_x; Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros | XAuto ] + | [ H0: (lt ?1 ?2); + H1: (drop ?3 ?2 ?4 ?5); H2: (drop ?1 (0) ?5 ?6) |- ? ] -> + LApply (drop_trans_le ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5 ?3); [ Clear H_x H1; Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x H2; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ H0: (le ?1 ?2); + H1: (drop ?3 ?1 ?4 ?5); H2: (drop ?2 (0) ?5 ?6) |- ? ] -> + LApply (drop_trans_ge ?2 ?4 ?5 ?1 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?6); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply H1; [ Clear H1; Intros | XAuto ]. + +(*#* #start macro *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/lift_defs.v b/helm/coq-contribs/LAMBDA-TYPES/lift_defs.v new file mode 100644 index 000000000..3185aad6f --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/lift_defs.v @@ -0,0 +1,236 @@ +(*#* #stop file *) + +Require Export terms_defs. + + Fixpoint bref_map [g:nat->nat; d:nat; t:T] : T := Cases t of + | (TSort n) => (TSort n) + | (TBRef n) => + if (blt n d) then (TBRef n) else (TBRef (g n)) + | (TTail k u t) => + (TTail k (bref_map g d u) (bref_map g (s k d) t)) + end. + + Definition lift : nat -> nat -> T -> T := + [h](bref_map [x](plus x h)). + + Section lift_rw. (********************************************************) + + Theorem lift_sort: (n:?; h,d:?) (lift h d (TSort n)) = (TSort n). + XAuto. + Qed. + + Theorem lift_bref_lt: (n:?; h,d:?) (lt n d) -> + (lift h d (TBRef n)) = (TBRef n). + Intros; Unfold lift; Simpl. + Replace (blt n d) with true; XAuto. + Qed. + + Theorem lift_bref_ge: (n:?; h,d:?) (le d n) -> + (lift h d (TBRef n)) = (TBRef (plus n h)). + + Intros; Unfold lift; Simpl. + Replace (blt n d) with false; XAuto. + Qed. + + Theorem lift_tail: (k:?; u,t:?; h,d:?) + (lift h d (TTail k u t)) = + (TTail k (lift h d u) (lift h (s k d) t)). + XAuto. + Qed. + + Theorem lift_bind: (b:?; u,t:?; h,d:?) + (lift h d (TTail (Bind b) u t)) = + (TTail (Bind b) (lift h d u) (lift h (S d) t)). + XAuto. + Qed. + + Theorem lift_flat: (f:?; u,t:?; h,d:?) + (lift h d (TTail (Flat f) u t)) = + (TTail (Flat f) (lift h d u) (lift h d t)). + XAuto. + Qed. + + End lift_rw. + + Hints Resolve lift_bref_lt lift_bind lift_flat : ltlc. + + Tactic Definition LiftTailRw := + Repeat (Rewrite lift_tail Orelse Rewrite lift_bind Orelse Rewrite lift_flat). + + Tactic Definition LiftTailRwBack := + Repeat (Rewrite <- lift_tail Orelse Rewrite <- lift_bind Orelse Rewrite <- lift_flat). + + Section lift_gen. (*******************************************************) + + Theorem lift_gen_sort: (h,d,n:?; t:?) (TSort n) = (lift h d t) -> + t = (TSort n). + XElim t; Intros. +(* case 1 : TSort *) + XAuto. +(* case 2 : TBRef n0 *) + Apply (lt_le_e n0 d); Intros. +(* case 2.1 : n0 < d *) + Rewrite lift_bref_lt in H; [ Inversion H | XAuto ]. +(* case 2.2 : n0 >= d *) + Rewrite lift_bref_ge in H; [ Inversion H | XAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H1; Inversion H1. + Qed. + + Theorem lift_gen_bref_lt: (h,d,n:?) (lt n d) -> + (t:?) (TBRef n) = (lift h d t) -> + t = (TBRef n). + XElim t; Intros. +(* case 1 : TSort *) + XAuto. +(* case 2 : TBRef n0 *) + Apply (lt_le_e n0 d); Intros. +(* case 2.1 : n0 < d *) + Rewrite lift_bref_lt in H0; XAuto. +(* case 2.2 : n0 >= d *) + Rewrite lift_bref_ge in H0; [ Inversion H0; Clear H0 | XAuto ]. + Rewrite H3 in H; Clear H3 n. + EApply le_false; [ Apply H1 | XEAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H2; Inversion H2. + Qed. + + Theorem lift_gen_bref_false: (h,d,n:?) (le d n) -> (lt n (plus d h)) -> + (t:?) (TBRef n) = (lift h d t) -> + (P:Prop) P. + XElim t; Intros. +(* case 1 : TSort *) + Inversion H1. +(* case 2 : TBRef n0 *) + Apply (lt_le_e n0 d); Intros. +(* case 2.1 : n0 < d *) + Rewrite lift_bref_lt in H1; [ Inversion H1; Clear H1 | XAuto ]. + Rewrite <- H4 in H2; Clear H4 n0. + EApply le_false; [ Apply H | XEAuto ]. +(* case 2.2 : n0 >= d *) + Rewrite lift_bref_ge in H1; [ Inversion H1; Clear H1 | XAuto ]. + Rewrite H4 in H0; Clear H4. + EApply le_false; [ Apply H2 | XEAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H3; Inversion H3. + Qed. + + Theorem lift_gen_bref_ge: (h,d,n:?) (le d n) -> + (t:?) (TBRef (plus n h)) = (lift h d t) -> + t = (TBRef n). + XElim t; Intros. +(* case 1 : TSort *) + Inversion H0. +(* case 2 : TBRef n0 *) + Apply (lt_le_e n0 d); Intros. +(* case 2.1 : n0 < d *) + Rewrite lift_bref_lt in H0; [ Inversion H0; Clear H0 | XAuto ]. + Rewrite <- H3 in H1; Clear H3 n0. + EApply le_false; [ Apply H | XEAuto ]. +(* case 2.2 : n0 >= d *) + Rewrite lift_bref_ge in H0; [ Inversion H0; XEAuto | XAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H2; Inversion H2. + Qed. + +(* NOTE: lift_gen_tail should be used instead of these two *) (**) + Theorem lift_gen_bind: (b:?; u,t,x:?; h,d:?) + (TTail (Bind b) u t) = (lift h d x) -> + (EX y z | x = (TTail (Bind b) y z) & + u = (lift h d y) & + t = (lift h (S d) z) + ). + XElim x; Intros. +(* case 1 : TSort *) + Inversion H. +(* case 2 : TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1 : n < d *) + Rewrite lift_bref_lt in H; [ Inversion H | XAuto ]. +(* case 2.2 : n >= d *) + Rewrite lift_bref_ge in H; [ Inversion H | XAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H1; Inversion H1. + XEAuto. + Qed. + + Theorem lift_gen_flat: (f:?; u,t,x:?; h,d:?) + (TTail (Flat f) u t) = (lift h d x) -> + (EX y z | x = (TTail (Flat f) y z) & + u = (lift h d y) & + t = (lift h d z) + ). + XElim x; Intros. +(* case 1 : TSort *) + Inversion H. +(* case 2 : TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1 : n < d *) + Rewrite lift_bref_lt in H; [ Inversion H | XAuto ]. +(* case 2.2 : n >= d *) + Rewrite lift_bref_ge in H; [ Inversion H | XAuto ]. +(* case 3 : TTail k *) + Rewrite lift_tail in H1; Inversion H1. + XEAuto. + Qed. + + End lift_gen. + + Tactic Definition LiftGenBase := + Match Context With + | [ H: (TSort ?0) = (lift ?1 ?2 ?3) |- ? ] -> + LApply (lift_gen_sort ?1 ?2 ?0 ?3); [ Clear H; Intros | XAuto ] + | [ H1: (le ?1 ?2); H2: (lt ?2 (plus ?1 ?3)); + H3: (TBRef ?2) = (lift ?3 ?1 ?4) |- ? ] -> + Apply (lift_gen_bref_false ?3 ?1 ?2 H1 H2 ?4 H3); XAuto + | [ H: (TBRef ?1) = (lift (1) ?1 ?2) |- ? ] -> + LApply (lift_gen_bref_false (1) ?1 ?1); [ Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros H_x | Arith7' ?1; XAuto ]; + LApply (H_x ?2); [ Clear H_x; Intros H_x | XAuto ]; + Apply H_x + | [ H: (TBRef (plus ?0 ?1)) = (lift ?1 ?2 ?3) |- ? ] -> + LApply (lift_gen_bref_ge ?1 ?2 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?3); [ Clear H_x H; Intros | XAuto ] + | [ H1: (TBRef ?0) = (lift ?1 ?2 ?3); H2: (lt ?0 ?4) |- ? ] -> + LApply (lift_gen_bref_lt ?1 ?2 ?0); + [ Intros H_x | Apply lt_le_trans with m:=?4; XEAuto ]; + LApply (H_x ?3); [ Clear H_x H1; Intros | XAuto ] + | [ H: (TBRef ?0) = (lift ?1 ?2 ?3) |- ? ] -> + LApply (lift_gen_bref_lt ?1 ?2 ?0); [ Intros H_x | XEAuto ]; + LApply (H_x ?3); [ Clear H_x H; Intros | XAuto ] + | [ H: (TTail (Bind ?0) ?1 ?2) = (lift ?3 ?4 ?5) |- ? ] -> + LApply (lift_gen_bind ?0 ?1 ?2 ?5 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (TTail (Flat ?0) ?1 ?2) = (lift ?3 ?4 ?5) |- ? ] -> + LApply (lift_gen_flat ?0 ?1 ?2 ?5 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section lift_props. (*****************************************************) + + Theorem lift_r: (t:?; d:?) (lift (0) d t) = t. + XElim t; Intros. +(* case 1: TSort *) + XAuto. +(* case 2: TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Rewrite lift_bref_lt; XAuto. +(* case 2.2: n >= d *) + Rewrite lift_bref_ge; XAuto. +(* case 3: TTail *) + LiftTailRw; XAuto. + Qed. + + Theorem lift_bref_gt : (d,n:?) (lt d n) -> + (lift (1) d (TBRef (pred n))) = (TBRef n). + Intros. + Rewrite lift_bref_ge. +(* case 1: first branch *) + Rewrite <- plus_sym; Simpl; Rewrite <- (S_pred n d); XAuto. +(* case 2: second branch *) + Apply le_S_n; Rewrite <- (S_pred n d); XAuto. + Qed. + + End lift_props. + + Hints Resolve lift_r lift_bref_gt : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/lift_gen.v b/helm/coq-contribs/LAMBDA-TYPES/lift_gen.v new file mode 100644 index 000000000..14914d4cb --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/lift_gen.v @@ -0,0 +1,126 @@ +(*#* #stop file *) + +Require lift_defs. + + Section lift_ini. (*******************************************************) + + Tactic Definition IH := + Match Context With + | [ H1: (lift ?1 ?2 t) = (lift ?1 ?2 ?3) |- ? ] -> + LApply (H ?3 ?1 ?2); [ Clear H H1; Intros | XAuto ] + | [ H1: (lift ?1 ?2 t0) = (lift ?1 ?2 ?3) |- ? ] -> + LApply (H0 ?3 ?1 ?2); [ Clear H0 H1; Intros | XAuto ]. + +(*#* #start file *) + +(*#* #caption "main properties of lift" #clauses lift_props *) + +(*#* #caption "injectivity" *) +(*#* #cap #alpha x in T1, t in T2, d in i *) + + Theorem lift_inj : (x,t:?; h,d:?) (lift h d x) = (lift h d t) -> x = t. + +(*#* #stop file *) + + XElim x. +(* case 1 : TSort *) + Intros; Rewrite lift_sort in H; LiftGenBase; XAuto. +(* case 2 : TBRef n *) + Intros; Apply (lt_le_e n d); Intros. +(* case 2.1 : n < d *) + Rewrite lift_bref_lt in H; [ LiftGenBase; XAuto | XAuto ]. +(* case 2.2 : n >= d *) + Rewrite lift_bref_ge in H; [ LiftGenBase; XAuto | XAuto ]. +(* case 3 : TTail k *) + XElim k; Intros; [ Rewrite lift_bind in H1 | Rewrite lift_flat in H1 ]; + LiftGenBase; Rewrite H1; IH; IH; XAuto. + Qed. + + End lift_ini. + + Section lift_gen_lift. (**************************************************) + + Tactic Definition IH := + Match Context With + | [ H_x: (lift ?0 ?1 t) = (lift ?2 (plus ?3 ?0) ?4) |- ? ] -> + LApply (H ?4 ?0 ?2 ?1 ?3); [ Clear H; Intros H | XAuto ]; + LApply H; [ Clear H H_x; Intros H | XAuto ]; + XElim H; Intros + | [ H_x: (lift ?0 ?1 t0) = (lift ?2 (plus ?3 ?0) ?4) |- ? ] -> + LApply (H0 ?4 ?0 ?2 ?1 ?3); [ Clear H0; Intros H0 | XAuto ]; + LApply H0; [ Clear H0 H_x; Intros H0 | XAuto ]; + XElim H0; Intros. + +(*#* #start file *) + +(*#* #caption "generation lemma for lift" *) +(*#* #cap #cap t1 #alpha t2 in T, x in T2, d1 in i1, d2 in i2 *) + + Theorem lift_gen_lift : (t1,x:?; h1,h2,d1,d2:?) (le d1 d2) -> + (lift h1 d1 t1) = (lift h2 (plus d2 h1) x) -> + (EX t2 | x = (lift h1 d1 t2) & + t1 = (lift h2 d2 t2) + ). + +(*#* #stop file *) + + XElim t1; Intros. +(* case 1 : TSort *) + Rewrite lift_sort in H0. + LiftGenBase; Rewrite H0; Clear H0 x. + EApply ex2_intro; Rewrite lift_sort; XAuto. +(* case 2 : TBRef n *) + Apply (lt_le_e n d1); Intros. +(* case 2.1 : n < d1 *) + Rewrite lift_bref_lt in H0; [ Idtac | XAuto ]. + LiftGenBase; Rewrite H0; Clear H0 x. + EApply ex2_intro; Rewrite lift_bref_lt; XEAuto. +(* case 2.2 : n >= d1 *) + Rewrite lift_bref_ge in H0; [ Idtac | XAuto ]. + Apply (lt_le_e n d2); Intros. +(* case 2.2.1 : n < d2 *) + LiftGenBase; Rewrite H0; Clear H0 x. + EApply ex2_intro; [ Rewrite lift_bref_ge | Rewrite lift_bref_lt ]; XEAuto. +(* case 2.2.2 : n >= d2 *) + Apply (lt_le_e n (plus d2 h2)); Intros. +(* case 2.2.2.1 : n < d2 + h2 *) + EApply lift_gen_bref_false; [ Idtac | Idtac | Apply H0 ]; + [ XAuto | Rewrite plus_permute_2_in_3; XAuto ]. +(* case 2.2.2.2 : n >= d2 + h2 *) + Rewrite (le_plus_minus_sym h2 (plus n h1)) in H0; [ Idtac | XEAuto ]. + LiftGenBase; Rewrite H0; Clear H0 x. + EApply ex2_intro; + [ Rewrite le_minus_plus; [ Idtac | XEAuto ] + | Rewrite (le_plus_minus_sym h2 n); [ Idtac | XEAuto ] ]; + Rewrite lift_bref_ge; XEAuto. +(* case 3 : TTail k *) + NewInduction k. +(* case 3.1 : Bind *) + Rewrite lift_bind in H2. + LiftGenBase; Rewrite H2; Clear H2 x. + IH; Rewrite H; Rewrite H2; Clear H H2 x0. + Arith4In H4 d2 h1; IH; Rewrite H; Rewrite H0; Clear H H0 x1 t t0. + EApply ex2_intro; Rewrite lift_bind; XAuto. +(* case 3.2 : Flat *) + Rewrite lift_flat in H2. + LiftGenBase; Rewrite H2; Clear H2 x. + IH; Rewrite H; Rewrite H2; Clear H H2 x0. + IH; Rewrite H; Rewrite H0; Clear H H0 x1 t t0. + EApply ex2_intro; Rewrite lift_flat; XAuto. + Qed. + + End lift_gen_lift. + + Tactic Definition LiftGen := + Match Context With + | [ H: (lift ?1 ?2 ?3) = (lift ?1 ?2 ?4) |- ? ] -> + LApply (lift_inj ?3 ?4 ?1 ?2); [ Clear H; Intros | XAuto ] + | [ H: (lift ?0 ?1 ?2) = (lift ?3 (plus ?4 ?0) ?5) |- ? ] -> + LApply (lift_gen_lift ?2 ?5 ?0 ?3 ?1 ?4); [ Intros H_x | XAuto ]; + LApply H_x; [ Clear H H_x; Intros H | XAuto ]; + XElim H; Intros + | [ H: (lift (1) (0) ?1) = (lift (1) (S ?2) ?3) |- ? ] -> + LApply (lift_gen_lift ?1 ?3 (1) (1) (0) ?2); [ Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x H; Intros H | Arith7' ?2; XAuto ]; + XElim H; Intros + | _ -> LiftGenBase. diff --git a/helm/coq-contribs/LAMBDA-TYPES/lift_props.v b/helm/coq-contribs/LAMBDA-TYPES/lift_props.v new file mode 100644 index 000000000..5d5d7d0a9 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/lift_props.v @@ -0,0 +1,43 @@ +(*#* #stop file *) + +Require lift_defs. + + Section lift_props. (*****************************************************) + + Theorem lift_free: (t:?; h,k,d,e:?) (le e (plus d h)) -> (le d e) -> + (lift k e (lift h d t)) = (lift (plus k h) d t). + XElim t; Intros. +(* case 1: TSort *) + Repeat Rewrite lift_sort; XAuto. +(* case 2: TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Repeat Rewrite lift_bref_lt; XEAuto. +(* case 2.2: n >= d *) + Repeat Rewrite lift_bref_ge; XEAuto. +(* case 3: TTail k *) + LiftTailRw; XAuto. + Qed. + + Theorem lift_d : (t:?; h,k,d,e:?) (le e d) -> + (lift h (plus k d) (lift k e t)) = (lift k e (lift h d t)). + XElim t; Intros. +(* case 1: TSort *) + Repeat Rewrite lift_sort; XAuto. +(* case 2: TBRef n *) + Apply (lt_le_e n e); Intros. +(* case 2.1: n < e *) + Cut (lt n d); Intros; Repeat Rewrite lift_bref_lt; XEAuto. +(* case 2.2: n >= e *) + Rewrite lift_bref_ge; [ Idtac | XAuto ]. + Rewrite plus_sym; Apply (lt_le_e n d); Intros. +(* case 2.2.1: n < d *) + Do 2 (Rewrite lift_bref_lt; [ Idtac | XAuto ]). + Rewrite lift_bref_ge; XAuto. +(* case 2.2.2: n >= d *) + Repeat Rewrite lift_bref_ge; XAuto. +(* case 3: TTail k *) + LiftTailRw; SRw; XAuto. + Qed. + + End lift_props. diff --git a/helm/coq-contribs/LAMBDA-TYPES/lift_tlt.v b/helm/coq-contribs/LAMBDA-TYPES/lift_tlt.v new file mode 100644 index 000000000..3a9cb3fce --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/lift_tlt.v @@ -0,0 +1,89 @@ +(*#* #stop file *) + +Require tlt_defs. +Require lift_defs. + + Hint discr : ltlc := Extern 4 (lt (weight_map (wadd ? ?) (lift (S ?) ? ?)) (wadd ? ? ?)) + Simpl; Rewrite <- lift_weight_add_O. + + Hint discr : ltlc := Extern 4 (lt (weight_map ? (lift (0) (0) ?)) ?) + Rewrite lift_r. + + Section lift_tlt_props. (*************************************************) + + Theorem lift_weight_map: (t:?; h,d:?; f:?) + ((m:?) (le d m) -> (f m)=(0)) -> + (weight_map f (lift h d t)) = (weight_map f t). + XElim t; Intros. +(* case 1: TSort *) + XAuto. +(* case 2: TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Rewrite lift_bref_lt; XAuto. +(* case 2.2: n >= d *) + Rewrite lift_bref_ge; [ Simpl | XAuto ]. + Rewrite (H n); XAuto. +(* case 3: TTail k *) + XElim k; Intros; LiftTailRw; Simpl. +(* case 3.1: Bind *) + XElim b; [ Rewrite H; [ Idtac | XAuto ] | Idtac | Idtac ]; + Rewrite H0; Intros; Try (LeLtGen; Rewrite H2; Simpl); XAuto. +(* case 3.2: Flat *) + XAuto. + Qed. + + Hints Resolve lift_weight_map : ltlc. + + Theorem lift_weight : (t:?; h,d:?) (weight (lift h d t)) = (weight t). + Unfold weight; XAuto. + Qed. + + Theorem lift_weight_add : (w:?; t:?; h,d:?; f,g:?) + ((m:?) (lt m d) -> (g m) = (f m)) -> + (g d) = w -> + ((m:?) (le d m) -> (g (S m)) = (f m)) -> + (weight_map f (lift h d t)) = + (weight_map g (lift (S h) d t)). + XElim t; Intros. +(* case 1: TSort *) + XAuto. +(* case 2: TBRef *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Repeat Rewrite lift_bref_lt; Simpl; XAuto. +(* case 2.2: n >= d *) + Repeat Rewrite lift_bref_ge; Simpl; Try Rewrite <- plus_n_Sm; XAuto. +(* case 3: TTail k *) + XElim k; Intros; LiftTailRw; Simpl. +(* case 1 : bind b *) + XElim b; Simpl; + Apply (f_equal nat); + (Apply (f_equal2 nat nat); [ XAuto | Idtac ]); + ( Apply H0; Simpl; Intros; Try (LeLtGen; Rewrite H4; Simpl); XAuto). +(* case 2 : Flat *) + XAuto. + Qed. + + Theorem lift_weight_add_O: (w:?; t:?; h:?; f:?) + (weight_map f (lift h (0) t)) = + (weight_map (wadd f w) (lift (S h) (0) t)). + Intros. + EApply lift_weight_add; XAuto. + Intros; Inversion H. + Qed. + + Theorem lift_tlt_dx: (k:?; u,t:?; h,d:?) + (tlt t (TTail k u (lift h d t))). + Unfold tlt; Intros. + Rewrite <- (lift_weight t h d). + Fold (tlt (lift h d t) (TTail k u (lift h d t))); XAuto. + Qed. + + End lift_tlt_props. + + Hints Resolve lift_tlt_dx : ltlc. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc1_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pc1_defs.v new file mode 100644 index 000000000..0dcc0b8c7 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc1_defs.v @@ -0,0 +1,79 @@ +(*#* #stop file *) + +Require Export pr0_defs. + + Inductive pc0 [t1,t2:T] : Prop := + | pc0_r : (pr0 t1 t2) -> (pc0 t1 t2) + | pc0_x : (pr0 t2 t1) -> (pc0 t1 t2). + + Hint pc0 : ltlc := Constructors pc0. + + Inductive pc1 : T -> T -> Prop := + | pc1_r : (t:?) (pc1 t t) + | pc1_u : (t2,t1:?) (pc0 t1 t2) -> (t3:?) (pc1 t2 t3) -> (pc1 t1 t3). + + Hint pc1 : ltlc := Constructors pc1. + + Section pc0_props. (******************************************************) + + Theorem pc0_s : (t2,t1:?) (pc0 t1 t2) -> (pc0 t2 t1). + Intros. + Inversion H; XAuto. + Qed. + + End pc0_props. + + Hints Resolve pc0_s : ltlc. + + Section pc1_props. (******************************************************) + + Theorem pc1_pr0_r : (t1,t2:?) (pr0 t1 t2) -> (pc1 t1 t2). + XEAuto. + Qed. + + Theorem pc1_pr0_x : (t1,t2:?) (pr0 t2 t1) -> (pc1 t1 t2). + XEAuto. + Qed. + + Theorem pc1_pc0 : (t1,t2:?) (pc0 t1 t2) -> (pc1 t1 t2). + XEAuto. + Qed. + + Theorem pc1_t : (t2,t1:?) (pc1 t1 t2) -> + (t3:?) (pc1 t2 t3) -> (pc1 t1 t3). + Intros t2 t1 H; XElim H; XEAuto. + Qed. + + Hints Resolve pc1_t : ltlc. + + Theorem pc1_s : (t2,t1:?) (pc1 t1 t2) -> (pc1 t2 t1). + Intros; XElim H; XEAuto. + Qed. + + Theorem pc1_tail_1: (u1,u2:?) (pc1 u1 u2) -> + (t:?; k:?) (pc1 (TTail k u1 t) (TTail k u2 t)). + Intros; XElim H; Intros. +(* case 1: pc1_r *) + XAuto. +(* case 2: pc1_u *) + XElim H; Intros; XEAuto. + Qed. + + Theorem pc1_tail_2: (t1,t2:?) (pc1 t1 t2) -> + (u:?; k:?) (pc1 (TTail k u t1) (TTail k u t2)). + Intros; XElim H; Intros. +(* case 1: pc1_r *) + XAuto. +(* case 2: pc1_u *) + XElim H; Intros; XEAuto. + Qed. + + Theorem pc1_tail: (u1,u2:?) (pc1 u1 u2) -> (t1,t2:?) (pc1 t1 t2) -> + (k:?) (pc1 (TTail k u1 t1) (TTail k u2 t2)). + Intros; EApply pc1_t; [ EApply pc1_tail_1 | EApply pc1_tail_2 ]; XAuto. + Qed. + + End pc1_props. + + Hints Resolve pc1_pr0_r pc1_pr0_x pc1_pc0 pc1_t pc1_s + pc1_tail_1 pc1_tail_2 pc1_tail : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc3_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pc3_defs.v new file mode 100644 index 000000000..b2b530d59 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc3_defs.v @@ -0,0 +1,160 @@ +(*#* #stop file *) + +Require Export pr2_defs. +Require Export pr3_defs. +Require Export pc1_defs. + + Inductive pc2 [c:C; t1,t2:T] : Prop := + | pc2_r : (pr2 c t1 t2) -> (pc2 c t1 t2) + | pc2_x : (pr2 c t2 t1) -> (pc2 c t1 t2). + + Hint pc2 : ltlc := Constructors pc2. + + Inductive pc3 [c:C] : T -> T -> Prop := + | pc3_r : (t:?) (pc3 c t t) + | pc3_u : (t2,t1:?) (pc2 c t1 t2) -> + (t3:?) (pc3 c t2 t3) -> (pc3 c t1 t3). + + Hint pc3 : ltlc := Constructors pc3. + + Section pc2_props. (******************************************************) + + Theorem pc2_s : (c,t2,t1:?) (pc2 c t1 t2) -> (pc2 c t2 t1). + Intros. + Inversion H; XAuto. + Qed. + + Theorem pc2_shift : (h:?; c,e:?) (drop h (0) c e) -> + (t1,t2:?) (pc2 c t1 t2) -> + (pc2 e (app c h t1) (app c h t2)). + Intros until 2; XElim H0; Intros. +(* case 1 : pc2_r *) + XAuto. +(* case 2 : pc2_x *) + XEAuto. + Qed. + + End pc2_props. + + Hints Resolve pc2_s pc2_shift : ltlc. + + Section pc3_props. (******************************************************) + + Theorem pc3_pr2_r : (c,t1,t2:?) (pr2 c t1 t2) -> (pc3 c t1 t2). + XEAuto. + Qed. + + Theorem pc3_pr2_x : (c,t1,t2:?) (pr2 c t2 t1) -> (pc3 c t1 t2). + XEAuto. + Qed. + + Theorem pc3_pc2 : (c,t1,t2:?) (pc2 c t1 t2) -> (pc3 c t1 t2). + XEAuto. + Qed. + + Theorem pc3_t : (t2,c,t1:?) (pc3 c t1 t2) -> + (t3:?) (pc3 c t2 t3) -> (pc3 c t1 t3). + Intros t2 c t1 H; XElim H; XEAuto. + Qed. + + Hints Resolve pc3_t : ltlc. + + Theorem pc3_s : (c,t2,t1:?) (pc3 c t1 t2) -> (pc3 c t2 t1). + Intros; XElim H; [ XAuto | XEAuto ]. + Qed. + + Hints Resolve pc3_s : ltlc. + + Theorem pc3_pr3_r : (c:?; t1,t2) (pr3 c t1 t2) -> (pc3 c t1 t2). + Intros; XElim H; XEAuto. + Qed. + + Theorem pc3_pr3_x : (c:?; t1,t2) (pr3 c t2 t1) -> (pc3 c t1 t2). + Intros; XElim H; XEAuto. + Qed. + + Hints Resolve pc3_pr3_r pc3_pr3_x : ltlc. + + Theorem pc3_pr3_t : (c:?; t1,t0:?) (pr3 c t1 t0) -> + (t2:?) (pr3 c t2 t0) -> (pc3 c t1 t2). + Intros; Apply (pc3_t t0); XAuto. + Qed. + + Theorem pc3_thin_dx : (c:? ;t1,t2:?) (pc3 c t1 t2) -> + (u:?; f:?) (pc3 c (TTail (Flat f) u t1) + (TTail (Flat f) u t2)). + Intros; XElim H; [XAuto | Intros ]. + EApply pc3_u; [ Inversion H | Apply H1 ]; XAuto. + Qed. + + Theorem pc3_tail_1 : (c:?; u1,u2:?) (pc3 c u1 u2) -> + (k:?; t:?) (pc3 c (TTail k u1 t) (TTail k u2 t)). + Intros until 1; XElim H; Intros. +(* case 1 : pc3_r *) + XAuto. +(* case 2 : pc3_u *) + EApply pc3_u; [ Inversion H | Apply H1 ]; XAuto. + Qed. + + Theorem pc3_tail_2 : (c:?; u,t1,t2:?; k:?) (pc3 (CTail c k u) t1 t2) -> + (pc3 c (TTail k u t1) (TTail k u t2)). + Intros. + XElim H; [ Idtac | Intros; Inversion H ]; XEAuto. + Qed. + + Theorem pc3_tail_12 : (c:?; u1,u2:?) (pc3 c u1 u2) -> + (k:?; t1,t2:?) (pc3 (CTail c k u2) t1 t2) -> + (pc3 c (TTail k u1 t1) (TTail k u2 t2)). + Intros. + EApply pc3_t; [ Apply pc3_tail_1 | Apply pc3_tail_2 ]; XAuto. + Qed. + + Theorem pc3_tail_21 : (c:?; u1,u2:?) (pc3 c u1 u2) -> + (k:?; t1,t2:?) (pc3 (CTail c k u1) t1 t2) -> + (pc3 c (TTail k u1 t1) (TTail k u2 t2)). + Intros. + EApply pc3_t; [ Apply pc3_tail_2 | Apply pc3_tail_1 ]; XAuto. + Qed. + + Theorem pc3_pr3_u : (c:?; t2,t1:?) (pr2 c t1 t2) -> + (t3:?) (pc3 c t2 t3) -> (pc3 c t1 t3). + XEAuto. + Qed. + + Theorem pc3_pr3_u2 : (c:?; t0,t1:?) (pr2 c t0 t1) -> + (t2:?) (pc3 c t0 t2) -> (pc3 c t1 t2). + Intros; Apply (pc3_t t0); XAuto. + Qed. + + Theorem pc3_shift : (h:?; c,e:?) (drop h (0) c e) -> + (t1,t2:?) (pc3 c t1 t2) -> + (pc3 e (app c h t1) (app c h t2)). + Intros until 2; XElim H0; Clear t1 t2; Intros. +(* case 1 : pc3_r *) + XAuto. +(* case 2 : pc3_u *) + XEAuto. + Qed. + + Theorem pc3_pc1: (t1,t2:?) (pc1 t1 t2) -> (c:?) (pc3 c t1 t2). + Intros; XElim H; Intros. +(* case 1: pc1_r *) + XAuto. +(* case 2 : pc1_u *) + XElim H; XEAuto. + Qed. + + End pc3_props. + + Hints Resolve pc3_pr2_r pc3_pr2_x pc3_pc2 pc3_pr3_r pc3_pr3_x + pc3_t pc3_s pc3_pr3_t pc3_thin_dx pc3_tail_1 pc3_tail_2 + pc3_tail_12 pc3_tail_21 pc3_pr3_u pc3_shift pc3_pc1 : ltlc. + + Tactic Definition Pc3T := + Match Context With + | [ _: (pr3 ?1 ?2 (TTail ?3 ?4 ?5)); _: (pc3 ?1 ?6 ?4) |- ? ] -> + LApply (pc3_t (TTail ?3 ?4 ?5) ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x (TTail ?3 ?6 ?5)); [ Clear H_x; Intros | Apply pc3_s; XAuto ] + | [ _: (pc3 ?1 ?2 ?3); _: (pr3 ?1 ?3 ?4) |- ? ] -> + LApply (pc3_t ?3 ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?4); [ Clear H_x; Intros | XAuto ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc3_gen.v b/helm/coq-contribs/LAMBDA-TYPES/pc3_gen.v new file mode 100644 index 000000000..4e5dabaaa --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc3_gen.v @@ -0,0 +1,80 @@ +(*#* #stop file *) + +Require lift_gen. +Require pr3_props. +Require pr3_gen. +Require pc3_defs. +Require pc3_props. + + Section pc3_gen. (********************************************************) + + Theorem pc3_gen_abst : (c:?; u1,u2,t1,t2:?) + (pc3 c (TTail (Bind Abst) u1 t1) + (TTail (Bind Abst) u2 t2) + ) -> + (pc3 c u1 u2) /\ + (b:?; u:?) (pc3 (CTail c (Bind b) u) t1 t2). + Intros. + Pc3Confluence; Pr3Gen; Pr3Gen; Rewrite H0 in H; Clear H0 x. + Inversion H; Rewrite H5 in H1; Rewrite H6 in H2. + Split; XEAuto. + Qed. + + Theorem pc3_gen_lift: (c:?; t1,t2:?; h,d:?) + (pc3 c (lift h d t1) (lift h d t2)) -> + (e:?) (drop h d c e) -> + (pc3 e t1 t2). + Intros. + Pc3Confluence; Pr3Gen; Pr3Gen; Rewrite H1 in H; Clear H1 x. + LiftGen; Rewrite H in H2; XEAuto. + Qed. + + Theorem pc3_gen_not_abst : (b:?) ~b=Abst -> (c:?; t1,t2,u1,u2:?) + (pc3 c (TTail (Bind b) u1 t1) + (TTail (Bind Abst) u2 t2) + ) -> + (pc3 (CTail c (Bind b) u1) t1 + (lift (1) (0) (TTail (Bind Abst) u2 t2)) + ) + . + Intros b; XElim b; Intros; + Try EqFalse; Pc3Confluence; Pr3Gen; Pr3Gen; + Try (Rewrite H1 in H0; Inversion H0); + Rewrite H1 in H4; Pr3Context; + EApply pc3_pr3_t; XEAuto. + Qed. + + Theorem pc3_gen_lift_abst : (c:?; t,t2,u2:?; h,d:?) + (pc3 c (lift h d t) + (TTail (Bind Abst) u2 t2) + ) -> + (e:?) (drop h d c e) -> + (EX u1 t1 | (pr3 e t (TTail (Bind Abst) u1 t1)) & + (pr3 c u2 (lift h d u1)) & + (b:B; u:T)(pr3 (CTail c (Bind b) u) t2 (lift h (S d) t1)) + ). + Intros. + Pc3Confluence; Pr3Gen; Pr3Gen; Rewrite H1 in H; Clear H1 x. + LiftGenBase; Rewrite H in H4; Rewrite H1 in H2; Rewrite H5 in H3; XEAuto. + Qed. + + End pc3_gen. + + Tactic Definition Pc3Gen := + Match Context With + | [ _: (pc3 ?1 (lift ?2 ?3 ?4) (lift ?2 ?3 ?5)); + _: (drop ?2 ?3 ?1 ?6) |- ? ] -> + LApply (pc3_gen_lift ?1 ?4 ?5 ?2 ?3); [ Intros H_x | XAuto ]; + LApply (H_x ?6); [ Clear H_x; Intros | XAuto ] + | [ H: (pc3 ?1 (TTail (Bind Abst) ?2 ?3) (TTail (Bind Abst) ?4 ?5)) |- ? ] -> + LApply (pc3_gen_abst ?1 ?2 ?4 ?3 ?5);[ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (pc3 ?1 (TTail (Bind ?2) ?3 ?4) (TTail (Bind Abst) ?5 ?6)); + _: ~ ?2 = Abst |- ? ] -> + LApply (pc3_gen_not_abst ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?1 ?4 ?6 ?3 ?5); [ Clear H H_x; Intros | XAuto ] + | [ _: (pc3 ?1 (lift ?2 ?3 ?4) (TTail (Bind Abst) ?5 ?6)); + _: (drop ?2 ?3 ?1 ?7) |- ? ] -> + LApply (pc3_gen_lift_abst ?1 ?4 ?6 ?5 ?2 ?3); [ Intros H_x | XAuto ]; + LApply (H_x ?7); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc3_gen_context.v b/helm/coq-contribs/LAMBDA-TYPES/pc3_gen_context.v new file mode 100644 index 000000000..4e26ce7ea --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc3_gen_context.v @@ -0,0 +1,22 @@ +(*#* #stop file *) + +Require subst1_confluence. +Require csubst1_defs. +Require pr3_gen_context. +Require pc3_defs. +Require pc3_props. + + Section pc3_gen_context. (************************************************) + + Theorem pc3_gen_cabbr: (c:?; t1,t2:?) (pc3 c t1 t2) -> (e:?; u:?; d:?) + (drop d (0) c (CTail e (Bind Abbr) u)) -> + (a0:?) (csubst1 d u c a0) -> + (a:?) (drop (1) d a0 a) -> + (x1:?) (subst1 d u t1 (lift (1) d x1)) -> + (x2:?) (subst1 d u t2 (lift (1) d x2)) -> + (pc3 a x1 x2). + Intros; Pc3Confluence; Repeat Pr3GenContext. + Subst1Confluence; Rewrite H in H3; Clear H x3; XEAuto. + Qed. + + End pc3_gen_context. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc3_props.v b/helm/coq-contribs/LAMBDA-TYPES/pc3_props.v new file mode 100644 index 000000000..49d9bc4ec --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc3_props.v @@ -0,0 +1,163 @@ +(*#* #stop file *) + +Require subst0_subst0. +Require pr0_subst0. +Require pr3_defs. +Require pr3_props. +Require pr3_confluence. +Require cpr0_defs. +Require cpr0_props. +Require pc3_defs. + + Section pc3_confluence. (*************************************************) + + Theorem pc3_confluence : (c:?; t1,t2:?) (pc3 c t1 t2) -> + (EX t0 | (pr3 c t1 t0) & (pr3 c t2 t0)). + Intros; XElim H; Intros. +(* case 1 : pc3_r *) + XEAuto. +(* case 2 : pc3_u *) + Clear H0; XElim H1; Intros. + Inversion_clear H; [ XEAuto | Pr3Confluence; XEAuto ]. + Qed. + + End pc3_confluence. + + Tactic Definition Pc3Confluence := + Match Context With + [ H: (pc3 ?1 ?2 ?3) |- ? ] -> + LApply (pc3_confluence ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section pc3_context. (****************************************************) + + Theorem pc3_pr0_pr2_t : (u1,u2:?) (pr0 u2 u1) -> + (c:?; t1,t2:?; k:?) (pr2 (CTail c k u2) t1 t2) -> + (pc3 (CTail c k u1) t1 t2). + Intros. + Inversion H0; Clear H0; [ XAuto | NewInduction i ]. +(* case 1 : pr2_delta i = 0 *) + DropGenBase; Inversion H0; Clear H0 H3 H4 c k. + Rewrite H5 in H; Clear H5 u2. + Pr0Subst0; XEAuto. +(* case 2 : pr2_delta i > 0 *) + NewInduction k; DropGenBase; XEAuto. + Qed. + + Theorem pc3_pr2_pr2_t : (c:?; u1,u2:?) (pr2 c u2 u1) -> + (t1,t2:?; k:?) (pr2 (CTail c k u2) t1 t2) -> + (pc3 (CTail c k u1) t1 t2). + Intros until 1; Inversion H; Clear H; Intros. +(* case 1 : pr2_pr0 *) + EApply pc3_pr0_pr2_t; [ Apply H0 | XAuto ]. +(* case 2 : pr2_delta *) + Inversion H; [ XAuto | NewInduction i0 ]. +(* case 2.1 : i0 = 0 *) + DropGenBase; Inversion H2; Clear H2. + Rewrite <- H5; Rewrite H6 in H; Rewrite <- H7 in H3; Clear H5 H6 H7 d0 k u0. + Subst0Subst0; Arith9'In H4 i. + EApply pc3_pr3_u. + EApply pr2_delta; XEAuto. + Apply pc3_pr2_x; EApply pr2_delta; [ Idtac | XEAuto ]; XEAuto. +(* case 2.2 : i0 > 0 *) + Clear IHi0; NewInduction k; DropGenBase; XEAuto. + Qed. + + Theorem pc3_pr2_pr3_t : (c:?; u2,t1,t2:?; k:?) + (pr3 (CTail c k u2) t1 t2) -> + (u1:?) (pr2 c u2 u1) -> + (pc3 (CTail c k u1) t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply pc3_t. + EApply pc3_pr2_pr2_t; [ Apply H2 | Apply H ]. + XAuto. + Qed. + + Theorem pc3_pr3_pc3_t : (c:?; u1,u2:?) (pr3 c u2 u1) -> + (t1,t2:?; k:?) (pc3 (CTail c k u2) t1 t2) -> + (pc3 (CTail c k u1) t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + Apply H1; Pc3Confluence. + EApply pc3_t; [ Idtac | Apply pc3_s ]; EApply pc3_pr2_pr3_t; XEAuto. + Qed. + + End pc3_context. + + Tactic Definition Pc3Context := + Match Context With + | [ H1: (pr0 ?3 ?2); H2: (pr2 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pc3_pr0_pr2_t ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr0 ?3 ?2); H2: (pr3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pc3_pr2_pr3_t ?1 ?3 ?5 ?6 ?4); [ Clear H2; Intros H2 | XAuto ]; + LApply (H2 ?2); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr2 ?1 ?3 ?2); H2: (pr2 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pc3_pr2_pr2_t ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr2 ?1 ?3 ?2); H2: (pr3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pc3_pr2_pr3_t ?1 ?3 ?5 ?6 ?4); [ Clear H2; Intros H2 | XAuto ]; + LApply (H2 ?2); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr3 ?1 ?3 ?2); H2: (pc3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pc3_pr3_pc3_t ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ] + | _ -> Pr3Context. + + Section pc3_lift. (*******************************************************) + + Theorem pc3_lift : (c,e:?; h,d:?) (drop h d c e) -> + (t1,t2:?) (pc3 e t1 t2) -> + (pc3 c (lift h d t1) (lift h d t2)). + + Intros. + Pc3Confluence. + EApply pc3_pr3_t; (EApply pr3_lift; [ XEAuto | Apply H0 Orelse Apply H1 ]). + Qed. + + End pc3_lift. + + Hints Resolve pc3_lift : ltlc. + + Section pc3_cpr0. (*******************************************************) + + Remark pc3_cpr0_t_aux : (c1,c2:?) (cpr0 c1 c2) -> + (k:?; u,t1,t2:?) (pr3 (CTail c1 k u) t1 t2) -> + (pc3 (CTail c2 k u) t1 t2). + Intros; XElim H0; Intros. +(* case 1.1 : pr3_r *) + XAuto. +(* case 1.2 : pr3_u *) + EApply pc3_t; [ Idtac | XEAuto ]. Clear H2 t1 t2. + Inversion_clear H0. +(* case 1.2.1 : pr2_pr0 *) + XAuto. +(* case 1.2.2 : pr2_delta *) + Cpr0Drop; Pr0Subst0. + EApply pc3_pr3_u; [ EApply pr2_delta; XEAuto | XAuto ]. + Qed. + + Theorem pc3_cpr0_t : (c1,c2:?) (cpr0 c1 c2) -> + (t1,t2:?) (pr3 c1 t1 t2) -> + (pc3 c2 t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : cpr0_refl *) + XAuto. +(* case 2 : cpr0_cont *) + Pc3Context; Pc3Confluence. + EApply pc3_t; [ Idtac | Apply pc3_s ]; EApply pc3_cpr0_t_aux; XEAuto. + Qed. + + Theorem pc3_cpr0 : (c1,c2:?) (cpr0 c1 c2) -> (t1,t2:?) (pc3 c1 t1 t2) -> + (pc3 c2 t1 t2). + Intros; Pc3Confluence. + EApply pc3_t; [ Idtac | Apply pc3_s ]; EApply pc3_cpr0_t; XEAuto. + Qed. + + End pc3_cpr0. + + Hints Resolve pc3_cpr0 : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pc3_subst0.v b/helm/coq-contribs/LAMBDA-TYPES/pc3_subst0.v new file mode 100644 index 000000000..52505544b --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pc3_subst0.v @@ -0,0 +1,141 @@ +(*#* #stop file *) + +Require subst0_subst0. +Require csubst0_defs. +Require pr0_subst0. +Require pc3_defs. + + Section pc3_fsubst0. (****************************************************) + + Theorem pc3_pr2_fsubst0: (c1:?; t1,t:?) (pr2 c1 t1 t) -> + (i:?; u,c2,t2:?) (fsubst0 i u c1 t1 c2 t2) -> + (e:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (pc3 c2 t2 t). + Intros until 1; XElim H. +(* case 1: pr2_pr0 *) + Intros until 2; XElim H0; Intros. +(* case 1.1: fsubst0_t *) + Pr0Subst0; [ XAuto | Apply (pc3_pr3_u c1 x); XEAuto ]. +(* case 1.2: fsubst0_c *) + XAuto. +(* case 1.3: fsubst0_b *) + Pr0Subst0; CSubst0Drop; [ XAuto | Apply (pc3_pr3_u c0 x); XEAuto ]. +(* case 2 : pr2_delta *) + Intros until 3; XElim H1; Intros. +(* case 2.1: fsubst0_t. *) + Apply (pc3_t t1); [ Apply pc3_s; XEAuto | XEAuto ]. +(* case 2.2: fsubst0_c. *) + Apply (lt_le_e i i0); Intros; CSubst0Drop. +(* case 2.2.1: i < i0, none *) + XEAuto. +(* case 2.2.2: i < i0, csubst0_fst *) + Inversion H; Rewrite <- H7 in H4; Rewrite <- H8 in H4; Rewrite <- H8 in H5; Rewrite <- H9 in H5; Clear H H7 H8 H9 c2 t2 x0 x1 x2. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H6; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); XEAuto. +(* case 2.2.3: i < i0, csubst0_snd *) + Inversion H; Rewrite <- H7 in H5; Rewrite <- H8 in H4; Rewrite <- H8 in H5; Rewrite <- H9 in H4; Clear H H7 H8 H9 c2 t2 x0 x1 x3. + Apply pc3_pr2_r; XEAuto. +(* case 2.2.4: i < i0, csubst0_both *) + Inversion H; Rewrite <- H8 in H6; Rewrite <- H9 in H4; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H5; Clear H H8 H9 H10 c2 t2 x0 x1 x3. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H7; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); XEAuto. +(* case 2.2.5: i >= i0 *) + XEAuto. +(* case 2.3: fsubst0_b *) + Apply (lt_le_e i i0); Intros; CSubst0Drop. +(* case 2.3.1 : i < i0, none *) + CSubst0Drop; Apply pc3_pr3_u2 with t0 := t1; XEAuto. +(* case 2.3.2 : i < i0, csubst0_fst *) + Inversion H; Rewrite <- H8 in H5; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H6; Clear H H8 H9 H10 c2 t2 x0 x1 x2. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H7; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u2 c0 t1); [ Idtac | Apply (pc3_pr3_u c0 x) ]; XEAuto. +(* case 2.3.3: i < i0, csubst0_snd *) + Inversion H; Rewrite <- H8 in H6; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H5; Clear H H8 H9 H10 c2 t2 x0 x1 x3. + CSubst0Drop; Apply (pc3_pr3_u2 c0 t1); [ Idtac | Apply pc3_pr2_r ]; XEAuto. +(* case 2.3.4: i < i0, csubst0_both *) + Inversion H; Rewrite <- H9 in H7; Rewrite <- H10 in H5; Rewrite <- H10 in H6; Rewrite <- H10 in H7; Rewrite <- H11 in H6; Clear H H9 H10 H11 c2 t2 x0 x1 x3. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H8; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u2 c0 t1); [ Idtac | Apply (pc3_pr3_u c0 x) ]; XEAuto. +(* case 2.3.5: i >= i0 *) + CSubst0Drop; Apply (pc3_pr3_u2 c0 t1); XEAuto. + Qed. + + Theorem pc3_pr2_fsubst0_back: (c1:?; t,t1:?) (pr2 c1 t t1) -> + (i:?; u,c2,t2:?) (fsubst0 i u c1 t1 c2 t2) -> + (e:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (pc3 c2 t t2). + Intros until 1; XElim H. +(* case 1: pr2_pr0 *) + Intros until 2; XElim H0; Intros. +(* case 1.1: fsubst0_t. *) + Apply (pc3_pr3_u c1 t1); XEAuto. +(* case 1.2: fsubst0_c. *) + XAuto. +(* case 1.3: fsubst0_c. *) + CSubst0Drop; Apply (pc3_pr3_u c0 t1); XEAuto. +(* case 2: pr2_delta *) + Intros until 3; XElim H1; Intros. +(* case 2.1: fsubst0_t. *) + Apply (pc3_t t1); XEAuto. +(* case 2.2: fsubst0_c. *) + Apply (lt_le_e i i0); Intros; CSubst0Drop. +(* case 2.2.1: i < i0, none *) + XEAuto. +(* case 2.2.2: i < i0, csubst0_bind *) + Inversion H; Rewrite <- H7 in H4; Rewrite <- H8 in H4; Rewrite <- H8 in H5; Rewrite <- H9 in H5; Clear H H7 H8 H9 c2 t2 x0 x1 x2. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H6; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); XEAuto. +(* case 2.2.3: i < i0, csubst0_snd *) + Inversion H; Rewrite <- H7 in H5; Rewrite <- H8 in H4; Rewrite <- H8 in H5; Rewrite <- H9 in H4; Clear H H7 H8 H9 c2 t2 x0 x1 x3. + Apply pc3_pr2_r; XEAuto. +(* case 2.2.4: i < i0, csubst0_both *) + Inversion H; Rewrite <- H8 in H6; Rewrite <- H9 in H4; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H5; Clear H H8 H9 H10 c2 t2 x0 x1 x3. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H7; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); XEAuto. +(* case 2.2.5: i >= i0 *) + XEAuto. +(* case 2.3: fsubst0_b *) + Apply (lt_le_e i i0); Intros; CSubst0Drop. +(* case 2.3.1 : i < i0, none *) + CSubst0Drop; Apply pc3_pr3_u with t2 := t1; XEAuto. +(* case 2.3.2 : i < i0, csubst0_fst *) + Inversion H; Rewrite <- H8 in H5; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H6; Clear H H8 H9 H10 c2 t2 x0 x1 x2. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H7; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); [ Idtac | Apply (pc3_pr3_u2 c0 t1) ]; XEAuto. +(* case 2.3.3: i < i0, csubst0_snd *) + Inversion H; Rewrite <- H8 in H6; Rewrite <- H9 in H5; Rewrite <- H9 in H6; Rewrite <- H10 in H5; Clear H H8 H9 H10 c2 t2 x0 x1 x3. + CSubst0Drop; Apply (pc3_pr3_u c0 t1); [ Idtac | Apply pc3_pr2_r ]; XEAuto. +(* case 2.3.4: i < i0, csubst0_both *) + Inversion H; Rewrite <- H9 in H7; Rewrite <- H10 in H5; Rewrite <- H10 in H6; Rewrite <- H10 in H7; Rewrite <- H11 in H6; Clear H H9 H10 H11 c2 t2 x0 x1 x3. + Subst0Subst0; Rewrite <- lt_plus_minus_r in H8; [ CSubst0Drop | XAuto ]. + Apply (pc3_pr3_u c0 x); [ Idtac | Apply (pc3_pr3_u2 c0 t1) ]; XEAuto. +(* case 2.3.5: i >= i0 *) + CSubst0Drop; Apply (pc3_pr3_u c0 t1); XEAuto. + Qed. + + Theorem pc3_pc2_fsubst0: (c1:?; t1,t:?) (pc2 c1 t1 t) -> + (i:?; u,c2,t2:?) (fsubst0 i u c1 t1 c2 t2) -> + (e:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (pc3 c2 t2 t). + Intros until 1; XElim H; Intros. +(* case 1: pc2_r *) + EApply pc3_pr2_fsubst0; XEAuto. +(* case 2: pc2_x *) + Apply pc3_s; EApply pc3_pr2_fsubst0_back; XEAuto. + Qed. + + Theorem pc3_fsubst0: (c1:?; t1,t:?) (pc3 c1 t1 t) -> + (i:?; u,c2,t2:?) (fsubst0 i u c1 t1 c2 t2) -> + (e:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (pc3 c2 t2 t). + Intros until 1; XElim H. +(* case 1: pc3_r *) + Intros until 1; XElim H; Intros; Try CSubst0Drop; XEAuto. +(* case 2: pc3_u *) + Intros until 4; XElim H2; Intros; + (Apply (pc3_t t2); [ EApply pc3_pc2_fsubst0; XEAuto | XEAuto ]). + Qed. + + End pc3_fsubst0. + + Hints Resolve pc3_fsubst0. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_confluence.v new file mode 100644 index 000000000..b107ac2a9 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_confluence.v @@ -0,0 +1,176 @@ +(*#* #stop file *) + +Require tlt_defs. +Require lift_gen. +Require lift_tlt. +Require subst0_gen. +Require subst0_confluence. +Require pr0_defs. +Require pr0_lift. +Require pr0_gen. +Require pr0_subst0. + + Section pr0_confluence. (*************************************************) + + Tactic Definition SSubstInv := + Match Context With + | [ H0: (TTail ? ? ?) = (TTail ? ? ?) |- ? ] -> + Inversion H0; Clear H0 + | [ H0: (pr0 (TTail (Bind ?) ? ?) ?) |- ? ] -> + Inversion H0; Clear H0 + | _ -> EqFalse Orelse LiftGen Orelse Pr0Gen. + + Tactic Definition SSubstBack := + Match Context With + | [ H0: Abst = ?1; H1:? |- ? ] -> + Rewrite <- H0 in H1 Orelse Rewrite <- H0 Orelse Clear H0 ?1 + | [ H0: Abbr = ?1; H1:? |- ? ] -> + Rewrite <- H0 in H1 Orelse Rewrite <- H0 Orelse Clear H0 ?1 + | [ H0: (? ?) = ?1; H1:? |- ? ] -> + Rewrite <- H0 in H1 Orelse Rewrite <- H0 Orelse Clear H0 ?1 + | [ H0: (? ? ? ?) = ?1; H1:? |- ? ] -> + Rewrite <- H0 in H1 Orelse Rewrite <- H0 Orelse Clear H0 ?1. + + Tactic Definition SSubst := + Match Context With + [ H0: ?1 = ?; H1:? |- ? ] -> + Rewrite H0 in H1 Orelse Rewrite H0 Orelse Clear H0 ?1. + + Tactic Definition XSubst := + Repeat (SSubstInv Orelse SSubstBack Orelse SSubst). + + Tactic Definition IH := + Match Context With + | [ H0: (pr0 ?1 ?2); H1: (pr0 ?1 ?3) |- ? ] -> + LApply (H ?1); [ Intros H_x | XEAuto ]; + LApply (H_x ?2); [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x ?3); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Clear H0 H1; Intros. + +(* case pr0_cong pr0_gamma pr0_refl *****************************************) + + Remark pr0_cong_gamma_refl: (b:?) ~ b = Abst -> + (u0,u3:?) (pr0 u0 u3) -> + (t4,t5:?) (pr0 t4 t5) -> + (u2,v2,x:?) (pr0 u2 x) -> (pr0 v2 x) -> + (EX t:T | (pr0 (TTail (Flat Appl) u2 (TTail (Bind b) u0 t4)) t) & + (pr0 (TTail (Bind b) u3 (TTail (Flat Appl) (lift (1) (0) v2) t5)) t)). + Intros. + Apply ex2_intro with x:=(TTail (Bind b) u3 (TTail (Flat Appl) (lift (1) (0) x) t5)); XAuto. + Qed. + +(* case pr0_cong pr0_gamma pr0_cong *****************************************) + + Remark pr0_cong_gamma_cong: (b:?) ~ b = Abst -> + (u2,v2,x:?) (pr0 u2 x) -> (pr0 v2 x) -> + (t2,t5,x0:?) (pr0 t2 x0) -> (pr0 t5 x0) -> + (u5,u3,x1:?) (pr0 u5 x1) -> (pr0 u3 x1) -> + (EX t:T | (pr0 (TTail (Flat Appl) u2 (TTail (Bind b) u5 t2)) t) & + (pr0 (TTail (Bind b) u3 (TTail (Flat Appl) (lift (1) (0) v2) t5)) t)). + Intros. + Apply ex2_intro with x:=(TTail (Bind b) x1 (TTail (Flat Appl) (lift (1) (0) x) x0)); XAuto. + Qed. + +(* case pr0_cong pr0_gamma pr0_delta *****************************************) + + Remark pr0_cong_gamma_delta: ~ Abbr = Abst -> + (u5,t2,w:?) (subst0 (0) u5 t2 w) -> + (u2,v2,x:?) (pr0 u2 x) -> (pr0 v2 x) -> + (t5,x0:?) (pr0 t2 x0) -> (pr0 t5 x0) -> + (u3,x1:?) (pr0 u5 x1) -> (pr0 u3 x1) -> + (EX t:T | (pr0 (TTail (Flat Appl) u2 (TTail (Bind Abbr) u5 w)) t) & + (pr0 (TTail (Bind Abbr) u3 (TTail (Flat Appl) (lift (1) (0) v2) t5)) t)). + Intros; Pr0Subst0. +(* case 1: x0 is a lift *) + Apply ex2_intro with x:=(TTail (Bind Abbr) x1 (TTail (Flat Appl) (lift (1) (0) x) x0)); XAuto. +(* case 2: x0 is not a lift *) + Apply ex2_intro with x:=(TTail (Bind Abbr) x1 (TTail (Flat Appl) (lift (1) (0) x) x2)); XEAuto. + Qed. + +(* case pr0_cong pr0_gamma pr0_zeta *****************************************) + + Remark pr0_cong_gamma_zeta: (b:?) ~ b = Abst -> + (u0,u3:?) (pr0 u0 u3) -> + (u2,v2,x0:?) (pr0 u2 x0) -> (pr0 v2 x0) -> + (x,t3,x1:?) (pr0 x x1) -> (pr0 t3 x1) -> + (EX t:T | (pr0 (TTail (Flat Appl) u2 t3) t) & + (pr0 (TTail (Bind b) u3 (TTail (Flat Appl) (lift (1) (0) v2) (lift (1) (0) x))) t)). + Intros; LiftTailRwBack; XEAuto. + Qed. + +(* case pr0_cong pr0_delta **************************************************) + + Remark pr0_cong_delta: (u3,t5,w:?) (subst0 (0) u3 t5 w) -> + (u2,x:?) (pr0 u2 x) -> (pr0 u3 x) -> + (t3,x0:?) (pr0 t3 x0) -> (pr0 t5 x0) -> + (EX t:T | (pr0 (TTail (Bind Abbr) u2 t3) t) & + (pr0 (TTail (Bind Abbr) u3 w) t)). + Intros; Pr0Subst0; XEAuto. + Qed. + +(* case pr0_gamma pr0_gamma *************************************************) + + Remark pr0_gamma_gamma: (b:?) ~ b = Abst -> + (v1,v2,x0:?) (pr0 v1 x0) -> (pr0 v2 x0) -> + (u1,u2,x1:?) (pr0 u1 x1) -> (pr0 u2 x1) -> + (t1,t2,x2:?) (pr0 t1 x2) -> (pr0 t2 x2) -> + (EX t:T | (pr0 (TTail (Bind b) u1 (TTail (Flat Appl) (lift (1) (0) v1) t1)) t) & + (pr0 (TTail (Bind b) u2 (TTail (Flat Appl) (lift (1) (0) v2) t2)) t)). + Intros. + Apply ex2_intro with x:=(TTail (Bind b) x1 (TTail (Flat Appl) (lift (1) (0) x0) x2)); XAuto. + Qed. + +(* case pr0_delta pr0_delta *************************************************) + + Remark pr0_delta_delta: (u2,t3,w:?) (subst0 (0) u2 t3 w) -> + (u3,t5,w0:?) (subst0 (0) u3 t5 w0) -> + (x:?) (pr0 u2 x) -> (pr0 u3 x) -> + (x0:?) (pr0 t3 x0) -> (pr0 t5 x0) -> + (EX t:T | (pr0 (TTail (Bind Abbr) u2 w) t) & + (pr0 (TTail (Bind Abbr) u3 w0) t)). + Intros; Pr0Subst0; Pr0Subst0; Try Subst0Confluence; XSubst; XEAuto. + Qed. + +(* case pr0_delta pr0_epsilon ***********************************************) + + Remark pr0_delta_epsilon: (u2,t3,w:?) (subst0 (0) u2 t3 w) -> + (t4:?) (pr0 (lift (1) (0) t4) t3) -> + (t2:?) (EX t:T | (pr0 (TTail (Bind Abbr) u2 w) t) & (pr0 t2 t)). + Intros; Pr0Gen; XSubst; Subst0Gen. + Qed. + +(* main *********************************************************************) + + Hints Resolve pr0_cong_gamma_refl pr0_cong_gamma_cong : ltlc. + Hints Resolve pr0_cong_gamma_delta pr0_cong_gamma_zeta : ltlc. + Hints Resolve pr0_cong_delta : ltlc. + Hints Resolve pr0_gamma_gamma : ltlc. + Hints Resolve pr0_delta_delta pr0_delta_epsilon : ltlc. + +(*#* #start proof *) + +(*#* #caption "confluence with itself: Church-Rosser property" *) +(*#* #cap #cap t0, t1, t2, t *) + + Theorem pr0_confluence : (t0,t1:?) (pr0 t0 t1) -> (t2:?) (pr0 t0 t2) -> + (EX t | (pr0 t1 t) & (pr0 t2 t)). + +(*#* #stop file *) + + XElimUsing tlt_wf_ind t0; Intros. + Inversion H0; Inversion H1; Clear H0 H1; + XSubst; Repeat IH; XEAuto. + Qed. + + End pr0_confluence. + + Tactic Definition Pr0Confluence := + Match Context With + [ H1: (pr0 ?1 ?2); H2: (pr0 ?1 ?3) |-? ] -> + LApply (pr0_confluence ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_defs.v new file mode 100644 index 000000000..3c7a96bbe --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_defs.v @@ -0,0 +1,91 @@ +(*#* #stop file *) + +Require Export subst0_defs. + + Inductive pr0 : T -> T -> Prop := +(* structural rules *) + | pr0_refl : (t:?) (pr0 t t) + | pr0_thin : (u1,u2:?) (pr0 u1 u2) -> (t1,t2:?) (pr0 t1 t2) -> + (k:?) (pr0 (TTail k u1 t1) (TTail k u2 t2)) +(* axiom rules *) + | pr0_beta : (k,v1,v2:?) (pr0 v1 v2) -> (t1,t2:?) (pr0 t1 t2) -> + (pr0 (TTail (Flat Appl) v1 (TTail (Bind Abst) k t1)) + (TTail (Bind Abbr) v2 t2)) + | pr0_gamma : (b:?) ~b=Abst -> (v1,v2:?) (pr0 v1 v2) -> + (u1,u2:?) (pr0 u1 u2) -> (t1,t2:?) (pr0 t1 t2) -> + (pr0 (TTail (Flat Appl) v1 (TTail (Bind b) u1 t1)) + (TTail (Bind b) u2 (TTail (Flat Appl) (lift (1) (0) v2) t2))) + | pr0_delta : (u1,u2:?) (pr0 u1 u2) -> (t1,t2:?) (pr0 t1 t2) -> + (w:?) (subst0 (0) u2 t2 w) -> + (pr0 (TTail (Bind Abbr) u1 t1) (TTail (Bind Abbr) u2 w)) + | pr0_zeta : (b:?) ~b=Abst -> (t1,t2:?) (pr0 t1 t2) -> + (u:?) (pr0 (TTail (Bind b) u (lift (1) (0) t1)) t2) + | pr0_eps : (t1,t2:?) (pr0 t1 t2) -> + (u:?) (pr0 (TTail (Flat Cast) u t1) t2). + + Hint pr0 : ltlc := Constructors pr0. + + Section pr0_gen. (********************************************************) + + Theorem pr0_gen_sort : (x:?; n:?) (pr0 (TSort n) x) -> x = (TSort n). + Intros; Inversion H; XAuto. + Qed. + + Theorem pr0_gen_bref : (x:?; n:?) (pr0 (TBRef n) x) -> x = (TBRef n). + Intros; Inversion H; XAuto. + Qed. + + Theorem pr0_gen_abst : (u1,t1,x:?) (pr0 (TTail (Bind Abst) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abst) u2 t2) & + (pr0 u1 u2) & (pr0 t1 t2) + ). + + Intros; Inversion H; Clear H. +(* case 1 : pr0_refl *) + XEAuto. +(* case 2 : pr0_cont *) + XEAuto. +(* case 3 : pr0_zeta *) + XElim H4; XAuto. + Qed. + + Theorem pr0_gen_appl : (u1,t1,x:?) (pr0 (TTail (Flat Appl) u1 t1) x) -> (OR + (EX u2 t2 | x = (TTail (Flat Appl) u2 t2) & + (pr0 u1 u2) & (pr0 t1 t2) + ) | + (EX y1 z1 u2 t2 | t1 = (TTail (Bind Abst) y1 z1) & + x = (TTail (Bind Abbr) u2 t2) & + (pr0 u1 u2) & (pr0 z1 t2) + ) | + (EX b y1 z1 u2 v2 t2 | + ~b=Abst & + t1 = (TTail (Bind b) y1 z1) & + x = (TTail (Bind b) v2 (TTail (Flat Appl) (lift (1) (0) u2) t2)) & + (pr0 u1 u2) & (pr0 y1 v2) & (pr0 z1 t2)) + ). + Intros; Inversion H; XEAuto. + Qed. + + Theorem pr0_gen_cast : (u1,t1,x:?) (pr0 (TTail (Flat Cast) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Flat Cast) u2 t2) & + (pr0 u1 u2) & (pr0 t1 t2) + ) \/ + (pr0 t1 x). + Intros; Inversion H; XEAuto. + Qed. + + End pr0_gen. + + Hints Resolve pr0_gen_sort pr0_gen_bref : ltlc. + + Tactic Definition Pr0GenBase := + Match Context With + | [ H: (pr0 (TTail (Bind Abst) ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_abst ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (pr0 (TTail (Flat Appl) ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_appl ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; Intros H; XElim H; Intros + | [ H: (pr0 (TTail (Flat Cast) ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_cast ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; [ Intros H; XElim H; Intros | Intros ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_gen.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_gen.v new file mode 100644 index 000000000..0b634e59c --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_gen.v @@ -0,0 +1,104 @@ +(*#* #stop file *) + +Require lift_gen. +Require lift_props. +Require subst0_gen. +Require pr0_defs. +Require pr0_lift. + + Section pr0_gen_abbr. (***************************************************) + + Theorem pr0_gen_abbr : (u1,t1,x:?) (pr0 (TTail (Bind Abbr) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abbr) u2 t2) & + (pr0 u1 u2) & + (pr0 t1 t2) \/ + (EX y | (pr0 t1 y) & (subst0 (0) u2 y t2)) + ) \/ + (pr0 t1 (lift (1) (0) x)). + Intros. + Inversion H; Clear H; XDEAuto 6. + Qed. + + End pr0_gen_abbr. + + Section pr0_gen_void. (***************************************************) + + Theorem pr0_gen_void : (u1,t1,x:?) (pr0 (TTail (Bind Void) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Void) u2 t2) & + (pr0 u1 u2) & (pr0 t1 t2) + ) \/ + (pr0 t1 (lift (1) (0) x)). + Intros. + Inversion H; Clear H; XEAuto. + Qed. + + End pr0_gen_void. + + Section pr0_gen_lift. (***************************************************) + + Tactic Definition IH := + Match Context With + | [ H: (_:?; _:?) ?0 = (lift ? ? ?) -> ?; + H0: ?0 = (lift ? ?2 ?3) |- ? ] -> + LApply (H ?3 ?2); [ Clear H H0; Intros H_x | XAuto ]; + XElim H_x; Intro; Intros H_x; Intro; + Try Rewrite H_x; Try Rewrite H_x in H3; Clear H_x. + +(*#* #start file *) + +(*#* #caption "generation lemma for lift" *) +(*#* #cap #alpha t1 in U1, t2 in U2, x in T, d in i *) + + Theorem pr0_gen_lift : (t1,x:?; h,d:?) (pr0 (lift h d t1) x) -> + (EX t2 | x = (lift h d t2) & (pr0 t1 t2)). + +(*#* #stop file *) + + Intros until 1; InsertEq H '(lift h d t1); + UnIntro H d; UnIntro H t1; XElim H; Clear y x; Intros; + Rename x into t3; Rename x0 into d. +(* case 1 : pr0_r *) + XEAuto. +(* case 2 : pr0_c *) + NewInduction k; LiftGen; Rewrite H3; Clear H3 t0; + IH; IH; XEAuto. +(* case 3 : pr0_beta *) + LiftGen; Rewrite H3; Clear H3 t0. + LiftGen; Rewrite H3; Clear H3 H5 x1 k. + IH; IH; XEAuto. +(* case 4 : pr0_gamma *) + LiftGen; Rewrite H6; Clear H6 t0. + LiftGen; Rewrite H6; Clear H6 x1. + IH; IH; IH. + Rewrite <- lift_d; [ Simpl | XAuto ]. + Rewrite <- lift_flat; XEAuto. +(* case 5 : pr0_delta *) + LiftGen; Rewrite H4; Clear H4 t0. + IH; IH; Arith3In H3 d; Subst0Gen. + Rewrite H3; XEAuto. +(* case 6 : pr0_zeta *) + LiftGen; Rewrite H2; Clear H2 t0. + Arith7In H4 d; LiftGen; Rewrite H2; Clear H2 x1. + IH; XEAuto. +(* case 7 : pr0_zeta *) + LiftGen; Rewrite H1; Clear H1 t0. + IH; XEAuto. + Qed. + + End pr0_gen_lift. + + Tactic Definition Pr0Gen := + Match Context With + | [ H: (pr0 (TTail (Bind Abbr) ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_abbr ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; + [ Intros H; XElim H; Do 4 Intro; Intros H_x; + XElim H_x; [ Intros | Intros H_x; XElim H_x; Intros ] + | Intros ] + | [ H: (pr0 (TTail (Bind Void) ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_void ?1 ?2 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; [ Intros H; XElim H; Intros | Intros ] + | [ H: (pr0 (lift ?0 ?1 ?2) ?3) |- ? ] -> + LApply (pr0_gen_lift ?2 ?3 ?0 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | _ -> Pr0GenBase. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_lift.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_lift.v new file mode 100644 index 000000000..f3dc1c518 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_lift.v @@ -0,0 +1,39 @@ +Require lift_props. +Require subst0_lift. +Require pr0_defs. + +(*#* #caption "main properties of predicate \\texttt{pr0}" *) +(*#* #clauses pr0_props *) + + Section pr0_lift. (*******************************************************) + +(*#* #caption "conguence with lift" *) +(*#* #cap #cap t1,t2 #alpha d in i *) + + Theorem pr0_lift: (t1,t2:?) (pr0 t1 t2) -> + (h,d:?) (pr0 (lift h d t1) (lift h d t2)). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1: pr0_refl *) + XAuto. +(* case 2: pr0_cong *) + LiftTailRw; XAuto. +(* case 3 : pr0_beta *) + LiftTailRw; XAuto. +(* case 4: pr0_gamma *) + LiftTailRw; Simpl; Arith0 d; Rewrite lift_d; XAuto. +(* case 5: pr0_delta *) + LiftTailRw; Simpl. + EApply pr0_delta; [ XAuto | Apply H2 | Idtac ]. + LetTac d' := (S d); Arith10 d; Unfold d'; XAuto. +(* case 6: pr0_zeta *) + LiftTailRw; Simpl; Arith0 d; Rewrite lift_d; XAuto. +(* case 7: pr0_epsilon *) + LiftTailRw; XAuto. + Qed. + + End pr0_lift. + + Hints Resolve pr0_lift : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_subst0.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_subst0.v new file mode 100644 index 000000000..ace613d6e --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_subst0.v @@ -0,0 +1,105 @@ +Require subst0_gen. +Require subst0_lift. +Require subst0_subst0. +Require subst0_confluence. +Require pr0_defs. +Require pr0_lift. + +(*#* #stop file *) + + Section pr0_subst0. (*****************************************************) + + Tactic Definition IH := + Match Context With + | [ H1: (u1:?) (pr0 u1 ?1) -> ?; H2: (pr0 ?2 ?1) |- ? ] -> + LApply (H1 ?2); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (u1:?) (pr0 ?1 u1) -> ?; H2: (pr0 ?1 ?2) |- ? ] -> + LApply (H1 ?2); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (v1,w1:?; i:?) (subst0 i v1 ?1 w1) -> (v2:T) (pr0 v1 v2) -> ?; + H2: (subst0 ?2 ?3 ?1 ?4); H3: (pr0 ?3 ?5) |- ? ] -> + LApply (H1 ?3 ?4 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; [ Intros | Intros H1; XElim H1; Intros ]. + + Theorem pr0_subst0_back: (u2,t1,t2:?; i:?) (subst0 i u2 t1 t2) -> + (u1:?) (pr0 u1 u2) -> + (EX t | (subst0 i u1 t1 t) & (pr0 t t2)). + Intros until 1; XElim H; Intros; + Repeat IH; XEAuto. + Qed. + + Theorem pr0_subst0_fwd: (u2,t1,t2:?; i:?) (subst0 i u2 t1 t2) -> + (u1:?) (pr0 u2 u1) -> + (EX t | (subst0 i u1 t1 t) & (pr0 t2 t)). + Intros until 1; XElim H; Intros; + Repeat IH; XEAuto. + Qed. + + Hints Resolve pr0_subst0_fwd : ltlc. + +(*#* #start file *) + +(*#* #caption "confluence with substitution" *) +(*#* #cap #cap t1,t2,v1,v2 #alpha w1 in U1, w2 in U2 *) + + Theorem pr0_subst0: (t1,t2:?) (pr0 t1 t2) -> + (v1,w1:?; i:?) (subst0 i v1 t1 w1) -> + (v2:?) (pr0 v1 v2) -> + (pr0 w1 t2) \/ + (EX w2 | (pr0 w1 w2) & (subst0 i v2 t2 w2)). + +(*#* #stop file *) + + Intros until 1; XElim H; Clear t1 t2; Intros. +(* case 1: pr0_refl *) + XEAuto. +(* case 2: pr0_cong *) + Subst0Gen; Rewrite H3; Repeat IH; XEAuto. +(* case 3: pr0_beta *) + Repeat Subst0Gen; Rewrite H3; Try Rewrite H5; Try Rewrite H6; + Repeat IH; XEAuto. +(* case 4: pr0_gamma *) + Repeat Subst0Gen; Rewrite H6; Try Rewrite H8; Try Rewrite H9; + Repeat IH; XDEAuto 7. +(* case 5: pr0_delta *) + Subst0Gen; Rewrite H4; Repeat IH; + [ XEAuto | Idtac | XEAuto | Idtac | XEAuto | Idtac | Idtac | Idtac ]. + Subst0Subst0; Arith9'In H9 i; XEAuto. + Subst0Confluence; XEAuto. + Subst0Subst0; Arith9'In H10 i; XEAuto. + Subst0Confluence; XEAuto. + Subst0Subst0; Arith9'In H11 i; Subst0Confluence; XDEAuto 6. +(* case 6: pr0_zeta *) + Repeat Subst0Gen; Rewrite H2; Try Rewrite H4; Try Rewrite H5; + Try (Simpl in H5; Rewrite <- minus_n_O in H5); + Try (Simpl in H6; Rewrite <- minus_n_O in H6); + Try IH; XEAuto. +(* case 7: pr0_epsilon *) + Subst0Gen; Rewrite H1; Try IH; XEAuto. + Qed. + + End pr0_subst0. + + Tactic Definition Pr0Subst0 := + Match Context With + | [ H1: (pr0 ?1 ?2); H2: (subst0 ?3 ?4 ?1 ?5); + H3: (pr0 ?4 ?6) |- ? ] -> + LApply (pr0_subst0 ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4 ?5 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply (H1 ?6); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; [ Intros | Intros H1; XElim H1; Intros ] + | [ H1: (pr0 ?1 ?2); H2: (subst0 ?3 ?4 ?1 ?5) |- ? ] -> + LApply (pr0_subst0 ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4 ?5 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; [ Intros | Intros H1; XElim H1; Intros ] + | [ H1: (subst0 ?0 ?1 ?2 ?3); H2: (pr0 ?4 ?1) |- ? ] -> + LApply (pr0_subst0_back ?1 ?2 ?3 ?0); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (subst0 ?0 ?1 ?2 ?3); H2: (pr0 ?1 ?4) |- ? ] -> + LApply (pr0_subst0_fwd ?1 ?2 ?3 ?0); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr0_subst1.v b/helm/coq-contribs/LAMBDA-TYPES/pr0_subst1.v new file mode 100644 index 000000000..fbf8e8b38 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr0_subst1.v @@ -0,0 +1,63 @@ +(*#* #stop file *) + +Require subst1_defs. +Require pr0_defs. +Require pr0_subst0. + + Section pr0_subst1_props. (***********************************************) + + Theorem pr0_delta1: (u1,u2:?) (pr0 u1 u2) -> (t1,t2:?) (pr0 t1 t2) -> + (w:?) (subst1 (0) u2 t2 w) -> + (pr0 (TTail (Bind Abbr) u1 t1) (TTail (Bind Abbr) u2 w)). + Intros until 3; XElim H1; Clear w; XEAuto. + Qed. + + Theorem pr0_subst1_back: (u2,t1,t2:?; i:?) (subst1 i u2 t1 t2) -> + (u1:?) (pr0 u1 u2) -> + (EX t | (subst1 i u1 t1 t) & (pr0 t t2)). + Intros until 1; XElim H; Intros; + Try Pr0Subst0; XEAuto. + Qed. + + Theorem pr0_subst1_fwd: (u2,t1,t2:?; i:?) (subst1 i u2 t1 t2) -> + (u1:?) (pr0 u2 u1) -> + (EX t | (subst1 i u1 t1 t) & (pr0 t2 t)). + Intros until 1; XElim H; Intros; + Try Pr0Subst0; XEAuto. + Qed. + + Theorem pr0_subst1: (t1,t2:?) (pr0 t1 t2) -> + (v1,w1:?; i:?) (subst1 i v1 t1 w1) -> + (v2:?) (pr0 v1 v2) -> + (EX w2 | (pr0 w1 w2) & (subst1 i v2 t2 w2)). + Intros until 2; XElim H0; Intros; + Try Pr0Subst0; XEAuto. + Qed. + + End pr0_subst1_props. + + Hints Resolve pr0_delta1 : ltlc. + + Tactic Definition Pr0Subst1 := + Match Context With + | [ H1: (pr0 ?1 ?2); H2: (subst1 ?3 ?4 ?1 ?5); + H3: (pr0 ?4 ?6) |- ? ] -> + LApply (pr0_subst1 ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4 ?5 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply (H1 ?6); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (pr0 ?1 ?2); H2: (subst1 ?3 ?4 ?1 ?5) |- ? ] -> + LApply (pr0_subst1 ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4 ?5 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (subst1 ?0 ?1 ?2 ?3); H2: (pr0 ?4 ?1) |- ? ] -> + LApply (pr0_subst1_back ?1 ?2 ?3 ?0); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (subst1 ?0 ?1 ?2 ?3); H2: (pr0 ?1 ?4) |- ? ] -> + LApply (pr0_subst1_fwd ?1 ?2 ?3 ?0); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | _ -> Pr0Subst0. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr1_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/pr1_confluence.v new file mode 100644 index 000000000..222a08cea --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr1_confluence.v @@ -0,0 +1,64 @@ +Require pr0_confluence. +Require pr1_defs. + +(*#* #caption "main properties of predicate \\texttt{pr1}" *) +(*#* #clauses pr1_props *) + + Section pr1_confluence. (*************************************************) + +(*#* #caption "confluence with single step reduction: strip lemma" *) +(*#* #cap #cap t0, t1, t2, t *) + + Theorem pr1_strip : (t0,t1:?) (pr1 t0 t1) -> (t2:?) (pr0 t0 t2) -> + (EX t | (pr1 t1 t) & (pr1 t2 t)). + +(*#* #stop proof *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr1_r *) + XEAuto. +(* case 2 : pr1_u *) + Pr0Confluence. + LApply (H1 x); [ Clear H1 H2; Intros H1 | XAuto ]. + XElim H1; Intros; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "confluence with itself: Church-Rosser property" *) +(*#* #cap #cap t0, t1, t2, t *) + + Theorem pr1_confluence : (t0,t1:?) (pr1 t0 t1) -> (t2:?) (pr1 t0 t2) -> + (EX t | (pr1 t1 t) & (pr1 t2 t)). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr1_r *) + XEAuto. +(* case 2 : pr1_u *) + LApply (pr1_strip t3 t5); [ Clear H2; Intros H2 | XAuto ]. + LApply (H2 t2); [ Clear H H2; Intros H | XAuto ]. + XElim H; Intros. + LApply (H1 x); [ Clear H1 H2; Intros H1 | XAuto ]. + XElim H1; Intros; XEAuto. + Qed. + + End pr1_confluence. + + Tactic Definition Pr1Confluence := + Match Context With + | [ H1: (pr1 ?1 ?2); H2: (pr0 ?1 ?3) |-? ] -> + LApply (pr1_strip ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (pr1 ?1 ?2); H2: (pr1 ?1 ?3) |-? ] -> + LApply (pr1_confluence ?1 ?2); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?3); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | _ -> Pr0Confluence. + +(*#* #start file *) + +(*#* #single *) + diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr1_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pr1_defs.v new file mode 100644 index 000000000..986b59489 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr1_defs.v @@ -0,0 +1,24 @@ +(*#* #stop file *) + +Require Export pr0_defs. + + Inductive pr1 : T -> T -> Prop := + | pr1_r : (t:?) (pr1 t t) + | pr1_u : (t2,t1:?) (pr0 t1 t2) -> (t3:?) (pr1 t2 t3) -> (pr1 t1 t3). + + Hint pr1 : ltlc := Constructors pr1. + + Section pr1_props. (******************************************************) + + Theorem pr1_pr0 : (t1,t2:?) (pr0 t1 t2) -> (pr1 t1 t2). + XEAuto. + Qed. + + Theorem pr1_t : (t2,t1:?) (pr1 t1 t2) -> + (t3:?) (pr1 t2 t3) -> (pr1 t1 t3). + Intros t2 t1 H; XElim H; XEAuto. + Qed. + + End pr1_props. + + Hints Resolve pr1_pr0 pr1_t : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_confluence.v new file mode 100644 index 000000000..afdab3d52 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_confluence.v @@ -0,0 +1,77 @@ +(*#* #stop file *) + +Require subst0_confluence. +Require drop_props. +Require pr0_subst0. +Require pr0_confluence. +Require pr2_defs. + + Section pr2_confluence. (*************************************************) + +(* case 1.1 : pr2_pr0 pr2_pr0 ***********************************************) + + Remark pr2_pr0_pr0: (c:?; t0,t1,t2:?) + (pr0 t0 t1) -> (pr0 t0 t2) -> + (EX t:T | (pr2 c t1 t) & (pr2 c t2 t)). + Intros; Pr0Confluence; XEAuto. + Qed. + +(* case 1.2 : pr2_pr0 pr2_delta *********************************************) + + Remark pr2_pr0_delta: (c,d:?; t0,t1,t2,u:?; i:?) + (pr0 t0 t1) -> + (drop i (0) c (CTail d (Bind Abbr) u)) -> + (subst0 i u t0 t2) -> + (EX t | (pr2 c t1 t) & (pr2 c t2 t)). + Intros; Pr0Subst0; XEAuto. + Qed. + +(* case 2.2 : pr2_delta pr2_delta *******************************************) + + Remark pr2_delta_delta: (c,d,d0:?; t0,t1,t2,u,u0:?; i,i0:?) + (drop i (0) c (CTail d (Bind Abbr) u)) -> + (subst0 i u t0 t1) -> + (drop i0 (0) c (CTail d0 (Bind Abbr) u0)) -> + (subst0 i0 u0 t0 t2) -> + (EX t:T | (pr2 c t1 t) & (pr2 c t2 t)). + Intros. + Apply (neq_eq_e i i0); Intros. +(* case 1 : i != i0 *) + Subst0Confluence; XEAuto. +(* case 2 : i = i0 *) + Rewrite H3 in H; Rewrite H3 in H0; Clear H3 i. + DropDis; Inversion H1; Rewrite H5 in H0; Clear H1 H4 H5 d u. + Subst0Confluence; [ Rewrite H1; XEAuto | XEAuto | XEAuto | XEAuto ]. + Qed. + +(* main *********************************************************************) + + Hints Resolve pr2_pr0_pr0 pr2_pr0_delta pr2_delta_delta : ltlc. + +(*#* #start file *) + +(*#* #caption "confluence with itself: Church-Rosser property" *) +(*#* #cap #cap c, t0, t1, t2, t *) + + Theorem pr2_confluence : (c,t0,t1:?) (pr2 c t0 t1) -> + (t2:?) (pr2 c t0 t2) -> + (EX t | (pr2 c t1 t) & (pr2 c t2 t)). + +(*#* #stop file *) + + Intros; Inversion H; Inversion H0; XEAuto. + Qed. + + End pr2_confluence. + + Tactic Definition Pr2Confluence := + Match Context With + | [ H1: (pr2 ?1 ?2 ?3); H2: (pr2 ?1 ?2 ?4) |-? ] -> + LApply (pr2_confluence ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | _ -> Pr0Confluence. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_defs.v new file mode 100644 index 000000000..a650dd26f --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_defs.v @@ -0,0 +1,120 @@ +(*#* #stop file *) + +Require Export drop_defs. +Require Export pr0_defs. + + Inductive pr2 [c:C; t1,t2:T] : Prop := +(* structural rules *) + | pr2_pr0 : (pr0 t1 t2) -> (pr2 c t1 t2) +(* axiom rules *) + | pr2_delta : (d:?; u:?; i:?) + (drop i (0) c (CTail d (Bind Abbr) u)) -> + (subst0 i u t1 t2) -> (pr2 c t1 t2). + + Hint pr2 : ltlc := Constructors pr2. + + Section pr2_gen_base. (***************************************************) + + Theorem pr2_gen_sort : (c:?; x:?; n:?) (pr2 c (TSort n) x) -> + x = (TSort n). + Intros; Inversion H; + Try Subst0GenBase; XEAuto. + Qed. + + Theorem pr2_gen_bref : (c:?; x:?; n:?) (pr2 c (TBRef n) x) -> + x = (TBRef n) \/ + (EX d u | (drop n (0) c (CTail d (Bind Abbr) u)) & + x = (lift (S n) (0) u) + ). + Intros; Inversion H; + Try Subst0GenBase; Try Rewrite <- H1 in H0; XEAuto. + Qed. + + Theorem pr2_gen_abst : (c:?; u1,t1,x:?) + (pr2 c (TTail (Bind Abst) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abst) u2 t2) & + (pr2 c u1 u2) & (b:?; u:?) + (pr2 (CTail c (Bind b) u) t1 t2) + ). + Intros; Inversion H; + Try Pr0GenBase; Try Subst0GenBase; XDEAuto 6. + Qed. + + Theorem pr2_gen_appl : (c:?; u1,t1,x:?) + (pr2 c (TTail (Flat Appl) u1 t1) x) -> (OR + (EX u2 t2 | x = (TTail (Flat Appl) u2 t2) & + (pr2 c u1 u2) & (pr2 c t1 t2) + ) | + (EX y1 z1 u2 t2 | t1 = (TTail (Bind Abst) y1 z1) & + x = (TTail (Bind Abbr) u2 t2) & + (pr0 u1 u2) & (pr0 z1 t2) + ) | + (EX b y1 z1 u2 v2 t2 | + ~b=Abst & + t1 = (TTail (Bind b) y1 z1) & + x = (TTail (Bind b) v2 (TTail (Flat Appl) (lift (1) (0) u2) t2)) & + (pr0 u1 u2) & (pr0 y1 v2) & (pr0 z1 t2)) + ). + Intros; Inversion H; + Try Pr0GenBase; Try Subst0GenBase; XEAuto. + Qed. + + Theorem pr2_gen_cast : (c:?; u1,t1,x:?) + (pr2 c (TTail (Flat Cast) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Flat Cast) u2 t2) & + (pr2 c u1 u2) & (pr2 c t1 t2) + ) \/ + (pr0 t1 x). + Intros; Inversion H; + Try Pr0GenBase; Try Subst0GenBase; XEAuto. + Qed. + + End pr2_gen_base. + + Tactic Definition Pr2GenBase := + Match Context With + | [ H: (pr2 ?1 (TTail (Bind Abst) ?2 ?3) ?4) |- ? ] -> + LApply (pr2_gen_abst ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section pr2_props. (******************************************************) + + Theorem pr2_thin_dx : (c:?; t1,t2:?) (pr2 c t1 t2) -> + (u:?; f:?) (pr2 c (TTail (Flat f) u t1) + (TTail (Flat f) u t2)). + Intros; Inversion H; XEAuto. + Qed. + + Theorem pr2_tail_1 : (c:?; u1,u2:?) (pr2 c u1 u2) -> + (k:?; t:?) (pr2 c (TTail k u1 t) (TTail k u2 t)). + Intros; Inversion H; XEAuto. + Qed. + + Theorem pr2_tail_2 : (c:?; u,t1,t2:?; k:?) (pr2 (CTail c k u) t1 t2) -> + (pr2 c (TTail k u t1) (TTail k u t2)). + XElim k; Intros; + (Inversion H; [ XAuto | Clear H ]; + (NewInduction i; DropGenBase; [ Inversion H; XEAuto | XEAuto ])). + Qed. + + Hints Resolve pr2_tail_2 : ltlc. + + Theorem pr2_shift : (i:?; c,e:?) (drop i (0) c e) -> + (t1,t2:?) (pr2 c t1 t2) -> + (pr2 e (app c i t1) (app c i t2)). + XElim i. +(* case 1 : i = 0 *) + Intros. + DropGenBase; Rewrite H in H0. + Repeat Rewrite app_O; XAuto. +(* case 2 : i > 0 *) + XElim c. +(* case 2.1 : CSort *) + Intros; DropGenBase; Rewrite H0; XAuto. +(* case 2.2 : CTail *) + XElim k; Intros; Simpl; DropGenBase; XAuto. + Qed. + + End pr2_props. + + Hints Resolve pr2_thin_dx pr2_tail_1 pr2_tail_2 pr2_shift : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_gen.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_gen.v new file mode 100644 index 000000000..6fcb00c30 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_gen.v @@ -0,0 +1,81 @@ +(*#* #stop file *) + +Require subst0_gen. +Require drop_props. +Require pr0_gen. +Require pr2_defs. + + Section pr2_gen. (********************************************************) + + Theorem pr2_gen_abbr : (c:?; u1,t1,x:?) + (pr2 c (TTail (Bind Abbr) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abbr) u2 t2) & + (pr2 c u1 u2) & + ((b:?; u:?) (pr2 (CTail c (Bind b) u) t1 t2)) \/ + (EX y | (pr0 t1 y) & (subst0 (0) u2 y t2)) + ) \/ + (pr0 t1 (lift (1) (0) x)). + Intros; Inversion H; + Try Pr0Gen; Try Subst0Gen; XDEAuto 8. + Qed. + + Theorem pr2_gen_void : (c:?; u1,t1,x:?) + (pr2 c (TTail (Bind Void) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Void) u2 t2) & + (pr2 c u1 u2) & (b:?; u:?) + (pr2 (CTail c (Bind b) u) t1 t2) + ) \/ + (pr0 t1 (lift (1) (0) x)). + Intros; Inversion H; + Try Pr0Gen; Try Subst0Gen; XDEAuto 7. + Qed. + +(*#* #start file *) + +(*#* #caption "generation lemma for lift" *) +(*#* #cap #cap c #alpha e in D, t1 in U1, t2 in U2, x in T, d in i *) + + Theorem pr2_gen_lift : (c:?; t1,x:?; h,d:?) (pr2 c (lift h d t1) x) -> + (e:?) (drop h d c e) -> + (EX t2 | x = (lift h d t2) & (pr2 e t1 t2)). + +(*#* #stop file *) + + Intros. + Inversion H; Clear H. +(* case 1 : pr2_pr0 *) + Pr0Gen; XEAuto. +(* case 2 : pr2_delta *) + Apply (lt_le_e i d); Intros. +(* case 2.1 : i < d *) + Rewrite (lt_plus_minus i d) in H0; [ Idtac | XAuto ]. + Rewrite (lt_plus_minus i d) in H2; [ Idtac | XAuto ]. + DropDis; Rewrite H0 in H2; Clear H0 u. + Subst0Gen; Rewrite <- lt_plus_minus in H0; XEAuto. +(* case 2.2 : i >= d *) + Apply (lt_le_e i (plus d h)); Intros. +(* case 2.2.1 : i < d + h *) + EApply subst0_gen_lift_false; [ Apply H | Apply H3 | XEAuto ]. +(* case 2.2.2 : i >= d + h *) + DropDis; Subst0Gen; XEAuto. + Qed. + + End pr2_gen. + + Tactic Definition Pr2Gen := + Match Context With + | [ H: (pr2 ?1 (TTail (Bind Abbr) ?2 ?3) ?4) |- ? ] -> + LApply (pr2_gen_abbr ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; + [ Intros H; XElim H; Do 4 Intro; Intros H_x; XElim H_x; + [ Intros | Intros H_x; XElim H_x; Intros ] + | Intros ] + | [ H: (pr2 ?1 (TTail (Bind Void) ?2 ?3) ?4) |- ? ] -> + LApply (pr2_gen_void ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; [ Intros H; XElim H; Intros | Intros ] + | [ H0: (pr2 ?1 (lift ?2 ?3 ?4) ?5); + H1: (drop ?2 ?3 ?1 ?6) |- ? ] -> + LApply (pr2_gen_lift ?1 ?4 ?5 ?2 ?3); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?6); [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | _ -> Pr2GenBase. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_gen_context.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_gen_context.v new file mode 100644 index 000000000..b2cfaead1 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_gen_context.v @@ -0,0 +1,59 @@ +(*#* #stop file *) + +Require drop_props. +Require subst1_gen. +Require subst1_subst1. +Require subst1_confluence. +Require csubst1_defs. +Require pr0_gen. +Require pr0_subst1. +Require pr2_defs. +Require pr2_subst1. + + Section pr2_gen_context. (************************************************) + + Theorem pr2_gen_cabbr: (c:?; t1,t2:?) (pr2 c t1 t2) -> (e:?; u:?; d:?) + (drop d (0) c (CTail e (Bind Abbr) u)) -> + (a0:?) (csubst1 d u c a0) -> + (a:?) (drop (1) d a0 a) -> + (x1:?) (subst1 d u t1 (lift (1) d x1)) -> + (EX x2 | (subst1 d u t2 (lift (1) d x2)) & + (pr2 a x1 x2) + ). + Intros until 1; XElim H; Intros. +(* case 1: pr2_pr0 *) + Pr0Subst1; Pr0Gen; Rewrite H in H3; Clear H x; XEAuto. +(* case 2: pr2_delta *) + Apply (lt_eq_gt_e i d0); Intros. +(* case 2.1: i < d0 *) + Subst1Confluence; CSubst1Drop. + Rewrite minus_x_Sy in H; [ Idtac | XAuto ]. + CSubst1GenBase; Rewrite H in H6; Clear H x0. + Rewrite (lt_plus_minus i d0) in H3; [ Idtac | XAuto ]. + DropDis; Rewrite H in H7; Clear H x2. + Subst1Subst1; Pattern 2 d0 in H; Rewrite (lt_plus_minus i d0) in H; [ Idtac | XAuto ]. + Subst1Gen; Rewrite H in H9; Simpl in H9; Clear H x2. + Rewrite <- lt_plus_minus in H9; [ Idtac | XAuto ]. + Rewrite <- lt_plus_minus_r in H9; XEAuto. +(* case 2.2: i = d0 *) + Rewrite H5 in H; Rewrite H5 in H0; Clear H5 i. + DropDis; Inversion H; Rewrite <- H7 in H0; Rewrite <- H7 in H1; Rewrite <- H7; Clear H H6 H7 e u. + Subst1Confluence; Subst1Gen; Rewrite H0 in H; Clear H0 x; XEAuto. +(* case 2.3: i > d0 *) + Subst1Confluence; Subst1Gen; Rewrite H4 in H0; Clear H1 H4 x. + CSubst1Drop; DropDis; XEAuto. + Qed. + + End pr2_gen_context. + + Tactic Definition Pr2GenContext := + Match Context With + | [ H0: (pr2 ?1 ?2 ?3); H1: (drop ?4 (0) ?1 (CTail ?5 (Bind Abbr) ?6)); + H2: (csubst1 ?4 ?6 ?1 ?7); H3: (drop (1) ?4 ?7 ?8); + H4: (subst1 ?4 ?6 ?2 (lift (1) ?4 ?9)) |- ? ] -> + LApply (pr2_gen_cabbr ?1 ?2 ?3); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5 ?6 ?4); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?8); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?9); [ Clear H0 H4; Intros H0 | XAuto ]; + XElim H0; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_lift.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_lift.v new file mode 100644 index 000000000..9f828bfa8 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_lift.v @@ -0,0 +1,34 @@ +Require subst0_lift. +Require drop_props. +Require pr0_lift. +Require pr2_defs. + +(*#* #caption "main properties of predicate \\texttt{pr2}" *) +(*#* #clauses pr2_props *) + + Section pr2_lift. (*******************************************************) + +(*#* #caption "conguence with lift" *) +(*#* #cap #cap c, t1, t2 #alpha e in D, d in i *) + + Theorem pr2_lift : (c,e:?; h,d:?) (drop h d c e) -> + (t1,t2:?) (pr2 e t1 t2) -> + (pr2 c (lift h d t1) (lift h d t2)). + +(*#* #stop file *) + + Intros until 2; XElim H0; Intros. +(* case 1 : pr2_pr0 *) + XAuto. +(* case 2 : pr2_delta *) + Apply (lt_le_e i d); Intros; DropDis. +(* case 2.1 : i < d *) + Rewrite minus_x_Sy in H0; [ Idtac | XAuto ]. + DropGenBase; Rewrite H0 in H; Simpl in H; XEAuto. +(* case 2.2 : i >= d *) + XEAuto. + Qed. + + End pr2_lift. + + Hints Resolve pr2_lift : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr2_subst1.v b/helm/coq-contribs/LAMBDA-TYPES/pr2_subst1.v new file mode 100644 index 000000000..988237fc1 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr2_subst1.v @@ -0,0 +1,46 @@ +(*#* #stop file *) + +Require subst1_defs. +Require subst1_confluence. +Require drop_props. +Require pr0_subst1. +Require pr2_defs. + + Section pr2_subst1_props. (***********************************************) + + Theorem pr2_delta1: (c,d:?; u:?; i:?) (drop i (0) c (CTail d (Bind Abbr) u)) -> + (t1,t2:?) (subst1 i u t1 t2) -> (pr2 c t1 t2). + Intros; XElim H0; Clear t2; XEAuto. + Qed. + + Hints Resolve pr2_delta1 : ltlc. + + Theorem pr2_subst1: (c,e:?; v:?; i:?) (drop i (0) c (CTail e (Bind Abbr) v)) -> + (t1,t2:?) (pr2 c t1 t2) -> + (w1:?) (subst1 i v t1 w1) -> + (EX w2 | (pr2 c w1 w2) & (subst1 i v t2 w2)). + Intros until 2; XElim H0; Intros. +(* case 1: pr2_pr0 *) + Pr0Subst1; XEAuto. +(* case 2: pr2_delta *) + Apply (neq_eq_e i i0); Intros. +(* case 2.1: i <> i0 *) + Subst1Confluence; XEAuto. +(* case 2.2: i = i0 *) + Rewrite <- H3 in H0; Rewrite <- H3 in H1; Clear H3 i0. + DropDis; Inversion H0; Rewrite H5 in H2; Clear H0 H4 H5 e v. + Subst1Confluence; XEAuto. + Qed. + + End pr2_subst1_props. + + Hints Resolve pr2_delta1 : ltlc. + + Tactic Definition Pr2Subst1 := + Match Context With + | [ H0: (drop ?1 (0) ?2 (CTail ?3 (Bind Abbr) ?4)); + H1: (pr2 ?2 ?5 ?6); H3: (subst1 ?1 ?4 ?5 ?7) |- ? ] -> + LApply (pr2_subst1 ?2 ?3 ?4 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?5 ?6); [ Clear H_x H1; Intros H1 | XAuto ]; + LApply (H1 ?7); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_confluence.v new file mode 100644 index 000000000..2267e88ae --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_confluence.v @@ -0,0 +1,60 @@ +Require pr2_confluence. +Require pr3_defs. + + Section pr3_confluence. (*************************************************) + +(*#* #caption "confluence with single step reduction: strip lemma" *) +(*#* #cap #cap c, t0, t1, t2, t *) + + Theorem pr3_strip : (c:?; t0,t1:?) (pr3 c t0 t1) -> (t2:?) (pr2 c t0 t2) -> + (EX t | (pr3 c t1 t) & (pr3 c t2 t)). + +(*#* #stop proof *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XEAuto. +(* case 2 : pr3_u *) + Pr2Confluence. + LApply (H1 x); [ Clear H1 H2; Intros H1 | XAuto ]. + XElim H1; Intros; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "confluence with itself: Church-Rosser property" *) +(*#* #cap #cap c, t0, t1, t2, t *) + + Theorem pr3_confluence : (c:?; t0,t1:?) (pr3 c t0 t1) -> (t2:?) (pr3 c t0 t2) -> + (EX t | (pr3 c t1 t) & (pr3 c t2 t)). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XEAuto. +(* case 2 : pr3_u *) + LApply (pr3_strip c t3 t5); [ Clear H2; Intros H2 | XAuto ]. + LApply (H2 t2); [ Clear H H2; Intros H | XAuto ]. + XElim H; Intros. + LApply (H1 x); [ Clear H1 H2; Intros H1 | XAuto ]. + XElim H1; Intros; XEAuto. + Qed. + + End pr3_confluence. + + Tactic Definition Pr3Confluence := + Match Context With + | [ H1: (pr3 ?1 ?2 ?3); H2: (pr2 ?1 ?2 ?4) |-? ] -> + LApply (pr3_strip ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (pr3 ?1 ?2 ?3); H2: (pr3 ?1 ?2 ?4) |-? ] -> + LApply (pr3_confluence ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?4); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros + | _ -> Pr2Confluence. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_defs.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_defs.v new file mode 100644 index 000000000..1d67abfb1 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_defs.v @@ -0,0 +1,75 @@ +(*#* #stop file *) + +Require Export pr1_defs. +Require Export pr2_defs. + + Inductive pr3 [c:C] : T -> T -> Prop := + | pr3_r : (t:?) (pr3 c t t) + | pr3_u : (t2,t1:?) (pr2 c t1 t2) -> + (t3:?) (pr3 c t2 t3) -> (pr3 c t1 t3). + + Hint pr3: ltlc := Constructors pr3. + + Section pr3_props. (******************************************************) + + Theorem pr3_pr2 : (c,t1,t2:?) (pr2 c t1 t2) -> (pr3 c t1 t2). + XEAuto. + Qed. + + Theorem pr3_t : (t2,t1,c:?) (pr3 c t1 t2) -> + (t3:?) (pr3 c t2 t3) -> (pr3 c t1 t3). + Intros until 1; XElim H; XEAuto. + Qed. + + Theorem pr3_tail_1 : (c:?; u1,u2:?) (pr3 c u1 u2) -> + (k:?; t:?) (pr3 c (TTail k u1 t) (TTail k u2 t)). + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply pr3_u; [ Apply pr2_tail_1; Apply H | XAuto ]. + Qed. + + Theorem pr3_tail_2 : (c:?; u,t1,t2:?; k:?) (pr3 (CTail c k u) t1 t2) -> + (pr3 c (TTail k u t1) (TTail k u t2)). + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply pr3_u; [ Apply pr2_tail_2; Apply H | XAuto ]. + Qed. + + Hints Resolve pr3_tail_1 pr3_tail_2 : ltlc. + + Theorem pr3_tail_21 : (c:?; u1,u2:?) (pr3 c u1 u2) -> + (k:?; t1,t2:?) (pr3 (CTail c k u1) t1 t2) -> + (pr3 c (TTail k u1 t1) (TTail k u2 t2)). + Intros. + EApply pr3_t; [ Apply pr3_tail_2 | Apply pr3_tail_1 ]; XAuto. + Qed. + + Theorem pr3_tail_12 : (c:?; u1,u2:?) (pr3 c u1 u2) -> + (k:?; t1,t2:?) (pr3 (CTail c k u2) t1 t2) -> + (pr3 c (TTail k u1 t1) (TTail k u2 t2)). + Intros. + EApply pr3_t; [ Apply pr3_tail_1 | Apply pr3_tail_2 ]; XAuto. + Qed. + + Theorem pr3_shift : (h:?; c,e:?) (drop h (0) c e) -> + (t1,t2:?) (pr3 c t1 t2) -> + (pr3 e (app c h t1) (app c h t2)). + Intros until 2; XElim H0; Clear t1 t2; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + XEAuto. + Qed. + + Theorem pr3_pr1: (t1,t2:?) (pr1 t1 t2) -> (c:?) (pr3 c t1 t2). + Intros until 1; XElim H; XEAuto. + Qed. + + End pr3_props. + + Hints Resolve pr3_pr2 pr3_t pr3_pr1 + pr3_tail_12 pr3_tail_21 pr3_shift : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_gen.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_gen.v new file mode 100644 index 000000000..855c4deab --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_gen.v @@ -0,0 +1,184 @@ +(*#* #stop file *) + +Require pr2_gen. +Require pr3_defs. +Require pr3_props. + + Section pr3_gen_void. (***************************************************) + + Tactic Definition IH := + Match Context With + [ H: (u,t:T) (TTail (Bind Void) ?1 ?2) = (TTail (Bind Void) u t) -> ? |- ? ] -> + LApply (H ?1 ?2); [ Clear H; Intros H | XAuto ]; + XElim H1; Intros H1; XElim H1; Intros. + + Theorem pr3_gen_void : (c:?; u1,t1,x:?) (pr3 c (TTail (Bind Void) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Void) u2 t2) & + (pr3 c u1 u2) & (b:?; u:?) + (pr3 (CTail c (Bind b) u) t1 t2) + ) \/ + (EX u | (pr3 c u1 u) & + (pr3 (CTail c (Bind Void) u) t1 (lift (1) (0) x)) + ). + Intros until 1; InsertEq H '(TTail (Bind Void) u1 t1); + UnIntro t1 H; UnIntro u1 H; XElim H; Intros. +(* case 1 : pr3_r *) + Rewrite H; XEAuto. +(* case 2 : pr3_u *) + Rewrite H2 in H; Clear H2 t0; Pr2Gen. +(* case 2.1 : short step: compatibility *) + Rewrite H in H0; Rewrite H in H1; Clear H t2; IH. +(* case 2.1.1 : long step: compatibility *) + Rewrite H; Rewrite H in H0; XEAuto. +(* case 2.1.2 : long step: zeta *) + XEAuto. +(* case 2.2 : short step: zeta *) + Clear H1; Right. + EApply ex2_intro; [ XAuto | Idtac ]. + EApply pr3_u; [ Idtac | EApply pr3_lift ]. + XEAuto. XAuto. XAuto. + Qed. + + End pr3_gen_void. + + Section pr3_gen_abbr. (***************************************************) + + Tactic Definition IH := + LApply (H1 x0 x1); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; + [ Intros H1; XElim H1; + Do 4 Intro; Intros H_x; XElim H_x; + [ Intros | Intros H_x; XElim H_x; Intros ] + | Intros H1; XElim H1; Intros ]. + + Theorem pr3_gen_abbr : (c:?; u1,t1,x:?) (pr3 c (TTail (Bind Abbr) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abbr) u2 t2) & + (pr3 c u1 u2) & + ((b:?; u:?) (pr3 (CTail c (Bind b) u) t1 t2)) \/ + (EX u3 t3 y | (pr3 c (TTail (Bind Abbr) u3 t3) x) & + (pr3 c u1 u3) & + (b:?; u:?) (pr3 (CTail c (Bind b) u) t1 y) & + (subst0 (0) u3 y t3) + ) + ) \/ + (EX u | (pr3 c u1 u) & + (pr3 (CTail c (Bind Abbr) u) t1 (lift (1) (0) x)) + ). + Intros until 1; InsertEq H '(TTail (Bind Abbr) u1 t1); + UnIntro H t1; UnIntro H u1; XElim H; Clear y x; Intros; + Rename x into u1; Rename x0 into t4. +(* case 1 : pr3_r *) + Rewrite H; XEAuto. +(* case 2 : pr3_u *) + Rewrite H2 in H; Clear H2 t1; Pr2Gen. +(* case 2.1 : short step: compatibility *) + Rewrite H in H0; Rewrite H in H1; Clear H t2; IH. +(* case 2.1.1 : long step: compatibility *) + Rewrite H; Rewrite H in H0; Clear H t3. + Left; EApply ex3_2_intro; XEAuto. +(* case 2.1.2 : long step: delta *) + Rewrite H; Rewrite H in H0; Rewrite H in H4; Clear H t3. + Left; EApply ex3_2_intro; + [ XEAuto | XEAuto + | Right; EApply ex4_3_intro; + [ EApply pr3_t; [ XAuto | Apply H4 ] | XEAuto | Idtac | Apply H7 ] ]. + XEAuto. +(* case 2.1.3 : long step: zeta *) + XEAuto. +(* case 2.2 : short step: delta *) + Rewrite H in H0; Rewrite H in H1; Clear H t2; IH. +(* case 2.2.1 : long step: compatibility *) + Left; EApply ex3_2_intro; + [ XEAuto | XEAuto + | Right; EApply ex4_3_intro; [ Rewrite H | Idtac | Idtac | Apply H4 ] ]. + XAuto. XAuto. XAuto. +(* case 2.2.2 : long step: delta *) + Left; EApply ex3_2_intro; + [ XEAuto | XEAuto + | Right; EApply ex4_3_intro; + [ EApply pr3_t; [ Apply pr3_tail_12 | Apply H5 ] + | Idtac | Idtac | Apply H4 ] ]. + XAuto. EApply pr3_t; [ Apply H7 | XEAuto ]. XAuto. XAuto. +(* case 2.2.3 : long step: zeta *) + Right; Apply ex2_intro with x := x0; [ XAuto | Idtac ]. + Apply pr3_u with t2 := x; [ XAuto | Idtac ]. + Apply pr3_u with t2 := x1; [ XEAuto | Idtac ]. + Pr3Context; XAuto. +(* case 2.3 : short step: zeta *) + Clear H1; Right. + EApply ex2_intro; [ XAuto | Idtac ]. + EApply pr3_u; [ Idtac | EApply pr3_lift ]. + XEAuto. XAuto. XAuto. + Qed. + + End pr3_gen_abbr. + + Section pr3_gen_abst. (***************************************************) + + Theorem pr3_gen_abst : (c:?; u1,t1,x:?) + (pr3 c (TTail (Bind Abst) u1 t1) x) -> + (EX u2 t2 | x = (TTail (Bind Abst) u2 t2) & + (pr3 c u1 u2) & (b:?; u:?) + (pr3 (CTail c (Bind b) u) t1 t2) + ). + Intros until 1; InsertEq H '(TTail (Bind Abst) u1 t1); + UnIntro H t1; UnIntro H u1; XElim H; Clear y x; Intros; + Rename x into u1; Rename x0 into t4. +(* case 1 : pr3_r *) + Rewrite H; XEAuto. +(* case 2 : pr3_u *) + Rewrite H2 in H; Clear H2 t1. + Pr2GenBase. + LApply (H1 x0 x1); [ Clear H H1; Intros | XAuto ]. + XElim H; XEAuto. + Qed. + + End pr3_gen_abst. + + Section pr3_gen_lift. (***************************************************) + +(*#* #start file *) + +(*#* #caption "generation lemma for lift" *) +(*#* #cap #cap c #alpha e in D, t1 in U1, t2 in U2, x in T, d in i *) + + Theorem pr3_gen_lift : (c:?; t1,x:?; h,d:?) (pr3 c (lift h d t1) x) -> + (e:?) (drop h d c e) -> + (EX t2 | x = (lift h d t2) & (pr3 e t1 t2)). + +(*#* #stop file *) + + Intros until 1; InsertEq H '(lift h d t1); + UnIntro H t1; XElim H; Clear y x; Intros; Rename x into t4. +(* case 1 : pr3_r *) + XEAuto. +(* case 2 : pr3_u *) + Rewrite H2 in H; Pr2Gen. + LApply (H1 x); [ Clear H1; Intros H1 | XAuto ]. + LApply (H1 e); [ Clear H1; Intros H1 | XAuto ]. + XElim H1; XEAuto. + Qed. + + End pr3_gen_lift. + + Tactic Definition Pr3Gen := + Match Context With + | [ H: (pr3 ?1 (TTail (Bind Abst) ?2 ?3) ?4) |- ? ] -> + LApply (pr3_gen_abst ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (pr3 ?1 (TTail (Bind Abbr) ?2 ?3) ?4) |- ? ] -> + LApply (pr3_gen_abbr ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; + [ Intros H; XElim H; + Do 4 Intro; Intros H_x; XElim H_x; + [ Intros | Intros H_x; XElim H_x; Intros ] + | Intros H; XElim H; Intros ] + | [ H: (pr3 ?1 (TTail (Bind Void) ?2 ?3) ?4) |- ? ] -> + LApply (pr3_gen_void ?1 ?2 ?3 ?4); [ Clear H; Intros H | XAuto ]; + XElim H; Intros H; XElim H; Intros + | [ H0: (pr3 ?1 (lift ?2 ?3 ?4) ?5); + H1: (drop ?2 ?3 ?1 ?6) |- ? ] -> + LApply (pr3_gen_lift ?1 ?4 ?5 ?2 ?3); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?6); [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | _ -> Pr2Gen. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_gen_context.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_gen_context.v new file mode 100644 index 000000000..f0662babe --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_gen_context.v @@ -0,0 +1,42 @@ +(*#* #stop file *) + +Require csubst1_defs. +Require pr2_gen_context. +Require pr3_defs. + + Section pr3_gen_context. (************************************************) + + Theorem pr3_gen_cabbr: (c:?; t1,t2:?) (pr3 c t1 t2) -> (e:?; u:?; d:?) + (drop d (0) c (CTail e (Bind Abbr) u)) -> + (a0:?) (csubst1 d u c a0) -> + (a:?) (drop (1) d a0 a) -> + (x1:?) (subst1 d u t1 (lift (1) d x1)) -> + (EX x2 | (subst1 d u t2 (lift (1) d x2)) & + (pr3 a x1 x2) + ). + Intros until 1; XElim H; Intros. +(* case 1: pr3_r *) + XEAuto. +(* case 1: pr3_r *) + Pr2GenContext. + LApply (H1 e u d); [ Clear H1; Intros H1 | XAuto ]. + LApply (H1 a0); [ Clear H1; Intros H1 | XAuto ]. + LApply (H1 a); [ Clear H1; Intros H1 | XAuto ]. + LApply (H1 x); [ Clear H1; Intros H1 | XAuto ]. + XElim H1; XEAuto. + Qed. + + End pr3_gen_context. + + Tactic Definition Pr3GenContext := + Match Context With + | [ H0: (pr3 ?1 ?2 ?3); H1: (drop ?4 (0) ?1 (CTail ?5 (Bind Abbr) ?6)); + H2: (csubst1 ?4 ?6 ?1 ?7); H3: (drop (1) ?4 ?7 ?8); + H4: (subst1 ?4 ?6 ?2 (lift (1) ?4 ?9)) |- ? ] -> + LApply (pr3_gen_cabbr ?1 ?2 ?3); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5 ?6 ?4); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?8); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?9); [ Clear H0 H4; Intros H0 | XAuto ]; + XElim H0; Intros + | _ -> Pr2GenContext. diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_props.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_props.v new file mode 100644 index 000000000..dfdc49c50 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_props.v @@ -0,0 +1,113 @@ +Require subst0_subst0. +Require pr0_subst0. +Require pr2_lift. +Require pr3_defs. + +(*#* #caption "main properties of predicate \\texttt{pr3}" *) +(*#* #clauses *) + +(*#* #stop file *) + + Section pr3_context. (****************************************************) + + Theorem pr3_pr0_pr2_t : (u1,u2:?) (pr0 u1 u2) -> + (c:?; t1,t2:?; k:?) (pr2 (CTail c k u2) t1 t2) -> + (pr3 (CTail c k u1) t1 t2). + Intros. + Inversion H0; Clear H0; XAuto. + NewInduction i. +(* case 1 : pr2_delta i = 0 *) + DropGenBase; Inversion H0; Clear H0 H3 H4 c k. + Rewrite H5 in H; Clear H5 u2. + Pr0Subst0; XEAuto. +(* case 2 : pr2_delta i > 0 *) + NewInduction k; DropGenBase; XEAuto. + Qed. + + Theorem pr3_pr2_pr2_t : (c:?; u1,u2:?) (pr2 c u1 u2) -> + (t1,t2:?; k:?) (pr2 (CTail c k u2) t1 t2) -> + (pr3 (CTail c k u1) t1 t2). + Intros until 1; Inversion H; Clear H; Intros. +(* case 1 : pr2_pr0 *) + EApply pr3_pr0_pr2_t; [ Apply H0 | XAuto ]. +(* case 2 : pr2_delta *) + Inversion H; [ XAuto | NewInduction i0 ]. +(* case 2.1 : i0 = 0 *) + DropGenBase; Inversion H2; Clear H2. + Rewrite <- H5; Rewrite H6 in H; Rewrite <- H7 in H3; Clear H5 H6 H7 d0 k u0. + Subst0Subst0; Arith9'In H4 i; XDEAuto 7. +(* case 2.2 : i0 > 0 *) + Clear IHi0; NewInduction k; DropGenBase; XEAuto. + Qed. + + Theorem pr3_pr2_pr3_t : (c:?; u2,t1,t2:?; k:?) + (pr3 (CTail c k u2) t1 t2) -> + (u1:?) (pr2 c u1 u2) -> + (pr3 (CTail c k u1) t1 t2). + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply pr3_t. + EApply pr3_pr2_pr2_t; [ Apply H2 | Apply H ]. + XAuto. + Qed. + +(*#* #start file *) + +(*#* #caption "reduction inside context items" *) +(*#* #cap #cap t1, t2 #alpha c in E, u1 in V1, u2 in V2, k in z *) + + Theorem pr3_pr3_pr3_t : (c:?; u1,u2:?) (pr3 c u1 u2) -> + (t1,t2:?; k:?) (pr3 (CTail c k u2) t1 t2) -> + (pr3 (CTail c k u1) t1 t2). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply pr3_pr2_pr3_t; [ Apply H1; XAuto | XAuto ]. + Qed. + + End pr3_context. + + Tactic Definition Pr3Context := + Match Context With + | [ H1: (pr0 ?2 ?3); H2: (pr2 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pr3_pr0_pr2_t ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr0 ?2 ?3); H2: (pr3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pr3_pr2_pr3_t ?1 ?3 ?5 ?6 ?4); [ Clear H2; Intros H2 | XAuto ]; + LApply (H2 ?2); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr2 ?1 ?2 ?3); H2: (pr2 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pr3_pr2_pr2_t ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr2 ?1 ?2 ?3); H2: (pr3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pr3_pr2_pr3_t ?1 ?3 ?5 ?6 ?4); [ Clear H2; Intros H2 | XAuto ]; + LApply (H2 ?2); [ Clear H1 H2; Intros | XAuto ] + | [ H1: (pr3 ?1 ?2 ?3); H2: (pr3 (CTail ?1 ?4 ?3) ?5 ?6) |- ? ] -> + LApply (pr3_pr3_pr3_t ?1 ?2 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply (H1 ?5 ?6 ?4); [ Clear H1 H2; Intros | XAuto ]. + + Section pr3_lift. (*******************************************************) + +(*#* #start file *) + +(*#* #caption "conguence with lift" *) +(*#* #cap #cap c, t1, t2 #alpha e in D, d in i *) + + Theorem pr3_lift : (c,e:?; h,d:?) (drop h d c e) -> + (t1,t2:?) (pr3 e t1 t2) -> + (pr3 c (lift h d t1) (lift h d t2)). + +(*#* #stop file *) + + Intros until 2; XElim H0; Intros; XEAuto. + Qed. + + End pr3_lift. + + Hints Resolve pr3_lift : ltlc. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/pr3_subst1.v b/helm/coq-contribs/LAMBDA-TYPES/pr3_subst1.v new file mode 100644 index 000000000..78c9834d5 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/pr3_subst1.v @@ -0,0 +1,33 @@ +(*#* #stop file *) + +Require subst1_defs. +Require pr2_subst1. +Require pr3_defs. + + Section pr3_subst1_props. (***********************************************) + + Theorem pr3_subst1: (c,e:?; v:?; i:?) (drop i (0) c (CTail e (Bind Abbr) v)) -> + (t1,t2:?) (pr3 c t1 t2) -> + (w1:?) (subst1 i v t1 w1) -> + (EX w2 | (pr3 c w1 w2) & (subst1 i v t2 w2)). + Intros until 2; XElim H0; Clear t1 t2; Intros. +(* case 1: pr3_refl *) + XEAuto. +(* case 2: pr3_single *) + Pr2Subst1. + LApply (H2 x); [ Clear H2; Intros H2 | XAuto ]. + XElim H2; XEAuto. + Qed. + + End pr3_subst1_props. + + Tactic Definition Pr3Subst1 := + Match Context With + | [ H0: (drop ?1 (0) ?2 (CTail ?3 (Bind Abbr) ?4)); + H1: (pr3 ?2 ?5 ?6); H3: (subst1 ?1 ?4 ?5 ?7) |- ? ] -> + LApply (pr3_subst1 ?2 ?3 ?4 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?5 ?6); [ Clear H_x H1; Intros H1 | XAuto ]; + LApply (H1 ?7); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | _ -> Pr2Subst1. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_confluence.v new file mode 100644 index 000000000..bbbfdc469 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_confluence.v @@ -0,0 +1,80 @@ +(*#* #stop file *) + +Require lift_gen. +Require subst0_gen. +Require subst0_defs. + + Section subst0_confluence. (**********************************************) + + Tactic Definition IH := + Match Context With + | [ H1: (t2,u2:?; i2:?) (subst0 i2 u2 ?1 t2) -> ~?2=i2 -> ?; + H2: (subst0 ?3 ?4 ?1 ?5); H3: ~?2=?3 |- ? ] -> + LApply (H1 ?5 ?4 ?3); [ Clear H1; Intros H1 | XAuto ]; + LApply H1; [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (t2,u2:?; i2:?) (subst0 i2 u2 ?1 t2) -> ~(s k ?2)=i2 -> ?; + H2: (subst0 (s k ?3) ?4 ?1 ?5); H3: ~?2=?3 |- ? ] -> + LApply (H1 ?5 ?4 (s k ?3)); [ Clear H1; Intros H1 | XAuto ]; + LApply H1; [ Clear H1; Intros H1 | Unfold not in H3; Unfold not; XEAuto ]; + XElim H1; Intros + | [ H1: (t2:T) (subst0 ?1 ?2 ?3 t2) -> ?; H2: (subst0 ?1 ?2 ?3 ?4) |- ? ] -> + LApply (H1 ?4); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros H1; [ Try Rewrite H1 | XElim H1; Intros | Idtac | Idtac ]. + + Theorem subst0_confluence_neq : (t0,t1,u1:?; i1:?) (subst0 i1 u1 t0 t1) -> + (t2,u2:?; i2:?) (subst0 i2 u2 t0 t2) -> + ~i1=i2 -> + (EX t | (subst0 i2 u2 t1 t) & + (subst0 i1 u1 t2 t)). + + Intros until 1; XElim H; Intros; + Subst0GenBase; Try Rewrite H in H0; Try Rewrite H1; Try Rewrite H3; + Try EqFalse; Repeat IH; XEAuto. + Qed. + + Theorem subst0_confluence_eq : (t0,t1,u:?; i:?) (subst0 i u t0 t1) -> + (t2:?) (subst0 i u t0 t2) -> (OR + t1 = t2 | + (EX t | (subst0 i u t1 t) & (subst0 i u t2 t)) | + (subst0 i u t1 t2) | + (subst0 i u t2 t1)). + Intros until 1; XElim H; Intros; + Subst0GenBase; Try Rewrite H1; Try Rewrite H3; + Repeat IH; XEAuto. + Qed. + + End subst0_confluence. + + Tactic Definition Subst0Confluence := + Match Context With + | [ H0: (subst0 ?1 ?2 ?3 ?4); + H1: (subst0 ?1 ?2 ?3 ?5) |- ? ] -> + LApply (subst0_confluence_eq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5); [ Clear H0; Intros H0 | XAuto ]; + XElim H0; [ Intros | Intros H0; XElim H0; Intros | Intros | Intros ] + | [ H0: (subst0 ?1 ?2 ?3 ?4); + H1: (subst0 ?5 ?6 ?3 ?7) |- ? ] -> + LApply (subst0_confluence_neq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7 ?6 ?5); [ Clear H0 H1; Intros H0 | XAuto ]; + LApply H0; [ Clear H0; Intros H0 | Simpl; XAuto ]; + XElim H0; Intros. + + Section subst0_confluence_lift. (*****************************************) + + Theorem subst0_confluence_lift: (t0,t1,u:?; i:?) (subst0 i u t0 (lift (1) i t1)) -> + (t2:?) (subst0 i u t0 (lift (1) i t2)) -> + t1 = t2. + Intros; Subst0Confluence; + Try Subst0Gen; SymEqual; LiftGen; XEAuto. + Qed. + + End subst0_confluence_lift. + + Tactic Definition Subst0ConfluenceLift := + Match Context With + | [ H0: (subst0 ?1 ?2 ?3 (lift (1) ?1 ?4)); + H1: (subst0 ?1 ?2 ?3 (lift (1) ?1 ?5)) |- ? ] -> + LApply (subst0_confluence_lift ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5); [ Clear H0; Intros | XAuto ] + | _ -> Subst0Confluence. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_defs.v new file mode 100644 index 000000000..5c9c2e5c8 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_defs.v @@ -0,0 +1,55 @@ +(*#* #stop file *) + +Require Export lift_defs. + + Inductive subst0 : nat -> T -> T -> T -> Prop := + | subst0_bref : (v:?; i:?) (subst0 i v (TBRef i) (lift (S i) (0) v)) + | subst0_fst : (v,w,u:?; i:?) (subst0 i v u w) -> + (t:?; k:?) (subst0 i v (TTail k u t) (TTail k w t)) + | subst0_snd : (k:?; v,w,t:?; i:?) (subst0 (s k i) v t w) -> (u:?) + (subst0 i v (TTail k u t) (TTail k u w)) + | subst0_both : (v,u1,u2:?; i:?) (subst0 i v u1 u2) -> + (k:?; t1,t2:?) (subst0 (s k i) v t1 t2) -> + (subst0 i v (TTail k u1 t1) (TTail k u2 t2)). + + Hint subst0 : ltlc := Constructors subst0. + + Section subst0_gen_base. (************************************************) + + Theorem subst0_gen_sort : (v,x:?; i,n:?) (subst0 i v (TSort n) x) -> + (P:Prop) P. + Intros; Inversion H. + Qed. + + Theorem subst0_gen_bref : (v,x:?; i,n:?) (subst0 i v (TBRef n) x) -> + n = i /\ x = (lift (S n) (0) v). + Intros; Inversion H; XAuto. + Qed. + + Theorem subst0_gen_tail : (k:?; v,u1,t1,x:?; i:?) + (subst0 i v (TTail k u1 t1) x) -> (OR + (EX u2 | x = (TTail k u2 t1) & + (subst0 i v u1 u2)) | + (EX t2 | x = (TTail k u1 t2) & + (subst0 (s k i) v t1 t2)) | + (EX u2 t2 | x = (TTail k u2 t2) & + (subst0 i v u1 u2) & + (subst0 (s k i) v t1 t2)) + ). + + Intros; Inversion H; XEAuto. + Qed. + + End subst0_gen_base. + + Tactic Definition Subst0GenBase := + Match Context With + | [ H: (subst0 ?1 ?2 (TSort ?3) ?4) |- ? ] -> + Apply (subst0_gen_sort ?2 ?4 ?1 ?3); Apply H + | [ H: (subst0 ?1 ?2 (TBRef ?3) ?4) |- ? ] -> + LApply (subst0_gen_bref ?2 ?4 ?1 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (subst0 ?1 ?2 (TTail ?3 ?4 ?5) ?6) |- ? ] -> + LApply (subst0_gen_tail ?3 ?2 ?4 ?5 ?6 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros H; XElim H; Intros. + diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_gen.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_gen.v new file mode 100644 index 000000000..7a0acfeb6 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_gen.v @@ -0,0 +1,130 @@ +(*#* #stop file *) + +Require lift_props. +Require subst0_defs. + + Section subst0_gen_lift_lt. (*********************************************) + + Tactic Definition IH := + Match Context With + [ H1: (x:T; i,h,d:nat) (subst0 i (lift h d ?1) (lift h (S (plus i d)) ?2) x) -> ?; + H2: (subst0 ?3 (lift ?4 ?5 ?1) (lift ?4 (S (plus ?3 ?5)) ?2) ?6) |- ? ] -> + LApply (H1 ?6 ?3 ?4 ?5); [ Clear H1 H2; Intros H1 | XAuto ]; + XElim H1; Intros. + + Theorem subst0_gen_lift_lt : (u,t1,x:?; i,h,d:?) (subst0 i (lift h d u) (lift h (S (plus i d)) t1) x) -> + (EX t2 | x = (lift h (S (plus i d)) t2) & (subst0 i u t1 t2)). + XElim t1; Intros. +(* case 1: TSort *) + Rewrite lift_sort in H; Subst0GenBase. +(* case 2: TBRef n *) + Apply (lt_le_e n (S (plus i d))); Intros. +(* case 2.1: n < 1 + i + d *) + Rewrite lift_bref_lt in H; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite H1; Rewrite H. + Rewrite <- lift_d; Simpl; XEAuto. +(* case 2.2: n >= 1 + i + d *) + Rewrite lift_bref_ge in H; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite <- H in H0. + EApply le_false; [ Idtac | Apply H0 ]; XAuto. +(* case 3: TTail k *) + Rewrite lift_tail in H1; Subst0GenBase; Rewrite H1; Clear H1 x. +(* case 3.1: subst0_fst *) + IH; Rewrite H; Rewrite <- lift_tail; XEAuto. +(* case 3.2: subst0_snd *) + SRwIn H2; IH; Rewrite H0; SRwBack; Rewrite <- lift_tail; XEAuto. +(* case 3.2: subst0_snd *) + SRwIn H3; Repeat IH; Rewrite H; Rewrite H0; SRwBack; + Rewrite <- lift_tail; XEAuto. + Qed. + + End subst0_gen_lift_lt. + + Section subst0_gen_lift_false. (******************************************) + + Theorem subst0_gen_lift_false : (t,u,x:?; h,d,i:?) + (le d i) -> (lt i (plus d h)) -> + (subst0 i u (lift h d t) x) -> + (P:Prop) P. + XElim t; Intros. +(* case 1: TSort *) + Rewrite lift_sort in H1; Subst0GenBase. +(* case 2: TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Rewrite lift_bref_lt in H1; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite H1 in H2. + EApply le_false; [ Apply H | XAuto ]. +(* case 2.2: n >= d *) + Rewrite lift_bref_ge in H1; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite <- H1 in H0. + EApply le_false; [ Apply H2 | XEAuto ]. +(* case 3: TTail k *) + Rewrite lift_tail in H3; Subst0GenBase. +(* case 3.1: subst0_fst *) + EApply H; XEAuto. +(* case 3.2: subst0_snd *) + EApply H0; [ Idtac | Idtac | XEAuto ]; [ Idtac | SRwBack ]; XAuto. +(* case 3.3: subst0_both *) + EApply H; XEAuto. + Qed. + + End subst0_gen_lift_false. + + Section subst0_gen_lift_ge. (*********************************************) + + Tactic Definition IH := + Match Context With + [ H1: (x:?; i,h,d:?) (subst0 i ?1 (lift h d ?2) x) -> ?; + H2: (subst0 ?3 ?1 (lift ?4 ?5 ?2) ?6) |- ? ] -> + LApply (H1 ?6 ?3 ?4 ?5); [ Clear H1 H2; Intros H1 | XAuto ]; + LApply H1; [ Clear H1; Intros H1 | SRwBack; XAuto ]; + XElim H1; Intros. + + Theorem subst0_gen_lift_ge : (u,t1,x:?; i,h,d:?) (subst0 i u (lift h d t1) x) -> + (le (plus d h) i) -> + (EX t2 | x = (lift h d t2) & (subst0 (minus i h) u t1 t2)). + XElim t1; Intros. +(* case 1: TSort *) + Rewrite lift_sort in H; Subst0GenBase. +(* case 2: TBRef n *) + Apply (lt_le_e n d); Intros. +(* case 2.1: n < d *) + Rewrite lift_bref_lt in H; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite H in H1. + EApply le_false; [ Apply H0 | XAuto ]. +(* case 2.2: n >= d *) + Rewrite lift_bref_ge in H; [ Idtac | XAuto ]. + Subst0GenBase; Rewrite <- H; Rewrite H2. + Rewrite minus_plus_r. + EApply ex2_intro; [ Idtac | XAuto ]. + Rewrite lift_free; [ Idtac | XEAuto (**) | XAuto ]. + Rewrite plus_sym; Rewrite plus_n_Sm; XAuto. +(* case 3: TTail k *) + Rewrite lift_tail in H1; Subst0GenBase; Rewrite H1; Clear H1 x; + Repeat IH; Try Rewrite H; Try Rewrite H0; + Rewrite <- lift_tail; Try Rewrite <- s_minus in H1; XEAuto. + Qed. + + End subst0_gen_lift_ge. + + Tactic Definition Subst0Gen := + Match Context With + | [ H: (subst0 ?0 (lift ?1 ?2 ?3) (lift ?1 (S (plus ?0 ?2)) ?4) ?5) |- ? ] -> + LApply (subst0_gen_lift_lt ?3 ?4 ?5 ?0 ?1 ?2); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (subst0 ?0 ?1 (lift (1) ?0 ?2) ?3) |- ? ] -> + LApply (subst0_gen_lift_false ?2 ?1 ?3 (1) ?0 ?0); [ Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros H_x | Rewrite plus_sym; XAuto ]; + LApply H_x; [ Clear H H_x; Intros H | XAuto ]; + Apply H + | [ _: (le ?1 ?2); _: (lt ?2 (plus ?1 ?3)); + _: (subst0 ?2 ?4 (lift ?3 ?1 ?5) ?6) |- ? ] -> + Apply (subst0_gen_lift_false ?5 ?4 ?6 ?3 ?1 ?2); XAuto + | [ _: (subst0 ?1 ?2 (lift (S ?1) (0) ?3) ?4) |- ? ] -> + Apply (subst0_gen_lift_false ?3 ?2 ?4 (S ?1) (0) ?1); XAuto + | [ H: (subst0 ?0 ?1 (lift ?2 ?3 ?4) ?5) |- ? ] -> + LApply (subst0_gen_lift_ge ?1 ?4 ?5 ?0 ?2 ?3); [ Clear H; Intros H | XAuto ]; + LApply H; [ Clear H; Intros H | Simpl; XAuto ]; + XElim H; Intros + | _ -> Subst0GenBase. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_lift.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_lift.v new file mode 100644 index 000000000..d4ce7412f --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_lift.v @@ -0,0 +1,49 @@ +(*#* #stop file *) + +Require lift_props. +Require subst0_defs. + + Section subst0_lift. (****************************************************) + + Theorem subst0_lift_lt : (t1,t2,u:?; i:?) (subst0 i u t1 t2) -> + (d:?) (lt i d) -> (h:?) + (subst0 i (lift h (minus d (S i)) u) (lift h d t1) (lift h d t2)). + Intros until 1; XElim H; Intros. +(* case 1: subst0_bref *) + Rewrite lift_bref_lt; [ Idtac | XAuto ]. + LetTac w := (minus d (S i0)). + Arith8 d '(S i0); Rewrite lift_d; XAuto. +(* case 2: subst0_fst *) + LiftTailRw; XAuto. +(* case 3: subst0_snd *) + SRwBackIn H0; LiftTailRw; Rewrite <- (minus_s_s k); XAuto. +(* case 4: subst0_both *) + SRwBackIn H2; LiftTailRw. + Apply subst0_both; [ Idtac | Rewrite <- (minus_s_s k) ]; XAuto. + Qed. + + Theorem subst0_lift_ge : (t1,t2,u:?; i,h:?) (subst0 i u t1 t2) -> + (d:?) (le d i) -> + (subst0 (plus i h) u (lift h d t1) (lift h d t2)). + Intros until 1; XElim H; Intros. +(* case 1: subst0_bref *) + Rewrite lift_bref_ge; [ Idtac | XAuto ]. + Rewrite lift_free; [ Idtac | Simpl; XAuto | XAuto ]. + Arith5'c h i0; XAuto. +(* case 2: subst0_fst *) + LiftTailRw; XAuto. +(* case 3: subst0_snd *) + SRwBackIn H0; LiftTailRw; XAuto. +(* case 4: subst0_snd *) + SRwBackIn H2; LiftTailRw; XAuto. + Qed. + + Theorem subst0_lift_ge_S : (t1,t2,u:?; i:?) (subst0 i u t1 t2) -> + (d:?) (le d i) -> (b:?) + (subst0 (s (Bind b) i) u (lift (1) d t1) (lift (1) d t2)). + Intros; Simpl; Arith7 i; Apply subst0_lift_ge; XAuto. + Qed. + + End subst0_lift. + + Hints Resolve subst0_lift_lt subst0_lift_ge subst0_lift_ge_S : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_subst0.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_subst0.v new file mode 100644 index 000000000..e092e23e7 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_subst0.v @@ -0,0 +1,68 @@ +(*#* #stop file *) + +Require subst0_defs. +Require subst0_gen. +Require subst0_lift. + + Section subst0_subst0. (**************************************************) + + Tactic Definition IH := + Match Context With + | [ H1: (u1,u:?; i:?) (subst0 i u u1 ?1) -> ?; + H2: (subst0 ?2 ?3 ?4 ?1) |- ? ] -> + LApply (H1 ?4 ?3 ?2); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros + | [ H1: (u1,u:?; i:?) (subst0 i u ?1 u1) -> ?; + H2: (subst0 ?2 ?3 ?1 ?4) |- ? ] -> + LApply (H1 ?4 ?3 ?2); [ Clear H1; Intros H1 | XAuto ]; + XElim H1; Intros. + + Theorem subst0_subst0: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) -> + (u1,u:?; i:?) (subst0 i u u1 u2) -> + (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t t2)). + Intros until 1; XElim H; Intros. +(* case 1 : subst0_bref *) + Arith5 i0 i; XEAuto. +(* case 2 : subst0_fst *) + IH; XEAuto. +(* case 3 : subst0_snd *) + IH; SRwBackIn H2; XEAuto. +(* case 4 : subst0_both *) + Repeat IH; SRwBackIn H4; XEAuto. + Qed. + + Theorem subst0_subst0_back: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) -> + (u1,u:?; i:?) (subst0 i u u2 u1) -> + (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t2 t)). + Intros until 1; XElim H; Intros. +(* case 1 : subst0_bref *) + Arith5 i0 i; XEAuto. +(* case 2 : subst0_fst *) + IH; XEAuto. +(* case 3 : subst0_snd *) + IH; SRwBackIn H2; XEAuto. +(* case 4 : subst0_both *) + Repeat IH; SRwBackIn H4; XEAuto. + Qed. + + Theorem subst0_trans: (t2,t1,v:?; i:?) (subst0 i v t1 t2) -> + (t3:?) (subst0 i v t2 t3) -> + (subst0 i v t1 t3). + Intros until 1; XElim H; Intros; + Subst0Gen; Try Rewrite H1; Try Rewrite H3; XAuto. + Qed. + + End subst0_subst0. + + Hints Resolve subst0_trans : ltlc. + + Tactic Definition Subst0Subst0 := + Match Context With + | [ H1: (subst0 ?0 ?1 ?2 ?3); H2: (subst0 ?4 ?5 ?6 ?1) |- ? ] -> + LApply (subst0_subst0 ?2 ?3 ?1 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?6 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ H1: (subst0 ?0 ?1 ?2 ?3); H2: (subst0 ?4 ?5 ?1 ?6) |- ? ] -> + LApply (subst0_subst0_back ?2 ?3 ?1 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?6 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst0_tlt.v b/helm/coq-contribs/LAMBDA-TYPES/subst0_tlt.v new file mode 100644 index 000000000..87bf9c8c0 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst0_tlt.v @@ -0,0 +1,62 @@ +(*#* #stop file *) + +Require tlt_defs. +Require lift_tlt. +Require subst0_defs. + + Section subst0_tlt_props. (***********************************************) + + Theorem subst0_weight_le : (u,t,z:?; d:?) (subst0 d u t z) -> + (f,g:?) ((m:?) (le (f m) (g m))) -> + (lt (weight_map f (lift (S d) (0) u)) (g d)) -> + (le (weight_map f z) (weight_map g t)). + Intros until 1; XElim H. +(* case 1: subst0_bref *) + Intros; XAuto. +(* case 2: subst0_fst *) + XElim k; [ XElim b | Idtac ]; Simpl; [ Auto 7 with ltlc (**) | XAuto | XAuto | XAuto ]. +(* case 3: subst0_snd *) + XElim k; [ XElim b | Idtac ]; Simpl; [ Auto 7 with ltlc (**) | XAuto | XAuto | XAuto ]. +(* case 4: subst0_both *) + XElim k; [ XElim b | Idtac ]; Simpl; [ Auto 7 with ltlc (**) | XAuto | XAuto | XAuto ]. + Qed. + + Theorem subst0_weight_lt : (u,t,z:?; d:?) (subst0 d u t z) -> (f,g:?) + ((m:?) (le (f m) (g m))) -> + (lt (weight_map f (lift (S d) (0) u)) (g d)) -> + (lt (weight_map f z) (weight_map g t)). + Intros until 1; XElim H. +(* case 1: subst0_bref *) + Intros; XAuto. +(* case 2: subst0_fst *) + XElim k; [ XElim b | Idtac ]; Simpl; Intros; + Apply lt_n_S; (Apply lt_le_plus_plus; [ XAuto | Idtac ]); (**) + [ Auto 6 with ltlc (**) | XAuto | XAuto | XAuto ]. +(* case 3: subst0_snd *) + XElim k; [ XElim b | Idtac ]; Simpl; + [ Auto 8 with ltlc | Auto 6 with ltlc | Auto 6 with ltlc | XAuto ]. (**) +(* case 3: subst0_both *) + XElim k; [ XElim b | Idtac ]; Simpl; + Intros; Apply lt_n_S; [ Apply lt_le_plus_plus | Apply lt_plus_plus | Apply lt_plus_plus | Apply lt_plus_plus ]; XAuto. + EApply subst0_weight_le; [ XEAuto | XAuto | XAuto ]. + Qed. + + Theorem subst0_tlt_tail: (u,t,z:?) (subst0 (0) u t z) -> + (tlt (TTail (Bind Abbr) u z) + (TTail (Bind Abbr) u t) + ). + Unfold tlt weight; Intros; Simpl. + Apply lt_n_S; Apply le_lt_plus_plus; [ XAuto | Idtac ]. + EApply subst0_weight_lt; [ XEAuto | XAuto | XAuto ]. + Qed. + + Theorem subst0_tlt: (u,t,z:?) (subst0 (0) u t z) -> + (tlt z (TTail (Bind Abbr) u t)). + Intros. + EApply tlt_trans; [ Idtac | Apply subst0_tlt_tail; XEAuto]. + XAuto. + Qed. + + End subst0_tlt_props. + + Hints Resolve subst0_tlt : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst1_confluence.v b/helm/coq-contribs/LAMBDA-TYPES/subst1_confluence.v new file mode 100644 index 000000000..0c473e9ef --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst1_confluence.v @@ -0,0 +1,82 @@ +(*#* #stop file *) + +Require lift_gen. +Require subst0_gen. +Require subst0_confluence. +Require subst1_defs. +Require subst1_gen. + + Section subst1_confluence. (**********************************************) + + Theorem subst1_confluence_neq: (t0,t1,u1:?; i1:?) (subst1 i1 u1 t0 t1) -> + (t2,u2:?; i2:?) (subst1 i2 u2 t0 t2) -> + ~i1=i2 -> + (EX t | (subst1 i2 u2 t1 t) & + (subst1 i1 u1 t2 t) + ). + Intros until 1; XElim H; Clear t1; Intros. +(* case 1; subst1_refl *) + XEAuto. +(* case 2; subst1_single *) + XElim H0; Intros; Try Subst0Confluence; XEAuto. + Qed. + + Theorem subst1_confluence_eq : (t0,t1,u:?; i:?) (subst1 i u t0 t1) -> + (t2:?) (subst1 i u t0 t2) -> + (EX t | (subst1 i u t1 t) & + (subst1 i u t2 t) + ). + Intros until 1; XElim H; Intros. +(* case 1; subst1_refl *) + XEAuto. +(* case 2; subst1_single *) + XElim H0; Intros; + Try Subst0Confluence; Try Rewrite H0; XEAuto. + Qed. + + Theorem subst1_confluence_lift: (t0,t1,u:?; i:?) (subst1 i u t0 (lift (1) i t1)) -> + (t2:?) (subst1 i u t0 (lift (1) i t2)) -> + t1 = t2. + Intros until 1; InsertEq H '(lift (1) i t1); XElim H; Clear y; Intros. +(* case 1: subst1_refl *) + Rewrite H in H0; Clear H t0. + Subst1Gen; SymEqual; LiftGen; XEAuto. +(* case 2: subst1_single *) + Rewrite H0 in H; Clear H0 t2. + InsertEq H1 '(lift (1) i t3); XElim H0; Clear y; Intros. +(* case 2.1: subst1_refl *) + Rewrite H0 in H; Clear H0 t0; Subst0Gen. +(* case 2.2: subst1_single *) + Rewrite H1 in H0; Clear H1 t2; Subst0ConfluenceLift; XAuto. + Qed. + + End subst1_confluence. + + Tactic Definition Subst1Confluence := + Match Context With + | [ H0: (subst1 ?1 ?2 ?3 (lift (1) ?1 ?4)); + H1: (subst1 ?1 ?2 ?3 (lift (1) ?1 ?5)) |- ? ] -> + LApply (subst1_confluence_lift ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5); [ Clear H0; Intros | XAuto ] + | [ H0: (subst1 ?1 ?2 ?3 ?4); + H1: (subst1 ?1 ?2 ?3 ?5) |- ? ] -> + LApply (subst1_confluence_eq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5); [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | [ H0: (subst0 ?1 ?2 ?3 ?4); + H1: (subst1 ?1 ?2 ?3 ?5) |- ? ] -> + LApply (subst1_confluence_eq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?5); [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | [ H0: (subst1 ?1 ?2 ?3 ?4); + H1: (subst1 ?5 ?6 ?3 ?7) |- ? ] -> + LApply (subst1_confluence_neq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7 ?6 ?5); [ Clear H0 H1; Intros H0 | XAuto ]; + LApply H0; [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | [ H0: (subst0 ?1 ?2 ?3 ?4); + H1: (subst1 ?5 ?6 ?3 ?7) |- ? ] -> + LApply (subst1_confluence_neq ?3 ?4 ?2 ?1); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7 ?6 ?5); [ Clear H0 H1; Intros H0 | XAuto ]; + LApply H0; [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst1_defs.v b/helm/coq-contribs/LAMBDA-TYPES/subst1_defs.v new file mode 100644 index 000000000..d1e091348 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst1_defs.v @@ -0,0 +1,58 @@ +(*#* #stop file *) + +Require Export subst0_defs. + + Inductive subst1 [i:nat; v:T; t1:T] : T -> Prop := + | subst1_refl : (subst1 i v t1 t1) + | subst1_single : (t2:?) (subst0 i v t1 t2) -> (subst1 i v t1 t2). + + Hint subst1 : ltlc := Constructors subst1. + + Section subst1_props. (***************************************************) + + Theorem subst1_tail: (v,u1,u2:?; i:?) (subst1 i v u1 u2) -> + (k:?; t1,t2:?) (subst1 (s k i) v t1 t2) -> + (subst1 i v (TTail k u1 t1) (TTail k u2 t2)). + Intros until 1; XElim H; Clear u2. +(* case 1: csubst1_refl *) + Intros until 1; XElim H; Clear t2; XAuto. +(* case 2: csubst1_single *) + Intros until 2; XElim H0; Clear t3; XAuto. + Qed. + + End subst1_props. + + Hints Resolve subst1_tail : ltlc. + + Section subst1_gen_base. (************************************************) + + Theorem subst1_gen_sort : (v,x:?; i,n:?) (subst1 i v (TSort n) x) -> + x = (TSort n). + Intros; XElim H; Clear x; Intros; + Try Subst0GenBase; XAuto. + Qed. + + Theorem subst1_gen_bref : (v,x:?; i,n:?) (subst1 i v (TBRef n) x) -> + x = (TBRef n) \/ + n = i /\ x = (lift (S n) (0) v). + Intros; XElim H; Clear x; Intros; + Try Subst0GenBase; XAuto. + Qed. + + Theorem subst1_gen_tail : (k:?; v,u1,t1,x:?; i:?) + (subst1 i v (TTail k u1 t1) x) -> + (EX u2 t2 | x = (TTail k u2 t2) & + (subst1 i v u1 u2) & + (subst1 (s k i) v t1 t2) + ). + Intros; XElim H; Clear x; Intros; + Try Subst0GenBase; XEAuto. + Qed. + + End subst1_gen_base. + + Tactic Definition Subst1GenBase := + Match Context With + | [ H: (subst1 ?1 ?2 (TTail ?3 ?4 ?5) ?6) |- ? ] -> + LApply (subst1_gen_tail ?3 ?2 ?4 ?5 ?6 ?1); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst1_gen.v b/helm/coq-contribs/LAMBDA-TYPES/subst1_gen.v new file mode 100644 index 000000000..0b2d4a170 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst1_gen.v @@ -0,0 +1,44 @@ +(*#* #stop file *) + +Require subst0_gen. +Require subst1_defs. + + Section subst1_gen_lift. (************************************************) + + Theorem subst1_gen_lift_lt : (u,t1,x:?; i,h,d:?) (subst1 i (lift h d u) (lift h (S (plus i d)) t1) x) -> + (EX t2 | x = (lift h (S (plus i d)) t2) & (subst1 i u t1 t2)). + Intros; XElim H; Clear x; Intros; + Try Subst0Gen; XEAuto. + Qed. + + Theorem subst1_gen_lift_eq : (t,u,x:?; h,d,i:?) + (le d i) -> (lt i (plus d h)) -> + (subst1 i u (lift h d t) x) -> + x = (lift h d t). + Intros; XElim H1; Clear x; Intros; + Try Subst0Gen; XAuto. + Qed. + + Theorem subst1_gen_lift_ge : (u,t1,x:?; i,h,d:?) (subst1 i u (lift h d t1) x) -> + (le (plus d h) i) -> + (EX t2 | x = (lift h d t2) & (subst1 (minus i h) u t1 t2)). + Intros; XElim H; Clear x; Intros; + Try Subst0Gen; XEAuto. + Qed. + + End subst1_gen_lift. + + Tactic Definition Subst1Gen := + Match Context With + | [ H: (subst1 ?0 (lift ?1 ?2 ?3) (lift ?1 (S (plus ?0 ?2)) ?4) ?5) |- ? ] -> + LApply (subst1_gen_lift_lt ?3 ?4 ?5 ?0 ?1 ?2); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (subst1 ?0 ?1 (lift (1) ?0 ?2) ?3) |- ? ] -> + LApply (subst1_gen_lift_eq ?2 ?1 ?3 (1) ?0 ?0); [ Intros H_x | XAuto ]; + LApply H_x; [ Clear H_x; Intros H_x | Rewrite plus_sym; XAuto ]; + LApply H_x; [ Clear H H_x; Intros | XAuto ] + | [ H0: (subst1 ?0 ?1 (lift (1) ?4 ?2) ?3); H1: (lt ?4 ?0) |- ? ] -> + LApply (subst1_gen_lift_ge ?1 ?2 ?3 ?0 (1) ?4); [ Clear H0; Intros H0 | XAuto ]; + LApply H0; [ Clear H0; Intros H0 | Rewrite plus_sym; XAuto ]; + XElim H0; Intros + | _ -> Subst1GenBase. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst1_lift.v b/helm/coq-contribs/LAMBDA-TYPES/subst1_lift.v new file mode 100644 index 000000000..396757179 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst1_lift.v @@ -0,0 +1,23 @@ +(*#* #stop file *) + +Require lift_props. +Require subst0_lift. +Require subst1_defs. + + Section subst1_lift. (****************************************************) + + Theorem subst1_lift_lt : (t1,t2,u:?; i:?) (subst1 i u t1 t2) -> + (d:?) (lt i d) -> (h:?) + (subst1 i (lift h (minus d (S i)) u) (lift h d t1) (lift h d t2)). + Intros until 1; XElim H; Clear t2; XAuto. + Qed. + + Theorem subst1_lift_ge : (t1,t2,u:?; i,h:?) (subst1 i u t1 t2) -> + (d:?) (le d i) -> + (subst1 (plus i h) u (lift h d t1) (lift h d t2)). + Intros until 1; XElim H; Clear t2; XAuto. + Qed. + + End subst1_lift. + + Hints Resolve subst1_lift_lt subst1_lift_ge : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/subst1_subst1.v b/helm/coq-contribs/LAMBDA-TYPES/subst1_subst1.v new file mode 100644 index 000000000..0f437ed9a --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/subst1_subst1.v @@ -0,0 +1,60 @@ +(*#* #stop file *) + +Require subst0_subst0. +Require subst1_defs. + + Section subst1_subst1. (**************************************************) + + Theorem subst1_subst1: (t1,t2,u2:?; j:?) (subst1 j u2 t1 t2) -> + (u1,u:?; i:?) (subst1 i u u1 u2) -> + (EX t | (subst1 j u1 t1 t) & (subst1 (S (plus i j)) u t t2)). + Intros until 1; XElim H; Clear t2. +(* case 1: subst1_refl on first premise *) + XEAuto. +(* case 2: subst1_single on first premise *) + Intros until 2; InsertEq H0 u2; XElim H0; Clear y; Intros. +(* case 2.1: subst1_refl on second premise *) + Rewrite H0; Clear H0 u1; XEAuto. +(* case 2.2: subst1_single on second premise *) + Rewrite H1 in H0; Clear H1 t0; Subst0Subst0; XEAuto. + Qed. + + Theorem subst1_subst1_back: (t1,t2,u2:?; j:?) (subst1 j u2 t1 t2) -> + (u1,u:?; i:?) (subst1 i u u2 u1) -> + (EX t | (subst1 j u1 t1 t) & (subst1 (S (plus i j)) u t2 t)). + Intros until 1; XElim H; Clear t2. +(* case 1: subst1_refl on first premise *) + XEAuto. +(* case 2: subst1_single on first premise *) + Intros until 2; XElim H0; Clear u1; Intros; + Try Subst0Subst0; XEAuto. + Qed. + + Theorem subst1_trans: (t2,t1,v:?; i:?) (subst1 i v t1 t2) -> + (t3:?) (subst1 i v t2 t3) -> + (subst1 i v t1 t3). + Intros until 1; XElim H; Clear t2. +(* case 1: subst1_refl on first premise *) + XEAuto. +(* case 2: subst1_single on first premise *) + Intros until 2; XElim H0; Clear t3; XEAuto. + Qed. + + End subst1_subst1. + + Hints Resolve subst1_trans : ltlc. + + Tactic Definition Subst1Subst1 := + Match Context With + | [ H1: (subst1 ?0 ?1 ?2 ?3); H2: (subst1 ?4 ?5 ?6 ?1) |- ? ] -> + LApply (subst1_subst1 ?2 ?3 ?1 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?6 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ H1: (subst1 ?0 ?1 ?2 ?3); H2: (subst0 ?4 ?5 ?6 ?1) |- ? ] -> + LApply (subst1_subst1 ?2 ?3 ?1 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?6 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros + | [ H1: (subst1 ?0 ?1 ?2 ?3); H2: (subst1 ?4 ?5 ?1 ?6) |- ? ] -> + LApply (subst1_subst1_back ?2 ?3 ?1 ?0); [ Intros H_x | XAuto ]; + LApply (H_x ?6 ?5 ?4); [ Clear H_x; Intros H_x | XAuto ]; + XElim H_x; Intros. diff --git a/helm/coq-contribs/LAMBDA-TYPES/terms_defs.v b/helm/coq-contribs/LAMBDA-TYPES/terms_defs.v new file mode 100644 index 000000000..157cb7456 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/terms_defs.v @@ -0,0 +1,78 @@ +(*#* #stop file *) + +Require Export Base. + + Inductive Set B := Abbr : B + | Abst : B + | Void : B. + + Inductive Set F := Appl : F + | Cast : F. + + Inductive Set K := Bind : B -> K + | Flat : F -> K. + + Inductive Set T := TSort : nat -> T + | TBRef : nat -> T + | TTail : K -> T -> T -> T. + + Hint f3KTT : ltlc := Resolve (f_equal3 K T T). + + Definition s: K -> nat -> nat := [k;i] Cases k of + | (Bind _) => (S i) + | (Flat _) => i + end. + + Section s_props. (********************************************************) + + Theorem s_S: (k:?; i:?) (s k (S i)) = (S (s k i)). + XElim k; XAuto. + Qed. + + Theorem s_plus: (k:?; i,j:?) (s k (plus i j)) = (plus (s k i) j). + XElim k; XAuto. + Qed. + + Theorem s_plus_sym: (k:?; i,j:?) (s k (plus i j)) = (plus i (s k j)). + XElim k; [ Intros; Simpl; Rewrite plus_n_Sm | Idtac ]; XAuto. + Qed. + + Theorem s_minus: (k:?; i,j:?) (le j i) -> + (s k (minus i j)) = (minus (s k i) j). + XElim k; [ Intros; Unfold s; Cbv Iota | XAuto ]. + Rewrite minus_Sn_m; XAuto. + Qed. + + Theorem minus_s_s: (k:?; i,j:?) (minus (s k i) (s k j)) = (minus i j). + XElim k; XAuto. + Qed. + + Theorem s_le: (k:?; i,j:?) (le i j) -> (le (s k i) (s k j)). + XElim k; Simpl; XAuto. + Qed. + + Theorem s_lt: (k:?; i,j:?) (lt i j) -> (lt (s k i) (s k j)). + XElim k; Simpl; XAuto. + Qed. + + Theorem s_inj: (k:?; i,j:?) (s k i) = (s k j) -> i = j. + XElim k; XEAuto. + Qed. + + End s_props. + + Hints Resolve s_le s_lt s_inj. + + Tactic Definition SRw := + Repeat (Rewrite s_S Orelse Rewrite s_plus_sym). + + Tactic Definition SRwIn H := + Repeat (Rewrite s_S in H Orelse Rewrite s_plus in H). + + Tactic Definition SRwBack := + Repeat (Rewrite <- s_S Orelse Rewrite <- s_plus Orelse Rewrite <- s_plus_sym). + + Tactic Definition SRwBackIn H := + Repeat (Rewrite <- s_S in H Orelse Rewrite <- s_plus in H Orelse Rewrite <- s_plus_sym in H). + + Hint discr : ltlc := Extern 4 (le ? (plus (s ? ?) ?)) SRwBack. diff --git a/helm/coq-contribs/LAMBDA-TYPES/tlt_defs.v b/helm/coq-contribs/LAMBDA-TYPES/tlt_defs.v new file mode 100644 index 000000000..689477a39 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/tlt_defs.v @@ -0,0 +1,115 @@ +(*#* #stop file *) + +Require Export terms_defs. + + Definition wadd : (nat -> nat) -> nat -> (nat -> nat) := + [f;w;n] Cases n of (0) => w | (S m) => (f m) end. + + Fixpoint weight_map [f:nat->nat; t:T] : nat := Cases t of + | (TSort n) => (0) + | (TBRef n) => (f n) + | (TTail (Bind Abbr) u t) => + (S (plus (weight_map f u) (weight_map (wadd f (S (weight_map f u))) t))) + | (TTail (Bind _) u t) => + (S (plus (weight_map f u) (weight_map (wadd f (0)) t))) + | (TTail _ u t) => (S (plus (weight_map f u) (weight_map f t))) + end. + + Definition weight : T -> nat := (weight_map [_](0)). + + Definition tlt : T -> T -> Prop := [t1,t2](lt (weight t1) (weight t2)). + + Section wadd_props. (*****************************************************) + + Theorem wadd_le: (f,g:?) ((n:?) (le (f n) (g n))) -> (v,w:?) (le v w) -> + (n:?) (le (wadd f v n) (wadd g w n)). + XElim n; Simpl; XAuto. + Qed. + + Theorem wadd_lt: (f,g:?) ((n:?) (le (f n) (g n))) -> (v,w:?) (lt v w) -> + (n:?) (le (wadd f v n) (wadd g w n)). + XElim n; Simpl; XAuto. + Qed. + + Theorem wadd_O: (n:?) (wadd [_](0) (0) n) = (0). + XElim n; XAuto. + Qed. + + End wadd_props. + + Hints Resolve wadd_le wadd_lt wadd_O : ltlc. + + Section weight_props. (***************************************************) + + Theorem weight_le : (t:?; f,g:?) ((n:?) (le (f n) (g n))) -> + (le (weight_map f t) (weight_map g t)). + XElim t; [ XAuto | Simpl; XAuto | Idtac ]. + XElim k; Simpl; [ Idtac | XAuto ]. + XElim b; Auto 7 with ltlc. (**) + Qed. + + Theorem weight_eq : (t:?; f,g:?) ((n:?) (f n) = (g n)) -> + (weight_map f t) = (weight_map g t). + Intros; Apply le_antisym; Apply weight_le; + Intros; Rewrite (H n); XAuto. + Qed. + + Hints Resolve weight_le weight_eq : ltlc. + + Theorem weight_add_O : (t:?) (weight_map (wadd [_](0) (0)) t) = (weight_map [_](0) t). + XAuto. + Qed. + + Theorem weight_add_S : (t:?; m:?) (le (weight_map (wadd [_](0) (0)) t) (weight_map (wadd [_](0) (S m)) t)). + XAuto. + Qed. + + End weight_props. + + Hints Resolve weight_le weight_add_S : ltlc. + + Section tlt_props. (******************************************************) + + Theorem tlt_trans: (v,u,t:?) (tlt u v) -> (tlt v t) -> (tlt u t). + Unfold tlt; XEAuto. + Qed. + + Theorem tlt_tail_sx: (k:?; u,t:?) (tlt u (TTail k u t)). + Unfold tlt weight. + XElim k; Simpl; [ XElim b | Idtac ]; XAuto. + Qed. + + Theorem tlt_tail_dx: (k:?; u,t:?) (tlt t (TTail k u t)). + Unfold tlt weight. + XElim k; Simpl; [ Idtac | XAuto ]. + XElim b; Intros; Try Rewrite weight_add_O; [ Idtac | XAuto | XAuto ]. + EApply lt_le_trans; [ Apply lt_n_Sn | Apply le_n_S ]. + EApply le_trans; [ Rewrite <- (weight_add_O t); Apply weight_add_S | XAuto ]. + Qed. + + End tlt_props. + + Hints Resolve tlt_tail_sx tlt_tail_dx tlt_trans : ltlc. + + Section tlt_wf. (*********************************************************) + + Local Q: (T -> Prop) -> nat -> Prop := + [P;n] (t:?) (weight t) = n -> (P t). + + Remark q_ind: (P:T->Prop)((n:?) (Q P n)) -> (t:?) (P t). + Unfold Q; Intros. + Apply (H (weight t) t); XAuto. + Qed. + + Theorem tlt_wf_ind: (P:T->Prop) + ((t:?)((v:?)(tlt v t) -> (P v)) -> (P t)) -> + (t:?)(P t). + Unfold tlt; Intros. + XElimUsing q_ind t; Intros. + Apply lt_wf_ind; Clear n; Intros. + Unfold Q in H0; Unfold Q; Intros. + Rewrite <- H1 in H0; Clear H1. + Apply H; XEAuto. + Qed. + + End tlt_wf. diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_defs.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_defs.v new file mode 100644 index 000000000..d9b302aca --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_defs.v @@ -0,0 +1,302 @@ +Require Export pc3_defs. + +(*#* #stop record *) + + Record G : Set := { + f : nat -> nat; + f_inc : (n:?) (lt n (f n)) + }. + +(*#* #start record *) + +(*#* #caption "typing", + "well formed context sort", "well formed context binder", + "conversion rule", "typed sort", "typed reference to abbreviation", + "typed reference to abstraction", "typed binder", "typed application", + "typed cast" +*) + Inductive wf0 [g:G] : C -> Prop := + | wf0_sort : (m:?) (wf0 g (CSort m)) + | wf0_bind : (c:?; u,t:?) (ty0 g c u t) -> + (b:?) (wf0 g (CTail c (Bind b) u)) + with ty0 [g:G] : C -> T -> T -> Prop := +(* structural rules *) + | ty0_conv : (c:?; t2,t:?) (ty0 g c t2 t) -> + (u,t1:?) (ty0 g c u t1) -> (pc3 c t1 t2) -> + (ty0 g c u t2) +(* axiom rules *) + | ty0_sort : (c:?) (wf0 g c) -> + (m:?) (ty0 g c (TSort m) (TSort (f g m))) + | ty0_abbr : (c:?) (wf0 g c) -> + (n:?; d:?; u:?) (drop n (0) c (CTail d (Bind Abbr) u)) -> + (t:?) (ty0 g d u t) -> + (ty0 g c (TBRef n) (lift (S n) (0) t)) + | ty0_abst : (c:?) (wf0 g c) -> + (n:?; d:?; u:?) (drop n (0) c (CTail d (Bind Abst) u)) -> + (t:?) (ty0 g d u t) -> + (ty0 g c (TBRef n) (lift (S n) (0) u)) + | ty0_bind : (c:?; u,t:?) (ty0 g c u t) -> + (b:?; t1,t2:?) (ty0 g (CTail c (Bind b) u) t1 t2) -> + (t0:?) (ty0 g (CTail c (Bind b) u) t2 t0) -> + (ty0 g c (TTail (Bind b) u t1) (TTail (Bind b) u t2)) + | ty0_appl : (c:?; w,u:?) (ty0 g c w u) -> + (v,t:?) (ty0 g c v (TTail (Bind Abst) u t)) -> + (ty0 g c (TTail (Flat Appl) w v) + (TTail (Flat Appl) w (TTail (Bind Abst) u t)) + ) + | ty0_cast : (c:?; t1,t2:?) (ty0 g c t1 t2) -> + (t0:?) (ty0 g c t2 t0) -> + (ty0 g c (TTail (Flat Cast) t2 t1) t2). + + Hint wf0 : ltlc := Constructors wf0. + + Hint ty0 : ltlc := Constructors ty0. + +(*#* #caption "generation lemma of typing" #clauses ty0_gen_base *) + + Section ty0_gen_base. (***************************************************) + +(*#* #caption "generation lemma for sort" *) +(*#* #cap #cap c #alpha x in T, n in h *) + + Theorem ty0_gen_sort: (g:?; c:?; x:?; n:?) + (ty0 g c (TSort n) x) -> + (pc3 c (TSort (f g n)) x). + +(*#* #stop proof *) + + Intros until 1; InsertEq H '(TSort n); XElim H; Intros. +(* case 1 : ty0_conv *) + XEAuto. +(* case 2 : ty0_sort *) + Inversion H0; XAuto. +(* case 3 : ty0_abbr *) + Inversion H3. +(* case 4 : ty0_abst *) + Inversion H3. +(* case 5 : ty0_bind *) + Inversion H5. +(* case 6 : ty0_appl *) + Inversion H3. +(* case 7 : ty0_cast *) + Inversion H3. + Qed. + +(*#* #start proof *) + +(*#* #caption "generation lemma for bound reference" *) +(*#* #cap #cap c, e #alpha x in T, t in U, u in V, n in i *) + + Theorem ty0_gen_bref: (g:?; c:?; x:?; n:?) (ty0 g c (TBRef n) x) -> + (EX e u t | (pc3 c (lift (S n) (0) t) x) & + (drop n (0) c (CTail e (Bind Abbr) u)) & + (ty0 g e u t) + ) \/ + (EX e u t | (pc3 c (lift (S n) (0) u) x) & + (drop n (0) c (CTail e (Bind Abst) u)) & + (ty0 g e u t) + ). + +(*#* #stop proof *) + + Intros until 1; InsertEq H '(TBRef n); XElim H; Intros. +(* case 1 : ty0_conv *) + LApply H2; [ Clear H2; Intros H2 | XAuto ]. + XElim H2; Intros; XElim H2; XEAuto. +(* case 2 : ty0_sort *) + Inversion H0. +(* case 3 : ty0_abbr *) + Inversion H3 ; Rewrite H5 in H0; XEAuto. +(* case 4 : ty0_abst *) + Inversion H3; Rewrite H5 in H0; XEAuto. +(* case 5 : ty0_bind *) + Inversion H5. +(* case 6 : ty0_appl *) + Inversion H3. +(* case 7 : ty0_cast *) + Inversion H3. + Qed. + +(*#* #start proof *) + +(*#* #caption "generation lemma for binder" *) +(*#* #cap #cap c #alpha x in T, t1 in U1, t2 in U2, u in V, t in U, t0 in U3 *) + + Theorem ty0_gen_bind: (g:?; b:?; c:?; u,t1,x:?) (ty0 g c (TTail (Bind b) u t1) x) -> + (EX t2 t t0 | (pc3 c (TTail (Bind b) u t2) x) & + (ty0 g c u t) & + (ty0 g (CTail c (Bind b) u) t1 t2) & + (ty0 g (CTail c (Bind b) u) t2 t0) + ). + +(*#* #stop proof *) + + Intros until 1; InsertEq H '(TTail (Bind b) u t1); XElim H; Intros. +(* case 1 : ty0_conv *) + LApply H2; [ Clear H2; Intros H2 | XAuto ]. + XElim H2; XEAuto. +(* case 2 : ty0_sort *) + Inversion H0. +(* case 3 : ty0_abbr *) + Inversion H3. +(* case 4 : ty0_abst *) + Inversion H3. +(* case 5 : ty0_bind *) + Inversion H5. + Rewrite H7 in H1; Rewrite H7 in H3. + Rewrite H8 in H; Rewrite H8 in H1; Rewrite H8 in H3. + Rewrite H9 in H1; XEAuto. +(* case 6 : ty0_appl *) + Inversion H3. +(* case 7 : ty0_cast *) + Inversion H3. + Qed. + +(*#* #start proof *) + +(*#* #caption "generation lemma for application" *) +(*#* #cap #cap c #alpha x in T, v in U1, w in V1, u in V2, t in U2 *) + + Theorem ty0_gen_appl: (g:?; c:?; w,v,x:?) (ty0 g c (TTail (Flat Appl) w v) x) -> + (EX u t | (pc3 c (TTail (Flat Appl) w (TTail (Bind Abst) u t)) x) & + (ty0 g c v (TTail (Bind Abst) u t)) & + (ty0 g c w u) + ). + +(*#* #stop proof *) + + Intros until 1; InsertEq H '(TTail (Flat Appl) w v); XElim H; Intros. +(* case 1 : ty0_conv *) + LApply H2; [ Clear H2; Intros H2 | XAuto ]. + XElim H2; XEAuto. +(* case 2 : ty0_sort *) + Inversion H0. +(* case 3 : ty0_abbr *) + Inversion H3. +(* case 4 : ty0_abst *) + Inversion H3. +(* case 5 : ty0_bind *) + Inversion H5. +(* case 6 : ty0_appl *) + Inversion H3; Rewrite H5 in H; Rewrite H6 in H1; XEAuto. +(* case 7 : ty0_cast *) + Inversion H3. + Qed. + +(*#* #start proof *) + +(*#* #caption "generation lemma for cast" *) +(*#* #cap #cap c #alpha x in T, t2 in V, t1 in U *) + + Theorem ty0_gen_cast: (g:?; c:?; t1,t2,x:?) + (ty0 g c (TTail (Flat Cast) t2 t1) x) -> + (pc3 c t2 x) /\ (ty0 g c t1 t2). + +(*#* #stop proof *) + + Intros until 1; InsertEq H '(TTail (Flat Cast) t2 t1); XElim H; Intros. +(* case 1 : ty0_conv *) + LApply H2; [ Clear H2; Intros H2 | XAuto ]. + XElim H2; XEAuto. +(* case 2 : ty0_sort *) + Inversion H0. +(* case 3 : ty0_abbr *) + Inversion H3. +(* case 4 : ty0_abst *) + Inversion H3. +(* case 5 : ty0_bind *) + Inversion H5. +(* case 6 : ty0_appl *) + Inversion H3. +(* case 7 : ty0_cast *) + Inversion H3; Rewrite H5 in H; Rewrite H5 in H1; Rewrite H6 in H; XAuto. + Qed. + + End ty0_gen_base. + + Tactic Definition Ty0GenBase := + Match Context With + | [ H: (ty0 ?1 ?2 (TSort ?3) ?4) |- ? ] -> + LApply (ty0_gen_sort ?1 ?2 ?4 ?3); [ Clear H; Intros | XAuto ] + | [ H: (ty0 ?1 ?2 (TBRef ?3) ?4) |- ? ] -> + LApply (ty0_gen_bref ?1 ?2 ?4 ?3); [ Clear H; Intros H | XAuto ]; + XElim H; Intros H; XElim H; Intros + | [ H: (ty0 ?1 ?2 (TTail (Bind ?3) ?4 ?5) ?6) |- ? ] -> + LApply (ty0_gen_bind ?1 ?3 ?2 ?4 ?5 ?6); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (ty0 ?1 ?2 (TTail (Flat Appl) ?3 ?4) ?5) |- ? ] -> + LApply (ty0_gen_appl ?1 ?2 ?3 ?4 ?5); [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (ty0 ?1 ?2 (TTail (Flat Cast) ?3 ?4) ?5) |- ? ] -> + LApply (ty0_gen_cast ?1 ?2 ?4 ?3 ?5); [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + + Section wf0_props. (******************************************************) + + Theorem wf0_ty0 : (g:?; c:?; u,t:?) (ty0 g c u t) -> (wf0 g c). + Intros; XElim H; XAuto. + Qed. + + Hints Resolve wf0_ty0 : ltlc. + + Theorem wf0_drop_O : (c,e:?; h:?) (drop h (0) c e) -> + (g:?) (wf0 g c) -> (wf0 g e). + XElim c. +(* case 1 : CSort *) + Intros; DropGenBase; Rewrite H; XAuto. +(* case 2 : CTail k *) + Intros c IHc; XElim k; ( + XElim h; Intros; DropGenBase; + [ Rewrite H in H0; XAuto | Inversion H1; XEAuto ] ). + Qed. + + End wf0_props. + + Hints Resolve wf0_ty0 wf0_drop_O : ltlc. + + Tactic Definition Wf0Ty0 := + Match Context With + [ _: (ty0 ?1 ?2 ?3 ?4) |- ? ] -> + LApply (wf0_ty0 ?1 ?2 ?3 ?4); [ Intros H_x | XAuto ]; + Inversion_clear H_x. + + Tactic Definition Wf0DropO := + Match Context With + | [ _: (drop ?1 (0) ?2 ?3); _: (wf0 ?4 ?2) |- ? ] -> + LApply (wf0_drop_O ?2 ?3 ?1); [ Intros H_x | XAuto ]; + LApply (H_x ?4); [ Clear H_x; Intros | XAuto ]. + + Section wf0_facilities. (*************************************************) + + Theorem wf0_drop_wf0 : (g:?; c:?) (wf0 g c) -> + (b:?; e:?; u:?; h:?) + (drop h (0) c (CTail e (Bind b) u)) -> (wf0 g e). + Intros. + Wf0DropO; Inversion H1; XEAuto. + Qed. + + Theorem ty0_drop_wf0 : (g:?; c:?; t1,t2:?) (ty0 g c t1 t2) -> + (b:?; e:?; u:?; h:?) + (drop h (0) c (CTail e (Bind b) u)) -> (wf0 g e). + Intros. + EApply wf0_drop_wf0; [ Idtac | EApply H0 ]; XEAuto. + Qed. + + End wf0_facilities. + + Hints Resolve wf0_drop_wf0 ty0_drop_wf0 : ltlc. + + Tactic Definition DropWf0 := + Match Context With + | [ _: (ty0 ?1 ?2 ?3 ?4); + _: (drop ?5 (0) ?2 (CTail ?6 (Bind ?7) ?8)) |- ? ] -> + LApply (ty0_drop_wf0 ?1 ?2 ?3 ?4); [ Intros H_x | XAuto ]; + LApply (H_x ?7 ?6 ?8 ?5); [ Clear H_x; Intros | XAuto ] + | [ _: (wf0 ?1 ?2); + _: (drop ?5 (0) ?2 (CTail ?6 (Bind ?7) ?8)) |- ? ] -> + LApply (wf0_drop_wf0 ?1 ?2); [ Intros H_x | XAuto ]; + LApply (H_x ?7 ?6 ?8 ?5); [ Clear H_x; Intros | XAuto ]. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_gen_context.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_gen_context.v new file mode 100644 index 000000000..bf9217602 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_gen_context.v @@ -0,0 +1,227 @@ +(*#* #stop file *) + +Require lift_gen. +Require lift_props. +Require subst1_defs. +Require subst1_lift. +Require subst1_confluence. +Require drop_props. +Require csubst1_defs. +Require pc3_gen. +Require pc3_gen_context. +Require ty0_defs. +Require ty0_lift. + +(* NOTE: these break the recursion between ty0_sred_cpr0_pr0 and ty0_gen_lift *) + + Section ty0_gen_cabbr. (**************************************************) + + Tactic Definition IH d a0 a := + Match Context With + [ H: (e:?; u:?; d:?) ? -> (a0:?) ? -> (a:?) ? -> ? -> ? |- ? ] -> + LApply (H e u0 d); [ Clear H; Intros H | XAuto ]; + LApply (H a0); [ Clear H; Intros H | XAuto ]; + LApply (H a); [ Clear H; Intros H | XEAuto ]; + LApply H; [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + +(* NOTE: This can be generalized removing the last three premises *) + Theorem ty0_gen_cabbr: (g:?; c:?; t1,t2:?) (ty0 g c t1 t2) -> + (e:?; u:?; d:?) (drop d (0) c (CTail e (Bind Abbr) u)) -> + (a0:?) (csubst1 d u c a0) -> + (a:?) (wf0 g a) -> (drop (1) d a0 a) -> + (EX y1 y2 | (subst1 d u t1 (lift (1) d y1)) & + (subst1 d u t2 (lift (1) d y2)) & + (ty0 g a y1 y2) + ). + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + Repeat IH d a0 a; EApply ex3_2_intro; + [ XEAuto | XEAuto | EApply ty0_conv; Try EApply pc3_gen_cabbr; XEAuto ]. +(* case 2 : ty0_sort *) + EApply ex3_2_intro; Try Rewrite lift_sort; XAuto. +(* case 3 : ty0_abbr *) + Apply (lt_eq_gt_e n d0); Intros; Clear c t1 t2. +(* case 3.1 : n < d0 *) + Clear H1; DropDis; Rewrite minus_x_Sy in H1; [ DropGenBase | XAuto ]. + CSubst1Drop; Rewrite minus_x_Sy in H0; [ Idtac | XAuto ]. + CSubst1GenBase; Rewrite H0 in H8; Clear H0 x; Simpl in H9. + Rewrite (lt_plus_minus n d0) in H6; [ Idtac | XAuto ]. + DropDis; Rewrite H0 in H9; Clear H0 x0. + IH '(minus d0 (S n)) x1 x3. + Subst1Confluence; Rewrite H0 in H11; Clear H0 x0. + Pattern 3 d0; Rewrite (le_plus_minus_sym (S n) d0); [ Idtac | XAuto ]. + Pattern 4 d0; Rewrite (le_plus_minus (S n) d0); [ Idtac | XAuto ]. + EApply ex3_2_intro; + [ Rewrite lift_bref_lt | Rewrite lift_d | EApply ty0_abbr ]; XEAuto. +(* case 3.2 : n = d0 *) + Rewrite H7; Rewrite H7 in H0; Clear H2 H7 n. + DropDis; Inversion H0; Rewrite H8 in H4; Clear H0 H7 H8 e u0. + CSubst1Drop; DropDis. + EApply ex3_2_intro; + [ EApply subst1_single; Rewrite lift_free; Simpl; XEAuto + | Rewrite lift_free; Simpl; XEAuto + | XEAuto ]. +(* case 3.3 : n > d0 *) + Clear H2 H3 e; CSubst1Drop; DropDis. + Pattern 1 n; Rewrite (lt_plus_minus (0) n); [ Idtac | XEAuto ]. + Arith4c '(0) '(minus n (1)). + EApply ex3_2_intro; + [ Rewrite lift_bref_ge + | Rewrite lift_free; Simpl + | Pattern 2 n; Rewrite (minus_x_SO n) + ]; XEAuto. +(* case 4 : ty0_abst *) + Apply (lt_eq_gt_e n d0); Intros; Clear c t1 t2. +(* case 4.1 : n < d0 *) + Clear H1; DropDis; Rewrite minus_x_Sy in H1; [ DropGenBase | XAuto ]. + CSubst1Drop; Rewrite minus_x_Sy in H0; [ Idtac | XAuto ]. + CSubst1GenBase; Rewrite H0 in H8; Clear H0 x; Simpl in H9. + Rewrite (lt_plus_minus n d0) in H6; [ Idtac | XAuto ]. + DropDis; Rewrite H0 in H9; Clear H0 x0. + IH '(minus d0 (S n)) x1 x3. + Subst1Confluence; Rewrite H0 in H11; Clear H0 x0. + Pattern 3 d0; Rewrite (le_plus_minus_sym (S n) d0); [ Idtac | XAuto ]. + Pattern 4 d0; Rewrite (le_plus_minus (S n) d0); [ Idtac | XAuto ]. + EApply ex3_2_intro; + [ Rewrite lift_bref_lt | Rewrite lift_d | EApply ty0_abst ]; XEAuto. +(* case 4.2 : n = d0 *) + Rewrite H7; Rewrite H7 in H0; DropDis; Inversion H0. +(* case 4.3 : n > d0 *) + Clear H2 H3 e; CSubst1Drop; DropDis. + Pattern 1 n; Rewrite (lt_plus_minus (0) n); [ Idtac | XEAuto ]. + Arith4c '(0) '(minus n (1)). + EApply ex3_2_intro; + [ Rewrite lift_bref_ge + | Rewrite lift_free; Simpl + | Pattern 2 n; Rewrite (minus_x_SO n) + ]; XEAuto. +(* case 5 : ty0_bind *) + IH d a0 a; Clear H H1 H3 c t1 t2. + IH '(S d) '(CTail a0 (Bind b) (lift (1) d x0)) '(CTail a (Bind b) x0). + IH '(S d) '(CTail a0 (Bind b) (lift (1) d x0)) '(CTail a (Bind b) x0). + Subst1Confluence; Rewrite H4 in H11; Clear H4 x5. + EApply ex3_2_intro; Try Rewrite lift_bind; XEAuto. +(* case 6 : ty0_appl *) + Repeat IH d a0 a; Clear H H1 c t1 t2. + Subst1GenBase; SymEqual; LiftGenBase; Rewrite H in H8; Rewrite H11 in H1; Rewrite H12 in H7; Clear H H11 H12 x1 x4 x5. + Subst1Confluence; Rewrite H in H8; Clear H x6. + EApply ex3_2_intro; Try Rewrite lift_flat; + [ Idtac | EApply subst1_tail; [ Idtac | Rewrite lift_bind ] | Idtac ]; XEAuto. +(* case 7 : ty0_cast *) + Rename u into u0; Repeat IH d a0 a; Clear H H1 c t1 t2. + Subst1Confluence; Rewrite H in H10; Clear H x3. + EApply ex3_2_intro; [ Rewrite lift_flat | Idtac | Idtac ]; XEAuto. + Qed. + + End ty0_gen_cabbr. + + Section ty0_gen_cvoid. (**************************************************) + + Tactic Definition IH d a := + Match Context With + [ H: (e:?; u:?; d:?) ? -> (a:?) ? -> ? -> ? |- ? ] -> + LApply (H e u0 d); [ Clear H; Intros H | XAuto ]; + LApply (H a); [ Clear H; Intros H | XEAuto ]; + LApply H; [ Clear H; Intros H | XAuto ]; + XElim H; Intros. + +(* NOTE: This can be generalized removing the last two premises *) + Theorem ty0_gen_cvoid: (g:?; c:?; t1,t2:?) (ty0 g c t1 t2) -> + (e:?; u:?; d:?) (drop d (0) c (CTail e (Bind Void) u)) -> + (a:?) (wf0 g a) -> (drop (1) d c a) -> + (EX y1 y2 | t1 = (lift (1) d y1) & + t2 = (lift (1) d y2) & + (ty0 g a y1 y2) + ). + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + Repeat IH d a; Rewrite H0 in H3; Rewrite H7 in H3; Pc3Gen; XEAuto. +(* case 2 : ty0_sort *) + EApply ex3_2_intro; Try Rewrite lift_sort; XEAuto. +(* case 3 : ty0_abbr *) + Apply (lt_eq_gt_e n d0); Intros. +(* case 3.1 : n < d0 *) + DropDis; Rewrite minus_x_Sy in H7; [ DropGenBase | XAuto ]. + Rewrite (lt_plus_minus n d0) in H5; [ Idtac | XAuto ]. + DropDis; Rewrite H0 in H2; Clear H0 H1 u. + IH '(minus d0 (S n)) x1; Rewrite H1; Clear H1 t. + LiftGen; Rewrite <- H0 in H2; Clear H0 x2. + Rewrite <- lift_d; [ Idtac | XAuto ]. + Rewrite <- le_plus_minus; [ Idtac | XAuto ]. + EApply ex3_2_intro; [ Rewrite lift_bref_lt | Idtac | EApply ty0_abbr ]; XEAuto. +(* case 3.2 : n = d0 *) + Rewrite H6 in H0; DropDis; Inversion H0. +(* case 3.3 : n > d0 *) + Clear H2 H3 c e t1 t2 u0; DropDis. + Pattern 1 n; Rewrite (lt_plus_minus (0) n); [ Idtac | XEAuto ]. + Arith4c '(0) '(minus n (1)). + EApply ex3_2_intro; + [ Rewrite lift_bref_ge + | Rewrite lift_free; Simpl + | Pattern 2 n; Rewrite (minus_x_SO n) + ]; XEAuto. +(* case 4 : ty0_abst *) + Apply (lt_eq_gt_e n d0); Intros. +(* case 4.1 : n < d0 *) + DropDis; Rewrite minus_x_Sy in H7; [ DropGenBase | XAuto ]. + Rewrite (lt_plus_minus n d0) in H5; [ Idtac | XAuto ]. + DropDis; Rewrite H0; Rewrite H0 in H2; Clear H0 H1 u. + IH '(minus d0 (S n)) x1; Clear H1 t. + LiftGen; Rewrite <- H0 in H2; Clear H0 x2. + Rewrite <- lift_d; [ Idtac | XAuto ]. + Rewrite <- le_plus_minus; [ Idtac | XAuto ]. + EApply ex3_2_intro; [ Rewrite lift_bref_lt | Idtac | EApply ty0_abst ]; XEAuto. +(* case 4.2 : n = d0 *) + Rewrite H6 in H0; DropDis; Inversion H0. +(* case 4.3 : n > d0 *) + Clear H2 H3 c e t1 t2 u0; DropDis. + Pattern 1 n; Rewrite (lt_plus_minus (0) n); [ Idtac | XEAuto ]. + Arith4c '(0) '(minus n (1)). + EApply ex3_2_intro; + [ Rewrite lift_bref_ge + | Rewrite lift_free; [ Simpl | Simpl | Idtac ] + | Pattern 2 n; Rewrite (minus_x_SO n) + ]; XEAuto. +(* case 5 : ty0_bind *) + IH d a; Rewrite H0; Rewrite H0 in H2; Rewrite H0 in H4; Clear H H0 H1 H3 H8 u t. + IH '(S d) '(CTail a (Bind b) x0); Rewrite H; Rewrite H in H2; Clear H H0 t3 t4. + IH '(S d) '(CTail a (Bind b) x0); Rewrite H; Clear H t0. + LiftGen; Rewrite <- H in H2; Clear H x5. + LiftTailRwBack; XEAuto. +(* case 6 : ty0_appl *) + IH d a; Rewrite H2; Clear H H1 H2 v. + LiftGenBase; Rewrite H in H7; Rewrite H1; Rewrite H1 in H0; Rewrite H2; Clear H H1 H2 u t x1. + IH d a; Rewrite H; Clear H w. + LiftGen; Rewrite <- H in H1; Clear H x4. + LiftTailRwBack; XEAuto. +(* case 7 : ty0_cast *) + Rename u into u0. + IH d a; Rewrite H2 in H0; Rewrite H2; Clear H H1 H2 H6 t3 t4. + IH d a; Rewrite H; Clear H t0. + LiftGen; Rewrite <- H in H1; Clear H x3. + LiftTailRwBack; XEAuto. + Qed. + + End ty0_gen_cvoid. + + Tactic Definition Ty0GenContext := + Match Context With + | [ H: (ty0 ?1 (CTail ?2 (Bind Abbr) ?3) ?4 ?5) |- ? ] -> + LApply (ty0_gen_cabbr ?1 (CTail ?2 (Bind Abbr) ?3) ?4 ?5); [ Clear H; Intros H | XAuto ]; + LApply (H ?2 ?3 (0)); [ Clear H; Intros H | XAuto ]; + LApply (H (CTail ?2 (Bind Abbr) ?3)); [ Clear H; Intros H | XAuto ]; + LApply (H ?2); [ Clear H; Intros H | XAuto ]; + LApply H; [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | [ H: (ty0 ?1 (CTail ?2 (Bind Void) ?3) ?4 ?5) |- ? ] -> + LApply (ty0_gen_cvoid ?1 (CTail ?2 (Bind Void) ?3) ?4 ?5); [ Clear H; Intros H | XAuto ]; + LApply (H ?2 ?3 (0)); [ Clear H; Intros H | XAuto ]; + LApply (H ?2); [ Clear H; Intros H | XAuto ]; + LApply H; [ Clear H; Intros H | XAuto ]; + XElim H; Intros + | _ -> Ty0GenBase. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_lift.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_lift.v new file mode 100644 index 000000000..107a4ca89 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_lift.v @@ -0,0 +1,65 @@ +Require lift_props. +Require drop_props. +Require pc3_props. +Require ty0_defs. + +(*#* #caption "main properties of typing" #clauses ty0_props *) + + Section ty0_lift. (*******************************************************) + +(*#* #caption "lift preserves types" *) +(*#* #cap #cap t1, t2 #alpha c in C1, e in C2, d in i *) + + Theorem ty0_lift : (g:?; e:?; t1,t2:?) (ty0 g e t1 t2) -> + (c:?) (wf0 g c) -> (d,h:?) (drop h d c e) -> + (ty0 g c (lift h d t1) (lift h d t2)). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + XEAuto. +(* case 2 : ty0_sort *) + Repeat Rewrite lift_sort; XAuto. +(* case 3 : ty0_abbr *) + Apply (lt_le_e n d0); Intros; DropDis. +(* case 3.1 : n < d0 *) + Rewrite minus_x_Sy in H4; [ Idtac | XAuto ]. + DropGenBase; Rewrite H4 in H0; Clear H4 x. + Rewrite lift_bref_lt; [ Idtac | XAuto ]. + Arith8 d0 '(S n); Rewrite lift_d; [ Arith8' d0 '(S n) | XAuto ]. + EApply ty0_abbr; XEAuto. +(* case 3.2 : n >= d0 *) + Rewrite lift_bref_ge; [ Idtac | XAuto ]. + Arith7' n; Rewrite lift_free; [ Idtac | Simpl; XAuto | XAuto ]. + Rewrite (plus_sym h (S n)); Simpl; XEAuto. +(* case 4: ty0_abst *) + Apply (lt_le_e n d0); Intros; DropDis. +(* case 4.1 : n < d0 *) + Rewrite minus_x_Sy in H4; [ Idtac | XAuto ]. + DropGenBase; Rewrite H4 in H0; Clear H4 x. + Rewrite lift_bref_lt; [ Idtac | XAuto ]. + Arith8 d0 '(S n); Rewrite lift_d; [ Arith8' d0 '(S n) | XAuto ]. + EApply ty0_abst; XEAuto. +(* case 4.2 : n >= d0 *) + Rewrite lift_bref_ge; [ Idtac | XAuto ]. + Arith7' n; Rewrite lift_free; [ Idtac | Simpl; XAuto | XAuto ]. + Rewrite (plus_sym h (S n)); Simpl; XEAuto. +(* case 5: ty0_bind *) + LiftTailRw; Simpl; EApply ty0_bind; XEAuto. +(* case 6: ty0_appl *) + LiftTailRw; Simpl; EApply ty0_appl; [ Idtac | Rewrite <- lift_bind ]; XEAuto. +(* case 7: ty0_cast *) + LiftTailRw; XEAuto. + Qed. + + End ty0_lift. + + Hints Resolve ty0_lift : ltlc. + + Tactic Definition Ty0Lift b u := + Match Context With + [ H: (ty0 ?1 ?2 ?3 ?4) |- ? ] -> + LApply (ty0_lift ?1 ?2 ?3 ?4); [ Intros H_x | XAuto ]; + LApply (H_x (CTail ?2 (Bind b) u)); [ Clear H_x; Intros H_x | XEAuto ]; + LApply (H_x (0) (1)); [ Clear H_x; Intros | XAuto ]. diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_props.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_props.v new file mode 100644 index 000000000..d51266a54 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_props.v @@ -0,0 +1,107 @@ +Require drop_props. +Require pc3_props. +Require ty0_defs. +Require ty0_lift. + + Section ty0_correct. (****************************************************) + +(*#* #caption "correctness of types" *) +(*#* #cap #cap c, t1, t2 #alpha t in T3 *) + + Theorem ty0_correct : (g:?; c:?; t1,t2:?) + (ty0 g c t1 t2) -> (EX t | (ty0 g c t2 t)). + +(*#* #stop file *) + + Intros; XElim H; Intros. +(* case 1 : ty0_conv *) + XEAuto. +(* case 2 : ty0_sort *) + XEAuto. +(* case 3 : ty0_abbr *) + XElim H2; XEAuto. +(* case 4 : ty0_abst *) + XEAuto. +(* case 5 : ty0_bind *) + XElim H4; XEAuto. +(* case 6 : ty0_appl *) + XElim H0; XElim H2; Intros. + Ty0GenBase; XEAuto. +(* case 7 : ty0_cast *) + XAuto. + Qed. + + End ty0_correct. + + Tactic Definition Ty0Correct := + Match Context With + [ _: (ty0 ?1 ?2 ?3 ?4) |- ? ] -> + LApply (ty0_correct ?1 ?2 ?3 ?4); [ Intros H_x | XAuto ]; + XElim H_x; Intros. + +(*#* #start file *) + + Section ty0_shift. (******************************************************) + +(*#* #caption "shift lemma for types" *) +(*#* #cap #cap t1, t2 #alpha c in C1, e in C2 *) + + Theorem ty0_shift : (h:?; c,e:?) (drop h (0) c e) -> + (g:?; t1,t2:?) (ty0 g c t1 t2) -> (wf0 g e) -> + (ty0 g e (app c h t1) (app c h t2)). + +(*#* #stop file *) + + XElim h. +(* case 1 : h = 0 *) + Intros; DropGenBase; Rewrite <- H. + Repeat Rewrite app_O; XAuto. +(* case 2 : h > 0 *) + Intros h IHh; XElim c. +(* case 2.1 : CSort *) + Intros; DropGenBase; Rewrite H. + Simpl; XAuto. +(* case 2.2 : CTail k *) + Intros c IHc; Clear IHc; XElim k; Intros; Wf0Ty0. + DropGenBase; Move H0 after H2; Ty0Correct. + Simpl; Apply IHh; [ Idtac | EApply ty0_bind | Idtac ]; XEAuto. + Qed. + + End ty0_shift. + + Hints Resolve ty0_shift : ltlc. + +(*#* #start file *) + + Section ty0_unique. (*****************************************************) + +(*#* #caption "uniqueness of types" *) +(*#* #cap #cap c, t1, t2 #alpha u in T *) + + Theorem ty0_unique : (g:?; c:?; u,t1:?) (ty0 g c u t1) -> + (t2:?) (ty0 g c u t2) -> (pc3 c t1 t2). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + XEAuto. +(* case 2 : ty0_sort *) + Ty0GenBase; XAuto. +(* case 3 : ty0_abbr *) + Ty0GenBase; DropDis; Inversion H4. + Rewrite H7 in H2; Rewrite H8 in H2; XEAuto. +(* case 4 : ty0_abst *) + Ty0GenBase; DropDis; Inversion H4. + Rewrite H7 in H2; Rewrite H8 in H2; XEAuto. +(* case 5 : ty0_bind *) + Ty0GenBase; XEAuto. +(* case 6 : ty0_appl *) + Ty0GenBase; EApply pc3_t; [ Idtac | EApply H3 ]; XEAuto. +(* case 7 : ty0_cast *) + Ty0GenBase; XEAuto. + Qed. + + End ty0_unique. + + Hints Resolve ty0_unique : ltlc. diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_sred.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_sred.v new file mode 100644 index 000000000..dc185a95a --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_sred.v @@ -0,0 +1,250 @@ +Require lift_gen. +Require subst1_gen. +Require csubst1_defs. +Require pr0_lift. +Require pr0_subst1. +Require cpr0_defs. +Require cpr0_props. +Require pc3_props. +Require pc3_gen. +Require ty0_defs. +Require ty0_lift. +Require ty0_props. +Require ty0_subst0. +Require ty0_gen_context. +Require csub0_defs. + +(*#* #caption "subject reduction" #clauses *) + +(*#* #stop file *) + + Section ty0_sred_cpr0_pr0. (**********************************************) + + Tactic Definition IH H c2 t2 := + LApply (H c2); [ Intros H_x | XEAuto ]; + LApply H_x; [ Clear H_x; Intros H_x | XAuto ]; + LApply (H_x t2); [ Clear H_x; Intros | XEAuto ]. + + Tactic Definition IH0 := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (ty0 ?1 ?2 ?3 ?4) |- ? ] -> + IH H1 ?5 ?3. + + Tactic Definition IH0c := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (ty0 ?1 ?2 ?3 ?4) |- ? ] -> + IH H1 ?5 ?3; Clear H1. + + Tactic Definition IH0B := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?6) ?7) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (ty0 ?1 (CTail ?2 (Bind ?6) ?7) ?3 ?4) |- ? ] -> + IH H1 '(CTail ?5 (Bind ?6) ?7) ?3. + + Tactic Definition IH0Bc := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?6) ?7) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (ty0 ?1 (CTail ?2 (Bind ?6) ?7) ?3 ?4) |- ? ] -> + IH H1 '(CTail ?5 (Bind ?6) ?7) ?3; Clear H1. + + Tactic Definition IH1 := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] -> + IH H1 ?5 ?6. + + Tactic Definition IH1c := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] -> + IH H1 ?5 ?6; Clear H1. + + Tactic Definition IH1Bc := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] -> + IH H1 '(CTail ?5 (Bind ?7) ?8) ?6; Clear H1. + + Tactic Definition IH1BLc := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 (lift ?10 ?11 ?3) t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] -> + IH H1 '(CTail ?5 (Bind ?7) ?8) '(lift ?10 ?11 ?6); Clear H1. + + Tactic Definition IH1T := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 (TTail ?7 ?8 ?3) t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] -> + IH H1 ?5 '(TTail ?7 ?8 ?6). + + Tactic Definition IH1T2c := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 (TTail ?7 ?8 ?3) t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6); H4: (pr0 ?8 ?9) |- ? ] -> + IH H1 ?5 '(TTail ?7 ?9 ?6); Clear H1. + + Tactic Definition IH3B := + Match Context With + [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4); + H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6); H4: (pr0 ?8 ?9) |- ? ] -> + IH H1 '(CTail ?5 (Bind ?7) ?9) ?6. + +(*#* #start file *) + +(*#* #caption "base case" *) +(*#* #cap #cap c1, c2 #alpha t1 in T, t2 in T1, t in T2 *) + + Theorem ty0_sred_cpr0_pr0 : (g:?; c1:?; t1,t:?) (ty0 g c1 t1 t) -> + (c2:?) (wf0 g c2) -> (cpr0 c1 c2) -> + (t2:?) (pr0 t1 t2) -> (ty0 g c2 t2 t). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : ty0_conv *) + IH1c; IH0c; EApply ty0_conv; XEAuto. +(* case 2 : ty0_sort *) + Inversion H2; XAuto. +(* case 3 : ty0_abbr *) + Inversion H5; Cpr0Drop; IH1c; XEAuto. +(* case 4 : ty0_abst *) + Intros; Inversion H5; Cpr0Drop; IH0; IH1. + EApply ty0_conv; + [ EApply ty0_lift; [ Idtac | XAuto | XEAuto ] + | EApply ty0_abst + | EApply pc3_lift ]; XEAuto. +(* case 5 : ty0_bind *) + Intros; Inversion H7; Clear H7. +(* case 5.1 : pr0_refl *) + IH0c; IH0Bc; IH0Bc. + EApply ty0_bind; XEAuto. +(* case 5.2 : pr0_cont *) + IH0; IH0B; Ty0Correct; IH3B; Ty0Correct. + EApply ty0_conv; [ EApply ty0_bind | EApply ty0_bind | Idtac ]; XEAuto. +(* case 5.3 : pr0_delta *) + Rewrite <- H8 in H1; Rewrite <- H8 in H2; + Rewrite <- H8 in H3; Rewrite <- H8 in H4; Clear H8 b. + IH0; IH0B; Ty0Correct; IH3B; Ty0Correct. + EApply ty0_conv; [ EApply ty0_bind | EApply ty0_bind | Idtac ]; XEAuto. +(* case 5.4 : pr0_zeta *) + Rewrite <- H11 in H1; Rewrite <- H11 in H2; Clear H8 H9 H10 H11 b0 t2 t7 u0. + IH0; IH1BLc; Move H3 after H8; IH0Bc; Ty0Correct; Move H8 after H4; Clear H H0 H1 H3 H6 c c1 t t1; + NewInduction b. +(* case 5.4.1 : Abbr *) + Ty0GenContext; Subst1Gen; LiftGen; Rewrite H in H1; Clear H x0. + EApply ty0_conv; + [ EApply ty0_bind; XEAuto | XEAuto + | EApply pc3_pr3_x; + EApply (pr3_t (TTail (Bind Abbr) u (lift (1) (0) x1))); XEAuto ]. +(* case 5.4.2 : Abst *) + EqFalse. +(* case 5.4.3 : Void *) + Ty0GenContext; Rewrite H0; Rewrite H0 in H2; Clear H0 t3. + LiftGen; Rewrite <- H in H1; Clear H x0. + EApply ty0_conv; [ EApply ty0_bind; XEAuto | XEAuto | XAuto ]. +(* case 6 : ty0_appl *) + Intros; Inversion H5; Clear H5. +(* case 6.1 : pr0_refl *) + IH0c; IH0c; EApply ty0_appl; XEAuto. +(* case 6.2 : pr0_cont *) + Clear H6 H7 H8 H9 c1 k t t1 t2 t3 u1. + IH0; Ty0Correct; Ty0GenBase; IH1c; IH0; IH1c. + EApply ty0_conv; + [ EApply ty0_appl; [ XEAuto | EApply ty0_bind; XEAuto ] + | EApply ty0_appl; XEAuto + | XEAuto ]. +(* case 6.3 : pr0_beta *) + Rewrite <- H7 in H1; Rewrite <- H7 in H2; Clear H6 H7 H9 c1 t t1 t2 v v1. + IH1T; IH0c; Ty0Correct; Ty0GenBase; IH0; IH1c. + Move H5 after H13; Ty0GenBase; Pc3Gen; Repeat CSub0Ty0. + EApply ty0_conv; + [ Apply ty0_appl; [ Idtac | EApply ty0_bind ] + | EApply ty0_bind + | Apply (pc3_t (TTail (Bind Abbr) v2 t0)) + ]; XEAuto. +(* case 6.4 : pr0_delta *) + Rewrite <- H7 in H1; Rewrite <- H7 in H2; Clear H6 H7 H11 c1 t t1 t2 v v1. + IH1T2c; Clear H1; Ty0Correct; NonLinear; Ty0GenBase; IH1; IH0c. + Move H5 after H1; Ty0GenBase; Pc3Gen; Rewrite lift_bind in H0. + Move H1 after H0; Ty0Lift b u2; Rewrite lift_bind in H17. + Ty0GenBase. + EApply ty0_conv; + [ Apply ty0_appl; [ Idtac | EApply ty0_bind ]; XEAuto + | EApply ty0_bind; + [ Idtac + | EApply ty0_appl; [ EApply ty0_lift | EApply ty0_conv ] + | EApply ty0_appl; [ EApply ty0_lift | EApply ty0_bind ] + ]; XEAuto + | Idtac ]. + Rewrite <- lift_bind; Apply pc3_pc1; + Apply (pc1_u (TTail (Flat Appl) v2 (TTail (Bind b) u2 (lift (1) (0) (TTail (Bind Abst) u t0))))); XAuto. +(* case 7 : ty0_cast *) + Intros; Inversion H5; Clear H5. +(* case 7.1 : pr0_refl *) + IH0c; IH0c; EApply ty0_cast; XEAuto. +(* case 7.2 : pr0_cont *) + Clear H6 H7 H8 H9 c1 k u1 t t1 t4 t5. + IH0; IH1c; IH1c. + EApply ty0_conv; + [ XEAuto + | EApply ty0_cast; [ EApply ty0_conv; XEAuto | XEAuto ] + | XAuto ]. +(* case 7.3 : pr0_eps *) + XAuto. + Qed. + + End ty0_sred_cpr0_pr0. + + Section ty0_sred_pr3. (**********************************************) + + Theorem ty0_sred_pr1 : (c:?; t1,t2:?) (pr1 t1 t2) -> + (g:?; t:?) (ty0 g c t1 t) -> + (ty0 g c t2 t). + Intros until 1; XElim H; Intros. +(* case 1 : pr1_r *) + XAuto. +(* case 2 : pr1_u *) + EApply H1; EApply ty0_sred_cpr0_pr0; XEAuto. + Qed. + + Theorem ty0_sred_pr2 : (c:?; t1,t2:?) (pr2 c t1 t2) -> + (g:?; t:?) (ty0 g c t1 t) -> + (ty0 g c t2 t). + Intros until 1; XElim H; Intros. +(* case 1 : pr2_pr0 *) + EApply ty0_sred_cpr0_pr0; XEAuto. +(* case 2 : pr2_u *) + XEAuto. + Qed. + +(*#* #start file *) + +(*#* #caption "general case" *) +(*#* #cap #cap c #alpha t1 in T, t2 in T1, t in T2 *) + + Theorem ty0_sred_pr3 : (c:?; t1,t2:?) (pr3 c t1 t2) -> + (g:?; t:?) (ty0 g c t1 t) -> + (ty0 g c t2 t). + +(*#* #stop file *) + + Intros until 1; XElim H; Intros. +(* case 1 : pr3_r *) + XAuto. +(* case 2 : pr3_u *) + EApply H1; EApply ty0_sred_pr2; XEAuto. + Qed. + + End ty0_sred_pr3. + + Tactic Definition Ty0SRed := + Match Context With + | [ H1: (pr3 ?1 ?2 ?3); H2: (ty0 ?4 ?1 ?2 ?5) |- ? ] -> + LApply (ty0_sred_pr3 ?1 ?2 ?3); [ Intros H_x | XAuto ]; + LApply (H_x ?4 ?5); [ Clear H2 H_x; Intros | XAuto ]. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_sred_props.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_sred_props.v new file mode 100644 index 000000000..6fb7f17e1 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_sred_props.v @@ -0,0 +1,175 @@ +Require lift_props. +Require drop_props. +Require pc3_props. +Require pc3_gen. +Require ty0_defs. +Require ty0_props. +Require ty0_sred. + +(*#* #caption "corollaries of subject reduction" #clauses *) + +(*#* #stop file *) + + Section ty0_gen. (********************************************************) + + Tactic Definition IH e := + Match Context With + [ H0: (t:?; d:?) ?1 = (lift ?2 d t) -> ?; H1: ?1 = (lift ?2 ?3 ?4) |- ? ] -> + LApply (H0 ?4 ?3); [ Clear H0 H1; Intros H0 | XAuto ]; + LApply (H0 e); [ Clear H0; Intros H0 | XEAuto ]; + LApply H0; [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros. + +(*#* #start file *) + +(*#* #caption "generation lemma for lift" *) +(*#* #cap #cap t2 #alpha c in C1, e in C2, t1 in T, x in T1, d in i *) + + Theorem ty0_gen_lift : (g:?; c:?; t1,x:?; h,d:?) + (ty0 g c (lift h d t1) x) -> + (e:?) (wf0 g e) -> (drop h d c e) -> + (EX t2 | (pc3 c (lift h d t2) x) & (ty0 g e t1 t2)). + +(*#* #stop file *) + + Intros until 1; InsertEq H '(lift h d t1); + UnIntro H d; UnIntro H t1; XElim H; Intros; + Rename x0 into t3; Rename x1 into d0. +(* case 1 : ty0_conv *) + IH e; XEAuto. +(* case 2 : ty0_sort *) + LiftGenBase; Rewrite H0; Clear H0 t. + EApply ex2_intro; [ Rewrite lift_sort; XAuto | XAuto ]. +(* case 3 : ty0_abbr *) + Apply (lt_le_e n d0); Intros. +(* case 3.1 : n < d0 *) + LiftGenBase; DropS; Rewrite H3; Clear H3 t3. + Rewrite (le_plus_minus (S n) d0); [ Idtac | XAuto ]. + Rewrite (lt_plus_minus n d0) in H5; [ DropDis; IH x1 | XAuto ]. + EApply ex2_intro; + [ Rewrite lift_d; [ EApply pc3_lift; XEAuto | XEAuto ] + | EApply ty0_abbr; XEAuto ]. +(* case 3.2 : n >= d0 *) + Apply (lt_le_e n (plus d0 h)); Intros. +(* case 3.2.1 : n < d0 + h *) + LiftGenBase. +(* case 3.2.2 : n >= d0 + h *) + Rewrite (le_plus_minus_sym h n) in H3; [ Idtac | XEAuto ]. + LiftGenBase; DropDis; Rewrite H3; Clear H3 t3. + EApply ex2_intro; [ Idtac | EApply ty0_abbr; XEAuto ]. + Rewrite lift_free; [ Idtac | XEAuto | XAuto ]. + Rewrite <- plus_n_Sm; Rewrite <- le_plus_minus; XEAuto. +(* case 4 : ty0_abst *) + Apply (lt_le_e n d0); Intros. +(* case 4.1 : n < d0 *) + LiftGenBase; Rewrite H3; Clear H3 t3. + Rewrite (le_plus_minus (S n) d0); [ Idtac | XAuto ]. + Rewrite (lt_plus_minus n d0) in H5; [ DropDis; Rewrite H0; IH x1 | XAuto ]. + EApply ex2_intro; [ Rewrite lift_d | EApply ty0_abst ]; XEAuto. +(* case 4.2 : n >= d0 *) + Apply (lt_le_e n (plus d0 h)); Intros. +(* case 4.2.1 : n < d0 + h *) + LiftGenBase. +(* case 4.2.2 : n >= d0 + h *) + Rewrite (le_plus_minus_sym h n) in H3; [ Idtac | XEAuto ]. + LiftGenBase; DropDis; Rewrite H3; Clear H3 t3. + EApply ex2_intro; [ Idtac | EApply ty0_abst; XEAuto ]. + Rewrite lift_free; [ Idtac | XEAuto | XAuto ]. + Rewrite <- plus_n_Sm; Rewrite <- le_plus_minus; XEAuto. +(* case 5 : ty0_bind *) + LiftGenBase; Rewrite H5; Rewrite H8; Rewrite H8 in H2; Clear H5 t3. + Move H0 after H2; IH e; IH '(CTail e (Bind b) x0); Ty0Correct. + EApply ex2_intro; [ Rewrite lift_bind; XEAuto | XEAuto ]. +(* case 6 : ty0_appl *) + LiftGenBase; Rewrite H3; Rewrite H6; Clear H3 c t3 x y. + IH e; IH e; Pc3Gen; Pc3T; Pc3Gen; Pc3T. + Move H3 after H12; Ty0Correct; Ty0SRed; Ty0GenBase; Wf0Ty0. + EApply ex2_intro; + [ Rewrite lift_flat; Apply pc3_thin_dx; + Rewrite lift_bind; Apply pc3_tail_21; [ EApply pc3_pr3_x | Idtac ] + | EApply ty0_appl; + [ EApply ty0_conv + | EApply ty0_conv; [ EApply ty0_bind | Idtac | Idtac ] ] + ]; XEAuto. +(* case 7 : ty0_cast *) + LiftGenBase; Rewrite H3; Rewrite H6; Rewrite H6 in H0. + IH e; IH e; Pc3Gen; XEAuto. + Qed. + + End ty0_gen. + + Tactic Definition Ty0Gen := + Match Context With + | [ H0: (ty0 ?1 ?2 (lift ?3 ?4 ?5) ?6); + H1: (drop ?3 ?4 ?2 ?7) |- ? ] -> + LApply (ty0_gen_lift ?1 ?2 ?5 ?6 ?3 ?4); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7); [ Clear H0; Intros H0 | XEAuto ]; + LApply H0; [ Clear H0 H1; Intros H0 | XAuto ]; + XElim H0; Intros + | [ H0: (ty0 ?1 ?2 (lift ?3 ?4 ?5) ?6); + _ : (wf0 ?1 ?7) |- ? ] -> + LApply (ty0_gen_lift ?1 ?2 ?5 ?6 ?3 ?4); [ Clear H0; Intros H0 | XAuto ]; + LApply (H0 ?7); [ Clear H0; Intros H0 | XAuto ]; + LApply H0; [ Clear H0; Intros H0 | XAuto ]; + XElim H0; Intros + | _ -> Ty0GenContext. + + Section ty0_sred_props. (*************************************************) + +(*#* #start file *) + +(*#* #caption "drop preserves well-formedness" *) +(*#* #cap #alpha c in C1, e in C2, d in i *) + + Theorem wf0_drop : (c,e:?; d,h:?) (drop h d c e) -> + (g:?) (wf0 g c) -> (wf0 g e). + +(*#* #stop proof *) + + XElim c. +(* case 1 : CSort *) + Intros; DropGenBase; Rewrite H; XAuto. +(* case 2 : CTail k *) + Intros c IHc; XElim k; ( + XElim d; + [ XEAuto + | Intros d IHd; Intros; + DropGenBase; Rewrite H; Rewrite H1 in H0; Clear IHd H H1 e t; + Inversion H0; Clear H3 H4 b0 u ]). +(* case 2.1 : Bind, d > 0 *) + Ty0Gen; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "type reduction" *) +(*#* #cap #cap c, t1, t2 #alpha u in T *) + + Theorem ty0_tred : (g:?; c:?; u,t1:?) (ty0 g c u t1) -> + (t2:?) (pr3 c t1 t2) -> (ty0 g c u t2). + +(*#* #stop proof *) + + Intros; Ty0Correct; Ty0SRed; EApply ty0_conv; XEAuto. + Qed. + +(*#* #start proof *) + +(*#* #caption "subject conversion" *) +(*#* #cap #cap c, u1, u2, t1, t2 *) + + Theorem ty0_sconv : (g:?; c:?; u1,t1:?) (ty0 g c u1 t1) -> + (u2,t2:?) (ty0 g c u2 t2) -> + (pc3 c u1 u2) -> (pc3 c t1 t2). + +(*#* #stop file *) + + Intros; Pc3Confluence; Repeat Ty0SRed; XEAuto. + Qed. + + + End ty0_sred_props. + +(*#* #start file *) + +(*#* #single *) diff --git a/helm/coq-contribs/LAMBDA-TYPES/ty0_subst0.v b/helm/coq-contribs/LAMBDA-TYPES/ty0_subst0.v new file mode 100644 index 000000000..3e4703200 --- /dev/null +++ b/helm/coq-contribs/LAMBDA-TYPES/ty0_subst0.v @@ -0,0 +1,333 @@ +Require drop_props. +Require csubst0_defs. +Require pc3_props. +Require pc3_subst0. +Require ty0_defs. +Require ty0_lift. +Require ty0_props. + + Section ty0_fsubst0. (****************************************************) + +(*#* #stop macro *) + + Tactic Definition IH H0 v1 v2 v3 v4 v5 := + LApply (H0 v1 v2 v3 v4); [ Intros H_x | XEAuto ]; + LApply H_x; [ Clear H_x; Intros H_x | XEAuto ]; + LApply (H_x v5); [ Clear H_x; Intros | XEAuto ]. + + Tactic Definition IHT := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 ?1 ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) ?1 (CTail e (Bind Abbr) u0)) -> ?; + _: (subst0 ?4 ?5 ?2 ?6); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H ?4 ?5 ?1 ?6 ?9. + + Tactic Definition IHTb1 := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (subst0 ?4 ?5 ?10 ?6); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?1 (Bind ?11) ?6) ?2 ?9. + + Tactic Definition IHTb2 := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (subst0 (s (Bind ?11) ?4) ?5 ?2 ?6); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?1 (Bind ?11) ?10) ?6 ?9. + + Tactic Definition IHC := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 ?1 ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) ?1 (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H ?4 ?5 ?6 ?2 ?9. + + Tactic Definition IHCb := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?6 (Bind ?11) ?10) ?2 ?9. + + Tactic Definition IHTTb := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (subst0 ?4 ?5 ?10 ?6); + _: (subst0 (s (Bind ?11) ?4) ?5 ?2 ?7); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?1 (Bind ?11) ?6) ?7 ?9. + + Tactic Definition IHCT := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 ?1 ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) ?1 (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (subst0 ?4 ?5 ?2 ?7); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H ?4 ?5 ?6 ?7 ?9. + + Tactic Definition IHCTb1 := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (subst0 ?4 ?5 ?10 ?7); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?6 (Bind ?11) ?7) ?2 ?9. + + Tactic Definition IHCTb2 := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (subst0 (s (Bind ?11) ?4) ?5 ?2 ?7); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?6 (Bind ?11) ?10) ?7 ?9. + + Tactic Definition IHCTTb := + Match Context With + [ H: (i:nat; u0:T; c2:C; t2:T) (fsubst0 i u0 (CTail ?1 (Bind ?11) ?10) ?2 c2 t2) -> + (wf0 ?3 c2) -> + (e:C) (drop i (0) (CTail ?1 (Bind ?11) ?10) (CTail e (Bind Abbr) u0)) -> ?; + _: (csubst0 ?4 ?5 ?1 ?6); + _: (subst0 ?4 ?5 ?10 ?7); + _: (subst0 (s (Bind ?11) ?4) ?5 ?2 ?8); + _: (drop ?4 (0) ?1 (CTail ?9 (Bind Abbr) ?5)) |- ? ] -> + IH H '(S ?4) ?5 '(CTail ?6 (Bind ?11) ?7) ?8 ?9. + +(*#* #start macro *) + +(*#* #caption "substitution preserves types" *) +(*#* #cap #cap c1, c2, e, t1, t2, t #alpha u in V *) + +(* NOTE: This breaks the mutual recursion between ty0_subst0 and ty0_csubst0 *) + Theorem ty0_fsubst0: (g:?; c1:?; t1,t:?) (ty0 g c1 t1 t) -> + (i:?; u,c2,t2:?) (fsubst0 i u c1 t1 c2 t2) -> + (wf0 g c2) -> + (e:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (ty0 g c2 t2 t). + +(*#* #stop file *) + + Intros until 1; XElim H. +(* case 1: ty0_conv *) + Intros until 6; XElim H4; Intros. +(* case 1.1: fsubst0_t *) + IHT; EApply ty0_conv; XEAuto. +(* case 1.2: fsubst0_c *) + IHC; EApply ty0_conv; Try EApply pc3_fsubst0; XEAuto. +(* case 1.3: fsubst0_b *) + IHCT; IHCT; EApply ty0_conv; Try EApply pc3_fsubst0; XEAuto. +(* case 2: ty0_sort *) + Intros until 2; XElim H0; Intros. +(* case 2.1: fsubst0_t *) + Subst0GenBase. +(* case 2.2: fsubst0_c *) + XAuto. +(* case 2.3: fsubst0_b *) + Subst0GenBase. +(* case 3: ty0_abbr *) + Intros until 5; XElim H3; Intros; Clear c1 c2 t t1 t2. +(* case 3.1: fsubst0_t *) + Subst0GenBase; Rewrite H6; Rewrite <- H3 in H5; Clear H3 H6 i t3. + DropDis; Inversion H5; Rewrite <- H6 in H0; Rewrite H7 in H1; XEAuto. +(* case 3.2: fsubst0_c *) + Apply (lt_le_e n i); Intros; CSubst0Drop. +(* case 3.2.1: n < i, none *) + EApply ty0_abbr; XEAuto. +(* case 3.2.2: n < i, csubst0_fst *) + Inversion H0; CSubst0Drop. + Rewrite <- H10 in H7; Rewrite <- H11 in H7; Rewrite <- H11 in H8; Rewrite <- H12 in H8; + Clear H0 H10 H11 H12 x0 x1 x2. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase | XAuto ]. + IHT; EApply ty0_abbr; XEAuto. +(* case 3.2.3: n < i, csubst0_snd *) + Inversion H0; CSubst0Drop. + Rewrite <- H10 in H8; Rewrite <- H11 in H7; Rewrite <- H11 in H8; Rewrite <- H12 in H7; + Clear H0 H10 H11 H12 x0 x1 x3. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase; CSubst0Drop | XAuto ]. + IHC; EApply ty0_abbr; XEAuto. +(* case 3.2.4: n < i, csubst0_both *) + Inversion H0; CSubst0Drop. + Rewrite <- H11 in H9; Rewrite <- H12 in H7; Rewrite <- H12 in H8; Rewrite <- H12 in H9; Rewrite <- H13 in H8; + Clear H0 H11 H12 H13 x0 x1 x3. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase; CSubst0Drop | XAuto ]. + IHCT; EApply ty0_abbr; XEAuto. +(* case 3.2.5: n >= i *) + EApply ty0_abbr; XEAuto. +(* case 3.3: fsubst0_b *) + Subst0GenBase; Rewrite H7; Rewrite <- H3 in H4; Rewrite <- H3 in H6; Clear H3 H7 i t3. + DropDis; Inversion H6; Rewrite <- H7 in H0; Rewrite H8 in H1. + CSubst0Drop; XEAuto. +(* case 4: ty0_abst *) + Intros until 5; XElim H3; Intros; Clear c1 c2 t t1 t2. +(* case 4.1: fsubst0_t *) + Subst0GenBase; Rewrite H3 in H0; DropDis; Inversion H0. +(* case 4.2: fsubst0_c *) + Apply (lt_le_e n i); Intros; CSubst0Drop. +(* case 4.2.1: n < i, none *) + EApply ty0_abst; XEAuto. +(* case 4.2.2: n < i, csubst0_fst *) + Inversion H0; CSubst0Drop. + Rewrite <- H10 in H7; Rewrite <- H11 in H7; Rewrite <- H11 in H8; Rewrite <- H12 in H8; Rewrite <- H12; + Clear H0 H10 H11 H12 x0 x1 x2. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase | XAuto ]. + IHT; EApply ty0_conv; + [ EApply ty0_lift | EApply ty0_abst | EApply pc3_lift ]; XEAuto. +(* case 4.2.3: n < i, csubst0_snd *) + Inversion H0; CSubst0Drop. + Rewrite <- H10 in H8; Rewrite <- H11 in H7; Rewrite <- H11 in H8; Rewrite <- H12 in H7; Rewrite <- H12; + Clear H0 H10 H11 H12 x0 x1 x3. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase; CSubst0Drop | XAuto ]. + IHC; EApply ty0_abst; XEAuto. +(* case 4.2.4: n < i, csubst0_both *) + Inversion H0; CSubst0Drop. + Rewrite <- H11 in H9; Rewrite <- H12 in H7; Rewrite <- H12 in H8; Rewrite <- H12 in H9; Rewrite <- H13 in H8; Rewrite <- H13; + Clear H0 H11 H12 H13 x0 x1 x3. + DropDis; Rewrite minus_x_Sy in H0; [ DropGenBase; CSubst0Drop | XAuto ]. + IHCT; IHC; EApply ty0_conv; + [ EApply ty0_lift | EApply ty0_abst + | EApply pc3_lift; Try EApply pc3_fsubst0; Try Apply H0 + ]; XEAuto. +(* case 4.2.4: n >= i *) + EApply ty0_abst; XEAuto. +(* case 4.3: fsubst0_b *) + Subst0GenBase; Rewrite H3 in H0; DropDis; Inversion H0. +(* case 5: ty0_bind *) + Intros until 7; XElim H5; Intros; Clear H4. +(* case 5.1: fsubst0_t *) + Subst0GenBase; Rewrite H4; Clear H4 t6. +(* case 5.1.1: subst0 on left argument *) + Ty0Correct; IHT; IHTb1; Ty0Correct. + EApply ty0_conv; + [ EApply ty0_bind | EApply ty0_bind | EApply pc3_fsubst0 ]; XEAuto. +(* case 5.1.2: subst0 on right argument *) + IHTb2; Ty0Correct; EApply ty0_bind; XEAuto. +(* case 5.1.3: subst0 on both arguments *) + Ty0Correct; IHT; IHTb1; IHTTb; Ty0Correct. + EApply ty0_conv; + [ EApply ty0_bind | EApply ty0_bind | EApply pc3_fsubst0 ]; XEAuto. +(* case 5.2: fsubst0_c *) + IHC; IHCb; Ty0Correct; EApply ty0_bind; XEAuto. +(* case 5.3: fsubst0_b *) + Subst0GenBase; Rewrite H4; Clear H4 t6. +(* case 5.3.1: subst0 on left argument *) + IHC; IHCb; Ty0Correct; Ty0Correct; IHCT; IHCTb1; Ty0Correct. + EApply ty0_conv; + [ EApply ty0_bind | EApply ty0_bind + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. +(* case 5.3.2: subst0 on right argument *) + IHC; IHCTb2; Ty0Correct; EApply ty0_bind; XEAuto. +(* case 5.3.3: subst0 on both arguments *) + IHC; IHCb; Ty0Correct; Ty0Correct; IHCT; IHCTTb; Ty0Correct. + EApply ty0_conv; + [ EApply ty0_bind | EApply ty0_bind + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. +(* case 6: ty0_appl *) + Intros until 5; XElim H3; Intros. +(* case 6.1: fsubst0_t *) + Subst0GenBase; Rewrite H3; Clear H3 c1 c2 t t1 t2 t3. +(* case 6.1.1: subst0 on left argument *) + Ty0Correct; Ty0GenBase; IHT; Ty0Correct. + EApply ty0_conv; + [ EApply ty0_appl | EApply ty0_appl | EApply pc3_fsubst0 ]; XEAuto. +(* case 6.1.2: subst0 on right argument *) + IHT; EApply ty0_appl; XEAuto. +(* case 6.1.3: subst0 on both arguments *) + Ty0Correct; Ty0GenBase; Move H after H10; Ty0Correct; IHT; Clear H2; IHT. + EApply ty0_conv; + [ EApply ty0_appl | EApply ty0_appl | EApply pc3_fsubst0 ]; XEAuto. +(* case 6.2: fsubst0_c *) + IHC; Clear H2; IHC; EApply ty0_appl; XEAuto. +(* case 6.3: fsubst0_b *) + Subst0GenBase; Rewrite H3; Clear H3 c1 c2 t t1 t2 t3. +(* case 6.3.1: subst0 on left argument *) + IHC; Ty0Correct; Ty0GenBase; Clear H2; IHC; IHCT. + EApply ty0_conv; + [ EApply ty0_appl | EApply ty0_appl + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. +(* case 6.3.2: subst0 on right argument *) + IHCT; Clear H2; IHC; EApply ty0_appl; XEAuto. +(* case 6.3.3: subst0 on both arguments *) + IHC; Ty0Correct; Ty0GenBase; IHCT; Clear H2; IHC; Ty0Correct; IHCT. + EApply ty0_conv; + [ EApply ty0_appl | EApply ty0_appl + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. +(* case 7: ty0_cast *) + Clear c1 t t1; Intros until 5; XElim H3; Intros; Clear c2 t3. +(* case 7.1: fsubst0_t *) + Subst0GenBase; Rewrite H3; Clear H3 t4. +(* case 7.1.1: subst0 on left argument *) + IHT; EApply ty0_conv; + [ Idtac + | EApply ty0_cast; + [ EApply ty0_conv; [ Idtac | Idtac | Apply pc3_s; EApply pc3_fsubst0 ] + | Idtac ] + | EApply pc3_fsubst0 ]; XEAuto. +(* case 7.1.2: subst0 on right argument *) + IHT; EApply ty0_cast; XEAuto. +(* case 7.1.3: subst0 on both arguments *) + IHT; Clear H2; IHT. + EApply ty0_conv; + [ Idtac + | EApply ty0_cast; + [ EApply ty0_conv; [ Idtac | Idtac | Apply pc3_s; EApply pc3_fsubst0 ] + | Idtac ] + | EApply pc3_fsubst0 ]; XEAuto. +(* case 7.2: fsubst0_c *) + IHC; Clear H2; IHC; EApply ty0_cast; XEAuto. +(* case 6.3: fsubst0_b *) + Subst0GenBase; Rewrite H3; Clear H3 t4. +(* case 7.3.1: subst0 on left argument *) + IHC; IHCT; Clear H2; IHC. + EApply ty0_conv; + [ Idtac + | EApply ty0_cast; + [ EApply ty0_conv; [ Idtac | Idtac | Apply pc3_s; EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ] + | Idtac ] + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. +(* case 7.3.2: subst0 on right argument *) + IHCT; IHC; EApply ty0_cast; XEAuto. +(* case 7.3.3: subst0 on both arguments *) + IHC; IHCT; Clear H2; IHCT. + EApply ty0_conv; + [ Idtac + | EApply ty0_cast; + [ EApply ty0_conv; [ Idtac | Idtac | Apply pc3_s; EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ] + | Idtac ] + | EApply pc3_fsubst0; [ Idtac | Idtac | XEAuto ] ]; XEAuto. + Qed. + + Theorem ty0_csubst0: (g:?; c1:?; t1,t2:?) (ty0 g c1 t1 t2) -> + (e:?; u:?; i:?) (drop i (0) c1 (CTail e (Bind Abbr) u)) -> + (c2:?) (wf0 g c2) -> (csubst0 i u c1 c2) -> + (ty0 g c2 t1 t2). + Intros; EApply ty0_fsubst0; XEAuto. + Qed. + + Theorem ty0_subst0: (g:?; c:?; t1,t:?) (ty0 g c t1 t) -> + (e:?; u:?; i:?) (drop i (0) c (CTail e (Bind Abbr) u)) -> + (t2:?) (subst0 i u t1 t2) -> (ty0 g c t2 t). + Intros; EApply ty0_fsubst0; XEAuto. + Qed. + + End ty0_fsubst0. + + Hints Resolve ty0_subst0 : ltlc. + diff --git a/helm/coq-contribs/SUBSETS.tgz b/helm/coq-contribs/SUBSETS.tgz deleted file mode 100644 index ad647f417..000000000 Binary files a/helm/coq-contribs/SUBSETS.tgz and /dev/null differ