text
stringlengths 0
3.34M
|
---|
#!/usr/bin/env Rscript
options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
# This is a helper script for fixing parameter file for FingerID
# Taking the command line arguments
args <- commandArgs(trailingOnly = TRUE)
if(length(args)==0)stop("No files have been specified!")
inputMSMSparam<-NA
realName<-NA
outputCSV<-"."
tryOffline=F
PPMOverwrite<-NA
PPM_MS2_Overwrite<-NA
DatabaseOverwrite<-NA
IonizationOverwrite<-NA
numberofCompounds=10
numberofCompoundsforIon<-numberofCompounds
timeout=10 # this is timeout for csi.
timeoutTree<-10
siriusPath<-"sh /usr/bin/sirius/bin/sirius"
sirCores<-2
canopus<-F
UseHeuristic<-T
mzToUseHeuristicOnly<-650
mzToUseHeuristic<-300
canopusoutputCSV<-NA
library(tools)
for(arg in args)
{
argCase<-strsplit(x = arg,split = "=")[[1]][1]
value<-strsplit(x = arg,split = "=")[[1]][2]
if(argCase=="UseHeuristic")
{
UseHeuristic=as.logical(value)
}
if(argCase=="mzToUseHeuristicOnly")
{
mzToUseHeuristicOnly=as.numeric(value)
}
if(argCase=="mzToUseHeuristic")
{
mzToUseHeuristic=as.numeric(value)
}
if(argCase=="canopusOutput")
{
canopusoutputCSV=as.character(value)
}
if(argCase=="canopus")
{
canopus<-as.logical(value)
}
if(argCase=="ncores")
{
sirCores<-as.numeric(value)
}
if(argCase=="numberofCompounds")
{
numberofCompounds=as.numeric(value)
}
if(argCase=="numberofCompoundsIon")
{
numberofCompoundsforIon=as.numeric(value)
}
if(argCase=="timeout")
{
timeout=as.numeric(value)
}
if(argCase=="timeoutTree")
{
timeoutTree=as.numeric(value)
}
if(argCase=="realName")
{
realName=as.character(value)
}
if(argCase=="input")
{
inputMSMSparam=as.character(value)
}
if(argCase=="tryOffline")
{
tryOffline=as.logical(value)
}
if(argCase=="ppm")
{
PPMOverwrite=as.numeric(value)
}
if(argCase=="ppmms2")
{
PPM_MS2_Overwrite=as.numeric(value)
}
if(argCase=="database")
{
DatabaseOverwrite=as.character(value)
}
if(argCase=="ionization")
{
IonizationOverwrite=as.character(value)
}
if(argCase=="output")
{
outputCSV=as.character(value)
}
}
tmpdir<-paste(".","/",sep="")
setwd(tmpdir)
inputMSMSparamList<-inputMSMSparam
if(canopus)
{
if(is.na(canopusoutputCSV))
{
stop("When canopus true, a path for output of canopus must be provided via canopusoutputCSV parameter!")
}
}
if(as.logical(file.info(inputMSMSparam)["isdir"]))
{
inputMSMSparamList<-list.files(inputMSMSparam,full.names = T)
}
if(file.exists("toCSI.ms"))
{
file.remove("toCSI.ms")
}
if(dir.exists("outputTMP1"))
{
unlink("outputTMP1",recursive = T,force = T)
}
for(inputMSMSparam in inputMSMSparamList)
{
cat("Loading ",inputMSMSparam,"\n")
MSMSparams<-readLines(inputMSMSparam)
splitParams<-strsplit(MSMSparams,split = " ",fixed = T)
database=""
ppm<-NA
databaseIndex<-sapply(splitParams,FUN = function(x){grep(x,pattern = "MetFragDatabaseType",fixed=T)})
database<-tolower(strsplit(splitParams[[1]][[databaseIndex]],split = "=",fixed=T)[[1]][[2]])
if(!is.na(DatabaseOverwrite))
database<-tolower(DatabaseOverwrite)
cat("Database is set to \"",database,"\"\n")
if(database=="localcsv")
stop("Local database is not supported yet! use any of the following: all, pubchem, bio, kegg, hmdb")
ppmIndex<-sapply(splitParams,FUN = function(x){grep(x,pattern = "DatabaseSearchRelativeMassDeviation",fixed=T)})
ppm<-as.numeric(strsplit(splitParams[[1]][[ppmIndex]],split = "=",fixed=T)[[1]][[2]])
if(!is.na(PPMOverwrite))
ppm<-as.numeric(PPMOverwrite)
cat("ppm is set to \"",ppm,"\"\n")
if(is.null(ppm) | is.na(ppm))
stop("Peak relative mass deviation is not defined!")
# set PPM for MS2
ppmms2Index<-sapply(splitParams,FUN = function(x){grep(x,pattern = "FragmentPeakMatchRelativeMassDeviation",fixed=T)})
ppm_ms2<-as.numeric(strsplit(splitParams[[1]][[ppmms2Index]],split = "=",fixed=T)[[1]][[2]])
if(!is.na(PPM_MS2_Overwrite))
ppm_ms2<-as.numeric(PPM_MS2_Overwrite)
cat("ppm for MS2 is set to \"",ppm_ms2,"\"\n")
if(is.null(ppm_ms2) | is.na(ppm_ms2))
stop("MS2 peak relative mass deviation is not defined!")
#### create MS file
compound<-basename(inputMSMSparam)
parentmass<-as.numeric(strsplit(compound,split = "_",fixed = T)[[1]][3])
cat("Parent mass is set to \"",parentmass,"\"\n")
if(is.null(parentmass) | is.na(parentmass))
stop("Parent mass is not defined!")
ionization<-""
ionizationIndex<-sapply(splitParams,FUN = function(x){grep(x,pattern = "PrecursorIonType",fixed=T)})
ionization<-as.character(strsplit(splitParams[[1]][[ionizationIndex]],split = "=",fixed=T)[[1]][[2]])
if(!is.na(PPMOverwrite))
IonizationOverwrite<-as.character(IonizationOverwrite)
cat("Ionization mass is set to \"",ionization,"\"\n")
if(is.na(ionization) | is.null(ionization) | ionization=="")
stop("ionization is not defined!")
collision<-""
collisionIndex<-sapply(splitParams,FUN = function(x){grep(x,pattern = "PeakListString",fixed=T)})
collision<-as.character(strsplit(splitParams[[1]][[collisionIndex]],split = "=",fixed=T)[[1]][[2]])
collision<-gsub(pattern = "_",replacement = " ",x = collision,fixed=T)
collision<-gsub(pattern = ";",replacement = "\n",x = collision,fixed=T)
cat("Extracting MS2 information ...\n")
if(is.na(collision) | is.null(collision) | collision=="")
stop("MS2 ions have not been not found!")
cat("Creating MS file ...\n")
toCSI<-paste(">compound ",compound,"\n",
">parentmass ",parentmass,"\n",
">ionization ",ionization,"\n",
">AdductSettings.detectable ",ionization,"\n",
">AdductSettings.fallback ",ionization,"\n",
">MS1MassDeviation.allowedMassDeviation ",ppm," ppm","\n",
">MS2MassDeviation.allowedMassDeviation ",ppm_ms2," ppm\n",
">NumberOfCandidatesPerIon ",numberofCompoundsforIon,"\n",
">StructureSearchDB ",database,"\n",
">Timeout.secondsPerInstance ",timeout,"\n",
">Timeout.secondsPerTree ",timeoutTree,"\n\n",
">collision\n",collision,"\n",sep = "")
write(toCSI,"toCSI.ms",append = T)
}
if(!is.numeric(sirCores) & sirCores<1)
{
stop("Number of cores (ncore) but be an integer number higher than 0!")
}else{
cat("Running CSI with",sirCores,"cores\n")
}
if(!is.numeric(timeout) & timeout<0)
{
stop("timeout should be 0 or higher!")
}else{
cat("Running CSI with",timeout,"seconds timeout! Ions taking more than",timeout,"seconds will not be considered (0=unlimited)!\n")
}
if(!is.numeric(timeoutTree) & timeoutTree<0)
{
stop("timeoutTree should be 0 or higher!")
}else{
cat("Running CSI with",timeoutTree,"seconds timeoutTree! Trees taking more than",timeoutTree,"seconds will not be considered (0=unlimited)!\n")
}
if(UseHeuristic)
{
if((!is.numeric(mzToUseHeuristicOnly) & mzToUseHeuristicOnly<0)|(!is.numeric(mzToUseHeuristic) & mzToUseHeuristic<0))
{
stop("mzToUseHeuristicOnly and mzToUseHeuristic must be numberic and higher than 0")
}else{
cat("Using heuristics with ",mzToUseHeuristicOnly, " as mzToUseHeuristicOnly and ",mzToUseHeuristic, "as mzToUseHeuristic!\n")
}
}
inpitToCSIFile<-file_path_as_absolute("toCSI.ms")
outputFolder<-paste(getwd(),"/outputTMP1",sep="")
if(canopus)
{
if(UseHeuristic)
{
toCSICommand<-paste(siriusPath," -i ", inpitToCSIFile," --output ",outputFolder, " --cores ",sirCores, " config ",
" --UseHeuristic.mzToUseHeuristicOnly ", mzToUseHeuristicOnly, " --UseHeuristic.mzToUseHeuristic ", mzToUseHeuristic," formula"," -c ",numberofCompounds," fingerid canopus", " 2>&1",sep="")
}else{
toCSICommand<-paste(siriusPath," -i ", inpitToCSIFile," --output ",outputFolder, " --cores ",sirCores, " config",
" formula"," -c ",numberofCompounds," fingerid canopus", " 2>&1",sep="")
}
}else{
if(UseHeuristic)
{
toCSICommand<-paste(siriusPath," -i ", inpitToCSIFile," --output ",outputFolder, " --cores ",sirCores, " config", "sirius --UseHeuristic.mzToUseHeuristicOnly ", mzToUseHeuristicOnly, " --UseHeuristic.mzToUseHeuristic ", mzToUseHeuristic,
" formula"," -c ",numberofCompounds," fingerid", " 2>&1",sep="")
}else{
toCSICommand<-paste(siriusPath," -i ", inpitToCSIFile," --output ",outputFolder, " --cores ",sirCores, " config",
" formula"," -c ",numberofCompounds," fingerid", " 2>&1",sep="")
}
}
cat("Running CSI using", toCSICommand, "\n")
unlink(recursive = T,x = outputFolder)
t1<-try(system(command = toCSICommand,intern = T))
if(!is.null(attr(t1,which = "status")) && attr(t1,which = "status")==1){
cat("::: Error :::\n")
stop(t1)
}else if(!is.null(attr(t1,which = "status")) && attr(t1,which = "status")==124){
cat("Took too long! Nothing will be output!\n")
}
cat("CSI finished! Trying to load the results ...\n")
requiredOutput<-paste(outputFolder,"/","compound_identifications.tsv",sep = "")
if(file.exists(requiredOutput))
{
CSI_results<-read.table(requiredOutput,header = T,sep = "\t",quote = "",check.names = F,stringsAsFactors = F,comment.char = "")
csi_input<-readLines(con = inpitToCSIFile)
csi_input<-csi_input[grepl(csi_input,pattern = ">compound ",fixed = T)]
csi_input<-gsub(pattern = ">compound ",replacement = "",x = csi_input,fixed = T)
for(cid in unique(CSI_results[,"id"]))
{
compound<-gsub(pattern = "[[:digit:]]_toCSI_",replacement = "",x = cid)
tmpData<-read.table(paste(outputFolder,"/",cid,"/","structure_candidates.tsv",sep = ""),
header = T,sep = "\t",quote = "",check.names = F,stringsAsFactors = F,comment.char = "")
if(nrow(tmpData)!=0)
{
tmpData[tmpData$name=="\"\"","name"]<-"NONAME"
parentRT<-as.numeric(strsplit(compound,split = "_",fixed = T)[[1]][2])
parentMZ<-as.numeric(strsplit(compound,split = "_",fixed = T)[[1]][3])
parentFile<-paste((strsplit(compound,split = "_",fixed = T)[[1]][-c(1,2,3)]),collapse = "_")
if(parentFile==".txt")
{
parentFile<-"NotFound"
}else{
parentFile<-gsub(pattern = ".txt",replacement = "",x = parentFile,fixed = T)
}
cat("Setting headers required for downstream ...\n")
tmpData<-data.frame(fileName=parentFile,parentMZ=parentMZ,parentRT=parentRT,tmpData)
tmpData<-cbind(data.frame(Name=tmpData[,"name"],
"Identifier"=paste("Metabolite_",1:nrow(tmpData),sep=""),
"InChI"=tmpData[,"InChI"]),score=tmpData[,"CSI.FingerIDScore"],tmpData)
cat("Writing the results ...\n")
write.csv(x = tmpData,file = paste(outputCSV,"/",compound,".csv",sep = ""))
cat("Done!\n")
}else{
cat("Empty results! Nothing will be output!\n")
}
}
}else{
cat("Empty results! Nothing will be written out!\n")
}
requiredOutput<-paste(outputFolder,"/","canopus_summary.tsv",sep = "")
if(file.exists(requiredOutput) & canopus==T)
{
cat("Loading canopus output ...\n")
canopus_results<-read.table(requiredOutput,header = T,sep = "\t",quote = "",check.names = F,stringsAsFactors = F,comment.char = "")
write.csv(x = canopus_results,file = canopusoutputCSV)
cat("write canopus output ...\n")
}
|
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b : α
l : List α
⊢ List.foldl (fun x y => op y x) b l = List.foldl op b l
[PROOFSTEP]
simp [hc.comm]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b a : α
s : Multiset α
⊢ fold op b (a ::ₘ s) = op (fold op b s) a
[PROOFSTEP]
simp [hc.comm]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b a : α
s : Multiset α
⊢ fold op b (a ::ₘ s) = fold op (op b a) s
[PROOFSTEP]
rw [fold_eq_foldl, foldl_cons, ← fold_eq_foldl]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b a : α
s : Multiset α
⊢ fold op b (a ::ₘ s) = fold op (op a b) s
[PROOFSTEP]
rw [fold_cons'_right, hc.comm]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b₁ b₂ : α
s₁ s₂ : Multiset α
⊢ fold op (op b₁ b₂) (s₁ + 0) = op (fold op b₁ s₁) (fold op b₂ 0)
[PROOFSTEP]
rw [add_zero, fold_zero, ← fold_cons'_right, ← fold_cons_right op]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
b₁ b₂ : α
s₁ s₂ : Multiset α
a : α
b : Multiset α
h : fold op (op b₁ b₂) (s₁ + b) = op (fold op b₁ s₁) (fold op b₂ b)
⊢ fold op (op b₁ b₂) (s₁ + a ::ₘ b) = op (fold op b₁ s₁) (fold op b₂ (a ::ₘ b))
[PROOFSTEP]
rw [fold_cons_left, add_cons, fold_cons_left, h, ← ha.assoc, hc.comm a, ha.assoc]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
ι : Type u_3
s : Multiset ι
t : ι → Multiset α
b : ι → α
b₀ : α
⊢ fold op (fold op b₀ (map b s)) (bind s t) = fold op b₀ (map (fun i => fold op (b i) (t i)) s)
[PROOFSTEP]
induction' s using Multiset.induction_on with a ha ih
[GOAL]
case empty
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
ι : Type u_3
t : ι → Multiset α
b : ι → α
b₀ : α
⊢ fold op (fold op b₀ (map b 0)) (bind 0 t) = fold op b₀ (map (fun i => fold op (b i) (t i)) 0)
[PROOFSTEP]
rw [zero_bind, map_zero, map_zero, fold_zero]
[GOAL]
case cons
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha✝ : IsAssociative α op
ι : Type u_3
t : ι → Multiset α
b : ι → α
b₀ : α
a : ι
ha : Multiset ι
ih : fold op (fold op b₀ (map b ha)) (bind ha t) = fold op b₀ (map (fun i => fold op (b i) (t i)) ha)
⊢ fold op (fold op b₀ (map b (a ::ₘ ha))) (bind (a ::ₘ ha) t) =
fold op b₀ (map (fun i => fold op (b i) (t i)) (a ::ₘ ha))
[PROOFSTEP]
rw [cons_bind, map_cons, map_cons, fold_cons_left, fold_cons_left, fold_add, ih]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
f g : β → α
u₁ u₂ : α
s : Multiset β
⊢ fold op (op u₁ u₂) (map (fun x => op (f x) (g x)) 0) = op (fold op u₁ (map f 0)) (fold op u₂ (map g 0))
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
f g : β → α
u₁ u₂ : α
s : Multiset β
a : β
b : Multiset β
h : fold op (op u₁ u₂) (map (fun x => op (f x) (g x)) b) = op (fold op u₁ (map f b)) (fold op u₂ (map g b))
⊢ fold op (op u₁ u₂) (map (fun x => op (f x) (g x)) (a ::ₘ b)) =
op (fold op u₁ (map f (a ::ₘ b))) (fold op u₂ (map g (a ::ₘ b)))
[PROOFSTEP]
rw [map_cons, fold_cons_left, h, map_cons, fold_cons_left, map_cons, fold_cons_right, ha.assoc, ← ha.assoc (g a),
hc.comm (g a), ha.assoc, hc.comm (g a), ha.assoc]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
op' : β → β → β
inst✝¹ : IsCommutative β op'
inst✝ : IsAssociative β op'
m : α → β
hm : ∀ (x y : α), m (op x y) = op' (m x) (m y)
b : α
s : Multiset α
⊢ fold op' (m b) (map m 0) = m (fold op b 0)
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
op' : β → β → β
inst✝¹ : IsCommutative β op'
inst✝ : IsAssociative β op'
m : α → β
hm : ∀ (x y : α), m (op x y) = op' (m x) (m y)
b : α
s : Multiset α
⊢ ∀ ⦃a : α⦄ {s : Multiset α},
fold op' (m b) (map m s) = m (fold op b s) → fold op' (m b) (map m (a ::ₘ s)) = m (fold op b (a ::ₘ s))
[PROOFSTEP]
simp (config := { contextual := true }) [hm]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
s₁ s₂ : Multiset α
b₁ b₂ : α
⊢ op (fold op b₁ (s₁ ∪ s₂)) (fold op b₂ (s₁ ∩ s₂)) = op (fold op b₁ s₁) (fold op b₂ s₂)
[PROOFSTEP]
rw [← fold_add op, union_add_inter, fold_add op]
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s : Multiset α
b : α
⊢ fold op b (dedup 0) = fold op b 0
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s✝ : Multiset α
b a : α
s : Multiset α
IH : fold op b (dedup s) = fold op b s
⊢ fold op b (dedup (a ::ₘ s)) = fold op b (a ::ₘ s)
[PROOFSTEP]
by_cases h : a ∈ s
[GOAL]
case pos
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s✝ : Multiset α
b a : α
s : Multiset α
IH : fold op b (dedup s) = fold op b s
h : a ∈ s
⊢ fold op b (dedup (a ::ₘ s)) = fold op b (a ::ₘ s)
[PROOFSTEP]
simp [IH, h]
[GOAL]
case neg
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s✝ : Multiset α
b a : α
s : Multiset α
IH : fold op b (dedup s) = fold op b s
h : ¬a ∈ s
⊢ fold op b (dedup (a ::ₘ s)) = fold op b (a ::ₘ s)
[PROOFSTEP]
simp [IH, h]
[GOAL]
case pos
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s✝ : Multiset α
b a : α
s : Multiset α
IH : fold op b (dedup s) = fold op b s
h : a ∈ s
⊢ fold op b s = op a (fold op b s)
[PROOFSTEP]
show fold op b s = op a (fold op b s)
[GOAL]
case pos
α : Type u_1
β : Type u_2
op : α → α → α
hc : IsCommutative α op
ha : IsAssociative α op
inst✝ : DecidableEq α
hi : IsIdempotent α op
s✝ : Multiset α
b a : α
s : Multiset α
IH : fold op b (dedup s) = fold op b s
h : a ∈ s
⊢ fold op b s = op a (fold op b s)
[PROOFSTEP]
rw [← cons_erase h, fold_cons_left, ← ha.assoc, hi.idempotent]
[GOAL]
α✝ : Type u_1
β : Type u_2
α : Type u_3
inst✝ : CanonicallyLinearOrderedAddMonoid α
l : Multiset α
n : α
h : ∀ (x : α), x ∈ l → x ≤ n
⊢ fold max ⊥ l ≤ n
[PROOFSTEP]
induction l using Quotient.inductionOn
[GOAL]
case h
α✝ : Type u_1
β : Type u_2
α : Type u_3
inst✝ : CanonicallyLinearOrderedAddMonoid α
n : α
a✝ : List α
h : ∀ (x : α), x ∈ Quotient.mk (List.isSetoid α) a✝ → x ≤ n
⊢ fold max ⊥ (Quotient.mk (List.isSetoid α) a✝) ≤ n
[PROOFSTEP]
simpa using List.max_le_of_forall_le _ _ h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
⊢ count a s ≤ count a (fold max 0 (map (fun a => count a s) s) • dedup s)
[PROOFSTEP]
rw [count_nsmul]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * count a (dedup s)
[PROOFSTEP]
by_cases h : a ∈ s
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : a ∈ s
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * count a (dedup s)
[PROOFSTEP]
refine' le_trans _ (Nat.mul_le_mul_left _ <| count_pos.2 <| mem_dedup.2 h)
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : a ∈ s
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * succ 0
[PROOFSTEP]
have : count a s ≤ fold max 0 (map (fun a => count a s) (a ::ₘ erase s a)) := by simp [le_max_left]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : a ∈ s
⊢ count a s ≤ fold max 0 (map (fun a => count a s) (a ::ₘ erase s a))
[PROOFSTEP]
simp [le_max_left]
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : a ∈ s
this : count a s ≤ fold max 0 (map (fun a => count a s) (a ::ₘ erase s a))
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * succ 0
[PROOFSTEP]
rw [cons_erase h] at this
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : a ∈ s
this : count a s ≤ fold max 0 (map (fun a => count a s) s)
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * succ 0
[PROOFSTEP]
simpa [mul_succ] using this
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
s : Multiset α
a : α
h : ¬a ∈ s
⊢ count a s ≤ fold max 0 (map (fun a => count a s) s) * count a (dedup s)
[PROOFSTEP]
simp [count_eq_zero.2 h, Nat.zero_le]
|
print("Hello, World!", quote=FALSE) |
function varargout = pdftops(cmd)
%PDFTOPS Calls a local pdftops executable with the input command
%
% Example:
% [status result] = pdftops(cmd)
%
% Attempts to locate a pdftops executable, finally asking the user to
% specify the directory pdftops was installed into. The resulting path is
% stored for future reference.
%
% Once found, the executable is called with the input command string.
%
% This function requires that you have pdftops (from the Xpdf package)
% installed on your system. You can download this from:
% http://www.foolabs.com/xpdf
%
% IN:
% cmd - Command string to be passed into pdftops.
%
% OUT:
% status - 0 iff command ran without problem.
% result - Output from pdftops.
% Copyright: Oliver Woodford, 2009-2010
% Thanks to Jonas Dorn for the fix for the title of the uigetdir window on
% Mac OS.
% Thanks to Christoph Hertel for pointing out a bug in check_xpdf_path
% under linux.
% 23/01/2014 - Add full path to pdftops.txt in warning.
% Call pdftops
[varargout{1:nargout}] = system(sprintf('"%s" %s', xpdf_path, cmd));
return
function path_ = xpdf_path
% Return a valid path
% Start with the currently set path
path_ = user_string('pdftops');
% Check the path works
if check_xpdf_path(path_)
return
end
% Check whether the binary is on the path
if ispc
bin = 'pdftops.exe';
else
bin = 'pdftops';
end
if check_store_xpdf_path(bin)
path_ = bin;
return
end
% Search the obvious places
if ispc
path_ = 'C:\Program Files\xpdf\pdftops.exe';
else
path_ = '/usr/local/bin/pdftops';
end
if check_store_xpdf_path(path_)
return
end
% Ask the user to enter the path
while 1
if strncmp(computer,'MAC',3) % Is a Mac
% Give separate warning as the uigetdir dialogue box doesn't have a
% title
uiwait(warndlg('Pdftops not found. Please locate the program, or install xpdf-tools from http://users.phg-online.de/tk/MOSXS/.'))
end
base = uigetdir('/', 'Pdftops not found. Please locate the program.');
if isequal(base, 0)
% User hit cancel or closed window
break;
end
base = [base filesep];
bin_dir = {'', ['bin' filesep], ['lib' filesep]};
for a = 1:numel(bin_dir)
path_ = [base bin_dir{a} bin];
if exist(path_, 'file') == 2
break;
end
end
if check_store_xpdf_path(path_)
return
end
end
error('pdftops executable not found.');
function good = check_store_xpdf_path(path_)
% Check the path is valid
good = check_xpdf_path(path_);
if ~good
return
end
% Update the current default path to the path found
if ~user_string('pdftops', path_)
warning('Path to pdftops executable could not be saved. Enter it manually in %s.', fullfile(fileparts(which('user_string.m')), '.ignore', 'pdftops.txt'));
return
end
return
function good = check_xpdf_path(path_)
% Check the path is valid
[good, message] = system(sprintf('"%s" -h', path_));
% system returns good = 1 even when the command runs
% Look for something distinct in the help text
good = ~isempty(strfind(message, 'PostScript'));
return |
/*
* Copyright 2019 LogMeIn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <future>
#include <iostream>
#include <thread>
#include <boost/chrono.hpp>
#include <boost/thread.hpp>
#include <benchmark/benchmark.h>
#include <asyncly/executor/ThreadPoolExecutorController.h>
namespace asyncly {
namespace {
const uint64_t counter_increment = 10000;
std::atomic<bool> keepRunning{ true };
std::atomic<uint64_t> result{ 0 };
thread_local uint64_t counter{ 0 };
static void
send(std::shared_ptr<IExecutor> executorToCallIn, std::shared_ptr<IExecutor> executorToCallBack)
{
if (!keepRunning.load()) {
return;
}
auto task
= [executorToCallIn, executorToCallBack]() { send(executorToCallBack, executorToCallIn); };
executorToCallIn->post(task);
counter++;
if (counter % counter_increment == 0) {
result.fetch_add(counter_increment, std::memory_order_relaxed);
}
}
} // namespace
} // namespace asyncly
using namespace asyncly;
static void threadPoolPerformanceTest(benchmark::State& state)
{
keepRunning = true;
auto range = static_cast<size_t>(state.range(0));
auto executorControlA = ThreadPoolExecutorController::create(range);
auto executorA = executorControlA->get_executor();
auto executorControlB = ThreadPoolExecutorController::create(range);
auto executorB = executorControlB->get_executor();
auto lastTs = std::chrono::steady_clock::now();
for (unsigned i = 0; i < 10 * range; i++) {
send(executorB, executorA);
}
bool allowedToRun = true;
uint64_t lastResult = 0;
while (allowedToRun) {
uint64_t currentResult = result;
while (lastResult == currentResult) {
boost::this_thread::sleep_for(boost::chrono::microseconds(5));
currentResult = result;
}
const auto afterTs = std::chrono::steady_clock::now();
auto incrementCount = (currentResult - lastResult);
const auto iterationTime
= std::chrono::duration_cast<std::chrono::duration<double>>(afterTs - lastTs).count()
/ incrementCount;
for (size_t i = 0; allowedToRun && i < incrementCount; ++i) {
allowedToRun = state.KeepRunning();
state.SetIterationTime(iterationTime);
}
lastTs = afterTs;
lastResult = currentResult;
}
keepRunning = false;
state.SetItemsProcessed(result.exchange(0));
std::promise<void> doneA;
executorA->post([&doneA]() { doneA.set_value(); });
std::promise<void> doneB;
executorB->post([&doneB]() { doneB.set_value(); });
doneA.get_future().wait();
doneB.get_future().wait();
}
BENCHMARK(threadPoolPerformanceTest)
->Arg(1)
->Arg(2)
->Arg(std::thread::hardware_concurrency() / 2)
->UseManualTime(); |
//This program takes a double array and returns the roots of the polynomial defined by them. The roots in question can be complex, and the complex data type will need usage in modelica.
#include <stdio.h>
#include <gsl/gsl_poly.h>
void poly_roots(double* a, const size_t size,double *z,size_t size_z);
void poly_roots(double* a, const size_t size,double *z,size_t size_z)
{
/* coefficients of P(x) = -1 + x^5 */
gsl_poly_complex_workspace * w = gsl_poly_complex_workspace_alloc ((size+1));
gsl_poly_complex_solve (a, size+1, w, z);
gsl_poly_complex_workspace_free (w);
for (int i = 0; i < size; i++)
{
printf ("z%d = %+.18f %+.18f\n",
i, z[2*i], z[2*i+1]);
}
}
//The main function has been provided solely for the sake of testing the function. It will be removed when the problem set is formally passed on.
/*
int main (void)
{
double a[6] = { -1, 0, 0, 0, 0, 1 };
int size_a = 5;
double *z;
poly_roots(a, size_a,z, 10);
return 0;
}
*/
|
module Cycle1
import Cycle2
|
from utils.mid_level_feature_classifier import classify_files
import numpy as np
import tkinter as tk
import tkinter.filedialog
import pickle
import os
import pdb
# %% Define the feature names and features to use
model = pickle.load(open("./models/mid_level_classifier_weights.pickle", "rb"))
DX_LABELS = ["Benign", "Atypia", "DCIS", "Invasive"]
# %%
window = tk.Tk()
l = tk.Label(window,
text='Diagnosis Prediction',
font=('Arial', 24),
width=50, height=1)
l.grid(row=0, column=0, columnspan=3)
# %%
def get_csv_paths():
if not os.path.exists("output"):
os.mkdir("output")
fn = tkinter.filedialog.askopenfilenames(initialdir = "output/",
title = "Select CSV files",
filetypes = (("Co-occurence Features", "*SuperpixelCooccurrence.csv"),
("all files","*.*")))
csv_paths_var.set(fn)
return fn
csv_paths_button = tk.Button(window, text="Select CSV files", width=30, height=1,
command=get_csv_paths)
csv_paths_button.grid(row=2, column=0)
csv_paths_var = tk.StringVar()
csv_paths_var.set("CSV Paths Goes Here")
csv_paths_label = tk.Label(window, textvariable=csv_paths_var)
csv_paths_label.grid(row=2, column=1)
# %%
def begin_dx_classification():
csv_paths = eval(csv_paths_var.get())
print(csv_paths)
results = {}
rst_txt = ""
preds = []
rst = classify_files(model, csv_paths)
for k in rst.keys():
pred, pred_label = rst[k]
rst_txt += "%s Prediction: %d (%s)\n" % (k, pred, pred_label)
preds.append(pred)
max_pred = np.max(preds)
rst_txt += "\nFinal Prediction: %d (%s)\n" % (max_pred, DX_LABELS[max_pred - 1])
print("Classification All Done!", csv_paths)
print(results)
# Show result
window_rst = tk.Tk()
tk.Message(window_rst, text=rst_txt,
width=800, bg="snow2", fg="red",font=("Arial", 20)
).pack()
return results
go_button = tk.Button(window, text="Begin Classification", width=40, height=2,
command=begin_dx_classification)
go_button.grid(row=7, column=0, columnspan=3)
# %%
window.mainloop()
|
(*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*)
(*
* This file introduces an experimental "distinct" command that takes
* a list of 'n' terms, and generates O(n^2) lemmas for you to prove
* that the 'n' terms are all distinct. These proofs can typically be
* carried out by an "apply auto" command, giving you O(n^2)
* distinctness theorems relatively easily. These new theorems can then
* be thrown into a simpset to avoid having to constantly unfold
* definitions merely to prove distinctness.
*
* This may significantly simplify certain proofs where inequality of
* defined terms is frequently relied upon.
*
* The "distinct" command is not really scalable, due to its O(n^2)
* proof terms generated. If we wanted to use this in a larger example,
* we would probably want a "ordered" command, which forces you to show
* that 'n' terms have some ordering, and then automatically derive the
* O(n^2) possible proof terms on-the-fly in a simproc (possibly using
* Isabelle's existing "order_tac").
*)
theory Distinct_Cmd
imports Main
keywords "distinct" :: thy_goal
begin
ML \<open>
local
(*
* Process a parsed binding, converting it from raw tokens (which
* can't be passed into Local_Theory.note) into its semantic meaning
* (which can).
*)
fun process_binding lthy binding =
apsnd (map (Attrib.check_src lthy)) binding
(* Parse the parameters to "distinct". *)
val distinct_parser =
(Scan.optional (Parse_Spec.opt_thm_name ":") Binding.empty_atts
-- Scan.repeat1 Parse.term)
(* Generate a prop of the form "a ~= b". *)
fun mk_inequality_pair a b =
HOLogic.mk_eq (a, b)
|> HOLogic.mk_not
|> HOLogic.mk_Trueprop
(* Generate O(n^2) distinctness goals. *)
fun gen_distinct_goals terms =
map_product
(fn a => fn b =>
if a = b then NONE
else SOME (mk_inequality_pair a b))
terms terms
|> map_filter I
|> map (fn t => (t, []))
(* Given a list of terms, coerce them all into the same type. *)
fun coerce_terms_to_same_type lthy terms =
HOLogic.mk_list dummyT terms
|> Syntax.check_term lthy
|> HOLogic.dest_list
(* We save the theorems to the context afterwards. *)
fun after_qed thm_name thms lthy =
Local_Theory.note (thm_name, (flat thms)) lthy |> snd
in
val _ =
Outer_Syntax.local_theory_to_proof @{command_keyword "distinct"}
"prove distinctness of a list of terms"
(distinct_parser
>> (fn (thm_name, terms) => fn lthy =>
Proof.theorem NONE (after_qed (process_binding lthy thm_name)) [
map (Syntax.parse_term lthy) terms
|> coerce_terms_to_same_type lthy
|> gen_distinct_goals
] lthy
))
end
\<close>
(* Test. *)
context
fixes A :: nat
fixes B :: nat
fixes C :: nat
assumes x: "A = 1 \<and> B = 2 \<and> C = 3"
begin
distinct A B C "5" "6" "2 + 11"
by (auto simp: x)
end
end
|
import Base: show
mutable struct Path
ug::NamedArray
f::Symbol
l::Symbol
path::Vector{Symbol}
visited::Vector{Vector{Symbol}}
next::Vector{Vector{Symbol}}
end
Path(d::DAG, f, l) = Path(
undirected_matrix(d), # Create undirected graph from DAG
f, # Path continuation symbol
l, # Path completed symbol
[f], # Symbols on path
[[l, f]], # Edges already walked
[[l, f]] # Edge to do next
)
function path_show(io::IO, p::Path)
println(io, "(f = $(p.f), l = $(p.l))")
println(io, "path = $(p.path)")
println(io, "visited = $(p.visited)")
println(io, "next = $(p.next)")
end
show(io::IO, p::Path) = path_show(io, p)
export
Path
|
subroutine test(x)
double precision, intent(inout) :: x(:)
integer :: k
do k=1,size(x)
x(k) = 1d0*k
end do
end subroutine test |
### FUNCTION to post data to Tone Analyzer and return results
process_data_to_tone <- function(text)
{
response <- POST(url="https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2016-05-19",
authenticate(username_TON,password_TON),
add_headers("Content-Type"="text/plain","charset"="UTF-8"),
body=text )
response_text <- content(response, "text", encoding = "UTF-8") # or encoding = "ISO-8859-1"
abc <- tidyResponse(response_text)
return(abc)
}
### FUNCTION NEW version=2017-09-21 = The array includes results for any tone whose score is at least 0.5.
### response <- POST(url="https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2017-09-21",
### Function to process output from API and table
tidyResponse <- function(data)
{
data <- as.data.frame(strsplit(as.character(data),"\"score\""))
data <- data[-c(1), ] # remove dud first row
data <- gsub("\"tone_id\":","",data)
data <- gsub(":","",data)
data <- gsub("\"","",data)
data <- gsub("_big5","",data)
data <- data.frame(data)
data <- data.frame(do.call('rbind', strsplit(as.character(data$data),',',fixed=TRUE)))
data <- data[,-c(3:6), ] # remove dud first row
data <- data[c("X2", "X1")]
data$X1 <- as.character.numeric_version(data$X1) # not sure why, but coercing to numbers requires this
data$X1 <- as.numeric(data$X1)
data$X1 <- round((data$X1),2)
setnames(data,c("trait","signal"))
return(data)
} |
[STATEMENT]
lemma (in prob_space) uniform_distributed_params:
assumes X: "distributed M MX X (\<lambda>x. indicator A x / measure MX A)"
shows "A \<in> sets MX" "measure MX A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. A \<in> sets MX &&& Sigma_Algebra.measure MX A \<noteq> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. A \<in> sets MX
2. Sigma_Algebra.measure MX A \<noteq> 0
[PROOF STEP]
interpret X: prob_space "distr M MX X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. prob_space (distr M MX X)
[PROOF STEP]
using distributed_measurable[OF X]
[PROOF STATE]
proof (prove)
using this:
random_variable MX X
goal (1 subgoal):
1. prob_space (distr M MX X)
[PROOF STEP]
by (rule prob_space_distr)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. A \<in> sets MX
2. Sigma_Algebra.measure MX A \<noteq> 0
[PROOF STEP]
show "measure MX A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Sigma_Algebra.measure MX A \<noteq> 0
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. Sigma_Algebra.measure MX A = 0 \<Longrightarrow> False
[PROOF STEP]
assume "measure MX A = 0"
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure MX A = 0
goal (1 subgoal):
1. Sigma_Algebra.measure MX A = 0 \<Longrightarrow> False
[PROOF STEP]
with X.emeasure_space_1 X.prob_space distributed_distr_eq_density[OF X]
[PROOF STATE]
proof (chain)
picking this:
emeasure (distr M MX X) (space (distr M MX X)) = 1
X.prob (space (distr M MX X)) = 1
distr M MX X = density MX (\<lambda>x. ennreal (indicat_real A x / Sigma_Algebra.measure MX A))
Sigma_Algebra.measure MX A = 0
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
emeasure (distr M MX X) (space (distr M MX X)) = 1
X.prob (space (distr M MX X)) = 1
distr M MX X = density MX (\<lambda>x. ennreal (indicat_real A x / Sigma_Algebra.measure MX A))
Sigma_Algebra.measure MX A = 0
goal (1 subgoal):
1. False
[PROOF STEP]
by (simp add: emeasure_density zero_ennreal_def[symmetric])
[PROOF STATE]
proof (state)
this:
False
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure MX A \<noteq> 0
goal (1 subgoal):
1. A \<in> sets MX
[PROOF STEP]
with measure_notin_sets[of A MX]
[PROOF STATE]
proof (chain)
picking this:
A \<notin> sets MX \<Longrightarrow> Sigma_Algebra.measure MX A = 0
Sigma_Algebra.measure MX A \<noteq> 0
[PROOF STEP]
show "A \<in> sets MX"
[PROOF STATE]
proof (prove)
using this:
A \<notin> sets MX \<Longrightarrow> Sigma_Algebra.measure MX A = 0
Sigma_Algebra.measure MX A \<noteq> 0
goal (1 subgoal):
1. A \<in> sets MX
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A \<in> sets MX
goal:
No subgoals!
[PROOF STEP]
qed |
SemiAlgebraic := module()
uses Domain, Domain_Type, SolveTools, Utilities;
export SimplName := "SemiAlgebraic";
export SimplOrder := 6+(1/2);
export ModuleApply := proc(dbnds :: DomBound, dshape :: DomShape, $)
local vs;
vs := ListTools[Reverse](Domain:-Bound:-varsOf(dbnds));
vs := map(v->if v::list then op(1,v) else v end if, vs);
do_sh( dshape , dbnds, vs );
end proc;
local extra_sol := (c -> c::`=` and (lhs(c)::DomBoundVar and evalb(lhs(c)=rhs(c))));
local postproc := proc(sol, $)
foldl((x,k)->subsindets(x,op(k)), sol
,[specfunc('piecewise')
,x->DSplit(Partition:-PWToPartition(x,'check_valid'))]
,[list(list),DSum@op]
,[list(relation),x->DConstrain(remove(extra_sol,x)[])]);
end proc;
# Check for trivial solutions, which are rejected because they are not an
# improvement in terms of Hakaru semantics (but SemiAlgebraic doesn't know
# anything about that)
local trivial_sol := proc(sh :: DomShape, ctx :: DomBound, $)
local ps, vs, vsc;
if sh::DomConstrain then
nops(sh)=0
elif sh::DomSplit then
# we assume that the conditions of a solution of SemiAlgebraic cover the
# entire domain, so it is left to check only the values
ps := KB:-kb_Partition( op(1,sh), Domain:-Bound:-contextOf(ctx),
((x_,y_)->true), #unused dummy to pass typechecks
((v,kb)->trivial_sol
(v,Domain:-Bound:-onContext(_->kb,ctx))) );
`and`(op(map(evalb@Partition:-valOf,Partition:-piecesOf(ps))));
elif sh::DomSum then
if nops(sh)<>2 then return false end if;
if ormap(s->not(s::DomConstrain) or nops(s)<>1,sh)
then return false; end if;
vs := Domain:-Bound:-varsOf(ctx,"set");
vsc := map((v->(v,-v)), vs);
ps := map2(op,1,[op(sh)]);
ps := map(p->classify_relation(p,v->v in vsc), ps);
if not(has(ps, {B_LO,B_HI})) then return false; end if;
if not(the(map2(op,3,ps))) then return false; end if;
if not(the(map(abs,map2(op,4,ps)))) then return; false end if;
return true;
elif sh::DomInto then
error "solution should not have DIntos: %1", sh;
else
error "unrecognized DomShape: %1", sh;
end if;
end proc;
local do_sh := proc( sh :: DomShape, ctx :: DomBound, vs, $)
local sol;
if sh :: DomConstrain then
sol := do_Constrain(sh, ctx, vs);
sol := `if`(sol::DomShape, sol, postproc(sol));
if not(sol::DomNoSol) and trivial_sol(sol, ctx) then
userinfo(3, Domain:-Improve,
printf("Discarding solution: %a\n", sol));
sh;
else sol end if;
elif sh :: DomSplit then
DSplit(Partition:-Amap(
[ (c,_)->c
, (p,c)-> p->do_sh(p, applyop(cs->{c,op(cs)},2,ctx), vs)
, c->c ], op(1, sh) ));
elif sh :: DomSum then
map(s->do_sh(s, ctx, vs), sh);
else
DNoSol(sprintf("Don't know how to solve DOMAIN(%a, %a)", ctx, sh));
end if;
end proc;
local do_Constrain := proc( sh :: DomConstrain , ctx, vs_, $ )
local ts, vs := vs_, cs;
cs := { op( Domain:-Bound:-toConstraints(ctx,'no_infinity') ), op(sh) } ;
ts, cs := selectremove(type, cs, `::`);
ts := select(t->op(2,t)<>real, ts);
if ts <> {} and has(cs,ts) then
WARNING("Variables of unrecognized types being passed to SemiAlgebraic: %1",ts);
end if;
try SemiAlgebraic(cs, vs);
catch: DNoSol(StringTools[FormatMessage](lastexception[2..-1]));
end try;
end proc;
end module; #SemiAlgebraic
|
! RUN: %python %S/test_modfile.py %s %flang_fc1
! Ensure that interfaces, which are internal to procedures and are used to
! define the interface of dummy or return value procedures, are included in
! .mod files.
module m
implicit none
contains
function f(x)
real, intent(in) :: x
abstract interface
subroutine used_int(x, p)
implicit none
real, intent(out) :: x
interface
subroutine inner_int(x)
implicit none
real, intent(out) :: x
end subroutine inner_int
end interface
procedure(inner_int) :: p
end subroutine used_int
pure logical function unused_int(i)
implicit none
integer, intent(in) :: i
end function unused_int
end interface
procedure(used_int), pointer :: f
f => null()
contains
subroutine internal()
end subroutine internal
end function f
end module m
!Expect: m.mod
!module m
!contains
!function f(x)
!real(4),intent(in)::x
!procedure(used_int),pointer::f
!abstract interface
!subroutine used_int(x,p)
!real(4),intent(out)::x
!procedure(inner_int)::p
!interface
!subroutine inner_int(x)
!real(4),intent(out)::x
!end
!end interface
!end
!end interface
!end
!end
|
context("Morans I")
test_that("Get the same result as in ape", {
set.seed(123)
graph <- rgraph_ba(t = 199)
w <- approx_geodesic(graph)
x <- rnorm(200)
# Computing Moran's I
ans0 <- moran(x, w)
# Comparing with the ape's package version
ans1 <- ape::Moran.I(x, as.matrix(w))
expect_equivalent(unclass(ans0), unclass(ans1))
})
#
# graphm <- as.matrix(graph)
# microbenchmark::microbenchmark(
# netdiffuseR::moran(x,graph),
# ape::Moran.I(x, graphm), times = 100,
# unit="relative"
# )
|
lemma csqrt_eq_0 [simp]: "csqrt z = 0 \<longleftrightarrow> z = 0" |
export CalculateSampling,
Convmtx,
DotTest,
InnerProduct,
Integrate,
MeasureSNR,
Pad5D,
PadFirstAxis,
PhaseShift,
TriangleFilter
include("CalculateSampling.jl")
include("Convmtx.jl")
include("DotTest.jl")
include("InnerProduct.jl")
include("Integrate.jl")
include("MeasureSNR.jl")
include("Pad5D.jl")
include("PadFirstAxis.jl")
include("PhaseShift.jl")
include("TriangleFilter.jl")
|
import tactic
import data.matrix.basic
import data.matrix.block
import linear_algebra.matrix.block
import linear_algebra.matrix.nonsingular_inverse
import algebra.group.units
import order.well_founded
import algebra.big_operators.basic
-- allows notation for matrix multiplication and summations
open_locale matrix
open_locale big_operators
/-
Currently, whole framework is for a Eucldiean Domains (some results could be weakened to PID or even weaker), and later lemmas have been restriced to nxn matrices rather than nxm
-/
-- # Elementary Matrices
/-
Defines the basis matrix, all zero's except for a 1 in the (i, j)'th entry and three elementary matrices
Left multiplication acts on rows, right multiplication acts on columns, but the effect of the elementary matrices is expressed as lemmas later
* `add_mult n i j a` - is the matrix that (via multiplication) induces the map which adds `a` times row/column `i` to row/column `j`
* `mul_by_unit n i u` - induces a similar map which multiplies row/column `i` by `u`
-/
-- ## Definiton of the Elementary Matrices
namespace elem_matrix
-- Basis Δ (as called in Jacobson)
def basis (R : Type*) [euclidean_domain R] (n : ℕ) (i j : fin n) : matrix (fin n) (fin n) R :=
(λ i' j', if i = i' ∧ j = j' then 1 else 0)
-- Type I: Add multiple of column/row i to j
def add_mult {R : Type*} [euclidean_domain R] (n : ℕ) (i j : fin n) (a : R) (h : i ≠ j) : matrix (fin n) (fin n) R :=
1 + a • (basis R n i j)
-- Type II: Multiply row/column by a unit
def mul_by_unit {R : Type*} [euclidean_domain R] (n : ℕ) (i : fin n) (u : R) (h : is_unit u) : matrix (fin n) (fin n) R :=
matrix.diagonal (λ i', if i' = i then u else 1)
--1 + (u - 1) • (basis R n i i)
-- Type III: Permutation
def perm (R : Type*) [euclidean_domain R] (n : ℕ) (i j : fin n) : matrix (fin n) (fin n) R :=
(equiv.to_pequiv (equiv.swap i j)).to_matrix
-- 1 - (basis R n i i) - (basis R n j j) + (basis R n i j) + (basis R n j i)
-- ## Elementary Matrices are Invertible (units)
/-
Proof all three elementary matrices are invertible, which is expressed as `is_unit M`, by using equivalence between `is_unit M` and `is_unit (det M)`
-/
theorem add_mult_inv {R : Type*} [euclidean_domain R] {n : ℕ} {i j : fin n} {a : R} (h : i ≠ j) : is_unit (add_mult n i j a h) :=
begin
apply (matrix.is_unit_iff_is_unit_det (add_mult n i j a h)).2,
by_cases h' : i < j, -- case split to use upper and lower triangular theorems (essentially same argument), could be condensed
{ rw (matrix.det_of_upper_triangular (add_mult n i j a h) _),
{ unfold add_mult,
unfold basis,
have h₁ : ∀ (x : fin n), ¬(i = x ∧ j = x),
{ simp [h.symm] },
simp [h₁] },
intros k l hlk,
unfold add_mult,
unfold basis,
have h₂ : ¬ (i = k ∧ j = l),
{ rintro ⟨rfl, rfl⟩,
exact asymm h' hlk },
simp [h₂, (ne_of_lt hlk).symm] },
rw (matrix.det_of_lower_triangular (add_mult n i j a h) _),
{ unfold add_mult,
unfold basis,
have h₁ : ∀ (x : fin n), ¬(i = x ∧ j = x),
{ simp [h.symm] },
simp [h₁] },
intros k l hkl,
unfold add_mult,
unfold basis,
have h₂ : ¬ (i = k ∧ j = l),
{ rintro ⟨rfl, rfl⟩,
exact h (false.rec (i = j) (h' hkl)) },
simp [h₂, (ne_of_lt hkl)],
end
theorem mul_by_unit_inv {R : Type*} [euclidean_domain R] {n : ℕ} {i : fin n} {u : R} {h : is_unit u} : is_unit (mul_by_unit n i u h) :=
begin
apply (matrix.is_unit_iff_is_unit_det (mul_by_unit n i u h)).2,
unfold mul_by_unit,
simp [matrix.det_diagonal, finset.prod_ite],
exact is_unit.pow (finset.filter (λ (x : fin n), x = i) finset.univ).card h,
end
theorem perm_inv {R : Type*} [euclidean_domain R] {n : ℕ} {i j : fin n} : is_unit (perm R n i j) :=
begin
apply (matrix.is_unit_iff_is_unit_det (perm R n i j)).2, -- has determinant -1
unfold perm,
rw matrix.det_permutation,
by_cases h : i = j,
{ rw equiv.perm.sign_swap',
simp [h] },
rw equiv.perm.sign_swap,
{ use -1,
simp },
exact h,
end
-- ## Lemmas About The Elementary Matrices
/-
ADD TO LIBRARY IN `data.matrix.pequiv`
This lemma fills in a missing lemma in `data.matrix.pequiv` which is necessary for proof of the effect of the permutation matrix
There are two different expressions of the theorem below, with the second one (using `matrix.submatrix`) being used
-/
/--
variables {m n α : Type*}
lemma to_pequiv_matrix_mul [fintype n] [decidable_eq n] [semiring α] (f : n ≃ n) (M : matrix m n α):
(M ⬝ f.to_pequiv.to_matrix) = λ i j, M i (f.symm j) :=
matrix.ext $ λ i j, by rw [pequiv.matrix_mul_apply, ←equiv.to_pequiv_symm, equiv.to_pequiv_apply]
-/
lemma pequiv.to_pequiv_matrix_mul {m n α : Type*} [fintype n] [decidable_eq n] [semiring α]
(f : n ≃ n) (M : matrix m n α) : (M ⬝ f.to_pequiv.to_matrix) = M.submatrix id (f.symm) :=
matrix.ext $ λ i j, by rw [pequiv.matrix_mul_apply, ←equiv.to_pequiv_symm,
equiv.to_pequiv_apply, matrix.submatrix_apply, id.def]
-- necessary for later lemmas
-- ### Effect of Permutation Matrix
/-
Effect of left and right multiplication by the permutation matrix expressed in two ways each
-/
lemma perm_mul {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (k l : fin n) : ∀ (i j : fin n), A i j = ((elem_matrix.perm R n k l) ⬝ A) (ite (i = k) l (ite (i = l) k i)) j
:= λ i j, by { unfold elem_matrix.perm, simp [pequiv.to_pequiv_mul_matrix, ←equiv.swap_apply_def] }
lemma perm_mul' {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (k l : fin n) : ∀ (i j : fin n), ((elem_matrix.perm R n k l) ⬝ A) i j = A (ite (i = k) l (ite (i = l) k i)) j
:= λ i j, by { unfold elem_matrix.perm, simp [pequiv.to_pequiv_mul_matrix, equiv.swap_apply_def] }
lemma mul_perm {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (k l : fin n) : ∀ (i j : fin n), A i j = (A ⬝ (elem_matrix.perm R n k l)) i (ite (j = k) l (ite (j = l) k j))
:= λ i j, by { unfold elem_matrix.perm, simp [pequiv.to_pequiv_matrix_mul, ←equiv.swap_apply_def] }
lemma mul_perm' {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (k l : fin n) : ∀ (i j : fin n), (A ⬝ (elem_matrix.perm R n k l)) i j = A i (ite (j = k) l (ite (j = l) k j))
:= λ i j, by { unfold elem_matrix.perm, simp [pequiv.to_pequiv_matrix_mul, equiv.swap_apply_def] }
lemma perm_eq_id {R : Type*} [euclidean_domain R] {n : ℕ} : ∀ {i : fin n}, elem_matrix.perm R n i i = (1 : matrix (fin n) (fin n) R) :=
begin
intro i,
unfold perm,
simp,
end
-- ### Effect of Add Mult Matrix
-- Left Mult
lemma add_mult_mul {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (i j : fin n) (c : R) (h : i ≠ j) : ((add_mult n i j c h) ⬝ A) i j = (A i j) + c * (A j j) :=
begin
rw matrix.mul_apply,
unfold add_mult basis,
simp,
ring_nf,
rw finset.sum_add_distrib,
rw fintype.sum_eq_add_sum_compl i,
simp,
rw finset.sum_eq_zero _,
intros x hx,
rw [finset.mem_compl, finset.mem_singleton] at hx,
simp [matrix.one_apply_ne (ne_comm.mp hx)]
end
-- Right Mult
lemma mul_add_mult {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (i j : fin n) (c : R) (h : i ≠ j) : (A ⬝ (add_mult n i j c h)) i j = (A i j) + c * (A i i) :=
begin
rw matrix.mul_apply,
unfold add_mult basis,
simp,
ring_nf,
simp [add_mul],
rw finset.sum_add_distrib,
rw fintype.sum_eq_add_sum_compl j,
simp,
rw finset.sum_eq_zero _,
{ ring_nf },
intros x hx,
rw [finset.mem_compl, finset.mem_singleton] at hx,
simp [matrix.one_apply_ne hx]
end
/-
No lemmas about the effect of the `unit_mul` elementary matrix since it isn't used in the restriced snf definition (where we don't require diagonal entries successively divide)
-/
end elem_matrix
-- # Equivalence of m x n matrices
/-
Basic Framework for the equivalence of matrices, that this is an equivalence relation and that left and right multiplication by invertable (`is_unit`) matrices preserves equivalence
-/
namespace matrix_equiv_rel
-- ## Equivalence Definition
-- two mxn matrices A and B are quivalent if A = M B N and M and N are invertible
def r (R : Type*) [euclidean_domain R] (m n : ℕ) : (matrix (fin m) (fin n) R) → (matrix (fin m) (fin n) R) → Prop :=
λ A, (λ B, ∃ (M : matrix (fin m) (fin m) R) (N : matrix (fin n) (fin n) R), (is_unit M) ∧ (is_unit N) ∧ ( A = M ⬝ B ⬝ N ))
-- ## Matrix Equivalence is an Equivalence Relation
lemma r_refl {R : Type*} [euclidean_domain R] {m n : ℕ} : reflexive (r R m n) :=
begin
intro A,
use [1,1],
finish,
end
lemma r_symm {R : Type*} [euclidean_domain R] {m n : ℕ} : symmetric (r R m n) :=
begin
rintros A B ⟨M, N, hM, hN, h⟩,
use [M⁻¹, N⁻¹],
simp [matrix.nonsing_inv_eq_ring_inverse, hM, hN] ,
simp [← matrix.nonsing_inv_eq_ring_inverse],
calc
B = (M⁻¹ ⬝ M) ⬝ B ⬝ (N ⬝ N⁻¹) : by {simp [matrix.mul_nonsing_inv N ((matrix.is_unit_iff_is_unit_det N).mp hN), matrix.nonsing_inv_mul M ((matrix.is_unit_iff_is_unit_det M).mp hM)]}
... = M⁻¹ ⬝ (M ⬝ B ⬝ N) ⬝ N⁻¹ : by {simp [matrix.mul_assoc]}
... = M⁻¹ ⬝ A ⬝ N⁻¹ : by {rw h}
end
lemma r_trans {R : Type*} [euclidean_domain R] {m n : ℕ} : transitive (r R m n) :=
begin
rintros A B C ⟨M₁, N₁, hM₁, hN₁, h₁⟩ ⟨M₂, N₂, hM₂, hN₂, h₂⟩,
use [M₁ ⬝ M₂, N₂ ⬝ N₁],
split,
{ exact is_unit.mul hM₁ hM₂ },
split,
{ exact is_unit.mul hN₂ hN₁ },
calc
A = M₁ ⬝ B ⬝ N₁ : h₁
... = M₁ ⬝ (M₂ ⬝ C ⬝ N₂) ⬝ N₁ : by {rw h₂}
... = M₁ ⬝ M₂ ⬝ C ⬝ (N₂ ⬝ N₁) : by {simp only [matrix.mul_assoc]}
end
theorem r_equiv {R : Type*} [euclidean_domain R] {m n : ℕ} : equivalence (r R m n) := ⟨r_refl, r_symm, r_trans⟩
-- ## Basic Equivalence Lemmas
-- left and right multiplication by invertible matrix preserves equivalence (in particular the elementary matrices)
lemma unit_mul {R : Type*} [euclidean_domain R] {m n : ℕ} (M : matrix (fin m) (fin n) R) (A : matrix (fin m) (fin m) R) (h : is_unit A) : r R m n M (A ⬝ M) :=
begin
use [A⁻¹, 1],
simp [matrix.nonsing_inv_eq_ring_inverse, h, ← matrix.mul_assoc, ← matrix.mul_eq_mul, (ring.inverse_mul_cancel A h)]
end
lemma mul_unit {R : Type*} [euclidean_domain R] {m n : ℕ} (M : matrix (fin m) (fin n) R) (A : matrix (fin n) (fin n) R) (h : is_unit A) : r R m n M (M ⬝ A) :=
begin
use [1, A⁻¹],
simp [matrix.nonsing_inv_eq_ring_inverse, h, matrix.mul_assoc, ← matrix.mul_eq_mul, (ring.mul_inverse_cancel A h)]
end
end matrix_equiv_rel
-- # Smith Normal Form
-- Notation for euclidean_domain.r, the well_founded relation to replace euclidean valuation function
local infix ` ≺ `:50 := euclidean_domain.r
-- If `δ` was the euclidean valuation function, as in Jacobson book, then we have the following equivalence `a ≺ b ↔ δ(a) < δ(b)`
namespace smith_norm_form
-- ## Definitions
-- Simple version of smith normal form, without division condition, and limited to nxn
-- See full definition in comments at bottom
def snf {n : ℕ} {R : Type*} [euclidean_domain R] [decidable_eq R] (A : matrix (fin n) (fin n) R) : Prop :=
∃ (d : (fin n) → R) (r : ℕ), (A = matrix.diagonal d) ∧ (∀ (i : fin n), ↑i ≥ r ↔ d i = 0 ) --∧ (∀ (i j : fin n), (i ≤ j) → ↑j < r → (d i) ∣ (d j))
-- desired form for induction step
def simple_block_diag {R : Type*} [euclidean_domain R] {n : ℕ} (a : R) (A : matrix (fin n) (fin n) R) : matrix (fin (n + 1)) (fin (n + 1)) R :=
matrix.reindex (fin_sum_fin_equiv.trans fin_add_flip) (fin_sum_fin_equiv.trans fin_add_flip) (matrix.from_blocks (a • (1 : matrix (fin 1) (fin 1) R)) 0 0 A)
-- use `matrix.submatrix` instead?
/-
a 0 0 0
0 ( )
0 | A |
0 ( )
-/
-- An element of a matrix (over a ED) is minimal if it's non zero and has minimal valuation (excluding zeros)
def is_minimal {R : Type*} [euclidean_domain R] {n : ℕ} (A : matrix (fin n) (fin n) R) (k l : fin n) : Prop := (A k l ≠ 0) ∧ (∀ (i j : fin n), A i j ≠ 0 → ¬((A i j) ≺ (A k l)))
-- ## Lemmas Setting Up Main Result
-- Every non-zero matrix has an element with minimal valuation
-- this lemma specifically can give the indices of the minimal element
lemma min_valuation_of_mat {R : Type*} [euclidean_domain R] [decidable_eq R] {n : ℕ} (A : matrix (fin n) (fin n) R) (hA0 : A ≠ 0) : ∃ (k l : fin n), is_minimal A k l :=
begin
-- A as a finset without the zero's
let A' := finset.filter (λ (a : R), a ≠ 0) (finset.image₂ A finset.univ finset.univ),
-- A has a non-zero element
have hA0' : ∃ (i' j' : fin n), A i' j' ≠ 0,
{ by_contra h',
push_neg at h',
have : A = 0,
ext A,
exact h' _ _,
contradiction },
rcases hA0' with ⟨i', j', hA0'⟩,
-- A' is nonempty
have hA'ne : A'.nonempty,
{ use A i' j',
simp [A'],
use [i', j'] },
-- A' has a minimal element since ≺ is well founded
rcases (well_founded.has_min euclidean_domain.r_well_founded (↑A') hA'ne) with ⟨m, hm, hmin⟩,
rcases ((finset.mem_image₂).mp (finset.mem_of_mem_filter m hm)) with ⟨k, l, _, _, hmin'⟩,
use [k, l],
split,
{ rw hmin',
exact (finset.mem_filter.mp hm).2 },
intros i j h,
have h'' : (A i j) ∈ A',
{ dsimp [A'],
rw finset.mem_filter,
split,
{ rw finset.mem_image₂,
use [i, j],
simp },
exact h },
rw hmin',
exact hmin (A i j) h''
end
-- Moves minimal element to top left
lemma minimal_element_to_00 {R : Type*} [euclidean_domain R] [decidable_eq R] {n : ℕ} (A : matrix (fin (n + 1)) (fin (n + 1)) R) (hA0 : A ≠ 0) : ∃ (B : matrix (fin (n + 1)) (fin (n + 1)) R), is_minimal B 0 0 ∧ matrix_equiv_rel.r R (n + 1) (n + 1) A B :=
begin
rcases (min_valuation_of_mat A hA0) with ⟨i, j, h⟩, -- A i j is minimal elt of A
use ((elem_matrix.perm R (n + 1) 0 i) ⬝ A ⬝ (elem_matrix.perm R (n + 1) 0 j)),
split,
{ -- minimal element is at 0 0
have aux : ∀ (k : fin (n + 1)), (ite (k = 0) k (ite (k = k) 0 k)) = 0,
{ have hj : j = 0 ∨ j ≠ 0, by tauto,
cases hj;
simp [hj] },
have h₁ : A i j = ((elem_matrix.perm R (n + 1) 0 i) ⬝ A ⬝ (elem_matrix.perm R (n + 1) 0 j)) 0 0,
{ have H₁ := (elem_matrix.mul_perm ((elem_matrix.perm R (n + 1) 0 i) ⬝ A) 0 j) 0 j,
rw [aux j] at H₁,
rw [← H₁, ((elem_matrix.perm_mul A 0 i) i j), aux i] },
have h₂ : ∀ (i' j' : fin (n + 1)), ∃ (k l : fin (n + 1)), A k l = ((elem_matrix.perm R (n + 1) 0 i) ⬝ A ⬝ (elem_matrix.perm R (n + 1) 0 j)) i' j',
{ intros i' j',
-- Very manual solution
have hi' : i' = 0 ∨ i' = i ∨ (i' ≠ 0 ∧ i' ≠ i), by tauto,
have hj' : j' = 0 ∨ j' = j ∨ (j' ≠ 0 ∧ j' ≠ j), by tauto,
have hi : i = 0 ∨ i ≠ 0, by tauto,
have hj : j = 0 ∨ j ≠ 0, by tauto,
cases hi;
cases hj,
{ rw [hi, hj, elem_matrix.perm_eq_id],
use [i', j'],
simp },
{ rw [hi, elem_matrix.perm_eq_id],
simp,
rcases hj' with hj' | hj' | ⟨hj'₁, hj'₂⟩,
{ use [i', j],
rw [hj', (elem_matrix.mul_perm A 0 j) i' j, aux j] },
{ use [i', 0],
simp [hj', (elem_matrix.mul_perm A 0 j) i' 0] },
{ use [i', j'],
simp [(elem_matrix.mul_perm A 0 j) i' j', hj'₁, hj'₂] } },
{ rw [hj, elem_matrix.perm_eq_id],
simp,
rcases hi' with hi' | hi' | ⟨hi'₁, hi'₂⟩,
{ use [i, j'],
rw [hi', (elem_matrix.perm_mul A 0 i) i j', aux i] },
{ use [0, j'],
simp [hi', (elem_matrix.perm_mul A 0 i) 0 j'] },
{ use [i', j'],
simp [(elem_matrix.perm_mul A 0 i) i' j', hi'₁, hi'₂] } },
{ have H₁ := elem_matrix.mul_perm ((elem_matrix.perm R (n + 1) 0 i) ⬝ A) 0 j,
have H₂ := elem_matrix.perm_mul A 0 i,
rcases hi' with hi' | hi' | ⟨hi'₁, hi'₂⟩;
rcases hj' with hj' | hj' | ⟨hj'₁, hj'₂⟩,
{ rw [hi', hj'] at *,
use [i, j],
have H₁' := H₁ 0 j,
rw [aux j] at H₁',
rw [← H₁', (H₂ i j), aux i] },
{ rw [hi', hj'] at *,
use [i, 0],
have H₁' := H₁ 0 0,
simp at H₁',
rw [← H₁', (H₂ i 0), aux i] },
{ rw [hi'] at *,
use [i, j'],
have H₁' := H₁ 0 j',
simp [hj'₁, hj'₂] at H₁',
rw [← H₁', (H₂ i j'), aux i] },
{ rw [hi', hj'] at *,
use [0, j],
have H₁' := H₁ i j,
rw [aux j] at H₁',
simp [← H₁', (H₂ 0 j)] },
{ rw [hi', hj'] at *,
use [0, 0],
have H₁' := H₁ i 0,
simp at H₁',
simp [← H₁', (H₂ 0 0)] },
{ rw hi' at *,
use [0, j'],
have H₁' := H₁ i j',
simp [hj'₁, hj'₂] at H₁',
simp [← H₁', (H₂ 0 j')] },
{ rw hj' at *,
use [i', j],
have H₁' := H₁ i' j,
rw aux j at H₁',
simp [← H₁', (H₂ i' j), hi'₁, hi'₂] },
{ rw hj' at *,
use [i', 0],
have H₁' := H₁ i' 0,
simp at H₁',
simp [← H₁', (H₂ i' 0), hi'₁, hi'₂] },
{ use [i', j'],
have H₁' := H₁ i' j',
simp [hj'₁, hj'₂] at H₁',
simp [← H₁', (H₂ i' j'), hi'₁, hi'₂] } } },
unfold is_minimal at h ⊢,
rw ← h₁,
split,
{ exact h.1 },
intros i' j' H,
rcases h₂ i' j' with ⟨k, l, h'⟩,
rw ← h' at H ⊢,
exact h.2 k l H },
-- matrices are equivalent
have h₁ := matrix_equiv_rel.unit_mul A (elem_matrix.perm R (n + 1) 0 i) elem_matrix.perm_inv,
have h₂ := matrix_equiv_rel.mul_unit ((elem_matrix.perm R (n + 1) 0 i) ⬝ A) (elem_matrix.perm R (n + 1) 0 j) elem_matrix.perm_inv,
exact matrix_equiv_rel.r_trans h₁ h₂,
end
-- Assume B 0 0 doesn't divide all elements in row 1 or column 1, then perform EA to give a new (smaller) minimal element
lemma temp1 {R : Type*} [euclidean_domain R] [decidable_eq R] {n : ℕ} (A : matrix (fin (n + 1)) (fin (n + 1)) R) (hA0 : A ≠ 0) (h00 : is_minimal A 0 0) (i : fin (n + 1)) (H : ¬(A 0 0 ∣ A i 0) ∨ ¬(A 0 0 ∣ A 0 i) ) : ∃ (B : matrix (fin (n + 1)) (fin (n + 1)) R), ((B i 0 ≺ A 0 0) ∨ (B 0 i ≺ A 0 0)) ∧ matrix_equiv_rel.r R (n + 1) (n + 1) A B :=
begin
have hi : i ≠ 0,
{ intro hc,
rw hc at H,
cases H;
contradiction },
cases H,
-- Argument for column 0 and row 0 are almost identical but do have small differences
-- column 0
{ let B := (elem_matrix.add_mult (n + 1) i 0 (-((A i 0) / (A 0 0))) hi),
have h' : is_unit B,
{ exact @elem_matrix.add_mult_inv R _inst_1 (n + 1) i 0 (-((A i 0) / (A 0 0))) hi },
use [B ⬝ A],
split,
{ left,
-- minimal valuation is lower
have h : (B ⬝ A) i 0 = (A i 0) % (A 0 0),
{ simp [euclidean_domain.mod_eq_sub_mul_div],
rw elem_matrix.add_mult_mul A i 0 (-((A i 0) / (A 0 0))) hi,
ring_nf },
rw h,
exact euclidean_domain.remainder_lt (A i 0) h00.1 },
-- matrices are equivalent
-- unfold matrix_equiv_rel.r,
use [B⁻¹, 1],
simp,
split,
{ cases h' with u h',
use u⁻¹,
simp [h'] },
simp [← matrix.mul_assoc, matrix.nonsing_inv_mul B ((matrix.is_unit_iff_is_unit_det B).1 h')] },
-- row zero
let B := (elem_matrix.add_mult (n + 1) 0 i (-((A 0 i) / (A 0 0))) hi.symm),
have h' : is_unit B,
{ exact @elem_matrix.add_mult_inv R _inst_1 (n + 1) 0 i (-((A 0 i) / (A 0 0))) hi.symm },
use [A ⬝ B],
split,
{ right,
-- minimal valuation is lower
have h : (A ⬝ B) 0 i = (A 0 i) % (A 0 0),
{ simp [euclidean_domain.mod_eq_sub_mul_div],
rw elem_matrix.mul_add_mult A 0 i (-((A 0 i) / (A 0 0))) hi.symm,
ring_nf },
rw h,
exact euclidean_domain.remainder_lt (A 0 i) h00.1 },
-- matrices are equivalent
-- unfold matrix_equiv_rel.r,
use [1, B⁻¹],
simp,
split,
{ cases h' with u h',
use u⁻¹,
simp [h'] },
have := ((matrix.is_unit_iff_is_unit_det B).1 h'),
simp [matrix.mul_assoc, matrix.mul_nonsing_inv B ((matrix.is_unit_iff_is_unit_det B).1 h')]
end
-- __1__ Assume B 0 0 does divide all elements in row 1 or column 1, then can make them all into zero's __For Loop Implementation__
-- __2__ We will always be in one of the above cases, if first one, there will be finitely many steps to second case (using well founded tactics, see extended EA and gcd processes proof) By The Equation Compiler and __Using_Well_Founded__
-- inductive steps between n and (n + 1)
-- __3__
lemma equiv_simple_block_diag {R : Type*} [euclidean_domain R] {n : ℕ} (h : n > 0) (A : matrix (fin (n + 1)) (fin (n + 1)) R) : ∃ (B : matrix (fin n) (fin n) R) (b : R), matrix_equiv_rel.r R (n + 1) (n + 1) A (simple_block_diag b B) :=
begin
unfold simple_block_diag,
sorry
end
-- use `matrix.submatrix`?
-- __4__
lemma temp2 {R : Type*} [euclidean_domain R] [decidable_eq R] {n : ℕ} (hn : n > 0) (A : matrix (fin n) (fin n) R) (B : matrix (fin n) (fin n) R) (hB : snf B) (hA : matrix_equiv_rel.r R n n A B) {a : R} : ∃ (C : matrix (fin (n + 1)) (fin (n + 1)) R), matrix_equiv_rel.r R (n + 1) (n + 1) (simple_block_diag a A) C ∧ snf C := sorry
-- Show that any zero matrix is in smith normal form
-- show that any non-zero 1x1 matrix is in smith normal form
/-
__Miscellaneous Defintions of SNF not currently implemented__
def smith_norm_form {n : ℕ} {D : Type*} [euclidean_domain D] (A : matrix (fin n) (fin n) D) : Prop :=
∃ (d : (fin n) → D) (r : ℕ), (A = matrix.diagonal d) ∧ (∀ (i : fin n), ↑i ≥ r ↔ d i = 0 ) ∧ (∀ (i j : fin n), (i ≤ j) → ↑j < r → (d i) ∣ (d j))
-- # Smith Normal Form (limited to nxn matrices)
def smith_norm_form {n : ℕ} {D : Type*} [euclidean_domain D] (A : matrix (fin n) (fin n) D) : Prop :=
∃ (d : (fin n) → D) (r : ℕ), (A = matrix.diagonal d) ∧ (∀ (i : fin n), ↑i ≥ r ↔ d i = 0 ) ∧ (∀ (i j : fin n), (i ≤ j) → ↑j < r → (d i) ∣ (d j))
-- # Main Theorem
theorem mat_equiv_to_smith_norm_mat {n : ℕ} {D : Type*} {D : Type*} [euclidean_domain D] (A : matrix (fin n) (fin n) D) : ∃ (B : matrix (fin n) (fin n) D), smith_norm_form B ∧ (matrix_equiv_rel.R D n n A B) :=
begin
sorry
end
-/
end smith_norm_form |
[STATEMENT]
lemma interior_union_boundary:
shows "interior (X \<union> Y) = interior X \<union> interior Y
\<longleftrightarrow> boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)" (is "(?lhs1 = ?lhs2) \<longleftrightarrow> ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (interior (X \<union> Y) = interior X \<union> interior Y) = (boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y))
[PROOF STEP]
proof(rule iffI[OF _ subset_antisym[OF subsetI]])
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. interior (X \<union> Y) = interior X \<union> interior Y \<Longrightarrow> boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
2. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
3. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
assume "?lhs1 = ?lhs2"
[PROOF STATE]
proof (state)
this:
interior (X \<union> Y) = interior X \<union> interior Y
goal (3 subgoals):
1. interior (X \<union> Y) = interior X \<union> interior Y \<Longrightarrow> boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
2. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
3. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior (X \<union> Y) = interior X \<union> interior Y
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
interior (X \<union> Y) = interior X \<union> interior Y
goal (1 subgoal):
1. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
[PROOF STEP]
by (force simp: boundary_def)
[PROOF STATE]
proof (state)
this:
boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
goal (2 subgoals):
1. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
2. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
2. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
2. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
assume ?rhs and "x \<in> ?lhs1"
[PROOF STATE]
proof (state)
this:
boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
x \<in> interior (X \<union> Y)
goal (2 subgoals):
1. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
2. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
have "x \<in> ?lhs2" if "x \<notin> interior X" "x \<notin> interior Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
proof(cases "x \<in> boundary X \<inter> boundary Y")
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. x \<in> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x \<in> boundary X \<inter> boundary Y
goal (2 subgoals):
1. x \<in> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
with \<open>?rhs\<close> \<open>x \<in> ?lhs1\<close>
[PROOF STATE]
proof (chain)
picking this:
boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
x \<in> interior (X \<union> Y)
x \<in> boundary X \<inter> boundary Y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y)
x \<in> interior (X \<union> Y)
x \<in> boundary X \<inter> boundary Y
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
by (simp add: boundary_def subset_iff)
[PROOF STATE]
proof (state)
this:
x \<in> interior X \<union> interior Y
goal (1 subgoal):
1. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<notin> boundary X \<inter> boundary Y
goal (1 subgoal):
1. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<notin> boundary X \<inter> boundary Y
[PROOF STEP]
consider (X) "x \<notin> boundary X" | (Y) "x \<notin> boundary Y"
[PROOF STATE]
proof (prove)
using this:
x \<notin> boundary X \<inter> boundary Y
goal (1 subgoal):
1. \<lbrakk>x \<notin> boundary X \<Longrightarrow> thesis; x \<notin> boundary Y \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>x \<notin> boundary X \<Longrightarrow> ?thesis; x \<notin> boundary Y \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
goal (1 subgoal):
1. x \<notin> boundary X \<inter> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>x \<notin> boundary X \<Longrightarrow> ?thesis; x \<notin> boundary Y \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>x \<notin> boundary X \<Longrightarrow> ?thesis; x \<notin> boundary Y \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
case X
[PROOF STATE]
proof (state)
this:
x \<notin> boundary X
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from X \<open>x \<notin> interior X\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> boundary X
x \<notin> interior X
[PROOF STEP]
have "x \<in> exterior X"
[PROOF STATE]
proof (prove)
using this:
x \<notin> boundary X
x \<notin> interior X
goal (1 subgoal):
1. x \<in> exterior X
[PROOF STEP]
by (simp add: exterior_def)
[PROOF STATE]
proof (state)
this:
x \<in> exterior X
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>x \<notin> boundary X\<close> \<open>x \<in> exterior X\<close> \<open>x \<notin> interior X\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> boundary X
x \<in> exterior X
x \<notin> interior X
[PROOF STEP]
obtain U where "open U" "U \<subseteq> - X" "x \<in> U"
[PROOF STATE]
proof (prove)
using this:
x \<notin> boundary X
x \<in> exterior X
x \<notin> interior X
goal (1 subgoal):
1. (\<And>U. \<lbrakk>open U; U \<subseteq> - X; x \<in> U\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis ComplI DiffI boundary_def closure_interior interior_subset open_interior)
[PROOF STATE]
proof (state)
this:
open U
U \<subseteq> - X
x \<in> U
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>x \<in> interior (X \<union> Y)\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior (X \<union> Y)
[PROOF STEP]
obtain U' where "open U'" "U' \<subseteq> X \<union> Y" "x \<in> U'"
[PROOF STATE]
proof (prove)
using this:
x \<in> interior (X \<union> Y)
goal (1 subgoal):
1. (\<And>U'. \<lbrakk>open U'; U' \<subseteq> X \<union> Y; x \<in> U'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson interiorE)
[PROOF STATE]
proof (state)
this:
open U'
U' \<subseteq> X \<union> Y
x \<in> U'
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>U \<subseteq> - X\<close> \<open>U' \<subseteq> X \<union> Y\<close>
[PROOF STATE]
proof (chain)
picking this:
U \<subseteq> - X
U' \<subseteq> X \<union> Y
[PROOF STEP]
have "U \<inter> U' \<subseteq> Y"
[PROOF STATE]
proof (prove)
using this:
U \<subseteq> - X
U' \<subseteq> X \<union> Y
goal (1 subgoal):
1. U \<inter> U' \<subseteq> Y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
U \<inter> U' \<subseteq> Y
goal (2 subgoals):
1. x \<notin> boundary X \<Longrightarrow> x \<in> interior X \<union> interior Y
2. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
with \<open>x \<notin> interior Y\<close> \<open>open U'\<close> \<open>open U\<close> \<open>x \<in> U'\<close> \<open>x \<in> U\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> interior Y
open U'
open U
x \<in> U'
x \<in> U
U \<inter> U' \<subseteq> Y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<notin> interior Y
open U'
open U
x \<in> U'
x \<in> U
U \<inter> U' \<subseteq> Y
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
by (meson IntI interiorI open_Int)
[PROOF STATE]
proof (state)
this:
x \<in> interior X \<union> interior Y
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
case Y
[PROOF STATE]
proof (state)
this:
x \<notin> boundary Y
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from Y \<open>x \<notin> interior Y\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> boundary Y
x \<notin> interior Y
[PROOF STEP]
have "x \<in> exterior Y"
[PROOF STATE]
proof (prove)
using this:
x \<notin> boundary Y
x \<notin> interior Y
goal (1 subgoal):
1. x \<in> exterior Y
[PROOF STEP]
by (simp add: exterior_def)
[PROOF STATE]
proof (state)
this:
x \<in> exterior Y
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>x \<notin> boundary Y\<close> \<open>x \<in> exterior Y\<close> \<open>x \<notin> interior Y\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> boundary Y
x \<in> exterior Y
x \<notin> interior Y
[PROOF STEP]
obtain U where "open U" "U \<subseteq> - Y" "x \<in> U"
[PROOF STATE]
proof (prove)
using this:
x \<notin> boundary Y
x \<in> exterior Y
x \<notin> interior Y
goal (1 subgoal):
1. (\<And>U. \<lbrakk>open U; U \<subseteq> - Y; x \<in> U\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis ComplI DiffI boundary_def closure_interior interior_subset open_interior)
[PROOF STATE]
proof (state)
this:
open U
U \<subseteq> - Y
x \<in> U
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>x \<in> interior (X \<union> Y)\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior (X \<union> Y)
[PROOF STEP]
obtain U' where "open U'" "U' \<subseteq> X \<union> Y" "x \<in> U'"
[PROOF STATE]
proof (prove)
using this:
x \<in> interior (X \<union> Y)
goal (1 subgoal):
1. (\<And>U'. \<lbrakk>open U'; U' \<subseteq> X \<union> Y; x \<in> U'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson interiorE)
[PROOF STATE]
proof (state)
this:
open U'
U' \<subseteq> X \<union> Y
x \<in> U'
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
from \<open>U \<subseteq> -Y\<close> \<open>U' \<subseteq> X \<union> Y\<close>
[PROOF STATE]
proof (chain)
picking this:
U \<subseteq> - Y
U' \<subseteq> X \<union> Y
[PROOF STEP]
have "U \<inter> U' \<subseteq> X"
[PROOF STATE]
proof (prove)
using this:
U \<subseteq> - Y
U' \<subseteq> X \<union> Y
goal (1 subgoal):
1. U \<inter> U' \<subseteq> X
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
U \<inter> U' \<subseteq> X
goal (1 subgoal):
1. x \<notin> boundary Y \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
with \<open>x \<notin> interior X\<close> \<open>open U'\<close> \<open>open U\<close> \<open>x \<in> U'\<close> \<open>x \<in> U\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<notin> interior X
open U'
open U
x \<in> U'
x \<in> U
U \<inter> U' \<subseteq> X
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<notin> interior X
open U'
open U
x \<in> U'
x \<in> U
U \<inter> U' \<subseteq> X
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
by (meson IntI interiorI open_Int)
[PROOF STATE]
proof (state)
this:
x \<in> interior X \<union> interior Y
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x \<in> interior X \<union> interior Y
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>x \<notin> interior X; x \<notin> interior Y\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
goal (2 subgoals):
1. \<And>x. \<lbrakk>boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y); x \<in> interior (X \<union> Y)\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
2. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
with \<open>x \<in> ?lhs1\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior (X \<union> Y)
\<lbrakk>x \<notin> interior X; x \<notin> interior Y\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
[PROOF STEP]
show "x \<in> ?lhs2"
[PROOF STATE]
proof (prove)
using this:
x \<in> interior (X \<union> Y)
\<lbrakk>x \<notin> interior X; x \<notin> interior Y\<rbrakk> \<Longrightarrow> x \<in> interior X \<union> interior Y
goal (1 subgoal):
1. x \<in> interior X \<union> interior Y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> interior X \<union> interior Y
goal (1 subgoal):
1. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. boundary X \<inter> boundary Y \<subseteq> boundary (X \<union> Y) \<Longrightarrow> interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
show "?lhs2 \<subseteq> ?lhs1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
[PROOF STEP]
by (simp add: interior_mono)
[PROOF STATE]
proof (state)
this:
interior X \<union> interior Y \<subseteq> interior (X \<union> Y)
goal:
No subgoals!
[PROOF STEP]
qed |
(*
This exercise introduces the basic Iris Proof Mode tactics by proving a simple
example: a function that swaps the contents of two pointers. We will use this
function to implement two other functions.
*)
From iris.heap_lang Require Import proofmode notation.
(* The swap function, defined as a heap-lang value. This looks like an ordinary
Coq function, but it is not: heap-lang is a deeply embedded language in Coq. It
uses strings for name binding and notations close to Coq's (but typically
augmented with a colon to avoid ambiguity) to make it easy to read and write
programs. *)
Definition swap : val := λ: "x" "y",
let: "tmp" := !"x" in
"x" <- !"y";;
"y" <- "tmp".
(* Using swap, we can define functions that rotate three pointers in left and
right direction. *)
Definition rotate_r : val := λ: "x" "y" "z",
swap "y" "z";; swap "x" "y".
Definition rotate_l : val := λ: "x" "y" "z",
swap "x" "y";; swap "y" "z".
Section proof.
(* Iris is parameterized by the type of ghost state that is needed to carry out
a proof. As such, the type of Iris propositions [iProp] is indexed by a [Σ]: a
list of cameras (actually, functors from OFEs to cameras). To make our proofs
generic, we abstract over any such [Σ] and use type classes to ensure that the
necessary cameras are present in [Σ].
For this proof, we do not need any special ghost state (i.e. cameras) apart from
the ghost state that's the heap-lang uses internally for modeling the [l ↦ v]
connective. The cameras for this ghost state is provided by the class [heapG].
*)
Context `{!heapG Σ}.
Lemma swap_spec x y v1 v2 :
{{{ x ↦ v1 ∗ y ↦ v2 }}} swap #x #y {{{ RET #(); x ↦ v2 ∗ y ↦ v1 }}}.
(* The "Texan triple" [ {{{ P }}} e {{{ RET v, Q }}} ] is syntactic sugar for:
∀ Φ, P -∗ (Q -∗ Φ v) -∗ WP e {{ v, Φ v }}
Which is logically equivalent to [ P -∗ WP e {{ x, x = v ∗ Q }} ]
In practice, the "Texan triple" is not more difficult to prove, but usually
easier to use in other proofs, because the post-condition does not have to
syntactically match [Q]. Using this way of stating specifications, the
consequence and framing rule is implicitly applied on the post-condition.
Note that [ # v ] is the embedding of values ([bool], [Z], [loc]) into
heap-lang values.*)
Proof.
iIntros (Φ) "[Hx Hy] Post".
unfold swap.
wp_lam. wp_let.
wp_load. wp_let.
wp_load. wp_store.
wp_store.
iApply "Post".
iSplitL "Hx".
- iApply "Hx".
- iApply "Hy".
Qed.
(* Same lemma, but using a bit of automation to shorten the proof. *)
Lemma swap_spec_2 x y v1 v2 :
{{{ x ↦ v1 ∗ y ↦ v2 }}} swap #x #y {{{ RET #(); x ↦ v2 ∗ y ↦ v1 }}}.
Proof.
iIntros (Φ) "[??] Post".
wp_lam. wp_let. wp_load. wp_let. wp_load. wp_store. wp_store.
iApply "Post". iFrame. done.
Qed.
(* We can further automate the lemma by defining a simple Ltac tactic for
symbolic executing. *)
Ltac wp_exec := repeat (wp_lam || wp_pure _ || wp_load || wp_store).
(* This tactic repeatedly tries to symbolically execute pure redexes, loads and
stores. It makes use of the tactic [wp_pure t], which tries to find the redex
[t] in the goal, and executes that redex. The redex [t] may contain holes, and
as such, tactics like [wp_seq] are actually defined as [wp_pure (_ ;; _)%E]. By
using [wp_pure _] it will symbolically execute *any* pure redex. *)
(* Same lemma again, but now using the tactic we just defined. *)
Lemma swap_spec_2_more_automation x y v1 v2 :
{{{ x ↦ v1 ∗ y ↦ v2 }}} swap #x #y {{{ RET #(); x ↦ v2 ∗ y ↦ v1 }}}.
Proof.
iIntros (Φ) "[??] Post". wp_exec.
iApply "Post". iFrame. done.
Qed.
Lemma rotate_r_spec x y z v1 v2 v3 :
{{{ x ↦ v1 ∗ y ↦ v2 ∗ z ↦ v3 }}}
rotate_r #x #y #z
{{{ RET #(); x ↦ v3 ∗ y ↦ v1 ∗ z ↦ v2 }}}.
Proof.
(* As in Coq, the IPM introduction pattern (p1 & p2 & .. & pn) ] is syntactic
sugar for [ [p1 [p2 [... pn]]] ]. *)
iIntros (Φ) "(Hx & Hy & Hz) Post".
unfold rotate_r. wp_lam. do 2 wp_let.
wp_bind (swap _ _).
iApply (swap_spec with "[Hy Hz]").
{ iFrame. }
(* Inspired by ssreflect, the IPM introduction pattern [ /= ] performs
[simpl]. *)
iNext. iIntros "[Hy Hz] /=". wp_seq.
(* We can also immediately frame hypothesis when using a lemma: *)
iApply (swap_spec with "[$Hx $Hy]"); iNext; iIntros "[Hx Hy]".
iApply "Post". iFrame.
Qed.
Lemma rotate_r_spec_again x y z v1 v2 v3 :
{{{ x ↦ v1 ∗ y ↦ v2 ∗ z ↦ v3 }}}
rotate_r #x #y #z
{{{ RET #(); x ↦ v3 ∗ y ↦ v1 ∗ z ↦ v2 }}}.
Proof.
iIntros (Φ) "(Hx & Hy & Hz) Post". wp_lam. do 2 wp_let.
(* We can shorten the above a bit: Instead of using the [iApply] tactic, we
can use [wp_apply] which automatically uses [wp_bind] first. Also, it strips
the later [▷] by calling [iNext] afterwards. *)
wp_apply (swap_spec with "[$Hy $Hz]"); iIntros "[Hy Hz] /="; wp_seq.
wp_apply (swap_spec with "[$Hx $Hy]"); iIntros "[Hx Hy] /=".
iApply "Post". iFrame.
Qed.
(* *Exercise*: Do this proof yourself. Try a couple of variations of the tactics
we have seen before:
- Do the whole proof explicitly by proving [swap] inline,
- Use the specification of [swap] in combination with [iApply],
- Use the specification of [swap] in combination with [wp_apply]
*)
Lemma rotate_l_spec x y z v1 v2 v3 :
{{{ x ↦ v1 ∗ y ↦ v2 ∗ z ↦ v3 }}}
rotate_l #x #y #z
{{{ RET #(); x ↦ v2 ∗ y ↦ v3 ∗ z ↦ v1 }}}.
(* SOLUTION *) Proof.
iIntros (Φ) "(Hx & Hy & Hz) Post". unfold rotate_l. wp_lam. do 2 wp_let.
wp_apply (swap_spec with "[$Hx $Hy]"); iIntros "[Hx Hy]"; wp_seq.
wp_apply (swap_spec with "[$Hy $Hz]"); iIntros "[Hy Hz]".
iApply ("Post" with "[$]").
Qed.
End proof.
|
module Issue296 where
postulate
Unit : Set
IO : Set → Set
foo : ((A B : Set) → Unit) → IO Unit
bar : (A B : Set) → Unit
{-# BUILTIN IO IO #-}
{-# COMPILED_TYPE IO IO #-}
{-# COMPILED_TYPE Unit () #-}
{-# COMPILED bar undefined #-}
main : IO Unit
main = foo bar
|
[GOAL]
V : QuivCat
⊢ { obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V) =
𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)
[PROOFSTEP]
change (show Paths V ⥤ _ from _) = _
[GOAL]
V : QuivCat
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this) =
𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)
[PROOFSTEP]
ext
[GOAL]
case h_obj.h
V : QuivCat
x✝ : Paths ↑V
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
x✝ =
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
x✝
case h
V : QuivCat
a✝ b✝ : ↑V
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
a✝ =
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
a✝) ≫
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
b✝ =
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
b✝)
[PROOFSTEP]
swap
[GOAL]
case h
V : QuivCat
a✝ b✝ : ↑V
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
a✝ =
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
a✝) ≫
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
b✝ =
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
b✝)
case h_obj.h
V : QuivCat
x✝ : Paths ↑V
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
x✝ =
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
x✝
[PROOFSTEP]
apply eq_conj_eqToHom
[GOAL]
case h_obj.h
V : QuivCat
x✝ : Paths ↑V
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(𝟙 V);
this).obj
x✝ =
(𝟙
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.obj
V)).obj
x✝
[PROOFSTEP]
rfl
[GOAL]
U x✝¹ x✝ : QuivCat
F : U ⟶ x✝¹
G : x✝¹ ⟶ x✝
⊢ { obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G) =
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G
[PROOFSTEP]
change (show Paths U ⥤ _ from _) = _
[GOAL]
U x✝¹ x✝ : QuivCat
F : U ⟶ x✝¹
G : x✝¹ ⟶ x✝
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this) =
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G
[PROOFSTEP]
ext
[GOAL]
case h_obj.h
U x✝² x✝¹ : QuivCat
F : U ⟶ x✝²
G : x✝² ⟶ x✝¹
x✝ : Paths ↑U
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
x✝ =
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
x✝
case h
U x✝¹ x✝ : QuivCat
F : U ⟶ x✝¹
G : x✝¹ ⟶ x✝
a✝ b✝ : ↑U
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
a✝ =
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
a✝) ≫
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
b✝ =
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
b✝)
[PROOFSTEP]
swap
[GOAL]
case h
U x✝¹ x✝ : QuivCat
F : U ⟶ x✝¹
G : x✝¹ ⟶ x✝
a✝ b✝ : ↑U
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
a✝ =
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
a✝) ≫
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
b✝ =
(let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk
{ obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
b✝)
case h_obj.h
U x✝² x✝¹ : QuivCat
F : U ⟶ x✝²
G : x✝² ⟶ x✝¹
x✝ : Paths ↑U
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
x✝ =
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
x✝
[PROOFSTEP]
apply eq_conj_eqToHom
[GOAL]
case h_obj.h
U x✝² x✝¹ : QuivCat
F : U ⟶ x✝²
G : x✝² ⟶ x✝¹
x✝ : Paths ↑U
⊢ (let_fun this :=
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
(F ≫ G);
this).obj
x✝ =
({ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
F ≫
{ obj := fun V => of (Paths ↑V),
map := fun {X Y} F =>
Functor.mk { obj := fun X_1 => F.obj X_1, map := fun {X_1 Y_1} f => Prefunctor.mapPath F f } }.map
G).obj
x✝
[PROOFSTEP]
rfl
[GOAL]
V : QuivCat
C : Cat
F : Cat.free.obj V ⟶ C
⊢ ∀ (a b : ↑V) (e : a ⟶ b),
((fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F)).map (Quiver.Hom.toPath e) =
eqToHom (_ : ((fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F)).obj a = F.obj a) ≫
F.map (Quiver.Hom.toPath e) ≫
eqToHom (_ : F.obj b = ((fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F)).obj b)
[PROOFSTEP]
simp
[GOAL]
V : QuivCat
C : Cat
⊢ Function.RightInverse (fun F => lift F) fun F => Paths.of ⋙q F.toPrefunctor
[PROOFSTEP]
rintro ⟨obj, map⟩
[GOAL]
case mk
V : QuivCat
C : Cat
obj : ↑V → ↑(forget.obj C)
map : {X Y : ↑V} → (X ⟶ Y) → (obj X ⟶ obj Y)
⊢ (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) { obj := obj, map := map }) = { obj := obj, map := map }
[PROOFSTEP]
dsimp only [Prefunctor.comp]
[GOAL]
case mk
V : QuivCat
C : Cat
obj : ↑V → ↑(forget.obj C)
map : {X Y : ↑V} → (X ⟶ Y) → (obj X ⟶ obj Y)
⊢ { obj := fun X => (lift { obj := obj, map := map }).obj (Paths.of.obj X),
map := fun {X Y} f => (lift { obj := obj, map := map }).map (Paths.of.map f) } =
{ obj := obj, map := map }
[PROOFSTEP]
congr
[GOAL]
case mk.e_map
V : QuivCat
C : Cat
obj : ↑V → ↑(forget.obj C)
map : {X Y : ↑V} → (X ⟶ Y) → (obj X ⟶ obj Y)
⊢ (fun {X Y} f => (lift { obj := obj, map := map }).map (Paths.of.map f)) = map
[PROOFSTEP]
funext X Y f
[GOAL]
case mk.e_map.h.h.h
V : QuivCat
C : Cat
obj : ↑V → ↑(forget.obj C)
map : {X Y : ↑V} → (X ⟶ Y) → (obj X ⟶ obj Y)
X Y : ↑V
f : X ⟶ Y
⊢ (lift { obj := obj, map := map }).map (Paths.of.map f) = map f
[PROOFSTEP]
exact Category.id_comp _
[GOAL]
V x✝¹ : QuivCat
x✝ : Cat
f : V ⟶ x✝¹
g : x✝¹ ⟶ forget.obj x✝
⊢ ↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ : ∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ : ∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g) =
Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ : ∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ : ∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g
[PROOFSTEP]
change (show Paths V ⥤ _ from _) = _
[GOAL]
V x✝¹ : QuivCat
x✝ : Cat
f : V ⟶ x✝¹
g : x✝¹ ⟶ forget.obj x✝
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ : ∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ : ∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this) =
Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ : ∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ : ∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g
[PROOFSTEP]
ext
[GOAL]
case h_obj.h
V x✝² : QuivCat
x✝¹ : Cat
f : V ⟶ x✝²
g : x✝² ⟶ forget.obj x✝¹
x✝ : Paths ↑V
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝¹).symm
(f ≫ g);
this).obj
x✝ =
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝² x✝¹).symm
g).obj
x✝
case h
V x✝¹ : QuivCat
x✝ : Cat
f : V ⟶ x✝¹
g : x✝¹ ⟶ forget.obj x✝
a✝ b✝ : ↑V
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).obj
a✝ =
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).obj
a✝) ≫
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).obj
b✝ =
(let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).obj
b✝)
[PROOFSTEP]
swap
[GOAL]
case h
V x✝¹ : QuivCat
x✝ : Cat
f : V ⟶ x✝¹
g : x✝¹ ⟶ forget.obj x✝
a✝ b✝ : ↑V
e✝ : a✝ ⟶ b✝
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).map
(Quiver.Hom.toPath e✝) =
eqToHom
(_ :
(let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).obj
a✝ =
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).obj
a✝) ≫
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).map
(Quiver.Hom.toPath e✝) ≫
eqToHom
(_ :
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝¹ x✝).symm
g).obj
b✝ =
(let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C),
(fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C),
(fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝).symm
(f ≫ g);
this).obj
b✝)
case h_obj.h
V x✝² : QuivCat
x✝¹ : Cat
f : V ⟶ x✝²
g : x✝² ⟶ forget.obj x✝¹
x✝ : Paths ↑V
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝¹).symm
(f ≫ g);
this).obj
x✝ =
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝² x✝¹).symm
g).obj
x✝
[PROOFSTEP]
apply eq_conj_eqToHom
[GOAL]
case h_obj.h
V x✝² : QuivCat
x✝¹ : Cat
f : V ⟶ x✝²
g : x✝² ⟶ forget.obj x✝¹
x✝ : Paths ↑V
⊢ (let_fun this :=
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
V x✝¹).symm
(f ≫ g);
this).obj
x✝ =
(Cat.free.map f ≫
↑((fun V C =>
{ toFun := fun F => Paths.of ⋙q F.toPrefunctor, invFun := fun F => lift F,
left_inv :=
(_ :
∀ (F : Cat.free.obj V ⟶ C), (fun F => lift F) ((fun F => Paths.of ⋙q F.toPrefunctor) F) = F),
right_inv :=
(_ :
∀ (x : V ⟶ forget.obj C), (fun F => Paths.of ⋙q F.toPrefunctor) ((fun F => lift F) x) = x) })
x✝² x✝¹).symm
g).obj
x✝
[PROOFSTEP]
rfl
|
module Inigo.Package.ExtraDep
import Data.List1
import Data.String
import Extra.String
import Inigo.Package.ParseHelpers
import Inigo.Paths
import System.Path
import Toml
-- TODO: Other methods?
public export
data Download
= Git
| SubDir
public export
DownloadInfo : Download -> Type
DownloadInfo Git = String -- commit
DownloadInfo SubDir = ()
public export
record ExtraDep where
constructor MkExtraDep
download : Download
downloadInfo : DownloadInfo download
url : String
subDirs : List String
export
Show ExtraDep where
show (MkExtraDep Git commit url subDirs) =
"MkExtraDep{download=git, download-info=\"\{commit}\", url=\"\{url}\", subDirs=\{show subDirs}}"
show (MkExtraDep SubDir () url subDirs) =
"MkExtraDep{download=folder, url=\"\{url}\", subDirs=\{show subDirs}}"
export
Eq ExtraDep where
MkExtraDep Git commit0 url0 subDirs0 == MkExtraDep Git commit1 url1 subDirs1 =
commit0 == commit1 && url0 == url1 && subDirs0 == subDirs1
MkExtraDep SubDir _ url0 subDirs0 == MkExtraDep SubDir _ url1 subDirs1 =
url0 == url1 && subDirs0 == subDirs1
_ == _ = False
export
eqIgnoreSubDirs : ExtraDep -> ExtraDep -> Bool
MkExtraDep Git commit0 url0 _ `eqIgnoreSubDirs` MkExtraDep Git commit1 url1 _ =
commit0 == commit1 && url0 == url1
MkExtraDep SubDir _ url0 _ `eqIgnoreSubDirs` MkExtraDep SubDir _ url1 _ =
url0 == url1
_ `eqIgnoreSubDirs` _ = False
export
toToml : List ExtraDep -> Toml
toToml deps = [(["extra-dep"], ArrTab $ depToToml <$> deps)]
where
depToToml : ExtraDep -> Toml
depToToml (MkExtraDep Git commit url subDirs) =
[ (["download"], Str "git")
, (["commit"], Str commit)
, (["url"], Str url)
, (["sub-folders"], Lst (Str <$> subDirs))
]
depToToml (MkExtraDep SubDir () url subDirs) =
[ (["download"], Str "folder")
, (["url"], Str url)
, (["sub-folders"], Lst (Str <$> subDirs))
]
export
parseDownload : Toml -> Either String Download
parseDownload toml = case get ["download"] toml of
Just (Str "git") => Right Git
Just (Str "folder") => Right SubDir
Just (Str val) => Left "Invalid download method: \{val}"
Just val => Left "Inavlid value for field download: \{show val}"
Nothing => Left "Missing field download"
export
parseExtraDeps : Toml -> Either String (List ExtraDep)
parseExtraDeps toml = case get ["extra-dep"] toml of
Nothing => Right []
Just (ArrTab deps) => foldlM extraDep [] deps
Just val => Left "Invalid extra dependency found: \{show val}"
where
sanitiseCommit : String -> Either String String
sanitiseCommit str =
let len = length str
allHex = all isHexDigit $ unpack str
in if len == 7 || len == 40 && allHex
then Right str
else Left "Invalid commit: \"\{str}\""
extraDep : List ExtraDep -> Toml -> Either String (List ExtraDep)
extraDep deps toml = do
url <- string ["url"] toml
subDirs <- withDefault [""] $ listStr ["sub-folders"] toml
download <- parseDownload toml
case download of
Git => do
commit <- string ["commit"] toml >>= sanitiseCommit
pure $ MkExtraDep Git commit url subDirs :: deps
SubDir => do
pure $ MkExtraDep SubDir () url subDirs :: deps
genFolder : String -> String
genFolder = concat . map escapeChar . unpack
where
escapeChar : Char -> String
escapeChar c = if isAlphaNum c || c == '@'
then cast c
else "_" ++ show (ord c)
export
getExtraDepDir : ExtraDep -> String
getExtraDepDir (MkExtraDep Git commit url _) = inigoDepDir </> genFolder "\{url}@\{commit}"
getExtraDepDir (MkExtraDep SubDir _ url _) = url
|
There exists a nonnegative real number $K$ such that for all $x$, we have $|f(x)| \leq |x|K$. |
open import Categories.Category
open import Categories.Category.CartesianClosed
open import Theory
module Categories.Category.Construction.Models
{ℓ₁ ℓ₂ ℓ₃}
(Th : Theory.Theory ℓ₁ ℓ₂ ℓ₃)
{o ℓ e}
(𝒞 : Category o ℓ e)
(cartesianClosed : CartesianClosed 𝒞)
where
open import Categories.Category.Cartesian 𝒞
open import Categories.Category.BinaryProducts 𝒞
open import Categories.Object.Terminal 𝒞
import Categories.Object.Product 𝒞 as P
open import Categories.Morphism 𝒞
open import Categories.Functor.Construction.Product using (Product)
open import Categories.Functor.Construction.Exponential using (Exp)
open import Categories.Functor.Properties using ([_]-resp-≅)
open Category 𝒞
open CartesianClosed cartesianClosed
open Cartesian cartesian
open BinaryProducts products
module T = Terminal terminal
open HomReasoning
open import Categories.Morphism.Reasoning 𝒞
open import Syntax
open Theory.Theory Th
open import Semantics 𝒞 cartesianClosed Sg
open Signature Sg
open import Data.Product using (Σ; Σ-syntax; proj₁; proj₂; _,_)
open import Relation.Binary using (Rel; IsEquivalence)
open import Level using (_⊔_)
⁂-id : forall {A B} -> id {A = A} ⁂ id {A = B} ≈ id
⁂-id = Equiv.trans (⟨⟩-cong₂ identityˡ identityˡ) η
module Homomorphism {M N : Model 𝒞 cartesianClosed Th}
(h : (g : Gr) -> ⟦ g ⟧G (proj₁ M) ≅ ⟦ g ⟧G (proj₁ N))
where
open _≅_
open Iso
H : (A : Type) -> ⟦ A ⟧T (proj₁ M) ≅ ⟦ A ⟧T (proj₁ N)
H ⌊ g ⌋ = h g
H Unit = up-to-iso terminal terminal
H (A * A₁) = [ Product 𝒞 cartesian ]-resp-≅
(record
{ from = from (H A) , from (H A₁)
; to = to (H A) , to (H A₁)
; iso = record { isoˡ = isoˡ (iso (H A)) , isoˡ (iso (H A₁)) ; isoʳ = isoʳ (iso (H A)) , isoʳ (iso (H A₁)) }
})
H (A => A₁) = [ Exp 𝒞 cartesianClosed ]-resp-≅
(record
{ from = from (H A₁) , to (H A)
; to = to (H A₁) , from (H A)
; iso = record { isoˡ = isoˡ (iso (H A₁)) , isoˡ (iso (H A)) ; isoʳ = isoʳ (iso (H A₁)) , isoʳ (iso (H A)) }
})
record homomorphism (M N : Model 𝒞 cartesianClosed Th) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ ⊔ e) where
field
h : (g : Gr) -> ⟦ g ⟧G (proj₁ M) ≅ ⟦ g ⟧G (proj₁ N)
open Homomorphism {M} {N} h public
field
comm : (f : Func) -> _≅_.from (H (cod f)) ∘ ⟦ f ⟧F (proj₁ M) ≈ ⟦ f ⟧F (proj₁ N) ∘ _≅_.from (H (dom f))
module _ {M N : Model 𝒞 cartesianClosed Th} where
_≗_ : Rel (homomorphism M N) (ℓ₁ ⊔ e)
_≗_ x y = (g : Gr) -> _≅_.from (homomorphism.h x g) ≈ _≅_.from (homomorphism.h y g)
module Id {M : Model 𝒞 cartesianClosed Th} where
open Homomorphism {M} {M} (λ _ → IsEquivalence.refl ≅-isEquivalence)
open Structure (proj₁ M)
-- The components of the homomorphism generated by identity morphisms are also identities.
H-id : forall A -> _≅_.from (H A) ≈ Category.id 𝒞
H-id˘ : forall A -> _≅_.to (H A) ≈ Category.id 𝒞
H-id ⌊ x ⌋ = Equiv.refl
H-id Unit = T.!-unique (Category.id 𝒞)
H-id (A * A₁) =
begin
_≅_.from (H A) ⁂ _≅_.from (H A₁)
≈⟨ ⁂-cong₂ (H-id A) (H-id A₁) ⟩
Category.id 𝒞 ⁂ Category.id 𝒞
≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩
⟨ π₁ , π₂ ⟩
≈⟨ η ⟩
Category.id 𝒞
∎
H-id (A => A₁) =
begin
λg (_≅_.from (H A₁) ∘ eval′ ∘ (id ⁂ _≅_.to (H A)))
≈⟨ λ-cong (∘-resp-≈ˡ (H-id A₁)) ⟩
λg (id ∘ eval′ ∘ (id ⁂ _≅_.to (H A)))
≈⟨ λ-cong (pullˡ identityˡ) ⟩
λg (eval′ ∘ (id ⁂ _≅_.to (H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (⁂-cong₂ Equiv.refl (H-id˘ A))) ⟩
λg (eval′ ∘ (id ⁂ id))
≈⟨ λ-cong (elimʳ ⁂-id) ⟩
λg eval′
≈⟨ η-id′ ⟩
id
∎
H-id˘ ⌊ x ⌋ = Equiv.refl
H-id˘ Unit = T.!-unique id
H-id˘ (A * A₁) =
begin
_≅_.to (H A) ⁂ _≅_.to (H A₁)
≈⟨ ⁂-cong₂ (H-id˘ A) (H-id˘ A₁) ⟩
id ⁂ id
≈⟨ ⁂-id ⟩
id
∎
H-id˘ (A => A₁) =
begin
λg (_≅_.to (H A₁) ∘ eval′ ∘ (id ⁂ _≅_.from (H A)))
≈⟨ λ-cong (elimˡ (H-id˘ A₁)) ⟩
λg (eval′ ∘ (id ⁂ _≅_.from (H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (⁂-cong₂ Equiv.refl (H-id A))) ⟩
λg (eval′ ∘ (id ⁂ id))
≈⟨ λ-cong (elimʳ ⁂-id) ⟩
λg eval′
≈⟨ η-id′ ⟩
id
∎
comm : (f : Func) -> _≅_.from (H (cod f)) ∘ ⟦ f ⟧F ≈ ⟦ f ⟧F ∘ _≅_.from (H (dom f))
comm f =
begin
_≅_.from (H (cod f)) ∘ ⟦ f ⟧F
≈⟨ elimˡ (H-id (cod f)) ⟩
⟦ f ⟧F
≈˘⟨ elimʳ (H-id (dom f)) ⟩
⟦ f ⟧F ∘ _≅_.from (H (dom f))
∎
id′ : homomorphism M M
id′ = record { h = λ _ → IsEquivalence.refl ≅-isEquivalence ; comm = comm }
module Compose {M N O : Model 𝒞 cartesianClosed Th} where
open _≅_
compose : homomorphism N O -> homomorphism M N -> homomorphism M O
compose x y = record
{ h = h
; comm = λ f →
begin
from (MO.H (cod f)) ∘ ⟦ f ⟧F (proj₁ M)
≈⟨ pushˡ (H-compose (cod f)) ⟩
from (NO.H (cod f)) ∘ from (MN.H (cod f)) ∘ ⟦ f ⟧F (proj₁ M)
≈⟨ ∘-resp-≈ʳ (MN.comm f) ⟩
from (NO.H (cod f)) ∘ ⟦ f ⟧F (proj₁ N) ∘ from (MN.H (dom f))
≈⟨ pullˡ (NO.comm f) ⟩
(⟦ f ⟧F (proj₁ O) ∘ from (NO.H (dom f))) ∘ from (MN.H (dom f))
≈˘⟨ pushʳ (H-compose (dom f)) ⟩
⟦ f ⟧F (proj₁ O) ∘ from (MO.H (dom f))
∎
}
where
h = λ g → IsEquivalence.trans ≅-isEquivalence (homomorphism.h y g) (homomorphism.h x g)
module MO = Homomorphism h
module MN = homomorphism y
module NO = homomorphism x
H-compose : forall A -> from (MO.H A) ≈ from (NO.H A) ∘ from (MN.H A)
H-compose˘ : forall A -> to (MO.H A) ≈ to (MN.H A) ∘ to (NO.H A)
H-compose ⌊ x ⌋ = Equiv.refl
H-compose Unit = T.!-unique₂
H-compose (A * A₁) = Equiv.trans (⁂-cong₂ (H-compose A) (H-compose A₁)) (Equiv.sym ⁂∘⁂)
H-compose (A => A₁) =
begin
λg (from (MO.H A₁) ∘ eval′ ∘ (id ⁂ to (MO.H A)))
≈⟨ λ-cong (∘-resp-≈ˡ (H-compose A₁)) ⟩
λg ((from (NO.H A₁) ∘ from (MN.H A₁)) ∘ eval′ ∘ (id ⁂ to (MO.H A)))
≈⟨ λ-cong assoc ⟩
λg (from (NO.H A₁) ∘ from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MO.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ Equiv.refl (H-compose˘ A))))) ⟩
λg (from (NO.H A₁) ∘ from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A) ∘ to (NO.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (∘-resp-≈ʳ second∘second))) ⟩
λg (from (NO.H A₁) ∘ from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A)) ∘ (id ⁂ to (NO.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ assoc²') ⟩
λg (from (NO.H A₁) ∘ (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ∘ (id ⁂ to (NO.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (pullˡ β′)) ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ⁂ id) ∘ (id ⁂ to (NO.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ∘ id ⁂ id ∘ to (NO.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ identityʳ identityˡ))) ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ⁂ to (NO.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ identityˡ identityʳ))) ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (id ∘ λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ⁂ to (NO.H A) ∘ id))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (id ⁂ to (NO.H A)) ∘ (λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ⁂ id))
≈˘⟨ λ-cong assoc²' ⟩
λg ((from (NO.H A₁) ∘ eval′ ∘ (id ⁂ to (NO.H A))) ∘ (λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A))) ⁂ id))
≈˘⟨ CartesianClosed.exp.subst cartesianClosed product product ⟩
λg (from (NO.H A₁) ∘ eval′ ∘ (id ⁂ to (NO.H A))) ∘ λg (from (MN.H A₁) ∘ eval′ ∘ (id ⁂ to (MN.H A)))
≈⟨ Equiv.refl ⟩
from (NO.H (A => A₁)) ∘ from (MN.H (A => A₁))
∎
H-compose˘ ⌊ x ⌋ = Equiv.refl
H-compose˘ Unit = T.!-unique₂
H-compose˘ (A * A₁) = Equiv.trans (⁂-cong₂ (H-compose˘ A) (H-compose˘ A₁)) (Equiv.sym ⁂∘⁂)
H-compose˘ (A => A₁) =
begin
λg (to (MO.H A₁) ∘ eval′ ∘ (id ⁂ from (MO.H A)))
≈⟨ λ-cong (∘-resp-≈ˡ (H-compose˘ A₁)) ⟩
λg ((to (MN.H A₁) ∘ to (NO.H A₁)) ∘ eval′ ∘ (id ⁂ from (MO.H A)))
≈⟨ λ-cong assoc ⟩
λg (to (MN.H A₁) ∘ to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (MO.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ Equiv.refl (H-compose A))))) ⟩
λg (to (MN.H A₁) ∘ to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A) ∘ from (MN.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (∘-resp-≈ʳ second∘second))) ⟩
λg (to (MN.H A₁) ∘ to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A)) ∘ (id ⁂ from (MN.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ assoc²') ⟩
λg (to (MN.H A₁) ∘ (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ∘ (id ⁂ from (MN.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (pullˡ β′)) ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ⁂ id) ∘ (id ⁂ from (MN.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ∘ id ⁂ id ∘ from (MN.H A)))
≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ identityʳ identityˡ))) ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ⁂ from (MN.H A)))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ identityˡ identityʳ))) ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (id ∘ λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ⁂ from (MN.H A) ∘ id))
≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (id ⁂ from (MN.H A)) ∘ (λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ⁂ id))
≈˘⟨ λ-cong assoc²' ⟩
λg ((to (MN.H A₁) ∘ eval′ ∘ (id ⁂ from (MN.H A))) ∘ (λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A))) ⁂ id))
≈˘⟨ CartesianClosed.exp.subst cartesianClosed product product ⟩
λg (to (MN.H A₁) ∘ eval′ ∘ (id ⁂ from (MN.H A))) ∘ λg (to (NO.H A₁) ∘ eval′ ∘ (id ⁂ from (NO.H A)))
≈⟨ Equiv.refl ⟩
to (MN.H (A => A₁)) ∘ to (NO.H (A => A₁))
∎
Models : Category (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ o ⊔ ℓ ⊔ e) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ ⊔ e) (ℓ₁ ⊔ e)
Models = record
{ Obj = Model 𝒞 cartesianClosed Th
; _⇒_ = homomorphism
; _≈_ = _≗_
; id = Id.id′
; _∘_ = Compose.compose
; assoc = λ _ → assoc
; sym-assoc = λ _ → sym-assoc
; identityˡ = λ _ → identityˡ
; identityʳ = λ _ → identityʳ
; identity² = λ _ → identity²
; equiv = record { refl = λ _ → IsEquivalence.refl equiv ; sym = λ x g → IsEquivalence.sym equiv (x g) ; trans = λ x x₁ g → IsEquivalence.trans equiv (x g) (x₁ g) }
; ∘-resp-≈ = λ x x₁ g → ∘-resp-≈ (x g) (x₁ g)
}
|
[STATEMENT]
lemma "JML \<Longrightarrow> MT2 \<^bold>\<not>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (SML3 \<and> Fr_2 \<F> \<and> Fr_3 \<F> \<and> Fr_4 \<F>) \<and> DNI \<^bold>\<not> \<Longrightarrow> MT2 \<^bold>\<not>
[PROOF STEP]
nitpick
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (SML3 \<and> Fr_2 \<F> \<and> Fr_3 \<F> \<and> Fr_4 \<F>) \<and> DNI \<^bold>\<not> \<Longrightarrow> MT2 \<^bold>\<not>
[PROOF STEP]
oops |
function pcd!(rbm::ConvRBM, data::AbstractArray;
batchsize::Int = 1,
epochs::Int = 1,
optim = Flux.ADAM(),
history::MVHistory = MVHistory(),
wts = nothing,
steps::Int = 1,
vm::AbstractArray = initial_fantasy_v(rbm, data, batchsize),
callback = Returns(nothing)
)
@assert length(vsizes(rbm, data).batch_size) == 1 # checks sizes and require single batch dim
@assert isnothing(wts) || _nobs(data) == _nobs(wts)
for epoch in 1:epochs
batches = RBMs.minibatches(data, wts; batchsize)
Δt = @elapsed for (batch_idx, (vd, wd)) in enumerate(batches)
vm .= RBMs.sample_v_from_v(rbm, vm; steps)
gs = Zygote.gradient(rbm) do rbm
contrastive_divergence(rbm, vd, vm; wd)
end
# removes keys with no gradient
∂ = Base.structdiff(only(gs), NamedTuple{(:stride, :pad, :dilation, :groups, :pool)})
Δ = RBMs.update!(∂, rbm, optim) # update step
callback(; rbm, epoch, batch_idx, vm, vd, wd, history, ∂, Δ)
RBMs.update!(rbm, Δ)
push!(history, :∂, RBMs.gradnorms(∂))
push!(history, :Δ, RBMs.gradnorms(∂))
end
push!(history, :epoch, epoch)
push!(history, :Δt, Δt)
push!(history, :vm, copy(vm))
@debug "epoch $epoch/$epochs ($(round(Δt, digits=2))s)"
end
return history
end
function RBMs.update!(∂::NamedTuple, x::ConvRBM, optim)
for (k, g) in pairs(∂)
if hasproperty(x, k)
RBMs.update!(g, getproperty(x, k), optim)
else
g .= 0
end
end
return ∂
end
function RBMs.update!(x::ConvRBM, ∂::NamedTuple)
for (k, Δ) in pairs(∂)
hasproperty(x, k) && RBMs.update!(getproperty(x, k), Δ)
end
return x
end
function contrastive_divergence(
rbm::ConvRBM, vd::AbstractArray, vm::AbstractArray; wd = nothing, wm = nothing
)
Fd = RBMs.mean_free_energy(rbm, vd; wts = wd)
Fm = RBMs.mean_free_energy(rbm, vm; wts = wm)
return Fd - Fm
end
function RBMs.mean_free_energy(rbm::ConvRBM, v::AbstractArray; wts = nothing)::Number
F = RBMs.free_energy(rbm, v)
if isempty(vsizes(rbm, v).batch_size)
wts::Nothing
return F
else
return RBMs.wmean(F; wts)
end
end
function initial_fantasy_v(rbm::ConvRBM, data::AbstractArray, batchsize::Int)
inputs = falses(size(data)[1:(end - 1)]..., batchsize)
vm = RBMs.transfer_sample(visible(rbm), inputs)
return oftype(data, vm)
end
|
module DFT (dft, idft) where
import FFT (fft)
import Data.Complex (Complex)
import Data.List (reverse, map, take)
dft :: [Complex Float] -> [Complex Float]
dft [] = []
dft xs = fft $ preprocess xs
idft :: [Complex Float] -> [Complex Float]
idft [] = []
idft xs = (invertFFT . dft) xs
invertFFT :: [Complex Float] -> [Complex Float]
invertFFT [] = []
invertFFT coeffs@(x:xs) = [ x' / n | x' <- (x : reverse xs) ]
where n = (fromIntegral . length) coeffs
preprocess :: [Complex Float] -> [Complex Float]
preprocess [] = []
preprocess xs = take targetLength (xs ++ (repeat 0))
where targetLength = 2 ^ ceiling (log ((fromIntegral . length) xs) / log 2) |
Require Coq.extraction.Extraction.
Extraction Language OCaml.
From Coq Require Import Arith.Arith.
From Coq Require Import Init.Nat.
From Coq Require Import Arith.EqNat.
From LF Require Import ImpCEvalFun.
Extraction "imp.ml" ceval_step.
Extract Inductive bool => "bool" [ "true" "false" ].
Extract Inductive nat => "int"
[ "0" "(fun x -> x + 1)"]
"(fun zero succ n ->
if n = 0 then zero () else succ (n-1))".
Extract Constant plus => "( + )".
Extract Constant mult => "( * )".
Extract Constant eqb => "( = )".
Extract Constant minus => "( - )".
Extraction "imp2.ml" ceval_step.
Require Import ExtrOcamlBasic.
Require Import ExtrOcamlString.
Extract Inductive sumbool => "bool" [ "true" "false" ].
From LF Require Import Imp.
From LF Require Import ImpParser.
From LF Require Import Maps.
Extraction "imp.ml" empty_st ceval_step parse.
|
[STATEMENT]
lemma UC\<^sub>i: "\<^bold>\<forall>y.\<^bold>\<exists>i. ID i \<^bold>\<and> i\<cdot>y \<cong> y \<^bold>\<and> (\<^bold>\<forall>j.(ID j \<^bold>\<and> j\<cdot>y \<cong> y) \<^bold>\<rightarrow> i \<cong> j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<^bold>\<forall>x. \<^bold>\<not> (\<^bold>\<forall>xa. \<^bold>\<not> (((\<^bold>\<forall>x. xa \<cdot> x \<cong> x \<^bold>\<leftarrow> E (xa \<cdot> x)) \<^bold>\<and> (\<^bold>\<forall>x. x \<cdot> xa \<cong> x \<^bold>\<leftarrow> E (x \<cdot> xa))) \<^bold>\<and> xa \<cdot> x \<cong> x \<^bold>\<and> (\<^bold>\<forall>xb. xa \<cong> xb \<^bold>\<leftarrow> ((\<^bold>\<forall>x. xb \<cdot> x \<cong> x \<^bold>\<leftarrow> E (xb \<cdot> x)) \<^bold>\<and> (\<^bold>\<forall>x. x \<cdot> xb \<cong> x \<^bold>\<leftarrow> E (x \<cdot> xb))) \<^bold>\<and> xb \<cdot> x \<cong> x)))
[PROOF STEP]
by (smt (verit) A\<^sub>i C\<^sub>i S\<^sub>i) |
As part of their program to suppress Polish culture , the German Nazis attempted to destroy Christianity in Poland , with a particular emphasis on the Roman Catholic Church . In some parts of occupied Poland , Poles were restricted , or even forbidden , from attending religious services . At the same time , church property was confiscated , prohibitions were placed on using the Polish language in religious services , organizations affiliated with the Catholic Church were abolished , and it was forbidden to perform certain religious songs — or to read passages of the Bible — in public . The worst conditions were found in the Reichsgau Wartheland , which the Nazis treated as a laboratory for their anti @-@ religious policies . Polish clergy and religious leaders figured prominently among portions of the intelligentsia that were targeted for extermination .
|
[GOAL]
⊢ ConcreteCategory MeasCat
[PROOFSTEP]
unfold MeasCat
[GOAL]
⊢ ConcreteCategory (Bundled MeasurableSpace)
[PROOFSTEP]
infer_instance
[GOAL]
μ : MeasureTheory.Measure (MeasureTheory.Measure ℝ≥0∞)
⊢ ∫⁻ (x : ℝ≥0∞), x ∂Measure.join μ = ∫⁻ (x : ℝ≥0∞), x ∂Measure.map (fun m => ∫⁻ (x : ℝ≥0∞), x ∂m) μ
[PROOFSTEP]
rw [Measure.lintegral_join, lintegral_map]
[GOAL]
case hf
μ : MeasureTheory.Measure (MeasureTheory.Measure ℝ≥0∞)
⊢ Measurable fun x => x
[PROOFSTEP]
apply_rules [measurable_id, Measure.measurable_lintegral]
[GOAL]
case hg
μ : MeasureTheory.Measure (MeasureTheory.Measure ℝ≥0∞)
⊢ Measurable fun m => ∫⁻ (x : ℝ≥0∞), x ∂m
[PROOFSTEP]
apply_rules [measurable_id, Measure.measurable_lintegral]
[GOAL]
μ : MeasureTheory.Measure (MeasureTheory.Measure ℝ≥0∞)
⊢ Measurable fun x => x
[PROOFSTEP]
apply_rules [measurable_id, Measure.measurable_lintegral]
|
Please arrive early for parking and group entry at 10:40am. No individual tickets.
Parking available on site, on street, or at garage at Hollman and Travis. |
using EconPDEs, Distributions
struct WachterModel{T<: Distribution}
# consumption process parameters
μ::Float64
σ::Float64
# idiosyncratic
λbar::Float64
κλ::Float64
νλ::Float64
ZDistribution::T
# utility parameters
ρ::Float64
γ::Float64
ψ::Float64
ϕ::Float64
end
# distirbution of jump comes from Ian Martin higher order cumulants paper
function WachterModel(;μ = 0.025, σ = 0.02, λbar = 0.0355, κλ = 0.08, νλ = 0.067, ZDistribution = Normal(-0.4, 0.25), ρ = 0.012, γ = 3.0, ψ = 1.1, ϕ = 2.6)
WachterModel(μ, σ, λbar, κλ, νλ, ZDistribution, ρ, γ, ψ, ϕ)
end
function initialize_stategrid(m::WachterModel; n = 30)
μ = m.μ ; σ = m.σ ; λbar = m.λbar ; κλ = m.κλ ; νλ = m.νλ ; ZDistribution = m.ZDistribution ; ρ = m.ρ ; γ = m.γ ; ψ = m.ψ
OrderedDict(:λ => range(0.0, stop = 0.1, length = n))
end
function initialize_y(m::WachterModel, stategrid::OrderedDict)
OrderedDict(:p => ones(length(stategrid[:λ])))
end
function (m::WachterModel)(state::NamedTuple, y::NamedTuple)
μ = m.μ ; σ = m.σ ; λbar = m.λbar ; κλ = m.κλ ; νλ = m.νλ ; ZDistribution = m.ZDistribution ; ρ = m.ρ ; γ = m.γ ; ψ = m.ψ ; ϕ = m.ϕ
λ = state.λ
p, pλ, pλλ = y.p, y.pλ, y.pλλ
# Drift and volatility of λ, p
μλ = κλ * (λbar - λ)
σλ = νλ * sqrt(λ)
μp = pλ / p * μλ + 0.5 * pλλ / p * σλ^2
σp_Zλ = pλ / p * σλ
# Market price of risk
κ_Zc = γ * σ
κ_Zλ = (γ * ψ - 1) / (ψ - 1) * σp_Zλ
η = λ * (mgf(ZDistribution, 1) - 1 + mgf(ZDistribution, -γ) - 1 - (mgf(ZDistribution, 1 - γ) - 1))
# Interest rate r
r = ρ + μ / ψ - (1 + 1 / ψ) / 2 * γ * σ^2 - λ * (mgf(ZDistribution, -γ) - 1) + (1 / ψ - γ) / (1 - γ) * λ * (mgf(ZDistribution, 1 - γ) - 1) - (γ * ψ - 1) / (2 * (ψ - 1)) * σp_Zλ^2
# Market Pricing
pt = p * (1 / p + μ + μp + λ * (mgf(ZDistribution, 1) - 1) - r - κ_Zc * σ - κ_Zλ * σp_Zλ - η)
return (pt,), (μλ,), (p = p, r = r, κ_Zc = κ_Zc, κ_Zλ = κ_Zλ, η = η)
end
m = WachterModel()
stategrid = initialize_stategrid(m)
y0 = initialize_y(m, stategrid)
y, result, distance = pdesolve(m, stategrid, y0)
#========================================================================================
Solve for levered equity claim
========================================================================================#
function pde_levered(m, state, y, r, κ_Zc, κ_Zλ)
μ = m.μ ; σ = m.σ ; λbar = m.λbar ; κλ = m.κλ ; νλ = m.νλ ; ZDistribution = m.ZDistribution ; ρ = m.ρ ; γ = m.γ ; ψ = m.ψ ; ϕ = m.ϕ
λ = state.λ
pe, peλ, peλλ = y.pe, y.peλ, y.peλλ
μλ = κλ * (λbar - λ)
σλ = νλ * sqrt(λ)
μpe = peλ / pe * μλ + 0.5 * peλλ / pe * σλ^2
σpe_Zλ = peλ / pe * σλ
η = λ * (mgf(ZDistribution, ϕ) - 1 + mgf(ZDistribution, -γ) - 1 - (mgf(ZDistribution, ϕ - γ) - 1))
pet = pe * (1 / pe + μ + μpe + λ * (mgf(ZDistribution, ϕ) - 1) - r(λ) - κ_Zc(λ) * ϕ * σ - κ_Zλ(λ) * σpe_Zλ - η)
return (pet,), (μλ,)
end
#using Interpolations
#r = interpolate((state[:λ],), result[:r], Gridded(Linear()))
#κ_Zc = interpolate((state[:λ],), result[:κ_Zc], Gridded(Linear()))
#κ_Zλ = interpolate((state[:λ],), result[:κ_Zλ], Gridded(Linear()))
#y2, _, distance = pdesolve((state, y) -> pde_levered(m, state, y, r, κ_Zc, κ_Zλ), stategrid, OrderedDict(:pe => y[:p])) |
lemma order_degree: assumes p: "p \<noteq> 0" shows "order a p \<le> degree p" |
function y = nansum(x,dim)
% nansum - Sum ignoring NaNs.
%
% Synopsis:
% y = nansum(x)
% y = nansum(x,dim)
%
% Arguments:
% x: Matrix or vector
% dim: Dimension along which sum operates. Default: First non-singleton
% dimension.
%
% Returns:
% y: Sum along the chosen dimension, treating NaNs as missing values.
%
% Description:
% For vectors, nansum(X) is the sum of the non-NaN elements in
% X. For matrices, nansum(X) is a row vector containing the sum
% of the non-NaN elements in each column of X. For N-D arrays,
% nansum(X) operates along the first non-singleton dimension.
%
% nansum(X,dim) sums along the dimension dim.
%
% Examples:
% nansum([1 2 NaN]) returns 3.
% nansum([1 2 NaN], 1) returns [1 2 NaN].
% nansum([1 2 NaN], 2) returns 3.
%
% See also: nanmean,nanstd
%
% Author(s): Anton Schwaighofer, Feb 2005
if nargin<2,
% Operate along the first non-singleton dimension
dim = min(find(size(x)~=1));
if isempty(dim),
dim = 1;
end
end
% Replace NaNs with zeros.
nans = isnan(x);
x(nans) = 0;
% Protect against an entire column of NaNs
y = sum(x, dim);
allNaNs = all(nans, dim);
y(allNaNs) = NaN;
|
Notes
|
module HelloWorld
export
hello : String
hello = "Hello, World!"
export
version : String
version = "1.0.0"
|
ybar = 178.2 # sample mean
mu0 = 190 # hypothesized value
sigma = 45.3 # population standard deviation
n = 100 # sample size
z = (ybar- mu0)/(sigma/sqrt(n))
print(z)
k=abs(z)
# test statistic
# formula based on level of significance
p_value=2*(1-pnorm(k))
print(p_value)
# mentioned p value in book is wrong
alpha=0.01
if(p_value>alpha){
print("we fail to reject H0")
print(" data do not support the research hypothesis(insufficient evidence).")
}else{
print(" there is very little evidence in the data to support the research hypothesis hence we will reject H0")
}
|
Require Import DecSolve IL Annotation Liveness.Liveness TrueLiveness LengthEq.
Instance argsLive_dec Caller Callee Y Z
: Computable (argsLive Caller Callee Y Z).
Proof.
decide(length Y = length Z).
- general induction Y; destruct Z as [|v Z]; isabsurd.
+ left; econstructor.
+ decide (v ∈ Callee -> live_op_sound a Caller);
edestruct (IHY Caller Callee); try dec_solve; try eassumption;
try inv an; eauto; try tauto.
- right; intro. eapply argsLive_length in H. congruence.
Defined.
Local Hint Extern 1 =>
match goal with
[ H : annotation _ _ |- annotation _ _ ] => inv H; eassumption
end.
Definition live_sound_dec i ZL Lv s slv
: Computable (live_sound i ZL Lv s slv).
Proof.
revert i ZL Lv slv.
sind s; intros; destruct s; destruct slv;
try solve [dec_right].
- edestruct (IH s); eauto; [| dec_right ];
ensure (getAnn slv\{{x}} ⊆ a);
ensure (live_exp_sound e a);
ensure (x ∈ getAnn slv); dec_solve.
- edestruct (IH s1); eauto; [| dec_right ];
edestruct (IH s2); eauto; [| dec_right ];
ensure (live_op_sound e a);
ensure (getAnn slv1 ⊆ a);
ensure (getAnn slv2 ⊆ a); dec_solve.
- destruct (get_dec Lv (counted l)) as [[blv ?]|?]; [| dec_right];
destruct (get_dec ZL (counted l)) as [[Z ?]|?]; [| dec_right];
decide (isImperative i); [ensure ((blv \ of_list Z) ⊆ a); [|cases in H6; eauto]|];
ensure (forall n y, get Y n y -> live_op_sound y a);
ensure (length Y = length Z);
left; econstructor; eauto; cases; eauto.
- decide(live_op_sound e a); try dec_solve.
- edestruct (IH s); eauto; [| dec_solve];
ensure (length F = length sa);
ensure (getAnn slv ⊆ a).
exploit (@indexwise_R_dec' _ _
(fun Zs a0 => live_sound i (fst ⊝ F ++ ZL)
(getAnn ⊝ sa ++ Lv)
(snd Zs) a0) F sa).
intros. eapply IH; eauto.
destruct H; [| dec_solve].
exploit (@indexwise_R_dec' _ _
(fun Zs a0 => of_list (fst Zs)[<=]getAnn a0 /\
NoDupA eq (fst Zs) /\
(if isFunctional i then
getAnn a0 \ of_list (fst Zs)[<=]a
else True)) F sa).
+ intros.
ensure (of_list (fst a0)[<=]getAnn b).
ensure (NoDupA _eq (fst a0)).
cases; [| dec_solve].
ensure ( getAnn b \ of_list (fst a0)[<=]a); dec_solve.
+ destruct H; dec_solve.
Defined.
Hint Extern 5 =>
match goal with
| [ H : ?A = ?B, H' : ?A <> ?B |- _ ] => exfalso; eapply H', H
end.
Definition true_live_sound_dec i ZL Lv s slv
: Computable (true_live_sound i ZL Lv s slv).
Proof.
revert i ZL Lv slv.
sind s; intros; destruct s; destruct slv;
try solve [right; intro A; inversion A].
- edestruct (IH s); eauto; [| dec_right ];
ensure (getAnn slv \ singleton x ⊆ a);
ensure (x ∈ getAnn slv \/ isCall e -> live_exp_sound e a); dec_solve.
- ensure (live_op_sound e a);
ensure (getAnn slv1 ⊆ a);
ensure (getAnn slv2 ⊆ a).
edestruct (IH s1); eauto; [ | dec_right].
edestruct (IH s2); eauto; [ | dec_right].
dec_solve.
- destruct (get_dec ZL (counted l)) as [[Z ?]|?]; [| dec_right];
destruct (get_dec Lv (counted l)) as [[blv ?]|?]; [| dec_right];
ensure (argsLive a blv Y Z).
exploit argsLive_length; eauto.
decide (isImperative i); try dec_solve.
+ decide ((blv \ of_list Z) ⊆ a).
* left; econstructor; eauto. cases; eauto.
* dec_right. cases in H7. eauto.
+ left; econstructor; eauto. cases; eauto.
- ensure (live_op_sound e a). dec_solve.
- edestruct (IH s); eauto; [| dec_right];
ensure (length F = length sa);
ensure (getAnn slv ⊆ a).
exploit (@indexwise_R_dec' _ _
(fun Zs a0 =>
true_live_sound i (fst ⊝ F ++ ZL)
(getAnn ⊝ sa ++ Lv)
(snd Zs) a0) F sa).
intros. eapply IH; eauto. destruct H; [| dec_right].
decide (isFunctional i); [| left; econstructor; try cases; eauto].
exploit (@indexwise_R_dec' _ _
(fun Zs a0 => getAnn a0 \ of_list (fst Zs)[<=]a) F sa).
+ intros.
decide ( getAnn b \ of_list (fst a0)[<=]a).
left; eauto. right; eauto.
+ destruct H. left; econstructor; try cases; eauto.
dec_right. cases in H9; eauto.
Defined.
|
/-
Copyright (c) 2021 Manuel Candales. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Manuel Candales
-/
import data.real.basic
import data.real.sqrt
import data.nat.prime
import number_theory.primes_congruent_one
import number_theory.quadratic_reciprocity
/-!
# IMO 2008 Q3
Prove that there exist infinitely many positive integers `n` such that `n^2 + 1` has a prime
divisor which is greater than `2n + √(2n)`.
# Solution
We first prove the following lemma: for every prime `p > 20`, satisfying `p ≡ 1 [MOD 4]`,
there exists `n ∈ ℕ` such that `p ∣ n^2 + 1` and `p > 2n + √(2n)`. Then the statement of the
problem follows from the fact that there exist infinitely many primes `p ≡ 1 [MOD 4]`.
To prove the lemma, notice that `p ≡ 1 [MOD 4]` implies `∃ n ∈ ℕ` such that `n^2 ≡ -1 [MOD p]`
and we can take this `n` such that `n ≤ p/2`. Let `k = p - 2n ≥ 0`. Then we have:
`k^2 + 4 = (p - 2n)^2 + 4 ≣ 4n^2 + 4 ≡ 0 [MOD p]`. Then `k^2 + 4 ≥ p` and so `k ≥ √(p - 4) > 4`.
Then `p = 2n + k ≥ 2n + √(p - 4) = 2n + √(2n + k - 4) > √(2n)` and we are done.
-/
lemma p_lemma (p : ℕ) (hpp : nat.prime p) (hp_mod_4_eq_1 : p ≡ 1 [MOD 4]) (hp_gt_20 : p > 20) :
∃ n : ℕ, p ∣ n^2 + 1 ∧ (p : ℝ) > 2*n + real.sqrt(2*n) :=
begin
haveI := fact.mk hpp,
have hp_mod_4_ne_3 : p % 4 ≠ 3, { linarith [(show p % 4 = 1, by exact hp_mod_4_eq_1)]},
obtain ⟨y, hy⟩ := (zmod.exists_pow_two_eq_neg_one_iff_mod_four_ne_three p).mpr hp_mod_4_ne_3,
let m := zmod.val_min_abs y,
let n := int.nat_abs (m),
have hnat₁ : p ∣ n^2 + 1,
{ refine int.coe_nat_dvd.mp _,
simp only [int.nat_abs_pow_two, int.coe_nat_pow, int.coe_nat_succ, int.coe_nat_dvd.mp],
refine (zmod.int_coe_zmod_eq_zero_iff_dvd (m^2 + 1) p).mp _,
simp only [int.cast_pow, int.cast_add, int.cast_one, zmod.coe_val_min_abs],
rw hy, exact add_left_neg 1 },
have hnat₂ : n ≤ p/2 := zmod.nat_abs_val_min_abs_le y,
have hnat₃ : p ≥ 2*n, { linarith [nat.div_mul_le_self p 2] },
set k : ℕ := p - 2*n with hnat₄,
have hnat₅ : p ∣ k^2 + 4,
{ cases hnat₁ with x hx,
let p₁ := (p : ℤ), let n₁ := (n : ℤ), let k₁ := (k : ℤ), let x₁ := (x : ℤ),
have : p₁ ∣ k₁^2 + 4,
{ use p₁ - 4*n₁ + 4*x₁,
calc k₁^2 + 4
= (p₁ - 2*n₁)^2 + 4 : by rw (show k₁ = p₁ - 2*n₁, by assumption_mod_cast)
... = p₁^2 - 4*p₁*n₁ + 4*(n₁^2 + 1) : by ring
... = p₁^2 - 4*p₁*n₁ + 4*(p₁*x₁) : by rw (show n₁^2 + 1 = p₁*x₁, by assumption_mod_cast)
... = p₁*(p₁ - 4*n₁ + 4*x₁) : by ring },
assumption_mod_cast },
have hnat₆ : k^2 + 4 ≥ p := nat.le_of_dvd (k^2 + 3).succ_pos hnat₅,
let p₀ := (p : ℝ), let n₀ := (n : ℝ), let k₀ := (k : ℝ),
have hreal₁ : p₀ = 2*n₀ + k₀, { linarith [(show k₀ = p₀ - 2*n₀, by assumption_mod_cast)] },
have hreal₂ : p₀ > 20, { assumption_mod_cast },
have hreal₃ : k₀^2 + 4 ≥ p₀, { assumption_mod_cast },
have hreal₄ : k₀ ≥ real.sqrt(p₀ - 4),
{ calc k₀ = real.sqrt(k₀^2) : eq.symm (real.sqrt_sqr (nat.cast_nonneg k))
... ≥ real.sqrt(p₀-4) : real.sqrt_le_sqrt (by linarith [hreal₃]) },
have hreal₅ : k₀ > 4,
{ calc k₀ ≥ real.sqrt(p₀-4) : hreal₄
... > real.sqrt(4^2) : (real.sqrt_lt (by linarith)).mpr (by linarith [hreal₂])
... = 4 : real.sqrt_sqr (by linarith) },
have hreal₆ : p₀ > 2*n₀ + real.sqrt(2*n),
{ calc p₀ = 2*n₀ + k₀ : hreal₁
... ≥ 2*n₀ + real.sqrt(p₀-4) : by linarith [hreal₄]
... = 2*n₀ + real.sqrt(2*n₀+k₀-4) : by rw hreal₁
... > 2*n₀ + real.sqrt(2*n₀) : by { refine add_lt_add_left _ (2*n₀),
refine (real.sqrt_lt _).mpr _,
refine mul_nonneg zero_le_two (nat.cast_nonneg n),
linarith [hreal₅] } },
exact ⟨n, hnat₁, hreal₆⟩,
end
theorem imo2008_q3 : ∀ N : ℕ, ∃ n : ℕ, n ≥ N ∧
∃ p : ℕ, nat.prime p ∧ p ∣ n^2 + 1 ∧ (p : ℝ) > 2*n + real.sqrt(2*n) :=
begin
intro N,
obtain ⟨p, hpp, hineq₁, hp_mod_4_eq_1⟩ := nat.exists_prime_ge_modeq_one 4 (N^2+21) zero_lt_four,
obtain ⟨n, hnat, hreal⟩ := p_lemma p hpp hp_mod_4_eq_1 (by linarith [hineq₁, nat.zero_le (N^2)]),
have hineq₂ : n^2 + 1 ≥ p := nat.le_of_dvd (n^2).succ_pos hnat,
have hineq₃ : n*n ≥ N*N, { linarith [hineq₁, hineq₂, (pow_two n), (pow_two N)] },
have hn_ge_N : n ≥ N := nat.mul_self_le_mul_self_iff.mpr hineq₃,
exact ⟨n, hn_ge_N, p, hpp, hnat, hreal⟩,
end
|
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ negY W x₁ (negY W x₁ y₁) = y₁
[PROOFSTEP]
simp only [negY]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ -(-y₁ - W.a₁ * x₁ - W.a₃) - W.a₁ * x₁ - W.a₃ = y₁
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ negY (baseChange W A) (↑(algebraMap R A) x₁) (↑(algebraMap R A) y₁) = ↑(algebraMap R A) (negY W x₁ y₁)
[PROOFSTEP]
simp only [negY]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ -↑(algebraMap R A) y₁ - (baseChange W A).a₁ * ↑(algebraMap R A) x₁ - (baseChange W A).a₃ =
↑(algebraMap R A) (-y₁ - W.a₁ * x₁ - W.a₃)
[PROOFSTEP]
map_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ -↑(algebraMap R A) y₁ - (baseChange W A).a₁ * ↑(algebraMap R A) x₁ - (baseChange W A).a₃ =
-↑(algebraMap R A) y₁ - ↑(algebraMap R A) W.a₁ * ↑(algebraMap R A) x₁ - ↑(algebraMap R A) W.a₃
[PROOFSTEP]
rfl
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁✝ x₂ y₁✝ y₂ L : R
x₁ y₁ : A
⊢ negY (baseChange W B) (↑(algebraMap A B) x₁) (↑(algebraMap A B) y₁) = ↑(algebraMap A B) (negY (baseChange W A) x₁ y₁)
[PROOFSTEP]
rw [← baseChange_negY, baseChange_baseChange]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ eval x₁ (eval (↑C y₁) (negPolynomial W)) = negY W x₁ y₁
[PROOFSTEP]
rw [negY, sub_sub, negPolynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ eval x₁ (eval (↑C y₁) (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) = -y₁ - (W.a₁ * x₁ + W.a₃)
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ XYIdeal W x₁ (↑C y₁) = XYIdeal W x₁ (linePolynomial x₁ y₁ L)
[PROOFSTEP]
simp only [XYIdeal, XClass, YClass, linePolynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ span {↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)), ↑(CoordinateRing.mk W) (Y - ↑C (↑C y₁))} =
span {↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)), ↑(CoordinateRing.mk W) (Y - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁))}
[PROOFSTEP]
rw [← span_pair_add_mul_right <| CoordinateRing.mk W <| C <| C <| -L, ← _root_.map_mul, ← map_add]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C y₁) + ↑C (Y - ↑C x₁) * ↑C (↑C (-L)))} =
span {↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)), ↑(CoordinateRing.mk W) (Y - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁))}
[PROOFSTEP]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ Y - ↑C (↑C y₁) + ↑C (Y - ↑C x₁) * ↑C (↑C (-L)) = Y - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁)
[PROOFSTEP]
C_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ Y - ↑C (↑C y₁) + (↑C Y - ↑C (↑C x₁)) * -↑C (↑C L) = Y - (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁))
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑C (addPolynomial W x₁ y₁ L) =
(Y - ↑C (linePolynomial x₁ y₁ L)) * (negPolynomial W - ↑C (linePolynomial x₁ y₁ L)) + WeierstrassCurve.polynomial W
[PROOFSTEP]
rw [addPolynomial, linePolynomial, WeierstrassCurve.polynomial, negPolynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑C
(eval (↑C L * (Y - ↑C x₁) + ↑C y₁)
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))) =
(Y - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁)) * (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃) - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁)) +
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑C
((↑C L * (Y - ↑C x₁) + ↑C y₁) ^ 2 + (↑C W.a₁ * Y + ↑C W.a₃) * (↑C L * (Y - ↑C x₁) + ↑C y₁) -
(Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) =
(Y - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁)) * (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃) - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁)) +
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))
[PROOFSTEP]
C_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁)) ^ 2 +
(↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)) * (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁)) -
(↑C Y ^ 3 + ↑C (↑C W.a₂) * ↑C Y ^ 2 + ↑C (↑C W.a₄) * ↑C Y + ↑C (↑C W.a₆)) =
(Y - (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁))) *
(-Y - (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)) - (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁))) +
(Y ^ 2 + (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)) * Y -
(↑C Y ^ 3 + ↑C (↑C W.a₂) * ↑C Y ^ 2 + ↑C (↑C W.a₄) * ↑C Y + ↑C (↑C W.a₆)))
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑C (addPolynomial W x₁ y₁ L) - (Y - ↑C (linePolynomial x₁ y₁ L)) * (negPolynomial W - ↑C (linePolynomial x₁ y₁ L)) =
WeierstrassCurve.polynomial W * 1
[PROOFSTEP]
rw [W.C_addPolynomial, add_sub_cancel', mul_one]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ addPolynomial W x₁ y₁ L =
-Cubic.toPoly
{ a := 1, b := -L ^ 2 - W.a₁ * L + W.a₂,
c := 2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄),
d := -x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }
[PROOFSTEP]
rw [addPolynomial, linePolynomial, WeierstrassCurve.polynomial, Cubic.toPoly]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ eval (↑C L * (Y - ↑C x₁) + ↑C y₁)
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) =
-(↑C
{ a := 1, b := -L ^ 2 - W.a₁ * L + W.a₂,
c := 2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄),
d := -x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.a *
Y ^ 3 +
↑C
{ a := 1, b := -L ^ 2 - W.a₁ * L + W.a₂,
c := 2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄),
d := -x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.b *
Y ^ 2 +
↑C
{ a := 1, b := -L ^ 2 - W.a₁ * L + W.a₂,
c := 2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄),
d := -x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.c *
Y +
↑C
{ a := 1, b := -L ^ 2 - W.a₁ * L + W.a₂,
c := 2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄),
d := -x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d)
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ (↑C L * (Y - ↑C x₁) + ↑C y₁) ^ 2 + (↑C W.a₁ * Y + ↑C W.a₃) * (↑C L * (Y - ↑C x₁) + ↑C y₁) -
(Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆) =
-(↑C 1 * Y ^ 3 + ↑C (-L ^ 2 - W.a₁ * L + W.a₂) * Y ^ 2 +
↑C (2 * x₁ * L ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * L + (-W.a₁ * y₁ + W.a₄)) * Y +
↑C (-x₁ ^ 2 * L ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * L - (y₁ ^ 2 + W.a₃ * y₁ - W.a₆)))
[PROOFSTEP]
C_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ (↑C L * (Y - ↑C x₁) + ↑C y₁) ^ 2 + (↑C W.a₁ * Y + ↑C W.a₃) * (↑C L * (Y - ↑C x₁) + ↑C y₁) -
(Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆) =
-(1 * Y ^ 3 + (-↑C L ^ 2 - ↑C W.a₁ * ↑C L + ↑C W.a₂) * Y ^ 2 +
(2 * ↑C x₁ * ↑C L ^ 2 + (↑C W.a₁ * ↑C x₁ - 2 * ↑C y₁ - ↑C W.a₃) * ↑C L + (-↑C W.a₁ * ↑C y₁ + ↑C W.a₄)) * Y +
(-↑C x₁ ^ 2 * ↑C L ^ 2 + (2 * ↑C x₁ * ↑C y₁ + ↑C W.a₃ * ↑C x₁) * ↑C L -
(↑C y₁ ^ 2 + ↑C W.a₃ * ↑C y₁ - ↑C W.a₆)))
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ addX (baseChange W A) (↑(algebraMap R A) x₁) (↑(algebraMap R A) x₂) (↑(algebraMap R A) L) =
↑(algebraMap R A) (addX W x₁ x₂ L)
[PROOFSTEP]
simp only [addX]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑(algebraMap R A) L ^ 2 + (baseChange W A).a₁ * ↑(algebraMap R A) L - (baseChange W A).a₂ - ↑(algebraMap R A) x₁ -
↑(algebraMap R A) x₂ =
↑(algebraMap R A) (L ^ 2 + W.a₁ * L - W.a₂ - x₁ - x₂)
[PROOFSTEP]
map_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑(algebraMap R A) L ^ 2 + (baseChange W A).a₁ * ↑(algebraMap R A) L - (baseChange W A).a₂ - ↑(algebraMap R A) x₁ -
↑(algebraMap R A) x₂ =
↑(algebraMap R A) L ^ 2 + ↑(algebraMap R A) W.a₁ * ↑(algebraMap R A) L - ↑(algebraMap R A) W.a₂ -
↑(algebraMap R A) x₁ -
↑(algebraMap R A) x₂
[PROOFSTEP]
rfl
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁✝ x₂✝ y₁ y₂ L✝ : R
x₁ x₂ L : A
⊢ addX (baseChange W B) (↑(algebraMap A B) x₁) (↑(algebraMap A B) x₂) (↑(algebraMap A B) L) =
↑(algebraMap A B) (addX (baseChange W A) x₁ x₂ L)
[PROOFSTEP]
rw [← baseChange_addX, baseChange_baseChange]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ addY' (baseChange W A) (↑(algebraMap R A) x₁) (↑(algebraMap R A) x₂) (↑(algebraMap R A) y₁) (↑(algebraMap R A) L) =
↑(algebraMap R A) (addY' W x₁ x₂ y₁ L)
[PROOFSTEP]
simp only [addY', baseChange_addX]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ↑(algebraMap R A) L * (↑(algebraMap R A) (addX W x₁ x₂ L) - ↑(algebraMap R A) x₁) + ↑(algebraMap R A) y₁ =
↑(algebraMap R A) (L * (addX W x₁ x₂ L - x₁) + y₁)
[PROOFSTEP]
map_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁✝ x₂✝ y₁✝ y₂ L✝ : R
x₁ x₂ y₁ L : A
⊢ addY' (baseChange W B) (↑(algebraMap A B) x₁) (↑(algebraMap A B) x₂) (↑(algebraMap A B) y₁) (↑(algebraMap A B) L) =
↑(algebraMap A B) (addY' (baseChange W A) x₁ x₂ y₁ L)
[PROOFSTEP]
rw [← baseChange_addY', baseChange_baseChange]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ addY (baseChange W A) (↑(algebraMap R A) x₁) (↑(algebraMap R A) x₂) (↑(algebraMap R A) y₁) (↑(algebraMap R A) L) =
↑(algebraMap R A) (addY W x₁ x₂ y₁ L)
[PROOFSTEP]
simp only [addY, baseChange_addY', baseChange_addX, baseChange_negY]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁✝ x₂✝ y₁✝ y₂ L✝ : R
x₁ x₂ y₁ L : A
⊢ addY (baseChange W B) (↑(algebraMap A B) x₁) (↑(algebraMap A B) x₂) (↑(algebraMap A B) y₁) (↑(algebraMap A B) L) =
↑(algebraMap A B) (addY (baseChange W A) x₁ x₂ y₁ L)
[PROOFSTEP]
rw [← baseChange_addY, baseChange_baseChange]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ XYIdeal W (addX W x₁ x₂ L) (↑C (addY W x₁ x₂ y₁ L)) =
span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ L))} ⊔ XIdeal W (addX W x₁ x₂ L)
[PROOFSTEP]
simp only [XYIdeal, XIdeal, XClass, YClass, addY, addY', negY, negPolynomial, linePolynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C (addX W x₁ x₂ L))),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (-(L * (addX W x₁ x₂ L - x₁) + y₁) - W.a₁ * addX W x₁ x₂ L - W.a₃)))} =
span {↑(CoordinateRing.mk W) (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃) - ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁))} ⊔
span {↑(CoordinateRing.mk W) (↑C (Y - ↑C (addX W x₁ x₂ L)))}
[PROOFSTEP]
rw [sub_sub <| -Y, neg_sub_left Y, map_neg, span_singleton_neg, sup_comm, ← span_insert, ←
span_pair_add_mul_right <| CoordinateRing.mk W <| C <| C <| W.a₁ + L, ← _root_.map_mul, ← map_add]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C (addX W x₁ x₂ L))),
↑(CoordinateRing.mk W)
(Y - ↑C (↑C (-(L * (addX W x₁ x₂ L - x₁) + y₁) - W.a₁ * addX W x₁ x₂ L - W.a₃)) +
↑C (Y - ↑C (addX W x₁ x₂ L)) * ↑C (↑C (W.a₁ + L)))} =
span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C (addX W x₁ x₂ L))),
↑(CoordinateRing.mk W) (↑C (↑C W.a₁ * Y + ↑C W.a₃) + ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁) + Y)}
[PROOFSTEP]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ Y - ↑C (↑C (-(L * (addX W x₁ x₂ L - x₁) + y₁) - W.a₁ * addX W x₁ x₂ L - W.a₃)) +
↑C (Y - ↑C (addX W x₁ x₂ L)) * ↑C (↑C (W.a₁ + L)) =
↑C (↑C W.a₁ * Y + ↑C W.a₃) + ↑C (↑C L * (Y - ↑C x₁) + ↑C y₁) + Y
[PROOFSTEP]
C_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ Y -
(-(↑C (↑C L) * (↑C (↑C (addX W x₁ x₂ L)) - ↑C (↑C x₁)) + ↑C (↑C y₁)) - ↑C (↑C W.a₁) * ↑C (↑C (addX W x₁ x₂ L)) -
↑C (↑C W.a₃)) +
(↑C Y - ↑C (↑C (addX W x₁ x₂ L))) * (↑C (↑C W.a₁) + ↑C (↑C L)) =
↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃) + (↑C (↑C L) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁)) + Y
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L) ↔
eval (addX W x₁ x₂ L) (addPolynomial W x₁ y₁ L) = 0
[PROOFSTEP]
rw [WeierstrassCurve.equation, addY', addPolynomial, linePolynomial, WeierstrassCurve.polynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ eval (addX W x₁ x₂ L)
(eval (↑C (L * (addX W x₁ x₂ L - x₁) + y₁))
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))) =
0 ↔
eval (addX W x₁ x₂ L)
(eval (↑C L * (Y - ↑C x₁) + ↑C y₁)
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))) =
0
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx : eval (addX W x₁ x₂ L) (↑derivative (addPolynomial W x₁ y₁ L)) ≠ 0
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
[PROOFSTEP]
rw [WeierstrassCurve.nonsingular, and_iff_right hx', addY', WeierstrassCurve.polynomialX, WeierstrassCurve.polynomialY]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx : eval (addX W x₁ x₂ L) (↑derivative (addPolynomial W x₁ y₁ L)) ≠ 0
⊢ eval (addX W x₁ x₂ L)
(eval (↑C (L * (addX W x₁ x₂ L - x₁) + y₁))
(↑C (↑C W.a₁) * Y - ↑C (↑C 3 * Y ^ 2 + ↑C (2 * W.a₂) * Y + ↑C W.a₄))) ≠
0 ∨
eval (addX W x₁ x₂ L) (eval (↑C (L * (addX W x₁ x₂ L - x₁) + y₁)) (↑C (↑C 2) * Y + ↑C (↑C W.a₁ * Y + ↑C W.a₃))) ≠ 0
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx : eval (addX W x₁ x₂ L) (↑derivative (addPolynomial W x₁ y₁ L)) ≠ 0
⊢ W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) ≠ 0 ∨
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) ≠ 0
[PROOFSTEP]
contrapose! hx
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ eval (addX W x₁ x₂ L) (↑derivative (addPolynomial W x₁ y₁ L)) = 0
[PROOFSTEP]
rw [addPolynomial, linePolynomial, WeierstrassCurve.polynomial]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ eval (addX W x₁ x₂ L)
(↑derivative
(eval (↑C L * (Y - ↑C x₁) + ↑C y₁)
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)))) =
0
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ eval (addX W x₁ x₂ L)
(↑derivative
((↑C L * (Y - ↑C x₁) + ↑C y₁) ^ 2 + (↑C W.a₁ * Y + ↑C W.a₃) * (↑C L * (Y - ↑C x₁) + ↑C y₁) -
(Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆))) =
0
[PROOFSTEP]
derivative_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ eval (addX W x₁ x₂ L)
(↑C 2 * (↑C L * (Y - ↑C x₁) + ↑C y₁) * (0 * (Y - ↑C x₁) + ↑C L * (1 - 0) + 0) +
((0 * Y + ↑C W.a₁ * 1 + 0) * (↑C L * (Y - ↑C x₁) + ↑C y₁) +
(↑C W.a₁ * Y + ↑C W.a₃) * (0 * (Y - ↑C x₁) + ↑C L * (1 - 0) + 0)) -
(↑C ↑3 * Y ^ (3 - 1) + (0 * Y ^ 2 + ↑C W.a₂ * (↑C 2 * Y * 1)) + (0 * Y + ↑C W.a₄ * 1) + 0)) =
0
[PROOFSTEP]
simp only [zero_add, add_zero, sub_zero, zero_mul, mul_one]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ eval (addX W x₁ x₂ L)
(↑C 2 * (↑C L * (Y - ↑C x₁) + ↑C y₁) * ↑C L +
(↑C W.a₁ * (↑C L * (Y - ↑C x₁) + ↑C y₁) + (↑C W.a₁ * Y + ↑C W.a₃) * ↑C L) -
(↑C ↑3 * Y ^ (3 - 1) + ↑C W.a₂ * (↑C 2 * Y) + ↑C W.a₄)) =
0
[PROOFSTEP]
eval_simp
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ 2 * (L * (addX W x₁ x₂ L - x₁) + y₁) * L +
(W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) * L) -
(↑3 * addX W x₁ x₂ L ^ (3 - 1) + W.a₂ * (2 * addX W x₁ x₂ L) + W.a₄) =
0
[PROOFSTEP]
linear_combination (norm := (norm_num1; ring1)) hx.left + L * hx.right
[GOAL]
case a
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ 2 * (L * (addX W x₁ x₂ L - x₁) + y₁) * L +
(W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) * L) -
(↑3 * addX W x₁ x₂ L ^ (3 - 1) + W.a₂ * (2 * addX W x₁ x₂ L) + W.a₄) -
0 -
(W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) +
L * (2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃)) -
(0 + L * 0)) =
0
[PROOFSTEP]
norm_num1
[GOAL]
case a
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
hx' : WeierstrassCurve.equation W (addX W x₁ x₂ L) (addY' W x₁ x₂ y₁ L)
hx :
W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) = 0 ∧
2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) = 0
⊢ 2 * (L * (addX W x₁ x₂ L - x₁) + y₁) * L +
(W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃) * L) -
(3 * addX W x₁ x₂ L ^ 2 + W.a₂ * (2 * addX W x₁ x₂ L) + W.a₄) -
0 -
(W.a₁ * (L * (addX W x₁ x₂ L - x₁) + y₁) - (3 * addX W x₁ x₂ L ^ 2 + 2 * W.a₂ * addX W x₁ x₂ L + W.a₄) +
L * (2 * (L * (addX W x₁ x₂ L - x₁) + y₁) + (W.a₁ * addX W x₁ x₂ L + W.a₃)) -
(0 + L * 0)) =
0
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ WeierstrassCurve.equation W x₁ (negY W x₁ y₁) ↔ WeierstrassCurve.equation W x₁ y₁
[PROOFSTEP]
rw [equation_iff, equation_iff, negY]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ (-y₁ - W.a₁ * x₁ - W.a₃) ^ 2 + W.a₁ * x₁ * (-y₁ - W.a₁ * x₁ - W.a₃) + W.a₃ * (-y₁ - W.a₁ * x₁ - W.a₃) =
x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆ ↔
y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
[PROOFSTEP]
congr! 1
[GOAL]
case a.h.e'_2
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ (-y₁ - W.a₁ * x₁ - W.a₃) ^ 2 + W.a₁ * x₁ * (-y₁ - W.a₁ * x₁ - W.a₃) + W.a₃ * (-y₁ - W.a₁ * x₁ - W.a₃) =
y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁
[PROOFSTEP]
ring1
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ WeierstrassCurve.nonsingular W x₁ (negY W x₁ y₁) ↔ WeierstrassCurve.nonsingular W x₁ y₁
[PROOFSTEP]
rw [nonsingular_iff, equation_neg_iff, ← negY, negY_negY, ← @ne_comm _ y₁, nonsingular_iff]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ WeierstrassCurve.equation W x₁ y₁ ∧ (W.a₁ * negY W x₁ y₁ ≠ 3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ ∨ y₁ ≠ negY W x₁ y₁) ↔
WeierstrassCurve.equation W x₁ y₁ ∧ (W.a₁ * y₁ ≠ 3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ ∨ y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃)
[PROOFSTEP]
exact
and_congr_right' <|
(iff_congr not_and_or.symm not_and_or.symm).mpr <| not_congr <| and_congr_left fun h => by rw [← h]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
h : y₁ = negY W x₁ y₁
⊢ W.a₁ * negY W x₁ y₁ = 3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ ↔ W.a₁ * y₁ = 3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄
[PROOFSTEP]
rw [← h]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ ∀ (x : Point W), - -x = x
[PROOFSTEP]
rintro (_ | _)
[GOAL]
case zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L : R
⊢ - -zero = zero
[PROOFSTEP]
simp [zero_def]
[GOAL]
case some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L x✝ y✝ : R
h✝ : WeierstrassCurve.nonsingular W x✝ y✝
⊢ - -some h✝ = some h✝
[PROOFSTEP]
simp [zero_def]
[GOAL]
case some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
A : Type v
inst✝⁵ : CommRing A
inst✝⁴ : Algebra R A
B : Type w
inst✝³ : CommRing B
inst✝² : Algebra R B
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x₁ x₂ y₁ y₂ L x✝ y✝ : R
h✝ : WeierstrassCurve.nonsingular W x✝ y✝
⊢ W.a₃ - (-y✝ - W.a₁ * x✝) - W.a₁ * x✝ - W.a₃ = y✝
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ slope W x₁ x₂ y₁ y₂ = 0
[PROOFSTEP]
rw [slope, if_pos hx, if_pos hy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ slope W x₁ x₂ y₁ y₂ = (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)
[PROOFSTEP]
rw [slope, if_pos hx, if_neg hy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ ≠ x₂
⊢ slope W x₁ x₂ y₁ y₂ = (y₁ - y₂) / (x₁ - x₂)
[PROOFSTEP]
rw [slope, if_neg hx]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ slope W x₁ x₂ y₁ y₂ =
-eval x₁ (eval (↑C y₁) (WeierstrassCurve.polynomialX W)) / eval x₁ (eval (↑C y₁) (WeierstrassCurve.polynomialY W))
[PROOFSTEP]
rw [slope_of_Y_ne hx hy, eval_polynomialX, neg_sub]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁) =
(3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / eval x₁ (eval (↑C y₁) (WeierstrassCurve.polynomialY W))
[PROOFSTEP]
congr 1
[GOAL]
case e_a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ y₁ - negY W x₁ y₁ = eval x₁ (eval (↑C y₁) (WeierstrassCurve.polynomialY W))
[PROOFSTEP]
rw [negY, eval_polynomialY]
[GOAL]
case e_a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) = 2 * y₁ + W.a₁ * x₁ + W.a₃
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope W x₁ x₂ y₁ y₂)
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope W x₁ x₂ y₁ y₂)
[PROOFSTEP]
by_cases hy : y₁ = W.negY x₂ y₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope W x₁ x₂ y₁ y₂)
[PROOFSTEP]
rw [slope_of_Y_eq hx hy, slope_of_Y_eq <| congr_arg _ hx, map_zero]
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ ↑(algebraMap F K) y₁ = negY (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂)
[PROOFSTEP]
rw [hy, baseChange_negY]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope W x₁ x₂ y₁ y₂)
[PROOFSTEP]
rw [slope_of_Y_ne hx hy, slope_of_Y_ne <| congr_arg _ hx]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ (3 * ↑(algebraMap F K) x₁ ^ 2 + 2 * (baseChange W K).a₂ * ↑(algebraMap F K) x₁ + (baseChange W K).a₄ -
(baseChange W K).a₁ * ↑(algebraMap F K) y₁) /
(↑(algebraMap F K) y₁ - negY (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) y₁)) =
↑(algebraMap F K) ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))
[PROOFSTEP]
map_simp
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ (3 * ↑(algebraMap F K) x₁ ^ 2 + 2 * (baseChange W K).a₂ * ↑(algebraMap F K) x₁ + (baseChange W K).a₄ -
(baseChange W K).a₁ * ↑(algebraMap F K) y₁) /
(↑(algebraMap F K) y₁ - negY (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) y₁)) =
(3 * ↑(algebraMap F K) x₁ ^ 2 + 2 * ↑(algebraMap F K) W.a₂ * ↑(algebraMap F K) x₁ + ↑(algebraMap F K) W.a₄ -
↑(algebraMap F K) W.a₁ * ↑(algebraMap F K) y₁) /
(↑(algebraMap F K) y₁ - ↑(algebraMap F K) (negY W x₁ y₁))
[PROOFSTEP]
simp only [baseChange_negY]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ (3 * ↑(algebraMap F K) x₁ ^ 2 + 2 * (baseChange W K).a₂ * ↑(algebraMap F K) x₁ + (baseChange W K).a₄ -
(baseChange W K).a₁ * ↑(algebraMap F K) y₁) /
(↑(algebraMap F K) y₁ - ↑(algebraMap F K) (negY W x₁ y₁)) =
(3 * ↑(algebraMap F K) x₁ ^ 2 + 2 * ↑(algebraMap F K) W.a₂ * ↑(algebraMap F K) x₁ + ↑(algebraMap F K) W.a₄ -
↑(algebraMap F K) W.a₁ * ↑(algebraMap F K) y₁) /
(↑(algebraMap F K) y₁ - ↑(algebraMap F K) (negY W x₁ y₁))
[PROOFSTEP]
rfl
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ ↑(algebraMap F K) y₁ ≠ negY (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂)
[PROOFSTEP]
rw [baseChange_negY]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ ↑(algebraMap F K) y₁ ≠ ↑(algebraMap F K) (negY W x₂ y₂)
[PROOFSTEP]
contrapose! hy
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : ↑(algebraMap F K) y₁ = ↑(algebraMap F K) (negY W x₂ y₂)
⊢ y₁ = negY W x₂ y₂
[PROOFSTEP]
exact NoZeroSMulDivisors.algebraMap_injective F K hy
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : ¬x₁ = x₂
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope W x₁ x₂ y₁ y₂)
[PROOFSTEP]
rw [slope_of_X_ne hx, slope_of_X_ne]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : ¬x₁ = x₂
⊢ (↑(algebraMap F K) y₁ - ↑(algebraMap F K) y₂) / (↑(algebraMap F K) x₁ - ↑(algebraMap F K) x₂) =
↑(algebraMap F K) ((y₁ - y₂) / (x₁ - x₂))
[PROOFSTEP]
map_simp
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : ¬x₁ = x₂
⊢ ↑(algebraMap F K) x₁ ≠ ↑(algebraMap F K) x₂
[PROOFSTEP]
contrapose! hx
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : ↑(algebraMap F K) x₁ = ↑(algebraMap F K) x₂
⊢ x₁ = x₂
[PROOFSTEP]
exact NoZeroSMulDivisors.algebraMap_injective F K hx
[GOAL]
F✝ : Type u
inst✝⁹ : Field F✝
W✝ : WeierstrassCurve F✝
K✝ : Type v
inst✝⁸ : Field K✝
inst✝⁷ : Algebra F✝ K✝
x₁✝ x₂✝ y₁✝ y₂✝ : F✝
h₁ : WeierstrassCurve.nonsingular W✝ x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W✝ x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W✝ x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W✝ x₂✝ y₂✝
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ x₂ y₁ y₂ : F
⊢ slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁) (↑(algebraMap F K) y₂) =
↑(algebraMap F K) (slope (baseChange W F) x₁ x₂ y₁ y₂)
[PROOFSTEP]
rw [← baseChange_slope, baseChange_baseChange]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
⊢ y₁ = y₂ ∨ y₁ = negY W x₂ y₂
[PROOFSTEP]
rw [equation_iff] at h₁' h₂'
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hx : x₁ = x₂
⊢ y₁ = y₂ ∨ y₁ = negY W x₂ y₂
[PROOFSTEP]
rw [← sub_eq_zero, ← @sub_eq_zero _ _ y₁, ← mul_eq_zero, negY]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hx : x₁ = x₂
⊢ (y₁ - y₂) * (y₁ - (-y₂ - W.a₁ * x₂ - W.a₃)) = 0
[PROOFSTEP]
linear_combination (norm := (rw [hx]; ring1)) h₁' - h₂'
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hx : x₁ = x₂
⊢ (y₁ - y₂) * (y₁ - (-y₂ - W.a₁ * x₂ - W.a₃)) - 0 -
(y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ - (y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂) -
(x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆ - (x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆))) =
0
[PROOFSTEP]
rw [hx]
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hx : x₁ = x₂
⊢ (y₁ - y₂) * (y₁ - (-y₂ - W.a₁ * x₂ - W.a₃)) - 0 -
(y₁ ^ 2 + W.a₁ * x₂ * y₁ + W.a₃ * y₁ - (y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂) -
(x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆ - (x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆))) =
0
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ XYIdeal W x₂ (↑C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
clear h₂
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ XYIdeal W x₂ (↑C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ :=
by
by_cases hx : x₁ = x₂
· rcases hx, Y_eq_of_Y_ne h₁' h₂' hx <| hxy hx with ⟨rfl, rfl⟩
field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
· field_simp [linePolynomial, slope_of_X_ne hx, sub_ne_zero_of_ne hx]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : x₁ = x₂
⊢ y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
rcases hx, Y_eq_of_Y_ne h₁' h₂' hx <| hxy hx with ⟨rfl, rfl⟩
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
⊢ y₁ = eval x₁ (linePolynomial x₁ y₁ (slope W x₁ x₁ y₁ y₁))
[PROOFSTEP]
field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : ¬x₁ = x₂
⊢ y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
field_simp [linePolynomial, slope_of_X_ne hx, sub_ne_zero_of_ne hx]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : ¬x₁ = x₂
⊢ y₂ * (x₁ - x₂) = (y₁ - y₂) * (x₂ - x₁) + y₁ * (x₁ - x₂)
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ XYIdeal W x₂ (↑C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
nth_rw 1 [hy₂]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ XYIdeal W x₂ (↑C (eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))) =
XYIdeal W x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
simp only [XYIdeal, XClass, YClass, linePolynomial]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₂)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (eval x₂ (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁))))} =
span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₂)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁))}
[PROOFSTEP]
rw [← span_pair_add_mul_right <| CoordinateRing.mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul, ← map_add]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₂)),
↑(CoordinateRing.mk W)
(Y - ↑C (↑C (eval x₂ (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁))) +
↑C (Y - ↑C x₂) * ↑C (↑C (-slope W x₁ x₂ y₁ y₂)))} =
span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₂)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁))}
[PROOFSTEP]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ Y - ↑C (↑C (eval x₂ (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁))) +
↑C (Y - ↑C x₂) * ↑C (↑C (-slope W x₁ x₂ y₁ y₂)) =
Y - ↑C (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁)
[PROOFSTEP]
eval_simp
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ Y - ↑C (↑C (slope W x₁ x₂ y₁ y₂ * (x₂ - x₁) + y₁)) + ↑C (Y - ↑C x₂) * ↑C (↑C (-slope W x₁ x₂ y₁ y₂)) =
Y - ↑C (↑C (slope W x₁ x₂ y₁ y₂) * (Y - ↑C x₁) + ↑C y₁)
[PROOFSTEP]
C_simp
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hy₂ : y₂ = eval x₂ (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))
⊢ Y - (↑C (↑C (slope W x₁ x₂ y₁ y₂)) * (↑C (↑C x₂) - ↑C (↑C x₁)) + ↑C (↑C y₁)) +
(↑C Y - ↑C (↑C x₂)) * -↑C (↑C (slope W x₁ x₂ y₁ y₂)) =
Y - (↑C (↑C (slope W x₁ x₂ y₁ y₂)) * (↑C Y - ↑C (↑C x₁)) + ↑C (↑C y₁))
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ addPolynomial W x₁ y₁ (slope W x₁ x₂ y₁ y₂) =
-((Y - ↑C x₁) * (Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
clear h₂
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ addPolynomial W x₁ y₁ (slope W x₁ x₂ y₁ y₂) =
-((Y - ↑C x₁) * (Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
rw [addPolynomial_eq, neg_inj, Cubic.prod_X_sub_C_eq, Cubic.toPoly_injective]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ { a := 1, b := -slope W x₁ x₂ y₁ y₂ ^ 2 - W.a₁ * slope W x₁ x₂ y₁ y₂ + W.a₂,
c := 2 * x₁ * slope W x₁ x₂ y₁ y₂ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₂ y₁ y₂ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₂ y₁ y₂ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₂ y₁ y₂ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) + x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂),
d := -(x₁ * x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) }
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : x₁ = x₂
⊢ { a := 1, b := -slope W x₁ x₂ y₁ y₂ ^ 2 - W.a₁ * slope W x₁ x₂ y₁ y₂ + W.a₂,
c := 2 * x₁ * slope W x₁ x₂ y₁ y₂ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₂ y₁ y₂ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₂ y₁ y₂ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₂ y₁ y₂ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) + x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂),
d := -(x₁ * x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) }
[PROOFSTEP]
rcases hx, Y_eq_of_Y_ne h₁' h₂' hx (hxy hx) with ⟨rfl, rfl⟩
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
⊢ { a := 1, b := -slope W x₁ x₁ y₁ y₁ ^ 2 - W.a₁ * slope W x₁ x₁ y₁ y₁ + W.a₂,
c := 2 * x₁ * slope W x₁ x₁ y₁ y₁ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₁ y₁ y₁ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₁ y₁ y₁ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₁ y₁ y₁ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁)),
c := x₁ * x₁ + x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁) + x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁),
d := -(x₁ * x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁)) }
[PROOFSTEP]
rw [equation_iff] at h₁' h₂'
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
⊢ { a := 1, b := -slope W x₁ x₁ y₁ y₁ ^ 2 - W.a₁ * slope W x₁ x₁ y₁ y₁ + W.a₂,
c := 2 * x₁ * slope W x₁ x₁ y₁ y₁ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₁ y₁ y₁ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₁ y₁ y₁ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₁ y₁ y₁ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁)),
c := x₁ * x₁ + x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁) + x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁),
d := -(x₁ * x₁ * addX W x₁ x₁ (slope W x₁ x₁ y₁ y₁)) }
[PROOFSTEP]
rw [slope_of_Y_ne rfl <| hxy rfl]
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }
[PROOFSTEP]
rw [negY, ← sub_ne_zero] at hxy
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }
[PROOFSTEP]
ext
[GOAL]
case pos.a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.a =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }.a
[PROOFSTEP]
rfl
[GOAL]
case pos.b
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.b =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }.b
[PROOFSTEP]
simp only [addX]
[GOAL]
case pos.b
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ -((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂ =
-(x₁ + x₁ +
(((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
W.a₂ -
x₁ -
x₁))
[PROOFSTEP]
ring1
[GOAL]
case pos.c
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.c =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }.c
[PROOFSTEP]
field_simp [hxy rfl]
[GOAL]
case pos.c
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ 2 * x₁ * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) *
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 +
(-(W.a₁ * y₁) + W.a₄) * ((y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃))) =
x₁ * x₁ * ((y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃))) +
x₁ *
((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) +
W.a₁ * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * W.a₂ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁) +
x₁ *
((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) +
W.a₁ * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * W.a₂ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁)
[PROOFSTEP]
ring1
[GOAL]
case pos.d
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d =
{ a := 1, b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }.d
[PROOFSTEP]
linear_combination (norm := (field_simp [hxy rfl]; ring1)) -h₁'
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ { a := 1,
b :=
-((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 -
W.a₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
W.a₂,
c :=
2 * x₁ * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(W.a₁ * x₁ - 2 * y₁ - W.a₃) *
((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) ^ 2 +
(2 * x₁ * y₁ + W.a₃ * x₁) * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d -
{ a := 1,
b := -(x₁ + x₁ + addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))),
c :=
x₁ * x₁ + x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)) +
x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁)),
d := -(x₁ * x₁ * addX W x₁ x₁ ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - negY W x₁ y₁))) }.d -
(-(y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁) - -(x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆)) =
0
[PROOFSTEP]
field_simp [hxy rfl]
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' h₂' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
hxy✝ : x₁ = x₁ → y₁ ≠ -y₁ - W.a₁ * x₁ - W.a₃
hxy : x₁ = x₁ → y₁ - (-y₁ - W.a₁ * x₁ - W.a₃) ≠ 0
⊢ -(x₁ ^ 2 * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃))) +
(2 * x₁ * y₁ + W.a₃ * x₁) * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) *
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * (y₁ ^ 2 + W.a₃ * y₁ - W.a₆) +
x₁ * x₁ *
((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) +
W.a₁ * (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * W.a₂ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁ -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) * x₁) -
(y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2 * (y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) *
(-(W.a₃ * y₁) + (-(W.a₁ * x₁ * y₁) + -y₁ ^ 2) - (-W.a₆ + (-(W.a₄ * x₁) + (-(W.a₂ * x₁ ^ 2) + -x₁ ^ 3)))) =
0
[PROOFSTEP]
ring1
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : ¬x₁ = x₂
⊢ { a := 1, b := -slope W x₁ x₂ y₁ y₂ ^ 2 - W.a₁ * slope W x₁ x₂ y₁ y₂ + W.a₂,
c := 2 * x₁ * slope W x₁ x₂ y₁ y₂ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₂ y₁ y₂ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₂ y₁ y₂ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₂ y₁ y₂ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) + x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂),
d := -(x₁ * x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) }
[PROOFSTEP]
rw [equation_iff] at h₁' h₂'
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : ¬x₁ = x₂
⊢ { a := 1, b := -slope W x₁ x₂ y₁ y₂ ^ 2 - W.a₁ * slope W x₁ x₂ y₁ y₂ + W.a₂,
c := 2 * x₁ * slope W x₁ x₂ y₁ y₂ ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * slope W x₁ x₂ y₁ y₂ + (-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * slope W x₁ x₂ y₁ y₂ ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * slope W x₁ x₂ y₁ y₂ -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) + x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂),
d := -(x₁ * x₂ * addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) }
[PROOFSTEP]
rw [slope_of_X_ne hx]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx : ¬x₁ = x₂
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }
[PROOFSTEP]
rw [← sub_eq_zero] at hx
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) } =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }
[PROOFSTEP]
ext
[GOAL]
case neg.a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.a =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.a
[PROOFSTEP]
rfl
[GOAL]
case neg.b
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.b =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.b
[PROOFSTEP]
simp only [addX]
[GOAL]
case neg.b
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂ =
-(x₁ + x₂ + (((y₁ - y₂) / (x₁ - x₂)) ^ 2 + W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) - W.a₂ - x₁ - x₂))
[PROOFSTEP]
ring1
[GOAL]
case neg.c
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.c =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.c
[PROOFSTEP]
apply mul_right_injective₀ hx
[GOAL]
case neg.c.a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.c =
(fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.c
[PROOFSTEP]
linear_combination (norm := (field_simp [hx]; ring1)) h₂' - h₁'
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.c -
(fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.c -
(y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ - (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁) -
(x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆ - (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆))) =
0
[PROOFSTEP]
field_simp [hx]
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (x₁ - x₂) *
(2 * x₁ * (y₁ - y₂) ^ 2 * (x₁ - x₂) + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * (y₁ - y₂) * (x₁ - x₂) ^ 2 +
(-(W.a₁ * y₁) + W.a₄) * ((x₁ - x₂) ^ 2 * (x₁ - x₂))) -
(x₁ - x₂) *
(x₁ * x₂ * ((x₁ - x₂) ^ 2 * (x₁ - x₂)) +
x₁ *
((y₁ - y₂) ^ 2 * (x₁ - x₂) + W.a₁ * (y₁ - y₂) * (x₁ - x₂) ^ 2 - (x₁ - x₂) ^ 2 * (x₁ - x₂) * W.a₂ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₁ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₂) +
x₂ *
((y₁ - y₂) ^ 2 * (x₁ - x₂) + W.a₁ * (y₁ - y₂) * (x₁ - x₂) ^ 2 - (x₁ - x₂) ^ 2 * (x₁ - x₂) * W.a₂ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₁ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₂)) -
(x₁ - x₂) ^ 2 * (x₁ - x₂) *
(y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ - (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁) -
(x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ - (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁))) =
0
[PROOFSTEP]
ring1
[GOAL]
case neg.d
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ { a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d =
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.d
[PROOFSTEP]
apply mul_right_injective₀ hx
[GOAL]
case neg.d.a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d =
(fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.d
[PROOFSTEP]
linear_combination (norm := (field_simp [hx]; ring1)) x₂ * h₁' - x₁ * h₂'
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -((y₁ - y₂) / (x₁ - x₂)) ^ 2 - W.a₁ * ((y₁ - y₂) / (x₁ - x₂)) + W.a₂,
c :=
2 * x₁ * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (W.a₁ * x₁ - 2 * y₁ - W.a₃) * ((y₁ - y₂) / (x₁ - x₂)) +
(-W.a₁ * y₁ + W.a₄),
d :=
-x₁ ^ 2 * ((y₁ - y₂) / (x₁ - x₂)) ^ 2 + (2 * x₁ * y₁ + W.a₃ * x₁) * ((y₁ - y₂) / (x₁ - x₂)) -
(y₁ ^ 2 + W.a₃ * y₁ - W.a₆) }.d -
(fun x x_1 => x * x_1) (x₁ - x₂)
{ a := 1, b := -(x₁ + x₂ + addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))),
c := x₁ * x₂ + x₁ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)) + x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂)),
d := -(x₁ * x₂ * addX W x₁ x₂ ((y₁ - y₂) / (x₁ - x₂))) }.d -
(x₂ * (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁) - x₁ * (y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂) -
(x₂ * (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆) - x₁ * (x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆))) =
0
[PROOFSTEP]
field_simp [hx]
[GOAL]
case a
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁ = x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆
h₂' : y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂ = x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx✝ : ¬x₁ = x₂
hx : ¬x₁ - x₂ = 0
⊢ (x₁ - x₂) *
(-(x₁ ^ 2 * (y₁ - y₂) ^ 2 * (x₁ - x₂)) + (2 * x₁ * y₁ + W.a₃ * x₁) * (y₁ - y₂) * (x₁ - x₂) ^ 2 -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * (y₁ ^ 2 + W.a₃ * y₁ - W.a₆)) +
(x₁ - x₂) *
(x₁ * x₂ *
((y₁ - y₂) ^ 2 * (x₁ - x₂) + W.a₁ * (y₁ - y₂) * (x₁ - x₂) ^ 2 - (x₁ - x₂) ^ 2 * (x₁ - x₂) * W.a₂ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₁ -
(x₁ - x₂) ^ 2 * (x₁ - x₂) * x₂)) -
(x₁ - x₂) ^ 2 * (x₁ - x₂) *
(x₂ * (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁) - x₁ * (y₂ ^ 2 + W.a₁ * x₂ * y₂ + W.a₃ * y₂) -
(x₂ * (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆) - x₁ * (x₂ ^ 3 + W.a₂ * x₂ ^ 2 + W.a₄ * x₂ + W.a₆))) =
0
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑(mk W) (↑C (addPolynomial W x₁ y₁ (slope W x₁ x₂ y₁ y₂))) =
-(XClass W x₁ * XClass W x₂ * XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
simp only [addPolynomial_slope h₁' h₂' hxy, C_neg, mk, map_neg, neg_inj, _root_.map_mul]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) (↑C (Y - ↑C x₁)) *
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) (↑C (Y - ↑C x₂)) *
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) (↑C (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)))) =
XClass W x₁ * XClass W x₂ * XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
rfl
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑derivative (addPolynomial W x₁ y₁ (slope W x₁ x₂ y₁ y₂)) =
-((Y - ↑C x₁) * (Y - ↑C x₂) + (Y - ↑C x₁) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) +
(Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
rw [addPolynomial_slope h₁' h₂' hxy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑derivative (-((Y - ↑C x₁) * (Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))) =
-((Y - ↑C x₁) * (Y - ↑C x₂) + (Y - ↑C x₁) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) +
(Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
derivative_simp
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ -(((1 - 0) * (Y - ↑C x₂) + (Y - ↑C x₁) * (1 - 0)) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) +
(Y - ↑C x₁) * (Y - ↑C x₂) * (1 - 0)) =
-((Y - ↑C x₁) * (Y - ↑C x₂) + (Y - ↑C x₁) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) +
(Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ WeierstrassCurve.equation W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
rw [equation_add_iff, addPolynomial_slope h₁' h₂' hxy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ eval (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))
(-((Y - ↑C x₁) * (Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))) =
0
[PROOFSTEP]
eval_simp
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ -((addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₁) * (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₂) *
(addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) =
0
[PROOFSTEP]
rw [neg_eq_zero, sub_self, mul_zero]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
clear h₂'
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
by_cases hx₁ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₁
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
rwa [addY', hx₁, sub_self, mul_zero, zero_add]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
by_cases hx₂ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
hx : x₁ = x₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
subst hx
[GOAL]
case pos
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₁ y₂
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₂
hx₁ : ¬addX W x₁ x₁ (slope W x₁ x₁ y₁ y₂) = x₁
hx₂ : addX W x₁ x₁ (slope W x₁ x₁ y₁ y₂) = x₁
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₁ (slope W x₁ x₁ y₁ y₂)) (addY' W x₁ x₁ y₁ (slope W x₁ x₁ y₁ y₂))
[PROOFSTEP]
contradiction
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
hx : ¬x₁ = x₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
rwa [addY', ← neg_sub, mul_neg, hx₂, slope_of_X_ne hx, div_mul_cancel _ <| sub_ne_zero_of_ne hx, neg_sub,
sub_add_cancel]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
⊢ WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY' W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))
[PROOFSTEP]
apply W.nonsingular_add_of_eval_derivative_ne_zero _ _ _ _ (equation_add' h₁.1 h₂.1 hxy)
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
⊢ eval (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (↑derivative (addPolynomial W x₁ y₁ (slope W x₁ x₂ y₁ y₂))) ≠ 0
[PROOFSTEP]
rw [derivative_addPolynomial_slope h₁.left h₂.left hxy]
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
⊢ eval (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))
(-((Y - ↑C x₁) * (Y - ↑C x₂) + (Y - ↑C x₁) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) +
(Y - ↑C x₂) * (Y - ↑C (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))))) ≠
0
[PROOFSTEP]
eval_simp
[GOAL]
case neg
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
hx₁ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₁
hx₂ : ¬addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) = x₂
⊢ -((addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₁) * (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₂) +
(addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₁) *
(addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) +
(addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - x₂) *
(addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂) - addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))) ≠
0
[PROOFSTEP]
simpa only [neg_ne_zero, sub_self, mul_zero, add_zero] using mul_ne_zero (sub_ne_zero_of_ne hx₁) (sub_ne_zero_of_ne hx₂)
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ∀ (a : Point W), 0 + a = a
[PROOFSTEP]
rintro (_ | _)
[GOAL]
case zero
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ 0 + zero = zero
[PROOFSTEP]
rfl
[GOAL]
case some
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular W x✝ y✝
⊢ 0 + some h✝ = some h✝
[PROOFSTEP]
rfl
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ∀ (a : Point W), a + 0 = a
[PROOFSTEP]
rintro (_ | _)
[GOAL]
case zero
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ zero + 0 = zero
[PROOFSTEP]
rfl
[GOAL]
case some
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular W x✝ y✝
⊢ some h✝ + 0 = some h✝
[PROOFSTEP]
rfl
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ some h₁ + some h₂ = 0
[PROOFSTEP]
simp only [← add_def, add, dif_pos hx, dif_pos hy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ = x₂
hy : y₁ ≠ negY W x₂ y₂
⊢ some h₁ + some h₂ =
some
(_ : WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
simp only [← add_def, add, dif_pos hx, dif_neg hy]
[GOAL]
F : Type u
inst✝² : Field F
W : WeierstrassCurve F
K : Type v
inst✝¹ : Field K
inst✝ : Algebra F K
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hx : x₁ ≠ x₂
⊢ some h₁ + some h₂ =
some
(_ : WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
simp only [← add_def, add, dif_neg hx]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ XYIdeal W x₁ (↑C (negY W x₁ y₁)) * XYIdeal W x₁ (↑C y₁) = XIdeal W x₁
[PROOFSTEP]
have Y_rw :
(Y - C (C y₁)) * (Y - C (C (W.negY x₁ y₁))) -
C (X - C x₁) * (C (X ^ 2 + C (x₁ + W.a₂) * X + C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - C (C W.a₁) * Y) =
W.polynomial * 1 :=
by
linear_combination (norm := (rw [negY, WeierstrassCurve.polynomial]; C_simp; ring1))
congr_arg C (congr_arg C ((W.equation_iff _ _).mp h₁.left).symm)
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ (Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
[PROOFSTEP]
linear_combination (norm := (rw [negY, WeierstrassCurve.polynomial]; C_simp; ring1))
congr_arg C (congr_arg C ((W.equation_iff _ _).mp h₁.left).symm)
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ (Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) -
WeierstrassCurve.polynomial W * 1 -
(↑C (↑C (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆)) - ↑C (↑C (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁))) =
0
[PROOFSTEP]
rw [negY, WeierstrassCurve.polynomial]
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ (Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (-y₁ - W.a₁ * x₁ - W.a₃))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) -
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) * 1 -
(↑C (↑C (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆)) - ↑C (↑C (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁))) =
0
[PROOFSTEP]
C_simp
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ (Y - ↑C (↑C y₁)) * (Y - (-↑C (↑C y₁) - ↑C (↑C W.a₁) * ↑C (↑C x₁) - ↑C (↑C W.a₃))) -
(↑C Y - ↑C (↑C x₁)) *
(↑C Y ^ 2 + (↑C (↑C x₁) + ↑C (↑C W.a₂)) * ↑C Y +
(↑C (↑C x₁) ^ 2 + ↑C (↑C W.a₂) * ↑C (↑C x₁) + ↑C (↑C W.a₄)) -
↑C (↑C W.a₁) * Y) -
(Y ^ 2 + (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)) * Y -
(↑C Y ^ 3 + ↑C (↑C W.a₂) * ↑C Y ^ 2 + ↑C (↑C W.a₄) * ↑C Y + ↑C (↑C W.a₆))) *
1 -
(↑C (↑C x₁) ^ 3 + ↑C (↑C W.a₂) * ↑C (↑C x₁) ^ 2 + ↑C (↑C W.a₄) * ↑C (↑C x₁) + ↑C (↑C W.a₆) -
(↑C (↑C y₁) ^ 2 + ↑C (↑C W.a₁) * ↑C (↑C x₁) * ↑C (↑C y₁) + ↑C (↑C W.a₃) * ↑C (↑C y₁))) =
0
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ XYIdeal W x₁ (↑C (negY W x₁ y₁)) * XYIdeal W x₁ (↑C y₁) = XIdeal W x₁
[PROOFSTEP]
simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert, ← span_singleton_mul_span_singleton, ← mul_sup, ←
span_insert]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ span {↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁))} *
span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)), ↑(CoordinateRing.mk W) (Y - ↑C (↑C y₁)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (negY W x₁ y₁))),
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W))
(↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y)} =
XIdeal W x₁
[PROOFSTEP]
convert mul_top (_ : Ideal W.CoordinateRing) using 2
[GOAL]
case h.e'_2.h.e'_6
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ span
{↑(CoordinateRing.mk W) (↑C (Y - ↑C x₁)), ↑(CoordinateRing.mk W) (Y - ↑C (↑C y₁)),
↑(CoordinateRing.mk W) (Y - ↑C (↑C (negY W x₁ y₁))),
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W))
(↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y)} =
⊤
[PROOFSTEP]
simp_rw [← @Set.image_singleton _ _ <| CoordinateRing.mk W, ← Set.image_insert_eq, ← map_span]
[GOAL]
case h.e'_2.h.e'_6
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ Ideal.map (CoordinateRing.mk W)
(span
{↑C (Y - ↑C x₁), Y - ↑C (↑C y₁), Y - ↑C (↑C (negY W x₁ y₁)),
↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y}) =
⊤
[PROOFSTEP]
convert map_top (R := F[X][Y]) (CoordinateRing.mk W) using 1
[GOAL]
case h.e'_2
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ Ideal.map (CoordinateRing.mk W)
(span
{↑C (Y - ↑C x₁), Y - ↑C (↑C y₁), Y - ↑C (↑C (negY W x₁ y₁)),
↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y}) =
Ideal.map (CoordinateRing.mk W) ⊤
[PROOFSTEP]
apply congr_arg
[GOAL]
case h.e'_2.h
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ span
{↑C (Y - ↑C x₁), Y - ↑C (↑C y₁), Y - ↑C (↑C (negY W x₁ y₁)),
↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y} =
⊤
[PROOFSTEP]
simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
[GOAL]
case h.e'_2.h
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
⊢ ∃ a a_1 a_2 a_3,
a_3 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + a * ↑C (Y - ↑C x₁) + a_1 * (Y - ↑C (↑C y₁)) + a_2 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
rcases((W.nonsingular_iff' _ _).mp h₁).right with hx | hy
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
⊢ ∃ a a_1 a_2 a_3,
a_3 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + a * ↑C (Y - ↑C x₁) + a_1 * (Y - ↑C (↑C y₁)) + a_2 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
let W_X := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
W_X : F := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
⊢ ∃ a a_1 a_2 a_3,
a_3 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + a * ↑C (Y - ↑C x₁) + a_1 * (Y - ↑C (↑C y₁)) + a_2 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
refine ⟨C (C W_X⁻¹ * -(X + C (2 * x₁ + W.a₂))), C (C <| W_X⁻¹ * W.a₁), 0, C (C <| W_X⁻¹ * -1), ?_⟩
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
W_X : F := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
⊢ ↑C (↑C (W_X⁻¹ * -1)) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + ↑C (↑C W_X⁻¹ * -(Y + ↑C (2 * x₁ + W.a₂))) * ↑C (Y - ↑C x₁) + ↑C (↑C (W_X⁻¹ * W.a₁)) * (Y - ↑C (↑C y₁)) +
0 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
W_X : F := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
⊢ ↑C (↑C (W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄))) *
(↑C (↑C (W_X⁻¹ * -1)) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y)) =
↑C (↑C (W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄))) *
(1 + ↑C (↑C W_X⁻¹ * -(Y + ↑C (2 * x₁ + W.a₂))) * ↑C (Y - ↑C x₁) + ↑C (↑C (W_X⁻¹ * W.a₁)) * (Y - ↑C (↑C y₁)) +
0 * (Y - ↑C (↑C (negY W x₁ y₁))))
[PROOFSTEP]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hx]
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
W_X : F := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
⊢ ↑C (↑C (1 * -1)) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
↑C (↑C (W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄))) * 1 +
↑C (↑C 1 * -(Y + ↑C (2 * x₁ + W.a₂)) * (Y - ↑C x₁)) +
↑C (↑C (1 * W.a₁)) * (Y - ↑C (↑C y₁)) +
↑C (↑C (W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄))) * 0 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
C_simp
[GOAL]
case h.e'_2.h.inl
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hx : W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄) ≠ 0
W_X : F := W.a₁ * y₁ - (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄)
⊢ 1 * -1 *
(↑C Y ^ 2 + (↑C (↑C x₁) + ↑C (↑C W.a₂)) * ↑C Y + (↑C (↑C x₁) ^ 2 + ↑C (↑C W.a₂) * ↑C (↑C x₁) + ↑C (↑C W.a₄)) -
↑C (↑C W.a₁) * Y) =
(↑C (↑C W.a₁) * ↑C (↑C y₁) - (3 * ↑C (↑C x₁) ^ 2 + 2 * ↑C (↑C W.a₂) * ↑C (↑C x₁) + ↑C (↑C W.a₄))) * 1 +
1 * -(↑C Y + (2 * ↑C (↑C x₁) + ↑C (↑C W.a₂))) * (↑C Y - ↑C (↑C x₁)) +
1 * ↑C (↑C W.a₁) * (Y - ↑C (↑C y₁)) +
(↑C (↑C W.a₁) * ↑C (↑C y₁) - (3 * ↑C (↑C x₁) ^ 2 + 2 * ↑C (↑C W.a₂) * ↑C (↑C x₁) + ↑C (↑C W.a₄))) * 0 *
(Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
ring1
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
⊢ ∃ a a_1 a_2 a_3,
a_3 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + a * ↑C (Y - ↑C x₁) + a_1 * (Y - ↑C (↑C y₁)) + a_2 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
let W_Y := 2 * y₁ + W.a₁ * x₁ + W.a₃
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
W_Y : F := 2 * y₁ + W.a₁ * x₁ + W.a₃
⊢ ∃ a a_1 a_2 a_3,
a_3 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + a * ↑C (Y - ↑C x₁) + a_1 * (Y - ↑C (↑C y₁)) + a_2 * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
refine ⟨0, C (C W_Y⁻¹), C (C <| W_Y⁻¹ * -1), 0, ?_⟩
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
W_Y : F := 2 * y₁ + W.a₁ * x₁ + W.a₃
⊢ 0 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
1 + 0 * ↑C (Y - ↑C x₁) + ↑C (↑C W_Y⁻¹) * (Y - ↑C (↑C y₁)) + ↑C (↑C (W_Y⁻¹ * -1)) * (Y - ↑C (↑C (negY W x₁ y₁)))
[PROOFSTEP]
rw [negY, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hy]
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
W_Y : F := 2 * y₁ + W.a₁ * x₁ + W.a₃
⊢ ↑C (↑C (2 * y₁ + W.a₁ * x₁ + W.a₃)) *
(0 * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y)) =
↑C (↑C (2 * y₁ + W.a₁ * x₁ + W.a₃)) *
(1 + 0 * ↑C (Y - ↑C x₁) + ↑C (↑C W_Y⁻¹) * (Y - ↑C (↑C y₁)) +
↑C (↑C (W_Y⁻¹ * -1)) * (Y - ↑C (↑C (-y₁ - W.a₁ * x₁ - W.a₃))))
[PROOFSTEP]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hy]
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
W_Y : F := 2 * y₁ + W.a₁ * x₁ + W.a₃
⊢ ↑C (↑C (2 * y₁ + W.a₁ * x₁ + W.a₃)) * 0 *
(↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
↑C (↑C (2 * y₁ + W.a₁ * x₁ + W.a₃)) * 1 + ↑C (↑C (2 * y₁ + W.a₁ * x₁ + W.a₃)) * 0 * ↑C (Y - ↑C x₁) +
↑C (↑C 1) * (Y - ↑C (↑C y₁)) +
↑C (↑C (1 * -1)) * (Y - ↑C (↑C (-y₁ - W.a₁ * x₁ - W.a₃)))
[PROOFSTEP]
C_simp
[GOAL]
case h.e'_2.h.inr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
Y_rw :
(Y - ↑C (↑C y₁)) * (Y - ↑C (↑C (negY W x₁ y₁))) -
↑C (Y - ↑C x₁) * (↑C (Y ^ 2 + ↑C (x₁ + W.a₂) * Y + ↑C (x₁ ^ 2 + W.a₂ * x₁ + W.a₄)) - ↑C (↑C W.a₁) * Y) =
WeierstrassCurve.polynomial W * 1
hy : 2 * y₁ + W.a₁ * x₁ + W.a₃ ≠ 0
W_Y : F := 2 * y₁ + W.a₁ * x₁ + W.a₃
⊢ (2 * ↑C (↑C y₁) + ↑C (↑C W.a₁) * ↑C (↑C x₁) + ↑C (↑C W.a₃)) * 0 *
(↑C Y ^ 2 + (↑C (↑C x₁) + ↑C (↑C W.a₂)) * ↑C Y + (↑C (↑C x₁) ^ 2 + ↑C (↑C W.a₂) * ↑C (↑C x₁) + ↑C (↑C W.a₄)) -
↑C (↑C W.a₁) * Y) =
(2 * ↑C (↑C y₁) + ↑C (↑C W.a₁) * ↑C (↑C x₁) + ↑C (↑C W.a₃)) * 1 +
(2 * ↑C (↑C y₁) + ↑C (↑C W.a₁) * ↑C (↑C x₁) + ↑C (↑C W.a₃)) * 0 * (↑C Y - ↑C (↑C x₁)) +
1 * (Y - ↑C (↑C y₁)) +
1 * -1 * (Y - (-↑C (↑C y₁) - ↑C (↑C W.a₁) * ↑C (↑C x₁) - ↑C (↑C W.a₃)))
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ↑(XYIdeal W x₁ (↑C y₁)) * (↑(XYIdeal W x₁ (↑C (negY W x₁ y₁))) * (↑(XIdeal W x₁))⁻¹) = 1
[PROOFSTEP]
rw [← mul_assoc, ← FractionalIdeal.coeIdeal_mul, mul_comm <| XYIdeal W _ _, XYIdeal_neg_mul h₁, XIdeal,
FractionalIdeal.coe_ideal_span_singleton_mul_inv W.FunctionField <| XClass_ne_zero W x₁]
-- porting note: increased `maxHeartbeats` for `ring1`
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ XIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) * (XYIdeal W x₁ (↑C y₁) * XYIdeal W x₂ (↑C y₂)) =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
XYIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (↑C (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
clear h₂
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ XIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) * (XYIdeal W x₁ (↑C y₁) * XYIdeal W x₂ (↑C y₂)) =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
XYIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (↑C (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
have sup_rw : ∀ a b c d : Ideal W.CoordinateRing, a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c := fun _ _ c _ => by
rw [← sup_assoc, @sup_comm _ _ c, sup_sup_sup_comm, ← sup_assoc]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
x✝² x✝¹ c x✝ : Ideal (CoordinateRing W)
⊢ x✝² ⊔ (x✝¹ ⊔ (c ⊔ x✝)) = x✝² ⊔ x✝ ⊔ x✝¹ ⊔ c
[PROOFSTEP]
rw [← sup_assoc, @sup_comm _ _ c, sup_sup_sup_comm, ← sup_assoc]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ XIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) * (XYIdeal W x₁ (↑C y₁) * XYIdeal W x₂ (↑C y₂)) =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
XYIdeal W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (↑C (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂)))
[PROOFSTEP]
rw [XYIdeal_add_eq, XIdeal, mul_comm, W.XYIdeal_eq₁ x₁ y₁ <| W.slope x₁ x₂ y₁ y₂, XYIdeal, XYIdeal_eq₂ h₁' h₂' hxy,
XYIdeal, span_pair_mul_span_pair]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span
{XClass W x₁ * XClass W x₂, XClass W x₁ * YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)),
YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) * XClass W x₂,
YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))} *
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))})
[PROOFSTEP]
simp_rw [span_insert, sup_rw, sup_mul, span_singleton_mul_span_singleton]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span {XClass W x₁ * XClass W x₂ * XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span
{YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span
{XClass W x₁ * YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span
{YClass W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) * XClass W x₂ *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))})
[PROOFSTEP]
rw [← neg_eq_iff_eq_neg.mpr <| CoordinateRing.C_addPolynomial_slope h₁' h₂' hxy, span_singleton_neg,
CoordinateRing.C_addPolynomial, _root_.map_mul, YClass]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span
{↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))) *
↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span
{↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))) *
↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))) *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span
{XClass W x₁ * ↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))) *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span
{↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂))) * XClass W x₂ *
XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))})
[PROOFSTEP]
simp_rw [mul_comm <| XClass W x₁, mul_assoc, ← span_singleton_mul_span_singleton, ← mul_sup]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span {↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} *
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span {XClass W x₁} * span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} ⊔
span {XClass W x₂} * span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))}) =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))})
[PROOFSTEP]
rw [span_singleton_mul_span_singleton, ← span_insert, ←
span_pair_add_mul_right <| -(XClass W <| W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂), mul_neg, ← sub_eq_add_neg, ← sub_mul, ←
map_sub <| CoordinateRing.mk W, sub_sub_sub_cancel_right, span_insert, ← span_singleton_mul_span_singleton, ← sup_rw,
← sup_mul, ← sup_mul]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span {↑(CoordinateRing.mk W) (Y - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
(span {XClass W x₁} ⊔ (span {XClass W x₂} ⊔ span {↑(CoordinateRing.mk W) (Y - negPolynomial W)})) *
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))}) =
YIdeal W (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)) *
(span {↑(CoordinateRing.mk W) (negPolynomial W - ↑C (linePolynomial x₁ y₁ (slope W x₁ x₂ y₁ y₂)))} ⊔
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))})
[PROOFSTEP]
apply congr_arg (_ ∘ _)
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ (span {XClass W x₁} ⊔ (span {XClass W x₂} ⊔ span {↑(CoordinateRing.mk W) (Y - negPolynomial W)})) *
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))} =
span {XClass W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂))}
[PROOFSTEP]
convert top_mul (_ : Ideal W.CoordinateRing)
[GOAL]
case h.e'_2.h.e'_5
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ span {XClass W x₁} ⊔ (span {XClass W x₂} ⊔ span {↑(CoordinateRing.mk W) (Y - negPolynomial W)}) = ⊤
[PROOFSTEP]
simp_rw [XClass, ← @Set.image_singleton _ _ <| CoordinateRing.mk W, ← map_span, ← Ideal.map_sup, eq_top_iff_one,
mem_map_iff_of_surjective _ <| AdjoinRoot.mk_surjective W.monic_polynomial, ← span_insert, mem_span_insert',
mem_span_singleton']
[GOAL]
case h.e'_2.h.e'_5
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₂)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ = x₂
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₂)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
rcases hx, Y_eq_of_Y_ne h₁' h₂' hx (hxy hx) with ⟨rfl, rfl⟩
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₁)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
let y := (y₁ - W.negY x₁ y₁) ^ 2
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
hxy : x₁ = x₁ → y₁ ≠ negY W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₁)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
replace hxy := pow_ne_zero 2 (sub_ne_zero_of_ne <| hxy rfl)
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₁)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
refine
⟨1 + C (C <| y⁻¹ * 4) * W.polynomial,
⟨C <| C y⁻¹ * (C 4 * X ^ 2 + C (4 * x₁ + W.b₂) * X + C (4 * x₁ ^ 2 + W.b₂ * x₁ + 2 * W.b₄)), 0,
C (C y⁻¹) * (Y - W.negPolynomial), ?_⟩,
by rw [map_add, map_one, _root_.map_mul <| CoordinateRing.mk W, AdjoinRoot.mk_self, mul_zero, add_zero]⟩
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) (1 + ↑C (↑C (y⁻¹ * 4)) * WeierstrassCurve.polynomial W) = 1
[PROOFSTEP]
rw [map_add, map_one, _root_.map_mul <| CoordinateRing.mk W, AdjoinRoot.mk_self, mul_zero, add_zero]
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑C (↑C y⁻¹) * (Y - negPolynomial W) * (Y - negPolynomial W) =
1 + ↑C (↑C (y⁻¹ * 4)) * WeierstrassCurve.polynomial W +
↑C (↑C y⁻¹ * (↑C 4 * Y ^ 2 + ↑C (4 * x₁ + b₂ W) * Y + ↑C (4 * x₁ ^ 2 + b₂ W * x₁ + 2 * b₄ W))) *
↑C (Y - ↑C x₁) +
0 * ↑C (Y - ↑C x₁)
[PROOFSTEP]
rw [WeierstrassCurve.polynomial, negPolynomial, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hxy]
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) *
(↑C (↑C y⁻¹) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃)))) =
↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) *
(1 +
↑C (↑C (y⁻¹ * 4)) *
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) +
↑C (↑C y⁻¹ * (↑C 4 * Y ^ 2 + ↑C (4 * x₁ + b₂ W) * Y + ↑C (4 * x₁ ^ 2 + b₂ W * x₁ + 2 * b₄ W))) *
↑C (Y - ↑C x₁) +
0 * ↑C (Y - ↑C x₁))
[PROOFSTEP]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hxy]
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑C (↑C 1) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) =
↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) * 1 +
↑C (↑C (1 * 4)) *
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) +
↑C
((↑C (1 * 4) * Y ^ 2 + ↑C (1 * 4 * x₁ + 1 * b₂ W) * Y + ↑C (1 * 4 * x₁ ^ 2 + 1 * b₂ W * x₁ + 1 * 2 * b₄ W)) *
(Y - ↑C x₁)) +
↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) * 0 * ↑C (Y - ↑C x₁)
[PROOFSTEP]
linear_combination (norm := (rw [b₂, b₄, negY]; C_simp; ring1))
-4 * congr_arg C (congr_arg C <| (W.equation_iff _ _).mp h₁')
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑C (↑C 1) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) -
(↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) * 1 +
↑C (↑C (1 * 4)) *
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) +
↑C
((↑C (1 * 4) * Y ^ 2 + ↑C (1 * 4 * x₁ + 1 * b₂ W) * Y +
↑C (1 * 4 * x₁ ^ 2 + 1 * b₂ W * x₁ + 1 * 2 * b₄ W)) *
(Y - ↑C x₁)) +
↑C (↑C ((y₁ - negY W x₁ y₁) ^ 2)) * 0 * ↑C (Y - ↑C x₁)) -
(-4 * ↑C (↑C (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁)) - -4 * ↑C (↑C (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆))) =
0
[PROOFSTEP]
rw [b₂, b₄, negY]
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ ↑C (↑C 1) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) * (Y - (-Y - ↑C (↑C W.a₁ * Y + ↑C W.a₃))) -
(↑C (↑C ((y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2)) * 1 +
↑C (↑C (1 * 4)) *
(Y ^ 2 + ↑C (↑C W.a₁ * Y + ↑C W.a₃) * Y - ↑C (Y ^ 3 + ↑C W.a₂ * Y ^ 2 + ↑C W.a₄ * Y + ↑C W.a₆)) +
↑C
((↑C (1 * 4) * Y ^ 2 + ↑C (1 * 4 * x₁ + 1 * (W.a₁ ^ 2 + 4 * W.a₂)) * Y +
↑C (1 * 4 * x₁ ^ 2 + 1 * (W.a₁ ^ 2 + 4 * W.a₂) * x₁ + 1 * 2 * (2 * W.a₄ + W.a₁ * W.a₃))) *
(Y - ↑C x₁)) +
↑C (↑C ((y₁ - (-y₁ - W.a₁ * x₁ - W.a₃)) ^ 2)) * 0 * ↑C (Y - ↑C x₁)) -
(-4 * ↑C (↑C (y₁ ^ 2 + W.a₁ * x₁ * y₁ + W.a₃ * y₁)) - -4 * ↑C (↑C (x₁ ^ 3 + W.a₂ * x₁ ^ 2 + W.a₄ * x₁ + W.a₆))) =
0
[PROOFSTEP]
C_simp
[GOAL]
case a
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
h₂' : WeierstrassCurve.equation W x₁ y₁
y : F := (y₁ - negY W x₁ y₁) ^ 2
hxy : (y₁ - negY W x₁ y₁) ^ 2 ≠ 0
⊢ 1 * (Y - (-Y - (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)))) * (Y - (-Y - (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)))) -
((↑C (↑C y₁) - (-↑C (↑C y₁) - ↑C (↑C W.a₁) * ↑C (↑C x₁) - ↑C (↑C W.a₃))) ^ 2 * 1 +
1 * 4 *
(Y ^ 2 + (↑C (↑C W.a₁) * ↑C Y + ↑C (↑C W.a₃)) * Y -
(↑C Y ^ 3 + ↑C (↑C W.a₂) * ↑C Y ^ 2 + ↑C (↑C W.a₄) * ↑C Y + ↑C (↑C W.a₆))) +
(1 * 4 * ↑C Y ^ 2 + (1 * 4 * ↑C (↑C x₁) + 1 * (↑C (↑C W.a₁) ^ 2 + 4 * ↑C (↑C W.a₂))) * ↑C Y +
(1 * 4 * ↑C (↑C x₁) ^ 2 + 1 * (↑C (↑C W.a₁) ^ 2 + 4 * ↑C (↑C W.a₂)) * ↑C (↑C x₁) +
1 * 2 * (2 * ↑C (↑C W.a₄) + ↑C (↑C W.a₁) * ↑C (↑C W.a₃)))) *
(↑C Y - ↑C (↑C x₁)) +
(↑C (↑C y₁) - (-↑C (↑C y₁) - ↑C (↑C W.a₁) * ↑C (↑C x₁) - ↑C (↑C W.a₃))) ^ 2 * 0 * (↑C Y - ↑C (↑C x₁))) -
(-4 * (↑C (↑C y₁) ^ 2 + ↑C (↑C W.a₁) * ↑C (↑C x₁) * ↑C (↑C y₁) + ↑C (↑C W.a₃) * ↑C (↑C y₁)) -
-4 * (↑C (↑C x₁) ^ 3 + ↑C (↑C W.a₂) * ↑C (↑C x₁) ^ 2 + ↑C (↑C W.a₄) * ↑C (↑C x₁) + ↑C (↑C W.a₆))) =
0
[PROOFSTEP]
ring1
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : ¬x₁ = x₂
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₂)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
replace hx := sub_ne_zero_of_ne hx
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ - x₂ ≠ 0
⊢ ∃ x,
(∃ a a_1 a_2, a_2 * (Y - negPolynomial W) = x + a * ↑C (Y - ↑C x₁) + a_1 * ↑C (Y - ↑C x₂)) ∧
↑(AdjoinRoot.mk (WeierstrassCurve.polynomial W)) x = 1
[PROOFSTEP]
refine ⟨_, ⟨⟨C <| C (x₁ - x₂)⁻¹, C <| C <| (x₁ - x₂)⁻¹ * -1, 0, ?_⟩, map_one _⟩⟩
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ - x₂ ≠ 0
⊢ 0 * (Y - negPolynomial W) = 1 + ↑C (↑C (x₁ - x₂)⁻¹) * ↑C (Y - ↑C x₁) + ↑C (↑C ((x₁ - x₂)⁻¹ * -1)) * ↑C (Y - ↑C x₂)
[PROOFSTEP]
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ - x₂ ≠ 0
⊢ ↑C (↑C (x₁ - x₂)) * (0 * (Y - negPolynomial W)) =
↑C (↑C (x₁ - x₂)) * (1 + ↑C (↑C (x₁ - x₂)⁻¹) * ↑C (Y - ↑C x₁) + ↑C (↑C ((x₁ - x₂)⁻¹ * -1)) * ↑C (Y - ↑C x₂))
[PROOFSTEP]
simp only [← mul_assoc, mul_add, ← C_mul, mul_inv_cancel hx]
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ - x₂ ≠ 0
⊢ ↑C (↑C (x₁ - x₂)) * 0 * (Y - negPolynomial W) =
↑C (↑C (x₁ - x₂)) * 1 + ↑C (↑C 1 * (Y - ↑C x₁)) + ↑C (↑C (1 * -1) * (Y - ↑C x₂))
[PROOFSTEP]
C_simp
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
sup_rw : ∀ (a b c d : Ideal (CoordinateRing W)), a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c
hx : x₁ - x₂ ≠ 0
⊢ (↑C (↑C x₁) - ↑C (↑C x₂)) * 0 * (Y - negPolynomial W) =
(↑C (↑C x₁) - ↑C (↑C x₂)) * 1 + 1 * (↑C Y - ↑C (↑C x₁)) + 1 * -1 * (↑C Y - ↑C (↑C x₂))
[PROOFSTEP]
ring1
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ↑ClassGroup.mk (XYIdeal' (_ : WeierstrassCurve.nonsingular W x₁ (negY W x₁ y₁))) * ↑ClassGroup.mk (XYIdeal' h₁) = 1
[PROOFSTEP]
rw [← _root_.map_mul]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ↑ClassGroup.mk (XYIdeal' (_ : WeierstrassCurve.nonsingular W x₁ (negY W x₁ y₁)) * XYIdeal' h₁) = 1
[PROOFSTEP]
exact
(ClassGroup.mk_eq_one_of_coe_ideal <| by
exact
(FractionalIdeal.coeIdeal_mul _ _).symm.trans <| FractionalIdeal.coeIdeal_inj.mpr <| XYIdeal_neg_mul h₁).mpr
⟨_, XClass_ne_zero W _, rfl⟩
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ↑(XYIdeal' (_ : WeierstrassCurve.nonsingular W x₁ (negY W x₁ y₁)) * XYIdeal' h₁) = ↑(span {XClass W ?m.4456306})
[PROOFSTEP]
exact (FractionalIdeal.coeIdeal_mul _ _).symm.trans <| FractionalIdeal.coeIdeal_inj.mpr <| XYIdeal_neg_mul h₁
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑ClassGroup.mk (XYIdeal' h₁) * ↑ClassGroup.mk (XYIdeal' h₂) =
↑ClassGroup.mk
(XYIdeal'
(_ :
WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
rw [← _root_.map_mul]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑ClassGroup.mk (XYIdeal' h₁ * XYIdeal' h₂) =
↑ClassGroup.mk
(XYIdeal'
(_ :
WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))))
[PROOFSTEP]
exact
(ClassGroup.mk_eq_mk_of_coe_ideal (by exact (FractionalIdeal.coeIdeal_mul _ _).symm) <| XYIdeal'_eq _).mpr
⟨_, _, XClass_ne_zero W _, YClass_ne_zero W _, XYIdeal_mul_XYIdeal h₁.left h₂.left hxy⟩
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ negY W x₂ y₂
⊢ ↑(XYIdeal' h₁ * XYIdeal' h₂) = ↑(XYIdeal W x₁ (↑C y₁) * XYIdeal W x₂ (↑C y₂))
[PROOFSTEP]
exact (FractionalIdeal.coeIdeal_mul _ _).symm
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ∀ (x y : Point W),
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (x + y) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } x +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } y
[PROOFSTEP]
rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
[GOAL]
case zero.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (zero + zero) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero
case zero.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂✝ y₁ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (zero + some h₂) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)
case some.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂ y₁✝ y₂ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂ y₂
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + zero) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + some h₂) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)
[PROOFSTEP]
any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
[GOAL]
case zero.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (zero + zero) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero
[PROOFSTEP]
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
[GOAL]
case zero.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂✝ y₁ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (zero + some h₂) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)
[PROOFSTEP]
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
[GOAL]
case some.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂ y₁✝ y₂ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂ y₂
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + zero) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero
[PROOFSTEP]
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
[GOAL]
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + some h₂) =
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)
[PROOFSTEP]
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
[GOAL]
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
hx : x₁ = x₂
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
by_cases hy : y₁ = W.negY x₂ y₂
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
substs hx hy
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂ y₁ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁
h₂✝ : WeierstrassCurve.nonsingular W x₂ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂✝
x₁ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₁ y₂
h₁ : WeierstrassCurve.nonsingular W x₁ (negY W x₁ y₂)
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
simpa only [some_add_some_of_Y_eq rfl rfl] using (mk_XYIdeal'_mul_mk_XYIdeal'_of_Y_eq h₂).symm
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
simpa only [some_add_some_of_Y_ne hx hy] using (mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ fun _ => hy).symm
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁✝ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂✝ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
hx : ¬x₁ = x₂
⊢ (match some h₁ + some h₂ with
| zero => 0
| some h => ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h))) =
↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₁)) + ↑Additive.ofMul (↑ClassGroup.mk (XYIdeal' h₂))
[PROOFSTEP]
simpa only [some_add_some_of_X_ne hx] using (mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ fun h => (hx h).elim).symm
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P Q : Point W
⊢ P + Q = 0 ↔ P = -Q
[PROOFSTEP]
rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
[GOAL]
case zero.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ zero + zero = 0 ↔ zero = -zero
case zero.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂✝ y₁ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝
case some.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂ y₁✝ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂ y₂
x₁ y₁ : F
h✝ : WeierstrassCurve.nonsingular W x₁ y₁
⊢ some h✝ + zero = 0 ↔ some h✝ = -zero
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝
[PROOFSTEP]
any_goals rfl
[GOAL]
case zero.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ zero + zero = 0 ↔ zero = -zero
[PROOFSTEP]
rfl
[GOAL]
case zero.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂✝ y₁ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝
[PROOFSTEP]
rfl
[GOAL]
case some.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂ y₁✝ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂ y₂
x₁ y₁ : F
h✝ : WeierstrassCurve.nonsingular W x₁ y₁
⊢ some h✝ + zero = 0 ↔ some h✝ = -zero
[PROOFSTEP]
rfl
[GOAL]
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝
[PROOFSTEP]
rfl
[GOAL]
case zero.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂✝ y₁ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝
[PROOFSTEP]
rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
[GOAL]
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝
[PROOFSTEP]
rw [neg_some, some.injEq]
[GOAL]
case some.some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
constructor
[GOAL]
case some.some.mp
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ some h✝¹ + some h✝ = 0 → x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
intro h
[GOAL]
case some.some.mp
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
h : some h✝¹ + some h✝ = 0
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
by_cases hy : y₁ = W.negY x₂ y₂
[GOAL]
case pos
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
hy : y₁ = negY W x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
exact ⟨hx, hy⟩
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
rw [some_add_some_of_Y_ne hx hy] at h
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY W x₂ y₂
h :
some
(_ :
WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))) =
0
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
contradiction
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : ¬x₁ = x₂
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
rw [some_add_some_of_X_ne hx] at h
[GOAL]
case neg
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
hx : ¬x₁ = x₂
h :
some
(_ :
WeierstrassCurve.nonsingular W (addX W x₁ x₂ (slope W x₁ x₂ y₁ y₂)) (addY W x₁ x₂ y₁ (slope W x₁ x₂ y₁ y₂))) =
0
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂
[PROOFSTEP]
contradiction
[GOAL]
case some.some.mpr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁✝ x₂✝ y₁✝ y₂✝ : F
h₁ : WeierstrassCurve.nonsingular W x₁✝ y₁✝
h₂ : WeierstrassCurve.nonsingular W x₂✝ y₂✝
h₁' : WeierstrassCurve.equation W x₁✝ y₁✝
h₂' : WeierstrassCurve.equation W x₂✝ y₂✝
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular W x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular W x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = negY W x₂ y₂ → some h✝¹ + some h✝ = 0
[PROOFSTEP]
exact fun ⟨hx, hy⟩ => some_add_some_of_Y_eq hx hy
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P : Point W
⊢ -P + P = 0
[PROOFSTEP]
rw [add_eq_zero]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P Q : Point W
⊢ -P + Q = 0 ↔ P = Q
[PROOFSTEP]
rw [add_eq_zero, neg_inj]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P : Point W
⊢ ↑toClass P = 0 ↔ P = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P : Point W
⊢ ↑toClass P = 0 → P = 0
[PROOFSTEP]
intro hP
[GOAL]
case mp
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P : Point W
hP : ↑toClass P = 0
⊢ P = 0
[PROOFSTEP]
rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
[GOAL]
case mp.zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
hP : ↑toClass zero = 0
⊢ zero = 0
[PROOFSTEP]
rfl
[GOAL]
case mp.some.intro
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.equation W x✝ y✝
right✝ :
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0
hP :
↑toClass
(some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0))) =
0
⊢ some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0)) =
0
[PROOFSTEP]
rcases(ClassGroup.mk_eq_one_of_coe_ideal <| by rfl).mp hP with ⟨p, h0, hp⟩
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.equation W x✝ y✝
right✝ :
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0
hP :
↑toClass
(some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0))) =
0
⊢ ↑(XYIdeal'
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0))) =
↑?m.4705169
[PROOFSTEP]
rfl
[GOAL]
case mp.some.intro.intro.intro
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.equation W x✝ y✝
right✝ :
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0
hP :
↑toClass
(some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0))) =
0
p : CoordinateRing W
h0 : p ≠ 0
hp : XYIdeal W x✝ (↑C y✝) = span {p}
⊢ some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0)) =
0
[PROOFSTEP]
apply (p.natDegree_norm_ne_one _).elim
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.equation W x✝ y✝
right✝ :
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0
hP :
↑toClass
(some
(_ :
WeierstrassCurve.equation W x✝ y✝ ∧
(eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialX W)) ≠ 0 ∨
eval x✝ (eval (↑C y✝) (WeierstrassCurve.polynomialY W)) ≠ 0))) =
0
p : CoordinateRing W
h0 : p ≠ 0
hp : XYIdeal W x✝ (↑C y✝) = span {p}
⊢ natDegree (↑(Algebra.norm F[X]) p) = 1
[PROOFSTEP]
rw [← finrank_quotient_span_eq_natDegree_norm (CoordinateRing.basis W) h0, ←
(quotientEquivAlgOfEq F hp).toLinearEquiv.finrank_eq, (quotientXYIdealEquiv W h).toLinearEquiv.finrank_eq,
FiniteDimensional.finrank_self]
[GOAL]
case mpr
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P : Point W
⊢ P = 0 → ↑toClass P = 0
[PROOFSTEP]
exact congr_arg toClass
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
⊢ Function.Injective ↑toClass
[PROOFSTEP]
rintro (_ | h) _ hP
[GOAL]
case zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
a₂✝ : Point W
hP : ↑toClass zero = ↑toClass a₂✝
⊢ zero = a₂✝
case some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.nonsingular W x✝ y✝
a₂✝ : Point W
hP : ↑toClass (some h) = ↑toClass a₂✝
⊢ some h = a₂✝
[PROOFSTEP]
all_goals rw [← neg_add_eq_zero, ← toClass_eq_zero, map_add, ← hP]
[GOAL]
case zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
a₂✝ : Point W
hP : ↑toClass zero = ↑toClass a₂✝
⊢ zero = a₂✝
[PROOFSTEP]
rw [← neg_add_eq_zero, ← toClass_eq_zero, map_add, ← hP]
[GOAL]
case some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.nonsingular W x✝ y✝
a₂✝ : Point W
hP : ↑toClass (some h) = ↑toClass a₂✝
⊢ some h = a₂✝
[PROOFSTEP]
rw [← neg_add_eq_zero, ← toClass_eq_zero, map_add, ← hP]
[GOAL]
case zero
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
a₂✝ : Point W
hP : ↑toClass zero = ↑toClass a₂✝
⊢ ↑toClass (-zero) + ↑toClass zero = 0
[PROOFSTEP]
exact zero_add 0
[GOAL]
case some
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
x✝ y✝ : F
h : WeierstrassCurve.nonsingular W x✝ y✝
a₂✝ : Point W
hP : ↑toClass (some h) = ↑toClass a₂✝
⊢ ↑toClass (-some h) + ↑toClass (some h) = 0
[PROOFSTEP]
exact mk_XYIdeal'_mul_mk_XYIdeal'_of_Y_eq h
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P Q : Point W
⊢ ↑toClass (P + Q) = ↑toClass (Q + P)
[PROOFSTEP]
simp only [map_add, _root_.add_comm]
[GOAL]
F : Type u
inst✝ : Field F
W : WeierstrassCurve F
x₁ x₂ y₁ y₂ : F
h₁ : WeierstrassCurve.nonsingular W x₁ y₁
h₂ : WeierstrassCurve.nonsingular W x₂ y₂
h₁' : WeierstrassCurve.equation W x₁ y₁
h₂' : WeierstrassCurve.equation W x₂ y₂
P Q R : Point W
⊢ ↑toClass (P + Q + R) = ↑toClass (P + (Q + R))
[PROOFSTEP]
simp only [map_add, _root_.add_assoc]
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
⊢ ∀ (x y : W⟮F⟯),
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(x + y) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } x +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } y
[PROOFSTEP]
rintro (_ | @⟨x₁, y₁, _⟩) (_ | @⟨x₂, y₂, _⟩)
[GOAL]
case zero.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(zero + zero) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero
case zero.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(zero + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
case some.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝ + zero) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
any_goals rfl
[GOAL]
case zero.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(zero + zero) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero
[PROOFSTEP]
rfl
[GOAL]
case zero.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(zero + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
rfl
[GOAL]
case some.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝ + zero) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) } zero
[PROOFSTEP]
rfl
[GOAL]
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
rfl
[GOAL]
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
by_cases hx : x₁ = x₂
[GOAL]
case pos
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
by_cases hy : y₁ = (W.baseChange F).negY x₂ y₂
[GOAL]
case pos
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
simp only [some_add_some_of_Y_eq hx hy, ofBaseChangeFun]
[GOAL]
case pos
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY (baseChange W F) x₂ y₂
⊢ 0 =
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) y₁)) +
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂))
[PROOFSTEP]
rw [some_add_some_of_Y_eq <| congr_arg _ hx]
[GOAL]
case pos
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : y₁ = negY (baseChange W F) x₂ y₂
⊢ ↑(algebraMap F K) y₁ = negY (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂)
[PROOFSTEP]
rw [hy, baseChange_negY_of_baseChange]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY (baseChange W F) x₂ y₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
simp only [some_add_some_of_Y_ne hx hy, ofBaseChangeFun]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY (baseChange W F) x₂ y₂
⊢ some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(↑(algebraMap F K) (addX (baseChange W F) x₁ x₂ (slope (baseChange W F) x₁ x₂ y₁ y₂)))
(↑(algebraMap F K) (addY (baseChange W F) x₁ x₂ y₁ (slope (baseChange W F) x₁ x₂ y₁ y₂)))) =
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) y₁)) +
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂))
[PROOFSTEP]
rw [some_add_some_of_Y_ne <| congr_arg _ hx]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY (baseChange W F) x₂ y₂
⊢ some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(↑(algebraMap F K) (addX (baseChange W F) x₁ x₂ (slope (baseChange W F) x₁ x₂ y₁ y₂)))
(↑(algebraMap F K) (addY (baseChange W F) x₁ x₂ y₁ (slope (baseChange W F) x₁ x₂ y₁ y₂)))) =
some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(addX (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂)
(slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(↑(algebraMap F K) y₂)))
(addY (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(↑(algebraMap F K) y₂))))
[PROOFSTEP]
simp only [baseChange_addX_of_baseChange, baseChange_addY_of_baseChange, baseChange_slope_of_baseChange]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY (baseChange W F) x₂ y₂
⊢ ↑(algebraMap F K) y₁ ≠ negY (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂)
[PROOFSTEP]
rw [baseChange_negY_of_baseChange]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = negY (baseChange W F) x₂ y₂
⊢ ↑(algebraMap F K) y₁ ≠ ↑(algebraMap F K) (negY (baseChange W F) x₂ y₂)
[PROOFSTEP]
contrapose! hy
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : x₁ = x₂
hy : ↑(algebraMap F K) y₁ = ↑(algebraMap F K) (negY (baseChange W F) x₂ y₂)
⊢ y₁ = negY (baseChange W F) x₂ y₂
[PROOFSTEP]
exact NoZeroSMulDivisors.algebraMap_injective F K hy
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : ¬x₁ = x₂
⊢ ZeroHom.toFun { toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹ + some h✝) =
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝¹) +
ZeroHom.toFun
{ toFun := ofBaseChangeFun W F K, map_zero' := (_ : ofBaseChangeFun W F K 0 = ofBaseChangeFun W F K 0) }
(some h✝)
[PROOFSTEP]
simp only [some_add_some_of_X_ne hx, ofBaseChangeFun]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : ¬x₁ = x₂
⊢ some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(↑(algebraMap F K) (addX (baseChange W F) x₁ x₂ (slope (baseChange W F) x₁ x₂ y₁ y₂)))
(↑(algebraMap F K) (addY (baseChange W F) x₁ x₂ y₁ (slope (baseChange W F) x₁ x₂ y₁ y₂)))) =
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) y₁)) +
some (_ : WeierstrassCurve.nonsingular (baseChange W K) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₂))
[PROOFSTEP]
rw [some_add_some_of_X_ne]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : ¬x₁ = x₂
⊢ some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(↑(algebraMap F K) (addX (baseChange W F) x₁ x₂ (slope (baseChange W F) x₁ x₂ y₁ y₂)))
(↑(algebraMap F K) (addY (baseChange W F) x₁ x₂ y₁ (slope (baseChange W F) x₁ x₂ y₁ y₂)))) =
some
(_ :
WeierstrassCurve.nonsingular (baseChange W K)
(addX (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂)
(slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(↑(algebraMap F K) y₂)))
(addY (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(slope (baseChange W K) (↑(algebraMap F K) x₁) (↑(algebraMap F K) x₂) (↑(algebraMap F K) y₁)
(↑(algebraMap F K) y₂))))
[PROOFSTEP]
simp only [baseChange_addX_of_baseChange, baseChange_addY_of_baseChange, baseChange_slope_of_baseChange]
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : ¬x₁ = x₂
⊢ ↑(algebraMap F K) x₁ ≠ ↑(algebraMap F K) x₂
[PROOFSTEP]
contrapose! hx
[GOAL]
case neg
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x₁ y₁ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x₁ y₁
x₂ y₂ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x₂ y₂
hx : ↑(algebraMap F K) x₁ = ↑(algebraMap F K) x₂
⊢ x₁ = x₂
[PROOFSTEP]
exact NoZeroSMulDivisors.algebraMap_injective F K hx
[GOAL]
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
⊢ Function.Injective ↑(ofBaseChange W F K)
[PROOFSTEP]
rintro (_ | _) (_ | _) h
[GOAL]
case zero.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
h : ↑(ofBaseChange W F K) zero = ↑(ofBaseChange W F K) zero
⊢ zero = zero
case zero.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) zero = ↑(ofBaseChange W F K) (some h✝)
⊢ zero = some h✝
case some.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝) = ↑(ofBaseChange W F K) zero
⊢ some h✝ = zero
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝¹ y✝¹ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x✝¹ y✝¹
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝¹) = ↑(ofBaseChange W F K) (some h✝)
⊢ some h✝¹ = some h✝
[PROOFSTEP]
any_goals contradiction
[GOAL]
case zero.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
h : ↑(ofBaseChange W F K) zero = ↑(ofBaseChange W F K) zero
⊢ zero = zero
[PROOFSTEP]
contradiction
[GOAL]
case zero.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) zero = ↑(ofBaseChange W F K) (some h✝)
⊢ zero = some h✝
[PROOFSTEP]
contradiction
[GOAL]
case some.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝) = ↑(ofBaseChange W F K) zero
⊢ some h✝ = zero
[PROOFSTEP]
contradiction
[GOAL]
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝¹ y✝¹ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x✝¹ y✝¹
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝¹) = ↑(ofBaseChange W F K) (some h✝)
⊢ some h✝¹ = some h✝
[PROOFSTEP]
contradiction
[GOAL]
case zero.zero
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
h : ↑(ofBaseChange W F K) zero = ↑(ofBaseChange W F K) zero
⊢ zero = zero
[PROOFSTEP]
rfl
[GOAL]
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝¹ y✝¹ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x✝¹ y✝¹
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝¹) = ↑(ofBaseChange W F K) (some h✝)
⊢ some h✝¹ = some h✝
[PROOFSTEP]
rw [some.injEq]
[GOAL]
case some.some
R : Type u
inst✝⁶ : CommRing R
W : WeierstrassCurve R
F : Type v
inst✝⁵ : Field F
inst✝⁴ : Algebra R F
K : Type w
inst✝³ : Field K
inst✝² : Algebra R K
inst✝¹ : Algebra F K
inst✝ : IsScalarTower R F K
x✝¹ y✝¹ : F
h✝¹ : WeierstrassCurve.nonsingular (baseChange W F) x✝¹ y✝¹
x✝ y✝ : F
h✝ : WeierstrassCurve.nonsingular (baseChange W F) x✝ y✝
h : ↑(ofBaseChange W F K) (some h✝¹) = ↑(ofBaseChange W F K) (some h✝)
⊢ x✝¹ = x✝ ∧ y✝¹ = y✝
[PROOFSTEP]
exact
⟨NoZeroSMulDivisors.algebraMap_injective F K (some.inj h).left,
NoZeroSMulDivisors.algebraMap_injective F K (some.inj h).right⟩
|
State Before: ι : Type u_1
inst✝ : Fintype ι
a b : ι → ℝ
h : a ≤ b
⊢ ENNReal.toReal (↑↑volume (Set.pi univ fun i => Ico (a i) (b i))) = ∏ i : ι, (b i - a i) State After: no goals Tactic: simp only [volume_pi_Ico, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))] |
#include "simple_demo_chain_version/main_program_logic/MainProgramLogicProvider.hpp"
#include "simple_demo_chain_version/security_keys/VerifyingKeys.hpp"
#include <tm_kit/infra/Environments.hpp>
#include <tm_kit/infra/TerminationController.hpp>
#include <tm_kit/infra/SinglePassIterationApp.hpp>
#include <tm_kit/basic/SpdLoggingComponent.hpp>
#include <tm_kit/basic/single_pass_iteration_clock/ClockComponent.hpp>
#include <tm_kit/basic/single_pass_iteration_clock/ClockOnOrderFacility.hpp>
#include <tm_kit/basic/ByteDataWithTopicRecordFileImporterExporter.hpp>
#include <tm_kit/basic/simple_shared_chain/ChainDataImporterExporter.hpp>
#include <tm_kit/basic/CommonFlowUtils.hpp>
#include <tm_kit/basic/AppRunnerUtils.hpp>
#include <tm_kit/transport/CrossGuidComponent.hpp>
#include <tm_kit/transport/SharedChainCreator.hpp>
#include <tm_kit/transport/security/SignatureAndVerifyHookFactoryComponents.hpp>
#include <iostream>
#include <fstream>
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
using namespace dev::cd606::tm;
using namespace simple_demo_chain_version;
using namespace boost::program_options;
template <class Env>
void run(Env *env, std::string const &chainLocatorStr, std::string const &outputFile) {
using M = infra::SinglePassIterationApp<Env>;
using R = infra::AppRunner<M>;
R r(env);
transport::SharedChainCreator<M> sharedChainCreator;
auto chainDataSource = basic::simple_shared_chain::createChainDataSource<
R, ChainData
>(
r
, sharedChainCreator.template readerFactory<
ChainData
, main_program_logic::TrivialChainDataFolder
>(
env
, chainLocatorStr
)
, "input_chain"
);
basic::AppRunnerUtilComponents<R>
::setupExitTimer(
r
, std::chrono::hours(24)
, chainDataSource.clone()
, [](Env *env) {
env->log(infra::LogLevel::Info, "Wrapping up!");
}
, "exitTimerPart"
);
if (outputFile != "") {
std::ofstream ofs(outputFile.c_str(), std::ios::binary);
auto fileWriter = basic::ByteDataWithTopicRecordFileImporterExporter<M>
::template createExporter<basic::ByteDataWithTopicRecordFileFormat<std::chrono::microseconds>>(
ofs
, {(std::byte) 0x01,(std::byte) 0x23,(std::byte) 0x45,(std::byte) 0x67}
, {(std::byte) 0x76,(std::byte) 0x54,(std::byte) 0x32,(std::byte) 0x10}
);
r.registerExporter("fileWriter", fileWriter);
auto encoder = M::template liftPure<ChainData>(
[](ChainData &&d) -> basic::ByteDataWithTopic {
return {
"chain.data"
, basic::bytedata_utils::RunSerializer<ChainData>::apply(std::move(d))
};
}
);
r.registerAction("encoder", encoder);
r.exportItem(fileWriter, r.execute(encoder, chainDataSource.clone()));
r.finalize();
} else {
auto printer = M::template pureExporter<ChainData>(
[env](ChainData &&d) {
std::ostringstream oss;
oss << d;
env->log(infra::LogLevel::Info, oss.str());
}
);
r.registerExporter("printer", printer);
r.exportItem(printer, chainDataSource.clone());
r.finalize();
}
}
void runSigned(std::string const &chainLocatorStr, std::string const &outputFile) {
using TheEnvironment = infra::Environment<
infra::CheckTimeComponent<true>,
infra::TrivialExitControlComponent,
basic::TimeComponentEnhancedWithSpdLogging<
basic::single_pass_iteration_clock::ClockComponent<std::chrono::system_clock::time_point>
, false //don't log thread ID
>,
transport::CrossGuidComponent,
transport::AllChainComponents,
transport::TrivialOutgoingHookFactoryComponent<ChainData>,
transport::security::VerifyUsingNameTagHookFactoryComponent<ChainData>
>;
TheEnvironment env;
env.transport::security::VerifyUsingNameTagHookFactoryComponent<ChainData>::operator=(
transport::security::VerifyUsingNameTagHookFactoryComponent<ChainData> {
verifyingKeys
}
);
run<TheEnvironment>(&env, chainLocatorStr, outputFile);
}
void runPlain(std::string const &chainLocatorStr, std::string const &outputFile) {
using TheEnvironment = infra::Environment<
infra::CheckTimeComponent<true>,
infra::TrivialExitControlComponent,
basic::TimeComponentEnhancedWithSpdLogging<
basic::single_pass_iteration_clock::ClockComponent<std::chrono::system_clock::time_point>
, false //don't log thread ID
>,
transport::CrossGuidComponent,
transport::AllChainComponents
>;
TheEnvironment env;
run<TheEnvironment>(&env, chainLocatorStr, outputFile);
}
int main(int argc, char **argv) {
options_description desc("allowed options");
desc.add_options()
("help", "display help message")
("chain", value<std::string>(), "the locator string of the chain to print")
("outputFile", value<std::string>(), "the file to write to (if not given, then print on terminal")
("chainIsSigned", "whether chain is signed")
;
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if (vm.count("help")) {
std::cout << desc << '\n';
return 0;
}
if (!vm.count("chain")) {
std::cerr << "Please provide chain to be printed\n";
return 1;
}
auto chainLocatorStr = vm["chain"].as<std::string>();
std::string outputFile = "";
if (vm.count("outputFile")) {
outputFile = vm["outputFile"].as<std::string>();
}
bool chainIsSigned = vm.count("chainIsSigned");
if (chainIsSigned) {
runSigned(chainLocatorStr, outputFile);
} else {
runPlain(chainLocatorStr, outputFile);
}
return 0;
} |
#include <cublas.h>
#include <cblas.h>
#include <stdio.h>
#include <stdlib.h>
void checkStatus(char* message, cublasStatus status) {
if (status != CUBLAS_STATUS_SUCCESS) {
fprintf (stderr, "!!!! %s fail %d\n", message, status);
exit(EXIT_FAILURE);
}
}
double cblas_ddot (const int n, const double *x, const int incx, const double *y, const int incy) {
double result;
double *cuA, *cuB;
cublasStatus status;
status = cublasInit();
checkStatus("init", status);
status = cublasAlloc(n, sizeof(double),(void**)&cuA);
checkStatus("A", status);
status = cublasAlloc(n, sizeof(double),(void**)&cuB);
checkStatus("B", status);
status = cublasSetVector(n, sizeof(double), x, incx, cuA, incx);
checkStatus("setA", status);
status = cublasSetVector(n, sizeof(double), y, incy, cuB, incy);
checkStatus("setB", status);
result = cublasDdot(n, cuA, incx, cuB, incy);
status = cublasFree(cuA);
checkStatus("freeA", status);
status = cublasFree(cuB);
checkStatus("freeB", status);
// cublasShutdown();
return result;
}
void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
const int K, const double alpha, const double *A,
const int lda, const double *B, const int ldb,
const double beta, double *C, const int ldc) {
double *cuA, *cuB, *cuC;
cublasStatus status;
status = cublasInit();
checkStatus("init", status);
status = cublasAlloc(M * N, sizeof(double),(void**)&cuA);
checkStatus("A", status);
status = cublasAlloc(N * K, sizeof(double),(void**)&cuB);
checkStatus("B", status);
status = cublasAlloc(M * K, sizeof(double),(void**)&cuC);
checkStatus("C", status);
status = cublasSetMatrix(M, N, sizeof(double), A, lda, cuA, lda);
checkStatus("setA", status);
status = cublasSetMatrix(M, N, sizeof(double), B, ldb, cuB, ldb);
checkStatus("setB", status);
// status = cublasSetMatrix(M, N, sizeof(double), C, ldc, cuC, ldc);
// checkStatus("setC", status);
// HACK: ignore trans
cublasDgemm('N', 'N', M, N, K, alpha, cuA, lda, cuB, ldb, beta, cuC, ldc);
//checkStatus("dgemm", status);
status = cublasGetMatrix(M, N, sizeof(double), cuC, ldc, C, ldc);
checkStatus("setB", status);
status = cublasFree(cuA);
checkStatus("freeA", status);
status = cublasFree(cuB);
checkStatus("freeB", status);
status = cublasFree(cuC);
checkStatus("freeC", status);
// cublasShutdown();
} |
import .convex set_theory.cardinal order.well_founded set_theory.cardinal_ordinal
open_locale cardinal
section
universe u
parameters {α : Type u} [has_betweenness α]
@[reducible]
def generates (b : set α) (s : set α) (h : is_affine s) : Prop :=
affine_hull b = s
theorem generates.of_span {s : set α} (h : is_affine s) : generates s s h :=
h
@[reducible]
def generators {s : set α} (h : is_affine s) : set (set α) :=
{b | generates b s h}
namespace generators
theorem self_gens {s : set α} : ∀ h : is_affine s, s ∈ generators h :=
generates.of_span
theorem is_nonempty {s : set α} (h : is_affine s) : (generators h).nonempty :=
⟨s, self_gens h⟩
end generators
@[reducible]
def is_basis {s : set α} {h : is_affine s} (b : generators h) : Prop :=
∀ b' ∈ generators h, #b ≤ #b'
@[reducible]
def bases {s : set α} (h : is_affine s) : set (@generators s h) :=
is_basis
end
protected def {u} bases.univ (α : Type u) [has_betweenness α] : set (generators is_affine.univ) :=
@bases α _ _ _
section
universe u
theorem cardinal.le_mk_le_iff_ex_sub_right {α : Type u} {s t : set α} (h : #s ≤ #t) :
∃ s' ⊆ t, #s' = #s :=
begin
rw cardinal.le_mk_iff_exists_subset at h,
rcases h with ⟨s', _, _⟩,
exact ⟨s', ‹_›, ‹_›⟩
end
parameters {α : Type u} [has_betweenness α]
namespace bases
theorem is_nonempty {s : set α} (h : is_affine s) : (bases h).nonempty :=
begin
have gne : (@set.univ $ generators h).nonempty,
{ cases generators.is_nonempty h with w h, exact ⟨⟨w, h⟩, trivial⟩ },
let f := λ l r : generators h, #l < #r,
rcases well_founded.has_min (inv_image.wf _ cardinal.wf) _ gne with ⟨b, _, hb⟩,
refine ⟨b, λ b' hb', _⟩,
specialize hb ⟨b', hb'⟩ trivial,
change ¬ _ < _ at hb,
simp at hb,
assumption
end
instance {s : set α} (h : is_affine s) : nonempty (bases h) :=
⟨⟨(is_nonempty h).some, (is_nonempty h).some_mem⟩⟩
def basis_card {s : set α} (h : is_affine s) : cardinal :=
#(nonempty h).some
theorem all_bases_same_card {s : set α} {h : is_affine s} (b : bases h) : #b = basis_card h :=
begin
rcases b with ⟨⟨g, hg⟩, hbg⟩,
let b' := (infer_instance : nonempty $ bases h).some,
change #g = #b',
exact le_antisymm (hbg b'.val b'.val.property) (b'.property g hg)
end
/-
theorem ex_union_basis_of_gen {s : set α} (hs : is_affine s) (g : generators _ hs) :
∃ (s' : set α) (b : bases hs), s' ∪ b = g :=
begin
by_cases hg : is_basis _ _ g, { exact ⟨∅, ⟨g, hg⟩, by simp⟩ },
rw is_basis at hg, push_neg at hg,
rcases hg with ⟨b, hbg, ⟨hb : _ ≤ #g.val, hb' : ¬ (#g.val ≤ _)⟩⟩,
by_contra h,
push_neg at h,
specialize h b,
end
--theorem ex_subgen {s : set α} {hs : is_affine s} {g : generators _ hs} (h : )
theorem ex_basis_sub_gen {s : set α} (hs : is_affine s) (g : generators _ hs) :
∃ b : bases hs, b.val.val ⊆ g.val :=
begin
by_cases hg : is_basis _ _ g, { exact ⟨⟨g, hg⟩, set.subset.rfl⟩ },
rw is_basis at hg, push_neg at hg,
rcases hg with ⟨b, hbg, ⟨hb : _ ≤ #g.val, hb' : ¬ (#g.val ≤ _)⟩⟩,
rw cardinal.le_mk_iff_exists_subset at hb hb',
rcases hb with ⟨w, hw, hw'⟩,
push_neg at hb',
refine ⟨⟨⟨w, _⟩, _⟩, hw⟩,
end
-/
end bases
end
|
//==================================================================================================
/*!
@file
@copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_FUNCTION_IS_GEZ_HPP_INCLUDED
#define BOOST_SIMD_FUNCTION_IS_GEZ_HPP_INCLUDED
#if defined(DOXYGEN_ONLY)
namespace boost { namespace simd
{
/*!
@ingroup group-predicates
This function object returns @ref True or @ref False according x
is greater or equal to @ref Zero or not.
@par Header <boost/simd/function/is_gez.hpp>
@par Note
Using `is_gez(x)` is equivalent to `x >= 0`
@par Example:
@snippet is_gez.cpp is_gez
@par Possible output:
@snippet is_gez.txt is_gez
**/
as_logical_t<Value> is_gez(Value const& x);
} }
#endif
#include <boost/simd/function/scalar/is_gez.hpp>
#include <boost/simd/function/simd/is_gez.hpp>
#endif
|
/-
Copyright (c) 2019 The Flypitch Project. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jesse Han, Floris van Doorn
-/
import .henkin
local attribute [instance, priority 0] classical.prop_decidable
open fol fol.Lhom
namespace fol
lemma satisfied_of_provable {L : Language} (T : Theory L) (ψ : sentence L) : T ⊢' ψ → T ⊨ ψ :=
λ _, soundness $ classical.choice ‹_›
lemma completeness_for_inconsistent_theories {L : Language} (T : Theory L) (ψ : sentence L) (h_inconsis : ¬ is_consistent T) : T ⊢' ψ ↔ T ⊨ ψ :=
⟨satisfied_of_provable _ _, λ _, exfalso' $ classical.by_contradiction ‹_›⟩
/- T is consistent iff there is a nonempty model of T -/
theorem model_existence {L : Language} (T : Theory L) : is_consistent T ↔ (∃ M : Structure L, (nonempty M) ∧ M ⊨ T) :=
begin
refine ⟨_,_⟩; intro H,
{ refine ⟨reduct (@henkin_language_over L T H)
(term_model $ completion_of_henkinization H), ⟨_,_⟩⟩,
{ exact reduct_nonempty_of_nonempty (by simp[fol.nonempty_term_model]) },
{ exact reduct_of_complete_henkinization_models_T _ } },
{ rcases H with ⟨M, ⟨H_nonempty, H_sat⟩⟩,
exact λ _, false_of_satisfied_false (satisfied_of_provable _ _ ‹_› ‹_› ‹_›) }
end
noncomputable def nonempty_model_of_consis {L : Language} {T : Theory L} (hT : is_consistent T) : Σ' M : Model T, nonempty M.fst.carrier :=
begin
have := (model_existence T).mp hT, apply classical.psigma_of_exists,
rcases this with ⟨M, hM, h_satisfied⟩,
apply exists.intro, swap, exact ⟨M, h_satisfied⟩, exact hM
end
/-- model_existence is implied by completeness --/
theorem model_existence_of_completeness {L : Language} (T : Theory L) (h_completeness : ∀ (T : Theory L) (ψ : sentence L), T ⊢' ψ ↔ T ⊨ ψ) : is_consistent T ↔ (∃ M : Structure L, (nonempty M) ∧ M ⊨ T) :=
begin
refine ⟨_,_⟩; intro H,
{ by_contra H', push_neg at H', apply H,
rw h_completeness,
intros M hM0 hMT, exfalso, exact H' M hM0 hMT },
{ intro H', rcases H with ⟨_,_,_⟩, rw[h_completeness] at H',
exact false_of_satisfied_false (H' ‹_› ‹_›) }
end
theorem completeness {L : Language} (T : Theory L) (ψ : sentence L) : T ⊢' ψ ↔ T ⊨ ψ :=
begin
refine ⟨λ _, satisfied_of_provable _ _ ‹_›, _⟩, by_contra H, push_neg at H,
rcases nonempty_model_of_consis (consis_not_of_not_provable H.right) with ⟨⟨M,HM⟩, H_nonempty⟩,
refine absurd H.left (not_satisfied_of_model_not _ _ _), swap,
exact ((by simp at HM; simp*) : (⟨M, by tidy⟩ : Model T) ⊨ _), from ‹_›
end
theorem compactness {L : Language} {T : Theory L} {f : sentence L} :
T ⊨ f ↔ ∃ fs : finset (sentence L), (↑fs : Theory L) ⊨ (f : sentence L) ∧ ↑fs ⊆ T :=
begin
rw [<-(completeness T f), theory_proof_compactness_iff], simp only [completeness]
end
end fol
|
//==================================================================================================
/*!
@file
@copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_FUNCTION_INEARBYINT_HPP_INCLUDED
#define BOOST_SIMD_FUNCTION_INEARBYINT_HPP_INCLUDED
#if defined(DOXYGEN_ONLY)
namespace boost { namespace simd
{
/*!
@ingroup group-arithmetic
Function object implementing inearbyint capabilities
Computes the integer conversion of the nearbyint of its parameter.
@par semantic:
For any given value @c x of type @c T:
@code
as_integer_t<T> r = inearbyint(x);
@endcode
is similar to:
@code
as_integer_t<T> r = toint_s(nearbyint(x));
@endcode
@par Note:
Speed can be gained using inearbyint(x, fast_) that uses @ref
toint in place of @ref toint_s, but be aware that large values can be not correctly converted
and that invalid entries lead to undefined results
**/
as_integer_t<Value> inearbyint(Value const& x);
} }
#endif
#include <boost/simd/function/scalar/inearbyint.hpp>
#include <boost/simd/function/simd/inearbyint.hpp>
#endif
|
import Lean.Elab.Tactic
-- import Lean.Elab.Tactic.Simp
#exit
#check Lean.Meta.getSimpLemmas
#check Lean.Elab.Tactic.mkSimpContext
#check Lean.Elab.Tactic.evalSimp
theorem pointfree_left {f : α → β} {g : β → γ} :
g (f x) = y →
(g ∘ f) x = y := id
theorem pointfree_right {f : α → β} {g : β → γ} :
x = g (f y) →
x = (g ∘ f) y := id
theorem finish_pointfree {f g : α → β} :
(∀ x, f x = g x) → f = g := funext
namespace Lean.Meta
namespace MakeBuddies
end MakeBuddies
open Lean.Expr
open Meta
open Lean.Macro
open Lean.Meta
-- def mkLam (v : Expr) (b : Expr) : MetaM Expr := do
-- let lctx ← getLCtx
-- let decl := lctx.get! v.fvarId!
-- let n := decl.userName
-- let t := decl.type
-- let bi := decl.binderInfo
-- return mkLambda n bi t (b.abstract #[v])
-- open Lean.Meta (mkLambdaFVars)
partial def finishPointFree (pr : Expr) : MetaM (FVarId × Expr) := do
match (← inferType pr) with
| app (app eq (app f x@(fvar x' _) _) _) (app f' y@(fvar y' _) _) _ => do
unless (x' == y') do
throwError "cannot transform into point-free: {x} {y}";
let args := #[none, none, f, f', (← mkLambdaFVars #[x] pr)]
let l ← mkAppOptM ``finish_pointfree args
return (x', l)
| t => do
throwError "bad shape {(← ppExpr t)}"
-- #check @pointfree_right
partial def mkPointFreeRight (pr : Expr) : MetaM (FVarId × Expr) := do
match (← inferType pr) with
| app (app eq lhs _) (app f (app g x _) _) _ =>
let args := #[none, none, none, none, x, g, f, pr]
(mkAppOptM ``pointfree_right args
>>= mkPointFreeRight)
| _ => finishPointFree pr
partial def mkPointFreeLeft (pr : Expr) : MetaM (FVarId × Expr) := do
match (← inferType pr) with
| app (app eq (app f (app g x _) _) _) _ _ =>
let args := #[none, none, none, x, none, g, f, pr]
(mkAppOptM ``pointfree_left args
>>= mkPointFreeLeft)
| _ => mkPointFreeRight pr
def makeBuddies (n : Name) : MetaM (Name × Name) := do
let info ← getConstInfo n
let ls : List Name := info.levelParams
let l ← mkConst n (ls.map mkLevelParam)
let n' := Name.appendAfter info.name "_pointfree"
let t ← inferType l
forallTelescopeReducing t λ args hd => do
for x in args do
IO.println s!"{(← ppExpr x)} : {(← ppExpr (← inferType x))}"
IO.println s!"{(← ppExpr hd)}"
let l' := mkAppN l args
IO.println s!"{(← ppExpr l')}"
IO.println s!"{(← ppExpr (← inferType l'))}"
let (v, e) ← mkPointFreeLeft l'
let args := args.erase (mkFVar v)
let e ← mkLambdaFVars args e
let t ← inferType e
-- let t ← mkForallFVars args (← inferType e)
modifyEnv λ env => env.add
<| ConstantInfo.thmInfo
<| { name := n',
levelParams := ls,
type := t,
value := e }
IO.println s!"{(← ppExpr e)} : {(← ppExpr (← inferType e))}"
return (n, n')
#eval makeBuddies ``LawfulFunctor.comp_map
#check @LawfulFunctor.comp_map_pointfree
#check getSimpLemmas
namespace Buddies
private partial def isPerm : Expr → Expr → MetaM Bool
| Expr.app f₁ a₁ _, Expr.app f₂ a₂ _ => isPerm f₁ f₂ <&&> isPerm a₁ a₂
| Expr.mdata _ s _, t => isPerm s t
| s, Expr.mdata _ t _ => isPerm s t
| s@(Expr.mvar ..), t@(Expr.mvar ..) => isDefEq s t
| Expr.forallE n₁ d₁ b₁ _, Expr.forallE n₂ d₂ b₂ _ => isPerm d₁ d₂ <&&> withLocalDeclD n₁ d₁ fun x => isPerm (b₁.instantiate1 x) (b₂.instantiate1 x)
| Expr.lam n₁ d₁ b₁ _, Expr.lam n₂ d₂ b₂ _ => isPerm d₁ d₂ <&&> withLocalDeclD n₁ d₁ fun x => isPerm (b₁.instantiate1 x) (b₂.instantiate1 x)
| Expr.letE n₁ t₁ v₁ b₁ _, Expr.letE n₂ t₂ v₂ b₂ _ =>
isPerm t₁ t₂ <&&> isPerm v₁ v₂ <&&> withLetDecl n₁ t₁ v₁ fun x => isPerm (b₁.instantiate1 x) (b₂.instantiate1 x)
| Expr.proj _ i₁ b₁ _, Expr.proj _ i₂ b₂ _ => i₁ == i₂ <&&> isPerm b₁ b₂
| s, t => s == t
private def checkTypeIsProp (type : Expr) : MetaM Unit :=
unless (← isProp type) do
throwError "invalid 'simp', proposition expected{indentExpr type}"
private def mkSimpLemmaCore (e : Expr) (levelParams : Array Name) (proof : Expr) (post : Bool) (prio : Nat) (name? : Option Name) : MetaM SimpLemma := do
let type ← instantiateMVars (← inferType e)
withNewMCtxDepth do
let (xs, _, type) ← withReducible <| forallMetaTelescopeReducing type
let type ← whnfR type
let (keys, perm) ←
match type.eq? with
| some (_, lhs, rhs) => pure (← DiscrTree.mkPath lhs, ← isPerm lhs rhs)
| none => throwError "unexpected kind of 'simp' theorem{indentExpr type}"
return { keys := keys, perm := perm, post := post, levelParams := levelParams, proof := proof, name? := name?, priority := prio }
private partial def shouldPreprocess (type : Expr) : MetaM Bool :=
forallTelescopeReducing type fun xs result => return !result.isEq
private partial def preprocess (e type : Expr) (inv : Bool) : MetaM (List (Expr × Expr)) := do
let type ← whnf type
if type.isForall then
forallTelescopeReducing type fun xs type => do
let e := mkAppN e xs
let ps ← preprocess e type inv
ps.mapM fun (e, type) =>
return (← mkLambdaFVars xs e, ← mkForallFVars xs type)
else if let some (_, lhs, rhs) := type.eq? then
if inv then
let type ← mkEq rhs lhs
let e ← mkEqSymm e
return [(e, type)]
else
return [(e, type)]
else if let some (lhs, rhs) := type.iff? then
if inv then
let type ← mkEq rhs lhs
let e ← mkEqSymm (← mkPropExt e)
return [(e, type)]
else
let type ← mkEq lhs rhs
let e ← mkPropExt e
return [(e, type)]
else if let some (_, lhs, rhs) := type.ne? then
if inv then
throwError "invalid '←' modifier in rewrite rule to 'False'"
let type ← mkEq (← mkEq lhs rhs) (mkConst ``False)
let e ← mkEqFalse e
return [(e, type)]
else if let some p := type.not? then
if inv then
throwError "invalid '←' modifier in rewrite rule to 'False'"
let type ← mkEq p (mkConst ``False)
let e ← mkEqFalse e
return [(e, type)]
else if let some (type₁, type₂) := type.and? then
let e₁ := mkProj ``And 0 e
let e₂ := mkProj ``And 1 e
return (← preprocess e₁ type₁ inv) ++ (← preprocess e₂ type₂ inv)
else
if inv then
throwError "invalid '←' modifier in rewrite rule to 'True'"
let type ← mkEq type (mkConst ``True)
let e ← mkEqTrue e
return [(e, type)]
private def mkSimpLemmasFromConst (declName : Name) (post : Bool) (inv : Bool) (prio : Nat) : MetaM (Array SimpLemma) := do
let cinfo ← getConstInfo declName
let val := mkConst declName (cinfo.levelParams.map mkLevelParam)
withReducible do
let type ← inferType val
checkTypeIsProp type
if inv || (← shouldPreprocess type) then
let mut r := #[]
for (val, type) in (← preprocess val type inv) do
let auxName ← mkAuxLemma cinfo.levelParams type val
r := r.push <| (← mkSimpLemmaCore (mkConst auxName (cinfo.levelParams.map mkLevelParam)) #[] (mkConst auxName) post prio declName)
return r
else
#[← mkSimpLemmaCore (mkConst declName (cinfo.levelParams.map mkLevelParam)) #[] (mkConst declName) post prio declName]
abbrev SimpExtension := SimpleScopedEnvExtension SimpEntry SimpLemmas
def SimpExtension.getLemmas (ext : SimpExtension) : CoreM SimpLemmas :=
return ext.getState (← getEnv)
def addSimpLemma (ext : SimpExtension) (declName : Name) (post : Bool) (inv : Bool) (attrKind : AttributeKind) (prio : Nat) : MetaM Unit := do
let simpLemmas ← mkSimpLemmasFromConst declName post inv prio
for simpLemma in simpLemmas do
ext.add (SimpEntry.lemma simpLemma) attrKind
def mkSimpAttr (attrName : Name) (attrDescr : String) (ext : SimpExtension) : IO Unit :=
registerBuiltinAttribute {
name := attrName
descr := attrDescr
add := fun declName stx attrKind =>
let go : MetaM Unit := do
let info ← getConstInfo declName
if (← isProp info.type) then
let post :=
if stx[1].isNone then true else stx[1][0].getKind == ``Lean.Parser.Tactic.simpPost
let prio ← getAttrParamOptPrio stx[2]
addSimpLemma ext declName post (inv := false) attrKind prio
else if info.hasValue then
ext.add (SimpEntry.toUnfold declName) attrKind
else
throwError "invalid 'simp', it is not a proposition nor a definition (to unfold)"
discard <| go.run {} {}
erase := fun declName => do
let s ← ext.getState (← getEnv)
let s ← s.erase declName
modifyEnv fun env => ext.modifyState env fun _ => s
}
def mkSimpExt (extName : Name) : IO SimpExtension :=
registerSimpleScopedEnvExtension {
name := extName
initial := {}
addEntry := fun d e =>
match e with
| SimpEntry.lemma e => addSimpLemmaEntry d e
| SimpEntry.toUnfold n => d.addDeclToUnfold n
}
def registerSimpAttr (attrName : Name) (attrDescr : String) (extName : Name := attrName.appendAfter "Ext") : IO SimpExtension := do
let ext ← mkSimpExt extName
mkSimpAttr attrName attrDescr ext
return ext
builtin_initialize mySimpExtension : SimpExtension ← registerSimpAttr `my_simp "simplification theorem with buddies"
def getSimpLemmas : CoreM SimpLemmas :=
simpExtension.getLemmas
end Buddies
end Lean.Meta
namespace Lean.Elab.Tactic
-- abbrev mkDischargeWrapper :=
-- _root_.Lean.Elab.Tactic.mkDischargeWrapper
open Lean.Meta
private def addDeclToUnfoldOrLemma (lemmas : Meta.SimpLemmas) (e : Expr) (post : Bool) (inv : Bool) : MetaM Meta.SimpLemmas := do
if e.isConst then
let declName := e.constName!
let info ← getConstInfo declName
if (← isProp info.type) then
lemmas.addConst declName (post := post) (inv := inv)
else
if inv then
throwError "invalid '←' modifier, '{declName}' is a declaration name to be unfolded"
lemmas.addDeclToUnfold declName
else
lemmas.add #[] e (post := post) (inv := inv)
private def addSimpLemma (lemmas : Meta.SimpLemmas) (stx : Syntax) (post : Bool) (inv : Bool) : TermElabM Meta.SimpLemmas := do
let (levelParams, proof) ← Term.withoutModifyingElabMetaStateWithInfo <| withRef stx <| Term.withoutErrToSorry do
let e ← Term.elabTerm stx none
Term.synthesizeSyntheticMVars (mayPostpone := false) (ignoreStuckTC := true)
let e ← instantiateMVars e
let e := e.eta
if e.hasMVar then
let r ← abstractMVars e
return (r.paramNames, r.expr)
else
return (#[], e)
lemmas.add levelParams proof (post := post) (inv := inv)
/--
Elaborate extra simp lemmas provided to `simp`. `stx` is of the `simpLemma,*`
If `eraseLocal == true`, then we consider local declarations when resolving names for erased lemmas (`- id`),
this option only makes sense for `simp_all`.
-/
private def elabSimpArgs (stx : Syntax) (ctx : Simp.Context) (eraseLocal : Bool) : TacticM ElabSimpArgsResult := do
if stx.isNone then
return { ctx }
else
/-
syntax simpPre := "↓"
syntax simpPost := "↑"
syntax simpLemma := (simpPre <|> simpPost)? term
syntax simpErase := "-" ident
-/
withMainContext do
let mut lemmas := ctx.simpLemmas
let mut starArg := false
for arg in stx[1].getSepArgs do
if arg.getKind == ``Lean.Parser.Tactic.simpErase then
if eraseLocal && (← Term.isLocalIdent? arg[1]).isSome then
-- We use `eraseCore` because the simp lemma for the hypothesis was not added yet
lemmas ← lemmas.eraseCore arg[1].getId
else
let declName ← resolveGlobalConstNoOverloadWithInfo arg[1]
lemmas ← lemmas.erase declName
else if arg.getKind == ``Lean.Parser.Tactic.simpLemma then
let post :=
if arg[0].isNone then
true
else
arg[0][0].getKind == ``Parser.Tactic.simpPost
let inv := !arg[1].isNone
let term := arg[2]
match (← resolveSimpIdLemma? term) with
| some e => lemmas ← addDeclToUnfoldOrLemma lemmas e post inv
| _ => lemmas ← addSimpLemma lemmas term post inv
else if arg.getKind == ``Lean.Parser.Tactic.simpStar then
starArg := true
else
throwUnsupportedSyntax
return { ctx := { ctx with simpLemmas := lemmas }, starArg }
where
resolveSimpIdLemma? (simpArgTerm : Syntax) : TacticM (Option Expr) := do
if simpArgTerm.isIdent then
try
Term.resolveId? simpArgTerm (withInfo := true)
catch _ =>
return none
else
Term.elabCDotFunctionAlias? simpArgTerm
private def mkDischargeWrapper (optDischargeSyntax : Syntax) : TacticM Simp.DischargeWrapper := do
if optDischargeSyntax.isNone then
return Simp.DischargeWrapper.default
else
let (ref, d) ← tacticToDischarge optDischargeSyntax[0][3]
return Simp.DischargeWrapper.custom ref d
-- TODO: move?
private def getPropHyps : MetaM (Array FVarId) := do
let mut result := #[]
for localDecl in (← getLCtx) do
unless localDecl.isAuxDecl do
if (← isProp localDecl.type) then
result := result.push localDecl.fvarId
return result
/--
If `ctx == false`, the config argument is assumed to have type `Meta.Simp.Config`, and `Meta.Simp.ConfigCtx` otherwise.
If `ctx == false`, the `discharge` option must be none -/
def mkSimpContext' (stx : Syntax) (eraseLocal : Bool) (ctx := false) (ignoreStarArg : Bool := false) : TacticM MkSimpContextResult := do
if ctx && !stx[2].isNone then
throwError "'simp_all' tactic does not support 'discharger' option"
let dischargeWrapper ← mkDischargeWrapper stx[2]
let simpOnly := !stx[3].isNone
let simpLemmas ←
if simpOnly then
({} : SimpLemmas).addConst ``eq_self
else
getSimpLemmas
let congrLemmas ← getCongrLemmas
let r ← elabSimpArgs stx[4] (eraseLocal := eraseLocal) {
config := (← elabSimpConfig stx[1] (ctx := ctx))
simpLemmas, congrLemmas
}
if !r.starArg || ignoreStarArg then
return { r with fvarIdToLemmaId := {}, dischargeWrapper }
else
let ctx := r.ctx
let erased := ctx.simpLemmas.erased
let hs ← getPropHyps
let mut ctx := ctx
let mut fvarIdToLemmaId := {}
for h in hs do
let localDecl ← getLocalDecl h
unless erased.contains localDecl.userName do
let fvarId := localDecl.fvarId
let proof := localDecl.toExpr
let id ← mkFreshUserName `h
fvarIdToLemmaId := fvarIdToLemmaId.insert fvarId id
let simpLemmas ← ctx.simpLemmas.add #[] proof (name? := id)
ctx := { ctx with simpLemmas }
return { ctx, fvarIdToLemmaId, dischargeWrapper }
@[tactic Lean.Parser.Tactic.simp] def evalSimp' : Tactic := fun stx => do
IO.println "simp!!!"
-- let { ctx, fvarIdToLemmaId, dischargeWrapper } ← withMainContext <| mkSimpContext stx (eraseLocal := false)
-- -- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
-- dischargeWrapper.with fun discharge? =>
-- simpLocation ctx discharge? fvarIdToLemmaId (expandOptLocation stx[5])
end Lean.Elab.Tactic
example : True := by simp
|
||| Why do we have to do this?
||| https://stackoverflow.com/q/51529100/834176
module ListExt
%default total
%access public export
splitOnL' : Eq a => (delim : List a) -> {auto dprf : NonEmpty delim }
-> (matching : List a) -> {auto mprf : NonEmpty matching}
-> List a -> (List a, List (List a))
splitOnL' _ _ [] = ([], [])
splitOnL' delim m@(_::m') list@(x::xs) =
if isPrefixOf m list
then
case m' of
[] => ([], uncurry (::) $ splitOnL' delim delim xs)
(m_ :: ms) => splitOnL' delim (m_ :: ms) xs
else
let (l, ls) = splitOnL' delim delim xs in
(x :: l, ls)
splitOnL : Eq a => (delim : List a) -> {auto dprf : NonEmpty delim}
-> List a -> List (List a)
splitOnL delim [] = []
splitOnL delim list@(_::_) = uncurry (::) $ splitOnL' delim delim list
substitute : Eq a => List a -> List a -> List a -> List a
substitute [] replacement = id
substitute (n :: ns) replacement = intercalate replacement . splitOnL (n :: ns)
strReplace : String -> String -> String -> String
strReplace needle replacement = pack . substitute (unpack needle) (unpack replacement) . unpack
|
#module Product_quantization
using Clustering
#for computing distances
using Distances
#for computing the error with k-means
include("../utils.jl")
include("../opq/kmeans.jl")
# Quantize using PQ codebooks
function quantize_pq{T <: AbstractFloat}(
X::Matrix{T}, # d-by-n. Data to encode
C::Vector{Matrix{T}}, # codebooks
V::Bool=false) # whether to print progress
d, n = size( X )
m = length( C )
h = size( C[1], 2 )
B = zeros(Int, m, n) # codes
subdims = splitarray( 1:d, m )
# auxiliary variables for update_assignments! function
costs = zeros(Float32, n)
counts = zeros(Int, h)
to_update = zeros(Bool, h)
unused = Int[]
for i = 1:m
if V print("Encoding on codebook $i / $m... ") end
# Find distances from X to codebook
dmat = pairwise( SqEuclidean(), C[i], X[subdims[i],:] )
dmat = convert(Array{T}, dmat)
update_assignments!( dmat, true, view(B,i,:), costs, counts, to_update, unused )
if V println("done"); end
end
return convert(Matrix{Int16}, B) # return the codes
end
# Train product quantization
function train_pq{T <: AbstractFloat}(
X::Matrix{T}, # d-by-n. Data to learn codebooks from
m::Integer, # number of codebooks
h::Integer, # number of entries per codebook
V::Bool=false) # whether to print progress
d, n = size( X )
C = Vector{Matrix{T}}(m); # codebooks
B = zeros(Int16, m, n); # codes
subdims = splitarray(1:d, m); # subspaces
for i = 1:m
if V print("Working on codebook $i / $m... "); end
cluster = kmeans( X[ subdims[i],: ], h, init=:kmpp);
C[i], B[i,:] = cluster.centers, cluster.assignments;
if V
subdim_cost = cluster.totalcost ./ n;
nits = cluster.iterations;
converged = cluster.converged;
println("done.");
println(" Ran for $nits iterations");
println(" Error in subspace is $subdim_cost");
println(" Converged: $converged")
end
end
error = qerror_pq( X, B, C )
return C, B, error
end
#end # module PQ
|
# This code assumes you've downloaded and unzipped the file
# exdata-data-NEI_data.zip in your working directory. If you haven't it's
# easy enough to write the code to check using file.exists etc
## This first line will likely take a few seconds. Be patient!
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
Balt <- NEI[NEI$fips == "24510",]
# Plot 3
library(ggplot2)
png(filename = "plot3.png",
width = 640,
height = 480)
ggplot(Balt, aes(factor(year), Emissions, fill=type)) +
geom_bar(stat="identity") +
theme_bw() +
guides(fill=FALSE) +
facet_grid(. ~ type, scales = "fixed", space="fixed") +
labs(x="Year", y=expression("Total PM"[2.5]*" Emission (Tons)")) +
labs(title=expression("Plot 3: PM"[2.5]*" Emissions, Baltimore City 1999-2008 by Source Type"))
dev.off() |
## This is wrapper around the FRED API
fred_api <- function(variables, frequency, agg_method, destfile) {
freq <- rep(frequency, length(variables)) # repeat frequency letter to match length of vector variables
method <- rep(agg_method, length(variables))
order <- rep("asc", length(variables)) # ascending order
units <- rep("lin", length(variables)) # levels, no transformation done to data
# Note: we don't specify the time period so it will pull all data available
params <- list(
series_id = variables,
frequency = freq,
aggregation_method = method,
sort_order = order,
units = units
)
df <- purrr::pmap_dfr(
.l = params,
.f = ~ fredr(series_id = ..1, frequency = ..2, aggregation_method = ..3,
sort_order = ..4, units = ..5)
)
saveRDS(df, file = destfile)
} |
(* Title: HOL/Isar_Examples/Expr_Compiler.thy
Author: Makarius
Correctness of a simple expression/stack-machine compiler.
*)
section \<open>Correctness of a simple expression compiler\<close>
theory Expr_Compiler
imports MainRLT
begin
text \<open>
This is a (rather trivial) example of program verification. We model a
compiler for translating expressions to stack machine instructions, and
prove its correctness wrt.\ some evaluation semantics.
\<close>
subsection \<open>Binary operations\<close>
text \<open>
Binary operations are just functions over some type of values. This is both
for abstract syntax and semantics, i.e.\ we use a ``shallow embedding''
here.
\<close>
type_synonym 'val binop = "'val \<Rightarrow> 'val \<Rightarrow> 'val"
subsection \<open>Expressions\<close>
text \<open>
The language of expressions is defined as an inductive type, consisting of
variables, constants, and binary operations on expressions.
\<close>
datatype (dead 'adr, dead 'val) expr =
Variable 'adr
| Constant 'val
| Binop "'val binop" "('adr, 'val) expr" "('adr, 'val) expr"
text \<open>
Evaluation (wrt.\ some environment of variable assignments) is defined by
primitive recursion over the structure of expressions.
\<close>
primrec eval :: "('adr, 'val) expr \<Rightarrow> ('adr \<Rightarrow> 'val) \<Rightarrow> 'val"
where
"eval (Variable x) env = env x"
| "eval (Constant c) env = c"
| "eval (Binop f e1 e2) env = f (eval e1 env) (eval e2 env)"
subsection \<open>Machine\<close>
text \<open>
Next we model a simple stack machine, with three instructions.
\<close>
datatype (dead 'adr, dead 'val) instr =
Const 'val
| Load 'adr
| Apply "'val binop"
text \<open>
Execution of a list of stack machine instructions is easily defined as
follows.
\<close>
primrec exec :: "(('adr, 'val) instr) list \<Rightarrow> 'val list \<Rightarrow> ('adr \<Rightarrow> 'val) \<Rightarrow> 'val list"
where
"exec [] stack env = stack"
| "exec (instr # instrs) stack env =
(case instr of
Const c \<Rightarrow> exec instrs (c # stack) env
| Load x \<Rightarrow> exec instrs (env x # stack) env
| Apply f \<Rightarrow> exec instrs (f (hd stack) (hd (tl stack)) # (tl (tl stack))) env)"
definition execute :: "(('adr, 'val) instr) list \<Rightarrow> ('adr \<Rightarrow> 'val) \<Rightarrow> 'val"
where "execute instrs env = hd (exec instrs [] env)"
subsection \<open>Compiler\<close>
text \<open>
We are ready to define the compilation function of expressions to lists of
stack machine instructions.
\<close>
primrec compile :: "('adr, 'val) expr \<Rightarrow> (('adr, 'val) instr) list"
where
"compile (Variable x) = [Load x]"
| "compile (Constant c) = [Const c]"
| "compile (Binop f e1 e2) = compile e2 @ compile e1 @ [Apply f]"
text \<open>
The main result of this development is the correctness theorem for
\<open>compile\<close>. We first establish a lemma about \<open>exec\<close> and list append.
\<close>
lemma exec_append:
"exec (xs @ ys) stack env =
exec ys (exec xs stack env) env"
proof (induct xs arbitrary: stack)
case Nil
show ?case by simp
next
case (Cons x xs)
show ?case
proof (induct x)
case Const
from Cons show ?case by simp
next
case Load
from Cons show ?case by simp
next
case Apply
from Cons show ?case by simp
qed
qed
theorem correctness: "execute (compile e) env = eval e env"
proof -
have "\<And>stack. exec (compile e) stack env = eval e env # stack"
proof (induct e)
case Variable
show ?case by simp
next
case Constant
show ?case by simp
next
case Binop
then show ?case by (simp add: exec_append)
qed
then show ?thesis by (simp add: execute_def)
qed
text \<open>
\<^bigskip>
In the proofs above, the \<open>simp\<close> method does quite a lot of work behind the
scenes (mostly ``functional program execution''). Subsequently, the same
reasoning is elaborated in detail --- at most one recursive function
definition is used at a time. Thus we get a better idea of what is actually
going on.
\<close>
lemma exec_append':
"exec (xs @ ys) stack env = exec ys (exec xs stack env) env"
proof (induct xs arbitrary: stack)
case (Nil s)
have "exec ([] @ ys) s env = exec ys s env"
by simp
also have "\<dots> = exec ys (exec [] s env) env"
by simp
finally show ?case .
next
case (Cons x xs s)
show ?case
proof (induct x)
case (Const val)
have "exec ((Const val # xs) @ ys) s env = exec (Const val # xs @ ys) s env"
by simp
also have "\<dots> = exec (xs @ ys) (val # s) env"
by simp
also from Cons have "\<dots> = exec ys (exec xs (val # s) env) env" .
also have "\<dots> = exec ys (exec (Const val # xs) s env) env"
by simp
finally show ?case .
next
case (Load adr)
from Cons show ?case
by simp \<comment> \<open>same as above\<close>
next
case (Apply fn)
have "exec ((Apply fn # xs) @ ys) s env =
exec (Apply fn # xs @ ys) s env" by simp
also have "\<dots> =
exec (xs @ ys) (fn (hd s) (hd (tl s)) # (tl (tl s))) env"
by simp
also from Cons have "\<dots> =
exec ys (exec xs (fn (hd s) (hd (tl s)) # tl (tl s)) env) env" .
also have "\<dots> = exec ys (exec (Apply fn # xs) s env) env"
by simp
finally show ?case .
qed
qed
theorem correctness': "execute (compile e) env = eval e env"
proof -
have exec_compile: "\<And>stack. exec (compile e) stack env = eval e env # stack"
proof (induct e)
case (Variable adr s)
have "exec (compile (Variable adr)) s env = exec [Load adr] s env"
by simp
also have "\<dots> = env adr # s"
by simp
also have "env adr = eval (Variable adr) env"
by simp
finally show ?case .
next
case (Constant val s)
show ?case by simp \<comment> \<open>same as above\<close>
next
case (Binop fn e1 e2 s)
have "exec (compile (Binop fn e1 e2)) s env =
exec (compile e2 @ compile e1 @ [Apply fn]) s env"
by simp
also have "\<dots> = exec [Apply fn]
(exec (compile e1) (exec (compile e2) s env) env) env"
by (simp only: exec_append)
also have "exec (compile e2) s env = eval e2 env # s"
by fact
also have "exec (compile e1) \<dots> env = eval e1 env # \<dots>"
by fact
also have "exec [Apply fn] \<dots> env =
fn (hd \<dots>) (hd (tl \<dots>)) # (tl (tl \<dots>))"
by simp
also have "\<dots> = fn (eval e1 env) (eval e2 env) # s"
by simp
also have "fn (eval e1 env) (eval e2 env) =
eval (Binop fn e1 e2) env"
by simp
finally show ?case .
qed
have "execute (compile e) env = hd (exec (compile e) [] env)"
by (simp add: execute_def)
also from exec_compile have "exec (compile e) [] env = [eval e env]" .
also have "hd \<dots> = eval e env"
by simp
finally show ?thesis .
qed
end
|
lemma has_integral_localized_vector_derivative: "((\<lambda>x. f (g x) * vector_derivative g (at x within {a..b})) has_integral i) {a..b} \<longleftrightarrow> ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {a..b}" |
/*==================BEGIN ASF AUTO-GENERATED DOCUMENTATION==================*/
/*
ABOUT EDITING THIS DOCUMENTATION:
If you wish to edit the documentation for this program, you need to
change the following defines. For the short ones (like
ASF_NAME_STRING) this is no big deal. However, for some of the longer
ones, such as ASF_COPYRIGHT_STRING, it can be a daunting task to get
all the newlines in correctly, etc. In order to help you with this
task, there is a tool, edit_man_header. The tool *only* works with
this portion of the code, so fear not. It will scan in defines of the
format #define ASF_<something>_STRING between the two auto-generated
documentation markers, format them for a text editor, run that editor,
allow you to edit the text in a clean manner, and then automatically
generate these defines, formatted appropriately. The only warning is
that any text between those two markers and not part of one of those
defines will not be preserved, and that all of this auto-generated
code will be at the top of the source file. Save yourself the time and
trouble, and use edit_man_header. :)
*/
#define ASF_NAME_STRING \
"asf_geocode"
#define ASF_USAGE_STRING \
" "ASF_NAME_STRING" -p <projection name> <<projection parameters>>\n"\
" [-force] [-resample-method <method>] [-height <height>]\n"\
" [-datum <datum>] [-pixel-size <pixel size>] [-band <band_id | all>]\n"\
" [-log <file>] [-write-proj-file <file>] [-read-proj-file <file>]\n"\
" [-save-mapping] [-background <value>] [-quiet] [-license]\n"\
" [-version] [-help]\n"\
" <in_base_name> <out_base_name>\n"\
"\n"\
" Use the -help option for more projection parameter controls.\n"
#define ASF_DESCRIPTION_STRING \
" This program takes a map projected or an unprojected (ground\n"\
" range) image in the ASF internal format and geocodes it,\n"\
" i.e. swizzles it around into one of the standard projections used\n"\
" for maps (universal transverse mercator, polar stereo, etc). The\n"\
" output is a new image in ASF internal format.\n"
#define ASF_INPUT_STRING \
" Most of the \"options\" are actually required. The specification\n"\
" of a certain projection type implies that all the parameters\n"\
" required to fully specify a projection of that type be included.\n"\
"\n"\
" This must be an ASF internal format image base name.\n"
#define ASF_OUTPUT_STRING \
" The base name of the geocoded image to produce.\n"
#define ASF_OPTIONS_STRING \
"%s"\
"\n"\
" -save-mapping\n"\
" Creates two additional files during geocoding. One will contain\n"\
" the line number from which the pixel was obtained from the\n"\
" original file, the other the sample numbers. Together, these\n"\
" define the mapping of pixels performed by the geocoding.\n"\
"\n"\
" -log <log file>\n"\
" Output will be written to a specified log file.\n"\
"\n"\
" -quiet\n"\
" Supresses all non-essential output.\n"\
"\n"\
" -license\n"\
" Print copyright and license for this software then exit.\n"\
"\n"\
" -version\n"\
" Print version and copyright then exit.\n"\
"\n"\
" -help\n"\
" Print a help page and exit.\n"
#define ASF_EXAMPLES_STRING \
" To map project an image with centerpoint at -147 degrees\n"\
" longitude and average height 466 meters into universal transverse\n"\
" mercator projection, with one pixel 50 meters on a side:\n"\
"\n"\
" "ASF_NAME_STRING" -p utm --central-meridian -147.0 --height 466\n"\
" input_image output_image\n"\
"\n"\
" To geocode one band within an image file, you specify the selected band\n"\
" with the -band option, and the selected band MUST be one of which appears\n"\
" in the list of available bands as noted in the 'bands' item found in the\n"\
" 'general' (first) block in the metadata file. For example, if 'bands'\n"\
" contains \"01,02,03,04\", then you could specify a band_id, e.g. \"-band 02\"\n"\
" etc on the command line. The same applies to band lists, such\n"\
" as \"HH,HV,VH,VV\" or just \"03\" etc.\n"\
"\n"\
" "ASF_NAME_STRING" -p utm -band HV file outfile_HV\n"
#define ASF_LIMITATIONS_STRING \
" May fail badly if bad projection parameters are supplied for the\n"\
" area in the image.\n"
#define ASF_SEE_ALSO_STRING \
" asf_import, asf_export\n"
/*===================END ASF AUTO-GENERATED DOCUMENTATION===================*/
#include <asf_contact.h>
#include <asf_license.h>
// Standard libraries.
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Libraries from packages outside ASF.
#include <glib.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_statistics_double.h>
// Libraries developed at ASF.
#include <asf.h>
#include <asf_nan.h>
#include <asf_meta.h>
#include <asf_raster.h>
#include "float_image.h"
#include <libasf_proj.h>
#include <spheroids.h>
#include <asf_contact.h>
// Headers used by this program.
#include "asf_geocode.h"
// Print minimalistic usage info & exit
static void print_usage(void)
{
asfPrintStatus("\n"
"Usage:\n"
ASF_USAGE_STRING
"\n");
exit(EXIT_FAILURE);
}
// Print the help info & exit
static void print_help(void)
{
asfPrintStatus(
"\n"
"Tool name:\n " ASF_NAME_STRING "\n\n"
"Usage:\n" ASF_USAGE_STRING "\n"
"Description:\n" ASF_DESCRIPTION_STRING "\n"
"Input:\n" ASF_INPUT_STRING "\n"
"Output:\n"ASF_OUTPUT_STRING "\n"
"Options:\n" ASF_OPTIONS_STRING "\n"
"Examples:\n" ASF_EXAMPLES_STRING "\n"
"Limitations:\n" ASF_LIMITATIONS_STRING "\n"
"See also:\n" ASF_SEE_ALSO_STRING "\n"
"Contact:\n" ASF_CONTACT_STRING "\n"
"Version:\n " SVN_REV " (part of " TOOL_SUITE_NAME " " MAPREADY_VERSION_STRING ")\n\n",
geocode_projection_options_help());
exit(EXIT_FAILURE);
}
// Main routine.
int
main (int argc, char **argv)
{
int force_flag = FALSE;
int debug_dump = FALSE;
char band_id[256]="";
char *in_base_name, *out_base_name;
in_base_name = (char *) MALLOC(sizeof(char)*255);
out_base_name = (char *) MALLOC(sizeof(char)*255);
// Get the projection parameters from the command line.
projection_type_t projection_type;
// Terrain height to assume. Defaults to 0 (no height correction)
double average_height = 0.0;
// Pixel size to use for output image, in projection coordinate
// units. This variable corresponds to a "private"
// (i.e. undocumented, so users don't fiddle with it) option.
// NOTE: Setting the pixel size to a negative number results in the
// code to pick a pixel size from the metadata
double pixel_size = -1;
// Datum to use in the target projection
datum_type_t datum;
spheroid_type_t spheroid;
// Method to use to resample images.
resample_method_t resample_method;
// Value to put in the region outside the image
double background_val = 0.0;
// Should we save the mapping files?
int save_map_flag;
if (detect_flag_options(argc, argv, "-help", "--help", "-h", NULL)) {
print_help();
}
// Detect & Process logging arguments
if ((logflag = detect_string_options(argc, argv, logFile,
"-log", "--log", NULL))) {
fLog = fopen (logFile, "a");
if ( fLog == NULL ) {
// Couldn't open the log file, so just don't do logging.
logflag = FALSE;
}
}
quietflag = detect_flag_options(argc, argv, "-quiet", "--quiet", NULL);
save_map_flag = extract_flag_options(&argc, &argv, "-save-mapping", "--save_mapping", NULL);
handle_license_and_version_args(argc, argv, ASF_NAME_STRING);
asfSplashScreen(argc, argv);
project_parameters_t *pp
= get_geocode_options (&argc, &argv, &projection_type, &average_height,
&pixel_size, &datum, &spheroid, &resample_method,
&force_flag, band_id);
if (!pp && projection_type != LAT_LONG_PSEUDO_PROJECTION) {
print_usage();
}
// The argument at which the filenames start
int arg_num = 1;
if (detect_flag_options(argc, argv, "-debug", NULL)) {
debug_dump=TRUE;
++arg_num;
}
if (!extract_double_options(&argc, &argv, &background_val, "--background",
"-background", NULL)) {
strcpy(in_base_name, argv[arg_num]);
meta_parameters *meta = meta_read(in_base_name);
background_val = meta->general->no_data;
asfPrintStatus("Extracted no data value (%f) out of the metadata.\n",
meta->general->no_data);
meta_free(meta);
}
if (ISNAN(background_val)) background_val = DEFAULT_NO_DATA_VALUE;
// Get non-option command line arguments.
if ( argc != 3 && !debug_dump ) {
int ii;
int bad_arg = FALSE;
for (ii = 0; ii < argc; ++ii) {
if (argv[ii][0] == '-') {
bad_arg = TRUE;
asfPrintStatus("Unrecognized argument: %s\n", argv[ii]);
}
}
if (!bad_arg)
fprintf (stderr, "Wrong number of arguments\n");
print_usage ();
}
strcpy (in_base_name, argv[arg_num]);
strcpy (out_base_name, argv[arg_num + 1]);
// Strip .img and also check to make sure input and output
// base names are not the same
char *ext = findExt(in_base_name);
if (ext && strncmp(ext, ".img", 4) == 0) *ext = '\0';
ext = findExt(out_base_name);
if (ext && strncmp(ext, ".img", 4) == 0) *ext = '\0';
char msg[512];
sprintf(msg,"Input and output basenames cannot be the same:\n"
" Input base name : %s\n"
" Output base name: %s\n",
in_base_name, out_base_name);
if (strcmp(in_base_name, out_base_name) == 0)
asfPrintError(msg);
// Call library function that does the actual work
asf_geocode(pp, projection_type, force_flag, resample_method, average_height,
datum, pixel_size, band_id, in_base_name, out_base_name,
(float)background_val, save_map_flag);
// Close Log, if needed
if (logflag)
FCLOSE (fLog);
exit (EXIT_SUCCESS);
}
|
function iterate_ienumerable(enumerator::CLRObject)
enumeratorty = T"System.Collections.IEnumerator"
hasnext = invokemember(enumeratorty, enumerator, :MoveNext)
hasnext || return nothing
next = invokemember(enumeratorty, enumerator, :Current)
return (next, (enumerator, enumeratorty))
end
function iterate_ienumerable_t(enumerator::CLRObject, elt::CLRObject)
enumeratorty = makegenerictype(T"System.Collections.Generic.IEnumerator`1", elt)
hasnext = invokemember(enumeratorty, enumerator, :MoveNext)
hasnext || return nothing
next = invokemember(enumeratorty, enumerator, :Current)
return (next, (enumerator, enumeratorty))
end
function Base.iterate(obj::CLRObject)
isnull(obj) && return nothing
objty = clrtypeof(obj)
enumerablety = T"System.Collections.IEnumerable"
if isassignable(enumerablety, objty)
enumerator = invokemember(enumerablety, obj, :GetEnumerator)
return iterate_ienumerable(enumerator)
end
elt = clreltype(obj)
if !isnull(elt)
enumerablety = makegenerictype(T"System.Collections.Generic.IEnumerable`1", elt)
if isassignable(enumerablety, objty)
enumerator = invokemember(enumerablety, obj, :GetEnumerator)
return iterate_ienumerable(enumerator)
end
end
(unbox(obj), nothing)
end
Base.iterate(::CLRObject, ::Nothing) = nothing
function Base.iterate(::CLRObject, state)
enumerator, enumeratorty = state
hasnext = invokemember(enumeratorty, enumerator, :MoveNext)
hasnext || return nothing
next = invokemember(enumeratorty, enumerator, :Current)
return (next, (enumerator, enumeratorty))
end
function clreltype(obj::CLRObject)
ty = clrtypeof(obj)
if isassignable(T"System.Collections.IEnumerable", ty) && invokemember(T"System.Type", ty, :IsGenericType)
return arrayload(invokemember(T"System.Type", ty, :GetGenericArguments), 0)
end
invokemember(T"System.Type", ty, :GetElementType)
end
function Base.eltype(obj::CLRObject)
elt = clreltype(obj)
typestr = string(isnull(elt) ? Any : elt)
return if haskey(TYPES_TO_UNBOX, typestr)
TYPES_TO_UNBOX[typestr][1]
else
CLRObject
end
end
function Base.length(obj::CLRObject)
objty = clrtypeof(obj)
if isassignable(T"System.Array", objty)
invokemember(T"System.Array", obj, :Length)
elseif isassignable(T"System.Collections.IList", objty)
invokemember(obj, :Count)
else
throw(ArgumentError("length() is not supported by $objty"))
end
end
function Base.axes(obj::CLRObject)
objty = clrtypeof(obj)
if isassignable(T"System.Array", objty)
rank = invokemember(obj, :Rank)
tuple((invokemember(obj, :GetLength, Int32(d)) for d = 0:rank-1)...)
elseif isassignable(T"System.Collections.IList", objty)
(Base.OneTo(invokemember(obj, :Count)),)
else
throw(ArgumentError("axes() is not supported by $objty"))
end
end
function Base.IteratorSize(obj::CLRObject)
objty = clrtypeof(obj)
if isassignable(T"System.Array", objty)
rank = invokemember(obj, :Rank)
Base.HasShape{rank}()
elseif isassignable(T"System.Collections.IList", objty)
Base.HasLength()
else
Base.SizeUnknown()
end
end
function arrayof(elty::CLRObject, dims)
invokemember(T"System.Array", CLRObject(0), :CreateInstance, elty, dims...)
end
function arraystore(arr::CLRObject, index, x)
invokemember(T"System.Array", arr, :SetValue, x, index...)
end
function arrayload(arr::CLRObject, index)
invokemember(T"System.Array", arr, :GetValue, index...)
end
makearraytype(ty::CLRObject, rank) = invokemember(ty, :MakeArrayType, rank)
function box(x::AbstractArray{T,N}, handle) where {T,N}
a = arrayof(boxedtype(T), size(x))
clrind = PermutedDimsArray(CartesianIndices(size(x)), ndims(x):-1:1)
for i in LinearIndices(x)
arraystore(a, Tuple(clrind[i]) .- 1, x[i])
end
return gethandle(a)
end
boxedtype(::Type{AbstractArray{T,N}}) where {T,N} = makearraytype(boxedtype(T), N)
|
(* -*- mode: coq; mode: visual-line -*- *)
Require Import Basics.
Require Import Types.
Require Import Cubical.
Require Import WildCat.
Require Import Colimits.Pushout.
Require Import NullHomotopy.
Require Import Truncations.
Require Import Extensions.
Import TrM.
(** * The suspension of a type *)
Generalizable Variables X A B f g n.
Local Open Scope path_scope.
(** TODO: remove and replace with HIT description. *)
(* ** Definition of suspension. *)
(*
Module Export Suspension.
(** We ensure that [Susp X] does not live in a lower universe than [X] *)
Private Inductive Susp (X : Type@{i}) : Type@{i} :=
| North : Susp X
| South : Susp X.
Global Arguments North {X}.
Global Arguments South {X}.
Axiom merid : forall (X : Type) (x : X), North = South :> Susp X.
Global Arguments merid {X} x.
Definition Susp_ind {X : Type} (P : Susp X -> Type)
(H_N : P North) (H_S : P South)
(H_merid : forall x:X, (merid x) # H_N = H_S)
: forall (y:Susp X), P y
:= fun y => (match y return (_ -> P y)
with North => (fun _ => H_N) | South => (fun _ => H_S) end) H_merid.
Axiom Susp_ind_beta_merid : forall {X : Type} (P : Susp X -> Type)
(H_N : P North) (H_S : P South)
(H_merid : forall x:X, (merid x) # H_N = H_S)
(x:X),
apD (Susp_ind P H_N H_S H_merid) (merid x) = H_merid x.
End Suspension. *)
(* ** Definition of suspension *)
Definition Susp (X : Type) := Pushout (@const X _ tt) (const tt).
Definition North {X} : Susp X := pushl tt.
Definition South {X} : Susp X := pushr tt.
Definition merid {X} (x : X) : North = South := pglue x.
Definition Susp_ind {X : Type} (P : Susp X -> Type)
(H_N : P North) (H_S : P South)
(H_merid : forall x:X, (merid x) # H_N = H_S)
: forall (y : Susp X), P y.
Proof.
serapply Pushout_ind.
- exact (Unit_ind H_N).
- exact (Unit_ind H_S).
- exact (H_merid).
Defined.
Definition Susp_ind_dp {X : Type} (P : Susp X -> Type)
(H_N : P North) (H_S : P South)
(H_merid : forall x:X, DPath P (merid x) H_N H_S)
: forall (y : Susp X), P y.
Proof.
serapply Susp_ind.
- exact H_N.
- exact H_S.
- intro x.
apply dp_path_transport^-1.
exact (H_merid x).
Defined.
Definition Susp_ind_beta_merid {X : Type}
(P : Susp X -> Type) (H_N : P North) (H_S : P South)
(H_merid : forall x:X, (merid x) # H_N = H_S) (x : X)
: apD (Susp_ind P H_N H_S H_merid) (merid x) = H_merid x.
Proof.
serapply Pushout_ind_beta_pglue.
Defined.
Definition Susp_ind_dp_beta_merid {X : Type}
(P : Susp X -> Type) (H_N : P North) (H_S : P South)
(H_merid : forall x:X, DPath P (merid x) H_N H_S) (x : X)
: dp_apD (Susp_ind_dp P H_N H_S H_merid) (merid x) = H_merid x.
Proof.
apply dp_apD_path_transport.
serapply Susp_ind_beta_merid.
Defined.
(** We want to allow the user to forget that we've defined suspension in this way. *)
Arguments Susp : simpl never.
Arguments North : simpl never.
Arguments South : simpl never.
Arguments merid : simpl never.
Arguments Susp_ind_beta_merid : simpl never.
(* ** Non-dependent eliminator. *)
Definition Susp_rec {X Y : Type}
(H_N H_S : Y) (H_merid : X -> H_N = H_S)
: Susp X -> Y.
Proof.
apply (Susp_ind (fun _ => Y) H_N H_S).
intros x. exact (transport_const _ _ @ H_merid x).
Defined.
Global Arguments Susp_rec {X Y}%type_scope H_N H_S H_merid%function_scope _.
Definition Susp_rec_beta_merid {X Y : Type}
{H_N H_S : Y} {H_merid : X -> H_N = H_S} (x:X)
: ap (Susp_rec H_N H_S H_merid) (merid x) = H_merid x.
Proof.
apply (cancelL (transport_const (merid x) H_N)).
transitivity (apD (Susp_rec H_N H_S H_merid) (merid x)).
- symmetry; refine (apD_const (Susp_rec H_N H_S H_merid) _).
- refine (Susp_ind_beta_merid (fun _ : Susp X => Y) _ _ _ _).
Defined.
(** ** Eta-rule. *)
(** The eta-rule for suspension states that any function out of a suspension is equal to one defined by [Susp_ind] in the obvious way. We give it first in a weak form, producing just a pointwise equality, and then turn this into an actual equality using [Funext]. *)
Definition Susp_eta_homot {X : Type} {P : Susp X -> Type} (f : forall y, P y)
: f == Susp_ind P (f North) (f South) (fun x => apD f (merid x)).
Proof.
unfold pointwise_paths. refine (Susp_ind _ 1 1 _).
intros x.
refine (transport_paths_FlFr_D
(g := Susp_ind P (f North) (f South) (fun x : X => apD f (merid x)))
_ _ @ _); simpl.
apply moveR_pM. apply (concat (concat_p1 _)), (concatR (concat_1p _)^).
apply ap, inverse. refine (Susp_ind_beta_merid _ _ _ _ _).
Defined.
Definition Susp_eta_homot_dp {X : Type} {P : Susp X -> Type} (f : forall y, P y)
: f == Susp_ind_dp P (f North) (f South) (fun x => dp_apD f (merid x)).
Proof.
unfold pointwise_paths. refine (Susp_ind_dp _ 1 1 _).
intros x.
apply dp_paths_FlFr_D.
cbn.
refine (concat_pp_p _ _ _ @ _).
apply moveR_Vp.
refine (concat_1p _ @ _ @ (concat_p1 _)^).
apply (equiv_inj dp_path_transport).
refine (dp_path_transport_apD _ _ @ _).
refine (_ @ (dp_path_transport_apD f (merid x))^).
serapply Susp_ind_dp_beta_merid.
Defined.
Definition Susp_rec_eta_homot {X Y : Type} (f : Susp X -> Y)
: f == Susp_rec (f North) (f South) (fun x => ap f (merid x)).
Proof.
refine (Susp_ind _ 1 1 _).
intro x.
refine ((transport_paths_FlFr _ _) @ _). apply moveR_Mp.
refine ((Susp_rec_beta_merid _) @ _). hott_simpl.
refine (_ @ (ap_V f _)). f_ap.
refine (inv_V _)^.
Defined.
Definition Susp_eta `{Funext}
{X : Type} {P : Susp X -> Type} (f : forall y, P y)
: f = Susp_ind P (f North) (f South) (fun x => apD f (merid x))
:= path_forall _ _ (Susp_eta_homot f).
Definition Susp_rec_eta `{Funext} {X Y : Type} (f : Susp X -> Y)
: f = Susp_rec (f North) (f South) (fun x => ap f (merid x))
:= path_forall _ _ (Susp_rec_eta_homot f).
(** ** Functoriality *)
Definition functor_susp {X Y : Type} (f : X -> Y)
: Susp X -> Susp Y.
Proof.
serapply Susp_rec.
- exact North.
- exact South.
- intros x; exact (merid (f x)).
Defined.
Definition ap_functor_susp_merid {X Y : Type} (f : X -> Y) (x : X)
: ap (functor_susp f) (merid x) = merid (f x).
Proof.
serapply Susp_rec_beta_merid.
Defined.
(** ** Universal property *)
Definition equiv_Susp_rec `{Funext} (X Y : Type)
: (Susp X -> Y) <~> { NS : Y * Y & X -> fst NS = snd NS }.
Proof.
unshelve econstructor.
{ intros f.
exists (f North , f South).
intros x. exact (ap f (merid x)). }
simple refine (isequiv_adjointify _ _ _ _).
- intros [[N S] m].
exact (Susp_rec N S m).
- intros [[N S] m].
apply ap, path_arrow. intros x; apply Susp_rec_beta_merid.
- intros f.
symmetry.
refine (Susp_eta f @ _).
unfold Susp_rec; apply ap.
apply path_forall; intros x.
apply apD_const.
Defined.
(** Using wild 0-groupoids, the universal property can be proven without funext. A simple equivalence of 0-groupoids between [Susp X -> Y] and [{ NS : Y * Y & X -> fst NS = snd NS }] would not carry all the higher-dimensional information, but if we generalize it to dependent functions, then it does suffice. *)
Section UnivProp.
Context (X : Type) (P : Susp X -> Type).
(** Here is the domain of the equivalence: sections of [P] over [Susp X]. *)
Definition Susp_ind_type := forall z:Susp X, P z.
Local Instance is01cat_Susp_ind_type : Is01Cat Susp_ind_type.
Proof. apply is01cat_forall; intros; apply is01cat_paths. Defined.
Local Instance is0gpd_Susp_ind_type : Is0Gpd Susp_ind_type.
Proof. apply is0gpd_forall; intros; apply is0gpd_paths. Defined.
(** The codomain is a sigma-groupoid of this family, consisting of input data for [Susp_ind]. *)
Definition Susp_ind_data' (NS : P North * P South)
:= forall x:X, DPath P (merid x) (fst NS) (snd NS).
Local Instance is01cat_Susp_ind_data' NS : Is01Cat (Susp_ind_data' NS).
Proof. apply is01cat_forall; intros; apply is01cat_paths. Defined.
Local Instance is0gpd_Susp_ind_data' NS : Is0Gpd (Susp_ind_data' NS).
Proof. apply is0gpd_forall; intros; apply is0gpd_paths. Defined.
(** Here is the codomain itself. *)
Definition Susp_ind_data := sig Susp_ind_data'.
Local Instance is01cat_Susp_ind_data : Is01Cat Susp_ind_data.
Proof. rapply is01cat_sigma. Defined.
Local Instance is0gpd_Susp_ind_data : Is0Gpd Susp_ind_data.
Proof. rapply is0gpd_sigma. Defined.
(** Here is the functor. *)
Definition Susp_ind_inv : Susp_ind_type -> Susp_ind_data.
Proof.
intros f.
exists (f North,f South).
intros x.
exact (dp_apD f (merid x)).
Defined.
Local Instance is0functor_susp_ind_inv : Is0Functor Susp_ind_inv.
Proof.
constructor; unfold Susp_ind_type; cbn.
intros f g p.
unshelve econstructor.
- apply path_prod; apply p.
- intros x.
rewrite transport_path_prod, !transport_forall_constant; cbn.
apply equiv_ds_transport_dpath.
exact (dp_apD_nat p (merid x)).
Defined.
(** And now we can prove that it's an equivalence. *)
Definition equiv0gpd_Susp_ind_inv : IsEquiv0Gpd Susp_ind_inv.
Proof.
constructor.
- intros [[n s] g].
exists (Susp_ind_dp P n s g); cbn.
exists idpath.
intros x; cbn.
apply Susp_ind_dp_beta_merid.
- intros f g [p q]; cbn in *.
serapply Susp_ind_dp; cbn.
1:exact (ap fst p).
1:exact (ap snd p).
intros x; specialize (q x).
apply equiv_sq_dp_D.
apply equiv_ds_transport_dpath.
rewrite transport_forall_constant in q.
rewrite <- (eta_path_prod p) in q.
rewrite transport_path_prod in q.
exact q.
Defined.
End UnivProp.
(** The full non-funext version of the universal property should be formulated with respect to a notion of "wild hom-oo-groupoid", which we don't currently have. However, we can deduce statements about full higher universal properties that we do have, for instance the statement that a type is local for [functor_susp f] -- expressed in terms of [ooExtendableAlong] -- if and only if all its identity types are local for [f]. (We will use this in [Modalities.Localization] for separated subuniverses.) To prove this, we again generalize it to the case of dependent types, starting with naturality of the above 0-dimensional universal property. *)
Section UnivPropNat.
(** We will show that [Susp_ind_inv] for [X] and [Y] commute with precomposition with [f] and [functor_susp f]. *)
Context {X Y : Type} (f : X -> Y) (P : Susp Y -> Type).
(** We recall all those instances from the previous section. *)
Local Existing Instances is01cat_Susp_ind_type is0gpd_Susp_ind_type is01cat_Susp_ind_data' is0gpd_Susp_ind_data' is01cat_Susp_ind_data is0gpd_Susp_ind_data.
(** Here is an intermediate family of groupoids that we have to use, since precomposition with [f] doesn't land in quite the right place. *)
Definition Susp_ind_data'' (NS : P North * P South)
:= forall x:X, DPath P (merid (f x)) (fst NS) (snd NS).
Local Instance is01cat_Susp_ind_data'' NS : Is01Cat (Susp_ind_data'' NS).
Proof. apply is01cat_forall; intros; apply is01cat_paths. Defined.
Local Instance is0gpd_Susp_ind_data'' NS : Is0Gpd (Susp_ind_data'' NS).
Proof. apply is0gpd_forall; intros; apply is0gpd_paths. Defined.
(** We decompose "precomposition with [f]" into a functor_sigma of two fiberwise functors. Here is the first. *)
Definition functor_Susp_ind_data'' (NS : P North * P South)
: Susp_ind_data' Y P NS -> Susp_ind_data'' NS
:= fun g x => g (f x).
Local Instance is0functor_functor_Susp_ind_data'' NS
: Is0Functor (functor_Susp_ind_data'' NS).
Proof.
constructor.
intros g h p a.
exact (p (f a)).
Defined.
(** And here is the second. This one is actually a fiberwise equivalence of types at each [x]. *)
Definition equiv_Susp_ind_data' (NS : P North * P South) (x : X)
: DPath P (merid (f x)) (fst NS) (snd NS)
<~> DPath (P o functor_susp f) (merid x) (fst NS) (snd NS).
Proof.
etransitivity.
- apply (equiv_transport (fun p => DPath P p (fst NS) (snd NS))).
symmetry; apply ap_functor_susp_merid.
- symmetry.
apply (dp_compose (functor_susp f) P (merid x)).
Defined.
Definition functor_Susp_ind_data' (NS : P North * P South)
: Susp_ind_data'' NS -> Susp_ind_data' X (P o functor_susp f) NS.
Proof.
serapply (functor_forall idmap); intros x.
apply equiv_Susp_ind_data'.
Defined.
Local Instance is0functor_functor_Susp_ind_data' NS
: Is0Functor (functor_Susp_ind_data' NS).
Proof.
constructor.
intros g h q x.
cbn; apply ap, ap.
exact (q x).
Defined.
(** And therefore a fiberwise equivalence of 0-groupoids. *)
Local Instance isequiv0gpd_functor_Susp_ind_data' NS
: IsEquiv0Gpd (functor_Susp_ind_data' NS).
Proof.
constructor.
- intros g.
unshelve econstructor.
+ intros x.
apply ((equiv_Susp_ind_data' NS x)^-1).
exact (g x).
+ intros x.
apply eisretr.
- intros g h p x.
apply (equiv_inj (equiv_Susp_ind_data' NS x)).
exact (p x).
Defined.
(** Now we put them together. *)
Definition functor_Susp_ind_data
: Susp_ind_data Y P -> Susp_ind_data X (P o functor_susp f)
:= fun NSg => (NSg.1 ; (functor_Susp_ind_data' NSg.1 o
(functor_Susp_ind_data'' NSg.1)) NSg.2).
Local Instance is0functor_functor_Susp_ind_data
: Is0Functor functor_Susp_ind_data.
Proof.
refine (is0functor_sigma _ _
(fun NS => functor_Susp_ind_data' NS o functor_Susp_ind_data'' NS)).
Defined.
(** Here is the "precomposition with [functor_susp f]" functor. *)
Definition functor_Susp_ind_type
: Susp_ind_type Y P -> Susp_ind_type X (P o functor_susp f)
:= fun g => g o functor_susp f.
Local Instance is0functor_functor_Susp_ind_type
: Is0Functor functor_Susp_ind_type.
Proof.
constructor.
intros g h p a.
exact (p (functor_susp f a)).
Defined.
(** And here is the desired naturality square. *)
Definition Susp_ind_inv_nat
: (Susp_ind_inv X (P o functor_susp f)) o functor_Susp_ind_type
$=> functor_Susp_ind_data o (Susp_ind_inv Y P).
Proof.
intros g; exists idpath; intros x.
change (dp_apD (fun x0 : Susp X => g (functor_susp f x0)) (merid x) =
(functor_Susp_ind_data (Susp_ind_inv Y P g)).2 x).
refine (dp_apD_compose (functor_susp f) P (merid x) g @ _).
cbn; apply ap.
apply (moveL_transport_V (fun p => DPath P p (g North) (g South))).
exact (apD (dp_apD g) (ap_functor_susp_merid f x)).
Defined.
(** From this we can deduce a equivalence between extendability, which is definitionally equal to split essential surjectivity of a functor between forall 0-groupoids. *)
Definition extension_iff_functor_susp
: (forall g, ExtensionAlong (functor_susp f) P g)
<-> (forall NS g, ExtensionAlong f (fun x => DPath P (merid x) (fst NS) (snd NS)) g).
Proof.
(** The proof is by chaining logical equivalences. *)
transitivity (SplEssSurj functor_Susp_ind_type).
{ reflexivity. }
etransitivity.
{ refine (isesssurj_iff_commsq Susp_ind_inv_nat); try exact _.
all:apply equiv0gpd_Susp_ind_inv. }
etransitivity.
{ refine (isesssurj_iff_sigma _ _
(fun NS => functor_Susp_ind_data' NS o functor_Susp_ind_data'' NS)). }
apply iff_functor_forall; intros [N S]; cbn.
etransitivity.
{ apply iffL_isesssurj; exact _. }
reflexivity.
Defined.
(** We have to close the section now because we have to generalize [extension_iff_functor_susp] over [P]. *)
End UnivPropNat.
(** Now we can iterate, deducing [n]-extendability. *)
Definition extendable_iff_functor_susp
{X Y : Type} (f : X -> Y) (P : Susp Y -> Type) (n : nat)
: (ExtendableAlong n (functor_susp f) P)
<-> (forall NS, ExtendableAlong n f (fun x => DPath P (merid x) (fst NS) (snd NS))).
Proof.
revert P. induction n as [|n IHn]; intros P; [ split; intros; exact tt | ].
(** It would be nice to be able to do this proof by chaining logcal equivalences too, especially since the two parts seem very similar. But I haven't managed to make that work. *)
split.
- intros [e1 en] [N S]; split.
+ apply extension_iff_functor_susp.
exact e1.
+ cbn; intros h k.
pose (h' := Susp_ind_dp P N S h).
pose (k' := Susp_ind_dp P N S k).
specialize (en h' k').
assert (IH := fst (IHn _) en (1,1)); clear IHn en.
cbn in IH.
refine (extendable_postcompose' n _ _ f _ IH); clear IH.
intros y.
etransitivity.
1:symmetry; apply equiv_sq_dp_D.
etransitivity.
1:apply equiv_ds_transport_dpath.
subst h' k'; cbn.
apply equiv_concat_lr.
* symmetry. exact (Susp_ind_dp_beta_merid P N S h y).
* exact (Susp_ind_dp_beta_merid P N S k y).
- intros e; split.
+ apply extension_iff_functor_susp.
intros NS; exact (fst (e NS)).
+ intros h k.
apply (IHn _).
intros [p q].
specialize (e (h North, k South)).
cbn in *; apply snd in e.
refine (extendable_postcompose' n _ _ f _ (e _ _)); intros y.
etransitivity.
2:apply equiv_sq_dp_D.
etransitivity.
2:symmetry;apply equiv_ds_transport_dpath.
etransitivity.
2:apply (equiv_moveR_transport_p (fun y0 : P North => DPath P (merid y) y0 (k South))).
reflexivity.
Defined.
(** As usual, deducing oo-extendability is trivial. *)
Definition ooextendable_iff_functor_susp
{X Y : Type} (f : X -> Y) (P : Susp Y -> Type)
: (ooExtendableAlong (functor_susp f) P)
<-> (forall NS, ooExtendableAlong f (fun x => DPath P (merid x) (fst NS) (snd NS))).
Proof.
split; intros e.
- intros NS n.
apply extendable_iff_functor_susp.
exact (e n).
- intros n.
apply extendable_iff_functor_susp.
intros NS; exact (e NS n).
Defined.
(** ** Nullhomotopies of maps out of suspensions *)
Definition nullhomot_susp_from_paths {X Z: Type} (f : Susp X -> Z)
(n : NullHomotopy (fun x => ap f (merid x)))
: NullHomotopy f.
Proof.
exists (f North).
refine (Susp_ind _ 1 n.1^ _); intros x.
refine (transport_paths_Fl _ _ @ _).
apply (concat (concat_p1 _)), ap. apply n.2.
Defined.
Definition nullhomot_paths_from_susp {X Z: Type} (H_N H_S : Z) (f : X -> H_N = H_S)
(n : NullHomotopy (Susp_rec H_N H_S f))
: NullHomotopy f.
Proof.
exists (n.2 North @ (n.2 South)^).
intro x. apply moveL_pV.
transitivity (ap (Susp_rec H_N H_S f) (merid x) @ n.2 South).
- apply whiskerR, inverse, Susp_rec_beta_merid.
- refine (concat_Ap n.2 (merid x) @ _).
apply (concatR (concat_p1 _)), whiskerL. apply ap_const.
Defined.
(** ** Contractibility of the suspension *)
Global Instance contr_susp (A : Type) `{Contr A}
: Contr (Susp A).
Proof.
unfold Susp; exact _.
Defined.
(** ** Connectedness of the suspension *)
Global Instance isconnected_susp {n : trunc_index} {X : Type}
`{H : IsConnected n X} : IsConnected n.+1 (Susp X).
Proof.
apply isconnected_from_elim.
intros C H' f. exists (f North).
assert ({ p0 : f North = f South & forall x:X, ap f (merid x) = p0 })
as [p0 allpath_p0] by (apply (isconnected_elim n); apply H').
apply (Susp_ind (fun a => f a = f North) 1 p0^).
intros x.
apply (concat (transport_paths_Fl _ _)).
apply (concat (concat_p1 _)).
apply ap, allpath_p0.
Defined.
|
lemma connected_component_set_empty [simp]: "connected_component_set {} x = {}" |
"""
fftPositiveFreq(ft,f)
Returns (coefficients, frequencies) for positive frequencies of the fourier transform
"""
function fftPositiveFreq(fft,f)
@assert length(fft) == length(f) "Fourier transform and frequency vectors much have matching length"
fftRange = f .>= 0
return (fft[fftRange],f[fftRange])
end
export fftPositiveFreq
"""
meanFFT(fft::Vector{S},cuts::Tuple{T,T}) where {S<:Real, T<:Integer}
Takes mean before taking fourier transform
"""
function meanFFT(timeSeries::Vector{S},cuts::Tuple{T,T}) where {S<:Real, T<:Integer}
tsPrep = timeSeries[cuts[1]:cuts[2]]
tsPrepMean = mean(tsPrep)
tsPrep = tsPrep .- tsPrepMean
return fft(tsPrep)
end
export meanFFT
"""
fftFreq(tres::Real,τ::Vector,cuts::Tuple{T,T}) where {T<:Integer}
Returns frequencies associated with Fourier transform
"""
function fftFreq(tres::Real,τ::Vector,cuts::Tuple{T,T}) where {T<:Integer}
τlen = cuts[2]-cuts[1]+1
freqFFT = fftfreq(τlen,1/tres)
end
export fftFreq
|
(* ------------------------------------------------------- *)
(** #<hr> <center> <h1>#
The double time redundancy (DTR) transformation
#</h1>#
- states transitions without any glitches for memoty block
Dmitry Burlyaev - Pascal Fradet - 2015
#</center> <hr># *)
(* ------------------------------------------------------- *)
Add LoadPath "..\..\Common\".
Add LoadPath "..\..\TMRProof\".
Add LoadPath "..\Transf\".
Require Import dtrTransform relationPred leftStep rightStep leftStepg.
Set Implicit Arguments.
(* ##################################################################### *)
(** Properties of Memory Block w/o Glitches for both cycles *)
(* ##################################################################### *)
(** Basic properties of evaluation of DTR circuits without faults *)
(*Odd cycles when all control signals (save, fail, rollBack) are zeros*)
Lemma step0_mb: forall S T (c c' c'':circuit S T) c2 c2' t2 s t,
pure_bset s -> dtrs0 c c' c2
-> step c' s t c''
-> step c2 {s,{~0,~0,~0}} t2 c2'
-> t2 = {t,{~0,~0,~0}} /\ dtrs1 c c' c'' c2'.
Proof.
introv P R H HT. induction H; unfold dtrs1.
- Inverts R. Invstep HT. Simpl.
- Inverts R. Invstep HT. Simpl.
- destruct c; Inverts R; Inverts HT; Simpl.
Apply IHstep1 in H6; Simpl.
Apply IHstep2 in H12; Simpl.
- Dd_buset t2. Inverts R.
unfold SWAP_LS in HT. unfold SWAP_LR in HT.
Invstep HT. SimpS.
Apply IHstep1 in H0; Simpl.
Apply IHstep2 in H11; Simpl.
repeat constructor; easy.
- Dd_buset t2. Inverts R. Inverts H8.
unfold memBlock in HT. unfold lhsMB in HT. unfold rhsMB in HT.
Invstep HT. SimpS.
Apply step_rhs in H16. SimpS.
apply step_lhs with (d:=r) (r:=r) (sav:=false) (rol:=false) (fai:=false) in H19; Simpl.
unfold bool2bset in H2. repeat rewrite eqb_reflx in H2. cbn in H2.
Apply IHstep in H2; Simpl. cbn in H1.
rewrite s2bob2s in H1.
repeat constructor; Simpl. cbn. constructor.
Qed.
(*Even cycles when the control signals (save, fail, rollBack) = {1,0, unknown not glitched}*)
Lemma step1_mb : forall S T (c c' c'':circuit S T) c2 c2' t2 s t f,
pure_bset s -> pure_bset f -> dtrs1 c c' c'' c2
-> step c' s t c''
-> step c2 {s,{~1,~0,f}} t2 c2'
-> (exists b, t2 = {t,{~1,~0,bool2bset b}}) /\ dtrs0 c' c'' c2'.
Proof.
intros S T c.
induction c; introv P1 P2 R H HT; unfold dtrs1; Inverts R.
- Invstep HT. Invstep H1. split; Simpl; try constructor.
exists (fbset2bool f). rewrite rew_bool2bsetf; easy.
- Invstep HT. Invstep H1. split; Simpl; try constructor.
exists (fbset2bool f). rewrite rew_bool2bsetf; easy.
- Inverts H. Invstep HT. Simpl.
apply IHc1 with (c':=c1') (c'':= c1'') (t:=t0) in H; Simpl.
apply IHc2 with (c':=c2'0) (c'':=c2'') (t:=t) in H0; Simpl.
split; Simpl. constructor; easy.
- unfold SWAP_LR in HT. unfold SWAP_LS in HT.
Invstep HT. SimpS. Inverts H13.
Apply IHc1 with H H0 H1 H2 in H3. SimpS.
Apply IHc2 with H1 H10 H11 in H9.
split; Simpl. constructor; easy.
- Inverts H8. unfold memBlock in HT. unfold lhsMB in HT.
unfold rhsMB in HT. Invstep HT.
Inverts H20. SimpS.
Apply step_rhs in H15.
apply step_lhs with (fai:= fbset2bool f) (sav:=true)
(rol:= false) (d:= x87) (r:= r) in H18; try rewrite rew_bool2bsetf; try easy.
SimpS. cbn in H1.
rewrite eqb_reflx in H2. unfold bool2bset in H2. cbn in H2.
Apply IHc with H4 H7 in H2.
destruct H2; Simpl. split.
+ exists x. easy.
+ cbn. repeat constructor; easy.
Qed.
|
Require Import Arith.Wf_nat.
Require Import AngelicComposition.
Theorem by_inclusion :
forall (T : Type) (R1 R2 : T -> T -> Prop),
well_founded R2
-> (forall x y, R1 x y -> R2 x y)
-> well_founded R1.
Proof.
intros.
unfold well_founded; intros.
pattern a.
apply (well_founded_ind H).
intros.
constructor; intros.
apply H1.
auto.
Qed.
Theorem by_extensionality : forall T (R S : T -> T -> Prop), (forall s s', R s s' <-> S s s') -> well_founded R <-> well_founded S.
Proof.
intros.
split; intros H1; apply (by_inclusion _ _ _ H1); firstorder.
Qed.
Theorem by_variant :
forall (T1 T2 : Type) (R : T1 -> T1 -> Prop) (f : T1 -> T2) W,
well_founded W
-> (forall x y, R x y -> W (f x) (f y))
-> well_founded R.
Proof.
intros T1 T2 R f W HHwfd HHsim.
intros t1'.
constructor; intros t1 HHr.
generalize t1 (HHsim _ _ HHr).
pattern (f t1'); apply (well_founded_ind HHwfd).
intros t2' HHind u1 HHw.
constructor; intros v1 HHrv.
apply (HHind (f u1)); auto.
Qed.
Theorem by_simulation :
forall (T1 T2 : Type) (R : T1 -> T1 -> Prop) (S : T1 -> T2 -> Prop) (W : T2 -> T2 -> Prop),
(forall x, (exists y, R y x) -> exists y, S x y)
-> well_founded W
-> (forall x z, (R ⊡ S) x z -> (S ⊡ W) x z)
-> well_founded R.
Proof.
intros T1 T2 R S W HHsurj HHwfd HHsim.
intros t1'.
constructor; intros t1 HHr.
destruct (HHsurj t1') as (s1,HHs1); eauto.
generalize t1 t1' HHr HHs1; clear t1 t1' HHs1 HHr.
pattern s1; apply (well_founded_ind HHwfd).
intros.
constructor; intros.
destruct (HHsurj t1) as (s1',HHs1'); eauto.
destruct (HHsim _ _ (ex_intro _ _ (conj HHr HHs1))) as (s1'',HHws).
destruct HHws.
eapply H; eauto.
Qed.
Theorem by_functional_simulation :
forall (T1 T2 : Type) (R : T1 -> T1 -> Prop) (S : T1 -> T2) (W : T2 -> T2 -> Prop),
well_founded W
-> (forall x y, R x y -> W (S x) (S y))
-> well_founded R.
Proof.
intros.
apply (by_simulation _ _ _ (fun x y => y = S x) W).
{ intros x _; eauto. }
{ exact H. }
{ intros; unfold "⊡" in *.
clear - H0 H1.
destruct H1 as (sx,(H11,H12)); subst.
eauto.
}
Qed.
Theorem by_direct_functional_simulation :
forall (T1 T2 : Type) (S : T1 -> T2) (W : T2 -> T2 -> Prop),
well_founded W
-> well_founded (fun x y => W (S x) (S y)).
Proof.
intros.
apply (by_functional_simulation _ _ _ S W H).
clear; auto.
Qed.
Theorem by_nat_variant :
forall (T1 : Type) (R : T1 -> T1 -> Prop) (f : T1 -> nat),
(forall x y, R x y -> f x < f y) -> well_founded R.
Proof. intros *. apply (by_variant _ _ _ _ _ lt_wf). Qed.
|
module Isomorphism where
import Sets
open Sets
infix 20 _≅_
data _≅_ (A B : Set) : Set where
iso : (i : A -> B)(j : B -> A) ->
(forall x -> j (i x) == x) ->
(forall y -> i (j y) == y) ->
A ≅ B
refl-≅ : (A : Set) -> A ≅ A
refl-≅ A = iso id id (\x -> refl) (\x -> refl)
iso[×] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [×] B₁ ≅ A₂ [×] B₂
iso[×] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =
iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where
ab₁₂ = a₁₂ <×> b₁₂
ab₂₁ = a₂₁ <×> b₂₁
pq₂₂ : (z : _ [×] _) -> ab₁₂ (ab₂₁ z) == z
pq₂₂ < x , y > =
subst (\ ∙ -> < ∙ , b₁₂ (b₂₁ y) > == < x , y >) (p₂₂ x)
$ cong < x ,∙> (q₂₂ y)
pq₁₁ : (z : _ [×] _) -> ab₂₁ (ab₁₂ z) == z
pq₁₁ < x , y > =
subst (\ ∙ -> < ∙ , b₂₁ (b₁₂ y) > == < x , y >) (p₁₁ x)
$ cong < x ,∙> (q₁₁ y)
iso[+] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [+] B₁ ≅ A₂ [+] B₂
iso[+] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =
iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where
ab₁₂ = a₁₂ <+> b₁₂
ab₂₁ = a₂₁ <+> b₂₁
pq₂₂ : (z : _ [+] _) -> ab₁₂ (ab₂₁ z) == z
pq₂₂ (inl x) = cong inl (p₂₂ x)
pq₂₂ (inr y) = cong inr (q₂₂ y)
pq₁₁ : (z : _ [+] _) -> ab₂₁ (ab₁₂ z) == z
pq₁₁ (inl x) = cong inl (p₁₁ x)
pq₁₁ (inr y) = cong inr (q₁₁ y)
|
Require Import QuickChick.
Class liftable (A B : Type) :=
{
lift_m : A -> B
}.
Global
Instance lift0 {A} : liftable (G A) (G A) :=
{
lift_m := id
}.
Global
Instance liftN {A B R} `(liftable (G B) R) : liftable (G (A -> B)) (G A -> R):=
{
lift_m f ga :=
lift_m (liftGen2 id f ga)
}.
Definition liftM {A B R} `{liftable (G B) R} (f : A -> B) (g : G A) : R :=
lift_m (fmap f g).
Definition ex1 : G nat := liftM (fun x => x + 3) (returnGen 0).
Definition ex2 : G nat := liftM (fun x y => x + y) (returnGen 0) (returnGen 1).
Definition ex3 : G nat := liftM (fun x y z => x + y + z)
(returnGen 0) (returnGen 1) (returnGen 2).
(*
Eval cbv -[plus] in ex1.
(* = fmap (fun x : nat => x + 3) (returnGen 0) -- fair enough *)
Eval cbv -[plus] in ex2.
(* = liftGen2 id (fmap (fun x y : nat => x + y) (returnGen 0)) (returnGen 1)
where
fmap : (nat -> (nat -> nat)) -> G nat -> G (nat -> nat)
liftGen2 : ((nat -> nat) -> nat -> nat) ->
(G (nat -> nat)) -> G nat -> G nat
*)
Eval cbv -[plus] in ex3.
(* = liftGen2 (fun x : nat -> nat => x)
(liftGen2 (fun x : nat -> nat -> nat => x)
(fmap (fun x y z : nat => x + y + z) (returnGen 0))
(returnGen 1)) (returnGen 2)
*)
(* this is not well typed ... wtf? *)
Check (liftM (fun x y => x + y + y) (returnGen 0) (returnGen 1) (returnGen 2)
: G nat).
(* it's even worse ... all kinds of stuff are accepted in Check and Eval *)
Eval simpl in (liftM (fun x => x + 1) (returnGen 0) 0 0 : G nat).
*)
(*
liftM nat nat (nat -> nat -> G nat) `{liftable (G nat) (nat -> nat -> G nat)} ...
-- but we don't have such an instance!
We need to use definitions to get a type error
Definition xxx := (liftM (fun x => x + 1) (returnGen 0) 0 0 : G nat).
Toplevel input, characters 19-24:
Error: Cannot infer the implicit parameter H of
liftM.
Could not find an instance for "liftable (G nat) (nat -> nat -> G nat)".
*)
|
[STATEMENT]
lemma mtx_init_adhoc_frame_match_rule[sepref_frame_match_rules]:
"hn_val (nat_rel\<times>\<^sub>rnat_rel \<rightarrow> A) x y \<Longrightarrow>\<^sub>t hn_val (nat_rel\<times>\<^sub>rnat_rel \<rightarrow> the_pure (pure A)) x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. hn_val (nat_rel \<times>\<^sub>r nat_rel \<rightarrow> A) x y \<Longrightarrow>\<^sub>t hn_val (nat_rel \<times>\<^sub>r nat_rel \<rightarrow> the_pure (pure A)) x y
[PROOF STEP]
by simp |
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_DEREF_IMPL_07202005_0851)
#define FUSION_DEREF_IMPL_07202005_0851
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/support/config.hpp>
namespace boost {
namespace fusion {
struct reverse_view_iterator_tag;
namespace extension {
template <typename Tag> struct deref_impl;
template <> struct deref_impl<reverse_view_iterator_tag> {
template <typename Iterator> struct apply {
typedef typename result_of::deref<
typename result_of::prior<typename Iterator::first_type>::type>::type
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type
call(Iterator const &i) {
return *fusion::prior(i.first);
}
};
};
} // namespace extension
} // namespace fusion
} // namespace boost
#endif
|
import analysis.inner_product_space.pi_L2
import topology.paracompact
--OUTPUT 1
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
have h1 : ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C) (hC1 : is_locally_finite_cover C),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space ℝ (fin n)), z ∈ B → z = y, from by {
-- First, we define a collection of pen balls.
-- Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.
have h1 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))) (hBm : is_open Bm) (hBm1 : is_ball Bm),
(0 : euclidean_space ℝ (fin n)) ∈ Bm ∧ ∀ (x : euclidean_space ℝ (fin n)), x ∈ Bm → ∃ (r : ℝ) (hr : r > 0), ∀ (y : euclidean_space ℝ (fin n)), y ∈ Bm → ∀ (i : fin n), abs (y.val i - x.val i) < r, from by {
assume (m : ℕ),
use (ball (0 : euclidean_space ℝ (fin n)) m),
obviously,
obviously,
obviously,
obviously,
},
-- Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$).
have h2 : ∀ (m : ℕ), ∃ (Cm : set (euclidean_space ℝ (fin n))) (hCm : is_open_cover Cm) (hCm1 : is_locally_finite_cover Cm),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space ℝ (fin n)), z ∈ B → z = y, from by {
assume (m : ℕ),
have h2 : ∃ (Cm : set (euclidean_space ℝ (fin n))) (hCm : is_open_cover Cm),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space ℝ (fin n)), z ∈ B → z = y, from by {
have h2 : ∃ (Cm : set (euclidean_space ℝ (fin n))) (hCm : is_open_cover Cm),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space ℝ (fin n)), z ∈ B → z = y, from by {
have h2 : ∃ (Cm : set (euclidean_space ℝ (fin n))) (hCm : is_open_cover Cm),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space ℝ (fin n)), z ∈ B → z = y, from by {
have h2 : ∃ (Cm : set (euclidean_space ℝ (fin n))) (hCm : is_open_cover Cm),
∀ (x : euclidean_space ℝ (fin n)), ∃ (U : set (euclidean_space ℝ (fin n))) (hU : is_open U),
x ∈ U ∧ ∃ (V : set (euclidean_space ℝ (fin n))) (hV : is_open V), x ∈ V ∧ V ⊆ U ∧ ∀ (y : euclidean_space ℝ (fin n)), y ∈ V → ∃ (B : set (euclidean_space ℝ (fin n))) (hB : is_open B) (hB1 : is_ball B), y ∈ B ∧ B ⊆ U ∧ ∀ (z : euclidean_space
end --Needs more than 2000 tokens!
--OUTPUT 2
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume (A : set (euclidean_space ℝ (fin n))),
assume hA : is_open_cover A,
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
have h1 : ∃ C : set (euclidean_space ℝ (fin n)), is_open_cover C ∧ locally_finite C ∧ (⋃₀ C = ⋃₀ A), from by {
-- First, we define a collection of pen balls.
-- Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.
let B0 : set (euclidean_space ℝ (fin n)) := ∅,
have h2 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from by {
assume m : ℕ,
have h3 : ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from by {
use {x : euclidean_space ℝ (fin n) | ∀ i : fin n, abs (x i) < m},
obviously,
},
show ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from h3,
},
let Bm : ℕ → set (euclidean_space ℝ (fin n)) := λ m, classical.some (h2 m).exists,
have h4 : ∀ m : ℕ, ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from by {
assume m : ℕ,
show ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from by {
assume x : euclidean_space ℝ (fin n),
show x ∈ Bm ↔ ∀ i : fin n, abs (x i) < m, from by {
apply exists_unique.unique (h2 m),
show x ∈ classical.some (h2 m).exists ↔ ∀ i : fin n, abs (x i) < m, from
classical.some_spec (exists_unique.exists (h2 m)),
},
},
},
-- Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$).
have h5 : ∀ m : ℕ, is_compact (closure (Bm m)), from by {
assume m : ℕ,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m)), from by {
apply compact_iff_compact_univ.mp,
show is_compact (closure (Bm m) ∩ univ), from by {
apply compact_iff_compact_univ.mpr,
show is_compact (closure (Bm m
end --Needs more than 2000 tokens!
--OUTPUT 3
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
have h1 : ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C) (hC1 : is_locally_finite C),
∀ (x : euclidean_space ℝ (fin n)), x ∈ C, from by {
-- First, we define a collection of pen balls.
-- Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.
have hB : ∀ (m : ℕ), (m : ℝ) ∈ {x : ℝ | x > 0} := by {
assume (m : ℕ),
have hB1 : (m : ℝ) > 0, from by {
rw ← nat.cast_zero,
apply nat.cast_lt.mpr,
rw ← nat.zero_lt_succ,
apply nat.succ_pos,
},
show (m : ℝ) ∈ {x : ℝ | x > 0}, from by {
apply set.mem_set_of_eq,
exact hB1,
},
},
have hB1 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB2 : (m : ℝ) ∈ {x : ℝ | x > 0}, from hB m,
have hB3 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply euclidean_space.is_open_ball_iff.mp,
rw set.mem_set_of_eq,
exact hB2,
},
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB3,
},
},
have hB2 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB3 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB1 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB3,
},
},
have hB3 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB4 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB2 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB4,
},
},
have hB4 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB5 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB3 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB5,
},
},
have hB5 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB6 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB4 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB6,
},
},
have hB6 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB7 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB5 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB7,
},
},
have hB7 : ∀ (m : ℕ), ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
assume (m : ℕ),
have hB8 : ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from hB6 m,
show ∃ (Bm : set (euclidean_space ℝ (fin n))), is_open Bm ∧ is_bounded Bm ∧ ball 0 (m : ℝ) ⊆ Bm, from by {
apply hB8,
},
},
have h
end --Needs more than 2000 tokens!
--OUTPUT 4
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume A : set (euclidean_space ℝ (fin n)),
assume hA : is_open_cover A,
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
let C : set (euclidean_space ℝ (fin n)) := {
-- First, we define a collection of pen balls.
-- Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.
-- Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$).
-- So $\mathcal{C} = \bigcup_{m = 0}^{\infty} \mathcal{C}_m$ is an open refinement of $\mathcal{A}$.
-- Note that $\mathcal{C}$ covers $\mathbb{R}^n$ since for any $x \in \mathbb{R}^n$, there is a smallest $m \in \mathbb{N}$ such that $x \in \Bar{B_{m}}$ (namely, some $m$ where $\rVert x \lVert \leq m \leq \rVert x \lVert + 1$), and so $x$ is an element of $\mathcal{C}_m$.
-- Now collection $\mathcal{C}$ is locally finite since for given $x \in \mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\mathcal{C}$, namely those elements in collection $\mathcal{C}_1 \cup \mathcal{C}_2 \cup \cdots \mathcal{C}_m$.
-- So $\mathcal{C}$ is a locally finite open refinement of $\mathcal{A}$ that covers $\mathbb{R}^n$, hence $\mathbb{R}^n$ is paracompact.
m : ℕ | ∃ (U : set (euclidean_space ℝ (fin n))), U ∈ A ∧
(set.inter U (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) m)))).nonempty
},
let C_m : set (euclidean_space ℝ (fin n)) := {
-- Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$).
-- So $\mathcal{C} = \bigcup_{m = 0}^{\infty} \mathcal{C}_m$ is an open refinement of $\mathcal{A}$.
-- Note that $\mathcal{C}$ covers $\mathbb{R}^n$ since for any $x \in \mathbb{R}^n$, there is a smallest $m \in \mathbb{N}$ such that $x \in \Bar{B_{m}}$ (namely, some $m$ where $\rVert x \lVert \leq m \leq \rVert x \lVert + 1$), and so $x$ is an element of $\mathcal{C}_m$.
-- Now collection $\mathcal{C}$ is locally finite since for given $x \in \mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\mathcal{C}$, namely those elements in collection $\mathcal{C}_1 \cup \mathcal{C}_2 \cup \cdots \mathcal{C}_m$.
-- So $\mathcal{C}$ is a locally finite open refinement of $\mathcal{A}$ that covers $\mathbb{R}^n$, hence $\mathbb{R}^n$ is paracompact.
U : set (euclidean_space ℝ (fin n)) | ∃ (U' : set (euclidean_space ℝ (fin n))), U' ∈ A ∧
(set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) m)))).nonempty ∧
(set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) (m-1))))).nonempty ∧
U = set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) (m-1)))),
},
let C_m_finite : set (euclidean_space ℝ (fin n)) := {
-- Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$).
-- So $\mathcal{C} = \bigcup_{m = 0}^{\infty} \mathcal{C}_m$ is an open refinement of $\mathcal{A}$.
-- Note that $\mathcal{C}$ covers $\mathbb{R}^n$ since for any $x \in \mathbb{R}^n$, there is a smallest $m \in \mathbb{N}$ such that $x \in \Bar{B_{m}}$ (namely, some $m$ where $\rVert x \lVert \leq m \leq \rVert x \lVert + 1$), and so $x$ is an element of $\mathcal{C}_m$.
-- Now collection $\mathcal{C}$ is locally finite since for given $x \in \mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\mathcal{C}$, namely those elements in collection $\mathcal{C}_1 \cup \mathcal.C_2 \cup \cdots \mathcal{C}_m$.
-- So $\mathcal{C}$ is a locally finite open refinement of $\mathcal{A}$ that covers $\mathbb{R}^n$, hence $\mathbb{R}^n$ is paracompact.
U : set (euclidean_space ℝ (fin n)) | ∃ (U' : set (euclidean_space ℝ (fin n))), U' ∈ A ∧
(set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) m)))).nonempty ∧
(set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) (m-1))))).nonempty ∧
U = set.inter U' (set.compl (set.closure (ball (0 : euclidean_space ℝ (fin n)) (m-1)))),
},
have h1 : C = (⋃ (m : ℕ), C_m), from by {
apply set.ext,
assume x : euclidean_space ℝ (fin
end --Needs more than 2000 tokens!
--OUTPUT 5
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
let C := {c : set (euclidean_space ℝ (fin n)) | ∃ a ∈ A, c = a ∩ (euclidean_space ℝ (fin n))},
have hC : is_open_refinement C A, from by {
-- First, we define a collection of pen balls.
let B : ℕ → set (euclidean_space ℝ (fin n)) := λ (m : ℕ), {x : euclidean_space ℝ (fin n) | ∃ (y : euclidean_space ℝ (fin n)), x ∈ y ∧ y ∈ A ∧ ∥ y ∥ ≤ m},
have h1 : ∀ (m : ℕ), ∃ (y : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ y ∧ y ∈ A ∧ ∥ y ∥ ≤ m, from by {
assume (m : ℕ),
have h2 : ∃ (y : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ y ∧ y ∈ A, from by {
have h3 : ∃ (y : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ y, from by {
use (0 : euclidean_space ℝ (fin n)),
obviously,
},
show ∃ (y : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ y ∧ y ∈ A, from by {
rcases h3 with ⟨y, hy⟩,
have h4 : ∃ (a : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ a ∧ a ∈ A, from by {
use y,
obviously,
},
show ∃ (y : euclidean_space ℝ (fin n)), (0 : euclidean_space ℝ (fin n)) ∈ y ∧ y ∈ A, from by {
rcases h4 with ⟨y, hy⟩,
use y,
obviously,
},
},
},
rcases h2 with ⟨y, hy⟩,
have h3 : ∃ (m : ℕ), ∥ y ∥ ≤ m, from by {
have h4 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h5 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h6 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h7 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h8 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h9 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h10 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h11 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h12 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h13 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h14 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h15 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h16 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h17 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h18 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h19 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h20 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h21 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h22 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h23 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h24 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h25 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h26 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h27 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h28 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h29 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h30 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h31 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h32 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h33 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h34 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h35 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h36 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h37 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h38 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h39 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h40 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h41 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h42 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h43 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h44 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
have h45 : ∃ (m : ℕ), ∥ y ∥ < m + 1, from by {
end --Needs more than 2000 tokens!
--OUTPUT 6
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
begin
-- Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$.
assume (A : set (set (euclidean_space ℝ (fin n)))) (hA : is_open_cover A),
-- We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$.
let C := {C ∈ A | ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ ⋃ i in finset.range (m+1), C i},
have h1 : C ⊆ A, from by {
assume (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ C),
show C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
have h1 : C ∈ A, from by {
end --Needs more than 2000 tokens!
/- FEW SHOT PROMPTS TO CODEX(START)
/--`theorem`
Power Set is Closed under Intersection
Let $S$ be a set.
Let $\powerset S$ be the power set of $S$.
Then:
:$\forall A, B \in \powerset S: A \cap B \in \powerset S$
`proof`
Let $A, B \in \powerset S$.
Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$.
From Intersection is Subset we have that $A \cap B \subseteq A$.
It follows from Subset Relation is Transitive that $A \cap B \subseteq S$.
Thus $A \cap B \in \powerset S$ and closure is proved.
{{qed}}
-/
theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=
begin
-- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$
assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),
-- Then $A ⊆ S$ and $B ⊆ S$, by power set definition
have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},
-- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset
have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,
-- Then $(A ∩ B) ⊆ S$, by subset relation is transitive
have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},
-- Hence $(A ∩ B) ∈ 𝒫 S$, by power set definition
show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3},
end
/--`theorem`
Square of Sum
:$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$
`proof`
Follows from the distribution of multiplication over addition:
{{begin-eqn}}
{{eqn | l = \left({x + y}\right)^2
| r = \left({x + y}\right) \cdot \left({x + y}\right)
}}
{{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right)
| c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y
| c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x^2 + 2xy + y^2
| c =
}}
{{end-eqn}}
{{qed}}
-/
theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) :=
begin
-- expand the power
calc (x + y)^2 = (x+y)*(x+y) : by rw sq
-- distributive property of multiplication over addition gives:
... = x*(x+y) + y*(x+y) : by rw add_mul
-- applying the above property further gives:
... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}
-- rearranging the terms using commutativity and adding gives:
... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}
end
/--`theorem`
Identity of Group is Unique
Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$.
`proof`
From Group has Latin Square Property, there exists a unique $x \in G$ such that:
:$a x = b$
and there exists a unique $y \in G$ such that:
:$y a = b$
Setting $b = a$, this becomes:
There exists a unique $x \in G$ such that:
:$a x = a$
and there exists a unique $y \in G$ such that:
:$y a = a$
These $x$ and $y$ are both $e$, by definition of identity element.
{{qed}}
-/
theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=
begin
-- Group has Latin Square Property
have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {
assume a b : G, use a⁻¹ * b, obviously, },
have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {
assume a b : G, use b * a⁻¹, obviously, },
-- Setting $b = a$, this becomes:
have h3 : ∀ a : G, ∃! x : G, a * x = a, from
assume a : G, h1 a a,
have h4 : ∀ a : G, ∃! y : G, y * a = a, from
assume a : G, h2 a a,
-- These $x$ and $y$ are both $(1 : G)$, by definition of identity element
have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,
exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))
(mul_one a),
have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,
exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a),
show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {
use (1 : G),
have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {
assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),
have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),
exists_unique.unique (h3 a) (hident a).right
(classical.some_spec (exists_unique.exists (h3 a))),
have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),
exists_unique.unique (h4 a) (hident a).left
(classical.some_spec (exists_unique.exists (h4 a))),
show e = (1 : G), from eq.trans (h9 e) (h6 _),
},
exact ⟨by obviously, h7⟩,
}
end
/--`theorem`
\mathbb{R}^n is paracompact
$\mathbb{R}^n$ is paracompact for all $n$.
`proof`
Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$. We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$
centered at 0. Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$). So $\mathcal{C} = \bigcup_{m = 0}^{\infty} \mathcal{C}_m$ is an open refinement of $\mathcal{A}$. Note that $\mathcal{C}$ covers $\mathbb{R}^n$ since for any $x \in \mathbb{R}^n$, there is a smallest $m \in \mathbb{N}$ such that $x \in \Bar{B_{m}}$ (namely, some $m$ where $\rVert x \lVert \leq m \leq \rVert x \lVert + 1$), and so $x$ is an element of $\mathcal{C}_m$. Now collection $\mathcal{C}$ is locally finite since for given $x \in \mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\mathcal{C}$, namely those elements in collection $\mathcal{C}_1 \cup \mathcal{C}_2 \cup \cdots \mathcal{C}_m$. So $\mathcal{C}$ is a locally finite open refinement of $\mathcal{A}$ that covers $\mathbb{R}^n$, hence $\mathbb{R}^n$ is paracompact.
QED
-/
theorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=
FEW SHOT PROMPTS TO CODEX(END)-/
|
(* Title: HOL/ex/Transfer_Int_Nat.thy
Author: Brian Huffman, TU Muenchen
*)
section {* Using the transfer method between nat and int *}
theory Transfer_Int_Nat
imports GCD
begin
subsection {* Correspondence relation *}
definition ZN :: "int \<Rightarrow> nat \<Rightarrow> bool"
where "ZN = (\<lambda>z n. z = of_nat n)"
subsection {* Transfer domain rules *}
lemma Domainp_ZN [transfer_domain_rule]: "Domainp ZN = (\<lambda>x. x \<ge> 0)"
unfolding ZN_def Domainp_iff[abs_def] by (auto intro: zero_le_imp_eq_int)
subsection {* Transfer rules *}
context
begin
interpretation lifting_syntax .
lemma bi_unique_ZN [transfer_rule]: "bi_unique ZN"
unfolding ZN_def bi_unique_def by simp
lemma right_total_ZN [transfer_rule]: "right_total ZN"
unfolding ZN_def right_total_def by simp
lemma ZN_0 [transfer_rule]: "ZN 0 0"
unfolding ZN_def by simp
lemma ZN_1 [transfer_rule]: "ZN 1 1"
unfolding ZN_def by simp
lemma ZN_add [transfer_rule]: "(ZN ===> ZN ===> ZN) (op +) (op +)"
unfolding rel_fun_def ZN_def by simp
lemma ZN_mult [transfer_rule]: "(ZN ===> ZN ===> ZN) (op *) (op *)"
unfolding rel_fun_def ZN_def by (simp add: int_mult)
lemma ZN_diff [transfer_rule]: "(ZN ===> ZN ===> ZN) tsub (op -)"
unfolding rel_fun_def ZN_def tsub_def by (simp add: zdiff_int)
lemma ZN_power [transfer_rule]: "(ZN ===> op = ===> ZN) (op ^) (op ^)"
unfolding rel_fun_def ZN_def by (simp add: int_power)
lemma ZN_nat_id [transfer_rule]: "(ZN ===> op =) nat id"
unfolding rel_fun_def ZN_def by simp
lemma ZN_id_int [transfer_rule]: "(ZN ===> op =) id int"
unfolding rel_fun_def ZN_def by simp
lemma ZN_All [transfer_rule]:
"((ZN ===> op =) ===> op =) (Ball {0..}) All"
unfolding rel_fun_def ZN_def by (auto dest: zero_le_imp_eq_int)
lemma ZN_transfer_forall [transfer_rule]:
"((ZN ===> op =) ===> op =) (transfer_bforall (\<lambda>x. 0 \<le> x)) transfer_forall"
unfolding transfer_forall_def transfer_bforall_def
unfolding rel_fun_def ZN_def by (auto dest: zero_le_imp_eq_int)
lemma ZN_Ex [transfer_rule]: "((ZN ===> op =) ===> op =) (Bex {0..}) Ex"
unfolding rel_fun_def ZN_def Bex_def atLeast_iff
by (metis zero_le_imp_eq_int zero_zle_int)
lemma ZN_le [transfer_rule]: "(ZN ===> ZN ===> op =) (op \<le>) (op \<le>)"
unfolding rel_fun_def ZN_def by simp
lemma ZN_less [transfer_rule]: "(ZN ===> ZN ===> op =) (op <) (op <)"
unfolding rel_fun_def ZN_def by simp
lemma ZN_eq [transfer_rule]: "(ZN ===> ZN ===> op =) (op =) (op =)"
unfolding rel_fun_def ZN_def by simp
lemma ZN_Suc [transfer_rule]: "(ZN ===> ZN) (\<lambda>x. x + 1) Suc"
unfolding rel_fun_def ZN_def by simp
lemma ZN_numeral [transfer_rule]:
"(op = ===> ZN) numeral numeral"
unfolding rel_fun_def ZN_def by simp
lemma ZN_dvd [transfer_rule]: "(ZN ===> ZN ===> op =) (op dvd) (op dvd)"
unfolding rel_fun_def ZN_def by (simp add: zdvd_int)
lemma ZN_div [transfer_rule]: "(ZN ===> ZN ===> ZN) (op div) (op div)"
unfolding rel_fun_def ZN_def by (simp add: zdiv_int)
lemma ZN_mod [transfer_rule]: "(ZN ===> ZN ===> ZN) (op mod) (op mod)"
unfolding rel_fun_def ZN_def by (simp add: zmod_int)
lemma ZN_gcd [transfer_rule]: "(ZN ===> ZN ===> ZN) gcd gcd"
unfolding rel_fun_def ZN_def by (simp add: transfer_int_nat_gcd)
lemma ZN_atMost [transfer_rule]:
"(ZN ===> rel_set ZN) (atLeastAtMost 0) atMost"
unfolding rel_fun_def ZN_def rel_set_def
by (clarsimp simp add: Bex_def, arith)
lemma ZN_atLeastAtMost [transfer_rule]:
"(ZN ===> ZN ===> rel_set ZN) atLeastAtMost atLeastAtMost"
unfolding rel_fun_def ZN_def rel_set_def
by (clarsimp simp add: Bex_def, arith)
lemma ZN_setsum [transfer_rule]:
"bi_unique A \<Longrightarrow> ((A ===> ZN) ===> rel_set A ===> ZN) setsum setsum"
apply (intro rel_funI)
apply (erule (1) bi_unique_rel_set_lemma)
apply (simp add: setsum.reindex int_setsum ZN_def rel_fun_def)
apply (rule setsum.cong)
apply simp_all
done
text {* For derived operations, we can use the @{text "transfer_prover"}
method to help generate transfer rules. *}
lemma ZN_listsum [transfer_rule]: "(list_all2 ZN ===> ZN) listsum listsum"
by transfer_prover
end
subsection {* Transfer examples *}
lemma
assumes "\<And>i::int. 0 \<le> i \<Longrightarrow> i + 0 = i"
shows "\<And>i::nat. i + 0 = i"
apply transfer
apply fact
done
lemma
assumes "\<And>i k::int. \<lbrakk>0 \<le> i; 0 \<le> k; i < k\<rbrakk> \<Longrightarrow> \<exists>j\<in>{0..}. i + j = k"
shows "\<And>i k::nat. i < k \<Longrightarrow> \<exists>j. i + j = k"
apply transfer
apply fact
done
lemma
assumes "\<forall>x\<in>{0::int..}. \<forall>y\<in>{0..}. x * y div y = x"
shows "\<forall>x y :: nat. x * y div y = x"
apply transfer
apply fact
done
lemma
assumes "\<And>m n::int. \<lbrakk>0 \<le> m; 0 \<le> n; m * n = 0\<rbrakk> \<Longrightarrow> m = 0 \<or> n = 0"
shows "m * n = (0::nat) \<Longrightarrow> m = 0 \<or> n = 0"
apply transfer
apply fact
done
lemma
assumes "\<forall>x\<in>{0::int..}. \<exists>y\<in>{0..}. \<exists>z\<in>{0..}. x + 3 * y = 5 * z"
shows "\<forall>x::nat. \<exists>y z. x + 3 * y = 5 * z"
apply transfer
apply fact
done
text {* The @{text "fixing"} option prevents generalization over the free
variable @{text "n"}, allowing the local transfer rule to be used. *}
lemma
assumes [transfer_rule]: "ZN x n"
assumes "\<forall>i\<in>{0..}. i < x \<longrightarrow> 2 * i < 3 * x"
shows "\<forall>i. i < n \<longrightarrow> 2 * i < 3 * n"
apply (transfer fixing: n)
apply fact
done
lemma
assumes "gcd (2^i) (3^j) = (1::int)"
shows "gcd (2^i) (3^j) = (1::nat)"
apply (transfer fixing: i j)
apply fact
done
lemma
assumes "\<And>x y z::int. \<lbrakk>0 \<le> x; 0 \<le> y; 0 \<le> z\<rbrakk> \<Longrightarrow>
listsum [x, y, z] = 0 \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]"
shows "listsum [x, y, z] = (0::nat) \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]"
apply transfer
apply fact
done
text {* Quantifiers over higher types (e.g. @{text "nat list"}) are
transferred to a readable formula thanks to the transfer domain rule @{thm Domainp_ZN} *}
lemma
assumes "\<And>xs::int list. list_all (\<lambda>x. x \<ge> 0) xs \<Longrightarrow>
(listsum xs = 0) = list_all (\<lambda>x. x = 0) xs"
shows "listsum xs = (0::nat) \<longleftrightarrow> list_all (\<lambda>x. x = 0) xs"
apply transfer
apply fact
done
text {* Equality on a higher type can be transferred if the relations
involved are bi-unique. *}
lemma
assumes "\<And>xs\<Colon>int list. \<lbrakk>list_all (\<lambda>x. x \<ge> 0) xs; xs \<noteq> []\<rbrakk> \<Longrightarrow>
listsum xs < listsum (map (\<lambda>x. x + 1) xs)"
shows "xs \<noteq> [] \<Longrightarrow> listsum xs < listsum (map Suc xs)"
apply transfer
apply fact
done
end
|
[STATEMENT]
lemma list_all_set: "\<forall> x \<in> set xs. P x \<Longrightarrow> list_all P xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<forall>x\<in>set xs. P x \<Longrightarrow> list_all P xs
[PROOF STEP]
by (metis (lifting) list_all_iff) |
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h"
#include "db.h"
#include "net.h"
#include "auxpow.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
using namespace std;
using namespace boost;
unsigned int nWalletDBUpdated;
//
// CDB
//
static CCriticalSection cs_db;
static bool fDbEnvInit = false;
DbEnv dbenv(0);
static map<string, int> mapFileUseCount;
static map<string, Db*> mapDb;
class CDBInit
{
public:
CDBInit()
{
}
~CDBInit()
{
if (fDbEnvInit)
{
dbenv.close(0);
fDbEnvInit = false;
}
}
}
instance_of_cdbinit;
CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
{
int ret;
if (pszFile == NULL)
return;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
bool fCreate = strchr(pszMode, 'c');
unsigned int nFlags = DB_THREAD;
if (fCreate)
nFlags |= DB_CREATE;
CRITICAL_BLOCK(cs_db)
{
if (!fDbEnvInit)
{
if (fShutdown)
return;
string strDataDir = GetDataDir();
string strLogDir = strDataDir + "/database";
filesystem::create_directory(strLogDir.c_str());
string strErrorFile = strDataDir + "/db.log";
printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str());
int nDbCache = GetArg("-dbcache", 25);
dbenv.set_lg_dir(strLogDir.c_str());
dbenv.set_cachesize(nDbCache / 1024, (nDbCache % 1024)*1048576, 1);
dbenv.set_lg_bsize(10485760);
dbenv.set_lg_max(104857600);
dbenv.set_lk_max_locks(10000);
dbenv.set_lk_max_objects(10000);
dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug
dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
ret = dbenv.open(strDataDir.c_str(),
DB_CREATE |
DB_INIT_LOCK |
DB_INIT_LOG |
DB_INIT_MPOOL |
DB_INIT_TXN |
DB_THREAD |
DB_PRIVATE |
DB_RECOVER,
S_IRUSR | S_IWUSR);
if (ret > 0)
throw runtime_error(strprintf("CDB() : error %d opening database environment", ret));
fDbEnvInit = true;
}
strFile = pszFile;
++mapFileUseCount[strFile];
pdb = mapDb[strFile];
if (pdb == NULL)
{
pdb = new Db(&dbenv, 0);
ret = pdb->open(NULL, // Txn pointer
pszFile, // Filename
"main", // Logical db name
DB_BTREE, // Database type
nFlags, // Flags
0);
if (ret > 0)
{
delete pdb;
pdb = NULL;
CRITICAL_BLOCK(cs_db)
--mapFileUseCount[strFile];
strFile = "";
throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret));
}
if (fCreate && !Exists(string("version")))
{
bool fTmp = fReadOnly;
fReadOnly = false;
WriteVersion(VERSION);
fReadOnly = fTmp;
}
mapDb[strFile] = pdb;
}
}
}
void CDB::Close()
{
if (!pdb)
return;
if (!vTxn.empty())
vTxn.front()->abort();
vTxn.clear();
pdb = NULL;
// Flush database activity from memory pool to disk log
// wallet.dat is always flushed, the other files only every couple of minutes
// note Namecoin has more .dat files than Bitcoin
unsigned int nMinutes = 2;
if (fReadOnly)
nMinutes = 1;
if (strFile == "wallet.dat")
nMinutes = 0;
if ((strFile == "blkindex.dat" || strFile == "game.dat" || strFile == "nameindexfull.dat") && IsInitialBlockDownload() && nBestHeight % 5000 != 0)
nMinutes = 5;
dbenv.txn_checkpoint(0, nMinutes, 0);
CRITICAL_BLOCK(cs_db)
--mapFileUseCount[strFile];
}
void static CloseDb(const string& strFile)
{
CRITICAL_BLOCK(cs_db)
{
if (mapDb[strFile] != NULL)
{
// Close the database handle
Db* pdb = mapDb[strFile];
pdb->close(0);
delete pdb;
mapDb[strFile] = NULL;
}
}
}
void static CheckpointLSN(const std::string &strFile)
{
dbenv.txn_checkpoint(0, 0, 0);
//if (fMockDb)
// return;
dbenv.lsn_reset(strFile.c_str(), 0);
}
bool CDB::Rewrite(const string& strFile, const char* pszSkip)
{
while (!fShutdown)
{
CRITICAL_BLOCK(cs_db)
{
if (!mapFileUseCount.count(strFile) || mapFileUseCount[strFile] == 0)
{
// Flush log data to the dat file
CloseDb(strFile);
CheckpointLSN(strFile);
mapFileUseCount.erase(strFile);
bool fSuccess = true;
printf("Rewriting %s...\n", strFile.c_str());
string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {}
CDB db(strFile.c_str(), "r");
Db* pdbCopy = new Db(&dbenv, 0);
int ret = pdbCopy->open(NULL, // Txn pointer
strFileRes.c_str(), // Filename
"main", // Logical db name
DB_BTREE, // Database type
DB_CREATE, // Flags
0);
if (ret > 0)
{
printf("Cannot create database file %s\n", strFileRes.c_str());
fSuccess = false;
}
Dbc* pcursor = db.GetCursor();
if (pcursor)
while (fSuccess)
{
CDataStream ssKey(SER_DISK, VERSION);
CDataStream ssValue(SER_DISK, VERSION);
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
if (ret == DB_NOTFOUND)
{
pcursor->close();
break;
}
else if (ret != 0)
{
pcursor->close();
fSuccess = false;
break;
}
if (pszSkip &&
strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
continue;
if (strncmp(&ssKey[0], "\x07version", 8) == 0)
{
// Update version:
ssValue.clear();
ssValue << VERSION;
}
Dbt datKey(&ssKey[0], ssKey.size());
Dbt datValue(&ssValue[0], ssValue.size());
int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE);
if (ret2 > 0)
fSuccess = false;
}
if (fSuccess)
{
db.Close();
CloseDb(strFile);
if (pdbCopy->close(0))
fSuccess = false;
delete pdbCopy;
}
}
if (fSuccess)
{
Db dbA(&dbenv, 0);
if (dbA.remove(strFile.c_str(), NULL, 0))
fSuccess = false;
Db dbB(&dbenv, 0);
if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0))
fSuccess = false;
}
if (!fSuccess)
printf("Rewriting of %s FAILED!\n", strFileRes.c_str());
return fSuccess;
}
}
Sleep(100);
}
return false;
}
void DBFlush(bool fShutdown)
{
// Flush log data to the actual data file
// on all files that are not in use
printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
if (!fDbEnvInit)
return;
CRITICAL_BLOCK(cs_db)
{
map<string, int>::iterator mi = mapFileUseCount.begin();
while (mi != mapFileUseCount.end())
{
string strFile = (*mi).first;
int nRefCount = (*mi).second;
printf("%s refcount=%d\n", strFile.c_str(), nRefCount);
if (nRefCount == 0)
{
// Move log data to the dat file
CloseDb(strFile);
dbenv.txn_checkpoint(0, 0, 0);
printf("%s flush\n", strFile.c_str());
dbenv.lsn_reset(strFile.c_str(), 0);
mapFileUseCount.erase(mi++);
}
else
mi++;
}
if (fShutdown)
{
char** listp;
if (mapFileUseCount.empty())
dbenv.log_archive(&listp, DB_ARCH_REMOVE);
try
{
dbenv.close(0);
}
catch (const DbException& e)
{
printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno());
}
fDbEnvInit = false;
}
}
}
//
// CTxDB
//
bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex)
{
assert(!fClient);
txindex.SetNull();
return Read(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex)
{
assert(!fClient);
return Write(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight)
{
assert(!fClient);
// Add to tx index
uint256 hash = tx.GetHash();
CTxIndex txindex(pos, tx.vout.size());
return Write(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::EraseTxIndex(const CTransaction& tx)
{
assert(!fClient);
uint256 hash = tx.GetHash();
return Erase(make_pair(string("tx"), hash));
}
bool CTxDB::ContainsTx(uint256 hash)
{
assert(!fClient);
return Exists(make_pair(string("tx"), hash));
}
bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
{
assert(!fClient);
tx.SetNull();
if (!ReadTxIndex(hash, txindex))
return false;
return (tx.ReadFromDisk(txindex.pos));
}
bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx)
{
CTxIndex txindex;
return ReadDiskTx(hash, tx, txindex);
}
bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex)
{
return ReadDiskTx(outpoint.hash, tx, txindex);
}
bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx)
{
CTxIndex txindex;
return ReadDiskTx(outpoint.hash, tx, txindex);
}
bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
{
return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex);
}
bool CTxDB::EraseBlockIndex(uint256 hash)
{
return Erase(make_pair(string("blockindex"), hash));
}
bool CTxDB::ReadHashBestChain(uint256& hashBestChain)
{
return Read(string("hashBestChain"), hashBestChain);
}
bool CTxDB::WriteHashBestChain(uint256 hashBestChain)
{
return Write(string("hashBestChain"), hashBestChain);
}
bool CTxDB::ReadBestInvalidWork(CBigNum& bnBestInvalidWork)
{
return Read(string("bnBestInvalidWork"), bnBestInvalidWork);
}
bool CTxDB::WriteBestInvalidWork(CBigNum bnBestInvalidWork)
{
return Write(string("bnBestInvalidWork"), bnBestInvalidWork);
}
CBlockIndex static * InsertBlockIndex(uint256 hash)
{
if (hash == 0)
return NULL;
// Return existing
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
return (*mi).second;
// Create new
CBlockIndex* pindexNew = new CBlockIndex();
if (!pindexNew)
throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
pindexNew->phashBlock = &((*mi).first);
return pindexNew;
}
bool CTxDB::LoadBlockIndex()
{
// Get database cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
return false;
// Load mapBlockIndex
unsigned int fFlags = DB_SET_RANGE;
loop
{
// Read next record
CDataStream ssKey;
if (fFlags == DB_SET_RANGE)
ssKey << make_pair(string("blockindex"), uint256(0));
CDataStream ssValue;
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
if (ret == DB_NOTFOUND)
break;
else if (ret != 0)
return false;
// Unserialize
string strType;
ssKey >> strType;
if (strType == "blockindex")
{
CDiskBlockIndex diskindex;
ssValue >> diskindex;
// Construct block index object
CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
pindexNew->pnext = InsertBlockIndex(diskindex.hashNext);
pindexNew->nFile = diskindex.nFile;
pindexNew->nBlockPos = diskindex.nBlockPos;
pindexNew->nHeight = diskindex.nHeight;
pindexNew->nVersion = diskindex.nVersion;
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
pindexNew->hashGameMerkleRoot = diskindex.hashGameMerkleRoot;
pindexNew->nTime = diskindex.nTime;
pindexNew->nBits = diskindex.nBits;
pindexNew->nNonce = diskindex.nNonce;
pindexNew->auxpow = diskindex.auxpow;
// Watch for genesis block
if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == hashGenesisBlock)
pindexGenesisBlock = pindexNew;
if (!pindexNew->CheckIndex())
return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);
}
else
{
break;
}
}
pcursor->close();
// Calculate bnChainWork
vector<pair<int, CBlockIndex*> > vSortedByHeight;
vSortedByHeight.reserve(mapBlockIndex.size());
BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
{
CBlockIndex* pindex = item.second;
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
{
CBlockIndex* pindex = item.second;
pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork();
}
// Load hashBestChain pointer to end of best chain
if (!ReadHashBestChain(hashBestChain))
{
if (pindexGenesisBlock == NULL)
return true;
return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded");
}
if (!mapBlockIndex.count(hashBestChain))
return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index");
pindexBest = mapBlockIndex[hashBestChain];
nBestHeight = pindexBest->nHeight;
bnBestChainWork = pindexBest->bnChainWork;
printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight);
// Load bnBestInvalidWork, OK if it doesn't exist
ReadBestInvalidWork(bnBestInvalidWork);
// Verify blocks in the best chain
CBlockIndex* pindexFork = NULL;
for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
{
if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks"))
break;
CBlock block;
if (!block.ReadFromDisk(pindex))
return error("LoadBlockIndex() : block.ReadFromDisk failed");
if (!block.CheckBlock(pindex->nHeight))
{
printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
pindexFork = pindex->pprev;
}
}
if (pindexFork)
{
// Reorg back to the fork
printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight);
CBlock block;
if (!block.ReadFromDisk(pindexFork))
return error("LoadBlockIndex() : block.ReadFromDisk failed");
CTxDB txdb;
block.SetBestChain(txdb, pindexFork);
}
return true;
}
//
// CAddrDB
//
bool CAddrDB::WriteAddress(const CAddress& addr)
{
return Write(make_pair(string("addr"), addr.GetKey()), addr);
}
bool CAddrDB::EraseAddress(const CAddress& addr)
{
return Erase(make_pair(string("addr"), addr.GetKey()));
}
bool CAddrDB::LoadAddresses()
{
CRITICAL_BLOCK(cs_mapAddresses)
{
// Load user provided addresses
CAutoFile filein = fopen((GetDataDir() + "/addr.txt").c_str(), "rt");
if (filein)
{
try
{
char psz[1000];
while (fgets(psz, sizeof(psz), filein))
{
CAddress addr(psz, NODE_NETWORK);
addr.nTime = 0; // so it won't relay unless successfully connected
if (addr.IsValid())
AddAddress(addr);
}
}
catch (...) { }
}
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
return false;
loop
{
// Read next record
CDataStream ssKey;
CDataStream ssValue;
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
if (ret == DB_NOTFOUND)
break;
else if (ret != 0)
return false;
// Unserialize
string strType;
ssKey >> strType;
if (strType == "addr")
{
CAddress addr;
ssValue >> addr;
mapAddresses.insert(make_pair(addr.GetKey(), addr));
}
}
pcursor->close();
printf("Loaded %d addresses\n", mapAddresses.size());
}
return true;
}
bool LoadAddresses()
{
return CAddrDB("cr+").LoadAddresses();
}
void PrintSettingsToLog()
{
printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
printf("nMinimumInputValue = %"PRI64d"\n", nMinimumInputValue);
printf("fMinimizeToTray = %d\n", fMinimizeToTray);
printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
printf("fUseProxy = %d\n", fUseProxy);
printf("addrProxy = %s\n", addrProxy.ToString().c_str());
if (fHaveUPnP)
printf("fUseUPnP = %d\n", fUseUPnP);
}
void ThreadFlushWalletDB(void* parg)
{
const string& strFile = ((const string*)parg)[0];
static bool fOneThread;
if (fOneThread)
return;
fOneThread = true;
if (mapArgs.count("-noflushwallet"))
return;
unsigned int nLastSeen = nWalletDBUpdated;
unsigned int nLastFlushed = nWalletDBUpdated;
int64 nLastWalletUpdate = GetTime();
while (!fShutdown)
{
Sleep(500);
if (nLastSeen != nWalletDBUpdated)
{
nLastSeen = nWalletDBUpdated;
nLastWalletUpdate = GetTime();
}
if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)
{
TRY_CRITICAL_BLOCK(cs_db)
{
// Don't do this if any databases are in use
int nRefCount = 0;
map<string, int>::iterator mi = mapFileUseCount.begin();
while (mi != mapFileUseCount.end())
{
nRefCount += (*mi).second;
mi++;
}
if (nRefCount == 0 && !fShutdown)
{
map<string, int>::iterator mi = mapFileUseCount.find(strFile);
if (mi != mapFileUseCount.end())
{
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("Flushing wallet.dat\n");
nLastFlushed = nWalletDBUpdated;
int64 nStart = GetTimeMillis();
// Flush wallet.dat so it's self contained
CloseDb(strFile);
dbenv.txn_checkpoint(0, 0, 0);
dbenv.lsn_reset(strFile.c_str(), 0);
mapFileUseCount.erase(mi++);
printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
}
}
}
}
}
}
bool BackupWallet(const CWallet& wallet, const string& strDest)
{
if (!wallet.fFileBacked)
return false;
while (!fShutdown)
{
CRITICAL_BLOCK(cs_db)
{
if (!mapFileUseCount.count(wallet.strWalletFile) || mapFileUseCount[wallet.strWalletFile] == 0)
{
// Flush log data to the dat file
CloseDb(wallet.strWalletFile);
dbenv.txn_checkpoint(0, 0, 0);
dbenv.lsn_reset(wallet.strWalletFile.c_str(), 0);
mapFileUseCount.erase(wallet.strWalletFile);
// Copy wallet.dat
filesystem::path pathSrc(GetDataDir() + "/" + wallet.strWalletFile);
filesystem::path pathDest(strDest);
if (filesystem::is_directory(pathDest))
pathDest = pathDest / wallet.strWalletFile;
try {
#if BOOST_VERSION >= 104000
filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists);
#else
filesystem::copy_file(pathSrc, pathDest);
#endif
printf("copied wallet.dat to %s\n", pathDest.string().c_str());
return true;
} catch(const filesystem::filesystem_error &e) {
printf("error copying wallet.dat to %s - %s\n", pathDest.string().c_str(), e.what());
return false;
}
}
}
Sleep(100);
}
return false;
}
|
From iris.base_logic Require Export invariants gen_heap.
From iris.program_logic Require Export weakestpre ectx_lifting.
From iris.proofmode Require Import proofmode.
From iris.algebra Require Import frac.
From cap_machine Require Export rules_base.
Section cap_lang_rules.
Context `{memG Σ, regG Σ}.
Context `{MachineParameters}.
Implicit Types P Q : iProp Σ.
Implicit Types σ : ExecConf.
Implicit Types c : cap_lang.expr.
Implicit Types a b : Addr.
Implicit Types r : RegName.
Implicit Types v : cap_lang.val.
Implicit Types w : Word.
Implicit Types reg : gmap RegName Word.
Implicit Types ms : gmap Addr Word.
Lemma wp_jmp_success E pc_p pc_b pc_e pc_a w r w' :
decodeInstrW w = Jmp r →
isCorrectPC (WCap pc_p pc_b pc_e pc_a) →
{{{ ▷ PC ↦ᵣ WCap pc_p pc_b pc_e pc_a
∗ ▷ pc_a ↦ₐ w
∗ ▷ r ↦ᵣ w' }}}
Instr Executable @ E
{{{ RET NextIV;
PC ↦ᵣ updatePcPerm w'
∗ pc_a ↦ₐ w
∗ r ↦ᵣ w' }}}.
Proof.
iIntros (Hinstr Hvpc ϕ) "(>HPC & >Hpc_a & >Hr) Hφ".
iApply wp_lift_atomic_head_step_no_fork; auto.
iIntros (σ1 ns l1 l2 nt) "Hσ1 /=". destruct σ1; simpl.
iDestruct "Hσ1" as "[Hr0 Hm]".
iDestruct (@gen_heap_valid with "Hm Hpc_a") as %?; auto.
iDestruct (@gen_heap_valid with "Hr0 HPC") as %?.
iDestruct (@gen_heap_valid with "Hr0 Hr") as %Hr_r0.
iModIntro. iSplitR. by iPureIntro; apply normal_always_head_reducible.
iNext. iIntros (e2 σ2 efs Hpstep).
apply prim_step_exec_inv in Hpstep as (-> & -> & (c & -> & Hstep)).
iIntros "_".
iSplitR; auto. eapply step_exec_inv in Hstep; eauto.
unfold exec, exec_opt in Hstep. rewrite Hr_r0 /= in Hstep. simplify_pair_eq.
iMod (@gen_heap_update with "Hr0 HPC") as "[Hr0 HPC]". iFrame.
iApply "Hφ". by iFrame.
Qed.
Lemma wp_jmp_successPC E pc_p pc_b pc_e pc_a w :
decodeInstrW w = Jmp PC →
isCorrectPC (WCap pc_p pc_b pc_e pc_a) →
{{{ ▷ PC ↦ᵣ WCap pc_p pc_b pc_e pc_a
∗ ▷ pc_a ↦ₐ w }}}
Instr Executable @ E
{{{ RET NextIV;
PC ↦ᵣ updatePcPerm (WCap pc_p pc_b pc_e pc_a)
∗ pc_a ↦ₐ w }}}.
Proof.
iIntros (Hinstr Hvpc ϕ) "(>HPC & >Hpc_a) Hφ".
iApply wp_lift_atomic_head_step_no_fork; auto.
iIntros (σ1 ns l1 l2 nt) "Hσ1 /=". destruct σ1; cbn.
iDestruct "Hσ1" as "[Hr0 Hm]".
iDestruct (@gen_heap_valid with "Hm Hpc_a") as %?; auto.
iDestruct (@gen_heap_valid with "Hr0 HPC") as %Hr_PC.
iModIntro. iSplitR. by iPureIntro; apply normal_always_head_reducible.
iNext. iIntros (e2 σ2 efs Hpstep).
apply prim_step_exec_inv in Hpstep as (-> & -> & (c & -> & Hstep)).
iIntros "_".
iSplitR; auto. eapply step_exec_inv in Hstep; eauto.
unfold exec, exec_opt in Hstep. rewrite Hr_PC /= in Hstep. simplify_pair_eq.
iMod (@gen_heap_update with "Hr0 HPC") as "[Hr0 HPC]". iFrame.
iApply "Hφ". by iFrame.
Qed.
End cap_lang_rules.
|
(*
MacBook-Air:~ billw$ /Applications/CoqIDE_8.4pl5.app/Contents/Resources/bin/coqtop
Welcome to Coq 8.4pl5 (October 2014)
Coq < Require Import Classical.
Coq < Section Exercise_01.
Coq < Goal forall a b:Prop, ~(a) -> (a -> b).
1 subgoal
============================
forall a b : Prop, ~ a -> a -> b
Unnamed_thm < intros.
1 subgoal
a : Prop
b : Prop
H : ~ a
H0 : a
============================
b
Unnamed_thm < tauto.
No more subgoals.
Unnamed_thm < Qed.
intros.
tauto.
Unnamed_thm is defined
Coq <
*)
Require Import Classical.
Section Exercise_01.
Goal forall a b:Prop, ~(a) -> (a -> b).
intros.
tauto.
Qed.
|
Require Export Iron.Language.SystemF2Effect.Value.
Require Export Iron.Language.SystemF2Effect.Store.
Require Export Iron.Language.SystemF2Effect.Step.Frame.
Require Export Iron.Language.SystemF2Effect.Step.TypeF.
(********************************************************************)
(* Type of an expression in a frame context. *)
Inductive TypeC
: kienv -> tyenv
-> stenv -> stprops
-> stack -> exp
-> ty -> ty -> Prop :=
| TcExp
: forall ke te se sp fs x1 t1 e1 t2 e2 e3
, EquivT ke sp (TSum e1 e2) e3 KEffect
-> TypeX ke te se sp x1 t1 e1
-> TypeF ke te se sp fs t1 t2 e2
-> TypeC ke te se sp fs x1 t2 e3.
Hint Constructors TypeC.
Ltac inverts_typec :=
repeat
(try (match goal with
| [H: TypeC _ _ _ _ _ _ _ _ |- _ ] => inverts H
end);
try inverts_typef).
(********************************************************************)
Lemma typeC_kindT_effect
: forall ke te se sp fs x t e
, TypeC ke te se sp fs x t e
-> KindT ke sp e KEffect.
Proof.
intros.
induction H; eauto.
Qed.
|
module Data.Time.Calendar
import Data.Time.Calendar.Days
export
data DayOfWeek
= Monday
| Tuesday
| Wednesday
| Thursday
| Friday
| Saturday
| Sunday
export
Enum DayOfWeek where
pred Monday = Tuesday
pred Tuesday = Wednesday
pred Wednesday = Thursday
pred Thursday = Friday
pred Friday = Saturday
pred Saturday = Sunday
pred Sunday = Monday
toNat Monday = 1
toNat Tuesday = 2
toNat Wednesday = 3
toNat Thursday = 4
toNat Friday = 5
toNat Saturday = 6
toNat Sunday = 7
-- this is really slow!! and unusable. I am not able to get a total function out of this using (fromNat : x -> Int)
fromNat x = case x of
Z => Sunday
(S (S (S (S (S (S (S k))))))) => fromNat k
(S (S (S (S (S (S k)))))) => Saturday
(S (S (S (S (S k))))) => Friday
(S (S (S (S k)))) => Thursday
(S (S (S k))) => Wednesday
(S (S k)) => Tuesday
(S k) => Monday
dayOfWeek : Day -> DayOfWeek
dayOfWeek (MkModifiedJulianDay d) = let x = fromInteger (d + 3)
in
case mod x 7 of
0 => Sunday
1 => Monday
2 => Tuesday
3 => Wednesday
4 => Thursday
5 => Friday
_ => Saturday
--dayOfWeek (MkModifiedJulianDay d)
|
from keras.models import load_model
import numpy as np
import cv2
"""
tensorflow_version --> '2.0.0'
keras_version -------> '2.3.1'
"""
'''
para usar:
1. instanciar modelo
face_detector = f_face_detector.detector_face_occlusion()
2. ingresar alguna imagen con un rostro y predecir
boxes_face = face_detector.detect_face(img)
Nota: devuleve los bounding_box donde encontro rostros
'''
class detector_face_occlusion():
def __init__(self):
# arquitectura de la red
prototxt_path = "face_detector/deploy.prototxt"
# pesos de la red
caffemodel_path = "face_detector/weights.caffemodel"
self.detector = cv2.dnn.readNetFromCaffe(prototxt_path, caffemodel_path)
def detect_face(self,image):
(h, w) = image.shape[:2]
# preparo la imagen para ingresar al modelo
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300, 300)), 1.0, (300, 300), (104.0, 177.0, 123.0))
# ingreso la imagen al modelo
self.detector.setInput(blob)
# propago la imagen hacia adelante del modelo
detections = self.detector.forward()
""""
detections, tiene 4 columnas que son:
0 column -->
1st column -->
2nd column --> numero dedetecciones que hizo por defecto 200
3th column --> tiene 7 subcolumnas que son
4.0 -->
4.1 -->
4.2 --> confidence
4.3 --> x0
4.4 --> y0
4.5 --> x1
4.6 --> y1
"""
# reviso la confianza de las 200's predicciones
list_box = []
for i in range(0, detections.shape[2]):
# box --> array[x0,y0,x1,y1]
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
# confidence range --> [0-1]
confidence = detections[0,0,i,2]
if confidence >=0.6:
if list_box == []:
list_box = np.expand_dims(box,axis=0)
else:
list_box = np.vstack((list_box,box))
return list_box
|
[STATEMENT]
lemma dedekind_1_left:
"x * 1 \<sqinter> y \<le> (x \<sqinter> y * 1) * 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x * (1::'a) \<sqinter> y \<le> (x \<sqinter> y * (1::'a)) * (1::'a)
[PROOF STEP]
by simp |
Formal statement is: lemma bounded_closure_image: "bounded (f ` closure S) \<Longrightarrow> bounded (f ` S)" Informal statement is: If the image of the closure of a set $S$ under a function $f$ is bounded, then the image of $S$ under $f$ is bounded. |
import graph_tool.all as gt
import numpy as np
from unnet.BarabasiGenerator import LinLogHomophilySampler, HomophilySamplerMulti, HomophilySamplerRejection
def barabassi_albert_network(n, m):
return gt.price_network(n, m, directed=False)
def barabassi_albert_network_with_random_labels(n, m, minority_fraction=None, rng=None):
""" Creates a barabasi albert graph and afterwards assigns random node labels
"""
G = barabassi_albert_network(n,m)
minority_size = int(minority_fraction * n)
labels = np.zeros(n, dtype=bool)
labels[:minority_size]=1
if rng is None:
np.random.shuffle(labels)
else:
raise NotImplementedError
G.vertex_properties["minority"] = G.new_vertex_property('bool', vals=labels)
return G
def homophily_barabasi_network(n, m , minority_fraction, homophily, epsilon, force_minority_first=False, multi_edges="none"):
""" Creates a homophilic + preferential attachment graph
"""
G=gt.Graph(directed=False)
if multi_edges=="none":
edges, labels = LinLogHomophilySampler(n, m , minority_fraction, homophily, epsilon=epsilon, force_minority_first=force_minority_first)
elif multi_edges=="allow":
edges, labels = HomophilySamplerMulti(n, m , minority_fraction, homophily, epsilon=epsilon, force_minority_first=force_minority_first)
elif multi_edges=="rejection":
edges, labels = HomophilySamplerRejection(n, m , minority_fraction, homophily, epsilon=epsilon, force_minority_first=force_minority_first)
else:
raise ValueError("multi_edges must be one of [none, allow, rejection]")
G.add_edge_list(edges)
G.vertex_properties["minority"]=G.new_vertex_property('bool', vals=labels)
return G
class ParamsSetter:
# pylint: disable=no-member
def parameters_set(self, params):
assert len(params) == len(self.parameters_mapping)
for key, value in params.items():
if key in self.parameters_mapping:
setattr(self, key, value)
else:
raise KeyError(f"The key {key} is not valid for "+str(self.__class__))
# pylint: enable=no-member
class BarabasiGenerator(ParamsSetter):
def __init__(self):
self.node_size = 0
self.node_growth = 0
def generate(self):
pass
@property
def parameters_mapping(self):
return {'node_size' : 'n',
'node_growth' : 'm'}
def execute(self,*args, **kwargs):
return barabassi_albert_network_with_random_labels(self.node_size,
self.node_growth,0,0)
class HomophilyGenerator(ParamsSetter):
"""
Generator class for homophilic random graph using BA preferential attachment model.
A graph of n nodes is grown by attaching new nodes each with m
edges that are preferentially attached to existing nodes with high
degree. The connections are established by linking probability which
depends on the connectivity of sites and the homophily(similarities).
homophily varies ranges from 0 to 1.
Parameters
----------
n : int
Number of nodes
m : int
Number of edges to attach from a new node to existing nodes
minority_fraction : float
fraction of instances in the minority group
homophily: float
value between 0 and 1. similarity between nodes
multi_edges: str
How to treat multi edges?
"none" : use sampling without replacement to avoid multi edges WARNING: produces a slightly different distribution
"rejection" : use rejection sampling to try and avoid multi edges (Fariba's approach)
"allow" : allow multi edges to have a perfect BA model
epsilon: float
constant value that any node gets an edge #TODO
Returns
-------
G : graph-tool.Graph
undirected graph, the vertex property 'minority' indicates (1 belongs to minority, 0 does not)
Notes
-----
The initialization is a graph with with m nodes and no edges.
"""
def __init__(self, multi_edges="none"):
super().__init__()
self.minority_fraction = 0.5
self.homophily = 0.5
self.n = 0
self.m = 0
self.epsilon = 10E-10
self.multi_edges = multi_edges
@property
def parameters_mapping(self):
return {
'n' : 'n',
'm' : 'm',
'minority_fraction':'minority_fraction',
'homophily' : 'homophily'}
def execute(self,*args, **kwargs):
return homophily_barabasi_network(n = self.n,
m = self.m,
minority_fraction = self.minority_fraction,
homophily = self.homophily,
epsilon=self.epsilon,
multi_edges=self.multi_edges)
|
[STATEMENT]
lemma unit_disc_fix_id_moebius [simp]:
shows "unit_disc_fix id_moebius"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. unit_disc_fix id_moebius
[PROOF STEP]
by (transfer, transfer, simp add: unitary11_gen_def mat_adj_def mat_cnj_def) |
(* *********************************************************************)
(* *)
(* The CertiKOS Certified Kit Operating System *)
(* *)
(* The FLINT Group, Yale University *)
(* *)
(* Copyright The FLINT Group, Yale University. All rights reserved. *)
(* This file is distributed under the terms of the Yale University *)
(* Non-Commercial License Agreement. *)
(* *)
(* *********************************************************************)
Require Import Coq.Program.Basics.
Require Export Coq.Classes.Morphisms.
Require Import Coq.Setoids.Setoid.
Require Import Coq.Lists.List.
Local Open Scope type.
Global Open Scope signature.
(** * Prerequisites *)
(** Some instances that would normally cause loops can be used
nontheless if we insist that some parameters cannot be existential
variables. One way to do this is to use this guard class, similar in
spirit to [Unconvertible]. *)
Class NotEvar {A} (x: A).
Hint Extern 1 (NotEvar ?x) =>
not_evar x; constructor : typeclass_instances.
(** Sometimes we may want to introduce an auxiliary variable to help
with unification. *)
Class Convertible {A} (x y: A) :=
convertible: x = y.
Hint Extern 1 (Convertible ?x ?y) =>
eapply eq_refl : typeclass_instances.
(** * Relations *)
(** The constructions in [Coq.Relations.Relation_Definitions] are only
concerned with relations within a single type, so that [relation A]
is defined as [A -> A -> Prop]. We will need more general
relations, and so I define [rel A B] as [A -> B -> Prop]. *)
(** When we move to a version of Coq with universe polymorphism, we
can make this a [Polymorphic Definition]. In the meantime, we need
to use a notation so that universes levels are instantiated at every
use site. *)
Notation rel := (fun A1 A2 => A1 -> A2 -> Prop).
(** ** Proper elements *)
(** I follow [Coq.Classes.Morphisms] and define morphisms as proper
elements of a corresponding logical relation. They can be registered
by declaring instances of the [Proper] typeclass.
However, we will build up logical relations from our own set of
relators, and use our own tactics to deduce new instances of
[Proper] from the existing ones. To prevent the two systems from
interfering with one another, I will use the following nearly
identical, but distinct definition of [Proper]. *)
(** There is one ugly tweak that we need, compared with the original.
Namely, we want the type parameter [A] to be unified in priority
with the type of element [m], rather than that of the relation [R].
That is because by necessity, the relator [forall_rel] defined below
yields an eta-expanded type of the form [(fun x => T x) x].
As a consequence, some instances declared using [forall_rel] become
unusable because [A] takes this peculiar form. To work around this,
we flip the order of arguments in our version of [Proper], so that
[A] is unified against the type of [m], then use notations to fake
the original order. *)
Class ProperDef {A} (m: A) (R: rel A A) := proper_prf : R m m.
Notation "'@' 'Proper' T R m" := (@ProperDef T m R)
(at level 10, T at next level, R at next level, m at next level).
Notation Proper R m := (ProperDef m R).
(** ** Order on relations *)
(** This is our generalization of [subrelation]. Like the original it
constitutes a preorder, and the union and intersection of relations
are the corresponding join and meet. *)
Class subrel {A B} (R1 R2: rel A B) :=
subrel_at x y: R1 x y -> R2 x y.
Global Instance subrel_preorder A B:
@PreOrder (rel A B) subrel.
Proof.
split; firstorder.
Qed.
Instance subrel_refl {A B} (R: rel A B):
subrel R R.
Proof.
firstorder.
Qed.
(** ** Union of relations *)
Definition rel_union {A B} (R1 R2: rel A B): rel A B :=
fun x y => R1 x y \/ R2 x y.
Infix "∪" := rel_union (at level 50) : signature_scope.
Lemma rel_union_introl {A B} (R1 R2: rel A B):
subrel R1 (R1 ∪ R2).
Proof.
firstorder.
Qed.
Hint Extern 0 (subrel _ (_ ∪ _)) =>
eapply rel_union_introl : typeclass_instances.
Lemma rel_union_intror {A B} (R1 R2: rel A B):
subrel R2 (R1 ∪ R2).
Proof.
firstorder.
Qed.
Hint Extern 0 (subrel _ (_ ∪ _)) =>
eapply rel_union_introl : typeclass_instances.
Lemma rel_union_lub {A B} (R1 R2 R: rel A B):
subrel R1 R ->
subrel R2 R ->
subrel (R1 ∪ R2)%signature R.
Proof.
firstorder.
Qed.
Hint Extern 2 (subrel (_ ∪ _) _) =>
eapply rel_union_lub : typeclass_instances.
(** ** Intersection of relations *)
Definition rel_inter {A B} (R1 R2: rel A B): rel A B :=
fun x y => R1 x y /\ R2 x y.
Infix "∩" := rel_inter (at level 40) : signature_scope.
Lemma rel_inter_eliml {A B} (R1 R2: rel A B):
subrel (R1 ∩ R2) R1.
Proof.
firstorder.
Qed.
Hint Extern 0 (subrel (_ ∩ _) _) =>
eapply rel_inter_eliml : typeclass_instances.
Lemma rel_inter_elimr {A B} (R1 R2: rel A B):
subrel (R1 ∩ R2) R2.
Proof.
firstorder.
Qed.
Hint Extern 0 (subrel (_ ∩ _) _) =>
eapply rel_inter_elimr : typeclass_instances.
Lemma rel_inter_glb {A B} (R R1 R2: rel A B):
subrel R R1 ->
subrel R R2 ->
subrel R (R1 ∩ R2).
Proof.
firstorder.
Qed.
Hint Extern 2 (subrel _ (_ ∩ _)) =>
eapply rel_inter_glb : typeclass_instances.
Lemma rel_inter_refl {A} (R1 R2: rel A A):
Reflexive R1 ->
Reflexive R2 ->
Reflexive (R1 ∩ R2).
Proof.
intros H1 H2.
split; reflexivity.
Qed.
Hint Extern 2 (Reflexive (_ ∩ _)) =>
eapply rel_inter_refl : typeclass_instances.
Lemma rel_inter_trans {A} (R1 R2: rel A A):
Transitive R1 ->
Transitive R2 ->
Transitive (R1 ∩ R2).
Proof.
intros H1 H2 x y z [Hxy1 Hxy2] [Hyz1 Hyz2].
split; etransitivity; eassumption.
Qed.
Hint Extern 2 (Transitive (_ ∩ _)) =>
eapply rel_inter_trans : typeclass_instances.
Lemma rel_inter_sym {A} (R1 R2: rel A A):
Symmetric R1 ->
Symmetric R2 ->
Symmetric (R1 ∩ R2).
Proof.
intros H1 H2 x y [Hxy1 Hxy2].
split; symmetry; assumption.
Qed.
Hint Extern 2 (Symmetric (_ ∩ _)) =>
eapply rel_inter_sym : typeclass_instances.
Global Instance rel_inter_flip_sym {A} (R: rel A A):
Symmetric (R ∩ flip R).
Proof.
intros x y [Hxy Hyx].
split; assumption.
Qed.
(** ** The bottom and top relations *)
Definition rel_bot {A B}: rel A B :=
fun x y => False.
Notation "⊥" := rel_bot : signature_scope.
Definition rel_top {A B}: rel A B :=
fun x y => True.
Notation "⊤" := rel_top : signature_scope.
Hint Resolve (fun A B (x:A) (y:B) => I : rel_top x y).
(** ** Relation equivalence *)
Definition eqrel {A B}: rel (rel A B) (rel A B) :=
(subrel ∩ flip subrel).
Global Instance eqrel_equivalence A B:
Equivalence (@eqrel A B).
Proof.
unfold eqrel.
split; typeclasses eauto.
Qed.
(** * Relators for function types *)
(** With this infrastructure in place, we can define actual relators
that cover the commonly used type constructors. There are two broad
categories: those related to function types, and those derived from
inductive types. First, we introduce the core relators necessary to
develop the tactics that follow, namely those for function types.
In a later section of this file, I provide a more comprehensive
library which covers many of the basic inductive type constructors
as well. *)
(** As a convention, we name relators and the associated monotonicity
theorems by appending the suffix [_rel] to the name of original type
and those of its constructors. Likewise, we use the suffix [_subrel]
for monotonicity theorems that characterize the variance of
corresponding relators with respect to [subrel]. *)
(** ** Non-dependent function types *)
(** First, I define relators for non-dependent functions. This
generalizes [respectful]. *)
Definition arrow_rel {A1 A2 B1 B2}:
rel A1 A2 -> rel B1 B2 -> rel (A1 -> B1) (A2 -> B2) :=
fun RA RB f g => forall x y, RA x y -> RB (f x) (g y).
Notation "RA ==> RB" := (arrow_rel RA RB)
(at level 55, right associativity) : signature_scope.
Notation "RA ++> RB" := (arrow_rel RA RB)
(at level 55, right associativity) : signature_scope.
Notation "RA --> RB" := (arrow_rel (flip RA) RB)
(at level 55, right associativity) : signature_scope.
Global Instance arrow_subrel {A1 A2 B1 B2}:
Proper (subrel --> subrel ++> subrel) (@arrow_rel A1 A2 B1 B2).
Proof.
firstorder.
Qed.
(** ** Pointwise extension of a relation *)
(** One useful special case is the pointwise extension of a relation
on the domain to the function type. This is equivalent to [eq ==> R],
however with the formulation below we don't have consider two equal
elements of the domain. *)
Definition arrow_pointwise_rel A {B1 B2}:
rel B1 B2 -> rel (A -> B1) (A -> B2) :=
fun RB f g => forall a, RB (f a) (g a).
Notation "- ==> R" := (arrow_pointwise_rel _ R)
(at level 55, right associativity) : signature_scope.
Global Instance arrow_pointwise_subrel {A B1 B2}:
Proper (subrel ++> subrel) (@arrow_pointwise_rel A B1 B2).
Proof.
firstorder.
Qed.
Global Instance arrow_pointwise_eq_subrel {A B1 B2} (RB1 RB2: rel B1 B2):
subrel RB1 RB2 ->
subrel (- ==> RB1) (@eq A ==> RB2).
Proof.
intros HRB f g Hfg x y Hxy.
subst.
apply HRB.
apply Hfg.
Qed.
(** ** Dependent products *)
(** Now we consider the dependent case. The definition of [forall_rel]
is somewhat involved, but you can think of relating [f] and [g] in
the context of a structure-preserving transformation from a quiver
([V], [E]) to the quiver ([Type], [rel]). Like a functor, it has two
components: [FV] maps nodes to types, and [FE] maps edges to
relations. Then, [forall_rel FE f g] states that given an edge
[(e : E v1 v2)], the images [f v1] and [g v2] are related by the
corresponding relation [FE v1 v2 e]. We will write [forall_rel FE f g]
as [(∀ e : E v1 v2, FE[v1,v2,e]) f g]. Notice that this notation
binds [v1] and [v2] as well as [e].
If that makes no sense, you can think of specific source quivers. So
for instance, oftentimes we will want to use ([Type], [rel]) as the
source quiver too. This corresponds to parametric polymorphism. The
type of [Some] is [∀ A : Type, A -> option A]; the corresponding
logical relation is [∀ R : rel A1 A2, R ++> option_rel R]. Stating
that [Proper (∀ R : rel A1 A2, R ++> option_rel R) Some] means that,
given any relation [R] and elements [x1] and [x2], if [R] relates
[x1] and [x2], then [option_rel R] will relate [Some x1] and [Some x2].
Another example from [liblayers] is the quiver of our data-indexed
simulation relations [simrel : layerdata -> layerdata -> Type].
Here the structure-preserving transformations are our simulation
relation diagrams, which have types such as
[lsim : forall D1 D2, simrel D1 D2 -> rel (layer D1) (layer D2)] or
[psim : forall {D1 D2}, simrel D1 D2 -> rel (primsem D1) (primsem D2)].
Then, the monotonicity of a data-indexed function —
say, [foo: forall D : layerdata, layer D -> primsem D] —
can be expressed as
[Proper (∀ R : simrel D1 D2, siml D1 D2 R ++> simp D1 D2 R) foo].
This definition is the same as [respectful_hetero]. *)
Definition forall_rel {V1 V2} {E: V1->V2->Type} {FV1: V1->Type} {FV2: V2->Type}:
(forall v1 v2, E v1 v2 -> rel (FV1 v1) (FV2 v2)) ->
rel (forall v1, FV1 v1) (forall v2, FV2 v2) :=
fun FE f g =>
forall v1 v2 (e: E v1 v2), FE v1 v2 e (f v1) (g v2).
Notation "∀ α : E v1 v2 , R" := (forall_rel (E := E) (fun v1 v2 α => R))
(at level 200, α ident, E at level 7, v1 ident, v2 ident, right associativity)
: signature_scope.
Notation "∀ α : E , R" := (forall_rel (E := E) (fun _ _ α => R))
(at level 200, α ident, E at level 7, right associativity)
: signature_scope.
Notation "∀ α , R" := (forall_rel (fun _ _ α => R))
(at level 200, α ident, right associativity)
: signature_scope.
(** ** Dependent pointwise extension *)
(** Like we did for non-dependent functions, we can provide a simpler
definition for the special case where [E] is [eq]. *)
Definition forall_pointwise_rel {V: Type} {FV1 FV2: V -> Type}:
(forall v, rel (FV1 v) (FV2 v)) ->
rel (forall v, FV1 v) (forall v, FV2 v) :=
fun FE f g =>
forall v, FE v (f v) (g v).
Notation "∀ - , FE" := (forall_pointwise_rel (fun _ => FE))
(at level 200).
Notation "∀ - : 'rel' , FE" := (forall_pointwise_rel (fun _ => FE))
(at level 200).
Notation "∀ - : 'rel' v , FE" := (forall_pointwise_rel (fun v => FE))
(at level 200, a at level 0).
(** * Tactics *)
(** ** Resolution process *)
(** Now that we have a way to express and register the monotonicity
properties of various operators, we want to use them to answer the
queries generated by setoid rewriting and the [monotonicity] tactic.
That is, given a relation [R] with existential holes and a term [m],
use the registered theorems to prove [R m m], instantiating some of
the existential holes in [R]. All things being equal, we will want
those instantiations to yield the strongest theorem possible.
I use the following procedure, implemented below.
- First, choose an orientation. Since [R m m <-> (flip R) m m],
we need to consider both of those goals. Furthermore, we need to
normalize [flip R] so that [flip] is pushed inward and any
occurence of [flip (flip Q)] is reduced to [Q].
- Then, if [m] is an applied function, we may want to look for a
more general [Proper] theorem. So for instance, assuming that
[Q x x], we can use a theorem of the form [Proper (Q ++> R) f]
to solve a goal of the form [R (f x) (f x)].
- Once we've chosen an orientation and a degree of partial
application, we can finally look for a corresponding [Proper]
instance.
We may want to add more phases in the future, for instance to
generalize the goal using [subrel] instances.
It is most convenient to embed this process into the typeclass
resolution mechanism. In particular, nondeterministic choices come
in handy. But we don't want these resolution steps to be applied
arbitrarily. In order to enforce the sequential aspect, we use the
proxy class [ProperQuery], which is parametrized by a list of
processing phases remaining. *)
Inductive processing_phase :=
| proper_orientation
| proper_partial_app
| proper_partial_arg
| proper_subrel.
Class ProperQuery (φs: list processing_phase) {A} (R: rel A A) (m: A) :=
proper_query_outcome: Proper R m.
(** The different [processing_phase]s will peel themselves off the
list and generate subgoals to be handled by the next phase.
Ultimately the list becomes empty, and we look for a regular
instance of [Proper]. *)
Global Instance proper_query_finalize {A} (R: rel A A) (m: A):
Proper R m ->
ProperQuery nil R m.
Proof.
tauto.
Qed.
(** ** Flipping [Proper] goals *)
(** Instances of this class can be used to indicate how [flip] is to
be pushed to the inside of given relation operators. *)
Class FlipsTo {A B} (R: rel A B) (R': rel B A) :=
flips_to: eqrel (flip R) R'.
(** Catch-all, default instance. *)
Instance atom_flipsto {A B} (R: rel A B):
FlipsTo R (flip R) | 10.
Proof.
firstorder.
Qed.
(** Flipping twice. This instance is also used when the first argument
is an existential variable, so that the resulting relation is itself
as general as possible. *)
Instance flip_flipsto {A B} (R: rel A B):
FlipsTo (flip R) R.
Proof.
firstorder.
Qed.
(** Symmetric relations flip to themselves. *)
Instance:
forall {A} (R: rel A A) (HR: Symmetric R),
FlipsTo R R.
Proof.
firstorder.
Qed.
(** Instances for basic relators. *)
Instance arrow_flipsto {A1 A2 B1 B2} (RA: rel A1 A2) (RB: rel B1 B2) RA' RB':
FlipsTo RA RA' ->
FlipsTo RB RB' ->
FlipsTo (RA ++> RB) (RA' ++> RB').
Proof.
unfold FlipsTo, flip.
firstorder.
Qed.
(** The [proper_orientation] phase causes both orientations to be tried. *)
Global Instance proper_orientation_direct φs {A} (R: rel A A) (m: A):
ProperQuery φs R m ->
ProperQuery (proper_orientation::φs) R m.
Proof.
tauto.
Qed.
Lemma proper_orientation_flip φs {A} (R R': rel A A) (m: A):
FlipsTo R R' ->
ProperQuery φs R' m ->
ProperQuery (proper_orientation::φs) R m.
Proof.
firstorder.
Qed.
(** For [proper_orientation_flip] above, we only want to use the
first instance of [FlipsTo] found. *)
Ltac proper_orientation_flip :=
lazymatch goal with
| |- @ProperQuery _ ?A ?R ?m =>
let Rv := fresh in evar (Rv: rel A A);
let R' := eval red in Rv in clear Rv;
let H := fresh in
assert (H: FlipsTo R R') by typeclasses eauto;
eapply (@proper_orientation_flip _ A R R' m H);
clear H
end.
Hint Extern 2 (ProperQuery (proper_orientation::_) _ _) =>
proper_orientation_flip : typeclass_instances.
(** ** Partial applications *)
(** In many contexts, we need to show [Proper Rg (op a₁ … aₖ … aₙ)],
but what we acually have is a more general instance of
[Proper R (op a₁ … aₖ)]. If [R] is built up from reflexive relations
(or at least, relations for which the corresponding [aᵢ] is a proper
element), then the former can be obtained from the latter.
In [Coq.Classes.Morphisms], this is handled by [partial_application_tactic],
which applies [Reflexive_partial_app_morphism] on a goal of the form
[Proper R' (op x)] to obtain the new goal [Proper (R ==> R') op],
with [R] an existential variable to be unified against the [Proper]
instances of this form that are eventually found. However, we cannot
naively extend this strategy to obtain goals of the form
[Proper (forall_rel R) op]. We would need the many more existential
variables [V : Type], [E : V -> V -> Type], [e : E x x],
[FV : V -> Type], [R : forall v1 v2, E v1 v2 -> rel (FV v1) (FV v2)],
and what's more we would have to perform the higher-order
unification of [R'] — likely just some existential variable at this
point — against [?R ?v ?v ?e]. #<em>#Maybe#</em># this could be achieved
by going through another existential variable within the context of
a lambda abstraction such that [R] ≐ [(fun v1 v2 e => ?)] (if that
is even possible). However the resulting unification process would
be rather messy and undebuggable.
Instead, we start with whatever instances of [Proper (forall_rel R) op]
we can find, then try to unify [R'] against the corresponding
mostly-concrete [R x x ?e]. To this end, we use the following
intermediate class. *)
Class ProperApplies A (B: A -> Type) R (a: A) R' (m: forall a, B a) :=
proper_applies : Proper R m -> Proper R' (m a).
Ltac proper_applies :=
let H := fresh in
unfold ProperApplies, ProperDef;
intro H;
eapply H;
eapply (@proper_query_outcome (proper_partial_arg::nil)).
Hint Extern 1 (ProperApplies _ _ _ _ _ _) =>
proper_applies : typeclass_instances.
(** The processing phase [proper_partial_arg] is used for proving that
a given argument can be applied. It is our version of
[Morphisms.ProperProxy]. *)
Instance proper_partial_arg_eq φs {A} (m: A):
ProperQuery (proper_partial_arg::φs) eq m.
Proof.
firstorder.
Qed.
Instance proper_partial_arg_reflexive φs {A} (R: rel A A) (m: A):
Reflexive R ->
ProperQuery (proper_partial_arg::φs) R m.
Proof.
firstorder.
Qed.
Instance proper_partial_arg_default φs {A} (R: rel A A) (m: A):
NotEvar R ->
ProperQuery φs R m ->
ProperQuery (proper_partial_arg::φs) R m.
Proof.
firstorder.
Qed.
(** The [proper_partial_app] processing phase consists in using
[proper_applies] an arbitrary number of times. TODO: we may want to
use the [Params] class to limit the resulting search space to only
one possibility instead. *)
Global Instance proper_partial_app_bail φs {A} (R: rel A A) (m: A):
ProperQuery φs R m ->
ProperQuery (proper_partial_app::φs) R m.
Proof.
tauto.
Qed.
Lemma proper_partial_app_arg φs {A} (B: A -> Type) R a R' m:
@ProperQuery (proper_partial_app::φs) (forall a, B a) R m ->
ProperApplies A B R a R' m ->
@ProperQuery (proper_partial_app::φs) (B a) R' (m a).
Proof.
firstorder.
Qed.
(** When using [proper_partial_app_arg], the unification of the goal
against the subterm [(B a)] is problematic, because usually the type
will be an arbitrary expression where [a] appears freely. Therefore,
we first need to put the goal in the right form. The tactic
[dependent_type_of] recovers the type of a term that can be applied,
as a function of its first argument. *)
Ltac dependent_type_of f arg T :=
let A := type of arg in
let x := fresh "x" in evar (x : A);
let fx := fresh "fx" in set (fx := f x);
pattern x in fx;
lazymatch type of fx with ?TT _ => set (T := TT) end;
let y := eval red in x in unify y arg;
subst x fx.
Ltac proper_partial_app_arg :=
lazymatch goal with
| |- ProperQuery (proper_partial_app::?φs) ?R (?op ?arg) =>
let T := fresh "T" in dependent_type_of op arg T;
eapply (proper_partial_app_arg φs T _ arg R op);
subst T
end.
Hint Extern 2 (ProperQuery (proper_partial_app::_) _ _) =>
proper_partial_app_arg : typeclass_instances.
(** ** Using [subrel] *)
(** The processing step [proper_subrel] causes the search to be
extended to subrelations. The order of the [ProperQuery] and
[subrel] arguments is pretty critical: first, we go on and try to
find /any/ instance of [Proper] for [m]; then, we check to see if
the associated relation is a subrelation of the target one. *)
Global Instance do_proper_subrel {A} φs (R1 R2: rel A A) (m: A):
ProperQuery φs R1 m ->
subrel R1 R2 ->
ProperQuery (proper_subrel::φs) R2 m.
Proof.
firstorder.
Qed.
(** ** Compatibility with setoid rewriting *)
(** So far our system is isolated from the similar constructions in
[Coq.Classes.Morphisms]. The [convert_proper] tactic permits a
controlled interaction between them. It converts a [Morphisms.Proper]
goal into a [Proper] one, replacing legacy relators such as
[respectful] with their more general counterparts defined here.
This allows the setoid rewriting mechanism to use the morphisms we
define. *)
Notation rewrite_proper_query :=
(proper_orientation :: proper_partial_app :: proper_subrel :: nil)
(only parsing).
Ltac convert_proper :=
repeat
match goal with
| |- appcontext C[respectful ?R1 ?R2] =>
let T' := context C[R1 ==> R2] in change T'
| |- appcontext C[forall_relation ?R] =>
let T' := context C[∀ -, R] in change T'
| |- Morphisms.Proper ?R ?m =>
change (ProperQuery rewrite_proper_query R m)
end.
(** We want [convert_proper] to be used for the initial [Proper] goal,
but we're not really interested in having it applied to the subgoals
generated by the original process in [Coq.Classes.Morphisms], since
we have our own. The following tactic attempts to detect and reject
cases where some work has already been done. *)
Ltac use_convert_proper :=
match goal with
| _ : normalization_done |- _ =>
fail 1
| H : apply_subrelation |- _ =>
clear H;
progress convert_proper
end.
Hint Extern 1 (Morphisms.Proper _ _) =>
use_convert_proper : typeclass_instances.
(** The monotonicity of transitive relations is sometimes needed to
solve the goals generated by setoid rewriting. *)
Instance transitive_proper {A} (R: rel A A):
Transitive R ->
Proper (R --> R ++> impl) R.
Proof.
firstorder.
Qed.
(** ** The [monotonicity] tactic *)
(** The purpose of the [monotonicity] tactic is to automatically
select and apply a theorem of the form [Proper ?R ?m] in order to
make progress when the goal is an applied relation. Compared with
setoid rewriting, [monotonicity] is less powerful, but more direct
and simple. This means it is easier to debug, and it can seamlessly
handle dependent types and heterogenous relations.
At the moment, [monotonicity] does not use any of the preprocessing
phases. *)
Ltac monotonicity :=
let rec apply_proper_prf m1 m2 :=
match m1 with
| m2 =>
let A := type of m1 in
let Rv := fresh "R" in evar (Rv: rel A A);
let Re := eval red in Rv in clear Rv;
let H := fresh in
assert (H: ProperQuery nil Re m1) by typeclasses eauto;
eapply H;
clear H
| ?f ?x1 =>
match m2 with
| ?g ?x2 => apply_proper_prf f g
end
end in
lazymatch goal with
| |- ?R ?m1 ?m2 =>
apply_proper_prf m1 m2
end.
(** Our version of [Morphisms.f_equiv]. *)
Ltac f_equiv :=
repeat monotonicity.
(** Our version of [Morphisms.solve_proper]. Note that we are somewhat
parcimonious with introductions because we don't want to cause undue
unfoldings. For instance, if we define the relation [R1] from [R2]
as [R1 x y := forall i, R2 (get i x) (get i y)], we may create a
situation where applying the monotonicity theorem for [get] on a
goal of the form [R2 (get i x) (get i y)] produces a subgoal of the
form [R1 x y], but then an introduction would get us back to where
we started. So we limit them to well-defined cases. *)
Ltac solve_monotonic_tac t :=
repeat
match goal with
| |- Proper _ _ => red
| |- flip _ _ _ => red
| |- _ => progress t
| |- _ _ _ => monotonicity
| |- (_ --> _) _ _ => let H := fresh in intros ? ? H; red in H
| |- (_ ++> _) _ _ => intros ? ? ?
| |- (- ==> _) _ _ => intro
| |- (∀ _, _) _ _ => intros ? ? ?
| |- (∀ -, _) _ _ => intro
| |- forall _, _ => intro
end.
Tactic Notation "solve_monotonic" :=
solve_monotonic_tac ltac:(eassumption || congruence || (now econstructor)).
Tactic Notation "solve_monotonic" tactic(t) :=
solve_monotonic_tac ltac:(eassumption || congruence || (now econstructor)|| t).
(** ** Exploiting [foo_subrel] instances *)
(** Although we declared [Proper] instances for the relation
constructors we defined, so far the usefulness of these instances
has been limited. But now we can use them in conjunction with our
[monotonicity] tactic to break up [subrel] goals along the structure
of the relations being considered. *)
Hint Extern 5 (subrel _ _) =>
monotonicity; unfold flip : typeclass_instances.
(** Furthermore, the following instance of [subrel] enables the use of
[foo_subrel] instances for rewriting along within applied relations.
So that for instance, a hypothesis [H: subrel R1 R2] can be used for
rewriting in a goal of the form [(R1 * R1' ++> R) x y]. *)
Instance subrel_pointwise_subrel {A B}:
subrel (@subrel A B) (eq ==> eq ==> impl).
Proof.
intros R1 R2 HR x1 x2 Hx y1 y2 Hy H; subst.
eauto.
Qed.
(** * More relators for basic types *)
(** ** Inductive types *)
(** For inductive types, there is a systematic way of converting their
definition into that of the corresponding relator. Where the
original inductive definition quantifies over types, the
corresponding relator will quantify over pairs of types and
relations between them. Then, the constructors of the relator will
essentially be [Proper] instances for the original constructors.
In other words, the resulting relation will be the smallest one such
that the constructors are order-preserving. *)
(** *** Nullary type constructors *)
(** As a proof-of-concept, we start with the most elementary types
[Empty_set] and [unit], which can be considered as nullary type
constructors related to [sum] and [prod] below. *)
Inductive Empty_set_rel: rel Empty_set Empty_set := .
Inductive unit_rel: rel unit unit :=
tt_rel: Proper unit_rel tt.
Global Existing Instance tt_rel.
(** *** Sum types *)
(** The definition of [sum_rel] could look something like this:
<<
Inductive sum_rel:
forall {A1 A2 B1 B2}, rel A1 A2 -> rel B1 B2 -> rel (A1+B1) (A2+B2):=
| inl_rel: Proper (∀ RA : rel, ∀ RB : rel, RA ++> sum_rel RA RB) (@inl)
| inr_rel: Proper (∀ RA : rel, ∀ RB : rel, RB ++> sum_rel RA RB) (@inr).
>>
However, to minimize the need for [inversion]s we want to keep as
many arguments as possible as parameters of the inductive type. *)
Inductive sum_rel {A1 A2} RA {B1 B2} RB: rel (A1 + B1) (A2 + B2) :=
| inl_rel_def: (RA ++> sum_rel RA RB) (@inl A1 B1) (@inl A2 B2)
| inr_rel_def: (RB ++> sum_rel RA RB) (@inr A1 B1) (@inr A2 B2).
Infix "+" := sum_rel : signature_scope.
(** Since it is not possible to retype the constructors after the
fact, we use the [_def] suffix when defining them, then redeclare
a corresponding, full-blown [Proper] instance. *)
Local Instance inl_rel:
Proper (∀ RA, ∀ RB, RA ++> RA + RB) (@inl).
Proof.
exact @inl_rel_def.
Qed.
Local Instance inr_rel:
Proper (∀ RA, ∀ RB, RB ++> RA + RB) (@inr).
Proof.
exact @inr_rel_def.
Qed.
Global Instance sum_subrel:
Proper (∀ -, ∀ -, subrel ++> ∀ -, ∀ -, subrel ++> subrel) (@sum_rel).
Proof.
intros A1 A2 RA1 RA2 HRA B1 B2 RB1 RB2 HRB.
intros x1 x2 Hx.
destruct Hx; constructor; eauto.
Qed.
Global Instance sum_rel_refl {A B} (R1: rel A A) (R2: rel B B):
Reflexive R1 -> Reflexive R2 -> Reflexive (R1 + R2).
Proof.
intros H1 H2 x.
destruct x; constructor; reflexivity.
Qed.
Global Instance sum_rel_trans {A B} (R1: rel A A) (R2: rel B B):
Transitive R1 -> Transitive R2 -> Transitive (R1 + R2).
Proof.
intros H1 H2 x y z Hxy Hyz.
destruct Hxy; inversion Hyz; constructor; etransitivity; eassumption.
Qed.
Global Instance sum_rel_sym {A B} (R1: rel A A) (R2: rel B B):
Symmetric R1 -> Symmetric R2 -> Symmetric (R1 + R2).
Proof.
intros H1 H2 x y Hxy.
destruct Hxy; constructor; symmetry; eassumption.
Qed.
Global Instance sum_rel_preorder {A B} (R1: rel A A) (R2: rel B B):
PreOrder R1 -> PreOrder R2 -> PreOrder (R1 + R2).
Proof.
split; typeclasses eauto.
Qed.
Hint Extern 0 (Proper _ (@inl)) => exact inl_rel : typeclass_instances.
Hint Extern 0 (Proper _ (@inr)) => exact inr_rel : typeclass_instances.
(** *** Pairs *)
Inductive prod_rel {A1 A2} RA {B1 B2} RB: rel (A1 * B1) (A2 * B2):=
| pair_rel_def: (RA ++> RB ++> prod_rel RA RB) (@pair A1 B1) (@pair A2 B2).
Infix "*" := prod_rel : signature_scope.
Local Instance pair_rel:
Proper (∀ RA, ∀ RB, RA ++> RB ++> RA * RB) (@pair).
Proof.
exact @pair_rel_def.
Qed.
Local Instance fst_rel:
Proper (∀ RA, ∀ RB, RA * RB ==> RA) (@fst).
Proof.
intros A1 A2 RA B1 B2 RB.
intros _ _ [a1 a2 Ha b1 b2 Hb].
assumption.
Qed.
Local Instance snd_rel:
Proper (∀ RA, ∀ RB, RA * RB ==> RB) (@snd).
Proof.
intros A1 A2 RA B1 B2 RB.
intros _ _ [a1 a2 Ha b1 b2 Hb].
assumption.
Qed.
Global Instance prod_rel_refl {A B} (R1: rel A A) (R2: rel B B):
Reflexive R1 -> Reflexive R2 -> Reflexive (R1 * R2).
Proof.
intros H1 H2 x.
destruct x; constructor; reflexivity.
Qed.
Global Instance prod_rel_trans {A B} (R1: rel A A) (R2: rel B B):
Transitive R1 -> Transitive R2 -> Transitive (R1 * R2).
Proof.
intros H1 H2 x y z Hxy Hyz.
destruct Hxy; inversion Hyz; constructor; etransitivity; eassumption.
Qed.
Global Instance prod_rel_sym {A B} (R1: rel A A) (R2: rel B B):
Symmetric R1 -> Symmetric R2 -> Symmetric (R1 * R2).
Proof.
intros H1 H2 x y Hxy.
destruct Hxy; constructor; symmetry; eassumption.
Qed.
Global Instance prod_rel_preorder {A B} (R1: rel A A) (R2: rel B B):
PreOrder R1 -> PreOrder R2 -> PreOrder (R1 * R2).
Proof.
split; typeclasses eauto.
Qed.
Hint Extern 0 (Proper _ (@pair)) => exact pair_rel : typeclass_instances.
Hint Extern 0 (Proper _ (@fst)) => exact fst_rel : typeclass_instances.
Hint Extern 0 (Proper _ (@snd)) => exact snd_rel : typeclass_instances.
(** *** Option types *)
Inductive option_rel {A1 A2} (RA: rel A1 A2): rel (option A1) (option A2) :=
| Some_rel_def: (RA ++> option_rel RA) (@Some A1) (@Some A2)
| None_rel_def: option_rel RA (@None A1) (@None A2).
Local Instance Some_rel:
Proper (∀ R : rel A1 A2, R ++> option_rel R) (@Some).
Proof.
exact @Some_rel_def.
Qed.
Local Instance None_rel:
Proper (∀ R, option_rel R) (@None).
Proof.
exact @None_rel_def.
Qed.
Global Instance option_subrel:
Proper (∀ -, ∀ -, subrel ++> subrel) (@option_rel).
Proof.
intros A1 A2 RA1 RA2 HRA.
intros x1 x2 Hx.
destruct Hx; constructor; eauto.
Qed.
Hint Extern 0 (Proper _ (@Some)) => exact Some_rel : typeclass_instances.
Hint Extern 0 (Proper _ (@None)) => exact None_rel : typeclass_instances.
(** *** Lists *)
Inductive list_rel {A1 A2} (R: rel A1 A2): rel (list A1) (list A2) :=
| nil_rel_def: (list_rel R) (@nil A1) (@nil A2)
| cons_rel_def: (R ++> list_rel R ++> list_rel R) (@cons A1) (@cons A2).
Local Instance nil_rel:
Proper (∀ R, list_rel R) (@nil).
Proof.
exact @nil_rel_def.
Qed.
Local Instance cons_rel:
Proper (∀ R, R ++> list_rel R ++> list_rel R) (@cons).
Proof.
exact @cons_rel_def.
Qed.
Hint Extern 0 (Proper _ (@nil)) => exact nil_rel : typeclass_instances.
Hint Extern 0 (Proper _ (@cons)) => exact cons_rel : typeclass_instances.
Global Instance app_rel:
Proper (∀ R : rel, list_rel R ++> list_rel R ++> list_rel R) (@app).
Proof.
intros A1 A2 R l1 l2 Hl.
induction Hl as [ | x1 x2 Hx l1 l2 Hl IHl]; simpl.
* firstorder.
* solve_monotonic.
apply IHl.
assumption.
Qed.
(** * Tests *)
(** ** Partial applications *)
Goal forall A (a1 a2: A) B (b1 b2: B) (RA: rel A A), True.
Proof.
intros.
evar (T: Type); evar (R: rel T T); subst T;
assert (H1: ProperQuery (proper_partial_app::nil) R (@pair A A a1)); subst R.
typeclasses eauto.
instantiate (1 := RA) in H1.
evar (T: Type); evar (R: rel T T); subst T;
assert (H2: ProperQuery (proper_partial_app::nil) R (@pair A)); subst R.
typeclasses eauto.
instantiate (1 := RA) in H2.
evar (T: Type); evar (R: rel T T); subst T;
assert (H3: ProperQuery (proper_partial_app::nil) R (@inl A B a2)); subst R.
typeclasses eauto.
instantiate (1 := eq) in H3.
exact I.
Qed.
(** ** Setoid rewriting *)
Goal
forall A (a b: A) `(HR: Equivalence A) (H: R a b),
sum_rel R R (inl a) (inl b).
Proof.
intros.
rewrite H.
rewrite <- H.
reflexivity.
Qed.
(** This test checks that [transitive_proper] is used as expected. *)
Goal
forall A (op: A -> A -> A) (R: rel A A) (x y z: A),
Proper (R ++> R ++> R) op ->
PreOrder R ->
R (op y x) (op x y) ->
R (op (op z y) x) (op z (op x y)).
Proof.
intros A op R x y z Hop HR H.
rewrite <- H.
(** For your debugging convenience, here are the goals generated by
the [rewrite] above. *)
evar (RE: rel A A);
assert (Morphisms.Proper (RE ==> flip impl) (R (op (op z y) x))
/\ Morphisms.Proper (flip R ==> RE) (op z)); subst RE.
{
split.
* convert_proper.
proper_orientation_flip.
proper_partial_app_arg.
eapply proper_partial_app_bail.
eapply transitive_proper.
typeclasses eauto.
proper_applies.
typeclasses eauto.
* convert_proper.
typeclasses eauto.
}
Abort.
(** ** Monotonicity tactics *)
Goal
forall A (a b: A) (R: rel A A) (H: R a b),
let f (x y: A * A) := (@pair (A+A) (A+A) (inr (fst x)) (inl (snd y))) in
Proper (R * ⊤ ++> ⊤ * R ++> (⊥ + R) * (R + ⊥)) f.
Proof.
intros; unfold f.
solve_monotonic.
Qed.
Goal
forall {A1 A2 B1 B2} (R1 R1': rel A1 A2) (R2 R2': rel B1 B2),
subrel R1' R1 ->
subrel R2 R2' ->
subrel (R1 ++> R2) (R1' ++> R2').
Proof.
solve_monotonic.
Qed.
(** ** Using [foo_subrel] instances *)
Goal
forall A1 A2 B1 B2 C1 C2 (R1 R2: rel A1 A2) (R1': rel B1 B2) (R: rel C1 C2),
subrel R1 R2 ->
forall x y,
(R2 ++> R) x y ->
(R1 ++> R) x y.
Proof.
intros A1 A2 B1 B2 C1 C2 R1 R2 R1' R HR12 x y H.
rewrite HR12.
assumption.
Qed.
(** FIXME: this should work as well. *)
Goal
forall A1 A2 B1 B2 C1 C2 (R1 R2: rel A1 A2) (R1': rel B1 B2) (R: rel C1 C2),
subrel R1 R2 ->
forall x y,
(R2 * R1' ++> R) x y ->
(R1 * R1' ++> R) x y.
Proof.
intros A1 A2 B1 B2 C1 C2 R1 R2 R1' R HR12 x y H.
try rewrite HR12.
Abort.
|
data List' a = Nil | Cons a (List' a)
-- Generated with `:gd 4 mapList'`
mapList' : ((1 x : a) -> b) -> (1 xs : List' a) -> List' b
mapList' f [] = []
mapList' f (Cons x y) = Cons (f x) (mapList' f y)
data Tree1 a = Nil1 | Node1 a (Tree1 a) (Tree1 a)
mapTree1 : ((1 x : a) -> b) -> (1 t : Tree1 a) -> Tree1 b
data Tree2 a = Nil2 | Node2 a (List' (Tree2 a))
-- TODO: Fix not entirly appropriate definition (nulls list of Node2)
mapTree2 : ((1 x : a) -> b) -> (1 t : Tree2 a) -> Tree2 b
|
/**
* This file is part of the "libterminal" project
* Copyright (c) 2019-2020 Christian Parpart <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <text_shaper/font.h>
#include <fmt/format.h>
#include <gsl/span>
#include <gsl/span_ext>
#include <optional>
#include <variant>
#include <vector>
namespace text
{
/// Holds the system path to a font file.
struct font_path
{
std::string value;
};
/// Holds a view into the contents of a font file.
struct font_memory_ref
{
std::string identifier; //!< a unique identifier for this font
gsl::span<uint8_t> data; //!< font file contents (non-owned)
};
/// Represents a font source (such as file path or memory).
using font_source = std::variant<font_path, font_memory_ref>;
/// Holds a list of fonts.
using font_source_list = std::vector<font_source>;
/**
* Font location API.
*
* Used for locating fonts and fallback fonts to be used
* for text shaping and glyph rendering.
*/
class font_locator
{
public:
virtual ~font_locator() = default;
/**
* Enumerates all available fonts.
*/
virtual font_source_list all() = 0;
/**
* Locates the font matching the given description the best
* and an ordered list of fallback fonts.
*/
virtual font_source_list locate(font_description const& description) = 0;
/**
* Resolves the given codepoint sequence into an ordered list of
* possible fonts that can be used for text shaping the given
* codepoint sequence.
*/
virtual font_source_list resolve(gsl::span<const char32_t> codepoints) = 0;
};
} // namespace text
namespace fmt // {{{
{
template <>
struct formatter<text::font_path>
{
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return ctx.begin();
}
template <typename FormatContext>
auto format(text::font_path path, FormatContext& ctx)
{
return fmt::format_to(ctx.out(), "path {}", path.value);
}
};
template <>
struct formatter<text::font_memory_ref>
{
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return ctx.begin();
}
template <typename FormatContext>
auto format(text::font_memory_ref ref, FormatContext& ctx)
{
return fmt::format_to(ctx.out(), "in-memory: {}", ref.identifier);
}
};
template <>
struct formatter<text::font_source>
{
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return ctx.begin();
}
template <typename FormatContext>
auto format(text::font_source source, FormatContext& ctx)
{
if (std::holds_alternative<text::font_path>(source))
return fmt::format_to(ctx.out(), "{}", std::get<text::font_path>(source));
if (std::holds_alternative<text::font_memory_ref>(source))
return fmt::format_to(ctx.out(), "{}", std::get<text::font_memory_ref>(source));
return fmt::format_to(ctx.out(), "UNKNOWN SOURCE");
}
};
} // namespace fmt
|
Turn this dessert into a quick and satisfying breakfast or lunch.
Toss together the blueberries, raspberries, and orange liqueur in a small bowl; set aside.
Combine the orange juice, sugar, and cornstarch in a small saucepan; add the blueberry mixture. Cook, stirring, until the mixture boils and thickens, about 1 minute. Remove the saucepan from the heat and let cool slightly.
Place a 1/2-cup scoop of the frozen yogurt into each of 4 goblets or dessert dishes. Spoon about 1/4 cup of the berry mixture on top and serve at once. Yields 1/2 cup frozen yogurt and 1/4 cup berry mixture per serving.
Spoon vanilla fat-free yogurt (not frozen) into a goblet, and alternately layer with the berry mixture and reduced-fat granola. Add fresh sliced peaches or nectarines, if you like. |
example (p q r s : Prop) :
p → q → r → s → (p ∧ q) ∧ (r ∧ s ∧ p) ∧ (p ∧ r ∧ q) :=
begin
intros; repeat { constructor }; assumption
end |
function default_methods!(mt)
mt["builtins.set"] = Set
mt["builtins.bytes"] = () -> b""
mt["builtins.list"] = Base.vect
mt["collections.defaultdict"] = DataStructures.DefaultDict
mt["codecs.encode"] = (s, c) -> codeunits(s)
_setentry!(mt.head, mt["builtins"], "__builtin__")
_setentry!(mt.head, mt["codecs"], "_codecs")
mt["__julia__.Set"] = "builtins.set"
mt["__julia__.Base.CodeUnits"] = "codecs.encode"
mt["__julia__.__py__.bytes"] = "builtins.bytes"
mt
end
|
function PDt(option, up)
%PDT detects PPG pulse peaks in PPG signals.
% PDt(option, up)
%
% Inputs:
% option the option which has led to this function being used
% up universal parameters structure
%
% Outputs:
% ...
%
fprintf('\n--- Detecting Pulse Peaks ');
log_int_respSig = 1; % Has value 1 unless this is a final respiratory signal
for subj = up.paramSet.subj_list
%% Skip if this processing has been done previously
iden_resp_sig_file_ending
savepath = [up.paths.data_save_folder, num2str(subj), ending];
filecontents = whos('-file', savepath);
var_names = extractfield(filecontents, 'name');
temp = strfind(var_names, [option(1:3), up.paths.filenames.elim_vhf]); rel_els = find(~cellfun(@isempty,temp));
rel_var_names = var_names(rel_els);
for rel_var_name_no = 1 : length(rel_var_names)
for current_opt_no = 1 : length(up.al.options.PDt)
eval(['save_name = ''' option(1:3), up.paths.filenames.pulse_peaks, up.al.options.PDt{current_opt_no}, rel_var_names{rel_var_name_no}(4:end) ''';']);
exist_log = check_exists(savepath, save_name);
if exist_log
continue
end
%% Load relevant data
loadpath = [up.paths.data_save_folder, num2str(subj), up.paths.filenames.int_respSigs];
rel_name = rel_var_names{rel_var_name_no};
load(loadpath, rel_name);
eval(['s = ' rel_name ';']);
eval(['fs = ' rel_name '.fs;']);
%% High-pass filter data for peak detection
s_filt = elim_sub_cardiac(s, up);
%% Detect Pulse Peaks in HPF'd version
[peaks,onsets] = feval(up.al.options.PDt{current_opt_no}, s_filt, fs, up);
eval([save_name '.fs = fs;']);
% Identify Pulse Peaks in original version
eval([save_name '.p.v = s.v(peaks);']);
eval([save_name '.p.t = s.t(peaks);']);
eval([save_name '.tr.v = s.v(onsets);']);
eval([save_name '.tr.t = s.t(onsets);']);
% Identify start and end times of raw data (for resampling)
eval([save_name '.timings.t_start = s.t(1);']);
eval([save_name '.timings.t_end = s.t(end);']);
%% Save processed data
save_or_append_data
clear peaks onsets s_filt s fs temp
end
end
end
end
function [peaks,onsets] = IMS(s_filt,fs,up)
[peaks,onsets,artifs] = adaptPulseSegment(s_filt.v,fs);
end |
\section{Billing}
\label{sec:billing}
\subsection{Viewing your billing information}
\label{sec:billing-view}
To view your account billing information, \action{tap} on the \keys{Settings} button on the \quicknav.
Then, while on \Screenshot{Settings} (Figure~\ref{fig:settings}), \action{tap} on \keys{Billing} button, you will be presented with your current billing information (Figure~\ref{fig:billing}). To download a copy of an invoice, \action{tap} on the \appbutton{invoice} button. This will download a copy of an invoice to your device. If any billing information is incorrect, see Section ~\ref{sec:troubleshoot} on troubleshooting.
\subsection{Update your billing information}
\label{sec:billing-update}
To update account billing information, \action{tap} on the \keys{Settings} button on the \quicknav. Then, while on \Screenshot{Settings} (Figure~\ref{fig:settings}), \action{tap} on the \keys{Billing} button, you will be presented with your current billing information (Figure~\ref{fig:billing}).
Then, while on \Screenshot{Billing} (Figure~\ref{fig:billing}), \action{tap} on the \appbutton{creditcard} button, you will be presented with your current credit card (Figure~\ref{fig:payment}). \action{Enter} your changes to \textvar{First Name}, \textvar{Last Name}, \textvar{Card Number}, \textvar{Zip Code} and \textvar{Expiration Date} fields. After you are satisfied with your changes, \action{tap} on the \keys{Save} button to save your changes.
You will be emailed a confirmation that your billing information has been changed.
\subsection{Downloading your invoices}
\label{sec:billing-invoices}
\subsection{Paying for your account services}
\label{sec:billing-paying}
Paying for your account happens automatically. You will need to set your billing information to use \Friending{}. If \Friending{} is unable to bill your account, you will be unable to use \Friending{} until your billing information is corrected. You will be billed on a monthly basis for your account.
You can see your billing information as specified in section ~\ref{sec:billing-view}. |
section \<open>Execution rules for threads\<close>
theory KPL_execution_thread imports
KPL_state
begin
text \<open>Evaluate a local expression down to a word\<close>
fun eval_word :: "local_expr \<Rightarrow> thread_state \<Rightarrow> word"
where
"eval_word (Loc (Var v)) \<tau> = l \<tau> (Inl v)"
(* eval_word (Loc (Name n)) \<tau> = undefined *)
| "eval_word Lid \<tau> = l \<tau> LID"
| "eval_word Gid \<tau> = l \<tau> GID"
| "eval_word eTrue \<tau> = 1"
| "eval_word (e1 \<and>* e2) \<tau> =
(eval_word e1 \<tau> * eval_word e2 \<tau>)"
| "eval_word (\<not>* e) \<tau> = (if eval_word e \<tau> = 0 then 1 else 0)"
text \<open>Evaluate a local expression down to a boolean\<close>
fun eval_bool :: "local_expr \<Rightarrow> thread_state \<Rightarrow> bool"
where
"eval_bool e \<tau> = (eval_word e \<tau> \<noteq> 0)"
text \<open>Abstraction level: none, equality abstraction, or adversarial abstraction\<close>
datatype abs_level = No_Abst | Eq_Abst | Adv_Abst
text \<open>The rules of Figure 4, plus two additional rules
for adversarial abstraction (Fig 7b)\<close>
inductive step_t
:: "abs_level \<Rightarrow> (thread_state \<times> pred_basic_stmt) \<Rightarrow> thread_state \<Rightarrow> bool"
where
T_Disabled:
"\<not> (eval_bool p \<tau>) \<Longrightarrow> step_t a (\<tau>, (b, p)) \<tau>"
| T_Assign:
"\<lbrakk> eval_bool p \<tau> ; l' = (l \<tau>) (Inl v := eval_word e \<tau>) \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Assign (Var v) e, p)) (\<tau> (| l := l' |))"
| T_Read:
"\<lbrakk> eval_bool p \<tau> ; l' = (l \<tau>) (Inl v := sh \<tau> (eval_word e \<tau>)) ;
R' = R \<tau> \<union> { eval_word e \<tau> } ; a \<in> {No_Abst, Eq_Abst} \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Read (Var v) e, p)) (\<tau> (| l := l', R := R' |))"
| T_Write:
"\<lbrakk> eval_bool p \<tau> ;
sh' = (sh \<tau>) (eval_word e1 \<tau> := eval_word e2 \<tau>) ;
W' = W \<tau> \<union> { eval_word e1 \<tau> } ; a \<in> {No_Abst, Eq_Abst} \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Write e1 e2, p)) (\<tau> (| sh := sh', W := W' |))"
| T_Read_Adv:
"\<lbrakk> eval_bool p \<tau> ; l' = (l \<tau>) (Inl v := asterisk) ;
R' = R \<tau> \<union> { eval_word e \<tau> } \<rbrakk>
\<Longrightarrow> step_t Adv_Abst (\<tau>, (Read (Var v) e, p)) (\<tau> (| l := l', R := R' |))"
| T_Write_Adv:
"\<lbrakk> eval_bool p \<tau> ; W' = W \<tau> \<union> { eval_word e1 \<tau> } \<rbrakk>
\<Longrightarrow> step_t Adv_Abst (\<tau>, (Write e1 e2, p)) (\<tau> (| \<^cancel>\<open>sh := sh',\<close> W := W' |))"
text \<open>Rephrasing \<open>T_Assign\<close> to make it more usable\<close>
lemma T_Assign_helper:
"\<lbrakk> eval_bool p \<tau> ; l' = (l \<tau>) (Inl v := eval_word e \<tau>) ; \<tau>' = \<tau> (| l := l' |) \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Assign (Var v) e, p)) \<tau>'"
by (auto simp add: step_t.T_Assign)
text \<open>Rephrasing \<open>T_Read\<close> to make it more usable\<close>
lemma T_Read_helper:
"\<lbrakk> eval_bool p \<tau> ; l' = (l \<tau>) (Inl v := sh \<tau> (eval_word e \<tau>)) ;
R' = R \<tau> \<union> { eval_word e \<tau> } ; a \<in> {No_Abst, Eq_Abst} ;
\<tau>' = \<tau> (| l := l', R := R' |) \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Read (Var v) e, p)) \<tau>'"
by (auto simp add: step_t.T_Read)
text \<open>Rephrasing \<open>T_Write\<close> to make it more usable\<close>
lemma T_Write_helper:
"\<lbrakk> eval_bool p \<tau> ;
sh' = (sh \<tau>) (eval_word e1 \<tau> := eval_word e2 \<tau>) ;
W' = W \<tau> \<union> { eval_word e1 \<tau> } ; a \<in> {No_Abst, Eq_Abst} ;
\<tau>' = \<tau> (| sh := sh', W := W' |) \<rbrakk>
\<Longrightarrow> step_t a (\<tau>, (Write e1 e2, p)) \<tau>'"
by (auto simp add: step_t.T_Write)
end
|
\cleardoublepage
\vspace*{0.5in}
\singlespacing
\begin{center}
\section{Results}
\label{sec:result}
\end{center}
\doublespacing
|
Fantastic New Student Development in the Baltic Triangle, Liverpool!
Students! Unfortunately all our existing town properties have now been taken.
However, we are delighted to be able to offer a new boutique development in the Baltic Triangle.
The houses will be available from September 2016 so there will be nothing to pay for the summer. Alternative accommodation is available for this period if required.
Please contact us for more information and to arrange viewings – this fantastic student development will not be available for long! |
foo : Int -> Int
foo x with (x + 1)
foo x | y = y + x
foo2 : Int
foo2 = foo 5
|
theory Exercise6
imports Main
begin
datatype 'a tree = Tip | Node "'a tree" 'a "'a tree"
fun contents :: "'a tree \<Rightarrow> 'a list" where
"contents Tip = Nil"
| "contents (Node l a r) = (contents l) @ [a] @ (contents r)"
fun treesum :: "nat tree \<Rightarrow> nat" where
"treesum Tip = 0"
| "treesum (Node l a r) = (treesum l) + a + (treesum r)"
fun listsum :: "nat list \<Rightarrow> nat" where
"listsum Nil = 0"
| "listsum (Cons x xs) = x + (listsum xs)"
lemma shallow_treesum [simp]: "treesum (Node Tip a Tip) = a"
apply (induction a)
apply (auto)
done
lemma zero_treesum [simp]: "treesum (Node l 0 r) = (treesum l) + (treesum r)"
apply (induction l)
apply (auto)
done
lemma suc_treesum [simp]: "treesum (Node l (Suc a) r) = Suc (treesum (Node l a r))"
apply (induction a)
apply (auto)
done
lemma listsum_app_distributivity [simp]: "listsum (xs @ ys) = (listsum xs) + (listsum ys)"
apply (induction xs)
apply (auto)
done
theorem treesum_is_contents_sum [simp]: "treesum t = listsum (contents t)"
apply (induction t rule: treesum.induct)
apply (auto)
done
end |
(* File: Elimination_Module.thy
Copyright 2021 Karlsruhe Institute of Technology (KIT)
*)
\<^marker>\<open>creator "Stephan Bohr, Karlsruhe Institute of Technology (KIT)"\<close>
\<^marker>\<open>contributor "Michael Kirsten, Karlsruhe Institute of Technology (KIT)"\<close>
section \<open>Elimination Module\<close>
theory Elimination_Module
imports Evaluation_Function
Electoral_Module
begin
text
\<open>This is the elimination module. It rejects a set of alternatives only if these
are not all alternatives. The alternatives potentially to be rejected are put
in a so-called elimination set. These are all alternatives that score below
a preset threshold value that depends on the specific voting rule.\<close>
subsection \<open>Definition\<close>
type_synonym Threshold_Value = nat
type_synonym Threshold_Relation = "nat \<Rightarrow> nat \<Rightarrow> bool"
type_synonym 'a Electoral_Set = "'a set \<Rightarrow> 'a Profile \<Rightarrow> 'a Pair_Vectors \<Rightarrow> 'a set"
fun elimination_set :: "'a Evaluation_Function \<Rightarrow> Threshold_Value \<Rightarrow>
Threshold_Relation \<Rightarrow> 'a Electoral_Set" where
"elimination_set e t r A p vs = {a \<in> A . r (e a A p vs) t }"
fun elimination_module :: "'a Evaluation_Function \<Rightarrow> Threshold_Value \<Rightarrow>
Threshold_Relation \<Rightarrow> 'a Electoral_Module" where
"elimination_module e t r A p vs =
(if (elimination_set e t r A p vs) \<noteq> A
then ({}, (elimination_set e t r A p vs), A - (elimination_set e t r A p vs))
else ({},{},A))"
subsection \<open>Common Eliminators\<close>
fun less_eliminator :: "'a Evaluation_Function \<Rightarrow> Threshold_Value \<Rightarrow>
'a Electoral_Module" where
"less_eliminator e t A p vs = elimination_module e t (<) A p vs"
fun max_eliminator :: "'a Evaluation_Function \<Rightarrow> 'a Electoral_Module" where
"max_eliminator e A p vs =
less_eliminator e (Max {e x A p vs | x. x \<in> A}) A p vs"
fun leq_eliminator :: "'a Evaluation_Function \<Rightarrow> Threshold_Value \<Rightarrow>
'a Electoral_Module" where
"leq_eliminator e t A p vs = elimination_module e t (\<le>) A p vs"
fun min_eliminator :: "'a Evaluation_Function \<Rightarrow> 'a Electoral_Module" where
"min_eliminator e A p vs =
leq_eliminator e (Min {e x A p vs | x. x \<in> A}) A p vs"
fun average :: "'a Evaluation_Function \<Rightarrow> 'a set \<Rightarrow> 'a Profile \<Rightarrow> 'a Pair_Vectors \<Rightarrow>
Threshold_Value" where
"average e A p vs = (\<Sum>x \<in> A. e x A p vs) div (card A)"
fun less_average_eliminator :: "'a Evaluation_Function \<Rightarrow>
'a Electoral_Module" where
"less_average_eliminator e A p vs = less_eliminator e (average e A p vs) A p vs"
fun leq_average_eliminator :: "'a Evaluation_Function \<Rightarrow>
'a Electoral_Module" where
"leq_average_eliminator e A p vs = leq_eliminator e (average e A p vs) A p vs"
subsection \<open>Soundness\<close>
lemma elim_mod_sound[simp]: "electoral_module (elimination_module e t r)"
proof (unfold electoral_module_def, safe)
fix
A :: "'a set" and
p :: "'a Profile" and
vs :: "'a Pair_Vectors"
have "set_equals_partition A (elimination_module e t r A p vs)"
by auto
thus "well_formed A (elimination_module e t r A p vs)"
by simp
qed
lemma less_elim_sound[simp]: "electoral_module (less_eliminator e t)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs :: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs < t} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs < t} \<union> A = A"
by safe
qed
lemma leq_elim_sound[simp]: "electoral_module (leq_eliminator e t)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs :: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs \<le> t} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs \<le> t} \<union> A = A"
by safe
qed
lemma max_elim_sound[simp]: "electoral_module (max_eliminator e)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs :: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs < Max {e x A p vs |x. x \<in> A}} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs < Max {e x A p vs |x. x \<in> A}} \<union> A = A"
by safe
qed
lemma min_elim_sound[simp]: "electoral_module (min_eliminator e)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs:: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs \<le> Min {e x A p vs |x. x \<in> A}} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs \<le> Min {e x A p vs |x. x \<in> A}} \<union> A = A"
by safe
qed
lemma less_avg_elim_sound[simp]: "electoral_module (less_average_eliminator e)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs:: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs < (\<Sum>x\<in>A. e x A p vs) div card A} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs < (\<Sum>x\<in>A. e x A p vs) div card A} \<union> A = A"
by safe
qed
lemma leq_avg_elim_sound[simp]: "electoral_module (leq_average_eliminator e)"
unfolding electoral_module_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs:: "'a Pair_Vectors"
show
"{a \<in> A. e a A p vs\<le> (\<Sum>x\<in>A. e x A p vs) div card A} \<noteq> A \<longrightarrow>
{a \<in> A. e a A p vs\<le> (\<Sum>x\<in>A. e x A p vs) div card A} \<union> A = A"
by safe
qed
subsection \<open>Non-Electing\<close>
lemma elim_mod_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (elimination_module e t r )"
by (simp add: non_electing_def)
lemma less_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (less_eliminator e t)"
using elim_mod_non_electing profile less_elim_sound
by (simp add: non_electing_def)
lemma leq_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (leq_eliminator e t)"
proof -
have "non_electing (elimination_module e t (\<le>))"
by (simp add: non_electing_def)
thus ?thesis
by (simp add: non_electing_def)
qed
lemma max_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (max_eliminator e)"
proof -
have "non_electing (elimination_module e t (<))"
by (simp add: non_electing_def)
thus ?thesis
by (simp add: non_electing_def)
qed
lemma min_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (min_eliminator e)"
proof -
have "non_electing (elimination_module e t (<))"
by (simp add: non_electing_def)
thus ?thesis
by (simp add: non_electing_def)
qed
lemma less_avg_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (less_average_eliminator e)"
proof -
have "non_electing (elimination_module e t (<))"
by (simp add: non_electing_def)
thus ?thesis
by (simp add: non_electing_def)
qed
lemma leq_avg_elim_non_electing:
assumes profile: "finite_profile A p" and vectors: "finite_pair_vectors A vs"
shows "non_electing (leq_average_eliminator e)"
proof -
have "non_electing (elimination_module e t (\<le>))"
by (simp add: non_electing_def)
thus ?thesis
by (simp add: non_electing_def)
qed
subsection \<open>Inference Rules\<close>
(*** If the used evaluation function is Condorcet rating,
max-eliminator is Condorcet compatible. ***)
theorem cr_eval_imp_ccomp_max_elim[simp]:
assumes
profile: "finite_profile A p" and
rating: "condorcet_rating e"
shows
"condorcet_compatibility (max_eliminator e)"
unfolding condorcet_compatibility_def
proof (auto)
have f1:
"\<And>A p w x vs. condorcet_winner A p w \<Longrightarrow>
finite A \<Longrightarrow> w \<in> A \<Longrightarrow> e w A p vs < Max {e x A p vs |x. x \<in> A} \<Longrightarrow>
x \<in> A \<Longrightarrow> e x A p vs < Max {e x A p vs |x. x \<in> A}"
using rating
by (simp add: cond_winner_imp_max_eval_val)
thus
"\<And>A p w x vs.
profile A p \<Longrightarrow> w \<in> A \<Longrightarrow>
\<forall>x\<in>A - {w}.
card {i. i < length p \<and> (w, x) \<in> (p!i)} <
card {i. i < length p \<and> (x, w) \<in> (p!i)} \<Longrightarrow>
finite A \<Longrightarrow> e w A p vs< Max {e x A p vs| x. x \<in> A} \<Longrightarrow>
x \<in> A \<Longrightarrow> e x A p vs< Max {e x A p vs| x. x \<in> A}"
by simp
qed
lemma cr_eval_imp_dcc_max_elim_helper1:
assumes
f_prof: "finite_profile A p" and
rating: "condorcet_rating e" and
winner: "condorcet_winner A p w" and
vectors: "finite_pair_vectors A vs"
shows "elimination_set e (Max {e x A p vs | x. x \<in> A}) (<) A p vs = A - {w}"
proof (safe, simp_all, safe)
assume
w_in_A: "w \<in> A" and
max: "e w A p vs< Max {e x A p vs|x. x \<in> A}"
show "False"
using cond_winner_imp_max_eval_val
rating winner f_prof max
by fastforce
next
fix
x :: "'a"
assume
x_in_A: "x \<in> A" and
not_max: "\<not> e x A p vs< Max {e y A p vs|y. y \<in> A}"
show "x = w"
using non_cond_winner_not_max_eval x_in_A
rating winner f_prof not_max vectors
by (metis (mono_tags, lifting))
qed
(*
If the used evaluation function is Condorcet rating, max-eliminator
is defer-Condorcet-consistent.
*)
theorem cr_eval_imp_dcc_max_elim[simp]:
assumes rating: "condorcet_rating e"
shows "defer_condorcet_consistency (max_eliminator e)"
unfolding defer_condorcet_consistency_def
proof (safe, simp)
fix
A :: "'a set" and
p :: "'a Profile" and
vs :: "'a Pair_Vectors" and
w :: "'a"
assume
winner: "condorcet_winner A p w" and
finite: "finite A" and
vectors: "vector_pair A vs"
let ?trsh = "(Max {e y A p vs| y. y \<in> A})"
show
"max_eliminator e A p vs=
({},
A - defer (max_eliminator e) A p vs,
{a \<in> A. condorcet_winner A p a})"
proof (cases "elimination_set e (?trsh) (<) A p vs \<noteq> A")
case True
have profile: "finite_profile A p"
using winner
by simp
with rating winner have 0:
"(elimination_set e ?trsh (<) A p vs) = A - {w}"
using cr_eval_imp_dcc_max_elim_helper1 profile vectors
by (metis (mono_tags, lifting))
have
"max_eliminator e A p vs=
({},
(elimination_set e ?trsh (<) A p vs),
A - (elimination_set e ?trsh (<) A p vs))"
using True
by simp
also have "... = ({}, A - {w}, A - (A - {w}))"
using "0"
by presburger
also have "... = ({}, A - {w}, {w})"
using winner
by auto
also have "... = ({},A - defer (max_eliminator e) A p vs, {w})"
using calculation
by auto
also have
"... =
({},
A - defer (max_eliminator e) A p vs,
{d \<in> A. condorcet_winner A p d})"
using cond_winner_unique3 winner Collect_cong
by (metis (no_types, lifting))
finally show ?thesis
using finite winner
by metis
next
case False
thus ?thesis
proof -
have f1:
"finite A \<and> profile A p \<and> w \<in> A \<and> (\<forall>a. a \<notin> A - {w} \<or> wins w p a)"
using winner
by auto
hence
"?trsh = e w A p vs"
using rating winner
by (simp add: cond_winner_imp_max_eval_val)
hence False
using f1 False
by auto
thus ?thesis
by simp
qed
qed
qed
end
|
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2010, Rice University, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Rice University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Ioan Sucan */
#define BOOST_TEST_MODULE "Memory"
#include <boost/test/unit_test.hpp>
#include "ompl/tools/benchmark/MachineSpecs.h"
#include <cstring>
#include <cstdlib>
#include <iostream>
using namespace ompl;
/* Just test we get some random values */
BOOST_AUTO_TEST_CASE(Simple)
{
BOOST_CHECK(!machine::getHostname().empty());
BOOST_CHECK(!machine::getCPUInfo().empty());
machine::MemUsage_t start = machine::getProcessMemoryUsage();
const unsigned int mb = 39;
machine::MemUsage_t size = mb * 1024 * 1024 / sizeof(char);
auto *data = (char*)malloc(size);
memset(data, 0, size);
machine::MemUsage_t u = machine::getProcessMemoryUsage() - start;
int allocated_MB = (size/1024)/1024;
int used_MB = (u/1024)/1024;
BOOST_CHECK(abs(used_MB - allocated_MB) < 2);
free(data);
}
|
SUBROUTINE LWP_PATH
& (month,day,year,UT)
c***********************************************************************
c Change history:
c 21 Oct 95 Added printing of path summary when PRINT_SWG > 0.
c 19 May 96 Modified to allow smaller minimum segment length to
c accommodate shorter terminators.
c 12 Nov 96 Modified to allow paths longer than 20000 km.
c*******************!***************************************************
c LWPC parameters
include 'lwpc_lun.cmn'
parameter (mxsgmnt=201)
character* 8 archive,prgm_id
character* 20 xmtr_id,path_id
character* 40 prfl_id
character* 80 case_id
character*120 file_id
integer pflag,pindex
real freq,tlat,tlon,bearng,rhomx,rlat,rlon,rrho,
& lat,lon,rho,azim,dip,bfield,sigma,epsr,beta,hprime,
& hofwr,topht,botht
common/lwpc_in/
& archive,file_id(3),prgm_id,
& case_id,prfl_id,xmtr_id,path_id,
& freq,tlat,tlon,bearng,rhomx,rlat,rlon,rrho,pflag,
& lat,lon,rho,azim,dip,bfield,sigma,epsr,beta,hprime,
& hofwr,topht,botht,pindex
real dst,xla,xlo,azm,xdp,fld,sgm,eps,bta,hpr
common/mf_sw_1/
& dst(mxsgmnt),xla(mxsgmnt),xlo(mxsgmnt),
& azm(mxsgmnt),xdp(mxsgmnt),fld(mxsgmnt),
& sgm(mxsgmnt),eps(mxsgmnt),ncd(mxsgmnt),
& bta(mxsgmnt),hpr(mxsgmnt),npr(mxsgmnt),
& num(mxsgmnt),nrsgmnt
real chi
common/mf_sw_4/
& chi(mxsgmnt)
integer print_swg
real * 4 drmin,drmax
common/sw_path/
& drmin,drmax,mdir,lost,lx,print_swg
character* 12 prfl_file
logical save
integer month,day,year,UT
real lng,lng1
data alt/80./,dtr/.01745329252/,rtk/6366.197/,drho/20./
tlng=tlon*dtr
tclt=(90.-tlat)*dtr
ctclt=COS(tclt)
stclt=SIN(tclt)
nrsgmnt=0
rho=0.
gcd=0.
lng=tlng
clt=tclt
cclt=ctclt
sclt=stclt
bear=bearng
xtr=bear*dtr
sinxtr=SIN(xtr)
c Get sub-solar point
UT_hours=(UT-(UT/100)*40)/60.
call ALMNAC (year,month,day,UT_hours,ssclt,sslng)
cssclt=COS(ssclt)
sssclt=SIN(ssclt)
last=0
do while (last .lt. 2)
lon=lng/dtr
clat=clt/dtr
lat=90.-clat
call NEWMAG (0,alt,lng,clt,bmf,d,bfield,br,bp,bt)
azim=bear-bmf/dtr
dip=d/dtr
if (azim .lt. 0.) then
azim=azim+360.
else
& if (azim .ge. 360.) then
azim=azim-360.
end if
call GROUND (lon,lat,ncode,sigma,epsr)
c Calculate signed solar zenith angle;
c -180<CHI<0 is midnight to noon; 0<CHI<180 is noon to midnight.
call GCDBR2 (lng-sslng,clt,cclt,sclt,ssclt,cssclt,sssclt,
& zn,br,0)
call RECVR2 (tlng,tclt,ctclt,stclt,xtr,gcd+.01,
& lng1,clt1,cclt1,sclt1)
call GCDBR2 (lng1-sslng,clt1,cclt1,sclt1,ssclt,cssclt,sssclt,
& zn1,br,0)
if (zn1-zn .lt. 0.) zn=-zn
if (sinxtr .lt. 0.) zn=-zn
zenith=zn/dtr
call PRFL_SPECIFICATION
& (.false.,0,
& prfl_file,prfl_id,pflag,
& freq,month,day,year,UT,
& lat,lon,rho,dip,zenith,
& hpr_mid,beta,hprime,pindex)
if (nrsgmnt .eq. 0) then
nrsgmnt=1
num(1)=0
dst(1)=0.
xla(1)=lat
xlo(1)=lon
azm(1)=azim
xdp(1)=dip
fld(1)=bfield
sgm(1)=sigma
eps(1)=epsr
ncd(1)=ncode
chi(1)=zenith
bta(1)=beta
hpr(1)=hprime
npr(1)=pindex
azm1=azim
dip1=dip
ncd1=ncode
hpr1=hprime
ndx1=pindex
if (print_swg .gt. 0) then
write(lwpcLOG_lun,
& '(/''Path summary: '',
& ''bearng='',f5.1,'' range='',f6.0)')
& bearng,rhomx
write(lwpcLOG_lun,
& '(/'' nr rho lat lon azim dip'',
& '' sigma chi beta h'''''')')
write(lwpcLOG_lun,
& '(i4,f9.0,f7.2,f8.2,2f6.1,1pe7.0,0pf7.1,
& f6.2,f6.1)')
& nrsgmnt,rho,lat,lon,azim,dip,
& sigma,zenith,beta,hprime
end if
else
save=.false.
if (ncode .ne. ncd1 .or.
& hprime .ne. hpr1 .or. pindex .ne. ndx1) then
c Conductivity or profile changed
save=.true.
if (nrsgmnt .gt. 2) then
c Check for a very short segment just before this one
if (rho-dst(nrsgmnt) .lt. 40.) then
if (sgm(nrsgmnt-1) .eq. sgm(nrsgmnt-2) .and.
& hpr(nrsgmnt-1) .eq. hpr(nrsgmnt-2))
& nrsgmnt=nrsgmnt-1
end if
end if
else
atst=ABS(azim-azm1)
dtst=ABS(dip-dip1)
absd=ABS(dip)
if (absd .lt. 80.) then
if (hprime .lt. hpr_mid) then
c Day-like case
if (dtst .gt. 15.) then
save=.true.
else
if (absd .ge. 70.) then
c 70 le dip lt 80
if (atst .gt. 45.) save=.true.
else
& if (absd .ge. 30.) then
c 30 le dip lt 70
if (atst .gt. 30.) save=.true.
else
c 0 le dip lt 30
if (atst .gt. 15.) save=.true.
end if
end if
else
c Night-like case
if (dtst .gt. 10.) then
save=.true.
else
if (absd .ge. 70.) then
c 70 le dip lt 80
if (atst .gt. 20.) save=.true.
else
& if (absd .ge. 30.) then
c 30 le dip lt 70
if (atst .gt. 15.) save=.true.
else
c 0 le dip lt 30
if (ABS(azim-190.) .lt. 20. .or.
& azim .gt. 330. .or. azim .lt. 10.) then
c Modal degeneracy cone of azimuths
if (dtst .gt. 3.) save=.true.
else
& if (dtst .gt. 5. .or. atst .gt. 15.) then
save=.true.
end if
end if
end if
end if
end if
end if
if (print_swg .gt. 2) then
write(lwpcLOG_lun,
& '(4x,f9.0,f7.2,f8.2,2f6.1,1pe7.0,0pf7.1,
& f6.2,f6.1)')
& rho,lat,lon,azim,dip,
& sigma,zenith,beta,hprime
end if
if (save .or. last .eq. 1) then
nrsgmnt=nrsgmnt+1
num(nrsgmnt)=0
dst(nrsgmnt)=rho
xla(nrsgmnt)=lat
xlo(nrsgmnt)=lon
azm(nrsgmnt)=azim
xdp(nrsgmnt)=dip
fld(nrsgmnt)=bfield
sgm(nrsgmnt)=sigma
eps(nrsgmnt)=epsr
ncd(nrsgmnt)=ncode
chi(nrsgmnt)=zenith
bta(nrsgmnt)=beta
hpr(nrsgmnt)=hprime
npr(nrsgmnt)=pindex
azm1=azim
dip1=dip
ncd1=ncode
hpr1=hprime
ndx1=pindex
if (print_swg .gt. 0) then
write(lwpcLOG_lun,
& '(i4,f9.0,f7.2,f8.2,2f6.1,1pe7.0,0pf7.1,
& f6.2,f6.1)')
& nrsgmnt,rho,lat,lon,azim,dip,
& sigma,zenith,beta,hprime
end if
end if
end if
rho=rho+drho
if (rho .ge. rhomx) then
if (last .eq. 0) then
if (rhomx .eq. 40000.) then
last=2
else
rho=rhomx
last=1
end if
else
last=2
end if
end if
if (rho .eq. 20000.) then
c At the antipode of the transmitter
c the bearing here is 540-bearing at the transmitter
lng=tlng+3.141592653
if (lng .gt. 6.2831853072) lng=lng-6.2831853072
clt=3.141592653-tclt
cclt=-ctclt
sclt= stclt
gcd=3.141592653
br=9.4247779608-xtr
if (br .gt. 6.2831853072) br=br-6.2831853072
else
gcd=rho/rtk
call RECVR2 (tlng,tclt,ctclt,stclt,xtr,gcd,
& lng,clt,cclt,sclt)
call GCDBR2 (tlng-lng,tclt,ctclt,stclt,clt,cclt,sclt,
& gcd,br,1)
end if
bear=br/dtr
end do
if (print_swg .gt. 0) write(lwpcLOG_lun,'('' '')')
RETURN
END ! LWP_PATH
|
Jan <unk> was originally cast by producer Harry Saltzman to play Blofeld . Upon his arrival at the Pinewood set , both producer Albert R. Broccoli and director Lewis Gilbert felt that he was a poor choice , resembling a " poor , benevolent Santa Claus " . Nonetheless , in an attempt to make the casting work , Gilbert continued filming . After several days , both Gilbert and Broccoli determined that <unk> was not menacing enough , and recast Blofeld with Donald Pleasence in the role . Pleasence 's ideas for Blofeld 's appearance included a hump , a limp , a beard , and a lame hand , before he settled on the scar . He found it uncomfortable , though , because of the glue that attached it to his eye .
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.EilenbergMacLane1
open import homotopy.EilenbergMacLane
{- Given sequence of groups (Gₙ : n ≥ 1) such that Gₙ is abelian for n > 1,
- we can construct a space X such that πₙ(X) == Gₙ.
- (We can also make π₀(X) whatever we want but this isn't done here.) -}
module homotopy.SpaceFromGroups where
{- From a sequence of spaces (Fₙ) such that Fₙ is n-connected and
- n+1-truncated, construct a space X such that πₙ₊₁(X) == πₙ₊₁(Fₙ) -}
module SpaceFromEMs {i} (F : ℕ → Ptd i)
{{pF : {n : ℕ} → has-level ⟨ S n ⟩ (de⊙ (F n))}}
{{cF : (n : ℕ) → is-connected ⟨ n ⟩ (de⊙ (F n))}} where
X : Ptd i
X = ⊙FinTuples F
πS-X : (n : ℕ) → πS n X ≃ᴳ πS n (F n)
πS-X n =
πS n (⊙FinTuples F)
≃ᴳ⟨ prefix-lemma n O F ⟩
πS n (⊙FinTuples (λ k → F (n + k)))
≃ᴳ⟨ πS-emap n (⊙fin-tuples-cons (λ k → F (n + k))) ⁻¹ᴳ ⟩
πS n (F (n + O) ⊙× ⊙FinTuples (λ k → F (n + S k)))
≃ᴳ⟨ πS-× n (F (n + O)) (⊙FinTuples (λ k → F (n + S k))) ⟩
πS n (F (n + O)) ×ᴳ πS n (⊙FinTuples (λ k → F (n + S k)))
≃ᴳ⟨ ×ᴳ-emap (idiso (πS n (F (n + O))) )
(contr-iso-0ᴳ _ $
connected-at-level-is-contr {{⟨⟩}}
{{Trunc-preserves-conn {n = 0} $ Ω^-conn _ (S n) _ $
transport
(λ k → is-connected k
(FinTuples (λ k → F (n + S k))))
(+2+-comm 0 ⟨ n ⟩₋₁)
(ncolim-conn _ _ {{connected-lemma _ _ (λ k →
transport (λ s → is-connected ⟨ s ⟩ (de⊙ (F (n + S k))))
(+-βr n k ∙ +-comm (S n) k)
(cF (n + S k)))}})}}) ⟩
πS n (F (n + O)) ×ᴳ 0ᴳ
≃ᴳ⟨ ×ᴳ-unit-r _ ⟩
πS n (F (n + O))
≃ᴳ⟨ transportᴳ-iso (λ k → πS n (F k)) (+-unit-r n) ⟩
πS n (F n)
≃ᴳ∎
where
{- In computing πₙ₊₁, spaces before Fₙ are ignored because of their
- truncation level -}
prefix-lemma : (n : ℕ) (m : ℕ) (F : ℕ → Ptd i)
{{_ : {k : ℕ} → has-level ⟨ S m + k ⟩ (de⊙ (F k))}}
→ πS (m + n) (⊙FinTuples F)
≃ᴳ πS (m + n) (⊙FinTuples (λ k → F (n + k)))
prefix-lemma O m F = idiso _
prefix-lemma (S n) m F =
πS (m + S n) (⊙FinTuples F)
≃ᴳ⟨ πS-emap (m + S n) (⊙fin-tuples-cons F) ⁻¹ᴳ ⟩
πS (m + S n) (F O ⊙× ⊙FinTuples (F ∘ S))
≃ᴳ⟨ πS-× (m + S n) (F O) (⊙FinTuples (F ∘ S)) ⟩
πS (m + S n) (F O) ×ᴳ πS (m + S n) (⊙FinTuples (F ∘ S))
≃ᴳ⟨ ×ᴳ-emap lemma₁ lemma₂ ⟩
0ᴳ ×ᴳ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k))))
≃ᴳ⟨ ×ᴳ-unit-l _ ⟩
πS (m + S n) (⊙FinTuples (λ k → F (S (n + k))))
≃ᴳ∎
where
{- ignore first space -}
lemma₁ : πS (m + S n) (F O) ≃ᴳ 0ᴳ
lemma₁ =
πS->level-econv (m + S n) _ (F O)
(⟨⟩-monotone-< (<-ap-S (<-+-l m (O<S n))))
{- ignore the rest by recursive call -}
lemma₂ : πS (m + S n) (⊙FinTuples (F ∘ S))
≃ᴳ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k))))
lemma₂ =
πS (m + S n) (⊙FinTuples (F ∘ S))
≃ᴳ⟨ transportᴳ-iso (λ s → πS s (⊙FinTuples (F ∘ S))) (+-βr m n) ⟩
πS (S m + n) (⊙FinTuples (F ∘ S))
≃ᴳ⟨ prefix-lemma n (S m) (F ∘ S)
{{λ {k} → transport (λ s → has-level ⟨ s ⟩ (de⊙ (F (S k))))
(+-βr (S m) k) ⟨⟩}} ⟩
πS (S m + n) (⊙FinTuples (λ k → F (S (n + k))))
≃ᴳ⟨ transportᴳ-iso (λ s → πS s (⊙FinTuples (λ k → F (S (n + k))))) (+-βr m n) ⁻¹ᴳ ⟩
πS (m + S n) (⊙FinTuples (λ k → F (S (n + k))))
≃ᴳ∎
connected-lemma : (m : ℕ) (F : ℕ → Ptd i)
(cA' : (n : ℕ) → is-connected ⟨ n + m ⟩ (de⊙ (F n)))
(n : ℕ) → is-connected ⟨ m ⟩ (FinTuplesType F n)
connected-lemma m F cA' O =
Trunc-preserves-level ⟨ m ⟩ ⟨⟩
connected-lemma m F cA' (S n) = ×-conn
(cA' O)
(connected-lemma m (F ∘ S)
(λ n → connected-≤T (⟨⟩-monotone-≤ (inr ltS)) {{cA' (S n)}}) n)
{- Given sequence of groups (Gₙ : n ≥ 1) such that Gₙ is abelian for n > 1,
- construct a space X such that πₙ(X) == Gₙ. -}
module SpaceFromGroups {i} (G : ℕ → Group i)
(abG-S : (n : ℕ) → is-abelian (G (S n))) where
private
F : ℕ → Ptd i
F O = ⊙EM₁ (G O)
F (S n) = EMExplicit.⊙EM (G (S n) , abG-S n) (S (S n))
instance
pF : (n : ℕ) → has-level ⟨ S n ⟩ (de⊙ (F n))
pF O = EM₁-level {G = G O}
pF (S n) = EMExplicit.EM-level (G (S n) , abG-S n) (S (S n))
cF : (n : ℕ) → is-connected ⟨ n ⟩ (de⊙ (F n))
cF O = EM₁-conn {G = G O}
cF (S n) = EMExplicit.EM-conn (G (S n) , abG-S n) (S n)
module M = SpaceFromEMs F
X = M.X
πS-X : (n : ℕ) → πS n X ≃ᴳ G n
πS-X O = π₁-EM₁ (G O) ∘eᴳ M.πS-X O
πS-X (S n) =
EMExplicit.πS-diag (G (S n) , abG-S n) (S n) ∘eᴳ M.πS-X (S n)
|
\documentclass[10pt,english,ignorenonframetext,]{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
\usetheme[]{Boadilla}
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,main=english]{babel}
\else
\usepackage{polyglossia}
\setmainlanguage[]{english}
\fi
\newif\ifbibliography
\hypersetup{
pdftitle={Pandoc some block examples},
pdfauthor={Norman Markgraf},
pdfborder={0 0 0},
breaklinks=true}
% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom
\AtBeginPart{
\let\insertpartnumber\relax
\let\partname\relax
\frame{\partpage}
}
\AtBeginSection{
\ifbibliography
\else
\let\insertsectionnumber\relax
\let\sectionname\relax
\frame{\sectionpage}
\fi
}
\AtBeginSubsection{
\let\insertsubsectionnumber\relax
\let\subsectionname\relax
\frame{\subsectionpage}
}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
\input{persons.tex} \input{moreblocks.tex}
\title{Pandoc some block examples}
\author{Norman Markgraf}
\date{}
\begin{document}
\frame{\titlepage}
\section{pandoc persons example}\label{pandoc-persons-example}
\begin{frame}{Just put in some pictures of great scientist}
\begin{columns}[T,onlytextwidth]
\begin{column}[t]{0.74\textwidth}
\begin{theorem}[of Vieta]\label{of-vieta}
If \(x_0\) and \(x_1\) are the roots of \(x^2+px+q=0\), than
\(p=-(x_0 + x_1)\) and \(q=x_0 \cdot x_1\).
\end{theorem}
\begin{Beweis}[]\label{section-1}
\((x-x_0) \cdot (x-x_1) = x^2 - (x_0+x_1) \cdot x + x_0 \cdot x_1\)
\end{Beweis}
\end{column}
\begin{column}{0.24\textwidth}
\personDB{Vieta}
\end{column}
\end{columns}
Wow!
\end{frame}
\begin{frame}[fragile]{The End!}
Well, much to do!
To process this try:
\begin{verbatim}
pandoc --from=markdown --to=json addpersons.md | \
./moreblocks.py beamer | ./addperson.py beamer | \
pandoc --from=json --to=beamer -s -o addpersons.pdf
\end{verbatim}
or
\begin{verbatim}
pandoc --from=markdown --to=beamer \
--filter=moreblocks.py --filter=addperson.py \
addpersons.md -o addpersons.pdf
\end{verbatim}
\end{frame}
\end{document}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.