Commit 6eea59b4 authored by Benoit Viguier's avatar Benoit Viguier
Browse files

better makefile with dependencies

parent 53837612
Require Export SumList.
Require Export Forall_extended.
Require Export Forall_ZofList.
Import ListNotations.
Open Scope Z.
......
Require Export Forall_extended.
Require Export notations.
Require Export ZofList.
Open Scope Z.
Import ListNotations.
Section Integer.
Variable n:Z.
Hypothesis Hn: n > 0.
(*
Forall LEMMAS
*)
Definition ZList_pos (l:list Z) : Prop := Forall (Zle 0) l.
Notation "ℤ.lst A" := (ZofList n A) (at level 65, right associativity).
Lemma ZofList_pos : forall l, ZList_pos l -> 0 <= .lst l.
Proof.
intros l Hl.
dependent induction Hl.
- go.
- rewrite ZofList_cons.
apply OMEGA2.
assumption.
rewrite Z.mul_comm.
apply Zmult_gt_0_le_0_compat.
apply pown0.
auto.
auto.
Qed.
Lemma ZofList_null : forall l, ZList_pos l -> .lst l = 0 -> Forall (Z.eq 0) l.
Proof.
intros l HFl HSl.
induction HFl.
- go.
- assert(Hx: {x < 0} + {x = 0} + {x > 0}) by apply Ztrichotomy_inf.
assert(Hl: {.lst l < 0} + {.lst l = 0} + {.lst l > 0}) by apply Ztrichotomy_inf.
rewrite ZofList_cons in HSl.
assert(Hlpos:= ZofList_pos l HFl).
case Hl ; intro Hl'.
case Hl' ; intro Hl''.
apply Zle_not_lt in Hlpos.
false.
+ clear Hl' Hl Hlpos.
case Hx ; intro Hx'.
case Hx' ; intro Hx''.
apply Zle_not_lt in H.
false.
* clear Hx' Hx.
apply Forall_cons ; go.
* assert(2 ^ n * (.lst l) = 0).
rewrite Z.eq_mul_0 ; auto.
rewrite H0 in HSl.
omega. (* contradiction between x = 0 and x > 0*)
+ clear Hlpos Hl.
case Hx ; intro Hx'.
case Hx' ; intro Hx''.
apply Zle_not_lt in H.
false.
* clear Hx' Hx.
subst x ; clear H.
rewrite Z.add_0_l in HSl.
rewrite Z.eq_mul_0 in HSl.
destruct HSl.
assert(H0' := pown0 n Hn) ; omega.
omega (* contraction between H and Hl'*).
* (*once again we need to show a contradiction in HSl. *)
assert(0 < x + 2 ^ n * (.lst l)).
apply Z.add_pos_pos.
omega. (*see Hx' *)
rewrite Z.lt_0_mul.
left ; split ; rewrite <- Z.gt_lt_iff.
apply pown0 ; auto.
assumption. (* apply Hl' *)
omega.
Qed.
Lemma ZofList_bound : forall (m:Z) l , 0 <= m < 2 ^ n -> ZList_pos l -> .lst l = m -> nth 0 l 0 = m.
Proof.
intros m l Hm HFl HSlm.
destruct l.
- go.
- rewrite ZofList_cons in HSlm.
unfold nth.
subst m.
replace (2 ^ n * (.lst l)) with 0.
apply Zplus_0_r_reverse.
unfold ZList_pos in HFl.
rewrite Forall_cons' in HFl.
destruct HFl as [Hz Hpos].
apply ZofList_pos in Hpos.
assert(Hl: {.lst l < 0} + {.lst l = 0} + {.lst l > 0}) by apply Ztrichotomy_inf.
case Hl ; intro Hl'.
case Hl' ; intro Hl''.
apply Zle_not_lt in Hpos.
false.
+ symmetry. rewrite Z.eq_mul_0 ; auto.
+ exfalso.
clear Hl Hpos.
assert(1 <= .lst l).
omega.
assert(2 ^ n * 1 <= 2 ^ n * (.lst l)).
apply Zmult_le_compat_l ; auto.
rewrite <- Z.ge_le_iff.
assert(Ht:= pown0).
omega.
omega.
Qed.
End Integer.
Require Export Tools.
Require Export ZofList.
Require Export Forall.
Require Export notations.
Lemma Forall_slice : forall n A (l:list A) (P:A -> Prop), Forall P l -> Forall P (slice n l).
Proof.
......@@ -37,117 +34,4 @@ Proof.
rewrite Forall_cons' in H.
destruct H.
go.
Qed.
Open Scope Z.
Import ListNotations.
Section Integer.
Variable n:Z.
Hypothesis Hn: n > 0.
(*
Forall LEMMAS
*)
Definition ZList_pos (l:list Z) : Prop := Forall (Zle 0) l.
Notation "ℤ.lst A" := (ZofList n A) (at level 65, right associativity).
Lemma ZofList_pos : forall l, ZList_pos l -> 0 <= .lst l.
Proof.
intros l Hl.
dependent induction Hl.
- go.
- rewrite ZofList_cons.
apply OMEGA2.
assumption.
rewrite Z.mul_comm.
apply Zmult_gt_0_le_0_compat.
apply pown0.
auto.
auto.
Qed.
Lemma ZofList_null : forall l, ZList_pos l -> .lst l = 0 -> Forall (Z.eq 0) l.
Proof.
intros l HFl HSl.
induction HFl.
- go.
- assert(Hx: {x < 0} + {x = 0} + {x > 0}) by apply Ztrichotomy_inf.
assert(Hl: {.lst l < 0} + {.lst l = 0} + {.lst l > 0}) by apply Ztrichotomy_inf.
rewrite ZofList_cons in HSl.
assert(Hlpos:= ZofList_pos l HFl).
case Hl ; intro Hl'.
case Hl' ; intro Hl''.
apply Zle_not_lt in Hlpos.
false.
+ clear Hl' Hl Hlpos.
case Hx ; intro Hx'.
case Hx' ; intro Hx''.
apply Zle_not_lt in H.
false.
* clear Hx' Hx.
apply Forall_cons ; go.
* assert(2 ^ n * (.lst l) = 0).
rewrite Z.eq_mul_0 ; auto.
rewrite H0 in HSl.
omega. (* contradiction between x = 0 and x > 0*)
+ clear Hlpos Hl.
case Hx ; intro Hx'.
case Hx' ; intro Hx''.
apply Zle_not_lt in H.
false.
* clear Hx' Hx.
subst x ; clear H.
rewrite Z.add_0_l in HSl.
rewrite Z.eq_mul_0 in HSl.
destruct HSl.
assert(H0' := pown0 n Hn) ; omega.
omega (* contraction between H and Hl'*).
* (*once again we need to show a contradiction in HSl. *)
assert(0 < x + 2 ^ n * (.lst l)).
apply Z.add_pos_pos.
omega. (*see Hx' *)
rewrite Z.lt_0_mul.
left ; split ; rewrite <- Z.gt_lt_iff.
apply pown0 ; auto.
assumption. (* apply Hl' *)
omega.
Qed.
Lemma ZofList_bound : forall (m:Z) l , 0 <= m < 2 ^ n -> ZList_pos l -> .lst l = m -> nth 0 l 0 = m.
Proof.
intros m l Hm HFl HSlm.
destruct l.
- go.
- rewrite ZofList_cons in HSlm.
unfold nth.
subst m.
replace (2 ^ n * (.lst l)) with 0.
apply Zplus_0_r_reverse.
unfold ZList_pos in HFl.
rewrite Forall_cons' in HFl.
destruct HFl as [Hz Hpos].
apply ZofList_pos in Hpos.
assert(Hl: {.lst l < 0} + {.lst l = 0} + {.lst l > 0}) by apply Ztrichotomy_inf.
case Hl ; intro Hl'.
case Hl' ; intro Hl''.
apply Zle_not_lt in Hpos.
false.
+ symmetry. rewrite Z.eq_mul_0 ; auto.
+ exfalso.
clear Hl Hpos.
assert(1 <= .lst l).
omega.
assert(2 ^ n * 1 <= 2 ^ n * (.lst l)).
apply Zmult_le_compat_l ; auto.
rewrite <- Z.ge_le_iff.
assert(Ht:= pown0).
omega.
omega.
Qed.
End Integer.
Qed.
\ No newline at end of file
#############################################################################
## v # The Coq Proof Assistant ##
## <O___,, # INRIA - CNRS - LIX - LRI - PPS ##
## \VV/ # ##
## // # Makefile automagically generated by coq_makefile V8.5pl2 ##
#############################################################################
# WARNING
#
# This Makefile has been automagically generated
# Edit at your own risks !
#
# END OF WARNING
#
# This Makefile was generated by the command line :
# coq_makefile -f _CoqProject -o Makefile
#
.DEFAULT_GOAL := all
# This Makefile may take arguments passed as environment variables:
# COQBIN to specify the directory where Coq binaries resides;
# TIMECMD set a command to log .v compilation time;
# TIMED if non empty, use the default time command as TIMECMD;
# ZDEBUG/COQDEBUG to specify debug flags for ocamlc&ocamlopt/coqc;
# DSTROOT to specify a prefix to install path.
# Here is a hack to make $(eval $(shell works:
define donewline
endef
includecmdwithout@ = $(eval $(subst @,$(donewline),$(shell { $(1) | tr -d '\r' | tr '\n' '@'; })))
$(call includecmdwithout@,$(COQBIN)coqtop -config)
TIMED=
TIMECMD=
STDTIME?=/usr/bin/time -f "$* (user: %U mem: %M ko)"
TIMER=$(if $(TIMED), $(STDTIME), $(TIMECMD))
vo_to_obj = $(addsuffix .o,\
$(filter-out Warning: Error:,\
$(shell $(COQBIN)coqtop -q -noinit -batch -quiet -print-mod-uid $(1))))
##########################
# #
# Libraries definitions. #
# #
##########################
COQLIBS?=\
-R "." VerifTweetNaCl
COQCHKLIBS?=\
-R "." VerifTweetNaCl
COQDOCLIBS?=\
-R "." VerifTweetNaCl
##########################
# #
# Variables definitions. #
# #
##########################
OPT?=
COQDEP?="$(COQBIN)coqdep" -c
COQFLAGS?=-q $(OPT) $(COQLIBS) $(OTHERFLAGS) $(COQ_XML)
COQCHKFLAGS?=-silent -o
COQDOCFLAGS?=-interpolate -utf8
COQC?=$(TIMER) "$(COQBIN)coqc"
GALLINA?="$(COQBIN)gallina"
COQDOC?="$(COQBIN)coqdoc"
COQCHK?="$(COQBIN)coqchk"
COQMKTOP?="$(COQBIN)coqmktop"
##################
# #
# Install Paths. #
# #
##################
ifdef USERINSTALL
XDG_DATA_HOME?="$(HOME)/.local/share"
COQLIBINSTALL=$(XDG_DATA_HOME)/coq
COQDOCINSTALL=$(XDG_DATA_HOME)/doc/coq
else
COQLIBINSTALL="${COQLIB}user-contrib"
COQDOCINSTALL="${DOCDIR}user-contrib"
COQTOPINSTALL="${COQLIB}toploop"
endif
######################
# #
# Files dispatching. #
# #
######################
VFILES:=Carry.v\
ZofList.v\
Libs.v\
ScalarMult.v\
Tools.v\
Forall_extended.v\
notations.v\
Reduce.v\
A.v\
Forall.v\
LibTactics.v\
SumList.v\
Forall_ZofList.v\
M.v\
ZCarry.v
ifneq ($(filter-out archclean clean cleanall printenv,$(MAKECMDGOALS)),)
-include $(addsuffix .d,$(VFILES))
else
ifeq ($(MAKECMDGOALS),)
-include $(addsuffix .d,$(VFILES))
endif
endif
.SECONDARY: $(addsuffix .d,$(VFILES))
VO=vo
VOFILES:=$(VFILES:.v=.$(VO))
GLOBFILES:=$(VFILES:.v=.glob)
GFILES:=$(VFILES:.v=.g)
HTMLFILES:=$(VFILES:.v=.html)
GHTMLFILES:=$(VFILES:.v=.g.html)
OBJFILES=$(call vo_to_obj,$(VOFILES))
ALLNATIVEFILES=$(OBJFILES:.o=.cmi) $(OBJFILES:.o=.cmo) $(OBJFILES:.o=.cmx) $(OBJFILES:.o=.cmxs)
NATIVEFILES=$(foreach f, $(ALLNATIVEFILES), $(wildcard $f))
ifeq '$(HASNATDYNLINK)' 'true'
HASNATDYNLINK_OR_EMPTY := yes
else
HASNATDYNLINK_OR_EMPTY :=
endif
#######################################
# #
# Definition of the toplevel targets. #
# #
#######################################
all: $(VOFILES)
quick: $(VOFILES:.vo=.vio)
vio2vo:
$(COQC) $(COQDEBUG) $(COQFLAGS) -schedule-vio2vo $(J) $(VOFILES:%.vo=%.vio)
checkproofs:
$(COQC) $(COQDEBUG) $(COQFLAGS) -schedule-vio-checking $(J) $(VOFILES:%.vo=%.vio)
gallina: $(GFILES)
html: $(GLOBFILES) $(VFILES)
- mkdir -p html
$(COQDOC) -toc $(COQDOCFLAGS) -html $(COQDOCLIBS) -d html $(VFILES)
gallinahtml: $(GLOBFILES) $(VFILES)
- mkdir -p html
$(COQDOC) -toc $(COQDOCFLAGS) -html -g $(COQDOCLIBS) -d html $(VFILES)
all.ps: $(VFILES)
$(COQDOC) -toc $(COQDOCFLAGS) -ps $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`
all-gal.ps: $(VFILES)
$(COQDOC) -toc $(COQDOCFLAGS) -ps -g $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`
all.pdf: $(VFILES)
$(COQDOC) -toc $(COQDOCFLAGS) -pdf $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`
all-gal.pdf: $(VFILES)
$(COQDOC) -toc $(COQDOCFLAGS) -pdf -g $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`
validate: $(VOFILES)
$(COQCHK) $(COQCHKFLAGS) $(COQCHKLIBS) $(notdir $(^:.vo=))
beautify: $(VFILES:=.beautified)
for file in $^; do mv $${file%.beautified} $${file%beautified}old && mv $${file} $${file%.beautified}; done
@echo 'Do not do "make clean" until you are sure that everything went well!'
@echo 'If there were a problem, execute "for file in $$(find . -name \*.v.old -print); do mv $${file} $${file%.old}; done" in your shell/'
.PHONY: all archclean beautify byte clean cleanall gallina gallinahtml html install install-doc install-natdynlink install-toploop opt printenv quick uninstall userinstall validate vio2vo
####################
# #
# Special targets. #
# #
####################
byte:
$(MAKE) all "OPT:=-byte"
opt:
$(MAKE) all "OPT:=-opt"
userinstall:
+$(MAKE) USERINSTALL=true install
install:
cd "." && for i in $(VOFILES) $(VFILES) $(GLOBFILES) $(NATIVEFILES) $(CMOFILES) $(CMIFILES) $(CMAFILES); do \
install -d "`dirname "$(DSTROOT)"$(COQLIBINSTALL)/VerifTweetNaCl/$$i`"; \
install -m 0644 $$i "$(DSTROOT)"$(COQLIBINSTALL)/VerifTweetNaCl/$$i; \
done
install-doc:
install -d "$(DSTROOT)"$(COQDOCINSTALL)/VerifTweetNaCl/html
for i in html/*; do \
install -m 0644 $$i "$(DSTROOT)"$(COQDOCINSTALL)/VerifTweetNaCl/$$i;\
done
uninstall_me.sh: Makefile
echo '#!/bin/sh' > $@
printf 'cd "$${DSTROOT}"$(COQLIBINSTALL)/VerifTweetNaCl && rm -f $(VOFILES) $(VFILES) $(GLOBFILES) $(NATIVEFILES) $(CMOFILES) $(CMIFILES) $(CMAFILES) && find . -type d -and -empty -delete\ncd "$${DSTROOT}"$(COQLIBINSTALL) && find "VerifTweetNaCl" -maxdepth 0 -and -empty -exec rmdir -p \{\} \;\n' >> "$@"
printf 'cd "$${DSTROOT}"$(COQDOCINSTALL)/VerifTweetNaCl \\\n' >> "$@"
printf '&& rm -f $(shell find "html" -maxdepth 1 -and -type f -print)\n' >> "$@"
printf 'cd "$${DSTROOT}"$(COQDOCINSTALL) && find VerifTweetNaCl/html -maxdepth 0 -and -empty -exec rmdir -p \{\} \;\n' >> "$@"
chmod +x $@
uninstall: uninstall_me.sh
sh $<
.merlin:
@echo 'FLG -rectypes' > .merlin
@echo "B $(COQLIB) kernel" >> .merlin
@echo "B $(COQLIB) lib" >> .merlin
@echo "B $(COQLIB) library" >> .merlin
@echo "B $(COQLIB) parsing" >> .merlin
@echo "B $(COQLIB) pretyping" >> .merlin
@echo "B $(COQLIB) interp" >> .merlin
@echo "B $(COQLIB) printing" >> .merlin
@echo "B $(COQLIB) intf" >> .merlin
@echo "B $(COQLIB) proofs" >> .merlin
@echo "B $(COQLIB) tactics" >> .merlin
@echo "B $(COQLIB) tools" >> .merlin
@echo "B $(COQLIB) toplevel" >> .merlin
@echo "B $(COQLIB) stm" >> .merlin
@echo "B $(COQLIB) grammar" >> .merlin
@echo "B $(COQLIB) config" >> .merlin
clean::
rm -f $(OBJFILES) $(OBJFILES:.o=.native) $(NATIVEFILES)
find . -name .coq-native -type d -empty -delete
rm -f $(VOFILES) $(VOFILES:.vo=.vio) $(GFILES) $(VFILES:.v=.v.d) $(VFILES:=.beautified) $(VFILES:=.old)
rm -f all.ps all-gal.ps all.pdf all-gal.pdf all.glob $(VFILES:.v=.glob) $(VFILES:.v=.tex) $(VFILES:.v=.g.tex) all-mli.tex
- rm -rf html mlihtml uninstall_me.sh
cleanall:: clean
rm -f $(patsubst %.v,.%.aux,$(VFILES))
archclean::
rm -f *.cmx *.o
printenv:
@"$(COQBIN)coqtop" -config
@echo 'CAMLC = $(CAMLC)'
@echo 'CAMLOPTC = $(CAMLOPTC)'
@echo 'PP = $(PP)'
@echo 'COQFLAGS = $(COQFLAGS)'
@echo 'COQLIBINSTALL = $(COQLIBINSTALL)'
@echo 'COQDOCINSTALL = $(COQDOCINSTALL)'
Makefile: _CoqProject
mv -f $@ $@.bak
"$(COQBIN)coq_makefile" -f $< -o $@
###################
# #
# Implicit rules. #
# #
###################
$(VOFILES): %.vo: %.v
$(COQC) $(COQDEBUG) $(COQFLAGS) $<
$(GLOBFILES): %.glob: %.v
$(COQC) $(COQDEBUG) $(COQFLAGS) $<
$(VFILES:.v=.vio): %.vio: %.v
$(COQC) -quick $(COQDEBUG) $(COQFLAGS) $<
$(GFILES): %.g: %.v
$(GALLINA) $<
$(VFILES:.v=.tex): %.tex: %.v
$(COQDOC) $(COQDOCFLAGS) -latex $< -o $@
$(HTMLFILES): %.html: %.v %.glob
$(COQDOC) $(COQDOCFLAGS) -html $< -o $@
$(VFILES:.v=.g.tex): %.g.tex: %.v
$(COQDOC) $(COQDOCFLAGS) -latex -g $< -o $@
$(GHTMLFILES): %.g.html: %.v %.glob
$(COQDOC) $(COQDOCFLAGS) -html -g $< -o $@
$(addsuffix .d,$(VFILES)): %.v.d: %.v
$(COQDEP) $(COQLIBS) "$<" > "$@" || ( RV=$$?; rm -f "$@"; exit $${RV} )
$(addsuffix .beautified,$(VFILES)): %.v.beautified:
$(COQC) $(COQDEBUG) $(COQFLAGS) -beautify $*.v
# WARNING
#
# This Makefile has been automagically generated
# Edit at your own risks !
#
# END OF WARNING
-R . VerifTweetNaCl
./Carry.v
./ZofList.v
./Libs.v
./ScalarMult.v
./Tools.v
./Forall_extended.v
./notations.v
./Reduce.v
./A.v
./Forall.v
./LibTactics.v
./SumList.v
./Forall_ZofList.v
./M.v
./ZCarry.v
COQ = coqc
all:
@echo genereting Tactical libs
${COQ} LibTactics.v
${COQ} Libs.v
@echo generating tools and libs
${COQ} Tools.v
${COQ} notations.v
${COQ} Forall.v
${COQ} ZofList.v
${COQ} Forall_extended.v
${COQ} Reduce.v
${COQ} Carry.v
${COQ} SumList.v
${COQ} ScalarMult.v
@echo generating libs for iterator
${COQ} A.v
${COQ} M.v
clean:
@echo cleaning...
@rm *.vo 2> /dev/null || true
@rm *.glob 2> /dev/null || true
@rm *.vio 2> /dev/null || true
@rm .*.aux 2> /dev/null || true
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment