text
stringlengths 0
1.25M
| meta
stringlengths 47
1.89k
|
|---|---|
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 19 22:25:29 2021
@author: milin
"""
#importing all the libraires
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
df=pd.read_csv('Cleaned DS data.csv')
df_to_use=df[['Rating','Size','Title_Simplified','Level','job_location','age','num_comp','avg_salary','company_txt','Type of ownership','Industry','Sector','Revenue','Easy Apply']]
#creating dummie for all categorical features
df_model = pd.get_dummies(df_to_use)
df_model=df_model.fillna(0)
X=df_model.drop('avg_salary',axis=1)
y=df_model.avg_salary.values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
#linear regrrion model building
reg=LinearRegression()
reg.fit(X_train,y_train)
#random forest model building'
classifier = RandomForestRegressor()
classifier.fit(X_train,y_train)
re_prec=reg.predict(X_test)
ra_prec=classifier.predict(X_test)
#evaluating the accuracy of the models
maer=mean_absolute_error(y_test,re_prec)
maerf=mean_absolute_error(y_test,ra_prec)
#random forest has less MAE score which shows this is more accurate model than linear regression
import pickle
pickl = {'model':classifier }
pickle.dump( pickl, open( 'classifier' + ".p", "wb" ) )
file_name = "classifier.p"
with open(file_name, 'rb') as pickled:
data = pickle.load(pickled)
model = data['model']
|
{"hexsha": "9fb5d90b7f42f41158379dbada5c8f57a69d0a41", "size": 1586, "ext": "py", "lang": "Python", "max_stars_repo_path": "Model_Building/DA model building.py", "max_stars_repo_name": "shrutijain0/Data-Analyst-Salary", "max_stars_repo_head_hexsha": "092877509663f89c7b642fd75d0403ce74f2a5a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2021-01-25T09:21:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-23T07:52:48.000Z", "max_issues_repo_path": "Model_Building/DA model building.py", "max_issues_repo_name": "shrutijain0/Data-Analyst-Salary", "max_issues_repo_head_hexsha": "092877509663f89c7b642fd75d0403ce74f2a5a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Model_Building/DA model building.py", "max_forks_repo_name": "shrutijain0/Data-Analyst-Salary", "max_forks_repo_head_hexsha": "092877509663f89c7b642fd75d0403ce74f2a5a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0980392157, "max_line_length": 181, "alphanum_fraction": 0.7515762926, "include": true, "reason": "import numpy", "num_tokens": 388}
|
#-*-coding: UTF-8-*-
####################################################################################
"""
successfully executed in python 3.6
"""
####################################################################################
import numpy as np
import os
import math
import copy
from Statistic import *
from LHSamples import Sample
###############################################################################
def accToVelocity (dt,acc):
#convert acceleration(cm/s2) to velocity(cm/s)
vel=[0]
num=len(acc)
for i in range(num-1):
velocity=((acc[i]+acc[i+1])*dt/float(2))+vel[-1]
vel.append(velocity)
return vel
##############################################################################
def velToDisp (dt,vel):
#convert velocity(cm/s) to displacement(cm)
disp=[0]
for i in range(len(vel)-1):
displacement=(vel[i]+vel[i+1])*dt/float(2)+disp[-1]
disp.append(displacement)
return disp
#######################################################################
def improvedMethod (accFilePath,velFilePath,dispFilePath,t,fileNamei,nIterate,saveAccPath,\
saveVelPath,saveDispPath,T3,T1Self=None,T2=None):
"""
improved Wu et al method for basedline correction
Wu Y-M, Wu C-F. Approximate recovery of coseismic deformation from Taiwan strong-motion records.
Journal of Seismology. 2007;11(2):159-70.
:param accFilePath: the file path of acceleration
:param velFilePath: the file path of velocity
:param dispFilePath: the file path of displacement
:param t: time interval of motion (s)
:param fileNamei: fileName of the processed ground motion
:param nIterate: sample numbers for t2 values
:param saveAccPath: the save path of processed acceleration
:param saveVelPath: the save path of processed velocity
:param saveDispPath: the save path of processed displacement
:param T3: T3 position in the motion
:param T1Self: T1 position in the motion, if T1self is none,the program will automatically determine it
:return: None
"""
cwd=os.getcwd()
pathAccE=os.path.join(cwd,accFilePath,str(fileNamei)+".txt")
txtopenAccE=np.loadtxt(pathAccE)
copyAccE1 = copy.deepcopy(txtopenAccE)
T3=int(T3)
for i2 in range(len(txtopenAccE)):
if copyAccE1[i2] * 981 > 50:
T150 = i2
break
pga=max(abs(txtopenAccE))*9.81*100 # convert acceleration to cm/s2
if pga>60: # only pga>60 cm/s2 it needs baseline correction
cwd=os.getcwd()
pathDispE=os.path.join(cwd,dispFilePath,str(fileNamei)+".txt") #upload displacement time history to process
txtopenDispE=np.loadtxt(pathDispE).tolist()
lengthTxt=len(txtopenDispE)
copyDispE=copy.deepcopy(txtopenDispE)
reversedDispE=copyDispE.reverse()
# automatically determine T1 position
for i2 in range(lengthTxt):
if txtopenDispE[-1]>0:
if copyDispE[i2]<=0:
T1=(lengthTxt-i2-1)
break
else:
if copyDispE[i2]>=0:
T1=(lengthTxt-i2-1)
break
# if T1 position larger than that determined by Iwan etal (1985), then use Iwan's T1 position
if T150>T1:
T1=T150
else:
T1=T1
# if users provide T1, and use it in the following process
if T1Self!=None:
T1=int(T1Self)
cwd=os.getcwd()
pathVelE=os.path.join(cwd,velFilePath,str(fileNamei)+".txt")
txtopenVelE=np.loadtxt(pathVelE).tolist()
v0=[]
af=[]
fValue=[]
T22=[]
maxfValue=None
# randomly generage nIterate intergers between T3 and (lengthTxt-10)
bounds = [(T3,lengthTxt-10)]
instance = Sample(bounds, nIterate)
samples = list(instance.LHSample()[:,0])
if T2!=None:
T2Index=T2
else:
for i3 in range(nIterate):
# print(i3)
T2=int(samples[i3])
X0 = [1 for x in range(T2, lengthTxt)]
X1 = [x * t for x in range(T2, lengthTxt)]
Y = txtopenVelE[T2:lengthTxt]
hZX11 = np.mat(X0).T
hZX33 = np.mat(X1).T
hZY33 = np.mat(Y).T
velData = np.hstack((hZX11, hZX33, hZY33))
instanceVel = Regression(velData)
wtotvel = instanceVel.linearRegression()
wvel = wtotvel[0].tolist()
v0vel = wvel[0][0]
Afvel = wvel[1][0]
# y=v0vel+Afvel*t
Amvel = (v0vel + Afvel * T2 * t) / float((T2 - T1) * t)
accOrignal = [x * 981 for x in txtopenAccE]
for i4 in range(T1, T2):
accOrignal[i4] = accOrignal[i4] - Amvel
for i5 in range(T2, len(accOrignal)):
accOrignal[i5] = accOrignal[i5] - Afvel
velBaseline = accToVelocity(t, accOrignal)
dispBaseline = velToDisp(t, velBaseline)
X10 = [1 for x in range(T3, lengthTxt)]
X11 = [x * t for x in range(T3, lengthTxt)]
Y11=dispBaseline[T3:lengthTxt]
hZX1=np.mat(X10).T
hZX2=np.mat(X11).T
hZY=np.mat(Y11).T
linerData=np.hstack((hZX1,hZX2,hZY))
#call linear regression function to fit the displacement from T3 to end
instance=Regression(linerData)
wtot=instance.linearRegression()
w=wtot[0].tolist() #regression coefficients
corrcoef=wtot[1] #correlation coefficient
var=wtot[4] #standard deviation
v00=w[0][0] #constant of the regression line
aff=w[1][0] #slope of the regression line
r=corrcoef
b=abs(aff)
fvalue=abs(r)/float(b*var**2) #calculate f value
fValue.append(fvalue)
v0.append(v00)
af.append(aff)
T22.append(T2)
maxIndex=fValue.index(max(fValue)) #find the maximum f index
T2Index=T22[maxIndex] #obtain the optimized T2 position
maxfValue=max(fValue)
#conduct baseline correction based on the optimized T2
X31=[1 for x in range(T2Index,lengthTxt)]
X33=[x*t for x in range(T2Index,lengthTxt)]
Y3=txtopenVelE[T2Index:lengthTxt]
hZX11=np.mat(X31).T
hZX33=np.mat(X33).T
hZY33=np.mat(Y3).T
velData=np.hstack((hZX11,hZX33,hZY33))
instanceVel=Regression(velData)
wtotvel=instanceVel.linearRegression()
wvel=wtotvel[0].tolist()
v0vel=wvel[0][0]
Afvel=wvel[1][0]
#y=v0vel+Afvel*t
Amvel=(v0vel+Afvel*T2Index*t)/float((T2Index-T1)*t)
accOrignal=[x*981 for x in txtopenAccE]
for i4 in range(T1,T2Index):
accOrignal[i4]=accOrignal[i4]-Amvel
for i5 in range(T2Index,len(accOrignal)):
accOrignal[i5]=accOrignal[i5]-Afvel
velBaseline=accToVelocity (t,accOrignal)
dispBaseline=velToDisp (t,velBaseline)
accToG=[x/float(981) for x in accOrignal]
cwd=os.getcwd()
# save the baseline corrected motion
pathaccBaseCorreE=os.path.join(cwd,saveAccPath,str(fileNamei)+".txt")
np.savetxt(pathaccBaseCorreE,accToG,fmt="%f")
pathvelBaseCorreE=os.path.join(cwd,saveVelPath,str(fileNamei)+".txt")
np.savetxt(pathvelBaseCorreE,velBaseline,fmt="%f")
pathdispBaseCorreE=os.path.join(cwd,saveDispPath,str(fileNamei)+".txt")
np.savetxt(pathdispBaseCorreE,dispBaseline,fmt="%f")
return T1,T2Index,T3,maxfValue
#######################################################################
#########################---main program---############################
#######################################################################
###provide the acceleration, velocity and displacement paths of the unprocessed motion
accFilePath='ChiChiEarthquakeAccg/E'
velFilePath='ChiChiEarthquakeVel/E'
dispFilePath='ChiChiEarthquakeDisp/E'
###provide the save paths for the processed acceleration, velocity and displacement
saveAccPath='accBaselineCorre/E'
saveVelPath='velBaselineCorre/E'
saveDispPath='dispBaselineCorre/E'
dt=0.005 #time interval (s)
nIterate=100 # sample size for T2 position from T3 to the end
fileNamei='TCU068' #file name of unprocessed motion
#########################################################################
#########################################################################
##automatically determine T1 and T3,T1=(4500,5500),T3=(5000,7000)
bounds = [(6000,7000),(7000,9000)]
NIter=10 #iterate number for T1 and T3
instance = Sample(bounds, NIter)
samples =instance.LHSample()
T1sample=samples[:,0]
T3sample=samples[:,1]
T1List=[]
T2List=[]
T3List=[]
fvalueList=[]
for j1 in range(10):
print(j1)
###call the improved Wu et al. method to conduct baseline correction
T11,T22,T33,fvalue=improvedMethod (accFilePath,velFilePath,dispFilePath,dt,\
fileNamei,nIterate,saveAccPath,saveVelPath,saveDispPath,T3sample[j1],T1sample[j1])
T1List.append(T11)
T2List.append(T22)
T3List.append(T33)
fvalueList.append(fvalue)
maxIndex=fvalueList.index(max(fvalueList))
finalT1=T1List[maxIndex]
finalT2=T2List[maxIndex]
finalT3=T3List[maxIndex]
print("finalT1,T2,T3",finalT1,finalT2,finalT3)
#########################################################################
#########################################################################
T1=finalT1 #T1 position in the motion, if T1=None the program will automatically determine T1
T3=finalT3 # T3 position in the motion
T2=finalT2 # T2 position in the motion
T11,T22,T33,fvalue=improvedMethod (accFilePath,velFilePath,dispFilePath,dt,\
fileNamei,nIterate,saveAccPath,saveVelPath,saveDispPath,T3,T1,T2)
|
{"hexsha": "cd73e86ae3cb7bce2086fd3aa6eb6e97671d48e4", "size": 8982, "ext": "py", "lang": "Python", "max_stars_repo_path": "WuImprovedBaselineCorrection.py", "max_stars_repo_name": "Junjun1guo/improvedWuBaselineCorrection", "max_stars_repo_head_hexsha": "06d2dee77b7fe4cbe746140500f1ededd5ceedf0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-30T12:22:43.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-07T06:43:14.000Z", "max_issues_repo_path": "WuImprovedBaselineCorrection.py", "max_issues_repo_name": "Junjun1guo/improvedWuBaselineCorrection", "max_issues_repo_head_hexsha": "06d2dee77b7fe4cbe746140500f1ededd5ceedf0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "WuImprovedBaselineCorrection.py", "max_forks_repo_name": "Junjun1guo/improvedWuBaselineCorrection", "max_forks_repo_head_hexsha": "06d2dee77b7fe4cbe746140500f1ededd5ceedf0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-27T02:32:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-27T02:32:25.000Z", "avg_line_length": 38.3846153846, "max_line_length": 110, "alphanum_fraction": 0.6329325317, "include": true, "reason": "import numpy", "num_tokens": 2600}
|
import sys
import argparse
import numpy as np
import tensorflow as tf
from tensorflow.keras.preprocessing.text import tokenizer_from_json
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.models import Model
from tensorflow.keras.models import load_model
from parsecorpus import replace_tokens
def gen(model_path, seeds_fp, tokenizer_fp, slen, n):
seeds = [replace_tokens(seed.strip('\n'))
for seed in seeds_fp.readlines()]
tokenizer = tokenizer_from_json(tokenizer_fp.read())
seed_seqs = tokenizer.texts_to_sequences(seeds)
# padded_seqs = pad_sequences(seed_seqs, slen)
model : Model = load_model(model_path)
model.summary()
feedback = list(np.zeros((32,)))
for seq in seed_seqs:
feedback.extend(list(seq))
for _ in range(1):
logit = 0
while logit not in [tokenizer.word_index['.']]:
seq_input = np.expand_dims(feedback[-slen:], 0)
pred = model.predict([seq_input], 1)
logit = pred.squeeze().argmax()
feedback.append(logit)
feedback.append(tokenizer.word_index['\n'])
out_seq = tokenizer.sequences_to_texts([feedback])
print(out_seq[0])
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Sentences generation script.')
parser.add_argument('-m', '--model', type=str, required=True)
parser.add_argument('-s', '--seed', type=open, default=sys.stdin, required=False)
parser.add_argument('-t', '--tokenizer', type=open, required=True)
parser.add_argument('-l', '--seq_len', type=int, required=True)
parser.add_argument('-n', '--num_words', type=int, default='1', required=False)
args = parser.parse_args()
gen(args.model, args.seed, args.tokenizer, args.seq_len, args.num_words)
|
{"hexsha": "72db81d199630854403be458e8d31a6d8651e8ed", "size": 1847, "ext": "py", "lang": "Python", "max_stars_repo_path": "gen_sentences.py", "max_stars_repo_name": "hhmaia/textgen-tensorflow", "max_stars_repo_head_hexsha": "45bcfca89f7e9c74a19d7d5d1e35bc0951cd6e14", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gen_sentences.py", "max_issues_repo_name": "hhmaia/textgen-tensorflow", "max_issues_repo_head_hexsha": "45bcfca89f7e9c74a19d7d5d1e35bc0951cd6e14", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gen_sentences.py", "max_forks_repo_name": "hhmaia/textgen-tensorflow", "max_forks_repo_head_hexsha": "45bcfca89f7e9c74a19d7d5d1e35bc0951cd6e14", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.4791666667, "max_line_length": 85, "alphanum_fraction": 0.6832701678, "include": true, "reason": "import numpy", "num_tokens": 407}
|
# Functions for data collection
# mymean(a) = isempty(a) ? missing : mean(a)
mymean(a) = isempty(a) ? 0.0 : mean(a)
mystd(a) = isempty(a) ? 0.0 : std(a)
mymedian(a) = isempty(a) ? 0.0 : median(a)
mysum(a) = isempty(a) ? 0.0 : sum(a)
"""
knowledge output of the researcher given the problems it has worked on and their publication success.
"""
function mean_knowledge_output(researcher::Researcher)
produced_knowledge = zeros(Float64, length(researcher.problem_history))
published_indices = findall(a-> !ismissing(a) && a == true, researcher.publication_success)
for index in published_indices
problem = researcher.problem_history[index]
produced_knowledge[index] = problem.information
end
return mymean(produced_knowledge)
end
submissions_per_author(r::Researcher) = length(r.publication_success)
publications_per_author(r::Researcher) = length(findall(a-> !ismissing(a) && a==true, r.publication_success))
isgranted(r::Researcher) = r.grant > 0 ? true : false
function totalcitations(r::Researcher)
j = sum(r.publication_citations)
if !isnan(j)
return 0
else
return j
end
end
npapers(r::Researcher) = length(findall(a-> !ismissing(a) && a==true, r.publication_success))
nprojects(r::Researcher) = length(r.publication_success)
pop(r::Researcher) = 1
adata = [
(mean_knowledge_output, mysum),
(mean_knowledge_output, mymean),
# (mean_knowledge_output, mystd),
(mean_knowledge_output, mymedian),
(submissions_per_author, mymean),
# (submissions_per_author, mystd),
(submissions_per_author, mymedian),
(publications_per_author, mymean),
# (publications_per_author, mystd),
(publications_per_author, mymedian),
(:experience, mymean),
(:experience, mymedian),
# (:experience, mystd),
(isgranted, count),
(:grant, mymean),
(totalcitations, mymean),
# (totalcitations, mystd),
(totalcitations, mymedian),
(:risk_taking, mymean),
# (:risk_taking, mystd),
(:risk_taking, mymedian),
(:generality, mymean),
# (:generality, mystd),
(:generality, mymedian),
(npapers, mymean),
# (npapers, mystd),
(npapers, mymedian),
(nprojects, mymean),
(nprojects, mymedian),
# (nprojects, mystd),
(pop, mysum)
]
|
{"hexsha": "3aff41bb525682dc41b5790dd7ac4f36ad379ca6", "size": 2149, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/data_collection.jl", "max_stars_repo_name": "kavir1698/Science_ABM.jl", "max_stars_repo_head_hexsha": "6a5ea8d723a62ac85b4e992ea957f61240318431", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-13T23:56:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-13T23:56:29.000Z", "max_issues_repo_path": "src/data_collection.jl", "max_issues_repo_name": "kavir1698/Science_ABM.jl", "max_issues_repo_head_hexsha": "6a5ea8d723a62ac85b4e992ea957f61240318431", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/data_collection.jl", "max_forks_repo_name": "kavir1698/Science_ABM.jl", "max_forks_repo_head_hexsha": "6a5ea8d723a62ac85b4e992ea957f61240318431", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2763157895, "max_line_length": 109, "alphanum_fraction": 0.7254536994, "num_tokens": 628}
|
/-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
! This file was ported from Lean 3 source module topology.metric_space.basic
! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Tactic.Positivity
import Mathbin.Topology.Algebra.Order.Compact
import Mathbin.Topology.MetricSpace.EmetricSpace
import Mathbin.Topology.Bornology.Constructions
/-!
# Metric spaces
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines metric spaces. Many definitions and theorems expected
on metric spaces are already introduced on uniform spaces and topological spaces.
For example: open and closed sets, compactness, completeness, continuity and uniform continuity
## Main definitions
* `has_dist α`: Endows a space `α` with a function `dist a b`.
* `pseudo_metric_space α`: A space endowed with a distance function, which can
be zero even if the two elements are non-equal.
* `metric.ball x ε`: The set of all points `y` with `dist y x < ε`.
* `metric.bounded s`: Whether a subset of a `pseudo_metric_space` is bounded.
* `metric_space α`: A `pseudo_metric_space` with the guarantee `dist x y = 0 → x = y`.
Additional useful definitions:
* `nndist a b`: `dist` as a function to the non-negative reals.
* `metric.closed_ball x ε`: The set of all points `y` with `dist y x ≤ ε`.
* `metric.sphere x ε`: The set of all points `y` with `dist y x = ε`.
* `proper_space α`: A `pseudo_metric_space` where all closed balls are compact.
* `metric.diam s` : The `supr` of the distances of members of `s`.
Defined in terms of `emetric.diam`, for better handling of the case when it should be infinite.
TODO (anyone): Add "Main results" section.
## Implementation notes
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory of `pseudo_metric_space`, where we don't require `dist x y = 0 → x = y` and we specialize
to `metric_space` at the end.
## Tags
metric, pseudo_metric, dist
-/
open Set Filter TopologicalSpace Bornology
open uniformity Topology BigOperators Filter NNReal ENNReal
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type _}
/- warning: uniform_space_of_dist -> UniformSpace.ofDist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (dist x y) (dist y z))) -> (UniformSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (dist x y) (dist y z))) -> (UniformSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align uniform_space_of_dist UniformSpace.ofDistₓ'. -/
/-- Construct a uniform structure from a distance function and metric space axioms -/
def UniformSpace.ofDist (dist : α → α → ℝ) (dist_self : ∀ x : α, dist x x = 0)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : UniformSpace α :=
UniformSpace.ofFun dist dist_self dist_comm dist_triangle fun ε ε0 =>
⟨ε / 2, half_pos ε0, fun x hx y hy => add_halves ε ▸ add_lt_add hx hy⟩
#align uniform_space_of_dist UniformSpace.ofDist
/-- This is an internal lemma used to construct a bornology from a metric in `bornology.of_dist`. -/
private theorem bounded_iff_aux {α : Type _} (dist : α → α → ℝ)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) (s : Set α) (a : α) :
(∃ c, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ c) ↔ ∃ r, ∀ ⦃x⦄, x ∈ s → dist x a ≤ r :=
by
constructor <;> rintro ⟨C, hC⟩
· rcases s.eq_empty_or_nonempty with (rfl | ⟨x, hx⟩)
· exact ⟨0, by simp⟩
· exact ⟨C + dist x a, fun y hy => (dist_triangle y x a).trans (add_le_add_right (hC hy hx) _)⟩
·
exact
⟨C + C, fun x hx y hy =>
(dist_triangle x a y).trans
(add_le_add (hC hx)
(by
rw [dist_comm]
exact hC hy))⟩
#align bounded_iff_aux bounded_iff_aux
/-- Construct a bornology from a distance function and metric space axioms. -/
def Bornology.ofDist {α : Type _} (dist : α → α → ℝ) (dist_self : ∀ x : α, dist x x = 0)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : Bornology α :=
Bornology.ofBounded { s : Set α | ∃ C, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C }
⟨0, fun x hx y => hx.elim⟩ (fun s ⟨c, hc⟩ t h => ⟨c, fun x hx y hy => hc (h hx) (h hy)⟩)
(fun s hs t ht => by
rcases s.eq_empty_or_nonempty with (rfl | ⟨z, hz⟩)
· exact (empty_union t).symm ▸ ht
· simp only [fun u => bounded_iff_aux dist dist_comm dist_triangle u z] at hs ht⊢
rcases hs, ht with ⟨⟨r₁, hr₁⟩, ⟨r₂, hr₂⟩⟩
exact
⟨max r₁ r₂, fun x hx =>
Or.elim hx (fun hx' => (hr₁ hx').trans (le_max_left _ _)) fun hx' =>
(hr₂ hx').trans (le_max_right _ _)⟩)
fun z =>
⟨0, fun x hx y hy => by
rw [eq_of_mem_singleton hx, eq_of_mem_singleton hy]
exact (dist_self z).le⟩
#align bornology.of_dist Bornology.ofDistₓ
#print Dist /-
/-- The distance function (given an ambient metric space on `α`), which returns
a nonnegative real number `dist x y` given `x y : α`. -/
@[ext]
class Dist (α : Type _) where
dist : α → α → ℝ
#align has_dist Dist
-/
export Dist (dist)
-- the uniform structure and the emetric space structure are embedded in the metric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
/-- This is an internal lemma used inside the default of `pseudo_metric_space.edist`. -/
private theorem pseudo_metric_space.dist_nonneg' {α} {x y : α} (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : 0 ≤ dist x y :=
have : 2 * dist x y ≥ 0 :=
calc
2 * dist x y = dist x y + dist y x := by rw [dist_comm x y, two_mul]
_ ≥ 0 := by rw [← dist_self x] <;> apply dist_triangle
nonneg_of_mul_nonneg_right this zero_lt_two
#align pseudo_metric_space.dist_nonneg' pseudo_metric_space.dist_nonneg'
/- warning: pseudo_metric_space.edist_dist_tac clashes with [anonymous] -> [anonymous]
Case conversion may be inaccurate. Consider using '#align pseudo_metric_space.edist_dist_tac [anonymous]ₓ'. -/
/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/
#print [anonymous] /-
/-- This tactic is used to populate `pseudo_metric_space.edist_dist` when the default `edist` is
used. -/
protected unsafe def [anonymous] : tactic Unit :=
tactic.intros >> sorry
#align pseudo_metric_space.edist_dist_tac [anonymous]
-/
#print PseudoMetricSpace /-
/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic pseudo_metric_space.edist_dist_tac -/
/-- Pseudo metric and Metric spaces
A pseudo metric space is endowed with a distance for which the requirement `d(x,y)=0 → x = y` might
not hold. A metric space is a pseudo metric space such that `d(x,y)=0 → x = y`.
Each pseudo metric space induces a canonical `uniform_space` and hence a canonical
`topological_space` This is enforced in the type class definition, by extending the `uniform_space`
structure. When instantiating a `pseudo_metric_space` structure, the uniformity fields are not
necessary, they will be filled in by default. In the same way, each (pseudo) metric space induces a
(pseudo) emetric space structure. It is included in the structure, but filled in by default.
-/
class PseudoMetricSpace (α : Type u) extends Dist α : Type u where
dist_self : ∀ x : α, dist x x = 0
dist_comm : ∀ x y : α, dist x y = dist y x
dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z
edist : α → α → ℝ≥0∞ := fun x y =>
@coe ℝ≥0 _ _ ⟨dist x y, PseudoMetricSpace.dist_nonneg' _ ‹_› ‹_› ‹_›⟩
edist_dist : ∀ x y : α, edist x y = ENNReal.ofReal (dist x y) := by
run_tac
[anonymous]
toUniformSpace : UniformSpace α := UniformSpace.ofDist dist dist_self dist_comm dist_triangle
uniformity_dist :
𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α |
dist p.1 p.2 < ε } := by
intros
rfl
toBornology : Bornology α := Bornology.ofDist dist dist_self dist_comm dist_triangle
cobounded_sets :
(Bornology.cobounded α).sets =
{ s | ∃ C, ∀ ⦃x⦄, x ∈ sᶜ →
∀ ⦃y⦄, y ∈ sᶜ → dist x y ≤ C } := by
intros
rfl
#align pseudo_metric_space PseudoMetricSpace
-/
#print PseudoMetricSpace.ext /-
/-- Two pseudo metric space structures with the same distance function coincide. -/
@[ext]
theorem PseudoMetricSpace.ext {α : Type _} {m m' : PseudoMetricSpace α}
(h : m.toHasDist = m'.toHasDist) : m = m' :=
by
rcases m with ⟨⟩
rcases m' with ⟨⟩
dsimp at h
subst h
congr
· ext (x y) : 2
dsimp at m_edist_dist m'_edist_dist
simp [m_edist_dist, m'_edist_dist]
· dsimp at m_uniformity_dist m'_uniformity_dist
rw [← m'_uniformity_dist] at m_uniformity_dist
exact uniformSpace_eq m_uniformity_dist
· ext1
dsimp at m_cobounded_sets m'_cobounded_sets
rw [← m'_cobounded_sets] at m_cobounded_sets
exact filter_eq m_cobounded_sets
#align pseudo_metric_space.ext PseudoMetricSpace.ext
-/
variable [PseudoMetricSpace α]
attribute [instance] PseudoMetricSpace.toUniformSpace
attribute [instance] PseudoMetricSpace.toBornology
#print PseudoMetricSpace.toEDist /-
-- see Note [lower instance priority]
instance (priority := 200) PseudoMetricSpace.toEDist : EDist α :=
⟨PseudoMetricSpace.edist⟩
#align pseudo_metric_space.to_has_edist PseudoMetricSpace.toEDist
-/
/- warning: pseudo_metric_space.of_dist_topology -> PseudoMetricSpace.ofDistTopology is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : TopologicalSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (dist x y) (dist y z))) -> (forall (s : Set.{u1} α), Iff (IsOpen.{u1} α _inst_2 s) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (y : α), (LT.lt.{0} Real Real.hasLt (dist x y) ε) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s)))))) -> (PseudoMetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : TopologicalSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (dist x y) (dist y z))) -> (forall (s : Set.{u1} α), Iff (IsOpen.{u1} α _inst_2 s) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (y : α), (LT.lt.{0} Real Real.instLTReal (dist x y) ε) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s)))))) -> (PseudoMetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align pseudo_metric_space.of_dist_topology PseudoMetricSpace.ofDistTopologyₓ'. -/
/-- Construct a pseudo-metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def PseudoMetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s) :
PseudoMetricSpace α :=
{ dist
dist_self
dist_comm
dist_triangle
toUniformSpace :=
{ isOpen_uniformity := fun s =>
(H s).trans <|
forall₂_congr fun x _ =>
((UniformSpace.hasBasis_ofFun (exists_gt (0 : ℝ)) dist _ _ _ _).comap
(Prod.mk x)).mem_iff.symm.trans
mem_comap_prod_mk
toCore := (UniformSpace.ofDist dist dist_self dist_comm dist_triangle).toCore }
uniformity_dist := rfl
toBornology := Bornology.ofDist dist dist_self dist_comm dist_triangle
cobounded_sets := rfl }
#align pseudo_metric_space.of_dist_topology PseudoMetricSpace.ofDistTopology
/- warning: dist_self -> dist_self is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))
Case conversion may be inaccurate. Consider using '#align dist_self dist_selfₓ'. -/
@[simp]
theorem dist_self (x : α) : dist x x = 0 :=
PseudoMetricSpace.dist_self x
#align dist_self dist_self
#print dist_comm /-
theorem dist_comm (x y : α) : dist x y = dist y x :=
PseudoMetricSpace.dist_comm x y
#align dist_comm dist_comm
-/
#print edist_dist /-
theorem edist_dist (x y : α) : edist x y = ENNReal.ofReal (dist x y) :=
PseudoMetricSpace.edist_dist x y
#align edist_dist edist_dist
-/
/- warning: dist_triangle -> dist_triangle is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y z))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y z))
Case conversion may be inaccurate. Consider using '#align dist_triangle dist_triangleₓ'. -/
theorem dist_triangle (x y z : α) : dist x z ≤ dist x y + dist y z :=
PseudoMetricSpace.dist_triangle x y z
#align dist_triangle dist_triangle
/- warning: dist_triangle_left -> dist_triangle_left is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) z x) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) z y))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) z x) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) z y))
Case conversion may be inaccurate. Consider using '#align dist_triangle_left dist_triangle_leftₓ'. -/
theorem dist_triangle_left (x y z : α) : dist x y ≤ dist z x + dist z y := by
rw [dist_comm z] <;> apply dist_triangle
#align dist_triangle_left dist_triangle_left
/- warning: dist_triangle_right -> dist_triangle_right is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x z) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y z))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x z) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y z))
Case conversion may be inaccurate. Consider using '#align dist_triangle_right dist_triangle_rightₓ'. -/
theorem dist_triangle_right (x y z : α) : dist x y ≤ dist x z + dist y z := by
rw [dist_comm y] <;> apply dist_triangle
#align dist_triangle_right dist_triangle_right
/- warning: dist_triangle4 -> dist_triangle4 is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α) (w : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x w) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y z)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) z w))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α) (w : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x w) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y z)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) z w))
Case conversion may be inaccurate. Consider using '#align dist_triangle4 dist_triangle4ₓ'. -/
theorem dist_triangle4 (x y z w : α) : dist x w ≤ dist x y + dist y z + dist z w :=
calc
dist x w ≤ dist x z + dist z w := dist_triangle x z w
_ ≤ dist x y + dist y z + dist z w := add_le_add_right (dist_triangle x y z) _
#align dist_triangle4 dist_triangle4
/- warning: dist_triangle4_left -> dist_triangle4_left is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x₁ : α) (y₁ : α) (x₂ : α) (y₂ : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₂ y₂) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₁ y₁) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₁ x₂) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y₁ y₂)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x₁ : α) (y₁ : α) (x₂ : α) (y₂ : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₂ y₂) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₁ y₁) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₁ x₂) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y₁ y₂)))
Case conversion may be inaccurate. Consider using '#align dist_triangle4_left dist_triangle4_leftₓ'. -/
theorem dist_triangle4_left (x₁ y₁ x₂ y₂ : α) :
dist x₂ y₂ ≤ dist x₁ y₁ + (dist x₁ x₂ + dist y₁ y₂) :=
by
rw [add_left_comm, dist_comm x₁, ← add_assoc]
apply dist_triangle4
#align dist_triangle4_left dist_triangle4_left
/- warning: dist_triangle4_right -> dist_triangle4_right is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x₁ : α) (y₁ : α) (x₂ : α) (y₂ : α), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₁ y₁) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₁ x₂) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y₁ y₂)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x₂ y₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x₁ : α) (y₁ : α) (x₂ : α) (y₂ : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₁ y₁) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₁ x₂) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y₁ y₂)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x₂ y₂))
Case conversion may be inaccurate. Consider using '#align dist_triangle4_right dist_triangle4_rightₓ'. -/
theorem dist_triangle4_right (x₁ y₁ x₂ y₂ : α) :
dist x₁ y₁ ≤ dist x₁ x₂ + dist y₁ y₂ + dist x₂ y₂ :=
by
rw [add_right_comm, dist_comm y₁]
apply dist_triangle4
#align dist_triangle4_right dist_triangle4_right
/- warning: dist_le_Ico_sum_dist -> dist_le_Ico_sum_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (f : Nat -> α) {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f m) (f n)) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.Ico.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) Nat.locallyFiniteOrder m n) (fun (i : Nat) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f i) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) i (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (f : Nat -> α) {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f m) (f n)) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.Ico.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) instLocallyFiniteOrderNatToPreorderToPartialOrderStrictOrderedSemiring m n) (fun (i : Nat) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f i) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) i (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))))
Case conversion may be inaccurate. Consider using '#align dist_le_Ico_sum_dist dist_le_Ico_sum_distₓ'. -/
/-- The triangle (polygon) inequality for sequences of points; `finset.Ico` version. -/
theorem dist_le_Ico_sum_dist (f : ℕ → α) {m n} (h : m ≤ n) :
dist (f m) (f n) ≤ ∑ i in Finset.Ico m n, dist (f i) (f (i + 1)) :=
by
revert n
apply Nat.le_induction
· simp only [Finset.sum_empty, Finset.Ico_self, dist_self]
· intro n hn hrec
calc
dist (f m) (f (n + 1)) ≤ dist (f m) (f n) + dist _ _ := dist_triangle _ _ _
_ ≤ (∑ i in Finset.Ico m n, _) + _ := (add_le_add hrec le_rfl)
_ = ∑ i in Finset.Ico m (n + 1), _ := by
rw [Nat.Ico_succ_right_eq_insert_Ico hn, Finset.sum_insert, add_comm] <;> simp
#align dist_le_Ico_sum_dist dist_le_Ico_sum_dist
/- warning: dist_le_range_sum_dist -> dist_le_range_sum_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (f : Nat -> α) (n : Nat), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (f n)) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.range n) (fun (i : Nat) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f i) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) i (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (f : Nat -> α) (n : Nat), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f n)) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.range n) (fun (i : Nat) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f i) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) i (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))))
Case conversion may be inaccurate. Consider using '#align dist_le_range_sum_dist dist_le_range_sum_distₓ'. -/
/-- The triangle (polygon) inequality for sequences of points; `finset.range` version. -/
theorem dist_le_range_sum_dist (f : ℕ → α) (n : ℕ) :
dist (f 0) (f n) ≤ ∑ i in Finset.range n, dist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_dist f (Nat.zero_le n)
#align dist_le_range_sum_dist dist_le_range_sum_dist
/- warning: dist_le_Ico_sum_of_dist_le -> dist_le_Ico_sum_of_dist_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Nat -> α} {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (forall {d : Nat -> Real}, (forall {k : Nat}, (LE.le.{0} Nat Nat.hasLe m k) -> (LT.lt.{0} Nat Nat.hasLt k n) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f k) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) k (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (d k))) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f m) (f n)) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.Ico.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) Nat.locallyFiniteOrder m n) (fun (i : Nat) => d i))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Nat -> α} {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (forall {d : Nat -> Real}, (forall {k : Nat}, (LE.le.{0} Nat instLENat m k) -> (LT.lt.{0} Nat instLTNat k n) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f k) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) k (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (d k))) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f m) (f n)) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.Ico.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) instLocallyFiniteOrderNatToPreorderToPartialOrderStrictOrderedSemiring m n) (fun (i : Nat) => d i))))
Case conversion may be inaccurate. Consider using '#align dist_le_Ico_sum_of_dist_le dist_le_Ico_sum_of_dist_leₓ'. -/
/-- A version of `dist_le_Ico_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_Ico_sum_of_dist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ}
(hd : ∀ {k}, m ≤ k → k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f m) (f n) ≤ ∑ i in Finset.Ico m n, d i :=
le_trans (dist_le_Ico_sum_dist f hmn) <|
Finset.sum_le_sum fun k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
#align dist_le_Ico_sum_of_dist_le dist_le_Ico_sum_of_dist_le
/- warning: dist_le_range_sum_of_dist_le -> dist_le_range_sum_of_dist_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Nat -> α} (n : Nat) {d : Nat -> Real}, (forall {k : Nat}, (LT.lt.{0} Nat Nat.hasLt k n) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f k) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) k (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (d k))) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (f n)) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.range n) (fun (i : Nat) => d i)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Nat -> α} (n : Nat) {d : Nat -> Real}, (forall {k : Nat}, (LT.lt.{0} Nat instLTNat k n) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f k) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) k (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (d k))) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f n)) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.range n) (fun (i : Nat) => d i)))
Case conversion may be inaccurate. Consider using '#align dist_le_range_sum_of_dist_le dist_le_range_sum_of_dist_leₓ'. -/
/-- A version of `dist_le_range_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_range_sum_of_dist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ}
(hd : ∀ {k}, k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f 0) (f n) ≤ ∑ i in Finset.range n, d i :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_of_dist_le (zero_le n) fun _ _ => hd
#align dist_le_range_sum_of_dist_le dist_le_range_sum_of_dist_le
#print swap_dist /-
theorem swap_dist : Function.swap (@dist α _) = dist := by funext x y <;> exact dist_comm _ _
#align swap_dist swap_dist
-/
/- warning: abs_dist_sub_le -> abs_dist_sub_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x z) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y z))) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x z) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y z))) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)
Case conversion may be inaccurate. Consider using '#align abs_dist_sub_le abs_dist_sub_leₓ'. -/
theorem abs_dist_sub_le (x y z : α) : |dist x z - dist y z| ≤ dist x y :=
abs_sub_le_iff.2
⟨sub_le_iff_le_add.2 (dist_triangle _ _ _), sub_le_iff_le_add.2 (dist_triangle_left _ _ _)⟩
#align abs_dist_sub_le abs_dist_sub_le
/- warning: dist_nonneg -> dist_nonneg is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α}, LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α}, LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)
Case conversion may be inaccurate. Consider using '#align dist_nonneg dist_nonnegₓ'. -/
theorem dist_nonneg {x y : α} : 0 ≤ dist x y :=
PseudoMetricSpace.dist_nonneg' dist dist_self dist_comm dist_triangle
#align dist_nonneg dist_nonneg
section
open Tactic Tactic.Positivity
/-- Extension for the `positivity` tactic: distances are nonnegative. -/
@[positivity]
unsafe def _root_.tactic.positivity_dist : expr → tactic strictness
| q(dist $(a) $(b)) => nonnegative <$> mk_app `` dist_nonneg [a, b]
| _ => failed
#align tactic.positivity_dist tactic.positivity_dist
end
/- warning: abs_dist -> abs_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {a : α} {b : α}, Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {a : α} {b : α}, Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b)
Case conversion may be inaccurate. Consider using '#align abs_dist abs_distₓ'. -/
@[simp]
theorem abs_dist {a b : α} : |dist a b| = dist a b :=
abs_of_nonneg dist_nonneg
#align abs_dist abs_dist
#print NNDist /-
/-- A version of `has_dist` that takes value in `ℝ≥0`. -/
class NNDist (α : Type _) where
nndist : α → α → ℝ≥0
#align has_nndist NNDist
-/
export NNDist (nndist)
#print PseudoMetricSpace.toNNDist /-
-- see Note [lower instance priority]
/-- Distance as a nonnegative real number. -/
instance (priority := 100) PseudoMetricSpace.toNNDist : NNDist α :=
⟨fun a b => ⟨dist a b, dist_nonneg⟩⟩
#align pseudo_metric_space.to_has_nndist PseudoMetricSpace.toNNDist
-/
#print nndist_edist /-
/-- Express `nndist` in terms of `edist`-/
theorem nndist_edist (x y : α) : nndist x y = (edist x y).toNNReal := by
simp [nndist, edist_dist, Real.toNNReal, max_eq_left dist_nonneg, ENNReal.ofReal]
#align nndist_edist nndist_edist
-/
#print edist_nndist /-
/-- Express `edist` in terms of `nndist`-/
theorem edist_nndist (x y : α) : edist x y = ↑(nndist x y) := by
simpa only [edist_dist, ENNReal.ofReal_eq_coe_nnreal dist_nonneg]
#align edist_nndist edist_nndist
-/
#print coe_nnreal_ennreal_nndist /-
@[simp, norm_cast]
theorem coe_nnreal_ennreal_nndist (x y : α) : ↑(nndist x y) = edist x y :=
(edist_nndist x y).symm
#align coe_nnreal_ennreal_nndist coe_nnreal_ennreal_nndist
-/
/- warning: edist_lt_coe -> edist_lt_coe is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal ENNReal (HasLiftT.mk.{1, 1} NNReal ENNReal (CoeTCₓ.coe.{1, 1} NNReal ENNReal (coeBase.{1, 1} NNReal ENNReal ENNReal.hasCoe))) c)) (LT.lt.{0} NNReal (Preorder.toLT.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.some c)) (LT.lt.{0} NNReal (Preorder.toLT.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
Case conversion may be inaccurate. Consider using '#align edist_lt_coe edist_lt_coeₓ'. -/
@[simp, norm_cast]
theorem edist_lt_coe {x y : α} {c : ℝ≥0} : edist x y < c ↔ nndist x y < c := by
rw [edist_nndist, ENNReal.coe_lt_coe]
#align edist_lt_coe edist_lt_coe
/- warning: edist_le_coe -> edist_le_coe is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal ENNReal (HasLiftT.mk.{1, 1} NNReal ENNReal (CoeTCₓ.coe.{1, 1} NNReal ENNReal (coeBase.{1, 1} NNReal ENNReal ENNReal.hasCoe))) c)) (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.some c)) (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
Case conversion may be inaccurate. Consider using '#align edist_le_coe edist_le_coeₓ'. -/
@[simp, norm_cast]
theorem edist_le_coe {x y : α} {c : ℝ≥0} : edist x y ≤ c ↔ nndist x y ≤ c := by
rw [edist_nndist, ENNReal.coe_le_coe]
#align edist_le_coe edist_le_coe
/- warning: edist_lt_top -> edist_lt_top is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] (x : α) (y : α), LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_2) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] (x : α) (y : α), LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_2) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))
Case conversion may be inaccurate. Consider using '#align edist_lt_top edist_lt_topₓ'. -/
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_lt_top {α : Type _} [PseudoMetricSpace α] (x y : α) : edist x y < ⊤ :=
(edist_dist x y).symm ▸ ENNReal.ofReal_lt_top
#align edist_lt_top edist_lt_top
/- warning: edist_ne_top -> edist_ne_top is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))
Case conversion may be inaccurate. Consider using '#align edist_ne_top edist_ne_topₓ'. -/
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_ne_top (x y : α) : edist x y ≠ ⊤ :=
(edist_lt_top x y).Ne
#align edist_ne_top edist_ne_top
/- warning: nndist_self -> nndist_self is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (a : α), Eq.{1} NNReal (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) a a) (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring)))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (a : α), Eq.{1} NNReal (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) a a) (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero))
Case conversion may be inaccurate. Consider using '#align nndist_self nndist_selfₓ'. -/
/-- `nndist x x` vanishes-/
@[simp]
theorem nndist_self (a : α) : nndist a a = 0 :=
(NNReal.coe_eq_zero _).1 (dist_self a)
#align nndist_self nndist_self
/- warning: dist_nndist -> dist_nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (NNReal.toReal (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y))
Case conversion may be inaccurate. Consider using '#align dist_nndist dist_nndistₓ'. -/
/-- Express `dist` in terms of `nndist`-/
theorem dist_nndist (x y : α) : dist x y = ↑(nndist x y) :=
rfl
#align dist_nndist dist_nndist
/- warning: coe_nndist -> coe_nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Eq.{1} Real ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α), Eq.{1} Real (NNReal.toReal (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)
Case conversion may be inaccurate. Consider using '#align coe_nndist coe_nndistₓ'. -/
@[simp, norm_cast]
theorem coe_nndist (x y : α) : ↑(nndist x y) = dist x y :=
(dist_nndist x y).symm
#align coe_nndist coe_nndist
/- warning: dist_lt_coe -> dist_lt_coe is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) c)) (LT.lt.{0} NNReal (Preorder.toLT.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (NNReal.toReal c)) (LT.lt.{0} NNReal (Preorder.toLT.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
Case conversion may be inaccurate. Consider using '#align dist_lt_coe dist_lt_coeₓ'. -/
@[simp, norm_cast]
theorem dist_lt_coe {x y : α} {c : ℝ≥0} : dist x y < c ↔ nndist x y < c :=
Iff.rfl
#align dist_lt_coe dist_lt_coe
/- warning: dist_le_coe -> dist_le_coe is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) c)) (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {c : NNReal}, Iff (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (NNReal.toReal c)) (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) c)
Case conversion may be inaccurate. Consider using '#align dist_le_coe dist_le_coeₓ'. -/
@[simp, norm_cast]
theorem dist_le_coe {x y : α} {c : ℝ≥0} : dist x y ≤ c ↔ nndist x y ≤ c :=
Iff.rfl
#align dist_le_coe dist_le_coe
/- warning: edist_lt_of_real -> edist_lt_ofReal is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {r : Real}, Iff (LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.ofReal r)) (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) r)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {r : Real}, Iff (LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.ofReal r)) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) r)
Case conversion may be inaccurate. Consider using '#align edist_lt_of_real edist_lt_ofRealₓ'. -/
@[simp]
theorem edist_lt_ofReal {x y : α} {r : ℝ} : edist x y < ENNReal.ofReal r ↔ dist x y < r := by
rw [edist_dist, ENNReal.ofReal_lt_ofReal_iff_of_nonneg dist_nonneg]
#align edist_lt_of_real edist_lt_ofReal
/- warning: edist_le_of_real -> edist_le_ofReal is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (Iff (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.ofReal r)) (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) r))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (Iff (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) x y) (ENNReal.ofReal r)) (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) r))
Case conversion may be inaccurate. Consider using '#align edist_le_of_real edist_le_ofRealₓ'. -/
@[simp]
theorem edist_le_ofReal {x y : α} {r : ℝ} (hr : 0 ≤ r) :
edist x y ≤ ENNReal.ofReal r ↔ dist x y ≤ r := by
rw [edist_dist, ENNReal.ofReal_le_ofReal_iff hr]
#align edist_le_of_real edist_le_ofReal
#print nndist_dist /-
/-- Express `nndist` in terms of `dist`-/
theorem nndist_dist (x y : α) : nndist x y = Real.toNNReal (dist x y) := by
rw [dist_nndist, Real.toNNReal_coe]
#align nndist_dist nndist_dist
-/
#print nndist_comm /-
theorem nndist_comm (x y : α) : nndist x y = nndist y x := by
simpa only [dist_nndist, NNReal.coe_eq] using dist_comm x y
#align nndist_comm nndist_comm
-/
/- warning: nndist_triangle -> nndist_triangle is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x z) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toHasAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) y z))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x z) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) y z))
Case conversion may be inaccurate. Consider using '#align nndist_triangle nndist_triangleₓ'. -/
/-- Triangle inequality for the nonnegative distance-/
theorem nndist_triangle (x y z : α) : nndist x z ≤ nndist x y + nndist y z :=
dist_triangle _ _ _
#align nndist_triangle nndist_triangle
/- warning: nndist_triangle_left -> nndist_triangle_left is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toHasAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) z x) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) z y))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) z x) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) z y))
Case conversion may be inaccurate. Consider using '#align nndist_triangle_left nndist_triangle_leftₓ'. -/
theorem nndist_triangle_left (x y z : α) : nndist x y ≤ nndist z x + nndist z y :=
dist_triangle_left _ _ _
#align nndist_triangle_left nndist_triangle_left
/- warning: nndist_triangle_right -> nndist_triangle_right is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toHasAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x z) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) y z))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) (y : α) (z : α), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))))) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) x z) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) y z))
Case conversion may be inaccurate. Consider using '#align nndist_triangle_right nndist_triangle_rightₓ'. -/
theorem nndist_triangle_right (x y z : α) : nndist x y ≤ nndist x z + nndist y z :=
dist_triangle_right _ _ _
#align nndist_triangle_right nndist_triangle_right
#print dist_edist /-
/-- Express `dist` in terms of `edist`-/
theorem dist_edist (x y : α) : dist x y = (edist x y).toReal := by
rw [edist_dist, ENNReal.toReal_ofReal dist_nonneg]
#align dist_edist dist_edist
-/
namespace Metric
-- instantiate pseudometric space as a topology
variable {x y z : α} {δ ε ε₁ ε₂ : ℝ} {s : Set α}
#print Metric.ball /-
/-- `ball x ε` is the set of all points `y` with `dist y x < ε` -/
def ball (x : α) (ε : ℝ) : Set α :=
{ y | dist y x < ε }
#align metric.ball Metric.ball
-/
/- warning: metric.mem_ball -> Metric.mem_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y x) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y x) ε)
Case conversion may be inaccurate. Consider using '#align metric.mem_ball Metric.mem_ballₓ'. -/
@[simp]
theorem mem_ball : y ∈ ball x ε ↔ dist y x < ε :=
Iff.rfl
#align metric.mem_ball Metric.mem_ball
/- warning: metric.mem_ball' -> Metric.mem_ball' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) ε)
Case conversion may be inaccurate. Consider using '#align metric.mem_ball' Metric.mem_ball'ₓ'. -/
theorem mem_ball' : y ∈ ball x ε ↔ dist x y < ε := by rw [dist_comm, mem_ball]
#align metric.mem_ball' Metric.mem_ball'
/- warning: metric.pos_of_mem_ball -> Metric.pos_of_mem_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε)
Case conversion may be inaccurate. Consider using '#align metric.pos_of_mem_ball Metric.pos_of_mem_ballₓ'. -/
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : 0 < ε :=
dist_nonneg.trans_lt hy
#align metric.pos_of_mem_ball Metric.pos_of_mem_ball
/- warning: metric.mem_ball_self -> Metric.mem_ball_self is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Metric.ball.{u1} α _inst_1 x ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (Metric.ball.{u1} α _inst_1 x ε))
Case conversion may be inaccurate. Consider using '#align metric.mem_ball_self Metric.mem_ball_selfₓ'. -/
theorem mem_ball_self (h : 0 < ε) : x ∈ ball x ε :=
show dist x x < ε by rw [dist_self] <;> assumption
#align metric.mem_ball_self Metric.mem_ball_self
/- warning: metric.nonempty_ball -> Metric.nonempty_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Set.Nonempty.{u1} α (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Set.Nonempty.{u1} α (Metric.ball.{u1} α _inst_1 x ε)) (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε)
Case conversion may be inaccurate. Consider using '#align metric.nonempty_ball Metric.nonempty_ballₓ'. -/
@[simp]
theorem nonempty_ball : (ball x ε).Nonempty ↔ 0 < ε :=
⟨fun ⟨x, hx⟩ => pos_of_mem_ball hx, fun h => ⟨x, mem_ball_self h⟩⟩
#align metric.nonempty_ball Metric.nonempty_ball
/- warning: metric.ball_eq_empty -> Metric.ball_eq_empty is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Eq.{succ u1} (Set.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α))) (LE.le.{0} Real Real.hasLe ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Eq.{succ u1} (Set.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α))) (LE.le.{0} Real Real.instLEReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))
Case conversion may be inaccurate. Consider using '#align metric.ball_eq_empty Metric.ball_eq_emptyₓ'. -/
@[simp]
theorem ball_eq_empty : ball x ε = ∅ ↔ ε ≤ 0 := by
rw [← not_nonempty_iff_eq_empty, nonempty_ball, not_lt]
#align metric.ball_eq_empty Metric.ball_eq_empty
/- warning: metric.ball_zero -> Metric.ball_zero is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Eq.{succ u1} (Set.{u1} α) (Metric.ball.{u1} α _inst_1 x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Eq.{succ u1} (Set.{u1} α) (Metric.ball.{u1} α _inst_1 x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α))
Case conversion may be inaccurate. Consider using '#align metric.ball_zero Metric.ball_zeroₓ'. -/
@[simp]
theorem ball_zero : ball x 0 = ∅ := by rw [ball_eq_empty]
#align metric.ball_zero Metric.ball_zero
/- warning: metric.exists_lt_mem_ball_of_mem_ball -> Metric.exists_lt_mem_ball_of_mem_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Metric.ball.{u1} α _inst_1 y ε)) -> (Exists.{1} Real (fun (ε' : Real) => Exists.{0} (LT.lt.{0} Real Real.hasLt ε' ε) (fun (H : LT.lt.{0} Real Real.hasLt ε' ε) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Metric.ball.{u1} α _inst_1 y ε'))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (Metric.ball.{u1} α _inst_1 y ε)) -> (Exists.{1} Real (fun (ε' : Real) => And (LT.lt.{0} Real Real.instLTReal ε' ε) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (Metric.ball.{u1} α _inst_1 y ε'))))
Case conversion may be inaccurate. Consider using '#align metric.exists_lt_mem_ball_of_mem_ball Metric.exists_lt_mem_ball_of_mem_ballₓ'. -/
/-- If a point belongs to an open ball, then there is a strictly smaller radius whose ball also
contains it.
See also `exists_lt_subset_ball`. -/
theorem exists_lt_mem_ball_of_mem_ball (h : x ∈ ball y ε) : ∃ ε' < ε, x ∈ ball y ε' :=
by
simp only [mem_ball] at h⊢
exact ⟨(ε + dist x y) / 2, by linarith, by linarith⟩
#align metric.exists_lt_mem_ball_of_mem_ball Metric.exists_lt_mem_ball_of_mem_ball
/- warning: metric.ball_eq_ball -> Metric.ball_eq_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (ε : Real) (x : α), Eq.{succ u1} (Set.{u1} α) (UniformSpace.ball.{u1} α x (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.snd.{u1, u1} α α p) (Prod.fst.{u1, u1} α α p)) ε))) (Metric.ball.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (ε : Real) (x : α), Eq.{succ u1} (Set.{u1} α) (UniformSpace.ball.{u1} α x (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.snd.{u1, u1} α α p) (Prod.fst.{u1, u1} α α p)) ε))) (Metric.ball.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.ball_eq_ball Metric.ball_eq_ballₓ'. -/
theorem ball_eq_ball (ε : ℝ) (x : α) :
UniformSpace.ball x { p | dist p.2 p.1 < ε } = Metric.ball x ε :=
rfl
#align metric.ball_eq_ball Metric.ball_eq_ball
/- warning: metric.ball_eq_ball' -> Metric.ball_eq_ball' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (ε : Real) (x : α), Eq.{succ u1} (Set.{u1} α) (UniformSpace.ball.{u1} α x (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))) (Metric.ball.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (ε : Real) (x : α), Eq.{succ u1} (Set.{u1} α) (UniformSpace.ball.{u1} α x (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))) (Metric.ball.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.ball_eq_ball' Metric.ball_eq_ball'ₓ'. -/
theorem ball_eq_ball' (ε : ℝ) (x : α) :
UniformSpace.ball x { p | dist p.1 p.2 < ε } = Metric.ball x ε :=
by
ext
simp [dist_comm, UniformSpace.ball]
#align metric.ball_eq_ball' Metric.ball_eq_ball'
/- warning: metric.Union_ball_nat -> Metric.unionᵢ_ball_nat is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))) (Set.univ.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (Nat.cast.{0} Real Real.natCast n))) (Set.univ.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric.Union_ball_nat Metric.unionᵢ_ball_natₓ'. -/
@[simp]
theorem unionᵢ_ball_nat (x : α) : (⋃ n : ℕ, ball x n) = univ :=
unionᵢ_eq_univ_iff.2 fun y => exists_nat_gt (dist y x)
#align metric.Union_ball_nat Metric.unionᵢ_ball_nat
/- warning: metric.Union_ball_nat_succ -> Metric.unionᵢ_ball_nat_succ is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))))) (Set.univ.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))))) (Set.univ.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric.Union_ball_nat_succ Metric.unionᵢ_ball_nat_succₓ'. -/
@[simp]
theorem unionᵢ_ball_nat_succ (x : α) : (⋃ n : ℕ, ball x (n + 1)) = univ :=
unionᵢ_eq_univ_iff.2 fun y => (exists_nat_gt (dist y x)).imp fun n hn => hn.trans (lt_add_one _)
#align metric.Union_ball_nat_succ Metric.unionᵢ_ball_nat_succ
#print Metric.closedBall /-
/-- `closed_ball x ε` is the set of all points `y` with `dist y x ≤ ε` -/
def closedBall (x : α) (ε : ℝ) :=
{ y | dist y x ≤ ε }
#align metric.closed_ball Metric.closedBall
-/
/- warning: metric.mem_closed_ball -> Metric.mem_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y x) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y x) ε)
Case conversion may be inaccurate. Consider using '#align metric.mem_closed_ball Metric.mem_closedBallₓ'. -/
@[simp]
theorem mem_closedBall : y ∈ closedBall x ε ↔ dist y x ≤ ε :=
Iff.rfl
#align metric.mem_closed_ball Metric.mem_closedBall
/- warning: metric.mem_closed_ball' -> Metric.mem_closedBall' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) ε)
Case conversion may be inaccurate. Consider using '#align metric.mem_closed_ball' Metric.mem_closedBall'ₓ'. -/
theorem mem_closedBall' : y ∈ closedBall x ε ↔ dist x y ≤ ε := by rw [dist_comm, mem_closed_ball]
#align metric.mem_closed_ball' Metric.mem_closedBall'
#print Metric.sphere /-
/-- `sphere x ε` is the set of all points `y` with `dist y x = ε` -/
def sphere (x : α) (ε : ℝ) :=
{ y | dist y x = ε }
#align metric.sphere Metric.sphere
-/
#print Metric.mem_sphere /-
@[simp]
theorem mem_sphere : y ∈ sphere x ε ↔ dist y x = ε :=
Iff.rfl
#align metric.mem_sphere Metric.mem_sphere
-/
#print Metric.mem_sphere' /-
theorem mem_sphere' : y ∈ sphere x ε ↔ dist x y = ε := by rw [dist_comm, mem_sphere]
#align metric.mem_sphere' Metric.mem_sphere'
-/
/- warning: metric.ne_of_mem_sphere -> Metric.ne_of_mem_sphere is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.sphere.{u1} α _inst_1 x ε)) -> (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Ne.{succ u1} α y x)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.sphere.{u1} α _inst_1 x ε)) -> (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Ne.{succ u1} α y x)
Case conversion may be inaccurate. Consider using '#align metric.ne_of_mem_sphere Metric.ne_of_mem_sphereₓ'. -/
theorem ne_of_mem_sphere (h : y ∈ sphere x ε) (hε : ε ≠ 0) : y ≠ x :=
by
contrapose! hε
symm
simpa [hε] using h
#align metric.ne_of_mem_sphere Metric.ne_of_mem_sphere
/- warning: metric.sphere_eq_empty_of_subsingleton -> Metric.sphere_eq_empty_of_subsingleton is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} [_inst_2 : Subsingleton.{succ u1} α], (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{succ u1} (Set.{u1} α) (Metric.sphere.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} [_inst_2 : Subsingleton.{succ u1} α], (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{succ u1} (Set.{u1} α) (Metric.sphere.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α)))
Case conversion may be inaccurate. Consider using '#align metric.sphere_eq_empty_of_subsingleton Metric.sphere_eq_empty_of_subsingletonₓ'. -/
theorem sphere_eq_empty_of_subsingleton [Subsingleton α] (hε : ε ≠ 0) : sphere x ε = ∅ :=
Set.eq_empty_iff_forall_not_mem.mpr fun y hy => ne_of_mem_sphere hy hε (Subsingleton.elim _ _)
#align metric.sphere_eq_empty_of_subsingleton Metric.sphere_eq_empty_of_subsingleton
/- warning: metric.sphere_is_empty_of_subsingleton -> Metric.sphere_isEmpty_of_subsingleton is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} [_inst_2 : Subsingleton.{succ u1} α], (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (IsEmpty.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Metric.sphere.{u1} α _inst_1 x ε)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} [_inst_2 : Subsingleton.{succ u1} α], (Ne.{1} Real ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (IsEmpty.{succ u1} (Set.Elem.{u1} α (Metric.sphere.{u1} α _inst_1 x ε)))
Case conversion may be inaccurate. Consider using '#align metric.sphere_is_empty_of_subsingleton Metric.sphere_isEmpty_of_subsingletonₓ'. -/
theorem sphere_isEmpty_of_subsingleton [Subsingleton α] (hε : ε ≠ 0) : IsEmpty (sphere x ε) := by
simp only [sphere_eq_empty_of_subsingleton hε, Set.hasEmptyc.Emptyc.isEmpty α]
#align metric.sphere_is_empty_of_subsingleton Metric.sphere_isEmpty_of_subsingleton
/- warning: metric.mem_closed_ball_self -> Metric.mem_closedBall_self is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Metric.closedBall.{u1} α _inst_1 x ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (Metric.closedBall.{u1} α _inst_1 x ε))
Case conversion may be inaccurate. Consider using '#align metric.mem_closed_ball_self Metric.mem_closedBall_selfₓ'. -/
theorem mem_closedBall_self (h : 0 ≤ ε) : x ∈ closedBall x ε :=
show dist x x ≤ ε by rw [dist_self] <;> assumption
#align metric.mem_closed_ball_self Metric.mem_closedBall_self
/- warning: metric.nonempty_closed_ball -> Metric.nonempty_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Set.Nonempty.{u1} α (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Set.Nonempty.{u1} α (Metric.closedBall.{u1} α _inst_1 x ε)) (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε)
Case conversion may be inaccurate. Consider using '#align metric.nonempty_closed_ball Metric.nonempty_closedBallₓ'. -/
@[simp]
theorem nonempty_closedBall : (closedBall x ε).Nonempty ↔ 0 ≤ ε :=
⟨fun ⟨x, hx⟩ => dist_nonneg.trans hx, fun h => ⟨x, mem_closedBall_self h⟩⟩
#align metric.nonempty_closed_ball Metric.nonempty_closedBall
/- warning: metric.closed_ball_eq_empty -> Metric.closedBall_eq_empty is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α))) (LT.lt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Iff (Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α))) (LT.lt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_eq_empty Metric.closedBall_eq_emptyₓ'. -/
@[simp]
theorem closedBall_eq_empty : closedBall x ε = ∅ ↔ ε < 0 := by
rw [← not_nonempty_iff_eq_empty, nonempty_closed_ball, not_le]
#align metric.closed_ball_eq_empty Metric.closedBall_eq_empty
#print Metric.ball_subset_closedBall /-
theorem ball_subset_closedBall : ball x ε ⊆ closedBall x ε := fun y (hy : _ < _) => le_of_lt hy
#align metric.ball_subset_closed_ball Metric.ball_subset_closedBall
-/
#print Metric.sphere_subset_closedBall /-
theorem sphere_subset_closedBall : sphere x ε ⊆ closedBall x ε := fun y => le_of_eq
#align metric.sphere_subset_closed_ball Metric.sphere_subset_closedBall
-/
/- warning: metric.closed_ball_disjoint_ball -> Metric.closedBall_disjoint_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Metric.closedBall.{u1} α _inst_1 x δ) (Metric.ball.{u1} α _inst_1 y ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Metric.closedBall.{u1} α _inst_1 x δ) (Metric.ball.{u1} α _inst_1 y ε))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_disjoint_ball Metric.closedBall_disjoint_ballₓ'. -/
theorem closedBall_disjoint_ball (h : δ + ε ≤ dist x y) : Disjoint (closedBall x δ) (ball y ε) :=
Set.disjoint_left.mpr fun a ha1 ha2 =>
(h.trans <| dist_triangle_left _ _ _).not_lt <| add_lt_add_of_le_of_lt ha1 ha2
#align metric.closed_ball_disjoint_ball Metric.closedBall_disjoint_ball
/- warning: metric.ball_disjoint_closed_ball -> Metric.ball_disjoint_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Metric.ball.{u1} α _inst_1 x δ) (Metric.closedBall.{u1} α _inst_1 y ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Metric.ball.{u1} α _inst_1 x δ) (Metric.closedBall.{u1} α _inst_1 y ε))
Case conversion may be inaccurate. Consider using '#align metric.ball_disjoint_closed_ball Metric.ball_disjoint_closedBallₓ'. -/
theorem ball_disjoint_closedBall (h : δ + ε ≤ dist x y) : Disjoint (ball x δ) (closedBall y ε) :=
(closedBall_disjoint_ball <| by rwa [add_comm, dist_comm]).symm
#align metric.ball_disjoint_closed_ball Metric.ball_disjoint_closedBall
/- warning: metric.ball_disjoint_ball -> Metric.ball_disjoint_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Metric.ball.{u1} α _inst_1 x δ) (Metric.ball.{u1} α _inst_1 y ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Metric.ball.{u1} α _inst_1 x δ) (Metric.ball.{u1} α _inst_1 y ε))
Case conversion may be inaccurate. Consider using '#align metric.ball_disjoint_ball Metric.ball_disjoint_ballₓ'. -/
theorem ball_disjoint_ball (h : δ + ε ≤ dist x y) : Disjoint (ball x δ) (ball y ε) :=
(closedBall_disjoint_ball h).mono_left ball_subset_closedBall
#align metric.ball_disjoint_ball Metric.ball_disjoint_ball
/- warning: metric.closed_ball_disjoint_closed_ball -> Metric.closedBall_disjoint_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LT.lt.{0} Real Real.hasLt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Metric.closedBall.{u1} α _inst_1 x δ) (Metric.closedBall.{u1} α _inst_1 y ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {δ : Real} {ε : Real}, (LT.lt.{0} Real Real.instLTReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) δ ε) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Metric.closedBall.{u1} α _inst_1 x δ) (Metric.closedBall.{u1} α _inst_1 y ε))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_disjoint_closed_ball Metric.closedBall_disjoint_closedBallₓ'. -/
theorem closedBall_disjoint_closedBall (h : δ + ε < dist x y) :
Disjoint (closedBall x δ) (closedBall y ε) :=
Set.disjoint_left.mpr fun a ha1 ha2 =>
h.not_le <| (dist_triangle_left _ _ _).trans <| add_le_add ha1 ha2
#align metric.closed_ball_disjoint_closed_ball Metric.closedBall_disjoint_closedBall
/- warning: metric.sphere_disjoint_ball -> Metric.sphere_disjoint_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Metric.sphere.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Metric.sphere.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.sphere_disjoint_ball Metric.sphere_disjoint_ballₓ'. -/
theorem sphere_disjoint_ball : Disjoint (sphere x ε) (ball x ε) :=
Set.disjoint_left.mpr fun y hy₁ hy₂ => absurd hy₁ <| ne_of_lt hy₂
#align metric.sphere_disjoint_ball Metric.sphere_disjoint_ball
/- warning: metric.ball_union_sphere -> Metric.ball_union_sphere is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (Metric.sphere.{u1} α _inst_1 x ε)) (Metric.closedBall.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (Metric.sphere.{u1} α _inst_1 x ε)) (Metric.closedBall.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.ball_union_sphere Metric.ball_union_sphereₓ'. -/
@[simp]
theorem ball_union_sphere : ball x ε ∪ sphere x ε = closedBall x ε :=
Set.ext fun y => (@le_iff_lt_or_eq ℝ _ _ _).symm
#align metric.ball_union_sphere Metric.ball_union_sphere
/- warning: metric.sphere_union_ball -> Metric.sphere_union_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) (Metric.sphere.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)) (Metric.closedBall.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) (Metric.sphere.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)) (Metric.closedBall.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.sphere_union_ball Metric.sphere_union_ballₓ'. -/
@[simp]
theorem sphere_union_ball : sphere x ε ∪ ball x ε = closedBall x ε := by
rw [union_comm, ball_union_sphere]
#align metric.sphere_union_ball Metric.sphere_union_ball
/- warning: metric.closed_ball_diff_sphere -> Metric.closedBall_diff_sphere is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) (Metric.closedBall.{u1} α _inst_1 x ε) (Metric.sphere.{u1} α _inst_1 x ε)) (Metric.ball.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (Metric.sphere.{u1} α _inst_1 x ε)) (Metric.ball.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_diff_sphere Metric.closedBall_diff_sphereₓ'. -/
@[simp]
theorem closedBall_diff_sphere : closedBall x ε \ sphere x ε = ball x ε := by
rw [← ball_union_sphere, Set.union_diff_cancel_right sphere_disjoint_ball.symm.le_bot]
#align metric.closed_ball_diff_sphere Metric.closedBall_diff_sphere
/- warning: metric.closed_ball_diff_ball -> Metric.closedBall_diff_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) (Metric.closedBall.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)) (Metric.sphere.{u1} α _inst_1 x ε)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (Metric.ball.{u1} α _inst_1 x ε)) (Metric.sphere.{u1} α _inst_1 x ε)
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_diff_ball Metric.closedBall_diff_ballₓ'. -/
@[simp]
theorem closedBall_diff_ball : closedBall x ε \ ball x ε = sphere x ε := by
rw [← ball_union_sphere, Set.union_diff_cancel_left sphere_disjoint_ball.symm.le_bot]
#align metric.closed_ball_diff_ball Metric.closedBall_diff_ball
#print Metric.mem_ball_comm /-
theorem mem_ball_comm : x ∈ ball y ε ↔ y ∈ ball x ε := by rw [mem_ball', mem_ball]
#align metric.mem_ball_comm Metric.mem_ball_comm
-/
#print Metric.mem_closedBall_comm /-
theorem mem_closedBall_comm : x ∈ closedBall y ε ↔ y ∈ closedBall x ε := by
rw [mem_closed_ball', mem_closed_ball]
#align metric.mem_closed_ball_comm Metric.mem_closedBall_comm
-/
#print Metric.mem_sphere_comm /-
theorem mem_sphere_comm : x ∈ sphere y ε ↔ y ∈ sphere x ε := by rw [mem_sphere', mem_sphere]
#align metric.mem_sphere_comm Metric.mem_sphere_comm
-/
/- warning: metric.ball_subset_ball -> Metric.ball_subset_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.hasLe ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 x ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.instLEReal ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 x ε₂))
Case conversion may be inaccurate. Consider using '#align metric.ball_subset_ball Metric.ball_subset_ballₓ'. -/
theorem ball_subset_ball (h : ε₁ ≤ ε₂) : ball x ε₁ ⊆ ball x ε₂ := fun y (yx : _ < ε₁) =>
lt_of_lt_of_le yx h
#align metric.ball_subset_ball Metric.ball_subset_ball
/- warning: metric.closed_ball_eq_bInter_ball -> Metric.closedBall_eq_bInter_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (Set.interᵢ.{u1, 1} α Real (fun (δ : Real) => Set.interᵢ.{u1, 0} α (GT.gt.{0} Real Real.hasLt δ ε) (fun (H : GT.gt.{0} Real Real.hasLt δ ε) => Metric.ball.{u1} α _inst_1 x δ)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (Set.interᵢ.{u1, 1} α Real (fun (δ : Real) => Set.interᵢ.{u1, 0} α (GT.gt.{0} Real Real.instLTReal δ ε) (fun (H : GT.gt.{0} Real Real.instLTReal δ ε) => Metric.ball.{u1} α _inst_1 x δ)))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_eq_bInter_ball Metric.closedBall_eq_bInter_ballₓ'. -/
theorem closedBall_eq_bInter_ball : closedBall x ε = ⋂ δ > ε, ball x δ := by
ext y <;> rw [mem_closed_ball, ← forall_lt_iff_le', mem_Inter₂] <;> rfl
#align metric.closed_ball_eq_bInter_ball Metric.closedBall_eq_bInter_ball
/- warning: metric.ball_subset_ball' -> Metric.ball_subset_ball' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
Case conversion may be inaccurate. Consider using '#align metric.ball_subset_ball' Metric.ball_subset_ball'ₓ'. -/
theorem ball_subset_ball' (h : ε₁ + dist x y ≤ ε₂) : ball x ε₁ ⊆ ball y ε₂ := fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ < ε₁ + dist x y := (add_lt_add_right hz _)
_ ≤ ε₂ := h
#align metric.ball_subset_ball' Metric.ball_subset_ball'
/- warning: metric.closed_ball_subset_closed_ball -> Metric.closedBall_subset_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.hasLe ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 x ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.instLEReal ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 x ε₂))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_subset_closed_ball Metric.closedBall_subset_closedBallₓ'. -/
theorem closedBall_subset_closedBall (h : ε₁ ≤ ε₂) : closedBall x ε₁ ⊆ closedBall x ε₂ :=
fun y (yx : _ ≤ ε₁) => le_trans yx h
#align metric.closed_ball_subset_closed_ball Metric.closedBall_subset_closedBall
/- warning: metric.closed_ball_subset_closed_ball' -> Metric.closedBall_subset_closedBall' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_subset_closed_ball' Metric.closedBall_subset_closedBall'ₓ'. -/
theorem closedBall_subset_closedBall' (h : ε₁ + dist x y ≤ ε₂) :
closedBall x ε₁ ⊆ closedBall y ε₂ := fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ ≤ ε₁ + dist x y := (add_le_add_right hz _)
_ ≤ ε₂ := h
#align metric.closed_ball_subset_closed_ball' Metric.closedBall_subset_closedBall'
/- warning: metric.closed_ball_subset_ball -> Metric.closedBall_subset_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LT.lt.{0} Real Real.hasLt ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 x ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε₁ : Real} {ε₂ : Real}, (LT.lt.{0} Real Real.instLTReal ε₁ ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 x ε₂))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_subset_ball Metric.closedBall_subset_ballₓ'. -/
theorem closedBall_subset_ball (h : ε₁ < ε₂) : closedBall x ε₁ ⊆ ball x ε₂ :=
fun y (yh : dist y x ≤ ε₁) => lt_of_le_of_lt yh h
#align metric.closed_ball_subset_ball Metric.closedBall_subset_ball
/- warning: metric.closed_ball_subset_ball' -> Metric.closedBall_subset_ball' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LT.lt.{0} Real Real.hasLt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LT.lt.{0} Real Real.instLTReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) ε₂) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_subset_ball' Metric.closedBall_subset_ball'ₓ'. -/
theorem closedBall_subset_ball' (h : ε₁ + dist x y < ε₂) : closedBall x ε₁ ⊆ ball y ε₂ :=
fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ ≤ ε₁ + dist x y := (add_le_add_right hz _)
_ < ε₂ := h
#align metric.closed_ball_subset_ball' Metric.closedBall_subset_ball'
/- warning: metric.dist_le_add_of_nonempty_closed_ball_inter_closed_ball -> Metric.dist_le_add_of_nonempty_closedBall_inter_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ ε₂))
Case conversion may be inaccurate. Consider using '#align metric.dist_le_add_of_nonempty_closed_ball_inter_closed_ball Metric.dist_le_add_of_nonempty_closedBall_inter_closedBallₓ'. -/
theorem dist_le_add_of_nonempty_closedBall_inter_closedBall
(h : (closedBall x ε₁ ∩ closedBall y ε₂).Nonempty) : dist x y ≤ ε₁ + ε₂ :=
let ⟨z, hz⟩ := h
calc
dist x y ≤ dist z x + dist z y := dist_triangle_left _ _ _
_ ≤ ε₁ + ε₂ := add_le_add hz.1 hz.2
#align metric.dist_le_add_of_nonempty_closed_ball_inter_closed_ball Metric.dist_le_add_of_nonempty_closedBall_inter_closedBall
/- warning: metric.dist_lt_add_of_nonempty_closed_ball_inter_ball -> Metric.dist_lt_add_of_nonempty_closedBall_inter_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ ε₂))
Case conversion may be inaccurate. Consider using '#align metric.dist_lt_add_of_nonempty_closed_ball_inter_ball Metric.dist_lt_add_of_nonempty_closedBall_inter_ballₓ'. -/
theorem dist_lt_add_of_nonempty_closedBall_inter_ball (h : (closedBall x ε₁ ∩ ball y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ :=
let ⟨z, hz⟩ := h
calc
dist x y ≤ dist z x + dist z y := dist_triangle_left _ _ _
_ < ε₁ + ε₂ := add_lt_add_of_le_of_lt hz.1 hz.2
#align metric.dist_lt_add_of_nonempty_closed_ball_inter_ball Metric.dist_lt_add_of_nonempty_closedBall_inter_ball
/- warning: metric.dist_lt_add_of_nonempty_ball_inter_closed_ball -> Metric.dist_lt_add_of_nonempty_ball_inter_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.closedBall.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ ε₂))
Case conversion may be inaccurate. Consider using '#align metric.dist_lt_add_of_nonempty_ball_inter_closed_ball Metric.dist_lt_add_of_nonempty_ball_inter_closedBallₓ'. -/
theorem dist_lt_add_of_nonempty_ball_inter_closedBall (h : (ball x ε₁ ∩ closedBall y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ := by
rw [inter_comm] at h
rw [add_comm, dist_comm]
exact dist_lt_add_of_nonempty_closed_ball_inter_ball h
#align metric.dist_lt_add_of_nonempty_ball_inter_closed_ball Metric.dist_lt_add_of_nonempty_ball_inter_closedBall
/- warning: metric.dist_lt_add_of_nonempty_ball_inter_ball -> Metric.dist_lt_add_of_nonempty_ball_inter_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ε₁ ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) ε₁ ε₂))
Case conversion may be inaccurate. Consider using '#align metric.dist_lt_add_of_nonempty_ball_inter_ball Metric.dist_lt_add_of_nonempty_ball_inter_ballₓ'. -/
theorem dist_lt_add_of_nonempty_ball_inter_ball (h : (ball x ε₁ ∩ ball y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ :=
dist_lt_add_of_nonempty_closedBall_inter_ball <|
h.mono (inter_subset_inter ball_subset_closedBall Subset.rfl)
#align metric.dist_lt_add_of_nonempty_ball_inter_ball Metric.dist_lt_add_of_nonempty_ball_inter_ball
/- warning: metric.Union_closed_ball_nat -> Metric.unionᵢ_closedBall_nat is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.closedBall.{u1} α _inst_1 x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))) (Set.univ.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Metric.closedBall.{u1} α _inst_1 x (Nat.cast.{0} Real Real.natCast n))) (Set.univ.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric.Union_closed_ball_nat Metric.unionᵢ_closedBall_natₓ'. -/
@[simp]
theorem unionᵢ_closedBall_nat (x : α) : (⋃ n : ℕ, closedBall x n) = univ :=
unionᵢ_eq_univ_iff.2 fun y => exists_nat_ge (dist y x)
#align metric.Union_closed_ball_nat Metric.unionᵢ_closedBall_nat
/- warning: metric.Union_inter_closed_ball_nat -> Metric.unionᵢ_inter_closedBall_nat is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (s : Set.{u1} α) (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s (Metric.closedBall.{u1} α _inst_1 x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n)))) s
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (s : Set.{u1} α) (x : α), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s (Metric.closedBall.{u1} α _inst_1 x (Nat.cast.{0} Real Real.natCast n)))) s
Case conversion may be inaccurate. Consider using '#align metric.Union_inter_closed_ball_nat Metric.unionᵢ_inter_closedBall_natₓ'. -/
theorem unionᵢ_inter_closedBall_nat (s : Set α) (x : α) : (⋃ n : ℕ, s ∩ closedBall x n) = s := by
rw [← inter_Union, Union_closed_ball_nat, inter_univ]
#align metric.Union_inter_closed_ball_nat Metric.unionᵢ_inter_closedBall_nat
/- warning: metric.ball_subset -> Metric.ball_subset is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) ε₂ ε₁)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε₁ : Real} {ε₂ : Real}, (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) ε₂ ε₁)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε₁) (Metric.ball.{u1} α _inst_1 y ε₂))
Case conversion may be inaccurate. Consider using '#align metric.ball_subset Metric.ball_subsetₓ'. -/
theorem ball_subset (h : dist x y ≤ ε₂ - ε₁) : ball x ε₁ ⊆ ball y ε₂ := fun z zx => by
rw [← add_sub_cancel'_right ε₁ ε₂] <;>
exact lt_of_le_of_lt (dist_triangle z x y) (add_lt_add_of_lt_of_le zx h)
#align metric.ball_subset Metric.ball_subset
/- warning: metric.ball_half_subset -> Metric.ball_half_subset is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) ε (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 y (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) ε (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))) (Metric.ball.{u1} α _inst_1 x ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real} (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) ε (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 y (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) ε (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) (Metric.ball.{u1} α _inst_1 x ε))
Case conversion may be inaccurate. Consider using '#align metric.ball_half_subset Metric.ball_half_subsetₓ'. -/
theorem ball_half_subset (y) (h : y ∈ ball x (ε / 2)) : ball y (ε / 2) ⊆ ball x ε :=
ball_subset <| by rw [sub_self_div_two] <;> exact le_of_lt h
#align metric.ball_half_subset Metric.ball_half_subset
/- warning: metric.exists_ball_subset_ball -> Metric.exists_ball_subset_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (Exists.{1} Real (fun (ε' : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε' (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε' (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 y ε') (Metric.ball.{u1} α _inst_1 x ε))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {ε : Real}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (Exists.{1} Real (fun (ε' : Real) => And (GT.gt.{0} Real Real.instLTReal ε' (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 y ε') (Metric.ball.{u1} α _inst_1 x ε))))
Case conversion may be inaccurate. Consider using '#align metric.exists_ball_subset_ball Metric.exists_ball_subset_ballₓ'. -/
theorem exists_ball_subset_ball (h : y ∈ ball x ε) : ∃ ε' > 0, ball y ε' ⊆ ball x ε :=
⟨_, sub_pos.2 h, ball_subset <| by rw [sub_sub_self]⟩
#align metric.exists_ball_subset_ball Metric.exists_ball_subset_ball
#print Metric.forall_of_forall_mem_closedBall /-
/-- If a property holds for all points in closed balls of arbitrarily large radii, then it holds for
all points. -/
theorem forall_of_forall_mem_closedBall (p : α → Prop) (x : α)
(H : ∃ᶠ R : ℝ in atTop, ∀ y ∈ closedBall x R, p y) (y : α) : p y :=
by
obtain ⟨R, hR, h⟩ : ∃ (R : ℝ)(H : dist y x ≤ R), ∀ z : α, z ∈ closed_ball x R → p z :=
frequently_iff.1 H (Ici_mem_at_top (dist y x))
exact h _ hR
#align metric.forall_of_forall_mem_closed_ball Metric.forall_of_forall_mem_closedBall
-/
#print Metric.forall_of_forall_mem_ball /-
/-- If a property holds for all points in balls of arbitrarily large radii, then it holds for all
points. -/
theorem forall_of_forall_mem_ball (p : α → Prop) (x : α)
(H : ∃ᶠ R : ℝ in atTop, ∀ y ∈ ball x R, p y) (y : α) : p y :=
by
obtain ⟨R, hR, h⟩ : ∃ (R : ℝ)(H : dist y x < R), ∀ z : α, z ∈ ball x R → p z :=
frequently_iff.1 H (Ioi_mem_at_top (dist y x))
exact h _ hR
#align metric.forall_of_forall_mem_ball Metric.forall_of_forall_mem_ball
-/
/- warning: metric.is_bounded_iff -> Metric.isBounded_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Exists.{1} Real (fun (C : Real) => forall {{x : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall {{y : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Exists.{1} Real (fun (C : Real) => forall {{x : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall {{y : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C))))
Case conversion may be inaccurate. Consider using '#align metric.is_bounded_iff Metric.isBounded_iffₓ'. -/
theorem isBounded_iff {s : Set α} :
IsBounded s ↔ ∃ C : ℝ, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C := by
rw [is_bounded_def, ← Filter.mem_sets, (@PseudoMetricSpace.cobounded_sets α _).out, mem_set_of_eq,
compl_compl]
#align metric.is_bounded_iff Metric.isBounded_iff
/- warning: metric.is_bounded_iff_eventually -> Metric.isBounded_iff_eventually is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Filter.Eventually.{0} Real (fun (C : Real) => forall {{x : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall {{y : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C))) (Filter.atTop.{0} Real Real.preorder))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Filter.Eventually.{0} Real (fun (C : Real) => forall {{x : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall {{y : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C))) (Filter.atTop.{0} Real Real.instPreorderReal))
Case conversion may be inaccurate. Consider using '#align metric.is_bounded_iff_eventually Metric.isBounded_iff_eventuallyₓ'. -/
theorem isBounded_iff_eventually {s : Set α} :
IsBounded s ↔ ∀ᶠ C in atTop, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C :=
isBounded_iff.trans
⟨fun ⟨C, h⟩ => eventually_atTop.2 ⟨C, fun C' hC' x hx y hy => (h hx hy).trans hC'⟩,
Eventually.exists⟩
#align metric.is_bounded_iff_eventually Metric.isBounded_iff_eventually
/- warning: metric.is_bounded_iff_exists_ge -> Metric.isBounded_iff_exists_ge is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} (c : Real), Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Exists.{1} Real (fun (C : Real) => And (LE.le.{0} Real Real.hasLe c C) (forall {{x : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall {{y : α}}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C)))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} (c : Real), Iff (Bornology.IsBounded.{u1} α (PseudoMetricSpace.toBornology.{u1} α _inst_1) s) (Exists.{1} Real (fun (C : Real) => And (LE.le.{0} Real Real.instLEReal c C) (forall {{x : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall {{y : α}}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C)))))
Case conversion may be inaccurate. Consider using '#align metric.is_bounded_iff_exists_ge Metric.isBounded_iff_exists_geₓ'. -/
theorem isBounded_iff_exists_ge {s : Set α} (c : ℝ) :
IsBounded s ↔ ∃ C, c ≤ C ∧ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C :=
⟨fun h => ((eventually_ge_atTop c).And (isBounded_iff_eventually.1 h)).exists, fun h =>
isBounded_iff.2 <| h.imp fun _ => And.right⟩
#align metric.is_bounded_iff_exists_ge Metric.isBounded_iff_exists_ge
#print Metric.isBounded_iff_nndist /-
theorem isBounded_iff_nndist {s : Set α} :
IsBounded s ↔ ∃ C : ℝ≥0, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → nndist x y ≤ C := by
simp only [is_bounded_iff_exists_ge 0, NNReal.exists, ← NNReal.coe_le_coe, ← dist_nndist,
NNReal.coe_mk, exists_prop]
#align metric.is_bounded_iff_nndist Metric.isBounded_iff_nndist
-/
#print Metric.toUniformSpace_eq /-
theorem toUniformSpace_eq :
‹PseudoMetricSpace α›.toUniformSpace =
UniformSpace.ofDist dist dist_self dist_comm dist_triangle :=
uniformSpace_eq PseudoMetricSpace.uniformity_dist
#align metric.to_uniform_space_eq Metric.toUniformSpace_eq
-/
/- warning: metric.uniformity_basis_dist -> Metric.uniformity_basis_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : Real) => LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) (fun (ε : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : Real) => LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) (fun (ε : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist Metric.uniformity_basis_distₓ'. -/
theorem uniformity_basis_dist :
(𝓤 α).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : α × α | dist p.1 p.2 < ε } :=
by
rw [to_uniform_space_eq]
exact UniformSpace.hasBasis_ofFun (exists_gt _) _ _ _ _ _
#align metric.uniformity_basis_dist Metric.uniformity_basis_dist
/- warning: metric.mk_uniformity_basis -> Metric.mk_uniformity_basis is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {β : Type.{u2}} {p : β -> Prop} {f : β -> Real}, (forall (i : β), (p i) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (f i))) -> (forall {{ε : Real}}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Exists.{succ u2} β (fun (i : β) => Exists.{0} (p i) (fun (hi : p i) => LE.le.{0} Real Real.hasLe (f i) ε)))) -> (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) p (fun (i : β) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (f i))))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {β : Type.{u1}} {p : β -> Prop} {f : β -> Real}, (forall (i : β), (p i) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (f i))) -> (forall {{ε : Real}}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Exists.{succ u1} β (fun (i : β) => And (p i) (LE.le.{0} Real Real.instLEReal (f i) ε)))) -> (Filter.HasBasis.{u2, succ u1} (Prod.{u2, u2} α α) β (uniformity.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) p (fun (i : β) => setOf.{u2} (Prod.{u2, u2} α α) (fun (p : Prod.{u2, u2} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (Prod.fst.{u2, u2} α α p) (Prod.snd.{u2, u2} α α p)) (f i))))
Case conversion may be inaccurate. Consider using '#align metric.mk_uniformity_basis Metric.mk_uniformity_basisₓ'. -/
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then `f i`-neighborhoods of the diagonal form a basis of `𝓤 α`.
For specific bases see `uniformity_basis_dist`, `uniformity_basis_dist_inv_nat_succ`,
and `uniformity_basis_dist_inv_nat_pos`. -/
protected theorem mk_uniformity_basis {β : Type _} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ i, p i → 0 < f i) (hf : ∀ ⦃ε⦄, 0 < ε → ∃ (i : _)(hi : p i), f i ≤ ε) :
(𝓤 α).HasBasis p fun i => { p : α × α | dist p.1 p.2 < f i } :=
by
refine' ⟨fun s => uniformity_basis_dist.mem_iff.trans _⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
obtain ⟨i, hi, H⟩ : ∃ (i : _)(hi : p i), f i ≤ ε
exact hf ε₀
exact ⟨i, hi, fun x (hx : _ < _) => hε <| lt_of_lt_of_le hx H⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩
#align metric.mk_uniformity_basis Metric.mk_uniformity_basis
/- warning: metric.uniformity_basis_dist_rat -> Metric.uniformity_basis_dist_rat is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Rat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (r : Rat) => LT.lt.{0} Rat Rat.hasLt (OfNat.ofNat.{0} Rat 0 (OfNat.mk.{0} Rat 0 (Zero.zero.{0} Rat Rat.hasZero))) r) (fun (r : Rat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Rat Real (HasLiftT.mk.{1, 1} Rat Real (CoeTCₓ.coe.{1, 1} Rat Real (Rat.castCoe.{0} Real Real.hasRatCast))) r)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Rat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (r : Rat) => LT.lt.{0} Rat Rat.instLTRat_1 (OfNat.ofNat.{0} Rat 0 (Rat.instOfNatRat 0)) r) (fun (r : Rat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (Rat.cast.{0} Real Real.ratCast r)))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_rat Metric.uniformity_basis_dist_ratₓ'. -/
theorem uniformity_basis_dist_rat :
(𝓤 α).HasBasis (fun r : ℚ => 0 < r) fun r => { p : α × α | dist p.1 p.2 < r } :=
Metric.mk_uniformity_basis (fun _ => Rat.cast_pos.2) fun ε hε =>
let ⟨r, hr0, hrε⟩ := exists_rat_btwn hε
⟨r, Rat.cast_pos.1 hr0, hrε.le⟩
#align metric.uniformity_basis_dist_rat Metric.uniformity_basis_dist_rat
/- warning: metric.uniformity_basis_dist_inv_nat_succ -> Metric.uniformity_basis_dist_inv_nat_succ is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (_x : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (_x : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_inv_nat_succ Metric.uniformity_basis_dist_inv_nat_succₓ'. -/
theorem uniformity_basis_dist_inv_nat_succ :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 < 1 / (↑n + 1) } :=
Metric.mk_uniformity_basis (fun n _ => div_pos zero_lt_one <| Nat.cast_add_one_pos n) fun ε ε0 =>
(exists_nat_one_div_lt ε0).imp fun n hn => ⟨trivial, le_of_lt hn⟩
#align metric.uniformity_basis_dist_inv_nat_succ Metric.uniformity_basis_dist_inv_nat_succ
/- warning: metric.uniformity_basis_dist_inv_nat_pos -> Metric.uniformity_basis_dist_inv_nat_pos is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (Nat.cast.{0} Real Real.natCast n))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_inv_nat_pos Metric.uniformity_basis_dist_inv_nat_posₓ'. -/
theorem uniformity_basis_dist_inv_nat_pos :
(𝓤 α).HasBasis (fun n : ℕ => 0 < n) fun n : ℕ => { p : α × α | dist p.1 p.2 < 1 / ↑n } :=
Metric.mk_uniformity_basis (fun n hn => div_pos zero_lt_one <| Nat.cast_pos.2 hn) fun ε ε0 =>
let ⟨n, hn⟩ := exists_nat_one_div_lt ε0
⟨n + 1, Nat.succ_pos n, by exact_mod_cast hn.le⟩
#align metric.uniformity_basis_dist_inv_nat_pos Metric.uniformity_basis_dist_inv_nat_pos
/- warning: metric.uniformity_basis_dist_pow -> Metric.uniformity_basis_dist_pow is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LT.lt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) r n))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LT.lt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) r n))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_pow Metric.uniformity_basis_dist_powₓ'. -/
theorem uniformity_basis_dist_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓤 α).HasBasis (fun n : ℕ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 < r ^ n } :=
Metric.mk_uniformity_basis (fun n hn => pow_pos h0 _) fun ε ε0 =>
let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1
⟨n, trivial, hn.le⟩
#align metric.uniformity_basis_dist_pow Metric.uniformity_basis_dist_pow
/- warning: metric.uniformity_basis_dist_lt -> Metric.uniformity_basis_dist_lt is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {R : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) R) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (r : Real) => And (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) (LT.lt.{0} Real Real.hasLt r R)) (fun (r : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) r)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {R : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) R) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (r : Real) => And (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) (LT.lt.{0} Real Real.instLTReal r R)) (fun (r : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) r)))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_lt Metric.uniformity_basis_dist_ltₓ'. -/
theorem uniformity_basis_dist_lt {R : ℝ} (hR : 0 < R) :
(𝓤 α).HasBasis (fun r : ℝ => 0 < r ∧ r < R) fun r => { p : α × α | dist p.1 p.2 < r } :=
Metric.mk_uniformity_basis (fun r => And.left) fun r hr =>
⟨min r (R / 2), ⟨lt_min hr (half_pos hR), min_lt_iff.2 <| Or.inr (half_lt_self hR)⟩,
min_le_left _ _⟩
#align metric.uniformity_basis_dist_lt Metric.uniformity_basis_dist_lt
/- warning: metric.mk_uniformity_basis_le -> Metric.mk_uniformity_basis_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {β : Type.{u2}} {p : β -> Prop} {f : β -> Real}, (forall (x : β), (p x) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (f x))) -> (forall (ε : Real), (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Exists.{succ u2} β (fun (x : β) => Exists.{0} (p x) (fun (hx : p x) => LE.le.{0} Real Real.hasLe (f x) ε)))) -> (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) p (fun (x : β) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (f x))))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {β : Type.{u1}} {p : β -> Prop} {f : β -> Real}, (forall (x : β), (p x) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (f x))) -> (forall (ε : Real), (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Exists.{succ u1} β (fun (x : β) => And (p x) (LE.le.{0} Real Real.instLEReal (f x) ε)))) -> (Filter.HasBasis.{u2, succ u1} (Prod.{u2, u2} α α) β (uniformity.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) p (fun (x : β) => setOf.{u2} (Prod.{u2, u2} α α) (fun (p : Prod.{u2, u2} α α) => LE.le.{0} Real Real.instLEReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (Prod.fst.{u2, u2} α α p) (Prod.snd.{u2, u2} α α p)) (f x))))
Case conversion may be inaccurate. Consider using '#align metric.mk_uniformity_basis_le Metric.mk_uniformity_basis_leₓ'. -/
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then closed neighborhoods of the diagonal of sizes `{f i | p i}`
form a basis of `𝓤 α`.
Currently we have only one specific basis `uniformity_basis_dist_le` based on this constructor.
More can be easily added if needed in the future. -/
protected theorem mk_uniformity_basis_le {β : Type _} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ (x : _)(hx : p x), f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | dist p.1 p.2 ≤ f x } :=
by
refine' ⟨fun s => uniformity_basis_dist.mem_iff.trans _⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases exists_between ε₀ with ⟨ε', hε'⟩
rcases hf ε' hε'.1 with ⟨i, hi, H⟩
exact ⟨i, hi, fun x (hx : _ ≤ _) => hε <| lt_of_le_of_lt (le_trans hx H) hε'.2⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x (hx : _ < _) => H (le_of_lt hx)⟩
#align metric.mk_uniformity_basis_le Metric.mk_uniformity_basis_le
/- warning: metric.uniformity_basis_dist_le -> Metric.uniformity_basis_dist_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : Real) => LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) (fun (ε : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Real (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : Real) => LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) (fun (ε : Real) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_le Metric.uniformity_basis_dist_leₓ'. -/
/-- Contant size closed neighborhoods of the diagonal form a basis
of the uniformity filter. -/
theorem uniformity_basis_dist_le :
(𝓤 α).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : α × α | dist p.1 p.2 ≤ ε } :=
Metric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩
#align metric.uniformity_basis_dist_le Metric.uniformity_basis_dist_le
/- warning: metric.uniformity_basis_dist_le_pow -> Metric.uniformity_basis_dist_le_pow is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LT.lt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) r n))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LT.lt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) Nat (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (n : Nat) => True) (fun (n : Nat) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) r n))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_basis_dist_le_pow Metric.uniformity_basis_dist_le_powₓ'. -/
theorem uniformity_basis_dist_le_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓤 α).HasBasis (fun n : ℕ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 ≤ r ^ n } :=
Metric.mk_uniformity_basis_le (fun n hn => pow_pos h0 _) fun ε ε0 =>
let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1
⟨n, trivial, hn.le⟩
#align metric.uniformity_basis_dist_le_pow Metric.uniformity_basis_dist_le_pow
/- warning: metric.mem_uniformity_dist -> Metric.mem_uniformity_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, Iff (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : α} {b : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) ε) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) s))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, Iff (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : α} {b : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) ε) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) s))))
Case conversion may be inaccurate. Consider using '#align metric.mem_uniformity_dist Metric.mem_uniformity_distₓ'. -/
theorem mem_uniformity_dist {s : Set (α × α)} :
s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, dist a b < ε → (a, b) ∈ s :=
uniformity_basis_dist.mem_uniformity_iff
#align metric.mem_uniformity_dist Metric.mem_uniformity_dist
/- warning: metric.dist_mem_uniformity -> Metric.dist_mem_uniformity is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align metric.dist_mem_uniformity Metric.dist_mem_uniformityₓ'. -/
/-- A constant size neighborhood of the diagonal is an entourage. -/
theorem dist_mem_uniformity {ε : ℝ} (ε0 : 0 < ε) : { p : α × α | dist p.1 p.2 < ε } ∈ 𝓤 α :=
mem_uniformity_dist.2 ⟨ε, ε0, fun a b => id⟩
#align metric.dist_mem_uniformity Metric.dist_mem_uniformity
/- warning: metric.uniform_continuous_iff -> Metric.uniformContinuous_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (UniformContinuous.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : α} {b : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (UniformContinuous.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : α} {b : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_continuous_iff Metric.uniformContinuous_iffₓ'. -/
theorem uniformContinuous_iff [PseudoMetricSpace β] {f : α → β} :
UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, dist a b < δ → dist (f a) (f b) < ε :=
uniformity_basis_dist.uniformContinuous_iff uniformity_basis_dist
#align metric.uniform_continuous_iff Metric.uniformContinuous_iff
/- warning: metric.uniform_continuous_on_iff -> Metric.uniformContinuousOn_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (UniformContinuousOn.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) (f y)) ε))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (UniformContinuousOn.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) (f y)) ε))))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_continuous_on_iff Metric.uniformContinuousOn_iffₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » s) -/
theorem uniformContinuousOn_iff [PseudoMetricSpace β] {f : α → β} {s : Set α} :
UniformContinuousOn f s ↔
∀ ε > 0, ∃ δ > 0, ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), dist x y < δ → dist (f x) (f y) < ε :=
Metric.uniformity_basis_dist.uniformContinuousOn_iff Metric.uniformity_basis_dist
#align metric.uniform_continuous_on_iff Metric.uniformContinuousOn_iff
/- warning: metric.uniform_continuous_on_iff_le -> Metric.uniformContinuousOn_iff_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (UniformContinuousOn.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) δ) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) (f y)) ε))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (UniformContinuousOn.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) δ) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) (f y)) ε))))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_continuous_on_iff_le Metric.uniformContinuousOn_iff_leₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » s) -/
theorem uniformContinuousOn_iff_le [PseudoMetricSpace β] {f : α → β} {s : Set α} :
UniformContinuousOn f s ↔
∀ ε > 0, ∃ δ > 0, ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), dist x y ≤ δ → dist (f x) (f y) ≤ ε :=
Metric.uniformity_basis_dist_le.uniformContinuousOn_iff Metric.uniformity_basis_dist_le
#align metric.uniform_continuous_on_iff_le Metric.uniformContinuousOn_iff_le
/- warning: metric.uniform_embedding_iff -> Metric.uniformEmbedding_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (UniformEmbedding.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (And (Function.Injective.{succ u1, succ u2} α β f) (And (UniformContinuous.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (forall (δ : Real), (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : α} {b : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ)))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (UniformEmbedding.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (And (Function.Injective.{succ u1, succ u2} α β f) (And (UniformContinuous.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) (forall (δ : Real), (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : α} {b : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ)))))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_embedding_iff Metric.uniformEmbedding_iffₓ'. -/
theorem uniformEmbedding_iff [PseudoMetricSpace β] {f : α → β} :
UniformEmbedding f ↔
Function.Injective f ∧
UniformContinuous f ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ :=
by
simp only [uniformity_basis_dist.uniform_embedding_iff uniformity_basis_dist, exists_prop]
rfl
#align metric.uniform_embedding_iff Metric.uniformEmbedding_iff
/- warning: metric.controlled_of_uniform_embedding -> Metric.controlled_of_uniformEmbedding is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, (UniformEmbedding.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) -> (And (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : α} {b : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε))))) (forall (δ : Real), (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : α} {b : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, (UniformEmbedding.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2) f) -> (And (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : α} {b : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε))))) (forall (δ : Real), (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : α} {b : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ))))))
Case conversion may be inaccurate. Consider using '#align metric.controlled_of_uniform_embedding Metric.controlled_of_uniformEmbeddingₓ'. -/
/-- If a map between pseudometric spaces is a uniform embedding then the distance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y`. -/
theorem controlled_of_uniformEmbedding [PseudoMetricSpace β] {f : α → β} :
UniformEmbedding f →
(∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, dist a b < δ → dist (f a) (f b) < ε) ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ :=
by
intro h
exact ⟨uniformContinuous_iff.1 (uniformEmbedding_iff.1 h).2.1, (uniformEmbedding_iff.1 h).2.2⟩
#align metric.controlled_of_uniform_embedding Metric.controlled_of_uniformEmbedding
/- warning: metric.totally_bounded_iff -> Metric.totallyBounded_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) => Metric.ball.{u1} α _inst_1 y ε)))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) (fun (H : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) => Metric.ball.{u1} α _inst_1 y ε)))))))
Case conversion may be inaccurate. Consider using '#align metric.totally_bounded_iff Metric.totallyBounded_iffₓ'. -/
theorem totallyBounded_iff {s : Set α} :
TotallyBounded s ↔ ∀ ε > 0, ∃ t : Set α, t.Finite ∧ s ⊆ ⋃ y ∈ t, ball y ε :=
⟨fun H ε ε0 => H _ (dist_mem_uniformity ε0), fun H r ru =>
let ⟨ε, ε0, hε⟩ := mem_uniformity_dist.1 ru
let ⟨t, ft, h⟩ := H ε ε0
⟨t, ft, h.trans <| unionᵢ₂_mono fun y yt z => hε⟩⟩
#align metric.totally_bounded_iff Metric.totallyBounded_iff
/- warning: metric.totally_bounded_of_finite_discretization -> Metric.totallyBounded_of_finite_discretization is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ (succ u1)} Type.{u1} (fun (β : Type.{u1}) => Exists.{succ u1} (Fintype.{u1} β) (fun (_x : Fintype.{u1} β) => Exists.{succ u1} ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) -> β) (fun (F : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) -> β) => forall (x : coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (y : coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s), (Eq.{succ u1} β (F x) (F y)) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s))))) y)) ε)))))) -> (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ (succ u1)} Type.{u1} (fun (β : Type.{u1}) => Exists.{succ u1} (Fintype.{u1} β) (fun (_x : Fintype.{u1} β) => Exists.{succ u1} ((Set.Elem.{u1} α s) -> β) (fun (F : (Set.Elem.{u1} α s) -> β) => forall (x : Set.Elem.{u1} α s) (y : Set.Elem.{u1} α s), (Eq.{succ u1} β (F x) (F y)) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) x) (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) y)) ε)))))) -> (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s)
Case conversion may be inaccurate. Consider using '#align metric.totally_bounded_of_finite_discretization Metric.totallyBounded_of_finite_discretizationₓ'. -/
/-- A pseudometric space is totally bounded if one can reconstruct up to any ε>0 any element of the
space from finitely many data. -/
theorem totallyBounded_of_finite_discretization {s : Set α}
(H :
∀ ε > (0 : ℝ),
∃ (β : Type u)(_ : Fintype β)(F : s → β), ∀ x y, F x = F y → dist (x : α) y < ε) :
TotallyBounded s := by
cases' s.eq_empty_or_nonempty with hs hs
· rw [hs]
exact totallyBounded_empty
rcases hs with ⟨x0, hx0⟩
haveI : Inhabited s := ⟨⟨x0, hx0⟩⟩
refine' totally_bounded_iff.2 fun ε ε0 => _
rcases H ε ε0 with ⟨β, fβ, F, hF⟩
skip
let Finv := Function.invFun F
refine' ⟨range (Subtype.val ∘ Finv), finite_range _, fun x xs => _⟩
let x' := Finv (F ⟨x, xs⟩)
have : F x' = F ⟨x, xs⟩ := Function.invFun_eq ⟨⟨x, xs⟩, rfl⟩
simp only [Set.mem_unionᵢ, Set.mem_range]
exact ⟨_, ⟨F ⟨x, xs⟩, rfl⟩, hF _ _ this.symm⟩
#align metric.totally_bounded_of_finite_discretization Metric.totallyBounded_of_finite_discretization
/- warning: metric.finite_approx_of_totally_bounded -> Metric.finite_approx_of_totallyBounded is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s) -> (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) (fun (H : HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) => Metric.ball.{u1} α _inst_1 y ε))))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (TotallyBounded.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) s) -> (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) t s) (And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) (fun (h._@.Mathlib.Topology.MetricSpace.Basic._hyg.10746 : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) => Metric.ball.{u1} α _inst_1 y ε))))))))
Case conversion may be inaccurate. Consider using '#align metric.finite_approx_of_totally_bounded Metric.finite_approx_of_totallyBoundedₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
theorem finite_approx_of_totallyBounded {s : Set α} (hs : TotallyBounded s) :
∀ ε > 0, ∃ (t : _)(_ : t ⊆ s), Set.Finite t ∧ s ⊆ ⋃ y ∈ t, ball y ε :=
by
intro ε ε_pos
rw [totallyBounded_iff_subset] at hs
exact hs _ (dist_mem_uniformity ε_pos)
#align metric.finite_approx_of_totally_bounded Metric.finite_approx_of_totallyBounded
/- warning: metric.tendsto_uniformly_on_filter_iff -> Metric.tendstoUniformlyOnFilter_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u3}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u3} ι} {p' : Filter.{u2} β}, Iff (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) F f p p') (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{max u3 u2} (Prod.{u3, u2} ι β) (fun (n : Prod.{u3, u2} ι β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f (Prod.snd.{u3, u2} ι β n)) (F (Prod.fst.{u3, u2} ι β n) (Prod.snd.{u3, u2} ι β n))) ε) (Filter.prod.{u3, u2} ι β p p')))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u1} ι} {p' : Filter.{u3} β}, Iff (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) F f p p') (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{max u3 u1} (Prod.{u1, u3} ι β) (fun (n : Prod.{u1, u3} ι β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f (Prod.snd.{u1, u3} ι β n)) (F (Prod.fst.{u1, u3} ι β n) (Prod.snd.{u1, u3} ι β n))) ε) (Filter.prod.{u1, u3} ι β p p')))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_uniformly_on_filter_iff Metric.tendstoUniformlyOnFilter_iffₓ'. -/
/-- Expressing uniform convergence using `dist` -/
theorem tendstoUniformlyOnFilter_iff {ι : Type _} {F : ι → β → α} {f : β → α} {p : Filter ι}
{p' : Filter β} :
TendstoUniformlyOnFilter F f p p' ↔
∀ ε > 0, ∀ᶠ n : ι × β in p ×ᶠ p', dist (f n.snd) (F n.fst n.snd) < ε :=
by
refine' ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu => _⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
refine' (H ε εpos).mono fun n hn => hε hn
#align metric.tendsto_uniformly_on_filter_iff Metric.tendstoUniformlyOnFilter_iff
/- warning: metric.tendsto_locally_uniformly_on_iff -> Metric.tendstoLocallyUniformlyOn_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u3}} [_inst_2 : TopologicalSpace.{u2} β] {F : ι -> β -> α} {f : β -> α} {p : Filter.{u3} ι} {s : Set.{u2} β}, Iff (TendstoLocallyUniformlyOn.{u2, u1, u3} β α ι (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_2 F f p s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (forall (x : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x s) -> (Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => Exists.{0} (Membership.Mem.{u2, u2} (Set.{u2} β) (Filter.{u2} β) (Filter.hasMem.{u2} β) t (nhdsWithin.{u2} β _inst_2 x s)) (fun (H : Membership.Mem.{u2, u2} (Set.{u2} β) (Filter.{u2} β) (Filter.hasMem.{u2} β) t (nhdsWithin.{u2} β _inst_2 x s)) => Filter.Eventually.{u3} ι (fun (n : ι) => forall (y : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) y t) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f y) (F n y)) ε)) p)))))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} [_inst_2 : TopologicalSpace.{u3} β] {F : ι -> β -> α} {f : β -> α} {p : Filter.{u1} ι} {s : Set.{u3} β}, Iff (TendstoLocallyUniformlyOn.{u3, u2, u1} β α ι (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) _inst_2 F f p s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (forall (x : β), (Membership.mem.{u3, u3} β (Set.{u3} β) (Set.instMembershipSet.{u3} β) x s) -> (Exists.{succ u3} (Set.{u3} β) (fun (t : Set.{u3} β) => And (Membership.mem.{u3, u3} (Set.{u3} β) (Filter.{u3} β) (instMembershipSetFilter.{u3} β) t (nhdsWithin.{u3} β _inst_2 x s)) (Filter.Eventually.{u1} ι (fun (n : ι) => forall (y : β), (Membership.mem.{u3, u3} β (Set.{u3} β) (Set.instMembershipSet.{u3} β) y t) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f y) (F n y)) ε)) p)))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_locally_uniformly_on_iff Metric.tendstoLocallyUniformlyOn_iffₓ'. -/
/-- Expressing locally uniform convergence on a set using `dist`. -/
theorem tendstoLocallyUniformlyOn_iff {ι : Type _} [TopologicalSpace β] {F : ι → β → α} {f : β → α}
{p : Filter ι} {s : Set β} :
TendstoLocallyUniformlyOn F f p s ↔
∀ ε > 0, ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε :=
by
refine' ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu x hx => _⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
rcases H ε εpos x hx with ⟨t, ht, Ht⟩
exact ⟨t, ht, Ht.mono fun n hs x hx => hε (hs x hx)⟩
#align metric.tendsto_locally_uniformly_on_iff Metric.tendstoLocallyUniformlyOn_iff
/- warning: metric.tendsto_uniformly_on_iff -> Metric.tendstoUniformlyOn_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u3}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u3} ι} {s : Set.{u2} β}, Iff (TendstoUniformlyOn.{u2, u1, u3} β α ι (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) F f p s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u3} ι (fun (n : ι) => forall (x : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (F n x)) ε)) p))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u1} ι} {s : Set.{u3} β}, Iff (TendstoUniformlyOn.{u3, u2, u1} β α ι (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) F f p s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u1} ι (fun (n : ι) => forall (x : β), (Membership.mem.{u3, u3} β (Set.{u3} β) (Set.instMembershipSet.{u3} β) x s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f x) (F n x)) ε)) p))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_uniformly_on_iff Metric.tendstoUniformlyOn_iffₓ'. -/
/-- Expressing uniform convergence on a set using `dist`. -/
theorem tendstoUniformlyOn_iff {ι : Type _} {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} :
TendstoUniformlyOn F f p s ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x ∈ s, dist (f x) (F n x) < ε :=
by
refine' ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu => _⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
exact (H ε εpos).mono fun n hs x hx => hε (hs x hx)
#align metric.tendsto_uniformly_on_iff Metric.tendstoUniformlyOn_iff
/- warning: metric.tendsto_locally_uniformly_iff -> Metric.tendstoLocallyUniformly_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u3}} [_inst_2 : TopologicalSpace.{u2} β] {F : ι -> β -> α} {f : β -> α} {p : Filter.{u3} ι}, Iff (TendstoLocallyUniformly.{u2, u1, u3} β α ι (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_2 F f p) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (forall (x : β), Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => Exists.{0} (Membership.Mem.{u2, u2} (Set.{u2} β) (Filter.{u2} β) (Filter.hasMem.{u2} β) t (nhds.{u2} β _inst_2 x)) (fun (H : Membership.Mem.{u2, u2} (Set.{u2} β) (Filter.{u2} β) (Filter.hasMem.{u2} β) t (nhds.{u2} β _inst_2 x)) => Filter.Eventually.{u3} ι (fun (n : ι) => forall (y : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) y t) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f y) (F n y)) ε)) p))))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} [_inst_2 : TopologicalSpace.{u3} β] {F : ι -> β -> α} {f : β -> α} {p : Filter.{u1} ι}, Iff (TendstoLocallyUniformly.{u3, u2, u1} β α ι (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) _inst_2 F f p) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (forall (x : β), Exists.{succ u3} (Set.{u3} β) (fun (t : Set.{u3} β) => And (Membership.mem.{u3, u3} (Set.{u3} β) (Filter.{u3} β) (instMembershipSetFilter.{u3} β) t (nhds.{u3} β _inst_2 x)) (Filter.Eventually.{u1} ι (fun (n : ι) => forall (y : β), (Membership.mem.{u3, u3} β (Set.{u3} β) (Set.instMembershipSet.{u3} β) y t) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f y) (F n y)) ε)) p))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_locally_uniformly_iff Metric.tendstoLocallyUniformly_iffₓ'. -/
/-- Expressing locally uniform convergence using `dist`. -/
theorem tendstoLocallyUniformly_iff {ι : Type _} [TopologicalSpace β] {F : ι → β → α} {f : β → α}
{p : Filter ι} :
TendstoLocallyUniformly F f p ↔
∀ ε > 0, ∀ x : β, ∃ t ∈ 𝓝 x, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε :=
by
simp only [← tendstoLocallyUniformlyOn_univ, tendsto_locally_uniformly_on_iff, nhdsWithin_univ,
mem_univ, forall_const, exists_prop]
#align metric.tendsto_locally_uniformly_iff Metric.tendstoLocallyUniformly_iff
/- warning: metric.tendsto_uniformly_iff -> Metric.tendstoUniformly_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u3}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u3} ι}, Iff (TendstoUniformly.{u2, u1, u3} β α ι (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) F f p) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u3} ι (fun (n : ι) => forall (x : β), LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (F n x)) ε) p))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {F : ι -> β -> α} {f : β -> α} {p : Filter.{u1} ι}, Iff (TendstoUniformly.{u3, u2, u1} β α ι (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) F f p) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u1} ι (fun (n : ι) => forall (x : β), LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f x) (F n x)) ε) p))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_uniformly_iff Metric.tendstoUniformly_iffₓ'. -/
/-- Expressing uniform convergence using `dist`. -/
theorem tendstoUniformly_iff {ι : Type _} {F : ι → β → α} {f : β → α} {p : Filter ι} :
TendstoUniformly F f p ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x, dist (f x) (F n x) < ε :=
by
rw [← tendstoUniformlyOn_univ, tendsto_uniformly_on_iff]
simp
#align metric.tendsto_uniformly_iff Metric.tendstoUniformly_iff
/- warning: metric.cauchy_iff -> Metric.cauchy_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Filter.{u1} α}, Iff (Cauchy.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) f) (And (Filter.NeBot.{u1} α f) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) t f) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) t f) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ε)))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Filter.{u1} α}, Iff (Cauchy.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) f) (And (Filter.NeBot.{u1} α f) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) t f) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) ε)))))))
Case conversion may be inaccurate. Consider using '#align metric.cauchy_iff Metric.cauchy_iffₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » t) -/
protected theorem cauchy_iff {f : Filter α} :
Cauchy f ↔ NeBot f ∧ ∀ ε > 0, ∃ t ∈ f, ∀ (x) (_ : x ∈ t) (y) (_ : y ∈ t), dist x y < ε :=
uniformity_basis_dist.cauchy_iff
#align metric.cauchy_iff Metric.cauchy_iff
/- warning: metric.nhds_basis_ball -> Metric.nhds_basis_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Real (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (ε : Real) => LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) (Metric.ball.{u1} α _inst_1 x)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Real (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (ε : Real) => LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) (Metric.ball.{u1} α _inst_1 x)
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_ball Metric.nhds_basis_ballₓ'. -/
theorem nhds_basis_ball : (𝓝 x).HasBasis (fun ε : ℝ => 0 < ε) (ball x) :=
nhds_basis_uniformity uniformity_basis_dist
#align metric.nhds_basis_ball Metric.nhds_basis_ball
/- warning: metric.mem_nhds_iff -> Metric.mem_nhds_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s)))
Case conversion may be inaccurate. Consider using '#align metric.mem_nhds_iff Metric.mem_nhds_iffₓ'. -/
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ ε > 0, ball x ε ⊆ s :=
nhds_basis_ball.mem_iff
#align metric.mem_nhds_iff Metric.mem_nhds_iff
/- warning: metric.eventually_nhds_iff -> Metric.eventually_nhds_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {p : α -> Prop}, Iff (Filter.Eventually.{u1} α (fun (y : α) => p y) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {{y : α}}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y x) ε) -> (p y))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {p : α -> Prop}, Iff (Filter.Eventually.{u1} α (fun (y : α) => p y) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {{y : α}}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y x) ε) -> (p y))))
Case conversion may be inaccurate. Consider using '#align metric.eventually_nhds_iff Metric.eventually_nhds_iffₓ'. -/
theorem eventually_nhds_iff {p : α → Prop} :
(∀ᶠ y in 𝓝 x, p y) ↔ ∃ ε > 0, ∀ ⦃y⦄, dist y x < ε → p y :=
mem_nhds_iff
#align metric.eventually_nhds_iff Metric.eventually_nhds_iff
/- warning: metric.eventually_nhds_iff_ball -> Metric.eventually_nhds_iff_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {p : α -> Prop}, Iff (Filter.Eventually.{u1} α (fun (y : α) => p y) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (p y))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {p : α -> Prop}, Iff (Filter.Eventually.{u1} α (fun (y : α) => p y) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y (Metric.ball.{u1} α _inst_1 x ε)) -> (p y))))
Case conversion may be inaccurate. Consider using '#align metric.eventually_nhds_iff_ball Metric.eventually_nhds_iff_ballₓ'. -/
theorem eventually_nhds_iff_ball {p : α → Prop} :
(∀ᶠ y in 𝓝 x, p y) ↔ ∃ ε > 0, ∀ y ∈ ball x ε, p y :=
mem_nhds_iff
#align metric.eventually_nhds_iff_ball Metric.eventually_nhds_iff_ball
/- warning: metric.eventually_prod_nhds_iff -> Metric.eventually_prod_nhds_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {ι : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Filter.{u2} ι} {x₀ : α} {p : (Prod.{u2, u1} ι α) -> Prop}, Iff (Filter.Eventually.{max u2 u1} (Prod.{u2, u1} ι α) (fun (x : Prod.{u2, u1} ι α) => p x) (Filter.prod.{u2, u1} ι α f (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x₀))) (Exists.{succ u2} (ι -> Prop) (fun (pa : ι -> Prop) => Exists.{0} (Filter.Eventually.{u2} ι (fun (i : ι) => pa i) f) (fun (ha : Filter.Eventually.{u2} ι (fun (i : ι) => pa i) f) => Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {i : ι}, (pa i) -> (forall {x : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x x₀) ε) -> (p (Prod.mk.{u2, u1} ι α i x))))))))
but is expected to have type
forall {α : Type.{u2}} {ι : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u2} α] {f : Filter.{u1} ι} {x₀ : α} {p : (Prod.{u1, u2} ι α) -> Prop}, Iff (Filter.Eventually.{max u2 u1} (Prod.{u1, u2} ι α) (fun (x : Prod.{u1, u2} ι α) => p x) (Filter.prod.{u1, u2} ι α f (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) x₀))) (Exists.{succ u1} (ι -> Prop) (fun (pa : ι -> Prop) => And (Filter.Eventually.{u1} ι (fun (i : ι) => pa i) f) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {i : ι}, (pa i) -> (forall {x : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) x x₀) ε) -> (p (Prod.mk.{u1, u2} ι α i x))))))))
Case conversion may be inaccurate. Consider using '#align metric.eventually_prod_nhds_iff Metric.eventually_prod_nhds_iffₓ'. -/
/-- A version of `filter.eventually_prod_iff` where the second filter consists of neighborhoods
in a pseudo-metric space.-/
theorem eventually_prod_nhds_iff {f : Filter ι} {x₀ : α} {p : ι × α → Prop} :
(∀ᶠ x in f ×ᶠ 𝓝 x₀, p x) ↔
∃ (pa : ι → Prop)(ha : ∀ᶠ i in f, pa i),
∃ ε > 0, ∀ {i}, pa i → ∀ {x}, dist x x₀ < ε → p (i, x) :=
by
simp_rw [eventually_prod_iff, Metric.eventually_nhds_iff]
refine' exists_congr fun q => exists_congr fun hq => _
constructor
· rintro ⟨r, ⟨ε, hε, hεr⟩, hp⟩
exact ⟨ε, hε, fun i hi x hx => hp hi <| hεr hx⟩
· rintro ⟨ε, hε, hp⟩
exact ⟨fun x => dist x x₀ < ε, ⟨ε, hε, fun y => id⟩, @hp⟩
#align metric.eventually_prod_nhds_iff Metric.eventually_prod_nhds_iff
/- warning: metric.eventually_nhds_prod_iff -> Metric.eventually_nhds_prod_iff is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_2 : PseudoMetricSpace.{u2} α] {f : Filter.{u1} ι} {x₀ : α} {p : (Prod.{u2, u1} α ι) -> Prop}, Iff (Filter.Eventually.{max u2 u1} (Prod.{u2, u1} α ι) (fun (x : Prod.{u2, u1} α ι) => p x) (Filter.prod.{u2, u1} α ι (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_2)) x₀) f)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => Exists.{succ u1} (ι -> Prop) (fun (pa : ι -> Prop) => Exists.{0} (Filter.Eventually.{u1} ι (fun (i : ι) => pa i) f) (fun (ha : Filter.Eventually.{u1} ι (fun (i : ι) => pa i) f) => forall {x : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} α (PseudoMetricSpace.toHasDist.{u2} α _inst_2) x x₀) ε) -> (forall {i : ι}, (pa i) -> (p (Prod.mk.{u2, u1} α ι x i))))))))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {f : Filter.{u2} ι} {x₀ : α} {p : (Prod.{u1, u2} α ι) -> Prop}, Iff (Filter.Eventually.{max u1 u2} (Prod.{u1, u2} α ι) (fun (x : Prod.{u1, u2} α ι) => p x) (Filter.prod.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) x₀) f)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Exists.{succ u2} (ι -> Prop) (fun (pa : ι -> Prop) => And (Filter.Eventually.{u2} ι (fun (i : ι) => pa i) f) (forall {x : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_2) x x₀) ε) -> (forall {i : ι}, (pa i) -> (p (Prod.mk.{u1, u2} α ι x i))))))))
Case conversion may be inaccurate. Consider using '#align metric.eventually_nhds_prod_iff Metric.eventually_nhds_prod_iffₓ'. -/
/-- A version of `filter.eventually_prod_iff` where the first filter consists of neighborhoods
in a pseudo-metric space.-/
theorem eventually_nhds_prod_iff {ι α} [PseudoMetricSpace α] {f : Filter ι} {x₀ : α}
{p : α × ι → Prop} :
(∀ᶠ x in 𝓝 x₀ ×ᶠ f, p x) ↔
∃ ε > (0 : ℝ),
∃ (pa : ι → Prop)(ha : ∀ᶠ i in f, pa i), ∀ {x}, dist x x₀ < ε → ∀ {i}, pa i → p (x, i) :=
by
rw [eventually_swap_iff, Metric.eventually_prod_nhds_iff]
constructor <;>
· rintro ⟨a1, a2, a3, a4, a5⟩
refine' ⟨a3, a4, a1, a2, fun b1 b2 b3 b4 => a5 b4 b2⟩
#align metric.eventually_nhds_prod_iff Metric.eventually_nhds_prod_iff
/- warning: metric.nhds_basis_closed_ball -> Metric.nhds_basis_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Real (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (ε : Real) => LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) (Metric.closedBall.{u1} α _inst_1 x)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Real (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (ε : Real) => LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) (Metric.closedBall.{u1} α _inst_1 x)
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_closed_ball Metric.nhds_basis_closedBallₓ'. -/
theorem nhds_basis_closedBall : (𝓝 x).HasBasis (fun ε : ℝ => 0 < ε) (closedBall x) :=
nhds_basis_uniformity uniformity_basis_dist_le
#align metric.nhds_basis_closed_ball Metric.nhds_basis_closedBall
/- warning: metric.nhds_basis_ball_inv_nat_succ -> Metric.nhds_basis_ball_inv_nat_succ is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (_x : Nat) => True) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (_x : Nat) => True) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))))
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_ball_inv_nat_succ Metric.nhds_basis_ball_inv_nat_succₓ'. -/
theorem nhds_basis_ball_inv_nat_succ :
(𝓝 x).HasBasis (fun _ => True) fun n : ℕ => ball x (1 / (↑n + 1)) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_succ
#align metric.nhds_basis_ball_inv_nat_succ Metric.nhds_basis_ball_inv_nat_succ
/- warning: metric.nhds_basis_ball_inv_nat_pos -> Metric.nhds_basis_ball_inv_nat_pos is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (Nat.cast.{0} Real Real.natCast n)))
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_ball_inv_nat_pos Metric.nhds_basis_ball_inv_nat_posₓ'. -/
theorem nhds_basis_ball_inv_nat_pos :
(𝓝 x).HasBasis (fun n => 0 < n) fun n : ℕ => ball x (1 / ↑n) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_pos
#align metric.nhds_basis_ball_inv_nat_pos Metric.nhds_basis_ball_inv_nat_pos
/- warning: metric.nhds_basis_ball_pow -> Metric.nhds_basis_ball_pow is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LT.lt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => True) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) r n)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LT.lt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => True) (fun (n : Nat) => Metric.ball.{u1} α _inst_1 x (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) r n)))
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_ball_pow Metric.nhds_basis_ball_powₓ'. -/
theorem nhds_basis_ball_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓝 x).HasBasis (fun n => True) fun n : ℕ => ball x (r ^ n) :=
nhds_basis_uniformity (uniformity_basis_dist_pow h0 h1)
#align metric.nhds_basis_ball_pow Metric.nhds_basis_ball_pow
/- warning: metric.nhds_basis_closed_ball_pow -> Metric.nhds_basis_closedBall_pow is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LT.lt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => True) (fun (n : Nat) => Metric.closedBall.{u1} α _inst_1 x (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) r n)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LT.lt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (Filter.HasBasis.{u1, 1} α Nat (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x) (fun (n : Nat) => True) (fun (n : Nat) => Metric.closedBall.{u1} α _inst_1 x (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) r n)))
Case conversion may be inaccurate. Consider using '#align metric.nhds_basis_closed_ball_pow Metric.nhds_basis_closedBall_powₓ'. -/
theorem nhds_basis_closedBall_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓝 x).HasBasis (fun n => True) fun n : ℕ => closedBall x (r ^ n) :=
nhds_basis_uniformity (uniformity_basis_dist_le_pow h0 h1)
#align metric.nhds_basis_closed_ball_pow Metric.nhds_basis_closedBall_pow
/- warning: metric.is_open_iff -> Metric.isOpen_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s))))
Case conversion may be inaccurate. Consider using '#align metric.is_open_iff Metric.isOpen_iffₓ'. -/
theorem isOpen_iff : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ball x ε ⊆ s := by
simp only [isOpen_iff_mem_nhds, mem_nhds_iff]
#align metric.is_open_iff Metric.isOpen_iff
#print Metric.isOpen_ball /-
theorem isOpen_ball : IsOpen (ball x ε) :=
isOpen_iff.2 fun y => exists_ball_subset_ball
#align metric.is_open_ball Metric.isOpen_ball
-/
/- warning: metric.ball_mem_nhds -> Metric.ball_mem_nhds is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x))
Case conversion may be inaccurate. Consider using '#align metric.ball_mem_nhds Metric.ball_mem_nhdsₓ'. -/
theorem ball_mem_nhds (x : α) {ε : ℝ} (ε0 : 0 < ε) : ball x ε ∈ 𝓝 x :=
isOpen_ball.mem_nhds (mem_ball_self ε0)
#align metric.ball_mem_nhds Metric.ball_mem_nhds
/- warning: metric.closed_ball_mem_nhds -> Metric.closedBall_mem_nhds is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α) {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_mem_nhds Metric.closedBall_mem_nhdsₓ'. -/
theorem closedBall_mem_nhds (x : α) {ε : ℝ} (ε0 : 0 < ε) : closedBall x ε ∈ 𝓝 x :=
mem_of_superset (ball_mem_nhds x ε0) ball_subset_closedBall
#align metric.closed_ball_mem_nhds Metric.closedBall_mem_nhds
#print Metric.closedBall_mem_nhds_of_mem /-
theorem closedBall_mem_nhds_of_mem {x c : α} {ε : ℝ} (h : x ∈ ball c ε) : closedBall c ε ∈ 𝓝 x :=
mem_of_superset (isOpen_ball.mem_nhds h) ball_subset_closedBall
#align metric.closed_ball_mem_nhds_of_mem Metric.closedBall_mem_nhds_of_mem
-/
/- warning: metric.nhds_within_basis_ball -> Metric.nhdsWithin_basis_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α}, Filter.HasBasis.{u1, 1} α Real (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x s) (fun (ε : Real) => LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) (fun (ε : Real) => Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α}, Filter.HasBasis.{u1, 1} α Real (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x s) (fun (ε : Real) => LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) (fun (ε : Real) => Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s)
Case conversion may be inaccurate. Consider using '#align metric.nhds_within_basis_ball Metric.nhdsWithin_basis_ballₓ'. -/
theorem nhdsWithin_basis_ball {s : Set α} :
(𝓝[s] x).HasBasis (fun ε : ℝ => 0 < ε) fun ε => ball x ε ∩ s :=
nhdsWithin_hasBasis nhds_basis_ball s
#align metric.nhds_within_basis_ball Metric.nhdsWithin_basis_ball
/- warning: metric.mem_nhds_within_iff -> Metric.mem_nhdsWithin_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x t)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) t) s)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x t)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) t) s)))
Case conversion may be inaccurate. Consider using '#align metric.mem_nhds_within_iff Metric.mem_nhdsWithin_iffₓ'. -/
theorem mem_nhdsWithin_iff {t : Set α} : s ∈ 𝓝[t] x ↔ ∃ ε > 0, ball x ε ∩ t ⊆ s :=
nhdsWithin_basis_ball.mem_iff
#align metric.mem_nhds_within_iff Metric.mem_nhdsWithin_iff
/- warning: metric.tendsto_nhds_within_nhds_within -> Metric.tendsto_nhdsWithin_nhdsWithin is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : PseudoMetricSpace.{u2} β] {t : Set.{u2} β} {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a s) (nhdsWithin.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b t)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {x : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x a) δ) -> (And (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) (f x) t) (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) b) ε))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : PseudoMetricSpace.{u2} β] {t : Set.{u2} β} {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a s) (nhdsWithin.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b t)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {x : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x a) δ) -> (And (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) (f x) t) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) b) ε))))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_nhds_within_nhds_within Metric.tendsto_nhdsWithin_nhdsWithinₓ'. -/
theorem tendsto_nhdsWithin_nhdsWithin [PseudoMetricSpace β] {t : Set β} {f : α → β} {a b} :
Tendsto f (𝓝[s] a) (𝓝[t] b) ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → f x ∈ t ∧ dist (f x) b < ε :=
(nhdsWithin_basis_ball.tendsto_iffₓ nhdsWithin_basis_ball).trans <|
forall₂_congr fun ε hε => exists₂_congr fun δ hδ => forall_congr' fun x => by simp <;> itauto
#align metric.tendsto_nhds_within_nhds_within Metric.tendsto_nhdsWithin_nhdsWithin
/- warning: metric.tendsto_nhds_within_nhds -> Metric.tendsto_nhdsWithin_nhds is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a s) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {x : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) b) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a s) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {x : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) b) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_nhds_within_nhds Metric.tendsto_nhdsWithin_nhdsₓ'. -/
theorem tendsto_nhdsWithin_nhds [PseudoMetricSpace β] {f : α → β} {a b} :
Tendsto f (𝓝[s] a) (𝓝 b) ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → dist (f x) b < ε :=
by
rw [← nhdsWithin_univ b, tendsto_nhds_within_nhds_within]
simp only [mem_univ, true_and_iff]
#align metric.tendsto_nhds_within_nhds Metric.tendsto_nhdsWithin_nhds
/- warning: metric.tendsto_nhds_nhds -> Metric.tendsto_nhds_nhds is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {x : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) b) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {b : β}, Iff (Filter.Tendsto.{u1, u2} α β f (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) b)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {x : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) b) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_nhds_nhds Metric.tendsto_nhds_nhdsₓ'. -/
theorem tendsto_nhds_nhds [PseudoMetricSpace β] {f : α → β} {a b} :
Tendsto f (𝓝 a) (𝓝 b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x : α}, dist x a < δ → dist (f x) b < ε :=
nhds_basis_ball.tendsto_iffₓ nhds_basis_ball
#align metric.tendsto_nhds_nhds Metric.tendsto_nhds_nhds
/- warning: metric.continuous_at_iff -> Metric.continuousAt_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α}, Iff (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f a) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {x : α}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) (f a)) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α}, Iff (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f a) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {x : α}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) (f a)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.continuous_at_iff Metric.continuousAt_iffₓ'. -/
theorem continuousAt_iff [PseudoMetricSpace β] {f : α → β} {a : α} :
ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x : α}, dist x a < δ → dist (f x) (f a) < ε := by
rw [ContinuousAt, tendsto_nhds_nhds]
#align metric.continuous_at_iff Metric.continuousAt_iff
/- warning: metric.continuous_within_at_iff -> Metric.continuousWithinAt_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {s : Set.{u1} α}, Iff (ContinuousWithinAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f s a) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {x : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f x) (f a)) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {a : α} {s : Set.{u1} α}, Iff (ContinuousWithinAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f s a) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {x : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x a) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f x) (f a)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.continuous_within_at_iff Metric.continuousWithinAt_iffₓ'. -/
theorem continuousWithinAt_iff [PseudoMetricSpace β] {f : α → β} {a : α} {s : Set α} :
ContinuousWithinAt f s a ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → dist (f x) (f a) < ε :=
by rw [ContinuousWithinAt, tendsto_nhds_within_nhds]
#align metric.continuous_within_at_iff Metric.continuousWithinAt_iff
/- warning: metric.continuous_on_iff -> Metric.continuousOn_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (ContinuousOn.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f s) (forall (b : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) -> (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (a : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β} {s : Set.{u1} α}, Iff (ContinuousOn.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f s) (forall (b : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b s) -> (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (a : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε))))))
Case conversion may be inaccurate. Consider using '#align metric.continuous_on_iff Metric.continuousOn_iffₓ'. -/
theorem continuousOn_iff [PseudoMetricSpace β] {f : α → β} {s : Set α} :
ContinuousOn f s ↔ ∀ b ∈ s, ∀ ε > 0, ∃ δ > 0, ∀ a ∈ s, dist a b < δ → dist (f a) (f b) < ε := by
simp [ContinuousOn, continuous_within_at_iff]
#align metric.continuous_on_iff Metric.continuousOn_iff
/- warning: metric.continuous_iff -> Metric.continuous_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (Continuous.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f) (forall (b : α) (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (a : α), (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (f a) (f b)) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {f : α -> β}, Iff (Continuous.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u2} β (PseudoMetricSpace.toUniformSpace.{u2} β _inst_2)) f) (forall (b : α) (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (a : α), (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (f a) (f b)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.continuous_iff Metric.continuous_iffₓ'. -/
theorem continuous_iff [PseudoMetricSpace β] {f : α → β} :
Continuous f ↔ ∀ (b), ∀ ε > 0, ∃ δ > 0, ∀ a, dist a b < δ → dist (f a) (f b) < ε :=
continuous_iff_continuousAt.trans <| forall_congr' fun b => tendsto_nhds_nhds
#align metric.continuous_iff Metric.continuous_iff
/- warning: metric.tendsto_nhds -> Metric.tendsto_nhds is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Filter.{u2} β} {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u f (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u x) a) ε) f))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : Filter.{u2} β} {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u f (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u x) a) ε) f))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_nhds Metric.tendsto_nhdsₓ'. -/
theorem tendsto_nhds {f : Filter β} {u : β → α} {a : α} :
Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, dist (u x) a < ε :=
nhds_basis_ball.tendsto_right_iff
#align metric.tendsto_nhds Metric.tendsto_nhds
/- warning: metric.continuous_at_iff' -> Metric.continuousAt_iff' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β}, Iff (ContinuousAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f b) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f b)) ε) (nhds.{u2} β _inst_2 b)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β}, Iff (ContinuousAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f b) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f x) (f b)) ε) (nhds.{u2} β _inst_2 b)))
Case conversion may be inaccurate. Consider using '#align metric.continuous_at_iff' Metric.continuousAt_iff'ₓ'. -/
theorem continuousAt_iff' [TopologicalSpace β] {f : β → α} {b : β} :
ContinuousAt f b ↔ ∀ ε > 0, ∀ᶠ x in 𝓝 b, dist (f x) (f b) < ε := by
rw [ContinuousAt, tendsto_nhds]
#align metric.continuous_at_iff' Metric.continuousAt_iff'
/- warning: metric.continuous_within_at_iff' -> Metric.continuousWithinAt_iff' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β} {s : Set.{u2} β}, Iff (ContinuousWithinAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s b) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f b)) ε) (nhdsWithin.{u2} β _inst_2 b s)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β} {s : Set.{u2} β}, Iff (ContinuousWithinAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s b) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f x) (f b)) ε) (nhdsWithin.{u2} β _inst_2 b s)))
Case conversion may be inaccurate. Consider using '#align metric.continuous_within_at_iff' Metric.continuousWithinAt_iff'ₓ'. -/
theorem continuousWithinAt_iff' [TopologicalSpace β] {f : β → α} {b : β} {s : Set β} :
ContinuousWithinAt f s b ↔ ∀ ε > 0, ∀ᶠ x in 𝓝[s] b, dist (f x) (f b) < ε := by
rw [ContinuousWithinAt, tendsto_nhds]
#align metric.continuous_within_at_iff' Metric.continuousWithinAt_iff'
/- warning: metric.continuous_on_iff' -> Metric.continuousOn_iff' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, Iff (ContinuousOn.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s) (forall (b : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) b s) -> (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f b)) ε) (nhdsWithin.{u2} β _inst_2 b s))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, Iff (ContinuousOn.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s) (forall (b : β), (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) b s) -> (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f x) (f b)) ε) (nhdsWithin.{u2} β _inst_2 b s))))
Case conversion may be inaccurate. Consider using '#align metric.continuous_on_iff' Metric.continuousOn_iff'ₓ'. -/
theorem continuousOn_iff' [TopologicalSpace β] {f : β → α} {s : Set β} :
ContinuousOn f s ↔ ∀ b ∈ s, ∀ ε > 0, ∀ᶠ x in 𝓝[s] b, dist (f x) (f b) < ε := by
simp [ContinuousOn, continuous_within_at_iff']
#align metric.continuous_on_iff' Metric.continuousOn_iff'
/- warning: metric.continuous_iff' -> Metric.continuous_iff' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α}, Iff (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) (forall (a : β) (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f a)) ε) (nhds.{u2} β _inst_2 a)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α}, Iff (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) (forall (a : β) (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Filter.Eventually.{u2} β (fun (x : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f x) (f a)) ε) (nhds.{u2} β _inst_2 a)))
Case conversion may be inaccurate. Consider using '#align metric.continuous_iff' Metric.continuous_iff'ₓ'. -/
theorem continuous_iff' [TopologicalSpace β] {f : β → α} :
Continuous f ↔ ∀ (a), ∀ ε > 0, ∀ᶠ x in 𝓝 a, dist (f x) (f a) < ε :=
continuous_iff_continuousAt.trans <| forall_congr' fun b => tendsto_nhds
#align metric.continuous_iff' Metric.continuous_iff'
/- warning: metric.tendsto_at_top -> Metric.tendsto_atTop is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u n) a) ε))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u n) a) ε))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_at_top Metric.tendsto_atTopₓ'. -/
theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {u : β → α} {a : α} :
Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε :=
(atTop_basis.tendsto_iffₓ nhds_basis_ball).trans <|
by
simp only [exists_prop, true_and_iff]
rfl
#align metric.tendsto_at_top Metric.tendsto_atTop
/- warning: metric.tendsto_at_top' -> Metric.tendsto_at_top' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] [_inst_4 : NoMaxOrder.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)))] {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u n) a) ε))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] [_inst_4 : NoMaxOrder.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)))] {u : β -> α} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α u (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u n) a) ε))))
Case conversion may be inaccurate. Consider using '#align metric.tendsto_at_top' Metric.tendsto_at_top'ₓ'. -/
/-- A variant of `tendsto_at_top` that
uses `∃ N, ∀ n > N, ...` rather than `∃ N, ∀ n ≥ N, ...`
-/
theorem tendsto_at_top' [Nonempty β] [SemilatticeSup β] [NoMaxOrder β] {u : β → α} {a : α} :
Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n > N, dist (u n) a < ε :=
(atTop_basis_Ioi.tendsto_iffₓ nhds_basis_ball).trans <|
by
simp only [exists_prop, true_and_iff]
rfl
#align metric.tendsto_at_top' Metric.tendsto_at_top'
/- warning: metric.is_open_singleton_iff -> Metric.isOpen_singleton_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {x : α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x)) (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (y : α), (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_2) y x) ε) -> (Eq.{succ u1} α y x))))
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {x : α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x)) (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (y : α), (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_2) y x) ε) -> (Eq.{succ u1} α y x))))
Case conversion may be inaccurate. Consider using '#align metric.is_open_singleton_iff Metric.isOpen_singleton_iffₓ'. -/
theorem isOpen_singleton_iff {α : Type _} [PseudoMetricSpace α] {x : α} :
IsOpen ({x} : Set α) ↔ ∃ ε > 0, ∀ y, dist y x < ε → y = x := by
simp [is_open_iff, subset_singleton_iff, mem_ball]
#align metric.is_open_singleton_iff Metric.isOpen_singleton_iff
/- warning: metric.exists_ball_inter_eq_singleton_of_mem_discrete -> Metric.exists_ball_inter_eq_singleton_of_mem_discrete is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : DiscreteTopology.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))] {x : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => Eq.{succ u1} (Set.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : DiscreteTopology.{u1} (Set.Elem.{u1} α s) (instTopologicalSpaceSubtype.{u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))] {x : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Eq.{succ u1} (Set.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x ε) s) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x))))
Case conversion may be inaccurate. Consider using '#align metric.exists_ball_inter_eq_singleton_of_mem_discrete Metric.exists_ball_inter_eq_singleton_of_mem_discreteₓ'. -/
/-- Given a point `x` in a discrete subset `s` of a pseudometric space, there is an open ball
centered at `x` and intersecting `s` only at `x`. -/
theorem exists_ball_inter_eq_singleton_of_mem_discrete [DiscreteTopology s] {x : α} (hx : x ∈ s) :
∃ ε > 0, Metric.ball x ε ∩ s = {x} :=
nhds_basis_ball.exists_inter_eq_singleton_of_mem_discrete hx
#align metric.exists_ball_inter_eq_singleton_of_mem_discrete Metric.exists_ball_inter_eq_singleton_of_mem_discrete
/- warning: metric.exists_closed_ball_inter_eq_singleton_of_discrete -> Metric.exists_closedBall_inter_eq_singleton_of_discrete is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : DiscreteTopology.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))] {x : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => Eq.{succ u1} (Set.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) s) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} [_inst_2 : DiscreteTopology.{u1} (Set.Elem.{u1} α s) (instTopologicalSpaceSubtype.{u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))] {x : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Eq.{succ u1} (Set.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x ε) s) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x))))
Case conversion may be inaccurate. Consider using '#align metric.exists_closed_ball_inter_eq_singleton_of_discrete Metric.exists_closedBall_inter_eq_singleton_of_discreteₓ'. -/
/-- Given a point `x` in a discrete subset `s` of a pseudometric space, there is a closed ball
of positive radius centered at `x` and intersecting `s` only at `x`. -/
theorem exists_closedBall_inter_eq_singleton_of_discrete [DiscreteTopology s] {x : α} (hx : x ∈ s) :
∃ ε > 0, Metric.closedBall x ε ∩ s = {x} :=
nhds_basis_closedBall.exists_inter_eq_singleton_of_mem_discrete hx
#align metric.exists_closed_ball_inter_eq_singleton_of_discrete Metric.exists_closedBall_inter_eq_singleton_of_discrete
/- warning: dense.exists_dist_lt -> Dense.exists_dist_lt is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Dense.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall (x : α) {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ε))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Dense.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall (x : α) {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) ε))))
Case conversion may be inaccurate. Consider using '#align dense.exists_dist_lt Dense.exists_dist_ltₓ'. -/
theorem Dense.exists_dist_lt {s : Set α} (hs : Dense s) (x : α) {ε : ℝ} (hε : 0 < ε) :
∃ y ∈ s, dist x y < ε :=
by
have : (ball x ε).Nonempty := by simp [hε]
simpa only [mem_ball'] using hs.exists_mem_open is_open_ball this
#align dense.exists_dist_lt Dense.exists_dist_lt
/- warning: dense_range.exists_dist_lt -> DenseRange.exists_dist_lt is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {β : Type.{u2}} {f : β -> α}, (DenseRange.{u1, u2} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) β f) -> (forall (x : α) {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Exists.{succ u2} β (fun (y : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x (f y)) ε)))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {β : Type.{u1}} {f : β -> α}, (DenseRange.{u2, u1} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) β f) -> (forall (x : α) {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Exists.{succ u1} β (fun (y : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) x (f y)) ε)))
Case conversion may be inaccurate. Consider using '#align dense_range.exists_dist_lt DenseRange.exists_dist_ltₓ'. -/
theorem DenseRange.exists_dist_lt {β : Type _} {f : β → α} (hf : DenseRange f) (x : α) {ε : ℝ}
(hε : 0 < ε) : ∃ y, dist x (f y) < ε :=
exists_range_iff.1 (hf.exists_dist_lt x hε)
#align dense_range.exists_dist_lt DenseRange.exists_dist_lt
end Metric
open Metric
/- warning: pseudo_metric.uniformity_basis_edist -> Metric.uniformity_basis_edist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) ENNReal (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : ENNReal) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (OfNat.ofNat.{0} ENNReal 0 (OfNat.mk.{0} ENNReal 0 (Zero.zero.{0} ENNReal ENNReal.hasZero))) ε) (fun (ε : ENNReal) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Filter.HasBasis.{u1, 1} (Prod.{u1, u1} α α) ENNReal (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (fun (ε : ENNReal) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (OfNat.ofNat.{0} ENNReal 0 (Zero.toOfNat0.{0} ENNReal instENNRealZero)) ε) (fun (ε : ENNReal) => setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1)) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε))
Case conversion may be inaccurate. Consider using '#align pseudo_metric.uniformity_basis_edist Metric.uniformity_basis_edistₓ'. -/
/-Instantiate a pseudometric space as a pseudoemetric space. Before we can state the instance,
we need to show that the uniform structure coming from the edistance and the
distance coincide. -/
/-- Expressing the uniformity in terms of `edist` -/
protected theorem Metric.uniformity_basis_edist :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p | edist p.1 p.2 < ε } :=
⟨by
intro t
refine' mem_uniformity_dist.trans ⟨_, _⟩ <;> rintro ⟨ε, ε0, Hε⟩
· use ENNReal.ofReal ε, ENNReal.ofReal_pos.2 ε0
rintro ⟨a, b⟩
simp only [edist_dist, ENNReal.ofReal_lt_ofReal_iff ε0]
exact Hε
· rcases ENNReal.lt_iff_exists_real_btwn.1 ε0 with ⟨ε', _, ε0', hε⟩
rw [ENNReal.ofReal_pos] at ε0'
refine' ⟨ε', ε0', fun a b h => Hε (lt_trans _ hε)⟩
rwa [edist_dist, ENNReal.ofReal_lt_ofReal_iff ε0']⟩
#align pseudo_metric.uniformity_basis_edist Metric.uniformity_basis_edist
/- warning: metric.uniformity_edist -> Metric.uniformity_edist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (infᵢ.{u1, 1} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.completeLattice.{u1} (Prod.{u1, u1} α α)))) ENNReal (fun (ε : ENNReal) => infᵢ.{u1, 0} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.completeLattice.{u1} (Prod.{u1, u1} α α)))) (GT.gt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) ε (OfNat.ofNat.{0} ENNReal 0 (OfNat.mk.{0} ENNReal 0 (Zero.zero.{0} ENNReal ENNReal.hasZero)))) (fun (H : GT.gt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) ε (OfNat.ofNat.{0} ENNReal 0 (OfNat.mk.{0} ENNReal 0 (Zero.zero.{0} ENNReal ENNReal.hasZero)))) => Filter.principal.{u1} (Prod.{u1, u1} α α) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε)))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (infᵢ.{u1, 1} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instCompleteLatticeFilter.{u1} (Prod.{u1, u1} α α)))) ENNReal (fun (ε : ENNReal) => infᵢ.{u1, 0} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instCompleteLatticeFilter.{u1} (Prod.{u1, u1} α α)))) (GT.gt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) ε (OfNat.ofNat.{0} ENNReal 0 (Zero.toOfNat0.{0} ENNReal instENNRealZero))) (fun (H : GT.gt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) ε (OfNat.ofNat.{0} ENNReal 0 (Zero.toOfNat0.{0} ENNReal instENNRealZero))) => Filter.principal.{u1} (Prod.{u1, u1} α α) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{0} ENNReal (Preorder.toLT.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EDist.edist.{u1} α (PseudoMetricSpace.toEDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_edist Metric.uniformity_edistₓ'. -/
theorem Metric.uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } :=
Metric.uniformity_basis_edist.eq_binfᵢ
#align metric.uniformity_edist Metric.uniformity_edist
#print PseudoMetricSpace.toPseudoEMetricSpace /-
-- see Note [lower instance priority]
/-- A pseudometric space induces a pseudoemetric space -/
instance (priority := 100) PseudoMetricSpace.toPseudoEMetricSpace : PseudoEMetricSpace α :=
{ ‹PseudoMetricSpace α› with
edist := edist
edist_self := by simp [edist_dist]
edist_comm := by simp only [edist_dist, dist_comm] <;> simp
edist_triangle := fun x y z =>
by
simp only [edist_dist, ← ENNReal.ofReal_add, dist_nonneg]
rw [ENNReal.ofReal_le_ofReal_iff _]
· exact dist_triangle _ _ _
· simpa using add_le_add (dist_nonneg : 0 ≤ dist x y) dist_nonneg
uniformity_edist := Metric.uniformity_edist }
#align pseudo_metric_space.to_pseudo_emetric_space PseudoMetricSpace.toPseudoEMetricSpace
-/
/- warning: metric.eball_top_eq_univ -> Metric.eball_top_eq_univ is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) (Set.univ.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) (Set.univ.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric.eball_top_eq_univ Metric.eball_top_eq_univₓ'. -/
/-- In a pseudometric space, an open ball of infinite radius is the whole space -/
theorem Metric.eball_top_eq_univ (x : α) : EMetric.ball x ∞ = Set.univ :=
Set.eq_univ_iff_forall.mpr fun y => edist_lt_top y x
#align metric.eball_top_eq_univ Metric.eball_top_eq_univ
#print Metric.emetric_ball /-
/-- Balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_ball {x : α} {ε : ℝ} : EMetric.ball x (ENNReal.ofReal ε) = ball x ε :=
by
ext y
simp only [EMetric.mem_ball, mem_ball, edist_dist]
exact ENNReal.ofReal_lt_ofReal_iff_of_nonneg dist_nonneg
#align metric.emetric_ball Metric.emetric_ball
-/
/- warning: metric.emetric_ball_nnreal -> Metric.emetric_ball_nnreal is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : NNReal}, Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal ENNReal (HasLiftT.mk.{1, 1} NNReal ENNReal (CoeTCₓ.coe.{1, 1} NNReal ENNReal (coeBase.{1, 1} NNReal ENNReal ENNReal.hasCoe))) ε)) (Metric.ball.{u1} α _inst_1 x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : NNReal}, Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (ENNReal.some ε)) (Metric.ball.{u1} α _inst_1 x (NNReal.toReal ε))
Case conversion may be inaccurate. Consider using '#align metric.emetric_ball_nnreal Metric.emetric_ball_nnrealₓ'. -/
/-- Balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_ball_nnreal {x : α} {ε : ℝ≥0} : EMetric.ball x ε = ball x ε :=
by
convert Metric.emetric_ball
simp
#align metric.emetric_ball_nnreal Metric.emetric_ball_nnreal
/- warning: metric.emetric_closed_ball -> Metric.emetric_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Eq.{succ u1} (Set.{u1} α) (EMetric.closedBall.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (ENNReal.ofReal ε)) (Metric.closedBall.{u1} α _inst_1 x ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Eq.{succ u1} (Set.{u1} α) (EMetric.closedBall.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (ENNReal.ofReal ε)) (Metric.closedBall.{u1} α _inst_1 x ε))
Case conversion may be inaccurate. Consider using '#align metric.emetric_closed_ball Metric.emetric_closedBallₓ'. -/
/-- Closed balls defined using the distance or the edistance coincide -/
theorem Metric.emetric_closedBall {x : α} {ε : ℝ} (h : 0 ≤ ε) :
EMetric.closedBall x (ENNReal.ofReal ε) = closedBall x ε := by
ext y <;> simp [edist_dist] <;> rw [ENNReal.ofReal_le_ofReal_iff h]
#align metric.emetric_closed_ball Metric.emetric_closedBall
/- warning: metric.emetric_closed_ball_nnreal -> Metric.emetric_closedBall_nnreal is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : NNReal}, Eq.{succ u1} (Set.{u1} α) (EMetric.closedBall.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal ENNReal (HasLiftT.mk.{1, 1} NNReal ENNReal (CoeTCₓ.coe.{1, 1} NNReal ENNReal (coeBase.{1, 1} NNReal ENNReal ENNReal.hasCoe))) ε)) (Metric.closedBall.{u1} α _inst_1 x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) ε))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {ε : NNReal}, Eq.{succ u1} (Set.{u1} α) (EMetric.closedBall.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (ENNReal.some ε)) (Metric.closedBall.{u1} α _inst_1 x (NNReal.toReal ε))
Case conversion may be inaccurate. Consider using '#align metric.emetric_closed_ball_nnreal Metric.emetric_closedBall_nnrealₓ'. -/
/-- Closed balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_closedBall_nnreal {x : α} {ε : ℝ≥0} :
EMetric.closedBall x ε = closedBall x ε :=
by
convert Metric.emetric_closedBall ε.2
simp
#align metric.emetric_closed_ball_nnreal Metric.emetric_closedBall_nnreal
/- warning: metric.emetric_ball_top -> Metric.emetric_ball_top is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) (Set.univ.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (EMetric.ball.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) x (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) (Set.univ.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric.emetric_ball_top Metric.emetric_ball_topₓ'. -/
@[simp]
theorem Metric.emetric_ball_top (x : α) : EMetric.ball x ⊤ = univ :=
eq_univ_of_forall fun y => edist_lt_top _ _
#align metric.emetric_ball_top Metric.emetric_ball_top
/- warning: metric.inseparable_iff -> Metric.inseparable_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α}, Iff (Inseparable.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x y) (Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α}, Iff (Inseparable.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x y) (Eq.{1} Real (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))
Case conversion may be inaccurate. Consider using '#align metric.inseparable_iff Metric.inseparable_iffₓ'. -/
theorem Metric.inseparable_iff {x y : α} : Inseparable x y ↔ dist x y = 0 := by
rw [EMetric.inseparable_iff, edist_nndist, dist_nndist, ENNReal.coe_eq_zero, NNReal.coe_eq_zero]
#align metric.inseparable_iff Metric.inseparable_iff
#print PseudoMetricSpace.replaceUniformity /-
/-- Build a new pseudometric space from an old one where the bundled uniform structure is provably
(but typically non-definitionaly) equal to some given uniform structure.
See Note [forgetful inheritance].
-/
def PseudoMetricSpace.replaceUniformity {α} [U : UniformSpace α] (m : PseudoMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : PseudoMetricSpace α
where
dist := @dist _ m.toHasDist
dist_self := dist_self
dist_comm := dist_comm
dist_triangle := dist_triangle
edist := edist
edist_dist := edist_dist
toUniformSpace := U
uniformity_dist := H.trans PseudoMetricSpace.uniformity_dist
#align pseudo_metric_space.replace_uniformity PseudoMetricSpace.replaceUniformity
-/
#print PseudoMetricSpace.replaceUniformity_eq /-
theorem PseudoMetricSpace.replaceUniformity_eq {α} [U : UniformSpace α] (m : PseudoMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : m.replaceUniformity H = m :=
by
ext
rfl
#align pseudo_metric_space.replace_uniformity_eq PseudoMetricSpace.replaceUniformity_eq
-/
#print PseudoMetricSpace.replaceTopology /-
/-- Build a new pseudo metric space from an old one where the bundled topological structure is
provably (but typically non-definitionaly) equal to some given topological structure.
See Note [forgetful inheritance].
-/
@[reducible]
def PseudoMetricSpace.replaceTopology {γ} [U : TopologicalSpace γ] (m : PseudoMetricSpace γ)
(H : U = m.toUniformSpace.toTopologicalSpace) : PseudoMetricSpace γ :=
@PseudoMetricSpace.replaceUniformity γ (m.toUniformSpace.replaceTopology H) m rfl
#align pseudo_metric_space.replace_topology PseudoMetricSpace.replaceTopology
-/
#print PseudoMetricSpace.replaceTopology_eq /-
theorem PseudoMetricSpace.replaceTopology_eq {γ} [U : TopologicalSpace γ] (m : PseudoMetricSpace γ)
(H : U = m.toUniformSpace.toTopologicalSpace) : m.replaceTopology H = m :=
by
ext
rfl
#align pseudo_metric_space.replace_topology_eq PseudoMetricSpace.replaceTopology_eq
-/
/- warning: pseudo_emetric_space.to_pseudo_metric_space_of_dist -> PseudoEMetricSpace.toPseudoMetricSpaceOfDist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [e : PseudoEMetricSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α e) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (ENNReal.toReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α e) x y))) -> (PseudoMetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [e : PseudoEMetricSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α e) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (ENNReal.toReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α e) x y))) -> (PseudoMetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align pseudo_emetric_space.to_pseudo_metric_space_of_dist PseudoEMetricSpace.toPseudoMetricSpaceOfDistₓ'. -/
/-- One gets a pseudometric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the pseudometric space and the pseudoemetric space. In this definition, the
distance is given separately, to be able to prescribe some expression which is not defeq to the
push-forward of the edistance to reals. -/
def PseudoEMetricSpace.toPseudoMetricSpaceOfDist {α : Type u} [e : PseudoEMetricSpace α]
(dist : α → α → ℝ) (edist_ne_top : ∀ x y : α, edist x y ≠ ⊤)
(h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) : PseudoMetricSpace α :=
let m : PseudoMetricSpace α :=
{ dist
dist_self := fun x => by simp [h]
dist_comm := fun x y => by simp [h, PseudoEMetricSpace.edist_comm]
dist_triangle := fun x y z => by
simp only [h]
rw [← ENNReal.toReal_add (edist_ne_top _ _) (edist_ne_top _ _),
ENNReal.toReal_le_toReal (edist_ne_top _ _)]
· exact edist_triangle _ _ _
· simp [ENNReal.add_eq_top, edist_ne_top]
edist := edist
edist_dist := fun x y => by simp [h, ENNReal.ofReal_toReal, edist_ne_top] }
m.replaceUniformity <|
by
rw [uniformity_pseudoedist, Metric.uniformity_edist]
rfl
#align pseudo_emetric_space.to_pseudo_metric_space_of_dist PseudoEMetricSpace.toPseudoMetricSpaceOfDist
/- warning: pseudo_emetric_space.to_pseudo_metric_space -> PseudoEMetricSpace.toPseudoMetricSpace is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [e : PseudoEMetricSpace.{u1} α], (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α e) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) -> (PseudoMetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [e : PseudoEMetricSpace.{u1} α], (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α e) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) -> (PseudoMetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align pseudo_emetric_space.to_pseudo_metric_space PseudoEMetricSpace.toPseudoMetricSpaceₓ'. -/
/-- One gets a pseudometric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the pseudometric space and the emetric space. -/
def PseudoEMetricSpace.toPseudoMetricSpace {α : Type u} [e : PseudoEMetricSpace α]
(h : ∀ x y : α, edist x y ≠ ⊤) : PseudoMetricSpace α :=
PseudoEMetricSpace.toPseudoMetricSpaceOfDist (fun x y => ENNReal.toReal (edist x y)) h fun x y =>
rfl
#align pseudo_emetric_space.to_pseudo_metric_space PseudoEMetricSpace.toPseudoMetricSpace
#print PseudoMetricSpace.replaceBornology /-
/-- Build a new pseudometric space from an old one where the bundled bornology structure is provably
(but typically non-definitionaly) equal to some given bornology structure.
See Note [forgetful inheritance].
-/
def PseudoMetricSpace.replaceBornology {α} [B : Bornology α] (m : PseudoMetricSpace α)
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
PseudoMetricSpace α :=
{ m with
toBornology := B
cobounded_sets :=
Set.ext <|
compl_surjective.forall.2 fun s =>
(H s).trans <| by rw [is_bounded_iff, mem_set_of_eq, compl_compl] }
#align pseudo_metric_space.replace_bornology PseudoMetricSpace.replaceBornology
-/
#print PseudoMetricSpace.replaceBornology_eq /-
theorem PseudoMetricSpace.replaceBornology_eq {α} [m : PseudoMetricSpace α] [B : Bornology α]
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
PseudoMetricSpace.replaceBornology _ H = m :=
by
ext
rfl
#align pseudo_metric_space.replace_bornology_eq PseudoMetricSpace.replaceBornology_eq
-/
/- warning: metric.complete_of_convergent_controlled_sequences -> Metric.complete_of_convergent_controlled_sequences is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (B : Nat -> Real), (forall (n : Nat), LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (B n)) -> (forall (u : Nat -> α), (forall (N : Nat) (n : Nat) (m : Nat), (LE.le.{0} Nat Nat.hasLe N n) -> (LE.le.{0} Nat Nat.hasLe N m) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u n) (u m)) (B N))) -> (Exists.{succ u1} α (fun (x : α) => Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)))) -> (CompleteSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (B : Nat -> Real), (forall (n : Nat), LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (B n)) -> (forall (u : Nat -> α), (forall (N : Nat) (n : Nat) (m : Nat), (LE.le.{0} Nat instLENat N n) -> (LE.le.{0} Nat instLENat N m) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u n) (u m)) (B N))) -> (Exists.{succ u1} α (fun (x : α) => Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)))) -> (CompleteSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))
Case conversion may be inaccurate. Consider using '#align metric.complete_of_convergent_controlled_sequences Metric.complete_of_convergent_controlled_sequencesₓ'. -/
/-- A very useful criterion to show that a space is complete is to show that all sequences
which satisfy a bound of the form `dist (u n) (u m) < B N` for all `n m ≥ N` are
converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to
`0`, which makes it possible to use arguments of converging series, while this is impossible
to do in general for arbitrary Cauchy sequences. -/
theorem Metric.complete_of_convergent_controlled_sequences (B : ℕ → Real) (hB : ∀ n, 0 < B n)
(H :
∀ u : ℕ → α,
(∀ N n m : ℕ, N ≤ n → N ≤ m → dist (u n) (u m) < B N) → ∃ x, Tendsto u atTop (𝓝 x)) :
CompleteSpace α :=
UniformSpace.complete_of_convergent_controlled_sequences
(fun n => { p : α × α | dist p.1 p.2 < B n }) (fun n => dist_mem_uniformity <| hB n) H
#align metric.complete_of_convergent_controlled_sequences Metric.complete_of_convergent_controlled_sequences
#print Metric.complete_of_cauchySeq_tendsto /-
theorem Metric.complete_of_cauchySeq_tendsto :
(∀ u : ℕ → α, CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)) → CompleteSpace α :=
EMetric.complete_of_cauchySeq_tendsto
#align metric.complete_of_cauchy_seq_tendsto Metric.complete_of_cauchySeq_tendsto
-/
section Real
#print Real.pseudoMetricSpace /-
/-- Instantiate the reals as a pseudometric space. -/
instance Real.pseudoMetricSpace : PseudoMetricSpace ℝ
where
dist x y := |x - y|
dist_self := by simp [abs_zero]
dist_comm x y := abs_sub_comm _ _
dist_triangle x y z := abs_sub_le _ _ _
#align real.pseudo_metric_space Real.pseudoMetricSpace
-/
/- warning: real.dist_eq -> Real.dist_eq is a dubious translation:
lean 3 declaration is
forall (x : Real) (y : Real), Eq.{1} Real (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x y) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y))
but is expected to have type
forall (x : Real) (y : Real), Eq.{1} Real (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x y) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y))
Case conversion may be inaccurate. Consider using '#align real.dist_eq Real.dist_eqₓ'. -/
theorem Real.dist_eq (x y : ℝ) : dist x y = |x - y| :=
rfl
#align real.dist_eq Real.dist_eq
/- warning: real.nndist_eq -> Real.nndist_eq is a dubious translation:
lean 3 declaration is
forall (x : Real) (y : Real), Eq.{1} NNReal (NNDist.nndist.{0} Real (PseudoMetricSpace.toNNDist.{0} Real Real.pseudoMetricSpace) x y) (coeFn.{1, 1} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) (fun (_x : MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) => Real -> NNReal) (MonoidWithZeroHom.hasCoeToFun.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) Real.nnabs (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y))
but is expected to have type
forall (x : Real) (y : Real), Eq.{1} NNReal (NNDist.nndist.{0} Real (PseudoMetricSpace.toNNDist.{0} Real Real.pseudoMetricSpace) x y) (FunLike.coe.{1, 1, 1} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real (fun (_x : Real) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Real) => NNReal) _x) (MulHomClass.toFunLike.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (MulOneClass.toMul.{0} Real (MulZeroOneClass.toMulOneClass.{0} Real (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))))) (MulOneClass.toMul.{0} NNReal (MulZeroOneClass.toMulOneClass.{0} NNReal (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)))) (MonoidHomClass.toMulHomClass.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (MulZeroOneClass.toMulOneClass.{0} Real (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal)))) (MulZeroOneClass.toMulOneClass.{0} NNReal (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) (MonoidWithZeroHomClass.toMonoidHomClass.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)) (MonoidWithZeroHom.monoidWithZeroHomClass.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)))))) Real.nnabs (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y))
Case conversion may be inaccurate. Consider using '#align real.nndist_eq Real.nndist_eqₓ'. -/
theorem Real.nndist_eq (x y : ℝ) : nndist x y = Real.nnabs (x - y) :=
rfl
#align real.nndist_eq Real.nndist_eq
/- warning: real.nndist_eq' -> Real.nndist_eq' is a dubious translation:
lean 3 declaration is
forall (x : Real) (y : Real), Eq.{1} NNReal (NNDist.nndist.{0} Real (PseudoMetricSpace.toNNDist.{0} Real Real.pseudoMetricSpace) x y) (coeFn.{1, 1} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) (fun (_x : MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) => Real -> NNReal) (MonoidWithZeroHom.hasCoeToFun.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.ring))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))) Real.nnabs (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) y x))
but is expected to have type
forall (x : Real) (y : Real), Eq.{1} NNReal (NNDist.nndist.{0} Real (PseudoMetricSpace.toNNDist.{0} Real Real.pseudoMetricSpace) x y) (FunLike.coe.{1, 1, 1} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real (fun (_x : Real) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Real) => NNReal) _x) (MulHomClass.toFunLike.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (MulOneClass.toMul.{0} Real (MulZeroOneClass.toMulOneClass.{0} Real (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))))) (MulOneClass.toMul.{0} NNReal (MulZeroOneClass.toMulOneClass.{0} NNReal (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)))) (MonoidHomClass.toMulHomClass.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (MulZeroOneClass.toMulOneClass.{0} Real (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal)))) (MulZeroOneClass.toMulOneClass.{0} NNReal (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) (MonoidWithZeroHomClass.toMonoidHomClass.{0, 0, 0} (MonoidWithZeroHom.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))) Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)) (MonoidWithZeroHom.monoidWithZeroHomClass.{0, 0} Real NNReal (NonAssocSemiring.toMulZeroOneClass.{0} Real (NonAssocRing.toNonAssocSemiring.{0} Real (Ring.toNonAssocRing.{0} Real Real.instRingReal))) (NonAssocSemiring.toMulZeroOneClass.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring)))))) Real.nnabs (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) y x))
Case conversion may be inaccurate. Consider using '#align real.nndist_eq' Real.nndist_eq'ₓ'. -/
theorem Real.nndist_eq' (x y : ℝ) : nndist x y = Real.nnabs (y - x) :=
nndist_comm _ _
#align real.nndist_eq' Real.nndist_eq'
/- warning: real.dist_0_eq_abs -> Real.dist_0_eq_abs is a dubious translation:
lean 3 declaration is
forall (x : Real), Eq.{1} Real (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x)
but is expected to have type
forall (x : Real), Eq.{1} Real (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x)
Case conversion may be inaccurate. Consider using '#align real.dist_0_eq_abs Real.dist_0_eq_absₓ'. -/
theorem Real.dist_0_eq_abs (x : ℝ) : dist x 0 = |x| := by simp [Real.dist_eq]
#align real.dist_0_eq_abs Real.dist_0_eq_abs
/- warning: real.dist_left_le_of_mem_uIcc -> Real.dist_left_le_of_mem_uIcc is a dubious translation:
lean 3 declaration is
forall {x : Real} {y : Real} {z : Real}, (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) y (Set.uIcc.{0} Real Real.lattice x z)) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x y) (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x z))
but is expected to have type
forall {x : Real} {y : Real} {z : Real}, (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) y (Set.uIcc.{0} Real Real.lattice x z)) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x y) (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x z))
Case conversion may be inaccurate. Consider using '#align real.dist_left_le_of_mem_uIcc Real.dist_left_le_of_mem_uIccₓ'. -/
theorem Real.dist_left_le_of_mem_uIcc {x y z : ℝ} (h : y ∈ uIcc x z) : dist x y ≤ dist x z := by
simpa only [dist_comm x] using abs_sub_left_of_mem_uIcc h
#align real.dist_left_le_of_mem_uIcc Real.dist_left_le_of_mem_uIcc
/- warning: real.dist_right_le_of_mem_uIcc -> Real.dist_right_le_of_mem_uIcc is a dubious translation:
lean 3 declaration is
forall {x : Real} {y : Real} {z : Real}, (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) y (Set.uIcc.{0} Real Real.lattice x z)) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) y z) (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x z))
but is expected to have type
forall {x : Real} {y : Real} {z : Real}, (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) y (Set.uIcc.{0} Real Real.lattice x z)) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) y z) (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x z))
Case conversion may be inaccurate. Consider using '#align real.dist_right_le_of_mem_uIcc Real.dist_right_le_of_mem_uIccₓ'. -/
theorem Real.dist_right_le_of_mem_uIcc {x y z : ℝ} (h : y ∈ uIcc x z) : dist y z ≤ dist x z := by
simpa only [dist_comm _ z] using abs_sub_right_of_mem_uIcc h
#align real.dist_right_le_of_mem_uIcc Real.dist_right_le_of_mem_uIcc
/- warning: real.dist_le_of_mem_uIcc -> Real.dist_le_of_mem_uIcc is a dubious translation:
lean 3 declaration is
forall {x : Real} {y : Real} {x' : Real} {y' : Real}, (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.uIcc.{0} Real Real.lattice x' y')) -> (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) y (Set.uIcc.{0} Real Real.lattice x' y')) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x y) (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x' y'))
but is expected to have type
forall {x : Real} {y : Real} {x' : Real} {y' : Real}, (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.uIcc.{0} Real Real.lattice x' y')) -> (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) y (Set.uIcc.{0} Real Real.lattice x' y')) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x y) (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x' y'))
Case conversion may be inaccurate. Consider using '#align real.dist_le_of_mem_uIcc Real.dist_le_of_mem_uIccₓ'. -/
theorem Real.dist_le_of_mem_uIcc {x y x' y' : ℝ} (hx : x ∈ uIcc x' y') (hy : y ∈ uIcc x' y') :
dist x y ≤ dist x' y' :=
abs_sub_le_of_uIcc_subset_uIcc <| uIcc_subset_uIcc (by rwa [uIcc_comm]) (by rwa [uIcc_comm])
#align real.dist_le_of_mem_uIcc Real.dist_le_of_mem_uIcc
/- warning: real.dist_le_of_mem_Icc -> Real.dist_le_of_mem_Icc is a dubious translation:
lean 3 declaration is
forall {x : Real} {y : Real} {x' : Real} {y' : Real}, (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.Icc.{0} Real Real.preorder x' y')) -> (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) y (Set.Icc.{0} Real Real.preorder x' y')) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x y) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) y' x'))
but is expected to have type
forall {x : Real} {y : Real} {x' : Real} {y' : Real}, (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.Icc.{0} Real Real.instPreorderReal x' y')) -> (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) y (Set.Icc.{0} Real Real.instPreorderReal x' y')) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x y) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) y' x'))
Case conversion may be inaccurate. Consider using '#align real.dist_le_of_mem_Icc Real.dist_le_of_mem_Iccₓ'. -/
theorem Real.dist_le_of_mem_Icc {x y x' y' : ℝ} (hx : x ∈ Icc x' y') (hy : y ∈ Icc x' y') :
dist x y ≤ y' - x' := by
simpa only [Real.dist_eq, abs_of_nonpos (sub_nonpos.2 <| hx.1.trans hx.2), neg_sub] using
Real.dist_le_of_mem_uIcc (Icc_subset_uIcc hx) (Icc_subset_uIcc hy)
#align real.dist_le_of_mem_Icc Real.dist_le_of_mem_Icc
/- warning: real.dist_le_of_mem_Icc_01 -> Real.dist_le_of_mem_Icc_01 is a dubious translation:
lean 3 declaration is
forall {x : Real} {y : Real}, (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.Icc.{0} Real Real.preorder (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))) -> (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) y (Set.Icc.{0} Real Real.preorder (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{0} Real (PseudoMetricSpace.toHasDist.{0} Real Real.pseudoMetricSpace) x y) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))
but is expected to have type
forall {x : Real} {y : Real}, (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.Icc.{0} Real Real.instPreorderReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))) -> (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) y (Set.Icc.{0} Real Real.instPreorderReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{0} Real (PseudoMetricSpace.toDist.{0} Real Real.pseudoMetricSpace) x y) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))
Case conversion may be inaccurate. Consider using '#align real.dist_le_of_mem_Icc_01 Real.dist_le_of_mem_Icc_01ₓ'. -/
theorem Real.dist_le_of_mem_Icc_01 {x y : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) (hy : y ∈ Icc (0 : ℝ) 1) :
dist x y ≤ 1 := by simpa only [sub_zero] using Real.dist_le_of_mem_Icc hx hy
#align real.dist_le_of_mem_Icc_01 Real.dist_le_of_mem_Icc_01
instance : OrderTopology ℝ :=
orderTopology_of_nhds_abs fun x => by
simp only [nhds_basis_ball.eq_binfi, ball, Real.dist_eq, abs_sub_comm]
/- warning: real.ball_eq_Ioo -> Real.ball_eq_Ioo is a dubious translation:
lean 3 declaration is
forall (x : Real) (r : Real), Eq.{1} (Set.{0} Real) (Metric.ball.{0} Real Real.pseudoMetricSpace x r) (Set.Ioo.{0} Real Real.preorder (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x r) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x r))
but is expected to have type
forall (x : Real) (r : Real), Eq.{1} (Set.{0} Real) (Metric.ball.{0} Real Real.pseudoMetricSpace x r) (Set.Ioo.{0} Real Real.instPreorderReal (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x r) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x r))
Case conversion may be inaccurate. Consider using '#align real.ball_eq_Ioo Real.ball_eq_Iooₓ'. -/
theorem Real.ball_eq_Ioo (x r : ℝ) : ball x r = Ioo (x - r) (x + r) :=
Set.ext fun y => by
rw [mem_ball, dist_comm, Real.dist_eq, abs_sub_lt_iff, mem_Ioo, ← sub_lt_iff_lt_add',
sub_lt_comm]
#align real.ball_eq_Ioo Real.ball_eq_Ioo
/- warning: real.closed_ball_eq_Icc -> Real.closedBall_eq_Icc is a dubious translation:
lean 3 declaration is
forall {x : Real} {r : Real}, Eq.{1} (Set.{0} Real) (Metric.closedBall.{0} Real Real.pseudoMetricSpace x r) (Set.Icc.{0} Real Real.preorder (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x r) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x r))
but is expected to have type
forall {x : Real} {r : Real}, Eq.{1} (Set.{0} Real) (Metric.closedBall.{0} Real Real.pseudoMetricSpace x r) (Set.Icc.{0} Real Real.instPreorderReal (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x r) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x r))
Case conversion may be inaccurate. Consider using '#align real.closed_ball_eq_Icc Real.closedBall_eq_Iccₓ'. -/
theorem Real.closedBall_eq_Icc {x r : ℝ} : closedBall x r = Icc (x - r) (x + r) := by
ext y <;>
rw [mem_closed_ball, dist_comm, Real.dist_eq, abs_sub_le_iff, mem_Icc, ← sub_le_iff_le_add',
sub_le_comm]
#align real.closed_ball_eq_Icc Real.closedBall_eq_Icc
/- warning: real.Ioo_eq_ball -> Real.Ioo_eq_ball is a dubious translation:
lean 3 declaration is
forall (x : Real) (y : Real), Eq.{1} (Set.{0} Real) (Set.Ioo.{0} Real Real.preorder x y) (Metric.ball.{0} Real Real.pseudoMetricSpace (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) y x) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))
but is expected to have type
forall (x : Real) (y : Real), Eq.{1} (Set.{0} Real) (Set.Ioo.{0} Real Real.instPreorderReal x y) (Metric.ball.{0} Real Real.pseudoMetricSpace (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) y x) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))
Case conversion may be inaccurate. Consider using '#align real.Ioo_eq_ball Real.Ioo_eq_ballₓ'. -/
theorem Real.Ioo_eq_ball (x y : ℝ) : Ioo x y = ball ((x + y) / 2) ((y - x) / 2) := by
rw [Real.ball_eq_Ioo, ← sub_div, add_comm, ← sub_add, add_sub_cancel', add_self_div_two, ←
add_div, add_assoc, add_sub_cancel'_right, add_self_div_two]
#align real.Ioo_eq_ball Real.Ioo_eq_ball
/- warning: real.Icc_eq_closed_ball -> Real.Icc_eq_closedBall is a dubious translation:
lean 3 declaration is
forall (x : Real) (y : Real), Eq.{1} (Set.{0} Real) (Set.Icc.{0} Real Real.preorder x y) (Metric.closedBall.{0} Real Real.pseudoMetricSpace (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) y x) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))
but is expected to have type
forall (x : Real) (y : Real), Eq.{1} (Set.{0} Real) (Set.Icc.{0} Real Real.instPreorderReal x y) (Metric.closedBall.{0} Real Real.pseudoMetricSpace (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) y x) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))
Case conversion may be inaccurate. Consider using '#align real.Icc_eq_closed_ball Real.Icc_eq_closedBallₓ'. -/
theorem Real.Icc_eq_closedBall (x y : ℝ) : Icc x y = closedBall ((x + y) / 2) ((y - x) / 2) := by
rw [Real.closedBall_eq_Icc, ← sub_div, add_comm, ← sub_add, add_sub_cancel', add_self_div_two, ←
add_div, add_assoc, add_sub_cancel'_right, add_self_div_two]
#align real.Icc_eq_closed_ball Real.Icc_eq_closedBall
section MetricOrdered
variable [Preorder α] [CompactIccSpace α]
#print totallyBounded_Icc /-
theorem totallyBounded_Icc (a b : α) : TotallyBounded (Icc a b) :=
isCompact_Icc.TotallyBounded
#align totally_bounded_Icc totallyBounded_Icc
-/
#print totallyBounded_Ico /-
theorem totallyBounded_Ico (a b : α) : TotallyBounded (Ico a b) :=
totallyBounded_subset Ico_subset_Icc_self (totallyBounded_Icc a b)
#align totally_bounded_Ico totallyBounded_Ico
-/
#print totallyBounded_Ioc /-
theorem totallyBounded_Ioc (a b : α) : TotallyBounded (Ioc a b) :=
totallyBounded_subset Ioc_subset_Icc_self (totallyBounded_Icc a b)
#align totally_bounded_Ioc totallyBounded_Ioc
-/
#print totallyBounded_Ioo /-
theorem totallyBounded_Ioo (a b : α) : TotallyBounded (Ioo a b) :=
totallyBounded_subset Ioo_subset_Icc_self (totallyBounded_Icc a b)
#align totally_bounded_Ioo totallyBounded_Ioo
-/
end MetricOrdered
/- warning: squeeze_zero' -> squeeze_zero' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {f : α -> Real} {g : α -> Real} {t₀ : Filter.{u1} α}, (Filter.Eventually.{u1} α (fun (t : α) => LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (f t)) t₀) -> (Filter.Eventually.{u1} α (fun (t : α) => LE.le.{0} Real Real.hasLe (f t) (g t)) t₀) -> (Filter.Tendsto.{u1, 0} α Real g t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Filter.Tendsto.{u1, 0} α Real f t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} {f : α -> Real} {g : α -> Real} {t₀ : Filter.{u1} α}, (Filter.Eventually.{u1} α (fun (t : α) => LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (f t)) t₀) -> (Filter.Eventually.{u1} α (fun (t : α) => LE.le.{0} Real Real.instLEReal (f t) (g t)) t₀) -> (Filter.Tendsto.{u1, 0} α Real g t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Filter.Tendsto.{u1, 0} α Real f t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align squeeze_zero' squeeze_zero'ₓ'. -/
/-- Special case of the sandwich theorem; see `tendsto_of_tendsto_of_tendsto_of_le_of_le'` for the
general case. -/
theorem squeeze_zero' {α} {f g : α → ℝ} {t₀ : Filter α} (hf : ∀ᶠ t in t₀, 0 ≤ f t)
(hft : ∀ᶠ t in t₀, f t ≤ g t) (g0 : Tendsto g t₀ (nhds 0)) : Tendsto f t₀ (𝓝 0) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds g0 hf hft
#align squeeze_zero' squeeze_zero'
/- warning: squeeze_zero -> squeeze_zero is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {f : α -> Real} {g : α -> Real} {t₀ : Filter.{u1} α}, (forall (t : α), LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (f t)) -> (forall (t : α), LE.le.{0} Real Real.hasLe (f t) (g t)) -> (Filter.Tendsto.{u1, 0} α Real g t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Filter.Tendsto.{u1, 0} α Real f t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} {f : α -> Real} {g : α -> Real} {t₀ : Filter.{u1} α}, (forall (t : α), LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (f t)) -> (forall (t : α), LE.le.{0} Real Real.instLEReal (f t) (g t)) -> (Filter.Tendsto.{u1, 0} α Real g t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Filter.Tendsto.{u1, 0} α Real f t₀ (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align squeeze_zero squeeze_zeroₓ'. -/
/-- Special case of the sandwich theorem; see `tendsto_of_tendsto_of_tendsto_of_le_of_le`
and `tendsto_of_tendsto_of_tendsto_of_le_of_le'` for the general case. -/
theorem squeeze_zero {α} {f g : α → ℝ} {t₀ : Filter α} (hf : ∀ t, 0 ≤ f t) (hft : ∀ t, f t ≤ g t)
(g0 : Tendsto g t₀ (𝓝 0)) : Tendsto f t₀ (𝓝 0) :=
squeeze_zero' (eventually_of_forall hf) (eventually_of_forall hft) g0
#align squeeze_zero squeeze_zero
/- warning: metric.uniformity_eq_comap_nhds_zero -> Metric.uniformity_eq_comap_nhds_zero is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Filter.comap.{u1, 0} (Prod.{u1, u1} α α) Real (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Filter.comap.{u1, 0} (Prod.{u1, u1} α α) Real (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align metric.uniformity_eq_comap_nhds_zero Metric.uniformity_eq_comap_nhds_zeroₓ'. -/
theorem Metric.uniformity_eq_comap_nhds_zero :
𝓤 α = comap (fun p : α × α => dist p.1 p.2) (𝓝 (0 : ℝ)) :=
by
ext s
simp [mem_uniformity_dist, (nhds_basis_ball.comap _).mem_iff, subset_def, Real.dist_0_eq_abs]
#align metric.uniformity_eq_comap_nhds_zero Metric.uniformity_eq_comap_nhds_zero
/- warning: cauchy_seq_iff_tendsto_dist_at_top_0 -> cauchySeq_iff_tendsto_dist_atTop_0 is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (Filter.Tendsto.{u2, 0} (Prod.{u2, u2} β β) Real (fun (n : Prod.{u2, u2} β β) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u (Prod.fst.{u2, u2} β β n)) (u (Prod.snd.{u2, u2} β β n))) (Filter.atTop.{u2} (Prod.{u2, u2} β β) (Prod.preorder.{u2, u2} β β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)) (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (Filter.Tendsto.{u2, 0} (Prod.{u2, u2} β β) Real (fun (n : Prod.{u2, u2} β β) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u (Prod.fst.{u2, u2} β β n)) (u (Prod.snd.{u2, u2} β β n))) (Filter.atTop.{u2} (Prod.{u2, u2} β β) (Prod.instPreorderProd.{u2, u2} β β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)) (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3)))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align cauchy_seq_iff_tendsto_dist_at_top_0 cauchySeq_iff_tendsto_dist_atTop_0ₓ'. -/
theorem cauchySeq_iff_tendsto_dist_atTop_0 [Nonempty β] [SemilatticeSup β] {u : β → α} :
CauchySeq u ↔ Tendsto (fun n : β × β => dist (u n.1) (u n.2)) atTop (𝓝 0) := by
rw [cauchySeq_iff_tendsto, Metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff, Prod.map_def]
#align cauchy_seq_iff_tendsto_dist_at_top_0 cauchySeq_iff_tendsto_dist_atTop_0
/- warning: tendsto_uniformity_iff_dist_tendsto_zero -> tendsto_uniformity_iff_dist_tendsto_zero is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u2}} {f : ι -> (Prod.{u1, u1} α α)} {p : Filter.{u2} ι}, Iff (Filter.Tendsto.{u2, u1} ι (Prod.{u1, u1} α α) f p (uniformity.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (Filter.Tendsto.{u2, 0} ι Real (fun (x : ι) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α (f x)) (Prod.snd.{u1, u1} α α (f x))) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {f : ι -> (Prod.{u2, u2} α α)} {p : Filter.{u1} ι}, Iff (Filter.Tendsto.{u1, u2} ι (Prod.{u2, u2} α α) f p (uniformity.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1))) (Filter.Tendsto.{u1, 0} ι Real (fun (x : ι) => Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (Prod.fst.{u2, u2} α α (f x)) (Prod.snd.{u2, u2} α α (f x))) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align tendsto_uniformity_iff_dist_tendsto_zero tendsto_uniformity_iff_dist_tendsto_zeroₓ'. -/
theorem tendsto_uniformity_iff_dist_tendsto_zero {ι : Type _} {f : ι → α × α} {p : Filter ι} :
Tendsto f p (𝓤 α) ↔ Tendsto (fun x => dist (f x).1 (f x).2) p (𝓝 0) := by
rw [Metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff]
#align tendsto_uniformity_iff_dist_tendsto_zero tendsto_uniformity_iff_dist_tendsto_zero
/- warning: filter.tendsto.congr_dist -> Filter.Tendsto.congr_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u2}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u2} ι} {a : α}, (Filter.Tendsto.{u2, u1} ι α f₁ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) -> (Filter.Tendsto.{u2, 0} ι Real (fun (x : ι) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Filter.Tendsto.{u2, u1} ι α f₂ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u1} ι} {a : α}, (Filter.Tendsto.{u1, u2} ι α f₁ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a)) -> (Filter.Tendsto.{u1, 0} ι Real (fun (x : ι) => Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Filter.Tendsto.{u1, u2} ι α f₂ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a))
Case conversion may be inaccurate. Consider using '#align filter.tendsto.congr_dist Filter.Tendsto.congr_distₓ'. -/
theorem Filter.Tendsto.congr_dist {ι : Type _} {f₁ f₂ : ι → α} {p : Filter ι} {a : α}
(h₁ : Tendsto f₁ p (𝓝 a)) (h : Tendsto (fun x => dist (f₁ x) (f₂ x)) p (𝓝 0)) :
Tendsto f₂ p (𝓝 a) :=
h₁.congr_uniformity <| tendsto_uniformity_iff_dist_tendsto_zero.2 h
#align filter.tendsto.congr_dist Filter.Tendsto.congr_dist
/- warning: tendsto_of_tendsto_of_dist -> tendsto_of_tendsto_of_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u2}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u2} ι} {a : α}, (Filter.Tendsto.{u2, u1} ι α f₁ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) -> (Filter.Tendsto.{u2, 0} ι Real (fun (x : ι) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Filter.Tendsto.{u2, u1} ι α f₂ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u1} ι} {a : α}, (Filter.Tendsto.{u1, u2} ι α f₁ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a)) -> (Filter.Tendsto.{u1, 0} ι Real (fun (x : ι) => Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Filter.Tendsto.{u1, u2} ι α f₂ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a))
Case conversion may be inaccurate. Consider using '#align tendsto_of_tendsto_of_dist tendsto_of_tendsto_of_distₓ'. -/
alias Filter.Tendsto.congr_dist ← tendsto_of_tendsto_of_dist
#align tendsto_of_tendsto_of_dist tendsto_of_tendsto_of_dist
/- warning: tendsto_iff_of_dist -> tendsto_iff_of_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {ι : Type.{u2}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u2} ι} {a : α}, (Filter.Tendsto.{u2, 0} ι Real (fun (x : ι) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Iff (Filter.Tendsto.{u2, u1} ι α f₁ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (Filter.Tendsto.{u2, u1} ι α f₂ p (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {ι : Type.{u1}} {f₁ : ι -> α} {f₂ : ι -> α} {p : Filter.{u1} ι} {a : α}, (Filter.Tendsto.{u1, 0} ι Real (fun (x : ι) => Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f₁ x) (f₂ x)) p (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Iff (Filter.Tendsto.{u1, u2} ι α f₁ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a)) (Filter.Tendsto.{u1, u2} ι α f₂ p (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) a)))
Case conversion may be inaccurate. Consider using '#align tendsto_iff_of_dist tendsto_iff_of_distₓ'. -/
theorem tendsto_iff_of_dist {ι : Type _} {f₁ f₂ : ι → α} {p : Filter ι} {a : α}
(h : Tendsto (fun x => dist (f₁ x) (f₂ x)) p (𝓝 0)) : Tendsto f₁ p (𝓝 a) ↔ Tendsto f₂ p (𝓝 a) :=
Uniform.tendsto_congr <| tendsto_uniformity_iff_dist_tendsto_zero.2 h
#align tendsto_iff_of_dist tendsto_iff_of_dist
/- warning: eventually_closed_ball_subset -> eventually_closedBall_subset is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {u : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) u (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) -> (Filter.Eventually.{0} Real (fun (r : Real) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.closedBall.{u1} α _inst_1 x r) u) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {u : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) u (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) x)) -> (Filter.Eventually.{0} Real (fun (r : Real) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.closedBall.{u1} α _inst_1 x r) u) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align eventually_closed_ball_subset eventually_closedBall_subsetₓ'. -/
/-- If `u` is a neighborhood of `x`, then for small enough `r`, the closed ball
`closed_ball x r` is contained in `u`. -/
theorem eventually_closedBall_subset {x : α} {u : Set α} (hu : u ∈ 𝓝 x) :
∀ᶠ r in 𝓝 (0 : ℝ), closedBall x r ⊆ u :=
by
obtain ⟨ε, εpos, hε⟩ : ∃ (ε : _)(hε : 0 < ε), closed_ball x ε ⊆ u :=
nhds_basis_closed_ball.mem_iff.1 hu
have : Iic ε ∈ 𝓝 (0 : ℝ) := Iic_mem_nhds εpos
filter_upwards [this]with _ hr using subset.trans (closed_ball_subset_closed_ball hr) hε
#align eventually_closed_ball_subset eventually_closedBall_subset
end Real
section CauchySeq
variable [Nonempty β] [SemilatticeSup β]
/- warning: metric.cauchy_seq_iff -> Metric.cauchySeq_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (N : β) => forall (m : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) m N) -> (forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u m) (u n)) ε)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (N : β) => forall (m : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) m N) -> (forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u m) (u n)) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.cauchy_seq_iff Metric.cauchySeq_iffₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (m n «expr ≥ » N) -/
-- see Note [nolint_ge]
/-- In a pseudometric space, Cauchy sequences are characterized by the fact that, eventually,
the distance between its elements is arbitrarily small -/
@[nolint ge_or_gt]
theorem Metric.cauchySeq_iff {u : β → α} :
CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ (m) (_ : m ≥ N) (n) (_ : n ≥ N), dist (u m) (u n) < ε :=
uniformity_basis_dist.cauchySeq_iff
#align metric.cauchy_seq_iff Metric.cauchySeq_iff
/- warning: metric.cauchy_seq_iff' -> Metric.cauchySeq_iff' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u n) (u N)) ε))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {u : β -> α}, Iff (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 u) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (N : β) => forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u n) (u N)) ε))))
Case conversion may be inaccurate. Consider using '#align metric.cauchy_seq_iff' Metric.cauchySeq_iff'ₓ'. -/
/-- A variation around the pseudometric characterization of Cauchy sequences -/
theorem Metric.cauchySeq_iff' {u : β → α} :
CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) (u N) < ε :=
uniformity_basis_dist.cauchySeq_iff'
#align metric.cauchy_seq_iff' Metric.cauchySeq_iff'
/- warning: metric.uniform_cauchy_seq_on_iff -> Metric.uniformCauchySeqOn_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {γ : Type.{u3}} {F : β -> γ -> α} {s : Set.{u3} γ}, Iff (UniformCauchySeqOn.{u3, u1, u2} γ α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) F (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (N : β) => forall (m : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) m N) -> (forall (n : β), (GE.ge.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n N) -> (forall (x : γ), (Membership.Mem.{u3, u3} γ (Set.{u3} γ) (Set.hasMem.{u3} γ) x s) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (F m x) (F n x)) ε))))))
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : PseudoMetricSpace.{u2} α] [_inst_2 : Nonempty.{succ u3} β] [_inst_3 : SemilatticeSup.{u3} β] {γ : Type.{u1}} {F : β -> γ -> α} {s : Set.{u1} γ}, Iff (UniformCauchySeqOn.{u1, u2, u3} γ α β (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1) F (Filter.atTop.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeSup.toPartialOrder.{u3} β _inst_3))) s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u3} β (fun (N : β) => forall (m : β), (GE.ge.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeSup.toPartialOrder.{u3} β _inst_3))) m N) -> (forall (n : β), (GE.ge.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeSup.toPartialOrder.{u3} β _inst_3))) n N) -> (forall (x : γ), (Membership.mem.{u1, u1} γ (Set.{u1} γ) (Set.instMembershipSet.{u1} γ) x s) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (F m x) (F n x)) ε))))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_cauchy_seq_on_iff Metric.uniformCauchySeqOn_iffₓ'. -/
-- see Note [nolint_ge]
/-- In a pseudometric space, unifom Cauchy sequences are characterized by the fact that, eventually,
the distance between all its elements is uniformly, arbitrarily small -/
@[nolint ge_or_gt]
theorem Metric.uniformCauchySeqOn_iff {γ : Type _} {F : β → γ → α} {s : Set γ} :
UniformCauchySeqOn F atTop s ↔
∀ ε : ℝ,
ε > 0 →
∃ N : β, ∀ m : β, m ≥ N → ∀ n : β, n ≥ N → ∀ x : γ, x ∈ s → dist (F m x) (F n x) < ε :=
by
constructor
· intro h ε hε
let u := { a : α × α | dist a.fst a.snd < ε }
have hu : u ∈ 𝓤 α := metric.mem_uniformity_dist.mpr ⟨ε, hε, fun a b => by simp⟩
rw [←
@Filter.eventually_atTop_prod_self' _ _ _ fun m =>
∀ x : γ, x ∈ s → dist (F m.fst x) (F m.snd x) < ε]
specialize h u hu
rw [prod_at_top_at_top_eq] at h
exact h.mono fun n h x hx => set.mem_set_of_eq.mp (h x hx)
· intro h u hu
rcases metric.mem_uniformity_dist.mp hu with ⟨ε, hε, hab⟩
rcases h ε hε with ⟨N, hN⟩
rw [prod_at_top_at_top_eq, eventually_at_top]
use (N, N)
intro b hb x hx
rcases hb with ⟨hbl, hbr⟩
exact hab (hN b.fst hbl.ge b.snd hbr.ge x hx)
#align metric.uniform_cauchy_seq_on_iff Metric.uniformCauchySeqOn_iff
/- warning: cauchy_seq_of_le_tendsto_0' -> cauchySeq_of_le_tendsto_0' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {s : β -> α} (b : β -> Real), (forall (n : β) (m : β), (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n m) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (s n) (s m)) (b n))) -> (Filter.Tendsto.{u2, 0} β Real b (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 s)
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {s : β -> α} (b : β -> Real), (forall (n : β) (m : β), (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) n m) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (s n) (s m)) (b n))) -> (Filter.Tendsto.{u2, 0} β Real b (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 s)
Case conversion may be inaccurate. Consider using '#align cauchy_seq_of_le_tendsto_0' cauchySeq_of_le_tendsto_0'ₓ'. -/
/-- If the distance between `s n` and `s m`, `n ≤ m` is bounded above by `b n`
and `b` converges to zero, then `s` is a Cauchy sequence. -/
theorem cauchySeq_of_le_tendsto_0' {s : β → α} (b : β → ℝ)
(h : ∀ n m : β, n ≤ m → dist (s n) (s m) ≤ b n) (h₀ : Tendsto b atTop (𝓝 0)) : CauchySeq s :=
Metric.cauchySeq_iff'.2 fun ε ε0 =>
(h₀.Eventually (gt_mem_nhds ε0)).exists.imp fun N hN n hn =>
calc
dist (s n) (s N) = dist (s N) (s n) := dist_comm _ _
_ ≤ b N := (h _ _ hn)
_ < ε := hN
#align cauchy_seq_of_le_tendsto_0' cauchySeq_of_le_tendsto_0'
/- warning: cauchy_seq_of_le_tendsto_0 -> cauchySeq_of_le_tendsto_0 is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {s : β -> α} (b : β -> Real), (forall (n : β) (m : β) (N : β), (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) N n) -> (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) N m) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (s n) (s m)) (b N))) -> (Filter.Tendsto.{u2, 0} β Real b (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 s)
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Nonempty.{succ u2} β] [_inst_3 : SemilatticeSup.{u2} β] {s : β -> α} (b : β -> Real), (forall (n : β) (m : β) (N : β), (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) N n) -> (LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) N m) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (s n) (s m)) (b N))) -> (Filter.Tendsto.{u2, 0} β Real b (Filter.atTop.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeSup.toPartialOrder.{u2} β _inst_3))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (CauchySeq.{u1, u2} α β (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) _inst_3 s)
Case conversion may be inaccurate. Consider using '#align cauchy_seq_of_le_tendsto_0 cauchySeq_of_le_tendsto_0ₓ'. -/
/-- If the distance between `s n` and `s m`, `n, m ≥ N` is bounded above by `b N`
and `b` converges to zero, then `s` is a Cauchy sequence. -/
theorem cauchySeq_of_le_tendsto_0 {s : β → α} (b : β → ℝ)
(h : ∀ n m N : β, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) (h₀ : Tendsto b atTop (𝓝 0)) :
CauchySeq s :=
cauchySeq_of_le_tendsto_0' b (fun n m hnm => h _ _ _ le_rfl hnm) h₀
#align cauchy_seq_of_le_tendsto_0 cauchySeq_of_le_tendsto_0
/- warning: cauchy_seq_bdd -> cauchySeq_bdd is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {u : Nat -> α}, (CauchySeq.{u1, 0} α Nat (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (CanonicallyLinearOrderedAddMonoid.semilatticeSup.{0} Nat Nat.canonicallyLinearOrderedAddMonoid) u) -> (Exists.{1} Real (fun (R : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt R (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt R (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (m : Nat) (n : Nat), LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (u m) (u n)) R)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {u : Nat -> α}, (CauchySeq.{u1, 0} α Nat (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (Lattice.toSemilatticeSup.{0} Nat (DistribLattice.toLattice.{0} Nat instDistribLatticeNat)) u) -> (Exists.{1} Real (fun (R : Real) => And (GT.gt.{0} Real Real.instLTReal R (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (m : Nat) (n : Nat), LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (u m) (u n)) R)))
Case conversion may be inaccurate. Consider using '#align cauchy_seq_bdd cauchySeq_bddₓ'. -/
/-- A Cauchy sequence on the natural numbers is bounded. -/
theorem cauchySeq_bdd {u : ℕ → α} (hu : CauchySeq u) : ∃ R > 0, ∀ m n, dist (u m) (u n) < R :=
by
rcases Metric.cauchySeq_iff'.1 hu 1 zero_lt_one with ⟨N, hN⟩
rsuffices ⟨R, R0, H⟩ : ∃ R > 0, ∀ n, dist (u n) (u N) < R
·
exact
⟨_, add_pos R0 R0, fun m n =>
lt_of_le_of_lt (dist_triangle_right _ _ _) (add_lt_add (H m) (H n))⟩
let R := Finset.sup (Finset.range N) fun n => nndist (u n) (u N)
refine' ⟨↑R + 1, add_pos_of_nonneg_of_pos R.2 zero_lt_one, fun n => _⟩
cases le_or_lt N n
· exact lt_of_lt_of_le (hN _ h) (le_add_of_nonneg_left R.2)
· have : _ ≤ R := Finset.le_sup (Finset.mem_range.2 h)
exact lt_of_le_of_lt this (lt_add_of_pos_right _ zero_lt_one)
#align cauchy_seq_bdd cauchySeq_bdd
/- warning: cauchy_seq_iff_le_tendsto_0 -> cauchySeq_iff_le_tendsto_0 is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Nat -> α}, Iff (CauchySeq.{u1, 0} α Nat (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (CanonicallyLinearOrderedAddMonoid.semilatticeSup.{0} Nat Nat.canonicallyLinearOrderedAddMonoid) s) (Exists.{1} (Nat -> Real) (fun (b : Nat -> Real) => And (forall (n : Nat), LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (b n)) (And (forall (n : Nat) (m : Nat) (N : Nat), (LE.le.{0} Nat Nat.hasLe N n) -> (LE.le.{0} Nat Nat.hasLe N m) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (s n) (s m)) (b N))) (Filter.Tendsto.{0, 0} Nat Real b (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Nat -> α}, Iff (CauchySeq.{u1, 0} α Nat (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (Lattice.toSemilatticeSup.{0} Nat (DistribLattice.toLattice.{0} Nat instDistribLatticeNat)) s) (Exists.{1} (Nat -> Real) (fun (b : Nat -> Real) => And (forall (n : Nat), LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (b n)) (And (forall (n : Nat) (m : Nat) (N : Nat), (LE.le.{0} Nat instLENat N n) -> (LE.le.{0} Nat instLENat N m) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (s n) (s m)) (b N))) (Filter.Tendsto.{0, 0} Nat Real b (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))))))
Case conversion may be inaccurate. Consider using '#align cauchy_seq_iff_le_tendsto_0 cauchySeq_iff_le_tendsto_0ₓ'. -/
/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the
most efficient. -/
theorem cauchySeq_iff_le_tendsto_0 {s : ℕ → α} :
CauchySeq s ↔
∃ b : ℕ → ℝ,
(∀ n, 0 ≤ b n) ∧
(∀ n m N : ℕ, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) ∧ Tendsto b atTop (𝓝 0) :=
⟨fun hs =>
by
/- `s` is a Cauchy sequence. The sequence `b` will be constructed by taking
the supremum of the distances between `s n` and `s m` for `n m ≥ N`.
First, we prove that all these distances are bounded, as otherwise the Sup
would not make sense. -/
let S N := (fun p : ℕ × ℕ => dist (s p.1) (s p.2)) '' { p | p.1 ≥ N ∧ p.2 ≥ N }
have hS : ∀ N, ∃ x, ∀ y ∈ S N, y ≤ x :=
by
rcases cauchySeq_bdd hs with ⟨R, R0, hR⟩
refine' fun N => ⟨R, _⟩
rintro _ ⟨⟨m, n⟩, _, rfl⟩
exact le_of_lt (hR m n)
have bdd : BddAbove (range fun p : ℕ × ℕ => dist (s p.1) (s p.2)) :=
by
rcases cauchySeq_bdd hs with ⟨R, R0, hR⟩
use R
rintro _ ⟨⟨m, n⟩, rfl⟩
exact le_of_lt (hR m n)
-- Prove that it bounds the distances of points in the Cauchy sequence
have ub : ∀ m n N, N ≤ m → N ≤ n → dist (s m) (s n) ≤ Sup (S N) := fun m n N hm hn =>
le_csupₛ (hS N) ⟨⟨_, _⟩, ⟨hm, hn⟩, rfl⟩
have S0m : ∀ n, (0 : ℝ) ∈ S n := fun n => ⟨⟨n, n⟩, ⟨le_rfl, le_rfl⟩, dist_self _⟩
have S0 := fun n => le_csupₛ (hS n) (S0m n)
-- Prove that it tends to `0`, by using the Cauchy property of `s`
refine' ⟨fun N => Sup (S N), S0, ub, Metric.tendsto_atTop.2 fun ε ε0 => _⟩
refine' (Metric.cauchySeq_iff.1 hs (ε / 2) (half_pos ε0)).imp fun N hN n hn => _
rw [Real.dist_0_eq_abs, abs_of_nonneg (S0 n)]
refine' lt_of_le_of_lt (csupₛ_le ⟨_, S0m _⟩ _) (half_lt_self ε0)
rintro _ ⟨⟨m', n'⟩, ⟨hm', hn'⟩, rfl⟩
exact le_of_lt (hN _ (le_trans hn hm') _ (le_trans hn hn')), fun ⟨b, _, b_bound, b_lim⟩ =>
cauchySeq_of_le_tendsto_0 b b_bound b_lim⟩
#align cauchy_seq_iff_le_tendsto_0 cauchySeq_iff_le_tendsto_0
end CauchySeq
#print PseudoMetricSpace.induced /-
/-- Pseudometric space structure pulled back by a function. -/
def PseudoMetricSpace.induced {α β} (f : α → β) (m : PseudoMetricSpace β) : PseudoMetricSpace α
where
dist x y := dist (f x) (f y)
dist_self x := dist_self _
dist_comm x y := dist_comm _ _
dist_triangle x y z := dist_triangle _ _ _
edist x y := edist (f x) (f y)
edist_dist x y := edist_dist _ _
toUniformSpace := UniformSpace.comap f m.toUniformSpace
uniformity_dist := (uniformity_basis_dist.comap _).eq_binfᵢ
toBornology := Bornology.induced f
cobounded_sets :=
Set.ext <|
compl_surjective.forall.2 fun s => by
simp only [compl_mem_comap, Filter.mem_sets, ← is_bounded_def, mem_set_of_eq, compl_compl,
is_bounded_iff, ball_image_iff]
#align pseudo_metric_space.induced PseudoMetricSpace.induced
-/
#print Inducing.comapPseudoMetricSpace /-
/-- Pull back a pseudometric space structure by an inducing map. This is a version of
`pseudo_metric_space.induced` useful in case if the domain already has a `topological_space`
structure. -/
def Inducing.comapPseudoMetricSpace {α β} [TopologicalSpace α] [PseudoMetricSpace β] {f : α → β}
(hf : Inducing f) : PseudoMetricSpace α :=
(PseudoMetricSpace.induced f ‹_›).replaceTopology hf.induced
#align inducing.comap_pseudo_metric_space Inducing.comapPseudoMetricSpace
-/
#print UniformInducing.comapPseudoMetricSpace /-
/-- Pull back a pseudometric space structure by a uniform inducing map. This is a version of
`pseudo_metric_space.induced` useful in case if the domain already has a `uniform_space`
structure. -/
def UniformInducing.comapPseudoMetricSpace {α β} [UniformSpace α] [PseudoMetricSpace β] (f : α → β)
(h : UniformInducing f) : PseudoMetricSpace α :=
(PseudoMetricSpace.induced f ‹_›).replaceUniformity h.comap_uniformity.symm
#align uniform_inducing.comap_pseudo_metric_space UniformInducing.comapPseudoMetricSpace
-/
#print Subtype.pseudoMetricSpace /-
instance Subtype.pseudoMetricSpace {p : α → Prop} : PseudoMetricSpace (Subtype p) :=
PseudoMetricSpace.induced coe ‹_›
#align subtype.pseudo_metric_space Subtype.pseudoMetricSpace
-/
#print Subtype.dist_eq /-
theorem Subtype.dist_eq {p : α → Prop} (x y : Subtype p) : dist x y = dist (x : α) y :=
rfl
#align subtype.dist_eq Subtype.dist_eq
-/
#print Subtype.nndist_eq /-
theorem Subtype.nndist_eq {p : α → Prop} (x y : Subtype p) : nndist x y = nndist (x : α) y :=
rfl
#align subtype.nndist_eq Subtype.nndist_eq
-/
namespace MulOpposite
@[to_additive]
instance : PseudoMetricSpace αᵐᵒᵖ :=
PseudoMetricSpace.induced MulOpposite.unop ‹_›
#print MulOpposite.dist_unop /-
@[simp, to_additive]
theorem dist_unop (x y : αᵐᵒᵖ) : dist (unop x) (unop y) = dist x y :=
rfl
#align mul_opposite.dist_unop MulOpposite.dist_unop
#align add_opposite.dist_unop AddOpposite.dist_unop
-/
#print MulOpposite.dist_op /-
@[simp, to_additive]
theorem dist_op (x y : α) : dist (op x) (op y) = dist x y :=
rfl
#align mul_opposite.dist_op MulOpposite.dist_op
#align add_opposite.dist_op AddOpposite.dist_op
-/
#print MulOpposite.nndist_unop /-
@[simp, to_additive]
theorem nndist_unop (x y : αᵐᵒᵖ) : nndist (unop x) (unop y) = nndist x y :=
rfl
#align mul_opposite.nndist_unop MulOpposite.nndist_unop
#align add_opposite.nndist_unop AddOpposite.nndist_unop
-/
#print MulOpposite.nndist_op /-
@[simp, to_additive]
theorem nndist_op (x y : α) : nndist (op x) (op y) = nndist x y :=
rfl
#align mul_opposite.nndist_op MulOpposite.nndist_op
#align add_opposite.nndist_op AddOpposite.nndist_op
-/
end MulOpposite
section NNReal
instance : PseudoMetricSpace ℝ≥0 :=
Subtype.pseudoMetricSpace
/- warning: nnreal.dist_eq -> NNReal.dist_eq is a dubious translation:
lean 3 declaration is
forall (a : NNReal) (b : NNReal), Eq.{1} Real (Dist.dist.{0} NNReal (PseudoMetricSpace.toHasDist.{0} NNReal NNReal.pseudoMetricSpace) a b) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) b)))
but is expected to have type
forall (a : NNReal) (b : NNReal), Eq.{1} Real (Dist.dist.{0} NNReal (PseudoMetricSpace.toDist.{0} NNReal instPseudoMetricSpaceNNReal) a b) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (NNReal.toReal a) (NNReal.toReal b)))
Case conversion may be inaccurate. Consider using '#align nnreal.dist_eq NNReal.dist_eqₓ'. -/
theorem NNReal.dist_eq (a b : ℝ≥0) : dist a b = |(a : ℝ) - b| :=
rfl
#align nnreal.dist_eq NNReal.dist_eq
/- warning: nnreal.nndist_eq -> NNReal.nndist_eq is a dubious translation:
lean 3 declaration is
forall (a : NNReal) (b : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal NNReal.pseudoMetricSpace) a b) (LinearOrder.max.{0} NNReal (ConditionallyCompleteLinearOrder.toLinearOrder.{0} NNReal (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{0} NNReal NNReal.conditionallyCompleteLinearOrderBot)) (HSub.hSub.{0, 0, 0} NNReal NNReal NNReal (instHSub.{0} NNReal NNReal.hasSub) a b) (HSub.hSub.{0, 0, 0} NNReal NNReal NNReal (instHSub.{0} NNReal NNReal.hasSub) b a))
but is expected to have type
forall (a : NNReal) (b : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal instPseudoMetricSpaceNNReal) a b) (Max.max.{0} NNReal (CanonicallyLinearOrderedSemifield.toMax.{0} NNReal NNReal.instCanonicallyLinearOrderedSemifieldNNReal) (HSub.hSub.{0, 0, 0} NNReal NNReal NNReal (instHSub.{0} NNReal NNReal.instSubNNReal) a b) (HSub.hSub.{0, 0, 0} NNReal NNReal NNReal (instHSub.{0} NNReal NNReal.instSubNNReal) b a))
Case conversion may be inaccurate. Consider using '#align nnreal.nndist_eq NNReal.nndist_eqₓ'. -/
theorem NNReal.nndist_eq (a b : ℝ≥0) : nndist a b = max (a - b) (b - a) :=
by
wlog h : b ≤ a
· rw [nndist_comm, max_comm]
exact this b a (le_of_not_le h)
rw [← NNReal.coe_eq, ← dist_nndist, NNReal.dist_eq, tsub_eq_zero_iff_le.2 h,
max_eq_left (zero_le <| a - b), ← NNReal.coe_sub h, abs_of_nonneg (a - b).coe_nonneg]
#align nnreal.nndist_eq NNReal.nndist_eq
/- warning: nnreal.nndist_zero_eq_val -> NNReal.nndist_zero_eq_val is a dubious translation:
lean 3 declaration is
forall (z : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal NNReal.pseudoMetricSpace) (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))))) z) z
but is expected to have type
forall (z : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal instPseudoMetricSpaceNNReal) (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero)) z) z
Case conversion may be inaccurate. Consider using '#align nnreal.nndist_zero_eq_val NNReal.nndist_zero_eq_valₓ'. -/
@[simp]
theorem NNReal.nndist_zero_eq_val (z : ℝ≥0) : nndist 0 z = z := by
simp only [NNReal.nndist_eq, max_eq_right, tsub_zero, zero_tsub, zero_le']
#align nnreal.nndist_zero_eq_val NNReal.nndist_zero_eq_val
/- warning: nnreal.nndist_zero_eq_val' -> NNReal.nndist_zero_eq_val' is a dubious translation:
lean 3 declaration is
forall (z : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal NNReal.pseudoMetricSpace) z (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring)))))))) z
but is expected to have type
forall (z : NNReal), Eq.{1} NNReal (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal instPseudoMetricSpaceNNReal) z (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero))) z
Case conversion may be inaccurate. Consider using '#align nnreal.nndist_zero_eq_val' NNReal.nndist_zero_eq_val'ₓ'. -/
@[simp]
theorem NNReal.nndist_zero_eq_val' (z : ℝ≥0) : nndist z 0 = z :=
by
rw [nndist_comm]
exact NNReal.nndist_zero_eq_val z
#align nnreal.nndist_zero_eq_val' NNReal.nndist_zero_eq_val'
/- warning: nnreal.le_add_nndist -> NNReal.le_add_nndist is a dubious translation:
lean 3 declaration is
forall (a : NNReal) (b : NNReal), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) a (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toHasAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))) b (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal NNReal.pseudoMetricSpace) a b))
but is expected to have type
forall (a : NNReal) (b : NNReal), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) a (HAdd.hAdd.{0, 0, 0} NNReal NNReal NNReal (instHAdd.{0} NNReal (Distrib.toAdd.{0} NNReal (NonUnitalNonAssocSemiring.toDistrib.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal instNNRealSemiring))))) b (NNDist.nndist.{0} NNReal (PseudoMetricSpace.toNNDist.{0} NNReal instPseudoMetricSpaceNNReal) a b))
Case conversion may be inaccurate. Consider using '#align nnreal.le_add_nndist NNReal.le_add_nndistₓ'. -/
theorem NNReal.le_add_nndist (a b : ℝ≥0) : a ≤ b + nndist a b :=
by
suffices (a : ℝ) ≤ (b : ℝ) + dist a b by exact nnreal.coe_le_coe.mp this
linarith [le_of_abs_le (by rfl : abs (a - b : ℝ) ≤ dist a b)]
#align nnreal.le_add_nndist NNReal.le_add_nndist
end NNReal
section ULift
variable [PseudoMetricSpace β]
instance : PseudoMetricSpace (ULift β) :=
PseudoMetricSpace.induced ULift.down ‹_›
/- warning: ulift.dist_eq -> ULift.dist_eq is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} β] (x : ULift.{u2, u1} β) (y : ULift.{u2, u1} β), Eq.{1} Real (Dist.dist.{max u1 u2} (ULift.{u2, u1} β) (PseudoMetricSpace.toHasDist.{max u1 u2} (ULift.{u2, u1} β) (ULift.pseudoMetricSpace.{u1, u2} β _inst_2)) x y) (Dist.dist.{u1} β (PseudoMetricSpace.toHasDist.{u1} β _inst_2) (ULift.down.{u2, u1} β x) (ULift.down.{u2, u1} β y))
but is expected to have type
forall {β : Type.{u2}} [_inst_2 : PseudoMetricSpace.{u2} β] (x : ULift.{u1, u2} β) (y : ULift.{u1, u2} β), Eq.{1} Real (Dist.dist.{max u2 u1} (ULift.{u1, u2} β) (PseudoMetricSpace.toDist.{max u2 u1} (ULift.{u1, u2} β) (instPseudoMetricSpaceULift.{u2, u1} β _inst_2)) x y) (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (ULift.down.{u1, u2} β x) (ULift.down.{u1, u2} β y))
Case conversion may be inaccurate. Consider using '#align ulift.dist_eq ULift.dist_eqₓ'. -/
theorem ULift.dist_eq (x y : ULift β) : dist x y = dist x.down y.down :=
rfl
#align ulift.dist_eq ULift.dist_eq
/- warning: ulift.nndist_eq -> ULift.nndist_eq is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} β] (x : ULift.{u2, u1} β) (y : ULift.{u2, u1} β), Eq.{1} NNReal (NNDist.nndist.{max u1 u2} (ULift.{u2, u1} β) (PseudoMetricSpace.toNNDist.{max u1 u2} (ULift.{u2, u1} β) (ULift.pseudoMetricSpace.{u1, u2} β _inst_2)) x y) (NNDist.nndist.{u1} β (PseudoMetricSpace.toNNDist.{u1} β _inst_2) (ULift.down.{u2, u1} β x) (ULift.down.{u2, u1} β y))
but is expected to have type
forall {β : Type.{u2}} [_inst_2 : PseudoMetricSpace.{u2} β] (x : ULift.{u1, u2} β) (y : ULift.{u1, u2} β), Eq.{1} NNReal (NNDist.nndist.{max u2 u1} (ULift.{u1, u2} β) (PseudoMetricSpace.toNNDist.{max u2 u1} (ULift.{u1, u2} β) (instPseudoMetricSpaceULift.{u2, u1} β _inst_2)) x y) (NNDist.nndist.{u2} β (PseudoMetricSpace.toNNDist.{u2} β _inst_2) (ULift.down.{u1, u2} β x) (ULift.down.{u1, u2} β y))
Case conversion may be inaccurate. Consider using '#align ulift.nndist_eq ULift.nndist_eqₓ'. -/
theorem ULift.nndist_eq (x y : ULift β) : nndist x y = nndist x.down y.down :=
rfl
#align ulift.nndist_eq ULift.nndist_eq
/- warning: ulift.dist_up_up -> ULift.dist_up_up is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} β] (x : β) (y : β), Eq.{1} Real (Dist.dist.{max u1 u2} (ULift.{u2, u1} β) (PseudoMetricSpace.toHasDist.{max u1 u2} (ULift.{u2, u1} β) (ULift.pseudoMetricSpace.{u1, u2} β _inst_2)) (ULift.up.{u2, u1} β x) (ULift.up.{u2, u1} β y)) (Dist.dist.{u1} β (PseudoMetricSpace.toHasDist.{u1} β _inst_2) x y)
but is expected to have type
forall {β : Type.{u2}} [_inst_2 : PseudoMetricSpace.{u2} β] (x : β) (y : β), Eq.{1} Real (Dist.dist.{max u2 u1} (ULift.{u1, u2} β) (PseudoMetricSpace.toDist.{max u2 u1} (ULift.{u1, u2} β) (instPseudoMetricSpaceULift.{u2, u1} β _inst_2)) (ULift.up.{u1, u2} β x) (ULift.up.{u1, u2} β y)) (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) x y)
Case conversion may be inaccurate. Consider using '#align ulift.dist_up_up ULift.dist_up_upₓ'. -/
@[simp]
theorem ULift.dist_up_up (x y : β) : dist (ULift.up x) (ULift.up y) = dist x y :=
rfl
#align ulift.dist_up_up ULift.dist_up_up
/- warning: ulift.nndist_up_up -> ULift.nndist_up_up is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} β] (x : β) (y : β), Eq.{1} NNReal (NNDist.nndist.{max u1 u2} (ULift.{u2, u1} β) (PseudoMetricSpace.toNNDist.{max u1 u2} (ULift.{u2, u1} β) (ULift.pseudoMetricSpace.{u1, u2} β _inst_2)) (ULift.up.{u2, u1} β x) (ULift.up.{u2, u1} β y)) (NNDist.nndist.{u1} β (PseudoMetricSpace.toNNDist.{u1} β _inst_2) x y)
but is expected to have type
forall {β : Type.{u2}} [_inst_2 : PseudoMetricSpace.{u2} β] (x : β) (y : β), Eq.{1} NNReal (NNDist.nndist.{max u2 u1} (ULift.{u1, u2} β) (PseudoMetricSpace.toNNDist.{max u2 u1} (ULift.{u1, u2} β) (instPseudoMetricSpaceULift.{u2, u1} β _inst_2)) (ULift.up.{u1, u2} β x) (ULift.up.{u1, u2} β y)) (NNDist.nndist.{u2} β (PseudoMetricSpace.toNNDist.{u2} β _inst_2) x y)
Case conversion may be inaccurate. Consider using '#align ulift.nndist_up_up ULift.nndist_up_upₓ'. -/
@[simp]
theorem ULift.nndist_up_up (x y : β) : nndist (ULift.up x) (ULift.up y) = nndist x y :=
rfl
#align ulift.nndist_up_up ULift.nndist_up_up
end ULift
section Prod
variable [PseudoMetricSpace β]
#print Prod.pseudoMetricSpaceMax /-
instance Prod.pseudoMetricSpaceMax : PseudoMetricSpace (α × β) :=
(PseudoEMetricSpace.toPseudoMetricSpaceOfDist (fun x y : α × β => dist x.1 y.1 ⊔ dist x.2 y.2)
(fun x y => (max_lt (edist_lt_top _ _) (edist_lt_top _ _)).Ne) fun x y => by
simp only [sup_eq_max, dist_edist, ←
ENNReal.toReal_max (edist_ne_top _ _) (edist_ne_top _ _), Prod.edist_eq]).replaceBornology
fun s =>
by
simp only [← is_bounded_image_fst_and_snd, is_bounded_iff_eventually, ball_image_iff, ←
eventually_and, ← forall_and, ← max_le_iff]
rfl
#align prod.pseudo_metric_space_max Prod.pseudoMetricSpaceMax
-/
/- warning: prod.dist_eq -> Prod.dist_eq is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {x : Prod.{u1, u2} α β} {y : Prod.{u1, u2} α β}, Eq.{1} Real (Dist.dist.{max u1 u2} (Prod.{u1, u2} α β) (PseudoMetricSpace.toHasDist.{max u1 u2} (Prod.{u1, u2} α β) (Prod.pseudoMetricSpaceMax.{u1, u2} α β _inst_1 _inst_2)) x y) (LinearOrder.max.{0} Real Real.linearOrder (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u2} α β x) (Prod.fst.{u1, u2} α β y)) (Dist.dist.{u2} β (PseudoMetricSpace.toHasDist.{u2} β _inst_2) (Prod.snd.{u1, u2} α β x) (Prod.snd.{u1, u2} α β y)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : PseudoMetricSpace.{u2} β] {x : Prod.{u1, u2} α β} {y : Prod.{u1, u2} α β}, Eq.{1} Real (Dist.dist.{max u1 u2} (Prod.{u1, u2} α β) (PseudoMetricSpace.toDist.{max u1 u2} (Prod.{u1, u2} α β) (Prod.pseudoMetricSpaceMax.{u1, u2} α β _inst_1 _inst_2)) x y) (Max.max.{0} Real (LinearOrderedRing.toMax.{0} Real Real.instLinearOrderedRingReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u2} α β x) (Prod.fst.{u1, u2} α β y)) (Dist.dist.{u2} β (PseudoMetricSpace.toDist.{u2} β _inst_2) (Prod.snd.{u1, u2} α β x) (Prod.snd.{u1, u2} α β y)))
Case conversion may be inaccurate. Consider using '#align prod.dist_eq Prod.dist_eqₓ'. -/
theorem Prod.dist_eq {x y : α × β} : dist x y = max (dist x.1 y.1) (dist x.2 y.2) :=
rfl
#align prod.dist_eq Prod.dist_eq
#print dist_prod_same_left /-
@[simp]
theorem dist_prod_same_left {x : α} {y₁ y₂ : β} : dist (x, y₁) (x, y₂) = dist y₁ y₂ := by
simp [Prod.dist_eq, dist_nonneg]
#align dist_prod_same_left dist_prod_same_left
-/
#print dist_prod_same_right /-
@[simp]
theorem dist_prod_same_right {x₁ x₂ : α} {y : β} : dist (x₁, y) (x₂, y) = dist x₁ x₂ := by
simp [Prod.dist_eq, dist_nonneg]
#align dist_prod_same_right dist_prod_same_right
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print ball_prod_same /-
theorem ball_prod_same (x : α) (y : β) (r : ℝ) : ball x r ×ˢ ball y r = ball (x, y) r :=
ext fun z => by simp [Prod.dist_eq]
#align ball_prod_same ball_prod_same
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print closedBall_prod_same /-
theorem closedBall_prod_same (x : α) (y : β) (r : ℝ) :
closedBall x r ×ˢ closedBall y r = closedBall (x, y) r :=
ext fun z => by simp [Prod.dist_eq]
#align closed_ball_prod_same closedBall_prod_same
-/
end Prod
/- warning: uniform_continuous_dist -> uniformContinuous_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], UniformContinuous.{u1, 0} (Prod.{u1, u1} α α) Real (Prod.uniformSpace.{u1, u1} α α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace) (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], UniformContinuous.{u1, 0} (Prod.{u1, u1} α α) Real (instUniformSpaceProd.{u1, u1} α α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace) (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
Case conversion may be inaccurate. Consider using '#align uniform_continuous_dist uniformContinuous_distₓ'. -/
theorem uniformContinuous_dist : UniformContinuous fun p : α × α => dist p.1 p.2 :=
Metric.uniformContinuous_iff.2 fun ε ε0 =>
⟨ε / 2, half_pos ε0, by
suffices
· intro p q h
cases' p with p₁ p₂
cases' q with q₁ q₂
cases' max_lt_iff.1 h with h₁ h₂
clear h
dsimp at h₁ h₂⊢
rw [Real.dist_eq]
refine' abs_sub_lt_iff.2 ⟨_, _⟩
· revert p₁ p₂ q₁ q₂ h₁ h₂
exact this
· apply this <;> rwa [dist_comm]
intro p₁ p₂ q₁ q₂ h₁ h₂
have :=
add_lt_add (abs_sub_lt_iff.1 (lt_of_le_of_lt (abs_dist_sub_le p₁ q₁ p₂) h₁)).1
(abs_sub_lt_iff.1 (lt_of_le_of_lt (abs_dist_sub_le p₂ q₂ q₁) h₂)).1
rwa [add_halves, dist_comm p₂, sub_add_sub_cancel, dist_comm q₂] at this⟩
#align uniform_continuous_dist uniformContinuous_dist
#print UniformContinuous.dist /-
theorem UniformContinuous.dist [UniformSpace β] {f g : β → α} (hf : UniformContinuous f)
(hg : UniformContinuous g) : UniformContinuous fun b => dist (f b) (g b) :=
uniformContinuous_dist.comp (hf.prod_mk hg)
#align uniform_continuous.dist UniformContinuous.dist
-/
/- warning: continuous_dist -> continuous_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Continuous.{u1, 0} (Prod.{u1, u1} α α) Real (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Continuous.{u1, 0} (Prod.{u1, u1} α α) Real (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (fun (p : Prod.{u1, u1} α α) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
Case conversion may be inaccurate. Consider using '#align continuous_dist continuous_distₓ'. -/
@[continuity]
theorem continuous_dist : Continuous fun p : α × α => dist p.1 p.2 :=
uniformContinuous_dist.Continuous
#align continuous_dist continuous_dist
#print Continuous.dist /-
@[continuity]
theorem Continuous.dist [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :
Continuous fun b => dist (f b) (g b) :=
continuous_dist.comp (hf.prod_mk hg : _)
#align continuous.dist Continuous.dist
-/
#print Filter.Tendsto.dist /-
theorem Filter.Tendsto.dist {f g : β → α} {x : Filter β} {a b : α} (hf : Tendsto f x (𝓝 a))
(hg : Tendsto g x (𝓝 b)) : Tendsto (fun x => dist (f x) (g x)) x (𝓝 (dist a b)) :=
(continuous_dist.Tendsto (a, b)).comp (hf.prod_mk_nhds hg)
#align filter.tendsto.dist Filter.Tendsto.dist
-/
/- warning: nhds_comap_dist -> nhds_comap_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (a : α), Eq.{succ u1} (Filter.{u1} α) (Filter.comap.{u1, 0} α Real (fun (a' : α) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a' a) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (a : α), Eq.{succ u1} (Filter.{u1} α) (Filter.comap.{u1, 0} α Real (fun (a' : α) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a' a) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)
Case conversion may be inaccurate. Consider using '#align nhds_comap_dist nhds_comap_distₓ'. -/
theorem nhds_comap_dist (a : α) : ((𝓝 (0 : ℝ)).comap fun a' => dist a' a) = 𝓝 a := by
simp only [@nhds_eq_comap_uniformity α, Metric.uniformity_eq_comap_nhds_zero, comap_comap,
(· ∘ ·), dist_comm]
#align nhds_comap_dist nhds_comap_dist
/- warning: tendsto_iff_dist_tendsto_zero -> tendsto_iff_dist_tendsto_zero is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α} {x : Filter.{u2} β} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (Filter.Tendsto.{u2, 0} β Real (fun (b : β) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f b) a) x (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α} {x : Filter.{u2} β} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) (Filter.Tendsto.{u2, 0} β Real (fun (b : β) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f b) a) x (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))
Case conversion may be inaccurate. Consider using '#align tendsto_iff_dist_tendsto_zero tendsto_iff_dist_tendsto_zeroₓ'. -/
theorem tendsto_iff_dist_tendsto_zero {f : β → α} {x : Filter β} {a : α} :
Tendsto f x (𝓝 a) ↔ Tendsto (fun b => dist (f b) a) x (𝓝 0) := by
rw [← nhds_comap_dist a, tendsto_comap_iff]
#align tendsto_iff_dist_tendsto_zero tendsto_iff_dist_tendsto_zero
/- warning: continuous_iff_continuous_dist -> continuous_iff_continuous_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α}, Iff (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) (Continuous.{u2, 0} (Prod.{u2, u2} β β) Real (Prod.topologicalSpace.{u2, u2} β β _inst_2 _inst_2) (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (fun (x : Prod.{u2, u2} β β) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f (Prod.fst.{u2, u2} β β x)) (f (Prod.snd.{u2, u2} β β x))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α}, Iff (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) (Continuous.{u2, 0} (Prod.{u2, u2} β β) Real (instTopologicalSpaceProd.{u2, u2} β β _inst_2 _inst_2) (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (fun (x : Prod.{u2, u2} β β) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f (Prod.fst.{u2, u2} β β x)) (f (Prod.snd.{u2, u2} β β x))))
Case conversion may be inaccurate. Consider using '#align continuous_iff_continuous_dist continuous_iff_continuous_distₓ'. -/
theorem continuous_iff_continuous_dist [TopologicalSpace β] {f : β → α} :
Continuous f ↔ Continuous fun x : β × β => dist (f x.1) (f x.2) :=
⟨fun h => (h.comp continuous_fst).dist (h.comp continuous_snd), fun h =>
continuous_iff_continuousAt.2 fun x =>
tendsto_iff_dist_tendsto_zero.2 <|
(h.comp (continuous_id.prod_mk continuous_const)).tendsto' _ _ <| dist_self _⟩
#align continuous_iff_continuous_dist continuous_iff_continuous_dist
/- warning: uniform_continuous_nndist -> uniformContinuous_nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], UniformContinuous.{u1, 0} (Prod.{u1, u1} α α) NNReal (Prod.uniformSpace.{u1, u1} α α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PseudoMetricSpace.toUniformSpace.{0} NNReal NNReal.pseudoMetricSpace) (fun (p : Prod.{u1, u1} α α) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], UniformContinuous.{u1, 0} (Prod.{u1, u1} α α) NNReal (instUniformSpaceProd.{u1, u1} α α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PseudoMetricSpace.toUniformSpace.{0} NNReal instPseudoMetricSpaceNNReal) (fun (p : Prod.{u1, u1} α α) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
Case conversion may be inaccurate. Consider using '#align uniform_continuous_nndist uniformContinuous_nndistₓ'. -/
theorem uniformContinuous_nndist : UniformContinuous fun p : α × α => nndist p.1 p.2 :=
uniformContinuous_dist.subtype_mk _
#align uniform_continuous_nndist uniformContinuous_nndist
/- warning: uniform_continuous.nndist -> UniformContinuous.nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_2 (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) f) -> (UniformContinuous.{u2, u1} β α _inst_2 (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) g) -> (UniformContinuous.{u2, 0} β NNReal _inst_2 (PseudoMetricSpace.toUniformSpace.{0} NNReal NNReal.pseudoMetricSpace) (fun (b : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f b) (g b)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_2 (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) f) -> (UniformContinuous.{u2, u1} β α _inst_2 (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) g) -> (UniformContinuous.{u2, 0} β NNReal _inst_2 (PseudoMetricSpace.toUniformSpace.{0} NNReal instPseudoMetricSpaceNNReal) (fun (b : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f b) (g b)))
Case conversion may be inaccurate. Consider using '#align uniform_continuous.nndist UniformContinuous.nndistₓ'. -/
theorem UniformContinuous.nndist [UniformSpace β] {f g : β → α} (hf : UniformContinuous f)
(hg : UniformContinuous g) : UniformContinuous fun b => nndist (f b) (g b) :=
uniformContinuous_nndist.comp (hf.prod_mk hg)
#align uniform_continuous.nndist UniformContinuous.nndist
/- warning: continuous_nndist -> continuous_nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Continuous.{u1, 0} (Prod.{u1, u1} α α) NNReal (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal NNReal.pseudoMetricSpace)) (fun (p : Prod.{u1, u1} α α) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Continuous.{u1, 0} (Prod.{u1, u1} α α) NNReal (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))) (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal instPseudoMetricSpaceNNReal)) (fun (p : Prod.{u1, u1} α α) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))
Case conversion may be inaccurate. Consider using '#align continuous_nndist continuous_nndistₓ'. -/
theorem continuous_nndist : Continuous fun p : α × α => nndist p.1 p.2 :=
uniformContinuous_nndist.Continuous
#align continuous_nndist continuous_nndist
/- warning: continuous.nndist -> Continuous.nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {g : β -> α}, (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) -> (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) g) -> (Continuous.{u2, 0} β NNReal _inst_2 (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal NNReal.pseudoMetricSpace)) (fun (b : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f b) (g b)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {g : β -> α}, (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f) -> (Continuous.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) g) -> (Continuous.{u2, 0} β NNReal _inst_2 (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal instPseudoMetricSpaceNNReal)) (fun (b : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f b) (g b)))
Case conversion may be inaccurate. Consider using '#align continuous.nndist Continuous.nndistₓ'. -/
theorem Continuous.nndist [TopologicalSpace β] {f g : β → α} (hf : Continuous f)
(hg : Continuous g) : Continuous fun b => nndist (f b) (g b) :=
continuous_nndist.comp (hf.prod_mk hg : _)
#align continuous.nndist Continuous.nndist
/- warning: filter.tendsto.nndist -> Filter.Tendsto.nndist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α} {g : β -> α} {x : Filter.{u2} β} {a : α} {b : α}, (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) -> (Filter.Tendsto.{u2, u1} β α g x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) b)) -> (Filter.Tendsto.{u2, 0} β NNReal (fun (x : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f x) (g x)) x (nhds.{0} NNReal (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal NNReal.pseudoMetricSpace)) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) a b)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α} {g : β -> α} {x : Filter.{u2} β} {a : α} {b : α}, (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) a)) -> (Filter.Tendsto.{u2, u1} β α g x (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) b)) -> (Filter.Tendsto.{u2, 0} β NNReal (fun (x : β) => NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) (f x) (g x)) x (nhds.{0} NNReal (UniformSpace.toTopologicalSpace.{0} NNReal (PseudoMetricSpace.toUniformSpace.{0} NNReal instPseudoMetricSpaceNNReal)) (NNDist.nndist.{u1} α (PseudoMetricSpace.toNNDist.{u1} α _inst_1) a b)))
Case conversion may be inaccurate. Consider using '#align filter.tendsto.nndist Filter.Tendsto.nndistₓ'. -/
theorem Filter.Tendsto.nndist {f g : β → α} {x : Filter β} {a b : α} (hf : Tendsto f x (𝓝 a))
(hg : Tendsto g x (𝓝 b)) : Tendsto (fun x => nndist (f x) (g x)) x (𝓝 (nndist a b)) :=
(continuous_nndist.Tendsto (a, b)).comp (hf.prod_mk_nhds hg)
#align filter.tendsto.nndist Filter.Tendsto.nndist
namespace Metric
variable {x y z : α} {ε ε₁ ε₂ : ℝ} {s : Set α}
#print Metric.isClosed_ball /-
theorem isClosed_ball : IsClosed (closedBall x ε) :=
isClosed_le (continuous_id.dist continuous_const) continuous_const
#align metric.is_closed_ball Metric.isClosed_ball
-/
#print Metric.isClosed_sphere /-
theorem isClosed_sphere : IsClosed (sphere x ε) :=
isClosed_eq (continuous_id.dist continuous_const) continuous_const
#align metric.is_closed_sphere Metric.isClosed_sphere
-/
#print Metric.closure_closedBall /-
@[simp]
theorem closure_closedBall : closure (closedBall x ε) = closedBall x ε :=
isClosed_ball.closure_eq
#align metric.closure_closed_ball Metric.closure_closedBall
-/
#print Metric.closure_ball_subset_closedBall /-
theorem closure_ball_subset_closedBall : closure (ball x ε) ⊆ closedBall x ε :=
closure_minimal ball_subset_closedBall isClosed_ball
#align metric.closure_ball_subset_closed_ball Metric.closure_ball_subset_closedBall
-/
#print Metric.frontier_ball_subset_sphere /-
theorem frontier_ball_subset_sphere : frontier (ball x ε) ⊆ sphere x ε :=
frontier_lt_subset_eq (continuous_id.dist continuous_const) continuous_const
#align metric.frontier_ball_subset_sphere Metric.frontier_ball_subset_sphere
-/
#print Metric.frontier_closedBall_subset_sphere /-
theorem frontier_closedBall_subset_sphere : frontier (closedBall x ε) ⊆ sphere x ε :=
frontier_le_subset_eq (continuous_id.dist continuous_const) continuous_const
#align metric.frontier_closed_ball_subset_sphere Metric.frontier_closedBall_subset_sphere
-/
#print Metric.ball_subset_interior_closedBall /-
theorem ball_subset_interior_closedBall : ball x ε ⊆ interior (closedBall x ε) :=
interior_maximal ball_subset_closedBall isOpen_ball
#align metric.ball_subset_interior_closed_ball Metric.ball_subset_interior_closedBall
-/
/- warning: metric.mem_closure_iff -> Metric.mem_closure_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s)) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) ε))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {a : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s)) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} α (fun (b : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b s) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) ε))))
Case conversion may be inaccurate. Consider using '#align metric.mem_closure_iff Metric.mem_closure_iffₓ'. -/
/-- ε-characterization of the closure in pseudometric spaces-/
theorem mem_closure_iff {s : Set α} {a : α} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, dist a b < ε :=
(mem_closure_iff_nhds_basis nhds_basis_ball).trans <| by simp only [mem_ball, dist_comm]
#align metric.mem_closure_iff Metric.mem_closure_iff
/- warning: metric.mem_closure_range_iff -> Metric.mem_closure_range_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {e : β -> α} {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Set.range.{u1, succ u2} α β e))) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (k : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a (e k)) ε)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {e : β -> α} {a : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Set.range.{u1, succ u2} α β e))) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (k : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a (e k)) ε)))
Case conversion may be inaccurate. Consider using '#align metric.mem_closure_range_iff Metric.mem_closure_range_iffₓ'. -/
theorem mem_closure_range_iff {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀ ε > 0, ∃ k : β, dist a (e k) < ε := by
simp only [mem_closure_iff, exists_range_iff]
#align metric.mem_closure_range_iff Metric.mem_closure_range_iff
/- warning: metric.mem_closure_range_iff_nat -> Metric.mem_closure_range_iff_nat is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {e : β -> α} {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Set.range.{u1, succ u2} α β e))) (forall (n : Nat), Exists.{succ u2} β (fun (k : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a (e k)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {e : β -> α} {a : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Set.range.{u1, succ u2} α β e))) (forall (n : Nat), Exists.{succ u2} β (fun (k : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a (e k)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))))))
Case conversion may be inaccurate. Consider using '#align metric.mem_closure_range_iff_nat Metric.mem_closure_range_iff_natₓ'. -/
theorem mem_closure_range_iff_nat {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀ n : ℕ, ∃ k : β, dist a (e k) < 1 / ((n : ℝ) + 1) :=
(mem_closure_iff_nhds_basis nhds_basis_ball_inv_nat_succ).trans <| by
simp only [mem_ball, dist_comm, exists_range_iff, forall_const]
#align metric.mem_closure_range_iff_nat Metric.mem_closure_range_iff_nat
/- warning: metric.mem_of_closed' -> Metric.mem_of_closed' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s) (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b) ε)))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall {a : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a s) (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} α (fun (b : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b s) (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b) ε)))))
Case conversion may be inaccurate. Consider using '#align metric.mem_of_closed' Metric.mem_of_closed'ₓ'. -/
theorem mem_of_closed' {s : Set α} (hs : IsClosed s) {a : α} :
a ∈ s ↔ ∀ ε > 0, ∃ b ∈ s, dist a b < ε := by
simpa only [hs.closure_eq] using @mem_closure_iff _ _ s a
#align metric.mem_of_closed' Metric.mem_of_closed'
/- warning: metric.closed_ball_zero' -> Metric.closedBall_zero' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), Eq.{succ u1} (Set.{u1} α) (Metric.closedBall.{u1} α _inst_1 x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x))
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_zero' Metric.closedBall_zero'ₓ'. -/
theorem closedBall_zero' (x : α) : closedBall x 0 = closure {x} :=
Subset.antisymm
(fun y hy =>
mem_closure_iff.2 fun ε ε0 => ⟨x, mem_singleton x, (mem_closedBall.1 hy).trans_lt ε0⟩)
(closure_minimal (singleton_subset_iff.2 (dist_self x).le) isClosed_ball)
#align metric.closed_ball_zero' Metric.closedBall_zero'
/- warning: metric.dense_iff -> Metric.dense_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Dense.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) (forall (x : α) (r : Real), (GT.gt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (Metric.ball.{u1} α _inst_1 x r) s)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Dense.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) (forall (x : α) (r : Real), (GT.gt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (Metric.ball.{u1} α _inst_1 x r) s)))
Case conversion may be inaccurate. Consider using '#align metric.dense_iff Metric.dense_iffₓ'. -/
theorem dense_iff {s : Set α} : Dense s ↔ ∀ x, ∀ r > 0, (ball x r ∩ s).Nonempty :=
forall_congr' fun x => by
simp only [mem_closure_iff, Set.Nonempty, exists_prop, mem_inter_iff, mem_ball', and_comm']
#align metric.dense_iff Metric.dense_iff
/- warning: metric.dense_range_iff -> Metric.denseRange_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α}, Iff (DenseRange.{u1, u2} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) β f) (forall (x : α) (r : Real), (GT.gt.{0} Real Real.hasLt r (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u2} β (fun (y : β) => LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x (f y)) r)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α}, Iff (DenseRange.{u1, u2} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) β f) (forall (x : α) (r : Real), (GT.gt.{0} Real Real.instLTReal r (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u2} β (fun (y : β) => LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x (f y)) r)))
Case conversion may be inaccurate. Consider using '#align metric.dense_range_iff Metric.denseRange_iffₓ'. -/
theorem denseRange_iff {f : β → α} : DenseRange f ↔ ∀ x, ∀ r > 0, ∃ y, dist x (f y) < r :=
forall_congr' fun x => by simp only [mem_closure_iff, exists_range_iff]
#align metric.dense_range_iff Metric.denseRange_iff
/- warning: topological_space.is_separable.separable_space -> TopologicalSpace.IsSeparable.separableSpace is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (TopologicalSpace.IsSeparable.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (TopologicalSpace.SeparableSpace.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoEMetricSpace.{u1} α] {s : Set.{u1} α}, (TopologicalSpace.IsSeparable.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoEMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (TopologicalSpace.SeparableSpace.{u1} (Set.Elem.{u1} α s) (instTopologicalSpaceSubtype.{u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) (UniformSpace.toTopologicalSpace.{u1} α (PseudoEMetricSpace.toUniformSpace.{u1} α _inst_1))))
Case conversion may be inaccurate. Consider using '#align topological_space.is_separable.separable_space TopologicalSpace.IsSeparable.separableSpaceₓ'. -/
/-- If a set `s` is separable, then the corresponding subtype is separable in a metric space.
This is not obvious, as the countable set whose closure covers `s` does not need in general to
be contained in `s`. -/
theorem TopologicalSpace.IsSeparable.separableSpace {s : Set α} (hs : IsSeparable s) :
SeparableSpace s := by
classical
rcases eq_empty_or_nonempty s with (rfl | ⟨⟨x₀, x₀s⟩⟩)
· infer_instance
rcases hs with ⟨c, hc, h'c⟩
haveI : Encodable c := hc.to_encodable
obtain ⟨u, -, u_pos, u_lim⟩ :
∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ tendsto u at_top (𝓝 0) :=
exists_seq_strictAnti_tendsto (0 : ℝ)
let f : c × ℕ → α := fun p =>
if h : (Metric.ball (p.1 : α) (u p.2) ∩ s).Nonempty then h.some else x₀
have fs : ∀ p, f p ∈ s := by
rintro ⟨y, n⟩
by_cases h : (ball (y : α) (u n) ∩ s).Nonempty
· simpa only [f, h, dif_pos] using h.some_spec.2
· simpa only [f, h, not_false_iff, dif_neg]
let g : c × ℕ → s := fun p => ⟨f p, fs p⟩
apply separable_space_of_dense_range g
apply Metric.denseRange_iff.2
rintro ⟨x, xs⟩ r (rpos : 0 < r)
obtain ⟨n, hn⟩ : ∃ n, u n < r / 2 := ((tendsto_order.1 u_lim).2 _ (half_pos rpos)).exists
obtain ⟨z, zc, hz⟩ : ∃ z ∈ c, dist x z < u n := Metric.mem_closure_iff.1 (h'c xs) _ (u_pos n)
refine' ⟨(⟨z, zc⟩, n), _⟩
change dist x (f (⟨z, zc⟩, n)) < r
have A : (Metric.ball z (u n) ∩ s).Nonempty := ⟨x, hz, xs⟩
dsimp [f]
simp only [A, dif_pos]
calc
dist x A.some ≤ dist x z + dist z A.some := dist_triangle _ _ _
_ < r / 2 + r / 2 := (add_lt_add (hz.trans hn) ((Metric.mem_ball'.1 A.some_spec.1).trans hn))
_ = r := add_halves _
#align topological_space.is_separable.separable_space TopologicalSpace.IsSeparable.separableSpace
#print Inducing.isSeparable_preimage /-
/-- The preimage of a separable set by an inducing map is separable. -/
protected theorem Inducing.isSeparable_preimage {f : β → α} [TopologicalSpace β] (hf : Inducing f)
{s : Set α} (hs : IsSeparable s) : IsSeparable (f ⁻¹' s) :=
by
have : second_countable_topology s :=
haveI : separable_space s := hs.separable_space
UniformSpace.secondCountable_of_separable _
let g : f ⁻¹' s → s := cod_restrict (f ∘ coe) s fun x => x.2
have : Inducing g := (hf.comp inducing_subtype_val).codRestrict _
haveI : second_countable_topology (f ⁻¹' s) := this.second_countable_topology
rw [show f ⁻¹' s = coe '' (univ : Set (f ⁻¹' s)) by
simpa only [image_univ, Subtype.range_coe_subtype] ]
exact (is_separable_of_separable_space _).image continuous_subtype_val
#align inducing.is_separable_preimage Inducing.isSeparable_preimage
-/
#print Embedding.isSeparable_preimage /-
protected theorem Embedding.isSeparable_preimage {f : β → α} [TopologicalSpace β] (hf : Embedding f)
{s : Set α} (hs : IsSeparable s) : IsSeparable (f ⁻¹' s) :=
hf.to_inducing.isSeparable_preimage hs
#align embedding.is_separable_preimage Embedding.isSeparable_preimage
-/
#print ContinuousOn.isSeparable_image /-
/-- If a map is continuous on a separable set `s`, then the image of `s` is also separable. -/
theorem ContinuousOn.isSeparable_image [TopologicalSpace β] {f : α → β} {s : Set α}
(hf : ContinuousOn f s) (hs : IsSeparable s) : IsSeparable (f '' s) :=
by
rw [show f '' s = s.restrict f '' univ by ext <;> simp]
exact
(is_separable_univ_iff.2 hs.separable_space).image (continuousOn_iff_continuous_restrict.1 hf)
#align continuous_on.is_separable_image ContinuousOn.isSeparable_image
-/
end Metric
section Pi
open Finset
variable {π : β → Type _} [Fintype β] [∀ b, PseudoMetricSpace (π b)]
#print pseudoMetricSpacePi /-
/-- A finite product of pseudometric spaces is a pseudometric space, with the sup distance. -/
instance pseudoMetricSpacePi : PseudoMetricSpace (∀ b, π b) :=
by
/- we construct the instance from the pseudoemetric space instance to avoid checking again that
the uniformity is the same as the product uniformity, but we register nevertheless a nice formula
for the distance -/
refine'
(PseudoEMetricSpace.toPseudoMetricSpaceOfDist
(fun f g : ∀ b, π b => ((sup univ fun b => nndist (f b) (g b) : ℝ≥0) : ℝ)) (fun f g => _)
fun f g => _).replaceBornology
fun s => _
show edist f g ≠ ⊤
exact ne_of_lt ((Finset.sup_lt_iff bot_lt_top).2 fun b hb => edist_lt_top _ _)
show ↑(sup univ fun b => nndist (f b) (g b)) = (sup univ fun b => edist (f b) (g b)).toReal
· simp only [edist_nndist, ← ENNReal.coe_finset_sup, ENNReal.coe_toReal]
show @is_bounded _ Pi.bornology s ↔ @is_bounded _ PseudoMetricSpace.toBornology _
· simp only [← is_bounded_def, is_bounded_iff_eventually, ← forall_is_bounded_image_eval_iff,
ball_image_iff, ← eventually_all, Function.eval_apply, @dist_nndist (π _)]
refine' eventually_congr ((eventually_ge_at_top 0).mono fun C hC => _)
lift C to ℝ≥0 using hC
refine'
⟨fun H x hx y hy => NNReal.coe_le_coe.2 <| Finset.sup_le fun b hb => H b x hx y hy,
fun H b x hx y hy => NNReal.coe_le_coe.2 _⟩
simpa only using Finset.sup_le_iff.1 (NNReal.coe_le_coe.1 <| H hx hy) b (Finset.mem_univ b)
#align pseudo_metric_space_pi pseudoMetricSpacePi
-/
/- warning: nndist_pi_def -> nndist_pi_def is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b), Eq.{1} NNReal (NNDist.nndist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) (Finset.sup.{0, u1} NNReal β NNReal.semilatticeSup NNReal.orderBot (Finset.univ.{u1} β _inst_2) (fun (b : β) => NNDist.nndist.{u2} (π b) (PseudoMetricSpace.toNNDist.{u2} (π b) (_inst_3 b)) (f b) (g b)))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b), Eq.{1} NNReal (NNDist.nndist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) (Finset.sup.{0, u2} NNReal β instNNRealSemilatticeSup NNReal.instOrderBotNNRealToLEToPreorderToPartialOrderInstNNRealStrictOrderedSemiring (Finset.univ.{u2} β _inst_2) (fun (b : β) => NNDist.nndist.{u1} (π b) (PseudoMetricSpace.toNNDist.{u1} (π b) (_inst_3 b)) (f b) (g b)))
Case conversion may be inaccurate. Consider using '#align nndist_pi_def nndist_pi_defₓ'. -/
theorem nndist_pi_def (f g : ∀ b, π b) : nndist f g = sup univ fun b => nndist (f b) (g b) :=
NNReal.eq rfl
#align nndist_pi_def nndist_pi_def
/- warning: dist_pi_def -> dist_pi_def is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b), Eq.{1} Real (Dist.dist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toHasDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) NNReal Real (HasLiftT.mk.{1, 1} NNReal Real (CoeTCₓ.coe.{1, 1} NNReal Real (coeBase.{1, 1} NNReal Real NNReal.Real.hasCoe))) (Finset.sup.{0, u1} NNReal β NNReal.semilatticeSup NNReal.orderBot (Finset.univ.{u1} β _inst_2) (fun (b : β) => NNDist.nndist.{u2} (π b) (PseudoMetricSpace.toNNDist.{u2} (π b) (_inst_3 b)) (f b) (g b))))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b), Eq.{1} Real (Dist.dist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) (NNReal.toReal (Finset.sup.{0, u2} NNReal β instNNRealSemilatticeSup NNReal.instOrderBotNNRealToLEToPreorderToPartialOrderInstNNRealStrictOrderedSemiring (Finset.univ.{u2} β _inst_2) (fun (b : β) => NNDist.nndist.{u1} (π b) (PseudoMetricSpace.toNNDist.{u1} (π b) (_inst_3 b)) (f b) (g b))))
Case conversion may be inaccurate. Consider using '#align dist_pi_def dist_pi_defₓ'. -/
theorem dist_pi_def (f g : ∀ b, π b) : dist f g = (sup univ fun b => nndist (f b) (g b) : ℝ≥0) :=
rfl
#align dist_pi_def dist_pi_def
/- warning: nndist_pi_le_iff -> nndist_pi_le_iff is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : NNReal}, Iff (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u2} (π b) (PseudoMetricSpace.toNNDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) r)
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : NNReal}, Iff (LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} (π b) (PseudoMetricSpace.toNNDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) r)
Case conversion may be inaccurate. Consider using '#align nndist_pi_le_iff nndist_pi_le_iffₓ'. -/
theorem nndist_pi_le_iff {f g : ∀ b, π b} {r : ℝ≥0} :
nndist f g ≤ r ↔ ∀ b, nndist (f b) (g b) ≤ r := by simp [nndist_pi_def]
#align nndist_pi_le_iff nndist_pi_le_iff
/- warning: dist_pi_lt_iff -> dist_pi_lt_iff is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (Iff (LT.lt.{0} Real Real.hasLt (Dist.dist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toHasDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} (π b) (PseudoMetricSpace.toHasDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) r))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (Iff (LT.lt.{0} Real Real.instLTReal (Dist.dist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} (π b) (PseudoMetricSpace.toDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) r))
Case conversion may be inaccurate. Consider using '#align dist_pi_lt_iff dist_pi_lt_iffₓ'. -/
theorem dist_pi_lt_iff {f g : ∀ b, π b} {r : ℝ} (hr : 0 < r) :
dist f g < r ↔ ∀ b, dist (f b) (g b) < r :=
by
lift r to ℝ≥0 using hr.le
simp [dist_pi_def, Finset.sup_lt_iff (show ⊥ < r from hr)]
#align dist_pi_lt_iff dist_pi_lt_iff
/- warning: dist_pi_le_iff -> dist_pi_le_iff is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (Iff (LE.le.{0} Real Real.hasLe (Dist.dist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toHasDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} Real Real.hasLe (Dist.dist.{u2} (π b) (PseudoMetricSpace.toHasDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) r))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (Iff (LE.le.{0} Real Real.instLEReal (Dist.dist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} (π b) (PseudoMetricSpace.toDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) r))
Case conversion may be inaccurate. Consider using '#align dist_pi_le_iff dist_pi_le_iffₓ'. -/
theorem dist_pi_le_iff {f g : ∀ b, π b} {r : ℝ} (hr : 0 ≤ r) :
dist f g ≤ r ↔ ∀ b, dist (f b) (g b) ≤ r :=
by
lift r to ℝ≥0 using hr
exact nndist_pi_le_iff
#align dist_pi_le_iff dist_pi_le_iff
/- warning: dist_pi_le_iff' -> dist_pi_le_iff' is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] [_inst_4 : Nonempty.{succ u1} β] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, Iff (LE.le.{0} Real Real.hasLe (Dist.dist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toHasDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} Real Real.hasLe (Dist.dist.{u2} (π b) (PseudoMetricSpace.toHasDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) r)
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] [_inst_4 : Nonempty.{succ u2} β] {f : forall (b : β), π b} {g : forall (b : β), π b} {r : Real}, Iff (LE.le.{0} Real Real.instLEReal (Dist.dist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g) r) (forall (b : β), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} (π b) (PseudoMetricSpace.toDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) r)
Case conversion may be inaccurate. Consider using '#align dist_pi_le_iff' dist_pi_le_iff'ₓ'. -/
theorem dist_pi_le_iff' [Nonempty β] {f g : ∀ b, π b} {r : ℝ} :
dist f g ≤ r ↔ ∀ b, dist (f b) (g b) ≤ r :=
by
by_cases hr : 0 ≤ r
· exact dist_pi_le_iff hr
·
exact
iff_of_false (fun h => hr <| dist_nonneg.trans h) fun h =>
hr <| dist_nonneg.trans <| h <| Classical.arbitrary _
#align dist_pi_le_iff' dist_pi_le_iff'
/- warning: dist_pi_const_le -> dist_pi_const_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Fintype.{u2} β] (a : α) (b : α), LE.le.{0} Real Real.hasLe (Dist.dist.{max u2 u1} (β -> α) (PseudoMetricSpace.toHasDist.{max u2 u1} (β -> α) (pseudoMetricSpacePi.{u2, u1} β (fun (_x : β) => α) _inst_2 (fun (b : β) => _inst_1))) (fun (_x : β) => a) (fun (_x : β) => b)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) a b)
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : Fintype.{u2} β] (a : α) (b : α), LE.le.{0} Real Real.instLEReal (Dist.dist.{max u1 u2} (β -> α) (PseudoMetricSpace.toDist.{max u1 u2} (β -> α) (pseudoMetricSpacePi.{u2, u1} β (fun (_x : β) => α) _inst_2 (fun (b : β) => _inst_1))) (fun (_x : β) => a) (fun (_x : β) => b)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) a b)
Case conversion may be inaccurate. Consider using '#align dist_pi_const_le dist_pi_const_leₓ'. -/
theorem dist_pi_const_le (a b : α) : (dist (fun _ : β => a) fun _ => b) ≤ dist a b :=
(dist_pi_le_iff dist_nonneg).2 fun _ => le_rfl
#align dist_pi_const_le dist_pi_const_le
#print nndist_pi_const_le /-
theorem nndist_pi_const_le (a b : α) : (nndist (fun _ : β => a) fun _ => b) ≤ nndist a b :=
nndist_pi_le_iff.2 fun _ => le_rfl
#align nndist_pi_const_le nndist_pi_const_le
-/
#print dist_pi_const /-
@[simp]
theorem dist_pi_const [Nonempty β] (a b : α) : (dist (fun x : β => a) fun _ => b) = dist a b := by
simpa only [dist_edist] using congr_arg ENNReal.toReal (edist_pi_const a b)
#align dist_pi_const dist_pi_const
-/
#print nndist_pi_const /-
@[simp]
theorem nndist_pi_const [Nonempty β] (a b : α) :
(nndist (fun x : β => a) fun _ => b) = nndist a b :=
NNReal.eq <| dist_pi_const a b
#align nndist_pi_const nndist_pi_const
-/
/- warning: nndist_le_pi_nndist -> nndist_le_pi_nndist is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b) (b : β), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (OrderedCancelAddCommMonoid.toPartialOrder.{0} NNReal (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} NNReal NNReal.strictOrderedSemiring)))) (NNDist.nndist.{u2} (π b) (PseudoMetricSpace.toNNDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) (NNDist.nndist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g)
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b) (b : β), LE.le.{0} NNReal (Preorder.toLE.{0} NNReal (PartialOrder.toPreorder.{0} NNReal (StrictOrderedSemiring.toPartialOrder.{0} NNReal instNNRealStrictOrderedSemiring))) (NNDist.nndist.{u1} (π b) (PseudoMetricSpace.toNNDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) (NNDist.nndist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toNNDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g)
Case conversion may be inaccurate. Consider using '#align nndist_le_pi_nndist nndist_le_pi_nndistₓ'. -/
theorem nndist_le_pi_nndist (f g : ∀ b, π b) (b : β) : nndist (f b) (g b) ≤ nndist f g :=
by
rw [nndist_pi_def]
exact Finset.le_sup (Finset.mem_univ b)
#align nndist_le_pi_nndist nndist_le_pi_nndist
/- warning: dist_le_pi_dist -> dist_le_pi_dist is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b) (b : β), LE.le.{0} Real Real.hasLe (Dist.dist.{u2} (π b) (PseudoMetricSpace.toHasDist.{u2} (π b) (_inst_3 b)) (f b) (g b)) (Dist.dist.{max u1 u2} (forall (b : β), π b) (PseudoMetricSpace.toHasDist.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g)
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (f : forall (b : β), π b) (g : forall (b : β), π b) (b : β), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} (π b) (PseudoMetricSpace.toDist.{u1} (π b) (_inst_3 b)) (f b) (g b)) (Dist.dist.{max u2 u1} (forall (b : β), π b) (PseudoMetricSpace.toDist.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b))) f g)
Case conversion may be inaccurate. Consider using '#align dist_le_pi_dist dist_le_pi_distₓ'. -/
theorem dist_le_pi_dist (f g : ∀ b, π b) (b : β) : dist (f b) (g b) ≤ dist f g := by
simp only [dist_nndist, NNReal.coe_le_coe, nndist_le_pi_nndist f g b]
#align dist_le_pi_dist dist_le_pi_dist
/- warning: ball_pi -> ball_pi is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (x : forall (b : β), π b) {r : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (Eq.{succ (max u1 u2)} (Set.{max u1 u2} (forall (b : β), π b)) (Metric.ball.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u1, u2} β (fun (b : β) => π b) (Set.univ.{u1} β) (fun (b : β) => Metric.ball.{u2} (π b) (_inst_3 b) (x b) r)))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (x : forall (b : β), π b) {r : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (forall (b : β), π b)) (Metric.ball.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u2, u1} β (fun (b : β) => π b) (Set.univ.{u2} β) (fun (b : β) => Metric.ball.{u1} (π b) (_inst_3 b) (x b) r)))
Case conversion may be inaccurate. Consider using '#align ball_pi ball_piₓ'. -/
/-- An open ball in a product space is a product of open balls. See also `metric.ball_pi'`
for a version assuming `nonempty β` instead of `0 < r`. -/
theorem ball_pi (x : ∀ b, π b) {r : ℝ} (hr : 0 < r) :
ball x r = Set.pi univ fun b => ball (x b) r :=
by
ext p
simp [dist_pi_lt_iff hr]
#align ball_pi ball_pi
/- warning: ball_pi' -> ball_pi' is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] [_inst_4 : Nonempty.{succ u1} β] (x : forall (b : β), π b) (r : Real), Eq.{succ (max u1 u2)} (Set.{max u1 u2} (forall (b : β), π b)) (Metric.ball.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u1, u2} β (fun (b : β) => π b) (Set.univ.{u1} β) (fun (b : β) => Metric.ball.{u2} (π b) (_inst_3 b) (x b) r))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] [_inst_4 : Nonempty.{succ u2} β] (x : forall (b : β), π b) (r : Real), Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (forall (b : β), π b)) (Metric.ball.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u2, u1} β (fun (b : β) => π b) (Set.univ.{u2} β) (fun (b : β) => Metric.ball.{u1} (π b) (_inst_3 b) (x b) r))
Case conversion may be inaccurate. Consider using '#align ball_pi' ball_pi'ₓ'. -/
/-- An open ball in a product space is a product of open balls. See also `metric.ball_pi`
for a version assuming `0 < r` instead of `nonempty β`. -/
theorem ball_pi' [Nonempty β] (x : ∀ b, π b) (r : ℝ) :
ball x r = Set.pi univ fun b => ball (x b) r :=
(lt_or_le 0 r).elim (ball_pi x) fun hr => by simp [ball_eq_empty.2 hr]
#align ball_pi' ball_pi'
/- warning: closed_ball_pi -> closedBall_pi is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] (x : forall (b : β), π b) {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (Eq.{succ (max u1 u2)} (Set.{max u1 u2} (forall (b : β), π b)) (Metric.closedBall.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u1, u2} β (fun (b : β) => π b) (Set.univ.{u1} β) (fun (b : β) => Metric.closedBall.{u2} (π b) (_inst_3 b) (x b) r)))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] (x : forall (b : β), π b) {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (forall (b : β), π b)) (Metric.closedBall.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u2, u1} β (fun (b : β) => π b) (Set.univ.{u2} β) (fun (b : β) => Metric.closedBall.{u1} (π b) (_inst_3 b) (x b) r)))
Case conversion may be inaccurate. Consider using '#align closed_ball_pi closedBall_piₓ'. -/
/-- A closed ball in a product space is a product of closed balls. See also `metric.closed_ball_pi'`
for a version assuming `nonempty β` instead of `0 ≤ r`. -/
theorem closedBall_pi (x : ∀ b, π b) {r : ℝ} (hr : 0 ≤ r) :
closedBall x r = Set.pi univ fun b => closedBall (x b) r :=
by
ext p
simp [dist_pi_le_iff hr]
#align closed_ball_pi closedBall_pi
/- warning: closed_ball_pi' -> closedBall_pi' is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {π : β -> Type.{u2}} [_inst_2 : Fintype.{u1} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u2} (π b)] [_inst_4 : Nonempty.{succ u1} β] (x : forall (b : β), π b) (r : Real), Eq.{succ (max u1 u2)} (Set.{max u1 u2} (forall (b : β), π b)) (Metric.closedBall.{max u1 u2} (forall (b : β), π b) (pseudoMetricSpacePi.{u1, u2} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u1, u2} β (fun (b : β) => π b) (Set.univ.{u1} β) (fun (b : β) => Metric.closedBall.{u2} (π b) (_inst_3 b) (x b) r))
but is expected to have type
forall {β : Type.{u2}} {π : β -> Type.{u1}} [_inst_2 : Fintype.{u2} β] [_inst_3 : forall (b : β), PseudoMetricSpace.{u1} (π b)] [_inst_4 : Nonempty.{succ u2} β] (x : forall (b : β), π b) (r : Real), Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (forall (b : β), π b)) (Metric.closedBall.{max u2 u1} (forall (b : β), π b) (pseudoMetricSpacePi.{u2, u1} β (fun (b : β) => π b) _inst_2 (fun (b : β) => _inst_3 b)) x r) (Set.pi.{u2, u1} β (fun (b : β) => π b) (Set.univ.{u2} β) (fun (b : β) => Metric.closedBall.{u1} (π b) (_inst_3 b) (x b) r))
Case conversion may be inaccurate. Consider using '#align closed_ball_pi' closedBall_pi'ₓ'. -/
/-- A closed ball in a product space is a product of closed balls. See also `metric.closed_ball_pi`
for a version assuming `0 ≤ r` instead of `nonempty β`. -/
theorem closedBall_pi' [Nonempty β] (x : ∀ b, π b) (r : ℝ) :
closedBall x r = Set.pi univ fun b => closedBall (x b) r :=
(le_or_lt 0 r).elim (closedBall_pi x) fun hr => by simp [closed_ball_eq_empty.2 hr]
#align closed_ball_pi' closedBall_pi'
/- warning: fin.nndist_insert_nth_insert_nth -> Fin.nndist_insertNth_insertNth is a dubious translation:
lean 3 declaration is
forall {n : Nat} {α : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Type.{u1}} [_inst_4 : forall (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), PseudoMetricSpace.{u1} (α i)] (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (x : α i) (y : α i) (f : forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (g : forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)), Eq.{1} NNReal (NNDist.nndist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), α j) (PseudoMetricSpace.toNNDist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), α j) (pseudoMetricSpacePi.{0, u1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α j) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => _inst_4 b))) (Fin.insertNth.{u1} n (fun (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α i) i x f) (Fin.insertNth.{u1} n (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α j) i y g)) (LinearOrder.max.{0} NNReal (ConditionallyCompleteLinearOrder.toLinearOrder.{0} NNReal (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{0} NNReal NNReal.conditionallyCompleteLinearOrderBot)) (NNDist.nndist.{u1} (α i) (PseudoMetricSpace.toNNDist.{u1} (α i) (_inst_4 i)) x y) (NNDist.nndist.{u1} (forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (PseudoMetricSpace.toNNDist.{u1} (forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (pseudoMetricSpacePi.{0, u1} (Fin n) (fun (j : Fin n) => α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (Fin.fintype n) (fun (b : Fin n) => _inst_4 (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) b)))) f g))
but is expected to have type
forall {n : Nat} {α : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Type.{u1}} [_inst_4 : forall (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), PseudoMetricSpace.{u1} (α i)] (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x : α i) (y : α i) (f : forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (g : forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)), Eq.{1} NNReal (NNDist.nndist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), α j) (PseudoMetricSpace.toNNDist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), α j) (pseudoMetricSpacePi.{0, u1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => α j) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_4 b))) (Fin.insertNth.{u1} n α i x f) (Fin.insertNth.{u1} n (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => α j) i y g)) (Max.max.{0} NNReal (CanonicallyLinearOrderedSemifield.toMax.{0} NNReal NNReal.instCanonicallyLinearOrderedSemifieldNNReal) (NNDist.nndist.{u1} (α i) (PseudoMetricSpace.toNNDist.{u1} (α i) (_inst_4 i)) x y) (NNDist.nndist.{u1} (forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (PseudoMetricSpace.toNNDist.{u1} (forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (pseudoMetricSpacePi.{0, u1} (Fin n) (fun (j : Fin n) => α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (Fin.fintype n) (fun (b : Fin n) => _inst_4 (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) b)))) f g))
Case conversion may be inaccurate. Consider using '#align fin.nndist_insert_nth_insert_nth Fin.nndist_insertNth_insertNthₓ'. -/
@[simp]
theorem Fin.nndist_insertNth_insertNth {n : ℕ} {α : Fin (n + 1) → Type _}
[∀ i, PseudoMetricSpace (α i)] (i : Fin (n + 1)) (x y : α i) (f g : ∀ j, α (i.succAbove j)) :
nndist (i.insertNth x f) (i.insertNth y g) = max (nndist x y) (nndist f g) :=
eq_of_forall_ge_iff fun c => by simp [nndist_pi_le_iff, i.forall_iff_succ_above]
#align fin.nndist_insert_nth_insert_nth Fin.nndist_insertNth_insertNth
/- warning: fin.dist_insert_nth_insert_nth -> Fin.dist_insertNth_insertNth is a dubious translation:
lean 3 declaration is
forall {n : Nat} {α : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Type.{u1}} [_inst_4 : forall (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), PseudoMetricSpace.{u1} (α i)] (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (x : α i) (y : α i) (f : forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (g : forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)), Eq.{1} Real (Dist.dist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), α j) (PseudoMetricSpace.toHasDist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), α j) (pseudoMetricSpacePi.{0, u1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α j) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => _inst_4 b))) (Fin.insertNth.{u1} n (fun (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α i) i x f) (Fin.insertNth.{u1} n (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => α j) i y g)) (LinearOrder.max.{0} Real Real.linearOrder (Dist.dist.{u1} (α i) (PseudoMetricSpace.toHasDist.{u1} (α i) (_inst_4 i)) x y) (Dist.dist.{u1} (forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (PseudoMetricSpace.toHasDist.{u1} (forall (j : Fin n), α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (pseudoMetricSpacePi.{0, u1} (Fin n) (fun (j : Fin n) => α (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) j)) (Fin.fintype n) (fun (b : Fin n) => _inst_4 (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i) b)))) f g))
but is expected to have type
forall {n : Nat} {α : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Type.{u1}} [_inst_4 : forall (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), PseudoMetricSpace.{u1} (α i)] (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x : α i) (y : α i) (f : forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (g : forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)), Eq.{1} Real (Dist.dist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), α j) (PseudoMetricSpace.toDist.{u1} (forall (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), α j) (pseudoMetricSpacePi.{0, u1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => α j) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_4 b))) (Fin.insertNth.{u1} n α i x f) (Fin.insertNth.{u1} n (fun (j : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => α j) i y g)) (Max.max.{0} Real (LinearOrderedRing.toMax.{0} Real Real.instLinearOrderedRingReal) (Dist.dist.{u1} (α i) (PseudoMetricSpace.toDist.{u1} (α i) (_inst_4 i)) x y) (Dist.dist.{u1} (forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (PseudoMetricSpace.toDist.{u1} (forall (j : Fin n), α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (pseudoMetricSpacePi.{0, u1} (Fin n) (fun (j : Fin n) => α (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) j)) (Fin.fintype n) (fun (b : Fin n) => _inst_4 (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i)) b)))) f g))
Case conversion may be inaccurate. Consider using '#align fin.dist_insert_nth_insert_nth Fin.dist_insertNth_insertNthₓ'. -/
@[simp]
theorem Fin.dist_insertNth_insertNth {n : ℕ} {α : Fin (n + 1) → Type _}
[∀ i, PseudoMetricSpace (α i)] (i : Fin (n + 1)) (x y : α i) (f g : ∀ j, α (i.succAbove j)) :
dist (i.insertNth x f) (i.insertNth y g) = max (dist x y) (dist f g) := by
simp only [dist_nndist, Fin.nndist_insertNth_insertNth, NNReal.coe_max]
#align fin.dist_insert_nth_insert_nth Fin.dist_insertNth_insertNth
/- warning: real.dist_le_of_mem_pi_Icc -> Real.dist_le_of_mem_pi_Icc is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} [_inst_2 : Fintype.{u1} β] {x : β -> Real} {y : β -> Real} {x' : β -> Real} {y' : β -> Real}, (Membership.Mem.{u1, u1} (β -> Real) (Set.{u1} (β -> Real)) (Set.hasMem.{u1} (β -> Real)) x (Set.Icc.{u1} (β -> Real) (Pi.preorder.{u1, 0} β (fun (ᾰ : β) => Real) (fun (i : β) => Real.preorder)) x' y')) -> (Membership.Mem.{u1, u1} (β -> Real) (Set.{u1} (β -> Real)) (Set.hasMem.{u1} (β -> Real)) y (Set.Icc.{u1} (β -> Real) (Pi.preorder.{u1, 0} β (fun (ᾰ : β) => Real) (fun (i : β) => Real.preorder)) x' y')) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} (β -> Real) (PseudoMetricSpace.toHasDist.{u1} (β -> Real) (pseudoMetricSpacePi.{u1, 0} β (fun (ᾰ : β) => Real) _inst_2 (fun (b : β) => Real.pseudoMetricSpace))) x y) (Dist.dist.{u1} (β -> Real) (PseudoMetricSpace.toHasDist.{u1} (β -> Real) (pseudoMetricSpacePi.{u1, 0} β (fun (ᾰ : β) => Real) _inst_2 (fun (b : β) => Real.pseudoMetricSpace))) x' y'))
but is expected to have type
forall {β : Type.{u1}} [_inst_2 : Fintype.{u1} β] {x : β -> Real} {y : β -> Real} {x' : β -> Real} {y' : β -> Real}, (Membership.mem.{u1, u1} (β -> Real) (Set.{u1} (β -> Real)) (Set.instMembershipSet.{u1} (β -> Real)) x (Set.Icc.{u1} (β -> Real) (Pi.preorder.{u1, 0} β (fun (ᾰ : β) => Real) (fun (i : β) => Real.instPreorderReal)) x' y')) -> (Membership.mem.{u1, u1} (β -> Real) (Set.{u1} (β -> Real)) (Set.instMembershipSet.{u1} (β -> Real)) y (Set.Icc.{u1} (β -> Real) (Pi.preorder.{u1, 0} β (fun (ᾰ : β) => Real) (fun (i : β) => Real.instPreorderReal)) x' y')) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} (β -> Real) (PseudoMetricSpace.toDist.{u1} (β -> Real) (pseudoMetricSpacePi.{u1, 0} β (fun (ᾰ : β) => Real) _inst_2 (fun (b : β) => Real.pseudoMetricSpace))) x y) (Dist.dist.{u1} (β -> Real) (PseudoMetricSpace.toDist.{u1} (β -> Real) (pseudoMetricSpacePi.{u1, 0} β (fun (ᾰ : β) => Real) _inst_2 (fun (b : β) => Real.pseudoMetricSpace))) x' y'))
Case conversion may be inaccurate. Consider using '#align real.dist_le_of_mem_pi_Icc Real.dist_le_of_mem_pi_Iccₓ'. -/
theorem Real.dist_le_of_mem_pi_Icc {x y x' y' : β → ℝ} (hx : x ∈ Icc x' y') (hy : y ∈ Icc x' y') :
dist x y ≤ dist x' y' :=
by
refine'
(dist_pi_le_iff dist_nonneg).2 fun b =>
(Real.dist_le_of_mem_uIcc _ _).trans (dist_le_pi_dist _ _ b) <;>
refine' Icc_subset_uIcc _
exacts[⟨hx.1 _, hx.2 _⟩, ⟨hy.1 _, hy.2 _⟩]
#align real.dist_le_of_mem_pi_Icc Real.dist_le_of_mem_pi_Icc
end Pi
section Compact
/- warning: finite_cover_balls_of_compact -> finite_cover_balls_of_compact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) s) -> (forall {e : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) e) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) (fun (H : HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t) => Metric.ball.{u1} α _inst_2 x e))))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) s) -> (forall {e : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) e) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) t s) (And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t) (fun (h._@.Mathlib.Topology.MetricSpace.Basic._hyg.25465 : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t) => Metric.ball.{u1} α _inst_2 x e))))))))
Case conversion may be inaccurate. Consider using '#align finite_cover_balls_of_compact finite_cover_balls_of_compactₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
/-- Any compact set in a pseudometric space can be covered by finitely many balls of a given
positive radius -/
theorem finite_cover_balls_of_compact {α : Type u} [PseudoMetricSpace α] {s : Set α}
(hs : IsCompact s) {e : ℝ} (he : 0 < e) :
∃ (t : _)(_ : t ⊆ s), Set.Finite t ∧ s ⊆ ⋃ x ∈ t, ball x e :=
by
apply hs.elim_finite_subcover_image
· simp [is_open_ball]
· intro x xs
simp
exact ⟨x, ⟨xs, by simpa⟩⟩
#align finite_cover_balls_of_compact finite_cover_balls_of_compact
/- warning: is_compact.finite_cover_balls -> IsCompact.finite_cover_balls is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) s) -> (forall {e : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) e) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) (fun (H : HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t) => Metric.ball.{u1} α _inst_2 x e))))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_2)) s) -> (forall {e : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) e) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) t s) (And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t) (fun (h._@.Mathlib.Topology.MetricSpace.Basic._hyg.25465 : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t) => Metric.ball.{u1} α _inst_2 x e))))))))
Case conversion may be inaccurate. Consider using '#align is_compact.finite_cover_balls IsCompact.finite_cover_ballsₓ'. -/
alias finite_cover_balls_of_compact ← IsCompact.finite_cover_balls
#align is_compact.finite_cover_balls IsCompact.finite_cover_balls
end Compact
section ProperSpace
open Metric
#print ProperSpace /-
/-- A pseudometric space is proper if all closed balls are compact. -/
class ProperSpace (α : Type u) [PseudoMetricSpace α] : Prop where
isCompact_closedBall : ∀ x : α, ∀ r, IsCompact (closedBall x r)
#align proper_space ProperSpace
-/
export ProperSpace (isCompact_closedBall)
#print isCompact_sphere /-
/-- In a proper pseudometric space, all spheres are compact. -/
theorem isCompact_sphere {α : Type _} [PseudoMetricSpace α] [ProperSpace α] (x : α) (r : ℝ) :
IsCompact (sphere x r) :=
isCompact_of_isClosed_subset (isCompact_closedBall x r) isClosed_sphere sphere_subset_closedBall
#align is_compact_sphere isCompact_sphere
-/
/-- In a proper pseudometric space, any sphere is a `compact_space` when considered as a subtype. -/
instance {α : Type _} [PseudoMetricSpace α] [ProperSpace α] (x : α) (r : ℝ) :
CompactSpace (sphere x r) :=
isCompact_iff_compactSpace.mp (isCompact_sphere _ _)
#print secondCountable_of_proper /-
-- see Note [lower instance priority]
/-- A proper pseudo metric space is sigma compact, and therefore second countable. -/
instance (priority := 100) secondCountable_of_proper [ProperSpace α] : SecondCountableTopology α :=
by
-- We already have `sigma_compact_space_of_locally_compact_second_countable`, so we don't
-- add an instance for `sigma_compact_space`.
suffices SigmaCompactSpace α by exact EMetric.secondCountable_of_sigmaCompact α
rcases em (Nonempty α) with (⟨⟨x⟩⟩ | hn)
· exact ⟨⟨fun n => closed_ball x n, fun n => is_compact_closed_ball _ _, Union_closed_ball_nat _⟩⟩
· exact ⟨⟨fun n => ∅, fun n => isCompact_empty, Union_eq_univ_iff.2 fun x => (hn ⟨x⟩).elim⟩⟩
#align second_countable_of_proper secondCountable_of_proper
-/
#print tendsto_dist_right_cocompact_atTop /-
theorem tendsto_dist_right_cocompact_atTop [ProperSpace α] (x : α) :
Tendsto (fun y => dist y x) (cocompact α) atTop :=
(hasBasis_cocompact.tendsto_iffₓ atTop_basis).2 fun r hr =>
⟨closedBall x r, isCompact_closedBall x r, fun y hy => (not_le.1 <| mt mem_closedBall.2 hy).le⟩
#align tendsto_dist_right_cocompact_at_top tendsto_dist_right_cocompact_atTop
-/
#print tendsto_dist_left_cocompact_atTop /-
theorem tendsto_dist_left_cocompact_atTop [ProperSpace α] (x : α) :
Tendsto (dist x) (cocompact α) atTop := by
simpa only [dist_comm] using tendsto_dist_right_cocompact_atTop x
#align tendsto_dist_left_cocompact_at_top tendsto_dist_left_cocompact_atTop
-/
/- warning: proper_space_of_compact_closed_ball_of_le -> properSpace_of_compact_closedBall_of_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (R : Real), (forall (x : α) (r : Real), (LE.le.{0} Real Real.hasLe R r) -> (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Metric.closedBall.{u1} α _inst_1 x r))) -> (ProperSpace.{u1} α _inst_1)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (R : Real), (forall (x : α) (r : Real), (LE.le.{0} Real Real.instLEReal R r) -> (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (Metric.closedBall.{u1} α _inst_1 x r))) -> (ProperSpace.{u1} α _inst_1)
Case conversion may be inaccurate. Consider using '#align proper_space_of_compact_closed_ball_of_le properSpace_of_compact_closedBall_of_leₓ'. -/
/-- If all closed balls of large enough radius are compact, then the space is proper. Especially
useful when the lower bound for the radius is 0. -/
theorem properSpace_of_compact_closedBall_of_le (R : ℝ)
(h : ∀ x : α, ∀ r, R ≤ r → IsCompact (closedBall x r)) : ProperSpace α :=
⟨by
intro x r
by_cases hr : R ≤ r
· exact h x r hr
· have : closed_ball x r = closed_ball x R ∩ closed_ball x r :=
by
symm
apply inter_eq_self_of_subset_right
exact closed_ball_subset_closed_ball (le_of_lt (not_le.1 hr))
rw [this]
exact (h x R le_rfl).inter_right is_closed_ball⟩
#align proper_space_of_compact_closed_ball_of_le properSpace_of_compact_closedBall_of_le
#print proper_of_compact /-
-- A compact pseudometric space is proper
-- see Note [lower instance priority]
instance (priority := 100) proper_of_compact [CompactSpace α] : ProperSpace α :=
⟨fun x r => isClosed_ball.IsCompact⟩
#align proper_of_compact proper_of_compact
-/
#print locally_compact_of_proper /-
-- see Note [lower instance priority]
/-- A proper space is locally compact -/
instance (priority := 100) locally_compact_of_proper [ProperSpace α] : LocallyCompactSpace α :=
locallyCompactSpace_of_hasBasis (fun x => nhds_basis_closedBall) fun x ε ε0 =>
isCompact_closedBall _ _
#align locally_compact_of_proper locally_compact_of_proper
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » t) -/
#print complete_of_proper /-
-- see Note [lower instance priority]
/-- A proper space is complete -/
instance (priority := 100) complete_of_proper [ProperSpace α] : CompleteSpace α :=
⟨by
intro f hf
/- We want to show that the Cauchy filter `f` is converging. It suffices to find a closed
ball (therefore compact by properness) where it is nontrivial. -/
obtain ⟨t, t_fset, ht⟩ : ∃ t ∈ f, ∀ (x) (_ : x ∈ t) (y) (_ : y ∈ t), dist x y < 1 :=
(Metric.cauchy_iff.1 hf).2 1 zero_lt_one
rcases hf.1.nonempty_of_mem t_fset with ⟨x, xt⟩
have : closed_ball x 1 ∈ f := mem_of_superset t_fset fun y yt => (ht y yt x xt).le
rcases(isCompact_iff_totallyBounded_isComplete.1 (is_compact_closed_ball x 1)).2 f hf
(le_principal_iff.2 this) with
⟨y, -, hy⟩
exact ⟨y, hy⟩⟩
#align complete_of_proper complete_of_proper
-/
#print prod_properSpace /-
/-- A binary product of proper spaces is proper. -/
instance prod_properSpace {α : Type _} {β : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β]
[ProperSpace α] [ProperSpace β] : ProperSpace (α × β)
where isCompact_closedBall := by
rintro ⟨x, y⟩ r
rw [← closedBall_prod_same x y]
apply (is_compact_closed_ball x r).Prod (is_compact_closed_ball y r)
#align prod_proper_space prod_properSpace
-/
#print pi_properSpace /-
/-- A finite product of proper spaces is proper. -/
instance pi_properSpace {π : β → Type _} [Fintype β] [∀ b, PseudoMetricSpace (π b)]
[h : ∀ b, ProperSpace (π b)] : ProperSpace (∀ b, π b) :=
by
refine' properSpace_of_compact_closedBall_of_le 0 fun x r hr => _
rw [closedBall_pi _ hr]
apply isCompact_univ_pi fun b => _
apply (h b).isCompact_closedBall
#align pi_proper_space pi_properSpace
-/
variable [ProperSpace α] {x : α} {r : ℝ} {s : Set α}
/- warning: exists_pos_lt_subset_ball -> exists_pos_lt_subset_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] {x : α} {r : Real} {s : Set.{u1} α}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.ball.{u1} α _inst_1 x r)) -> (Exists.{1} Real (fun (r' : Real) => Exists.{0} (Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) r' (Set.Ioo.{0} Real Real.preorder (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r)) (fun (H : Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) r' (Set.Ioo.{0} Real Real.preorder (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.ball.{u1} α _inst_1 x r'))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] {x : α} {r : Real} {s : Set.{u1} α}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.ball.{u1} α _inst_1 x r)) -> (Exists.{1} Real (fun (r' : Real) => And (Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) r' (Set.Ioo.{0} Real Real.instPreorderReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.ball.{u1} α _inst_1 x r'))))
Case conversion may be inaccurate. Consider using '#align exists_pos_lt_subset_ball exists_pos_lt_subset_ballₓ'. -/
/-- If a nonempty ball in a proper space includes a closed set `s`, then there exists a nonempty
ball with the same center and a strictly smaller radius that includes `s`. -/
theorem exists_pos_lt_subset_ball (hr : 0 < r) (hs : IsClosed s) (h : s ⊆ ball x r) :
∃ r' ∈ Ioo 0 r, s ⊆ ball x r' :=
by
rcases eq_empty_or_nonempty s with (rfl | hne)
· exact ⟨r / 2, ⟨half_pos hr, half_lt_self hr⟩, empty_subset _⟩
have : IsCompact s :=
isCompact_of_isClosed_subset (is_compact_closed_ball x r) hs
(subset.trans h ball_subset_closed_ball)
obtain ⟨y, hys, hy⟩ : ∃ y ∈ s, s ⊆ closed_ball x (dist y x)
exact this.exists_forall_ge hne (continuous_id.dist continuous_const).ContinuousOn
have hyr : dist y x < r := h hys
rcases exists_between hyr with ⟨r', hyr', hrr'⟩
exact ⟨r', ⟨dist_nonneg.trans_lt hyr', hrr'⟩, subset.trans hy <| closed_ball_subset_ball hyr'⟩
#align exists_pos_lt_subset_ball exists_pos_lt_subset_ball
/- warning: exists_lt_subset_ball -> exists_lt_subset_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] {x : α} {r : Real} {s : Set.{u1} α}, (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.ball.{u1} α _inst_1 x r)) -> (Exists.{1} Real (fun (r' : Real) => Exists.{0} (LT.lt.{0} Real Real.hasLt r' r) (fun (H : LT.lt.{0} Real Real.hasLt r' r) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.ball.{u1} α _inst_1 x r'))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] {x : α} {r : Real} {s : Set.{u1} α}, (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.ball.{u1} α _inst_1 x r)) -> (Exists.{1} Real (fun (r' : Real) => And (LT.lt.{0} Real Real.instLTReal r' r) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.ball.{u1} α _inst_1 x r'))))
Case conversion may be inaccurate. Consider using '#align exists_lt_subset_ball exists_lt_subset_ballₓ'. -/
/-- If a ball in a proper space includes a closed set `s`, then there exists a ball with the same
center and a strictly smaller radius that includes `s`. -/
theorem exists_lt_subset_ball (hs : IsClosed s) (h : s ⊆ ball x r) : ∃ r' < r, s ⊆ ball x r' :=
by
cases' le_or_lt r 0 with hr hr
· rw [ball_eq_empty.2 hr, subset_empty_iff] at h
subst s
exact (exists_lt r).imp fun r' hr' => ⟨hr', empty_subset _⟩
· exact (exists_pos_lt_subset_ball hr hs h).imp fun r' hr' => ⟨hr'.fst.2, hr'.snd⟩
#align exists_lt_subset_ball exists_lt_subset_ball
end ProperSpace
#print IsCompact.isSeparable /-
theorem IsCompact.isSeparable {s : Set α} (hs : IsCompact s) : IsSeparable s :=
haveI : CompactSpace s := is_compact_iff_compact_space.mp hs
is_separable_of_separable_space_subtype s
#align is_compact.is_separable IsCompact.isSeparable
-/
namespace Metric
section SecondCountable
open TopologicalSpace
/- warning: metric.second_countable_of_almost_dense_set -> Metric.secondCountable_of_almost_dense_set is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ u1} (Set.{u1} α) (fun (s : Set.{u1} α) => And (Set.Countable.{u1} α s) (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) ε)))))) -> (TopologicalSpace.SecondCountableTopology.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ u1} (Set.{u1} α) (fun (s : Set.{u1} α) => And (Set.Countable.{u1} α s) (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) ε)))))) -> (TopologicalSpace.SecondCountableTopology.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align metric.second_countable_of_almost_dense_set Metric.secondCountable_of_almost_dense_setₓ'. -/
/-- A pseudometric space is second countable if, for every `ε > 0`, there is a countable set which
is `ε`-dense. -/
theorem secondCountable_of_almost_dense_set
(H : ∀ ε > (0 : ℝ), ∃ s : Set α, s.Countable ∧ ∀ x, ∃ y ∈ s, dist x y ≤ ε) :
SecondCountableTopology α :=
by
refine' EMetric.secondCountable_of_almost_dense_set fun ε ε0 => _
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 ε0 with ⟨ε', ε'0, ε'ε⟩
choose s hsc y hys hyx using H ε' (by exact_mod_cast ε'0)
refine' ⟨s, hsc, Union₂_eq_univ_iff.2 fun x => ⟨y x, hys _, le_trans _ ε'ε.le⟩⟩
exact_mod_cast hyx x
#align metric.second_countable_of_almost_dense_set Metric.secondCountable_of_almost_dense_set
end SecondCountable
end Metric
/- warning: lebesgue_number_lemma_of_metric -> lebesgue_number_lemma_of_metric is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {ι : Sort.{u2}} {c : ι -> (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall (i : ι), IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (c i)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, u2} α ι (fun (i : ι) => c i))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{u2} ι (fun (i : ι) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x δ) (c i))))))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {s : Set.{u2} α} {ι : Sort.{u1}} {c : ι -> (Set.{u2} α)}, (IsCompact.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) s) -> (forall (i : ι), IsOpen.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) (c i)) -> (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) s (Set.unionᵢ.{u2, u1} α ι (fun (i : ι) => c i))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) -> (Exists.{u1} ι (fun (i : ι) => HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Metric.ball.{u2} α _inst_1 x δ) (c i))))))
Case conversion may be inaccurate. Consider using '#align lebesgue_number_lemma_of_metric lebesgue_number_lemma_of_metricₓ'. -/
theorem lebesgue_number_lemma_of_metric {s : Set α} {ι} {c : ι → Set α} (hs : IsCompact s)
(hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) : ∃ δ > 0, ∀ x ∈ s, ∃ i, ball x δ ⊆ c i :=
let ⟨n, en, hn⟩ := lebesgue_number_lemma hs hc₁ hc₂
let ⟨δ, δ0, hδ⟩ := mem_uniformity_dist.1 en
⟨δ, δ0, fun x hx =>
let ⟨i, hi⟩ := hn x hx
⟨i, fun y hy => hi (hδ (mem_ball'.mp hy))⟩⟩
#align lebesgue_number_lemma_of_metric lebesgue_number_lemma_of_metric
/- warning: lebesgue_number_lemma_of_metric_sUnion -> lebesgue_number_lemma_of_metric_unionₛ is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {c : Set.{u1} (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall (t : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) t)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionₛ.{u1} α c)) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Metric.ball.{u1} α _inst_1 x δ) t))))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {c : Set.{u1} (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) s) -> (forall (t : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) t c) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) t)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionₛ.{u1} α c)) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) t c) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Metric.ball.{u1} α _inst_1 x δ) t))))))
Case conversion may be inaccurate. Consider using '#align lebesgue_number_lemma_of_metric_sUnion lebesgue_number_lemma_of_metric_unionₛₓ'. -/
theorem lebesgue_number_lemma_of_metric_unionₛ {s : Set α} {c : Set (Set α)} (hs : IsCompact s)
(hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) : ∃ δ > 0, ∀ x ∈ s, ∃ t ∈ c, ball x δ ⊆ t := by
rw [sUnion_eq_Union] at hc₂ <;> simpa using lebesgue_number_lemma_of_metric hs (by simpa) hc₂
#align lebesgue_number_lemma_of_metric_sUnion lebesgue_number_lemma_of_metric_unionₛ
namespace Metric
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » s) -/
#print Metric.Bounded /-
/-- Boundedness of a subset of a pseudometric space. We formulate the definition to work
even in the empty space. -/
def Bounded (s : Set α) : Prop :=
∃ C, ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), dist x y ≤ C
#align metric.bounded Metric.Bounded
-/
section Bounded
variable {x : α} {s t : Set α} {r : ℝ}
#print Metric.bounded_iff_isBounded /-
theorem bounded_iff_isBounded (s : Set α) : Bounded s ↔ IsBounded s :=
by
change bounded s ↔ sᶜ ∈ (cobounded α).sets
simp [PseudoMetricSpace.cobounded_sets, Metric.Bounded]
#align metric.bounded_iff_is_bounded Metric.bounded_iff_isBounded
-/
#print Metric.bounded_empty /-
@[simp]
theorem bounded_empty : Bounded (∅ : Set α) :=
⟨0, by simp⟩
#align metric.bounded_empty Metric.bounded_empty
-/
#print Metric.bounded_iff_mem_bounded /-
theorem bounded_iff_mem_bounded : Bounded s ↔ ∀ x ∈ s, Bounded s :=
⟨fun h _ _ => h, fun H =>
s.eq_empty_or_nonempty.elim (fun hs => hs.symm ▸ bounded_empty) fun ⟨x, hx⟩ => H x hx⟩
#align metric.bounded_iff_mem_bounded Metric.bounded_iff_mem_bounded
-/
#print Metric.Bounded.mono /-
/-- Subsets of a bounded set are also bounded -/
theorem Bounded.mono (incl : s ⊆ t) : Bounded t → Bounded s :=
Exists.imp fun C hC x hx y hy => hC x (incl hx) y (incl hy)
#align metric.bounded.mono Metric.Bounded.mono
-/
#print Metric.bounded_closedBall /-
/-- Closed balls are bounded -/
theorem bounded_closedBall : Bounded (closedBall x r) :=
⟨r + r, fun y hy z hz => by
simp only [mem_closed_ball] at *
calc
dist y z ≤ dist y x + dist z x := dist_triangle_right _ _ _
_ ≤ r + r := add_le_add hy hz
⟩
#align metric.bounded_closed_ball Metric.bounded_closedBall
-/
#print Metric.bounded_ball /-
/-- Open balls are bounded -/
theorem bounded_ball : Bounded (ball x r) :=
bounded_closedBall.mono ball_subset_closedBall
#align metric.bounded_ball Metric.bounded_ball
-/
#print Metric.bounded_sphere /-
/-- Spheres are bounded -/
theorem bounded_sphere : Bounded (sphere x r) :=
bounded_closedBall.mono sphere_subset_closedBall
#align metric.bounded_sphere Metric.bounded_sphere
-/
#print Metric.bounded_iff_subset_ball /-
/-- Given a point, a bounded subset is included in some ball around this point -/
theorem bounded_iff_subset_ball (c : α) : Bounded s ↔ ∃ r, s ⊆ closedBall c r :=
by
constructor <;> rintro ⟨C, hC⟩
· cases' s.eq_empty_or_nonempty with h h
· subst s
exact ⟨0, by simp⟩
· rcases h with ⟨x, hx⟩
exact
⟨C + dist x c, fun y hy =>
calc
dist y c ≤ dist y x + dist x c := dist_triangle _ _ _
_ ≤ C + dist x c := add_le_add_right (hC y hy x hx) _
⟩
· exact bounded_closed_ball.mono hC
#align metric.bounded_iff_subset_ball Metric.bounded_iff_subset_ball
-/
#print Metric.Bounded.subset_ball /-
theorem Bounded.subset_ball (h : Bounded s) (c : α) : ∃ r, s ⊆ closedBall c r :=
(bounded_iff_subset_ball c).1 h
#align metric.bounded.subset_ball Metric.Bounded.subset_ball
-/
/- warning: metric.bounded.subset_ball_lt -> Metric.Bounded.subset_ball_lt is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (forall (a : Real) (c : α), Exists.{1} Real (fun (r : Real) => And (LT.lt.{0} Real Real.hasLt a r) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.closedBall.{u1} α _inst_1 c r))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (forall (a : Real) (c : α), Exists.{1} Real (fun (r : Real) => And (LT.lt.{0} Real Real.instLTReal a r) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.closedBall.{u1} α _inst_1 c r))))
Case conversion may be inaccurate. Consider using '#align metric.bounded.subset_ball_lt Metric.Bounded.subset_ball_ltₓ'. -/
theorem Bounded.subset_ball_lt (h : Bounded s) (a : ℝ) (c : α) : ∃ r, a < r ∧ s ⊆ closedBall c r :=
by
rcases h.subset_ball c with ⟨r, hr⟩
refine' ⟨max r (a + 1), lt_of_lt_of_le (by linarith) (le_max_right _ _), _⟩
exact subset.trans hr (closed_ball_subset_closed_ball (le_max_left _ _))
#align metric.bounded.subset_ball_lt Metric.Bounded.subset_ball_lt
#print Metric.bounded_closure_of_bounded /-
theorem bounded_closure_of_bounded (h : Bounded s) : Bounded (closure s) :=
let ⟨C, h⟩ := h
⟨C, fun a ha b hb => (isClosed_le' C).closure_subset <| map_mem_closure₂ continuous_dist ha hb h⟩
#align metric.bounded_closure_of_bounded Metric.bounded_closure_of_bounded
-/
alias bounded_closure_of_bounded ← bounded.closure
#align metric.bounded.closure Metric.Bounded.closure
#print Metric.bounded_closure_iff /-
@[simp]
theorem bounded_closure_iff : Bounded (closure s) ↔ Bounded s :=
⟨fun h => h.mono subset_closure, fun h => h.closure⟩
#align metric.bounded_closure_iff Metric.bounded_closure_iff
-/
/- warning: metric.bounded.union -> Metric.Bounded.union is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Metric.Bounded.{u1} α _inst_1 t) -> (Metric.Bounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Metric.Bounded.{u1} α _inst_1 t) -> (Metric.Bounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t))
Case conversion may be inaccurate. Consider using '#align metric.bounded.union Metric.Bounded.unionₓ'. -/
/-- The union of two bounded sets is bounded. -/
theorem Bounded.union (hs : Bounded s) (ht : Bounded t) : Bounded (s ∪ t) :=
by
refine' bounded_iff_mem_bounded.2 fun x _ => _
rw [bounded_iff_subset_ball x] at hs ht⊢
rcases hs with ⟨Cs, hCs⟩; rcases ht with ⟨Ct, hCt⟩
exact
⟨max Cs Ct,
union_subset (subset.trans hCs <| closed_ball_subset_closed_ball <| le_max_left _ _)
(subset.trans hCt <| closed_ball_subset_closed_ball <| le_max_right _ _)⟩
#align metric.bounded.union Metric.Bounded.union
/- warning: metric.bounded_union -> Metric.bounded_union is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Metric.Bounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t)) (And (Metric.Bounded.{u1} α _inst_1 s) (Metric.Bounded.{u1} α _inst_1 t))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Metric.Bounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t)) (And (Metric.Bounded.{u1} α _inst_1 s) (Metric.Bounded.{u1} α _inst_1 t))
Case conversion may be inaccurate. Consider using '#align metric.bounded_union Metric.bounded_unionₓ'. -/
/-- The union of two sets is bounded iff each of the sets is bounded. -/
@[simp]
theorem bounded_union : Bounded (s ∪ t) ↔ Bounded s ∧ Bounded t :=
⟨fun h => ⟨h.mono (by simp), h.mono (by simp)⟩, fun h => h.1.union h.2⟩
#align metric.bounded_union Metric.bounded_union
#print Metric.bounded_bunionᵢ /-
/-- A finite union of bounded sets is bounded -/
theorem bounded_bunionᵢ {I : Set β} {s : β → Set α} (H : I.Finite) :
Bounded (⋃ i ∈ I, s i) ↔ ∀ i ∈ I, Bounded (s i) :=
Finite.induction_on H (by simp) fun x I _ _ IH => by simp [or_imp, forall_and, IH]
#align metric.bounded_bUnion Metric.bounded_bunionᵢ
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print Metric.Bounded.prod /-
protected theorem Bounded.prod [PseudoMetricSpace β] {s : Set α} {t : Set β} (hs : Bounded s)
(ht : Bounded t) : Bounded (s ×ˢ t) :=
by
refine' bounded_iff_mem_bounded.mpr fun x hx => _
rcases hs.subset_ball x.1 with ⟨rs, hrs⟩
rcases ht.subset_ball x.2 with ⟨rt, hrt⟩
suffices : s ×ˢ t ⊆ closed_ball x (max rs rt)
exact bounded_closed_ball.mono this
rw [← @Prod.mk.eta _ _ x, ← closedBall_prod_same]
exact
prod_mono (hrs.trans <| closed_ball_subset_closed_ball <| le_max_left _ _)
(hrt.trans <| closed_ball_subset_closed_ball <| le_max_right _ _)
#align metric.bounded.prod Metric.Bounded.prod
-/
#print TotallyBounded.bounded /-
/-- A totally bounded set is bounded -/
theorem TotallyBounded.bounded {s : Set α} (h : TotallyBounded s) : Bounded s :=
let-- We cover the totally bounded set by finitely many balls of radius 1,
-- and then argue that a finite union of bounded sets is bounded
⟨t, fint, subs⟩ :=
(totallyBounded_iff.mp h) 1 zero_lt_one
Bounded.mono subs <| (bounded_bunionᵢ fint).2 fun i hi => bounded_ball
#align totally_bounded.bounded TotallyBounded.bounded
-/
#print IsCompact.bounded /-
/-- A compact set is bounded -/
theorem IsCompact.bounded {s : Set α} (h : IsCompact s) : Bounded s :=
-- A compact set is totally bounded, thus bounded
h.TotallyBounded.Bounded
#align is_compact.bounded IsCompact.bounded
-/
#print Metric.bounded_of_finite /-
/-- A finite set is bounded -/
theorem bounded_of_finite {s : Set α} (h : s.Finite) : Bounded s :=
h.IsCompact.Bounded
#align metric.bounded_of_finite Metric.bounded_of_finite
-/
alias bounded_of_finite ← _root_.set.finite.bounded
#align set.finite.bounded Set.Finite.bounded
#print Metric.bounded_singleton /-
/-- A singleton is bounded -/
theorem bounded_singleton {x : α} : Bounded ({x} : Set α) :=
bounded_of_finite <| finite_singleton _
#align metric.bounded_singleton Metric.bounded_singleton
-/
/- warning: metric.bounded_range_iff -> Metric.bounded_range_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α}, Iff (Metric.Bounded.{u1} α _inst_1 (Set.range.{u1, succ u2} α β f)) (Exists.{1} Real (fun (C : Real) => forall (x : β) (y : β), LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f y)) C))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] {f : β -> α}, Iff (Metric.Bounded.{u1} α _inst_1 (Set.range.{u1, succ u2} α β f)) (Exists.{1} Real (fun (C : Real) => forall (x : β) (y : β), LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) (f x) (f y)) C))
Case conversion may be inaccurate. Consider using '#align metric.bounded_range_iff Metric.bounded_range_iffₓ'. -/
/-- Characterization of the boundedness of the range of a function -/
theorem bounded_range_iff {f : β → α} : Bounded (range f) ↔ ∃ C, ∀ x y, dist (f x) (f y) ≤ C :=
exists_congr fun C =>
⟨fun H x y => H _ ⟨x, rfl⟩ _ ⟨y, rfl⟩, by rintro H _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ <;> exact H x y⟩
#align metric.bounded_range_iff Metric.bounded_range_iff
#print Metric.bounded_range_of_tendsto_cofinite_uniformity /-
theorem bounded_range_of_tendsto_cofinite_uniformity {f : β → α}
(hf : Tendsto (Prod.map f f) (cofinite ×ᶠ cofinite) (𝓤 α)) : Bounded (range f) :=
by
rcases(has_basis_cofinite.prod_self.tendsto_iff uniformity_basis_dist).1 hf 1 zero_lt_one with
⟨s, hsf, hs1⟩
rw [← image_univ, ← union_compl_self s, image_union, bounded_union]
use (hsf.image f).Bounded, 1
rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩
exact le_of_lt (hs1 (x, y) ⟨hx, hy⟩)
#align metric.bounded_range_of_tendsto_cofinite_uniformity Metric.bounded_range_of_tendsto_cofinite_uniformity
-/
#print Metric.bounded_range_of_cauchy_map_cofinite /-
theorem bounded_range_of_cauchy_map_cofinite {f : β → α} (hf : Cauchy (map f cofinite)) :
Bounded (range f) :=
bounded_range_of_tendsto_cofinite_uniformity <| (cauchy_map_iff.1 hf).2
#align metric.bounded_range_of_cauchy_map_cofinite Metric.bounded_range_of_cauchy_map_cofinite
-/
#print CauchySeq.bounded_range /-
theorem CauchySeq.bounded_range {f : ℕ → α} (hf : CauchySeq f) : Bounded (range f) :=
bounded_range_of_cauchy_map_cofinite <| by rwa [Nat.cofinite_eq_atTop]
#align cauchy_seq.bounded_range CauchySeq.bounded_range
-/
#print Metric.bounded_range_of_tendsto_cofinite /-
theorem bounded_range_of_tendsto_cofinite {f : β → α} {a : α} (hf : Tendsto f cofinite (𝓝 a)) :
Bounded (range f) :=
bounded_range_of_tendsto_cofinite_uniformity <|
(hf.Prod_map hf).mono_right <| nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)
#align metric.bounded_range_of_tendsto_cofinite Metric.bounded_range_of_tendsto_cofinite
-/
#print Metric.bounded_of_compactSpace /-
/-- In a compact space, all sets are bounded -/
theorem bounded_of_compactSpace [CompactSpace α] : Bounded s :=
isCompact_univ.Bounded.mono (subset_univ _)
#align metric.bounded_of_compact_space Metric.bounded_of_compactSpace
-/
#print Metric.bounded_range_of_tendsto /-
theorem bounded_range_of_tendsto (u : ℕ → α) {x : α} (hu : Tendsto u atTop (𝓝 x)) :
Bounded (range u) :=
hu.CauchySeq.bounded_range
#align metric.bounded_range_of_tendsto Metric.bounded_range_of_tendsto
-/
/- warning: metric.exists_is_open_bounded_image_inter_of_is_compact_of_forall_continuous_within_at -> Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_forall_continuousWithinAt is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {k : Set.{u2} β} {s : Set.{u2} β} {f : β -> α}, (IsCompact.{u2} β _inst_2 k) -> (forall (x : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x k) -> (ContinuousWithinAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s x)) -> (Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.hasSubset.{u2} β) k t) (And (IsOpen.{u2} β _inst_2 t) (Metric.Bounded.{u1} α _inst_1 (Set.image.{u2, u1} β α f (Inter.inter.{u2} (Set.{u2} β) (Set.hasInter.{u2} β) t s))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {k : Set.{u2} β} {s : Set.{u2} β} {f : β -> α}, (IsCompact.{u2} β _inst_2 k) -> (forall (x : β), (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) x k) -> (ContinuousWithinAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s x)) -> (Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.instHasSubsetSet.{u2} β) k t) (And (IsOpen.{u2} β _inst_2 t) (Metric.Bounded.{u1} α _inst_1 (Set.image.{u2, u1} β α f (Inter.inter.{u2} (Set.{u2} β) (Set.instInterSet.{u2} β) t s))))))
Case conversion may be inaccurate. Consider using '#align metric.exists_is_open_bounded_image_inter_of_is_compact_of_forall_continuous_within_at Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_forall_continuousWithinAtₓ'. -/
/-- If a function is continuous within a set `s` at every point of a compact set `k`, then it is
bounded on some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_bounded_image_inter_of_isCompact_of_forall_continuousWithinAt
[TopologicalSpace β] {k s : Set β} {f : β → α} (hk : IsCompact k)
(hf : ∀ x ∈ k, ContinuousWithinAt f s x) : ∃ t, k ⊆ t ∧ IsOpen t ∧ Bounded (f '' (t ∩ s)) :=
by
apply hk.induction_on
· exact ⟨∅, subset.refl _, isOpen_empty, by simp only [image_empty, bounded_empty, empty_inter]⟩
· rintro s s' hss' ⟨t, s't, t_open, t_bounded⟩
exact ⟨t, hss'.trans s't, t_open, t_bounded⟩
· rintro s s' ⟨t, st, t_open, t_bounded⟩ ⟨t', s't', t'_open, t'_bounded⟩
refine' ⟨t ∪ t', union_subset_union st s't', t_open.union t'_open, _⟩
rw [union_inter_distrib_right, image_union]
exact t_bounded.union t'_bounded
· intro x hx
have A : ball (f x) 1 ∈ 𝓝 (f x) := ball_mem_nhds _ zero_lt_one
have B : f ⁻¹' ball (f x) 1 ∈ 𝓝[s] x := hf x hx A
obtain ⟨u, u_open, xu, uf⟩ : ∃ u : Set β, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' ball (f x) 1
exact _root_.mem_nhds_within.1 B
refine' ⟨u, _, u, subset.refl _, u_open, _⟩
· apply nhdsWithin_le_nhds
exact u_open.mem_nhds xu
· apply bounded.mono (image_subset _ uf)
exact bounded_ball.mono (image_preimage_subset _ _)
#align metric.exists_is_open_bounded_image_inter_of_is_compact_of_forall_continuous_within_at Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_forall_continuousWithinAt
#print Metric.exists_isOpen_bounded_image_of_isCompact_of_forall_continuousAt /-
/-- If a function is continuous at every point of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_bounded_image_of_isCompact_of_forall_continuousAt [TopologicalSpace β]
{k : Set β} {f : β → α} (hk : IsCompact k) (hf : ∀ x ∈ k, ContinuousAt f x) :
∃ t, k ⊆ t ∧ IsOpen t ∧ Bounded (f '' t) :=
by
simp_rw [← continuousWithinAt_univ] at hf
simpa only [inter_univ] using
exists_is_open_bounded_image_inter_of_is_compact_of_forall_continuous_within_at hk hf
#align metric.exists_is_open_bounded_image_of_is_compact_of_forall_continuous_at Metric.exists_isOpen_bounded_image_of_isCompact_of_forall_continuousAt
-/
/- warning: metric.exists_is_open_bounded_image_inter_of_is_compact_of_continuous_on -> Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_continuousOn is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {k : Set.{u2} β} {s : Set.{u2} β} {f : β -> α}, (IsCompact.{u2} β _inst_2 k) -> (HasSubset.Subset.{u2} (Set.{u2} β) (Set.hasSubset.{u2} β) k s) -> (ContinuousOn.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s) -> (Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.hasSubset.{u2} β) k t) (And (IsOpen.{u2} β _inst_2 t) (Metric.Bounded.{u1} α _inst_1 (Set.image.{u2, u1} β α f (Inter.inter.{u2} (Set.{u2} β) (Set.hasInter.{u2} β) t s))))))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {k : Set.{u2} β} {s : Set.{u2} β} {f : β -> α}, (IsCompact.{u2} β _inst_2 k) -> (HasSubset.Subset.{u2} (Set.{u2} β) (Set.instHasSubsetSet.{u2} β) k s) -> (ContinuousOn.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) f s) -> (Exists.{succ u2} (Set.{u2} β) (fun (t : Set.{u2} β) => And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.instHasSubsetSet.{u2} β) k t) (And (IsOpen.{u2} β _inst_2 t) (Metric.Bounded.{u1} α _inst_1 (Set.image.{u2, u1} β α f (Inter.inter.{u2} (Set.{u2} β) (Set.instInterSet.{u2} β) t s))))))
Case conversion may be inaccurate. Consider using '#align metric.exists_is_open_bounded_image_inter_of_is_compact_of_continuous_on Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_continuousOnₓ'. -/
/-- If a function is continuous on a set `s` containing a compact set `k`, then it is bounded on
some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_bounded_image_inter_of_isCompact_of_continuousOn [TopologicalSpace β]
{k s : Set β} {f : β → α} (hk : IsCompact k) (hks : k ⊆ s) (hf : ContinuousOn f s) :
∃ t, k ⊆ t ∧ IsOpen t ∧ Bounded (f '' (t ∩ s)) :=
exists_isOpen_bounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk fun x hx =>
hf x (hks hx)
#align metric.exists_is_open_bounded_image_inter_of_is_compact_of_continuous_on Metric.exists_isOpen_bounded_image_inter_of_isCompact_of_continuousOn
#print Metric.exists_isOpen_bounded_image_of_isCompact_of_continuousOn /-
/-- If a function is continuous on a neighborhood of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_bounded_image_of_isCompact_of_continuousOn [TopologicalSpace β] {k s : Set β}
{f : β → α} (hk : IsCompact k) (hs : IsOpen s) (hks : k ⊆ s) (hf : ContinuousOn f s) :
∃ t, k ⊆ t ∧ IsOpen t ∧ Bounded (f '' t) :=
exists_isOpen_bounded_image_of_isCompact_of_forall_continuousAt hk fun x hx =>
hf.ContinuousAt (hs.mem_nhds (hks hx))
#align metric.exists_is_open_bounded_image_of_is_compact_of_continuous_on Metric.exists_isOpen_bounded_image_of_isCompact_of_continuousOn
-/
#print Metric.isCompact_of_isClosed_bounded /-
/-- The **Heine–Borel theorem**: In a proper space, a closed bounded set is compact. -/
theorem isCompact_of_isClosed_bounded [ProperSpace α] (hc : IsClosed s) (hb : Bounded s) :
IsCompact s := by
rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩)
· exact isCompact_empty
· rcases hb.subset_ball x with ⟨r, hr⟩
exact isCompact_of_isClosed_subset (is_compact_closed_ball x r) hc hr
#align metric.is_compact_of_is_closed_bounded Metric.isCompact_of_isClosed_bounded
-/
#print Metric.Bounded.isCompact_closure /-
/-- The **Heine–Borel theorem**: In a proper space, the closure of a bounded set is compact. -/
theorem Bounded.isCompact_closure [ProperSpace α] (h : Bounded s) : IsCompact (closure s) :=
isCompact_of_isClosed_bounded isClosed_closure h.closure
#align metric.bounded.is_compact_closure Metric.Bounded.isCompact_closure
-/
#print Metric.isCompact_iff_isClosed_bounded /-
/-- The **Heine–Borel theorem**:
In a proper Hausdorff space, a set is compact if and only if it is closed and bounded. -/
theorem isCompact_iff_isClosed_bounded [T2Space α] [ProperSpace α] :
IsCompact s ↔ IsClosed s ∧ Bounded s :=
⟨fun h => ⟨h.IsClosed, h.Bounded⟩, fun h => isCompact_of_isClosed_bounded h.1 h.2⟩
#align metric.is_compact_iff_is_closed_bounded Metric.isCompact_iff_isClosed_bounded
-/
#print Metric.compactSpace_iff_bounded_univ /-
theorem compactSpace_iff_bounded_univ [ProperSpace α] : CompactSpace α ↔ Bounded (univ : Set α) :=
⟨@bounded_of_compactSpace α _ _, fun hb => ⟨isCompact_of_isClosed_bounded isClosed_univ hb⟩⟩
#align metric.compact_space_iff_bounded_univ Metric.compactSpace_iff_bounded_univ
-/
section ConditionallyCompleteLinearOrder
variable [Preorder α] [CompactIccSpace α]
#print Metric.bounded_Icc /-
theorem bounded_Icc (a b : α) : Bounded (Icc a b) :=
(totallyBounded_Icc a b).Bounded
#align metric.bounded_Icc Metric.bounded_Icc
-/
#print Metric.bounded_Ico /-
theorem bounded_Ico (a b : α) : Bounded (Ico a b) :=
(totallyBounded_Ico a b).Bounded
#align metric.bounded_Ico Metric.bounded_Ico
-/
#print Metric.bounded_Ioc /-
theorem bounded_Ioc (a b : α) : Bounded (Ioc a b) :=
(totallyBounded_Ioc a b).Bounded
#align metric.bounded_Ioc Metric.bounded_Ioc
-/
#print Metric.bounded_Ioo /-
theorem bounded_Ioo (a b : α) : Bounded (Ioo a b) :=
(totallyBounded_Ioo a b).Bounded
#align metric.bounded_Ioo Metric.bounded_Ioo
-/
#print Metric.bounded_of_bddAbove_of_bddBelow /-
/-- In a pseudo metric space with a conditionally complete linear order such that the order and the
metric structure give the same topology, any order-bounded set is metric-bounded. -/
theorem bounded_of_bddAbove_of_bddBelow {s : Set α} (h₁ : BddAbove s) (h₂ : BddBelow s) :
Bounded s :=
let ⟨u, hu⟩ := h₁
let ⟨l, hl⟩ := h₂
Bounded.mono (fun x hx => mem_Icc.mpr ⟨hl hx, hu hx⟩) (bounded_Icc l u)
#align metric.bounded_of_bdd_above_of_bdd_below Metric.bounded_of_bddAbove_of_bddBelow
-/
end ConditionallyCompleteLinearOrder
end Bounded
section Diam
variable {s : Set α} {x y z : α}
#print Metric.diam /-
/-- The diameter of a set in a metric space. To get controllable behavior even when the diameter
should be infinite, we express it in terms of the emetric.diameter -/
noncomputable def diam (s : Set α) : ℝ :=
ENNReal.toReal (EMetric.diam s)
#align metric.diam Metric.diam
-/
/- warning: metric.diam_nonneg -> Metric.diam_nonneg is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Metric.diam.{u1} α _inst_1 s)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Metric.diam.{u1} α _inst_1 s)
Case conversion may be inaccurate. Consider using '#align metric.diam_nonneg Metric.diam_nonnegₓ'. -/
/-- The diameter of a set is always nonnegative -/
theorem diam_nonneg : 0 ≤ diam s :=
ENNReal.toReal_nonneg
#align metric.diam_nonneg Metric.diam_nonneg
/- warning: metric.diam_subsingleton -> Metric.diam_subsingleton is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Set.Subsingleton.{u1} α s) -> (Eq.{1} Real (Metric.diam.{u1} α _inst_1 s) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Set.Subsingleton.{u1} α s) -> (Eq.{1} Real (Metric.diam.{u1} α _inst_1 s) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))
Case conversion may be inaccurate. Consider using '#align metric.diam_subsingleton Metric.diam_subsingletonₓ'. -/
theorem diam_subsingleton (hs : s.Subsingleton) : diam s = 0 := by
simp only [diam, EMetric.diam_subsingleton hs, ENNReal.zero_toReal]
#align metric.diam_subsingleton Metric.diam_subsingleton
/- warning: metric.diam_empty -> Metric.diam_empty is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{1} Real (Metric.diam.{u1} α _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α))) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α], Eq.{1} Real (Metric.diam.{u1} α _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α))) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))
Case conversion may be inaccurate. Consider using '#align metric.diam_empty Metric.diam_emptyₓ'. -/
/-- The empty set has zero diameter -/
@[simp]
theorem diam_empty : diam (∅ : Set α) = 0 :=
diam_subsingleton subsingleton_empty
#align metric.diam_empty Metric.diam_empty
/- warning: metric.diam_singleton -> Metric.diam_singleton is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α}, Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))
Case conversion may be inaccurate. Consider using '#align metric.diam_singleton Metric.diam_singletonₓ'. -/
/-- A singleton has zero diameter -/
@[simp]
theorem diam_singleton : diam ({x} : Set α) = 0 :=
diam_subsingleton subsingleton_singleton
#align metric.diam_singleton Metric.diam_singleton
#print Metric.diam_pair /-
-- Does not work as a simp-lemma, since {x, y} reduces to (insert y {x})
theorem diam_pair : diam ({x, y} : Set α) = dist x y := by
simp only [diam, EMetric.diam_pair, dist_edist]
#align metric.diam_pair Metric.diam_pair
-/
/- warning: metric.diam_triple -> Metric.diam_triple is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {z : α}, Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Insert.insert.{u1, u1} α (Set.{u1} α) (Set.hasInsert.{u1} α) x (Insert.insert.{u1, u1} α (Set.{u1} α) (Set.hasInsert.{u1} α) y (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) z)))) (LinearOrder.max.{0} Real Real.linearOrder (LinearOrder.max.{0} Real Real.linearOrder (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x z)) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y z))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {y : α} {z : α}, Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Insert.insert.{u1, u1} α (Set.{u1} α) (Set.instInsertSet.{u1} α) x (Insert.insert.{u1, u1} α (Set.{u1} α) (Set.instInsertSet.{u1} α) y (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) z)))) (Max.max.{0} Real (LinearOrderedRing.toMax.{0} Real Real.instLinearOrderedRingReal) (Max.max.{0} Real (LinearOrderedRing.toMax.{0} Real Real.instLinearOrderedRingReal) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x z)) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y z))
Case conversion may be inaccurate. Consider using '#align metric.diam_triple Metric.diam_tripleₓ'. -/
-- Does not work as a simp-lemma, since {x, y, z} reduces to (insert z (insert y {x}))
theorem diam_triple :
Metric.diam ({x, y, z} : Set α) = max (max (dist x y) (dist x z)) (dist y z) :=
by
simp only [Metric.diam, EMetric.diam_triple, dist_edist]
rw [ENNReal.toReal_max, ENNReal.toReal_max] <;> apply_rules [ne_of_lt, edist_lt_top, max_lt]
#align metric.diam_triple Metric.diam_triple
/- warning: metric.ediam_le_of_forall_dist_le -> Metric.ediam_le_of_forall_dist_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {C : Real}, (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))) (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (ENNReal.ofReal C))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {C : Real}, (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} ENNReal (Preorder.toLE.{0} ENNReal (PartialOrder.toPreorder.{0} ENNReal (CompleteSemilatticeInf.toPartialOrder.{0} ENNReal (CompleteLattice.toCompleteSemilatticeInf.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))) (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (ENNReal.ofReal C))
Case conversion may be inaccurate. Consider using '#align metric.ediam_le_of_forall_dist_le Metric.ediam_le_of_forall_dist_leₓ'. -/
/-- If the distance between any two points in a set is bounded by some constant `C`,
then `ennreal.of_real C` bounds the emetric diameter of this set. -/
theorem ediam_le_of_forall_dist_le {C : ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) :
EMetric.diam s ≤ ENNReal.ofReal C :=
EMetric.diam_le fun x hx y hy => (edist_dist x y).symm ▸ ENNReal.ofReal_le_ofReal (h x hx y hy)
#align metric.ediam_le_of_forall_dist_le Metric.ediam_le_of_forall_dist_le
/- warning: metric.diam_le_of_forall_dist_le -> Metric.diam_le_of_forall_dist_le is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {C : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) C) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 s) C)
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {C : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) C) -> (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 s) C)
Case conversion may be inaccurate. Consider using '#align metric.diam_le_of_forall_dist_le Metric.diam_le_of_forall_dist_leₓ'. -/
/-- If the distance between any two points in a set is bounded by some non-negative constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le {C : ℝ} (h₀ : 0 ≤ C) (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) :
diam s ≤ C :=
ENNReal.toReal_le_of_le_ofReal h₀ (ediam_le_of_forall_dist_le h)
#align metric.diam_le_of_forall_dist_le Metric.diam_le_of_forall_dist_le
/- warning: metric.diam_le_of_forall_dist_le_of_nonempty -> Metric.diam_le_of_forall_dist_le_of_nonempty is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (forall {C : Real}, (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 s) C))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (forall {C : Real}, (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) C))) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 s) C))
Case conversion may be inaccurate. Consider using '#align metric.diam_le_of_forall_dist_le_of_nonempty Metric.diam_le_of_forall_dist_le_of_nonemptyₓ'. -/
/-- If the distance between any two points in a nonempty set is bounded by some constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le_of_nonempty (hs : s.Nonempty) {C : ℝ}
(h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) : diam s ≤ C :=
have h₀ : 0 ≤ C :=
let ⟨x, hx⟩ := hs
le_trans dist_nonneg (h x hx x hx)
diam_le_of_forall_dist_le h₀ h
#align metric.diam_le_of_forall_dist_le_of_nonempty Metric.diam_le_of_forall_dist_le_of_nonempty
/- warning: metric.dist_le_diam_of_mem' -> Metric.dist_le_diam_of_mem' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α}, (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (Metric.diam.{u1} α _inst_1 s))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α}, (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (Metric.diam.{u1} α _inst_1 s))
Case conversion may be inaccurate. Consider using '#align metric.dist_le_diam_of_mem' Metric.dist_le_diam_of_mem'ₓ'. -/
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem' (h : EMetric.diam s ≠ ⊤) (hx : x ∈ s) (hy : y ∈ s) :
dist x y ≤ diam s := by
rw [diam, dist_edist]
rw [ENNReal.toReal_le_toReal (edist_ne_top _ _) h]
exact EMetric.edist_le_diam_of_mem hx hy
#align metric.dist_le_diam_of_mem' Metric.dist_le_diam_of_mem'
/- warning: metric.bounded_iff_ediam_ne_top -> Metric.bounded_iff_ediam_ne_top is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Metric.Bounded.{u1} α _inst_1 s) (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, Iff (Metric.Bounded.{u1} α _inst_1 s) (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))
Case conversion may be inaccurate. Consider using '#align metric.bounded_iff_ediam_ne_top Metric.bounded_iff_ediam_ne_topₓ'. -/
/-- Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter. -/
theorem bounded_iff_ediam_ne_top : Bounded s ↔ EMetric.diam s ≠ ⊤ :=
Iff.intro
(fun ⟨C, hC⟩ => ne_top_of_le_ne_top ENNReal.ofReal_ne_top <| ediam_le_of_forall_dist_le hC)
fun h => ⟨diam s, fun x hx y hy => dist_le_diam_of_mem' h hx hy⟩
#align metric.bounded_iff_ediam_ne_top Metric.bounded_iff_ediam_ne_top
/- warning: metric.bounded.ediam_ne_top -> Metric.Bounded.ediam_ne_top is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Ne.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))
Case conversion may be inaccurate. Consider using '#align metric.bounded.ediam_ne_top Metric.Bounded.ediam_ne_topₓ'. -/
theorem Bounded.ediam_ne_top (h : Bounded s) : EMetric.diam s ≠ ⊤ :=
bounded_iff_ediam_ne_top.1 h
#align metric.bounded.ediam_ne_top Metric.Bounded.ediam_ne_top
/- warning: metric.ediam_univ_eq_top_iff_noncompact -> Metric.ediam_univ_eq_top_iff_noncompact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1], Iff (Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) (Set.univ.{u1} α)) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) (NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1], Iff (Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) (Set.univ.{u1} α)) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) (NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align metric.ediam_univ_eq_top_iff_noncompact Metric.ediam_univ_eq_top_iff_noncompactₓ'. -/
theorem ediam_univ_eq_top_iff_noncompact [ProperSpace α] :
EMetric.diam (univ : Set α) = ∞ ↔ NoncompactSpace α := by
rw [← not_compactSpace_iff, compact_space_iff_bounded_univ, bounded_iff_ediam_ne_top,
Classical.not_not]
#align metric.ediam_univ_eq_top_iff_noncompact Metric.ediam_univ_eq_top_iff_noncompact
/- warning: metric.ediam_univ_of_noncompact -> Metric.ediam_univ_of_noncompact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))], Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) (Set.univ.{u1} α)) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))], Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) (Set.univ.{u1} α)) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))
Case conversion may be inaccurate. Consider using '#align metric.ediam_univ_of_noncompact Metric.ediam_univ_of_noncompactₓ'. -/
@[simp]
theorem ediam_univ_of_noncompact [ProperSpace α] [NoncompactSpace α] :
EMetric.diam (univ : Set α) = ∞ :=
ediam_univ_eq_top_iff_noncompact.mpr ‹_›
#align metric.ediam_univ_of_noncompact Metric.ediam_univ_of_noncompact
/- warning: metric.diam_univ_of_noncompact -> Metric.diam_univ_of_noncompact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))], Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Set.univ.{u1} α)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : NoncompactSpace.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1))], Eq.{1} Real (Metric.diam.{u1} α _inst_1 (Set.univ.{u1} α)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))
Case conversion may be inaccurate. Consider using '#align metric.diam_univ_of_noncompact Metric.diam_univ_of_noncompactₓ'. -/
@[simp]
theorem diam_univ_of_noncompact [ProperSpace α] [NoncompactSpace α] : diam (univ : Set α) = 0 := by
simp [diam]
#align metric.diam_univ_of_noncompact Metric.diam_univ_of_noncompact
/- warning: metric.dist_le_diam_of_mem -> Metric.dist_le_diam_of_mem is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y) (Metric.diam.{u1} α _inst_1 s))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α}, (Metric.Bounded.{u1} α _inst_1 s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y) (Metric.diam.{u1} α _inst_1 s))
Case conversion may be inaccurate. Consider using '#align metric.dist_le_diam_of_mem Metric.dist_le_diam_of_memₓ'. -/
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem (h : Bounded s) (hx : x ∈ s) (hy : y ∈ s) : dist x y ≤ diam s :=
dist_le_diam_of_mem' h.ediam_ne_top hx hy
#align metric.dist_le_diam_of_mem Metric.dist_le_diam_of_mem
/- warning: metric.ediam_of_unbounded -> Metric.ediam_of_unbounded is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Not (Metric.Bounded.{u1} α _inst_1 s)) -> (Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Not (Metric.Bounded.{u1} α _inst_1 s)) -> (Eq.{1} ENNReal (EMetric.diam.{u1} α (PseudoMetricSpace.toPseudoEMetricSpace.{u1} α _inst_1) s) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal))))
Case conversion may be inaccurate. Consider using '#align metric.ediam_of_unbounded Metric.ediam_of_unboundedₓ'. -/
theorem ediam_of_unbounded (h : ¬Bounded s) : EMetric.diam s = ∞ := by
rwa [bounded_iff_ediam_ne_top, Classical.not_not] at h
#align metric.ediam_of_unbounded Metric.ediam_of_unbounded
/- warning: metric.diam_eq_zero_of_unbounded -> Metric.diam_eq_zero_of_unbounded is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Not (Metric.Bounded.{u1} α _inst_1 s)) -> (Eq.{1} Real (Metric.diam.{u1} α _inst_1 s) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α}, (Not (Metric.Bounded.{u1} α _inst_1 s)) -> (Eq.{1} Real (Metric.diam.{u1} α _inst_1 s) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))
Case conversion may be inaccurate. Consider using '#align metric.diam_eq_zero_of_unbounded Metric.diam_eq_zero_of_unboundedₓ'. -/
/-- An unbounded set has zero diameter. If you would prefer to get the value ∞, use `emetric.diam`.
This lemma makes it possible to avoid side conditions in some situations -/
theorem diam_eq_zero_of_unbounded (h : ¬Bounded s) : diam s = 0 := by
rw [diam, ediam_of_unbounded h, ENNReal.top_toReal]
#align metric.diam_eq_zero_of_unbounded Metric.diam_eq_zero_of_unbounded
/- warning: metric.diam_mono -> Metric.diam_mono is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s t) -> (Metric.Bounded.{u1} α _inst_1 t) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 s) (Metric.diam.{u1} α _inst_1 t))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s t) -> (Metric.Bounded.{u1} α _inst_1 t) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 s) (Metric.diam.{u1} α _inst_1 t))
Case conversion may be inaccurate. Consider using '#align metric.diam_mono Metric.diam_monoₓ'. -/
/-- If `s ⊆ t`, then the diameter of `s` is bounded by that of `t`, provided `t` is bounded. -/
theorem diam_mono {s t : Set α} (h : s ⊆ t) (ht : Bounded t) : diam s ≤ diam t :=
by
unfold diam
rw [ENNReal.toReal_le_toReal (bounded.mono h ht).ediam_ne_top ht.ediam_ne_top]
exact EMetric.diam_mono h
#align metric.diam_mono Metric.diam_mono
/- warning: metric.diam_union -> Metric.diam_union is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α} {t : Set.{u1} α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Metric.diam.{u1} α _inst_1 s) (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x y)) (Metric.diam.{u1} α _inst_1 t)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {y : α} {t : Set.{u1} α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Metric.diam.{u1} α _inst_1 s) (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x y)) (Metric.diam.{u1} α _inst_1 t)))
Case conversion may be inaccurate. Consider using '#align metric.diam_union Metric.diam_unionₓ'. -/
/-- The diameter of a union is controlled by the sum of the diameters, and the distance between
any two points in each of the sets. This lemma is true without any side condition, since it is
obviously true if `s ∪ t` is unbounded. -/
theorem diam_union {t : Set α} (xs : x ∈ s) (yt : y ∈ t) :
diam (s ∪ t) ≤ diam s + dist x y + diam t :=
by
by_cases H : bounded (s ∪ t)
· have hs : bounded s := H.mono (subset_union_left _ _)
have ht : bounded t := H.mono (subset_union_right _ _)
rw [bounded_iff_ediam_ne_top] at H hs ht
rw [dist_edist, diam, diam, diam, ← ENNReal.toReal_add, ← ENNReal.toReal_add,
ENNReal.toReal_le_toReal] <;>
repeat' apply ENNReal.add_ne_top.2 <;> constructor <;>
try assumption <;>
try apply edist_ne_top
exact EMetric.diam_union xs yt
· rw [diam_eq_zero_of_unbounded H]
apply_rules [add_nonneg, diam_nonneg, dist_nonneg]
#align metric.diam_union Metric.diam_union
/- warning: metric.diam_union' -> Metric.diam_union' is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s t)) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Metric.diam.{u1} α _inst_1 s) (Metric.diam.{u1} α _inst_1 t)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s t)) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Metric.diam.{u1} α _inst_1 s) (Metric.diam.{u1} α _inst_1 t)))
Case conversion may be inaccurate. Consider using '#align metric.diam_union' Metric.diam_union'ₓ'. -/
/-- If two sets intersect, the diameter of the union is bounded by the sum of the diameters. -/
theorem diam_union' {t : Set α} (h : (s ∩ t).Nonempty) : diam (s ∪ t) ≤ diam s + diam t :=
by
rcases h with ⟨x, ⟨xs, xt⟩⟩
simpa using diam_union xs xt
#align metric.diam_union' Metric.diam_union'
/- warning: metric.diam_le_of_subset_closed_ball -> Metric.diam_le_of_subset_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Metric.closedBall.{u1} α _inst_1 x r)) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 s) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) r))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Set.{u1} α} {x : α} {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Metric.closedBall.{u1} α _inst_1 x r)) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 s) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) r))
Case conversion may be inaccurate. Consider using '#align metric.diam_le_of_subset_closed_ball Metric.diam_le_of_subset_closedBallₓ'. -/
theorem diam_le_of_subset_closedBall {r : ℝ} (hr : 0 ≤ r) (h : s ⊆ closedBall x r) :
diam s ≤ 2 * r :=
diam_le_of_forall_dist_le (mul_nonneg zero_le_two hr) fun a ha b hb =>
calc
dist a b ≤ dist a x + dist b x := dist_triangle_right _ _ _
_ ≤ r + r := (add_le_add (h ha) (h hb))
_ = 2 * r := by simp [mul_two, mul_comm]
#align metric.diam_le_of_subset_closed_ball Metric.diam_le_of_subset_closedBall
/- warning: metric.diam_closed_ball -> Metric.diam_closedBall is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 (Metric.closedBall.{u1} α _inst_1 x r)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) r))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 (Metric.closedBall.{u1} α _inst_1 x r)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) r))
Case conversion may be inaccurate. Consider using '#align metric.diam_closed_ball Metric.diam_closedBallₓ'. -/
/-- The diameter of a closed ball of radius `r` is at most `2 r`. -/
theorem diam_closedBall {r : ℝ} (h : 0 ≤ r) : diam (closedBall x r) ≤ 2 * r :=
diam_le_of_subset_closedBall h Subset.rfl
#align metric.diam_closed_ball Metric.diam_closedBall
/- warning: metric.diam_ball -> Metric.diam_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) r) -> (LE.le.{0} Real Real.hasLe (Metric.diam.{u1} α _inst_1 (Metric.ball.{u1} α _inst_1 x r)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) r))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {x : α} {r : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) r) -> (LE.le.{0} Real Real.instLEReal (Metric.diam.{u1} α _inst_1 (Metric.ball.{u1} α _inst_1 x r)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) r))
Case conversion may be inaccurate. Consider using '#align metric.diam_ball Metric.diam_ballₓ'. -/
/-- The diameter of a ball of radius `r` is at most `2 r`. -/
theorem diam_ball {r : ℝ} (h : 0 ≤ r) : diam (ball x r) ≤ 2 * r :=
diam_le_of_subset_closedBall h ball_subset_closedBall
#align metric.diam_ball Metric.diam_ball
/- warning: is_complete.nonempty_Inter_of_nonempty_bInter -> IsComplete.nonempty_interᵢ_of_nonempty_bInter is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Nat -> (Set.{u1} α)}, (IsComplete.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (s (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) -> (forall (n : Nat), IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (s n)) -> (forall (n : Nat), Metric.Bounded.{u1} α _inst_1 (s n)) -> (forall (N : Nat), Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => Set.interᵢ.{u1, 0} α (LE.le.{0} Nat Nat.hasLe n N) (fun (H : LE.le.{0} Nat Nat.hasLe n N) => s n)))) -> (Filter.Tendsto.{0, 0} Nat Real (fun (n : Nat) => Metric.diam.{u1} α _inst_1 (s n)) (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => s n)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {s : Nat -> (Set.{u1} α)}, (IsComplete.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) (s (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) -> (forall (n : Nat), IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (s n)) -> (forall (n : Nat), Metric.Bounded.{u1} α _inst_1 (s n)) -> (forall (N : Nat), Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => Set.interᵢ.{u1, 0} α (LE.le.{0} Nat instLENat n N) (fun (H : LE.le.{0} Nat instLENat n N) => s n)))) -> (Filter.Tendsto.{0, 0} Nat Real (fun (n : Nat) => Metric.diam.{u1} α _inst_1 (s n)) (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => s n)))
Case conversion may be inaccurate. Consider using '#align is_complete.nonempty_Inter_of_nonempty_bInter IsComplete.nonempty_interᵢ_of_nonempty_bInterₓ'. -/
/-- If a family of complete sets with diameter tending to `0` is such that each finite intersection
is nonempty, then the total intersection is also nonempty. -/
theorem IsComplete.nonempty_interᵢ_of_nonempty_bInter {s : ℕ → Set α} (h0 : IsComplete (s 0))
(hs : ∀ n, IsClosed (s n)) (h's : ∀ n, Bounded (s n)) (h : ∀ N, (⋂ n ≤ N, s n).Nonempty)
(h' : Tendsto (fun n => diam (s n)) atTop (𝓝 0)) : (⋂ n, s n).Nonempty :=
by
let u N := (h N).some
have I : ∀ n N, n ≤ N → u N ∈ s n := by
intro n N hn
apply mem_of_subset_of_mem _ (h N).choose_spec
intro x hx
simp only [mem_Inter] at hx
exact hx n hn
have : ∀ n, u n ∈ s 0 := fun n => I 0 n (zero_le _)
have : CauchySeq u := by
apply cauchySeq_of_le_tendsto_0 _ _ h'
intro m n N hm hn
exact dist_le_diam_of_mem (h's N) (I _ _ hm) (I _ _ hn)
obtain ⟨x, hx, xlim⟩ : ∃ (x : α)(H : x ∈ s 0), tendsto (fun n : ℕ => u n) at_top (𝓝 x) :=
cauchySeq_tendsto_of_isComplete h0 (fun n => I 0 n (zero_le _)) this
refine' ⟨x, mem_Inter.2 fun n => _⟩
apply (hs n).mem_of_tendsto xlim
filter_upwards [Ici_mem_at_top n]with p hp
exact I n p hp
#align is_complete.nonempty_Inter_of_nonempty_bInter IsComplete.nonempty_interᵢ_of_nonempty_bInter
/- warning: metric.nonempty_Inter_of_nonempty_bInter -> Metric.nonempty_interᵢ_of_nonempty_bInter is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : CompleteSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)] {s : Nat -> (Set.{u1} α)}, (forall (n : Nat), IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (s n)) -> (forall (n : Nat), Metric.Bounded.{u1} α _inst_1 (s n)) -> (forall (N : Nat), Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => Set.interᵢ.{u1, 0} α (LE.le.{0} Nat Nat.hasLe n N) (fun (H : LE.le.{0} Nat Nat.hasLe n N) => s n)))) -> (Filter.Tendsto.{0, 0} Nat Real (fun (n : Nat) => Metric.diam.{u1} α _inst_1 (s n)) (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))) -> (Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => s n)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : CompleteSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)] {s : Nat -> (Set.{u1} α)}, (forall (n : Nat), IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (s n)) -> (forall (n : Nat), Metric.Bounded.{u1} α _inst_1 (s n)) -> (forall (N : Nat), Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => Set.interᵢ.{u1, 0} α (LE.le.{0} Nat instLENat n N) (fun (H : LE.le.{0} Nat instLENat n N) => s n)))) -> (Filter.Tendsto.{0, 0} Nat Real (fun (n : Nat) => Metric.diam.{u1} α _inst_1 (s n)) (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{0} Real (UniformSpace.toTopologicalSpace.{0} Real (PseudoMetricSpace.toUniformSpace.{0} Real Real.pseudoMetricSpace)) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))) -> (Set.Nonempty.{u1} α (Set.interᵢ.{u1, 1} α Nat (fun (n : Nat) => s n)))
Case conversion may be inaccurate. Consider using '#align metric.nonempty_Inter_of_nonempty_bInter Metric.nonempty_interᵢ_of_nonempty_bInterₓ'. -/
/-- In a complete space, if a family of closed sets with diameter tending to `0` is such that each
finite intersection is nonempty, then the total intersection is also nonempty. -/
theorem nonempty_interᵢ_of_nonempty_bInter [CompleteSpace α] {s : ℕ → Set α}
(hs : ∀ n, IsClosed (s n)) (h's : ∀ n, Bounded (s n)) (h : ∀ N, (⋂ n ≤ N, s n).Nonempty)
(h' : Tendsto (fun n => diam (s n)) atTop (𝓝 0)) : (⋂ n, s n).Nonempty :=
(hs 0).IsComplete.nonempty_interᵢ_of_nonempty_bInter hs h's h h'
#align metric.nonempty_Inter_of_nonempty_bInter Metric.nonempty_interᵢ_of_nonempty_bInter
end Diam
/- warning: metric.exists_local_min_mem_ball -> Metric.exists_local_min_mem_ball is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : TopologicalSpace.{u2} β] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : OrderTopology.{u2} β _inst_3 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {a : α} {z : α} {r : Real}, (ContinuousOn.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) _inst_3 f (Metric.closedBall.{u1} α _inst_1 a r)) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z (Metric.closedBall.{u1} α _inst_1 a r)) -> (forall (z' : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z' (Metric.sphere.{u1} α _inst_1 a r)) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))) (f z) (f z'))) -> (Exists.{succ u1} α (fun (z : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z (Metric.ball.{u1} α _inst_1 a r)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z (Metric.ball.{u1} α _inst_1 a r)) => IsLocalMin.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f z)))
but is expected to have type
forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u1} α] [_inst_2 : ProperSpace.{u1} α _inst_1] [_inst_3 : TopologicalSpace.{u2} β] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : OrderTopology.{u2} β _inst_3 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {a : α} {z : α} {r : Real}, (ContinuousOn.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) _inst_3 f (Metric.closedBall.{u1} α _inst_1 a r)) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z (Metric.closedBall.{u1} α _inst_1 a r)) -> (forall (z' : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z' (Metric.sphere.{u1} α _inst_1 a r)) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))) (f z) (f z'))) -> (Exists.{succ u1} α (fun (z : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z (Metric.ball.{u1} α _inst_1 a r)) (IsLocalMin.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f z)))
Case conversion may be inaccurate. Consider using '#align metric.exists_local_min_mem_ball Metric.exists_local_min_mem_ballₓ'. -/
theorem exists_local_min_mem_ball [ProperSpace α] [TopologicalSpace β]
[ConditionallyCompleteLinearOrder β] [OrderTopology β] {f : α → β} {a z : α} {r : ℝ}
(hf : ContinuousOn f (closedBall a r)) (hz : z ∈ closedBall a r)
(hf1 : ∀ z' ∈ sphere a r, f z < f z') : ∃ z ∈ ball a r, IsLocalMin f z :=
by
simp_rw [← closed_ball_diff_ball] at hf1
exact
(is_compact_closed_ball a r).exists_local_min_mem_open ball_subset_closed_ball hf hz hf1
is_open_ball
#align metric.exists_local_min_mem_ball Metric.exists_local_min_mem_ball
end Metric
namespace Tactic
open Positivity
/-- Extension for the `positivity` tactic: the diameter of a set is always nonnegative. -/
@[positivity]
unsafe def positivity_diam : expr → tactic strictness
| q(Metric.diam $(s)) => nonnegative <$> mk_app `` Metric.diam_nonneg [s]
| e => pp e >>= fail ∘ format.bracket "The expression " " is not of the form `metric.diam s`"
#align tactic.positivity_diam tactic.positivity_diam
end Tactic
/- warning: comap_dist_right_at_top_le_cocompact -> comap_dist_right_atTop_le_cocompact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (Filter.comap.{u1, 0} α Real (fun (y : α) => Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) y x) (Filter.atTop.{0} Real Real.preorder)) (Filter.cocompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Filter.comap.{u1, 0} α Real (fun (y : α) => Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) y x) (Filter.atTop.{0} Real Real.instPreorderReal)) (Filter.cocompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align comap_dist_right_at_top_le_cocompact comap_dist_right_atTop_le_cocompactₓ'. -/
theorem comap_dist_right_atTop_le_cocompact (x : α) :
comap (fun y => dist y x) atTop ≤ cocompact α :=
by
refine' filter.has_basis_cocompact.ge_iff.2 fun s hs => mem_comap.2 _
rcases hs.bounded.subset_ball x with ⟨r, hr⟩
exact ⟨Ioi r, Ioi_mem_at_top r, fun y hy hys => (mem_closed_ball.1 <| hr hys).not_lt hy⟩
#align comap_dist_right_at_top_le_cocompact comap_dist_right_atTop_le_cocompact
/- warning: comap_dist_left_at_top_le_cocompact -> comap_dist_left_atTop_le_cocompact is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (Filter.comap.{u1, 0} α Real (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) x) (Filter.atTop.{0} Real Real.preorder)) (Filter.cocompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Filter.comap.{u1, 0} α Real (Dist.dist.{u1} α (PseudoMetricSpace.toDist.{u1} α _inst_1) x) (Filter.atTop.{0} Real Real.instPreorderReal)) (Filter.cocompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align comap_dist_left_at_top_le_cocompact comap_dist_left_atTop_le_cocompactₓ'. -/
theorem comap_dist_left_atTop_le_cocompact (x : α) : comap (dist x) atTop ≤ cocompact α := by
simpa only [dist_comm _ x] using comap_dist_right_atTop_le_cocompact x
#align comap_dist_left_at_top_le_cocompact comap_dist_left_atTop_le_cocompact
#print comap_dist_right_atTop_eq_cocompact /-
theorem comap_dist_right_atTop_eq_cocompact [ProperSpace α] (x : α) :
comap (fun y => dist y x) atTop = cocompact α :=
(comap_dist_right_atTop_le_cocompact x).antisymm <|
(tendsto_dist_right_cocompact_atTop x).le_comap
#align comap_dist_right_at_top_eq_cocompact comap_dist_right_atTop_eq_cocompact
-/
#print comap_dist_left_atTop_eq_cocompact /-
theorem comap_dist_left_atTop_eq_cocompact [ProperSpace α] (x : α) :
comap (dist x) atTop = cocompact α :=
(comap_dist_left_atTop_le_cocompact x).antisymm <| (tendsto_dist_left_cocompact_atTop x).le_comap
#align comap_dist_left_at_top_eq_cocompact comap_dist_left_atTop_eq_cocompact
-/
#print tendsto_cocompact_of_tendsto_dist_comp_atTop /-
theorem tendsto_cocompact_of_tendsto_dist_comp_atTop {f : β → α} {l : Filter β} (x : α)
(h : Tendsto (fun y => dist (f y) x) l atTop) : Tendsto f l (cocompact α) :=
by
refine' tendsto.mono_right _ (comap_dist_right_atTop_le_cocompact x)
rwa [tendsto_comap_iff]
#align tendsto_cocompact_of_tendsto_dist_comp_at_top tendsto_cocompact_of_tendsto_dist_comp_atTop
-/
#print MetricSpace /-
/-- We now define `metric_space`, extending `pseudo_metric_space`. -/
class MetricSpace (α : Type u) extends PseudoMetricSpace α : Type u where
eq_of_dist_eq_zero : ∀ {x y : α}, dist x y = 0 → x = y
#align metric_space MetricSpace
-/
#print MetricSpace.ext /-
/-- Two metric space structures with the same distance coincide. -/
@[ext]
theorem MetricSpace.ext {α : Type _} {m m' : MetricSpace α} (h : m.toHasDist = m'.toHasDist) :
m = m' :=
by
have h' : m.to_pseudo_metric_space = m'.to_pseudo_metric_space := PseudoMetricSpace.ext h
rcases m with ⟨⟩
rcases m' with ⟨⟩
dsimp at h'
subst h'
#align metric_space.ext MetricSpace.ext
-/
/- warning: metric_space.of_dist_topology -> MetricSpace.ofDistTopology is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_2 : TopologicalSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.hasLe (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (dist x y) (dist y z))) -> (forall (s : Set.{u1} α), Iff (IsOpen.{u1} α _inst_2 s) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall (y : α), (LT.lt.{0} Real Real.hasLt (dist x y) ε) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s)))))) -> (forall (x : α) (y : α), (Eq.{1} Real (dist x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{succ u1} α x y)) -> (MetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_2 : TopologicalSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α), Eq.{1} Real (dist x x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (dist y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{0} Real Real.instLEReal (dist x z) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (dist x y) (dist y z))) -> (forall (s : Set.{u1} α), Iff (IsOpen.{u1} α _inst_2 s) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall (y : α), (LT.lt.{0} Real Real.instLTReal (dist x y) ε) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s)))))) -> (forall (x : α) (y : α), (Eq.{1} Real (dist x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{succ u1} α x y)) -> (MetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align metric_space.of_dist_topology MetricSpace.ofDistTopologyₓ'. -/
/-- Construct a metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def MetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s)
(eq_of_dist_eq_zero : ∀ x y : α, dist x y = 0 → x = y) : MetricSpace α :=
{ PseudoMetricSpace.ofDistTopology dist dist_self dist_comm dist_triangle H with
eq_of_dist_eq_zero }
#align metric_space.of_dist_topology MetricSpace.ofDistTopology
variable {γ : Type w} [MetricSpace γ]
/- warning: eq_of_dist_eq_zero -> eq_of_dist_eq_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (Eq.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (Eq.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align eq_of_dist_eq_zero eq_of_dist_eq_zeroₓ'. -/
theorem eq_of_dist_eq_zero {x y : γ} : dist x y = 0 → x = y :=
MetricSpace.eq_of_dist_eq_zero
#align eq_of_dist_eq_zero eq_of_dist_eq_zero
/- warning: dist_eq_zero -> dist_eq_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align dist_eq_zero dist_eq_zeroₓ'. -/
@[simp]
theorem dist_eq_zero {x y : γ} : dist x y = 0 ↔ x = y :=
Iff.intro eq_of_dist_eq_zero fun this : x = y => this ▸ dist_self _
#align dist_eq_zero dist_eq_zero
/- warning: zero_eq_dist -> zero_eq_dist is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} Real (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} Real (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align zero_eq_dist zero_eq_distₓ'. -/
@[simp]
theorem zero_eq_dist {x y : γ} : 0 = dist x y ↔ x = y := by rw [eq_comm, dist_eq_zero]
#align zero_eq_dist zero_eq_dist
/- warning: dist_ne_zero -> dist_ne_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Ne.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Ne.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Ne.{1} Real (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Ne.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align dist_ne_zero dist_ne_zeroₓ'. -/
theorem dist_ne_zero {x y : γ} : dist x y ≠ 0 ↔ x ≠ y := by
simpa only [not_iff_not] using dist_eq_zero
#align dist_ne_zero dist_ne_zero
/- warning: dist_le_zero -> dist_le_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align dist_le_zero dist_le_zeroₓ'. -/
@[simp]
theorem dist_le_zero {x y : γ} : dist x y ≤ 0 ↔ x = y := by
simpa [le_antisymm_iff, dist_nonneg] using @dist_eq_zero _ _ x y
#align dist_le_zero dist_le_zero
/- warning: dist_pos -> dist_pos is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Ne.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Ne.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align dist_pos dist_posₓ'. -/
@[simp]
theorem dist_pos {x y : γ} : 0 < dist x y ↔ x ≠ y := by
simpa only [not_le] using not_congr dist_le_zero
#align dist_pos dist_pos
/- warning: eq_of_forall_dist_le -> eq_of_forall_dist_le is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) ε)) -> (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) ε)) -> (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align eq_of_forall_dist_le eq_of_forall_dist_leₓ'. -/
theorem eq_of_forall_dist_le {x y : γ} (h : ∀ ε > 0, dist x y ≤ ε) : x = y :=
eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h)
#align eq_of_forall_dist_le eq_of_forall_dist_le
/- warning: eq_of_nndist_eq_zero -> eq_of_nndist_eq_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (Eq.{1} NNReal (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring)))))))) -> (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, (Eq.{1} NNReal (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero))) -> (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align eq_of_nndist_eq_zero eq_of_nndist_eq_zeroₓ'. -/
/-- Deduce the equality of points with the vanishing of the nonnegative distance-/
theorem eq_of_nndist_eq_zero {x y : γ} : nndist x y = 0 → x = y := by
simp only [← NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero]
#align eq_of_nndist_eq_zero eq_of_nndist_eq_zero
/- warning: nndist_eq_zero -> nndist_eq_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} NNReal (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring)))))))) (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} NNReal (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y) (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero))) (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align nndist_eq_zero nndist_eq_zeroₓ'. -/
/-- Characterize the equality of points with the vanishing of the nonnegative distance-/
@[simp]
theorem nndist_eq_zero {x y : γ} : nndist x y = 0 ↔ x = y := by
simp only [← NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero]
#align nndist_eq_zero nndist_eq_zero
/- warning: zero_eq_nndist -> zero_eq_nndist is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} NNReal (OfNat.ofNat.{0} NNReal 0 (OfNat.mk.{0} NNReal 0 (Zero.zero.{0} NNReal (MulZeroClass.toHasZero.{0} NNReal (NonUnitalNonAssocSemiring.toMulZeroClass.{0} NNReal (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} NNReal (Semiring.toNonAssocSemiring.{0} NNReal NNReal.semiring))))))) (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Eq.{succ u1} γ x y)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ} {y : γ}, Iff (Eq.{1} NNReal (OfNat.ofNat.{0} NNReal 0 (Zero.toOfNat0.{0} NNReal instNNRealZero)) (NNDist.nndist.{u1} γ (PseudoMetricSpace.toNNDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y)) (Eq.{succ u1} γ x y)
Case conversion may be inaccurate. Consider using '#align zero_eq_nndist zero_eq_nndistₓ'. -/
@[simp]
theorem zero_eq_nndist {x y : γ} : 0 = nndist x y ↔ x = y := by
simp only [← NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, zero_eq_dist]
#align zero_eq_nndist zero_eq_nndist
namespace Metric
variable {x : γ} {s : Set γ}
/- warning: metric.closed_ball_zero -> Metric.closedBall_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ}, Eq.{succ u1} (Set.{u1} γ) (Metric.closedBall.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Singleton.singleton.{u1, u1} γ (Set.{u1} γ) (Set.hasSingleton.{u1} γ) x)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ}, Eq.{succ u1} (Set.{u1} γ) (Metric.closedBall.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Singleton.singleton.{u1, u1} γ (Set.{u1} γ) (Set.instSingletonSet.{u1} γ) x)
Case conversion may be inaccurate. Consider using '#align metric.closed_ball_zero Metric.closedBall_zeroₓ'. -/
@[simp]
theorem closedBall_zero : closedBall x 0 = {x} :=
Set.ext fun y => dist_le_zero
#align metric.closed_ball_zero Metric.closedBall_zero
/- warning: metric.sphere_zero -> Metric.sphere_zero is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ}, Eq.{succ u1} (Set.{u1} γ) (Metric.sphere.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (Singleton.singleton.{u1, u1} γ (Set.{u1} γ) (Set.hasSingleton.{u1} γ) x)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {x : γ}, Eq.{succ u1} (Set.{u1} γ) (Metric.sphere.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (Singleton.singleton.{u1, u1} γ (Set.{u1} γ) (Set.instSingletonSet.{u1} γ) x)
Case conversion may be inaccurate. Consider using '#align metric.sphere_zero Metric.sphere_zeroₓ'. -/
@[simp]
theorem sphere_zero : sphere x 0 = {x} :=
Set.ext fun y => dist_eq_zero
#align metric.sphere_zero Metric.sphere_zero
/- warning: metric.subsingleton_closed_ball -> Metric.subsingleton_closedBall is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] (x : γ) {r : Real}, (LE.le.{0} Real Real.hasLe r (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Set.Subsingleton.{u1} γ (Metric.closedBall.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x r))
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] (x : γ) {r : Real}, (LE.le.{0} Real Real.instLEReal r (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Set.Subsingleton.{u1} γ (Metric.closedBall.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x r))
Case conversion may be inaccurate. Consider using '#align metric.subsingleton_closed_ball Metric.subsingleton_closedBallₓ'. -/
theorem subsingleton_closedBall (x : γ) {r : ℝ} (hr : r ≤ 0) : (closedBall x r).Subsingleton :=
by
rcases hr.lt_or_eq with (hr | rfl)
· rw [closed_ball_eq_empty.2 hr]
exact subsingleton_empty
· rw [closed_ball_zero]
exact subsingleton_singleton
#align metric.subsingleton_closed_ball Metric.subsingleton_closedBall
/- warning: metric.subsingleton_sphere -> Metric.subsingleton_sphere is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] (x : γ) {r : Real}, (LE.le.{0} Real Real.hasLe r (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Set.Subsingleton.{u1} γ (Metric.sphere.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x r))
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] (x : γ) {r : Real}, (LE.le.{0} Real Real.instLEReal r (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Set.Subsingleton.{u1} γ (Metric.sphere.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2) x r))
Case conversion may be inaccurate. Consider using '#align metric.subsingleton_sphere Metric.subsingleton_sphereₓ'. -/
theorem subsingleton_sphere (x : γ) {r : ℝ} (hr : r ≤ 0) : (sphere x r).Subsingleton :=
(subsingleton_closedBall x hr).anti sphere_subset_closedBall
#align metric.subsingleton_sphere Metric.subsingleton_sphere
#print MetricSpace.to_separated /-
-- see Note [lower instance priority]
instance (priority := 100) MetricSpace.to_separated : SeparatedSpace γ :=
separated_def.2 fun x y h =>
eq_of_forall_dist_le fun ε ε0 => le_of_lt (h _ (dist_mem_uniformity ε0))
#align metric_space.to_separated MetricSpace.to_separated
-/
/- warning: metric.uniform_embedding_iff' -> Metric.uniformEmbedding_iff' is a dubious translation:
lean 3 declaration is
forall {β : Type.{u1}} {γ : Type.{u2}} [_inst_2 : MetricSpace.{u2} γ] [_inst_3 : MetricSpace.{u1} β] {f : γ -> β}, Iff (UniformEmbedding.{u2, u1} γ β (PseudoMetricSpace.toUniformSpace.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) (PseudoMetricSpace.toUniformSpace.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) f) (And (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (δ : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : γ} {b : γ}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} γ (PseudoMetricSpace.toHasDist.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) a b) δ) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} β (PseudoMetricSpace.toHasDist.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) (f a) (f b)) ε))))) (forall (δ : Real), (GT.gt.{0} Real Real.hasLt δ (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{1} Real (fun (ε : Real) => Exists.{0} (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (fun (H : GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) => forall {a : γ} {b : γ}, (LT.lt.{0} Real Real.hasLt (Dist.dist.{u1} β (PseudoMetricSpace.toHasDist.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.hasLt (Dist.dist.{u2} γ (PseudoMetricSpace.toHasDist.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) a b) δ))))))
but is expected to have type
forall {β : Type.{u1}} {γ : Type.{u2}} [_inst_2 : MetricSpace.{u2} γ] [_inst_3 : MetricSpace.{u1} β] {f : γ -> β}, Iff (UniformEmbedding.{u2, u1} γ β (PseudoMetricSpace.toUniformSpace.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) (PseudoMetricSpace.toUniformSpace.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) f) (And (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (δ : Real) => And (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : γ} {b : γ}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} γ (PseudoMetricSpace.toDist.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) a b) δ) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} β (PseudoMetricSpace.toDist.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) (f a) (f b)) ε))))) (forall (δ : Real), (GT.gt.{0} Real Real.instLTReal δ (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{1} Real (fun (ε : Real) => And (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (forall {a : γ} {b : γ}, (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u1} β (PseudoMetricSpace.toDist.{u1} β (MetricSpace.toPseudoMetricSpace.{u1} β _inst_3)) (f a) (f b)) ε) -> (LT.lt.{0} Real Real.instLTReal (Dist.dist.{u2} γ (PseudoMetricSpace.toDist.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) a b) δ))))))
Case conversion may be inaccurate. Consider using '#align metric.uniform_embedding_iff' Metric.uniformEmbedding_iff'ₓ'. -/
/-- A map between metric spaces is a uniform embedding if and only if the distance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y` and conversely. -/
theorem uniformEmbedding_iff' [MetricSpace β] {f : γ → β} :
UniformEmbedding f ↔
(∀ ε > 0, ∃ δ > 0, ∀ {a b : γ}, dist a b < δ → dist (f a) (f b) < ε) ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : γ}, dist (f a) (f b) < ε → dist a b < δ :=
by
simp only [uniformEmbedding_iff_uniformInducing,
uniformity_basis_dist.uniform_inducing_iff uniformity_basis_dist, exists_prop]
rfl
#align metric.uniform_embedding_iff' Metric.uniformEmbedding_iff'
#print MetricSpace.ofT0PseudoMetricSpace /-
/-- If a `pseudo_metric_space` is a T₀ space, then it is a `metric_space`. -/
def MetricSpace.ofT0PseudoMetricSpace (α : Type _) [PseudoMetricSpace α] [T0Space α] :
MetricSpace α :=
{ ‹PseudoMetricSpace α› with
eq_of_dist_eq_zero := fun x y hdist => Inseparable.eq <| Metric.inseparable_iff.2 hdist }
#align metric_space.of_t0_pseudo_metric_space MetricSpace.ofT0PseudoMetricSpace
-/
#print MetricSpace.toEMetricSpace /-
-- see Note [lower instance priority]
/-- A metric space induces an emetric space -/
instance (priority := 100) MetricSpace.toEMetricSpace : EMetricSpace γ :=
EMetricSpace.ofT0PseudoEMetricSpace γ
#align metric_space.to_emetric_space MetricSpace.toEMetricSpace
-/
/- warning: metric.is_closed_of_pairwise_le_dist -> Metric.isClosed_of_pairwise_le_dist is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {s : Set.{u1} γ} {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (Set.Pairwise.{u1} γ s (fun (x : γ) (y : γ) => LE.le.{0} Real Real.hasLe ε (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y))) -> (IsClosed.{u1} γ (UniformSpace.toTopologicalSpace.{u1} γ (PseudoMetricSpace.toUniformSpace.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2))) s)
but is expected to have type
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {s : Set.{u1} γ} {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (Set.Pairwise.{u1} γ s (fun (x : γ) (y : γ) => LE.le.{0} Real Real.instLEReal ε (Dist.dist.{u1} γ (PseudoMetricSpace.toDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) x y))) -> (IsClosed.{u1} γ (UniformSpace.toTopologicalSpace.{u1} γ (PseudoMetricSpace.toUniformSpace.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2))) s)
Case conversion may be inaccurate. Consider using '#align metric.is_closed_of_pairwise_le_dist Metric.isClosed_of_pairwise_le_distₓ'. -/
theorem isClosed_of_pairwise_le_dist {s : Set γ} {ε : ℝ} (hε : 0 < ε)
(hs : s.Pairwise fun x y => ε ≤ dist x y) : IsClosed s :=
isClosed_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hs
#align metric.is_closed_of_pairwise_le_dist Metric.isClosed_of_pairwise_le_dist
/- warning: metric.closed_embedding_of_pairwise_le_dist -> Metric.closedEmbedding_of_pairwise_le_dist is a dubious translation:
lean 3 declaration is
forall {γ : Type.{u1}} [_inst_2 : MetricSpace.{u1} γ] {α : Type.{u2}} [_inst_3 : TopologicalSpace.{u2} α] [_inst_4 : DiscreteTopology.{u2} α _inst_3] {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (forall {f : α -> γ}, (Pairwise.{u2} α (fun (x : α) (y : α) => LE.le.{0} Real Real.hasLe ε (Dist.dist.{u1} γ (PseudoMetricSpace.toHasDist.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2)) (f x) (f y)))) -> (ClosedEmbedding.{u2, u1} α γ _inst_3 (UniformSpace.toTopologicalSpace.{u1} γ (PseudoMetricSpace.toUniformSpace.{u1} γ (MetricSpace.toPseudoMetricSpace.{u1} γ _inst_2))) f))
but is expected to have type
forall {γ : Type.{u2}} [_inst_2 : MetricSpace.{u2} γ] {α : Type.{u1}} [_inst_3 : TopologicalSpace.{u1} α] [_inst_4 : DiscreteTopology.{u1} α _inst_3] {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (forall {f : α -> γ}, (Pairwise.{u1} α (fun (x : α) (y : α) => LE.le.{0} Real Real.instLEReal ε (Dist.dist.{u2} γ (PseudoMetricSpace.toDist.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2)) (f x) (f y)))) -> (ClosedEmbedding.{u1, u2} α γ _inst_3 (UniformSpace.toTopologicalSpace.{u2} γ (PseudoMetricSpace.toUniformSpace.{u2} γ (MetricSpace.toPseudoMetricSpace.{u2} γ _inst_2))) f))
Case conversion may be inaccurate. Consider using '#align metric.closed_embedding_of_pairwise_le_dist Metric.closedEmbedding_of_pairwise_le_distₓ'. -/
theorem closedEmbedding_of_pairwise_le_dist {α : Type _} [TopologicalSpace α] [DiscreteTopology α]
{ε : ℝ} (hε : 0 < ε) {f : α → γ} (hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
ClosedEmbedding f :=
closedEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
#align metric.closed_embedding_of_pairwise_le_dist Metric.closedEmbedding_of_pairwise_le_dist
/- warning: metric.uniform_embedding_bot_of_pairwise_le_dist -> Metric.uniformEmbedding_bot_of_pairwise_le_dist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : PseudoMetricSpace.{u1} α] {β : Type.{u2}} {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (forall {f : β -> α}, (Pairwise.{u2} β (fun (x : β) (y : β) => LE.le.{0} Real Real.hasLe ε (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α _inst_1) (f x) (f y)))) -> (UniformEmbedding.{u2, u1} β α (Bot.bot.{u2} (UniformSpace.{u2} β) (UniformSpace.hasBot.{u2} β)) (PseudoMetricSpace.toUniformSpace.{u1} α _inst_1) f))
but is expected to have type
forall {α : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} α] {β : Type.{u1}} {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (forall {f : β -> α}, (Pairwise.{u1} β (fun (x : β) (y : β) => LE.le.{0} Real Real.instLEReal ε (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α _inst_1) (f x) (f y)))) -> (UniformEmbedding.{u1, u2} β α (Bot.bot.{u1} (UniformSpace.{u1} β) (instBotUniformSpace.{u1} β)) (inferInstance.{succ u2} (UniformSpace.{u2} α) (PseudoMetricSpace.toUniformSpace.{u2} α _inst_1)) f))
Case conversion may be inaccurate. Consider using '#align metric.uniform_embedding_bot_of_pairwise_le_dist Metric.uniformEmbedding_bot_of_pairwise_le_distₓ'. -/
/-- If `f : β → α` sends any two distinct points to points at distance at least `ε > 0`, then
`f` is a uniform embedding with respect to the discrete uniformity on `β`. -/
theorem uniformEmbedding_bot_of_pairwise_le_dist {β : Type _} {ε : ℝ} (hε : 0 < ε) {f : β → α}
(hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
@UniformEmbedding _ _ ⊥ (by infer_instance) f :=
uniformEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
#align metric.uniform_embedding_bot_of_pairwise_le_dist Metric.uniformEmbedding_bot_of_pairwise_le_dist
end Metric
#print MetricSpace.replaceUniformity /-
/-- Build a new metric space from an old one where the bundled uniform structure is provably
(but typically non-definitionaly) equal to some given uniform structure.
See Note [forgetful inheritance].
-/
def MetricSpace.replaceUniformity {γ} [U : UniformSpace γ] (m : MetricSpace γ)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : MetricSpace γ :=
{ PseudoMetricSpace.replaceUniformity m.toPseudoMetricSpace H with
eq_of_dist_eq_zero := @eq_of_dist_eq_zero _ _ }
#align metric_space.replace_uniformity MetricSpace.replaceUniformity
-/
#print MetricSpace.replaceUniformity_eq /-
theorem MetricSpace.replaceUniformity_eq {γ} [U : UniformSpace γ] (m : MetricSpace γ)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : m.replaceUniformity H = m :=
by
ext
rfl
#align metric_space.replace_uniformity_eq MetricSpace.replaceUniformity_eq
-/
#print MetricSpace.replaceTopology /-
/-- Build a new metric space from an old one where the bundled topological structure is provably
(but typically non-definitionaly) equal to some given topological structure.
See Note [forgetful inheritance].
-/
@[reducible]
def MetricSpace.replaceTopology {γ} [U : TopologicalSpace γ] (m : MetricSpace γ)
(H : U = m.toPseudoMetricSpace.toUniformSpace.toTopologicalSpace) : MetricSpace γ :=
@MetricSpace.replaceUniformity γ (m.toUniformSpace.replaceTopology H) m rfl
#align metric_space.replace_topology MetricSpace.replaceTopology
-/
#print MetricSpace.replaceTopology_eq /-
theorem MetricSpace.replaceTopology_eq {γ} [U : TopologicalSpace γ] (m : MetricSpace γ)
(H : U = m.toPseudoMetricSpace.toUniformSpace.toTopologicalSpace) : m.replaceTopology H = m :=
by
ext
rfl
#align metric_space.replace_topology_eq MetricSpace.replaceTopology_eq
-/
/- warning: emetric_space.to_metric_space_of_dist -> EMetricSpace.toMetricSpaceOfDist is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [e : EMetricSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α (EMetricSpace.toPseudoEmetricSpace.{u1} α e)) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (ENNReal.toReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α (EMetricSpace.toPseudoEmetricSpace.{u1} α e)) x y))) -> (MetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [e : EMetricSpace.{u1} α] (dist : α -> α -> Real), (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α (EMetricSpace.toPseudoEMetricSpace.{u1} α e)) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) -> (forall (x : α) (y : α), Eq.{1} Real (dist x y) (ENNReal.toReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α (EMetricSpace.toPseudoEMetricSpace.{u1} α e)) x y))) -> (MetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align emetric_space.to_metric_space_of_dist EMetricSpace.toMetricSpaceOfDistₓ'. -/
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. In this definition, the distance
is given separately, to be able to prescribe some expression which is not defeq to the push-forward
of the edistance to reals. -/
def EMetricSpace.toMetricSpaceOfDist {α : Type u} [e : EMetricSpace α] (dist : α → α → ℝ)
(edist_ne_top : ∀ x y : α, edist x y ≠ ⊤) (h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) :
MetricSpace α :=
@MetricSpace.ofT0PseudoMetricSpace α
(PseudoEMetricSpace.toPseudoMetricSpaceOfDist dist edist_ne_top h) _
#align emetric_space.to_metric_space_of_dist EMetricSpace.toMetricSpaceOfDist
/- warning: emetric_space.to_metric_space -> EMetricSpace.toMetricSpace is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_3 : EMetricSpace.{u1} α], (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toHasEdist.{u1} α (EMetricSpace.toPseudoEmetricSpace.{u1} α _inst_3)) x y) (Top.top.{0} ENNReal (CompleteLattice.toHasTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.completeLinearOrder)))) -> (MetricSpace.{u1} α)
but is expected to have type
forall {α : Type.{u1}} [_inst_3 : EMetricSpace.{u1} α], (forall (x : α) (y : α), Ne.{1} ENNReal (EDist.edist.{u1} α (PseudoEMetricSpace.toEDist.{u1} α (EMetricSpace.toPseudoEMetricSpace.{u1} α _inst_3)) x y) (Top.top.{0} ENNReal (CompleteLattice.toTop.{0} ENNReal (CompleteLinearOrder.toCompleteLattice.{0} ENNReal ENNReal.instCompleteLinearOrderENNReal)))) -> (MetricSpace.{u1} α)
Case conversion may be inaccurate. Consider using '#align emetric_space.to_metric_space EMetricSpace.toMetricSpaceₓ'. -/
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. -/
def EMetricSpace.toMetricSpace {α : Type u} [EMetricSpace α] (h : ∀ x y : α, edist x y ≠ ⊤) :
MetricSpace α :=
EMetricSpace.toMetricSpaceOfDist (fun x y => ENNReal.toReal (edist x y)) h fun x y => rfl
#align emetric_space.to_metric_space EMetricSpace.toMetricSpace
#print MetricSpace.replaceBornology /-
/-- Build a new metric space from an old one where the bundled bornology structure is provably
(but typically non-definitionaly) equal to some given bornology structure.
See Note [forgetful inheritance].
-/
def MetricSpace.replaceBornology {α} [B : Bornology α] (m : MetricSpace α)
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) : MetricSpace α :=
{ PseudoMetricSpace.replaceBornology _ H, m with toBornology := B }
#align metric_space.replace_bornology MetricSpace.replaceBornology
-/
#print MetricSpace.replaceBornology_eq /-
theorem MetricSpace.replaceBornology_eq {α} [m : MetricSpace α] [B : Bornology α]
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
MetricSpace.replaceBornology _ H = m := by
ext
rfl
#align metric_space.replace_bornology_eq MetricSpace.replaceBornology_eq
-/
#print MetricSpace.induced /-
/-- Metric space structure pulled back by an injective function. Injectivity is necessary to
ensure that `dist x y = 0` only if `x = y`. -/
def MetricSpace.induced {γ β} (f : γ → β) (hf : Function.Injective f) (m : MetricSpace β) :
MetricSpace γ :=
{ PseudoMetricSpace.induced f m.toPseudoMetricSpace with
eq_of_dist_eq_zero := fun x y h => hf (dist_eq_zero.1 h) }
#align metric_space.induced MetricSpace.induced
-/
#print UniformEmbedding.comapMetricSpace /-
/-- Pull back a metric space structure by a uniform embedding. This is a version of
`metric_space.induced` useful in case if the domain already has a `uniform_space` structure. -/
@[reducible]
def UniformEmbedding.comapMetricSpace {α β} [UniformSpace α] [MetricSpace β] (f : α → β)
(h : UniformEmbedding f) : MetricSpace α :=
(MetricSpace.induced f h.inj ‹_›).replaceUniformity h.comap_uniformity.symm
#align uniform_embedding.comap_metric_space UniformEmbedding.comapMetricSpace
-/
#print Embedding.comapMetricSpace /-
/-- Pull back a metric space structure by an embedding. This is a version of
`metric_space.induced` useful in case if the domain already has a `topological_space` structure. -/
@[reducible]
def Embedding.comapMetricSpace {α β} [TopologicalSpace α] [MetricSpace β] (f : α → β)
(h : Embedding f) : MetricSpace α :=
letI : UniformSpace α := Embedding.comapUniformSpace f h
UniformEmbedding.comapMetricSpace f (h.to_uniform_embedding f)
#align embedding.comap_metric_space Embedding.comapMetricSpace
-/
#print Subtype.metricSpace /-
instance Subtype.metricSpace {α : Type _} {p : α → Prop} [MetricSpace α] :
MetricSpace (Subtype p) :=
MetricSpace.induced coe Subtype.coe_injective ‹_›
#align subtype.metric_space Subtype.metricSpace
-/
@[to_additive]
instance {α : Type _} [MetricSpace α] : MetricSpace αᵐᵒᵖ :=
MetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_›
instance : MetricSpace Empty where
dist _ _ := 0
dist_self _ := rfl
dist_comm _ _ := rfl
edist _ _ := 0
eq_of_dist_eq_zero _ _ _ := Subsingleton.elim _ _
dist_triangle _ _ _ := show (0 : ℝ) ≤ 0 + 0 by rw [add_zero]
toUniformSpace := Empty.uniformSpace
uniformity_dist := Subsingleton.elim _ _
instance : MetricSpace PUnit.{u + 1} where
dist _ _ := 0
dist_self _ := rfl
dist_comm _ _ := rfl
edist _ _ := 0
eq_of_dist_eq_zero _ _ _ := Subsingleton.elim _ _
dist_triangle _ _ _ := show (0 : ℝ) ≤ 0 + 0 by rw [add_zero]
toUniformSpace := PUnit.uniformSpace
uniformity_dist := by
simp only
have : ne_bot (⨅ ε > (0 : ℝ), 𝓟 { p : PUnit.{u + 1} × PUnit.{u + 1} | 0 < ε }) :=
@uniformity.neBot _
(UniformSpace.ofDist (fun _ _ => 0) (fun _ => rfl) (fun _ _ => rfl) fun _ _ _ => by
rw [zero_add])
_
refine' (eq_top_of_ne_bot _).trans (eq_top_of_ne_bot _).symm
section Real
#print Real.metricSpace /-
/-- Instantiate the reals as a metric space. -/
instance Real.metricSpace : MetricSpace ℝ :=
{ Real.pseudoMetricSpace with
eq_of_dist_eq_zero := fun x y h => by simpa [dist, sub_eq_zero] using h }
#align real.metric_space Real.metricSpace
-/
end Real
section NNReal
instance : MetricSpace ℝ≥0 :=
Subtype.metricSpace
end NNReal
instance [MetricSpace β] : MetricSpace (ULift β) :=
MetricSpace.induced ULift.down ULift.down_injective ‹_›
section Prod
#print Prod.metricSpaceMax /-
instance Prod.metricSpaceMax [MetricSpace β] : MetricSpace (γ × β) :=
{ Prod.pseudoMetricSpaceMax with
eq_of_dist_eq_zero := fun x y h =>
by
cases' max_le_iff.1 (le_of_eq h) with h₁ h₂
exact Prod.ext_iff.2 ⟨dist_le_zero.1 h₁, dist_le_zero.1 h₂⟩ }
#align prod.metric_space_max Prod.metricSpaceMax
-/
end Prod
section Pi
open Finset
variable {π : β → Type _} [Fintype β] [∀ b, MetricSpace (π b)]
#print metricSpacePi /-
/-- A finite product of metric spaces is a metric space, with the sup distance. -/
instance metricSpacePi : MetricSpace (∀ b, π b) :=
{/- we construct the instance from the emetric space instance to avoid checking again that the
uniformity is the same as the product uniformity, but we register nevertheless a nice formula
for the distance -/
pseudoMetricSpacePi with
eq_of_dist_eq_zero := fun f g eq0 =>
by
have eq1 : edist f g = 0 := by simp only [edist_dist, eq0, ENNReal.ofReal_zero]
have eq2 : (sup univ fun b : β => edist (f b) (g b)) ≤ 0 := le_of_eq eq1
simp only [Finset.sup_le_iff] at eq2
exact funext fun b => edist_le_zero.1 <| eq2 b <| mem_univ b }
#align metric_space_pi metricSpacePi
-/
end Pi
namespace Metric
section SecondCountable
open TopologicalSpace
/- warning: metric.second_countable_of_countable_discretization -> Metric.secondCountable_of_countable_discretization is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} [_inst_3 : MetricSpace.{u1} α], (forall (ε : Real), (GT.gt.{0} Real Real.hasLt ε (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Exists.{succ (succ u2)} Type.{u2} (fun (β : Type.{u2}) => Exists.{succ u2} (Encodable.{u2} β) (fun (_x : Encodable.{u2} β) => Exists.{max (succ u1) (succ u2)} (α -> β) (fun (F : α -> β) => forall (x : α) (y : α), (Eq.{succ u2} β (F x) (F y)) -> (LE.le.{0} Real Real.hasLe (Dist.dist.{u1} α (PseudoMetricSpace.toHasDist.{u1} α (MetricSpace.toPseudoMetricSpace.{u1} α _inst_3)) x y) ε)))))) -> (TopologicalSpace.SecondCountableTopology.{u1} α (UniformSpace.toTopologicalSpace.{u1} α (PseudoMetricSpace.toUniformSpace.{u1} α (MetricSpace.toPseudoMetricSpace.{u1} α _inst_3))))
but is expected to have type
forall {α : Type.{u2}} [_inst_3 : MetricSpace.{u2} α], (forall (ε : Real), (GT.gt.{0} Real Real.instLTReal ε (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Exists.{succ (succ u1)} Type.{u1} (fun (β : Type.{u1}) => Exists.{succ u1} (Encodable.{u1} β) (fun (_x : Encodable.{u1} β) => Exists.{max (succ u2) (succ u1)} (α -> β) (fun (F : α -> β) => forall (x : α) (y : α), (Eq.{succ u1} β (F x) (F y)) -> (LE.le.{0} Real Real.instLEReal (Dist.dist.{u2} α (PseudoMetricSpace.toDist.{u2} α (MetricSpace.toPseudoMetricSpace.{u2} α _inst_3)) x y) ε)))))) -> (TopologicalSpace.SecondCountableTopology.{u2} α (UniformSpace.toTopologicalSpace.{u2} α (PseudoMetricSpace.toUniformSpace.{u2} α (MetricSpace.toPseudoMetricSpace.{u2} α _inst_3))))
Case conversion may be inaccurate. Consider using '#align metric.second_countable_of_countable_discretization Metric.secondCountable_of_countable_discretizationₓ'. -/
/-- A metric space is second countable if one can reconstruct up to any `ε>0` any element of the
space from countably many data. -/
theorem secondCountable_of_countable_discretization {α : Type u} [MetricSpace α]
(H :
∀ ε > (0 : ℝ), ∃ (β : Type _)(_ : Encodable β)(F : α → β), ∀ x y, F x = F y → dist x y ≤ ε) :
SecondCountableTopology α :=
by
cases' (univ : Set α).eq_empty_or_nonempty with hs hs
· haveI : CompactSpace α := ⟨by rw [hs] <;> exact isCompact_empty⟩
· infer_instance
rcases hs with ⟨x0, hx0⟩
letI : Inhabited α := ⟨x0⟩
refine' second_countable_of_almost_dense_set fun ε ε0 => _
rcases H ε ε0 with ⟨β, fβ, F, hF⟩
skip
let Finv := Function.invFun F
refine' ⟨range Finv, ⟨countable_range _, fun x => _⟩⟩
let x' := Finv (F x)
have : F x' = F x := Function.invFun_eq ⟨x, rfl⟩
exact ⟨x', mem_range_self _, hF _ _ this.symm⟩
#align metric.second_countable_of_countable_discretization Metric.secondCountable_of_countable_discretization
end SecondCountable
end Metric
section EqRel
instance {α : Type u} [PseudoMetricSpace α] : Dist (UniformSpace.SeparationQuotient α)
where dist p q :=
Quotient.liftOn₂' p q dist fun x y x' y' hx hy => by
rw [dist_edist, dist_edist, ← UniformSpace.SeparationQuotient.edist_mk x, ←
UniformSpace.SeparationQuotient.edist_mk x', Quot.sound hx, Quot.sound hy]
#print UniformSpace.SeparationQuotient.dist_mk /-
theorem UniformSpace.SeparationQuotient.dist_mk {α : Type u} [PseudoMetricSpace α] (p q : α) :
@dist (UniformSpace.SeparationQuotient α) _ (Quot.mk _ p) (Quot.mk _ q) = dist p q :=
rfl
#align uniform_space.separation_quotient.dist_mk UniformSpace.SeparationQuotient.dist_mk
-/
instance {α : Type u} [PseudoMetricSpace α] : MetricSpace (UniformSpace.SeparationQuotient α) :=
EMetricSpace.toMetricSpaceOfDist dist (fun x y => Quotient.inductionOn₂' x y edist_ne_top)
fun x y => Quotient.inductionOn₂' x y dist_edist
end EqRel
/-!
### `additive`, `multiplicative`
The distance on those type synonyms is inherited without change.
-/
open Additive Multiplicative
section
variable [Dist X]
instance : Dist (Additive X) :=
‹Dist X›
instance : Dist (Multiplicative X) :=
‹Dist X›
#print dist_ofMul /-
@[simp]
theorem dist_ofMul (a b : X) : dist (ofMul a) (ofMul b) = dist a b :=
rfl
#align dist_of_mul dist_ofMul
-/
#print dist_ofAdd /-
@[simp]
theorem dist_ofAdd (a b : X) : dist (ofAdd a) (ofAdd b) = dist a b :=
rfl
#align dist_of_add dist_ofAdd
-/
#print dist_toMul /-
@[simp]
theorem dist_toMul (a b : Additive X) : dist (toMul a) (toMul b) = dist a b :=
rfl
#align dist_to_mul dist_toMul
-/
#print dist_toAdd /-
@[simp]
theorem dist_toAdd (a b : Multiplicative X) : dist (toAdd a) (toAdd b) = dist a b :=
rfl
#align dist_to_add dist_toAdd
-/
end
section
variable [PseudoMetricSpace X]
instance : PseudoMetricSpace (Additive X) :=
‹PseudoMetricSpace X›
instance : PseudoMetricSpace (Multiplicative X) :=
‹PseudoMetricSpace X›
#print nndist_ofMul /-
@[simp]
theorem nndist_ofMul (a b : X) : nndist (ofMul a) (ofMul b) = nndist a b :=
rfl
#align nndist_of_mul nndist_ofMul
-/
#print nndist_ofAdd /-
@[simp]
theorem nndist_ofAdd (a b : X) : nndist (ofAdd a) (ofAdd b) = nndist a b :=
rfl
#align nndist_of_add nndist_ofAdd
-/
#print nndist_toMul /-
@[simp]
theorem nndist_toMul (a b : Additive X) : nndist (toMul a) (toMul b) = nndist a b :=
rfl
#align nndist_to_mul nndist_toMul
-/
#print nndist_toAdd /-
@[simp]
theorem nndist_toAdd (a b : Multiplicative X) : nndist (toAdd a) (toAdd b) = nndist a b :=
rfl
#align nndist_to_add nndist_toAdd
-/
end
instance [MetricSpace X] : MetricSpace (Additive X) :=
‹MetricSpace X›
instance [MetricSpace X] : MetricSpace (Multiplicative X) :=
‹MetricSpace X›
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Additive X) :=
‹ProperSpace X›
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Multiplicative X) :=
‹ProperSpace X›
/-!
### Order dual
The distance on this type synonym is inherited without change.
-/
open OrderDual
section
variable [Dist X]
instance : Dist Xᵒᵈ :=
‹Dist X›
#print dist_toDual /-
@[simp]
theorem dist_toDual (a b : X) : dist (toDual a) (toDual b) = dist a b :=
rfl
#align dist_to_dual dist_toDual
-/
#print dist_ofDual /-
@[simp]
theorem dist_ofDual (a b : Xᵒᵈ) : dist (ofDual a) (ofDual b) = dist a b :=
rfl
#align dist_of_dual dist_ofDual
-/
end
section
variable [PseudoMetricSpace X]
instance : PseudoMetricSpace Xᵒᵈ :=
‹PseudoMetricSpace X›
#print nndist_toDual /-
@[simp]
theorem nndist_toDual (a b : X) : nndist (toDual a) (toDual b) = nndist a b :=
rfl
#align nndist_to_dual nndist_toDual
-/
#print nndist_ofDual /-
@[simp]
theorem nndist_ofDual (a b : Xᵒᵈ) : nndist (ofDual a) (ofDual b) = nndist a b :=
rfl
#align nndist_of_dual nndist_ofDual
-/
end
instance [MetricSpace X] : MetricSpace Xᵒᵈ :=
‹MetricSpace X›
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace Xᵒᵈ :=
‹ProperSpace X›
|
{"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/MetricSpace/Basic.lean"}
|
#!/usr/bin/env python
"""
Simple binning search algorithm
"""
__author__ = "Keith Bechtol"
# Python libraries
import sys
import os
import glob
import yaml
from matplotlib import mlab
import numpy as np
import healpy as hp
import astropy.io.fits as pyfits
import fitsio as fits
# Ugali libraries
import ugali.utils.healpix
import ugali.utils.projector
# Simple binner modules
import simple.filters
import simple.simple_utils
###########################################################
with open('config.yaml', 'r') as ymlfile:
cfg = yaml.load(ymlfile)
survey = cfg['survey']
nside = cfg[survey]['nside']
datadir = cfg[survey]['datadir']
mag_max = cfg[survey]['mag_max']
basis_1 = cfg[survey]['basis_1']
basis_2 = cfg[survey]['basis_2']
band_1 = cfg[survey]['band_1']
band_2 = cfg[survey]['band_2']
mag = cfg[survey]['mag']
mag_err = cfg[survey]['mag_err']
mag_dered = cfg[survey]['mag_dered']
mode = cfg[survey]['mode']
sim_population = cfg[survey]['sim_population']
sim_dir = cfg[survey]['sim_dir']
#object_list = cfg[survey]['object_list']
fracdet_map = cfg[survey]['fracdet']
#mag_g = cfg[survey]['mag_g']
#mag_r = cfg[survey]['mag_r']
#mag_g_err = cfg[survey]['mag_g_err']
#mag_r_err = cfg[survey]['mag_r_err']
results_dir = os.path.join(os.getcwd(), cfg['output']['results_dir'])
if not os.path.exists(results_dir):
os.mkdir(results_dir)
############################################################
# construct mags
mag_1 = mag.format(band_1.upper())
mag_2 = mag.format(band_2.upper())
mag_err_1 = mag_err.format(band_1.upper())
mag_err_2 = mag_err.format(band_2.upper())
mag_dered_1 = mag_dered.format(band_1.upper())
mag_dered_2 = mag_dered.format(band_2.upper())
# main
try:
ra_select, dec_select = float(sys.argv[1]), float(sys.argv[2])
except:
sys.exit('ERROR! Coordinates not given in correct format.')
try:
mc_source_id = float(sys.argv[3])
except:
mc_source_id = 0
try:
outfile = sys.argv[4]
except:
sys.exit('ERROR: no outfile given.')
# if (mode == 0):
# outfile = '{}/results_nside_{}_{}.csv'.format(results_dir, nside, pix_nside_select)
# elif (mode == 1):
# outfile = '{}/results_mc_source_id_{}.csv'.format(results_dir, mc_source_id_array[0]) # all values in mc_source_id_array should be the same
print('Search coordinates: (RA, Dec) = ({:0.2f}, {:0.2f})').format(ra_select, dec_select)
# Now cut for a single pixel
pix_nside_select = ugali.utils.healpix.angToPix(nside, ra_select, dec_select)
#ra_select, dec_select = ugali.utils.healpix.pixToAng(nside, pix_nside_select)
pix_nside_neighbors = np.concatenate([[pix_nside_select], hp.get_all_neighbours(nside, pix_nside_select)])
print('Center healpixel: {}'.format(pix_nside_select))
print('Healpixels: {}'.format(pix_nside_neighbors))
# Construct data
#data = simple_utils.construct_modal_data(mode, pix_nside_neighbors, mc_source_id)
data = simple.simple_utils.construct_real_data(pix_nside_neighbors)
print('MC_SOURCE_ID = {}'.format(mc_source_id))
if (mode == 0):
print('mode = 0: running only on real data')
elif (mode == 1):
print('mode = 1: running on real data and simulated data')
# inject objects for simulated object of mc_source_id
sim_data = simple.simple_utils.construct_sim_data(pix_nside_neighbors, mc_source_id)
data = simple.simple_utils.inject_sim(data, sim_data, mc_source_id)
elif (mode == 2):
print('mode = 2: running only on real data')
else:
print('No/unsupported mode specified; running only on real data')
# Quality cut
quality = simple.filters.quality_filter(survey, data)
data = data[quality]
# Deredden magnitudes
data = simple.filters.dered_mag(survey, data)
print('Found {} objects...').format(len(data))
if (len(data) == 0):
print('Ending search prematurely. Look at data for debugging.')
nan_array = [np.nan]
simple.simple_utils.write_output(results_dir, nside, pix_nside_select,
nan_array, nan_array, nan_array, nan_array,
nan_array, nan_array, nan_array, nan_array,
[mc_source_id], mode, outfile)
exit()
print('Applying cuts...')
cut = simple.filters.star_filter(survey, data)
cut_gal = simple.filters.galaxy_filter(survey, data)
data_gal = data[cut_gal] # this isn't used at all other than for noting number of galaxy-like objects in ROI
data = data[cut]
print('{} star-like objects in ROI...'.format(len(data)))
print('{} galaxy-like objects in ROI...'.format(len(data_gal)))
if (mode == 1):
print('{} simulated objects in ROI...'.format(np.sum(data['MC_SOURCE_ID'] != 0)))
# Read in fracdet map
if (fracdet_map is not None) and (fracdet_map.lower().strip() != 'none') and (fracdet_map != ''):
print('Reading fracdet map {} ...').format(fracdet_map)
fracdet = ugali.utils.healpix.read_map(fracdet_map)
else:
print('No fracdet map specified ...')
fracdet = None
distance_modulus_search_array = np.arange(16., mag_max, 0.5)
ra_peak_array = []
dec_peak_array = []
r_peak_array = []
sig_peak_array = []
distance_modulus_array = []
mc_source_id_array = []
n_obs_peak_array = []
n_obs_half_peak_array = []
n_model_peak_array = []
if (mode == 0):
for distance_modulus in distance_modulus_search_array:
ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.search_by_distance(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet)
ra_peak_array.append(ra_peaks)
dec_peak_array.append(dec_peaks)
r_peak_array.append(r_peaks)
sig_peak_array.append(sig_peaks)
distance_modulus_array.append(dist_moduli)
n_obs_peak_array.append(n_obs_peaks)
n_obs_half_peak_array.append(n_obs_half_peaks)
n_model_peak_array.append(n_model_peaks)
mc_source_id_array.append(np.tile(0, len(sig_peaks)))
elif (mode == 1):
# grab distance_modulus from population
sim_pop = fits.read(sim_population)
distance_modulus_select = sim_pop[sim_pop['MC_SOURCE_ID'] == mc_source_id]['DISTANCE_MODULUS'][0]
distance_modulus = distance_modulus_search_array[np.argmin(np.fabs(distance_modulus_search_array - distance_modulus_select))]
ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.search_by_simulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet)
ra_peak_array.append(ra_peaks)
dec_peak_array.append(dec_peaks)
r_peak_array.append(r_peaks)
sig_peak_array.append(sig_peaks)
distance_modulus_array.append(dist_moduli)
n_obs_peak_array.append(n_obs_peaks)
n_obs_half_peak_array.append(n_obs_half_peaks)
n_model_peak_array.append(n_model_peaks)
mc_source_id_array.append(np.tile(mc_source_id, len(sig_peaks)))
elif (mode == 2):
# grab distance_modulus from population
#sim_pop = fits.read(object_list)
sim_pop = np.genfromtxt(object_list, delimiter=',', names=['RA', 'DEC', 'DISTANCE_MODULUS', 'MC_SOURCE_ID', 'NAME'])[1:]
distance_modulus_select = sim_pop[sim_pop['MC_SOURCE_ID'] == mc_source_id]['DISTANCE_MODULUS'][0]
distance_modulus = distance_modulus_search_array[np.argmin(np.fabs(distance_modulus_search_array - distance_modulus_select))]
ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.search_by_simulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet)
ra_peak_array.append(ra_peaks)
dec_peak_array.append(dec_peaks)
r_peak_array.append(r_peaks)
sig_peak_array.append(sig_peaks)
distance_modulus_array.append(dist_moduli)
n_obs_peak_array.append(n_obs_peaks)
n_obs_half_peak_array.append(n_obs_half_peaks)
n_model_peak_array.append(n_model_peaks)
mc_source_id_array.append(np.tile(mc_source_id, len(sig_peaks)))
ra_peak_array = np.concatenate(ra_peak_array)
dec_peak_array = np.concatenate(dec_peak_array)
r_peak_array = np.concatenate(r_peak_array)
sig_peak_array = np.concatenate(sig_peak_array)
distance_modulus_array = np.concatenate(distance_modulus_array)
n_obs_peak_array = np.concatenate(n_obs_peak_array)
n_obs_half_peak_array = np.concatenate(n_obs_half_peak_array)
n_model_peak_array = np.concatenate(n_model_peak_array)
mc_source_id_array = np.concatenate(mc_source_id_array)
# Sort peaks according to significance
index_sort = np.argsort(sig_peak_array)[::-1]
ra_peak_array = ra_peak_array[index_sort]
dec_peak_array = dec_peak_array[index_sort]
r_peak_array = r_peak_array[index_sort]
sig_peak_array = sig_peak_array[index_sort]
distance_modulus_array = distance_modulus_array[index_sort]
n_obs_peak_array = n_obs_peak_array[index_sort]
n_obs_half_peak_array = n_obs_half_peak_array[index_sort]
n_model_peak_array = n_model_peak_array[index_sort]
mc_source_id_array = mc_source_id_array[index_sort]
# Collect overlapping peaks
for ii in range(0, len(sig_peak_array)):
if sig_peak_array[ii] < 0:
continue
angsep = ugali.utils.projector.angsep(ra_peak_array[ii], dec_peak_array[ii], ra_peak_array, dec_peak_array)
sig_peak_array[(angsep < r_peak_array[ii]) & (np.arange(len(sig_peak_array)) > ii)] = -1.
#sig_peak_array[(angsep < 0.5) & (np.arange(len(sig_peak_array)) > ii)] = -1. # 0.5 deg radius
if (mode == 0):
# Prune the list of peaks
ra_peak_array = ra_peak_array[sig_peak_array > 0.]
dec_peak_array = dec_peak_array[sig_peak_array > 0.]
r_peak_array = r_peak_array[sig_peak_array > 0.]
distance_modulus_array = distance_modulus_array[sig_peak_array > 0.]
n_obs_peak_array = n_obs_peak_array[sig_peak_array > 0.]
n_obs_half_peak_array = n_obs_half_peak_array[sig_peak_array > 0.]
n_model_peak_array = n_model_peak_array[sig_peak_array > 0.]
mc_source_id_array = mc_source_id_array[sig_peak_array > 0.]
sig_peak_array = sig_peak_array[sig_peak_array > 0.] # Update the sig_peak_array last!
for ii in range(0, len(sig_peak_array)):
print('{:0.2f} sigma; (RA, Dec, d) = ({:0.2f}, {:0.2f}); r = {:0.2f} deg; d = {:0.1f}, mu = {:0.2f} mag), mc_source_id: {:0.2f}'.format(sig_peak_array[ii],
ra_peak_array[ii],
dec_peak_array[ii],
r_peak_array[ii],
ugali.utils.projector.distanceModulusToDistance(distance_modulus_array[ii]),
distance_modulus_array[ii],
mc_source_id_array[ii]))
# Write output
if (len(sig_peak_array) > 0):
simple.simple_utils.write_output(results_dir, nside, pix_nside_select, ra_peak_array, dec_peak_array, r_peak_array, distance_modulus_array,
n_obs_peak_array, n_obs_half_peak_array, n_model_peak_array,
sig_peak_array, mc_source_id_array, mode, outfile)
else:
print('No significant hotspots found.')
nan_array = [np.nan]
simple.simple_utils.write_output(results_dir, nside, pix_nside_select,
nan_array, nan_array, nan_array, nan_array,
nan_array, nan_array, nan_array, nan_array,
[mc_source_id], mode, outfile)
|
{"hexsha": "6f9ab445feebb29977309fc341e15bf474e51aae", "size": 11334, "ext": "py", "lang": "Python", "max_stars_repo_path": "simple/search_algorithm.py", "max_stars_repo_name": "sidneymau/simple", "max_stars_repo_head_hexsha": "df1fb1d8cfdbf6f4964a6554072b56609baf5245", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-10-12T03:02:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T23:28:26.000Z", "max_issues_repo_path": "simple/search_algorithm.py", "max_issues_repo_name": "kadrlica/simple", "max_issues_repo_head_hexsha": "14dc9fa0d39c4cd95b2b32790fe7c25a18c3280c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2017-12-28T07:16:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-10T19:36:11.000Z", "max_forks_repo_path": "simple/search_algorithm.py", "max_forks_repo_name": "sidneymau/simple", "max_forks_repo_head_hexsha": "df1fb1d8cfdbf6f4964a6554072b56609baf5245", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-12T03:01:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-28T22:07:37.000Z", "avg_line_length": 40.7697841727, "max_line_length": 237, "alphanum_fraction": 0.7170460561, "include": true, "reason": "import numpy,import astropy", "num_tokens": 2951}
|
# python3
#
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# 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
#
# https://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.
"""Example using TF Lite to detect objects with the Raspberry Pi camera."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import io
import re
import time
from annotation import Annotator
from gpiozero import LED
import numpy as np
import picamera
from PIL import Image
from tflite_runtime.interpreter import Interpreter
CAMERA_WIDTH = 640
CAMERA_HEIGHT = 480
def load_labels(path):
"""Loads the labels file. Supports files with or without index numbers."""
with open(path, 'r', encoding='utf-8') as f:
lines = f.readlines()
labels = {}
for row_number, content in enumerate(lines):
pair = re.split(r'[:\s]+', content.strip(), maxsplit=1)
if len(pair) == 2 and pair[0].strip().isdigit():
labels[int(pair[0])] = pair[1].strip()
else:
labels[row_number] = pair[0].strip()
return labels
def set_input_tensor(interpreter, image):
"""Sets the input tensor."""
tensor_index = interpreter.get_input_details()[0]['index']
input_tensor = interpreter.tensor(tensor_index)()[0]
input_tensor[:, :] = image
def get_output_tensor(interpreter, index):
"""Returns the output tensor at the given index."""
output_details = interpreter.get_output_details()[index]
tensor = np.squeeze(interpreter.get_tensor(output_details['index']))
return tensor
def intersect(box):
hotspot_width = 140
#r2
h_xmin = int ((CAMERA_WIDTH - hotspot_width) / 2)
h_xmax = int (h_xmin + hotspot_width)
h_ymin = int ((CAMERA_HEIGHT - hotspot_width) / 2)
h_ymax = int (h_ymin + hotspot_width)
#r1
ymin, xmin, ymax, xmax = box
xmin = int(xmin * CAMERA_WIDTH)
xmax = int(xmax * CAMERA_WIDTH)
ymin = int(ymin * CAMERA_HEIGHT)
ymax = int(ymax * CAMERA_HEIGHT)
return not(h_xmin > xmax or h_xmax < xmin or h_ymax < ymin or h_ymin > ymax)
def detect_objects(interpreter, image, threshold):
"""Returns a list of detection results, each a dictionary of object info."""
set_input_tensor(interpreter, image)
interpreter.invoke()
# Get all output details
boxes = get_output_tensor(interpreter, 0)
classes = get_output_tensor(interpreter, 1)
scores = get_output_tensor(interpreter, 2)
count = int(get_output_tensor(interpreter, 3))
results = []
for i in range(count):
# We don't have birds or dogs in the gallery - always mark them as people.
if scores[i] >= threshold and (classes[i] == 0 or classes[i] == 15 or classes[i] == 16 or classes[i] == 17) and intersect(boxes[i]):
result = {
'bounding_box': boxes[i],
'class_id': 0,
'score': scores[i]
}
results.append(result)
return results
def annotate_objects(annotator, results, labels):
"""Draws the bounding box and label for each object in the results."""
for obj in results:
# Convert the bounding box figures from relative coordinates
# to absolute coordinates based on the original resolution
ymin, xmin, ymax, xmax = obj['bounding_box']
xmin = int(xmin * CAMERA_WIDTH)
xmax = int(xmax * CAMERA_WIDTH)
ymin = int(ymin * CAMERA_HEIGHT)
ymax = int(ymax * CAMERA_HEIGHT)
# Overlay the box, label, and score on the camera preview
annotator.bounding_box([xmin, ymin, xmax, ymax])
annotator.text([xmin, ymin],
'%s\n%.2f' % (labels[obj['class_id']], obj['score']))
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--model', help='File path of .tflite file.', required=True)
parser.add_argument(
'--labels', help='File path of labels file.', required=True)
parser.add_argument(
'--threshold',
help='Score threshold for detected objects.',
required=False,
type=float,
default=0.4)
args = parser.parse_args()
labels = load_labels(args.labels)
interpreter = Interpreter(args.model)
interpreter.allocate_tensors()
_, input_height, input_width, _ = interpreter.get_input_details()[0]['shape']
led = LED(14)
with picamera.PiCamera(
resolution=(CAMERA_WIDTH, CAMERA_HEIGHT), framerate=30) as camera:
camera.start_preview()
# Save the first frame to disk, so it can be downloaded for calibration
# and configuration purposes.
camera.capture('test.jpg');
last_time = time.time_ns()
on = False
try:
stream = io.BytesIO()
annotator = Annotator(camera)
for _ in camera.capture_continuous(
stream, format='jpeg', use_video_port=True):
stream.seek(0)
image = Image.open(stream).convert('RGB').resize(
(input_width, input_height), Image.ANTIALIAS)
start_time = time.monotonic()
results = detect_objects(interpreter, image, args.threshold)
elapsed_ms = (time.monotonic() - start_time) * 1000
# If we have detected something that looks like a person - toggle the
# relay.
if len(results) == 0 and on:
on = False
last_time = time.time_ns()
elif len(results) > 0:
on = True
led.on()
# We will wait a second when it has stopped detecting before turning
# the relay off. This stops bouncing if the algorithm can't get a
# solid fix on a person.
delta_t = (time.time_ns() - last_time) / 1000000000
if not on and delta_t > 1.0:
led.off()
annotator.clear()
annotate_objects(annotator, results, labels)
annotator.text([5, 0], '%.1fms' % (elapsed_ms))
annotator.update()
stream.seek(0)
stream.truncate()
finally:
camera.stop_preview()
if __name__ == '__main__':
main()
|
{"hexsha": "4f07e34d603aba5f754bb143214a9376e542d7b3", "size": 6346, "ext": "py", "lang": "Python", "max_stars_repo_path": "sensor.py", "max_stars_repo_name": "cfreeman/hota-alinta", "max_stars_repo_head_hexsha": "70f07a853800bf051e17a51e099b9d8069a35561", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sensor.py", "max_issues_repo_name": "cfreeman/hota-alinta", "max_issues_repo_head_hexsha": "70f07a853800bf051e17a51e099b9d8069a35561", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sensor.py", "max_forks_repo_name": "cfreeman/hota-alinta", "max_forks_repo_head_hexsha": "70f07a853800bf051e17a51e099b9d8069a35561", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.73, "max_line_length": 136, "alphanum_fraction": 0.676489127, "include": true, "reason": "import numpy", "num_tokens": 1547}
|
import os
import uuid
import pathlib
import numpy as np
import torch
import baselines.methods.bulkandcut as bnc
from baselines.problems import get_flowers
from baselines.problems import flowers
from baselines.problems import get_fashion
from baselines.problems import fashion
from baselines import save_experiment
def get_datasets(path):
x_train = torch.tensor(np.load(path('x_train.npy'))).float()
x_train = x_train.permute(0, 3, 1, 2)
y_train = torch.tensor(np.load(path('y_train.npy'))).long()
ds_train = torch.utils.data.TensorDataset(x_train, y_train)
x_val = torch.tensor(np.load(path('x_val.npy'))).float()
x_val = x_val.permute(0, 3, 1, 2)
y_val = torch.tensor(np.load(path('y_val.npy'))).long()
ds_val = torch.utils.data.TensorDataset(x_val, y_val)
x_test = torch.tensor(np.load(path('x_test.npy'))).float()
x_test = x_test.permute(0, 3, 1, 2)
y_test = torch.tensor(np.load(path('y_test.npy'))).long()
ds_test = torch.utils.data.TensorDataset(x_test, y_test)
return ds_train, ds_val, ds_test
if __name__ == '__main__':
# Parameters Flowers
input_shape = (3, 16, 16)
num_classes = 17
budget = 24 * 3600
path = lambda x: str(
pathlib.Path(flowers.__file__).
parent.absolute().joinpath('data').joinpath(x)
)
experiment = get_flowers('BNC')
# Parameters Fashion
# input_shape = (1, 28, 28)
# num_classes = 10
# budget = 24 * 3600
# path = lambda x: str(
# pathlib.Path(fashion.__file__).
# parent.absolute().joinpath('data').joinpath(x)
# )
# experiment = get_fashion('BNC')
################
#### MOBOHB ####
################
# Run a full optimization:
ds_train, ds_val, ds_test = get_datasets(path)
work_dir = os.path.join('bulkandcutoutput', f"{str(uuid.uuid4())}")
evolution = bnc.Evolution(
experiment,
input_shape=input_shape,
n_classes=num_classes,
work_directory=work_dir,
train_dataset=ds_train,
valid_dataset=ds_val,
test_dataset=ds_test,
debugging=False,
)
evolution.run(time_budget=budget)
save_experiment(experiment, f'{experiment.name}.pickle')
|
{"hexsha": "39c015ef8fcd8acf4e510c018713769fdb72bf2f", "size": 2227, "ext": "py", "lang": "Python", "max_stars_repo_path": "examples/bulkandcut.py", "max_stars_repo_name": "serizba/multi-obj-baselines", "max_stars_repo_head_hexsha": "b5c97b8009ed32f0eb9a08454cf0d4c6620a2286", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2021-05-02T10:03:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-14T00:52:03.000Z", "max_issues_repo_path": "examples/bulkandcut.py", "max_issues_repo_name": "serizba/multi-obj-baselines", "max_issues_repo_head_hexsha": "b5c97b8009ed32f0eb9a08454cf0d4c6620a2286", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-05-18T05:42:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-18T05:42:31.000Z", "max_forks_repo_path": "examples/bulkandcut.py", "max_forks_repo_name": "serizba/multi-obj-baselines", "max_forks_repo_head_hexsha": "b5c97b8009ed32f0eb9a08454cf0d4c6620a2286", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-16T14:28:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:28:38.000Z", "avg_line_length": 28.1898734177, "max_line_length": 71, "alphanum_fraction": 0.6524472384, "include": true, "reason": "import numpy", "num_tokens": 600}
|
[STATEMENT]
lemma (in node_histories) prefix_elem_to_carriers:
assumes "xs prefix of i"
and "x \<in> set xs"
shows "x \<in> set (history i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<in> set (history i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
xs prefix of i
x \<in> set xs
goal (1 subgoal):
1. x \<in> set (history i)
[PROOF STEP]
by(clarsimp simp: prefix_of_node_history_def) (metis Un_iff set_append)
|
{"llama_tokens": 186, "file": "CRDT_Network", "length": 2}
|
import sys
import numpy as np
import tensorflow
from tensorflow.keras.models import Model
def openset_predict(model: Model, X_test: np.ndarray) -> np.ndarray:
predictions = model.predict(X_test)
openset_predictions = predict_on_threshold(predictions)
return openset_predictions
def predict_on_threshold(predictions: np.ndarray, threshold: float = 0.5) -> np.ndarray:
predict_openset = np.zeros((predictions.shape[0], predictions.shape[1]))
for j in range(predictions.shape[0]):
max_value = np.amax(predictions[j, :])
idx_max_value = np.where(predictions[j, :] == max_value)
idx_max_value = idx_max_value[0]
if max_value >= threshold:
predict_openset[j, idx_max_value] = 1
return predict_openset
if sys.argv[1] == 'l3':
from feature_extraction.transfer_learning import AudioL3
extractor = AudioL3()
elif sys.argv[1] == 'yamnet':
from feature_extraction.transfer_learning import YamNet
extractor = YamNet()
else:
raise Exception('Not available pre-trained network')
print('Not available pre-trained network')
emb = extractor.get_embedding(sys.argv[2])
emb = np.expand_dims(emb, axis=0)
print(emb.shape)
# load model with keras
model = tensorflow.keras.models.load_model(sys.argv[3])
preds = openset_predict(model, emb)
print(preds)
|
{"hexsha": "aa4c7a4942ceade8b16f3b1d847b0cb285ac9aad", "size": 1338, "ext": "py", "lang": "Python", "max_stars_repo_path": "demo.py", "max_stars_repo_name": "Machine-Listeners-Valencia/fsl_osr_dataset_baseline", "max_stars_repo_head_hexsha": "06c99e2e715be550ac0c85c5c1e4f713228d5450", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-09-14T00:44:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-15T14:15:45.000Z", "max_issues_repo_path": "demo.py", "max_issues_repo_name": "Machine-Listeners-Valencia/fsl_osr_dataset_baseline", "max_issues_repo_head_hexsha": "06c99e2e715be550ac0c85c5c1e4f713228d5450", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "demo.py", "max_forks_repo_name": "Machine-Listeners-Valencia/fsl_osr_dataset_baseline", "max_forks_repo_head_hexsha": "06c99e2e715be550ac0c85c5c1e4f713228d5450", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-24T04:35:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T04:35:20.000Z", "avg_line_length": 26.76, "max_line_length": 88, "alphanum_fraction": 0.72122571, "include": true, "reason": "import numpy", "num_tokens": 315}
|
"Symbolic integration via external software"
from sage.symbolic.expression import Expression
from sage.symbolic.ring import SR
def maxima_integrator(expression, v, a=None, b=None):
"""
sage: from sage.symbolic.integration.external import maxima_integrator
sage: maxima_integrator(sin(x), x)
-cos(x)
sage: maxima_integrator(cos(x), x)
sin(x)
sage: f(x) = function('f', x)
sage: maxima_integrator(f(x), x)
integrate(f(x), x)
"""
from sage.calculus.calculus import maxima
if not isinstance(expression, Expression):
expression = SR(expression)
if a is None:
result = maxima.sr_integral(expression,v)
else:
result = maxima.sr_integral(expression, v, a, b)
return result._sage_()
def sympy_integrator(expression, v, a=None, b=None):
"""
sage: from sage.symbolic.integration.external import sympy_integrator
sage: sympy_integrator(sin(x), x)
-cos(x)
sage: sympy_integrator(cos(x), x)
sin(x)
"""
import sympy
ex = expression._sympy_()
v = v._sympy_()
if a is None:
result = sympy.integrate(ex, v)
else:
result = sympy.integrate(ex, (v, a._sympy_(), b._sympy_()))
return result._sage_()
def mma_free_integrator(expression, v, a=None, b=None):
"""
sage: from sage.symbolic.integration.external import mma_free_integrator
sage: mma_free_integrator(sin(x), x) # optional - internet
-cos(x)
"""
import urllib, re
# We need to integrate against x
vars = [str(x) for x in expression.variables()]
if any(len(x)>1 for x in vars):
raise NotImplementedError("Mathematica online integrator can only handle single letter variables.")
x = SR.var('x')
if repr(v) != 'x':
for i in range(ord('a'), ord('z')+1):
if chr(i) not in vars:
shadow_x = SR.var(chr(i))
break
expression = expression.subs({x:shadow_x}).subs({dvar: x})
params = urllib.urlencode({'expr': expression._mathematica_init_(), 'random': 'false'})
page = urllib.urlopen("http://integrals.wolfram.com/index.jsp", params).read()
page = page[page.index('"inputForm"'):page.index('"outputForm"')]
page = re.sub("\s", "", page)
mexpr = re.match(r".*Integrate.*==</em><br/>(.*)</p>", page).groups()[0]
try:
ans = SR(mexpr.lower().replace('[', '(').replace(']', ')'))
if repr(v) != 'x':
ans = ans.subs({x:v}).subs({shadow_x:x})
return ans
except TypeError:
raise ValueError("Unable to parse: %s" % mexpr)
def fricas_integrator(expression, v, a=None, b=None):
"""
Integration using FriCAS
EXAMPLES::
sage: from sage.symbolic.integration.external import fricas_integrator # optional - fricas
sage: fricas_integrator(sin(x), x) # optional - fricas
-cos(x)
sage: fricas_integrator(cos(x), x) # optional - fricas
sin(x)
sage: fricas_integrator(1/(x^2-2), x, 0, 1) # optional - fricas
1/4*(log(3*sqrt(2) - 4) - log(sqrt(2)))*sqrt(2)
sage: fricas_integrator(1/(x^2+6), x, -oo, oo) # optional - fricas
1/6*pi*sqrt(6)
"""
if not isinstance(expression, Expression):
expression = SR(expression)
if a is None:
result = expression._fricas_().integrate(v)
else:
import sage.rings.infinity
if a == sage.rings.infinity.PlusInfinity():
a = "%plusInfinity"
elif a == sage.rings.infinity.MinusInfinity():
a = "%minusInfinity"
if b == sage.rings.infinity.PlusInfinity():
b = "%plusInfinity"
elif b == sage.rings.infinity.MinusInfinity():
b = "%minusInfinity"
result = expression._fricas_().integrate("{}={}..{}".format(v, a, b))
locals = {str(v): v for v in expression.variables()}
if str(result) == "potentialPole":
raise ValueError("The integrand has a potential pole"
" in the integration interval")
parsed_result = result.unparsed_input_form()
import sage.misc.sage_eval
try:
return sage.misc.sage_eval.sage_eval(parsed_result, locals=locals)
except:
raise ValueError("Unable to parse: {}".format(parsed_result))
|
{"hexsha": "481ee9c01dee266af872e46c2f0c6eb48ee14ea5", "size": 4452, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/sage/symbolic/integration/external.py", "max_stars_repo_name": "switzel/sage", "max_stars_repo_head_hexsha": "7eb8510dacf61b691664cd8f1d2e75e5d473e5a0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/sage/symbolic/integration/external.py", "max_issues_repo_name": "switzel/sage", "max_issues_repo_head_hexsha": "7eb8510dacf61b691664cd8f1d2e75e5d473e5a0", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sage/symbolic/integration/external.py", "max_forks_repo_name": "switzel/sage", "max_forks_repo_head_hexsha": "7eb8510dacf61b691664cd8f1d2e75e5d473e5a0", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-24T12:20:37.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-24T12:20:37.000Z", "avg_line_length": 38.0512820513, "max_line_length": 107, "alphanum_fraction": 0.5862533693, "include": true, "reason": "import sympy,import sage,from sage", "num_tokens": 1134}
|
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import matplotlib.gridspec as gridspec
import scipy.io as scio
import numpy as np
from minisom import MiniSom
import math
import torch
from RBF import RBF
from sklearn import svm
'''
分类函数
'''
def classify(som,data,winmap):
from numpy import sum as npsum
default_class = npsum(list(winmap.values())).most_common()[0][0]
result = []
for d in data:
win_position = som.winner(d)
if win_position in winmap:
result.append(winmap[win_position].most_common()[0][0])
else:
result.append(default_class)
return result
def SOM_RBF():
'''
导入数据 214个1 116个-1
'''
data_train = scio.loadmat('data_train.mat')['data_train']
data_test = scio.loadmat('data_test.mat')['data_test']
data_label = scio.loadmat('label_train.mat')['label_train'].squeeze()
print(data_train)
'''
#划分训练集和验证集 7:3
'''
X_train, X_valid, y_train, y_valid = train_test_split(data_train,data_label,test_size=0.3,random_state=1,stratify=data_label)
print(sum(y_train))
print(">> shape of training data:",X_train.shape)
print(">> shape of validation data:",X_valid.shape)
'''
#训练SOM
'''
N = X_train.shape[0] #样本数量
M = X_train.shape[1] #维度/特征数量
'''
设置超参数
'''
# size = math.ceil(np.sqrt(5 * np.sqrt(N))) # 经验公式:决定输出层尺寸
size=8
print("训练样本个数:{} 测试样本个数:{}".format(N,X_valid.shape[0]))
print("输出网格最佳边长为:",size)
max_iter = 40000
sigma_0= (np.sqrt((size-1)**2+(size-1)**2))/2
print('initial sigma:',sigma_0)
# Initialization and training
som = MiniSom(size, size, M, sigma=1, learning_rate=0.1, neighborhood_function='gaussian')
'''
初始化权值,有2个API
'''
#som.random_weights_init(X_train)
som.pca_weights_init(X_train)
'''
开始训练
'''
som.train_batch(X_train, max_iter, verbose=False)
#som.train_random(X_train, max_iter, verbose=False)
'''
分类
'''
winmap = som.labels_map(X_train,y_train)
print(winmap)
y_pred = classify(som,X_valid,winmap)
print('SOM validation accuracy')
print(classification_report(y_valid, np.array(y_pred)))
'''
输出权重
'''
weights = som.get_weights().copy()
# print(type(weights))
# print(weights.shape)
# print(weights)
center_vectors=weights.reshape(-1,33)
print(">> shape of center_vectors:",center_vectors.shape)
# print(center_vectors)
'''
# 训练RBF
# '''
#转换数据类型X_train, X_valid, y_train, y_valid, data_test
center_vectors = torch.tensor(center_vectors)
X = torch.tensor(X_train)
# print(X)
train_label = torch.tensor(y_train).unsqueeze(1)
y_trainT = torch.tensor(y_train,dtype=torch.int32)
# print(y_trainT.dtype)
valid_X = torch.tensor(X_valid)
valid_label = torch.tensor(y_valid).unsqueeze(1)
y_validT = torch.tensor(y_valid, dtype=torch.int32)
test_X = torch.tensor(data_test)
# print(test_X)
# print(center_vectors.dtype,X.dtype)
# print(X,X.size())
# print(train_label,train_label.size())
print('Building RBF model...')
RBF_model = RBF(33, center_vectors, 1)
weight = RBF_model.train(X, train_label)
predictions_train = RBF_model.test(X).int()
predictions_valid = RBF_model.test(valid_X).int()
predictions_test = RBF_model.test(test_X).int()
# print(predictions_train.dtype)
# print(predictions_valid)
# print(y_validT)
print(classification_report(y_trainT,predictions_train))
print(classification_report(y_validT,predictions_valid))
accuracy_train = (predictions_train == y_trainT).sum() / torch.tensor(X.size(0)).float()
accuracy_valid = (predictions_valid == y_validT).sum() / torch.tensor(valid_X.size(0)).float()
print("accuracy of training data:", accuracy_train)
print("accuracy of validation data:", accuracy_valid)
print(predictions_test)
# '''
# 可视化
# '''
# # U-max
# # plt.figure(figsize=(9,9),num=0)
# # heatmap = som.distance_map() #生成U-Matrix
# # print(heatmap,heatmap[3,1])
#
# # plt.imshow(heatmap,cmap='bone_r')
# # plt.pcolor(heatmap, cmap='bone_r') #miniSom案例中用的pcolor函数,需要调整坐标
# # plt.colorbar()
# # plt.plot(0 + .5, 0 + .5, 'o', markerfacecolor='None',
# # markeredgecolor='C0', markersize=12, markeredgewidth=2)
# # plt.show()
#
# plt.figure(figsize=(9, 9),num=0)
# # 背景上画U-Matrix
# heatmap = som.distance_map()
# plt.pcolor(heatmap.T, cmap='bone_r') # plotting the distance map as background
# plt.colorbar()
# # 定义不同标签的图案标记
# markers = {1: 'o', -1: 's'}
# colors = {1: 'C0', -1: 'C3'}
# category_color = {'Class 1': 'C0',
# 'Class -1': 'C3',}
# for cnt, xx in enumerate(X_train):
# w = som.winner(xx) # getting the winner
# # 在样本Heat的地方画上标记
# plt.plot(w[0]+.5, w[1]+.5, markers[y_train[cnt]], markerfacecolor='None',
# markeredgecolor=colors[y_train[cnt]], markersize=12, markeredgewidth=2)
# plt.axis([0, 8, 0, 8])
# # ax = plt.gca()
# # ax.invert_yaxis() #颠倒y轴方向
# legend_elements = [Patch(facecolor=clr,
# edgecolor='w',
# label=l) for l, clr in category_color.items()]
# plt.legend(handles=legend_elements, loc='lower left', bbox_to_anchor=(1.20, 0.9))
# plt.show()
#
# label_name_map_number = {"Class 1": 0, "Class -1": 1}
#
# from matplotlib.gridspec import GridSpec
# plt.figure(figsize=(9, 9),num=1)
# the_grid = GridSpec(8, 8)
# # YY=0
# for position in winmap.keys():
# # print(position)
# label_fracs = [winmap[position][label] for label in [-1, 1]]
# # print(label_fracs)
# # YY+=label_fracs[0]
# plt.subplot(the_grid[7-position[1], position[0]], aspect=1)
# patches, texts = plt.pie(label_fracs,colors=['C3','C0'])
# plt.text(position[0] / 100, position[1] / 100, str(len(list(winmap[position].elements()))),
# color='black', fontdict={'weight': 'bold', 'size': 15},
# va='center', ha='center')
# # plt.legend(handles=legend_elements, loc='lower left', bbox_to_anchor=(1.15, 0.95))
# plt.show()
# # print(YY)
def SVM():
data_train = scio.loadmat('data_train.mat')
data_test = scio.loadmat('data_test.mat')
data_label = scio.loadmat('label_train.mat')
X = data_train['data_train']
y = np.squeeze(data_label['label_train'])
test = data_test['data_test']
print(test)
X_train, X_valid, y_train, y_valid = train_test_split(X, y, test_size=0.3, random_state=1,stratify=y)
print(">> shape of training data:", X_train.shape)
print(">> shape of validation data:", X_valid.shape)
print(sum(y_valid))
print('Building SVM model')
clf = svm.SVC(C=0.5,kernel='rbf',gamma=0.5,decision_function_shape='ovo')
clf.fit(X_train,y_train)
predictions = clf.predict(X_train)
accuracy_training = (predictions==y_train).sum().__float__() / X_train.shape[0]
predictions_valid = clf.predict(X_valid)
accuracy_valid = (predictions_valid == y_valid).sum().__float__() / X_valid.shape[0]
predictions_y = clf.predict(test)
print(">>accuracy_training :",accuracy_training)
print(">>accuracy_validation :", accuracy_valid)
print(predictions_y)
if __name__ == '__main__':
mode = 0
if mode == 0:
SOM_RBF()
else:
SVM()
|
{"hexsha": "53fb0d5bb337e2d154b060ab83e345f0e9031057", "size": 7846, "ext": "py", "lang": "Python", "max_stars_repo_path": "main.py", "max_stars_repo_name": "KGTKD/EE7207", "max_stars_repo_head_hexsha": "8fde6310aba96b58631f1652e2c32663d621a0d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.py", "max_issues_repo_name": "KGTKD/EE7207", "max_issues_repo_head_hexsha": "8fde6310aba96b58631f1652e2c32663d621a0d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.py", "max_forks_repo_name": "KGTKD/EE7207", "max_forks_repo_head_hexsha": "8fde6310aba96b58631f1652e2c32663d621a0d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1838565022, "max_line_length": 130, "alphanum_fraction": 0.614835585, "include": true, "reason": "import numpy,from numpy,import scipy", "num_tokens": 2240}
|
# Copyright 2021 Franklin Siqueira.
# SPDX-License-Identifier: Apache-2.0
'''
Created on Jul 12, 2019
@author: franklincarrilho
'''
from pandas_datareader import data
from dateutil.relativedelta import relativedelta
import datetime
from datetime import date, time
import yfinance as yf
import numpy as np
# import matplotlib.pyplot as plt
# import seaborn as sea
# from bokeh.plotting import figure, show, output_file, ColumnDataSource
# from bokeh.layouts import gridplot, Box
# from bokeh.embed import components
# from bokeh.resources import CDN
# from bokeh.models import HoverTool, LayoutDOM, NumeralTickFormatter, Legend, LegendItem
# import for importing WikipidiA data
import bs4 as bs
import pickle
import requests
import os
import pandas as pd
import time as tmp
# mpltLibPlot, getSP500Stocks, getB3Stocks, getDataB3Stocks, getDataSP500Stocks, condenseData
# def mpltLibPlot(figureName, dataFrameName):
# '''
# matplotlib to axis plot
# **********************
# requires: mtplotlib, pandas, seaborn
# '''
# mpltFigure = figureName
# dfAnalysis = dataFrameName
# mpltFigure, (axis1, axis2) = plt.subplots(2, 1, figsize = (16, 12))
#
# #relReturns = dfAnalysis.pct_change(1)
# logReturns = np.log(dfAnalysis).diff()
#
# for c in logReturns:
# axis1.plot(logReturns.index, logReturns[c].cumsum(), label = str(c))
#
# axis1.set_ylabel("Cumulative Log Returns")
# axis1.legend(loc ="best")
#
# for c in logReturns:
# axis2.plot(logReturns.index, 100*(np.exp(logReturns[c].cumsum())-1), label = str(c))
#
# axis2.set_ylabel("Total Relative Returns (%)")
# axis2.legend(loc ="best")
#
# return mpltFigure
# define function to get S&P 500 data
def getSP500Stocks(pickFile):
'''
matplotlib 2 axis plot
************************
requires: BeautifulSoup4
'''
response = requests.get("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
soup = bs.BeautifulSoup(response.text, "lxml")
table = soup.find("table", {"class":"wikitable sortable"})
tickers = []
for row in table.findAll("tr")[1:]:
ticker = row.findAll("td")[0].text
tickers.append(ticker.rstrip("\n"))
# write bytes to memory "wb"
with open(pickFile, "wb") as file:
pickle.dump(tickers, file)
print(tickers)
return tickers
# define function to get B3 data
def getB3Stocks(pickFile):
response = requests.get("https://en.wikipedia.org/wiki/List_of_companies_listed_on_Ibovespa")
soup = bs.BeautifulSoup(response.text, "lxml")
table = soup.find("table", {"class":"wikitable sortable"})
tickers = []
for row in table.findAll("tr")[1:]:
tickerSymbol = row.findAll("td")[1].text
#tickerName = row.findAll("td")[1].text
tickers.append(tickerSymbol.rstrip("\n"))
# write bytes to memory "wb"
with open(pickFile, "wb") as file:
pickle.dump(tickers, file)
print(tickers)
return tickers
# getDataB3Stocks
def getDataB3Stocks(pickFile, pickDir, reLoadB3 = False):
if reLoadB3 or not os.path.exists(pickDir):
os.makedirs(pickDir)
tickers = getB3Stocks(pickFile)
else:
# read bytes from memory "rb" or file
with open(pickFile, "rb") as file:
tickers = pickle.load(file)
if not os.path.exists(pickDir):
os.makedirs(pickDir)
generalStartDate = datetime.datetime(2014, 1, 1)
generalEndDate = date.today()
stocksNumber = []
for count, ticker in enumerate(tickers):
stocksNumber = tickers[count:count+10]
if count % 10 == 0:
print(count)
for ticker in stocksNumber:
#if not os.path.exists("../stocks_B3dfs/{}.csv".format(ticker)):
if not os.path.exists(os.path.join(pickDir, "{}.csv".format(ticker))):
#= os.path.join(pickDir, "{}.csv".format(ticker))
try:
df = data.get_data_yahoo(ticker, start = generalStartDate, end = generalEndDate)
# os.path.join(pickDir, "{}.csv".format(ticker))
# df.to_csv("../stocks_B3dfs/{}.csv".format(ticker))
df.to_csv(os.path.join(pickDir, "{}.csv".format(ticker)))
except:
pass
print("Values added to {}".format(ticker), count)
else:
print("Values already loaded to {}".format(ticker), count)
#pass
# getDataSP500Stocks
def getDataSP500Stocks(pickFile, pickDir, reLoadSP500 = False):
if reLoadSP500 or not os.path.exists(pickDir):
os.makedirs(pickDir)
tickers = getSP500Stocks(pickFile)
else:
# read bytes from memory "rb" or file
with open(pickFile, "rb") as file:
tickers = pickle.load(file)
if not os.path.exists(pickDir):
os.makedirs(pickDir)
generalStartDate = datetime.datetime(2014, 1, 1)
generalEndDate = date.today()
stocksNumber = []
for count, ticker in enumerate(tickers):
stocksNumber = tickers[count:count+10]
if count % 10 == 0:
print(count)
for ticker in stocksNumber:
if not os.path.exists(os.path.join(pickDir, "{}.csv".format(ticker))):
try:
df = data.get_data_yahoo(ticker, start = generalStartDate, end = generalEndDate)
df.to_csv(os.path.join(pickDir, "{}.csv".format(ticker)))
except:
pass
print("Values added to {}".format(ticker), count)
else:
#print("Values already loaded to {}".format(ticker), count)
pass
# condenseData()
def condenseData():
with open("../sp500tickers.pickle", "rb") as file:
tickers = pickle.load(file)
mainDf = pd.DataFrame()
for count, ticker in enumerate(tickers):
try:
df = pd.read_csv("../stocks_dfs/{}.csv".format(ticker))
df.set_index("Date", inplace = True)
df.rename(columns = {"Adj Close":ticker}, inplace = True)
df.drop(["Open", "High", "Low", "Close", "Volume"], 1, inplace = True)
except:
pass
if mainDf.empty:
mainDf = df
else:
mainDf = mainDf.merge(df, how = "outter", on = "Date")
if count % 10 == 0:
print(count)
print(mainDf.head())
mainDf.to_csv("../sp500Condensed.csv")
################## end functions ########################
|
{"hexsha": "f0c9e1098b78d9cc62b981fb9e7164b9eeb50c77", "size": 6863, "ext": "py", "lang": "Python", "max_stars_repo_path": "app18/stocks.py", "max_stars_repo_name": "Franklin-Siqueira/Python-Generic-lLab", "max_stars_repo_head_hexsha": "c56208d14196b4ed2046ecf604c2b535fbdcf2c9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app18/stocks.py", "max_issues_repo_name": "Franklin-Siqueira/Python-Generic-lLab", "max_issues_repo_head_hexsha": "c56208d14196b4ed2046ecf604c2b535fbdcf2c9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app18/stocks.py", "max_forks_repo_name": "Franklin-Siqueira/Python-Generic-lLab", "max_forks_repo_head_hexsha": "c56208d14196b4ed2046ecf604c2b535fbdcf2c9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.9209302326, "max_line_length": 100, "alphanum_fraction": 0.5783185196, "include": true, "reason": "import numpy", "num_tokens": 1704}
|
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""Combine Normalized DRACS Specta.
Script that take one imput parameter which is the path to the normobs directory
Needs functions/modules to get the filenames, export to a fits tablefile, change fits hdr
"""
import argparse
import fnmatch
import os
import time
import IOmodule
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
from astropy.io import fits
def get_filenames(path, regexp, regexp2=False):
"""Regexp must be a regular expression as a string.
eg '*.ms.*', '*_2.*', '*.ms.norm.fits*'
resexp2 is if want to match two expressions such as
'*_1*' and '*.ms.fits*'
"""
os.chdir(path)
filelist = []
for file in os.listdir('.'):
if regexp2: # Match two regular expresions
if fnmatch.fnmatch(file, regexp) and fnmatch.fnmatch(file, regexp2):
# print file
filelist.append(file)
else:
if fnmatch.fnmatch(file, regexp):
# print file
filelist.append(file)
filelist.sort()
return filelist
def SumNods(Spectra, Headers, Pos="All", Norm="None"):
"""Add together the nod postitions of Crires spectra.
Currently this implements baised on expected nod ordering,
If want to be more sure the correct nods are added the headers
should be checked for its nod position.
"""
if Pos == "All":
NodNum = len(Spectra)
else:
NodNum = len(Spectra) / 2.0
# print("number of nods ", NodNum)
# if Headers[i]["HIERARCH ESO SEQ NODPOS"] == Pos:
NodSum = np.zeros_like(Spectra[0])
if Pos.upper() == "ALL":
# Sum all
# NodNum = 8
for Spec in Spectra:
NodSum += np.array(Spec)
elif Pos.upper() == "A":
# Sum A nods
# NodNum = 4
# for i in [0, 3, 4, 7]:
# NodSum += np.array(Spectra[i])
for Spec, hdr in zip(Spectra, Headers):
if hdr["HIERARCH ESO SEQ NODPOS"] == "A":
NodSum += np.array(Spec)
elif Pos.upper() == "B":
# Sum B nods
# NodNum = 4
# for i in [1, 2, 5, 6]:
# NodSum += np.array(Spectra[i])
for Spec, hdr in zip(Spectra, Headers):
if hdr["HIERARCH ESO SEQ NODPOS"] == "B":
NodSum += np.array(Spec)
if Norm.upper() == "MEDIAN":
NodSum /= np.median(NodSum)
elif Norm.upper() == "MEAN":
NodSum /= np.mean(NodSum)
elif Norm.upper() == "DIVIDE":
NodSum /= NodNum
return NodSum
def ExportToFits(Outputfile, Norm_All, NodA, NodB, hdr, hdrkeys, hdrvals):
"""Write Combined DRACS CRIRES NOD Spectra to a fits table file."""
col1 = fits.Column(name="Combined", format="E", array=Norm_All) # colums of data
col2 = fits.Column(name="Nod A", format="E", array=NodA)
col3 = fits.Column(name="Nod B", format="E", array=NodB)
cols = fits.ColDefs([col1, col2, col3])
tbhdu = fits.BinTableHDU.from_columns(cols) # binary tbale hdu
prihdr = append_hdr(hdr, hdrkeys, hdrvals)
prihdu = fits.PrimaryHDU(header=prihdr)
thdulist = fits.HDUList([prihdu, tbhdu])
thdulist.writeto(Outputfile, output_verify="silentfix") # Fixing errors to work properly
return None
def append_hdr(hdr, keys, values, item=0):
"""Apend/change parameters to fits hdr.
Can take list or tuple as input of keywords
and values to change in the header
Defaults at changing the header in the 0th item
unless the number the index is givien,
If a key is not found it adds it to the header.
"""
# open fits file
# hdulist = fits.open(output)
# hdr = hdulist[item].header
# print repr(hdr[0:10])
# assert type(keys) == type(values), 'keys and values do not match'
if type(keys) == str: # To handle single value
hdr[keys] = values
else:
assert len(keys) == len(values), 'Not the same number of keys as values'
for i in range(len(keys)):
hdr[keys[i]] = values[i]
print(repr(hdr[-2:10]))
return hdr
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Combine CRIRES Nod positions \
Normized values')
parser.add_argument('inputpath', help='Path to normobs directory')
# parser.add_argument('-s', '--sun', help='Plot with spectra of the Sun (1)',
# default=False)
args = parser.parse_args()
# print args
path = args.inputpath
# find norm values in this directory:
chips = range(4)
for chip in chips:
# while True:
# chip = 1
org_vals = get_filenames(path, "CRIRE*.ms.fits", "*_" + str(chip + 1) + "*")
norm_vals = get_filenames(path, "CRIRE*.ms.norm.fits", "*_" + str(chip + 1) + "*")
i_dracs = []
i_dracs_hdrs = []
i_norm = []
i_norm_hdrs = []
for name in org_vals:
ThisFile = path + name
i_dracs.append(fits.getdata(ThisFile, 0))
i_dracs_hdrs.append(fits.getheader(ThisFile, 0))
dracs_All = SumNods(i_dracs, i_dracs_hdrs, Pos="All", Norm="Divide")
dracs_A = SumNods(i_dracs, i_dracs_hdrs, Pos="A", Norm="Divide")
dracs_B = SumNods(i_dracs, i_dracs_hdrs, Pos="B", Norm="Divide")
# print(norm_vals)
for name in norm_vals:
ThisFile = path + name
ThisNorm = fits.open(ThisFile)
Last_normhdr = ThisNorm[0].header
i_norm_hdrs.append(Last_normhdr)
i_norm.append(ThisNorm[0].data)
ThisNorm.close()
print("Inorm", i_norm)
NormalizeMethod = "Divide"
Norm_All = SumNods(i_norm, i_norm_hdrs, Pos="All", Norm=NormalizeMethod)
Norm_A = SumNods(i_norm, i_norm_hdrs, Pos="A", Norm=NormalizeMethod)
Norm_B = SumNods(i_norm, i_norm_hdrs, Pos="B", Norm=NormalizeMethod)
# plt.plot(dracs_All, label="dracs All")
# plt.plot(dracs_A, label="dracs A")
# plt.plot(dracs_B, label="dracs B")
# plt.legend()
# plt.show()
#
# plt.plot(Norm_All, label="All")
# plt.plot(Norm_A, label="A")
# plt.plot(Norm_B, label="B")
# plt.legend()
# plt.show()
# write ouput to fits file
# testhdr = fits.Header()
# testhdr['TESTVal'] = 'Edwin Hubble'
# testhdr['Date'] = (T_Now, ' Time fits was last changed')
T_Now = str(time.gmtime()[0:6])
outputfile = path + norm_vals[-1][0:-4] + "comb.fits"
print("Output file name", outputfile)
hdrkeys = ["Description"]
hdrvals = ["Combine DRACS Nomalized CRIRES Nod Spectra"]
hdrkeys = ['COMBINEDATE', "COMBINEMETHOD", "COMBNORMALIZE"]
hdrvals = [(T_Now, "Time Nods were combined"),
("Addition", "How nods were added"),
(NormalizeMethod, "Method for normalizing combined spectra (divide/mean/median)")]
for i, name in zip(range(len(org_vals)), org_vals):
hdrkeys.append("CRIRES NOD FILE " + str(i + 1))
hdrvals.append((name, "Input filename"))
ExportToFits(outputfile, Norm_All, Norm_A, Norm_B, Last_normhdr, hdrkeys, hdrvals)
print("Wrote to fits Succesfully")
# break
# # Try load in the combined nod spectra fits files now
|
{"hexsha": "87c727d692217e620b8c0cce1036fa61c75bdc7b", "size": 7398, "ext": "py", "lang": "Python", "max_stars_repo_path": "octotribble/Combine_nod_spectra.py", "max_stars_repo_name": "jason-neal/equanimous-octo-tribble", "max_stars_repo_head_hexsha": "a8788909331034725afe38ae96c83584b17c9fbd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-05-10T20:24:02.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-10T20:24:02.000Z", "max_issues_repo_path": "octotribble/Combine_nod_spectra.py", "max_issues_repo_name": "jason-neal/equanimous-octo-tribble", "max_issues_repo_head_hexsha": "a8788909331034725afe38ae96c83584b17c9fbd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-04-11T17:35:35.000Z", "max_issues_repo_issues_event_max_datetime": "2016-04-11T17:35:35.000Z", "max_forks_repo_path": "octotribble/Combine_nod_spectra.py", "max_forks_repo_name": "jason-neal/equanimous-octo-tribble", "max_forks_repo_head_hexsha": "a8788909331034725afe38ae96c83584b17c9fbd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-08-18T11:00:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-18T11:00:56.000Z", "avg_line_length": 34.8962264151, "max_line_length": 101, "alphanum_fraction": 0.5924574209, "include": true, "reason": "import numpy,import scipy,from astropy", "num_tokens": 2033}
|
[STATEMENT]
lemma lzip_trans'_fusion [stream_fusion]:
"lunstream' (lzip_trans' g h) (sg, sh, None) = lzip (lunstream' g sg) (lunstream' h sh)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. lunstream' (lzip_trans' g h) (sg, sh, None) = lzip (lunstream' g sg) (lunstream' h sh)
[PROOF STEP]
by transfer(rule lzip_trans_fusion)
|
{"llama_tokens": 146, "file": "Stream_Fusion_Code_Stream_Fusion_LList", "length": 1}
|
import os, sys, inspect
# realpath() with make your script run, even if you symlink it :)
cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0]) + "/../fdasrsf")
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)
import h5py
import numpy as np
import curve_functions as cf
import curve_regression as cr
fun = h5py.File('/Users/jdtucker/Documents/Research/SRVF_FDA/Data/Full20shapedata.h5')
C = fun['beta'][:]
C = C.T
a, b, c = C.shape
beta = np.zeros((a, b, 80))
for ii in range(0, 20):
beta_tmp = np.zeros((a, b+1))
beta_tmp[:, 0:b] = C[:, :, ii]
beta_tmp[:, b] = C[:, 0, ii]
beta[:, :, ii] = cf.resamplecurve(beta_tmp, b)
beta_tmp[:, 0:b] = C[:, :, ii+20]
beta_tmp[:, b] = C[:, 0, ii+20]
beta[:, :, ii+20] = cf.resamplecurve(beta_tmp, b)
beta_tmp[:, 0:b] = C[:, :, ii+40]
beta_tmp[:, b] = C[:, 0, ii+40]
beta[:, :, ii+40] = cf.resamplecurve(beta_tmp, b)
beta_tmp[:, 0:b] = C[:, :, ii+60]
beta_tmp[:, b] = C[:, 0, ii+60]
beta[:, :, ii+60] = cf.resamplecurve(beta_tmp, b)
y = np.ones(80, dtype=int)
y[20:40] = 2
y[40:60] = 3
y[60:80] = 4
model = cr.oc_elastic_mlogistic(beta, y, df=60, T=200, max_itr=40,
deltaO=.08, deltag=.05)
out = cr.oc_elastic_prediction(beta, model, y=y)
|
{"hexsha": "5871bf8695c1c4040fdef8f368a02902a0ee5194", "size": 1332, "ext": "py", "lang": "Python", "max_stars_repo_path": "debug/test_oc_mlogit.py", "max_stars_repo_name": "gitter-badger/fdasrsf_python", "max_stars_repo_head_hexsha": "f59bd74b570662c17a1a042556d4887e6a75fa3e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2017-02-17T13:48:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T11:17:14.000Z", "max_issues_repo_path": "debug/test_oc_mlogit.py", "max_issues_repo_name": "gitter-badger/fdasrsf_python", "max_issues_repo_head_hexsha": "f59bd74b570662c17a1a042556d4887e6a75fa3e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 23, "max_issues_repo_issues_event_min_datetime": "2018-05-21T20:12:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T23:19:10.000Z", "max_forks_repo_path": "debug/test_oc_mlogit.py", "max_forks_repo_name": "gitter-badger/fdasrsf_python", "max_forks_repo_head_hexsha": "f59bd74b570662c17a1a042556d4887e6a75fa3e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2018-03-07T13:16:06.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-31T05:21:53.000Z", "avg_line_length": 34.1538461538, "max_line_length": 123, "alphanum_fraction": 0.5968468468, "include": true, "reason": "import numpy", "num_tokens": 465}
|
"""
Euler deconvolution methods for potential fields.
**Implementations**
* :class:`~fatiando.gravmag.euler.Classic`: The classic 3D solution to Euler's
equation for potential fields (Reid et al., 1990). Runs on the whole dataset.
**Solution selection procedures**
* :class:`~fatiando.gravmag.euler.ExpandingWindow`: Run a given Euler
deconvolution on an expanding window and keep the best estimate.
* :class:`~fatiando.gravmag.euler.MovingWindow`: Run a given Euler
deconvolution on a moving window to produce a set of estimates.
**References**
Reid, A. B., J. M. Allsop, H. Granser, A. J. Millett, and I. W. Somerton
(1990), Magnetic interpretation in three dimensions using Euler deconvolution,
Geophysics, 55(1), 80-91, doi:10.1190/1.1442774.
----
"""
from __future__ import division
import numpy
from .. import gridder
from ..inversion.base import Misfit
from ..utils import safe_inverse, safe_dot, safe_diagonal
class Classic(Misfit):
"""
Classic 3D Euler deconvolution of potential field data.
Follows the formulation of Reid et al. (1990). Performs the deconvolution
on the whole data set. For windowed approaches, use
:class:`~fatiando.gravmag.euler.ExpandingWindow`.
Works on any potential field that satisfies Euler's homogeneity equation.
.. note::
The data does **not** need to be gridded for this! So long as you
can calculate the derivatives of non-gridded data (using an Equivalent
Layer, for example).
.. note:: x is North, y is East, and z is down.
.. warning::
Units of the input data (x, y, z, field, derivatives) must be in SI
units! Otherwise, the results will be in strange units. Use functions
in :mod:`fatiando.utils` to convert between units.
Parameters:
* x, y, z : 1d-arrays
The x, y, and z coordinates of the observation points
* field : 1d-array
The potential field measured at the observation points
* xderiv, yderiv, zderiv : 1d-arrays
The x-, y-, and z-derivatives of the potential field (measured or
calculated) at the observation points
* index : float
The structural index of the source
"""
def __init__(self, x, y, z, field, xderiv, yderiv, zderiv,
structural_index):
if (len(x) != len(y) != len(z) != len(field) != len(xderiv)
!= len(yderiv) != len(zderiv)):
raise ValueError("x, y, z, field, xderiv, yderiv, zderiv must " +
"have the same number of elements")
if structural_index < 0:
raise ValueError("Invalid structural index '%g'. Should be >= 0"
% (structural_index))
super(Classic, self).__init__(
data=-x * xderiv - y * yderiv - z *
zderiv - structural_index * field,
positional=dict(x=x, y=y, z=z, field=field, xderiv=xderiv,
yderiv=yderiv, zderiv=zderiv),
model=dict(structural_index=structural_index),
nparams=4, islinear=True)
def _get_jacobian(self, p):
jac = numpy.transpose(
[-self.positional['xderiv'], -self.positional['yderiv'],
-self.positional['zderiv'],
-self.model['structural_index'] * numpy.ones(self.ndata)])
return jac
def _get_predicted(self, p):
return safe_dot(self.jacobian(p), p)
def fit(self):
"""
Solve the deconvolution on the whole data set.
Estimates an (x, y, z) point (stored in ``estimate_``) and a base level
(stored in ``baselevel_``).
"""
super(Classic, self).fit()
self._estimate = self.p_[:3]
self.baselevel_ = self.p_[3]
return self
class ExpandingWindow(object):
"""
Solve an Euler deconvolution problem using an expanding window scheme.
Uses data inside a window of growing size to perform the Euler
deconvolution. Keeps the best result, judged by the estimated error.
Like any other Euler solver, use the
:meth:`~fatiando.gravmag.euler.ExpandingWindow.fit` method to produce an
estimate. The estimated point is stored in ``estimate_``, the base level in
``baselevel_``.
Parameters:
* euler : Euler solver
An instance of an Euler deconvolution solver, like
:class:`~fatiando.gravmag.euler.Classic`.
* center : [x, y]
The x, y coordinates of the center of the expanding windows.
* sizes : list or 1d-array
The sizes of the windows.
"""
def __init__(self, euler, center, sizes):
self.euler = euler
self.center = center
self.sizes = sizes
self.estimate_ = None
self.p_ = None
def fit(self):
"""
Perform the Euler deconvolution with expanding windows.
The estimated point is stored in ``estimate_``, the base level in
``baselevel_``.
"""
xc, yc = self.center
euler = self.euler
x, y = euler.positional['x'], euler.positional['y']
results = []
errors = []
for size in self.sizes:
ds = 0.5 * size
xmin, xmax, ymin, ymax = xc - ds, xc + ds, yc - ds, yc + ds
indices = (x >= xmin) & (x <= xmax) & (y >= ymin) & (y <= ymax)
if not numpy.any(indices):
continue
solver = euler.subset(indices).fit()
cov = safe_inverse(solver.hessian(solver.p_))
uncertainty = numpy.sqrt(safe_diagonal(cov)[0:3])
mean_error = numpy.linalg.norm(uncertainty)
errors.append(mean_error)
results.append(solver.p_)
self.p_ = results[numpy.argmin(errors)]
self.estimate_ = self.p_[:3]
self.baselevel_ = self.p_[3]
return self
class MovingWindow(object):
"""
Solve an Euler deconvolution problem using a moving window scheme.
Uses data inside a window moving to perform the Euler deconvolution. Keeps
the estimate from all windows.
Like any other Euler solver, use the
:meth:`~fatiando.gravmag.euler.MovingWindow.fit` method to produce an
estimate. The estimated points are stored in ``estimate_``, the base levels
in ``baselevel_``.
Parameters:
* euler : Euler solver
An instance of an Euler deconvolution solver, like
:class:`~fatiando.gravmag.euler.Classic`.
* windows : (ny, nx)
The number of windows in the y and x directions
* size : (dy, dx)
The size of the windows in the y and x directions
* keep : float
Decimal percentage of solutions to keep. Will rank the solutions by
increasing error and keep only the first *keep* percent.
"""
def __init__(self, euler, windows, size, keep=0.2):
self.euler = euler
self.windows = windows
self.size = size
self.keep = keep
self.window_centers = None
self.estimate_ = None
self.p_ = None
def fit(self):
"""
Perform the Euler deconvolution on a moving window.
The estimated points are stored in ``estimate_``, the base levels in
``baselevel_``.
"""
ny, nx = self.windows
dy, dx = self.size
euler = self.euler
x, y = euler.positional['x'], euler.positional['y']
x1, x2, y1, y2 = x.min(), x.max(), y.min(), y.max()
paramvecs = []
estimates = []
baselevels = []
errors = []
# Thank you Saulinho for the solution!
# Calculate the mid-points of the windows
self.window_centers = []
xmidpoints = numpy.linspace(x1 + 0.5 * dx, x2 - 0.5 * dx, nx)
ymidpoints = numpy.linspace(y1 + 0.5 * dy, y2 - 0.5 * dy, ny)
for yc in ymidpoints:
for xc in xmidpoints:
self.window_centers.append([xc, yc])
# Separate the indices that fall inside the window with center
# (xc, yc)
indices = ((x >= xc - 0.5 * dx) & (x <= xc + 0.5 * dx) &
(y >= yc - 0.5 * dy) & (y <= yc + 0.5 * dy))
if not numpy.any(indices):
continue
solver = euler.subset(indices).fit()
cov = safe_inverse(solver.hessian(solver.p_))
uncertainty = numpy.sqrt(safe_diagonal(cov)[0:3])
mean_error = numpy.linalg.norm(uncertainty)
errors.append(mean_error)
paramvecs.append(solver.p_)
estimates.append(solver.estimate_)
baselevels.append(solver.baselevel_)
best = numpy.argsort(errors)[:int(self.keep * len(errors))]
self.p_ = numpy.array(paramvecs)[best]
self.estimate_ = numpy.array(estimates)[best]
self.baselevel_ = numpy.array(baselevels)[best]
return self
|
{"hexsha": "5aaf66dee3f45b9f24381861c9d5c83ce909e39d", "size": 8902, "ext": "py", "lang": "Python", "max_stars_repo_path": "fatiando/gravmag/euler.py", "max_stars_repo_name": "silky/fatiando", "max_stars_repo_head_hexsha": "5041c6b29758a5e73e9d7b2b906fa5e493fd9aba", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-06-27T11:32:56.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T11:32:56.000Z", "max_issues_repo_path": "fatiando/gravmag/euler.py", "max_issues_repo_name": "silky/fatiando", "max_issues_repo_head_hexsha": "5041c6b29758a5e73e9d7b2b906fa5e493fd9aba", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fatiando/gravmag/euler.py", "max_forks_repo_name": "silky/fatiando", "max_forks_repo_head_hexsha": "5041c6b29758a5e73e9d7b2b906fa5e493fd9aba", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.503875969, "max_line_length": 79, "alphanum_fraction": 0.6007638733, "include": true, "reason": "import numpy", "num_tokens": 2204}
|
/*
* Copyright 2021 Assured Information Security, Inc.
*
* 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.
*/
#include <introvirt/core/exception/InvalidMethodException.hh>
#include <introvirt/windows/libraries/ws2_32/functions/WSASendTo.hh>
#include <boost/io/ios_state.hpp>
#include "../../helpers.hh"
namespace introvirt {
namespace windows {
namespace ws2_32 {
/* Input arguments */
DEFINE_VALUE_GETTER_SETTER(WSASendTo, s, 0, SOCKET);
DEFINE_ADDRESS_GETTER_SETTER(WSASendTo, lpBuffers, 1);
DEFINE_VALUE_GETTER_SETTER(WSASendTo, dwBufferCount, 2, uint32_t);
DEFINE_ADDRESS_GETTER_SETTER(WSASendTo, lpNumberOfBytesSent, 3);
DEFINE_VALUE_GETTER_SETTER(WSASendTo, dwFlags, 4, uint32_t);
DEFINE_ADDRESS_GETTER_SETTER(WSASendTo, lpTo, 5);
DEFINE_VALUE_GETTER_SETTER(WSASendTo, iTolen, 6, int32_t);
DEFINE_ADDRESS_GETTER_SETTER(WSASendTo, lpOverlapped, 7);
DEFINE_ADDRESS_GETTER_SETTER(WSASendTo, lpCompletionRoutine, 8);
/* Helpers */
uint32_t WSASendTo::NumberOfBytesSent() const {
if (lpNumberOfBytesSent_) {
return *guest_ptr<uint32_t>(lpNumberOfBytesSent_);
}
// TODO: Throw an exception
return 0;
}
void WSASendTo::NumberOfBytesSent(uint32_t NumberOfBytesSent) {
if (lpNumberOfBytesSent_) {
*guest_ptr<uint32_t>(lpNumberOfBytesSent_) = NumberOfBytesSent;
return;
}
// TODO: Throw an exception
}
const SOCKADDR* WSASendTo::To() const {
if (!to_ && lpTo_) {
to_ = SOCKADDR::make_unique(lpTo(), x64());
}
return to_.get();
}
SOCKADDR* WSASendTo::To() {
const auto* const_this = this;
return const_cast<SOCKADDR*>(const_this->To());
}
int32_t WSASendTo::result() const { return raw_return_value(); }
const std::string& WSASendTo::function_name() const { return FunctionName; }
const std::string& WSASendTo::library_name() const { return LibraryName; }
void WSASendTo::write(std::ostream& os) const {
boost::io::ios_flags_saver ifs(os);
// TODO
}
WSASendTo::WSASendTo(Event& event) : WindowsFunctionCall(event, ArgumentCount) {
s_ = get_argument(0);
lpBuffers_ = get_address_argument(1);
dwBufferCount_ = get_argument(2);
lpNumberOfBytesSent_ = get_address_argument(3);
dwFlags_ = get_argument(4);
lpTo_ = get_address_argument(5);
iTolen_ = get_argument(6);
lpOverlapped_ = get_address_argument(7);
lpCompletionRoutine_ = get_address_argument(8);
}
WSASendTo::~WSASendTo() = default;
} // namespace ws2_32
} // namespace windows
} // namespace introvirt
|
{"hexsha": "73fab73a3e7a6b941335aa35d8352965d3828099", "size": 2998, "ext": "cc", "lang": "C++", "max_stars_repo_path": "src/windows/libraries/ws2_32/functions/WSASendTo.cc", "max_stars_repo_name": "srpape/IntroVirt", "max_stars_repo_head_hexsha": "fe553221c40b8ef71f06e79c9d54d9e123a06c89", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/windows/libraries/ws2_32/functions/WSASendTo.cc", "max_issues_repo_name": "srpape/IntroVirt", "max_issues_repo_head_hexsha": "fe553221c40b8ef71f06e79c9d54d9e123a06c89", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/windows/libraries/ws2_32/functions/WSASendTo.cc", "max_forks_repo_name": "srpape/IntroVirt", "max_forks_repo_head_hexsha": "fe553221c40b8ef71f06e79c9d54d9e123a06c89", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3111111111, "max_line_length": 80, "alphanum_fraction": 0.7358238826, "num_tokens": 820}
|
import numpy as np
import sqlalchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
import datetime as dt
import sqlalchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func, desc
from sqlalchemy import create_engine, inspect
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy import create_engine, MetaData, Table
from flask import Flask, jsonify
#################################################
# Database Setup
#################################################
engine = create_engine("sqlite:///Resources/hawaii.sqlite", connect_args={'check_same_thread': False})
# reflect an existing database into a new model
Base = automap_base()
# reflect the tables
Base.prepare(engine, reflect=True)
# Save reference to the table
Measurement = Base.classes.measurements
Station = Base.classes.stations
#################################################
# Flask Setup
#################################################
app = Flask(__name__)
last_twelve_months = '2016-08-23'
year_ago = dt.date(2017, 8, 23) - dt.timedelta(days=365)
#################################################
# Flask Routes
#################################################
@app.route("/")
def welcome():
"""List all available api routes."""
return (
f"<p>Welcome to the Hawaii weather API!</p>"
f"<p>Usage:</p>"
f"/api/v1.0/precipitation<br/>Returns a JSON list of percipitation data for the dates between 8/23/16 and 8/23/17<br/><br/>"
f"/api/v1.0/stations<br/>Returns a JSON list of the weather stations<br/><br/>"
f"/api/v1.0/tobs<br/>Returns a JSON list of the Temperature Observations (tobs) for each station for the dates between 8/23/16 and 8/23/17<br/><br/>"
f"/api/v1.0/date<br/>Returns a JSON list of the minimum temperature, the average temperature, and the max temperature for the dates between the given start date and 8/23/17<br/><br/>."
f"/api/v1.0/start_date/end_date<br/>Returns a JSON list of the minimum temperature, the average temperature, and the max temperature for the dates between the given start date and end date<br/><br/>."
)
@app.route("/api/v1.0/precipitation")
def precipitation():
# Create our session (link) from Python to the DB
session = Session(engine)
"""Return a list of all passenger names"""
# Query all passengers
filtered_dates = session.query(Measurement.date, Measurement.prcp).\
filter(Measurement.date.between(year_ago, max)).\
group_by(Measurement.date).\
order_by(Measurement.date.asc()).all()
filtered_dates
session.close()
# Convert list of tuples into normal list
filtered_dates = list(np.ravel(results))
return jsonify(filtered_dates)
@app.route("/api/v1.0/stations")
def stations():
# Create our session (link) from Python to the DB
session = Session(engine)
"""Return a list of passenger data including the name, age, and sex of each passenger"""
# Query all passengers
results = session.query(Station.station. Station.name).all()
session.close()
stations = list(np.ravel(results))
return jsonify(stations)
@app.route("/api/v1.0/tobs")
def tobs():
# Create our session (link) from Python to the DB
session = Session(engine)
"""Return a list of passenger data including the name, age, and sex of each passenger"""
# Query all passengers
max = session.query(func.max(Measurement.date)).scalar()
year_ago = dt.date(2017, 8, 23) - dt.timedelta(days=365)
results = session.query(Measurement.date, Measurement.tobs).\
filter(Measurement.station == 'USC00519281').\
filter(Measurement.date.between(year_ago, max)).all()
session.close()
tobs = list(np.ravel(results))
return jsonify(tobs)
# Create a dictionary from the row data and append to a list of all_passengers
@app.route("/api/v1.0/<start>/<end>")
def startDateEndDate(start,end):
multi_day_temp_results = session.query(func.min(Measurement.tobs), func.avg(Measurement.tobs), func.max(Measurement.tobs)).filter(Measurement.date >= start).filter(Measurement.date <= end).all()
return jsonify(multi_day_temp_results)
if __name__ == "__main__":
app.run(debug=True)
if __name__ == '__main__':
app.run(debug=True)
|
{"hexsha": "0a220d1d87b201fe8a15abc2cc0ac24145bde64c", "size": 4423, "ext": "py", "lang": "Python", "max_stars_repo_path": "app.py", "max_stars_repo_name": "alalufcan/sqlalchemy-challenge", "max_stars_repo_head_hexsha": "0f0644ef763d67a7013ed0e470c9cbb9ed25890d", "max_stars_repo_licenses": ["ADSL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app.py", "max_issues_repo_name": "alalufcan/sqlalchemy-challenge", "max_issues_repo_head_hexsha": "0f0644ef763d67a7013ed0e470c9cbb9ed25890d", "max_issues_repo_licenses": ["ADSL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app.py", "max_forks_repo_name": "alalufcan/sqlalchemy-challenge", "max_forks_repo_head_hexsha": "0f0644ef763d67a7013ed0e470c9cbb9ed25890d", "max_forks_repo_licenses": ["ADSL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1031746032, "max_line_length": 208, "alphanum_fraction": 0.6665159394, "include": true, "reason": "import numpy", "num_tokens": 999}
|
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 11:45:06 2018
Administrator
"""
import cv2
import numpy as np
o = cv2.imread(r'../image/contours.bmp')
gray = cv2.cvtColor(o,cv2.COLOR_BGR2GRAY)
ret, binary = cv2.threshold(gray,127,255,cv2.THRESH_BINARY)
image,contours, hierarchy = cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
co=o.copy()
r=cv2.drawContours(co,contours,2,(0,0,255),6)
cv2.imshow("original",o)
cv2.imshow("contours",r)
cv2.waitKey()
cv2.destroyAllWindows()
|
{"hexsha": "6f53669ea3a38d8e44f3aa1b99d4c340acc28156", "size": 502, "ext": "py", "lang": "Python", "max_stars_repo_path": "py_simple/13.\u56fe\u50cf\u8f6e\u5ed3/13.1.1\u56fe\u50cf\u8f6e\u5ed3.py", "max_stars_repo_name": "ztfmars/OpenCV_Tutorial", "max_stars_repo_head_hexsha": "2c9cf57f469dfec2aca8356f59f7473e5a506988", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-16T04:26:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-16T04:26:03.000Z", "max_issues_repo_path": "py_simple/13.\u56fe\u50cf\u8f6e\u5ed3/13.1.1\u56fe\u50cf\u8f6e\u5ed3.py", "max_issues_repo_name": "ztfmars/OpenCV_Tutorial", "max_issues_repo_head_hexsha": "2c9cf57f469dfec2aca8356f59f7473e5a506988", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "py_simple/13.\u56fe\u50cf\u8f6e\u5ed3/13.1.1\u56fe\u50cf\u8f6e\u5ed3.py", "max_forks_repo_name": "ztfmars/OpenCV_Tutorial", "max_forks_repo_head_hexsha": "2c9cf57f469dfec2aca8356f59f7473e5a506988", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1, "max_line_length": 92, "alphanum_fraction": 0.7250996016, "include": true, "reason": "import numpy", "num_tokens": 160}
|
# -*- coding: utf-8 -*-
# Author: Hao Chun Chang <changhaochun84@gmail.comm>
#
# LIME: Local Interpretable Model-agnostic Explanations
#
# Ref:
# 1. https://arxiv.org/abs/1602.04938
# 2. https://github.com/marcotcr/lime
from functools import partial
import numpy as np
import scipy as sp
from sklearn.linear_model import Ridge
from sklearn.metrics import pairwise_distances
from sklearn.utils import check_random_state
from torch import Tensor
import tqdm
class LIME:
"""
Explains predictions on ECG signal data.
(e.g. Data with 1-D time series with multiple channels)
"""
def __init__(
self,
model,
kernel_width=.25,
kernel=None,
verbose=False,
feature_selection="auto",
random_state=None
):
"""
Arguments
---------
model: classifier prediction probability function, which
takes a numpy array and outputs prediction probabilities.
Other parameters see LimeBase for detail.
"""
kernel_width = float(kernel_width)
if kernel is None:
def kernel(d, kernel_width):
return np.sqrt(np.exp(-(d ** 2) / kernel_width ** 2))
kernel_fn = partial(kernel, kernel_width=kernel_width)
self.random_state = check_random_state(random_state)
self.feature_selection = feature_selection
self.base = LimeBase(kernel_fn, verbose, random_state=self.random_state)
self.model = model
def __call__(
self,
instance,
labels=(1,),
max_features=100000,
num_samples=100,
batch_size=10,
distance_metric="cosine",
model_regressor=None,
random_seed=None,
progress_bar=False
):
"""
Generates explanations for a prediction.
First, we generate neighborhood data by randomly perturbing features
from the instance.
We then learn locally weighted linear models on this neighborhood data
to explain each of the classes.
Arguments
---------
instance: numpy.ndarray of shape (1, num_channels, time_duration).
labels: iterable with labels to be explained.
max_features: maximum number of features present in explanation.
num_samples: number of neighborhood data for learning the linear model.
batch_size: number of neighborhood data to feed in ```self.model```
at each label-generation step (in ```generate_data_labels```).
distance_metric: the distance metric to use for weights.
model_regressor: sklearn regressor to use in explanation.
Defaults to Ridge regression in LimeBase.
Must have model_regressor.coef_ and 'sample_weight' as a parameter to model_regressor.fit()
random_seed: integer used as random seed for the segmentation
algorithm. If None, a random integer, between 0 and 1000,
will be generated using the internal random number generator.
progress_bar: if True, show tqdm progress bar.
Returns
-------
An ECG signal Explanation object with the corresponding explanations.
"""
if random_seed is None:
random_seed = self.random_state.randint(0, high=1000)
segments = self.segment_signals(instance, num_segments=10)
data, labels = self.generate_data_labels(
instance, segments, num_samples,
batch_size=batch_size,
progress_bar=progress_bar
)
distances = pairwise_distances(
data,
data[0].reshape(1, -1),
metric=distance_metric
).ravel()
res = SignalExplanation(instance, segments)
for label in range(labels.shape[1]):
(
res.intercept[label],
res.local_exp[label],
res.score,
res.local_pred
) = self.base.explain_instance_with_data(
data, labels, distances, label, max_features,
model_regressor=model_regressor,
feature_selection=self.feature_selection
)
return res
def segment_signals(self, instance, num_segments):
"""
Segment signal instance into fixed time windows.
Returns
-------
segments: np.ndarray, integer mask with same shape as ```instance```.
"""
segments = np.zeros_like(instance)
segment_size = instance.shape[-1] // num_segments
for i in range(1, num_segments + 1):
segments[0, :, i * segment_size:(i + 1) * segment_size] = i
last_segment = segments[0, :, num_segments * segment_size:]
if last_segment.shape[0] > 0:
last_segment = num_segments + 1
return segments
def generate_data_labels(
self,
instance,
segments,
num_samples,
batch_size=10,
progress_bar=True
):
"""
Generates signals and predictions in the neighborhood of this instance.
By masking some parts of the instance, specified by segments.
Returns
-------
A tuple (data, labels), where:
data: integer array indicating which parts of the instance is masked with
shape (num_samples, num_segments).
labels: prediction probabilities matrix with shape (num_samples, num_classes).
"""
num_features = np.unique(segments).shape[0]
data = self.random_state.randint(0, 2, size=(num_samples, num_features))
# First sample is the original data point, so disable all masks.
data[0, :] = 1
labels = []
signals = []
samples = tqdm(data) if progress_bar else data
for sample in samples:
temp = np.copy(instance)
zeros = np.where(sample == 0)[0]
mask = np.zeros(segments.shape).astype(bool)
for z in zeros:
mask[segments == z] = True
temp[mask] = 0
signals.append(temp)
if len(signals) == batch_size:
try:
preds = self.model(np.array(signals))
except TypeError:
preds = self.model(Tensor(signals))
preds = preds.detach().numpy()
labels.extend(preds)
signals = []
labels = np.array(labels)
return data, labels
class LimeBase:
"""
Base class for learning a locally linear sparse model from perturbed data
"""
def __init__(self, kernel_fn, verbose=False, random_state=None):
"""
Arguments
---------
kernel_fn: function that transforms an array of distances into an
array of proximity values (floats). (For sampling neighborhood data)
verbose: if true, print local prediction values from linear model.
random_state: an integer or numpy.RandomState that will be used to
generate random numbers. If None, the random state will be
initialized using the internal numpy seed.
"""
self.kernel_fn = kernel_fn
self.verbose = verbose
self.random_state = check_random_state(random_state)
def explain_instance_with_data(
self,
neighborhood_data,
neighborhood_labels,
distances,
label,
num_features,
feature_selection="auto",
model_regressor=None
):
"""
Takes perturbed data, labels and distances, returns explanation.
Arguments
---------
neighborhood_data: perturbed data, 2d array.
first element is assumed to be the original data point.
neighborhood_labels: corresponding perturbed labels. should have as
many columns as the number of possible labels.
distances: distances to original data point.
label: int, label for which we want an explanation.
num_features: int, maximum number of features in explanation.
feature_selection: str, how to select ```num_features```.
Options are:
"forward_selection": iteratively add features to the model.
This is costly when ```num_features``` is high.
"highest_weights": selects the features that have the highest
product of absolute weight * original data point when
learning with all the features.
"none": uses all features, ignores ```num_features```.
"auto": uses forward_selection if ```num_features``` <= 6, and
"highest_weights" otherwise. (Default)
model_regressor: sklearn regressor to use in explanation.
Defaults to Ridge regression if None. Must have
model_regressor.coef_ and 'sample_weight' as a parameter
to model_regressor.fit()
Returns
-------
(intercept, exp, score, local_pred):
intercept: float
exp: a sorted list of tuples, where each tuple (x,y) corresponds
to the feature id (x) and the local weight (y).
The list is sorted by decreasing absolute value of y.
score: float, the R^2 value of the returned explanation.
local_pred: the prediction of the explanation model on the original instance.
"""
weights = self.kernel_fn(distances)
labels_column = neighborhood_labels[:, label]
used_features = self.feature_selection(
neighborhood_data,
labels_column,
weights,
num_features,
feature_selection
)
if model_regressor is None:
model_regressor = Ridge(alpha=1, fit_intercept=True, random_state=self.random_state)
easy_model = model_regressor
easy_model.fit(
neighborhood_data[:, used_features],
labels_column,
sample_weight=weights
)
prediction_score = easy_model.score(
neighborhood_data[:, used_features],
labels_column,
sample_weight=weights
)
original_sample = neighborhood_data[0, used_features].reshape(1, -1)
local_pred = easy_model.predict(original_sample)
if self.verbose:
print("Intercept: ", easy_model.intercept_)
print("Local prediction: ", local_pred)
print("True label: ", neighborhood_labels[0, label])
return (
easy_model.intercept_,
sorted(
zip(used_features, easy_model.coef_),
key=lambda x: np.abs(x[1]),
reverse=True
),
prediction_score,
local_pred
)
def feature_selection(self, data, labels, weights, num_features, method):
"""
Selects features for the model. see explain_instance_with_data to
understand the parameters.
"""
if method == "none":
return np.array(range(data.shape[1]))
elif method == "forward_selection":
return self.forward_selection(data, labels, weights, num_features)
elif method == "highest_weights":
return self.highest_weights(data, labels, weights, num_features)
elif method == "auto":
if num_features <= 6:
n_method = "forward_selection"
else:
n_method = "highest_weights"
return self.feature_selection(
data, labels, weights,
num_features, n_method
)
else:
raise ValueError("Unrecognized feature selection method: {}".format(method))
def forward_selection(self, data, labels, weights, num_features):
"""
Adds one feature (with the highest improvement) at a time.
Returns an array of selected feature indexes.
"""
clf = Ridge(alpha=0, fit_intercept=True, random_state=self.random_state)
used_features = []
for _ in range(min(num_features, data.shape[1])):
max_ = -100000000
best = 0
for feature in range(data.shape[1]):
if feature in used_features:
continue
clf.fit(
data[:, used_features + [feature]],
labels,
sample_weight=weights
)
score = clf.score(
data[:, used_features + [feature]],
labels,
sample_weight=weights
)
if score > max_:
best = feature
max_ = score
used_features.append(best)
return np.array(used_features)
def highest_weights(self, data, labels, weights, num_features):
"""
Selects the features that have the highest
```absolute weight * original data point``` when learning with all the features.
Returns
-------
An array of selected feature indexes.
"""
clf = Ridge(alpha=0.01, fit_intercept=True, random_state=self.random_state)
clf.fit(data, labels, sample_weight=weights)
coef = clf.coef_
weighted_data = coef * data[0]
feature_weights = sorted(
zip(range(data.shape[1]), weighted_data),
key=lambda x: np.abs(x[1]),
reverse=True
)
return np.array([x[0] for x in feature_weights[:num_features]])
class SignalExplanation:
"""
Class for holding ECG signal explanation.
"""
def __init__(self, instance, segments):
self.instance = instance
self.segments = segments
self.intercept = {}
self.local_exp = {}
self.score = 0
self.local_pred = None
def get_instance_and_mask(
self,
label,
positive_only=True,
negative_only=False,
num_features=5,
min_weight=0.
):
"""
Process and output time masks to explain the important parts of the signal.
Arguments
---------
label: int, label to explain.
positive_only: if True, only take segments that positively contribute to
the prediction of the label.
negative_only: if True, only take segments that negatively contribute to
the prediction of the label. If false, and so is positive_only, then both
negativey and positively contributions will be taken.
Both can't be True at the same time.
num_features: number of segments to include in explanation.
min_weight: minimum weight of the segments to include in explanation.
Returns
-------
(instance, mask), where
instance and mask both are 2d numpy array with shape (num_channel, duration).
"""
if label not in self.local_exp:
raise KeyError('Label not in explanation')
if positive_only and negative_only:
raise ValueError("Positive_only and negative_only cannot be true at the same time.")
segments = self.segments
instance = self.instance
exp = self.local_exp[label]
mask = np.zeros(segments.shape, segments.dtype)
if isinstance(instance, Tensor):
instance = instance.numpy()
temp = instance.copy()
if positive_only:
fs = [index for index, weight in exp
if weight > 0 and weight > min_weight][:num_features]
if negative_only:
fs = [index for index, weight in exp
if weight < 0 and abs(weight) > min_weight][:num_features]
if positive_only or negative_only:
for f in fs:
temp[segments == f] = instance[segments == f].copy()
mask[segments == f] = 1
else:
for f, w in exp[:num_features]:
if np.abs(w) < min_weight:
continue
c = 0 if w < 0 else 1
mask[segments == f] = -1 if w < 0 else 1
temp[segments == f] = instance[segments == f].copy()
temp[segments == f, c] = np.max(instance)
return temp[0], mask[0]
|
{"hexsha": "d767b4ab6bb85f4106dc0205ef8c98f1c9d5bf94", "size": 16511, "ext": "py", "lang": "Python", "max_stars_repo_path": "interpret/LIME.py", "max_stars_repo_name": "haochunchang/explain-ECG-diagnosis", "max_stars_repo_head_hexsha": "6799ad38a71e2392192919d123548bdce5059541", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "interpret/LIME.py", "max_issues_repo_name": "haochunchang/explain-ECG-diagnosis", "max_issues_repo_head_hexsha": "6799ad38a71e2392192919d123548bdce5059541", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "interpret/LIME.py", "max_forks_repo_name": "haochunchang/explain-ECG-diagnosis", "max_forks_repo_head_hexsha": "6799ad38a71e2392192919d123548bdce5059541", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-07T20:03:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-07T20:03:11.000Z", "avg_line_length": 36.1291028446, "max_line_length": 107, "alphanum_fraction": 0.5823390467, "include": true, "reason": "import numpy,import scipy", "num_tokens": 3243}
|
function _fatal_err(f::Function, gwt::GWTask)
try; f()
catch err
_printerr(err)
_print_eotask(gwt)
_flush()
if is_worker_mode(gwt)
_up_task_status!(gwt, _GW_TASK_ERROR_STATUS)
# TODO: del proc reg
end
exit()
end
end
function _expr_src(ex::Expr)
buf = IOBuffer()
Base.show_unquoted(buf, ex)
src = String(take!(buf))
src = replace(src, r"#.*#\n" => "")
return string("# NOTE: This source is not 'original', it was generated from an `Expr`.", "\n", src)
end
_expr_src(gwt::GWTask) = _expr_src(_task_expr(gwt))
## ------------------------------------------------------
const _GW_TASK_T0_KEY = "_T0"
_tic!(gwt::GWTask) = set!(gwt, _GW_TASK_T0_KEY, now())
_toc(gwt::GWTask) = now() - get(gwt, _GW_TASK_T0_KEY, now())
## ------------------------------------------------------
const _GW_WELCOME_TOKEN = rpad("RUNNING TASK ", 60, ">")
const _GW_EOTASK_TOKEN = rpad("END OF TASK ", 60, ">")
const _GW_HEAD_SEP = rpad("", 60, "<")
function _print_welcome(gwt::GWTask)
_tic!(gwt)
println(_GW_WELCOME_TOKEN)
# println()
println("taskid ", task_id(gwt))
println("pid ", getpid())
println("pwd ", pwd())
println("wroker mode ", is_worker_mode(gwt))
println("start time ", now())
# println()
println(_GW_HEAD_SEP)
println("\n"^2)
_flush()
end
function _print_eotask(gwt::GWTask)
_flush()
println("\n"^2)
println(_GW_EOTASK_TOKEN)
println("end time ", now())
cantime = Dates.canonicalize(Dates.CompoundPeriod(_toc(gwt)))
println("tot time ", cantime)
println(_GW_HEAD_SEP)
end
|
{"hexsha": "3a31f92936c76aa6941412885349ab7597cdc9a7", "size": 1727, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/Tasks/utils.jl", "max_stars_repo_name": "josePereiro/GitWorkers", "max_stars_repo_head_hexsha": "1228521db61f601ee8a21dcfa2a8b1f2b8517587", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Tasks/utils.jl", "max_issues_repo_name": "josePereiro/GitWorkers", "max_issues_repo_head_hexsha": "1228521db61f601ee8a21dcfa2a8b1f2b8517587", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Tasks/utils.jl", "max_forks_repo_name": "josePereiro/GitWorkers", "max_forks_repo_head_hexsha": "1228521db61f601ee8a21dcfa2a8b1f2b8517587", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8548387097, "max_line_length": 103, "alphanum_fraction": 0.5547191662, "num_tokens": 481}
|
#!/usr/bin/env python2
"""
bittrex_autotrader.py
Bittrex currency exchange autotrading script in a nutshell.
Copyright 2017, Marc S. Brooks (https://mbrooks.info)
Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
Dependencies:
humanfriendly
numpy
requests
Notes:
- This script has been tested to work with Unix-like operating systems
- This script can be run via cronjob
.. seealso:: https://bittrex.com/Home/Api
"""
import argparse
import ConfigParser
import csv
import hashlib
import hmac
import humanfriendly
import numpy
import requests
import StringIO
import sys
import time
SELL = 'SELL'
BUY = 'BUY'
#
# Bittrex API autotrader object.
#
class BittrexAutoTrader(object):
"""
Bittrex API autotrader object.
Dependencies:
humanfriendly
numpy
"""
# Percent Bittrex charges for BUY/SELL trades.
TRADE_FEES = .0025
def __init__(self, options):
"""
Create a new instance of BittrexAutoTrader
Args:
options (dict):
Dictionary of options.
Attributes:
apiReq (BittrexApiRequest):
Instance of BittrexApiRequest object.
market (str):
String literal for the market (ie. BTC-LTC).
units (float):
BUY/SELL total units.
spread (array):
BUY/SELL markup/markdown percentage.
method (str):
Moving Average calculation method.
delay (str):
Seconds to delay order status requests (default: 30).
prompt (bool):
Require user interaction to begin trading.
"""
self.apiReq = BittrexApiRequest(options['apikey'], options['secret'])
self.market = options['market']
self.units = options['units']
self.spread = options['spread'].split('/')
self.method = options['method']
self.delay = options['delay']
self.prompt = options['prompt']
# List of orders as dictionary items.
self._orders = []
def run(self):
"""
Get open orders, prompt if necessary / determine next trade type and start trading.
"""
self._orders = self.apiReq.market_open_orders(self.market)
if not self._orders and self.prompt == 'True':
prompt_choice = humanfriendly.prompt_for_choice(
[
'BUY in at markdown (need units to trade)',
'SELL out at markup (need liquidity)'
],
default='SELL'
)
next_trade = prompt_choice.split(' ', 1)[0]
else:
next_trade = SELL
if self._orders and self.last_order()['OrderType'] == 'LIMIT_SELL':
next_trade = BUY
while True:
# Check for open orders.
if self._orders:
order = self.apiReq.account_order(
self.last_order()['OrderUuid']
)
if order['IsOpen']:
BittrexAutoTrader._wait(seconds=float(self.delay))
continue
#Allow user to cancel order remotely, recalculate and resubmit
if order['CancelInitiated']:
next_trade = BUY if next_trade == SELL else SELL
# Submit a new order.
self.submit_order(next_trade)
next_trade = BUY if next_trade == SELL else SELL
def submit_order(self, trade_type=BUY):
"""
Submit an order to the Bittrex API.
Args:
trade_type (str):
BUY or SELL (default: BUY).
"""
# Get BUY/SELL order market totals.
market_totals = self.market_totals(trade_type)
market_max = round(market_totals.max(), 8)
# Calculate Moving Average (TODO: weights).
if self.method == 'weighted':
moving_avg = round(market_totals.average(weights=None), 8)
else:
moving_avg = round(market_totals.mean(), 8)
# Get current ASK/BID orders.
ticker = self.apiReq.public_ticker(self.market)
# Format human-friendly results.
stdout = {
'cols': [trade_type, self.market.replace('BTC-', '')],
'rows': []
}
# Perform trade operation.
if trade_type == BUY:
# Reinvest earnings.
self._reinvest(float(ticker['Last']))
# Calculate markdown.
markdown = BittrexAutoTrader._calc_decimal_percent(self.spread[1])
# Submit limit BUY
ticker_bid = float(ticker['Bid'])
trader_bid = round(
(ticker_bid - (ticker_bid * markdown)), 8
)
stdout['rows'].append(['Avg', format(moving_avg, '.8f')])
stdout['rows'].append(['Max', format(market_max, '.8f')])
stdout['rows'].append(['Ask', format(ticker_bid, '.8f')])
stdout['rows'].append(['Bid', humanfriendly.terminal.ansi_wrap(
format(trader_bid, '.8f'),
bold=True
)])
self._submit(trade_type, trader_bid)
else:
# Calculate markup.
markup = BittrexAutoTrader._calc_decimal_percent(self.spread[0])
# Submit limit SELL
ticker_ask = float(ticker['Ask'])
trader_ask = round(
(ticker_ask + (ticker_ask * markup)), 8
)
stdout['rows'].append(['Avg', format(moving_avg, '.8f')])
stdout['rows'].append(['Max', format(market_max, '.8f')])
stdout['rows'].append(['Bid', format(ticker_ask, '.8f')])
stdout['rows'].append(['Ask', humanfriendly.terminal.ansi_wrap(
format(trader_ask, '.8f'),
bold=True
)])
self._submit(trade_type, trader_ask)
stdout['rows'].append(['Qty', format(float(self.units), '.8f')])
# Output human-friendly results.
print humanfriendly.tables.format_pretty_table(
stdout['rows'],
stdout['cols']
), "\n", time.strftime(' %Y-%m-%d %H:%M:%S '), "\n"
def market_totals(self, trade_type=BUY):
"""
Returns BUY/SELL order market totals as ndarray.
Args:
trade_type (str):
BUY or SELL (default: BUY).
Returns:
ndarray
"""
market_history = self.apiReq.public_market_history(self.market)
return BittrexAutoTrader._numpy_loadtxt(
BittrexAutoTrader._list_of_dict_filter_by(
market_history, 'OrderType', trade_type
),
['Price']
)
def last_order(self, trade_type=None):
"""
Return the last successful order by type.
Args:
trade_type (str):
BUY or SELL (optional).
Returns:
dict
"""
for order in reversed(self._orders):
if not trade_type or trade_type in order['Type']:
return order
def last_buy_price(self):
"""
Return the last successful BUY price.
Returns:
float (default: 0)
"""
order = self.last_order(BUY)
return float(order['Price']) if order else 0
def last_sell_price(self):
"""
Return the last successfull SELL price.
Returns:
float (default: 0)
"""
order = self.last_order(SELL)
return float(order['Price']) if order else 0
def _reinvest(self, last_price):
"""
Update units to purchase based on total earnings available.
Args:
last_price (float):
Latest market SELL price.
"""
quantity = float(self.units)
sell_price = self.last_sell_price()
buy_price = self.last_buy_price()
if sell_price and buy_price:
earnings = (sell_price - buy_price) * quantity
if earnings > 0:
processed = quantity * sell_price
available = (processed - \
(processed * BittrexAutoTrader.TRADE_FEES)) + earnings
# Output human-friendly results.
print humanfriendly.terminal.ansi_wrap(
''.join(['Total earnings: ', str(earnings)]),
bold=True
), "\n"
# Check balance can cover purchase.
quantity = available / last_price
if (quantity * last_price) <= available:
self.units = quantity
def _submit(self, trade_type, price):
"""
Submit the API request and store order details.
Args:
trade_type (str):
BUY or SELL (default: SELL).
"""
if trade_type == BUY:
uuid = self.apiReq.market_buy_limit(
self.market, self.units, price
)['uuid']
else:
uuid = self.apiReq.market_sell_limit(
self.market, self.units, price
)['uuid']
self._orders.append({
'OrderUuid': uuid,
'Type': trade_type,
'Price': price,
'Quantity': self.units
})
@staticmethod
def _calc_decimal_percent(num):
"""
Returns string percentage as a decimal percent.
Args:
num (str):
Percentage as string.
Returns:
float
"""
return float(num) if float(num) < 1 else float(num) / 100
@staticmethod
def _list_of_dict_filter_by(data, key, value):
"""
Returns list of dictionary items filtered by key/value.
Args:
data (dict):
Data to filter.
key (str):
Dictionary key search.
value (str):
Dictionary key value match.
Returns:
list
"""
return [
item for i, item in enumerate(data) if data[i].get(key) == value
]
@staticmethod
def _list_of_dict_to_csv(data, keys=None):
"""
Returns list of prefiltered dictionary items as CSV string.
Args:
data (dict):
Data to convert.
keys (list):
Columns to exclude from result.
Returns:
string
"""
output = StringIO.StringIO()
# Filter items by key names.
writer = csv.DictWriter(output, fieldnames=keys)
for item in data:
filtered_item = dict(
(key, value) for key, value in item.iteritems() if key in keys
)
writer.writerow(filtered_item)
return output.getvalue()
@staticmethod
def _numpy_calc_sma(a, n):
"""
Return Simple Moving Average for a given data sequence.
Args:
a (list):
One-dimensional input array.
n (int):
Number of days (n-day).
Returns:
list
"""
return numpy.convolve(a, numpy.ones((n,)) / n, mode='valid')
@staticmethod
def _numpy_loadtxt(data, keys=None, converters=None):
"""
Returns list of prefiltered dictionary items as ndarray.
Args:
data: dict
Data to convert.
keys: list
Columns to exclude from result.
Returns:
ndarray
"""
return numpy.loadtxt(
StringIO.StringIO(
BittrexAutoTrader._list_of_dict_to_csv(data, keys)
),
converters=converters,
delimiter=',',
unpack=True
)
@staticmethod
def _wait(label='Waiting', seconds=10, timer=False):
"""
Suspend execution for given number of seconds while showing a spinner.
Args:
label (str):
The label for the spinner (default: Waiting).
seconds (float):
Seconds to delay execution (default: 10).
timer (bool):
Show the elapsed time (default: False).
"""
with humanfriendly.AutomaticSpinner(label, show_time=timer) as spinner:
time.sleep(seconds)
#
# Bittrex AutoTrader config object.
#
class BittrexAutoTraderConfig(object):
"""
Bittrex AutoTrader config object.
"""
@staticmethod
def values():
"""
Return command-line arguments / configuration values as a dictionary.
Returns:
dict
.. seealso:: bittrex_autotrader.conf.example
"""
argv = sys.argv
arg_parser = argparse.ArgumentParser()
# Configuration options can be passed as script arguments.
arg_parser.add_argument(
'--conf',
help='Configuration file (bittrex_autotrader.conf)',
metavar='FILE'
)
arg_parser.add_argument(
'--apikey',
help='Bittrex issued API key.',
required='--conf' not in argv
)
arg_parser.add_argument(
'--secret',
help='Bittrex issued API secret.',
required='--conf' not in argv
)
arg_parser.add_argument(
'--market',
help='String literal for the market (ie. BTC-LTC)',
default='BTC-LTC'
)
arg_parser.add_argument(
'--units',
help='BUY/SELL total units (default: 1.0)',
default='1.0'
)
arg_parser.add_argument(
'--spread',
help='BUY/SELL markup/markdown percentage (default: 0.1/0.1)',
default='0.1/0.1'
)
arg_parser.add_argument(
'--method',
help='Moving Average calculation method (default: arithmetic)',
default='arithmetic'
)
arg_parser.add_argument(
'--delay',
help='Seconds to delay order status requests (default: 30)',
default='30'
)
arg_parser.add_argument(
'--prompt',
help='Require user interaction to begin trading (default: true)',
default=True
)
args, remaining_args = arg_parser.parse_known_args()
# Return configuration values from file.
if args.conf:
config_parser = ConfigParser.SafeConfigParser()
config_parser.read([args.conf])
return dict(config_parser.items('config'))
# Return command-line argument values.
else:
return vars(args)
#
# Bittrex API request object.
#
class BittrexApiRequest(object):
"""
Bittrex API request object.
Dependencies:
requests
"""
# Bittrex API URL
BASE_URL = 'https://bittrex.com/api/v1.1/'
# Total retries on failed connection.
CONNECT_RETRIES = 10
# Delay between failed requests.
CONNECT_WAIT = 5
def __init__(self, apikey, secret):
"""
Create a new instance of the BittrexApiRequest
Args:
apikey (str):
Bittrex issued API key.
secret (str):
Bittrex issued API secret.
Attributes:
apikey (str):
Bittrex issued API key.
secret (str):
Bittrex issued API secret.
"""
self.apikey = apikey
self.secret = secret
def public_markets(self):
"""
Get the open and available trading markets along with other meta data.
Returns:
list
"""
return self.get('public/getmarkets')
def public_currencies(self):
"""
Get all supported currencies along with other meta data.
Returns:
list
"""
return self.get('public/getcurrencies')
def public_ticker(self, market):
"""
Get the current tick values for a market.
Args:
market (str):
String literal (ie. BTC-LTC).
Returns:
list
"""
return self.get('public/getticker', {
'market': market
})
def public_market_summaries(self):
"""
Get the last 24 hour summary of all active exchanges.
Returns:
list
"""
return self.get('public/getmarketsummaries')
def public_market_summary(self, market):
"""
Get the last 24 hour summary of all active exchanges.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
Returns:
list
"""
return self.get('public/getmarketsummary', {
'market': market
})
def public_market_history(self, market):
"""
Get the latest trades that have occured for a specific market.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
Returns:
list
"""
return self.get('public/getmarkethistory', {
'market': market
})
def public_order_book(self, market, book_type):
"""
Get the orderbook for a given market.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
book_type (str):
Buy, sell or both to identify the type of orderbook.
Returns:
list
"""
return self.get('public/getorderbook', {
'market': market,
'type': book_type
})
def market_buy_limit(self, market, quantity, rate):
"""
Send a buy order in a specific market.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
quantity (float):
The amount to purchase.
rate (float):
Rate at which to place the order.
Returns:
list
"""
return self.get('market/buylimit', {
'market': market,
'quantity': quantity,
'rate': rate
}, signed=True)
def market_sell_limit(self, market, quantity, rate):
"""
Send a sell order in a specific market.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
quantity (float):
The amount to sell.
rate: (float)
Rate at which to place the order.
Returns:
list
"""
return self.get('market/selllimit', {
'market': market,
'quantity': quantity,
'rate': rate
}, signed=True)
def market_cancel(self, uuid):
"""
Send a cancel a buy or sell order.
Args:
uuid (str):
UUID of buy or sell order.
"""
return self.get('market/cancel', {
'uuid': uuid
}, signed=True)
def market_open_orders(self, market):
"""
Get all orders that you currently have opened.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
Returns:
list
"""
return self.get('market/getopenorders', {
'market': market
}, signed=True)
def account_balances(self):
"""
Get all balances from your account.
Returns:
list
"""
return self.get('account/getbalances', signed=True)
def account_balance(self, currency):
"""
Get the balance from your account for a specific currency.
Args:
currency (float):
String literal (ie. BTC). If omitted, return all currency.
Returns:
list
"""
return self.get('account/getbalance', {
'currency': currency
}, signed=True)
def account_deposit_address(self, currency):
"""
Get existing, or generate new address for a specific currency.
Args:
currency (float):
String literal (ie. BTC). If omitted, return all currency.
Returns:
list
"""
return self.get('account/getdepositaddress', {
'currency': currency
}, signed=True)
def account_withdraw(self, currency, quantity, address, paymentid):
"""
Send request to withdraw funds from your account.
Args:
currency (float):
String literal (ie. BTC). If omitted, return all currency.
quantity (str):
The amount to withdrawl.
address (str):
The address where to send the funds.
paymentid (str):
CryptoNotes/BitShareX/Nxt field (memo/paymentid optional).
Returns:
list
"""
return self.get('account/getwithdraw', {
'currency': currency,
'quantity': quantity,
'address': address,
'paymentid': paymentid
}, signed=True)
def account_order(self, uuid):
"""
Get a single order by uuid.
Args:
uuid (str):
UUID of buy or sell order.
Return:
list
"""
return self.get('account/getorder', {
'uuid': uuid
}, signed=True)
def account_order_history(self, market):
"""
Get order history.
Args:
market (str):
String literal (ie. BTC-LTC). If omitted, return all markets.
Returns:
list
"""
return self.get('account/getorderhistory', {
'market': market
}, signed=True)
def account_deposit_history(self, currency):
"""
Get deposit history.
Args:
currency (float):
String literal (ie. BTC). If omitted, return all currency.
Returns:
list
"""
return self.get('account/getdeposithistory', {
'currency': currency
}, signed=True)
def account_withdrawl_history(self, currency):
"""
Get withdrawl history.
Args:
currency (float):
String literal (ie. BTC). If omitted, return all currency.
Returns:
list
"""
return self.get('account/getwithdrawlhistory', {
'currency': currency
}, signed=True)
def get(self, method, params=dict, headers=None, signed=False):
"""
Construct and send a HTTP request to the Bittrex API.
Args:
method (str):
URI resource that references an API service.
params (dict):
Dictionary that contains name/value parameters (optional).
headers (dict):
Dictionary that contains HTTP header key/values (optional).
signed (bool):
Authenticate using a signed header (optional).
Returns:
list
"""
# Add parameters required for signed requests.
if signed == True:
params['apikey'] = self.apikey
params['nonce'] = str(int(time.time()))
# Create query string from parameter items.
query_str = []
for name, value in params.iteritems():
query_str.append(name + '=' + str(value))
# Format the URL with query string.
uri = [BittrexApiRequest.BASE_URL + method]
uri.append('?' + '&'.join(query_str))
url = ''.join(uri)
# Create the signed HTTP header.
if headers is None:
headers = {}
if signed == True:
headers['apisign'] = BittrexApiRequest._sign(self.secret, url)
# Send the API request.
for i in range(BittrexApiRequest.CONNECT_RETRIES):
try:
req = requests.get(url, headers=headers)
except requests.exceptions.ConnectionError:
time.sleep(BittrexApiRequest.CONNECT_WAIT)
else:
break
res = req.json()
if res == None:
print >> sys.stderr, 'Script failure: Connection timeout'
sys.exit(1)
if res['success'] == False:
print >> sys.stderr, "Bittex response: %s" % res['message']
sys.exit(1)
# Return list of dicts.
return res['result']
@staticmethod
def _sign(secret, message):
"""
Return signed message using the HMAC algorithm.
Args:
secret (str):
Bittrex issued API secret.
message (str):
Message to convert.
Returns:
str
.. seealso:: https://www.bittrex.com/Manage#sectionApi
"""
return hmac.new(secret, message, hashlib.sha512).hexdigest()
#
# Start program.
#
if __name__ == '__main__':
# Let's get this party started.
BittrexAutoTrader(
BittrexAutoTraderConfig.values()
).run()
|
{"hexsha": "f97cf6938ccf3420e98ab5c4638abd63ebf13d8d", "size": 25492, "ext": "py", "lang": "Python", "max_stars_repo_path": "bittrex_autotrader.py", "max_stars_repo_name": "Daiwv/bittrex_autotrader", "max_stars_repo_head_hexsha": "d4d6ba78c23e3b6edf2f52bf190077356f0573f0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-19T02:32:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-19T02:32:04.000Z", "max_issues_repo_path": "bittrex_autotrader.py", "max_issues_repo_name": "Daiwv/bittrex_autotrader", "max_issues_repo_head_hexsha": "d4d6ba78c23e3b6edf2f52bf190077356f0573f0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bittrex_autotrader.py", "max_forks_repo_name": "Daiwv/bittrex_autotrader", "max_forks_repo_head_hexsha": "d4d6ba78c23e3b6edf2f52bf190077356f0573f0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0903294368, "max_line_length": 91, "alphanum_fraction": 0.5259297034, "include": true, "reason": "import numpy", "num_tokens": 5189}
|
import random
from PIL import Image
import torch
from torchvision import transforms
import torch.nn as nn
import numpy as np
class GaussianBlur(object):
"""Blur a single image on CPU.
"""
def __init__(self, kernel_size, sigma_min=0.1, sigma_max=2.0):
radius = kernel_size // 2
kernel_size = radius * 2 + 1
self.blur_h = nn.Conv2d(3, 3, kernel_size=(kernel_size, 1),
stride=1, padding=0, bias=False, groups=3)
self.blur_v = nn.Conv2d(3, 3, kernel_size=(1, kernel_size),
stride=1, padding=0, bias=False, groups=3)
self.sigma_min = sigma_min
self.sigma_max = sigma_max
self.k = kernel_size
self.r = radius
self.blur = nn.Sequential(
nn.ReflectionPad2d(radius),
self.blur_h,
self.blur_v
)
self.pil_to_tensor = transforms.ToTensor()
self.tensor_to_pil = transforms.ToPILImage()
def __call__(self, img):
img = self.pil_to_tensor(img).unsqueeze(0)
sigma = np.random.uniform(self.sigma_min, self.sigma_max)
x = np.arange(-self.r, self.r + 1)
x = np.exp(-np.power(x, 2) / (2 * sigma * sigma))
x = x / x.sum()
x = torch.from_numpy(x).view(1, -1).repeat(3, 1)
self.blur_h.weight.data.copy_(x.view(3, 1, self.k, 1))
self.blur_v.weight.data.copy_(x.view(3, 1, 1, self.k))
with torch.no_grad():
img = self.blur(img)
img = img.squeeze()
img = self.tensor_to_pil(img)
return img
class ResizeBlur(object):
"""Cost efficient alternative of Gaussian blur.
"""
def __init__(self, input_size, max_level=3, interpolation=Image.BICUBIC):
self.input_size = input_size
self.max_level = max_level
self.factors = [1.1, 1.2, 1.5, 2.0, 4.0, 8.0]
self.interpolation = interpolation
def __call__(self, img):
level = np.random.randint(0, self.max_level)
w, h = img.size
dn_size = (int(h // self.factors[level]),
int(w // self.factors[level]))
up_size = (h, w)
# note that interpolation method is different from the reference code (AREA)
img = transforms.functional.resize(img, dn_size, interpolation=self.interpolation)
img = transforms.functional.resize(img, up_size, interpolation=self.interpolation)
return img
|
{"hexsha": "c7eeae71679c4e378ec00d45803f2a6593d77b3f", "size": 2453, "ext": "py", "lang": "Python", "max_stars_repo_path": "augment/gaussian_blur.py", "max_stars_repo_name": "merlinarer/scrl", "max_stars_repo_head_hexsha": "f5bc426ed6eef130d44dd3a5609dc0772da59613", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 102, "max_stars_repo_stars_event_min_datetime": "2021-03-25T08:54:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T03:46:47.000Z", "max_issues_repo_path": "augment/gaussian_blur.py", "max_issues_repo_name": "merlinarer/scrl", "max_issues_repo_head_hexsha": "f5bc426ed6eef130d44dd3a5609dc0772da59613", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2021-03-23T01:53:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-30T08:51:19.000Z", "max_forks_repo_path": "augment/gaussian_blur.py", "max_forks_repo_name": "merlinarer/scrl", "max_forks_repo_head_hexsha": "f5bc426ed6eef130d44dd3a5609dc0772da59613", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2021-04-15T06:02:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-10T15:34:39.000Z", "avg_line_length": 32.7066666667, "max_line_length": 90, "alphanum_fraction": 0.596004892, "include": true, "reason": "import numpy", "num_tokens": 637}
|
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 4 10:58:22 2022
@author: sarangbhagwat
A module with examples of task-based unit process specifications.
"""
import numpy as np
import biosteam as bst
import thermosteam as tmo
from thermosteam import Stream
from biosteam.process_tools import BoundedNumericalSpecification
from matplotlib import pyplot as plt
from timeit import timeit
import flexsolve as flx
tmo.settings.set_thermo(['Caproic acid', 'Ethanol', 'Decanol', 'Undecanol', 'Water', 'Hydrogen', 'Acetic acid'])
# Define feed stream
feed = tmo.Stream('feed')
feed.imol['Ethanol'] = 4000.
feed.imol['Caproic acid'] = 20.
feed.imol['Decanol'] = 20.
feed.imol['Undecanol'] = 2.
feed.T = 273.15 + 40.
#%%% Bounded numerical process specification
# (for when you want to solve numerically for design parameter values given unit performance target(s))
# Define unit and target(s)
F401 = bst.units.Flash('F401', ins=feed, outs=('F401_t', 'F401_b'), P = 101325., V = 0.5)
F401.target_bottom_conc = 0.05 # let's say we want to concentrate the feed caproic acid solution to 5 wt%
# Define objective function to achieve target(s)
def F401_bottom_conc_objective_fn(V):
F401.V = V
F401._run()
F401_b = F401.outs[1]
return F401_b.imass['Caproic acid']/F401_b.F_mass - F401.target_bottom_conc # we want this to be 0
F401.specification = BoundedNumericalSpecification(F401_bottom_conc_objective_fn, 0.001, 0.999)
# BoundedNumericalSpecification args: objective fn, objective fn arg min val, objective fn arg max val
# Simulate and print
F401.simulate()
F401.show()
# Plot to show the specification is working
def get_F401_bottom_conc_given_feed_imol_caproic_acid(i):
feed.imol['Caproic acid'] = i
F401.simulate()
F401_b = F401.outs[1]
return F401_b.imass['Caproic acid']/F401_b.F_mass
feed_imol_caproic_acid = np.linspace(5., 50., 20)
F401_b_concs = [np.round(get_F401_bottom_conc_given_feed_imol_caproic_acid(i), 6) for i in feed_imol_caproic_acid]
plt.plot(feed_imol_caproic_acid, F401_b_concs)
#%%% General process specification
# Usually used when you want to alter the simulation of a unit in some way,
# or if you want to solve analytically instead of numerically
# Can also be used when you want to explicitly define numerical solvers, especially when multiple equations need to be solved
# Let's say we happen to know all of the decanol and undecanol will always appear in the bottom product
# and we would like to exclude them from the vle.
# One way to do this is:
excluded_chems = ['Decanol', 'Undecanol']
def F401_spec_dont_include_decanol():
excluded_chems_mol_dct = {}
F401_feed = F401.ins[0]
for c in excluded_chems:
excluded_chems_mol_dct[c] = F401_feed.imol[c]
F401_feed.imol[c] = 0. # remove from feed
F401._run()
F401_b = F401.outs[1]
for c in excluded_chems:
mol_c = excluded_chems_mol_dct[c]
F401_feed.imol[c] = mol_c # add back to feed
F401_b.imol[c] = mol_c # add to bottom product
F401.specification = F401_spec_dont_include_decanol
# Simulate and print
F401.simulate()
F401.show()
#%%% Bounded numerical specification for a maximum allowable concentration in a stream
feed.imol['Acetic acid'] = 200.
# Define objective function to achieve target(s)
def F401_bottom_conc_objective_fn(V):
F401.V = V
F401._run()
F401_t = F401.outs[0]
return F401_t.imass['Acetic acid']/F401_t.F_mass - 0.02 # we want this to be 0
# Define specification
def F401_spec():
if F401.ins[0].imass['Acetic acid']/F401.ins[0].F_mass > 0.02:
# solve
flx.IQ_interpolation(F401_bottom_conc_objective_fn, 1e-4, 1.-1e-4)
else:
F401.V = 0.1
F401._run()
F401.specification = F401_spec
# Simulate and print
F401.simulate()
F401.show()
#%% Reactant mixer example
M401 = bst.Mixer('M401', ins = (feed.copy(), 'hydrogen_gas'), outs = ('reaction_mix'))
def M401_spec():
M401_ins_0 = M401.ins[0]
M401_ins_1 = M401.ins[1]
M401_ins_1.imol['Hydrogen'] = 2* M401_ins_0.imol['Caproic acid']
M401._run()
M401.specification = M401_spec
# Simulate and print
M401.simulate()
M401.show()
#%% Feed hexanol mixer example
tmo.settings.set_thermo(['Hexanol'])
# Separation streams and units
hexanol = Stream('Hexanol')
M402 = bst.units.Mixer('M402', ins = (hexanol, ''), outs = 'hexanol_solvent')
# We want at least 50 kmol/hr of hexanol to be output by this mixer, including any recycled hexanol
M402.output_hexanol_minimum_req = 50. # this is a new attribute that you just created
def M402_spec():
# this makes sure we're not taking more fresh (make-up) hexanol than needed to achieve at least 50 kmol/h
M402.ins[0].imol['Hexanol'] = max(0., M402.output_hexanol_minimum_req - M402.ins[1].imol['Hexanol'])
# a more general way to write this, which would include ALL inlet ports for M402 other than the fresh feed, would be:
# M402.ins[0].imol['Hexanol'] = max(0., M402.output_hexanol_required - sum([i.imol['Hexanol'] for i in M402.ins[1:]]))
M402._run()
M402.specification = M402_spec
# recycle streams would come from other, downstream units; let's make a fake one here
recycled_hexanol = Stream('recycled_hexanol')
recycled_hexanol.imol['Hexanol'] = 20.
# connect the recycle stream to the mixer's recycle port
recycled_hexanol-1-M402
# add a specification to change the flow of Hexanol
# Facilities streams and units
hexanol_fresh = Stream('hexanol_fresh', price=5.)
T601 = bst.units.StorageTank('T601', ins=hexanol_fresh)
T601_P = bst.units.Pump('T601_P', ins=T601-0, outs = hexanol)
# Simulate and print
M402.simulate()
M402.show()
|
{"hexsha": "eb78becc6d4d6dac6afae08c269b0c4b16708345", "size": 5643, "ext": "py", "lang": "Python", "max_stars_repo_path": "BioSTEAM 2.x.x/biorefineries/make_a_biorefinery/example_process_specifications.py", "max_stars_repo_name": "yoelcortes/Bioindustrial-Complex", "max_stars_repo_head_hexsha": "d39edfec88e443ef7a62218ca0215e3b105f4b96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-03T21:04:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-09T01:15:48.000Z", "max_issues_repo_path": "BioSTEAM 2.x.x/biorefineries/make_a_biorefinery/example_process_specifications.py", "max_issues_repo_name": "yoelcortes/Bioindustrial-Complex", "max_issues_repo_head_hexsha": "d39edfec88e443ef7a62218ca0215e3b105f4b96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-01-03T21:31:27.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-28T13:53:56.000Z", "max_forks_repo_path": "BioSTEAM 2.x.x/biorefineries/make_a_biorefinery/example_process_specifications.py", "max_forks_repo_name": "yoelcortes/Bioindustrial-Complex", "max_forks_repo_head_hexsha": "d39edfec88e443ef7a62218ca0215e3b105f4b96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-07T14:04:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-08T23:05:25.000Z", "avg_line_length": 33.1941176471, "max_line_length": 125, "alphanum_fraction": 0.727449938, "include": true, "reason": "import numpy", "num_tokens": 1699}
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Floris van Doorn, Gabriel Ebner, Yury Kudryashov
-/
import data.nat.enat
import order.conditionally_complete_lattice
/-!
# Conditionally complete linear order structure on `ℕ`
In this file we
* define a `conditionally_complete_linear_order_bot` structure on `ℕ`;
* define a `complete_linear_order` structure on `enat`;
* prove a few lemmas about `supr`/`infi`/`set.Union`/`set.Inter` and natural numbers.
-/
open set
namespace nat
open_locale classical
noncomputable instance : has_Inf ℕ :=
⟨λs, if h : ∃n, n ∈ s then @nat.find (λn, n ∈ s) _ h else 0⟩
noncomputable instance : has_Sup ℕ :=
⟨λs, if h : ∃n, ∀a∈s, a ≤ n then @nat.find (λn, ∀a∈s, a ≤ n) _ h else 0⟩
lemma Inf_def {s : set ℕ} (h : s.nonempty) : Inf s = @nat.find (λn, n ∈ s) _ h :=
dif_pos _
lemma Sup_def {s : set ℕ} (h : ∃n, ∀a∈s, a ≤ n) :
Sup s = @nat.find (λn, ∀a∈s, a ≤ n) _ h :=
dif_pos _
@[simp] lemma Inf_eq_zero {s : set ℕ} : Inf s = 0 ↔ 0 ∈ s ∨ s = ∅ :=
begin
cases eq_empty_or_nonempty s,
{ subst h, simp only [or_true, eq_self_iff_true, iff_true, Inf, has_Inf.Inf,
mem_empty_eq, exists_false, dif_neg, not_false_iff] },
{ have := ne_empty_iff_nonempty.mpr h,
simp only [this, or_false, nat.Inf_def, h, nat.find_eq_zero] }
end
@[simp] lemma Inf_empty : Inf ∅ = 0 :=
by { rw Inf_eq_zero, right, refl }
lemma Inf_mem {s : set ℕ} (h : s.nonempty) : Inf s ∈ s :=
by { rw [nat.Inf_def h], exact nat.find_spec h }
lemma not_mem_of_lt_Inf {s : set ℕ} {m : ℕ} (hm : m < Inf s) : m ∉ s :=
begin
cases eq_empty_or_nonempty s,
{ subst h, apply not_mem_empty },
{ rw [nat.Inf_def h] at hm, exact nat.find_min h hm }
end
protected lemma Inf_le {s : set ℕ} {m : ℕ} (hm : m ∈ s) : Inf s ≤ m :=
by { rw [nat.Inf_def ⟨m, hm⟩], exact nat.find_min' ⟨m, hm⟩ hm }
lemma nonempty_of_pos_Inf {s : set ℕ} (h : 0 < Inf s) : s.nonempty :=
begin
by_contradiction contra, rw set.not_nonempty_iff_eq_empty at contra,
have h' : Inf s ≠ 0, { exact ne_of_gt h, }, apply h',
rw nat.Inf_eq_zero, right, assumption,
end
lemma nonempty_of_Inf_eq_succ {s : set ℕ} {k : ℕ} (h : Inf s = k + 1) : s.nonempty :=
nonempty_of_pos_Inf (h.symm ▸ (succ_pos k) : Inf s > 0)
lemma eq_Ici_of_nonempty_of_upward_closed {s : set ℕ} (hs : s.nonempty)
(hs' : ∀ (k₁ k₂ : ℕ), k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s) : s = Ici (Inf s) :=
ext (λ n, ⟨λ H, nat.Inf_le H, λ H, hs' (Inf s) n H (Inf_mem hs)⟩)
lemma Inf_upward_closed_eq_succ_iff {s : set ℕ}
(hs : ∀ (k₁ k₂ : ℕ), k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s) (k : ℕ) :
Inf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s :=
begin
split,
{ intro H,
rw [eq_Ici_of_nonempty_of_upward_closed (nonempty_of_Inf_eq_succ H) hs, H, mem_Ici, mem_Ici],
exact ⟨le_refl _, k.not_succ_le_self⟩, },
{ rintro ⟨H, H'⟩,
rw [Inf_def (⟨_, H⟩ : s.nonempty), find_eq_iff],
exact ⟨H, λ n hnk hns, H' $ hs n k (lt_succ_iff.mp hnk) hns⟩, },
end
/-- This instance is necessary, otherwise the lattice operations would be derived via
conditionally_complete_linear_order_bot and marked as noncomputable. -/
instance : lattice ℕ := lattice_of_linear_order
noncomputable instance : conditionally_complete_linear_order_bot ℕ :=
{ Sup := Sup, Inf := Inf,
le_cSup := assume s a hb ha, by rw [Sup_def hb]; revert a ha; exact @nat.find_spec _ _ hb,
cSup_le := assume s a hs ha, by rw [Sup_def ⟨a, ha⟩]; exact nat.find_min' _ ha,
le_cInf := assume s a hs hb,
by rw [Inf_def hs]; exact hb (@nat.find_spec (λn, n ∈ s) _ _),
cInf_le := assume s a hb ha, by rw [Inf_def ⟨a, ha⟩]; exact nat.find_min' _ ha,
cSup_empty :=
begin
simp only [Sup_def, set.mem_empty_eq, forall_const, forall_prop_of_false, not_false_iff,
exists_const],
apply bot_unique (nat.find_min' _ _),
trivial
end,
.. (infer_instance : order_bot ℕ), .. (lattice_of_linear_order : lattice ℕ),
.. (infer_instance : linear_order ℕ) }
lemma Inf_add {n : ℕ} {p : ℕ → Prop} (hn : n ≤ Inf {m | p m}) :
Inf {m | p (m + n)} + n = Inf {m | p m} :=
begin
obtain h | ⟨m, hm⟩ := {m | p (m + n)}.eq_empty_or_nonempty,
{ rw [h, nat.Inf_empty, zero_add],
obtain hnp | hnp := hn.eq_or_lt,
{ exact hnp },
suffices hp : p (Inf {m | p m} - n + n),
{ exact (h.subset hp).elim },
rw tsub_add_cancel_of_le hn,
exact Inf_mem (nonempty_of_pos_Inf $ n.zero_le.trans_lt hnp) },
{ have hp : ∃ n, n ∈ {m | p m} := ⟨_, hm⟩,
rw [nat.Inf_def ⟨m, hm⟩, nat.Inf_def hp],
rw [nat.Inf_def hp] at hn,
exact find_add hn }
end
section
variables {α : Type*} [complete_lattice α]
lemma supr_lt_succ (u : ℕ → α) (n : ℕ) : (⨆ k < n + 1, u k) = (⨆ k < n, u k) ⊔ u n :=
by simp [nat.lt_succ_iff_lt_or_eq, supr_or, supr_sup_eq]
lemma supr_lt_succ' (u : ℕ → α) (n : ℕ) : (⨆ k < n + 1, u k) = u 0 ⊔ (⨆ k < n, u (k + 1)) :=
by { rw ← sup_supr_nat_succ, simp }
lemma infi_lt_succ (u : ℕ → α) (n : ℕ) : (⨅ k < n + 1, u k) = (⨅ k < n, u k) ⊓ u n :=
@supr_lt_succ (order_dual α) _ _ _
lemma infi_lt_succ' (u : ℕ → α) (n : ℕ) : (⨅ k < n + 1, u k) = u 0 ⊓ (⨅ k < n, u (k + 1)) :=
@supr_lt_succ' (order_dual α) _ _ _
end
end nat
namespace set
variable {α : Type*}
lemma bUnion_lt_succ (u : ℕ → set α) (n : ℕ) : (⋃ k < n + 1, u k) = (⋃ k < n, u k) ∪ u n :=
nat.supr_lt_succ u n
lemma bUnion_lt_succ' (u : ℕ → set α) (n : ℕ) : (⋃ k < n + 1, u k) = u 0 ∪ (⋃ k < n, u (k + 1)) :=
nat.supr_lt_succ' u n
lemma bInter_lt_succ (u : ℕ → set α) (n : ℕ) : (⋂ k < n + 1, u k) = (⋂ k < n, u k) ∩ u n :=
nat.infi_lt_succ u n
lemma bInter_lt_succ' (u : ℕ → set α) (n : ℕ) : (⋂ k < n + 1, u k) = u 0 ∩ (⋂ k < n, u (k + 1)) :=
nat.infi_lt_succ' u n
end set
namespace enat
open_locale classical
noncomputable instance : complete_linear_order enat :=
{ .. enat.linear_order,
.. with_top_order_iso.symm.to_galois_insertion.lift_complete_lattice }
end enat
|
{"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/nat/lattice.lean"}
|
import numpy as np
import pytest
from imitation.data import types
from imitation.data.buffer import Buffer, ReplayBuffer
def _fill_chunk(start, chunk_len, sample_shape, dtype=np.float):
fill_vals = np.arange(start, start + chunk_len, dtype=dtype)
fill_vals = np.reshape(fill_vals, (-1,) + (1,) * len(sample_shape))
chunk = np.tile(fill_vals, (1,) + sample_shape)
return chunk
def _get_fill_from_chunk(chunk):
chunk_len, *sample_shape = chunk.shape
sample_size = max(1, np.prod(sample_shape))
return chunk.flatten()[::sample_size]
def _check_bound(end, capacity, samples, offset=0):
start = max(0, end - capacity)
assert np.all(start + offset <= samples), "samples violate lower bound"
assert np.all(samples <= end + offset), "samples violate upper bound"
@pytest.mark.parametrize("capacity", [10, 30, 60])
@pytest.mark.parametrize("chunk_len", [1, 2, 4, 9])
@pytest.mark.parametrize("sample_shape", [(), (1, 2), (5, 4, 4)])
def test_buffer(capacity, chunk_len, sample_shape):
"""Builds a Buffer with the provided `capacity` and insert `capacity * 3`
samples into the buffer in chunks of shape `(chunk_len,) + sample_shape`.
We always insert chunks with consecutive integers.
* `len(buffer)` should increase until we reach capacity.
* `buffer._idx` should loop between 0 and `capacity - 1`.
* After every insertion, samples should be in expected range, verifying
FIFO insertion.
* Mutating the inserted chunk shouldn't mutate the buffer.
"""
buf = Buffer(
capacity,
sample_shapes={"a": sample_shape, "b": sample_shape},
dtypes={"a": float, "b": float},
)
to_insert = 3 * capacity
for i in range(0, to_insert, chunk_len):
assert buf.size() == min(i, capacity)
assert buf._idx == i % capacity
chunk_a = _fill_chunk(i, chunk_len, sample_shape)
chunk_b = _fill_chunk(i + to_insert, chunk_len, sample_shape)
buf.store({"a": chunk_a, "b": chunk_b})
samples = buf.sample(100)
assert set(samples.keys()) == {"a", "b"}, samples.keys()
_check_bound(i + chunk_len, capacity, samples["a"])
_check_bound(i + chunk_len + to_insert, capacity, samples["b"])
assert np.all(samples["b"] - samples["a"] == to_insert)
# Confirm that buffer is not mutable from inserted sample.
chunk_a[:] = np.nan
chunk_b[:] = np.nan
assert not np.any(np.isnan(buf._arrays["a"]))
assert not np.any(np.isnan(buf._arrays["b"]))
@pytest.mark.parametrize("capacity", [30, 60])
@pytest.mark.parametrize("chunk_len", [1, 4, 9])
@pytest.mark.parametrize("obs_shape", [(), (1, 2)])
@pytest.mark.parametrize("act_shape", [(), (5, 4, 4)])
@pytest.mark.parametrize("dtype", [int, np.float32])
def test_replay_buffer(capacity, chunk_len, obs_shape, act_shape, dtype):
"""Builds a ReplayBuffer with the provided `capacity` and inserts.
`capacity * 3` observation-action-observation samples into the buffer in
chunks of length `chunk_len`.
All chunks are of the appropriate observation or action shape, and contain
the value fill_val.
`len(buffer)` should increase until we reach capacity.
`buffer._idx` should loop between 0 and `capacity - 1`.
After every insertion, samples should only contain 66.6.
"""
buf = ReplayBuffer(
capacity,
obs_shape=obs_shape,
act_shape=act_shape,
obs_dtype=dtype,
act_dtype=dtype,
)
for i in range(0, capacity * 3, chunk_len):
assert buf.size() == min(i, capacity)
assert buf._buffer._idx == i % capacity
dones = np.arange(i, i + chunk_len, dtype=np.int32) % 2
dones = dones.astype(bool)
infos = _fill_chunk(9 * capacity + i, chunk_len, (), dtype=dtype)
infos = np.array([{"a": val} for val in infos])
batch = types.Transitions(
obs=_fill_chunk(i, chunk_len, obs_shape, dtype=dtype),
next_obs=_fill_chunk(3 * capacity + i, chunk_len, obs_shape, dtype=dtype),
acts=_fill_chunk(6 * capacity + i, chunk_len, act_shape, dtype=dtype),
dones=dones,
infos=infos,
)
buf.store(batch)
# Are samples right shape?
sample = buf.sample(100)
info_vals = np.array([info["a"] for info in sample.infos])
assert sample.obs.shape == sample.next_obs.shape == (100,) + obs_shape
assert sample.acts.shape == (100,) + act_shape
assert sample.dones.shape == (100,)
assert info_vals.shape == (100,)
# Are samples right data type?
assert sample.obs.dtype == dtype
assert sample.acts.dtype == dtype
assert sample.next_obs.dtype == dtype
assert info_vals.dtype == dtype
assert sample.dones.dtype == bool
assert sample.infos.dtype == np.object
# Are samples in range?
_check_bound(i + chunk_len, capacity, sample.obs)
_check_bound(i + chunk_len, capacity, sample.next_obs, 3 * capacity)
_check_bound(i + chunk_len, capacity, sample.acts, 6 * capacity)
_check_bound(i + chunk_len, capacity, info_vals, 9 * capacity)
# Are samples in-order?
obs_fill = _get_fill_from_chunk(sample.obs)
next_obs_fill = _get_fill_from_chunk(sample.next_obs)
act_fill = _get_fill_from_chunk(sample.acts)
info_vals_fill = _get_fill_from_chunk(info_vals)
assert np.all(next_obs_fill - obs_fill == 3 * capacity), "out of order"
assert np.all(act_fill - next_obs_fill == 3 * capacity), "out of order"
assert np.all(info_vals_fill - act_fill == 3 * capacity), "out of order"
# Can't do much other than parity check for boolean values.
# `samples.done` has the same parity as `obs_fill` by construction.
assert np.all(obs_fill % 2 == sample.dones), "out of order"
@pytest.mark.parametrize("sample_shape", [(), (1,), (5, 2)])
def test_buffer_store_errors(sample_shape):
capacity = 11
dtype = "float32"
def buf():
return Buffer(capacity, {"k": sample_shape}, {"k": dtype})
# Unexpected keys
b = buf()
with pytest.raises(ValueError):
b.store({})
chunk = np.ones((1,) + sample_shape)
with pytest.raises(ValueError):
b.store({"y": chunk})
with pytest.raises(ValueError):
b.store({"k": chunk, "y": chunk})
# `data` is empty.
b = buf()
with pytest.raises(ValueError):
b.store({"k": np.empty((0,) + sample_shape, dtype=dtype)})
# `data` has too many samples.
b = buf()
with pytest.raises(ValueError):
b.store({"k": np.empty((capacity + 1,) + sample_shape, dtype=dtype)})
# `data` has the wrong sample shape.
b = buf()
with pytest.raises(ValueError):
b.store({"k": np.empty((1, 3, 3, 3, 3), dtype=dtype)})
def test_buffer_sample_errors():
b = Buffer(10, {"k": (2, 1)}, dtypes={"k": bool})
with pytest.raises(ValueError):
b.sample(5)
def test_buffer_init_errors():
with pytest.raises(KeyError, match=r"sample_shape and dtypes.*"):
Buffer(10, dict(a=(2, 1), b=(3,)), dtypes=dict(a="float32", c=bool))
def test_replay_buffer_init_errors():
with pytest.raises(ValueError, match=r"Specified.* and environment"):
ReplayBuffer(15, venv="MockEnv", obs_shape=(10, 10))
with pytest.raises(ValueError, match=r"Shape or dtype missing.*"):
ReplayBuffer(15, obs_shape=(10, 10), act_shape=(15,), obs_dtype=bool)
with pytest.raises(ValueError, match=r"Shape or dtype missing.*"):
ReplayBuffer(15, obs_shape=(10, 10), obs_dtype=bool, act_dtype=bool)
def test_buffer_from_data():
data = np.ndarray([50, 30], dtype=bool)
buf = Buffer.from_data({"k": data})
assert buf._arrays["k"] is not data
assert data.dtype == buf._arrays["k"].dtype
assert np.array_equal(buf._arrays["k"], data)
def test_replay_buffer_from_data():
obs = np.array([5, 2], dtype=int)
acts = np.ones((2, 6), dtype=float)
next_obs = np.array([7, 8], dtype=int)
dones = np.array([True, False])
infos = np.array([{}, {"a": "sdf"}])
def _check_buf(buf):
assert np.array_equal(buf._buffer._arrays["obs"], obs)
assert np.array_equal(buf._buffer._arrays["next_obs"], next_obs)
assert np.array_equal(buf._buffer._arrays["acts"], acts)
assert np.array_equal(buf._buffer._arrays["infos"], infos)
buf_std = ReplayBuffer.from_data(
types.Transitions(
obs=obs, acts=acts, next_obs=next_obs, dones=dones, infos=infos
)
)
_check_buf(buf_std)
rews = np.array([0.5, 1.0], dtype=float)
buf_rew = ReplayBuffer.from_data(
types.TransitionsWithRew(
obs=obs,
acts=acts,
next_obs=next_obs,
rews=rews,
dones=dones,
infos=infos,
)
)
_check_buf(buf_rew)
|
{"hexsha": "655f5f4af9c7a3d7c7cdb210129c9fa52c714af6", "size": 8946, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_buffer.py", "max_stars_repo_name": "bbrito/imitation-1", "max_stars_repo_head_hexsha": "c1c1f01ce7a141a501238adcdffa73fe8acceb73", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-08T03:05:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T03:05:55.000Z", "max_issues_repo_path": "tests/test_buffer.py", "max_issues_repo_name": "yuzhouxianzhi/imitation", "max_issues_repo_head_hexsha": "39fe780abb1a313001e9ae1fab1fa35a589a58cc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/test_buffer.py", "max_forks_repo_name": "yuzhouxianzhi/imitation", "max_forks_repo_head_hexsha": "39fe780abb1a313001e9ae1fab1fa35a589a58cc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-18T12:04:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-18T12:04:38.000Z", "avg_line_length": 36.9669421488, "max_line_length": 86, "alphanum_fraction": 0.6343617259, "include": true, "reason": "import numpy", "num_tokens": 2283}
|
import re
import sys
import nltk
import string
import math
import numpy as np
import seaborn as sns
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import sklearn
from sklearn.model_selection import cross_val_predict, KFold
from sklearn.metrics import classification_report
from nltk.tokenize import RegexpTokenizer
#from sklearn.grid_search import RandomizedSearchCV
import sklearn_crfsuite
from sklearn_crfsuite import scorers
from sklearn_crfsuite import metrics
from sklearn_crfsuite.utils import flatten
import CRF_features_baseline
import CRF_measures_baseline
import xml.etree.cElementTree as Elem
import xml
from xml.etree.ElementTree import Element, ElementTree
import parsingReportsXML_baseline
import confusionmatrix_heatmap
def token_LabelCreation(reports):
docs=[]
labelList=[]
report_count=0
#label_report_count={}
for report in reports:
#print report
report=report.strip('[(').strip('\n').strip(')]')
lines=report.split('), (')
EachReport=[]
report_count=report_count+1
for line in lines:
#line=re.sub(r'\d+[,-]*\d*[?]*\s*[mc]m',"#NUM",line)
#print line
line=line.strip("'").strip('"')
#print line
#line=re.sub(r"\\","",line)
ar=re.split(r"', '|', \"|', u'",line)
#print ar
if len(ar)!=2:
#ar=line.split("', \"")
print line
print ar
#print ar
#ar[0]=re.sub(r"'","",ar[0])
#print ar[0]
#ar[1]=re.sub(r"'|\"","",ar[1])
#print ar[1]
#print ar[0]
label=("/").join(ar[0].split('/')[2:])
labelList.append(label)
#print label
tokens=ar[1].strip()
#print tokens
tovPat=re.compile(r't,o,v',re.IGNORECASE)
tokens=tovPat.sub('tov',tokens)
#date=re.search(r'\d\d-\d\d-\d\d',tokens)
#if date!=None:
# print line
# date_new=re.sub(r'-','\\',date.group())
# tokens=re.sub(r'\d\d-\d\d-\d\d',date_new,tokens)
tokens=re.sub(r'\d',"#NUM",tokens)
#tokens=re.sub(r'#NUM#NUM-#NUM#NUM-#NUM#NUM#NUM#NUM',"#NUM#NUM/#NUM#NUM/#NUM#NUM#NUM#NUM",tokens)
tokens=re.split(r'([,\(\).?:-]*)\s*',tokens)
tokens=filter(lambda a: a!='', tokens)
#tokens=re.findall(r"[\w']+|[.,?!;]",tokens)
#print tokens
if not label_count_report.has_key(label):
label_count_report[label]=[1,report_count]
else:
if report_count!=label_count_report[label][1]:
label_count_report[label][0]=label_count_report[label][0]+1
label_count_report[label][1]=report_count
for i in range(len(tokens)):
if label=='O':
EachReport.append((tokens[i],label))
else:
if i==0:
tag='B-'+label
EachReport.append((tokens[i],tag))
else:
tag='I-'+label
EachReport.append((tokens[i],tag))
docs.append(EachReport)
#print np.unique(labelList)
return docs
def CRF_featureCreation(docs):
tokenList,data=CRF_features_baseline.posTagAdding(docs)
X = [CRF_features_baseline.sent2features(doc) for doc in data]
y = [CRF_features_baseline.sent2labels(doc) for doc in data]
print len(X)
print len(y)
return X,y,tokenList
def CRF_trainer(X,y,X_Te):
crf = sklearn_crfsuite.CRF(
algorithm='lbfgs',
c1=0.1,
c2=0.1,
max_iterations=100,
all_possible_transitions=True
)
#kf=KFold(n_splits=5,shuffle=True)
#predicted=cross_val_predict(crf, X, y, cv=kf)
crf.fit(X,y)
predicted=crf.predict(X_Te)
return predicted
tree_all = Elem.parse('./../labeling/new_data.xml')
list_tree=tree_all.findall('report')
print len(list_tree)
k=len(list_tree)/4
label_dic_all={}
label_dic_2={}
out=open('CRF_baseline_file.txt','a')
out1=open('CRF_baseline_featurefile.txt','a')
out2=open('CRF_baseline_predictedvsTrue.txt','a')
label_dic_2_pre={}
conf_mat_agg=np.zeros((34,34))
root=Element('radiology_reports')
for list_tree_elem in list_tree:
root.append(list_tree_elem)
out4=open('file_test','w')
EachReport1=[]
parsingReportsXML_baseline.print_path_of_elems(out4,EachReport1, root, root.tag)
out4.close()
f=open('file_test','r')
reports_te=f.readlines()
label_count_report={}
docs1_te=token_LabelCreation(reports_te)
print label_count_report
'''for i in range(0,4):
if i==0:
list_tree_test=list_tree[:k]
list_tree_train=list_tree[k:]
elif i==len(list_tree)-1:
list_tree_test=list_tree[3*k:]
list_tree_train=list_tree[:3*k]
else:
list_tree_train=list_tree[:i*k]+list_tree[(i+1)*k:]
list_tree_test=list_tree[i*k:(i+1)*k]
root=Element('radiology_reports')
root1=Element('radiology_reports')
for list_tree_elem in list_tree_train:
root.append(list_tree_elem)
print "length:",len(root)
for list_tree_elem in list_tree_test:
root1.append(list_tree_elem)
print "length:",len(root1)
tree=ElementTree(root)
#roott=tree.getroot()
tree1=ElementTree(root1)
#roott1=tree1.getroot()
out3=open('file_train_'+str(i),'w')
out4=open('file_test_'+str(i),'w')
EachReport1=[]
EachReport2=[]
parsingReportsXML_baseline.print_path_of_elems(out3,EachReport1, root, root.tag)
parsingReportsXML_baseline.print_path_of_elems(out4,EachReport2, root1, root1.tag)
total_measure_dic={}
out3.close()
out4.close()
f_train=open('file_train_'+str(i),'r')
f_test=open('file_test_'+str(i),'r')
reports_tr=f_train.readlines()
reports_te=f_test.readlines()
docs1_tr=token_LabelCreation(reports_tr)
docs1_te=token_LabelCreation(reports_te)
for i,doc in enumerate(docs1_te):
for line in doc:
out.write(str(i)+"\t"+line[0]+"\t"+line[1]+"\n")
X_tr,Y_tr,tokenList_tr_=CRF_featureCreation(docs1_tr)
X_te,Y_te,tokenList_te=CRF_featureCreation(docs1_te)
for doc in X_te:
for line in doc:
out1.write(str(line)+"\n")
predicted1=CRF_trainer(X_tr,Y_tr,X_te)
predicted2=[]
Y1=[]
for data1,true1,pre1 in zip(tokenList_te,Y_te,predicted1):
preSub=[]
YSub=[]
for i in range(0,len(data1)):
preSub.append(pre1[i])
YSub.append(true1[i])
if data1[i] not in string.punctuation:
out2.write(str(data1[i])+"\t"+str(true1[i])+"\t"+str(pre1[i])+"\n")
#print data1[i],"\t",pre1[i],"\t",true1[i]
predicted2.append(preSub)
Y1.append(YSub)
CRF_measures_baseline.tokenLevel_measures(predicted2,Y1,tokenList_te,label_dic_all,conf_mat_agg)
predictPredictList1=[]
tokenFor2levelList1=[]
trueLabel_2labelsList1=[]
predictList1=[]
tokenFor1levelList1=[]
trueLabel_1labelsList1=[]
nfc=0
for j in range(len(tokenList_te)):
predictPredict1=[]
tokenFor2level=[]
trueLabel_2labels1=[]
predict1=[]
tokenFor1level=[]
trueLabel_1labels1=[]
for m in range(len(tokenList_te[j])):
#print predicted2[j][k]
#print Y1[j][k]
pred1=predicted2[j][m].split('/')
true1=Y1[j][m].split('/')
if true1=="B-negative_finding" or true1=="I-negative_finding":
nfc=nfc+1
#Level2
if len(pred1)>=2 or len(true1)>=2 or true1[0].split('-')[len(true1[0].split('-'))-1]=='negative_finding' or pred1[0].split('-')[len(pred1[0].split('-'))-1]=='negative_finding':
predictPredict="/".join(pred1[:2])
trueTrue="/".join(true1[:2])
tokenFor2level.append(tokenList_te[j][m])
predictPredict1.append(predictPredict)
trueLabel_2labels1.append(trueTrue)
#Level1
predictL="/".join(pred1[:1])
trueL="/".join(true1[:1])
tokenFor1level.append(tokenList_te[j][m])
predict1.append(predictL)
trueLabel_1labels1.append(trueL)
#Level2
predictPredictList1.append(predictPredict1)
trueLabel_2labelsList1.append(trueLabel_2labels1)
tokenFor2levelList1.append(tokenFor2level)
#Level1
predictList1.append(predict1)
trueLabel_1labelsList1.append(trueLabel_1labels1)
tokenFor1levelList1.append(tokenFor1level)
#CRF_measures_baseline.tokenLevel_measures(predictPredictList1,trueLabel_2labelsList1,tokenFor2levelList1,label_dic_2_pre)
#CRF_measures_baseline.tokenLevel_measures(predictList1,trueLabel_1labelsList1,tokenFor1levelList1,label_dic_2_pre)
print nfc
f_train.close()
f_test.close()'''
#partial_phrase_dic,complete_phrase_dic=CRF_measures_baseline.partialPhraseLevel_measures(tokenList_te,predicted1,Y_te)
#print "Label\tTokenPrecision,recall,fmeasure,support\tPartialPhraseAccuracy\tCompletePhraseAccuracy"
#for key in token_dic.iterkeys():
# total_measure_dic[key]=[token_dic[key],partial_phrase_dic[key],complete_phrase_dic[key]]
# print key,"\t",token_dic[key],"\t", partial_phrase_dic[key],"\t",complete_phrase_dic[key]'''
'''label_dic2_fscore={}
label_dic2_support={}
for key in label_dic_all.iterkeys():
label_dic2_fscore[key]=float(sum(label_dic_all[key][0]))/len(label_dic_all[key][0])
label_dic2_support[key]=label_dic_all[key][1][0]
print label_dic2_fscore
print label_dic2_support'''
label_dic_abb={'O':'O','breast_composition':'BC','positive_finding/mass/location':'PF/MS/L','positive_finding/mass/size':'PF/MS/SI','positive_finding/mass/margin':'PF/MS/MA','positive_finding/mass/density':'PF/MS/DE','positive_finding/mass/associated_features':'PF/MS/AF','positive_finding/mass/shape':'PF/MS/SH','positive_finding/mass':'PF/MS/O','positive_finding/calcification/location':'PF/C/L',\
'positive_finding/calcification/size':'PF/C/SI','positive_finding/calcification/morphology':'PF/C/MO','positive_finding/calcification/distribution':'PF/C/DI','positive_finding/calcification/associated_features':'PF/C/AF','positive_finding/calcification':'PF/C/O','positive_finding/architectural_distortion/location':'PF/AD/L','positive_finding/architectural_distortion/associated_features':'PF/AD/AF',\
'positive_finding/architectural_distortion':'PF/AD/O','positive_finding/associated_features/location':'PF/AF/L','positive_finding/associated_features':'PF/AF/O','positive_finding/asymmetry/location':'PF/AS/L','positive_finding/asymmetry/size':'PF/AS/SI','positive_finding/asymmetry/associated_features':'PF/AS/AF','positive_finding/asymmetry':'PF/AS/O','negative_finding/mass/location':'NF/MS/L',\
'negative_finding/mass/margin':'NF/MS/MA','negative_finding/mass':'NF/MS/O','negative_finding/calcification/location':'NF/C/L','negative_finding/calcification/morphology':'NF/C/MO','negative_finding/calcification/distribution':'NF/C/DI','negative_finding/calcification':'NF/C/O','negative_finding/architectural_distortion/location':'NF/AD/L','negative_finding/architectural_distortion':'NF/AD/O',\
'negative_finding/associated_features/location':'NF/AF/L','negative_finding/associated_features':'NF/AF/O','negative_finding/asymmetry/location':'NF/AS/L','negative_finding/asymmetry':'NF/AS/O','negative_finding/location':'NF/L','negative_finding':'NF/O'}
label_dic1={}
for key in label_dic_all.iterkeys():
label_dic1[label_dic_abb[key]]=label_dic_all[key][2][0]
sns.set()
#df_data=pd.DataFrame(label_dic1)
print label_dic1
axis_labels=sorted(label_dic1,key=label_dic1.__getitem__)
conf_mat_agg=conf_mat_agg.astype(int)
#print conf_mat_agg
conf_mat_agg_norm=(np.zeros((34,34))).astype('float')
for i in range(len(conf_mat_agg)):
s=np.sum(conf_mat_agg[i,:])
for j in range(len(conf_mat_agg[i])):
conf_mat_agg_norm[i,j]=float(conf_mat_agg[i,j])/s
f=plt.figure(figsize=(8,5))
sns.heatmap(
yticklabels=axis_labels,
xticklabels=axis_labels,
data=conf_mat_agg_norm,
cmap='YlGnBu',
#annot=True,
#fmt="d",
linewidths=0.75)
#plt.tight_layout()
plt.ylabel('True label')
plt.xlabel('Predicted label')
f.savefig("ConfusionMatrixHeatmap_baseline.pdf",bbox_inches='tight')
'''boundaries = [0.0, 0.001, 0.003, 0.1, 0.25, 0.5, 0.75, 0.9, 1.0] # custom boundaries
# here I generated twice as many colors,
# so that I could prune the boundaries more clearly
hex_colors = sns.light_palette('navy', n_colors=len(boundaries) * 2 + 2, as_cmap=False).as_hex()
hex_colors = [hex_colors[i] for i in range(0, len(hex_colors), 2)]
colors=list(zip(boundaries, hex_colors))
custom_color_map = matplotlib.colors.LinearSegmentedColormap.from_list(
name='custom_navy',
colors=colors,
)
sns.heatmap(
vmin=0,
vmax=500,
data=conf_mat_agg,
cmap=custom_color_map,
xticklabels=axis_labels,
yticklabels=axis_labels,
linewidths=0.75,
)'''
'''conf_mat_agg_df=pd.DataFrame(conf_mat_agg,index=axis_labels,columns=axis_labels)
corr=conf_mat_agg_df.corr()
sns.heatmap(corr,cmap="magma_r")'''
'''def NonLinCdict(steps, hexcol_array):
cdict = {'red': (), 'green': (), 'blue': ()}
for s, hexcol in zip(steps, hexcol_array):
rgb =matplotlib.colors.hex2color(hexcol)
cdict['red'] = cdict['red'] + ((s, rgb[0], rgb[0]),)
cdict['green'] = cdict['green'] + ((s, rgb[1], rgb[1]),)
cdict['blue'] = cdict['blue'] + ((s, rgb[2], rgb[2]),)
return cdict
#hc = ['#ffe5e5','#E6B3B3','#ffb2b2','#ff9999','#ff7f7f','#ff6666','#ff4c4c','#ff3232', '#ff1919','#acacdf', '#7272bf', '#39399f', '#000080'] #'#e5e5ff'
#th = [0, 0.001, 0.03, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.5, 0.6, 1.0]
hc = ['#ffe5e5','#ff9999','#ff7f7f','#ff6666','#ff4c4c','#ff3232', '#ff1919', '#ff0000','#991900'] #'#e5e5ff'
th = [0, 0.1, 0.2, 0.25, 0.3, 0.35, 0.5, 0.6, 1.0]
cdict = NonLinCdict(th, hc)
cm = matplotlib.colors.LinearSegmentedColormap('test', cdict)
#plt.figure()
sns.heatmap(
yticklabels=axis_labels,
xticklabels=axis_labels,
vmin=0,
vmax=1374,
data=conf_mat_agg,
cmap=cm,
annot=True,
fmt="d",
linewidths=0.75)'''
#ax=sns.heatmap(conf_mat_agg,yticklabels=axis_labels,xticklabels=axis_labels,annot=True,linewidths=0.75,fmt="d",cmap="rainbow")#cmap=sns.diverging_palette(220,30,as_cmap=True))#cmap="YlGnBu")
#fig=confusionmatrix_heatmap.print_confusion_matrix(conf_mat_agg,axis_labels)
#plt.show()
label_dic2_fscore={}
label_dic2_support={}
for key in label_dic_2_pre.iterkeys():
label_dic2_fscore[key]=float(sum(label_dic_2_pre[key][0]))/len(label_dic_2_pre[key][0])
label_dic2_support[key]=label_dic_2_pre[key][1][0]
print label_dic2_fscore
print label_dic2_support
|
{"hexsha": "29166acfe8a979fbf9d4968f127d1f1c8b6ed6dc", "size": 15139, "ext": "py", "lang": "Python", "max_stars_repo_path": "AutomaticStructuring/CRF Baseline/CRF_training_testing_baseline.py", "max_stars_repo_name": "ShreyasiPathak/AutomaticStructuringBreastCancerReports", "max_stars_repo_head_hexsha": "a7e109b515e99fdb1928bc558d7ffe5aa9b1a604", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-02-18T09:20:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-07T10:51:54.000Z", "max_issues_repo_path": "AutomaticStructuring/CRF Baseline/CRF_training_testing_baseline.py", "max_issues_repo_name": "ShreyasiPathak/AutomaticStructuringBreastCancerReports", "max_issues_repo_head_hexsha": "a7e109b515e99fdb1928bc558d7ffe5aa9b1a604", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AutomaticStructuring/CRF Baseline/CRF_training_testing_baseline.py", "max_forks_repo_name": "ShreyasiPathak/AutomaticStructuringBreastCancerReports", "max_forks_repo_head_hexsha": "a7e109b515e99fdb1928bc558d7ffe5aa9b1a604", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-09-10T10:55:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-18T14:22:58.000Z", "avg_line_length": 41.7052341598, "max_line_length": 417, "alphanum_fraction": 0.6563841733, "include": true, "reason": "import numpy", "num_tokens": 4209}
|
import numpy as np
import copy
from scipy.stats import entropy
from scipy.special import logsumexp
from numpy.random import choice
from scipy.special import softmax
#from scipy.stats import entropy
#import LinkedList as LL
#class LinkedList(object):
# def __init__(self, head=None):
# self.head = head
# remove xspace in each iteration
class Problem():
def __init__(self, xspace, yspace, hyperlist, pz_theta_model, py_eq_z, pi_theta = None, classnum = 2, dataidx = None):
self.xspace = xspace
self.yspace = yspace
self.hyperlist = hyperlist
self.PzGivenXTheta = pz_theta_model
self.PYeqZ = py_eq_z#if PYeqZ is None, means that there is no flip error
# if pi_theta is None:
# pi_theta = np.ones(len(thetalist))
# pi_theta /= pi_theta.sum()
# self.pi_theta = pi_theta
#change pzmat_Theta
self.cnum = classnum
self.pzmat_Theta = self.PzGivenData(self.hyperlist)
self.pymat_Theta = self.PyGivenData(self.hyperlist)
self.thetanum = 1000
self.binnum = 16
self.dataidx = dataidx
# if self.PYeqZ is None:
# self.pymat_Theta = self.pzmat_Theta
# elif self.PYeqZ.__name__ == 'py_eq_z':
# self.pymat_Theta = self.PYeqZ(self.xspace, self.pzmat_Theta)
# elif self.PYeqZ.__name__ == 'py_eq_z_vari':
# self.pymat_Theta = self.PyGivenData(self.pi_theta)
def Initialize(self, xspace, yspace, hyperlist, dataidx = None):
self.hyperlist = hyperlist
self.xspace = xspace
self.yspace = yspace
self.dataidx = dataidx
# def fr(self, x , thetar):
#
#
#
# pz = self.PzGivenXTheta(x, thetar)
# if self.PYeqZ is None:
# py = pz
# elif self.PYeqZ.__name__ == 'py_eq_z':
# py = self.PYeqZ(x, pz)
# elif self.PYeqZ.__name__ == 'py_eq_z_vari':
# py = self.PYeqZ(x, pz, thetar)
#
# if x is self.xspace:
# ymat = np.zeros(len(self.xspace))
# for i, xx in enumerate(self.xspace):
# ymat[i] = choice(range(self.cnum), p=py[:, i] )
# else:
# ymat = choice(range(self.cnum), p = py)
#
# return ymat
def ParameterUpdate(self, x, y):#update this for error #############################
#Here the input of x can only be single input: x = np.array([x1[i][0],x2[j]])
# the posterior distribution is deterministic here, we only need to update it
# to probabilistic case
hyperlist2 = copy.copy(self.hyperlist) # hyperlist = [blist; alist] <=> p(y = 0|x), p(y = 1|x)
y = int(y)
x = np.reshape(x, (1, -1))
hyperlist2[y, x]+=1
return hyperlist2
def PzGivenData(self, hyperlist): ################closed form
pTheta_in_bins = hyperlist/np.sum(hyperlist, axis = 0)
pzmat = pTheta_in_bins[:, self.xspace]
# pzmat = np.zeros([self.cnum, len(self.xspace)])
#
# for i in range(len(pi_theta)):
# pzmat += self.PzGivenXTheta(self.xspace, self.thetalist[i])*pi_theta[i]
return pzmat
def PyGivenData(self, pi_theta):
if self.PYeqZ is None:
return self.pzmat_Theta
if self.PYeqZ.__name__ == 'py_eq_z':
return self.PYeqZ(self.xspace, self.pzmat_Theta)
if self.PYeqZ.__name__ == 'py_eq_z_vari':
# self.pymat_Theta = self.PyGivenData(self.pi_theta)
#if PYeqZ.__name__ == 'py_eq_z_vari'
pymat = np.zeros([self.cnum, len(self.xspace)])
for i in range(len(pi_theta)):
pztemp = self.PzGivenXTheta(self.xspace, self.thetalist[i])
pytemp = self.PYeqZ(self.xspace, pztemp, self.thetalist[i])
pymat += pytemp*pi_theta[i]
return pymat
def ObcError(self, hyperlist):
pzmat_Theta = self.PzGivenData(hyperlist)
errormat = 1 - np.amax(pzmat_Theta, axis = 0)
error = np.mean(errormat)#assume x is uniform distributed
return error
def MinIbrResidual(self, x, py_x):
sumresidual = 0
for i in range(self.cnum):
p = py_x[i]
y = i
# for i in range(2):
# if i == 0:
# p = py_x
# y = 1
# else:
# p = 1-py_x
# y = 0
hyperlist2 = self.ParameterUpdate(x, y)
sumresidual += self.ObcError(hyperlist2)*p
return -sumresidual
def MinIbrResidualWhole(self):
#the IbrResidual for the whole space
utilitymat = np.zeros(len(self.xspace))
# if self.PYeqZ is None:
# pymat = self.pzmat_Theta
# elif self.PYeqZ.__name__ == 'py_eq_z':
# pymat = self.PYeqZ(self.xspace, self.pzmat_Theta)
# elif self.PYeqZ.__name__ == 'py_eq_z_vari':
# pymat = self.PyGivenData(self.pi_theta)
pymat = self.pymat_Theta
for i, x in enumerate(self.xspace):
py_x = pymat[:, i]
utilitymat[i] = self.MinIbrResidual(x, py_x)
return self.ObcError(self.hyperlist)+utilitymat
def SMOCU(self, hyperlist, k, softtype):
# smocu = np.zeros(len(self.xspace))
pzmat = self.PzGivenData(hyperlist)
if softtype == 1:
# obc_correct = (pzmat*np.exp(pzmat*k) + (1-pzmat)*np.exp(k-pzmat*k))/(np.exp(pzmat*k)+np.exp(k-pzmat*k))
obc_correct = np.sum(softmax(pzmat*k, axis = 0)*pzmat, axis=0)
############ softmax()
smocu = np.mean( - obc_correct)
elif softtype == 2:
# pzmat_array = np.array([pzmat, 1-pzmat])
obc_correct = logsumexp(k*pzmat, axis = 0)/k
smocu = np.mean( - obc_correct)
elif softtype == 3: #this is weighted-MOCU with weight 1-K
bayesian_precision = np.zeros(len(self.xspace))
thetalist = np.random.beta(hyperlist[1, :], hyperlist[0, :], size = (self.thetanum, self.binnum))
pi_theta = np.ones(len(thetalist))
pi_theta /= pi_theta.sum()
for i, theta in enumerate(thetalist):
bayesian_precision += np.amax(self.PzGivenXTheta(self.xspace, theta), axis=0 )*pi_theta[i]
average_loss = bayesian_precision - np.amax(pzmat, axis=0)
weight = 1 - average_loss
smocu = np.mean(weight*average_loss)
# elif softtype == 4:
# bayesian_precision = np.zeros(len(self.xspace))
# for i, theta in enumerate(self.thetalist):
# bayesian_precision += np.amax(self.PzGivenXTheta(self.xspace, theta), axis=0 )*pi_theta[i]
# average_loss = bayesian_precision - np.amax(pzmat, axis=0)
## zhat = np.argmax(pzmat, axis = 0)
## pzmat_r[zhat, range(self.xspace.shape[0])]
# weight = np.exp(np.amax(pzmat, axis=0))/np.sum(np.exp(pzmat), axis = 0)
# smocu = np.mean(weight*average_loss)
return smocu
def D_SMOCU(self, x, py_x, k, softtype):
# x = self.xspace[xidx]
# pz_x = self.pzmat_Theta[:, xidx]
# if self.PYeqZ is None:
# py_x = pz_x
# elif self.PYeqZ.__name__ == 'py_eq_z':
# py_x = self.PYeqZ(x, pz_x)
# elif self.PYeqZ.__name__ == 'py_eq_z_vari':
# py_x = self.pymat_Theta[xidx]
smocu2 = 0
for i in range(self.cnum):
p = py_x[i]
y = i
hyperlist2 = self.ParameterUpdate(x, y)
smocu2 += p*self.SMOCU(hyperlist2, k, softtype)
return smocu2
def SoftMOCU_K(self, k, softtype):##########################
# smocu = self.SMOCU(self.pi_theta, k)
utilitymat = np.zeros(len(self.xspace))
utilitybin = np.zeros(self.binnum)
pzTheta_in_bins = self.hyperlist/np.sum(self.hyperlist, axis = 0)
for j in range(self.binnum):
pz_x_bin = pzTheta_in_bins[:, j]
utilitybin[j] = - self.D_SMOCU(j, pz_x_bin, k, softtype)
for i, x in enumerate(self.xspace):
utilitymat[i] = utilitybin[x]
# utilitymat[i] = smocu - self.D_SMOCU(i, k)
# pz_x = self.pzmat_Theta[:, i]
# if self.PYeqZ is None:
# py_x = pz_x
# elif self.PYeqZ.__name__ == 'py_eq_z':
# py_x = self.PYeqZ(x, pz_x)
# elif self.PYeqZ.__name__ == 'py_eq_z_vari':
# py_x = self.pymat_Theta[:, i]
# utilitymat[i] = - self.D_SMOCU(x, py_x, k, softtype)
return utilitymat
def SoftMOCUWhole(self, k = 1, softtype = 1):######################
return lambda: self.SoftMOCU_K(k, softtype)
# def SMOCU2(self, pi_theta, k):
# pzmat = self.PzGivenData(pi_theta)
## pzmat1 = 1-pzmat
# pzmat_array = np.array(pzmat, 1-pzmat)
# obc_correct = logsumexp(k*pzmat, axis = 1)/k
# smocu = np.mean(-obc_correct)
# return smocu
def EntropyWhole(self):
entropymat = np.zeros(len(self.xspace))
# self.pzmat_Theta = self.PzGivenData( self.pi_theta)
# pymat = self.PzGivenData( self.pi_theta)
# if self.PYeqZ is None:
# pymat = self.pzmat_Theta
# else:
# pymat = self.PYeqZ(self.xspace, self.pzmat_Theta)
pymat = self.pymat_Theta
pytheta_entropy_mat = np.zeros(len(self.xspace))
# posterior_entropy_mat2 = posterior_entropy_mat
thetalist = np.random.beta(self.hyperlist[1, :], self.hyperlist[0, :], size = (self.thetanum, self.binnum))
pi_theta = np.ones(len(thetalist))
pi_theta /= pi_theta.sum()
for i in range(len(thetalist)):
theta = thetalist[i]
pz_theta_mat = self.PzGivenXTheta(self.xspace, theta)
if self.PYeqZ is None:
py_theta_mat = pz_theta_mat
elif self.PYeqZ.__name__ == 'py_eq_z':
py_theta_mat = self.PYeqZ(self.xspace, pz_theta_mat)
elif self.PYeqZ.__name__ == 'py_eq_z_vari':
py_theta_mat = self.PYeqZ(self.xspace, pz_theta_mat, theta)
# pz_theta_mat*self.PYeqZ(self.xspace) +\
# (1-pz_theta_mat)*(1-self.PYeqZ(self.xspace))
# posterior_entropy_mat += self.pi_theta[i]*bientropy(py_theta_mat)
pytheta_entropy_mat += pi_theta[i]*entropy(py_theta_mat)##########################samples
# posterior_entropy_mat += self.pi_theta[i]*entropy([py_theta_mat, 1-py_theta_mat])
# entropymat = bientropy(self.pzmat_Theta) - posterior_entropy_mat
entropymat = entropy(pymat) - pytheta_entropy_mat
return entropymat
def UncertaintyWhole(self):
# pymat = self.PYeqZ(self.xspace)*self.pzmat_Theta+(1-self.pzmat_Theta)*(1-self.PYeqZ(self.xspace))
objmat = entropy(self.pzmat_Theta)
return objmat
# def EntropyPoint(self, x, py_x):
# bientropy = lambda x: -x*np.log(x)-(1-x)*np.log(1-x)
def Selector(self, func):
utilitymat = np.zeros(len(self.xspace))
utilitymat = func()
if self.yspace is not None:
utilitymat[self.dataidx] = float('-Inf')
max_index = np.argmax(utilitymat, axis = None)
x = self.xspace[max_index]
if self.yspace is not None:
y = self.yspace[max_index]
else:
y = None
return x, y, max_index
def Update(self, xstar, ystar, xidx):
# for i, pi in enumerate(self.pi_theta):
# pz1_xtheta = self.PzGivenXTheta(xstar, self.thetalist[i])
# if self.PYeqZ is None:
# py1_xtheta = pz1_xtheta
# else:
# py1_xtheta = self.PYeqZ(xstar, pz1_xtheta)
#
# if ystar == 1:
# py_xtheta = py1_xtheta
# else:
# py_xtheta = (1 - py1_xtheta)
# self.pi_theta[i] *= py_xtheta
#
# self.pi_theta /= self.pi_theta.sum()
self.hyperlist = self.ParameterUpdate(xstar, ystar)
self.pzmat_Theta = self.PzGivenData(self.hyperlist)
self.pymat_Theta = self.PyGivenData(self.hyperlist)
return
def ObcEstimate(self, pzmat_Theta):
# py = PyGivenTheta(xspace, pi_theta)
zhat = np.argmax(pzmat_Theta, axis = 0)
# zhat = (pzmat_Theta>= 0.5)
zhat = zhat.astype(int)
return zhat
def ClassifierError(self, xspace, yspace):
# pymat is the prediction distribution of y given D
# pzmat_Theta = self.PzGivenData(pi_theta)
zhat = self.ObcEstimate(self.pzmat_Theta)
# zhat = zhat.astype(int)
# pzmat_r = self.PzGivenXTheta(self.xspace, thetar)
error = np.mean((zhat != yspace).astype(float))
# error = np.mean(np.abs(zhat - pzmat_r))
# z = fc(xspace, thetar)
# error = np.mean(zhat^z)
return error
def BayesianError(self, thetar):
pzmat = self.PzGivenXTheta(self.xspace, thetar)
errormat = np.amin(1-pzmat, axis = 0)
error = np.mean(errormat)#assume x is uniform distributed
return error
|
{"hexsha": "e05d70f3991a5597e03a64e9351014fcca7d8279", "size": 13342, "ext": "py", "lang": "Python", "max_stars_repo_path": "figure5/MethodsTrueData_M.py", "max_stars_repo_name": "QianLab/WMOCU_AL", "max_stars_repo_head_hexsha": "b8f095366e731a730ba6e043a7fa57ef66510a33", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "figure5/MethodsTrueData_M.py", "max_issues_repo_name": "QianLab/WMOCU_AL", "max_issues_repo_head_hexsha": "b8f095366e731a730ba6e043a7fa57ef66510a33", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "figure5/MethodsTrueData_M.py", "max_forks_repo_name": "QianLab/WMOCU_AL", "max_forks_repo_head_hexsha": "b8f095366e731a730ba6e043a7fa57ef66510a33", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1260997067, "max_line_length": 122, "alphanum_fraction": 0.5675311048, "include": true, "reason": "import numpy,from numpy,from scipy", "num_tokens": 3816}
|
# Automatically adapted for numpy.oldnumeric Jul 23, 2007 by
# taken from Pmv/measureCommands.py
def torsion(x1, x2, x3, x4):
"""
Compute the torsion angle between x1, x2, x3, x4.
All coordinates are cartesian; result is in degrees.
Raises a ValueError if angle is not defined.
"""
from math import sqrt, acos
import numpy.oldnumeric as Numeric
N = Numeric
tang = 0.0
x1 = N.array(x1, "f")
x2 = N.array(x2, "f")
x3 = N.array(x3, "f")
x4 = N.array(x4, "f")
assert x1.shape == (3,)
assert x2.shape == (3,)
assert x3.shape == (3,)
assert x4.shape == (3,)
a = x1 - x2
b = x3 - x2
c = vvmult(a, b)
a = x2 - x3
b = x4 - x3
d = vvmult(a, b)
dd = sqrt(Numeric.sum(c * c))
de = sqrt(Numeric.sum(d * d))
if dd < 0.001 or de < 0.001:
raise ValueError("Torsion angle undefined, degenerate points")
vv = Numeric.dot(c, d) / (dd * de)
if vv < 1.0:
tang = vv
else:
tang = 1.0
if tang < -1.0:
tang = -1.0
tang = acos(tang)
tang = tang * 57.296
b = vvmult(c, d)
if Numeric.dot(a, b) > 0.0:
tang = -tang
return tang
def vvmult(a, b):
"""
Compute a vector product for 3D vectors
"""
import numpy.oldnumeric as Numeric
res = Numeric.zeros(3, "f")
res[0] = a[1] * b[2] - a[2] * b[1]
res[1] = a[2] * b[0] - a[0] * b[2]
res[2] = a[0] * b[1] - a[1] * b[0]
return res
|
{"hexsha": "a4a12df7bddd6e774632ca4a99d6ee9a98ece2cb", "size": 1474, "ext": "py", "lang": "Python", "max_stars_repo_path": "mgl_tools/mglutil/math/torsion.py", "max_stars_repo_name": "mesoscope/cellpack", "max_stars_repo_head_hexsha": "ec6b736fc706c1fae16392befa814b5337a3a692", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mgl_tools/mglutil/math/torsion.py", "max_issues_repo_name": "mesoscope/cellpack", "max_issues_repo_head_hexsha": "ec6b736fc706c1fae16392befa814b5337a3a692", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2021-10-02T00:07:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T00:02:10.000Z", "max_forks_repo_path": "mgl_tools/mglutil/math/torsion.py", "max_forks_repo_name": "mesoscope/cellpack", "max_forks_repo_head_hexsha": "ec6b736fc706c1fae16392befa814b5337a3a692", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.3623188406, "max_line_length": 70, "alphanum_fraction": 0.5278154681, "include": true, "reason": "import numpy", "num_tokens": 537}
|
[STATEMENT]
lemma tm_ntcf_arrows_in_cf_arrows[cat_map_cs_intros]:
assumes "\<NN> \<in>\<^sub>\<circ> tm_ntcf_arrows \<alpha> \<AA> \<BB>"
shows "\<NN> \<in>\<^sub>\<circ> ntcf_arrows \<alpha> \<AA> \<BB>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<NN> \<in>\<^sub>\<circ> ntcf_arrows \<alpha> \<AA> \<BB>
[PROOF STEP]
using assms tm_ntcf_arrows_vsubset_ntcf_arrows[of \<alpha> \<AA> \<BB>]
[PROOF STATE]
proof (prove)
using this:
\<NN> \<in>\<^sub>\<circ> tm_ntcf_arrows \<alpha> \<AA> \<BB>
tm_ntcf_arrows \<alpha> \<AA> \<BB> \<subseteq>\<^sub>\<circ> ntcf_arrows \<alpha> \<AA> \<BB>
goal (1 subgoal):
1. \<NN> \<in>\<^sub>\<circ> ntcf_arrows \<alpha> \<AA> \<BB>
[PROOF STEP]
by blast
|
{"llama_tokens": 308, "file": "CZH_Elementary_Categories_czh_ecategories_CZH_DG_FUNCT", "length": 2}
|
# -*- coding: utf-8 -*-
"""
Collection of tools for writing formatted text to files.
"""
import numpy as np
from pyyeti import ytools
def getith(i, args, fncs):
"""
Return list with i'th value from each input, typically called by
:func:`vecwrite`.
Parameters
----------
i : integer
Specifies which value to extract from each input; starts at 0.
args : list of variables
Variable to extract the i'th value from. Must be compatibly
sized (scalars or vectors of equal length). Strings are
considered scalars.
fncs : list of functions
Same length as args; the function is used to extract the
i'th item. Call signature: ith_element_of_a = func(a, i).
The function must return an iterable of items (eg, list).
Returns
-------
lst : list
List of the i'th items extracted from each variable in `args`.
Examples
--------
>>> from pyyeti import writer
>>> import numpy as np
>>> r = np.array([1.2, 45.])
>>> s = 'test string'
>>> i = 5
>>> v = ['One', 'Two']
>>> def f(a, i): return [a]
>>> def f2(a, i): return [a[i]]
>>> args = [r, s, i, v]
>>> fncs = [f2, f, f, f2]
>>> writer.getith(0, args, fncs)
[1.2, 'test string', 5, 'One']
>>> writer.getith(1, args, fncs)
[45.0, 'test string', 5, 'Two']
"""
lst = []
for arg, fnc in zip(args, fncs):
lst.extend(fnc(arg, i))
return lst
@ytools.write_text_file
def _vecwrite(fout, string, length, args, fncs, postfunc, pfargs, so):
"""Utility routine for :func:`vecwrite`."""
v = range(length)
if so is not None:
v = v[so]
if postfunc:
if pfargs is None:
pfargs = []
for i in v:
curargs = getith(i, args, fncs)
s = postfunc(string.format(*curargs), *pfargs)
fout.write(s)
else:
for i in v:
curargs = getith(i, args, fncs)
fout.write(string.format(*curargs))
def vecwrite(f, string, *args, postfunc=None, pfargs=None, so=None):
"""
Vectorized write.
Parameters
----------
f : string or file_like or 1 or None
Either a name of a file, or is a file_like object as returned
by :func:`open` or :class:`io.StringIO`. Input as integer 1 to
write to stdout. Can also be the name of a directory or None;
in these cases, a GUI is opened for file selection.
string : string
The formatting string for the write, Python 3 format as in:
`string`.format(a,b)
*args : list of variables
Variables to write. Must be compatibly sized (scalars or
vectors or numpy arrays of compatible sizes). numpy arrays of
length 1 are considered scalars. For 2-d numpy arrays, each
row is written on one line and each element of the row must
have a conversion specifier. 1-d numpy arrays are treated
like a column 2-d numpy array. Strings are considered
scalars.
postfunc : function or None
If a function, it is called with the final string (for each
line) as the argument and it must return a string. The return
string is what gets output. This can be handy for final string
substitutions, for example. This input must be named and must
be after the arguments to be printed; see example.
pfargs : iterable or None
If an iterable, contains extra arguments to pass to `postfunc`
after the string argument. Must be named and after the
arguments to be printed.
so : slice object or None
Allows selection of limited range and custom increment; eg:
``slice(0, 10, 2)``. Scalars are not sliced. Must be named and
after the arguments to be printed.
Returns
-------
None.
Notes
-----
The expected vector length is determined from the first non-scalar
input. Note that scalar values are repeated automatically as
necessary.
Raises
------
ValueError
When the lengths of print arguments do not match (for
lengths > 1). Note that the slice object `so` can make
otherwise incompatible arguments compatible; for example,
arguments of length 10 and length 100 would be compatible if
``so = slice(10)`` (or similar).
Examples
--------
>>> from pyyeti import writer
>>> import sys
>>> import numpy as np
>>> r = np.array([1.2, 45.8])
>>> s = 'test string'
>>> i = 5
>>> v = ['short string', 'a bit longer string']
>>> frm = '{:3}, {:5.1f}, {:<25}, {}' + chr(10)
>>> writer.vecwrite(sys.stdout, frm, i, r, v, s)
5, 1.2, short string , test string
5, 45.8, a bit longer string , test string
>>> r = np.array([[1.1, 1.2, 1.3], [10.1, 10.2, 10.3]])
>>> frm = '{:2}, {:=^25} : ' + ' {:6.2f}'*3 + chr(10)
>>> writer.vecwrite(sys.stdout, frm, i, v, r)
5, ======short string======= : 1.10 1.20 1.30
5, ===a bit longer string=== : 10.10 10.20 10.30
>>> def pf(s):
... return s.replace('0 ', ' ')
>>> writer.vecwrite(sys.stdout, frm, i, v, r, postfunc=pf)
5, ======short string======= : 1.1 1.2 1.30
5, ===a bit longer string=== : 10.1 10.2 10.30
>>> def pf(s, s_old, s_new):
... return s.replace(s_old, s_new)
>>> writer.vecwrite(1, frm, i, v, r, postfunc=pf,
... pfargs=['0 ', ' '])
5, ======short string======= : 1.1 1.2 1.30
5, ===a bit longer string=== : 10.1 10.2 10.30
"""
def _get_scalar(a, i):
return [a]
def _get_scalar1(a, i):
return [a[0]]
def _get_itemi(a, i):
return [a[i]]
def _get_matrow(a, i):
return a[i]
length = 1
fncs = []
for i, arg in enumerate(args):
if not isinstance(arg, str) and hasattr(arg, "__len__"):
if np.ndim(arg) == 2:
fncs.append(_get_matrow)
curlen = np.size(arg, 0)
elif len(arg) == 1:
fncs.append(_get_scalar1)
curlen = 1
else:
fncs.append(_get_itemi)
curlen = len(arg)
if curlen > 1:
if length > 1:
if so is not None:
if range(curlen)[so] != range(length)[so]:
msg = (
"length mismatch with slice object:"
f" arg # {i + 1} is incompatible with "
"previous args"
)
raise ValueError(msg)
elif curlen != length:
msg = (
f"length mismatch: arg # {i + 1} has "
f"length {curlen}; expected {length} or 1."
)
raise ValueError(msg)
length = curlen
else:
fncs.append(_get_scalar)
_vecwrite(f, string, length, args, fncs, postfunc, pfargs, so)
def formheader(headers, widths, formats, sep=(0, 2), just=-1, ulchar="-"):
"""
Form a nice table header for formatted output via f.write().
Parameters
----------
headers : list or tuple
List or tuple of column header strings, eg:
['Desc', 'Maximum', 'Time']. Can also be a list of lists (or
tuples) to support multiple header lines, eg:
[['Maximum', 'Minimum', 'Time'], ['(lbs)', '(lbs)', '(sec)']]
widths : iterable
Iterable of field widths, eg: (25, 10, 8) or [25, 10, 8]. If
an element in `widths` is < length of corresponding word in a
header-line, the length of the word is used for that field.
Note that if this doesn't match with `formats`, the columns
will not line up nicely.
formats : list or tuple
List or tuple of format specifiers for the values in the table,
eg: ['{:25s}', '{:10f}', '{:8.3f}']
sep : string, list, tuple, or integer
Defines 'spacer' in front of each word:
- if a string, that string is used in front of all headers
- use a list or tuple of strings for complete control
- if an integer, that many spaces are used in front of all
headers
- use a vector of integers to specify a variable number of
spaces
- if len(sep) < len(headers), the last element is used for
all remaining elements
just : string or integer or list
Justification flag or flags for each header string:
- 'l', 'c', 'r' (or -1, 0, 1) to left, center, or right
justify headers in their fields
- can be a list or tuple of len(headers) for complete
control
ulchar : string
Character to use for underlining of headers.
Returns
-------
hu : string
Contains formatted header string(s) and the underline string.
f : string
Final formatting string.
Examples
--------
>>> import numpy as np
>>> import sys
>>> from pyyeti import writer
>>> descs = ['Item 1', 'A different item']
>>> mx = np.array([[1.2, 2.3], [3.4, 4.5]]) * 1000
>>> time = np.array([[1.234], [2.345]])
>>> headers = [['The']*3, ['Descriptions', 'Maximum', 'Time']]
>>> formats = ['{:<25s}', '{:10.2f}', '{:8.3f}']
>>> widths = [25, 10, 8]
>>> hu, f = writer.formheader(headers, widths, formats,
... sep=[4, 5, 2], just=0)
>>> fout = sys.stdout
>>> if 1: # just so all output is together
... b = fout.write(hu)
... writer.vecwrite(fout, f, descs, mx, time)
The The The
Descriptions Maximum Time
------------------------- ---------- --------
Item 1 1200.00 2300.000
A different item 3400.00 4500.000
"""
if not isinstance(headers, (list, tuple)):
raise ValueError("input 'headers' must be a list or tuple")
if isinstance(headers[0], (list, tuple)):
length = len(headers[0])
nheaders = len(headers)
mxlengths = np.array([len(s) for s in headers[0]])
for j in range(1, nheaders):
if len(headers[j]) != length:
raise ValueError(
f"headers[{len(headers[j])}] != length of previous headers"
)
for k in range(length):
mxlengths[k] = max(mxlengths[k], len(headers[j][k]))
else:
nheaders = 0
mxlengths = np.array([len(s) for s in headers])
length = len(headers)
if not length == len(formats) == len(widths):
s = ""
if isinstance(headers[0], (list, tuple)):
s = "[*]"
raise ValueError(
f"this check failed: ``len(headers{s}) == len(formats) == len(widths)``"
)
def strexp(string, width, just):
if just == -1 or just == "l":
return string.ljust(width)
if just == 0 or just == "c":
return string.center(width)
return string.rjust(width)
if isinstance(just, (str, int)):
just = [just]
if isinstance(sep, int):
sep = " " * sep
if isinstance(sep, str):
sep = [sep]
if nheaders > 0:
h = [""] * nheaders
else:
h = ""
u, f = "", ""
for j in range(length):
if j >= len(just):
cj = just[-1]
else:
cj = just[j]
if j >= len(sep):
csep = sep[-1]
else:
csep = sep[j]
if isinstance(csep, int):
csep = " " * csep
w = max(widths[j], mxlengths[j])
if nheaders > 0:
for k in range(nheaders):
h[k] += csep + strexp(headers[k][j], w, just=cj)
else:
h += csep + strexp(headers[j], w, just=cj)
u += csep + ulchar * w
f += csep + formats[j]
if nheaders > 0:
h = [hj.rstrip() + "\n" for hj in h]
else:
h = h.rstrip() + "\n"
u = u.rstrip() + "\n"
f = f.rstrip() + "\n"
return "".join(h) + u, f
|
{"hexsha": "0c2ac1e16c3a2e2c73f049eb0c91be9038465e23", "size": 12367, "ext": "py", "lang": "Python", "max_stars_repo_path": "pyyeti/writer.py", "max_stars_repo_name": "twmacro/pyye", "max_stars_repo_head_hexsha": "c4febd44be836bd87368da13c1fb0cf82838b687", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pyyeti/writer.py", "max_issues_repo_name": "twmacro/pyye", "max_issues_repo_head_hexsha": "c4febd44be836bd87368da13c1fb0cf82838b687", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pyyeti/writer.py", "max_forks_repo_name": "twmacro/pyye", "max_forks_repo_head_hexsha": "c4febd44be836bd87368da13c1fb0cf82838b687", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6414565826, "max_line_length": 84, "alphanum_fraction": 0.5193660548, "include": true, "reason": "import numpy", "num_tokens": 3317}
|
#! /usr/bin/env python
from operator import is_
from random import randint
import gym
from gym import spaces
from gym.spaces import space
from typing import Union
from stable_baselines3.common.env_checker import check_env
import yaml
from rl_agent.utils.observation_collector import ObservationCollector
from rl_agent.utils.reward import RewardCalculator
from rl_agent.utils.debug import timeit
from task_generator.tasks import ABSTask
import numpy as np
import rospy
from geometry_msgs.msg import Twist
from flatland_msgs.srv import StepWorld, StepWorldRequest
import time
class FlatlandEnv(gym.Env):
"""Custom Environment that follows gym interface"""
def __init__(self, task: ABSTask, robot_yaml_path: str, settings_yaml_path: str, reward_fnc: str, is_action_space_discrete, safe_dist: float = None, goal_radius: float = 0.1, max_steps_per_episode=100):
"""Default env
Flatland yaml node check the entries in the yaml file, therefore other robot related parameters cound only be saved in an other file.
TODO : write an uniform yaml paser node to handel with multiple yaml files.
Args:
task (ABSTask): [description]
robot_yaml_path (str): [description]
setting_yaml_path ([type]): [description]
reward_fnc (str): [description]
is_action_space_discrete (bool): [description]
safe_dist (float, optional): [description]. Defaults to None.
goal_radius (float, optional): [description]. Defaults to 0.1.
"""
super(FlatlandEnv, self).__init__()
# Define action and observation space
# They must be gym.spaces objects
self._is_action_space_discrete = is_action_space_discrete
self.setup_by_configuration(robot_yaml_path, settings_yaml_path)
# observation collector
self.observation_collector = ObservationCollector(
self._laser_num_beams, self._laser_max_range)
self.observation_space = self.observation_collector.get_observation_space()
# reward calculator
if safe_dist is None:
safe_dist = 1.5*self._robot_radius
self.reward_calculator = RewardCalculator(
robot_radius=self._robot_radius, safe_dist=1.1*self._robot_radius, goal_radius=goal_radius, rule=reward_fnc)
# action agent publisher
self.agent_action_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)
# service clients
self._is_train_mode = rospy.get_param("train_mode")
if self._is_train_mode:
self._service_name_step = '/step_world'
self._sim_step_client = rospy.ServiceProxy(
self._service_name_step, StepWorld)
self.task = task
self._steps_curr_episode = 0
self._max_steps_per_episode = max_steps_per_episode
# # get observation
# obs=self.observation_collector.get_observations()
def setup_by_configuration(self, robot_yaml_path: str, settings_yaml_path: str):
"""get the configuration from the yaml file, including robot radius, discrete action space and continuous action space.
Args:
robot_yaml_path (str): [description]
"""
with open(robot_yaml_path, 'r') as fd:
robot_data = yaml.safe_load(fd)
# get robot radius
for body in robot_data['bodies']:
if body['name'] == "base_footprint":
for footprint in body['footprints']:
if footprint['type'] == 'circle':
self._robot_radius = footprint.setdefault(
'radius', 0.3)*1.04
if footprint['radius']:
self._robot_radius = footprint['radius']*1.04
# get laser related information
for plugin in robot_data['plugins']:
if plugin['type'] == 'Laser':
laser_angle_min = plugin['angle']['min']
laser_angle_max = plugin['angle']['max']
laser_angle_increment = plugin['angle']['increment']
self._laser_num_beams = int(
round((laser_angle_max-laser_angle_min)/laser_angle_increment)+1)
self._laser_max_range = plugin['range']
with open(settings_yaml_path, 'r') as fd:
setting_data = yaml.safe_load(fd)
if self._is_action_space_discrete:
# self._discrete_actions is a list, each element is a dict with the keys ["name", 'linear','angular']
self._discrete_acitons = setting_data['robot']['discrete_actions']
self.action_space = spaces.Discrete(
len(self._discrete_acitons))
else:
linear_range = setting_data['robot']['continuous_actions']['linear_range']
angular_range = setting_data['robot']['continuous_actions']['angular_range']
self.action_space = spaces.Box(low=np.array([linear_range[0], angular_range[0]]),
high=np.array(
[linear_range[1], angular_range[1]]),
dtype=np.float)
def _pub_action(self, action):
action_msg = Twist()
if self._is_action_space_discrete:
action_msg.linear.x = self._discrete_acitons[action]['linear']
action_msg.angular.z = self._discrete_acitons[action]['angular']
else:
action_msg.linear.x = action[0]
action_msg.angular.z = action[1]
self.agent_action_pub.publish(action_msg)
def step(self, action):
"""
done_reasons: 0 - exceeded max steps
1 - collision with obstacle
2 - goal reached
"""
self._pub_action(action)
self._steps_curr_episode += 1
# wait for new observations
s = time.time()
merged_obs, obs_dict = self.observation_collector.get_observations()
# print("get observation: {}".format(time.time()-s))
# calculate reward
reward, reward_info = self.reward_calculator.get_reward(
obs_dict['laser_scan'], obs_dict['goal_in_robot_frame'])
done = reward_info['is_done']
print("reward: {}".format(reward))
# info
info = {}
if done:
info['done_reason'] = reward_info['done_reason']
else:
if self._steps_curr_episode == self._max_steps_per_episode:
done = True
info['done_reason'] = 0
return merged_obs, reward, done, info
def reset(self):
# set task
# regenerate start position end goal position of the robot and change the obstacles accordingly
self.agent_action_pub.publish(Twist())
if self._is_train_mode:
self._sim_step_client()
self.task.reset()
self.reward_calculator.reset()
self._steps_curr_episode = 0
obs, _ = self.observation_collector.get_observations()
return obs # reward, done, info can't be included
def close(self):
pass
if __name__ == '__main__':
rospy.init_node('flatland_gym_env', anonymous=True)
print("start")
flatland_env = FlatlandEnv()
check_env(flatland_env, warn=True)
# init env
obs = flatland_env.reset()
# run model
n_steps = 200
for step in range(n_steps):
# action, _states = model.predict(obs)
action = flatland_env.action_space.sample()
obs, rewards, done, info = flatland_env.step(action)
time.sleep(0.1)
|
{"hexsha": "2f39a885692e51d3a1deb63bedba8645800c4703", "size": 7741, "ext": "py", "lang": "Python", "max_stars_repo_path": "navigation/arena_local_planner/learning_based/arena_local_planner_drl/rl_agent/envs/flatland_gym_env.py", "max_stars_repo_name": "kilinmao/sarl_star", "max_stars_repo_head_hexsha": "dde9bb2b690c705a615195f4b570af3ea9dfe05e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "navigation/arena_local_planner/learning_based/arena_local_planner_drl/rl_agent/envs/flatland_gym_env.py", "max_issues_repo_name": "kilinmao/sarl_star", "max_issues_repo_head_hexsha": "dde9bb2b690c705a615195f4b570af3ea9dfe05e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "navigation/arena_local_planner/learning_based/arena_local_planner_drl/rl_agent/envs/flatland_gym_env.py", "max_forks_repo_name": "kilinmao/sarl_star", "max_forks_repo_head_hexsha": "dde9bb2b690c705a615195f4b570af3ea9dfe05e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3177083333, "max_line_length": 206, "alphanum_fraction": 0.6204624725, "include": true, "reason": "import numpy", "num_tokens": 1643}
|
"""
see: get_sorted_connected_regions
input a 3D mask numpy array, output a dict, with key 1, 2, 3, ... (int), which conforms to the ranking of the volume of
the connected component. The value of the dict is lists of locations like {1: [(x1, y1, z1), (x2, y2, z2), ...], ...}
"""
import numpy as np
import Tool_Functions.Functions as Functions
import Analysis.connected_region2d_and_scale_free_stat as rim_detect
np.set_printoptions(precision=10, suppress=True)
epsilon = 0.001
class DimensionError(Exception):
def __init__(self, array):
self.shape = np.shape(array)
self.dimension = len(self.shape)
def __str__(self):
print("invalid dimension of", self.dimension, ", array has shape", self.shape)
def get_connected_regions(input_array, threshold=None, strict=False, start_id=None):
"""
:param input_array: the mask array, with shape [x, y, z]
:param threshold: the threshold of cast the mask array to binary
:param strict: whether diagonal pixel is considered as adjacent.
:param start_id: the connect region id
:return: a dict, with key 1, 2, 3, ... (int), value is list of location: {1: [(x1, y1, z1), (x2, y2, z2), ...], ...}
a dict, with key 1, 2, 3, ... (int), value is length(list of location)
helper_array has shape [a, b, c, 2], first channel is the merge count, second for region id
optional: start_id for next stage
"""
if threshold is not None:
input_array = np.array(input_array > threshold, 'float32')
shape = np.shape(input_array)
helper_array = np.zeros([shape[0], shape[1], shape[2], 2])
# the last dim has two channels, the first is the key, the second is the volume
helper_array[:, :, :, 0] = -input_array
tracheae_points = np.where(helper_array[:, :, :, 0] < -epsilon)
num_checking_points = len(tracheae_points[0])
# print("we will check:", num_checking_points)
id_volume_dict = {}
id_loc_dict = {}
if start_id is None:
connected_id = 1
else:
connected_id = start_id
for index in range(num_checking_points):
pixel_location = (tracheae_points[0][index], tracheae_points[1][index], tracheae_points[2][index])
if helper_array[pixel_location[0], pixel_location[1], pixel_location[2], 0] > epsilon:
# this means this point has been allocated id and volume
continue
else:
# this means this point has been allocated id and volume
if strict:
volume, locations = broadcast_connected_component(helper_array, pixel_location, connected_id)
else:
volume, locations = broadcast_connected_component_2(helper_array, pixel_location, connected_id)
# now, the volume and id has been broadcast to this connected component.
id_volume_dict[connected_id] = volume
id_loc_dict[connected_id] = locations
connected_id += 1 # the id is 1, 2, 3, ...
if start_id is None:
return id_volume_dict, id_loc_dict, helper_array
else:
return id_volume_dict, id_loc_dict, helper_array, connected_id
def get_connected_regions_light(input_flow, strict=False):
"""
:param input_flow: the binary mask array, with shape [x, y, z], pid_id
:param strict: whether diagonal pixel is considered as adjacent.
:return: a dict, with key 1, 2, 3, ... (int), value is list of location: {1: [(x1, y1, z1), (x2, y2, z2), ...], ...}
"""
input_array = input_flow[0]
print("processing interval", input_flow[1])
shape = np.shape(input_array)
helper_array = np.zeros([shape[0], shape[1], shape[2], 2])
# the last dim has two channels, the first is the key, the second is the volume
helper_array[:, :, :, 0] = -input_array
tracheae_points = np.where(helper_array[:, :, :, 0] < -epsilon)
num_checking_points = len(tracheae_points[0])
# print("we will check:", num_checking_points)
id_loc_dict = {}
connected_id = 1
for index in range(num_checking_points):
pixel_location = (tracheae_points[0][index], tracheae_points[1][index], tracheae_points[2][index])
if helper_array[pixel_location[0], pixel_location[1], pixel_location[2], 0] > epsilon:
# this means this point has been allocated id and volume
continue
else:
# this means this point has been allocated id and volume
if strict:
volume, locations = broadcast_connected_component(helper_array, pixel_location, connected_id)
else:
volume, locations = broadcast_connected_component_2(helper_array, pixel_location, connected_id)
# now, the volume and id has been broadcast to this connected component.
id_loc_dict[connected_id] = locations
connected_id += 1 # the id is 1, 2, 3, ...
return id_loc_dict
def broadcast_connected_component(helper_array, initial_location, region_id):
# helper_array has shape [a, b, c, 2]
# initial_location is a tuple, (x, y, z)
# return the volume of this connected_component (int) and the location list like [(389, 401), (389, 402), ..].
volume = 0 # the volume of this connected component
un_labeled_region = [initial_location, ]
helper_array[initial_location[0], initial_location[1], initial_location[2], 1] = region_id
region_locations = []
while un_labeled_region: # this mean un_labeled_region is not empty
location = un_labeled_region.pop()
region_locations.append(location) # get the locations of the connected component
volume += 1
if helper_array[location[0] + 1, location[1], location[2], 0] < -epsilon:
# whether the adjacent pixel is in the same connected_component
if not helper_array[location[0] + 1, location[1], location[2], 1] == region_id:
# this adjacent location is not visited
un_labeled_region.append((location[0] + 1, location[1], location[2]))
helper_array[location[0] + 1, location[1], location[2], 1] = region_id # label this unlabeled pixel
if helper_array[location[0] - 1, location[1], location[2], 0] < -epsilon:
if not helper_array[location[0] - 1, location[1], location[2], 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1], location[2]))
helper_array[location[0] - 1, location[1], location[2], 1] = region_id
if helper_array[location[0], location[1] + 1, location[2], 0] < -epsilon:
if not helper_array[location[0], location[1] + 1, location[2], 1] == region_id:
un_labeled_region.append((location[0], location[1] + 1, location[2]))
helper_array[location[0], location[1] + 1, location[2], 1] = region_id
if helper_array[location[0], location[1] - 1, location[2], 0] < -epsilon:
if not helper_array[location[0], location[1] - 1, location[2], 1] == region_id:
un_labeled_region.append((location[0], location[1] - 1, location[2]))
helper_array[location[0], location[1] - 1, location[2], 1] = region_id
if helper_array[location[0], location[1], location[2] + 1, 0] < -epsilon:
if not helper_array[location[0], location[1], location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0], location[1], location[2] + 1))
helper_array[location[0], location[1], location[2] + 1, 1] = region_id
if helper_array[location[0], location[1], location[2] - 1, 0] < -epsilon:
if not helper_array[location[0], location[1], location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0], location[1], location[2] - 1))
helper_array[location[0], location[1], location[2] - 1, 1] = region_id
for location in region_locations:
helper_array[location[0], location[1], location[2], 0] = volume
# print('this component has id', region_id, 'volume', volume)
return volume, region_locations
def broadcast_connected_component_2(helper_array, initial_location, region_id):
# the difference is that here diagonal pixels are considered as adjacency.
# helper_array has shape [a, b, c, 2]
# initial_location is a tuple, (x, y, z)
# return the volume of this connected_component (int) and the location list like [(389, 401), (389, 402), ..].
volume = 0 # the volume of this connected component
un_labeled_region = [initial_location, ]
helper_array[initial_location[0], initial_location[1], initial_location[2], 1] = region_id
region_locations = []
while un_labeled_region: # this mean un_labeled_region is not empty
location = un_labeled_region.pop()
region_locations.append(location) # get the locations of the connected component
volume += 1
if not np.min(helper_array[location[0]-1:location[0]+2, location[1]-1:location[1]+2,
location[2]-1:location[2]+2]) < -epsilon:
continue
if helper_array[location[0] + 1, location[1], location[2], 0] < -epsilon: # (1, 0, 0)
# whether the adjacent pixel is in the same connected_component
if not helper_array[location[0] + 1, location[1], location[2], 1] == region_id:
# this adjacent location is not visited
un_labeled_region.append((location[0] + 1, location[1], location[2]))
helper_array[location[0] + 1, location[1], location[2], 1] = region_id # label this unlabeled pixel
if helper_array[location[0] - 1, location[1], location[2], 0] < -epsilon:
if not helper_array[location[0] - 1, location[1], location[2], 1] == region_id: # (-1, 0, 0)
un_labeled_region.append((location[0] - 1, location[1], location[2]))
helper_array[location[0] - 1, location[1], location[2], 1] = region_id
if helper_array[location[0], location[1] + 1, location[2], 0] < -epsilon: # (0, 1, 0)
if not helper_array[location[0], location[1] + 1, location[2], 1] == region_id:
un_labeled_region.append((location[0], location[1] + 1, location[2]))
helper_array[location[0], location[1] + 1, location[2], 1] = region_id
if helper_array[location[0], location[1] - 1, location[2], 0] < -epsilon: # (0, -1, 0)
if not helper_array[location[0], location[1] - 1, location[2], 1] == region_id:
un_labeled_region.append((location[0], location[1] - 1, location[2]))
helper_array[location[0], location[1] - 1, location[2], 1] = region_id
if helper_array[location[0], location[1], location[2] + 1, 0] < -epsilon: # (0, 0, 1)
if not helper_array[location[0], location[1], location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0], location[1], location[2] + 1))
helper_array[location[0], location[1], location[2] + 1, 1] = region_id
if helper_array[location[0], location[1], location[2] - 1, 0] < -epsilon: # (0, 0, -1)
if not helper_array[location[0], location[1], location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0], location[1], location[2] - 1))
helper_array[location[0], location[1], location[2] - 1, 1] = region_id
if helper_array[location[0] - 1, location[1] - 1, location[2], 0] < -epsilon: # (-1, -1, 0)
if not helper_array[location[0] - 1, location[1] - 1, location[2], 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] - 1, location[2]))
helper_array[location[0] - 1, location[1] - 1, location[2], 1] = region_id
if helper_array[location[0] - 1, location[1] + 1, location[2], 0] < -epsilon: # (-1, 1, 0)
if not helper_array[location[0] - 1, location[1] + 1, location[2], 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] + 1, location[2]))
helper_array[location[0] - 1, location[1] + 1, location[2], 1] = region_id
if helper_array[location[0] + 1, location[1] + 1, location[2], 0] < -epsilon: # (1, 1, 0)
if not helper_array[location[0] + 1, location[1] + 1, location[2], 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] + 1, location[2]))
helper_array[location[0] + 1, location[1] + 1, location[2], 1] = region_id
if helper_array[location[0] + 1, location[1] - 1, location[2], 0] < -epsilon: # (1, -1, 0)
if not helper_array[location[0] + 1, location[1] - 1, location[2], 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] - 1, location[2]))
helper_array[location[0] + 1, location[1] - 1, location[2], 1] = region_id
if helper_array[location[0] - 1, location[1] - 1, location[2] + 1, 0] < -epsilon: # (-1, -1, 1)
if not helper_array[location[0] - 1, location[1] - 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] - 1, location[2] + 1))
helper_array[location[0] - 1, location[1] - 1, location[2] + 1, 1] = region_id
if helper_array[location[0] - 1, location[1] + 1, location[2] + 1, 0] < -epsilon: # (-1, 1, 1)
if not helper_array[location[0] - 1, location[1] + 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] + 1, location[2] + 1))
helper_array[location[0] - 1, location[1] + 1, location[2] + 1, 1] = region_id
if helper_array[location[0] + 1, location[1] + 1, location[2] + 1, 0] < -epsilon: # (1, 1, 1)
if not helper_array[location[0] + 1, location[1] + 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] + 1, location[2] + 1))
helper_array[location[0] + 1, location[1] + 1, location[2] + 1, 1] = region_id
if helper_array[location[0] + 1, location[1] - 1, location[2] + 1, 0] < -epsilon: # (1, -1, 1)
if not helper_array[location[0] + 1, location[1] - 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] - 1, location[2] + 1))
helper_array[location[0] + 1, location[1] - 1, location[2] + 1, 1] = region_id
if helper_array[location[0], location[1] - 1, location[2] + 1, 0] < -epsilon: # (0, -1, 1)
if not helper_array[location[0], location[1] - 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0], location[1] - 1, location[2] + 1))
helper_array[location[0], location[1] - 1, location[2] + 1, 1] = region_id
if helper_array[location[0], location[1] + 1, location[2] + 1, 0] < -epsilon: # (0, 1, 1)
if not helper_array[location[0], location[1] + 1, location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0], location[1] + 1, location[2] + 1))
helper_array[location[0], location[1] + 1, location[2] + 1, 1] = region_id
if helper_array[location[0] + 1, location[1], location[2] + 1, 0] < -epsilon: # (1, 0, 1)
if not helper_array[location[0] + 1, location[1], location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1], location[2] + 1))
helper_array[location[0] + 1, location[1], location[2] + 1, 1] = region_id
if helper_array[location[0] - 1, location[1], location[2] + 1, 0] < -epsilon: # (-1, 0, 1)
if not helper_array[location[0] - 1, location[1], location[2] + 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1], location[2] + 1))
helper_array[location[0] - 1, location[1], location[2] + 1, 1] = region_id
if helper_array[location[0] - 1, location[1] - 1, location[2] - 1, 0] < -epsilon: # (-1, -1, -1)
if not helper_array[location[0] - 1, location[1] - 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] - 1, location[2] - 1))
helper_array[location[0] - 1, location[1] - 1, location[2] - 1, 1] = region_id
if helper_array[location[0] - 1, location[1] + 1, location[2] - 1, 0] < -epsilon: # (-1, 1, -1)
if not helper_array[location[0] - 1, location[1] + 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1] + 1, location[2] - 1))
helper_array[location[0] - 1, location[1] + 1, location[2] - 1, 1] = region_id
if helper_array[location[0] + 1, location[1] + 1, location[2] - 1, 0] < -epsilon: # (1, 1, -1)
if not helper_array[location[0] + 1, location[1] + 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] + 1, location[2] - 1))
helper_array[location[0] + 1, location[1] + 1, location[2] - 1, 1] = region_id
if helper_array[location[0] + 1, location[1] - 1, location[2] - 1, 0] < -epsilon: # (1, -1, -1)
if not helper_array[location[0] + 1, location[1] - 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1] - 1, location[2] - 1))
helper_array[location[0] + 1, location[1] - 1, location[2] - 1, 1] = region_id
if helper_array[location[0], location[1] - 1, location[2] - 1, 0] < -epsilon: # (0, -1, -1)
if not helper_array[location[0], location[1] - 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0], location[1] - 1, location[2] - 1))
helper_array[location[0], location[1] - 1, location[2] - 1, 1] = region_id
if helper_array[location[0], location[1] + 1, location[2] - 1, 0] < -epsilon: # (0, 1, -1)
if not helper_array[location[0], location[1] + 1, location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0], location[1] + 1, location[2] - 1))
helper_array[location[0], location[1] + 1, location[2] - 1, 1] = region_id
if helper_array[location[0] + 1, location[1], location[2] - 1, 0] < -epsilon: # (1, 0, -1)
if not helper_array[location[0] + 1, location[1], location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] + 1, location[1], location[2] - 1))
helper_array[location[0] + 1, location[1], location[2] - 1, 1] = region_id
if helper_array[location[0] - 1, location[1], location[2] - 1, 0] < -epsilon: # (-1, 0, -1)
if not helper_array[location[0] - 1, location[1], location[2] - 1, 1] == region_id:
un_labeled_region.append((location[0] - 1, location[1], location[2] - 1))
helper_array[location[0] - 1, location[1], location[2] - 1, 1] = region_id
for location in region_locations:
helper_array[location[0], location[1], location[2], 0] = volume
# print('this component has id', region_id, 'volume', volume)
return volume, region_locations
def sort_on_id_loc_dict(id_loc_dict, id_volume_dict=None):
# refactor the key of the connected_components
keys_list = list(id_loc_dict.keys())
number_keys = len(keys_list)
if id_volume_dict is None:
id_volume_dict = {}
for i in range(1, number_keys + 1):
id_volume_dict[i] = len(id_loc_dict[i])
old_factor_list = []
for i in range(1, number_keys + 1):
old_factor_list.append((i, id_volume_dict[i]))
def adjacency_cmp(tuple_a, tuple_b):
return tuple_a[1] - tuple_b[1]
from functools import cmp_to_key
old_factor_list.sort(key=cmp_to_key(adjacency_cmp), reverse=True)
id_loc_dict_sorted = {}
id_volume_dict_sorted = {}
for i in range(0, number_keys):
id_loc_dict_sorted[i + 1] = id_loc_dict[old_factor_list[i][0]]
id_volume_dict_sorted[i + 1] = id_volume_dict[old_factor_list[i][0]]
return id_loc_dict_sorted, id_volume_dict_sorted
def stat_on_connected_component(id_loc_dict, total_volume=None, show=True): # total_volume is like the volume of lung
keys_list = list(id_loc_dict.keys())
if show:
print("we have:", len(keys_list), "number of connected components")
id_loc_dict_sorted, id_volume_dict_sorted = sort_on_id_loc_dict(id_loc_dict)
if total_volume is None:
if show:
print("the volume of these components are:\n", id_volume_dict_sorted)
else:
if show:
print("total_volume is:", total_volume)
for key in keys_list:
if show:
print("component", key, "constitute:", id_volume_dict_sorted[key]/total_volume, "of total volume")
return id_loc_dict_sorted
def get_sorted_connected_regions(input_array, threshold=0.5, strict=False, show=True):
"""
:param input_array: the mask array, with shape [x, y, z]
:param threshold: the threshold of cast the mask array to binary
:param strict: whether diagonal pixel is considered as adjacent.
:return id_loc_dict_sorted
"""
# key start from 1: id_loc_dict_sorted[1] is the largest; threshold > 0.5 will be considered as positive, otherwise,
# will be considered negative
if len(np.shape(input_array)) == 3:
id_volume_dict, id_loc_dict, helper_array = get_connected_regions(input_array, threshold=threshold,
strict=strict)
return stat_on_connected_component(id_loc_dict, show=show)
elif len(np.shape(input_array)) == 2:
shape = np.shape(input_array)
temp_array = np.zeros((shape[0], shape[1], 3), 'float32')
temp_array[:, :, 1] = input_array
id_volume_dict, id_loc_dict, helper_array = get_connected_regions(temp_array, threshold=threshold,
strict=strict)
id_loc_dict_sorted = stat_on_connected_component(id_loc_dict, show=show)
keys_list = list(id_loc_dict_sorted.keys())
return_dict = {}
for key in keys_list:
return_dict[key] = list()
for key in keys_list:
for loc in id_loc_dict_sorted[key]:
return_dict[key].append((loc[0], loc[1]))
return return_dict
else:
raise DimensionError(input_array)
def connectedness_2d(loc_list, strict=False):
"""
whether the loc_list forms a region that has the connectedness same to a circle?
:param loc_list: a list of locations, like [(x1, y1), (x2, y2), ...]
:param strict: if True, then diagonal pixel is considered as adjacent.
:return:
True if loc_list forms a region that has the connectedness same to a circle.
False if otherwise, like their are more than one connected
"""
x_min = 99999999999
x_max = 0
y_min = 99999999999
y_max = 0
for loc in loc_list:
if loc[0] > x_max:
x_max = loc[0]
if loc[0] < x_min:
x_min = loc[0]
if loc[1] > y_max:
y_max = loc[1]
if loc[1] < y_min:
y_min = loc[1]
x_range = x_max - x_min
y_range = y_max - y_min
bounding_array = np.zeros((x_range + 6, y_range + 6), 'float32')
for loc in loc_list:
bounding_array[loc[0] - x_min + 3, loc[1] - y_min + 3] = 1
# Functions.image_show(bounding_array)
# we require there are only on connected component.
assert len(list(get_sorted_connected_regions(bounding_array, strict=strict, show=False).keys())) == 1
if not strict:
rim_array = rim_detect.get_rim(bounding_array, outer=True)
num_boundaries = len(list(get_sorted_connected_regions(rim_array, strict=strict, show=False).keys()))
if num_boundaries == 1:
return True
else:
print(num_boundaries)
return False
else:
print("do not support strict adjacency")
return None
if __name__ == '__main__':
exit()
|
{"hexsha": "523fe12cd2f7be941300025c3595ab62035390bc", "size": 24271, "ext": "py", "lang": "Python", "max_stars_repo_path": "Analysis/connect_region_detect.py", "max_stars_repo_name": "LongxiZhou/DLPE-method", "max_stars_repo_head_hexsha": "ed20abc91e27423c7ff677a009cfd99314730217", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Analysis/connect_region_detect.py", "max_issues_repo_name": "LongxiZhou/DLPE-method", "max_issues_repo_head_hexsha": "ed20abc91e27423c7ff677a009cfd99314730217", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Analysis/connect_region_detect.py", "max_forks_repo_name": "LongxiZhou/DLPE-method", "max_forks_repo_head_hexsha": "ed20abc91e27423c7ff677a009cfd99314730217", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-22T14:29:58.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-22T14:29:58.000Z", "avg_line_length": 58.7675544794, "max_line_length": 120, "alphanum_fraction": 0.6136129537, "include": true, "reason": "import numpy", "num_tokens": 7207}
|
import sys
count = 0;
total = 0
data = sys.stdin.read().splitlines()
for i in range(len(data)) :
val = int(data[i],16)
if (val >= 555555 and val <= 777777) :
total += 1
count += 1
print(float(total/count))
#print(val)
#print(type(val))
#print(count)
#print(total)
#print(val)
#print(data[0])
"""
import sys
import numpy as np
data = np.fromfile(f, dtype=np.uint32)
ext = ('.bin')
file_num = 0
for i in range(len(data)) :
loc = ('/u/tkral/532/unsorted/' + 'unsorted_' + str(file_num) + ext)
fromfile = open(loc)
print(data[i])
file_num += 1
"""
"""
import sys
def value(data) :
print(data)
data = sys.stdin.read()
array = []
"""
"""
count = 0
hit = 0
file_num = 0
path_of_directory = '/u/tkral/532/unsorted/'
ext = ('.bin')
#print(loc)
for files in os.listdir(path_of_directory) :
loc = (path_of_directory + "unsorted_" + str(file_num) + ext);
if files.endswith(ext) :
fd = open(loc)
print(fd)
file_num += 1
"""
"""
for files in os.listdir(path_of_directory) :
if files.endswith(ext) :
i = 0
fd = open(path_of_directory + 'unsorted_' + str(file_num) + ext, 'rb')
with open(path_of_directory + 'unsorted_' + str(file_num) + ext, 'rb') as file :
value = fd.readline()
#print("line is: ",value[i])
print(bin(value[i]))
if (value[i] >= 555555 and value[i] <= 777777) :
count += 1
total += 1
i += 1
fd.close()
file_num += 1
print(float(count/total))
"""
"""
for files in os.listdir(path_of_directory) :
loc = (path_of_directory + "unsorted_" + str(file_num) + ext)
if files.endswith(ext) :
fd = open(loc, 'rb')
with open(loc) as file :
value = fd.readline()
print(int.from_bytes(value,"little",signed=False),"\n")
if (int.from_bytes(value,"big",signed=False) >= 555555 and int.from_bytes(value,"big",signed=False) <= 777777) :
hit += 1
count += 1
file_num += 1
print(count)
print(hit)
"""
|
{"hexsha": "b2123c225bea4aedea7ae6132698b1894870f2d6", "size": 1985, "ext": "py", "lang": "Python", "max_stars_repo_path": "unsorted.py", "max_stars_repo_name": "TotallyNotTito/concurrency", "max_stars_repo_head_hexsha": "151bbabe4daac1b1e72e75fdbe2724d0863cc4a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-07T22:54:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-07T22:54:51.000Z", "max_issues_repo_path": "unsorted.py", "max_issues_repo_name": "TotallyNotTito/xv6-riscv", "max_issues_repo_head_hexsha": "f5ff81e6ed869ac1be804d2260fc5a86a74cf97f", "max_issues_repo_licenses": ["MIT-0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "unsorted.py", "max_forks_repo_name": "TotallyNotTito/xv6-riscv", "max_forks_repo_head_hexsha": "f5ff81e6ed869ac1be804d2260fc5a86a74cf97f", "max_forks_repo_licenses": ["MIT-0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.6806722689, "max_line_length": 118, "alphanum_fraction": 0.5929471033, "include": true, "reason": "import numpy", "num_tokens": 597}
|
"""
Given annotations, segment images to extract lines, words, and letters.
"""
# Copyright (c) 2017 Ben Zimmer. All rights reserved.
import cv2
import numpy as np
from handwriting import geom
VISUALIZE = False
def extract_line_image(line, image, px_above, px_below):
"""extract line annotation image slice"""
diag = int(np.sqrt(image.shape[0] ** 2 + image.shape[1] ** 2))
_, theta = geom.points_to_polar(*line)
h, w = image.shape[:2]
center = (w / 2, h / 2)
# angle is in degrees
t_mat = cv2.getRotationMatrix2D(center, theta * 180.0 / np.pi, 1.0)
rotated_image = cv2.warpAffine(image, t_mat, (diag, diag))
line_full = geom.line_segment_within_image(line, image.shape)
p1 = np.array(line_full[0:2], dtype=np.int)
p2 = np.array(line_full[2:4], dtype=np.int)
pts_t = cv2.transform(np.array([[p1, p2]]), t_mat)
p1_t = np.maximum(pts_t[0][0], 0)
p2_t = np.maximum(pts_t[0][1], 0)
# segment by slicing a fixed amount above and below the line
line_y = p1_t[1] # should be very close to p2_t[1] - could average the two
full_line_image = rotated_image[(line_y - px_above):(line_y + px_below), :]
# discard the extra at the left and right
x_range = np.sort([p1_t[0], p2_t[0]])
line_image = full_line_image[:, x_range[0]:x_range[1]]
# print(rotated_image.shape)
# cv2.namedWindow("rot", cv2.WINDOW_NORMAL)
# cv2.imshow("rot", rotated_image)
# cv2.resizeWindow("rot", int(rotated_image.shape[1] / 5), int(rotated_image.shape[0] / 5))
if VISUALIZE:
# draw_lines(rotated_image, [np.hstack((p1_t, p2_t)).tolist()])
print(p1, p2, " -> ", p1_t, p2_t)
print(full_line_image.shape)
print(line_image.shape)
cv2.namedWindow("line", cv2.WINDOW_NORMAL)
cv2.imshow(
"line", cv2.resize(line_image,
(int(line_image.shape[1] / 2), int(line_image.shape[0] / 2))))
cv2.waitKey(0)
return line_image
def extract_letters(word_image, lgaps):
"""given a word image and line gap positions, extract letter images."""
# Unlike word extraction, this is its own function because the logic here
# is potentially more complex.
letter_width_min = 2
lgaps = [0] + lgaps + [word_image.shape[1]]
letter_images = []
for idx in range(len(lgaps) - 1):
letter_image = np.copy(word_image[:, lgaps[idx]:lgaps[idx + 1], :])
if letter_image.shape[1] > letter_width_min:
letter_images.append(letter_image)
return letter_images
|
{"hexsha": "b954e5b28c4a01dd605113033f6e1ae7caaf02fe", "size": 2551, "ext": "py", "lang": "Python", "max_stars_repo_path": "handwriting/extract.py", "max_stars_repo_name": "bdzimmer/handwriting", "max_stars_repo_head_hexsha": "eaa22c12a7a3210bbbee67b3d35ab0bb50bb38ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-10-30T10:32:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-02T23:40:15.000Z", "max_issues_repo_path": "handwriting/extract.py", "max_issues_repo_name": "bdzimmer/handwriting", "max_issues_repo_head_hexsha": "eaa22c12a7a3210bbbee67b3d35ab0bb50bb38ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-10-30T10:32:01.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-08T10:02:39.000Z", "max_forks_repo_path": "handwriting/extract.py", "max_forks_repo_name": "bdzimmer/handwriting", "max_forks_repo_head_hexsha": "eaa22c12a7a3210bbbee67b3d35ab0bb50bb38ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6629213483, "max_line_length": 95, "alphanum_fraction": 0.6468051744, "include": true, "reason": "import numpy", "num_tokens": 733}
|
"""
Created on Sun Feb 2 13:28:48 2020
@author: matias
"""
import numpy as np
from scipy.interpolate import interp1d
from scipy.constants import c as c_luz #metros/segundos
c_luz_km = c_luz/1000
import sys
import os
from os.path import join as osjoin
from pc_path import definir_path
path_git, path_datos_global = definir_path()
os.chdir(path_git)
sys.path.append('./Software/Funcionales/')
from funciones_int import Hubble_teorico
from funciones_supernovas import magn_aparente_teorica, chi2_supernovas
from funciones_BAO import r_drag, Hs_to_Ds, Ds_to_obs_final
from funciones_AGN import zs_2_logDlH0
### Generales
def chi2_sin_cov(teo, data, errores_cuad):
chi2 = np.sum((data-teo)**2/errores_cuad)
return chi2
def all_parameters(theta, params_fijos, index):
'''Esta función junta los valores de los parámetros
variables y los parámetros fijos en una sola lista con un criterio
dado por el valor de index.'''
if index == 4:
[Mabs, omega_m, b, H_0] = theta
_ = params_fijos
elif index == 31:
[omega_m, b, H_0] = theta
Mabs = params_fijos
elif index == 32:
[Mabs, omega_m, H_0] = theta
b = params_fijos
elif index == 33:
[Mabs, omega_m, b] = theta
H_0 = params_fijos
elif index == 21:
[omega_m, b] = theta
[Mabs, H_0] = params_fijos
elif index == 22:
[omega_m, H_0] = theta
[Mabs, b] = params_fijos
elif index == 1:
omega_m = theta
[Mabs, b, H_0] = params_fijos
return [Mabs, omega_m, b, H_0]
def params_to_chi2_odintsov(theta, params_fijos, index=0,
dataset_SN=None, dataset_CC=None,
dataset_BAO=None, dataset_AGN=None, H0_Riess=False,
cantidad_zs=int(10**5), model='HS',n=1,
nuisance_2 = False, errores_agrandados=False):
'''Dados los parámetros del modelo devuelve un chi2 para los datos
de supernovas.'''
# chi2_SN = chi2_CC = chi2_BAO = chi2_AGN = chi2_H0 = 0
chi2_SN = 0
chi2_CC = 0
chi2_BAO = 0
chi2_AGN = 0
chi2_H0 = 0
[Mabs, omega_m, b, H_0] = all_parameters(theta, params_fijos, index)
params_fisicos = [omega_m,b,H_0]
zs_modelo_2, Hs_modelo_2 = Hubble_teorico(params_fisicos, n=n, model=model,
z_min=0, z_max=10, cantidad_zs=cantidad_zs)
#Los datos de AGN van hasta z mas altos!
#MAL!
#Filtro para z=0 para que no diverja la integral de (1/H)
#mask = zs_modelo_2 > 0.001
zs_modelo = zs_modelo_2
Hs_modelo = Hs_modelo_2
if dataset_SN != None:
#Importo los datos
zcmb, zhel, Cinv, mb = dataset_SN
muth = magn_aparente_teorica(zs_modelo, Hs_modelo, zcmb, zhel)
muobs = mb - Mabs
chi2_SN = chi2_supernovas(muth, muobs, Cinv)
if dataset_CC != None:
#Importo los datos
z_data, H_data, dH = dataset_CC
H_interp = interp1d(zs_modelo, Hs_modelo)
H_teo = H_interp(z_data)
chi2_CC = chi2_sin_cov(H_teo, H_data, dH**2)
if dataset_BAO != None:
z_data_BAO, H_data_BAO, dH_BAO, rd_fid = dataset_BAO
H_interp = interp1d(zs_modelo, Hs_modelo)
H_teo = H_interp(z_data_BAO)
H_data_BAO_norm = np.zeros(len(H_data_BAO))
for i in range(len(H_data_BAO_norm)):
if rd_fid[i]==1:
factor = 1
else:
rd = r_drag(omega_m,H_0,wb=0.0225) #Calculo del rd, fijo wb!! CHequear que es correcto
factor = rd_fid[i]/rd
H_data_BAO_norm[i] = H_data_BAO[i] * factor
chi2_BAO = chi2_sin_cov(H_teo,H_data_BAO_norm,dH_BAO**2)
return chi2_SN + chi2_CC + chi2_BAO
#%%
if __name__ == '__main__':
from matplotlib import pyplot as plt
os.chdir(path_git)
sys.path.append('./Software/Funcionales/')
from funciones_data import leer_data_pantheon, leer_data_cronometros, leer_data_BAO_odintsov
# Supernovas
os.chdir(path_git+'/Software/Estadística/Datos/Datos_pantheon/')
ds_SN = leer_data_pantheon('lcparam_full_long_zhel.txt')
# Cronómetros
os.chdir(path_git+'/Software/Estadística/Datos/')
ds_CC = leer_data_cronometros('datos_cronometros.txt')
# BAO de odintsov
os.chdir(path_git+'/Software/Estadística/Datos/BAO/Datos_odintsov')
ds_BAO = leer_data_BAO_odintsov('datos_bao_odintsov.txt')
#%%
a = params_to_chi2_odintsov([-19.351100617405038, 0.30819459447582237, 69.2229987565787], _, index=32,
dataset_SN = ds_SN,
dataset_CC = ds_CC,
dataset_BAO = ds_BAO,
#dataset_AGN = ds_AGN,
#H0_Riess = True,
model = 'LCDM'
)
print(a)
|
{"hexsha": "7a93ceb60ea7904e68011f4548b0bf2c1931a204", "size": 4820, "ext": "py", "lang": "Python", "max_stars_repo_path": "Software/Funcionales/funciones_alternativos_odintsov.py", "max_stars_repo_name": "matiasleize/tesis_licenciatura", "max_stars_repo_head_hexsha": "5df6e341314583702b466b8ed7977d410f0ee457", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Software/Funcionales/funciones_alternativos_odintsov.py", "max_issues_repo_name": "matiasleize/tesis_licenciatura", "max_issues_repo_head_hexsha": "5df6e341314583702b466b8ed7977d410f0ee457", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Software/Funcionales/funciones_alternativos_odintsov.py", "max_forks_repo_name": "matiasleize/tesis_licenciatura", "max_forks_repo_head_hexsha": "5df6e341314583702b466b8ed7977d410f0ee457", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0967741935, "max_line_length": 106, "alphanum_fraction": 0.6331950207, "include": true, "reason": "import numpy,from scipy", "num_tokens": 1505}
|
using SparseArrays
using LinearAlgebra
using UnicodePlots
include("diagonal_sbp.jl")
# flatten tuples to arrays
flatten_tuples(x) = reshape(collect(Iterators.flatten(x)), length(x[1]),
length(x))
⊗(A,B) = kron(A, B)
const BC_DIRICHLET = 1
const BC_NEUMANN = 2
const BC_LOCKED_INTERFACE = 0
const BC_JUMP_INTERFACE = 7
#{{{ Transfinite Blend
function transfinite_blend(α1, α2, α3, α4, α1s, α2s, α3r, α4r, r, s)
# +---4---+
# | |
# 1 2
# | |
# +---3---+
@assert [α1(-1) α2(-1) α1( 1) α2( 1)] ≈ [α3(-1) α3( 1) α4(-1) α4( 1)]
x = (1 .+ r) .* α2(s)/2 + (1 .- r) .* α1(s)/2 +
(1 .+ s) .* α4(r)/2 + (1 .- s) .* α3(r)/2 -
((1 .+ r) .* (1 .+ s) .* α2( 1) +
(1 .- r) .* (1 .+ s) .* α1( 1) +
(1 .+ r) .* (1 .- s) .* α2(-1) +
(1 .- r) .* (1 .- s) .* α1(-1)) / 4
xr = α2(s)/2 - α1(s)/2 +
(1 .+ s) .* α4r(r)/2 + (1 .- s) .* α3r(r)/2 -
(+(1 .+ s) .* α2( 1) +
-(1 .+ s) .* α1( 1) +
+(1 .- s) .* α2(-1) +
-(1 .- s) .* α1(-1)) / 4
xs = (1 .+ r) .* α2s(s)/2 + (1 .- r) .* α1s(s)/2 +
α4(r)/2 - α3(r)/2 -
(+(1 .+ r) .* α2( 1) +
+(1 .- r) .* α1( 1) +
-(1 .+ r) .* α2(-1) +
-(1 .- r) .* α1(-1)) / 4
return (x, xr, xs)
end
function transfinite_blend(α1, α2, α3, α4, r, s, p)
(Nrp, Nsp) = size(r)
(Dr, _, _, _) = diagonal_sbp_D1(p, Nrp-1; xc = (-1,1))
(Ds, _, _, _) = diagonal_sbp_D1(p, Nsp-1; xc = (-1,1))
α2s(s) = α2(s) * Ds'
α1s(s) = α1(s) * Ds'
α4r(s) = Dr * α4(r)
α3r(s) = Dr * α3(r)
transfinite_blend(α1, α2, α3, α4, α1s, α2s, α3r, α4r, r, s)
end
function transfinite_blend(v1::T1, v2::T2, v3::T3, v4::T4, r, s
) where {T1 <: Number, T2 <: Number,
T3 <: Number, T4 <: Number}
e1(α) = v1 * (1 .- α) / 2 + v3 * (1 .+ α) / 2
e2(α) = v2 * (1 .- α) / 2 + v4 * (1 .+ α) / 2
e3(α) = v1 * (1 .- α) / 2 + v2 * (1 .+ α) / 2
e4(α) = v3 * (1 .- α) / 2 + v4 * (1 .+ α) / 2
e1α(α) = -v1 / 2 + v3 / 2
e2α(α) = -v2 / 2 + v4 / 2
e3α(α) = -v1 / 2 + v2 / 2
e4α(α) = -v3 / 2 + v4 / 2
transfinite_blend(e1, e2, e3, e4, e1α, e2α, e3α, e4α, r, s)
end
#}}}
#{{{ connectivityarrays
function connectivityarrays(EToV, EToF)
# number of elements
nelems = size(EToV, 2)
nfaces = maximum(maximum(EToF))
# Determine secondary arrays
# FToE : Unique Global Face to Element Number
# FToLF: Unique Global Face to Element local face number
# EToO : Element to Unique Global Faces Orientation
# EToS : Element to Unique Global Face Side
FToE = zeros(Int64, 2, nfaces)
FToLF = zeros(Int64, 2, nfaces)
EToO = Array{Bool,2}(undef, 4, nelems)
EToS = zeros(Int64, 4, nelems)
# Local Face to Local Vertex map
LFToLV = flatten_tuples(((1,3), (2, 4), (1,2), (3,4)))
for e = 1:nelems
for lf = 1:4
gf = EToF[lf, e]
if FToE[1, gf] == 0
@assert FToLF[1, gf] == 0
FToE[1, gf] = e
FToLF[1, gf] = lf
EToO[lf, e] = true
EToS[lf, e] = 1
else
@assert FToE[2, gf] == 0
@assert FToLF[2, gf] == 0
FToE[2, gf] = e
FToLF[2, gf] = lf
EToS[lf, e] = 2
ne = FToE[1, gf]
nf = FToLF[1, gf]
nv = EToV[LFToLV[:,nf], ne]
lv = EToV[LFToLV[:,lf], e]
if nv == lv
EToO[lf, e] = true
elseif nv[end:-1:1] == lv
EToO[lf, e] = false
else
error("problem with connectivity")
end
end
end
end
(FToE, FToLF, EToO, EToS)
end
#}}}
#{{{ locoperator
function create_metrics(pm, Nr, Ns,
xf=(r,s)->(r, ones(size(r)), zeros(size(r))),
yf=(r,s)->(s, zeros(size(s)), ones(size(s))))
Nrp = Nr + 1
Nsp = Ns + 1
Np = Nrp * Nsp
# Derivative operators for the metric terms
@assert pm <= 8
pp = pm == 6 ? 8 : pm
r = range(-1, stop=1, length=Nrp)
s = range(-1, stop=1, length=Nsp)
# Create the mesh
r = ones(1, Nsp) ⊗ r
s = s' ⊗ ones(Nrp)
(x, xr, xs) = xf(r, s)
(y, yr, ys) = yf(r, s)
J = xr .* ys - xs .* yr
@assert minimum(J) > 0
rx = ys ./ J
sx = -yr ./ J
ry = -xs ./ J
sy = xr ./ J
# variable coefficient matrix components
crr = J .* (rx .* rx + ry .* ry)
crs = J .* (sx .* rx + sy .* ry)
css = J .* (sx .* sx + sy .* sy)
#
# Block surface matrices
#
(xf1, yf1) = (view(x, 1, :), view(y, 1, :))
nx1 = -ys[1, :]
ny1 = xs[1, :]
sJ1 = hypot.(nx1, ny1)
nx1 = nx1 ./ sJ1
ny1 = ny1 ./ sJ1
(xf2, yf2) = (view(x, Nrp, :), view(y, Nrp, :))
nx2 = ys[end, :]
ny2 = -xs[end, :]
sJ2 = hypot.(nx2, ny2)
nx2 = nx2 ./ sJ2
ny2 = ny2 ./ sJ2
(xf3, yf3) = (view(x, :, 1), view(y, :, 1))
nx3 = yr[:, 1]
ny3 = -xr[:, 1]
sJ3 = hypot.(nx3, ny3)
nx3 = nx3 ./ sJ3
ny3 = ny3 ./ sJ3
(xf4, yf4) = (view(x, :, Nsp), view(y, :, Nsp))
nx4 = -yr[:, end]
ny4 = xr[:, end]
sJ4 = hypot.(nx4, ny4)
nx4 = nx4 ./ sJ4
ny4 = ny4 ./ sJ4
(coord = (x,y),
facecoord = ((xf1, xf2, xf3, xf4), (yf1, yf2, yf3, yf4)),
crr = crr, css = css, crs = crs,
J=J,
sJ = (sJ1, sJ2, sJ3, sJ4),
nx = (nx1, nx2, nx3, nx4),
ny = (ny1, ny2, ny3, ny4),
rx = rx, ry = ry, sx = sx, sy = sy)
end
function locoperator(p, Nr, Ns, metrics=create_metrics(p,Nr,Ns),
LFToB = (BC_DIRICHLET, BC_DIRICHLET,
BC_DIRICHLET, BC_DIRICHLET);
τscale = 2,
crr = metrics.crr,
css = metrics.css,
crs = metrics.crs)
csr = crs
J = metrics.J
Nrp = Nr + 1
Nsp = Ns + 1
Np = Nrp * Nsp
# Derivative operators for the rest of the computation
(Dr, HrI, Hr, r) = diagonal_sbp_D1(p, Nr; xc = (-1,1))
Qr = Hr * Dr
QrT = sparse(transpose(Qr))
(Ds, HsI, Hs, s) = diagonal_sbp_D1(p, Ns; xc = (-1,1))
Qs = Hs * Ds
QsT = sparse(transpose(Qs))
# Identity matrices for the comuptation
Ir = sparse(I, Nrp, Nrp)
Is = sparse(I, Nsp, Nsp)
#{{{ Set up the rr derivative matrix
ISr0 = Array{Int64,1}(undef,0)
JSr0 = Array{Int64,1}(undef,0)
VSr0 = Array{Float64,1}(undef,0)
ISrN = Array{Int64,1}(undef,0)
JSrN = Array{Int64,1}(undef,0)
VSrN = Array{Float64,1}(undef,0)
(_, S0e, SNe, _, _, Ae, _) = variable_diagonal_sbp_D2(p, Nr, rand(Nrp))
IArr = Array{Int64,1}(undef,Nsp * length(Ae.nzval))
JArr = Array{Int64,1}(undef,Nsp * length(Ae.nzval))
VArr = Array{Float64,1}(undef,Nsp * length(Ae.nzval))
stArr = 0
ISr0 = Array{Int64,1}(undef,Nsp * length(S0e.nzval))
JSr0 = Array{Int64,1}(undef,Nsp * length(S0e.nzval))
VSr0 = Array{Float64,1}(undef,Nsp * length(S0e.nzval))
stSr0 = 0
ISrN = Array{Int64,1}(undef,Nsp * length(SNe.nzval))
JSrN = Array{Int64,1}(undef,Nsp * length(SNe.nzval))
VSrN = Array{Float64,1}(undef,Nsp * length(SNe.nzval))
stSrN = 0
for j = 1:Nsp
rng = (j-1) * Nrp .+ (1:Nrp)
(_, S0e, SNe, _, _, Ae, _) = variable_diagonal_sbp_D2(p, Nr, crr[rng])
(Ie, Je, Ve) = findnz(Ae)
IArr[stArr .+ (1:length(Ve))] = Ie .+ (j-1) * Nrp
JArr[stArr .+ (1:length(Ve))] = Je .+ (j-1) * Nrp
VArr[stArr .+ (1:length(Ve))] = Hs[j,j] * Ve
stArr += length(Ve)
(Ie, Je, Ve) = findnz(S0e)
ISr0[stSr0 .+ (1:length(Ve))] = Ie .+ (j-1) * Nrp
JSr0[stSr0 .+ (1:length(Ve))] = Je .+ (j-1) * Nrp
VSr0[stSr0 .+ (1:length(Ve))] = Hs[j,j] * Ve
stSr0 += length(Ve)
(Ie, Je, Ve) = findnz(SNe)
ISrN[stSrN .+ (1:length(Ve))] = Ie .+ (j-1) * Nrp
JSrN[stSrN .+ (1:length(Ve))] = Je .+ (j-1) * Nrp
VSrN[stSrN .+ (1:length(Ve))] = Hs[j,j] * Ve
stSrN += length(Ve)
end
Ãrr = sparse(IArr[1:stArr], JArr[1:stArr], VArr[1:stArr], Np, Np)
Sr0 = sparse(ISr0[1:stSr0], JSr0[1:stSr0], VSr0[1:stSr0], Np, Np)
SrN = sparse(ISrN[1:stSrN], JSrN[1:stSrN], VSrN[1:stSrN], Np, Np)
Sr0T = sparse(JSr0[1:stSr0], ISr0[1:stSr0], VSr0[1:stSr0], Np, Np)
SrNT = sparse(JSrN[1:stSrN], ISrN[1:stSrN], VSrN[1:stSrN], Np, Np)
#= affine mesh test
# @assert Ãrr ≈ Ãrr'
(D2, S0, SN, _, _, _) = diagonal_sbp_D2(p, Nr)
Ar = SN - S0 - Hr * D2
@assert Ãrr ≈ Hs ⊗ Ar
=#
# @assert Sr0 ≈ ((sparse(Diagonal(crr[1 .+ Nrp*(0:Ns)])) * Hs) ⊗ S0)
# @assert SrN ≈ ((sparse(Diagonal(crr[Nrp .+ Nrp*(0:Ns)])) * Hs) ⊗ SN)
#}}}
#{{{ Set up the ss derivative matrix
(_, S0e, SNe, _, _, Ae, _) = variable_diagonal_sbp_D2(p, Ns, rand(Nsp))
IAss = Array{Int64,1}(undef,Nrp * length(Ae.nzval))
JAss = Array{Int64,1}(undef,Nrp * length(Ae.nzval))
VAss = Array{Float64,1}(undef,Nrp * length(Ae.nzval))
stAss = 0
ISs0 = Array{Int64,1}(undef,Nrp * length(S0e.nzval))
JSs0 = Array{Int64,1}(undef,Nrp * length(S0e.nzval))
VSs0 = Array{Float64,1}(undef,Nrp * length(S0e.nzval))
stSs0 = 0
ISsN = Array{Int64,1}(undef,Nrp * length(SNe.nzval))
JSsN = Array{Int64,1}(undef,Nrp * length(SNe.nzval))
VSsN = Array{Float64,1}(undef,Nrp * length(SNe.nzval))
stSsN = 0
for i = 1:Nrp
rng = i .+ Nrp * (0:Ns)
(_, S0e, SNe, _, _, Ae, _) = variable_diagonal_sbp_D2(p, Ns, css[rng])
R = Ae - Dr' * Hr * Diagonal(css[rng]) * Dr
(Ie, Je, Ve) = findnz(Ae)
IAss[stAss .+ (1:length(Ve))] = i .+ Nrp * (Ie .- 1)
JAss[stAss .+ (1:length(Ve))] = i .+ Nrp * (Je .- 1)
VAss[stAss .+ (1:length(Ve))] = Hr[i,i] * Ve
stAss += length(Ve)
(Ie, Je, Ve) = findnz(S0e)
ISs0[stSs0 .+ (1:length(Ve))] = i .+ Nrp * (Ie .- 1)
JSs0[stSs0 .+ (1:length(Ve))] = i .+ Nrp * (Je .- 1)
VSs0[stSs0 .+ (1:length(Ve))] = Hr[i,i] * Ve
stSs0 += length(Ve)
(Ie, Je, Ve) = findnz(SNe)
ISsN[stSsN .+ (1:length(Ve))] = i .+ Nrp * (Ie .- 1)
JSsN[stSsN .+ (1:length(Ve))] = i .+ Nrp * (Je .- 1)
VSsN[stSsN .+ (1:length(Ve))] = Hr[i,i] * Ve
stSsN += length(Ve)
end
Ãss = sparse(IAss[1:stAss], JAss[1:stAss], VAss[1:stAss], Np, Np)
Ss0 = sparse(ISs0[1:stSs0], JSs0[1:stSs0], VSs0[1:stSs0], Np, Np)
SsN = sparse(ISsN[1:stSsN], JSsN[1:stSsN], VSsN[1:stSsN], Np, Np)
Ss0T = sparse(JSs0[1:stSs0], ISs0[1:stSs0], VSs0[1:stSs0], Np, Np)
SsNT = sparse(JSsN[1:stSsN], ISsN[1:stSsN], VSsN[1:stSsN], Np, Np)
# @assert Ãss ≈ Ãss'
#= affine mesh test
(D2, S0, SN, _, _, _) = diagonal_sbp_D2(p, Ns)
As = SN - S0 - Hs * D2
@assert Ãss ≈ As ⊗ Hr
=#
# @assert Ss0 ≈ (S0 ⊗ (Hr * sparse(Diagonal(css[1:Nrp]))))
# @assert SsN ≈ (SN ⊗ (Hr * sparse(Diagonal(css[Nrp*Ns .+ (1:Nrp)]))))
#}}}
#{{{ Set up the sr and rs derivative matrices
Ãsr = (QsT ⊗ Ir) * sparse(1:length(crs), 1:length(crs), view(crs, :)) * (Is ⊗ Qr)
Ãrs = (Is ⊗ QrT) * sparse(1:length(csr), 1:length(csr), view(csr, :)) * (Qs ⊗ Ir)
#}}}
à = Ãrr + Ãss + Ãrs + Ãsr
#
# Boundary point matrices
#
Er0 = sparse([1], [1], [1], Nrp, Nrp)
ErN = sparse([Nrp], [Nrp], [1], Nrp, Nrp)
Es0 = sparse([1], [1], [1], Nsp, Nsp)
EsN = sparse([Nsp], [Nsp], [1], Nsp, Nsp)
er0 = sparse([1 ], [1], [1], Nrp, 1)
erN = sparse([Nrp], [1], [1], Nrp, 1)
es0 = sparse([1 ], [1], [1], Nsp, 1)
esN = sparse([Nsp], [1], [1], Nsp, 1)
er0T = sparse([1], [1 ], [1], 1, Nrp)
erNT = sparse([1], [Nrp], [1], 1, Nrp)
es0T = sparse([1], [1 ], [1], 1, Nsp)
esNT = sparse([1], [Nsp], [1], 1, Nsp)
#
# Store coefficient matrices as matrices
#
crs0 = sparse(Diagonal(crs[1:Nrp]))
crsN = sparse(Diagonal(crs[Nrp*Ns .+ (1:Nrp)]))
csr0 = sparse(Diagonal(csr[1 .+ Nrp*(0:Ns)]))
csrN = sparse(Diagonal(csr[Nrp .+ Nrp*(0:Ns)]))
#
# Surface mass matrices
#
H1 = Hs
H1I = HsI
H2 = Hs
H2I = HsI
H3 = Hr
H3I = HrI
H4 = Hr
H4I = HrI
#
# Penalty terms
#
if p == 2
l = 2
β = 0.363636363
α = 1 / 2
elseif p == 4
l = 4
β = 0.2505765857
α = 17 / 48
elseif p == 6
l = 7
β = 0.1878687080
α = 13649 / 43200
else
error("unknown order")
end
ψmin = reshape((crr + css - sqrt.((crr - css).^2 + 4crs.^2)) / 2, Nrp, Nsp)
@assert minimum(ψmin) > 0
hr = 2 / Nr
hs = 2 / Ns
ψ1 = ψmin[ 1, :]
ψ2 = ψmin[Nrp, :]
ψ3 = ψmin[:, 1]
ψ4 = ψmin[:, Nsp]
for k = 2:l
ψ1 = min.(ψ1, ψmin[k, :])
ψ2 = min.(ψ2, ψmin[Nrp+1-k, :])
ψ3 = min.(ψ3, ψmin[:, k])
ψ4 = min.(ψ4, ψmin[:, Nsp+1-k])
end
τ1 = (2τscale / hr) * (crr[ 1, :].^2 / β + crs[ 1, :].^2 / α) ./ ψ1
τ2 = (2τscale / hr) * (crr[Nrp, :].^2 / β + crs[Nrp, :].^2 / α) ./ ψ2
τ3 = (2τscale / hs) * (css[:, 1].^2 / β + crs[:, 1].^2 / α) ./ ψ3
τ4 = (2τscale / hs) * (css[:, Nsp].^2 / β + crs[:, Nsp].^2 / α) ./ ψ4
τ1 = sparse(1:Nsp, 1:Nsp, τ1)
τ2 = sparse(1:Nsp, 1:Nsp, τ2)
τ3 = sparse(1:Nrp, 1:Nrp, τ3)
τ4 = sparse(1:Nrp, 1:Nrp, τ4)
C̃1 = (Sr0 + Sr0T) + ((csr0 * Qs + QsT * csr0) ⊗ Er0) + ((τ1 * H1) ⊗ Er0)
C̃2 = -(SrN + SrNT) - ((csrN * Qs + QsT * csrN) ⊗ ErN) + ((τ2 * H2) ⊗ ErN)
C̃3 = (Ss0 + Ss0T) + (Es0 ⊗ (crs0 * Qr + QrT * crs0)) + (Es0 ⊗ (τ3 * H3))
C̃4 = -(SsN + SsNT) - (EsN ⊗ (crsN * Qr + QrT * crsN)) + (EsN ⊗ (τ4 * H4))
# TODO: Fix minus sign (reverse of the paper)
G1 = -(Is ⊗ er0T) * Sr0 - ((csr0 * Qs) ⊗ er0T)
G2 = +(Is ⊗ erNT) * SrN + ((csrN * Qs) ⊗ erNT)
G3 = -(es0T ⊗ Ir) * Ss0 - (es0T ⊗ (crs0 * Qr))
G4 = +(esNT ⊗ Ir) * SsN + (esNT ⊗ (crsN * Qr))
F1 = G1' - ((τ1 * H1) ⊗ er0)
F2 = G2' - ((τ2 * H2) ⊗ erN)
F3 = G3' - (es0 ⊗ (τ3 * H3))
F4 = G4' - (esN ⊗ (τ4 * H4))
HfI_F1T = H1I * G1 - (τ1 ⊗ er0')
HfI_F2T = H2I * G2 - (τ2 ⊗ erN')
HfI_F3T = H3I * G3 - (es0' ⊗ τ3)
HfI_F4T = H4I * G4 - (esN' ⊗ τ4)
HfI_G1 = H1I * G1
HfI_G2 = H2I * G2
HfI_G3 = H3I * G3
HfI_G4 = H4I * G4
M̃ = Ã + C̃1 + C̃2 + C̃3 + C̃4
# Modify the operator to handle the boundary conditions
bctype=(BC_LOCKED_INTERFACE, BC_LOCKED_INTERFACE, BC_LOCKED_INTERFACE, BC_LOCKED_INTERFACE)
F = (F1, F2, F3, F4)
τ = (τ1, τ2, τ3, τ4)
HfI = (H1I, H2I, H3I, H4I)
# Modify operators for the BC
for lf = 1:4
if LFToB[lf] == BC_NEUMANN
M̃ -= F[lf] * (Diagonal(1 ./ (diag(τ[lf]))) * HfI[lf]) * F[lf]'
elseif !(LFToB[lf] == BC_DIRICHLET ||
LFToB[lf] == BC_LOCKED_INTERFACE ||
LFToB[lf] >= BC_JUMP_INTERFACE)
error("invalid bc")
end
end
bctype=(LFToB[1], LFToB[2], LFToB[3], LFToB[4])
# (E, V) = eigen(Matrix(M̃))
# println((minimum(E), maximum(E)))
JH = sparse(1:Np, 1:Np, view(J, :)) * (Hs ⊗ Hr)
(M̃ = M̃,
F = (F1, F2, F3, F4),
HfI_FT = (HfI_F1T, HfI_F2T, HfI_F3T, HfI_F4T),
HfI_G = (HfI_G1, HfI_G2, HfI_G3, HfI_G4),
coord = metrics.coord,
facecoord = metrics.facecoord,
JH = JH,
sJ = metrics.sJ,
nx = metrics.nx,
ny = metrics.ny,
Hf = (H1, H2, H3, H4),
HfI = (H1I, H2I, H3I, H4I),
τ = (τ1, τ2, τ3, τ4),
bctype=bctype)
end
#}}}
#{{{ gloλoperator: Build the trace operators
function gloλoperator(lop, vstarts, FToB, FToE, FToLF, EToO, EToS, Nr, Ns)
nelems = length(lop)
nfaces = length(FToB)
Nλp = zeros(Int64, nfaces)
FToλstarts = Array{Int64, 1}(undef, nfaces + 1)
FToλstarts[1] = 1
IT = Array{Int64,1}(undef,0)
JT = Array{Int64,1}(undef,0)
VT = Array{Float64,1}(undef,0)
VD = Array{Float64,1}(undef,0)
for f = 1:nfaces
if FToB[f] == BC_DIRICHLET || FToB[f] == BC_NEUMANN
FToλstarts[f+1] = FToλstarts[f]
continue
end
(em, ep) = FToE[:, f]
(fm, fp) = FToLF[:, f]
Nλp[f] = (fm <= 2 ? Ns[em]+1 : Nr[em]+1)
@assert Nλp[f] == (fp <= 2 ? Ns[ep]+1 : Nr[ep]+1)
FToλstarts[f+1] = FToλstarts[f] + Nλp[f]
@assert EToO[fm, em] && EToS[fm, em] == 1
Fm = lop[em].F[fm]
# swap I and J to get transpose
(Je, Ie, Ve) = findnz(Fm)
IT = [IT; Ie .+ (FToλstarts[f] - 1)]
JT = [JT; Je .+ (vstarts[em] - 1)]
VT = [VT; Ve]
@assert EToS[fp, ep] == 2
Fp = lop[ep].F[fp]
# swap I and J to get transpose
(Je, Ie, Ve) = findnz(Fp)
# if element and face orientation do not match, then flip
if EToO[fp, ep]
IT = [IT; Ie .+ (FToλstarts[f] - 1)]
τm = Vector(diag(lop[em].τ[fm]))
τp = Vector(diag(lop[ep].τ[fp]))
else
IT = [IT; FToλstarts[f+1] .- Ie]
τm = Vector(diag(lop[em].τ[fm]))
τp = Vector(diag(rot180(lop[ep].τ[fp])))
end
JT = [JT; Je .+ (vstarts[ep] - 1)]
VT = [VT; Ve]
Hf = Vector(diag(lop[em].Hf[fm]))
VD = [VD; Hf .* (τm + τp)]
end
λNp = FToλstarts[nfaces+1]-1
VNp = vstarts[nelems+1]-1
FbarT = sparse(IT, JT, VT, λNp, VNp)
# Ttranspose = sparse(JT, IT, VT, VNp, λNp)
(FToλstarts, FbarT, VD)
end
#}}}
#{{{ volbcarray()
function locbcarray_mod!(ge, lop, LFToB, bc_Dirichlet, bc_Neumann,
bcargs = ())
F = lop.F
(xf, yf) = lop.facecoord
Hf = lop.Hf
sJ = lop.sJ
nx = lop.nx
ny = lop.ny
τ = lop.τ
ge[:] .= 0
for lf = 1:4
if LFToB[lf] == BC_DIRICHLET
vf = bc_Dirichlet(lf, xf[lf], yf[lf], bcargs...)
elseif LFToB[lf] == BC_NEUMANN
gN = bc_Neumann(lf, xf[lf], yf[lf], nx[lf], ny[lf], bcargs...)
vf = sJ[lf] .* gN ./ diag(τ[lf])
elseif LFToB[lf] == BC_LOCKED_INTERFACE
continue # nothing to do here
else
error("invalid bc")
end
ge[:] -= F[lf] * vf
end
end
#{{{ volbcarray()
function locbcarray!(ge, gδe, lop, LFToB, bc_Dirichlet, bc_Neumann, in_jump,
bcargs = ())
F = lop.F
(xf, yf) = lop.facecoord
Hf = lop.Hf
sJ = lop.sJ
nx = lop.nx
ny = lop.ny
τ = lop.τ
ge[:] .= 0
for lf = 1:4
if LFToB[lf] == BC_DIRICHLET
vf = bc_Dirichlet(lf, xf[lf], yf[lf], bcargs...)
elseif LFToB[lf] == BC_NEUMANN
gN = bc_Neumann(lf, xf[lf], yf[lf], nx[lf], ny[lf], bcargs...)
vf = sJ[lf] .* gN ./ diag(τ[lf])
elseif LFToB[lf] == BC_LOCKED_INTERFACE
continue # nothing to do here
elseif LFToB[lf] >= BC_JUMP_INTERFACE
# In this case we need to add in half the jump
vf = in_jump(lf, xf[lf], yf[lf], bcargs...) / 2
gδe[lf][:] -= Hf[lf] * τ[lf] * vf
else
error("invalid bc")
end
ge[:] -= F[lf] * vf
end
end
#}}}
#{{{ computetraction
function computetraction_mod(lop, lf, u, δ)
HfI_FT = lop.HfI_FT[lf]
τf = lop.τ[lf]
sJ = lop.sJ[lf]
return (HfI_FT * u + τf * (δ .- δ / 2)) ./ sJ
end
#{{{ computetraction
function computetraction(lop, lf, u, λ, δ)
HfI_FT = lop.HfI_FT[lf]
τf = lop.τ[lf]
sJ = lop.sJ[lf]
return (HfI_FT * u + τf * (λ .- δ / 2)) ./ sJ
end
#}}}
#{{{ volsourcearray()
function locsourcearray!(ge, source, lop, volargs = ())
(xloc, yloc) = lop.coord
JHloc = lop.JH
ge[:] += JHloc * source(xloc[:], yloc[:], volargs...)
end
#}}}
#{{{
struct SBPLocalOperator1{T<:Real, S<:Factorization}
offset::Array{Int64,1}
H::Array{T,1}
X::Array{T,1}
Y::Array{T,1}
E::Array{Int64,1}
F::Array{S,1}
SBPLocalOperator1{T,S}(vstarts::Array{Int64,1}, H::Array{T,1}, X::Array{T,1},
Y::Array{T,1}, E::Array{Int64,1},
F::Array{S,1}) where {T<:Real, S<:Factorization} =
new(vstarts, H, X, Y, E, F)
end
function SBPLocalOperator1(lop, Nr, Ns, factorization)
nelems = length(lop)
vstarts = Array{Int64, 1}(undef, nelems + 1)
vstarts[1] = 1
Np = Array{Int64, 1}(undef, nelems)
VH = Array{Float64,1}(undef,0)
X = Array{Float64,1}(undef,0)
Y = Array{Float64,1}(undef,0)
E = Array{Int64,1}(undef,0)
FTYPE = typeof(factorization(sparse([1],[1],[1.0])))
factors = Array{FTYPE, 1}(undef, nelems)
for e = 1:nelems
# Fill arrays to build global sparse matrix
Np[e] = (Nr[e]+1)*(Ns[e]+1)
vstarts[e+1] = vstarts[e] + Np[e]
# Global "mass" matrix
JH = lop[e].JH
VH = [VH;Vector(diag(JH))]
# global coordinates and element number array (needed for jump)
(x,y) = lop[e].coord
X = [X;x[:]]
Y = [Y;y[:]]
E = [E;e * ones(Int64, Np[e])]
factors[e] = factorization(lop[e].M̃)
end
VNp = vstarts[nelems+1]-1 # total number of volume points
SBPLocalOperator1{Float64, FTYPE}(vstarts, VH, X, Y, E, factors)
end
#}}}
function LocalGlobalOperators(lop, Nr, Ns, FToB, FToE, FToLF, EToO, EToS,
factorization)
M = SBPLocalOperator1(lop, Nr, Ns, factorization)
(FToλstarts, FbarT, D) = gloλoperator(lop, M.offset, FToB, FToE, FToLF, EToO,
EToS, Nr, Ns)
(M, FbarT, D, M.offset, FToλstarts)
end
function bcstarts(FToB, FToE, FToLF, bctype, Nr, Ns)
nfaces = length(FToB)
bcstarts = Array{Int64, 1}(undef, nfaces + 1)
bcstarts[1] = 1
for f = 1:nfaces
if FToB[f] ∈ bctype
e = FToE[1,f]
lf = FToLF[1,f]
bcstarts[f+1] = bcstarts[f] + (lf ∈ (1,2) ? Ns[e] : Nr[e]) + 1
else
bcstarts[f+1] = bcstarts[f]
end
end
bcstarts
end
function LocalToGLobalRHS!(b, g, gδ, u, M, FbarT, vstarts)
u .= 0
@inbounds for e = 1:length(M)
if maximum(abs.(g[vstarts[e]:(vstarts[e+1]-1)])) > 0
@views u[vstarts[e]:(vstarts[e+1]-1)] = (M[e] \
g[vstarts[e]:(vstarts[e+1]-1)])
end
end
mul!(b, FbarT, u)
@. b = gδ - b
end
#{{{ assembleλmatrix: Schur complement system
function assembleλmatrix(FToλstarts, vstarts, EToF, FToB, F, D, FbarT)
nfaces = length(FToλstarts)-1
nelems = length(vstarts)-1
λNp = FToλstarts[nfaces+1]-1
sz = λNp
for e = 1:nelems
lλs = Array{Int64, 1}(undef, 4)
for lf = 1:4
f = EToF[lf,e]
lλs[lf] = FToλstarts[f+1] - FToλstarts[f]
end
for lf = 1:4
sz += lλs[lf]*sum(lλs)
end
end
Ie = Array{Int64, 1}(undef, sz)
Je = Array{Int64, 1}(undef, sz)
Ve = Array{Float64, 1}(undef, sz)
Ie[1:λNp] = 1:λNp
Je[1:λNp] = 1:λNp
Ve[1:λNp] = D
offset = λNp
Fbar = FbarT'
for e = 1:nelems
# println((e, nelems))
vrng = vstarts[e]:(vstarts[e+1]-1)
for lf = 1:4
f = EToF[lf,e]
if FToB[f] == BC_LOCKED_INTERFACE || FToB[f] >= BC_JUMP_INTERFACE
λrng = FToλstarts[f]:(FToλstarts[f+1]-1)
B = -(Matrix(F[e]' \ Fbar[vrng, λrng]))
for lf2 = 1:4
f2 = EToF[lf2,e]
if FToB[f2] == BC_LOCKED_INTERFACE || FToB[f2] >= BC_JUMP_INTERFACE
λrng2 = FToλstarts[f2]:(FToλstarts[f2+1]-1)
C = -(FbarT[λrng2, vrng] * B)
λblck = λrng*ones(Int64, 1, length(λrng2))
λblck2 = ones(Int64, length(λrng), 1) * λrng2'
last = length(λrng) * length(λrng2)
Ie[offset.+(1:last)] = λblck[:]
Je[offset.+(1:last)] = λblck2[:]
Ve[offset.+(1:last)] = -C'[:]
offset += last
end
end
end
end
end
@assert offset == sz
B = sparse(Ie, Je, Ve, λNp, λNp)
@assert B ≈ B'
# println((λNp * λNp, nnz(B), nnz(B) / λNp^2))
B
end
#}}}
# {{{ Constructor for inp files
function read_inp_2d(T, S, filename::String; bc_map=1:10000)
# {{{ Read in the file
f = try
open(filename)
catch
error("InpRead cannot open \"$filename\" ")
end
lines = readlines(f)
close(f)
# }}}
# {{{ Read in nodes
str = "NSET=ALLNODES"
linenum = SeekToSubstring(lines, str);
linenum > 0 || error("did not find: $str")
num_nodes = 0
for l = linenum+1:length(lines)
occursin(r"^\s*[0-9]*\s*,.*", lines[l]) ? num_nodes+=1 : break
end
Vx = fill(S(NaN), num_nodes)
Vy = fill(S(NaN), num_nodes)
Vz = fill(S(NaN), num_nodes)
for l = linenum .+ (1:num_nodes)
node_data = split(lines[l], r"\s|,", keepempty=false)
(node_num, node_x, node_y, node_z) = try
(parse(T, node_data[1]),
parse(S, node_data[2]),
parse(S, node_data[3]),
parse(S, node_data[4]))
catch
error("cannot parse line $l: \"$(lines[l])\" ")
end
Vx[node_num] = node_x
Vy[node_num] = node_y
Vz[node_num] = node_z
end
# }}}
# {{{ Read in Elements
str = "ELEMENT"
linenum = SeekToSubstring(lines, str);
num_elm = 0
while linenum > 0
for l = linenum .+ (1:length(lines))
occursin(r"^\s*[0-9]*\s*,.*", lines[l]) ? num_elm+=1 : break
end
linenum = SeekToSubstring(lines, str; first=linenum+1)
end
num_elm > 0 || error("did not find any element")
EToV = fill(T(0), 4, num_elm)
EToBlock = fill(T(0), num_elm)
linenum = SeekToSubstring(lines, str);
while linenum > 0
foo = split(lines[linenum], r"[^0-9]", keepempty=false)
B = parse(T, foo[end])
for l = linenum .+ (1:num_elm)
elm_data = split(lines[l], r"\s|,", keepempty=false)
# read into z-order
(elm_num, elm_v1, elm_v2, elm_v4, elm_v3) = try
(parse(T, elm_data[1]),
parse(T, elm_data[2]),
parse(T, elm_data[3]),
parse(T, elm_data[4]),
parse(T, elm_data[5]))
catch
break
end
EToV[:, elm_num] = [elm_v1, elm_v2, elm_v3, elm_v4]
EToBlock[elm_num] = B
end
linenum = SeekToSubstring(lines, str; first=linenum+1)
end
# }}}
# {{{ Determine connectivity
EToF = fill(T(0), 4, num_elm)
VsToF = Dict{Tuple{Int64, Int64}, Int64}()
numfaces = 0
for e = 1:num_elm
for lf = 1:4
if lf == 1
Vs = (EToV[1, e], EToV[3, e])
elseif lf == 2
Vs = (EToV[2, e], EToV[4, e])
elseif lf == 3
Vs = (EToV[1, e], EToV[2, e])
elseif lf == 4
Vs = (EToV[3, e], EToV[4, e])
end
if Vs[1] > Vs[2]
Vs = (Vs[2], Vs[1])
end
if haskey(VsToF, Vs)
EToF[lf, e] = VsToF[Vs]
else
numfaces = numfaces + 1
EToF[lf, e] = VsToF[Vs] = numfaces
end
end
end
#}}}
# {{{ Read in side set info
FToB = Array{T, 1}(undef, numfaces)
fill!(FToB, BC_LOCKED_INTERFACE)
linenum = SeekToSubstring(lines, "\\*ELSET")
inp_to_zorder = [3, 2, 4, 1]
while linenum > 0
foo = split(lines[linenum], r"[^0-9]", keepempty=false)
(bc, face) = try
(parse(T, foo[1]),
parse(T, foo[2]))
catch
error("cannot parse line $linenum: \"$(lines[linenum])\" ")
end
bc = bc_map[bc]
face = inp_to_zorder[face]
for l = linenum+1:length(lines)
if !occursin(r"^\s*[0-9]+", lines[l])
break
end
elms = split(lines[l], r"\s|,", keepempty=false)
for elm in elms
elm = try
parse(T, elm)
catch
error("cannot parse line $linenum: \"$(lines[l])\" ")
end
if bc == 3
bc = BC_LOCKED_INTERFACE
end
FToB[EToF[face, elm]] = bc
@assert (bc == BC_DIRICHLET || bc == BC_NEUMANN ||
bc == BC_LOCKED_INTERFACE || bc >= BC_JUMP_INTERFACE)
end
end
linenum = SeekToSubstring(lines, "\\*ELSET"; first=linenum+1)
end
# }}}
([Vx Vy]', EToV, EToF, FToB, EToBlock)
end
read_inp_2d(filename;kw...) = read_inp_2d(Int64, Float64, filename;kw...)
function SeekToSubstring(lines, substring; first=1)
for l = first:length(lines)
if occursin(Regex(".*$(substring).*"), lines[l])
return l
end
end
return -1
end
# }}}
function plot_connectivity(verts, EToV)
Lx = extrema(verts[1,:])
Lx = (floor(Int, Lx[1]), ceil(Int, Lx[2]))
Ly = extrema(verts[2,:])
Ly = (floor(Int, Ly[1]), ceil(Int, Ly[2]))
width = Lx[2] - Lx[1]
height = Ly[2] - Ly[1]
plt = Plot(BrailleCanvas(80, ceil(Int, 40 * height / width),
origin_x = Lx[1], origin_y = Ly[1],
width = width, height = height))
annotate!(plt, :l, nrows(plt.graphics), string(Ly[1]), color = :light_black)
annotate!(plt, :l, 1, string(Ly[2]), color = :light_black)
annotate!(plt, :bl, string(Lx[1]), color = :light_black)
annotate!(plt, :br, string(Lx[2]), color = :light_black)
for e = 1:size(EToV, 2)
(v1, v2, v3, v4) = EToV[1:4, e]
x = verts[1, [v1 v2 v4 v3 v1]][:]
y = verts[2, [v1 v2 v4 v3 v1]][:]
lineplot!(plt, x, y)
end
title!(plt, "connectivity")
display(plt)
end
function plot_blocks(lop)
Lx = (floatmax(), -floatmax())
Ly = (floatmax(), -floatmax())
for e = 1:length(lop)
(x, y) = lop[e].coord
Lxe = extrema(x)
Lye = extrema(y)
Lx = (min(Lx[1], Lxe[1]), max(Lx[2], Lxe[2]))
Ly = (min(Ly[1], Lye[1]), max(Ly[2], Lye[2]))
end
Lx = (floor(Int, Lx[1]), ceil(Int, Lx[2]))
Ly = (floor(Int, Ly[1]), ceil(Int, Ly[2]))
width = Lx[2] - Lx[1]
height = Ly[2] - Ly[1]
plt = Plot(BrailleCanvas(80, ceil(Int, 40 * height / width),
origin_x = Lx[1], origin_y = Ly[1],
width = width, height = height))
annotate!(plt, :l, nrows(plt.graphics), string(Ly[1]), color = :light_black)
annotate!(plt, :l, 1, string(Ly[2]), color = :light_black)
annotate!(plt, :bl, string(Lx[1]), color = :light_black)
annotate!(plt, :br, string(Lx[2]), color = :light_black)
for e = 1:length(lop)
(xf, yf) = lop[e].facecoord
bctype = lop[e].bctype
for lf = 1:length(xf)
if bctype[lf] == BC_LOCKED_INTERFACE
lineplot!(plt, xf[lf], yf[lf], color=:blue)
elseif bctype[lf] == BC_DIRICHLET
lineplot!(plt, xf[lf], yf[lf], color=:green)
elseif bctype[lf] == BC_DIRICHLET
lineplot!(plt, xf[lf], yf[lf], color=:yellow)
else
lineplot!(plt, xf[lf], yf[lf], color=:red)
end
end
end
title!(plt, "mesh")
display(plt)
end
function rateandstate(V, psi, σn, ϕ, η, a, V0)
Y = (1 ./ (2 .* V0)) .* exp.(psi ./ a)
f = a .* asinh.(V .* Y)
dfdV = a .* (1 ./ sqrt.(1 + (V .* Y).^2)) .* Y
g = σn .* f + η .* V - ϕ
dgdV = σn .* dfdV + η
(g, dgdV)
end
function newtbndv(func, xL, xR, x; ftol = 1e-6, maxiter = 500, minchange=0,
atolx = 1e-4, rtolx = 1e-4)
(fL, _) = func(xL)
(fR, _) = func(xR)
if fL .* fR > 0
return (typeof(x)(NaN), typeof(x)(NaN), -maxiter)
end
(f, df) = func(x)
dxlr = xR - xL
for iter = 1:maxiter
dx = -f / df
x = x + dx
if x < xL || x > xR || abs(dx) / dxlr < minchange
x = (xR + xL) / 2
dx = (xR - xL) / 2
end
(f, df) = func(x)
if f * fL > 0
(fL, xL) = (f, x)
else
(fR, xR) = (f, x)
end
dxlr = xR - xL
if abs(f) < ftol && abs(dx) < atolx + rtolx * (abs(dx) + abs(x))
return (x, f, iter)
end
end
return (x, f, -maxiter)
end
|
{"hexsha": "f98678ee3621e376107a90ba196d3a574d32a0af", "size": 29954, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "global_curved.jl", "max_stars_repo_name": "brittany-erickson/HybridSBP", "max_stars_repo_head_hexsha": "29dc9fe084c561ea0c4007e5097baf456fd86462", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "global_curved.jl", "max_issues_repo_name": "brittany-erickson/HybridSBP", "max_issues_repo_head_hexsha": "29dc9fe084c561ea0c4007e5097baf456fd86462", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "global_curved.jl", "max_forks_repo_name": "brittany-erickson/HybridSBP", "max_forks_repo_head_hexsha": "29dc9fe084c561ea0c4007e5097baf456fd86462", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8382899628, "max_line_length": 93, "alphanum_fraction": 0.5242037791, "num_tokens": 13029}
|
from __future__ import print_function
import argparse
import os
import shutil
import time
import random
import cv2
import imageio
import utils
import numpy as np
import pickle
import scipy.misc
import skimage
import skimage.io
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data as data
import timecycle as tc
import davis_test as davis
import jhmdb_test as jhmdb
from scipy.ndimage.morphology import binary_dilation,generate_binary_structure
from torch.autograd import Variable
params = {}
def str_to_bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
# Parse arguments
parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
# Datasets
parser.add_argument('--workers', default=4, type=int, metavar='N',
help='number of data loading workers (default: 4)')
parser.add_argument('--resume', default='', type=str, metavar='PATH',
help='path to latest checkpoint (default: none)')
parser.add_argument('--manualSeed', type=int, help='manual seed')
parser.add_argument('-e', '--evaluate', dest='evaluate', action='store_true',
help='evaluate model on validation set')
#Device options
parser.add_argument('--gpu-id', default='0', type=str,
help='id(s) for CUDA_VISIBLE_DEVICES')
parser.add_argument('--batchSize', default=1, type=int,
help='batchSize')
parser.add_argument('--temperature', default=1.0, type=float,
help='temperature')
parser.add_argument('--topk_vis', default=20, type=int,
help='topk_vis')
parser.add_argument('--radius', default=3, type=float,
help='topk_vis')
parser.add_argument('--all-nn', default=False, action='store_true',
help='use all as nn')
parser.add_argument('--videoLen', default=4, type=int,
help='predict how many frames away')
parser.add_argument('--cropSize', default=320, type=int,
help='predict how many frames away')
parser.add_argument('--outSize', default=640, type=int,
help='size of output mask image')
parser.add_argument('--filelist', default='/scratch/ajabri/data/davis/val2017.txt', type=str)
parser.add_argument('--save-path', default='./results', type=str)
parser.add_argument('--visdom', default=False, action='store_true')
parser.add_argument('--server', default='localhost', type=str)
parser.add_argument('--model-type', default='scratch', type=str)
parser.add_argument('--head-depth', default=0, type=int,
help='')
parser.add_argument('--no-maxpool', default=False, action='store_true', help='')
parser.add_argument('--use-res4', default=False, action='store_true', help='')
parser.add_argument('--skip-res3', default=False, action='store_true', help='')
parser.add_argument('--skip-res2', default=False, action='store_true', help='')
parser.add_argument('--no-l2', default=False, action='store_true', help='')
parser.add_argument('--long-mem', default=[0], type=int, nargs='*', help='')
parser.add_argument('--texture', default=False, action='store_true', help='')
parser.add_argument('--round', default=False, action='store_true', help='')
parser.add_argument('--time-dilation', default=1, type=int, help='time dilation of context')
parser.add_argument('--mapRatio', default=1, type=int, help='map aspect ratio')
parser.add_argument('--norm_mask', default=False, action='store_true', help='')
parser.add_argument('--finetune', default=0, type=int, help='')
args = parser.parse_args()
params = {k: v for k, v in args._get_kwargs()}
print('batchSize: ' + str(params['batchSize']) )
print('videoLen: ' + str(params['videoLen']) )
print('cropSize: ' + str(params['cropSize']) )
params['imgSize'] = params['cropSize']
# Use CUDA
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_id
use_cuda = torch.cuda.is_available()
# args.gpu_id = os.getenv('CUDA_VISIBLE_DEVICES')
print(args.gpu_id)
import visdom
vis = None
if args.visdom:
vis = visdom.Visdom(server=args.server, port=8095, env='main_davis_viz1'); vis.close()
import wandb
wandb.init(project='palindromes', group='test_online')
vis.close()
# Random seed
if args.manualSeed is None:
args.manualSeed = random.randint(1, 10000)
random.seed(args.manualSeed)
torch.manual_seed(args.manualSeed)
if use_cuda:
torch.cuda.manual_seed_all(args.manualSeed)
class Wrap(nn.Module):
def __init__(self, model):
super(Wrap, self).__init__()
self.model = model
def forward(self, *args, func='forward', **kwargs):
return getattr(self.model, func)(*args, **kwargs)
def batched_index_select(input, dim, index):
for ii in range(1, len(input.shape)):
if ii != dim:
index = index.unsqueeze(ii)
expanse = list(input.shape)
expanse[0] = -1
expanse[dim] = -1
index = index.expand(expanse)
return torch.gather(input, dim, index)
def main():
global best_loss
start_epoch = 0 # start from epoch 0 or last checkpoint epoch
args.kldv_coef = 1
args.long_coef = 1
args.frame_transforms = 'crop'
args.frame_aug = 'grid'
args.npatch = 49
args.img_size = 256
args.pstride = [0.5,0.5]
args.patch_size = [64, 64, 3]
args.visualize=False
model = tc.TimeCycle(
args,
vis=vis
).cuda()
params['mapScale'] = model(torch.zeros(1, 10, 3, 320, 320).cuda(), just_feats=True)[1].shape[-2:]
params['mapScale'] = 320 // np.array(params['mapScale'])
val_loader = torch.utils.data.DataLoader(
davis.DavisSet(params, is_train=False) if not 'jhmdb' in args.filelist else \
jhmdb.JhmdbSet(params, is_train=False),
batch_size=int(params['batchSize']), shuffle=False,
num_workers=args.workers, pin_memory=True)
cudnn.benchmark = False
print(' Total params: %.2fM' % (sum(p.numel() for p in model.parameters())/1000000.0))
# Load checkpoint.
if os.path.isfile(args.resume):
print('==> Resuming from checkpoint..')
checkpoint = torch.load(args.resume)
utils.partial_load(checkpoint['model'], model, skip_keys=['head'])
del checkpoint
model.eval()
# model = torch.nn.DataParallel(model).cuda() # model = model.cuda()
model = model.cuda()
if not os.path.exists(args.save_path):
os.makedirs(args.save_path)
print('\Testing')
# with torch.no_grad():
test_loss = test(val_loader, model, 1, use_cuda, args)
from matplotlib import cm
def dump_predictions(predlbls, lbl_set, img_now, prefix):
sz = img_now.shape[:-1]
pad = params['mapScale']
predlbls_cp = predlbls.copy()
predlbls_cp = cv2.resize(predlbls_cp, sz[::-1])[:]
# predlbls_cp2 = np.zeros((sz[-2]+pad[0], sz[-1]+pad[1], predlbls_cp.shape[-1]))
# predlbls_cp2[:, :, 0] = 1
# predlbls_cp2[:-pad[0], :-pad[1], :] = predlbls_cp
# predlbls_cp = predlbls_cp2
# predlbls_cp = cv2.resize(predlbls_cp, (sz[-1] + pad[0], sz[-2] + pad[1]))[:]
# predlbls_cp =predlbls_cp[pad[0]//2:-pad[0]//2, pad[1]//2:-pad[1]//2]
# predlbls_cp =predlbls_cp[pad[0]:, pad[1]:]
predlbls_val = np.zeros((*sz, 3))
ids = np.argmax(predlbls_cp[:, :, 1 : len(lbl_set)], 2)
predlbls_val = np.argmax(predlbls_cp, axis=-1)
predlbls_val = np.array(lbl_set, dtype=np.int32)[predlbls_val]
# predlbls_val = predlbls_val.astype(np.uint8)
# if img_now.shape[0] != args.outSize:
# img_now = cv2.resize(img_now, (args.outSize, args.outSize), interpolation=cv2.INTER_LINEAR)
# import pdb; pdb.set_trace()
predlbls_val2 = cv2.resize(predlbls_val, (img_now.shape[1], img_now.shape[0]), interpolation=cv2.INTER_NEAREST)
# activation_heatmap = cv2.applyColorMap(predlbls, cv2.COLORMAP_JET)
img_with_heatmap = np.float32(img_now) * 0.5 + np.float32(predlbls_val2) * 0.5
predlbls_soft = predlbls_cp[..., 1]
predlbls_soft = cv2.resize(predlbls_soft, (img_now.shape[1], img_now.shape[0]), interpolation=cv2.INTER_NEAREST)
predlbls_soft = cm.jet(predlbls_soft)[..., :3] * 255.0
img_with_heatmap2 = np.float32(img_now) * 0.5 + np.float32(predlbls_soft) * 0.5
imname = prefix + '_blend.jpg'
imageio.imwrite(imname, np.uint8(img_with_heatmap))
if prefix[-4] != '.':
imname2 = prefix + '_mask.png'
# skimage.io.imsave(imname2, np.uint8(predlbls_val))
else:
imname2 = prefix.replace('jpg','png')
# predlbls_val = np.uint8(predlbls_val)
# if predlbls_val.max() > 20:#: or :
# import pdb; pdb.set_trace()
# skimage.io.imsave(imname2.replace('jpg','png'), predlbls_val)
imageio.imwrite(imname2, np.uint8(predlbls_val))
return img_with_heatmap, predlbls_val, img_with_heatmap2
def softmax_base(A):
if not args.all_nn:
N, T, H, W, H, W = A.shape
A = A.view(N, T, H*W, H, W)
A = torch.nn.functional.softmax(A, dim=-3)
else:
N, T, H, W, H, W = A.shape
A = A.view(N, T*H*W, H, W)
A = torch.nn.functional.softmax(A, dim=-3)
return A
def extract_values(lbls, ids, weights):
T, H, W, L = lbls.shape
if args.all_nn:
lbls = lbls.view(T*H*W, L)
predlbls = batched_index_select(
lbls, 0, ids.view(-1))
predlbls = (weights.unsqueeze(-1) * \
predlbls.view(weights.shape[0], H, W, L)).sum(0)
else:
lbls = lbls.view(T, H*W, L)
predlbls = batched_index_select(
lbls, 1, ids.view(T, -1))
predlbls = (weights.unsqueeze(-1)/T * \
predlbls.view(T, weights.shape[0], H, W, L)).sum(0).sum(0)
return predlbls
def hard_prop(predlbls):
pred_max = predlbls.max(axis=0)[0]
predlbls[predlbls < pred_max] = 0
predlbls[predlbls >= pred_max] = 1
predlbls /= predlbls.sum(0)[None]
return predlbls
def process_pose(predlbls, lbl_set, topk=3):
# generate the coordinates:
predlbls = predlbls[..., 1:]
flatlbls = predlbls.flatten(0,1)
topk = min(flatlbls.shape[0], topk)
vals, ids = torch.topk(flatlbls, k=topk, dim=0)
vals /= vals.sum(0)[None]
xx, yy = ids % predlbls.shape[1], ids // predlbls.shape[1]
current_coord = torch.stack([(xx * vals).sum(0), (yy * vals).sum(0)], dim=0)
current_coord[:, flatlbls.sum(0) == 0] = -1
predlbls_val_sharp = np.zeros((*predlbls.shape[:2], 3))
for t in range(len(lbl_set) - 1):
x = int(current_coord[0, t])
y = int(current_coord[1, t])
if x >=0 and y >= 0:
predlbls_val_sharp[y, x, :] = lbl_set[t + 1]
return current_coord.cpu(), predlbls_val_sharp
import kornia
import kornia.augmentation as K
def test(val_loader, model, epoch, use_cuda, args):
save_path = args.save_path + '/'
end = time.time()
n_context = params['videoLen']
# Radius mask
D = None
t_vid = 0
import copy
_model_state = copy.deepcopy(model.state_dict())
# _model_state = model.state_dict().copy()
res4 = model.encoder.model.layer4
ssfc = model.selfsim_fc
for batch_idx, (imgs_total, imgs_orig, lbl_set, lbls_tensor, lbls_onehot, lbls_resize, meta) in enumerate(val_loader):
t_vid = time.time()
print('******* Vid %s *******' % batch_idx)
# import pdb; pdb.set_trace()
# measure data loading time
imgs_total = imgs_total.cuda()
bs, total_frame_num, channel_num, height_len, weight_len = imgs_total.shape
imgs_toprint = [ii for ii in imgs_orig[0]]
assert(bs == 1)
folder_paths = meta['folder_path']
print('total_frame_num: ' + str(total_frame_num))
##################################################################
# Compute image features
##################################################################
print("MODEL StATE AVG", list(_model_state.items())[0][1].mean())
model.encoder.model.layer4 = res4
model.selfsim_fc = ssfc
model.load_state_dict(_model_state)
model.xent_coef, model.kldv_coef = 1, 0
model.long_coef, model.skip_coef = 1, 0
model.sk_align, model.sk_targets = True, False #, True, True #, True
model.dropout_rate = 0.0
train_len = 3
def fit(model, video, targets, steps=1):
optimizer = torch.optim.Adam(model.parameters(), lr=0.00005)#, momentum=0.9, weight_decay=0)
# optimizer = torch.optim.SGD(model.parameters(), lr=0.1)#, momentum=0.9, weight_decay=0)
h = video.shape[-2]
random_crop = K.RandomCrop((h, h), same_on_batch=True)
for _ in range(steps):
fps = np.random.randint(1, 3)
idx = np.random.randint(video.shape[1]//fps - train_len)
x = video[:, ::fps][:, idx:idx+train_len].cuda()
# import pdb; pdb.set_trace()
# output, xent_loss, kldv_loss, diagnostics = model(video, orig=video, targets=targets)
# print('step', _, kldv_loss.mean().item(), diagnostics)
# import pdb; pdb.set_trace()
x = random_crop(x[0])[None]
output, xent_loss, kldv_loss, diagnostics = model(x, orig=x[0], unfold=False)
# import pdb; pdb.set_trace()
# output, xent_loss, kldv_loss, diagnostics = model(x, orig=x[0], unfold=True)
if (_ % 20) == 0:
print('step', _, xent_loss.mean().item(), diagnostics)
loss = (xent_loss.mean() + kldv_loss.mean())
optimizer.zero_grad()
loss.backward()
optimizer.step()
optimizer = None
torch.cuda.empty_cache()
# make labels: uniform prob to indices with same mask id
# targets = lbls_onehot.max(-1)[1]
# targets = (targets[0, 0:1, ..., None, None] == targets[0, 0:1])
# targets = targets*1.0/ targets.sum(-1).sum(-1)[..., None, None]*1.0
# targets = targets.flatten(1,2).flatten(-2,-1).cuda()
b, bsize = 0, 5
# fit(model, video, targets, steps=nsteps)
# imgs_total =
fit(model, imgs_total, None, steps=args.finetune)
# import pdb; pdb.set_trace()
torch.cuda.empty_cache()
model.encoder.model.layer4 = None
model.selfsim_fc = tc.Identity()
model.dropout_rate = 0.0
with torch.no_grad():
t00 = time.time()
feats = []
bsize = 5
for b in range(0, imgs_total.shape[1], bsize):
node, feat = model(imgs_total[:, b:b+bsize].cuda(), orig=None, just_feats=True)
feats.append(feat.cpu())
feats = torch.cat(feats, dim=2)
# nodes, feats = model.module(imgs_total, None, True, func='forward')
feats = feats.squeeze(1)
if not args.no_l2:
feats = torch.nn.functional.normalize(feats, dim=1)
print('computed features', time.time()-t00)
##################################################################
# Compute correlation features
##################################################################
torch.cuda.empty_cache()
im_num = total_frame_num - n_context
t03 = time.time()
def make_bank():
ll = []
for t in args.long_mem:
idx = torch.zeros(im_num, 1).long()
if t > 0:
assert t < im_num
idx += t + (args.videoLen+1)
idx[:args.videoLen+t+1] = 0
ll.append(idx)
ss = [(torch.arange(n_context)[None].repeat(im_num, 1) + torch.arange(im_num)[:, None])[:, :]]
# if len(args.long_mem) == 0 or True:
# import pdb; pdb.set_trace()
return ll + ss
indices = torch.cat(make_bank(), dim=-1)
keys, query = feats[:, :, indices], feats[:, :, n_context:]
restrict = utils.RestrictAttention(args.radius, flat=False)
D = restrict.mask(*query.shape[-2:])[None]
D = D.flatten(-4, -3).flatten(-2)
D[D==0] = -1e10; D[D==1] = 0
Ws, Is = [], []
keys, query = keys.flatten(-2), query.flatten(-2)
bsize, pbsize = 2, 100 #keys.shape[2] // 2
for b in range(0, keys.shape[2], bsize):
_k, _q = keys[:, :, b:b+bsize].cuda(), query[:, :, b:b+bsize].cuda()
w_s, i_s = [], []
for pb in range(0, _k.shape[-1], pbsize):
# A = torch.einsum('ijklmn,ijkop->iklmnop', _k, _q) / args.temperature
A = torch.einsum('ijklm,ijkn->iklmn',
_k, _q[..., pb:pb+pbsize])
# import pdb; pdb.set_trace()
A[0, :, len(args.long_mem):] += D[..., pb:pb+pbsize].cuda()
_, N, T, h1w1, hw = A.shape
A = A.view(N, T*h1w1, hw)
A /= args.temperature
weights, ids = torch.topk(A, args.topk_vis, dim=-2)
weights = torch.nn.functional.softmax(weights, dim=-2)
# import pdb; pdb.set_trace()
w_s.append(weights.cpu())
i_s.append(ids.cpu())
# import pdb; pdb.set_trace()
weights = torch.cat(w_s, dim=-1)
ids = torch.cat(i_s, dim=-1)
Ws += [w for w in weights]
Is += [ii for ii in ids]
# Ws, Is = torch.cat(Ws, 1), torch.cat(Is, 1) # A = torch.cat(As, dim=1)
t04 = time.time()
print(t04-t03, 'affinity forward, max mem', torch.cuda.max_memory_allocated() / (1024**2))
if isinstance(lbl_set, list):
lbl_set = torch.cat(lbl_set)[None]
lbls_resize[0, n_context*2 - 1:] *= 0
# if lbl_set.ndim > 2:
# import pdb; pdb.set_trace()
lbl_set, lbls_resize = lbl_set.squeeze(0), lbls_resize.squeeze(0)
##################################################################
# Label propagation
##################################################################
maps = []
keypts = []
images = []
for it in range(indices.shape[0]):
if it % 10 == 0:
print(it)
lbls_base = lbls_resize[indices[it]].cuda()
flat_lbls = lbls_base.flatten(0, 2).transpose(0, 1)
predlbls = (flat_lbls[:, Is[it]] * Ws[it].cuda()[None]).sum(1)
predlbls = predlbls.view(-1, *feats.shape[-2:])
# print(predlbls.mean(-1).mean(-1))
#predlbls = hard_prop(predlbls)
predlbls = predlbls.permute(1,2,0)
img_now = imgs_toprint[it + n_context].permute(1,2,0).numpy() * 255
if it > 0:
lbls_resize[it + n_context] = predlbls
else:
predlbls = lbls_resize[0]
lbls_resize[it + n_context] = predlbls
if args.norm_mask:
# import pdb; pdb.set_trace()
predlbls[:, :, :] -= predlbls.min(-1)[0][:, :, None]
predlbls[:, :, :] /= predlbls.max(-1)[0][:, :, None]
# import pdb; pdb.set_trace()
_maps = []
if 'jhmdb' in args.filelist.lower():
coords, predlbls_sharp = process_pose(predlbls, lbl_set)
keypts.append(coords)
pose_map = utils.vis_pose(np.array(img_now).copy(), coords.numpy() * params['mapScale'][..., None])
_maps += [pose_map]
# Save Predictions
if 'VIP' in args.filelist:
outpath = os.path.join(save_path, 'videos'+meta['img_paths'][it+n_context][0].split('videos')[-1])
os.makedirs(os.path.dirname(outpath), exist_ok=True)
else:
outpath = os.path.join(save_path, str(batch_idx) + '_' + str(it))
heatmap, lblmap, heatmap_prob = dump_predictions(
predlbls.cpu().numpy(),
lbl_set, img_now, outpath)
_maps += [heatmap, lblmap, heatmap_prob]
maps.append(_maps)
images.append(img_now)
if args.visdom:
[vis.image(np.uint8(_m).transpose(2, 0, 1)) for _m in _maps]
if len(keypts) > 0:
# import pdb; pdb.set_trace()
coordpath = os.path.join(save_path, str(batch_idx) + '.dat')
np.stack(keypts, axis=-1).dump(coordpath)
if args.visdom:
# wandb.log({'vid%s' % batch_idx: [wandb.Image(mm[0]) for mm in maps]})
# for m in maps:
# wandb.log({'blend vid%s' % batch_idx: wandb.Image(
# m[0])})
wandb.log({'blend vid%s' % batch_idx: wandb.Video(
np.array([m[0] for m in maps]).transpose(0, -1, 1, 2), fps=12, format="gif")})
wandb.log({'prob vid%s' % batch_idx: wandb.Video(
np.array([m[-1] for m in maps]).transpose(0, -1, 1, 2), fps=12, format="gif")})
# import pdb; pdb.set_trace()
# wandb.log({'plain vid%s' % batch_idx: wandb.Video(
# np.array(images).transpose(0, -1, 1, 2), fps=12, format="gif")})
torch.cuda.empty_cache()
print('******* Vid %s TOOK %s *******' % (batch_idx, time.time() - t_vid))
if __name__ == '__main__':
main()
|
{"hexsha": "400b81c22567e5ff7eac76f589dc30d9f4ea62ab", "size": 22431, "ext": "py", "lang": "Python", "max_stars_repo_path": "references/video_classification/test_mem_online.py", "max_stars_repo_name": "ajabri/vision", "max_stars_repo_head_hexsha": "f69847cc761937891be77e1780bc4ddea46dbe68", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-11T20:54:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T20:54:46.000Z", "max_issues_repo_path": "references/video_classification/test_mem_online.py", "max_issues_repo_name": "ajabri/vision", "max_issues_repo_head_hexsha": "f69847cc761937891be77e1780bc4ddea46dbe68", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "references/video_classification/test_mem_online.py", "max_forks_repo_name": "ajabri/vision", "max_forks_repo_head_hexsha": "f69847cc761937891be77e1780bc4ddea46dbe68", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-11T20:54:56.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-11T20:54:56.000Z", "avg_line_length": 35.103286385, "max_line_length": 122, "alphanum_fraction": 0.5532521956, "include": true, "reason": "import numpy,import scipy,from scipy", "num_tokens": 5813}
|
# Packages
import pandas as pd
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
from pprint import pprint
import argparse
# Functions
def plotHeatmap(data, fname, xlabs, ylabs):
cm = "hot_r"
fig = plt.figure(figsize=(3*len(xlabs), len(ylabs)))
sns.set(style="white", font_scale = 2)
sns.heatmap(data, xticklabels = xlabs, yticklabels = ylabs, cmap=cm, cbar_kws = {"fraction":0.5, "shrink":0.5})
plt.xticks(rotation=90)
fig.savefig(fname = fname, bbox_inches = 'tight', pad_inches = 1)
def plotClustermap(enr, pvals, fname, xlabs, ylabs):
cm = "hot_r"
# rc={'axes.labelsize': 12, 'font.size': 48, 'legend.fontsize': 12, 'axes.titlesize': 12}
# sns.set(rc = rc, style="white", font_scale=3)
sns.set(style="white", font_scale=3)
fig0 = sns.clustermap(enr, figsize = (5*len(xlabs), len(ylabs)), xticklabels = xlabs, yticklabels = ylabs, cmap=cm, cbar_kws = {"fraction":0.5, "shrink":0.8})
row_order = fig0.dendrogram_row.reordered_ind
col_order = fig0.dendrogram_col.reordered_ind
pvals = pvals[:, col_order][row_order]
annot = np.zeros(np.shape(pvals), dtype = "<S4")
annot[pvals > 2.99] = "*"
annot[pvals > 4.6] = "**"
annot[pvals > 6.9] = "***"
# ticks = [0, np.floor(np.max(enr)/2.0), np.floor(np.max(enr))]
# fig = sns.clustermap(enr, figsize = (5*len(xlabs), len(ylabs)), xticklabels = xlabs, yticklabels = ylabs, cbar_kws = {"fraction":2.0, "shrink":1.5, "ticks":ticks}, cmap=cm, annot = pvals, annot_kws={"size": 24})
# fig = sns.clustermap(enr, figsize = (5*len(xlabs), len(ylabs)), xticklabels = xlabs, yticklabels = ylabs, cbar_kws = {"fraction":2.0, "shrink":1.5}, cmap=cm)
fig = sns.clustermap(enr, figsize = (5*len(xlabs), len(ylabs)), xticklabels = xlabs, yticklabels = ylabs, cbar_kws = {"fraction":2.0, "shrink":1.5}, cmap=cm, annot = annot, fmt = '')
fig.savefig(fname = fname+".enrichment.png", bbox_inches = 'tight', pad_inches = 1)
def readLDSCfiles(fnames):
alldat = [pd.read_csv(f, delim_whitespace=True) for f in fnames]
enr = np.concatenate([d[['Enrichment']].fillna(0).values for d in alldat], 1)
pvals = -np.log(np.concatenate([d[['Enrichment_p']].fillna(1).values for d in alldat], 1))
enr_er = np.concatenate([d[['Enrichment_std_error']].fillna(0).values for d in alldat], 1)
op = np.argsort(-np.mean(pvals,1))
pvals = pvals[op]
enr = enr[op]
enr_er = enr_er[op]
ylabs = [l.split("_0")[0] for l in alldat[0]['Category'][op]]
return alldat, enr, pvals, enr_er, ylabs
# Code to run
parser = argparse.ArgumentParser(description='Plot results of LDSC',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--results', nargs=1, type=str, default="", help='comma separated list of result files from LDSC')
parser.add_argument('--labels', nargs=1, type=str, default="", help='comma separated list of labels for each LDSC analysis')
parser.add_argument('--outpref', nargs='?', type=str, default="", help='output file preference')
parser.add_argument('--pthresh', nargs='?', type=float, default=0.05, help='pvalue threshold for plotting')
parser.add_argument('--ethresh', nargs='?', type=float, default=np.inf, help='enrichment std error threshold for plotting')
args = parser.parse_args()
fnames = args.results[0].replace(" ", "").split(",")
labels = args.labels[0].replace(" ", "").split(",")
alldat, enr, pvals, enr_er, ylabs = readLDSCfiles(fnames)
nominal = np.max(pvals,1) > -np.log(args.pthresh)
pvals = pvals[nominal,:]
enr = enr[nominal,:]
enr_er = enr_er[nominal,:]
ylabs = [y for i, y in enumerate(ylabs) if nominal[i]]
abv_error = np.max(enr_er,1) < args.ethresh
pvals = pvals[abv_error,:]
enr = enr[abv_error,:]
enr_er = enr_er[abv_error,:]
ylabs = [y for i, y in enumerate(ylabs) if abv_error[i]]
if np.shape(enr)[1] == 1:
plotHeatmap(enr, args.outpref+"enrichment.png", args.labels, ylabs)
plotHeatmap(pvals, args.outpref+"pvalues.png", args.labels, ylabs)
else:
if np.shape(enr)[0] > 1:
plotClustermap(enr, pvals, args.outpref, labels, ylabs)
|
{"hexsha": "8baaff9ed23d7a12dc3625e93b607f2ef7e794f8", "size": 4012, "ext": "py", "lang": "Python", "max_stars_repo_path": "plotLDSC_2.py", "max_stars_repo_name": "mwoodbri/ldsc_wdl", "max_stars_repo_head_hexsha": "b9497b9cdd23c990f8003adde368e852d2349a0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plotLDSC_2.py", "max_issues_repo_name": "mwoodbri/ldsc_wdl", "max_issues_repo_head_hexsha": "b9497b9cdd23c990f8003adde368e852d2349a0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plotLDSC_2.py", "max_forks_repo_name": "mwoodbri/ldsc_wdl", "max_forks_repo_head_hexsha": "b9497b9cdd23c990f8003adde368e852d2349a0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-03-01T12:20:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-10T15:34:24.000Z", "avg_line_length": 46.6511627907, "max_line_length": 214, "alphanum_fraction": 0.6941674975, "include": true, "reason": "import numpy", "num_tokens": 1301}
|
#! /usr/bin/env python3
#
# Copyright 2018 Google LLC
#
# 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
#
# https://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.
"""Implement random graph generators and Graph class."""
import copy
import numpy as np
import jacinle.random as random
__all__ = ['Graph', 'randomly_generate_graph_er', 'randomly_generate_graph_dnc',
'get_random_graph_generator']
class Graph(object):
"""Store a graph using adjacency matrix.
Args:
nr_nodes: The number of nodes in the graph.
edges: The adjacency matrix of the graph.
"""
def __init__(self, nr_nodes, edges, coordinates=None):
edges = edges.astype('int32')
assert edges.min() >= 0 and edges.max() <= 1
self._nr_nodes = nr_nodes
self._edges = edges
self._coordinates = coordinates
self._shortest = None
self.extra_info = {}
@property
def nr_nodes(self):
return self._nr_nodes
def get_edges(self):
return copy.copy(self._edges)
def get_coordinates(self):
return self._coordinates
def get_relations(self):
"""Return edges and identity matrix."""
return np.stack([self.get_edges(), np.eye(self.nr_nodes)], axis=-1)
def has_edge(self, x, y):
return self._edges[x, y] == 1
def get_out_degree(self):
"""Return the out degree of each node."""
return np.sum(self._edges, axis=1)
def get_shortest(self):
"""Return the length of shortest path between nodes."""
if self._shortest is not None:
return self._shortest
n = self.nr_nodes
edges = self.get_edges()
# n + 1 indicates unreachable.
shortest = np.ones((n, n)) * (n + 1)
shortest[np.where(edges == 1)] = 1
# Make sure that shortest[x, x] = 0
shortest -= shortest * np.eye(n)
shortest = shortest.astype('int32')
# Floyd Algorithm
for k in range(n):
for i in range(n):
for j in range(n):
if i != j:
shortest[i, j] = min(shortest[i, j],
shortest[i, k] + shortest[k, j])
self._shortest = shortest
return self._shortest
def get_connectivity(self, k=None, exclude_self=True):
"""Calculate the k-connectivity.
Args:
k: The limited steps. unlimited if k=None or k<0.
exclude_self: remove connectivity[x, x] if exclude_self=True.
Returns:
A numpy.ndarray representing the k-connectivity for each pair of nodes.
"""
shortest = self.get_shortest()
if k is None or k < 0:
k = self.nr_nodes
k = min(k, self.nr_nodes)
conn = (shortest <= k).astype('int32')
if exclude_self:
n = self.nr_nodes
inds = np.where(~np.eye(n, dtype=bool))
conn = conn[inds]
conn.resize(n, n - 1)
return conn
def randomly_generate_graph_er(n, p, directed=False):
"""Randomly generate a graph by sampling the existence of each edge.
Each edge between nodes has the probability $p (directed) or
1 - (1-$p)^2 (undirected) to exist.
Args:
n: The number of nodes in the graph.
p: the probability that a edge doesn't exist in directed graph.
directed: Directed or Undirected graph. Default: False (undirected)
Returns:
A Graph class representing randomly generated graph.
"""
edges = (random.rand(n, n) < p).astype('float')
edges -= edges * np.eye(n)
if not directed:
edges = np.maximum(edges, edges.T)
return Graph(n, edges)
def randomly_generate_graph_dnc(n, p=None, directed=False):
"""Random graph generation method as in DNC.
As described in Differentiable neural computers (DNC),
(https://www.nature.com/articles/nature20101.epdf?author_access_token=ImTXBI8aWbYxYQ51Plys8NRgN0jAjWel9jnR3ZoTv0MggmpDmwljGswxVdeocYSurJ3hxupzWuRNeGvvXnoO8o4jTJcnAyhGuZzXJ1GEaD-Z7E6X_a9R-xqJ9TfJWBqz)
Sample $n nodes in a unit square. Then sample out-degree (m) of each nodes,
connect to $m nearest neighbors (Euclidean distance) in the unit square.
Args:
n: The number of nodes in the graph.
p: Control the sampling of the out-degree.
If p=None, the default range is [1, n // 3].
If p is float, the range is [1, int(n * p)].
If p is int, the range is [1, p].
If p is tuple. the range is [p[0], p[1]].
directed: Directed or Undirected graph. Default: False (undirected)
Returns:
A Graph class representing randomly generated graph.
"""
edges = np.zeros((n, n), dtype='float')
pos = random.rand(n, 2)
def dist(x, y):
return ((x - y)**2).mean()
if isinstance(p, tuple):
lower, upper = p
else:
lower = 1
if p is None:
upper = n // 3
elif isinstance(p, int):
upper = p
elif isinstance(p, float):
upper = int(n * p)
else:
assert False, 'Unknown argument type: {}'.format(type(p))
upper = max(upper, 1)
lower = max(lower, 1)
upper = min(upper, n - 1)
for i in range(n):
d = []
k = random.randint(upper - lower + 1) + lower
for j in range(n):
if i != j:
d.append((dist(pos[i], pos[j]), j))
d.sort()
for j in range(k):
edges[i, d[j][1]] = 1
if not directed:
edges = np.maximum(edges, edges.T)
return Graph(n, edges, pos)
def get_random_graph_generator(name):
if name == 'dnc':
return randomly_generate_graph_dnc
return randomly_generate_graph_er
|
{"hexsha": "753fbb9d1d798b0d0862d6ee620ff4357d93d8fd", "size": 5729, "ext": "py", "lang": "Python", "max_stars_repo_path": "difflogic/envs/graph/graph.py", "max_stars_repo_name": "isabella232/neural-logic-machines", "max_stars_repo_head_hexsha": "3f8a8966c54d13d2658c77c03793a9a98a283e22", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 243, "max_stars_repo_stars_event_min_datetime": "2019-01-05T20:13:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T19:25:07.000Z", "max_issues_repo_path": "difflogic/envs/graph/graph.py", "max_issues_repo_name": "dair-iitd/1oML_workdir", "max_issues_repo_head_hexsha": "37117de4abf1774548786e9534c90977d67091d8", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-05-10T04:46:06.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-31T07:08:27.000Z", "max_forks_repo_path": "difflogic/envs/graph/graph.py", "max_forks_repo_name": "dair-iitd/1oML_workdir", "max_forks_repo_head_hexsha": "37117de4abf1774548786e9534c90977d67091d8", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2019-05-07T02:35:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-05T19:38:21.000Z", "avg_line_length": 29.6839378238, "max_line_length": 201, "alphanum_fraction": 0.6571827544, "include": true, "reason": "import numpy", "num_tokens": 1566}
|
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// 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)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <boost/beast/core/dynamic_buffer_ref.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/asio/read_until.hpp>
namespace boost {
namespace beast {
namespace {
template <class SyncReadStream>
std::size_t read_line (SyncReadStream& stream, flat_buffer& buffer)
{
return net::read_until(stream, dynamic_buffer_ref(buffer), "\r\n");
}
} // (anon)
class dynamic_buffer_ref_test : public beast::unit_test::suite
{
public:
void
testJavadocs()
{
BEAST_EXPECT(static_cast<
std::size_t(*)(test::stream&, flat_buffer&)>(
&read_line<test::stream>));
}
void
testBuffer()
{
flat_buffer b;
b.max_size(1000);
auto db = dynamic_buffer_ref(b);
BEAST_EXPECT(db.max_size() == 1000);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 0);
db.prepare(512);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 512);
db.commit(12);
BEAST_EXPECT(db.size() == 12);
BEAST_EXPECT(db.capacity() == 512);
BEAST_EXPECT(buffer_size(db.data()) == 12);
db.consume(12);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 512);
}
void run() override
{
testJavadocs();
testBuffer();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,dynamic_buffer_ref);
} // beast
} // boost
|
{"hexsha": "21a5fecb415781caacf6de3e7dc55606e330557c", "size": 1867, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/beast/core/dynamic_buffer_ref.cpp", "max_stars_repo_name": "DokuEnterprise/boost", "max_stars_repo_head_hexsha": "f2dc8be896eabd5f5da18d3b78abec2f5a04d4e5", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/beast/core/dynamic_buffer_ref.cpp", "max_issues_repo_name": "DokuEnterprise/boost", "max_issues_repo_head_hexsha": "f2dc8be896eabd5f5da18d3b78abec2f5a04d4e5", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/beast/core/dynamic_buffer_ref.cpp", "max_forks_repo_name": "DokuEnterprise/boost", "max_forks_repo_head_hexsha": "f2dc8be896eabd5f5da18d3b78abec2f5a04d4e5", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2297297297, "max_line_length": 79, "alphanum_fraction": 0.6395286556, "num_tokens": 476}
|
module Niancat
include("Users.jl")
include("Http.jl")
include("Gameface.jl")
include("Languages.jl")
include("Formatters.jl")
include("Persistence.jl")
include("Scores.jl")
include("GameServiceImpl.jl")
include("Instances.jl")
module Games
include("Games/NiancatGames.jl")
end
include("service.jl")
end # module
|
{"hexsha": "9d2db918d0aeb5ad5c894e44c8b6394ab41be900", "size": 316, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/Niancat.jl", "max_stars_repo_name": "erikedin/Niancat.jl", "max_stars_repo_head_hexsha": "e5c94bbbc957dae1a9896dadf285cd7e900dde7b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Niancat.jl", "max_issues_repo_name": "erikedin/Niancat.jl", "max_issues_repo_head_hexsha": "e5c94bbbc957dae1a9896dadf285cd7e900dde7b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-06-08T20:18:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-13T16:56:29.000Z", "max_forks_repo_path": "src/Niancat.jl", "max_forks_repo_name": "erikedin/Niancat.jl", "max_forks_repo_head_hexsha": "e5c94bbbc957dae1a9896dadf285cd7e900dde7b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.8, "max_line_length": 32, "alphanum_fraction": 0.746835443, "num_tokens": 87}
|
import numpy as np
from time import clock
from pygeonet_rasterio import *
from pygeonet_plot import *
# Skeleton by thresholding one grid measure e.g. flow or curvature
def compute_skeleton_by_single_threshold(inputArray, threshold):
skeletonArray = np.zeros((inputArray.shape))
skeletonArray[np.where(inputArray > threshold)] = 1
return skeletonArray
# Skeleton by thresholding two grid measures e.g. flow and curvature
def compute_skeleton_by_dual_threshold(inputArray1, inputArray2, threshold1, threshold2):
skeletonArray = np.zeros((inputArray1.shape))
mask1 = np.where(inputArray1> threshold1,1,False)
mask2 = np.where(inputArray2>threshold2,1,False)
skeletonArray= mask1*mask2
return skeletonArray
def main():
outfilepath = Parameters.geonetResultsDir
demName = Parameters.demFileName
curvature_filename = demName.split('.')[0]+'_curvature.tif'
fac_filename = demName.split('.')[0] + '_fac.tif'
thresholdCurvatureQQxx = 1
## outlets = [[2, 4, 9], [27, 26, 23]]
filteredDemArray = read_geotif_filteredDEM()
curvatureDemArray = read_geotif_generic(outfilepath, curvature_filename)
finiteCurvatureDemList = curvatureDemArray[np.isfinite(curvatureDemArray[:])]
curvatureDemMean = np.nanmean(finiteCurvatureDemList)
curvatureDemStdDevn = np.nanstd(finiteCurvatureDemList)
print 'Curvature mean: ', curvatureDemMean
print 'Curvature standard deviation: ', curvatureDemStdDevn
flowArray = read_geotif_generic(outfilepath, fac_filename)
flowArray[np.isnan(filteredDemArray)]=np.nan
flowMean = np.mean(flowArray[~np.isnan(flowArray[:])])
print 'Mean upstream flow: ', flowMean
# Define a skeleton based on flow alone
skeletonFromFlowArray = \
compute_skeleton_by_single_threshold(flowArray,\
defaults.flowThresholdForSkeleton)
# Define a skeleton based on curvature alone
skeletonFromCurvatureArray =\
compute_skeleton_by_single_threshold(curvatureDemArray,\
curvatureDemMean+
thresholdCurvatureQQxx*curvatureDemStdDevn)
# Writing the skeletonFromCurvatureArray array
outfilename = demName.split('.')[0]+'_curvatureskeleton.tif'
write_geotif_generic(skeletonFromCurvatureArray,\
outfilepath, outfilename)
# Define a skeleton based on curvature and flow
skeletonFromFlowAndCurvatureArray =\
compute_skeleton_by_dual_threshold(curvatureDemArray, flowArray, \
curvatureDemMean+thresholdCurvatureQQxx*curvatureDemStdDevn, \
defaults.flowThresholdForSkeleton)
# Writing the skeletonFromFlowAndCurvatureArray array
outfilename = demName.split('.')[0]+'_skeleton.tif'
write_geotif_generic(skeletonFromFlowAndCurvatureArray,\
outfilepath,outfilename)
# plotting only for testing purposes
try:
if defaults.doPlot == 1:
raster_point_plot(skeletonFromFlowAndCurvatureArray,outlets,
'Skeleton with outlets',cm.binary)
except NameError:
pass
if __name__ == '__main__':
t0 = clock()
main()
t1 = clock()
print "time taken to complete skeleton definition:", t1-t0, " seconds"
|
{"hexsha": "d54f14f065df4435923284eb08dcf3efe8981afa", "size": 3451, "ext": "py", "lang": "Python", "max_stars_repo_path": "pygeonet_skeleton_definition.py", "max_stars_repo_name": "uva-hydroinformatics/wetland_identification", "max_stars_repo_head_hexsha": "21b797eec1f4babe5c4fb53441bc256385dc2094", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-12-23T17:56:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-01T20:16:05.000Z", "max_issues_repo_path": "pygeonet_skeleton_definition.py", "max_issues_repo_name": "uva-hydroinformatics/wetland_identification", "max_issues_repo_head_hexsha": "21b797eec1f4babe5c4fb53441bc256385dc2094", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pygeonet_skeleton_definition.py", "max_forks_repo_name": "uva-hydroinformatics/wetland_identification", "max_forks_repo_head_hexsha": "21b797eec1f4babe5c4fb53441bc256385dc2094", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-28T21:48:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-28T21:48:40.000Z", "avg_line_length": 44.2435897436, "max_line_length": 102, "alphanum_fraction": 0.6803824978, "include": true, "reason": "import numpy", "num_tokens": 770}
|
(* This file is generated by Why3's Coq driver *)
(* Beware! Only edit allowed sections below *)
Require Import BuiltIn.
Require BuiltIn.
Require HighOrd.
Require int.Int.
Require int.Abs.
Require int.MinMax.
Require int.EuclideanDivision.
Require real.Real.
Require map.Map.
Axiom set : forall (a:Type), Type.
Parameter set_WhyType : forall (a:Type) {a_WT:WhyType a}, WhyType (set a).
Existing Instance set_WhyType.
Parameter mem: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> Prop.
Parameter infix_eqeq:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> Prop.
Axiom infix_eqeq_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (infix_eqeq s1 s2) -> forall (x:a),
(mem x s1) -> mem x s2.
Axiom infix_eqeq_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (infix_eqeq s1 s2) -> forall (x:a),
(mem x s2) -> mem x s1.
Axiom infix_eqeq_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (forall (x:a), (mem x s1) <-> (mem x s2)) ->
infix_eqeq s1 s2.
Axiom extensionality :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (infix_eqeq s1 s2) -> (s1 = s2).
Parameter subset:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> Prop.
Axiom subset_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (subset s1 s2) -> forall (x:a), (mem x s1) ->
mem x s2.
Axiom subset_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (forall (x:a), (mem x s1) -> mem x s2) ->
subset s1 s2.
Axiom subset_refl :
forall {a:Type} {a_WT:WhyType a}, forall (s:set a), subset s s.
Axiom subset_trans :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a) (s3:set a), (subset s1 s2) ->
(subset s2 s3) -> subset s1 s3.
Parameter is_empty: forall {a:Type} {a_WT:WhyType a}, (set a) -> Prop.
Axiom is_empty_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (is_empty s) -> forall (x:a), ~ (mem x s).
Axiom is_empty_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (forall (x:a), ~ (mem x s)) -> is_empty s.
Parameter empty: forall {a:Type} {a_WT:WhyType a}, set a.
Axiom empty_def : forall {a:Type} {a_WT:WhyType a}, is_empty (empty : set a).
Parameter add: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> set a.
Axiom add_spec :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (mem y (add x s)) ->
(y = x) \/ (mem y s).
Axiom add_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (y = x) -> mem y (add x s).
Axiom add_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (mem y s) -> mem y (add x s).
Parameter singleton: forall {a:Type} {a_WT:WhyType a}, a -> set a.
Axiom singleton_def :
forall {a:Type} {a_WT:WhyType a},
forall (x:a), ((singleton x) = (add x (empty : set a))).
Parameter remove: forall {a:Type} {a_WT:WhyType a}, a -> (set a) -> set a.
Axiom remove_spec :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (mem y (remove x s)) -> ~ (y = x).
Axiom remove_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (mem y (remove x s)) -> mem y s.
Axiom remove_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), forall (y:a), (~ (y = x) /\ (mem y s)) ->
mem y (remove x s).
Axiom add_remove :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), (mem x s) -> ((add x (remove x s)) = s).
Axiom remove_add :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), ((remove x (add x s)) = (remove x s)).
Axiom subset_remove :
forall {a:Type} {a_WT:WhyType a},
forall (x:a) (s:set a), subset (remove x s) s.
Parameter union:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.
Axiom union_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x (union s1 s2)) ->
(mem x s1) \/ (mem x s2).
Axiom union_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x s1) ->
mem x (union s1 s2).
Axiom union_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x s2) ->
mem x (union s1 s2).
Parameter inter:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.
Axiom inter_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x (inter s1 s2)) ->
mem x s1.
Axiom inter_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x (inter s1 s2)) ->
mem x s2.
Axiom inter_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), ((mem x s1) /\ (mem x s2)) ->
mem x (inter s1 s2).
Parameter diff:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.
Axiom diff_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x (diff s1 s2)) ->
mem x s1.
Axiom diff_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), (mem x (diff s1 s2)) ->
~ (mem x s2).
Axiom diff_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), forall (x:a), ((mem x s1) /\ ~ (mem x s2)) ->
mem x (diff s1 s2).
Axiom subset_diff :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), subset (diff s1 s2) s1.
Parameter choose: forall {a:Type} {a_WT:WhyType a}, (set a) -> a.
Axiom choose_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ~ (is_empty s) -> mem (choose s) s.
Parameter cardinal: forall {a:Type} {a_WT:WhyType a}, (set a) -> Z.
Axiom cardinal_nonneg :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) >= 0%Z)%Z.
Axiom cardinal_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) = 0%Z) -> is_empty s.
Axiom cardinal_empty1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (is_empty s) -> ((cardinal s) = 0%Z).
Axiom cardinal_add :
forall {a:Type} {a_WT:WhyType a},
forall (x:a), forall (s:set a), ~ (mem x s) ->
((cardinal (add x s)) = (1%Z + (cardinal s))%Z).
Axiom cardinal_remove :
forall {a:Type} {a_WT:WhyType a},
forall (x:a), forall (s:set a), (mem x s) ->
((cardinal s) = (1%Z + (cardinal (remove x s)))%Z).
Axiom cardinal_subset :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (subset s1 s2) ->
((cardinal s1) <= (cardinal s2))%Z.
Axiom subset_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a), (subset s1 s2) ->
((cardinal s1) = (cardinal s2)) -> infix_eqeq s1 s2.
Axiom cardinal1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) = 1%Z) -> forall (x:a), (mem x s) ->
(x = (choose s)).
Parameter filter:
forall {a:Type} {a_WT:WhyType a}, (a -> bool) -> (set a) -> set a.
Axiom filter_def :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (u:set a), forall (x:a), (mem x (filter p u)) ->
((p x) = true).
Axiom filter_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (u:set a), forall (x:a), (mem x (filter p u)) ->
mem x u.
Axiom filter_def2 :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (u:set a), forall (x:a),
(((p x) = true) /\ (mem x u)) -> mem x (filter p u).
Axiom filter_cardinal :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (u:set a), ((cardinal (filter p u)) <= (cardinal u))%Z.
Parameter map:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> set b.
Axiom map_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), forall (y:b), (mem y (map f u)) ->
exists x:a, (mem x u) /\ (y = (f x)).
Axiom map_def11 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), forall (y:b),
(exists x:a, (mem x u) /\ (y = (f x))) -> mem y (map f u).
Axiom map_def2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), forall (x:a), (mem x u) -> mem (f x) (map f u).
Axiom map_cardinal :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ((cardinal (map f u)) <= (cardinal u))%Z.
Parameter eq_e: forall {a:Type} {a_WT:WhyType a}, a -> a -> Prop.
Axiom eq_e_def :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a), (eq_e a1 a') -> (a1 = a').
Axiom eq_e_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a), (a1 = a') -> eq_e a1 a'.
Axiom assert_equal : True.
Axiom goal_comm :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (b:a), (a1 = b) -> (b = a1).
Parameter fir:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a* b)%type ->
a.
Parameter sec:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a* b)%type ->
b.
Axiom projections :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (o:(a* b)%type), (o = (fir o, sec o)).
Axiom get_fir :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (b1:b), ((fir (a1, b1)) = a1).
Axiom get_sec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (b1:b), ((sec (a1, b1)) = b1).
(* Why3 assumption *)
Inductive ref (a:Type) :=
| mk_ref : a -> ref a.
Axiom ref_WhyType : forall (a:Type) {a_WT:WhyType a}, WhyType (ref a).
Existing Instance ref_WhyType.
Arguments mk_ref {a}.
(* Why3 assumption *)
Definition contents {a:Type} {a_WT:WhyType a} (v:ref a) : a :=
match v with
| mk_ref x => x
end.
Parameter prefix_ex: forall {a:Type} {a_WT:WhyType a}, (ref a) -> a.
Axiom prefix_ex_def :
forall {a:Type} {a_WT:WhyType a},
forall (r:ref a), ((prefix_ex r) = (contents r)).
Axiom union_exchange :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), ~ (is_empty s') ->
((union (add (choose s') s) (remove (choose s') s')) = (union s s')).
Axiom get_filter :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (s:set a) (x:a), (mem x (filter p s)) ->
((p x) = true).
Axiom get_filter1 :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (s:set a) (x:a), (mem x (filter p s)) -> mem x s.
Axiom set_filter :
forall {a:Type} {a_WT:WhyType a},
forall (p:a -> bool) (s:set a) (x:a), ((p x) = true) -> (mem x s) ->
mem x (filter p s).
Axiom inter_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (is_empty s) -> is_empty (inter s s').
Axiom inter_empty_comm :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (is_empty s') -> is_empty (inter s s').
Axiom inter_sym :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), ((inter s s') = (inter s' s)).
Axiom union_sym :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), ((union s s') = (union s' s)).
Axiom union_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (is_empty s) -> ((union s s') = s').
Axiom union_comm :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (is_empty s') -> ((union s s') = s).
Axiom union_members :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), forall (a1:a), (mem a1 (union s s')) ->
~ (mem a1 s) -> mem a1 s'.
Axiom union_members1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), forall (a1:a), (mem a1 (union s s')) ->
~ (mem a1 s') -> mem a1 s.
Axiom union_alt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (e:a), (mem e (union s s')) -> ~ (mem e s) ->
mem e s'.
Axiom union_empty_comm :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (is_empty s') -> ((union s s') = s).
Axiom set_subset :
forall {a:Type} {a_WT:WhyType a},
forall (s':set a) (s:set a), (forall (e:a), (mem e s') -> mem e s) ->
subset s' s.
Axiom set_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (forall (e:a), ~ (mem e s)) -> (s = (empty : set a)).
Axiom set_empty1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (forall (e:a), ~ (mem e s)) -> is_empty s.
Axiom set_equal :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (forall (e:a), (mem e s) -> mem e s') ->
(forall (e:a), (mem e s') -> mem e s) -> (s = s').
Axiom get_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (s = (empty : set a)) -> forall (e:a), ~ (mem e s).
Axiom get_empty1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (s = (empty : set a)) -> is_empty s.
Axiom get_non_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ~ (is_empty s) -> exists e:a, mem e s.
Axiom set_non_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (exists e:a, mem e s) -> ~ (is_empty s).
Axiom set_non_empty1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (exists e:a, mem e s) -> ((cardinal s) > 0%Z)%Z.
Axiom set_pos_card_elt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (mem a1 s) -> ((cardinal s) > 0%Z)%Z.
Axiom union_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (x:a), ~ (mem x s') ->
((union s (add x s')) = (add x (union s s'))).
Axiom union_add_mem :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (x:a) (y:a), (mem x (add y (union s s'))) ->
~ (mem x s') -> ~ (mem x s) -> (x = y).
Axiom union_add_comm :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (x:a), ~ (mem x s') ->
((add x (union s s')) = (union s (add x s'))).
Axiom remove_add1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:a), ~ (mem x s) -> ((remove x (add x s)) = s).
Axiom add_remove1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:a), (mem x s) -> ((add x (remove x s)) = s).
Parameter p_injective:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> Prop.
Axiom p_injective_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), (p_injective f s) -> forall (e:a) (e':a),
(mem e s) -> (mem e' s) -> ~ (e = e') -> ~ ((f e) = (f e')).
Axiom p_injective_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
p_injective f s.
Axiom set_map_mem :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (b1:b),
(exists a1:a, (mem a1 s) /\ (b1 = (f a1))) -> mem b1 (map f s).
Axiom map_add :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (x:a), ~ (mem x s) ->
((map f (add x s)) = (add (f x) (map f s))).
Axiom map_eq :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b) (s:set a),
(forall (e:a), (mem e s) -> ((f e) = (g e))) -> ((map f s) = (map g s)).
Axiom injective_map_cardinal :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), (p_injective f s) ->
((cardinal (map f s)) = (cardinal s)).
Axiom set_map_mem_el :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (b1:b) (a1:a), (mem a1 s) -> (b1 = (f a1)) ->
mem b1 (map f s).
Axiom set_map_mem_el_gen :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (b1:b),
(exists a1:a, (mem a1 s) /\ (b1 = (f a1))) -> mem b1 (map f s).
Axiom map_antec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (b1:b), (mem b1 (map f s)) ->
exists a1:a, (mem a1 s) /\ (b1 = (f a1)).
Axiom map_antec_gen :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), forall (b1:b), (mem b1 (map f s)) ->
exists a1:a, (mem a1 s) /\ (b1 = (f a1)).
Axiom map_remove_choose :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b), (p_injective f s) ->
((map f (remove (choose s) s)) = (remove (f (choose s)) (map f s))).
Parameter antec_set:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(a -> b) -> b -> set a.
Parameter result:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
b -> a -> bool.
Axiom result_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (b1:b) (e:a),
(((result f b1) e) = true) <-> (eq_e (f e) b1).
Axiom antec_set_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
((antec_set s f b1) = (filter (result f b1) s)).
Parameter remove_s:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (set a) -> set a.
Parameter result1: forall {a:Type} {a_WT:WhyType a}, (set a) -> a -> bool.
Axiom result_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s':set a) (e:a), (((result1 s') e) = true) <-> ~ (mem e s').
Axiom remove_s_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (subset s' s) ->
((remove_s s s') = (filter (result1 s') s)).
Axiom remove_s_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (subset s' s) -> forall (e:a),
(mem e (remove_s s s')) -> mem e s.
Axiom remove_s_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (subset s' s) -> forall (e:a),
(mem e (remove_s s s')) -> ~ (mem e s').
Axiom remove_s_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), (subset s' s) -> forall (e:a),
((mem e s) /\ ~ (mem e s')) -> mem e (remove_s s s').
Parameter remove_antecs:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(a -> b) -> b -> set a.
Axiom remove_antecs_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
((remove_antecs s f b1) = (remove_s s (antec_set s f b1))).
Axiom remove_antecs_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) -> forall (e:a),
(mem e (remove_antecs s f b1)) -> mem e s.
Axiom remove_antecs_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) -> forall (e:a),
(mem e (remove_antecs s f b1)) -> ~ ((f e) = b1).
Axiom remove_antecs_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) -> forall (e:a),
((mem e s) /\ ~ ((f e) = b1)) -> mem e (remove_antecs s f b1).
Axiom remove_antecs_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
((cardinal (remove_antecs s f b1)) < (cardinal s))%Z.
Axiom map_remove_antec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (f:a -> b) (b1:b), (mem b1 (map f s)) ->
((map f (remove_antecs s f b1)) = (remove b1 (map f s))).
Axiom map_non_empty :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), ((cardinal s) > 0%Z)%Z ->
((cardinal (map f s)) > 0%Z)%Z.
Axiom non_empty_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), ((cardinal (map f s)) > 0%Z)%Z ->
((cardinal s) > 0%Z)%Z.
Parameter right_injections:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, a -> (set b) ->
set (a* b)%type.
Axiom right_injections_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), (is_empty s) ->
((right_injections a1 s) = (empty : set (a* b)%type)).
Axiom right_injections_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), ~ (is_empty s) ->
((right_injections a1 s) =
(add (a1, choose s) (right_injections a1 (remove (choose s) s)))).
Axiom right_injections_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b),
((cardinal (right_injections a1 s)) = (cardinal s)).
Axiom right_injections_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
(mem (a', b1) (right_injections a1 s)) -> (a' = a1).
Axiom right_injections_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
(mem (a', b1) (right_injections a1 s)) -> mem b1 s.
Axiom right_injections_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
((a' = a1) /\ (mem b1 s)) -> mem (a', b1) (right_injections a1 s).
Axiom right_injections_spec4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b),
((right_injections a1 s) = (map (fun (b1:b) => (a1, b1)) s)).
Parameter left_injections:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) -> b ->
set (a* b)%type.
Axiom left_injections_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), (is_empty s) ->
((left_injections s b1) = (empty : set (a* b)%type)).
Axiom left_injections_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), ~ (is_empty s) ->
((left_injections s b1) =
(add (choose s, b1) (left_injections (remove (choose s) s) b1))).
Axiom left_injections_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
(mem (a1, b') (left_injections s b1)) -> mem a1 s.
Axiom left_injections_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
(mem (a1, b') (left_injections s b1)) -> (b' = b1).
Axiom left_injections_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
((mem a1 s) /\ (b' = b1)) -> mem (a1, b') (left_injections s b1).
Axiom left_injections_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), ((cardinal (left_injections s b1)) = (cardinal s)).
Axiom left_injections_spec4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b),
((left_injections s b1) = (map (fun (a1:a) => (a1, b1)) s)).
Axiom right_injections_l :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b),
((cardinal (right_injections a1 s)) = (cardinal s)).
Axiom right_injections_l1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
(mem (a', b1) (right_injections a1 s)) -> (a' = a1).
Axiom right_injections_l2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
(mem (a', b1) (right_injections a1 s)) -> mem b1 s.
Axiom right_injections_l3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b), forall (a':a), forall (b1:b),
((a' = a1) /\ (mem b1 s)) -> mem (a', b1) (right_injections a1 s).
Axiom right_injections_l4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (s:set b),
((right_injections a1 s) = (map (fun (b1:b) => (a1, b1)) s)).
Axiom left_injections_l :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
(mem (a1, b') (left_injections s b1)) -> mem a1 s.
Axiom left_injections_l1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
(mem (a1, b') (left_injections s b1)) -> (b' = b1).
Axiom left_injections_l2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), forall (a1:a), forall (b':b),
((mem a1 s) /\ (b' = b1)) -> mem (a1, b') (left_injections s b1).
Axiom left_injections_l3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b), ((cardinal (left_injections s b1)) = (cardinal s)).
Axiom left_injections_l4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b),
((left_injections s b1) = (map (fun (a1:a) => (a1, b1)) s)).
Axiom disjoint_injections :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b) (c:b), ~ (b1 = c) ->
is_empty (inter (right_injections b1 s) (right_injections c s)).
Axiom disjoint_injections1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (b1:b) (c:b), ~ (b1 = c) ->
is_empty (inter (left_injections s b1) (left_injections s c)).
Axiom induction :
forall {a:Type} {a_WT:WhyType a},
forall (p:(set a) -> bool) (t:set a),
(forall (s:set a), (is_empty s) -> ((p s) = true)) ->
(forall (s:set a), ((p s) = true) -> forall (t1:a), ~ (mem t1 s) ->
((p (add t1 s)) = true)) ->
((p t) = true).
Axiom cardinal_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a),
((cardinal (union s s')) =
(((cardinal s) + (cardinal s'))%Z - (cardinal (inter s s')))%Z).
Axiom cardinal_sum_empty_inter :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a), ((inter s s') = (empty : set a)) ->
((cardinal (union s s')) = ((cardinal s) + (cardinal s'))%Z).
Parameter cartesian_product:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(set b) -> set (a* b)%type.
Axiom cartesian_product_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b),
((cardinal (cartesian_product s1 s2)) = ((cardinal s1) * (cardinal s2))%Z).
Axiom cartesian_product_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (a1:a), forall (b1:b),
(mem (a1, b1) (cartesian_product s1 s2)) -> mem a1 s1.
Axiom cartesian_product_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (a1:a), forall (b1:b),
(mem (a1, b1) (cartesian_product s1 s2)) -> mem b1 s2.
Axiom cartesian_product_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (a1:a), forall (b1:b),
((mem a1 s1) /\ (mem b1 s2)) -> mem (a1, b1) (cartesian_product s1 s2).
Axiom cartesian_product_spec4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type),
(mem o (cartesian_product s1 s2)) -> mem (fir o) s1.
Axiom cartesian_product_spec5 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type),
(mem o (cartesian_product s1 s2)) -> mem (sec o) s2.
Axiom cartesian_product_spec6 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type),
((mem (fir o) s1) /\ (mem (sec o) s2)) -> mem o (cartesian_product s1 s2).
Parameter commute:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a* b)%type ->
(b* a)%type.
Axiom commute_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (o:(a* b)%type), forall (x:a) (x1:b), (o = (x, x1)) ->
((commute o) = (x1, x)).
Axiom commute_inj :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b), ~ (a1 = a') ->
~ ((commute (a1, b1)) = (commute (a', b'))).
Axiom commute_inj1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b), ~ (b1 = b') ->
~ ((commute (a1, b1)) = (commute (a', b'))).
Axiom mem_cartesian_product :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (a1:a) (b1:b), (mem a1 s1) -> (mem b1 s2) ->
mem (a1, b1) (cartesian_product s1 s2).
Axiom commute_inj_gen :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b),
p_injective (fun (y0:(a* b)%type) => (commute y0))
(cartesian_product s1 s2).
Parameter commute_product:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(set b) -> set (b* a)%type.
Axiom commute_product_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b),
((commute_product s1 s2) =
(map (fun (y0:(a* b)%type) => (commute y0)) (cartesian_product s1 s2))).
Axiom commute_product_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b),
((commute_product s1 s2) = (cartesian_product s2 s1)).
Parameter commute_product_el:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(set b) -> set (b* a)%type.
Axiom commute_product_el_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b),
((commute_product_el s1 s2) =
(map (fun (y0:(a* b)%type) => (commute y0)) (cartesian_product s1 s2))).
Axiom commute_product_el_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> (mem o (cartesian_product s1 s2)) -> mem x s1.
Axiom commute_product_el_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> (mem o (cartesian_product s1 s2)) -> mem x1 s2.
Axiom commute_product_el_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> ((mem x s1) /\ (mem x1 s2)) ->
mem o (cartesian_product s1 s2).
Axiom commute_product_el_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> ((mem x s1) /\ (mem x1 s2)) ->
mem (x1, x) (commute_product_el s1 s2).
Axiom commute_product_el_spec4 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> (mem (x1, x) (commute_product_el s1 s2)) -> mem x s1.
Axiom commute_product_el_spec5 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), forall (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> (mem (x1, x) (commute_product_el s1 s2)) -> mem x1 s2.
Axiom cartesian_product_union :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (s3:set b),
((cartesian_product s1 (union s2 s3)) =
(union (cartesian_product s1 s2) (cartesian_product s1 s3))).
Axiom cartesian_union_product :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set a) (s3:set b),
((cartesian_product (union s1 s2) s3) =
(union (cartesian_product s1 s3) (cartesian_product s2 s3))).
Axiom cartesian_product_cardone_r :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), ((cardinal s1) = 1%Z) ->
infix_eqeq (cartesian_product s1 s2) (right_injections (choose s1) s2).
Axiom cartesian_product_cardone_r1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), ((cardinal s1) = 1%Z) ->
infix_eqeq (cartesian_product s1 s2)
(map (fun (e2:b) => (choose s1, e2)) s2).
Axiom cartesian_product_cardone_l :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), ((cardinal s2) = 1%Z) ->
infix_eqeq (cartesian_product s1 s2) (left_injections s1 (choose s2)).
Axiom cartesian_product_cardone_l1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b), ((cardinal s2) = 1%Z) ->
infix_eqeq (cartesian_product s1 s2)
(map (fun (e1:a) => (e1, choose s2)) s1).
Axiom disjoint_cartesian_product_l :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set a) (s3:set b),
((inter s1 s2) = (empty : set a)) ->
((inter (cartesian_product s1 s3) (cartesian_product s2 s3)) =
(empty : set (a* b)%type)).
Axiom disjoint_cartesian_product_r :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (s3:set b),
((inter s2 s3) = (empty : set b)) ->
((inter (cartesian_product s1 s2) (cartesian_product s1 s3)) =
(empty : set (a* b)%type)).
Parameter to_set: forall {a:Type} {a_WT:WhyType a}, a -> set a.
Axiom to_set_def :
forall {a:Type} {a_WT:WhyType a},
forall (e:a), ((to_set e) = (add e (empty : set a))).
Axiom to_set_spec :
forall {a:Type} {a_WT:WhyType a},
forall (e:a), ((cardinal (to_set e)) = 1%Z).
Axiom to_set_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (e:a), forall (b:a), (mem b (to_set e)) -> (b = e).
Parameter to_fset: Z -> Z -> set Z.
Axiom to_fset_spec :
forall (i:Z) (j:Z), (i < j)%Z -> ((cardinal (to_fset i j)) = (j - i)%Z).
Axiom to_fset_spec1 :
forall (i:Z) (j:Z), (j <= i)%Z -> is_empty (to_fset i j).
Axiom to_fset_spec2 :
forall (i:Z) (j:Z), forall (k:Z), (mem k (to_fset i j)) -> (i <= k)%Z.
Axiom to_fset_spec3 :
forall (i:Z) (j:Z), forall (k:Z), (mem k (to_fset i j)) -> (k < j)%Z.
Axiom to_fset_spec4 :
forall (i:Z) (j:Z), forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) ->
mem k (to_fset i j).
Axiom to_fset_unit_ext :
forall (i:Z) (j:Z), (i < j)%Z ->
((to_fset i j) = (add i (to_fset (i + 1%Z)%Z j))).
Axiom to_fset_ext :
forall (i:Z) (i':Z) (j:Z), ((i <= i')%Z /\ (i' <= j)%Z) ->
((to_fset i j) = (union (to_fset i i') (to_fset i' j))).
Axiom card_fset :
forall (n:Z), (0%Z <= n)%Z -> ((cardinal (to_fset 0%Z n)) = n).
Parameter op: forall {im:Type} {im_WT:WhyType im}, im -> im -> im.
Parameter po: forall {im:Type} {im_WT:WhyType im}, im -> im -> im.
Parameter inver: forall {im:Type} {im_WT:WhyType im}, im -> im.
Parameter op_neutral_left:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im -> Prop.
Axiom op_neutral_left_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im), (op_neutral_left op1 neutral) ->
forall (e:im), (((op1 neutral) e) = e).
Axiom op_neutral_left_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im),
(forall (e:im), (((op1 neutral) e) = e)) -> op_neutral_left op1 neutral.
Parameter op_neutral_right:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im -> Prop.
Axiom op_neutral_right_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im), (op_neutral_right op1 neutral) ->
forall (e:im), (((op1 e) neutral) = e).
Axiom op_neutral_right_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im),
(forall (e:im), (((op1 e) neutral) = e)) -> op_neutral_right op1 neutral.
Parameter op_assoc:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> Prop.
Axiom op_assoc_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (op_assoc op1) -> forall (a:im) (b:im) (c:im),
(((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c))).
Axiom op_assoc_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im),
(forall (a:im) (b:im) (c:im),
(((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c)))) ->
op_assoc op1.
Parameter op_neutral_left_comm:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im -> Prop.
Axiom op_neutral_left_comm_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im),
(op_neutral_left_comm op1 neutral) -> forall (a:im),
(forall (b:im), (((op1 a) b) = b)) -> (a = neutral).
Axiom op_neutral_left_comm_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral:im),
(forall (a:im), (forall (b:im), (((op1 a) b) = b)) -> (a = neutral)) ->
op_neutral_left_comm op1 neutral.
Parameter commut:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> Prop.
Axiom commut_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (commut op1) -> forall (a:im) (b:im),
(((op1 a) b) = ((op1 b) a)).
Axiom commut_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im),
(forall (a:im) (b:im), (((op1 a) b) = ((op1 b) a))) -> commut op1.
Parameter assoc:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> Prop.
Axiom assoc_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (assoc op1) -> forall (a:im) (b:im) (c:im),
(((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c))).
Axiom assoc_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im),
(forall (a:im) (b:im) (c:im),
(((op1 ((op1 a) b)) c) = ((op1 a) ((op1 b) c)))) ->
assoc op1.
Parameter opposite_n:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) ->
(im -> im -> im) -> im -> Prop.
Axiom opposite_n_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral:im),
(opposite_n op1 po1 neutral) -> forall (a:im), (((po1 a) a) = neutral).
Axiom opposite_n_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral:im),
(forall (a:im), (((po1 a) a) = neutral)) -> opposite_n op1 po1 neutral.
Parameter inverse:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) ->
(im -> im -> im) -> (im -> im) -> Prop.
Axiom inverse_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (inver1:im -> im),
(inverse op1 po1 inver1) -> forall (a:im) (b:im),
(((po1 a) b) = ((op1 a) (inver1 b))).
Axiom inverse_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (inver1:im -> im),
(forall (a:im) (b:im), (((po1 a) b) = ((op1 a) (inver1 b)))) ->
inverse op1 po1 inver1.
Parameter opposite:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) ->
(im -> im -> im) -> Prop.
Axiom opposite_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im), (opposite op1 po1) ->
forall (a:im) (b:im), (((op1 ((po1 a) b)) b) = a).
Axiom opposite_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im),
(forall (a:im) (b:im), (((op1 ((po1 a) b)) b) = a)) -> opposite op1 po1.
Parameter opposite_com:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) ->
(im -> im -> im) -> Prop.
Axiom opposite_com_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im), (opposite_com op1 po1) ->
forall (a:im) (b:im), (((po1 ((op1 a) b)) b) = a).
Axiom opposite_com_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im),
(forall (a:im) (b:im), (((po1 ((op1 a) b)) b) = a)) -> opposite_com op1 po1.
Axiom refl :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (a:im) (b:im), (commut op1) ->
(((op1 a) b) = ((op1 b) a)).
Parameter neutral:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im -> Prop.
Axiom neutral_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neut:im), (neutral op1 neut) ->
op_neutral_left op1 neut.
Axiom neutral_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neut:im), (neutral op1 neut) ->
op_neutral_right op1 neut.
Axiom neutral_def2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neut:im), (neutral op1 neut) -> op_assoc op1.
Axiom neutral_def3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neut:im),
((op_neutral_left op1 neut) /\
((op_neutral_right op1 neut) /\ (op_assoc op1))) ->
neutral op1 neut.
Axiom set_neutral :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neut:im), (op_neutral_left op1 neut) ->
(op_neutral_right op1 neut) -> (op_assoc op1) -> neutral op1 neut.
Parameter has_neutral:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> Prop.
Axiom has_neutral_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (has_neutral op1) ->
exists e:im, neutral op1 e.
Axiom has_neutral_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (exists e:im, neutral op1 e) ->
has_neutral op1.
Parameter iterates:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im -> Prop.
Axiom iterates_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im), (iterates op1 neutral1) ->
op_neutral_left op1 neutral1.
Axiom iterates_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im), (iterates op1 neutral1) ->
op_neutral_right op1 neutral1.
Axiom iterates_def2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im), (iterates op1 neutral1) ->
op_assoc op1.
Axiom iterates_def3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im),
((op_neutral_left op1 neutral1) /\
((op_neutral_right op1 neutral1) /\ (op_assoc op1))) ->
iterates op1 neutral1.
Parameter iterable:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> Prop.
Axiom iterable_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (iterable op1) -> exists e:im, iterates op1 e.
Axiom iterable_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), (exists e:im, iterates op1 e) -> iterable op1.
Axiom iterates_ :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im),
(op_neutral_left op1 neutral1) -> (op_neutral_right op1 neutral1) ->
(op_assoc op1) -> iterates op1 neutral1.
Axiom iterates_1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (neutral1:im),
(op_neutral_left op1 neutral1) -> (op_neutral_right op1 neutral1) ->
(op_assoc op1) -> iterable op1.
Parameter neutral_elt:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> im.
Axiom neutral_elt_spec :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), forall (e:im), (neutral op1 e) ->
((neutral_elt op1) = e).
Axiom neutral_elt_spec1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), forall (e:im), ((neutral_elt op1) = e) ->
neutral op1 e.
Parameter inverse_tuple:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) ->
(im -> im -> im) -> im -> Prop.
Axiom inverse_tuple_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral1:im),
(inverse_tuple op1 po1 neutral1) -> opposite_n op1 po1 neutral1.
Axiom inverse_tuple_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral1:im),
(inverse_tuple op1 po1 neutral1) -> opposite op1 po1.
Axiom inverse_tuple_def2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral1:im),
(inverse_tuple op1 po1 neutral1) -> opposite_com op1 po1.
Axiom inverse_tuple_def3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (neutral1:im),
((opposite_n op1 po1 neutral1) /\
((opposite op1 po1) /\ (opposite_com op1 po1))) ->
inverse_tuple op1 po1 neutral1.
Parameter iterate:
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
(im -> im -> im) -> (set a) -> (a -> im) -> im.
Axiom Iterate_def_empty :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), forall (s:set a), forall (f:a -> im),
(commut op1) -> (iterable op1) -> (is_empty s) ->
((iterate op1 (empty : set a) f) = (neutral_elt op1)).
Axiom Iterate_one :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), forall (s:set a), forall (f:a -> im),
forall (x:a), (is_empty s) -> (commut op1) ->
((iterate op1 (add x s) f) = (f x)).
Axiom Iterate_add :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im), forall (s:set a), forall (f:a -> im),
forall (x:a), ((cardinal s) > 0%Z)%Z -> (commut op1) -> ~ (mem x s) ->
((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).
Axiom minus_zero :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im), (iterable op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) ->
(((po1 a) (neutral_elt op1)) = a).
Axiom unic :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im) (b:im) (c:im),
(iterable op1) -> (commut op1) -> (((op1 a) b) = ((op1 a) c)) ->
(inverse_tuple op1 po1 (neutral_elt op1)) -> (b = c).
Axiom substract_comm :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im) (b:im),
(iterable op1) -> (commut op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) -> (((po1 ((op1 a) b)) a) = b).
Axiom substract_comm1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im) (b:im),
(iterable op1) -> (commut op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) -> (((po1 ((op1 b) a)) a) = b).
Axiom substract_comm2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im) (b:im) (c:im),
(iterable op1) -> (commut op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) ->
(((po1 a) ((po1 b) c)) = ((op1 ((po1 a) b)) c)).
Axiom substract_comm3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (a:im) (b:im) (c:im),
(iterable op1) -> (commut op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) ->
(((po1 ((op1 a) b)) c) = ((op1 a) ((po1 b) c))).
Parameter int_iterate:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> (Z -> im) ->
Z -> Z -> im.
Axiom int_iterate_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
(j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1)).
Axiom int_iterate_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
~ (j <= i)%Z -> (j = (i + 1%Z)%Z) -> ((int_iterate op1 f i j) = (f i)).
Axiom int_iterate_def2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
~ (j <= i)%Z -> ~ (j = (i + 1%Z)%Z) ->
((int_iterate op1 f i j) = ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))).
Axiom int_iterate_def3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
(j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1)).
Axiom int_iterate_def4 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
~ (j <= i)%Z -> (j = (i + 1%Z)%Z) -> ((int_iterate op1 f i j) = (f i)).
Axiom int_iterate_def5 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
~ (j <= i)%Z -> ~ (j = (i + 1%Z)%Z) ->
((int_iterate op1 f i j) = ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))).
Axiom int_iterate_spec :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
(j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1)).
Axiom int_iterate_spec1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
(j = (i + 1%Z)%Z) ->
((int_iterate op1 f i j) = ((op1 (f i)) (neutral_elt op1))).
Axiom int_iterate_spec2 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
(j <= i)%Z -> ((int_iterate op1 f i j) = (neutral_elt op1)).
Axiom int_iterate_spec3 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
(j = (i + 1%Z)%Z) ->
((int_iterate op1 f i j) = ((op1 (f i)) (neutral_elt op1))).
Parameter int_int_iterate:
forall {im:Type} {im_WT:WhyType im}, (im -> im -> im) -> (Z -> Z -> im) ->
Z -> Z -> Z -> Z -> im.
Axiom int_int_iterate_def :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> Z -> im) (i:Z) (j:Z) (k:Z) (l:Z),
(iterable op1) -> (j <= i)%Z ->
((int_int_iterate op1 f i j k l) = (neutral_elt op1)).
Axiom int_int_iterate_def1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> Z -> im) (i:Z) (j:Z) (k:Z) (l:Z),
(iterable op1) -> ~ (j <= i)%Z ->
((int_int_iterate op1 f i j k l) =
((op1 (int_iterate op1 (f i) k l))
(int_int_iterate op1 f (i + 1%Z)%Z j k l))).
Parameter element: forall {a:Type} {a_WT:WhyType a}, (set a) -> a.
Axiom element_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) = 1%Z) -> ((element s) = (choose s)).
Axiom cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
((cardinal s) > 0%Z)%Z -> ((cardinal s) = 1%Z).
Axiom cardone1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
((cardinal s) > 0%Z)%Z -> ((element s) = a1).
Axiom set_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) > 0%Z)%Z ->
(exists a1:a, forall (b:a), (mem b s) <-> (b = a1)) -> ((cardinal s) = 1%Z).
Axiom get_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), ((cardinal s) = 1%Z) ->
exists a1:a, forall (b:a), (mem b s) <-> (b = a1).
Axiom set_cardone_elt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
((cardinal s) = 1%Z).
Axiom set_cardone_elt1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
((element s) = a1).
Axiom set_cardone_elt_ :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (a1:a), (forall (b:a), (mem b s) <-> (b = a1)) ->
((cardinal s) = 1%Z).
Axiom cardzero :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a), (forall (b:a), ~ (mem b s)) -> ((cardinal s) = 0%Z).
Parameter p_injective_in:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> Prop.
Axiom p_injective_in_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_injective_in f s s') ->
forall (e:a), (mem e s) -> mem (f e) s'.
Axiom p_injective_in_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_injective_in f s s') ->
forall (e:a), (mem e s) -> forall (e1:a) (e':a), (mem e1 s) ->
(mem e' s) -> ~ (e1 = e') -> ~ ((f e1) = (f e')).
Axiom p_injective_in_def2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
(forall (e:a), (mem e s) ->
(mem (f e) s') /\
forall (e1:a) (e':a), (mem e1 s) -> (mem e' s) -> ~ (e1 = e') ->
~ ((f e1) = (f e'))) ->
p_injective_in f s s'.
Parameter equal_func:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(a -> b) -> Prop.
Axiom equal_func_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b), (equal_func f g) -> forall (e:a),
((f e) = (g e)).
Axiom equal_func_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b), (forall (e:a), ((f e) = (g e))) ->
equal_func f g.
Axiom set_equal_func :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b), (forall (e:a), ((f e) = (g e))) -> (f = g).
Axiom get_equal_func :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b), (equal_func f g) -> forall (e:a),
((f e) = (g e)).
Axiom set_injective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
p_injective f s.
Parameter image:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> set b.
Axiom image_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), ((image f s) = (map f s)).
Axiom image_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), forall (a1:b), (mem a1 (image f s)) ->
exists antec_a:a, (mem antec_a s) /\ (a1 = (f antec_a)).
Axiom image_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), forall (a1:b),
(exists antec_a:a, (mem antec_a s) /\ (a1 = (f antec_a))) ->
mem a1 (image f s).
Axiom card_image :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), ((cardinal (image f s)) <= (cardinal s))%Z.
Axiom card_image_injective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), (p_injective f s) ->
((cardinal (image f s)) = (cardinal s)).
Axiom get_injective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), (p_injective f s) -> forall (e:a) (e':a),
(mem e s) -> (mem e' s) -> ~ (e = e') -> ~ ((f e) = (f e')).
Axiom set_injective_in :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
(forall (e:a), (mem e s) -> mem (f e) s') ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
p_injective f s.
Axiom get_injective_in :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_injective_in f s s') ->
forall (e:a), (mem e s) -> mem (f e) s'.
Axiom get_injective_in1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_injective_in f s s') ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e')).
Parameter p_surjective:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> Prop.
Axiom p_surjective_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
forall (e:a), (mem e s) -> mem (f e) s'.
Axiom p_surjective_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e').
Axiom p_surjective_def2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
((forall (e:a), (mem e s) -> mem (f e) s') /\
forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
p_surjective f s s'.
Axiom set_surjective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
(forall (e:a), (mem e s) -> mem (f e) s') ->
(forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
p_surjective f s s'.
Axiom get_surjective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
forall (e:a), (mem e s) -> mem (f e) s'.
Axiom get_surjective1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e').
Axiom image_surjective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_surjective f s s') ->
((image f s) = s').
Parameter p_bijective:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> Prop.
Axiom p_bijective_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_injective_in f s s'.
Axiom p_bijective_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_surjective f s s'.
Axiom p_bijective_def2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
((p_injective_in f s s') /\ (p_surjective f s s')) -> p_bijective f s s'.
Axiom bijective_is_injective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_injective f s.
Axiom bijective_is_surjective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_surjective f s s'.
Axiom set_bijective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
(forall (e:a), (mem e s) -> mem (f e) s') ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
p_bijective f s s'.
Axiom set_bijective1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b),
(forall (e:a), (mem e s) -> mem (f e) s') ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e')) ->
((map f s) = s').
Axiom bijectivity_is_transitive :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{c:Type} {c_WT:WhyType c},
forall (f:a -> b) (g:b -> c) (s:set a) (s':set b) (s'':set c),
(p_bijective f s s') -> (p_bijective g s' s'') ->
p_bijective (fun (k:a) => (g (f k))) s s''.
Axiom bijective_image :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> a) (s:set a) (s':set a), (p_bijective f s s') ->
((cardinal s) = (cardinal s')).
Axiom bijective_image1 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> a) (s:set a) (s':set a), (p_bijective f s s') ->
(s' = (image f s)).
Axiom get_bijective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (e:a), (mem e s) -> mem (f e) s'.
Axiom get_bijective1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e')).
Axiom get_bijective2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (e':b), (mem e' s') -> exists e:a, (mem e s) /\ ((f e) = e').
Axiom get_bijective3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
((cardinal s) = (cardinal s')).
Axiom bijective_eq :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
(forall (e:a), (mem e s) -> ((f e) = (g e))) -> p_bijective g s s'.
Axiom bijective_eq_gen :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (g:a -> b), (forall (e:a), (mem e s) -> ((f e) = (g e))) ->
p_bijective g s s'.
Axiom bij_equal_card :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a), ((cardinal s) = (cardinal (map f s))) ->
p_bijective f s (map f s).
Axiom set_bijective_auto :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> a) (s:set a), (forall (e:a), (mem e s) -> mem (f e) s) ->
(forall (e':a), (mem e' s) -> exists e:a, (mem e s) /\ ((f e) = e')) ->
p_bijective f s s.
Parameter p_id: forall {a:Type} {a_WT:WhyType a}, a -> a.
Axiom p_id_def :
forall {a:Type} {a_WT:WhyType a}, forall (a1:a), ((p_id a1) = a1).
Parameter const:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, a -> b -> a.
Axiom const_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (b1:b), ((const a1 b1) = a1).
Axiom iterate_empty :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (t:a -> im), (is_empty s) ->
(commut op1) -> (iterable op1) -> ((iterate op1 s t) = (neutral_elt op1)).
Axiom iterate_one :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (t:a -> im), ((cardinal s) = 1%Z) ->
(commut op1) -> ((iterate op1 s t) = (t (choose s))).
Axiom iterate_add :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (x:a), (commut op1) ->
(iterable op1) -> ~ (mem x s) ->
((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).
Axiom iterate_add_ :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (x:a), (commut op1) ->
~ (mem x s) -> ~ (is_empty s) ->
((iterate op1 (add x s) f) = ((op1 (f x)) (iterate op1 s f))).
Axiom iterate_remove :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (x:a), (commut op1) ->
(iterable op1) ->
(inverse_tuple op1 (fun (y0:im) (y1:im) => (po y0 y1)) (neutral_elt op1)) ->
(mem x s) -> ((iterate op1 (remove x s) f) = (po (iterate op1 s f) (f x))).
Axiom iterate_def_choose :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im),
~ ((cardinal s) = 1%Z) -> (commut op1) -> ~ (is_empty s) ->
((iterate op1 s f) =
((op1 (f (choose s))) (iterate op1 (remove (choose s) s) f))).
Axiom iterate_def_choose1 :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im), (iterable op1) ->
(commut op1) -> ~ (is_empty s) ->
((iterate op1 s f) =
((op1 (f (choose s))) (iterate op1 (remove (choose s) s) f))).
Axiom choose_any :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (t:a), (iterable op1) ->
(commut op1) -> (mem t s) ->
((iterate op1 s f) = ((op1 (f t)) (iterate op1 (remove t s) f))).
Axiom iterate_comp_iterate :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s1:set a) (f:a -> im) (g:a -> im),
(iterable op1) -> (commut op1) -> (assoc op1) ->
((iterate op1 s1 (fun (k:a) => ((op1 (f k)) (g k)))) =
((op1 (iterate op1 s1 (fun (k:a) => (f k))))
(iterate op1 s1 (fun (k:a) => (g k))))).
Axiom iterate_comp_iterate_com :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s1:set a) (f:a -> im) (g:a -> im),
(iterable op1) -> (commut op1) ->
(((op1 (iterate op1 s1 (fun (k:a) => (f k))))
(iterate op1 s1 (fun (k:a) => (g k))))
= (iterate op1 s1 (fun (k:a) => ((op1 (f k)) (g k))))).
Axiom iterate_transitivity :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (po1:im -> im -> im) (s1:set a) (s2:set a)
(f:a -> im),
(iterable op1) -> (commut op1) ->
(inverse_tuple op1 po1 (neutral_elt op1)) ->
((iterate op1 (union s1 s2) f) =
((po1 ((op1 (iterate op1 s1 f)) (iterate op1 s2 f)))
(iterate op1 (inter s1 s2) f))).
Axiom iterate_disjoint_transitivity :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s1:set a) (s2:set a) (t:a -> im),
(iterable op1) -> (commut op1) -> ((inter s1 s2) = (empty : set a)) ->
((iterate op1 (union s1 s2) t) =
((op1 (iterate op1 s1 t)) (iterate op1 s2 t))).
Axiom iterate_eq :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (g:a -> im),
(forall (x:a), (mem x s) -> ((f x) = (g x))) -> (commut op1) ->
~ (is_empty s) -> ((iterate op1 s f) = (iterate op1 s g)).
Axiom iterate_eq1 :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f:a -> im) (g:a -> im),
(forall (x:a), (mem x s) -> ((f x) = (g x))) -> (commut op1) ->
(iterable op1) -> ((iterate op1 s f) = (iterate op1 s g)).
Axiom iterate_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set b) (f:b -> a) (t:a -> im),
~ (is_empty s) -> (commut op1) -> (p_injective f s) ->
((iterate op1 (map f s) t) = (iterate op1 s (fun (b1:b) => (t (f b1))))).
Axiom iterate_map1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set b) (f:b -> a) (t:a -> im),
(iterable op1) -> (commut op1) -> (p_injective f s) ->
((iterate op1 (map f s) t) = (iterate op1 s (fun (b1:b) => (t (f b1))))).
Axiom iterate_cardone :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (t:a -> im), (iterable op1) ->
(commut op1) -> ((cardinal s) = 1%Z) ->
((iterate op1 s t) = (t (element s))).
Axiom iterate_cardzero :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (t:a -> im), (commut op1) ->
(iterable op1) -> ((cardinal s) = 0%Z) ->
((iterate op1 s t) = (neutral_elt op1)).
Axiom injec_iterate :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (a1:a) (s:set b) (f:a -> b -> im),
(iterable op1) -> (commut op1) ->
((iterate op1 s (f a1)) =
(iterate op1 (cartesian_product (to_set a1) s)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).
Axiom iterate_cartesian_product :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s1:set a) (s2:set b) (f:a -> b -> im),
(iterable op1) -> (commut op1) ->
((iterate op1 s1 (fun (a1:a) => (iterate op1 s2 (f a1)))) =
(iterate op1 (cartesian_product s1 s2)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).
Axiom iterate_eq_func :
forall {a:Type} {a_WT:WhyType a} {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (s:set a) (f1:a -> im) (f2:a -> im),
(commut op1) -> (iterable op1) -> (p_injective f1 s) ->
(p_injective f2 s) -> ((map f1 s) = (map f2 s)) ->
((iterate op1 s f1) = (iterate op1 s f2)).
Axiom int_iterate_def_empty :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (j <= i)%Z ->
(iterable op1) -> ((int_iterate op1 f i j) = (neutral_elt op1)).
Axiom int_iterate_def_plus_one :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (i < j)%Z ->
~ ((i + 1%Z)%Z = j) ->
((int_iterate op1 f i j) = ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))).
Axiom int_iterate_def_plus_one1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (i < j)%Z ->
(iterable op1) ->
((int_iterate op1 f i j) = ((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j))).
Axiom int_iterate_cardone :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
((int_iterate op1 f i j) = (f i)).
Axiom int_iterate_def_plus_one_com :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (i < j)%Z ->
~ (j = (i + 1%Z)%Z) ->
(((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j)) = (int_iterate op1 f i j)).
Axiom int_iterate_def_plus_one_com1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (i < j)%Z ->
(iterable op1) ->
(((op1 (f i)) (int_iterate op1 f (i + 1%Z)%Z j)) = (int_iterate op1 f i j)).
Axiom int_iterate_to_iterate :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), ~ (j <= i)%Z ->
(commut op1) -> ((int_iterate op1 f i j) = (iterate op1 (to_fset i j) f)).
Axiom int_iterate_to_iterate1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
(commut op1) -> ((int_iterate op1 f i j) = (iterate op1 (to_fset i j) f)).
Axiom int_iterate_right_extension :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (iterable op1) ->
(i < j)%Z ->
((int_iterate op1 f i j) =
((op1 (int_iterate op1 f i (j - 1%Z)%Z)) (f (j - 1%Z)%Z))).
Axiom int_iterate_right_extension_ :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z), (assoc op1) ->
((i + 1%Z)%Z < j)%Z ->
((int_iterate op1 f i j) =
((op1 (int_iterate op1 f i (j - 1%Z)%Z)) (f (j - 1%Z)%Z))).
Axiom int_iterate_transitivity :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (k:Z) (j:Z),
(iterable op1) -> (iterable op1) ->
(op_neutral_left op1 (neutral_elt op1)) -> ((i <= k)%Z /\ (k <= j)%Z) ->
((int_iterate op1 f i j) =
((op1 (int_iterate op1 f i k)) (int_iterate op1 f k j))).
Axiom int_iterate_transitivity_ :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (k:Z) (j:Z),
(op_neutral_left op1 (neutral_elt op1)) -> ((i < k)%Z /\ (k < j)%Z) ->
((int_iterate op1 f i j) =
((op1 (int_iterate op1 f i k)) (int_iterate op1 f k j))).
Axiom int_iterate_comp_iterate :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (g:Z -> im) (i:Z) (j:Z),
(iterable op1) -> (op_neutral_right op1 (neutral_elt op1)) ->
(commut op1) ->
((int_iterate op1 (fun (k:Z) => ((op1 (f k)) (g k))) i j) =
((op1 (int_iterate op1 f i j)) (int_iterate op1 g i j))).
Axiom int_iterate_attr_no_f :
forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t1:Z -> im1)
(t2:Z -> im2) (f:im1 -> im2) (i:Z) (j:Z),
(forall (x:Z), forall (y:im1),
(((op2 (t2 x)) (f y)) = (f ((op1 (t1 x)) y)))) ->
((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
(iterable op2) -> (forall (i1:Z), ((f (t1 i1)) = (t2 i1))) ->
((int_iterate op2 t2 i j) = (f (int_iterate op1 t1 i j))).
Axiom int_iterate_attr :
forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t:Z -> im1)
(f:im1 -> im2) (i:Z) (j:Z),
(forall (x:Z), forall (y:im1),
(((op2 (f (t x))) (f y)) = (f ((op1 (t x)) y)))) ->
((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
(iterable op2) ->
((int_iterate op2 (fun (e:Z) => (f (t e))) i j) =
(f (int_iterate op1 t i j))).
Axiom int_iterate_attr_comm :
forall {im1:Type} {im1_WT:WhyType im1} {im2:Type} {im2_WT:WhyType im2},
forall (op1:im1 -> im1 -> im1) (op2:im2 -> im2 -> im2) (t:Z -> im1)
(f:im1 -> im2) (i:Z) (j:Z),
(forall (x:Z), forall (y:im1),
(((op2 (f (t x))) (f y)) = (f ((op1 (t x)) y)))) ->
((f (neutral_elt op1)) = (neutral_elt op2)) -> (iterable op1) ->
(iterable op2) ->
((f (int_iterate op1 t i j)) =
(int_iterate op2 (fun (e:Z) => (f (t e))) i j)).
Axiom int_iterate_eq :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (g:Z -> im) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
~ (j <= i)%Z -> ((int_iterate op1 f i j) = (int_iterate op1 g i j)).
Axiom int_iterate_eq1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (g:Z -> im) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
(iterable op1) -> ((int_iterate op1 f i j) = (int_iterate op1 g i j)).
Axiom int_iterate_left_right :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (l:Z) (k:Z) (h:Z),
(iterable op1) -> (commut op1) -> ((l <= k)%Z /\ (k <= h)%Z) ->
((int_iterate op1 f l k) =
(int_iterate op1 (fun (a:Z) => (f ((h - (a + 1%Z)%Z)%Z + l)%Z))
((h - k)%Z + l)%Z h)).
Axiom int_iterate_eq_func :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (i:Z) (j:Z) (f:Z -> im) (g:Z -> im),
(iterable op1) -> (commut op1) -> (p_injective f (to_fset i j)) ->
(p_injective g (to_fset i j)) ->
((map f (to_fset i j)) = (map g (to_fset i j))) ->
((int_iterate op1 f i j) = (int_iterate op1 g i j)).
Axiom int_iterate_map :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t:Z -> im),
~ (j <= i)%Z -> (commut op1) ->
(p_bijective f (to_fset i j) (to_fset k l)) ->
((int_iterate op1 t k l) = (int_iterate op1 (fun (b:Z) => (t (f b))) i j)).
Axiom int_iterate_map1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t:Z -> im),
(iterable op1) -> (commut op1) ->
(p_bijective f (to_fset i j) (to_fset k l)) ->
((int_iterate op1 t k l) = (int_iterate op1 (fun (b:Z) => (t (f b))) i j)).
Axiom int_iterate_transl :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (f:Z -> im) (i:Z) (j:Z) (k:Z),
(iterable op1) ->
((int_iterate op1 f i j) =
(int_iterate op1 (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).
Axiom int_iterate_map_auto :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (i:Z) (j:Z) (f:Z -> Z) (t:Z -> im),
~ (j <= i)%Z -> (commut op1) ->
(p_bijective f (to_fset i j) (to_fset i j)) ->
((int_iterate op1 t i j) = (int_iterate op1 (fun (b:Z) => (t (f b))) i j)).
Axiom int_iterate_map_auto1 :
forall {im:Type} {im_WT:WhyType im},
forall (op1:im -> im -> im) (i:Z) (j:Z) (f:Z -> Z) (t:Z -> im),
(iterable op1) -> (commut op1) ->
(p_bijective f (to_fset i j) (to_fset i j)) ->
((int_iterate op1 t i j) = (int_iterate op1 (fun (b:Z) => (t (f b))) i j)).
Axiom neutrals : (0%Z = (neutral_elt (fun (y0:Z) (y1:Z) => (y0 + y1)%Z))).
Axiom neutrals1 : (1%Z = (neutral_elt (fun (y0:Z) (y1:Z) => (y0 * y1)%Z))).
Axiom neutrals2 : iterable (fun (y0:Z) (y1:Z) => (y0 + y1)%Z).
Axiom neutrals3 : iterable (fun (y0:Z) (y1:Z) => (y0 * y1)%Z).
Parameter isum: forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> Z) -> Z.
Axiom isum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t:a -> Z),
((isum s t) = (iterate (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) s t)).
Axiom isum_iter : iterates (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) 0%Z.
Axiom isum_iter__ : iterable (fun (y0:Z) (y1:Z) => (y0 + y1)%Z).
Axiom isum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t:a -> Z) (t':a -> Z),
(forall (e:a), (mem e s) -> ((t e) = (t' e))) -> ((isum s t) = (isum s t')).
Axiom isum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (t:a -> Z) (t':a -> Z), (s = s') ->
(forall (e:a), (mem e s) -> ((t e) = (t' e))) -> ((isum s t) = (isum s t')).
Axiom isum_add :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> Z) (x:b), ~ (mem x s) ->
((isum (add x s) f) = ((f x) + (isum s f))%Z).
Axiom mul_assoc :
forall (a:Z) (b:Z) (c:Z), (((a * b)%Z * c)%Z = (a * (b * c)%Z)%Z).
Axiom mul_comm : forall (a:Z) (b:Z), ((a * b)%Z = (b * a)%Z).
Axiom mul_assoc_rev :
forall (a:Z) (b:Z) (c:Z), ((a * (b * c)%Z)%Z = ((a * b)%Z * c)%Z).
Axiom mult_add_distr :
forall (a:Z) (b:Z) (c:Z) (d:Z),
(((a + b)%Z * (c + d)%Z)%Z =
((((a * c)%Z + (a * d)%Z)%Z + (b * c)%Z)%Z + (b * d)%Z)%Z).
Axiom mult_add_right :
forall (a:Z) (b:Z) (c:Z), (((a + b)%Z * c)%Z = ((a * c)%Z + (b * c)%Z)%Z).
Axiom mult_add_right_rev :
forall (a:Z) (b:Z) (c:Z), (((a * c)%Z + (b * c)%Z)%Z = ((a + b)%Z * c)%Z).
Axiom mult_add_left :
forall (a:Z) (b:Z) (c:Z), ((a * (b + c)%Z)%Z = ((a * b)%Z + (a * c)%Z)%Z).
Axiom mult_add_left_rev :
forall (a:Z) (b:Z) (c:Z), (((a * b)%Z + (a * c)%Z)%Z = (a * (b + c)%Z)%Z).
Axiom mult_add_distr_rev :
forall (a:Z) (b:Z) (c:Z) (d:Z),
(((((a * c)%Z + (a * d)%Z)%Z + (b * c)%Z)%Z + (b * d)%Z)%Z =
((a + b)%Z * (c + d)%Z)%Z).
Axiom mul_assoc_comm :
forall (a:Z) (b:Z) (c:Z), (((a * b)%Z * c)%Z = (b * (a * c)%Z)%Z).
Axiom mul_assoc_rev_comm :
forall (a:Z) (b:Z) (c:Z), ((a * (b * c)%Z)%Z = ((a * c)%Z * b)%Z).
Axiom add_assoc :
forall (a:Z) (b:Z) (c:Z), (((a + b)%Z + c)%Z = (a + (b + c)%Z)%Z).
Axiom add_assoc_rev :
forall (a:Z) (b:Z) (c:Z), ((a + (b + c)%Z)%Z = ((a + b)%Z + c)%Z).
Axiom isum_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> Z), (is_empty s) -> ((isum s f) = 0%Z).
Axiom isum_iter_ :
opposite_n (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
(fun (y0:Z) (y1:Z) => (y0 - y1)%Z) 0%Z.
Axiom isum_iter_1 :
opposite (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
(fun (y0:Z) (y1:Z) => (y0 - y1)%Z).
Axiom isum_iter_2 :
opposite_com (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
(fun (y0:Z) (y1:Z) => (y0 - y1)%Z).
Axiom isum_iter_3 :
inverse_tuple (fun (y0:Z) (y1:Z) => (y0 + y1)%Z)
(fun (y0:Z) (y1:Z) => (y0 - y1)%Z) 0%Z.
Parameter ind_isum: (Z -> Z) -> Z -> Z -> Z.
Axiom ind_isum_def :
forall (f:Z -> Z) (i:Z) (j:Z),
((ind_isum f i j) = (int_iterate (fun (y0:Z) (y1:Z) => (y0 + y1)%Z) f i j)).
Axiom ind_isum_empty :
forall (f:Z -> Z) (i:Z) (j:Z), (j <= i)%Z -> ((ind_isum f i j) = 0%Z).
Axiom ind_isum_one :
forall (f:Z -> Z) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
((ind_isum f i j) = (f i)).
Axiom ind_isum_plus_one :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
((ind_isum f i j) = ((f i) + (ind_isum f (i + 1%Z)%Z j))%Z).
Axiom ind_isum_to_isum :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
((ind_isum f i j) = (isum (to_fset i j) f)).
Axiom ind_isum_const :
forall (k:Z) (i:Z) (j:Z), (i < j)%Z ->
((ind_isum ((fun (y0:Z) (y1:Z) => (const y0 y1)) k) i j) =
(k * (j - i)%Z)%Z).
Axiom ind_isum_null :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = 0%Z)) ->
((ind_isum f i j) = 0%Z).
Axiom ind_isum_right_extension :
forall (f:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
((ind_isum f i (j + 1%Z)%Z) = ((ind_isum f i j) + (f j))%Z).
Axiom ind_isum_eq :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ind_isum f i j) = (ind_isum g i j)).
Parameter fc: (Z -> Z) -> (Z -> Z) -> (Z -> bool) -> Z -> Z.
Axiom fc_def :
forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (k:Z),
(((p k) = true) -> (((fc f g p) k) = (f k))) /\
(~ ((p k) = true) -> (((fc f g p) k) = (g k))).
Axiom ind_isum_to_guard :
forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((p k) = true)) ->
((ind_isum (fc f g p) i j) = (ind_isum f i j)).
Parameter fc1: (Z -> Z) -> (Z -> Z) -> (Z -> bool) -> Z -> Z.
Axiom fc_def1 :
forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (k:Z),
(((p k) = true) -> (((fc1 f g p) k) = (g k))) /\
(~ ((p k) = true) -> (((fc1 f g p) k) = (f k))).
Axiom ind_isum_no_guard :
forall (f:Z -> Z) (g:Z -> Z) (p:Z -> bool) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ~ ((p k) = true)) ->
((ind_isum (fc1 f g p) i j) = (ind_isum f i j)).
Axiom ind_isum_eq_gen :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (i1:Z) (j:Z) (j1:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) -> (i = i1) ->
(j = j1) -> ((ind_isum f i j) = (ind_isum g i1 j1)).
Axiom ind_isum_func_const :
forall (k:Z) (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (l:Z), ((i <= l)%Z /\ (l < j)%Z) -> ((f l) = k)) ->
((ind_isum f i j) = (k * (j - i)%Z)%Z).
Axiom ind_isum_pos :
forall (f:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) >= 0%Z)%Z) ->
(0%Z <= (ind_isum f i j))%Z.
Parameter ind_iproduct: (Z -> Z) -> Z -> Z -> Z.
Axiom ind_iproduct_def :
forall (f:Z -> Z) (i:Z) (j:Z),
((ind_iproduct f i j) =
(int_iterate (fun (y0:Z) (y1:Z) => (y0 * y1)%Z) f i j)).
Axiom ind_iproduct_eq :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ind_iproduct f i j) = (ind_iproduct g i j)).
Axiom ind_iproduct_eq_gen :
forall (f:Z -> Z) (g:Z -> Z) (i1:Z) (j1:Z) (i2:Z) (j2:Z),
(forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
(i1 = i2) -> (j1 = j2) -> ((ind_iproduct f i1 j1) = (ind_iproduct g i2 j2)).
Axiom mult_one_int : forall (a:Z) (b:Z), (b = 1%Z) -> ((a * b)%Z = a).
Axiom one_mult_int : forall (a:Z) (b:Z), (a = 1%Z) -> ((a * b)%Z = b).
Axiom mult_zero_int : forall (a:Z) (b:Z), (b = 0%Z) -> ((a * b)%Z = 0%Z).
Axiom zero_mult_int : forall (a:Z) (b:Z), (a = 0%Z) -> ((a * b)%Z = 0%Z).
Axiom iproduct_to_iterate :
forall (f:Z -> Z) (i:Z) (j:Z),
((ind_iproduct f i j) =
(int_iterate (fun (y0:Z) (y1:Z) => (y0 * y1)%Z) f i j)).
Axiom ind_isum_map_auto :
forall (i:Z) (j:Z) (f:Z -> Z) (t:Z -> Z),
(p_bijective f (to_fset i j) (to_fset i j)) ->
((ind_isum t i j) = (ind_isum (fun (b:Z) => (t (f b))) i j)).
Axiom ind_isum_map :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t:Z -> Z),
(p_bijective f (to_fset i j) (to_fset k l)) ->
((ind_isum t k l) = (ind_isum (fun (b:Z) => (t (f b))) i j)).
Axiom ind_isum_map_auto_bij :
forall (i:Z) (j:Z) (f:Z -> Z) (t:Z -> Z),
(forall (e:Z), ((i <= e)%Z /\ (e < j)%Z) ->
(i <= (f e))%Z /\ ((f e) < j)%Z) ->
(forall (e:Z) (e':Z), ((i <= e)%Z /\ (e < j)%Z) ->
((i <= e')%Z /\ (e' < j)%Z) -> ~ (e = e') -> ~ ((f e) = (f e'))) ->
(forall (e':Z), ((i <= e')%Z /\ (e' < j)%Z) ->
exists e:Z, ((i <= e)%Z /\ (e < j)%Z) /\ ((f e) = e')) ->
((ind_isum t i j) = (ind_isum (fun (b:Z) => (t (f b))) i j)).
Axiom ind_isum_map_bij :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t:Z -> Z),
(forall (e:Z), ((i <= e)%Z /\ (e < j)%Z) ->
(k <= (f e))%Z /\ ((f e) < l)%Z) ->
(forall (e:Z) (e':Z), ((i <= e)%Z /\ (e < j)%Z) ->
((i <= e')%Z /\ (e' < j)%Z) -> ~ (e = e') -> ~ ((f e) = (f e'))) ->
(forall (e':Z), ((k <= e')%Z /\ (e' < l)%Z) ->
exists e:Z, ((i <= e)%Z /\ (e < j)%Z) /\ ((f e) = e')) ->
((ind_isum t k l) = (ind_isum (fun (b:Z) => (t (f b))) i j)).
Axiom ind_iproduct_empty :
forall (f:Z -> Z) (i:Z) (j:Z), (i >= j)%Z -> ((ind_iproduct f i j) = 1%Z).
Axiom ind_iproduct_plus_one :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
((ind_iproduct f i j) = ((f i) * (ind_iproduct f (i + 1%Z)%Z j))%Z).
Axiom ind_iproduct_right_extension :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
((ind_iproduct f i j) =
((ind_iproduct f i (j - 1%Z)%Z) * (f (j - 1%Z)%Z))%Z).
Axiom ind_iproduct_right_extension_comm :
forall (f:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
(((ind_iproduct f i (j - 1%Z)%Z) * (f (j - 1%Z)%Z))%Z =
(ind_iproduct f i j)).
Axiom ind_iproduct_one :
forall (f:Z -> Z) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = 1%Z)) ->
((ind_iproduct f i j) = 1%Z).
Axiom positive_iproduct :
forall (f:Z -> Z) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) > 0%Z)%Z) ->
((ind_iproduct f i j) > 0%Z)%Z.
Axiom ind_iproduct_left_right :
forall (f:Z -> Z) (l:Z) (k:Z) (h:Z), ((l <= k)%Z /\ (k <= h)%Z) ->
((ind_iproduct f l k) =
(ind_iproduct (fun (a:Z) => (f ((h - (a + 1%Z)%Z)%Z + l)%Z))
((h - k)%Z + l)%Z h)).
Axiom iterable_imult : iterable (fun (y0:Z) (y1:Z) => (y0 * y1)%Z).
Axiom ind_iproduct_map_auto :
forall (i:Z) (j:Z) (f:Z -> Z) (t:Z -> Z),
(p_bijective f (to_fset i j) (to_fset i j)) ->
((ind_iproduct t i j) = (ind_iproduct (fun (b:Z) => (t (f b))) i j)).
Axiom ind_iproduct_map :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t:Z -> Z),
(p_bijective f (to_fset i j) (to_fset k l)) ->
((ind_iproduct t k l) = (ind_iproduct (fun (b:Z) => (t (f b))) i j)).
Axiom ind_iproduct_trans :
forall (f:Z -> Z) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
((ind_iproduct f i j) = ((ind_iproduct f i k) * (ind_iproduct f k j))%Z).
Axiom ind_isum_transl :
forall (f:Z -> Z) (i:Z) (j:Z) (k:Z),
((ind_isum f i j) =
(ind_isum (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).
Axiom ind_isum_transl_plus_one :
forall (f:Z -> Z) (i:Z) (j:Z),
((ind_isum f i j) =
(ind_isum (fun (b:Z) => (f (b - 1%Z)%Z)) (i + 1%Z)%Z (j + 1%Z)%Z)).
Axiom ind_isum_transl_minus_one :
forall (f:Z -> Z) (i:Z) (j:Z),
((ind_isum f i j) =
(ind_isum (fun (b:Z) => (f (b + 1%Z)%Z)) (i - 1%Z)%Z (j - 1%Z)%Z)).
Axiom ind_isum_scal :
forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
((ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j) = (a * (ind_isum f i j))%Z).
Axiom ind_isum_scal_rev :
forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
((a * (ind_isum f i j))%Z = (ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j)).
Axiom ind_isum_scal_rev_right :
forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
(((ind_isum f i j) * a)%Z = (ind_isum (fun (i1:Z) => ((f i1) * a)%Z) i j)).
Axiom ind_isum_scal_right :
forall (f:Z -> Z) (i:Z) (j:Z) (a:Z), (i <= j)%Z ->
((ind_isum (fun (i1:Z) => ((f i1) * a)%Z) i j) = ((ind_isum f i j) * a)%Z).
Axiom ind_isum_bound :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) < (g k))%Z) ->
((ind_isum f i j) < (ind_isum g i j))%Z.
Axiom comp_trans_equal_strict :
forall (a:Z) (b:Z) (c:Z), (a <= b)%Z -> (b < c)%Z -> (a < c)%Z.
Axiom compeq_trans_sum :
forall (a:Z) (b:Z) (c:Z), (b <= c)%Z -> ((a + b)%Z <= (a + c)%Z)%Z.
Axiom compeq_trans_sum_zero :
forall (a:Z) (b:Z), (0%Z <= b)%Z -> (a <= (a + b)%Z)%Z.
Axiom comp_trans_sum :
forall (a:Z) (b:Z) (c:Z), (b < c)%Z -> ((a + b)%Z < (a + c)%Z)%Z.
Axiom ind_isum_bound_eq :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) <= (g k))%Z) ->
((ind_isum f i j) <= (ind_isum g i j))%Z.
Axiom ind_isum_scal_gen :
forall (f:Z -> Z) (i:Z) (j:Z), forall (a:Z), ((i <= a)%Z /\ (a < j)%Z) ->
((ind_isum (fun (i1:Z) => (a * (f i1))%Z) i j) = (a * (ind_isum f i j))%Z).
Axiom ind_isum_trans :
forall (f:Z -> Z) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
((ind_isum f i j) = ((ind_isum f i k) + (ind_isum f k j))%Z).
Parameter power: Z -> Z -> Z.
Axiom power_def :
forall (e:Z) (i:Z), (i >= 0%Z)%Z -> (i = 0%Z) -> ((power e i) = 1%Z).
Axiom power_def1 :
forall (e:Z) (i:Z), (i >= 0%Z)%Z -> ~ (i = 0%Z) ->
((power e i) = (e * (power e (i - 1%Z)%Z))%Z).
Axiom Power_zero : forall (i:Z), ((power i 0%Z) = 1%Z).
Axiom Power_one : forall (i:Z), ((power i 1%Z) = i).
Axiom Power_sum :
forall (x:Z) (y:Z) (i:Z), (x >= 0%Z)%Z -> (y >= 0%Z)%Z ->
((power i (x + y)%Z) = ((power i x) * (power i y))%Z).
Axiom Power_mult :
forall (x:Z) (y:Z) (i:Z), (x >= 0%Z)%Z -> (y >= 0%Z)%Z ->
((power i (x * y)%Z) = (power (power i x) y)).
Axiom power_plus_one :
forall (e:Z) (i:Z), (i >= 0%Z)%Z ->
((power e (i + 1%Z)%Z) = (e * (power e i))%Z).
Axiom power_to_ind_iproduct :
forall (e:Z) (i:Z), (0%Z <= i)%Z ->
((power e i) =
(ind_iproduct ((fun (y0:Z) (y1:Z) => (const y0 y1)) e) 0%Z i)).
Axiom power_transl :
forall (e:Z) (k:Z) (i:Z), (0%Z <= i)%Z ->
((power e i) =
(ind_iproduct ((fun (y0:Z) (y1:Z) => (const y0 y1)) e) k (k + i)%Z)).
Axiom ind_iproduct_to_power :
forall (e:Z) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i <= j)%Z) ->
((ind_iproduct ((fun (y0:Z) (y1:Z) => (const y0 y1)) e) i j) =
(power e (j - i)%Z)).
Axiom ind_iproduct_to_power_gen :
forall (e:Z), forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i <= j)%Z) ->
((ind_iproduct ((fun (y0:Z) (y1:Z) => (const y0 y1)) e) i j) =
(power e (j - i)%Z)).
Axiom power_sum :
forall (x:Z) (n:Z) (m:Z), (n >= 0%Z)%Z -> (m >= 0%Z)%Z ->
((power x (n + m)%Z) = ((power x n) * (power x m))%Z).
Axiom power_sum_rev :
forall (x:Z) (n:Z) (m:Z), (n >= 0%Z)%Z -> (m >= 0%Z)%Z ->
(((power x n) * (power x m))%Z = (power x (n + m)%Z)).
Axiom power_eq :
forall (x:Z) (n:Z) (m:Z), (n = m) -> ((power x n) = (power x m)).
Axiom power_eq_gen :
forall (x:Z) (y:Z) (n:Z) (m:Z), (n = m) -> (x = y) ->
((power x n) = (power y m)).
Axiom power_decomp :
forall (i:Z), (i >= 1%Z)%Z ->
((ind_isum (fun (k:Z) => (power 2%Z (k + 1%Z)%Z)) 0%Z i) <
(power 2%Z (i + 1%Z)%Z))%Z.
Parameter fc2: Z -> Z -> Z.
Axiom fc_def2 :
forall (i:Z) (k:Z),
(((1%Z <= k)%Z /\ (k < (i + 1%Z)%Z)%Z) ->
(((fc2 i) k) = (power 2%Z (k - 1%Z)%Z))) /\
(~ ((1%Z <= k)%Z /\ (k < (i + 1%Z)%Z)%Z) -> (((fc2 i) k) = 0%Z)).
Axiom power_decomp_minus_one :
forall (i:Z), (i >= 1%Z)%Z ->
((ind_isum (fc2 i) 1%Z i) < (power 2%Z (i - 1%Z)%Z))%Z.
Axiom power_decomp_ :
forall (i:Z), (i >= 1%Z)%Z ->
((ind_isum (fun (k:Z) => (power 2%Z k)) 0%Z i) < (power 2%Z i))%Z.
Axiom power_decomp_one :
forall (i:Z), (i >= 1%Z)%Z ->
((ind_isum (fun (k:Z) => (power 2%Z (k + 1%Z)%Z)) 1%Z i) <
(power 2%Z (i + 1%Z)%Z))%Z.
Axiom power_decomp_one_ :
forall (i:Z), (i >= 1%Z)%Z ->
((ind_isum (fun (k:Z) => (power 2%Z k)) 1%Z i) < (power 2%Z i))%Z.
Axiom growing_mult :
forall (n:Z) (m:Z), (0%Z <= n)%Z -> (1%Z <= m)%Z -> ((n * m)%Z >= n)%Z.
Axiom strict_growing_mult :
forall (n:Z) (m:Z), (1%Z < n)%Z -> (1%Z < m)%Z -> ((n * m)%Z > n)%Z.
Axiom init_exp : forall (k:Z), ((power k 0%Z) = 1%Z).
Axiom init_exp1 : forall (k:Z), ((power k 1%Z) = k).
Axiom init_exp2 : forall (k:Z), ((power k 2%Z) = (k * k)%Z).
Axiom positive_int_exp :
forall (k:Z) (n:Z), (1%Z <= k)%Z -> (0%Z <= n)%Z -> ((power k n) >= 1%Z)%Z.
Axiom positive_int_exp1 :
forall (k:Z) (n:Z), (1%Z <= k)%Z -> (0%Z <= n)%Z -> ((power k n) > 0%Z)%Z.
Axiom positive_int_exp2 :
forall (k:Z) (n:Z), (1%Z <= k)%Z -> (0%Z <= n)%Z ->
((power k n) <= (power k (n + 1%Z)%Z))%Z.
Axiom strict_positive_int_exp :
forall (k:Z) (n:Z), (1%Z < k)%Z -> (0%Z < n)%Z -> ((power k n) > 1%Z)%Z.
Axiom strict_positive_int_exp1 :
forall (k:Z) (n:Z), (1%Z < k)%Z -> (0%Z < n)%Z ->
((power k (n - 1%Z)%Z) < (power k n))%Z.
Axiom strict_positive_int_exp2 :
forall (k:Z) (n:Z), (1%Z < k)%Z -> (0%Z < n)%Z ->
((power k n) < (power k (n + 1%Z)%Z))%Z.
Axiom power_minus_one :
forall (i:Z), (0%Z <= i)%Z -> ((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) ->
((power (-1%Z)%Z i) = 1%Z).
Axiom power_minus_one1 :
forall (i:Z), (0%Z <= i)%Z -> ((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
((power (-1%Z)%Z i) = (-1%Z)%Z).
Axiom growing_exp :
forall (k:Z) (m:Z) (n:Z), (1%Z <= k)%Z -> ((0%Z <= m)%Z /\ (m <= n)%Z) ->
((power k m) <= (power k n))%Z.
Axiom strict_growing_exp :
forall (k:Z) (m:Z) (n:Z), (1%Z < k)%Z -> ((0%Z <= m)%Z /\ (m < n)%Z) ->
((power k m) < (power k n))%Z.
Axiom unicity_exp :
forall (k:Z) (m:Z) (n:Z), (1%Z < k)%Z -> (0%Z <= m)%Z -> (0%Z <= n)%Z ->
((power k m) = (power k n)) -> (m = n).
Axiom unicity_exp1 :
forall (k:Z) (m:Z) (n:Z), (1%Z < k)%Z -> (0%Z <= m)%Z -> (0%Z <= n)%Z ->
(m = n) -> ((power k m) = (power k n)).
Axiom bounded_sum_exp :
forall (i:Z) (j:Z) (m:Z) (n:Z), (0%Z <= m)%Z -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z m))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
(((i * (power 2%Z n))%Z + j)%Z < (power 2%Z (m + n)%Z))%Z.
Axiom t : Type.
Parameter t_WhyType : WhyType t.
Existing Instance t_WhyType.
Parameter teq: t -> t -> Prop.
Axiom teq_spec : forall (x:t) (y:t), (teq x y) -> (x = y).
Axiom teq_spec1 : forall (x:t) (y:t), (x = y) -> teq x y.
Parameter tzero: t.
Parameter tone: t.
Parameter prefix_mndt: t -> t.
Parameter infix_pldt: t -> t -> t.
Parameter infix_asdt: t -> t -> t.
Parameter inv: t -> t.
Axiom Assoc :
forall (x:t) (y:t) (z:t),
((infix_pldt (infix_pldt x y) z) = (infix_pldt x (infix_pldt y z))).
Axiom Unit_def_l : forall (x:t), ((infix_pldt tzero x) = x).
Axiom Unit_def_r : forall (x:t), ((infix_pldt x tzero) = x).
Axiom Inv_def_l : forall (x:t), ((infix_pldt (prefix_mndt x) x) = tzero).
Axiom Inv_def_r : forall (x:t), ((infix_pldt x (prefix_mndt x)) = tzero).
Axiom Comm : forall (x:t) (y:t), ((infix_pldt x y) = (infix_pldt y x)).
Axiom Assoc1 :
forall (x:t) (y:t) (z:t),
((infix_asdt (infix_asdt x y) z) = (infix_asdt x (infix_asdt y z))).
Axiom Mul_distr_l :
forall (x:t) (y:t) (z:t),
((infix_asdt x (infix_pldt y z)) =
(infix_pldt (infix_asdt x y) (infix_asdt x z))).
Axiom Mul_distr_r :
forall (x:t) (y:t) (z:t),
((infix_asdt (infix_pldt y z) x) =
(infix_pldt (infix_asdt y x) (infix_asdt z x))).
Axiom Comm1 : forall (x:t) (y:t), ((infix_asdt x y) = (infix_asdt y x)).
Axiom Unitary : forall (x:t), ((infix_asdt tone x) = x).
Axiom NonTrivialRing : ~ (tzero = tone).
Axiom Inverse :
forall (x:t), ~ (x = tzero) -> ((infix_asdt x (inv x)) = tone).
Parameter infix_mn: t -> t -> t.
Axiom infix_mn_def :
forall (x:t) (y:t), ((infix_mn x y) = (infix_pldt x (prefix_mndt y))).
Parameter infix_sl: t -> t -> t.
Axiom infix_sl_def :
forall (x:t) (y:t), ((infix_sl x y) = (infix_asdt x (inv y))).
Axiom add_div :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_sl (infix_pldt x y) z) =
(infix_pldt (infix_sl x z) (infix_sl y z))).
Axiom sub_div :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_sl (infix_mn x y) z) = (infix_mn (infix_sl x z) (infix_sl y z))).
Axiom neg_div :
forall (x:t) (y:t), ~ (y = tzero) ->
((infix_sl (prefix_mndt x) y) = (prefix_mndt (infix_sl x y))).
Axiom assoc_mul_div :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_sl (infix_asdt x y) z) = (infix_asdt x (infix_sl y z))).
Axiom assoc_div_mul :
forall (x:t) (y:t) (z:t), (~ (y = tzero) /\ ~ (z = tzero)) ->
((infix_sl (infix_sl x y) z) = (infix_sl x (infix_asdt y z))).
Axiom assoc_div_div :
forall (x:t) (y:t) (z:t), (~ (y = tzero) /\ ~ (z = tzero)) ->
((infix_sl x (infix_sl y z)) = (infix_sl (infix_asdt x z) y)).
Parameter infix_mndt: t -> t -> t.
Axiom infix_mndt_def :
forall (x:t) (y:t), ((infix_mndt x y) = (infix_pldt x (prefix_mndt y))).
Parameter infix_sldt: t -> t -> t.
Axiom infix_sldt_def :
forall (x:t) (y:t), ~ (y = tzero) ->
((infix_sldt x y) = (infix_asdt x (inv y))).
Axiom infix_sldt_spec :
forall (x:t) (y:t), ~ (y = tzero) ->
((infix_sldt x y) = (infix_asdt x (inv y))).
Parameter infix_slas: R -> R -> R.
Axiom infix_slas_def :
forall (x:R) (y:R), ~ (y = 0%R) -> ((infix_slas x y) = (x / y)%R).
Parameter infix_eqas: R -> R -> Prop.
Axiom infix_eqas_spec : forall (x:R) (y:R), (infix_eqas x y) -> (x = y).
Axiom infix_eqas_spec1 : forall (x:R) (y:R), (x = y) -> infix_eqas x y.
Parameter infix_lsgtas: R -> R -> Prop.
Axiom infix_lsgtas_spec :
forall (x:R) (y:R), (infix_lsgtas x y) -> ~ (x = y).
Axiom infix_lsgtas_spec1 : forall (x:R) (y:R), ~ (x = y) -> infix_lsgtas x y.
Parameter infix_plas: R -> R -> R.
Axiom infix_plas_def : forall (x:R) (y:R), ((infix_plas x y) = (x + y)%R).
Parameter infix_mnas: R -> R -> R.
Axiom infix_mnas_def :
forall (x:R) (y:R), ((infix_mnas x y) = (x + (-y)%R)%R).
Parameter infix_asas: R -> R -> R.
Axiom infix_asas_def : forall (x:R) (y:R), ((infix_asas x y) = (x * y)%R).
Parameter infix_lseqas: R -> R -> Prop.
Axiom infix_lseqas_def :
forall (x:R) (y:R), (infix_lseqas x y) -> (x <= y)%R.
Axiom infix_lseqas_def1 : forall (x:R) (y:R), (x <= y)%R -> infix_lseqas x y.
Parameter prefix_mnas: R -> R.
Axiom prefix_mnas_def : forall (y:R), ((prefix_mnas y) = (-y)%R).
Parameter infix_lsas: R -> R -> Prop.
Axiom infix_lsas_def :
forall (x:R) (y:R), (infix_lsas x y) -> infix_lseqas x y.
Axiom infix_lsas_def1 :
forall (x:R) (y:R), (infix_lsas x y) -> infix_lsgtas x y.
Axiom infix_lsas_def2 :
forall (x:R) (y:R), ((infix_lseqas x y) /\ (infix_lsgtas x y)) ->
infix_lsas x y.
Parameter infix_gtas: R -> R -> Prop.
Axiom infix_gtas_def :
forall (x:R) (y:R), (infix_gtas x y) -> infix_lsas y x.
Axiom infix_gtas_def1 :
forall (x:R) (y:R), (infix_lsas y x) -> infix_gtas x y.
Parameter infix_gteqas: R -> R -> Prop.
Axiom infix_gteqas_def :
forall (x:R) (y:R), (infix_gteqas x y) -> infix_lseqas y x.
Axiom infix_gteqas_def1 :
forall (x:R) (y:R), (infix_lseqas y x) -> infix_gteqas x y.
Parameter from_int: Z -> R.
Axiom Zero : ((from_int 0%Z) = 0%R).
Axiom One : ((from_int 1%Z) = 1%R).
Axiom Add :
forall (x:Z) (y:Z),
((from_int (x + y)%Z) = (infix_plas (from_int x) (from_int y))).
Axiom Sub :
forall (x:Z) (y:Z),
((from_int (x - y)%Z) = (infix_mnas (from_int x) (from_int y))).
Axiom Mul :
forall (x:Z) (y:Z),
((from_int (x * y)%Z) = (infix_asas (from_int x) (from_int y))).
Axiom Neg : forall (x:Z), ((from_int (-x)%Z) = (prefix_mnas (from_int x))).
Axiom Injective :
forall (x:Z) (y:Z), ((from_int x) = (from_int y)) -> (x = y).
Axiom Monotonic :
forall (x:Z) (y:Z), (x <= y)%Z -> infix_lseqas (from_int x) (from_int y).
Axiom r_zeroLessOne : infix_lseqas 0%R 1%R.
Axiom r_compatOrderAdd :
forall (x:R) (y:R) (z:R), (infix_lseqas x y) ->
infix_lseqas (infix_plas x z) (infix_plas y z).
Axiom r_compatOrderMult :
forall (x:R) (y:R) (z:R), (infix_lseqas x y) -> (infix_lseqas 0%R z) ->
infix_lseqas (infix_asas x z) (infix_asas y z).
Axiom inv_order :
forall (a:R) (b:R), (infix_lsas 0%R a) -> (infix_lsas 0%R b) ->
(infix_lseqas a b) -> infix_lseqas (1%R / b)%R (1%R / a)%R.
Axiom inv_strict_order :
forall (a:R) (b:R), (infix_lsas 0%R a) -> (infix_lsas 0%R b) ->
(infix_lsas a b) -> infix_lsas (1%R / b)%R (1%R / a)%R.
Axiom Absorbing_zero :
forall (a:t) (b:t), ((infix_asdt a b) = tzero) -> ~ (a = tzero) ->
(b = tzero).
Axiom Absorbing_zero1 :
forall (a:t) (b:t), (a = tzero) -> ((infix_asdt a b) = tzero).
Axiom Absorbing_zero2 :
forall (a:t) (b:t), (b = tzero) -> ((infix_asdt a b) = tzero).
Axiom absorbing_zero :
forall (a:t) (b:t), ((infix_asdt a b) = tzero) -> ~ (a = tzero) ->
(b = tzero).
Axiom absorbing_zero1 :
forall (a:t) (b:t), ((infix_asdt a b) = tzero) -> ~ (b = tzero) ->
(a = tzero).
Axiom invol_neg : forall (a:t), ((prefix_mndt (prefix_mndt a)) = a).
Axiom injective_neg :
forall (a:t) (b:t), ((prefix_mndt a) = (prefix_mndt b)) -> (a = b).
Axiom find_opposite :
forall (a:t) (b:t), ((infix_mndt a b) = tzero) -> (a = b).
Axiom add_opposite : forall (a:t), ((infix_pldt a (prefix_mndt a)) = tzero).
Axiom opposite1 : forall (a:t), ((infix_mndt a a) = tzero).
Axiom mult_num :
forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
((infix_sldt (infix_asdt a b) c) = (infix_asdt a (infix_sldt b c))).
Axiom div_as_mult_inv :
forall (a:t) (b:t), ~ (b = tzero) ->
((infix_sldt a b) = (infix_asdt a (infix_sldt tone b))).
Axiom div_rev :
forall (a:t) (b:t), ~ (b = tzero) ->
((infix_asdt a (infix_sldt tone b)) = (infix_sldt a b)).
Axiom mult_div_num :
forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
((infix_asdt (infix_sldt a c) b) = (infix_sldt (infix_asdt a b) c)).
Axiom mult_denom :
forall (a:t) (b:t) (c:t), ~ (c = tzero) -> ~ (b = tzero) ->
((infix_sldt a (infix_asdt b c)) =
(infix_asdt (infix_sldt a b) (infix_sldt tone c))).
Axiom mult_simpl :
forall (a:t) (b:t) (c:t), ~ (c = tzero) -> ~ (b = tzero) ->
((infix_sldt (infix_asdt a b) (infix_asdt c b)) = (infix_sldt a c)).
Axiom non_zero_prod :
forall (a:t) (b:t), ~ (a = tzero) -> ~ (b = tzero) ->
~ ((infix_asdt a b) = tzero).
Axiom minus_tone :
forall (a:t), ((prefix_mndt a) = (infix_asdt (prefix_mndt tone) a)).
Axiom mult_neg_l :
forall (a:t) (b:t),
((infix_asdt (prefix_mndt a) b) = (prefix_mndt (infix_asdt a b))).
Axiom mult_neg_r :
forall (a:t) (b:t),
((infix_asdt a (prefix_mndt b)) = (prefix_mndt (infix_asdt a b))).
Axiom neg_neg_out : forall (a:t), ((prefix_mndt (prefix_mndt a)) = a).
Axiom div_neg_l :
forall (a:t) (b:t), ~ (b = tzero) ->
((infix_sldt (prefix_mndt a) b) = (prefix_mndt (infix_sldt a b))).
Axiom div_neg_r :
forall (a:t) (b:t), ~ (b = tzero) ->
((infix_sldt a (prefix_mndt b)) = (prefix_mndt (infix_sldt a b))).
Axiom invadd :
forall (i:t), ((prefix_mndt i) = (infix_asdt (prefix_mndt tone) i)).
Axiom notZeroAdd :
forall (x:t) (y:t), ~ (x = tzero) -> ~ ((infix_pldt x y) = y).
Parameter im: t.
Axiom im_Def : ((infix_asdt im im) = (prefix_mndt tone)).
Parameter ttwo: t.
Axiom ttwo_def : (ttwo = (infix_pldt tone tone)).
Parameter r_to_t: R -> t.
Axiom r_to_t_zero : ((r_to_t 0%R) = tzero).
Axiom r_to_t_one : ((r_to_t 1%R) = tone).
Axiom r_to_t_add :
forall (i:R) (j:R),
((infix_pldt (r_to_t i) (r_to_t j)) = (r_to_t (infix_plas i j))).
Axiom r_to_t_inv :
forall (i:R), ((r_to_t (prefix_mnas i)) = (prefix_mndt (r_to_t i))).
Axiom r_to_t_mult :
forall (i:R) (j:R),
((infix_asdt (r_to_t i) (r_to_t j)) = (r_to_t (infix_asas i j))).
Axiom r_to_t_sub :
forall (i:R) (j:R),
((infix_mndt (r_to_t i) (r_to_t j)) = (r_to_t (infix_mnas i j))).
Axiom r_to_t_div :
forall (i:R) (j:R), ~ (j = 0%R) ->
((infix_sldt (r_to_t i) (r_to_t j)) = (r_to_t (infix_slas i j))).
Parameter real_part: t -> R.
Parameter im_part: t -> R.
Axiom Real_part_add :
forall (i:t) (j:t),
((real_part (infix_pldt i j)) = (infix_plas (real_part i) (real_part j))).
Axiom Im_part_add :
forall (i:t) (j:t),
((im_part (infix_pldt i j)) = (infix_plas (im_part i) (im_part j))).
Axiom Real_part_opposite :
forall (i:t), ((real_part (prefix_mndt i)) = (prefix_mnas (real_part i))).
Axiom Im_part_opposite :
forall (i:t), ((im_part (prefix_mndt i)) = (prefix_mnas (im_part i))).
Axiom real_part_add :
forall (i:t) (j:t),
((real_part (infix_pldt i j)) = (infix_plas (real_part i) (real_part j))).
Axiom mult_im_rev : forall (a:t), ((infix_asdt a im) = (infix_asdt im a)).
Axiom im_im_elim :
forall (a:t), ((infix_asdt im (infix_asdt im a)) = (prefix_mndt a)).
Axiom im_im_fact :
forall (a:t) (b:t),
((infix_asdt (infix_asdt im a) (infix_asdt im b)) =
(prefix_mndt (infix_asdt a b))).
Axiom minus_minus_fact :
forall (a:t) (b:t),
((infix_asdt (prefix_mndt a) (prefix_mndt b)) = (infix_asdt a b)).
Axiom minus_minus_add :
forall (a:t) (b:t),
((infix_pldt (prefix_mndt a) (prefix_mndt b)) =
(prefix_mndt (infix_pldt a b))).
Axiom minus_minus_add_rev :
forall (a:t) (b:t),
((prefix_mndt (infix_pldt a b)) =
(infix_pldt (prefix_mndt a) (prefix_mndt b))).
Axiom minus_out_left :
forall (a:t) (b:t),
((infix_asdt (prefix_mndt a) b) = (prefix_mndt (infix_asdt a b))).
Axiom minus_out_right :
forall (a:t) (b:t),
((infix_asdt a (prefix_mndt b)) = (prefix_mndt (infix_asdt a b))).
Axiom minus_in_left :
forall (a:t) (b:t),
((prefix_mndt (infix_asdt a b)) = (infix_asdt (prefix_mndt a) b)).
Axiom minus_in_right :
forall (a:t) (b:t),
((prefix_mndt (infix_asdt a b)) = (infix_asdt a (prefix_mndt b))).
Axiom minus_add_out_left :
forall (a:t) (b:t),
((infix_pldt (prefix_mndt a) b) =
(prefix_mndt (infix_pldt a (prefix_mndt b)))).
Axiom minus_add_out_right :
forall (a:t) (b:t),
((infix_pldt a (prefix_mndt b)) =
(prefix_mndt (infix_pldt (prefix_mndt a) b))).
Axiom minus_add_in :
forall (a:t) (b:t),
((prefix_mndt (infix_pldt a b)) =
(infix_pldt (prefix_mndt a) (prefix_mndt b))).
Axiom minus_add_out :
forall (a:t) (b:t),
((infix_pldt (prefix_mndt a) (prefix_mndt b)) =
(prefix_mndt (infix_pldt a b))).
Axiom minus_eq :
forall (a:t) (b:t), (a = b) -> ((prefix_mndt a) = (prefix_mndt b)).
Axiom im_out_right :
forall (a:t) (b:t),
((infix_asdt (infix_asdt im a) b) = (infix_asdt im (infix_asdt a b))).
Axiom im_out_left :
forall (a:t) (b:t),
((infix_asdt a (infix_asdt im b)) = (infix_asdt im (infix_asdt a b))).
Axiom im_part_add :
forall (i:t) (j:t),
((im_part (infix_pldt i j)) = (infix_plas (im_part i) (im_part j))).
Axiom Complex_decomp :
forall (i:t),
(i =
(infix_pldt (r_to_t (real_part i)) (infix_asdt im (r_to_t (im_part i))))).
Axiom Unic_decomp :
forall (i:t), forall (x:R) (y:R),
(i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
(x = (real_part i)).
Axiom Unic_decomp1 :
forall (i:t), forall (x:R) (y:R),
(i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
(y = (im_part i)).
Axiom injective_real_part :
forall (i:t) (j:t), ~ ((real_part i) = (real_part j)) -> ~ (i = j).
Axiom injective_im_part :
forall (i:t) (j:t), ~ ((im_part i) = (im_part j)) -> ~ (i = j).
Axiom complex_decomp :
forall (i:t),
(i =
(infix_pldt (r_to_t (real_part i)) (infix_asdt im (r_to_t (im_part i))))).
Axiom unic_decomp :
forall (i:t) (x:R) (y:R),
(i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
(x = (real_part i)).
Axiom unic_decomp1 :
forall (i:t) (x:R) (y:R),
(i = (infix_pldt (r_to_t x) (infix_asdt im (r_to_t y)))) ->
(y = (im_part i)).
Parameter real_: t -> Prop.
Axiom real__def : forall (x:t), (real_ x) -> ((im_part x) = 0%R).
Axiom real__def1 : forall (x:t), ((im_part x) = 0%R) -> real_ x.
Parameter pure_im_: t -> Prop.
Axiom pure_im__def : forall (x:t), (pure_im_ x) -> ((real_part x) = 0%R).
Axiom pure_im__def1 : forall (x:t), ((real_part x) = 0%R) -> pure_im_ x.
Axiom r_to_t_real : forall (x:t), (real_ x) -> (x = (r_to_t (real_part x))).
Axiom real_r_to_t : forall (x:R), real_ (r_to_t x).
Axiom r_to_t_pure_im :
forall (x:t), (pure_im_ x) -> (x = (infix_asdt im (r_to_t (im_part x)))).
Axiom simpl_frac :
forall (x:t) (y:t), ~ (y = tzero) -> ((infix_sldt (infix_asdt x y) y) = x).
Axiom simpl_frac_ :
forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
((infix_sldt (infix_asdt x y) (infix_asdt z y)) = (infix_sldt x z)).
Axiom fact_frac :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_sldt (infix_asdt x y) z) = (infix_asdt x (infix_sldt y z))).
Axiom fact_frac_rev :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_asdt x (infix_sldt y z)) = (infix_sldt (infix_asdt x y) z)).
Axiom inv_mult :
forall (x:t) (y:t), ~ (x = tzero) -> ~ (y = tzero) ->
((infix_asdt (infix_sldt tone x) (infix_sldt tone y)) =
(infix_sldt tone (infix_asdt x y))).
Axiom div_div :
forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
((infix_sldt (infix_sldt x y) z) = (infix_sldt x (infix_asdt y z))).
Axiom div_div_rev :
forall (x:t) (y:t) (z:t), ~ (y = tzero) -> ~ (z = tzero) ->
((infix_sldt x (infix_asdt y z)) = (infix_sldt (infix_sldt x y) z)).
Axiom involutive_inv :
forall (a:t), ~ (a = tzero) -> ((infix_sldt tone (infix_sldt tone a)) = a).
Parameter infix_lseqdt: t -> t -> Prop.
Axiom Inf_eq_def :
forall (x:t) (y:t), (infix_lseqdt x y) -> (real_ x) \/ (x = y).
Axiom Inf_eq_def1 :
forall (x:t) (y:t), (infix_lseqdt x y) -> (real_ y) \/ (x = y).
Axiom Inf_eq_def2 :
forall (x:t) (y:t), (infix_lseqdt x y) ->
(infix_lseqas (real_part x) (real_part y)) \/ (x = y).
Axiom Inf_eq_def3 :
forall (x:t) (y:t),
((real_ x) /\ ((real_ y) /\ (infix_lseqas (real_part x) (real_part y)))) ->
infix_lseqdt x y.
Axiom Inf_eq_def4 : forall (x:t) (y:t), (x = y) -> infix_lseqdt x y.
Parameter infix_lsdt: t -> t -> Prop.
Parameter infix_gteqdt: t -> t -> Prop.
Parameter infix_gtdt: t -> t -> Prop.
Parameter square_rt: t -> t.
Axiom square_rt_spec :
forall (x:t), ((infix_asdt (square_rt x) (square_rt x)) = x).
Axiom inf_st : forall (x:t) (y:t), (infix_lsdt x y) -> infix_lseqdt x y.
Axiom inf_st1 : forall (x:t) (y:t), (infix_lsdt x y) -> ~ (x = y).
Axiom inf_st2 :
forall (x:t) (y:t), ((infix_lseqdt x y) /\ ~ (x = y)) -> infix_lsdt x y.
Axiom sup_eq : forall (x:t) (y:t), (infix_gteqdt x y) -> infix_lseqdt y x.
Axiom sup_eq1 : forall (x:t) (y:t), (infix_lseqdt y x) -> infix_gteqdt x y.
Axiom sup_st : forall (x:t) (y:t), (infix_gtdt x y) -> infix_gteqdt x y.
Axiom sup_st1 : forall (x:t) (y:t), (infix_gtdt x y) -> ~ (x = y).
Axiom sup_st2 :
forall (x:t) (y:t), ((infix_gteqdt x y) /\ ~ (x = y)) -> infix_gtdt x y.
Axiom real_square_rt :
forall (x:t), (real_ x) -> (infix_lseqdt tzero x) -> real_ (square_rt x).
Axiom pos_square_rt :
forall (x:t), (real_ x) -> (infix_lseqdt tzero x) ->
infix_gteqdt (square_rt x) tzero.
Axiom square_rt_mult :
forall (t1:t) (t':t), (real_ t1) -> (infix_lseqdt tzero t1) ->
(real_ t') -> (infix_lseqdt tzero t') ->
((infix_asdt (square_rt t1) (square_rt t')) =
(square_rt (infix_asdt t1 t'))).
Axiom Refl : forall (x:t), infix_lseqdt x x.
Axiom Trans :
forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (infix_lseqdt y z) ->
infix_lseqdt x z.
Axiom Antisymm :
forall (x:t) (y:t), (infix_lseqdt x y) -> (infix_lseqdt y x) -> (x = y).
Axiom Refl1 : forall (x:t), infix_gteqdt x x.
Axiom Trans1 :
forall (x:t) (y:t) (z:t), (infix_gteqdt x y) -> (infix_gteqdt y z) ->
infix_gteqdt x z.
Axiom Antisymm1 :
forall (x:t) (y:t), (infix_gteqdt x y) -> (infix_gteqdt y x) -> (x = y).
Axiom Trans2 :
forall (x:t) (y:t) (z:t), (infix_lsdt x y) -> (infix_lsdt y z) ->
infix_lsdt x z.
Axiom Asymm : forall (x:t) (y:t), (infix_lsdt x y) -> ~ (infix_lsdt y x).
Axiom Trans3 :
forall (x:t) (y:t) (z:t), (infix_gtdt x y) -> (infix_gtdt y z) ->
infix_gtdt x z.
Axiom Asymm1 : forall (x:t) (y:t), (infix_gtdt x y) -> ~ (infix_gtdt y x).
Axiom r_to_t_inf :
forall (i:R) (j:R), (infix_lseqdt (r_to_t i) (r_to_t j)) ->
infix_lseqas i j.
Axiom r_to_t_inf1 :
forall (i:R) (j:R), (infix_lseqas i j) ->
infix_lseqdt (r_to_t i) (r_to_t j).
Parameter pi: t.
Axiom pi_def : real_ pi.
Axiom pi_def1 : infix_lsdt tzero pi.
Axiom inf_to_non_sup_eq :
forall (x:t) (y:t), (real_ x) -> (real_ y) -> (infix_lsdt x y) ->
~ (infix_gteqdt x y).
Axiom sup_eq_to_non_inf :
forall (x:t) (y:t), (real_ x) -> (real_ y) -> (infix_gteqdt x y) ->
~ (infix_lsdt x y).
Axiom unic_inv :
forall (i:t) (j:t), ~ (i = tzero) -> ((infix_asdt i j) = tone) ->
(j = (inv i)).
Axiom inf_eq_def :
forall (x:t) (y:t), (infix_lseqdt x y) -> (real_ x) \/ (x = y).
Axiom inf_eq_def1 :
forall (x:t) (y:t), (infix_lseqdt x y) -> (real_ y) \/ (x = y).
Axiom inf_eq_def2 :
forall (x:t) (y:t), (infix_lseqdt x y) ->
(infix_lseqas (real_part x) (real_part y)) \/ (x = y).
Axiom inf_eq_def3 :
forall (x:t) (y:t),
((real_ x) /\ ((real_ y) /\ (infix_lseqas (real_part x) (real_part y)))) ->
infix_lseqdt x y.
Axiom inf_eq_def4 : forall (x:t) (y:t), (x = y) -> infix_lseqdt x y.
Axiom inf_minus :
forall (x:t) (y:t), (infix_lsdt x y) ->
infix_lsdt (prefix_mndt y) (prefix_mndt x).
Axiom mult_pos :
forall (x:t) (y:t), (infix_lseqdt tzero x) -> (infix_lseqdt tzero y) ->
infix_lseqdt tzero (infix_asdt x y).
Axiom inf_def : forall (x:t) (y:t), (infix_lsdt x y) -> real_ x.
Axiom inf_def1 : forall (x:t) (y:t), (infix_lsdt x y) -> real_ y.
Axiom inf_def2 :
forall (x:t) (y:t), (infix_lsdt x y) ->
infix_lsas (real_part x) (real_part y).
Axiom inf_def3 :
forall (x:t) (y:t),
((real_ x) /\ ((real_ y) /\ (infix_lsas (real_part x) (real_part y)))) ->
infix_lsdt x y.
Axiom sup_eq_def :
forall (x:t) (y:t), (infix_gteqdt x y) -> (real_ x) \/ (x = y).
Axiom sup_eq_def1 :
forall (x:t) (y:t), (infix_gteqdt x y) -> (real_ y) \/ (x = y).
Axiom sup_eq_def2 :
forall (x:t) (y:t), (infix_gteqdt x y) ->
(infix_gteqas (real_part x) (real_part y)) \/ (x = y).
Axiom sup_eq_def3 :
forall (x:t) (y:t),
((real_ x) /\ ((real_ y) /\ (infix_gteqas (real_part x) (real_part y)))) ->
infix_gteqdt x y.
Axiom sup_eq_def4 : forall (x:t) (y:t), (x = y) -> infix_gteqdt x y.
Axiom sup_def : forall (x:t) (y:t), (infix_gtdt x y) -> real_ x.
Axiom sup_def1 : forall (x:t) (y:t), (infix_gtdt x y) -> real_ y.
Axiom sup_def2 :
forall (x:t) (y:t), (infix_gtdt x y) ->
infix_gtas (real_part x) (real_part y).
Axiom sup_def3 :
forall (x:t) (y:t),
((real_ x) /\ ((real_ y) /\ (infix_gtas (real_part x) (real_part y)))) ->
infix_gtdt x y.
Axiom decomp_mult :
forall (a:t) (b:t),
((infix_asdt a b) =
(infix_pldt
(infix_mndt (infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b)))
(infix_asdt (r_to_t (im_part a)) (r_to_t (im_part b))))
(infix_asdt im
(infix_pldt (infix_asdt (r_to_t (real_part a)) (r_to_t (im_part b)))
(infix_asdt (r_to_t (real_part b)) (r_to_t (im_part a))))))).
Axiom decomp_mult_real_part :
forall (a:t) (b:t),
((real_part (infix_asdt a b)) =
(infix_mnas (infix_asas (real_part a) (real_part b))
(infix_asas (im_part a) (im_part b)))).
Axiom decomp_mult_im_part :
forall (a:t) (b:t),
((im_part (infix_asdt a b)) =
(infix_plas (infix_asas (real_part a) (im_part b))
(infix_asas (real_part b) (im_part a)))).
Parameter t_real_part: t -> t.
Axiom t_real_part_def :
forall (x:t), ((t_real_part x) = (r_to_t (real_part x))).
Axiom t_real_part_spec : forall (x:t), real_ (t_real_part x).
Axiom t_real_part_inv :
forall (x:t),
((t_real_part (prefix_mndt x)) = (prefix_mndt (t_real_part x))).
Axiom lower_inv :
forall (a:t) (b:t) (c:t), (infix_lsdt tzero b) -> (infix_lseqdt tzero a) ->
(infix_lseqdt b c) -> infix_gteqdt (infix_sldt a b) (infix_sldt a c).
Axiom assoc_mult_div :
forall (x:t) (y:t) (z:t), ~ (z = tzero) ->
((infix_asdt x (infix_sldt y z)) = (infix_sldt (infix_asdt x y) z)).
Axiom transitive_infeq :
forall (a:t) (b:t) (c:t), (infix_lseqdt a b) -> (infix_lseqdt b c) ->
infix_lseqdt a c.
Axiom transitive_supeq :
forall (a:t) (b:t) (c:t), (infix_gteqdt a b) -> (infix_gteqdt b c) ->
infix_gteqdt a c.
Axiom compat_mult_sup_eq_right :
forall (a:t) (b:t) (c:t), (infix_lseqdt tzero a) -> (infix_gteqdt b c) ->
infix_gteqdt (infix_asdt a b) (infix_asdt a c).
Axiom infeq_to_supeq :
forall (a:t) (b:t), (infix_lseqdt a b) -> infix_gteqdt b a.
Axiom lower_over_cons :
forall (a:t) (b:t) (c:t), (infix_lsdt tzero c) -> (infix_lseqdt tzero a) ->
(infix_lseqdt a b) -> infix_lseqdt (infix_sldt a c) (infix_sldt b c).
Parameter t_im_part: t -> t.
Axiom t_im_part_def : forall (x:t), ((t_im_part x) = (r_to_t (im_part x))).
Axiom t_im_part_spec : forall (x:t), real_ (t_im_part x).
Axiom t_im_part_inv :
forall (x:t), ((t_im_part (prefix_mndt x)) = (prefix_mndt (t_im_part x))).
Axiom t_mult_real :
forall (a:t) (b:t),
((t_real_part (infix_asdt a b)) =
(infix_mndt (infix_asdt (t_real_part a) (t_real_part b))
(infix_asdt (t_im_part a) (t_im_part b)))).
Axiom t_im_real :
forall (a:t) (b:t),
((t_im_part (infix_asdt a b)) =
(infix_pldt (infix_asdt (t_real_part a) (t_im_part b))
(infix_asdt (t_im_part a) (t_real_part b)))).
Axiom t_decomp_mult :
forall (a:t) (b:t),
((infix_asdt a b) =
(infix_pldt
(infix_mndt (infix_asdt (t_real_part a) (t_real_part b))
(infix_asdt (t_im_part a) (t_im_part b)))
(infix_asdt im
(infix_pldt (infix_asdt (t_real_part a) (t_im_part b))
(infix_asdt (t_im_part a) (t_real_part b)))))).
Axiom t_complex_decomp :
forall (i:t),
(i = (infix_pldt (t_real_part i) (infix_asdt im (t_im_part i)))).
Axiom t_unic_decomp :
forall (i:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(i = (infix_pldt a (infix_asdt im b))) -> (a = (t_real_part i)).
Axiom t_unic_decomp1 :
forall (i:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(i = (infix_pldt a (infix_asdt im b))) -> (b = (t_im_part i)).
Axiom t_decomp_minus :
forall (i:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(i = (infix_mndt a (infix_asdt im b))) -> (a = (t_real_part i)).
Axiom t_decomp_minus1 :
forall (i:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(i = (infix_mndt a (infix_asdt im b))) -> ((prefix_mndt b) = (t_im_part i)).
Axiom real_sum :
forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_pldt x y).
Axiom real_diff :
forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_mndt x y).
Axiom pure_im_sum :
forall (x:t) (y:t), (pure_im_ x) -> (pure_im_ y) ->
pure_im_ (infix_pldt x y).
Axiom equal_decomp :
forall (x:t) (y:t), ((real_part x) = (real_part y)) ->
((im_part x) = (im_part y)) -> (x = y).
Axiom t_equal_decomp :
forall (x:t) (y:t), ((t_real_part x) = (t_real_part y)) ->
((t_im_part x) = (t_im_part y)) -> (x = y).
Axiom pure_im_diff :
forall (x:t) (y:t), (pure_im_ x) -> (pure_im_ y) ->
pure_im_ (infix_mndt x y).
Axiom real_mult :
forall (x:t) (y:t), (real_ x) -> (real_ y) -> real_ (infix_asdt x y).
Axiom real_inv :
forall (x:t), (real_ x) -> ~ (x = tzero) -> real_ (infix_sldt tone x).
Axiom real_div :
forall (x:t) (y:t), (real_ x) -> ~ (y = tzero) -> (real_ y) ->
real_ (infix_sldt x y).
Axiom mult_real_real :
forall (a:t) (b:t), (real_ a) -> (real_ b) ->
((infix_asdt a b) =
(infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b)))).
Axiom mult_real_real1 :
forall (a:t) (b:t), (real_ a) -> (real_ b) ->
((infix_asdt (r_to_t (real_part a)) (r_to_t (real_part b))) =
(r_to_t (infix_asas (real_part a) (real_part b)))).
Axiom mult_real_real2 :
forall (a:t) (b:t), (real_ a) -> (real_ b) ->
((real_part (infix_asdt a b)) = (infix_asas (real_part a) (real_part b))).
Axiom mult_real_real3 :
forall (a:t) (b:t), (real_ a) -> (real_ b) ->
((im_part (infix_asdt a b)) = 0%R).
Axiom mult_im_im :
forall (a:t) (b:t), (pure_im_ a) -> (pure_im_ b) ->
((infix_asdt a b) =
(infix_asdt (infix_asdt im im)
(infix_asdt (r_to_t (im_part a)) (r_to_t (im_part b))))).
Axiom mult_im_im1 :
forall (a:t) (b:t), (pure_im_ a) -> (pure_im_ b) ->
((infix_asdt a b) =
(prefix_mndt (r_to_t (infix_asas (im_part a) (im_part b))))).
Axiom mult_im_im2 :
forall (a:t) (b:t), (pure_im_ a) -> (pure_im_ b) ->
((real_part (infix_asdt a b)) =
(prefix_mnas (infix_asas (im_part a) (im_part b)))).
Axiom mult_im_im3 :
forall (a:t) (b:t), (pure_im_ a) -> (pure_im_ b) ->
((im_part (infix_asdt a b)) = 0%R).
Axiom mult_real_im :
forall (a:t) (b:t), (real_ a) -> (pure_im_ b) ->
((infix_asdt a b) =
(infix_asdt im (infix_asdt (r_to_t (real_part a)) (r_to_t (im_part b))))).
Axiom mult_real_im1 :
forall (a:t) (b:t), (real_ a) -> (pure_im_ b) ->
((infix_asdt a b) =
(infix_asdt im (r_to_t (infix_asas (real_part a) (im_part b))))).
Axiom mult_real_im2 :
forall (a:t) (b:t), (real_ a) -> (pure_im_ b) ->
((real_part (infix_asdt a b)) = 0%R).
Axiom mult_real_im3 :
forall (a:t) (b:t), (real_ a) -> (pure_im_ b) ->
((im_part (infix_asdt a b)) = (infix_asas (real_part a) (im_part b))).
Axiom mult_im_real :
forall (a:t) (b:t), (pure_im_ a) -> (real_ b) ->
((infix_asdt a b) =
(infix_asdt im (infix_asdt (r_to_t (im_part a)) (r_to_t (real_part b))))).
Axiom mult_im_real1 :
forall (a:t) (b:t), (pure_im_ a) -> (real_ b) ->
((infix_asdt a b) =
(infix_asdt im (r_to_t (infix_asas (im_part a) (real_part b))))).
Axiom mult_im_real2 :
forall (a:t) (b:t), (pure_im_ a) -> (real_ b) ->
((real_part (infix_asdt a b)) = 0%R).
Axiom mult_im_real3 :
forall (a:t) (b:t), (pure_im_ a) -> (real_ b) ->
((im_part (infix_asdt a b)) = (infix_asas (im_part a) (real_part b))).
Axiom decomp_mult_gen :
forall (a:t) (b:t),
((real_part (infix_asdt a b)) =
(infix_mnas (infix_asas (real_part a) (real_part b))
(infix_asas (im_part a) (im_part b)))).
Axiom decomp_mult_gen1 :
forall (a:t) (b:t),
((im_part (infix_asdt a b)) =
(infix_plas (infix_asas (real_part a) (im_part b))
(infix_asas (im_part a) (real_part b)))).
Axiom inv_real :
forall (a:t), ~ (a = tzero) -> (real_ a) ->
((real_part (infix_sldt tone a)) = (infix_slas 1%R (real_part a))).
Axiom inv_real1 :
forall (a:t), ~ (a = tzero) -> (real_ a) -> real_ (infix_sldt tone a).
Axiom zeroLessOne : infix_lseqdt tzero tone.
Axiom compatOrderAdd :
forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> infix_lseqdt (infix_pldt x z) (infix_pldt y z).
Axiom strict_compatOrderAdd :
forall (x:t) (y:t) (z:t) (t1:t), (infix_lsdt x y) -> (infix_lsdt z t1) ->
(real_ x) -> (real_ y) -> (real_ z) -> (real_ t1) ->
infix_lsdt (infix_pldt x z) (infix_pldt y t1).
Axiom compat_order_mult :
forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lseqdt tzero z) ->
infix_lseqdt (infix_asdt x z) (infix_asdt y z).
Axiom strict_compat_order_mult :
forall (x:t) (y:t) (z:t), (infix_lsdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lsdt tzero z) ->
infix_lsdt (infix_asdt x z) (infix_asdt y z).
Axiom compat_order_mult_left :
forall (x:t) (y:t) (z:t), (infix_lseqdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lseqdt tzero z) ->
infix_lseqdt (infix_asdt x z) (infix_asdt y z).
Axiom strict_compat_order_mult_left :
forall (x:t) (y:t) (z:t), (infix_lsdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lsdt tzero z) ->
infix_lsdt (infix_asdt z x) (infix_asdt z y).
Axiom compat_sup_mult :
forall (x:t) (y:t) (z:t), (infix_gteqdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lseqdt tzero z) ->
infix_gteqdt (infix_asdt x z) (infix_asdt y z).
Axiom strict_compat_sup_mult :
forall (x:t) (y:t) (z:t), (infix_gtdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lsdt tzero z) ->
infix_gtdt (infix_asdt x z) (infix_asdt y z).
Axiom compat_sup_mult_left :
forall (x:t) (y:t) (z:t), (infix_gteqdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lseqdt tzero z) ->
infix_gteqdt (infix_asdt z x) (infix_asdt z y).
Axiom strict_compat_sup_mult_left :
forall (x:t) (y:t) (z:t), (infix_gtdt x y) -> (real_ x) -> (real_ y) ->
(real_ z) -> (infix_lsdt tzero z) ->
infix_gtdt (infix_asdt z x) (infix_asdt z y).
Axiom inv_eqinf :
forall (x:t) (y:t), (real_ x) -> (real_ y) ->
((infix_lsdt tzero x) /\ (infix_lseqdt x y)) ->
infix_gteqdt (infix_sldt tone x) (infix_sldt tone y).
Axiom inv_inf :
forall (x:t) (y:t), (real_ x) -> (real_ y) ->
((infix_lsdt tzero x) /\ (infix_lsdt x y)) ->
infix_gtdt (infix_sldt tone x) (infix_sldt tone y).
Axiom inv_eqsup :
forall (x:t) (y:t), (real_ x) -> (real_ y) ->
((infix_gteqdt x y) /\ (infix_gtdt y tzero)) ->
infix_lseqdt (infix_sldt tone x) (infix_sldt tone y).
Axiom inv_sup :
forall (x:t) (y:t), (real_ x) -> (real_ y) ->
((infix_gtdt x y) /\ (infix_gtdt y tzero)) ->
infix_lsdt (infix_sldt tone x) (infix_sldt tone y).
Axiom inv_pos :
forall (x:t), (real_ x) -> (infix_lsdt tzero x) ->
infix_gtdt (infix_sldt tone x) tzero.
Axiom inv_neg :
forall (x:t), (real_ x) -> (infix_gtdt tzero x) ->
infix_lsdt (infix_sldt tone x) tzero.
Axiom zero_add_t :
forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_pldt a1 a2) = a2).
Axiom add_zero_t :
forall (a1:t) (a2:t), (a2 = tzero) -> ((infix_pldt a1 a2) = a1).
Axiom one_mult_t :
forall (a1:t) (a2:t), (a1 = tone) -> ((infix_asdt a1 a2) = a2).
Axiom one_mult_t_const : forall (a:t), ((infix_asdt tone a) = a).
Axiom zero_mult_t_const : forall (a:t), ((infix_asdt tzero a) = tzero).
Axiom mult_zero_t_const : forall (a:t), ((infix_asdt a tzero) = tzero).
Axiom zero_mult_t :
forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_asdt a1 a2) = tzero).
Axiom mult_zero_t :
forall (a1:t) (a2:t), (a1 = tzero) -> ((infix_asdt a2 a1) = tzero).
Axiom mult_one_t :
forall (a1:t) (a2:t), (a2 = tone) -> ((infix_asdt a1 a2) = a1).
Axiom add_eq_t :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_pldt a1 b1) = (infix_pldt a2 b2)).
Axiom add_eq_t_rev :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_pldt a1 b1) = (infix_pldt b2 a2)).
Axiom subs_eq :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_mndt a1 b1) = (infix_mndt a2 b2)).
Axiom subst_itself :
forall (a1:t) (a2:t), (a1 = a2) -> ((infix_mndt a1 a2) = tzero).
Axiom add_op :
forall (a1:t) (a2:t), (a1 = (prefix_mndt a2)) ->
((infix_pldt a1 a2) = tzero).
Axiom mult_eq_t :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_asdt a1 b1) = (infix_asdt a2 b2)).
Axiom mult_eq_t_rev :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_asdt a1 b1) = (infix_asdt b2 a2)).
Axiom mult_comm : forall (a:t) (b:t), ((infix_asdt a b) = (infix_asdt b a)).
Axiom mult_assoc :
forall (a:t) (b:t) (c:t),
((infix_asdt (infix_asdt a b) c) = (infix_asdt a (infix_asdt b c))).
Axiom mult_assoc_rev :
forall (a:t) (b:t) (c:t),
((infix_asdt a (infix_asdt b c)) = (infix_asdt (infix_asdt a b) c)).
Axiom div_mult :
forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
((infix_asdt a (infix_sldt b c)) = (infix_sldt (infix_asdt a b) c)).
Axiom div_mult_rev :
forall (a:t) (b:t) (c:t), ~ (c = tzero) ->
((infix_sldt (infix_asdt a b) c) = (infix_asdt a (infix_sldt b c))).
Axiom triang_p :
forall (a:t) (b:t),
((infix_asdt (infix_pldt a b) (infix_pldt a b)) =
(infix_pldt
(infix_pldt (infix_asdt a a) (infix_asdt (infix_asdt ttwo a) b))
(infix_asdt b b))).
Axiom triang_n :
forall (a:t) (b:t),
((infix_asdt (infix_mndt a b) (infix_mndt a b)) =
(infix_pldt
(infix_mndt (infix_asdt a a) (infix_asdt (infix_asdt ttwo a) b))
(infix_asdt b b))).
Axiom triang_s :
forall (a:t) (b:t) (c:t) (d:t) (e:t),
((infix_pldt (infix_pldt (infix_pldt a b) c)
(infix_pldt (infix_mndt d b) e))
= (infix_pldt (infix_pldt a c) (infix_pldt d e))).
Axiom triang_t :
forall (a:t) (b:t),
((infix_asdt (infix_pldt a b) (infix_mndt a b)) =
(infix_mndt (infix_asdt a a) (infix_asdt b b))).
Axiom triang_sr :
forall (a:t) (b:t) (c:t) (d:t) (e:t),
((infix_pldt (infix_pldt (infix_mndt a b) c)
(infix_pldt (infix_pldt d b) e))
= (infix_pldt (infix_pldt a c) (infix_pldt d e))).
Axiom modulus_pre_pre :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_asdt a b) (infix_asdt c d))
(infix_pldt (infix_asdt a d) (infix_asdt c b)))
=
(infix_pldt (infix_asdt a (infix_pldt b d))
(infix_asdt c (infix_pldt b d)))).
Axiom modulus_pre_pre1 :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_asdt a b) (infix_asdt c d))
(infix_pldt (infix_asdt a d) (infix_asdt c b)))
= (infix_asdt (infix_pldt a c) (infix_pldt b d))).
Axiom modulus_pre :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt
(infix_pldt (infix_asdt (infix_asdt a b) (infix_asdt a b))
(infix_asdt (infix_asdt c d) (infix_asdt c d)))
(infix_pldt (infix_asdt (infix_asdt a d) (infix_asdt a d))
(infix_asdt (infix_asdt c b) (infix_asdt c b))))
=
(infix_asdt (infix_pldt (infix_asdt a a) (infix_asdt c c))
(infix_pldt (infix_asdt b b) (infix_asdt d d)))).
Parameter modulus: t -> t.
Axiom modulus_def :
forall (x:t),
((modulus x) =
(square_rt
(infix_pldt (infix_asdt (t_real_part x) (t_real_part x))
(infix_asdt (t_im_part x) (t_im_part x))))).
Axiom modulus_spec : forall (x:t), infix_lseqdt tzero (modulus x).
Parameter tone_modulus: t -> Prop.
Axiom tone_modulus_def :
forall (x:t), (tone_modulus x) -> ((modulus x) = tone).
Axiom tone_modulus_def1 :
forall (x:t), ((modulus x) = tone) -> tone_modulus x.
Axiom modulus_eq :
forall (x:t) (y:t),
((infix_asdt (t_real_part x) (t_real_part x)) =
(infix_asdt (t_real_part y) (t_real_part y))) ->
((infix_asdt (t_im_part x) (t_im_part x)) =
(infix_asdt (t_im_part y) (t_im_part y))) ->
((modulus x) = (modulus y)).
Axiom modulus_itself :
forall (x:t) (y:t), (x = y) -> ((modulus x) = (modulus y)).
Axiom strict_positive_modulus :
forall (x:t), ~ (x = tzero) -> infix_lsdt tzero (modulus x).
Axiom mult_modulus :
forall (x:t) (y:t),
((modulus (infix_asdt x y)) = (infix_asdt (modulus x) (modulus y))).
Axiom mult_tone_modulus :
forall (x:t) (y:t), (tone_modulus x) -> (tone_modulus y) ->
tone_modulus (infix_asdt x y).
Axiom div_eq :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
~ (b1 = tzero) -> ((infix_sldt a1 b1) = (infix_sldt a2 b2)).
Axiom add_eq_inv_t :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_pldt a1 b1) = (infix_pldt b2 a2)).
Axiom mult_eq_inv_t :
forall (a1:t) (a2:t) (b1:t) (b2:t), (a1 = a2) -> (b1 = b2) ->
((infix_asdt a1 b1) = (infix_asdt b2 a2)).
Axiom sum_frac :
forall (a1:t) (a2:t) (b:t), ~ (b = tzero) ->
((infix_pldt (infix_sldt a1 b) (infix_sldt a2 b)) =
(infix_sldt (infix_pldt a1 a2) b)).
Axiom sum_frac_rev :
forall (a1:t) (a2:t) (b:t), ~ (b = tzero) ->
((infix_sldt (infix_pldt a1 a2) b) =
(infix_pldt (infix_sldt a1 b) (infix_sldt a2 b))).
Parameter nonn_part:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (set a) -> (a -> im1) -> set a.
Parameter result2:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.
Axiom result_def2 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
(((result2 op1 t1) e) = true) <-> ~ (neutral op1 (t1 e)).
Axiom nonn_part_def :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1),
((nonn_part op1 s t1) = (filter (result2 op1 t1) s)).
Axiom nonn_part_spec :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (nonn_part op1 s t1)) -> mem e s.
Axiom nonn_part_spec1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (nonn_part op1 s t1)) -> ~ (neutral op1 (t1 e)).
Axiom nonn_part_spec2 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
((mem e s) /\ ~ (neutral op1 (t1 e))) -> mem e (nonn_part op1 s t1).
Parameter n_part:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (set a) -> (a -> im1) -> set a.
Parameter result3:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.
Axiom result_def3 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
(((result3 op1 t1) e) = true) <-> (neutral op1 (t1 e)).
Axiom n_part_def :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1),
((n_part op1 s t1) = (filter (result3 op1 t1) s)).
Axiom n_part_spec :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (n_part op1 s t1)) -> mem e s.
Axiom n_part_spec1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (n_part op1 s t1)) -> neutral op1 (t1 e).
Axiom n_part_spec2 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
((mem e s) /\ (neutral op1 (t1 e))) -> mem e (n_part op1 s t1).
Axiom nullity_partition :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
(s = (union (nonn_part op1 s t1) (n_part op1 s t1))).
Axiom nullity_partition1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
((inter (nonn_part op1 s t1) (n_part op1 s t1)) = (empty : set a)).
Axiom iterate_neutral :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
(commut op1) ->
(forall (a1:a), (mem a1 s) -> ((t1 a1) = (neutral_elt op1))) ->
((iterate op1 s t1) = (neutral_elt op1)).
Axiom iterate_nullity_partition :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
(commut op1) ->
((iterate op1 s t1) = (iterate op1 (nonn_part op1 s t1) t1)).
Parameter couple:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im1:Type} {im1_WT:WhyType im1},
(a -> b -> im1) -> (a* b)%type -> im1.
Axiom couple_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im1:Type} {im1_WT:WhyType im1},
forall (f:a -> b -> im1) (o:(a* b)%type), forall (x:a) (x1:b),
(o = (x, x1)) -> ((couple f o) = ((f x) x1)).
Axiom null_product :
forall (a:t) (b:t), ((infix_asdt a b) = tzero) ->
(a = tzero) \/ (b = tzero).
Axiom couple_value :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im1:Type} {im1_WT:WhyType im1},
forall (f:a -> b -> im1) (o:(a* b)%type),
((couple f o) = ((f (fir o)) (sec o))).
Axiom couple_value_dev :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im1:Type} {im1_WT:WhyType im1},
forall (f:a -> b -> im1) (o:(a* b)%type) (a1:a) (b1:b), (o = (a1, b1)) ->
((couple f o) = ((f a1) b1)).
Axiom neutral_tzero :
neutral (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) tzero.
Axiom neutral_tzero1 : iterable (fun (y0:t) (y1:t) => (infix_pldt y0 y1)).
Parameter sum: forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> t) -> t.
Axiom sum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
((sum s t1) = (iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) s t1)).
Parameter eq_t: t -> t -> Prop.
Axiom eq_t_def : forall (a:t) (a':t), (eq_t a a') -> (a = a').
Axiom eq_t_def1 : forall (a:t) (a':t), (a = a') -> eq_t a a'.
Axiom sum_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), (is_empty s) -> ((sum s t1) = tzero).
Axiom sum_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), ((cardinal s) = 1%Z) ->
((sum s t1) = (t1 (choose s))).
Axiom sum_add :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> t) (x:b), ~ (mem x s) ->
((sum (add x s) f) = (infix_pldt (f x) (sum s f))).
Axiom sum_plus_one :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> t), ((cardinal s) > 1%Z)%Z ->
((sum s f) = (infix_pldt (f (choose s)) (sum (remove (choose s) s) f))).
Axiom sum_real :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t), (forall (a1:a), (mem a1 s) -> real_ (f a1)) ->
((cardinal s) > 0%Z)%Z -> real_ (sum s f).
Axiom map_sum_eq :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> a) (t1:a -> t), (p_injective f s) ->
((sum (map f s) t1) = (sum s (fun (b1:b) => (t1 (f b1))))).
Axiom sum_comp :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> t) (g:b -> t),
((sum s (fun (k:b) => (infix_pldt (f k) (g k)))) =
(infix_pldt (sum s f) (sum s g))).
Axiom sum_iter_ :
opposite_n (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
(fun (y0:t) (y1:t) => (infix_mndt y0 y1)) tzero.
Axiom sum_iter_1 :
opposite (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
(fun (y0:t) (y1:t) => (infix_mndt y0 y1)).
Axiom sum_iter_2 :
opposite_com (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
(fun (y0:t) (y1:t) => (infix_mndt y0 y1)).
Axiom sum_iter_3 :
inverse_tuple (fun (y0:t) (y1:t) => (infix_pldt y0 y1))
(fun (y0:t) (y1:t) => (infix_mndt y0 y1)) tzero.
Axiom neutral_zero :
((neutral_elt (fun (y0:t) (y1:t) => (infix_pldt y0 y1))) = tzero).
Axiom sum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t) (g:a -> t),
(forall (x:a), (mem x s) -> ((f x) = (g x))) -> ((sum s f) = (sum s g)).
Axiom sum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> t) (g:a -> t), (s = s') ->
(forall (x:a), (mem x s) -> ((f x) = (g x))) -> ((sum s f) = (sum s' g)).
Axiom sum_disjoint_transitivity :
forall {a:Type} {a_WT:WhyType a},
forall (s1:set a) (s2:set a) (t1:a -> t),
((inter s1 s2) = (empty : set a)) ->
((sum (union s1 s2) t1) = (infix_pldt (sum s1 t1) (sum s2 t1))).
Axiom sum_to_cartesian_product :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (f:a -> b -> t),
((sum s1 (fun (a1:a) => (sum s2 (f a1)))) =
(sum (cartesian_product s1 s2)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).
Axiom sum_from_cartesian_product :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (f:a -> b -> t),
((sum (cartesian_product s1 s2)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))
= (sum s1 (fun (a1:a) => (sum s2 (f a1))))).
Parameter ind_sum: (Z -> t) -> Z -> Z -> t.
Axiom ind_sum_def :
forall (f:Z -> t) (i:Z) (j:Z),
((ind_sum f i j) =
(int_iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) f i j)).
Axiom ind_sum_to_int_iterate :
forall (f:Z -> t) (i:Z) (j:Z),
((ind_sum f i j) =
(int_iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) f i j)).
Axiom ind_sum_cardone :
forall (f:Z -> t) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
((ind_sum f i j) = (f i)).
Axiom ind_sum_right_extension :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
((ind_sum f i j) = (infix_pldt (ind_sum f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).
Axiom ind_sum_plus_one :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
((ind_sum f i j) = (infix_pldt (f i) (ind_sum f (i + 1%Z)%Z j))).
Axiom real_ind_sum :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> real_ (f k)) ->
real_ (ind_sum f i j).
Axiom ind_sum_eq :
forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ind_sum f i j) = (ind_sum g i j)).
Parameter fc3: (Z -> t) -> t -> Z -> Z -> Z -> t.
Axiom fc_def3 :
forall (f:Z -> t) (g:t) (i:Z) (j:Z) (k:Z),
(((i <= k)%Z /\ (k < j)%Z) -> (((fc3 f g i j) k) = (f k))) /\
(~ ((i <= k)%Z /\ (k < j)%Z) -> (((fc3 f g i j) k) = g)).
Axiom ind_sum_eq_del_bound :
forall (f:Z -> t) (g:t) (i:Z) (j:Z),
((ind_sum (fc3 f g i j) i j) = (ind_sum f i j)).
Parameter fc4: (Z -> t) -> t -> Z -> Z -> Z -> t.
Axiom fc_def4 :
forall (f:Z -> t) (g:t) (i:Z) (j:Z) (k:Z),
(((i <= k)%Z /\ (k < j)%Z) -> (((fc4 f g i j) k) = (f k))) /\
(~ ((i <= k)%Z /\ (k < j)%Z) -> (((fc4 f g i j) k) = g)).
Axiom ind_sum_eq_del_bound_rev :
forall (f:Z -> t) (g:t) (i:Z) (j:Z),
((ind_sum f i j) = (ind_sum (fc4 f g i j) i j)).
Axiom ind_sum_eq_gen :
forall (f:Z -> t) (g:Z -> t) (i1:Z) (j1:Z) (i2:Z) (j2:Z), (i1 = i2) ->
(j1 = j2) ->
(forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
((ind_sum f i1 j1) = (ind_sum g i2 j2)).
Axiom ind_sum_eq_bound :
forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z), (i = j) ->
(forall (k:Z), ((0%Z <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ind_sum f 0%Z i) = (ind_sum g 0%Z j)).
Axiom ind_sum_comp :
forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
((ind_sum (fun (k:Z) => (infix_pldt (f k) (g k))) i j) =
(infix_pldt (ind_sum f i j) (ind_sum g i j))).
Axiom ind_sum_to_iterate :
forall (f:Z -> t) (i:Z) (j:Z),
((ind_sum f i j) =
(iterate (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) (to_fset i j) f)).
Axiom ind_sum_to_sum :
forall (f:Z -> t) (i:Z) (j:Z), ((ind_sum f i j) = (sum (to_fset i j) f)).
Axiom map_ind_sum_eq :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> t),
(p_bijective f (to_fset i j) (to_fset k l)) ->
((ind_sum t1 k l) = (ind_sum (fun (b:Z) => (t1 (f b))) i j)).
Axiom sum_scal :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> t) (s:set a) (c:t),
((sum s (fun (x:a) => (infix_asdt c (f x)))) = (infix_asdt c (sum s f))).
Axiom sum_scal_right :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> t) (s:set a) (c:t),
((sum s (fun (x:a) => (infix_asdt (f x) c))) = (infix_asdt (sum s f) c)).
Axiom sum_scal_rev_right :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> t) (s:set a) (c:t),
((infix_asdt (sum s f) c) = (sum s (fun (x:a) => (infix_asdt (f x) c)))).
Axiom sum_scal_rev :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> t) (s:set a) (c:t),
((infix_asdt c (sum s f)) = (sum s (fun (x:a) => (infix_asdt c (f x))))).
Axiom ind_sum_scal :
forall (f:Z -> t) (i:Z) (j:Z) (a:t),
((ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j) =
(infix_asdt a (ind_sum f i j))).
Axiom ind_sum_scal_rev :
forall (f:Z -> t) (i:Z) (j:Z) (a:t),
((infix_asdt a (ind_sum f i j)) =
(ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j)).
Axiom scal_ind_sum :
forall (f:Z -> t) (i:Z) (j:Z) (a:t),
((ind_sum (fun (i1:Z) => (infix_asdt (f i1) a)) i j) =
(infix_asdt (ind_sum f i j) a)).
Axiom scal_ind_sum_rev :
forall (f:Z -> t) (i:Z) (j:Z) (a:t),
((infix_asdt (ind_sum f i j) a) =
(ind_sum (fun (i1:Z) => (infix_asdt (f i1) a)) i j)).
Axiom sum_scal_gen :
forall (f:Z -> t) (s:set Z), forall (a:t),
((sum s (fun (i:Z) => (infix_asdt a (f i)))) = (infix_asdt a (sum s f))).
Axiom ind_sum_scal_gen :
forall (f:Z -> t) (i:Z) (j:Z), forall (a:t),
((ind_sum (fun (i1:Z) => (infix_asdt a (f i1))) i j) =
(infix_asdt a (ind_sum f i j))).
Axiom int_int_iterate_def_empty :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(j <= i)%Z -> (iterable op1) ->
((int_int_iterate op1 f i j k l) = (neutral_elt op1)).
Axiom int_int_iterate_def_plus_one :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(i < j)%Z -> (iterable op1) ->
((int_int_iterate op1 f i j k l) =
((op1 (int_iterate op1 (fun (n:Z) => ((f i) n)) k l))
(int_int_iterate op1 f (i + 1%Z)%Z j k l))).
Axiom int_int_iterate_to_int_iterate :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(i <= j)%Z -> (iterable op1) ->
((int_int_iterate op1 f i j k l) =
(int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j)).
Axiom int_iterate_to_int_int_iterate :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(i <= j)%Z -> (iterable op1) ->
((int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j) =
(int_int_iterate op1 f i j k l)).
Axiom int_int_iterate_to_iterate :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(i <= j)%Z -> (iterable op1) -> (commut op1) ->
((int_int_iterate op1 f i j k l) =
(iterate op1 (cartesian_product (to_fset i j) (to_fset k l))
(fun (o:(Z* Z)%type) => ((f (fir o)) (sec o))))).
Axiom iterate_commute :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s1:set a) (s2:set b) (f:a -> b -> im1),
(iterable op1) -> (commut op1) ->
((iterate op1 (cartesian_product s1 s2)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))
=
(iterate op1 (cartesian_product s2 s1)
(fun (o:(b* a)%type) => ((f (sec o)) (fir o))))).
Axiom int_int_iterate_commute :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(iterable op1) -> (commut op1) -> (i <= j)%Z -> (k <= l)%Z ->
((int_int_iterate op1 f i j k l) =
(int_int_iterate op1 (fun (a:Z) (b:Z) => ((f b) a)) k l i j)).
Axiom int_iterate_commute :
forall {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (f:Z -> Z -> im1) (i:Z) (j:Z) (k:Z) (l:Z),
(iterable op1) -> (commut op1) -> (i <= j)%Z -> (k <= l)%Z ->
((int_iterate op1 (fun (a:Z) => (int_iterate op1 (f a) k l)) i j) =
(int_iterate op1
(fun (a:Z) => (int_iterate op1 (fun (b:Z) => ((f b) a)) i j)) k l)).
Axiom ind_sum_commute :
forall (f:Z -> Z -> t) (i:Z) (j:Z) (k:Z) (l:Z), (i <= j)%Z -> (k <= l)%Z ->
((ind_sum (fun (k1:Z) => (ind_sum (f k1) k l)) i j) =
(ind_sum (fun (k1:Z) => (ind_sum (fun (k2:Z) => ((f k2) k1)) i j)) k l)).
Axiom sum_commute :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b -> t) (sa:set a) (sb:set b),
((sum sa (fun (a1:a) => (sum sb (f a1)))) =
(sum sb (fun (b1:b) => (sum sa (fun (a1:a) => ((f a1) b1)))))).
Parameter non_tzero:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> t) -> set a.
Axiom non_tzero_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
((non_tzero s t1) =
(nonn_part (fun (y0:t) (y1:t) => (infix_pldt y0 y1)) s t1)).
Axiom non_tzero_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), forall (e:a), (mem e (non_tzero s t1)) ->
mem e s.
Axiom non_tzero_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), forall (e:a), (mem e (non_tzero s t1)) ->
~ ((t1 e) = tzero).
Axiom non_tzero_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), forall (e:a),
((mem e s) /\ ~ ((t1 e) = tzero)) -> mem e (non_tzero s t1).
Axiom get_non_tzero_member :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (e:a), (mem e (non_tzero s t1)) -> mem e s.
Axiom get_non_tzero_member1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (e:a), (mem e (non_tzero s t1)) ->
~ ((t1 e) = tzero).
Axiom set_non_tzero_member :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (e:a), (mem e s) -> ~ ((t1 e) = tzero) ->
mem e (non_tzero s t1).
Axiom set_non_tzero_member_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), forall (e:a),
((mem e s) /\ ~ ((t1 e) = tzero)) -> mem e (non_tzero s t1).
Axiom set_non_tzero_member_gen_ :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), forall (e:a),
((mem e s) /\ ~ ((t1 e) = tzero)) -> mem e (non_tzero s t1).
Axiom sum_nullity_partition :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), ((sum s t1) = (sum (non_tzero s t1) t1)).
Axiom non_null_map :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> a) (t1:a -> t),
((non_tzero (map f s) t1) =
(map f (non_tzero s (fun (b:a) => (t1 (f b)))))).
Axiom map_sum_eq_nonnull :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> a) (t1:a -> t),
(p_bijective f (non_tzero s (fun (b:a) => (t1 (f b))))
(non_tzero (map f s) t1)) ->
((sum (non_tzero (map f s) t1) t1) =
(sum (non_tzero s (fun (b:a) => (t1 (f b)))) (fun (b:a) => (t1 (f b))))).
Axiom sum_null_but_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), ((cardinal (non_tzero s t1)) = 1%Z) ->
((sum s t1) = (t1 (element (non_tzero s t1)))).
Axiom sum_null :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t), ((cardinal (non_tzero s t1)) = 0%Z) ->
((sum s t1) = tzero).
Axiom sum_null_ :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
(forall (e:a), (mem e s) -> ((t1 e) = tzero)) -> ((sum s t1) = tzero).
Axiom sum_null_forall :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
(forall (e:a), (mem e s) -> ((t1 e) = tzero)) -> ((sum s t1) = tzero).
Axiom ind_sum_null :
forall (t1:Z -> t) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((t1 k) = tzero)) ->
((ind_sum t1 i j) = tzero).
Axiom sum_null_but_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (elt:a),
((mem elt s) /\ ~ ((t1 elt) = tzero)) ->
(forall (a1:a), (mem a1 s) -> ~ (a1 = elt) -> ((t1 a1) = tzero)) ->
((sum s t1) = (t1 elt)).
Axiom sum_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (t1:a -> t) (s:set a) (elt:a), (mem elt s) ->
(forall (k:a), (mem k s) -> ~ (k = elt) -> ((t1 k) = tzero)) ->
((sum s t1) = (t1 elt)).
Axiom ind_sum_null_but_maybe_one_elt :
forall (t1:Z -> t) (i:Z) (j:Z) (ind:Z), ((i <= ind)%Z /\ (ind < j)%Z) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ~ (k = ind) ->
((t1 k) = tzero)) ->
((ind_sum t1 i j) = (t1 ind)).
Axiom neutral_tone : neutral (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone.
Axiom neutral_tone1 : iterable (fun (y0:t) (y1:t) => (infix_asdt y0 y1)).
Axiom product_iter :
op_neutral_left (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone.
Axiom product_iter1 :
op_neutral_right (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone.
Axiom product_iter2 : op_assoc (fun (y0:t) (y1:t) => (infix_asdt y0 y1)).
Axiom product_iter3 : commut (fun (y0:t) (y1:t) => (infix_asdt y0 y1)).
Axiom product_iter4 :
iterates (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) tone.
Parameter product:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> t) -> t.
Axiom product_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
((product s t1) = (iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) s t1)).
Axiom product_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (t':a -> t),
(forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
((product s t1) = (product s t')).
Axiom product_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (t1:a -> t) (t':a -> t), (s = s') ->
(forall (e:a), (mem e s) -> ((t1 e) = (t' e))) ->
((product s t1) = (product s' t')).
Axiom product_empty :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t), (is_empty s) -> ((product s f) = tone).
Axiom product_iter_ : iterable (fun (y0:t) (y1:t) => (infix_asdt y0 y1)).
Axiom add_product :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t) (x:a), ~ (mem x s) ->
((product (add x s) f) = (infix_asdt (f x) (product s f))).
Axiom product_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t) (x:a), ~ (mem x s) ->
((product (add x s) f) = (infix_asdt (product s f) (f x))).
Axiom neutral_one :
((neutral_elt (fun (y0:t) (y1:t) => (infix_asdt y0 y1))) = tone).
Parameter ind_product: (Z -> t) -> Z -> Z -> t.
Axiom ind_product_def :
forall (f:Z -> t) (i:Z) (j:Z),
((ind_product f i j) =
(int_iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1)) f i j)).
Axiom ind_product_eq :
forall (f:Z -> t) (g:Z -> t) (i:Z) (j:Z),
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ind_product f i j) = (ind_product g i j)).
Axiom ind_product_cardone :
forall (f:Z -> t) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
((ind_product f i j) = (f i)).
Axiom ind_product_eq_gen :
forall (f:Z -> t) (g:Z -> t) (i1:Z) (j1:Z) (i2:Z) (j2:Z),
(forall (k:Z), ((i1 <= k)%Z /\ (k < j1)%Z) -> ((f k) = (g k))) ->
(i1 = i2) -> (j1 = j2) -> ((ind_product f i1 j1) = (ind_product g i2 j2)).
Axiom ind_product_right_extension :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
((ind_product f i j) =
(infix_asdt (ind_product f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).
Axiom ind_product_left_extension :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
((ind_product f i j) = (infix_asdt (f i) (ind_product f (i + 1%Z)%Z j))).
Axiom ind_product_to_product :
forall (f:Z -> t) (i:Z) (j:Z),
((ind_product f i j) = (product (to_fset i j) f)).
Axiom map_product_eq :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> a) (t1:a -> t), (p_injective f s) ->
((product (map f s) t1) = (product s (fun (b1:b) => (t1 (f b1))))).
Axiom map_ind_product_eq :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> t),
(p_bijective f (to_fset i j) (to_fset k l)) ->
((ind_product t1 k l) = (ind_product (fun (b:Z) => (t1 (f b))) i j)).
Axiom ind_product_right_extension_comm :
forall (f:Z -> t) (i:Z) (j:Z), (i < j)%Z ->
((infix_asdt (ind_product f i (j - 1%Z)%Z) (f (j - 1%Z)%Z)) =
(ind_product f i j)).
Axiom ind_product_eq_func :
forall (i:Z) (j:Z) (f1:Z -> t) (f2:Z -> t),
(p_injective f1 (to_fset i j)) -> (p_injective f2 (to_fset i j)) ->
((map f1 (to_fset i j)) = (map f2 (to_fset i j))) ->
((ind_product f1 i j) = (ind_product f2 i j)).
Axiom ind_product_trans :
forall (f:Z -> t) (i:Z) (k:Z) (j:Z), ((i <= k)%Z /\ (k <= j)%Z) ->
((ind_product f i j) =
(infix_asdt (ind_product f i k) (ind_product f k j))).
Axiom ind_product_zero_pre :
forall (f:Z -> t) (i:Z) (t1:Z) (j:Z), ((i <= t1)%Z /\ (t1 < j)%Z) ->
((f t1) = tzero) -> ((ind_product f i j) = tzero).
Axiom ind_product_zero :
forall (f:Z -> t) (i:Z) (j:Z), (i <= j)%Z ->
(exists t1:Z, ((i <= t1)%Z /\ (t1 < j)%Z) /\ ((f t1) = tzero)) ->
((ind_product f i j) = tzero).
Axiom ind_product_zero_elt :
forall (f:Z -> t) (i:Z) (j:Z) (t1:Z), (i <= j)%Z ->
((i <= t1)%Z /\ (t1 < j)%Z) -> ((f t1) = tzero) ->
((ind_product f i j) = tzero).
Axiom ind_product_const_tone :
forall (f:Z -> t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (t1:Z), ((i <= t1)%Z /\ (t1 < j)%Z) -> ((f t1) = tone)) ->
((ind_product f i j) = tone).
Axiom div_plus_one :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
(((int.EuclideanDivision.div i j) * j)%Z <= i)%Z.
Axiom div_plus_one1 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
(i < (((int.EuclideanDivision.div i j) + 1%Z)%Z * j)%Z)%Z.
Axiom zero_add : forall (a1:Z) (a2:Z), (a1 = 0%Z) -> ((a1 + a2)%Z = a2).
Axiom add_zero : forall (a1:Z) (a2:Z), (a2 = 0%Z) -> ((a1 + a2)%Z = a1).
Axiom one_mult : forall (a1:Z) (a2:Z), (a1 = 1%Z) -> ((a1 * a2)%Z = a2).
Axiom mult_one : forall (a1:Z) (a2:Z), (a2 = 1%Z) -> ((a1 * a2)%Z = a1).
Axiom add_eq :
forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
((a1 + b1)%Z = (a2 + b2)%Z).
Axiom mult_eq :
forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
((a1 * b1)%Z = (a2 * b2)%Z).
Axiom add_eq_inv :
forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
((a1 + b1)%Z = (b2 + a2)%Z).
Axiom mult_eq_inv :
forall (a1:Z) (a2:Z) (b1:Z) (b2:Z), (a1 = a2) -> (b1 = b2) ->
((a1 * b1)%Z = (b2 * a2)%Z).
Axiom bound_eq :
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < j)%Z) ->
(i = (int.EuclideanDivision.mod1 i j)).
Axiom bound_eq_rev :
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < j)%Z) ->
((int.EuclideanDivision.mod1 i j) = i).
Axiom unicity_div_mod :
forall (i:Z) (j:Z) (q:Z) (r:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z ->
(0%Z <= r)%Z -> (0%Z < j)%Z -> (i = ((q * j)%Z + r)%Z) ->
((0%Z <= r)%Z /\ (r < j)%Z) -> (q = (int.EuclideanDivision.div i j)).
Axiom unicity_div_mod1 :
forall (i:Z) (j:Z) (q:Z) (r:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z ->
(0%Z <= r)%Z -> (0%Z < j)%Z -> (i = ((q * j)%Z + r)%Z) ->
((0%Z <= r)%Z /\ (r < j)%Z) -> (r = (int.EuclideanDivision.mod1 i j)).
Axiom unicity_div_gen :
forall (j:Z) (q:Z), (0%Z <= q)%Z -> (0%Z < j)%Z -> forall (i:Z),
(0%Z <= i)%Z ->
((0%Z <= (i - (q * j)%Z)%Z)%Z /\ ((i - (q * j)%Z)%Z < j)%Z) ->
(q = (int.EuclideanDivision.div i j)).
Axiom unicity_div_gen1 :
forall (j:Z) (q:Z), (0%Z <= q)%Z -> (0%Z < j)%Z -> forall (i:Z),
(0%Z <= i)%Z ->
((0%Z <= (i - (q * j)%Z)%Z)%Z /\ ((i - (q * j)%Z)%Z < j)%Z) ->
((i - (j * q)%Z)%Z = (int.EuclideanDivision.mod1 i j)).
Axiom bound_mod :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
(0%Z <= (int.EuclideanDivision.mod1 i j))%Z.
Axiom bound_mod1 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((int.EuclideanDivision.mod1 i j) < j)%Z.
Axiom mod_eq :
forall (a:Z) (b:Z) (d:Z), (a = b) ->
((int.EuclideanDivision.mod1 a d) = (int.EuclideanDivision.mod1 b d)).
Axiom e_div_eq :
forall (a:Z) (b:Z) (d:Z), (a = b) ->
((int.EuclideanDivision.div a d) = (int.EuclideanDivision.div b d)).
Axiom decomp :
forall (i:Z) (j:Z), ~ (0%Z = j) ->
(i =
((j * (int.EuclideanDivision.div i j))%Z +
(int.EuclideanDivision.mod1 i j))%Z).
Axiom div_mod_eq :
forall (i:Z) (j:Z) (q:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z -> (0%Z < q)%Z ->
((int.EuclideanDivision.div i q) = (int.EuclideanDivision.div j q)) ->
((int.EuclideanDivision.mod1 i q) = (int.EuclideanDivision.mod1 j q)) ->
(i = j).
Axiom mod_zero :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((int.EuclideanDivision.mod1 i j) = 0%Z) ->
(i = (j * (int.EuclideanDivision.div i j))%Z).
Axiom div_plus_quotient :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((int.EuclideanDivision.div (i + j)%Z j) =
((int.EuclideanDivision.div i j) + 1%Z)%Z).
Axiom div_plus_fact_gen_div :
forall (i:Z) (j:Z) (k:Z), (0%Z < j)%Z ->
((int.EuclideanDivision.div (i + (k * j)%Z)%Z j) =
((int.EuclideanDivision.div i j) + k)%Z).
Axiom mod_plus_fact_gen_mod :
forall (i:Z) (j:Z) (k:Z), (0%Z < j)%Z ->
((int.EuclideanDivision.mod1 ((k * j)%Z + i)%Z j) =
(int.EuclideanDivision.mod1 i j)).
Axiom bound_div :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
(i < (f * q)%Z)%Z -> (0%Z <= (int.EuclideanDivision.div i q))%Z.
Axiom bound_div1 :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
(i < (f * q)%Z)%Z -> (0%Z <= ((int.EuclideanDivision.div i q) * q)%Z)%Z.
Axiom bound_div2 :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
(i < (f * q)%Z)%Z -> (((int.EuclideanDivision.div i q) * q)%Z <= i)%Z.
Axiom bound_div3 :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
(i < (f * q)%Z)%Z ->
(i < (q * ((int.EuclideanDivision.div i q) + 1%Z)%Z)%Z)%Z.
Axiom bound_div4 :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z <= q)%Z -> (0%Z <= f)%Z ->
(i < (f * q)%Z)%Z -> ((int.EuclideanDivision.div i q) < f)%Z.
Axiom mod_upper_bound :
forall (i:Z) (q:Z), (0%Z < i)%Z -> (i = q) ->
((int.EuclideanDivision.mod1 i q) = 0%Z).
Axiom bound_div_gen :
forall (q:Z) (f:Z), (0%Z < q)%Z -> (0%Z <= f)%Z -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (q * f)%Z)%Z) ->
((int.EuclideanDivision.div i q) < f)%Z.
Axiom mod_invariant :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < q)%Z -> (0%Z < f)%Z ->
((int.EuclideanDivision.mod1
((q * (f * (int.EuclideanDivision.div i (q * f)%Z))%Z)%Z +
(int.EuclideanDivision.mod1 i (q * f)%Z))%Z
q)
= (int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (q * f)%Z) q)).
Axiom mod_inf :
forall (i:Z) (q:Z), ((0%Z <= i)%Z /\ (i < q)%Z) ->
((int.EuclideanDivision.mod1 i q) = i).
Axiom mod_mod_left :
forall (i:Z) (j:Z) (f:Z), (0%Z < j)%Z -> (0%Z < f)%Z ->
((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (f * j)%Z) j) =
(int.EuclideanDivision.mod1 i j)).
Axiom mod_mod_i :
forall (i:Z) (j:Z), (0%Z < j)%Z ->
((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i j) j) =
(int.EuclideanDivision.mod1 i j)).
Axiom binary_prod :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((int.EuclideanDivision.mod1
((int.EuclideanDivision.mod1 i 2%Z) *
(int.EuclideanDivision.mod1 j 2%Z))%Z
2%Z)
= (int.EuclideanDivision.mod1 (i * j)%Z 2%Z)).
Axiom add_mod :
forall (a:Z) (b:Z) (c:Z), (c > 0%Z)%Z ->
((int.EuclideanDivision.mod1
((int.EuclideanDivision.mod1 a c) + (int.EuclideanDivision.mod1 b c))%Z
c)
= (int.EuclideanDivision.mod1 (a + b)%Z c)).
Axiom mod_mod_right :
forall (i:Z) (j:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < f)%Z ->
((int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j * f)%Z) j) =
(int.EuclideanDivision.mod1 i j)).
Axiom mod_mod_rev :
forall (i:Z) (j:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < f)%Z ->
((int.EuclideanDivision.mod1 i j) =
(int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j * f)%Z) j)).
Axiom mod_mod_rev1 :
forall (i:Z) (j:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < f)%Z ->
((int.EuclideanDivision.mod1 i j) =
(int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (f * j)%Z) j)).
Axiom mod_mod_plus :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((int.EuclideanDivision.mod1 i j) =
(int.EuclideanDivision.mod1 (int.EuclideanDivision.mod1 i (j + j)%Z) j)).
Axiom mult_assoc1 :
forall (i:Z) (q:Z) (f:Z), (0%Z <= i)%Z -> (0%Z < q)%Z -> (0%Z < f)%Z ->
((q * (f * (int.EuclideanDivision.div i (q * f)%Z))%Z)%Z =
((q * f)%Z * (int.EuclideanDivision.div i (q * f)%Z))%Z).
Axiom div_div1 :
forall (i:Z) (j:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < k)%Z ->
((int.EuclideanDivision.div (int.EuclideanDivision.div i k) j) =
(int.EuclideanDivision.div i (k * j)%Z)).
Axiom div_div2 :
forall (i:Z) (j:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < k)%Z ->
((int.EuclideanDivision.div (int.EuclideanDivision.div i k) j) =
(int.EuclideanDivision.div i (j * k)%Z)).
Axiom mod_div :
forall (i:Z) (j:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (0%Z < k)%Z ->
((int.EuclideanDivision.div (int.EuclideanDivision.mod1 i (j * k)%Z) j) =
(int.EuclideanDivision.mod1 (int.EuclideanDivision.div i j) k)).
Axiom inf_mul :
forall (ia:Z) (ib:Z) (a:Z) (b:Z), ((0%Z <= ia)%Z /\ (ia < a)%Z) ->
((0%Z <= ib)%Z /\ (ib < b)%Z) -> (((a * ib)%Z + ia)%Z < (a * b)%Z)%Z.
Axiom inf_mul1 :
forall (ia:Z) (ib:Z) (a:Z) (b:Z), ((0%Z <= ia)%Z /\ (ia < a)%Z) ->
((0%Z <= ib)%Z /\ (ib < b)%Z) -> (((ib * a)%Z + ia)%Z < (b * a)%Z)%Z.
Axiom inf_mul_gen :
forall (n:Z) (v:Z) (p:Z), ((0%Z <= p)%Z /\ (p < v)%Z) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < n)%Z) -> (((k * v)%Z + p)%Z < (n * v)%Z)%Z.
Axiom inf_mul_gen_b :
forall (n:Z) (v:Z) (p:Z), ((0%Z <= p)%Z /\ (p < n)%Z) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < v)%Z) -> (((p * v)%Z + k)%Z < (n * v)%Z)%Z.
Axiom inf_mul_comm :
forall (i:Z) (bi:Z) (quot:Z) (rest:Z), ((0%Z <= i)%Z /\ (i < bi)%Z) ->
(0%Z < rest)%Z -> (0%Z < quot)%Z -> (bi = (quot * rest)%Z) ->
((int.EuclideanDivision.mod1 i rest) < rest)%Z.
Parameter nonn_part1:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (set a) -> (a -> im1) -> set a.
Parameter result4:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.
Axiom result_def4 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
(((result4 op1 t1) e) = true) <-> ~ (neutral op1 (t1 e)).
Axiom nonn_part_def1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1),
((nonn_part1 op1 s t1) = (filter (result4 op1 t1) s)).
Axiom nonn_part_spec3 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (nonn_part1 op1 s t1)) -> mem e s.
Axiom nonn_part_spec4 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (nonn_part1 op1 s t1)) -> ~ (neutral op1 (t1 e)).
Axiom nonn_part_spec5 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
((mem e s) /\ ~ (neutral op1 (t1 e))) -> mem e (nonn_part1 op1 s t1).
Parameter n_part1:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (set a) -> (a -> im1) -> set a.
Parameter result5:
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
(im1 -> im1 -> im1) -> (a -> im1) -> a -> bool.
Axiom result_def5 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (t1:a -> im1) (e:a),
(((result5 op1 t1) e) = true) <-> (neutral op1 (t1 e)).
Axiom n_part_def1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1),
((n_part1 op1 s t1) = (filter (result5 op1 t1) s)).
Axiom n_part_spec3 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (n_part1 op1 s t1)) -> mem e s.
Axiom n_part_spec4 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
(mem e (n_part1 op1 s t1)) -> neutral op1 (t1 e).
Axiom n_part_spec5 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), forall (e:a),
((mem e s) /\ (neutral op1 (t1 e))) -> mem e (n_part1 op1 s t1).
Axiom nullity_partition2 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
(s = (union (nonn_part1 op1 s t1) (n_part1 op1 s t1))).
Axiom nullity_partition3 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (commut op1) ->
((inter (nonn_part1 op1 s t1) (n_part1 op1 s t1)) = (empty : set a)).
Axiom iterate_neutral1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
(commut op1) ->
(forall (a1:a), (mem a1 s) -> ((t1 a1) = (neutral_elt op1))) ->
((iterate op1 s t1) = (neutral_elt op1)).
Axiom iterate_nullity_partition1 :
forall {a:Type} {a_WT:WhyType a} {im1:Type} {im1_WT:WhyType im1},
forall (op1:im1 -> im1 -> im1) (s:set a) (t1:a -> im1), (iterable op1) ->
(commut op1) ->
((iterate op1 s t1) = (iterate op1 (nonn_part1 op1 s t1) t1)).
Parameter indic: forall {a:Type} {a_WT:WhyType a}, a -> a -> t.
Axiom indic_spec :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a),
((a1 = a') -> ((indic a1 a') = tone)) /\
(~ (a1 = a') -> ((indic a1 a') = tzero)).
Axiom get_indic :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a),
((a1 = a') -> ((indic a1 a') = tone)) /\
(~ (a1 = a') -> ((indic a1 a') = tzero)).
Parameter indic_bool: forall {a:Type} {a_WT:WhyType a}, a -> a -> bool.
Axiom indic_bool_spec :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a),
((a1 = a') -> ((indic_bool a1 a') = true)) /\
(~ (a1 = a') -> ((indic_bool a1 a') = false)).
Axiom indic_comm :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (a':a), ((indic a1 a') = (indic a' a1)).
Axiom indic_transl_r :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (b:a) (c:a), (b = c) -> ((indic a1 b) = (indic a1 c)).
Axiom indic_transl_l :
forall {a:Type} {a_WT:WhyType a},
forall (a1:a) (b:a) (c:a), (b = c) -> ((indic b a1) = (indic c a1)).
Parameter indic_2:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, a -> a -> b ->
b -> t.
Axiom indic_2_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
(((indic_bool a1 a') = true) /\ ((indic_bool b1 b') = true)) ->
((indic_2 a1 a' b1 b') = tone).
Axiom indic_2_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b), ~ ((indic_bool a1 a') = true) ->
((indic_2 a1 a' b1 b') = tzero).
Axiom indic_2_def2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b), ~ ((indic_bool b1 b') = true) ->
((indic_2 a1 a' b1 b') = tzero).
Axiom indic_2_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
((indic_2 a1 a' b1 b') = (infix_asdt (indic a1 a') (indic b1 b'))).
Axiom indic_2_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
((indic_2 a1 a' b1 b') = (indic (a1, b1) (a', b'))).
Axiom indic_2_if :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (i:a) (k:a) (j:b) (l:b),
(((i = k) /\ (j = l)) -> ((indic_2 i k j l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((indic_2 i k j l) = tzero)).
Axiom indic_2_comm :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
((indic_2 a1 a' b1 b') = (indic_2 a' a1 b1 b')).
Axiom indic_2_comm1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
((indic_2 a1 a' b1 b') = (indic_2 a1 a' b' b1)).
Axiom indic_2_comm2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (a1:a) (a':a) (b1:b) (b':b),
((indic_2 a1 a' b1 b') = (indic_2 a' a1 b' b1)).
Parameter sum_indic:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> t) -> a -> t.
Axiom sum_indic_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (i:a),
((sum_indic s t1 i) =
(sum s (fun (e:a) => (infix_asdt (t1 e) (indic i e))))).
Parameter ind_sum_indic: (Z -> t) -> Z -> Z -> Z -> t.
Axiom ind_sum_indic_def :
forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), (l < h)%Z ->
((ind_sum_indic t1 l h i) =
(ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h)).
Axiom ind_sum_indic_spec :
forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), (l < h)%Z ->
((ind_sum_indic t1 l h i) = (sum_indic (to_fset l h) t1 i)).
Axiom sum_indic_t :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (i:a), (mem i s) ->
((sum_indic s t1 i) = (t1 i)).
Axiom sum_indic_ts :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (i:a), (mem i s) ->
((sum s (fun (e:a) => (infix_asdt (t1 e) (indic i e)))) = (t1 i)).
Axiom ind_sum_indic_t :
forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), ((l <= i)%Z /\ (i < h)%Z) ->
((ind_sum_indic t1 l h i) = (t1 i)).
Axiom ind_sum_indic_t1 :
forall (t1:Z -> t) (l:Z) (h:Z) (i:Z), ((l <= i)%Z /\ (i < h)%Z) ->
((ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h) = (t1 i)).
Axiom ind_sum_indic_t_quant :
forall (t1:Z -> t) (l:Z) (h:Z), forall (i:Z), ((l <= i)%Z /\ (i < h)%Z) ->
((ind_sum (fun (e:Z) => (infix_asdt (t1 e) (indic i e))) l h) = (t1 i)).
Axiom indic_div_mod :
forall (i:Z) (j:Z) (q:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z -> (0%Z < q)%Z ->
((indic i j) =
(infix_asdt
(indic (int.EuclideanDivision.mod1 i q) (int.EuclideanDivision.mod1 j q))
(indic (int.EuclideanDivision.div i q) (int.EuclideanDivision.div j q)))).
Axiom indic_div_mod_gen :
forall (q:Z), (0%Z < q)%Z -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (0%Z <= j)%Z) ->
((indic i j) =
(infix_asdt
(indic (int.EuclideanDivision.mod1 i q) (int.EuclideanDivision.mod1 j q))
(indic (int.EuclideanDivision.div i q) (int.EuclideanDivision.div j q)))).
Axiom set_inf : True.
Axiom set_infeq : True.
Axiom bounded_cycle :
forall (a:Z) (b:Z) (c:Z) (d:Z), (0%Z <= a)%Z -> (0%Z < b)%Z ->
((0%Z <= d)%Z /\ (d < b)%Z) -> (0%Z < c)%Z ->
((int.EuclideanDivision.div ((a * b)%Z + d)%Z (b * c)%Z) =
(int.EuclideanDivision.div a c)).
Axiom power_minus_one2 :
forall (i:Z), (i >= 0%Z)%Z -> ((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) ->
((power (-1%Z)%Z i) = 1%Z).
Axiom power_minus_one3 :
forall (i:Z), (i >= 0%Z)%Z -> ((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
((power (-1%Z)%Z i) = (-1%Z)%Z).
Parameter kth_right: Z -> Z -> Z -> (Z -> Z) -> Z.
Axiom kth_right_def :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (l:Z), (((h - k)%Z <= l)%Z /\ (l < h)%Z) -> (0%Z < (f l))%Z) ->
((kth_right i k h f) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (ind_iproduct f ((h - k)%Z + 1%Z)%Z h))
(f (h - k)%Z))).
Axiom kth_right_spec :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (l:Z), (((h - k)%Z <= l)%Z /\ (l < h)%Z) -> (0%Z < (f l))%Z) ->
(0%Z <= (kth_right i k h f))%Z.
Axiom kth_right_spec1 :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (l:Z), (((h - k)%Z <= l)%Z /\ (l < h)%Z) -> (0%Z < (f l))%Z) ->
((kth_right i k h f) < (f (h - k)%Z))%Z.
Axiom kth_right_eq :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z) (g:Z -> Z), (0%Z <= i)%Z ->
(1%Z <= k)%Z ->
(forall (l:Z), (((h - k)%Z <= l)%Z /\ (l <= h)%Z) -> (0%Z < (f l))%Z) ->
(forall (l:Z), (((h - k)%Z <= l)%Z /\ (l <= h)%Z) -> ((f l) = (g l))) ->
((kth_right i k h f) = (kth_right i k h g)).
Axiom kth_right_trans :
forall (i:Z) (k:Z) (h:Z) (t1:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (l:Z), (0%Z < (f l))%Z) -> (0%Z <= h)%Z -> (0%Z <= t1)%Z ->
((kth_right (int.EuclideanDivision.div i (ind_iproduct f h (h + t1)%Z)) k h
f)
= (kth_right i (k + t1)%Z (h + t1)%Z f)).
Parameter kth_left: Z -> Z -> Z -> Z -> (Z -> Z) -> Z.
Axiom kth_left_def :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
((kth_left i k l h f) = (kth_right i (((h - l)%Z - k)%Z + 1%Z)%Z h f)).
Axiom kth_left_spec :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
((kth_left i k l h f) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (ind_iproduct f (l + k)%Z h))
(f ((l + k)%Z - 1%Z)%Z))).
Axiom kth_left_spec1 :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
(0%Z <= (kth_left i k l h f))%Z.
Axiom kth_left_spec2 :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) -> (0%Z < (f ind))%Z) ->
((kth_left i k l h f) < (f ((l + k)%Z - 1%Z)%Z))%Z.
Axiom kth_left_eq :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z) (g:Z -> Z), (0%Z <= i)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) -> (0%Z <= l)%Z ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind < h)%Z) ->
((f ind) = (g ind)) /\ ((g ind) > 0%Z)%Z) ->
((kth_left i k l h f) = (kth_left i k l h g)).
Axiom kth_left_to_mod_div :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind <= h)%Z) -> ((f ind) > 0%Z)%Z) ->
((kth_left i k l h f) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (ind_iproduct f (l + k)%Z h))
(f ((l + k)%Z - 1%Z)%Z))).
Axiom kth_left_trans :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (0%Z <= l)%Z ->
((1%Z <= k)%Z /\ (k < (h - l)%Z)%Z) ->
(forall (ind:Z), ((l <= ind)%Z /\ (ind <= h)%Z) -> ((f ind) > 0%Z)%Z) ->
((kth_left i k l h f) =
(kth_left (int.EuclideanDivision.div i (f (h - 1%Z)%Z)) k l (h - 1%Z)%Z f)).
Axiom div_isum_exponents :
forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
(0%Z <= n)%Z -> (0%Z <= m)%Z ->
((power k (n + m)%Z) = ((power k n) * (power k m))%Z).
Axiom div_isum_exponents1 :
forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
(0%Z <= n)%Z -> (0%Z <= m)%Z ->
((power k (n + 1%Z)%Z) = ((power k n) * k)%Z).
Axiom div_isum_exponents2 :
forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
(0%Z <= n)%Z -> (0%Z <= m)%Z -> ((power k 1%Z) = k).
Axiom div_isum_exponents3 :
forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
(0%Z <= n)%Z -> (0%Z <= m)%Z ->
((int.EuclideanDivision.div (int.EuclideanDivision.div i (power k n))
(power k m))
= (int.EuclideanDivision.div i (power k (n + m)%Z))).
Axiom div_isum_exponents4 :
forall (i:Z) (k:Z) (n:Z) (m:Z), (0%Z <= i)%Z -> (0%Z < k)%Z ->
(0%Z <= n)%Z -> (0%Z <= m)%Z ->
((int.EuclideanDivision.div (int.EuclideanDivision.div i (power k n)) k) =
(int.EuclideanDivision.div i (power k (n + 1%Z)%Z))).
Parameter divp: Z -> Z -> Z.
Axiom divp_def :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
((divp i j) = ((int.EuclideanDivision.div i j) * j)%Z).
Axiom divp_spec :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
(i = ((divp i j) + (int.EuclideanDivision.mod1 i j))%Z).
Axiom divp_spec1 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> ((divp i j) <= i)%Z.
Axiom divp_spec2 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z ->
(i < (((divp i j) + 1%Z)%Z * j)%Z)%Z.
Axiom divp_spec3 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z < j)%Z -> (i > j)%Z ->
((divp i j) > 0%Z)%Z.
Axiom kth_right_div_mod :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((kth_right i k h f) =
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h))
(ind_iproduct f ((h - k)%Z + 1%Z)%Z h))).
Axiom kth_head :
forall (i:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= h)%Z ->
(forall (k:Z), (0%Z < (f k))%Z) ->
((kth_right i 1%Z h f) = (int.EuclideanDivision.mod1 i (f (h - 1%Z)%Z))).
Parameter weighted_kth_right: Z -> Z -> Z -> (Z -> Z) -> Z.
Axiom weighted_kth_right_def :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z ->
(forall (k1:Z), (0%Z < (f k1))%Z) -> (1%Z <= k)%Z ->
((weighted_kth_right i k h f) =
((kth_right i k h f) * (ind_iproduct f ((h - k)%Z + 1%Z)%Z h))%Z).
Axiom weighted_kth_right_ :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (1%Z <= k)%Z -> (0%Z <= i)%Z ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h)) =
((weighted_kth_right i k h f) +
(int.EuclideanDivision.mod1 i (ind_iproduct f ((h - k)%Z + 1%Z)%Z h)))%Z).
Axiom kth_right_decomposition :
forall (i:Z) (k:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (1%Z <= k)%Z ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((int.EuclideanDivision.mod1 i (ind_iproduct f (h - k)%Z h)) =
(ind_isum (fun (a:Z) => (weighted_kth_right i a h f)) 1%Z (k + 1%Z)%Z)).
Axiom kth_left_div_mod :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z ->
((0%Z <= l)%Z /\ (l <= h)%Z) -> ((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((kth_left i k l h f) =
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h))
(ind_iproduct f (l + k)%Z h))).
Parameter weighted_kth_left: Z -> Z -> Z -> Z -> (Z -> Z) -> Z.
Axiom weighted_kth_left_def :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((weighted_kth_left i k l h f) =
(weighted_kth_right i (((h - l)%Z - k)%Z + 1%Z)%Z h f)).
Axiom weighted_kth_left_ :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h)) =
((weighted_kth_left i k l h f) +
(int.EuclideanDivision.mod1 i (ind_iproduct f (l + k)%Z h)))%Z).
Axiom bounded_kth_left_decomposition :
forall (i:Z) (k:Z) (l:Z) (h:Z) (f:Z -> Z), (0%Z <= i)%Z -> (l <= h)%Z ->
((1%Z <= k)%Z /\ (k <= (h - l)%Z)%Z) ->
(forall (k1:Z), (0%Z < (f k1))%Z) ->
((int.EuclideanDivision.mod1 i (ind_iproduct f ((l + k)%Z - 1%Z)%Z h)) =
(ind_isum (fun (a:Z) => (weighted_kth_left i a l h f)) k
((h - l)%Z + 1%Z)%Z)).
Axiom kth_left_decomposition :
forall (i:Z) (l:Z) (h:Z) (f:Z -> Z),
((0%Z <= i)%Z /\ (i < (ind_iproduct f l h))%Z) -> (l < h)%Z ->
(forall (k:Z), (0%Z < (f k))%Z) ->
(i =
(ind_isum (fun (a:Z) => (weighted_kth_left i a l h f)) 1%Z
((h - l)%Z + 1%Z)%Z)).
Parameter binary: (Z -> Z) -> Prop.
Axiom binary_def :
forall (t1:Z -> Z), (binary t1) -> forall (k:Z), (0%Z <= (t1 k))%Z.
Axiom binary_def1 :
forall (t1:Z -> Z), (binary t1) -> forall (k:Z), ((t1 k) < 2%Z)%Z.
Axiom binary_def2 :
forall (t1:Z -> Z),
(forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) -> binary t1.
Axiom set_binary :
forall (t1:Z -> Z),
(forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) -> binary t1.
Axiom get_binary :
forall (t1:Z -> Z), (binary t1) -> forall (k:Z), (0%Z <= (t1 k))%Z.
Axiom get_binary1 :
forall (t1:Z -> Z), (binary t1) -> forall (k:Z), ((t1 k) < 2%Z)%Z.
Parameter shift: forall {a:Type} {a_WT:WhyType a}, (Z -> a) -> Z -> Z -> a.
Axiom shift_def :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (i:Z) (k:Z), ((shift f i k) = (f (k + i)%Z)).
Axiom shift_value :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (i:Z) (k:Z), ((shift f i k) = (f (k + i)%Z)).
Axiom shiftz :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (k:Z), ((shift f 0%Z k) = (f k)).
Axiom shiftz_gen :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (i:Z) (k:Z), (i = 0%Z) -> ((shift f i k) = (f k)).
Axiom shiftz_quant :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a),
((((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) 0%Z) = f).
Axiom shiftz_quant_rev :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a),
(f = (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) 0%Z)).
Parameter concat_fun:
forall {a:Type} {a_WT:WhyType a}, (Z -> a) -> (Z -> a) -> Z -> Z -> a.
Axiom concat_fun_def :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (g:Z -> a) (i:Z) (k:Z), (k < i)%Z ->
((concat_fun f g i k) = (f k)).
Axiom concat_fun_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (g:Z -> a) (i:Z) (k:Z), ~ (k < i)%Z ->
((concat_fun f g i k) = (g (k - i)%Z)).
Axiom shift_add :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (i:Z) (j:Z) (k:Z),
((shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) j) i k) =
(shift f (i + j)%Z k)).
Axiom concat_fun_value :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (g:Z -> a) (i:Z) (k:Z),
((k < i)%Z -> ((concat_fun f g i k) = (f k))) /\
(~ (k < i)%Z -> ((concat_fun f g i k) = (g (k - i)%Z))).
Axiom concat_eq :
forall {a:Type} {a_WT:WhyType a},
forall (f1:Z -> a) (g1:Z -> a) (f2:Z -> a) (g2:Z -> a) (i1:Z) (i2:Z) (k:Z),
(forall (l:Z), (l < i1)%Z -> ((f1 l) = (f2 l))) ->
(forall (l:Z), (l >= 0%Z)%Z -> ((g1 l) = (g2 l))) -> (i1 = i2) ->
((concat_fun f1 g1 i1 k) = (concat_fun f2 g2 i2 k)).
Parameter mod_func:
forall {a:Type} {a_WT:WhyType a}, (Z -> a) -> Z -> Z -> a.
Axiom mod_func_def :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (k:Z) (i:Z), (k > 0%Z)%Z ->
((mod_func f k i) = (f (int.EuclideanDivision.mod1 i k))).
Axiom mod_func_inf :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (k:Z) (i:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < k)%Z) -> ((mod_func f k i) = (f i)).
Axiom shift_mod :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (k:Z) (i:Z), (k > 0%Z)%Z ->
((mod_func f k i) =
(shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k) k i)).
Axiom shift_mod_rev :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> a) (k:Z) (i:Z), (k > 0%Z)%Z ->
((shift (((fun (y0:Z -> a) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k) k i)
= (mod_func f k i)).
Parameter head_bit: Z -> Z -> Z.
Axiom head_bit_def :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((head_bit i k) = (int.EuclideanDivision.div i (power 2%Z (k - 1%Z)%Z))).
Axiom head_bit_spec :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) -> (0%Z <= (head_bit i k))%Z.
Axiom head_bit_spec1 :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) -> ((head_bit i k) <= 1%Z)%Z.
Parameter tail_bits: Z -> Z -> Z.
Axiom tail_bits_def :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((tail_bits i k) = (int.EuclideanDivision.mod1 i (power 2%Z (k - 1%Z)%Z))).
Axiom tail_bits_spec :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) -> (0%Z <= (tail_bits i k))%Z.
Axiom tail_bits_spec1 :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((tail_bits i k) <= (power 2%Z (k - 1%Z)%Z))%Z.
Parameter ht_to_int: Z -> Z -> Z -> Z.
Axiom ht_to_int_def :
forall (hi:Z) (ti:Z) (k:Z), (0%Z < k)%Z ->
((0%Z <= hi)%Z /\ (hi < 2%Z)%Z) ->
((0%Z <= ti)%Z /\ (ti < (power 2%Z (k - 1%Z)%Z))%Z) ->
((ht_to_int hi ti k) = ((hi * (power 2%Z (k - 1%Z)%Z))%Z + ti)%Z).
Axiom head_tail_inv :
forall (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((ht_to_int (head_bit i k) (tail_bits i k) k) = i).
Axiom ht_to_int_head :
forall (i:Z) (ti:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((0%Z <= ti)%Z /\ (ti < (power 2%Z (k - 1%Z)%Z))%Z) ->
((head_bit (ht_to_int (head_bit i k) ti k) k) = (head_bit i k)).
Axiom ht_to_int_tail :
forall (hi:Z) (i:Z) (k:Z), (k > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z k))%Z) ->
((0%Z <= hi)%Z /\ (hi < 2%Z)%Z) ->
((tail_bits (ht_to_int hi (tail_bits i k) k) k) = (tail_bits i k)).
Axiom concat_fun_bin_i :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (k:Z), (binary f) -> (binary g) ->
(0%Z <= (concat_fun f g i k))%Z.
Axiom concat_fun_bin_i1 :
forall (f:Z -> Z) (g:Z -> Z) (i:Z) (k:Z), (binary f) -> (binary g) ->
((concat_fun f g i k) < 2%Z)%Z.
Axiom shift_bin_i :
forall (f:Z -> Z) (i:Z) (k:Z), (binary f) -> (0%Z <= (shift f i k))%Z.
Axiom shift_bin_i1 :
forall (f:Z -> Z) (i:Z) (k:Z), (binary f) -> ((shift f i k) < 2%Z)%Z.
Axiom concat_fun_bin :
forall (f:Z -> Z) (g:Z -> Z) (i:Z), (binary f) -> (binary g) ->
binary
((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) => (concat_fun y0 y1 y2 y3))
f)
g)
i).
Axiom mod_func_bin :
forall (f:Z -> Z) (k:Z), (k > 0%Z)%Z -> (binary f) ->
binary (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (mod_func y0 y1 y2)) f) k).
Axiom shift_bin :
forall (f:Z -> Z) (i:Z), (binary f) ->
binary (((fun (y0:Z -> Z) (y1:Z) (y2:Z) => (shift y0 y1 y2)) f) i).
Axiom binary_comp :
forall (f:Z -> Z) (g:Z -> Z), (binary f) -> binary (fun (x:Z) => (f (g x))).
Axiom set_is_all_binary :
forall (t1:Z -> Z),
(forall (k:Z), (0%Z <= (t1 k))%Z /\ ((t1 k) < 2%Z)%Z) -> binary t1.
Parameter nary_length: Z -> Z -> Z.
Axiom nary_length_spec :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z -> (0%Z < i)%Z ->
((power n ((nary_length i n) - 1%Z)%Z) <= i)%Z.
Axiom nary_length_spec1 :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z -> (0%Z < i)%Z ->
(i < (power n (nary_length i n)))%Z.
Axiom nary_length_spec2 :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z -> (i < n)%Z ->
((nary_length i n) = 1%Z).
Axiom nary_length_spec3 :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z ->
((nary_length i n) >= 1%Z)%Z.
Axiom nary_length_spec4 :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z ->
(i = (int.EuclideanDivision.mod1 i (power n (nary_length i n)))).
Parameter binary_length: Z -> Z.
Axiom binary_length_def :
forall (i:Z), (0%Z <= i)%Z -> ((binary_length i) = (nary_length i 2%Z)).
Axiom binary_length_spec :
forall (i:Z), (0%Z <= i)%Z -> (0%Z < i)%Z ->
((power 2%Z ((binary_length i) - 1%Z)%Z) <= i)%Z.
Axiom binary_length_spec1 :
forall (i:Z), (0%Z <= i)%Z -> (0%Z < i)%Z ->
(i < (power 2%Z (binary_length i)))%Z.
Axiom binary_length_spec2 :
forall (i:Z), (0%Z <= i)%Z -> (i < 2%Z)%Z -> ((binary_length i) = 1%Z).
Axiom binary_length_spec3 :
forall (i:Z), (0%Z <= i)%Z -> ((binary_length i) >= 1%Z)%Z.
Axiom binary_length_spec4 :
forall (i:Z), (0%Z <= i)%Z ->
(i = (int.EuclideanDivision.mod1 i (power 2%Z (binary_length i)))).
Axiom set_binary_length :
forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z <= k)%Z -> ~ (0%Z < i)%Z ->
~ (i < 2%Z)%Z -> (k = (binary_length i)).
Axiom set_binary_length1 :
forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z <= k)%Z -> ~ (0%Z < i)%Z ->
(k = 1%Z) -> (k = (binary_length i)).
Axiom set_binary_length2 :
forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z <= k)%Z ->
(((power 2%Z (k - 1%Z)%Z) <= i)%Z /\ (i < (power 2%Z k))%Z) ->
~ (i < 2%Z)%Z -> (k = (binary_length i)).
Axiom set_binary_length3 :
forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z <= k)%Z ->
(((power 2%Z (k - 1%Z)%Z) <= i)%Z /\ (i < (power 2%Z k))%Z) -> (k = 1%Z) ->
(k = (binary_length i)).
Axiom set_binary_length_b :
forall (i:Z) (k:Z), (0%Z <= i)%Z -> (0%Z < k)%Z -> (i < (power 2%Z k))%Z ->
((binary_length i) <= k)%Z.
Axiom matrix : forall (a:Type), Type.
Parameter matrix_WhyType :
forall (a:Type) {a_WT:WhyType a}, WhyType (matrix a).
Existing Instance matrix_WhyType.
Parameter elts: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a.
Parameter rows: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z.
Parameter columns: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z.
Axiom matrix'invariant :
forall {a:Type} {a_WT:WhyType a},
forall (self:matrix a), (0%Z < (rows self))%Z.
Axiom matrix'invariant1 :
forall {a:Type} {a_WT:WhyType a},
forall (self:matrix a), (0%Z < (columns self))%Z.
Parameter valid_index:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> Prop.
Axiom valid_index_def :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), (valid_index a1 r c) -> (0%Z <= r)%Z.
Axiom valid_index_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), (valid_index a1 r c) -> (r < (rows a1))%Z.
Axiom valid_index_def2 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), (valid_index a1 r c) -> (0%Z <= c)%Z.
Axiom valid_index_def3 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), (valid_index a1 r c) ->
(c < (columns a1))%Z.
Axiom valid_index_def4 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z),
(((0%Z <= r)%Z /\ (r < (rows a1))%Z) /\
((0%Z <= c)%Z /\ (c < (columns a1))%Z)) ->
valid_index a1 r c.
Parameter equal_size:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> (matrix a) -> Prop.
Axiom equal_size_def :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (b:matrix a), (equal_size a1 b) ->
((rows a1) = (rows b)).
Axiom equal_size_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (b:matrix a), (equal_size a1 b) ->
((columns a1) = (columns b)).
Axiom equal_size_def2 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (b:matrix a),
(((rows a1) = (rows b)) /\ ((columns a1) = (columns b))) -> equal_size a1 b.
Parameter get: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a.
Axiom get_spec :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), ((get a1 r c) = (((elts a1) r) c)).
Parameter make: forall {a:Type} {a_WT:WhyType a}, Z -> Z -> a -> matrix a.
Axiom make_spec :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (v:a), ((r > 0%Z)%Z /\ (c > 0%Z)%Z) ->
((rows (make r c v)) = r).
Axiom make_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (v:a), ((r > 0%Z)%Z /\ (c > 0%Z)%Z) ->
((columns (make r c v)) = c).
Axiom make_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (v:a), ((r > 0%Z)%Z /\ (c > 0%Z)%Z) ->
forall (i:Z) (j:Z),
(((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
((get (make r c v) i j) = v).
Axiom make_value :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (i:Z) (j:Z) (v:a), ((r > 0%Z)%Z /\ (c > 0%Z)%Z) ->
((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
((get (make r c v) i j) = v).
Parameter mat_indices:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> set (Z* Z)%type.
Axiom mat_indices_def :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a),
((mat_indices m) =
(cartesian_product (to_fset 0%Z (rows m)) (to_fset 0%Z (columns m)))).
Axiom mat_indices_spec :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a), forall (i:Z) (j:Z), (valid_index m i j) ->
mem (i, j) (mat_indices m).
Axiom mat_indices_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a), forall (i:Z) (j:Z), (mem (i, j) (mat_indices m)) ->
valid_index m i j.
Parameter set1:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Z -> Z -> a -> matrix a.
Axiom set_spec :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
((rows (set1 a1 r c v)) = (rows a1)).
Axiom set_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
((columns (set1 a1 r c v)) = (columns a1)).
Axiom set_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) ->
(((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = v)) /\
(~ ((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = (get a1 i j))).
Axiom set_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
((get (set1 a1 r c v) r c) = v).
Axiom set_spec4 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
forall (i:Z) (j:Z), (valid_index (set1 a1 r c v) i j) -> ~ (i = r) ->
((get (set1 a1 r c v) i j) = (get a1 i j)).
Axiom set_spec5 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
forall (i:Z) (j:Z), (valid_index (set1 a1 r c v) i j) -> ~ (j = c) ->
((get (set1 a1 r c v) i j) = (get a1 i j)).
Axiom set_valid_index :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows a1))%Z) ->
((0%Z <= j)%Z /\ (j < (columns a1))%Z) -> valid_index a1 i j.
Axiom get_valid_index :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), ((rows a1) = r) -> ((columns a1) = c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) -> (0%Z <= i)%Z.
Axiom get_valid_index1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), ((rows a1) = r) -> ((columns a1) = c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) -> (i < r)%Z.
Axiom get_valid_index2 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), ((rows a1) = r) -> ((columns a1) = c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) -> (0%Z <= j)%Z.
Axiom get_valid_index3 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z), ((rows a1) = r) -> ((columns a1) = c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) -> (j < c)%Z.
Axiom get_valid_index_params :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (i:Z) (j:Z), ((rows a1) = r) ->
((columns a1) = c) -> (valid_index a1 i j) -> (0%Z <= i)%Z.
Axiom get_valid_index_params1 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (i:Z) (j:Z), ((rows a1) = r) ->
((columns a1) = c) -> (valid_index a1 i j) -> (i < r)%Z.
Axiom get_valid_index_params2 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (i:Z) (j:Z), ((rows a1) = r) ->
((columns a1) = c) -> (valid_index a1 i j) -> (0%Z <= j)%Z.
Axiom get_valid_index_params3 :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (i:Z) (j:Z), ((rows a1) = r) ->
((columns a1) = c) -> (valid_index a1 i j) -> (j < c)%Z.
Axiom set_values :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
forall (i:Z) (j:Z), (valid_index a1 i j) ->
(((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = v)) /\
(~ ((i = r) /\ (j = c)) -> ((get (set1 a1 r c v) i j) = (get a1 i j))).
Axiom set_rows :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
((rows (set1 a1 r c v)) = (rows a1)).
Axiom set_columns :
forall {a:Type} {a_WT:WhyType a},
forall (a1:matrix a) (r:Z) (c:Z) (v:a), (valid_index a1 r c) ->
((columns (set1 a1 r c v)) = (columns a1)).
Parameter make_f:
forall {a:Type} {a_WT:WhyType a}, Z -> Z -> (Z -> Z -> a) -> matrix a.
Axiom make_f_spec :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a), (r > 0%Z)%Z -> (c > 0%Z)%Z ->
((rows (make_f r c f)) = r).
Axiom make_f_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a), (r > 0%Z)%Z -> (c > 0%Z)%Z ->
((columns (make_f r c f)) = c).
Axiom make_f_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a), (r > 0%Z)%Z -> (c > 0%Z)%Z ->
forall (i:Z) (j:Z), ((get (make_f r c f) i j) = ((f i) j)).
Axiom assert_make :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a) (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
((get (make_f r c f) i j) = ((f i) j)).
Axiom assert_make_r :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a), (0%Z < r)%Z -> (0%Z < c)%Z ->
((rows (make_f r c f)) = r).
Axiom assert_make_c :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a), (0%Z < r)%Z -> (0%Z < c)%Z ->
((columns (make_f r c f)) = c).
Parameter to_indexes:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> set (Z* Z)%type.
Axiom to_indexes_def :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a),
((to_indexes m) =
(cartesian_product (to_fset 0%Z (rows m)) (to_fset 0%Z (columns m)))).
Axiom to_indexes_spec :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a),
((cardinal (to_indexes m)) = ((rows m) * (columns m))%Z).
Axiom set_to_indexes_mem :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) -> mem (i, j) (to_indexes m).
Axiom get_to_indexes_mem :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (o:(Z* Z)%type), (mem o (to_indexes m)) ->
(0%Z <= (fir o))%Z.
Axiom get_to_indexes_mem1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (o:(Z* Z)%type), (mem o (to_indexes m)) ->
((fir o) < (rows m))%Z.
Axiom get_to_indexes_mem2 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (o:(Z* Z)%type), (mem o (to_indexes m)) ->
(0%Z <= (sec o))%Z.
Axiom get_to_indexes_mem3 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (o:(Z* Z)%type), (mem o (to_indexes m)) ->
((sec o) < (columns m))%Z.
Parameter equal:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> (matrix a) -> Prop.
Axiom equal_mat :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal m n) -> ((rows m) = (rows n)).
Axiom equal_mat1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal m n) ->
((columns m) = (columns n)).
Axiom equal_mat2 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal m n) -> forall (i:Z) (j:Z),
(valid_index m i j) -> ((get m i j) = (get n i j)).
Axiom equal_mat3 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a),
((((rows m) = (rows n)) /\ ((columns m) = (columns n))) /\
forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))) ->
equal m n.
Axiom equality :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal m n) -> (m = n).
Axiom equality1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (m = n) -> equal m n.
Axiom mat_equality :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
(forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))) ->
equal m n.
Parameter square: forall {a:Type} {a_WT:WhyType a}, (matrix a) -> Prop.
Axiom square_mat :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a), (square m) -> ((rows m) = (columns m)).
Axiom square_mat1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a), ((rows m) = (columns m)) -> square m.
Axiom equal_sym :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal m n) -> equal n m.
Axiom equal_sym1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (equal n m) -> equal m n.
Axiom equal_rex :
forall {a:Type} {a_WT:WhyType a}, forall (m:matrix a), equal m m.
Axiom equal_trans :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a) (o:matrix a), (equal m n) ->
(equal n o) -> equal m o.
Parameter equal_funct:
forall {a:Type} {a_WT:WhyType a}, (Z -> matrix a) -> (Z -> matrix a) ->
Prop.
Axiom equal_mat_funct :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> matrix a) (g:Z -> matrix a), forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < j)%Z) -> (equal_funct f g) -> forall (k:Z),
((i <= k)%Z /\ (k < j)%Z) -> equal (f k) (g k).
Axiom equal_mat_funct1 :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> matrix a) (g:Z -> matrix a), forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < j)%Z) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> equal (f k) (g k)) ->
equal_funct f g.
Axiom set_equal_mat :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
(forall (i:Z) (j:Z), (valid_index m i j) -> ((get m i j) = (get n i j))) ->
(m = n).
Axiom set_equal_mat_make :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a) (g:Z -> Z -> a), (0%Z < r)%Z ->
(0%Z < c)%Z ->
(forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> (((f i) j) = ((g i) j))) ->
((make_f r c f) = (make_f r c g)).
Axiom set_equal_mat_make_t :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (r':Z) (c:Z) (c':Z) (f:Z -> Z -> a) (g:Z -> Z -> a),
(0%Z < r)%Z -> (0%Z < c)%Z -> (r = r') -> (c = c') ->
(forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> (((f i) j) = ((g i) j))) ->
((make_f r c f) = (make_f r' c' g)).
Axiom get_equal_mat :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (m = n) -> ((rows m) = (rows n)).
Axiom get_equal_mat1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (m = n) -> ((columns m) = (columns n)).
Axiom get_equal_mat2 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (n:matrix a), (m = n) -> forall (i:Z) (j:Z),
(valid_index m i j) -> ((get m i j) = (get n i j)).
Axiom equal_functions :
forall {a:Type} {a_WT:WhyType a},
forall (r:Z) (c:Z) (f:Z -> Z -> a) (g:Z -> Z -> a), (0%Z < r)%Z ->
(0%Z < c)%Z ->
(forall (i:Z) (j:Z),
(((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
(((f i) j) = ((g i) j))) ->
((make_f r c f) = (make_f r c g)).
Axiom equal_functions_mat :
forall {a:Type} {a_WT:WhyType a},
forall (f:Z -> Z -> a) (m:matrix a),
(forall (i:Z) (j:Z),
(((0%Z <= i)%Z /\ (i < (rows m))%Z) /\
((0%Z <= j)%Z /\ (j < (columns m))%Z)) ->
(((f i) j) = (get m i j))) ->
(m = (make_f (rows m) (columns m) f)).
Parameter null_mat: (matrix t) -> Prop.
Axiom null_mat_def :
forall (a:matrix t), (null_mat a) -> forall (i:Z) (j:Z),
(valid_index a i j) -> ((get a i j) = tzero).
Axiom null_mat_def1 :
forall (a:matrix t),
(forall (i:Z) (j:Z), (valid_index a i j) -> ((get a i j) = tzero)) ->
null_mat a.
Axiom set_null_mat :
forall (a:matrix t),
(forall (i:Z) (j:Z), (valid_index a i j) -> ((get a i j) = tzero)) ->
null_mat a.
Axiom get_null_mat :
forall (a:matrix t), (null_mat a) -> forall (i:Z) (j:Z),
(valid_index a i j) -> ((get a i j) = tzero).
Parameter kronecker_neutral: matrix t.
Axiom kronecker_neutral1 : (kronecker_neutral = (make 1%Z 1%Z tone)).
Parameter identity: Z -> matrix t.
Parameter result6: Z -> Z -> t.
Axiom result_def6 :
forall (i:Z) (j:Z),
((i = j) -> (((result6 i) j) = tone)) /\
(~ (i = j) -> (((result6 i) j) = tzero)).
Axiom identity_def :
forall (n:Z), (0%Z <= n)%Z ->
((identity n) = (make_f (power 2%Z n) (power 2%Z n) result6)).
Axiom identity_spec :
forall (n:Z), (0%Z <= n)%Z -> ((rows (identity n)) = (power 2%Z n)).
Axiom identity_spec1 :
forall (n:Z), (0%Z <= n)%Z -> ((columns (identity n)) = (power 2%Z n)).
Axiom identity_spec2 :
forall (n:Z), (0%Z <= n)%Z -> forall (i:Z) (j:Z),
(valid_index (identity n) i j) ->
((i = j) -> ((get (identity n) i j) = tone)) /\
(~ (i = j) -> ((get (identity n) i j) = tzero)).
Parameter kronecker: (matrix t) -> (matrix t) -> matrix t.
Axiom kronecker_def :
forall (m:matrix t) (n:matrix t),
((kronecker m n) =
(make_f ((rows m) * (rows n))%Z ((columns m) * (columns n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(get m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)))
(get n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n))))))).
Axiom kronecker_spec :
forall (m:matrix t) (n:matrix t),
((rows (kronecker m n)) = ((rows m) * (rows n))%Z).
Axiom kronecker_spec1 :
forall (m:matrix t) (n:matrix t),
((columns (kronecker m n)) = ((columns m) * (columns n))%Z).
Axiom kronecker_spec2 :
forall (m:matrix t) (n:matrix t), forall (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
((get (kronecker m n) i j) =
(infix_asdt
(get m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)))
(get n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n))))).
Axiom kronecker_eq :
forall (m1:matrix t) (n1:matrix t) (m2:matrix t) (n2:matrix t),
(m1 = m2) -> (n1 = n2) -> ((kronecker m1 n1) = (kronecker m2 n2)).
Axiom get_kronecker :
forall (m:matrix t) (n:matrix t),
((kronecker m n) =
(make_f ((rows m) * (rows n))%Z ((columns m) * (columns n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(get m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)))
(get n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n))))))).
Axiom kronecker_values :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
((get (kronecker m n) i j) =
(infix_asdt
(get m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)))
(get n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n))))).
Axiom kronecker_rows :
forall (m:matrix t) (n:matrix t),
((rows (kronecker m n)) = ((rows m) * (rows n))%Z).
Axiom kronecker_columns :
forall (m:matrix t) (n:matrix t),
((columns (kronecker m n)) = ((columns m) * (columns n))%Z).
Axiom kronecker_values_gen :
forall (m:matrix t) (n:matrix t), forall (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
((get (kronecker m n) i j) =
(infix_asdt
(get m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)))
(get n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n))))).
Axiom kronecker_mod_values :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
((get (kronecker m n) i j) =
(infix_asdt
(get m
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (rows (kronecker m n))) (rows n))
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 j (columns (kronecker m n))) (columns n)))
(get n
(int.EuclideanDivision.mod1
(int.EuclideanDivision.mod1 i (rows (kronecker m n))) (rows n))
(int.EuclideanDivision.mod1
(int.EuclideanDivision.mod1 j (columns (kronecker m n))) (columns n))))).
Axiom kronecker_indexes :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z) (k:Z) (l:Z),
(valid_index m i j) -> (valid_index n k l) ->
valid_index (kronecker m n) ((i * (rows n))%Z + k)%Z
((j * (columns n))%Z + l)%Z.
Axiom kronecker_indexes_com :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
valid_index m (int.EuclideanDivision.div i (rows n))
(int.EuclideanDivision.div j (columns n)).
Axiom kronecker_indexes_com1 :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(valid_index (kronecker m n) i j) ->
valid_index n (int.EuclideanDivision.mod1 i (rows n))
(int.EuclideanDivision.mod1 j (columns n)).
Axiom kronecker_assoc_pre :
forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (((rows m) * (rows n))%Z * (rows o))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < (((columns m) * (columns n))%Z * (columns o))%Z)%Z) ->
((get (kronecker (kronecker m n) o) i j) =
(get (kronecker m (kronecker n o)) i j)).
Axiom kronecker_assoc :
op_assoc (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)).
Axiom neutral_ : forall (m:matrix t), ((kronecker m kronecker_neutral) = m).
Axiom neutral_1 : forall (m:matrix t), ((kronecker kronecker_neutral m) = m).
Axiom neutral1 :
(kronecker_neutral =
(neutral_elt (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)))).
Axiom neutral2 :
has_neutral (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)).
Axiom neutral3 :
iterable (fun (y0:matrix t) (y1:matrix t) => (kronecker y0 y1)).
Axiom kronecker_equal :
forall (m:matrix t) (ml:matrix t) (n:matrix t) (nl:matrix t),
(equal m ml) -> (equal n nl) -> equal (kronecker m n) (kronecker ml nl).
Axiom kron_id :
forall (m:Z) (n:Z), (0%Z <= m)%Z -> (0%Z <= n)%Z ->
((kronecker (identity m) (identity n)) = (identity (m + n)%Z)).
Parameter frows: (Z -> matrix t) -> Z -> Z.
Axiom frows_def :
forall (f:Z -> matrix t) (k:Z), ((frows f k) = (rows (f k))).
Axiom frows_spec : forall (f:Z -> matrix t) (k:Z), ((frows f k) > 0%Z)%Z.
Parameter fcolumns: (Z -> matrix t) -> Z -> Z.
Axiom fcolumns_def :
forall (f:Z -> matrix t) (k:Z), ((fcolumns f k) = (columns (f k))).
Axiom fcolumns_spec :
forall (f:Z -> matrix t) (k:Z), ((fcolumns f k) > 0%Z)%Z.
Axiom const_fcol :
forall (m:matrix t) (k:Z),
((fcolumns ((fun (y0:matrix t) (y1:Z) => (const y0 y1)) m) k) =
(columns m)).
Axiom const_frows :
forall (m:matrix t) (k:Z),
((frows ((fun (y0:matrix t) (y1:Z) => (const y0 y1)) m) k) = (rows m)).
Parameter mat_mult_no_bound: (matrix t) -> (matrix t) -> matrix t.
Axiom mat_mult_no_bound_def :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((mat_mult_no_bound m n) =
(make_f (rows m) (columns n)
(fun (i:Z) (j:Z) =>
(ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
(columns m))))).
Axiom mat_mult_no_bound_def1 :
forall (m:matrix t) (n:matrix t), ~ ((columns m) = (rows n)) ->
((mat_mult_no_bound m n) = (make_f 1%Z 1%Z (fun (i:Z) (j:Z) => tzero))).
Axiom mat_mult_no_bound_spec :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((rows (mat_mult_no_bound m n)) = (rows m)).
Axiom mat_mult_no_bound_spec1 :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((columns (mat_mult_no_bound m n)) = (columns n)).
Axiom mat_mult_no_bound_spec2 :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
forall (i:Z) (j:Z), (valid_index (mat_mult_no_bound m n) i j) ->
((get (mat_mult_no_bound m n) i j) =
(ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
(columns m))).
Parameter mat_mult: (matrix t) -> (matrix t) -> matrix t.
Axiom mat_mult_def :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((mat_mult m n) = (mat_mult_no_bound m n)).
Axiom mat_mult_spec :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((rows (mat_mult m n)) = (rows m)).
Axiom mat_mult_spec1 :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((columns (mat_mult m n)) = (columns n)).
Axiom mat_mult_spec2 :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
forall (i:Z) (j:Z), (valid_index (mat_mult m n) i j) ->
((get (mat_mult m n) i j) =
(ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
(columns m))).
Axiom mat_mult_values :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z), ((columns m) = (rows n)) ->
(valid_index (mat_mult m n) i j) ->
((get (mat_mult m n) i j) =
(ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
(columns m))).
Axiom mat_mult_columns :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((columns (mat_mult m n)) = (columns n)).
Axiom mat_mult_rows :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
((rows (mat_mult m n)) = (rows m)).
Axiom mat_mult_values_quant :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
forall (i:Z) (j:Z), (valid_index (mat_mult m n) i j) ->
((get (mat_mult m n) i j) =
(ind_sum (fun (k:Z) => (infix_asdt (get m i k) (get n k j))) 0%Z
(columns m))).
Parameter int_mat_prod: (Z -> matrix t) -> Z -> Z -> matrix t.
Axiom int_mat_prod_def :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((j - i)%Z = 0%Z) -> ((int_mat_prod f i j) = (f i)).
Axiom int_mat_prod_def1 :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
~ ((j - i)%Z = 0%Z) ->
((int_mat_prod f i j) =
(mat_mult_no_bound (int_mat_prod f i (j - 1%Z)%Z) (f j))).
Axiom int_mat_prod_spec :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((rows (int_mat_prod f i j)) = (rows (f i))).
Axiom int_mat_prod_spec1 :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((columns (int_mat_prod f i j)) = (columns (f i))).
Axiom int_mat_prod_spec2 :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((columns (int_mat_prod f i j)) = (rows (f i))).
Axiom int_mat_prod_zero :
forall (f:Z -> matrix t) (i:Z) (j:Z), ((rows (f i)) = (columns (f i))) ->
(i = j) -> ((int_mat_prod f i j) = (f i)).
Parameter int_mat_prod_plus_one: (Z -> matrix t) -> Z -> Z -> unit.
Axiom int_mat_prod_plus_one_def :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((int_mat_prod_plus_one f i j) = tt).
Axiom int_mat_prod_plus_one_spec :
forall (f:Z -> matrix t) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z) (k':Z),
(((i <= k)%Z /\ (k <= j)%Z) /\ ((i <= k')%Z /\ (k' <= j)%Z)) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
((int_mat_prod f i j) = (mat_mult (int_mat_prod f i (j - 1%Z)%Z) (f j))).
Axiom int_mat_prod_eq :
forall (f:Z -> matrix t) (g:Z -> matrix t) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z) (k':Z), ((i <= k)%Z /\ (k <= j)%Z) ->
((i <= k')%Z /\ (k' <= j)%Z) ->
((rows (f k)) = (rows (f k'))) /\ ((rows (f k')) = (columns (f k')))) ->
(forall (k:Z), ((i <= k)%Z /\ (k <= j)%Z) -> ((f k) = (g k))) ->
((int_mat_prod f i j) = (int_mat_prod g i j)).
Axiom mat_mult_id :
forall (n:Z) (m:matrix t), (n >= 0%Z)%Z -> ((columns m) = (power 2%Z n)) ->
((mat_mult m (identity n)) = m).
Axiom id_mat_mult :
forall (n:Z) (m:matrix t), (n >= 0%Z)%Z -> ((rows m) = (power 2%Z n)) ->
((mat_mult (identity n) m) = m).
Axiom mat_mult_eq :
forall (m:matrix t) (n:matrix t) (m':matrix t) (n':matrix t), (m = m') ->
(n = n') -> ((columns m) = (rows n)) -> ((mat_mult m n) = (mat_mult m' n')).
Parameter add_mat: (matrix t) -> (matrix t) -> matrix t.
Axiom add_mat_def :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((add_mat m n) =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) => (infix_pldt (get m i j) (get n i j))))).
Axiom add_mat_spec :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((columns (add_mat m n)) = (columns m)).
Axiom add_mat_spec1 : True.
Axiom add_mat_spec2 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((rows (add_mat m n)) = (rows m)).
Axiom add_mat_spec3 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((rows m) = (rows n)).
Axiom add_mat_spec4 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> forall (i:Z) (j:Z),
((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j))).
Axiom add_mat_equal :
forall (m:matrix t) (n:matrix t) (m':matrix t) (n':matrix t),
((rows m) = (rows n)) -> ((columns m) = (columns n)) -> (m = m') ->
(n = n') -> ((add_mat m n) = (add_mat m' n')).
Axiom add_value :
forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
((rows m) = (rows n)) -> ((columns m) = (columns n)) -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j))).
Axiom add_values :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
((columns m) = (columns n)) -> ((rows m) = (rows n)) ->
((get (add_mat m n) i j) = (infix_pldt (get m i j) (get n i j))).
Axiom add_mat_null_left :
forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
((rows m) = (rows n)) -> (null_mat m) -> ((add_mat m n) = n).
Axiom add_mat_null_right :
forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
((rows m) = (rows n)) -> (null_mat n) -> ((add_mat m n) = m).
Axiom set_equal_columns_elt :
forall (m:matrix t) (n:matrix t) (i:Z),
(((columns m) = (columns n)) /\ ((columns n) = i)) ->
((columns m) = (columns n)).
Axiom set_equal_rows_elt :
forall (m:matrix t) (n:matrix t) (i:Z),
(((rows m) = (rows n)) /\ ((rows n) = i)) -> ((rows m) = (rows n)).
Axiom add_columns :
forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
((rows m) = (rows n)) -> ((columns (add_mat m n)) = (columns m)).
Axiom add_rows :
forall (m:matrix t) (n:matrix t), ((columns m) = (columns n)) ->
((rows m) = (rows n)) -> ((rows (add_mat m n)) = (rows m)).
Axiom set_equal_dim_elt :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(((rows m) = (rows n)) /\ ((rows n) = i)) ->
(((columns m) = (columns n)) /\ ((columns n) = j)) ->
((columns m) = (columns n)).
Axiom set_equal_dim_elt1 :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(((rows m) = (rows n)) /\ ((rows n) = i)) ->
(((columns m) = (columns n)) /\ ((columns n) = j)) -> ((rows m) = (rows n)).
Axiom set_dim_add :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(((rows m) = (rows n)) /\ ((rows n) = i)) ->
(((columns m) = (columns n)) /\ ((columns n) = j)) ->
((rows (add_mat m n)) = i).
Axiom set_dim_add1 :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(((rows m) = (rows n)) /\ ((rows n) = i)) ->
(((columns m) = (columns n)) /\ ((columns n) = j)) ->
((columns (add_mat m n)) = j).
Axiom add_mat_eq :
forall (m:matrix t) (m1:matrix t) (n:matrix t) (n1:matrix t),
((rows m) = (rows n)) -> ((columns m) = (columns n)) -> (m = m1) ->
(n = n1) -> ((add_mat m n) = (add_mat m1 n1)).
Axiom add_mat_comm :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((add_mat m n) = (add_mat n m)).
Parameter add_neutral: unit -> matrix t.
Axiom add_neutral_spec :
forall (us:unit), forall (i:Z) (j:Z), (valid_index (add_neutral us) i j) ->
((get (add_neutral us) i j) = tzero).
Axiom add_neutral_spec1 :
forall (us:unit), ((rows (add_neutral us)) > 0%Z)%Z.
Axiom add_neutral_spec2 :
forall (us:unit), ((columns (add_neutral us)) > 0%Z)%Z.
Axiom distr_1_pre :
forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
((rows m) = (rows n)) -> ((columns m) = (columns n)) ->
((columns m) = (rows o)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns o))%Z) ->
((get (mat_mult (add_mat m n) o) i j) =
(get (add_mat (mat_mult m o) (mat_mult n o)) i j)).
Axiom distr_l :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((columns m) = (rows o)) ->
((mat_mult (add_mat m n) o) = (add_mat (mat_mult m o) (mat_mult n o))).
Axiom distr_2_pre :
forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
((rows n) = (rows o)) -> ((columns n) = (columns o)) ->
((columns m) = (rows n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
valid_index (mat_mult m (add_mat n o)) i j.
Axiom distr_2_pre1 :
forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
((rows n) = (rows o)) -> ((columns n) = (columns o)) ->
((columns m) = (rows n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
((get (mat_mult m (add_mat n o)) i j) =
(get (add_mat (mat_mult m n) (mat_mult m o)) i j)).
Axiom distr_r :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows n) = (rows o)) ->
((columns n) = (columns o)) -> ((columns m) = (rows n)) ->
((mat_mult m (add_mat n o)) = (add_mat (mat_mult m n) (mat_mult m o))).
Parameter infix_asdtdt: t -> (matrix t) -> matrix t.
Axiom infix_asdtdt_def :
forall (s:t) (m:matrix t),
((infix_asdtdt s m) =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) => (infix_asdt s (get m i j))))).
Axiom infix_asdtdt_spec :
forall (s:t) (m:matrix t), ((columns (infix_asdtdt s m)) = (columns m)).
Axiom infix_asdtdt_spec1 :
forall (s:t) (m:matrix t), ((rows (infix_asdtdt s m)) = (rows m)).
Axiom infix_asdtdt_spec2 :
forall (s:t) (m:matrix t), forall (i:Z) (j:Z),
(valid_index (infix_asdtdt s m) i j) ->
((get (infix_asdtdt s m) i j) = (infix_asdt s (get m i j))).
Axiom infix_asdtdt_spec3 :
forall (s:t) (m:matrix t), forall (i:Z) (j:Z),
(valid_index (infix_asdtdt s m) i j) -> valid_index m i j.
Axiom infix_asdtdt_spec4 :
forall (s:t) (m:matrix t), forall (i:Z) (j:Z), (valid_index m i j) ->
valid_index (infix_asdtdt s m) i j.
Axiom scalar_columns :
forall (m:matrix t) (a:t), ((columns (infix_asdtdt a m)) = (columns m)).
Axiom scalar_values :
forall (m:matrix t) (a:t) (i:Z) (j:Z),
((get (infix_asdtdt a m) i j) = (infix_asdt a (get m i j))).
Axiom scalar_rows :
forall (m:matrix t) (a:t), ((rows (infix_asdtdt a m)) = (rows m)).
Axiom scalar_null : forall (m:matrix t), null_mat (infix_asdtdt tzero m).
Axiom scalar_tone : forall (m:matrix t), ((infix_asdtdt tone m) = m).
Axiom scalar_tone_gen :
forall (m:matrix t) (a:t), (a = tone) -> ((infix_asdtdt a m) = m).
Axiom scalar_null_gen :
forall (m:matrix t) (a:t), (a = tzero) -> null_mat (infix_asdtdt a m).
Axiom scalar_plus :
forall (m:matrix t) (a:t) (b:t),
((infix_asdtdt (infix_pldt a b) m) =
(add_mat (infix_asdtdt a m) (infix_asdtdt b m))).
Axiom scalar_plus_rev :
forall (m:matrix t) (a:t) (b:t),
((add_mat (infix_asdtdt a m) (infix_asdtdt b m)) =
(infix_asdtdt (infix_pldt a b) m)).
Axiom add_scal :
forall (m:matrix t) (n:matrix t) (a:t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((infix_asdtdt a (add_mat m n)) =
(add_mat (infix_asdtdt a m) (infix_asdtdt a n))).
Axiom mat_mult_scal_values_l :
forall (m:matrix t) (n:matrix t) (a:t) (i:Z) (j:Z),
((rows n) = (columns m)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
((infix_asdt a (get (mat_mult m n) i j)) =
(ind_sum
(fun (k:Z) => (infix_asdt (infix_asdt a (get m i k)) (get n k j))) 0%Z
(columns m))).
Axiom mat_mult_scal_values_r :
forall (m:matrix t) (n:matrix t) (a:t) (i:Z) (j:Z),
((rows n) = (columns m)) -> ((rows m) = (columns n)) ->
((columns m) = (columns n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns n))%Z) ->
((infix_asdt (get (mat_mult m n) i j) a) =
(ind_sum
(fun (k:Z) => (infix_asdt (infix_asdt a (get m i k)) (get n k j))) 0%Z
(columns m))).
Axiom mat_mut_scal :
forall (m:matrix t) (n:matrix t) (a:t), ((rows n) = (columns m)) ->
((mat_mult m (infix_asdtdt a n)) = (infix_asdtdt a (mat_mult m n))).
Axiom scal_mat_mut :
forall (m:matrix t) (n:matrix t) (a:t), ((rows n) = (columns m)) ->
((mat_mult (infix_asdtdt a m) n) = (infix_asdtdt a (mat_mult m n))).
Axiom ind_sum_commute_scal_r :
forall (f:Z -> Z -> t) (g:Z -> t) (i:Z) (j:Z) (k:Z) (l:Z), (i <= j)%Z ->
(k <= l)%Z ->
((ind_sum (fun (k1:Z) => (infix_asdt (ind_sum (f k1) k l) (g k1))) i j) =
(ind_sum
(fun (k1:Z) =>
(ind_sum (fun (k2:Z) => (infix_asdt ((f k2) k1) (g k2))) i j))
k l)).
Axiom mat_mult_assoc_pre :
forall (m:matrix t) (n:matrix t) (o:matrix t) (i:Z) (j:Z),
((columns m) = (rows n)) -> ((columns n) = (rows o)) ->
((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns o))%Z) ->
((get (mat_mult (mat_mult m n) o) i j) =
(get (mat_mult m (mat_mult n o)) i j)).
Axiom mat_mult_assoc :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((columns m) = (rows n)) ->
((columns n) = (rows o)) ->
((mat_mult (mat_mult m n) o) = (mat_mult m (mat_mult n o))).
Axiom mat_mult_assoc_quant :
forall (m:matrix t) (n:matrix t), ((columns m) = (rows n)) ->
forall (o:matrix t), ((columns n) = (rows o)) ->
((mat_mult (mat_mult m n) o) = (mat_mult m (mat_mult n o))).
Axiom mat_mult_assoc_comm :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((columns m) = (rows n)) ->
((columns n) = (rows o)) ->
((mat_mult m (mat_mult n o)) = (mat_mult (mat_mult m n) o)).
Axiom scalar_eq :
forall (m:matrix t) (n:matrix t) (a:t), (m = n) ->
((infix_asdtdt a m) = (infix_asdtdt a n)).
Axiom scalar_eq_gen :
forall (m:matrix t) (n:matrix t) (a:t) (b:t), (m = n) -> (a = b) ->
((infix_asdtdt a m) = (infix_asdtdt b n)).
Axiom scalar_add :
forall (m:matrix t) (a:t) (b:t),
((infix_asdtdt (infix_pldt a b) m) =
(add_mat (infix_asdtdt a m) (infix_asdtdt b m))).
Axiom scalar_assoc :
forall (m:matrix t) (a:t) (b:t),
((infix_asdtdt a (infix_asdtdt b m)) = (infix_asdtdt (infix_asdt a b) m)).
Axiom scalar_assoc_rev :
forall (m:matrix t) (a:t) (b:t),
((infix_asdtdt (infix_asdt a b) m) = (infix_asdtdt a (infix_asdtdt b m))).
Axiom eq_scalar :
forall (m:matrix t) (a:t) (b:t),
(exists i:Z, exists j:Z, (valid_index m i j) /\ ~ ((get m i j) = tzero)) ->
((infix_asdtdt a m) = (infix_asdtdt b m)) -> (a = b).
Parameter mat_substr: (matrix t) -> (matrix t) -> matrix t.
Axiom mat_substr_def :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((mat_substr m n) = (add_mat m (infix_asdtdt (prefix_mndt tone) n))).
Axiom mat_substr_spec :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((rows (mat_substr m n)) = (rows m)).
Axiom mat_substr_spec1 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((columns (mat_substr m n)) = (columns m)).
Axiom mat_substr_spec2 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((get (mat_substr m n) i j) = (infix_mndt (get m i j) (get n i j))).
Axiom substr_rows :
forall (m:matrix t) (n:matrix t) (r:Z),
(((rows m) = (rows n)) /\ ((rows n) = r)) -> ((columns m) = (columns n)) ->
((rows (mat_substr m n)) = r).
Axiom substr_columns :
forall (m:matrix t) (n:matrix t) (c:Z), ((rows m) = (rows n)) ->
(((columns m) = (columns n)) /\ ((columns n) = c)) ->
((columns (mat_substr m n)) = c).
Axiom substr_value :
forall (m:matrix t) (n:matrix t) (i:Z) (j:Z), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((get (mat_substr m n) i j) = (infix_mndt (get m i j) (get n i j))).
Axiom distr_l_substr :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ((columns m) = (rows o)) ->
((mat_mult (mat_substr m n) o) =
(mat_substr (mat_mult m o) (mat_mult n o))).
Axiom distr_r_substr :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows n) = (rows o)) ->
((columns n) = (columns o)) -> ((columns m) = (rows o)) ->
((mat_mult m (mat_substr n o)) =
(mat_substr (mat_mult m n) (mat_mult m o))).
Axiom add_real_part :
forall (i:t) (j:t),
((infix_pldt (t_real_part i) (t_real_part j)) =
(t_real_part (infix_pldt i j))).
Axiom add_im_part :
forall (i:t) (j:t),
((infix_pldt (t_im_part i) (t_im_part j)) = (t_im_part (infix_pldt i j))).
Axiom add_real_part_rev :
forall (i:t) (j:t),
((t_real_part (infix_pldt i j)) =
(infix_pldt (t_real_part i) (t_real_part j))).
Axiom add_im_part_rev :
forall (i:t) (j:t),
((t_im_part (infix_pldt i j)) = (infix_pldt (t_im_part i) (t_im_part j))).
Axiom mult_distr_add_r :
forall (a:t) (b:t) (c:t),
((infix_asdt a (infix_pldt b c)) =
(infix_pldt (infix_asdt a b) (infix_asdt a c))).
Axiom mult_distr_add_l :
forall (a:t) (b:t) (c:t),
((infix_asdt (infix_pldt b c) a) =
(infix_pldt (infix_asdt a b) (infix_asdt a c))).
Axiom mult_distr_minus_r :
forall (a:t) (b:t) (c:t),
((infix_asdt a (infix_mndt b c)) =
(infix_mndt (infix_asdt a b) (infix_asdt a c))).
Axiom minus_distr_op :
forall (a:t) (b:t) (c:t),
((infix_mndt a (infix_pldt b c)) = (infix_mndt (infix_mndt a b) c)).
Axiom mult_distr_minus_l :
forall (a:t) (b:t) (c:t),
((infix_asdt (infix_mndt b c) a) =
(infix_mndt (infix_asdt a b) (infix_asdt a c))).
Axiom assoc_right :
forall (a:t) (b:t) (c:t),
((infix_pldt a (infix_pldt b c)) = (infix_pldt (infix_pldt a b) c)).
Axiom assoc_right_mult :
forall (a:t) (b:t) (c:t),
((infix_asdt a (infix_asdt b c)) = (infix_asdt (infix_asdt a b) c)).
Axiom minus_elim :
forall (a:t) (b:t), ((infix_mndt a b) = (infix_pldt a (prefix_mndt b))).
Axiom minus_distr_elim :
forall (a:t) (b:t) (c:t),
((infix_mndt a (infix_pldt b c)) =
(infix_pldt (infix_pldt a (prefix_mndt b)) (prefix_mndt c))).
Axiom plus_minus_distr_elim :
forall (a:t) (b:t) (c:t),
((infix_pldt a (prefix_mndt (infix_pldt b c))) =
(infix_pldt (infix_pldt a (prefix_mndt b)) (prefix_mndt c))).
Axiom def_by_minus :
forall (x:t) (y:t) (z:t), (x = (infix_mndt y z)) -> (y = (infix_pldt y z)).
Axiom switch :
forall (a:t) (b:t) (c:t),
((infix_pldt (infix_pldt a b) c) = (infix_pldt (infix_pldt a c) b)).
Axiom meet_a_c :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt a c) b) d)).
Axiom meet_a_d :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt a d) b) c)).
Axiom meet_b_c :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt b c) a) d)).
Axiom meet_b_d :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt b d) a) c)).
Axiom meet_c_d :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt c d) a) b)).
Axiom inv_add :
forall (a:t) (b:t), ((infix_pldt (infix_pldt a (prefix_mndt a)) b) = b).
Axiom switch_m :
forall (a:t) (b:t) (c:t),
((infix_pldt (infix_pldt a b) c) = (infix_pldt (infix_pldt a c) b)).
Axiom meet_a_c_m :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt a c) b) d)).
Axiom meet_a_d_m :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt a d) b) c)).
Axiom meet_b_c_m :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt b c) a) d)).
Axiom meet_b_d_m :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt b d) a) c)).
Axiom meet_c_d_m :
forall (a:t) (b:t) (c:t) (d:t),
((infix_pldt (infix_pldt (infix_pldt a b) c) d) =
(infix_pldt (infix_pldt (infix_pldt c d) a) b)).
Axiom t_real_part_add :
forall (a:t) (b:t),
((t_real_part (infix_pldt a b)) =
(infix_pldt (t_real_part a) (t_real_part b))).
Axiom t_real_part_subs :
forall (a:t) (b:t),
((t_real_part (infix_mndt a b)) =
(infix_mndt (t_real_part a) (t_real_part b))).
Axiom t_im_part_add :
forall (a:t) (b:t),
((t_im_part (infix_pldt a b)) = (infix_pldt (t_im_part a) (t_im_part b))).
Axiom t_im_part_subs :
forall (a:t) (b:t),
((t_im_part (infix_mndt a b)) = (infix_mndt (t_im_part a) (t_im_part b))).
Axiom t_real_part_real : forall (a:t), (real_ a) -> ((t_real_part a) = a).
Axiom t_real_part_im :
forall (a:t), (pure_im_ a) -> ((t_real_part a) = tzero).
Axiom im_t_im_part_im :
forall (a:t), (pure_im_ a) -> ((infix_asdt im (t_im_part a)) = a).
Axiom t_im_part_im :
forall (a:t), (pure_im_ a) ->
((t_im_part a) = (infix_asdt (prefix_mndt im) a)).
Axiom t_im_part_real : forall (a:t), (real_ a) -> ((t_im_part a) = tzero).
Axiom a_div_b_mult_a :
forall (a:t) (b:t) (c:t) (d:t), ~ (b = tzero) -> ~ (c = tzero) ->
(d = (infix_sldt tone b)) -> (a = c) ->
((infix_asdt (infix_sldt a b) (infix_sldt tone c)) = d).
Axiom mat_substr_eq :
forall (m:matrix t) (m':matrix t) (n:matrix t) (n':matrix t),
((rows m) = (rows n)) -> ((columns m) = (columns n)) -> (m = m') ->
(n = n') -> ((mat_substr m n) = (mat_substr m' n')).
Axiom substr_decomp :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> (m = (add_mat n (mat_substr m n))).
Axiom get_equal_mat_to_substr :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> (m = n) ->
((mat_substr m n) = (make (rows m) (columns m) tzero)).
Axiom set_inequal_mat_by_substr :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) -> ~ (m = n) ->
~ ((mat_substr m n) = (make (rows m) (columns m) tzero)).
Axiom set_inequal_mat_by_substr1 :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
~ ((mat_substr m n) = (make (rows m) (columns m) tzero)) -> ~ (m = n).
Parameter constant_size:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Prop.
Axiom constant_size_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) -> forall (e:a),
(mem e s) -> ((rows (f e)) = (rows (f (choose s)))).
Axiom constant_size_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) -> forall (e:a),
(mem e s) -> ((columns (f e)) = (columns (f (choose s)))).
Axiom constant_size_def2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t),
(forall (e:a), (mem e s) ->
((rows (f e)) = (rows (f (choose s)))) /\
((columns (f e)) = (columns (f (choose s))))) ->
constant_size s f.
Axiom set_constant_size :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((rows (f e)) = (rows (f e')))) ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((columns (f e)) = (columns (f e')))) ->
constant_size s f.
Axiom set_constant_size_exists :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t),
(exists r:Z, forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(exists c:Z, forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
constant_size s f.
Axiom set_constant_size_t :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z),
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> constant_size s f.
Parameter fc5:
forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (a -> bool) ->
(matrix t) -> a -> matrix t.
Axiom fc_def5 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (p:a -> bool) (m:matrix t) (j:a),
(((p j) = true) -> (((fc5 f p m) j) = (f j))) /\
(~ ((p j) = true) -> (((fc5 f p m) j) = m)).
Axiom guarded_set_constant_size :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (p:a -> bool) (m:matrix t),
(constant_size s f) -> (forall (e:a), (mem e s) -> ((p e) = true)) ->
constant_size s (fc5 f p m).
Axiom set_constant_size_set :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t) (m:matrix t) (i:Z) (j:Z),
(valid_index m i j) -> constant_size s (fun (e:a) => (set1 m i j (f e))).
Axiom get_constant_size :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((rows (f e)) = (rows (f e'))).
Axiom get_constant_size1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((columns (f e)) = (columns (f e'))).
Parameter s_rows:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z.
Axiom s_rows_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((s_rows s f) = (rows (f (choose s)))).
Axiom s_rows_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
(0%Z < (s_rows s f))%Z.
Axiom s_rows_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) -> forall (e:a),
(mem e s) -> ((rows (f e)) = (s_rows s f)).
Axiom s_rows_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((rows (f e)) = (rows (f e'))).
Parameter s_columns:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z.
Axiom s_columns_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((s_columns s f) = (columns (f (choose s)))).
Axiom s_columns_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
(0%Z < (s_columns s f))%Z.
Axiom s_columns_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) -> forall (e:a),
(mem e s) -> ((columns (f e)) = (s_columns s f)).
Axiom s_columns_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
forall (e:a) (e':a), (mem e s) -> (mem e' s) ->
((columns (f e)) = (columns (f e'))).
Axiom set_s_rows :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z), (constant_size s f) ->
((rows (f (choose s))) = r) -> ((s_rows s f) = r).
Axiom set_s_rows_elt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (elt:a), (constant_size s f) ->
(mem elt s) -> ((s_rows s f) = (rows (f elt))).
Axiom set_s_columns :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z), (constant_size s f) ->
((columns (f (choose s))) = r) -> ((s_columns s f) = r).
Axiom set_s_columns_elt :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (elt:a), (constant_size s f) ->
(mem elt s) -> ((s_columns s f) = (columns (f elt))).
Axiom s_rows_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
(constant_size s f) -> ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((f e) = (g e))) ->
((s_rows s f) = (s_rows s g)).
Axiom set_constant_size_give :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> constant_size s f.
Axiom set_constant_size_give1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> forall (e:a),
(mem e s) -> ((rows (f e)) = r).
Axiom set_constant_size_give2 : True.
Axiom set_constant_size_give3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> ((s_rows s f) = r).
Axiom set_constant_size_give4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> ((s_columns s f) = c).
Axiom s_columns_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
(constant_size s f) -> ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((f e) = (g e))) ->
((s_columns s f) = (s_columns s g)).
Axiom subset_constant_size :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t), (constant_size s f) ->
~ (is_empty s') -> (subset s' s) -> constant_size s' f.
Axiom subset_constant_size1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t), (constant_size s f) ->
~ (is_empty s') -> (subset s' s) -> ((s_rows s' f) = (s_rows s f)).
Axiom subset_constant_size2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t), (constant_size s f) ->
~ (is_empty s') -> (subset s' s) -> ((s_columns s' f) = (s_columns s f)).
Axiom set_s_rows_rem :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) -> constant_size (remove (choose s) s) f.
Axiom set_s_rows_rem1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) ->
((s_rows (remove (choose s) s) f) = (rows (f (choose s)))).
Axiom set_s_columns_rem :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) -> constant_size (remove (choose s) s) f.
Axiom set_s_columns_rem1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) ->
((s_columns (remove (choose s) s) f) = (columns (f (choose s)))).
Axiom set_s_rows_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
((rows (f x)) = (s_rows s f)) -> ((s_rows (add x s) f) = (s_rows s f)).
Axiom set_s_columns_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
((rows (f x)) = (s_rows s f)) ->
((s_columns (add x s) f) = (s_columns s f)).
Axiom set_s_rows_columns_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
((rows (f x)) = (s_rows s f)) ->
((s_columns (add x s) f) = (s_columns s f)).
Axiom set_s_rows_columns_add1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) -> ((columns (f x)) = (s_columns s f)) ->
((rows (f x)) = (s_rows s f)) -> ((s_rows (add x s) f) = (s_rows s f)).
Parameter mat_sum:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.
Axiom mat_sum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> ((cardinal s) = 1%Z) ->
((mat_sum s f) = (f (element s))).
Axiom mat_sum_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> ~ ((cardinal s) = 1%Z) ->
((mat_sum s f) =
(add_mat (f (choose s)) (mat_sum (remove (choose s) s) f))).
Axiom mat_sum_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> ((rows (mat_sum s f)) = (s_rows s f)).
Axiom mat_sum_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> ((columns (mat_sum s f)) = (s_columns s f)).
Axiom mat_sum_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> forall (e:a), (mem e s) ->
((rows (f e)) = (s_rows s f)).
Axiom mat_sum_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> forall (e:a), (mem e s) ->
((columns (f e)) = (s_columns s f)).
Axiom columns_mat_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), ~ ((cardinal s) = 0%Z) ->
(constant_size s f) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = n)) ->
((columns (mat_sum s f)) = n).
Axiom rows_mat_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), ~ ((cardinal s) = 0%Z) ->
(constant_size s f) -> (forall (e:a), (mem e s) -> ((rows (f e)) = n)) ->
((rows (mat_sum s f)) = n).
Axiom mat_sum_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) = 1%Z) ->
((mat_sum s f) = (f (element s))).
Axiom mat_sum_to_sum_pre :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (i:Z) (j:Z), (constant_size s f) ->
((cardinal s) > 0%Z)%Z -> ((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
((get (mat_sum s f) i j) = (sum s (fun (e:a) => (get (f e) i j)))).
Axiom mat_sum_to_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((mat_sum s f) =
(make_f (s_rows s f) (s_columns s f)
(fun (i:Z) (j:Z) => (sum s (fun (e:a) => (get (f e) i j)))))).
Axiom mat_sum_value :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((mat_sum s f) =
(make_f (s_rows s f) (s_columns s f)
(fun (i:Z) (j:Z) => (sum s (fun (e:a) => (get (f e) i j)))))).
Axiom mat_sum_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) -> ((rows (f x)) = (s_rows s f)) ->
((columns (f x)) = (s_columns s f)) -> ~ (mem x s) ->
((mat_sum (add x s) f) = (add_mat (f x) (mat_sum s f))).
Axiom mat_sum_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) ->
((mat_sum s f) =
(add_mat (f (choose s)) (mat_sum (remove (choose s) s) f))).
Axiom mat_sum_comp_pre :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (i:Z) (j:Z),
(constant_size s f) -> (constant_size s g) ->
((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
((cardinal s) > 0%Z)%Z ->
((get (mat_sum s (fun (k:b) => (add_mat (f k) (g k)))) i j) =
(get (add_mat (mat_sum s f) (mat_sum s g)) i j)).
Axiom mat_sum_comp :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t),
(constant_size s f) -> (constant_size s g) ->
((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (k:b) => (add_mat (f k) (g k)))) =
(add_mat (mat_sum s f) (mat_sum s g))).
Axiom mat_sum_comp_rec :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t),
(constant_size s f) -> (constant_size s g) ->
((s_rows s f) = (s_rows s g)) -> ((s_columns s f) = (s_columns s g)) ->
((cardinal s) > 0%Z)%Z ->
((add_mat (mat_sum s f) (mat_sum s g)) =
(mat_sum s (fun (k:b) => (add_mat (f k) (g k))))).
Axiom mat_sum_to_sum_fun :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (s':set b) (f:a -> b -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z),
((cardinal s) > 0%Z)%Z -> ((cardinal s') > 0%Z)%Z ->
(forall (e:a), forall (e1:b), (mem e s) -> (mem e1 s') ->
((rows ((f e) e1)) = r)) ->
(forall (e:a), forall (e1:b), (mem e s) -> (mem e1 s') ->
((columns ((f e) e1)) = c)) ->
((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
((sum s (fun (e:a) => (get (mat_sum s' (f e)) i j))) =
(sum s (fun (e:a) => (sum s' (fun (e1:b) => (get ((f e) e1) i j)))))).
Axiom mat_sum_to_sum_double_pre :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (s':set b) (f:a -> b -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z),
(forall (e:a) (e':b), (mem e s) -> (mem e' s') -> ((rows ((f e) e')) = r)) ->
(forall (e:a) (e':b), (mem e s) -> (mem e' s') ->
((columns ((f e) e')) = c)) ->
((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
((cardinal s) > 0%Z)%Z -> ((cardinal s') > 0%Z)%Z ->
((get (mat_sum s (fun (e:a) => (mat_sum s' (f e)))) i j) =
(sum s (fun (e:a) => (sum s' (fun (e':b) => (get ((f e) e') i j)))))).
Axiom mat_mult_sum_out_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((columns (f e)) = (rows n))) ->
(exists r:Z, forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
((mat_mult (mat_sum s f) n) =
(mat_sum s (fun (e:a) => (mat_mult (f e) n)))).
Parameter mat_sum_dim:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
Z -> matrix t.
Axiom mat_sum_dim_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (make r c tzero)).
Axiom mat_sum_dim_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
~ ((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (mat_sum s f)).
Axiom mat_sum_dim_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((cardinal s) > 0%Z)%Z -> ((mat_sum_dim s f r c) = (mat_sum s f)).
Axiom mat_sum_dim_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((cardinal s) = 0%Z) -> ((mat_sum_dim s f r c) = (make r c tzero)).
Axiom mat_sum_dim_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((rows (mat_sum_dim s f r c)) = r).
Axiom mat_sum_dim_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (0%Z < r)%Z ->
(0%Z < c)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((columns (mat_sum_dim s f r c)) = c).
Axiom mat_sum_dim_to_mat_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) > 0%Z)%Z ->
(0%Z < r)%Z -> (0%Z < c)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((mat_sum_dim s f r c) = (mat_sum s f)).
Axiom mat_sum_dim_to_make_zero :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), ((cardinal s) = 0%Z) ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) -> (0%Z < r)%Z ->
(0%Z < c)%Z -> ((mat_sum_dim s f r c) = (make r c tzero)).
Axiom mat_sum_dim_add :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (x:a) (r:Z) (c:Z),
((cardinal s) >= 0%Z)%Z -> ~ (mem x s) ->
(forall (e:a), (mem e (add x s)) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e (add x s)) -> ((columns (f e)) = c)) ->
(0%Z < r)%Z -> (0%Z < c)%Z ->
((mat_sum_dim (add x s) f r c) = (add_mat (f x) (mat_sum_dim s f r c))).
Axiom mat_sum_scalar :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k)))) =
(infix_asdtdt a1 (mat_sum s f))).
Axiom mat_sum_scalar_rev :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((infix_asdtdt a1 (mat_sum s f)) =
(mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k))))).
Axiom real : forall (x:t), (real_ x) -> (x = (r_to_t (real_part x))).
Axiom pure_im :
forall (x:t), (pure_im_ x) -> (x = (infix_asdt im (r_to_t (im_part x)))).
Axiom im_dec : ((real_part im) = 0%R).
Axiom im_dec1 : ((im_part im) = 1%R).
Axiom tone_dec : ((real_part tone) = 1%R).
Axiom tone_dec1 : ((im_part tone) = 0%R).
Axiom tzero_dec : ((real_part tzero) = 0%R).
Axiom tzero_dec1 : ((im_part tzero) = 0%R).
Axiom ttwo_dec : ((real_part ttwo) = 2%R).
Axiom ttwo_dec1 : ((im_part ttwo) = 0%R).
Parameter i_to_t: Z -> t.
Axiom i_to_t_def : forall (i:Z), ((i_to_t i) = (r_to_t (from_int i))).
Axiom i_to_t_spec : forall (i:Z), real_ (i_to_t i).
Axiom i_to_t_zero : ((i_to_t 0%Z) = tzero).
Axiom i_to_t_eq : forall (i:Z) (j:Z), (i = j) -> ((i_to_t i) = (i_to_t j)).
Axiom i_to_t_nzero : forall (i:Z), ~ (i = 0%Z) -> ~ ((i_to_t i) = tzero).
Axiom i_to_t_one : ((i_to_t 1%Z) = tone).
Axiom i_to_t_add :
forall (i:Z) (j:Z),
((infix_pldt (i_to_t i) (i_to_t j)) = (i_to_t (i + j)%Z)).
Axiom i_to_t_add_rev :
forall (i:Z) (j:Z),
((i_to_t (i + j)%Z) = (infix_pldt (i_to_t i) (i_to_t j))).
Axiom i_to_t_ttwo : ((i_to_t 2%Z) = ttwo).
Axiom i_to_t_mult :
forall (i:Z) (j:Z),
((infix_asdt (i_to_t i) (i_to_t j)) = (i_to_t (i * j)%Z)).
Axiom i_to_t_mult_rev :
forall (i:Z) (j:Z),
((i_to_t (i * j)%Z) = (infix_asdt (i_to_t i) (i_to_t j))).
Axiom i_to_t_mult_assoc :
forall (x:t) (i:Z) (j:Z),
((infix_asdt x (i_to_t (i * j)%Z)) =
(infix_asdt (infix_asdt x (i_to_t i)) (i_to_t j))).
Axiom i_to_t_mult_assoc_rev :
forall (x:t) (i:Z) (j:Z),
((infix_asdt (infix_asdt x (i_to_t i)) (i_to_t j)) =
(infix_asdt x (i_to_t (i * j)%Z))).
Axiom i_to_t_sub :
forall (i:Z) (j:Z),
((infix_mndt (i_to_t i) (i_to_t j)) = (i_to_t (i - j)%Z)).
Axiom i_to_t_opp :
forall (i:Z), ((i_to_t (-i)%Z) = (prefix_mndt (i_to_t i))).
Axiom i_to_t_div :
forall (i:Z) (j:Z), ~ (j = 0%Z) ->
((infix_sldt (i_to_t (i * j)%Z) (i_to_t j)) = (i_to_t i)).
Axiom i_to_t_minus_mult :
forall (i:Z) (j:Z),
((infix_asdt (i_to_t (-i)%Z) (i_to_t j)) =
(infix_asdt (i_to_t i) (i_to_t (-j)%Z))).
Axiom positive_int_squrt :
forall (i:Z), (i > 0%Z)%Z -> infix_gtdt (square_rt (i_to_t i)) tzero.
Axiom non_null_int_squrt :
forall (i:Z), (i > 0%Z)%Z -> ~ ((square_rt (i_to_t i)) = tzero).
Axiom sum_constant :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t) (x:t),
(forall (e:a), (mem e s) -> ((t1 e) = x)) ->
((sum s t1) = (infix_asdt (i_to_t (cardinal s)) x)).
Axiom sum_const_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (t1:a -> t),
(forall (e:a), (mem e s) -> ((t1 e) = tone)) ->
((sum s t1) = (i_to_t (cardinal s))).
Axiom mat_sum_const :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:matrix t), ((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (us:a) => x)) = (infix_asdtdt (i_to_t (cardinal s)) x)).
Axiom mat_sum_quot :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:matrix t), ((cardinal s) > 0%Z)%Z ->
(x =
(infix_asdtdt (infix_sldt tone (i_to_t (cardinal s)))
(mat_sum s (fun (us:a) => x)))).
Axiom mat_sum_scalar_right :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (i:Z) (j:Z),
(constant_size s f) -> ((cardinal s) > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
((infix_asdtdt (get (mat_sum s f) i j) m) =
(mat_sum s (fun (k:a) => (infix_asdtdt (get (f k) i j) m)))).
Axiom mat_sum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (g:a -> matrix t),
((cardinal s) > 0%Z)%Z -> (constant_size s f) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((mat_sum s f) = (mat_sum s g)).
Axiom mat_sum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t),
((cardinal s) > 0%Z)%Z -> (s = s') -> (constant_size s f) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((mat_sum s f) = (mat_sum s' g)).
Axiom mat_sum_eq_gen_int :
forall (i1:Z) (i2:Z) (o1:Z) (o2:Z) (f:Z -> matrix t) (g:Z -> matrix t),
(i1 < o1)%Z -> (i1 = o1) -> (i2 = o2) ->
(constant_size (to_fset i1 o1) f) ->
(forall (a:Z), (mem a (to_fset i1 o1)) -> ((f a) = (g a))) ->
((mat_sum (to_fset i1 o1) f) = (mat_sum (to_fset i2 o2) g)).
Axiom mat_sum_comp_eq :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (h:b -> matrix t),
(constant_size s f) -> (constant_size s g) -> (constant_size s h) ->
(((s_rows s f) = (s_rows s g)) /\ ((s_rows s g) = (s_rows s h))) ->
(((s_columns s f) = (s_columns s g)) /\
((s_columns s g) = (s_columns s h))) ->
((cardinal s) > 0%Z)%Z ->
(forall (e:b), forall (i:Z) (j:Z), (mem e s) ->
((0%Z <= i)%Z /\ (i < (s_rows s f))%Z) ->
((0%Z <= j)%Z /\ (j < (s_columns s f))%Z) ->
((infix_pldt (get (f e) i j) (get (g e) i j)) = (get (h e) i j))) ->
((add_mat (mat_sum s f) (mat_sum s g)) = (mat_sum s h)).
Axiom mat_sum_dim_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (g:a -> matrix t) (r:Z) (c:Z),
(0%Z < r)%Z -> (0%Z < c)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
(forall (e:a), (mem e s) -> ((f e) = (g e))) ->
((mat_sum_dim s f r c) = (mat_sum_dim s g r c)).
Axiom constant_size_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:b -> matrix t) (s:set a) (t1:a -> b),
(constant_size s (fun (a1:a) => (f (t1 a1)))) -> constant_size (map t1 s) f.
Axiom map_mat_sum :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:b -> matrix t) (s:set a) (t1:a -> b), ((cardinal s) > 0%Z)%Z ->
(constant_size s (fun (a1:a) => (f (t1 a1)))) -> (p_injective t1 s) ->
((mat_sum (map t1 s) f) = (mat_sum s (fun (a1:a) => (f (t1 a1))))).
Axiom map_mat_sum_rec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:b -> matrix t) (s:set a) (t1:a -> b), ((cardinal s) > 0%Z)%Z ->
(constant_size s (fun (a1:a) => (f (t1 a1)))) -> (p_injective t1 s) ->
((mat_sum s (fun (a1:a) => (f (t1 a1)))) = (mat_sum (map t1 s) f)).
Axiom mat_sum_id :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), ((cardinal s) > 0%Z)%Z ->
(constant_size s f) ->
(constant_size (map f s) (fun (y0:matrix t) => (p_id y0))) ->
(p_injective f s) ->
((mat_sum (map f s) (fun (y0:matrix t) => (p_id y0))) = (mat_sum s f)).
Parameter nonn_mat_subset:
forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (set a) -> set a.
Parameter result7:
forall {a:Type} {a_WT:WhyType a}, (a -> matrix t) -> (set a) -> a -> bool.
Axiom result_def7 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e:a),
(((result7 f s) e) = true) <->
~ (equal (f e) (make (s_rows s f) (s_columns s f) tzero)).
Axiom nonn_mat_subset_def :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
((nonn_mat_subset f s) = (filter (result7 f s) s)).
Axiom nonn_mat_subset_spec :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
subset (nonn_mat_subset f s) s.
Axiom nonn_mat_subset_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) -> forall (e:a),
(mem e (nonn_mat_subset f s)) -> mem e s.
Axiom nonn_mat_subset_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
constant_size (nonn_mat_subset f s) f.
Axiom nonn_mat_subset_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
~ ((nonn_mat_subset f s) = (empty : set a)) ->
((s_rows (nonn_mat_subset f s) f) = (s_rows s f)).
Axiom nonn_mat_subset_spec4 :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) ->
~ ((nonn_mat_subset f s) = (empty : set a)) ->
((s_columns (nonn_mat_subset f s) f) = (s_columns s f)).
Axiom mat_subset_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) -> forall (e:a),
(mem e (nonn_mat_subset f s)) -> mem e s.
Axiom mat_subset_nonn_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), (constant_size s f) -> forall (e:a),
(mem e (nonn_mat_subset f s)) ->
~ ((f e) = (make (s_rows s f) (s_columns s f) tzero)).
Axiom nonn_mat_sum_cardzero :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) = 0%Z) ->
(r > 0%Z)%Z -> (c > 0%Z)%Z ->
((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).
Axiom nonn_mat_sum_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) = 1%Z) ->
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((rows (f (choose s))) = r) ->
((columns (f (choose s))) = c) ->
((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).
Axiom mat_sum_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e:a), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) -> (mem e s) ->
(forall (e':a), (mem e' s) -> ~ (e = e') -> null_mat (f e')) ->
((mat_sum s f) = (f e)).
Axiom nonn_mat_sum_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) > 1%Z)%Z ->
(r > 0%Z)%Z -> (c > 0%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((mat_sum_dim (remove (choose s) s) f r c) =
(mat_sum_dim (nonn_mat_subset f (remove (choose s) s)) f r c)) ->
((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).
Axiom nonn_mat_sum :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
((mat_sum_dim s f r c) = (mat_sum_dim (nonn_mat_subset f s) f r c)).
Axiom mat_sum_map_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}
{c:Type} {c_WT:WhyType c},
forall (s1:set a) (s2:set b) (t1:a -> c) (t2:b -> c) (f:c -> matrix t),
((cardinal s1) > 0%Z)%Z -> (p_injective t1 s1) ->
(constant_size s1 (fun (a1:a) => (f (t1 a1)))) ->
((cardinal s2) > 0%Z)%Z -> (p_injective t2 s2) ->
(constant_size s2 (fun (a1:b) => (f (t2 a1)))) ->
((map t1 s1) = (map t2 s2)) ->
((mat_sum (map t1 s1) f) = (mat_sum (map t2 s2) f)).
Axiom mat_sum_disjoint_transitivity :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s1:set a) (s2:set a) (f:a -> matrix t),
(constant_size s f) -> ((inter s1 s2) = (empty : set a)) ->
((union s1 s2) = s) -> ((cardinal s1) > 0%Z)%Z ->
((cardinal s2) > 0%Z)%Z ->
((add_mat (mat_sum s1 f) (mat_sum s2 f)) = (mat_sum s f)).
Axiom mat_sum_null :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a), ((cardinal s) > 1%Z)%Z ->
(constant_size s f) ->
(forall (e:a), (mem e s) -> forall (i:Z) (j:Z), (valid_index (f e) i j) ->
((get (f e) i j) = tzero)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum s f) i j) ->
((get (mat_sum s f) i j) = tzero).
Axiom mat_sum_null_b :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (r:Z) (c:Z), ((cardinal s) > 1%Z)%Z ->
(forall (e:a), (mem e s) -> ((rows (f e)) = r)) ->
(forall (e:a), (mem e s) -> ((columns (f e)) = c)) ->
(forall (e:a), (mem e s) -> forall (i:Z) (j:Z), (valid_index (f e) i j) ->
((get (f e) i j) = tzero)) ->
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> ((get (mat_sum s f) i j) = tzero).
Axiom map_add_mat_sum_t :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s:set a) (s':set b) (f:b -> matrix t) (injz:a -> b) (injo:a -> b),
(constant_size s' f) -> ((cardinal s) > 0%Z)%Z ->
((inter (map injz s) (map injo s)) = (empty : set b)) ->
((union (map injz s) (map injo s)) = s') -> (p_injective injo s) ->
(p_injective injz s) ->
((mat_sum s (fun (e:a) => (add_mat (f (injz e)) (f (injo e))))) =
(mat_sum s' f)).
Axiom map_add_mat_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s1:set a) (s2:set a) (s':set a) (f:a -> matrix t)
(g:a -> matrix t) (h:a -> matrix t),
(constant_size s' h) -> (constant_size s f) -> (constant_size s g) ->
(((s_rows s' h) = (s_rows s f)) /\ ((s_rows s f) = (s_rows s g))) ->
(((s_columns s' h) = (s_columns s f)) /\
((s_columns s f) = (s_columns s g))) ->
((cardinal s) > 0%Z)%Z -> (p_injective f s) -> (p_injective g s) ->
(p_injective h s') -> ((map f s) = (map h s1)) ->
((map g s) = (map h s2)) -> ((inter s1 s2) = (empty : set a)) ->
((union s1 s2) = s') ->
((mat_sum s (fun (e:a) => (add_mat (f e) (g e)))) =
(mat_sum s' (fun (e:a) => (h e)))).
Parameter inv_func:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> b -> a.
Axiom inv_func_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e':b), (p_bijective f s s') ->
(mem e' s') ->
((inv_func f s s' e') =
(element (filter (fun (e:a) => (indic_bool (f e) e')) s))).
Axiom inv_func_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e':b), (p_bijective f s s') ->
(mem e' s') -> mem (inv_func f s s' e') s.
Axiom inv_func_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e':b), (p_bijective f s s') ->
(mem e' s') -> ((f (inv_func f s s' e')) = e').
Axiom inv_rec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e:a), (p_bijective f s s') ->
(mem e s) -> ((inv_func f s s' (f e)) = e).
Parameter inv_:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> b -> a.
Axiom inv__def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e:b), (p_bijective f s s') ->
(mem e s') -> ((inv_ f s s' e) = (inv_func f s s' e)).
Axiom inv__spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e:b), (p_bijective f s s') ->
(mem e s') -> mem (inv_ f s s' e) s.
Axiom inv__spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b) (e:b), (p_bijective f s s') ->
(mem e s') -> ((f (inv_ f s s' e)) = e).
Axiom inv_bijective :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_bijective
((((fun (y0:a -> b) (y1:set a) (y2:set b) (y3:b) => (inv_ y0 y1 y2 y3)) f)
s)
s')
s' s.
Axiom set_bijective_inv :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:b -> a) (s:set a) (b1:b), (mem b1 (map f s)) ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
p_bijective f s (map f s).
Axiom set_bijective_inv1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:b -> a) (s:set a) (b1:b), (mem b1 (map f s)) ->
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
((inv_func f s (map f s) b1) = (g b1)).
Axiom set_bij_inv :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:b -> a) (s:set a),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
p_bijective f s (map f s).
Axiom set_bij_inv1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:b -> a) (s:set a),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
p_bijective g (map f s) s.
Axiom set_bij_inv2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (g:b -> a) (s:set a),
(forall (e:a) (e':a), (mem e s) -> (mem e' s) -> ~ (e = e') ->
~ ((f e) = (f e'))) ->
(forall (e':b), (mem e' (map f s)) -> (mem (g e') s) /\ ((f (g e')) = e')) ->
forall (b1:b), (mem b1 (map f s)) -> ((inv_func f s (map f s) b1) = (g b1)).
Parameter inv_f:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> (set b) -> b -> a.
Axiom inv_f_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (e:b), (mem e s') -> mem ((inv_f f s s') e) s.
Axiom inv_f_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
forall (e:b), (mem e s') -> ((f ((inv_f f s s') e)) = e).
Axiom inv_f_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (s:set a) (s':set b), (p_bijective f s s') ->
p_bijective (inv_f f s s') s' s.
Axiom bitvec : Type.
Parameter bitvec_WhyType : WhyType bitvec.
Existing Instance bitvec_WhyType.
Parameter value: bitvec -> Z -> Z.
Parameter length: bitvec -> Z.
Axiom bitvec'invariant : forall (self:bitvec), (0%Z <= (length self))%Z.
Axiom bitvec'invariant1 :
forall (self:bitvec), forall (i:Z),
((0%Z <= i)%Z /\ (i < (length self))%Z) -> (0%Z <= ((value self) i))%Z.
Axiom bitvec'invariant2 :
forall (self:bitvec), forall (i:Z),
((0%Z <= i)%Z /\ (i < (length self))%Z) -> (((value self) i) < 2%Z)%Z.
Axiom bitvec'invariant3 :
forall (self:bitvec), forall (i:Z), ~ (0%Z <= i)%Z ->
(((value self) i) = 0%Z).
Axiom bitvec'invariant4 :
forall (self:bitvec), forall (i:Z), ~ (i < (length self))%Z ->
(((value self) i) = 0%Z).
Parameter bvlength: (Z -> Z) -> Z -> Prop.
Axiom bvlength_def :
forall (f:Z -> Z) (i:Z), (bvlength f i) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < i)%Z) -> (0%Z <= (f k))%Z.
Axiom bvlength_def1 :
forall (f:Z -> Z) (i:Z), (bvlength f i) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < i)%Z) -> ((f k) < 2%Z)%Z.
Axiom bvlength_def2 :
forall (f:Z -> Z) (i:Z),
(forall (k:Z), ((0%Z <= k)%Z /\ (k < i)%Z) ->
(0%Z <= (f k))%Z /\ ((f k) < 2%Z)%Z) ->
bvlength f i.
Axiom binary_mult :
forall (a:Z) (b:Z),
((int.EuclideanDivision.mod1 (a * b)%Z 2%Z) =
((int.EuclideanDivision.mod1 a 2%Z) *
(int.EuclideanDivision.mod1 b 2%Z))%Z).
Parameter getbv: bitvec -> Z -> Z.
Axiom getbv_def : forall (a:bitvec), ((getbv a) = (value a)).
Axiom getbv_spec : forall (a:bitvec), binary (getbv a).
Axiom getbv_spec1 :
forall (a:bitvec), forall (i:Z), (((getbv a) i) = ((value a) i)).
Parameter to_bool: Z -> bool.
Axiom to_bool_def :
forall (i:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) -> ~ (i = 0%Z) ->
((to_bool i) = true).
Axiom to_bool_def1 :
forall (i:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) -> (i = 0%Z) ->
((to_bool i) = false).
Axiom getbv_bound : forall (bv:bitvec) (i:Z), (0%Z <= ((getbv bv) i))%Z.
Axiom getbv_bound1 : forall (bv:bitvec) (i:Z), (((getbv bv) i) < 2%Z)%Z.
Axiom getbv_eq :
forall (bvx:bitvec) (bvy:bitvec) (i:Z), (bvx = bvy) ->
(((getbv bvx) i) = ((getbv bvy) i)).
Axiom getbv_eq_gen :
forall (bvx:bitvec) (bvy:bitvec) (i:Z) (j:Z), (bvx = bvy) -> (i = j) ->
(((getbv bvx) i) = ((getbv bvy) j)).
Parameter setbv: (Z -> Z) -> Z -> Z -> Z -> Z.
Axiom setbv_def :
forall (bv:Z -> Z) (i:Z) (j:Z),
let result8 := setbv bv i j in
forall (k:Z),
((k = i) -> ((result8 k) = j)) /\ (~ (k = i) -> ((result8 k) = (bv k))).
Axiom setbv_spec :
forall (bv:Z -> Z) (i:Z) (j:Z), forall (k:Z), ~ (k = i) ->
(((setbv bv i j) k) = (bv k)).
Axiom setbv_spec1 : forall (bv:Z -> Z) (i:Z) (j:Z), (((setbv bv i j) i) = j).
Parameter setbv_int: (Z -> Z) -> (Z -> Z) -> Z -> Z -> Z -> Z.
Axiom setbv_int_def :
forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z),
let result8 := setbv_int bv1 bv2 i j in
forall (k:Z),
(((i < k)%Z /\ (k <= j)%Z) -> ((result8 k) = (bv2 (k - i)%Z))) /\
(~ ((i < k)%Z /\ (k <= j)%Z) -> ((result8 k) = (bv1 k))).
Axiom setbv_int_spec :
forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z), forall (k:Z),
((i < k)%Z /\ (k <= j)%Z) ->
(((setbv_int bv1 bv2 i j) k) = (bv2 (k - i)%Z)).
Axiom setbv_int_spec1 :
forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z), forall (k:Z), (k <= i)%Z ->
(((setbv_int bv1 bv2 i j) k) = (bv1 k)).
Axiom setbv_int_spec2 :
forall (bv1:Z -> Z) (bv2:Z -> Z) (i:Z) (j:Z), forall (k:Z), (j < k)%Z ->
(((setbv_int bv1 bv2 i j) k) = (bv1 k)).
Axiom set_bvlength :
forall (bv:bitvec) (i:Z),
(forall (k:Z), ((1%Z <= k)%Z /\ (k < i)%Z) ->
(0%Z <= ((getbv bv) k))%Z /\ (((getbv bv) k) < 2%Z)%Z) ->
bvlength (getbv bv) i.
Axiom set_flength :
forall (f:Z -> Z) (i:Z),
(forall (k:Z), ((0%Z <= k)%Z /\ (k < i)%Z) ->
(0%Z <= (f k))%Z /\ ((f k) < 2%Z)%Z) ->
bvlength f i.
Axiom get_bvlength :
forall (f:Z -> Z) (i:Z), (bvlength f i) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < i)%Z) -> (0%Z <= (f k))%Z.
Axiom get_bvlength1 :
forall (f:Z -> Z) (i:Z), (bvlength f i) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < i)%Z) -> ((f k) < 2%Z)%Z.
Axiom set_bv_to :
forall (f:Z -> Z) (i:Z), (0%Z < i)%Z ->
(forall (j:Z), ((0%Z <= j)%Z /\ (j < i)%Z) ->
(0%Z <= (f j))%Z /\ ((f j) <= 1%Z)%Z) ->
bvlength f i.
Axiom set_in_range_val :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
(0%Z <= ((getbv bv) i))%Z.
Axiom set_in_range_val1 :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
(((getbv bv) i) < 2%Z)%Z.
Axiom bvlengthm :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
bvlength (getbv bv) i.
Parameter in_range: bitvec -> Z -> Prop.
Axiom in_range_def :
forall (bv:bitvec) (r:Z), (in_range bv r) -> (0%Z <= r)%Z.
Axiom in_range_def1 :
forall (bv:bitvec) (r:Z), (in_range bv r) -> (r < (length bv))%Z.
Axiom in_range_def2 :
forall (bv:bitvec) (r:Z), ((0%Z <= r)%Z /\ (r < (length bv))%Z) ->
in_range bv r.
Axiom binary_bv :
forall (bv:bitvec) (i:Z), (in_range bv i) -> (0%Z <= ((getbv bv) i))%Z.
Axiom binary_bv1 :
forall (bv:bitvec) (i:Z), (in_range bv i) -> (((getbv bv) i) <= 1%Z)%Z.
Axiom equal_bv :
forall (m:bitvec) (n:bitvec), (m = n) -> ((length m) = (length n)).
Axiom equal_bv1 :
forall (m:bitvec) (n:bitvec), (m = n) -> forall (i:Z), (in_range m i) ->
(((getbv m) i) = ((getbv n) i)).
Axiom equal_bv2 :
forall (m:bitvec) (n:bitvec),
(((length m) = (length n)) /\
forall (i:Z), (in_range m i) -> (((getbv m) i) = ((getbv n) i))) ->
(m = n).
Axiom set_equal_bv :
forall (bv:bitvec) (bv':bitvec), ((length bv) = (length bv')) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
(((getbv bv) i) = ((getbv bv') i))) ->
(bv = bv').
Axiom get_equal_bv :
forall (bv:bitvec) (bv':bitvec), (bv = bv') -> ((length bv) = (length bv')).
Axiom get_equal_bv1 :
forall (bv:bitvec) (bv':bitvec), (bv = bv') -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (length bv))%Z) -> (((getbv bv) i) = ((getbv bv') i)).
Parameter make_bv: (Z -> Z) -> Z -> bitvec.
Axiom make_bv_spec :
forall (f:Z -> Z) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(s >= 0%Z)%Z -> ((length (make_bv f s)) = s).
Axiom make_bv_spec1 :
forall (f:Z -> Z) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(s >= 0%Z)%Z -> forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(((getbv (make_bv f s)) i) = (f i)).
Axiom make_bv_spec2 :
forall (f:Z -> Z) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(s >= 0%Z)%Z -> forall (i:Z), ~ (0%Z <= i)%Z ->
(((getbv (make_bv f s)) i) = 0%Z).
Axiom make_bv_spec3 :
forall (f:Z -> Z) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(s >= 0%Z)%Z -> forall (i:Z), ~ (i < s)%Z ->
(((getbv (make_bv f s)) i) = 0%Z).
Parameter make_bv_m: (Z -> Z) -> Z -> bitvec.
Axiom make_bv_m_def :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z ->
((make_bv_m f s) =
(make_bv (fun (k:Z) => (int.EuclideanDivision.mod1 (f k) 2%Z)) s)).
Axiom make_bv_m_spec :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> ((length (make_bv_m f s)) = s).
Axiom make_bv_m_spec1 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (i:Z),
bvlength (getbv (make_bv_m f s)) i.
Axiom make_bv_m_spec2 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (k:Z),
((0%Z <= k)%Z /\ (k < s)%Z) ->
(((getbv (make_bv_m f s)) k) = (int.EuclideanDivision.mod1 (f k) 2%Z)).
Axiom make_bv_m_spec3 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (k:Z), ~ (0%Z <= k)%Z ->
(((getbv (make_bv_m f s)) k) = 0%Z).
Axiom make_bv_m_spec4 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (k:Z), ~ (k < s)%Z ->
(((getbv (make_bv_m f s)) k) = 0%Z).
Axiom assert_make_bv_no_bound :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
((1%Z <= i)%Z /\ (i <= s)%Z) -> (((getbv (make_bv f 0%Z)) i) = 0%Z).
Axiom make_bv_length :
forall (f:Z -> Z) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(s >= 0%Z)%Z -> ((length (make_bv f s)) = s).
Axiom assert_make_bv :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
(0%Z <= s)%Z ->
(((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (make_bv f s)) i) = (f i))) /\
(~ ((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (make_bv f s)) i) = 0%Z)).
Axiom assert_make_m :
forall (f:Z -> Z) (s:Z) (i:Z), (s >= 0%Z)%Z ->
(((0%Z <= i)%Z /\ (i < s)%Z) ->
(((getbv (make_bv_m f s)) i) = (int.EuclideanDivision.mod1 (f i) 2%Z))) /\
(~ ((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (make_bv_m f s)) i) = 0%Z)).
Axiom assert_make_bv_b :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (make_bv f s)) i) = (f i)).
Axiom assert_make_m_b :
forall (f:Z -> Z) (s:Z) (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(s >= 0%Z)%Z ->
(((getbv (make_bv_m f s)) i) = (int.EuclideanDivision.mod1 (f i) 2%Z)).
Axiom make_m_bv_length :
forall (f:Z -> Z) (s:Z) (i:Z), (s >= 0%Z)%Z ->
bvlength (getbv (make_bv_m f s)) i.
Axiom make_m_length :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> ((length (make_bv_m f s)) = s).
Axiom set_equal_bv_make :
forall (f:Z -> Z) (g:Z -> Z) (s:Z),
(forall (i:Z), (0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) -> (s >= 0%Z)%Z ->
(forall (i:Z), ((f i) = (g i))) -> ((make_bv f s) = (make_bv g s)).
Axiom set_equal_bv_m_make :
forall (f:Z -> Z) (g:Z -> Z) (s:Z), (s >= 0%Z)%Z ->
(forall (i:Z),
((int.EuclideanDivision.mod1 (f i) 2%Z) =
(int.EuclideanDivision.mod1 (g i) 2%Z))) ->
((make_bv_m f s) = (make_bv_m g s)).
Axiom make_bv_itself :
forall (x:bitvec) (n:Z), ((length x) = n) ->
((make_bv (fun (i:Z) => ((getbv x) i)) n) = x).
Parameter head: bitvec -> Z.
Axiom head_def :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((head bv) = ((getbv bv) 0%Z)).
Axiom head_spec :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z -> (0%Z <= (head bv))%Z.
Axiom head_spec1 :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z -> ((head bv) <= 1%Z)%Z.
Parameter makes_bv: (Z -> Z) -> Z -> bitvec.
Parameter result8: (Z -> Z) -> Z -> Z.
Axiom result_def8 :
forall (f:Z -> Z) (i:Z),
((let q1_ := f i in (0%Z <= q1_)%Z /\ (q1_ < 2%Z)%Z) ->
(((result8 f) i) = (f i))) /\
(~ (let q1_ := f i in (0%Z <= q1_)%Z /\ (q1_ < 2%Z)%Z) ->
(((result8 f) i) = 0%Z)).
Axiom makes_bv_def :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z ->
((makes_bv f s) = (make_bv (result8 f) s)).
Axiom makes_bv_spec :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> ((length (makes_bv f s)) = s).
Axiom makes_bv_spec1 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (i:Z),
((0%Z <= i)%Z /\ (i < s)%Z) -> ((0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
(((getbv (makes_bv f s)) i) = (f i)).
Axiom makes_bv_spec2 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
(0%Z <= (f i))%Z /\ ((f i) < 2%Z)%Z) ->
((makes_bv f s) = (make_bv f s)).
Axiom makes_bv_spec3 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (i:Z), ~ (0%Z <= i)%Z ->
(((getbv (makes_bv f s)) i) = 0%Z).
Axiom makes_bv_spec4 :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> forall (i:Z), ~ (i < s)%Z ->
(((getbv (makes_bv f s)) i) = 0%Z).
Axiom assert_makes_bv_c :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
(0%Z <= s)%Z ->
(((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (makes_bv f s)) i) = (f i))) /\
(~ ((0%Z <= i)%Z /\ (i < s)%Z) -> (((getbv (makes_bv f s)) i) = 0%Z)).
Axiom assert_makes_bv_b :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
(0%Z <= s)%Z -> ((0%Z <= i)%Z /\ (i < s)%Z) ->
(((getbv (makes_bv f s)) i) = (f i)).
Axiom assert_makes_bv :
forall (f:Z -> Z) (s:Z) (i:Z),
(forall (i1:Z), ((0%Z <= i1)%Z /\ (i1 < s)%Z) ->
(0%Z <= (f i1))%Z /\ ((f i1) < 2%Z)%Z) ->
(0%Z <= s)%Z ->
((((0%Z <= i)%Z /\ (i < s)%Z) /\ (0%Z <= (f i))%Z) ->
(((getbv (makes_bv f s)) i) = (f i))) /\
(~ (((0%Z <= i)%Z /\ (i < s)%Z) /\ (0%Z <= (f i))%Z) ->
(((getbv (makes_bv f s)) i) = 0%Z)).
Axiom makes_bv_length :
forall (f:Z -> Z) (s:Z), (s >= 0%Z)%Z -> ((length (makes_bv f s)) = s).
Parameter tail: bitvec -> bitvec.
Axiom tail_def :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((tail bv) =
(make_bv (fun (i:Z) => ((getbv bv) (i + 1%Z)%Z)) ((length bv) - 1%Z)%Z)).
Axiom tail_spec :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((length (tail bv)) = ((length bv) - 1%Z)%Z).
Axiom tail_spec1 :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z -> forall (i:Z),
(in_range (tail bv) i) ->
(((getbv (tail bv)) i) = ((getbv bv) (i + 1%Z)%Z)).
Parameter concat_l: bitvec -> Z -> bitvec.
Parameter result9: bitvec -> Z -> Z -> Z.
Axiom result_def9 :
forall (bv:bitvec) (i:Z) (k:Z),
((k = 0%Z) -> (((result9 bv i) k) = i)) /\
(~ (k = 0%Z) -> (((result9 bv i) k) = ((getbv bv) (k - 1%Z)%Z))).
Axiom concat_l_def :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
((concat_l bv i) = (make_bv (result9 bv i) ((length bv) + 1%Z)%Z)).
Axiom concat_l_spec :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
((length (concat_l bv i)) = ((length bv) + 1%Z)%Z).
Axiom concat_l_spec1 :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
(((getbv (concat_l bv i)) 0%Z) = i).
Axiom concat_l_spec2 :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) -> forall (j:Z),
(in_range bv j) -> (((getbv (concat_l bv i)) (j + 1%Z)%Z) = ((getbv bv) j)).
Axiom concat_l_value :
forall (bv:bitvec) (i:Z) (k:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((k = 0%Z) -> (((getbv (concat_l bv i)) k) = i)) /\
(~ (k = 0%Z) ->
(((0%Z < k)%Z /\ (k <= ((length bv) + 1%Z)%Z)%Z) ->
(((getbv (concat_l bv i)) k) = ((getbv bv) (k - 1%Z)%Z))) /\
(~ ((0%Z < k)%Z /\ (k <= ((length bv) + 1%Z)%Z)%Z) ->
(((getbv (concat_l bv i)) k) = 0%Z))).
Axiom concat_l_value_b :
forall (bv:bitvec) (i:Z) (k:Z),
((0%Z <= k)%Z /\ (k < ((length bv) + 1%Z)%Z)%Z) ->
((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((k = 0%Z) -> (((getbv (concat_l bv i)) k) = i)) /\
(~ (k = 0%Z) -> (((getbv (concat_l bv i)) k) = ((getbv bv) (k - 1%Z)%Z))).
Axiom concat_ht :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
(bv = (concat_l (tail bv) (head bv))).
Axiom concat_ht_union :
forall (bv:bitvec), ((length bv) >= 2%Z)%Z ->
~ (bv = (concat_l (tail bv) 0%Z)) -> (bv = (concat_l (tail bv) 1%Z)).
Parameter bv_to_int: bitvec -> Z.
Parameter result10: bitvec -> Z -> Z.
Axiom result_def10 :
forall (bv:bitvec) (k:Z),
((in_range bv k) ->
(((result10 bv) k) =
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)) /\
(~ (in_range bv k) -> (((result10 bv) k) = 1%Z)).
Axiom bv_to_int_def :
forall (bv:bitvec),
((bv_to_int bv) = (ind_isum (result10 bv) 0%Z (length bv))).
Axiom bv_to_int_spec :
forall (bv:bitvec),
((bv_to_int bv) =
(ind_isum
(fun (k:Z) =>
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))).
Axiom bv_to_int_spec1 : forall (bv:bitvec), (0%Z <= (bv_to_int bv))%Z.
Axiom bv_to_int_eq :
forall (bv1:bitvec) (bv2:bitvec), (bv1 = bv2) ->
((bv_to_int bv1) = (bv_to_int bv2)).
Axiom bv_to_int_sum :
forall (bv:bitvec),
((bv_to_int bv) =
(ind_isum
(fun (k:Z) =>
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))).
Axiom bv_to_int_sum_opp :
forall (bv:bitvec),
((-(bv_to_int bv))%Z =
(ind_isum
(fun (k:Z) =>
((-((getbv bv) k))%Z * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))).
Axiom bv_to_int_onebit :
forall (bv:bitvec), ((length bv) = 1%Z) ->
((bv_to_int bv) = ((getbv bv) 0%Z)).
Axiom ind_isum_bv_rev :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= (length bv))%Z) ->
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
i (length bv))
=
(ind_isum
(fun (l:Z) =>
(((getbv bv) (((length bv) - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z)
0%Z ((length bv) - i)%Z)).
Axiom ind_isum_bin_rev :
forall (f:Z -> Z) (n:Z) (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> (binary f) ->
((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) i n)
=
(ind_isum (fun (l:Z) => ((f ((n - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z) 0%Z
(n - i)%Z)).
Axiom ind_isum_bin_rev_z :
forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) 0%Z
n)
=
(ind_isum (fun (l:Z) => ((f ((n - 1%Z)%Z - l)%Z) * (power 2%Z l))%Z) 0%Z
n)).
Axiom bv_to_int_sum_rev :
forall (bv:bitvec),
((ind_isum
(fun (k:Z) =>
(((getbv bv) (((length bv) - 1%Z)%Z - k)%Z) * (power 2%Z k))%Z)
0%Z (length bv))
= (bv_to_int bv)).
Axiom ind_isum_bv_bound_growing :
forall (bv:bitvec) (i:Z), ((0%Z < i)%Z /\ (i < (length bv))%Z) ->
((ind_isum (fun (l:Z) => (((getbv bv) l) * (power 2%Z l))%Z) 0%Z i) <
(power 2%Z i))%Z.
Axiom ind_isum_bv_bound :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
i (length bv))
< (power 2%Z ((length bv) - i)%Z))%Z.
Axiom ind_isum_bin_bound :
forall (f:Z -> Z) (n:Z) (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> (binary f) ->
((ind_isum (fun (l:Z) => ((f l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z) i n)
< (power 2%Z (n - i)%Z))%Z.
Axiom bv_to_int_bound :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((bv_to_int bv) < (power 2%Z (length bv)))%Z.
Axiom abs_eqinf :
forall (x:Z) (y:Z), ((x <= y)%Z /\ (y <= 0%Z)%Z) ->
((ZArith.BinInt.Z.abs x) >= (ZArith.BinInt.Z.abs y))%Z.
Axiom abs_inf :
forall (x:Z) (y:Z), ((0%Z < x)%Z /\ ((x < y)%Z /\ (y <= 0%Z)%Z)) ->
((ZArith.BinInt.Z.abs x) > (ZArith.BinInt.Z.abs y))%Z.
Axiom abs_eqsup :
forall (x:Z) (y:Z), ((0%Z >= x)%Z /\ (x >= y)%Z) ->
((ZArith.BinInt.Z.abs x) <= (ZArith.BinInt.Z.abs y))%Z.
Axiom abs_sup :
forall (x:Z) (y:Z), ((0%Z >= x)%Z /\ (x > y)%Z) ->
((ZArith.BinInt.Z.abs x) < (ZArith.BinInt.Z.abs y))%Z.
Axiom inv_negeq :
forall (x:Z), (0%Z >= x)%Z -> ((ZArith.BinInt.Z.abs x) >= 0%Z)%Z.
Axiom inv_neg1 :
forall (x:Z), (0%Z > x)%Z -> ((ZArith.BinInt.Z.abs x) > 0%Z)%Z.
Parameter cpower: t -> Z -> t.
Axiom Cpower_zero : forall (i:t), ((cpower i 0%Z) = tone).
Axiom Cpower_one : forall (i:t), ((cpower i 1%Z) = i).
Axiom Cpower_sum :
forall (i:t), forall (n:Z) (m:Z), ~ (i = tzero) ->
((cpower i (n + m)%Z) = (infix_asdt (cpower i n) (cpower i m))).
Axiom Cpower_sum1 :
forall (i:t), forall (n:Z) (m:Z), ~ (n = (-m)%Z) ->
((cpower i (n + m)%Z) = (infix_asdt (cpower i n) (cpower i m))).
Axiom zero_poower : forall (e:Z), ~ (e = 0%Z) -> ((cpower tzero e) = tzero).
Parameter squarert_two: t.
Axiom squarert_two_def : (squarert_two = (square_rt ttwo)).
Axiom real_squarert_two : real_ squarert_two.
Axiom squarertTwo : ((cpower squarert_two 2%Z) = ttwo).
Axiom complete_rt_two :
forall (a:t), (a = (infix_sldt squarert_two ttwo)) ->
((infix_asdt squarert_two a) = tone).
Axiom cpower_sum :
forall (x:t) (n:Z) (m:Z), ~ (x = tzero) ->
((cpower x (n + m)%Z) = (infix_asdt (cpower x n) (cpower x m))).
Axiom cpower_sum1 :
forall (x:t) (n:Z) (m:Z), ~ (n = (-m)%Z) ->
((cpower x (n + m)%Z) = (infix_asdt (cpower x n) (cpower x m))).
Axiom cpower_one : forall (x:t) (n:Z), (n = 1%Z) -> ((cpower x n) = x).
Axiom cpower_sum_rev :
forall (x:t) (n:Z) (m:Z), ~ (x = tzero) ->
((infix_asdt (cpower x n) (cpower x m)) = (cpower x (n + m)%Z)).
Axiom cpower_sum_rev1 :
forall (x:t) (n:Z) (m:Z), ~ (n = (-m)%Z) ->
((infix_asdt (cpower x n) (cpower x m)) = (cpower x (n + m)%Z)).
Axiom cpower_plus_one :
forall (e:t) (i:Z), ~ (e = tzero) ->
((cpower e (i + 1%Z)%Z) = (infix_asdt (cpower e i) e)).
Axiom cpower_plus_one1 :
forall (e:t) (i:Z), ~ (i = (-1%Z)%Z) ->
((cpower e (i + 1%Z)%Z) = (infix_asdt (cpower e i) e)).
Axiom cpower_zero : forall (e:t), ((cpower e 0%Z) = tone).
Axiom cpower_eq :
forall (e:t) (e':t) (i:Z) (i':Z), (e = e') -> (i = i') ->
((cpower e i) = (cpower e' i')).
Axiom cpower_inv :
forall (e:t) (i:Z), ~ (e = tzero) ->
((infix_asdt (cpower e i) (cpower e (-i)%Z)) = tone).
Axiom cpower_inv_rew :
forall (e:t) (i:Z), ~ (e = tzero) ->
((cpower e i) = (infix_sldt tone (cpower e (-i)%Z))).
Axiom inv_cpower :
forall (e:t) (i:Z), ~ ((cpower e i) = tzero) ->
((infix_sldt tone (cpower e i)) = (cpower e (-i)%Z)).
Axiom cpower_mult_split :
forall (x:t) (y:t) (m:Z), (0%Z <= m)%Z ->
((cpower (infix_asdt x y) m) = (infix_asdt (cpower x m) (cpower y m))).
Axiom cpower_inv_out :
forall (x:t) (y:t), ~ (y = tzero) ->
((infix_asdt (cpower (infix_asdt (infix_sldt tone (square_rt y)) x) 2%Z) y)
= (cpower x 2%Z)).
Axiom cpower_tone_pos :
forall (m:Z), (m >= 0%Z)%Z -> ((cpower tone m) = tone).
Axiom mult_cpower :
forall (x:t) (x':t) (i:Z), (0%Z <= i)%Z ->
((infix_asdt (cpower x i) (cpower x' i)) = (cpower (infix_asdt x x') i)).
Axiom mult_cpower_rev :
forall (x:t) (x':t) (i:Z), (0%Z <= i)%Z ->
((cpower (infix_asdt x x') i) = (infix_asdt (cpower x i) (cpower x' i))).
Axiom cpower_iterate :
forall (e:t) (i:Z), (0%Z <= i)%Z ->
((cpower e i) =
(int_iterate (fun (y0:t) (y1:t) => (infix_asdt y0 y1))
((fun (y0:t) (y1:Z) => (const y0 y1)) e) 0%Z i)).
Axiom cpower_modulus :
forall (x:t) (n:Z), (0%Z <= n)%Z ->
((modulus (cpower x n)) = (cpower (modulus x) n)).
Axiom cpower_modulus1 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z ->
(infix_lsdt (modulus x) tone) -> infix_lsdt (modulus (cpower x n)) tone.
Axiom cpower_modulus2 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z -> ((modulus x) = tone) ->
((modulus (cpower x n)) = tone).
Axiom cpower_modulus3 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z ->
(infix_gtdt (modulus x) tone) -> infix_gtdt (modulus (cpower x n)) tone.
Axiom cpower_modulus4 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z ->
(infix_lsdt (modulus (cpower x n)) tone) -> infix_lsdt (modulus x) tone.
Axiom cpower_modulus5 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z ->
((modulus (cpower x n)) = tone) -> ((modulus x) = tone).
Axiom cpower_modulus6 :
forall (x:t) (n:Z), (0%Z <= n)%Z -> (n > 0%Z)%Z ->
(infix_gtdt (modulus (cpower x n)) tone) -> infix_gtdt (modulus x) tone.
Axiom cpower_mult_pre :
forall (x:t) (n:Z) (m:Z), (0%Z <= m)%Z ->
((cpower x (n * m)%Z) = (cpower (cpower x n) m)).
Axiom cpower_mult :
forall (x:t) (n:Z) (m:Z), ((cpower x (n * m)%Z) = (cpower (cpower x n) m)).
Axiom non_zero_cpower_pos :
forall (i:t) (n:Z), ~ (i = tzero) -> (n >= 0%Z)%Z ->
~ ((cpower i n) = tzero).
Axiom inv_cpower_ :
forall (e:t) (i:Z), ~ (e = tzero) ->
((infix_sldt tone (cpower e i)) = (cpower e (-i)%Z)).
Axiom zero_cpower_pos :
forall (n:Z), (n > 0%Z)%Z -> ((cpower tzero n) = tzero).
Axiom zero_cpower : forall (n:Z), ~ (n = 0%Z) -> ((cpower tzero n) = tzero).
Axiom non_zero_cpower :
forall (i:t) (n:Z), ~ (i = tzero) -> ~ ((cpower i n) = tzero).
Axiom real_cpower_pos :
forall (elt:t) (i:Z), (real_ elt) -> (0%Z <= i)%Z -> real_ (cpower elt i).
Axiom real_cpower :
forall (elt:t) (i:Z), (real_ elt) -> real_ (cpower elt i).
Axiom real_modulus_square :
forall (x:t), (real_ x) -> ((cpower (modulus x) 2%Z) = (cpower x 2%Z)).
Axiom real_modulus_pos :
forall (x:t), (real_ x) -> (infix_gteqdt x tzero) -> ((modulus x) = x).
Axiom square_frac_modulus :
forall (x:t) (y:t),
((cpower (modulus (infix_sldt x y)) 2%Z) =
(infix_sldt (cpower (modulus x) 2%Z) (cpower (modulus y) 2%Z))).
Axiom extract_2_sq_modulus :
forall (x:t) (y:t) (a:t), ~ (a = tzero) -> ~ (y = tzero) ->
((infix_sldt (cpower (modulus x) 2%Z) (cpower (modulus y) 2%Z)) =
(infix_sldt (infix_asdt a (cpower (modulus x) 2%Z))
(infix_asdt a (cpower (modulus y) 2%Z)))).
Axiom cpower_2_modulus_simpl :
forall (x:t) (y:t) (z:t), ~ (x = tzero) -> ~ (y = tzero) ->
~ (z = tzero) ->
((infix_sldt (cpower (modulus (infix_asdt x y)) 2%Z)
(cpower (modulus (infix_asdt z y)) 2%Z))
= (infix_sldt (cpower (modulus x) 2%Z) (cpower (modulus z) 2%Z))).
Axiom pre_cond_int_ :
forall (a:t) (b:t) (c:t), (infix_lsdt a b) -> (infix_lsdt tzero c) ->
infix_lsdt (infix_asdt a c) (infix_asdt b c).
Axiom growing_mult1 :
forall (n:t) (m:t), (infix_lseqdt tzero n) -> (infix_lseqdt tone m) ->
infix_lseqdt n (infix_asdt n m).
Axiom strict_growing_mult_pos :
forall (n:t) (m:t), (infix_lsdt tone n) -> (infix_lsdt tone m) ->
infix_lsdt n (infix_asdt n m).
Axiom init_exp3 : forall (k:t), ((cpower k 0%Z) = tone).
Axiom init_exp4 : forall (k:t), ((cpower k 1%Z) = k).
Axiom init_exp5 : forall (k:t), ((cpower k 2%Z) = (infix_asdt k k)).
Axiom int_exp_pos :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (0%Z <= n)%Z ->
infix_gteqdt (cpower k n) tone.
Axiom int_exp_pos1 :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (0%Z <= n)%Z ->
infix_gtdt (cpower k n) tzero.
Axiom int_exp_pos2 :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (0%Z <= n)%Z ->
infix_lseqdt (cpower k n) (cpower k (n + 1%Z)%Z).
Axiom strict_int_exp_pos :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (0%Z < n)%Z ->
infix_gtdt (cpower k n) tone.
Axiom strict_int_exp_pos1 :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (0%Z < n)%Z ->
infix_lsdt (cpower k (n - 1%Z)%Z) (cpower k n).
Axiom strict_int_exp_pos2 :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (0%Z < n)%Z ->
infix_lsdt (cpower k n) (cpower k (n + 1%Z)%Z).
Axiom strict_int_exp_neg :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (n < 0%Z)%Z ->
infix_lsdt (cpower k n) tone.
Axiom strict_int_exp_neg1 :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (n < 0%Z)%Z ->
infix_lsdt (cpower k (n - 1%Z)%Z) (cpower k n).
Axiom strict_int_exp_neg2 :
forall (k:t) (n:Z), (infix_lsdt tone k) -> (n < 0%Z)%Z ->
infix_lsdt (cpower k n) (cpower k (n + 1%Z)%Z).
Axiom int_exp_neg :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (n < 0%Z)%Z ->
infix_lseqdt (cpower k n) tone.
Axiom int_exp_neg1 :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (n < 0%Z)%Z ->
infix_gtdt (cpower k n) tzero.
Axiom int_exp_neg2 :
forall (k:t) (n:Z), (infix_lseqdt tone k) -> (n < 0%Z)%Z ->
infix_lseqdt (cpower k n) (cpower k (n + 1%Z)%Z).
Axiom positive_exp :
forall (k:t) (m:Z), (infix_lseqdt tone k) -> infix_lsdt tzero (cpower k m).
Axiom growing_exp_pos :
forall (k:t) (m:Z) (n:Z), (infix_lseqdt tone k) ->
((0%Z <= m)%Z /\ (m <= n)%Z) -> infix_lseqdt (cpower k m) (cpower k n).
Axiom growing_exp1 :
forall (k:t) (m:Z) (n:Z), (infix_lseqdt tone k) -> (m <= n)%Z ->
infix_lseqdt (cpower k m) (cpower k n).
Axiom strict_growing_exp1 :
forall (k:t) (m:Z) (n:Z), (infix_lsdt tone k) -> (m < n)%Z ->
infix_lsdt (cpower k m) (cpower k n).
Axiom cpower_comm_pos :
forall (x:t) (y:t) (n:Z), (infix_lseqdt tone x) -> (infix_lseqdt tone y) ->
(0%Z <= n)%Z ->
((cpower (infix_asdt x y) n) = (infix_asdt (cpower x n) (cpower y n))).
Axiom cpower_comm :
forall (x:t) (y:t) (n:Z), (infix_lseqdt tone x) -> (infix_lseqdt tone y) ->
((cpower (infix_asdt x y) n) = (infix_asdt (cpower x n) (cpower y n))).
Axiom unicity_exp2 :
forall (k:t) (m:Z) (n:Z), (infix_lsdt tone k) ->
((cpower k m) = (cpower k n)) -> (m = n).
Axiom unicity_exp3 :
forall (k:t) (m:Z) (n:Z), (infix_lsdt tone k) -> (m = n) ->
((cpower k m) = (cpower k n)).
Axiom geometric_series :
forall (a:t) (q:t) (n:Z), (n >= 1%Z)%Z ->
((sum (to_fset 0%Z n) (fun (i:Z) => (infix_asdt a (cpower q i)))) =
(infix_sldt (infix_asdt a (infix_mndt tone (cpower q (n + 1%Z)%Z)))
(infix_mndt tone q))).
Axiom geometric_series_init_one :
forall (q:t) (n:Z), (n >= 1%Z)%Z ->
((sum (to_fset 0%Z n) (fun (i:Z) => (cpower q i))) =
(infix_sldt (infix_mndt tone (cpower q (n + 1%Z)%Z)) (infix_mndt tone q))).
Axiom positive_cpower_2 :
forall (x:t), ~ (tzero = x) -> infix_lsdt tzero (cpower x 2%Z).
Axiom positive_cpower_2_mod :
forall (x:t), infix_lseqdt tzero (cpower (modulus x) 2%Z).
Axiom growing_cpower_2 :
forall (x:t) (y:t), ((infix_lseqdt tzero x) /\ (infix_lseqdt x y)) ->
infix_lseqdt (cpower x 2%Z) (cpower y 2%Z).
Parameter power_: Z -> Z -> Z.
Axiom power__def :
forall (e:Z) (i:Z), (i >= 0%Z)%Z -> ((power_ e i) = (power e i)).
Axiom power__def1 :
forall (e:Z) (i:Z), ~ (i >= 0%Z)%Z -> ((power_ e i) = 0%Z).
Axiom Power_zero_ : forall (i:Z), ((power_ i 0%Z) = 1%Z).
Axiom Power_one_ : forall (i:Z), ((power_ i 1%Z) = i).
Axiom Power_sum_ :
forall (x:Z) (y:Z) (i:Z), (x >= 0%Z)%Z -> (y >= 0%Z)%Z ->
((power_ i (x + y)%Z) = ((power_ i x) * (power_ i y))%Z).
Axiom Power_mult_ :
forall (x:Z) (y:Z) (i:Z), (x >= 0%Z)%Z -> (y >= 0%Z)%Z ->
((power i (x * y)%Z) = (power (power i x) y)).
Axiom Power_pos_ : forall (i:Z), (i >= 0%Z)%Z -> ((power_ i 0%Z) > 0%Z)%Z.
Axiom Power_pos_gen_ :
forall (i:Z) (j:Z), (i > 0%Z)%Z -> (j >= 0%Z)%Z -> (0%Z < (power_ i j))%Z.
Axiom cpower_incr_power_2 :
forall (k:Z), (0%Z <= k)%Z ->
((cpower (i_to_t (power 2%Z k)) 2%Z) = (i_to_t (power_ 2%Z (2%Z * k)%Z))).
Axiom cpower_modulus_incr_power_2 :
forall (k:Z), (0%Z <= k)%Z ->
((cpower (modulus (i_to_t (power 2%Z k))) 2%Z) =
(i_to_t (power_ 2%Z (2%Z * k)%Z))).
Axiom cpower_modulus_supeq :
forall (x:t) (y:t) (i:Z), (i >= 1%Z)%Z ->
(infix_gteqdt (modulus x) (modulus y)) ->
infix_gteqdt (cpower (modulus x) i) (cpower (modulus y) i).
Axiom angle : Type.
Parameter angle_WhyType : WhyType angle.
Existing Instance angle_WhyType.
Parameter ang_inv: angle -> angle.
Parameter ang_add: angle -> angle -> angle.
Parameter ang_exp: angle -> t.
Axiom ang_exp_spec : forall (us:angle), ~ ((ang_exp us) = tzero).
Parameter arg: t -> angle.
Axiom arg_spec : forall (x:t), ((ang_exp (arg x)) = x).
Parameter ang_zero: angle.
Axiom Assoc2 :
forall (x:angle) (y:angle) (z:angle),
((ang_add (ang_add x y) z) = (ang_add x (ang_add y z))).
Axiom Unit_def_l1 : forall (x:angle), ((ang_add ang_zero x) = x).
Axiom Unit_def_r1 : forall (x:angle), ((ang_add x ang_zero) = x).
Axiom Inv_def_l1 : forall (x:angle), ((ang_add (ang_inv x) x) = ang_zero).
Axiom Inv_def_r1 : forall (x:angle), ((ang_add x (ang_inv x)) = ang_zero).
Axiom Comm2 : forall (x:angle) (y:angle), ((ang_add x y) = (ang_add y x)).
Parameter int_to_ang: Z -> Z -> angle.
Parameter exp: t -> t.
Parameter e: t.
Axiom e_def : (e = (exp tone)).
Axiom e_diff_tzero : forall (x:t), ~ ((exp x) = tzero).
Axiom Exp_one : real_ (exp tone).
Axiom Exp_zero : ((exp tzero) = tone).
Axiom Exp_sum :
forall (x:t) (y:t), ((exp (infix_pldt x y)) = (infix_asdt (exp x) (exp y))).
Axiom exp_one : real_ e.
Axiom exp_sum :
forall (x:t) (y:t), ((exp (infix_pldt x y)) = (infix_asdt (exp x) (exp y))).
Axiom exp_eq : forall (t1:t) (t2:t), (t1 = t2) -> ((exp t1) = (exp t2)).
Axiom exp_sum_rev :
forall (x:t) (y:t), ((infix_asdt (exp x) (exp y)) = (exp (infix_pldt x y))).
Axiom exp_inv :
forall (i:t), ~ ((exp i) = tzero) ->
((exp (prefix_mndt i)) = (infix_sldt tone (exp i))).
Axiom exp_inv_rev :
forall (i:t), ~ ((exp i) = tzero) ->
((infix_sldt tone (exp i)) = (exp (prefix_mndt i))).
Axiom exp_mult_pre :
forall (x:t) (y:Z), (y >= 0%Z)%Z ->
((exp (infix_asdt x (i_to_t y))) = (cpower (exp x) y)).
Axiom exp_mult :
forall (x:t) (y:Z), ((exp (infix_asdt x (i_to_t y))) = (cpower (exp x) y)).
Axiom cpower_to_exp :
forall (x:t) (y:Z), ((cpower (exp x) y) = (exp (infix_asdt x (i_to_t y)))).
Axiom Exp_quarter_pi :
((exp (infix_sldt (infix_asdt im pi) (i_to_t 4%Z))) =
(infix_pldt (infix_sldt squarert_two ttwo)
(infix_asdt im (infix_sldt squarert_two ttwo)))).
Axiom exp_h_pi : ((exp (infix_sldt (infix_asdt im pi) ttwo)) = im).
Parameter two_pi_i: t.
Axiom two_pi_i_def : (two_pi_i = (infix_asdt (infix_asdt im pi) ttwo)).
Axiom exp_pi : ((exp (infix_asdt im pi)) = (prefix_mndt tone)).
Axiom exp_two_pi : ((exp two_pi_i) = tone).
Axiom exp_two_pi_mul :
forall (k:Z), ((exp (infix_asdt (i_to_t k) two_pi_i)) = tone).
Axiom exp_two_pi_mul_den :
forall (k:Z) (l:Z), ~ (k = 0%Z) ->
((exp (infix_sldt (infix_asdt (i_to_t (k * l)%Z) two_pi_i) (i_to_t k))) =
tone).
Axiom exp_two_pi_mul_den_add :
forall (k:Z) (l:Z) (m:Z),
((exp (infix_asdt (i_to_t ((k * m)%Z + l)%Z) two_pi_i)) =
(exp (infix_asdt (i_to_t l) two_pi_i))).
Parameter ang_mult_int: angle -> Z -> angle.
Parameter conjugate: t -> t.
Axiom conjugate_def :
forall (i:t),
((conjugate i) =
(infix_mndt (t_real_part i) (infix_asdt im (t_im_part i)))).
Axiom real_part_conjugate :
forall (i:t), ((t_real_part (conjugate i)) = (t_real_part i)).
Axiom im_part_conjugate :
forall (i:t), ((t_im_part (conjugate i)) = (prefix_mndt (t_im_part i))).
Axiom invol_conjugate : forall (i:t), ((conjugate (conjugate i)) = i).
Axiom add_conjugate :
forall (i:t) (j:t),
((conjugate (infix_pldt i j)) = (infix_pldt (conjugate i) (conjugate j))).
Axiom add_own_conjugate :
forall (i:t),
((infix_pldt i (conjugate i)) = (infix_asdt ttwo (t_real_part i))).
Axiom conjugate_to_modulus :
forall (i:t), ((modulus i) = (square_rt (infix_asdt i (conjugate i)))).
Axiom sum_conjugate :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> t),
((conjugate (sum s f)) = (sum s (fun (x:a) => (conjugate (f x))))).
Axiom conjugate_module_one :
forall (i:t), ((modulus i) = tone) -> ((conjugate i) = (inv i)).
Axiom conjugate_module_one_rev :
forall (i:t), ~ (i = tzero) -> ((conjugate i) = (inv i)) ->
((modulus i) = tone).
Axiom conjugate_real : forall (i:t), (real_ i) -> ((conjugate i) = i).
Axiom conjugate_real_gen : forall (i:t), (real_ i) -> ((conjugate i) = i).
Axiom conjugate_one : ((conjugate tone) = tone).
Axiom conjugate_tzero : ((conjugate tzero) = tzero).
Axiom conjugate_indic :
forall {a:Type} {a_WT:WhyType a},
forall (i:a) (j:a), ((conjugate (indic i j)) = (indic i j)).
Axiom conjugate_indic_rev :
forall {a:Type} {a_WT:WhyType a},
forall (i:a) (j:a), ((indic i j) = (conjugate (indic i j))).
Axiom conjugate_indic_gen_int :
forall (i:Z) (j:Z), ((conjugate (indic i j)) = (indic i j)).
Axiom conjugate_pure_im :
forall (i:t), (pure_im_ i) -> ((conjugate i) = (prefix_mndt i)).
Axiom conjugate_im : ((conjugate im) = (prefix_mndt im)).
Axiom conjugate_value :
forall (c:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(c = (infix_pldt a (infix_asdt im b))) ->
((conjugate c) = (infix_mndt a (infix_asdt im b))).
Axiom conjugate_minus_value :
forall (c:t) (a:t) (b:t), (real_ a) -> (real_ b) ->
(c = (infix_mndt a (infix_asdt im b))) ->
((conjugate c) = (infix_pldt a (infix_asdt im b))).
Axiom prod_conjugate :
forall (a:t) (b:t),
((infix_asdt a (conjugate b)) =
(infix_pldt
(infix_pldt (infix_asdt (t_real_part a) (t_real_part b))
(infix_asdt (t_im_part a) (t_im_part b)))
(infix_asdt im
(infix_mndt (infix_asdt (t_real_part b) (t_im_part a))
(infix_asdt (t_im_part b) (t_real_part a)))))).
Axiom mult_conjugate :
forall (a:t) (b:t),
((conjugate (infix_asdt a b)) = (infix_asdt (conjugate a) (conjugate b))).
Axiom conjugate_prod :
forall (a:t) (b:t),
((infix_asdt (conjugate a) b) =
(infix_pldt
(infix_pldt (infix_asdt (t_real_part a) (t_real_part b))
(infix_asdt (t_im_part a) (t_im_part b)))
(infix_asdt im
(infix_mndt (infix_asdt (t_real_part a) (t_im_part b))
(infix_asdt (t_real_part b) (t_im_part a)))))).
Axiom conj_conj_prod :
forall (a:t) (b:t),
((conjugate (infix_asdt (conjugate a) b)) = (infix_asdt a (conjugate b))).
Axiom conj_prod_conj :
forall (a:t) (b:t),
((conjugate (infix_asdt a (conjugate b))) = (infix_asdt (conjugate a) b)).
Axiom itself_prod_conjugate_modulus_one :
forall (a:t), ((modulus a) = tone) -> ((infix_asdt a (conjugate a)) = tone).
Axiom conjugate_prod_itself_modulus_one :
forall (a:t), ((modulus a) = tone) -> ((infix_asdt a (conjugate a)) = tone).
Axiom modulus_pos :
forall (a:t), (real_ a) -> (infix_lseqdt tzero a) -> ((modulus a) = a).
Parameter real_to_ang: t -> angle.
Axiom real_to_ang_eq :
forall (phi:t) (phi':t), (real_ phi) -> (phi = phi') ->
((real_to_ang phi) = (real_to_ang phi')).
Axiom Real_To_Ang_value :
forall (phi:t), (real_ phi) ->
((ang_exp (real_to_ang phi)) = (exp (infix_asdt two_pi_i phi))).
Axiom Real_to_ang_to_int_to_ang :
forall (k:Z) (n:Z), (n >= 0%Z)%Z ->
((int_to_ang k n) =
(real_to_ang (infix_sldt (i_to_t k) (i_to_t (power 2%Z n))))).
Axiom Real_To_Ang_inv :
forall (phi:t), ~ (phi = tzero) -> (real_ phi) ->
((ang_inv (real_to_ang phi)) = (real_to_ang (prefix_mndt phi))).
Axiom Real_To_Ang_inv_add :
forall (phi:t), (real_ phi) ->
((ang_add (real_to_ang phi) (real_to_ang (prefix_mndt phi))) = ang_zero).
Axiom Real_To_Ang_add :
forall (phi:t) (phi':t), (real_ phi) -> (real_ phi') ->
((ang_add (real_to_ang phi) (real_to_ang phi')) =
(real_to_ang (infix_pldt phi phi'))).
Axiom Real_To_Ang_up :
forall (phi:t), (real_ phi) ->
((real_to_ang phi) = (real_to_ang (infix_pldt tone phi))).
Axiom Real_To_Ang_cyclic :
forall (phi:t), forall (k:Z), (real_ phi) ->
((real_to_ang phi) =
(real_to_ang (infix_pldt tone (infix_asdt (i_to_t k) phi)))).
Axiom Real_zero_n : ((real_to_ang tzero) = ang_zero).
Axiom Real_ang_mult :
forall (phi:t), forall (i:Z),
((ang_mult_int (real_to_ang phi) i) =
(real_to_ang (infix_asdt phi (i_to_t i)))).
Axiom real_to_ang_down_cucles :
forall (phi:t) (x:t), (real_ phi) -> (x = tone) ->
((real_to_ang (infix_mndt phi x)) = (real_to_ang phi)).
Axiom Equal_angle :
forall (o:angle) (o':angle), ((ang_exp o) = (ang_exp o')) -> (o = o').
Axiom Equal_angle1 :
forall (o:angle) (o':angle), (o = o') -> ((ang_exp o) = (ang_exp o')).
Axiom Int_To_Ang_inv :
forall (k:Z) (n:Z), (n >= 0%Z)%Z ->
((ang_inv (int_to_ang k n)) = (int_to_ang (-k)%Z n)).
Axiom Int_To_Ang_inv_add :
forall (k:Z) (n:Z), (n >= 0%Z)%Z ->
((ang_add (int_to_ang k n) (int_to_ang (-k)%Z n)) = ang_zero).
Axiom Int_To_Ang_add :
forall (k:Z) (k':Z) (n:Z), (n >= 0%Z)%Z ->
((ang_add (int_to_ang k n) (int_to_ang k' n)) = (int_to_ang (k + k')%Z n)).
Axiom Int_To_Ang_up :
forall (k:Z) (n:Z), (0%Z <= n)%Z ->
((int_to_ang k n) = (int_to_ang (2%Z * k)%Z (n + 1%Z)%Z)).
Axiom Int_To_Ang_cyclic :
forall (k:Z) (n:Z), (0%Z <= n)%Z ->
((int_to_ang k n) = (int_to_ang (k + (power 2%Z n))%Z n)).
Axiom Zero_n : forall (n:Z), (n >= 0%Z)%Z -> ((int_to_ang 0%Z n) = ang_zero).
Parameter ang_minus_one: angle.
Axiom ang_minus_one_def : (ang_minus_one = (int_to_ang 1%Z 1%Z)).
Axiom ang_minus_one_from_real :
(ang_minus_one = (real_to_ang (prefix_mndt tone))).
Parameter div_two_: angle -> angle.
Axiom Div_two_int_to_ang :
forall (k:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((div_two_ (int_to_ang k n)) = (int_to_ang k (n + 1%Z)%Z)).
Axiom Div_two : forall (d:angle), ((ang_add (div_two_ d) (div_two_ d)) = d).
Axiom Add1 :
forall (d:angle) (d':angle),
((ang_exp (ang_add d d')) = (infix_asdt (ang_exp d) (ang_exp d'))).
Axiom ang_exp_mult :
forall (x:angle) (x':angle),
((infix_asdt (ang_exp x) (ang_exp x')) = (ang_exp (ang_add x x'))).
Parameter k_int_to_ang: Z -> angle.
Axiom K_int_to_ang :
forall (k:Z), (k >= 0%Z)%Z -> ((k_int_to_ang k) = (int_to_ang 1%Z k)).
Axiom K_int_to_angplus_one :
forall (k:Z), (k > 0%Z)%Z ->
((ang_add (k_int_to_ang k) (k_int_to_ang k)) = (k_int_to_ang (k - 1%Z)%Z)).
Parameter phase_inv_: Z -> angle -> angle.
Axiom Even_phase_inv :
forall (d:angle), forall (i:Z),
((int.EuclideanDivision.mod1 i 2%Z) = 0%Z) -> ((phase_inv_ i d) = d).
Axiom Odd_phase_inv :
forall (d:angle), forall (i:Z),
((int.EuclideanDivision.mod1 i 2%Z) = 1%Z) ->
((phase_inv_ i d) = (ang_inv d)).
Axiom Gen_phase_inv :
forall (k:Z) (n:Z) (i:Z), (n >= 0%Z)%Z -> (i >= 0%Z)%Z ->
((phase_inv_ i (int_to_ang k n)) =
(int_to_ang ((power (-1%Z)%Z i) * k)%Z n)).
Axiom Gen_phase_inv_neg :
forall (k:Z) (n:Z) (i:Z), (n >= 0%Z)%Z -> (i < 0%Z)%Z ->
((phase_inv_ i (int_to_ang k n)) =
(int_to_ang ((power (-1%Z)%Z (-i)%Z) * k)%Z n)).
Axiom Ang_exp_inv :
forall (o:angle), ((ang_exp (ang_inv o)) = (infix_sldt tone (ang_exp o))).
Axiom ang_inv_to_conjugate :
forall (o:angle), ((ang_exp (ang_inv o)) = (conjugate (ang_exp o))).
Axiom conjugate_to_ang_inv :
forall (o:angle), ((conjugate (ang_exp o)) = (ang_exp (ang_inv o))).
Axiom ang_exp_zero_ : ((ang_exp ang_zero) = tone).
Axiom ang_mult_int_in :
forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
((ang_mult_int (int_to_ang k n) i) = (int_to_ang (i * k)%Z n)).
Axiom ang_mult_int_out :
forall (i:Z) (k:Z) (n:Z), (0%Z <= n)%Z ->
((int_to_ang (i * k)%Z n) = (ang_mult_int (int_to_ang k n) i)).
Axiom int_to_ang_cycles :
forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z <= i)%Z ->
((int_to_ang (k + (i * (power 2%Z n))%Z)%Z n) = (int_to_ang k n)).
Axiom int_to_ang_add_rev :
forall (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
((int_to_ang (i + j)%Z n) = (ang_add (int_to_ang i n) (int_to_ang j n))).
Axiom real_to_ang_add_rev :
forall (i:t) (j:t), (real_ i) -> (real_ j) ->
((real_to_ang (infix_pldt i j)) =
(ang_add (real_to_ang i) (real_to_ang j))).
Axiom int_to_ang_cycles_neg :
forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z -> (0%Z >= i)%Z ->
((int_to_ang (k + (i * (power 2%Z n))%Z)%Z n) = (int_to_ang k n)).
Axiom int_to_ang_cycles_gen :
forall (k:Z) (n:Z) (i:Z), (0%Z <= n)%Z ->
((int_to_ang (k + (i * (power 2%Z n))%Z)%Z n) = (int_to_ang k n)).
Axiom int_to_ang_cycles_zero :
forall (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
((int_to_ang (power 2%Z n') n) = ang_zero).
Axiom int_to_ang_cycles_zero_mult :
forall (k:Z) (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
((int_to_ang (k * (power 2%Z n'))%Z n) = ang_zero).
Axiom int_to_ang_cycles_zero_mult_ :
forall (k:Z) (n':Z) (n:Z), ((0%Z <= n)%Z /\ (n <= n')%Z) ->
((int_to_ang (k * (power_ 2%Z n'))%Z n) = ang_zero).
Axiom int_to_ang_eq :
forall (k1:Z) (k2:Z) (n1:Z) (n2:Z), (k1 = k2) -> (n1 = n2) ->
((int_to_ang k1 n1) = (int_to_ang k2 n2)).
Axiom int_to_ang_mod :
forall (k:Z) (n:Z), (0%Z <= n)%Z ->
((int_to_ang k n) =
(int_to_ang (int.EuclideanDivision.mod1 k (power 2%Z n)) n)).
Axiom int_to_ang_red :
forall (k:Z) (n:Z), (1%Z <= n)%Z -> ~ (0%Z = k) ->
((int.EuclideanDivision.mod1 k 2%Z) = 0%Z) ->
((int_to_ang k n) =
(int_to_ang (int.EuclideanDivision.div k 2%Z) (n - 1%Z)%Z)).
Axiom int_to_ang_up :
forall (k:Z) (n:Z) (n':Z), (0%Z <= n)%Z -> (0%Z <= n')%Z ->
((int_to_ang (k * (power 2%Z n'))%Z (n + n')%Z) = (int_to_ang k n)).
Axiom int_to_ang_simpl :
forall (k:Z) (n1:Z) (n2:Z), (n1 >= 0%Z)%Z -> (n2 >= 0%Z)%Z ->
((int_to_ang (k * (power 2%Z n1))%Z (n2 + n1)%Z) = (int_to_ang k n2)).
Axiom ang_add_eq :
forall (d1:angle) (d2:angle) (e1:angle) (e2:angle), (d1 = e1) ->
(d2 = e2) -> ((ang_add d1 d2) = (ang_add e1 e2)).
Axiom ang_add_comm :
forall (d1:angle) (d2:angle), ((ang_add d1 d2) = (ang_add d2 d1)).
Axiom ang_add_eq_comm :
forall (d1:angle) (d2:angle) (d3:angle) (d4:angle), (d1 = d3) ->
(d2 = d4) -> ((ang_add d1 d2) = (ang_add d4 d3)).
Axiom ang_div :
forall (k:Z) (n:Z) (i:Z), (n >= 0%Z)%Z -> (i >= 0%Z)%Z ->
((int_to_ang k n) = (ang_mult_int (int_to_ang k (n + i)%Z) (power 2%Z i))).
Axiom ang_zero_add :
forall (d':angle) (d:angle), (d' = ang_zero) -> ((ang_add d' d) = d).
Axiom int_to_ang_rev :
forall (k:Z) (l:Z) (n:Z) (m:Z), (0%Z < n)%Z -> (0%Z <= k)%Z ->
(n = (m + 1%Z)%Z) ->
((int_to_ang (((-k)%Z * l)%Z * (power 2%Z m))%Z n) =
(int_to_ang ((k * l)%Z * (power 2%Z m))%Z n)).
Axiom int_to_ang_rev_ :
forall (k:Z) (l:Z) (n:Z) (m:Z), (0%Z < n)%Z -> (0%Z <= k)%Z ->
(0%Z <= l)%Z -> (n = (m + 1%Z)%Z) ->
((int_to_ang (((-k)%Z * l)%Z * (power_ 2%Z m))%Z n) =
(int_to_ang ((k * l)%Z * (power_ 2%Z m))%Z n)).
Axiom ang_add_zero_d :
forall (d':angle) (d:angle), (d' = ang_zero) -> ((ang_add d d') = d).
Parameter ang_sum: (Z -> angle) -> Z -> Z -> angle.
Axiom ang_sum_def :
forall (f:Z -> angle), forall (i:Z) (j:Z),
((j <= i)%Z -> ((ang_sum f i j) = ang_zero)) /\
(~ (j <= i)%Z ->
((ang_sum f i j) =
(int_iterate (fun (y0:angle) (y1:angle) => (ang_add y0 y1)) f i j))).
Axiom ang_sumto_int_iterate :
forall (f:Z -> angle) (i:Z) (j:Z), (i < j)%Z ->
((ang_sum f i j) =
(int_iterate (fun (y0:angle) (y1:angle) => (ang_add y0 y1)) f i j)).
Axiom ang_sum_plus_one :
forall (f:Z -> angle) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
((ang_sum f i j) = (ang_add (f i) (ang_sum f (i + 1%Z)%Z j))).
Axiom ang_sum_cardone :
forall (f:Z -> angle) (i:Z) (j:Z), (j = (i + 1%Z)%Z) ->
((ang_sum f i j) = (f i)).
Axiom ang_sum_cardone_p :
forall (f:Z -> angle) (i:Z) (j:Z) (r:angle), (j = (i + 1%Z)%Z) ->
((f i) = r) -> (r = (ang_sum f i j)).
Axiom ang_sum_neutral :
forall (f:Z -> angle) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = ang_zero)) ->
((ang_sum f i j) = ang_zero).
Axiom ang_sum_def_plus_one_com :
forall (f:Z -> angle) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
((ang_add (f i) (ang_sum f (i + 1%Z)%Z j)) = (ang_sum f i j)).
Axiom ang_sum_right_extension :
forall (f:Z -> angle) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
((ang_sum f i j) = (ang_add (ang_sum f i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).
Axiom ang_sum_transitivity :
forall (f:Z -> angle) (i:Z) (k:Z) (j:Z), ((i < k)%Z /\ (k < j)%Z) ->
((ang_sum f i j) = (ang_add (ang_sum f i k) (ang_sum f k j))).
Axiom ang_sum_eq :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z), (i <= j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_sum f i j) = (ang_sum g i j)).
Axiom ang_sum_int_to_ang :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
(exists n:Z,
forall (k:Z),
exists j1:Z, exists j':Z,
((f k) = (int_to_ang j1 n)) /\ (((g k) = (int_to_ang j' n)) /\ (j1 = j'))) ->
((ang_sum f i j) = (ang_sum g i j)).
Axiom vang_sum_eq :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_exp (ang_sum f i j)) = (ang_exp (ang_sum g i j))).
Axiom vang_sum_scal_eq :
forall (f:Z -> angle) (g:Z -> angle) (m:matrix t) (n:matrix t) (i:Z) (j:Z),
(i < j)%Z -> (m = n) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((infix_asdtdt (ang_exp (ang_sum f i j)) m) =
(infix_asdtdt (ang_exp (ang_sum g i j)) n)).
Axiom ang_sum_plus_one_p :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (l = (i + 1%Z)%Z) -> (m = j) -> ((g i) = r) ->
(forall (k:Z), (((i + 1%Z)%Z <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_add r (ang_sum f l m)) = (ang_sum g i j)).
Axiom vang_sum_plus_one_p :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (l = (i + 1%Z)%Z) -> (m = j) -> ((g i) = r) ->
(forall (k:Z), (((i + 1%Z)%Z <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((infix_asdt (ang_exp r) (ang_exp (ang_sum f l m))) =
(ang_exp (ang_sum g i j))).
Axiom vang_sum_plus_one_rev :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (l = (i + 1%Z)%Z) -> (m = j) -> ((g i) = r) ->
(forall (k:Z), (((i + 1%Z)%Z <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_exp (ang_sum g i j)) =
(infix_asdt (ang_exp r) (ang_exp (ang_sum f l m)))).
Axiom ang_sum_right_extension_p :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (m = (j - 1%Z)%Z) -> (l = i) ->
((g (j - 1%Z)%Z) = r) ->
(forall (k:Z), ((i <= k)%Z /\ (k < (j - 1%Z)%Z)%Z) -> ((f k) = (g k))) ->
((ang_add (ang_sum f l m) r) = (ang_sum g i j)).
Axiom vang_sum_right_extension_p :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (m = (j - 1%Z)%Z) -> (l = i) ->
((g (j - 1%Z)%Z) = r) ->
(forall (k:Z), ((i <= k)%Z /\ (k < (j - 1%Z)%Z)%Z) -> ((f k) = (g k))) ->
((infix_asdt (ang_exp (ang_sum f l m)) (ang_exp r)) =
(ang_exp (ang_sum g i j))).
Axiom vang_sum_right_extension_rev :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (l:Z) (m:Z) (r:angle),
((i + 1%Z)%Z < j)%Z -> (m = (j - 1%Z)%Z) -> (l = i) ->
((g (j - 1%Z)%Z) = r) ->
(forall (k:Z), ((i <= k)%Z /\ (k < (j - 1%Z)%Z)%Z) -> ((f k) = (g k))) ->
((ang_exp (ang_sum g i j)) =
(infix_asdt (ang_exp (ang_sum f l m)) (ang_exp r))).
Axiom ang_sum_cardzero :
forall (f:Z -> angle) (i:Z) (j:Z), (j <= i)%Z ->
((ang_sum f i j) = ang_zero).
Axiom ang_sum_eq_gen :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (i':Z) (j':Z),
(i < j)%Z -> (i = i') -> (j = j') ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_sum f i j) = (ang_sum g i' j')).
Axiom ang_sum_sum_eq_vl :
forall (f:Z -> Z -> angle) (g:Z -> Z -> angle) (i:Z) (j:Z) (i':Z) (j':Z)
(l:Z) (l':Z),
(i < j)%Z -> (j <= l)%Z -> (i = i') -> (j = j') -> (l = l') ->
(forall (x:Z) (x':Z), ((i <= x)%Z /\ (x < j)%Z) ->
((x <= x')%Z /\ (x' < l)%Z) -> (((f x) x') = ((g x) x'))) ->
((ang_sum (fun (x:Z) => (ang_sum (f x) x l)) i j) =
(ang_sum (fun (x:Z) => (ang_sum (g x) x l')) i' j')).
Axiom ang_sum_minus :
forall (f:Z -> Z) (i:Z) (j:Z) (n:Z), (n >= 0%Z)%Z -> (i < j)%Z ->
((ang_sum (fun (k:Z) => (int_to_ang (-(f k))%Z n)) i j) =
(int_to_ang (-(ind_isum f i j))%Z n)).
Axiom multiple_control_as_ang_sum :
forall (n:Z) (o:angle), (0%Z <= n)%Z -> forall (x:bitvec),
((length x) = n) ->
((forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
(o = (ang_mult_int o (ind_iproduct (getbv x) 0%Z n)))) /\
(~ (forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
(ang_zero = (ang_mult_int o (ind_iproduct (getbv x) 0%Z n)))).
Axiom multiple_control_as_ang_sum_rev :
forall (n:Z) (o:angle), (0%Z <= n)%Z -> forall (x:bitvec),
((length x) = n) ->
((forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
((ang_mult_int o (ind_iproduct (getbv x) 0%Z n)) = o)) /\
(~ (forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
((ang_mult_int o (ind_iproduct (getbv x) 0%Z n)) = ang_zero)).
Axiom multiple_control_neg_as_ang_sum :
forall (n:Z), (0%Z <= n)%Z -> forall (x:bitvec), ((length x) = n) ->
((forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 0%Z)) ->
((ang_mult_int ang_minus_one
(ind_iproduct (fun (j:Z) => (1%Z - ((getbv x) j))%Z) 0%Z n))
= ang_minus_one)) /\
(~ (forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 0%Z)) ->
((ang_mult_int ang_minus_one
(ind_iproduct (fun (j:Z) => (1%Z - ((getbv x) j))%Z) 0%Z n))
= ang_zero)).
Axiom ang_sum_map :
forall (i:Z) (j:Z) (k:Z) (l:Z) (f:Z -> Z) (t1:Z -> angle), (i < j)%Z ->
(p_bijective f (to_fset i j) (to_fset k l)) ->
((ang_sum t1 k l) = (ang_sum (fun (b:Z) => (t1 (f b))) i j)).
Axiom ang_sum_break :
forall (f:Z -> angle) (i:Z) (j:Z) (y:Z), ((i <= y)%Z /\ (y <= j)%Z) ->
((ang_sum f i j) = (ang_add (ang_sum f i y) (ang_sum f y j))).
Axiom ang_sum_break_zero_l :
forall (f:Z -> angle) (i:Z) (j:Z) (y:Z), ((i <= y)%Z /\ (y <= j)%Z) ->
(forall (k:Z), ((i <= k)%Z /\ (k < y)%Z) -> ((f k) = ang_zero)) ->
((ang_sum f y j) = (ang_sum f i j)).
Axiom ang_sum_break_zero_lg :
forall (f:Z -> angle) (g:Z -> angle) (i:Z) (j:Z) (y:Z),
((i <= y)%Z /\ (y <= j)%Z) ->
(forall (k:Z), ((i <= k)%Z /\ (k < y)%Z) -> ((f k) = ang_zero)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((ang_sum f y j) = (ang_sum g i j)).
Axiom ang_sum_break_zero_lg_params :
forall (f:bitvec -> bitvec -> Z -> Z -> angle)
(g:bitvec -> bitvec -> Z -> Z -> angle) (i:Z) (j:Z) (s:Z) (r:Z),
(s >= 0%Z)%Z -> (r >= 0%Z)%Z ->
(forall (x:bitvec) (z:bitvec), forall (a:Z) (k:Z), ((length x) = s) ->
((length z) = r) -> ((i <= a)%Z /\ (a < j)%Z) ->
((i <= k)%Z /\ (k < a)%Z) -> (((((g x) z) a) k) = ang_zero)) ->
(forall (x:bitvec) (z:bitvec), forall (a:Z) (k:Z), ((length x) = s) ->
((length z) = r) -> ((i <= a)%Z /\ (a < j)%Z) ->
((a <= k)%Z /\ (k < j)%Z) -> (((((f x) z) a) k) = ((((g x) z) a) k))) ->
forall (x:bitvec) (z:bitvec), forall (a:Z), ((length x) = s) ->
((length z) = r) -> ((i <= a)%Z /\ (a < j)%Z) ->
((ang_sum (fun (k:Z) => ((((f x) z) a) k)) a j) =
(ang_sum (fun (k:Z) => ((((g x) z) a) k)) i j)).
Axiom ang_sum_break_zero_l_params :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> a -> Z -> angle) (g:a -> a -> Z -> angle) (i:Z) (j:Z) (l:Z),
((i <= l)%Z /\ (l <= j)%Z) -> forall (x:a) (y:a),
(forall (k:Z), ((i <= k)%Z /\ (k < l)%Z) -> ((((f x) y) k) = ang_zero)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) ->
((((f x) y) k) = (((g x) y) k))) ->
((ang_sum ((g x) y) i j) = (ang_sum ((f x) y) l j)).
Axiom ang_sum_break_param :
forall (f:Z -> Z -> angle) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
((i <= y)%Z /\ (y < j)%Z) ->
((ang_sum (f y) i j) = (ang_add (ang_sum (f y) i y) (ang_sum (f y) y j))).
Axiom ang_sum_neutral_param_r :
forall (f:Z -> Z -> angle) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
((i <= y)%Z /\ (y < j)%Z) ->
(forall (k:Z), ((y <= k)%Z /\ (k < j)%Z) -> (((f y) k) = ang_zero)) ->
((ang_sum (f y) y j) = ang_zero).
Axiom ang_sum_neutral_param_l :
forall (f:Z -> Z -> angle) (i:Z) (j:Z), (i < j)%Z -> forall (y:Z),
((i <= y)%Z /\ (y < j)%Z) ->
(forall (k:Z), ((i <= k)%Z /\ (k < y)%Z) -> (((f y) k) = ang_zero)) ->
((ang_sum (f y) i y) = ang_zero).
Axiom ang_sum_transl :
forall (f:Z -> angle) (i:Z) (j:Z) (k:Z), (i < j)%Z ->
((ang_sum f i j) =
(ang_sum (fun (b:Z) => (f (b + k)%Z)) (i - k)%Z (j - k)%Z)).
Axiom ang_sum_transl_one :
forall (f:Z -> angle) (i:Z) (j:Z), (i < j)%Z ->
((ang_sum f i j) =
(ang_sum (fun (b:Z) => (f (b - 1%Z)%Z)) (i + 1%Z)%Z (j + 1%Z)%Z)).
Axiom ang_exp_eq :
forall (o:angle) (o':angle), (o = o') -> ((ang_exp o) = (ang_exp o')).
Axiom ang_sum_to_ind_isum :
forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
((ang_sum (fun (k:Z) => (int_to_ang (f k) n)) i j) =
(int_to_ang (ind_isum f i j) n)).
Axiom ind_isum_to_d_sum :
forall (f:Z -> Z) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z -> (i < j)%Z ->
((int_to_ang (ind_isum f i j) n) =
(ang_sum (fun (k:Z) => (int_to_ang (f k) n)) i j)).
Axiom ind_isum_mod_div :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
((int.EuclideanDivision.mod1
(ind_isum
(fun (k:Z) =>
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))
(power 2%Z ((length bv) - i)%Z))
=
(ind_isum
(fun (k:Z) =>
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
i (length bv))).
Axiom ind_isum_mod_div1 :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
((int.EuclideanDivision.div
(ind_isum
(fun (k:Z) =>
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))
(power 2%Z ((length bv) - i)%Z))
=
(ind_isum
(fun (k:Z) => (((getbv bv) k) * (power 2%Z ((i - 1%Z)%Z - k)%Z))%Z) 0%Z
i)).
Axiom mod_ind_isum :
forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
(binary f) ->
((int.EuclideanDivision.mod1
(ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
l)
(power 2%Z i))
=
(ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z)
(l - i)%Z l)).
Axiom mod_ind_isum_z :
forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
(binary f) ->
((int.EuclideanDivision.mod1
(ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
l)
(power 2%Z i))
=
(ind_isum
(fun (k:Z) =>
((f ((k + l)%Z - i)%Z) * (power 2%Z ((i - 1%Z)%Z - k)%Z))%Z)
0%Z i)).
Axiom div_ind_isum :
forall (f:Z -> Z) (i:Z) (l:Z), ((0%Z <= i)%Z /\ (i <= l)%Z) ->
(binary f) ->
((int.EuclideanDivision.div
(ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((l - 1%Z)%Z - k)%Z))%Z) 0%Z
l)
(power 2%Z i))
=
(ind_isum
(fun (k:Z) => ((f k) * (power 2%Z (((l - 1%Z)%Z - k)%Z - i)%Z))%Z) 0%Z
(l - i)%Z)).
Axiom ind_isum_mod :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
((int.EuclideanDivision.mod1
(ind_isum (fun (l:Z) => (((getbv bv) l) * (power 2%Z (i - l)%Z))%Z) 0%Z
(i + 1%Z)%Z)
2%Z)
= ((getbv bv) i)).
Axiom bv_to_int_kth_pre :
forall (bv:bitvec) (k:Z),
((0%Z <= k)%Z /\ (k < ((length bv) - 1%Z)%Z)%Z) ->
(((getbv bv) k) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div
(ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z (length bv))
(power 2%Z (((length bv) - k)%Z - 1%Z)%Z))
2%Z)).
Axiom bv_to_int_kth_pre1 :
forall (bv:bitvec) (k:Z),
((0%Z <= k)%Z /\ (k < ((length bv) - 1%Z)%Z)%Z) ->
(((getbv bv) k) =
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1
(ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z (length bv))
(power 2%Z ((length bv) - k)%Z))
(power 2%Z (((length bv) - k)%Z - 1%Z)%Z))).
Parameter int_to_bv: Z -> Z -> bitvec.
Parameter result11: Z -> Z -> Z -> Z.
Axiom result_def11 :
forall (i:Z) (n:Z) (k:Z),
(((0%Z <= k)%Z /\ (k < n)%Z) ->
(((result11 i n) k) =
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (power 2%Z (n - k)%Z))
(power 2%Z ((n - k)%Z - 1%Z)%Z)))) /\
(~ ((0%Z <= k)%Z /\ (k < n)%Z) -> (((result11 i n) k) = 0%Z)).
Axiom int_to_bv_def :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((int_to_bv i n) = (make_bv (result11 i n) n)).
Axiom int_to_bv_spec :
forall (i:Z) (n:Z), (n >= 0%Z)%Z -> ((length (int_to_bv i n)) = n).
Axiom int_to_bv_spec1 :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((int_to_bv i n) =
(make_bv
(fun (k:Z) =>
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (power 2%Z (n - k)%Z))
(power 2%Z ((n - k)%Z - 1%Z)%Z)))
n)).
Axiom int_to_bv_sum_pre :
forall (i:Z) (n:Z) (k:Z), ((n >= k)%Z /\ (k >= 0%Z)%Z) ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int.EuclideanDivision.mod1 i (power 2%Z k)) =
(ind_isum
(fun (l:Z) =>
(((getbv (int_to_bv i n)) l) * (power 2%Z ((n - l)%Z - 1%Z)%Z))%Z)
(n - k)%Z n)).
Axiom int_to_bv_sum :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
(i =
(ind_isum
(fun (k:Z) =>
(((getbv (int_to_bv i n)) k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z)
0%Z n)).
Axiom int_to_bv_mod_div :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_to_bv i n) =
(make_bv
(fun (k:Z) =>
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z))
n)).
Axiom mod_isum :
forall (i:Z) (k:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
((int.EuclideanDivision.mod1 i (power 2%Z k)) =
(ind_isum
(fun (l:Z) =>
(((getbv (int_to_bv i n)) l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z)
(n - k)%Z n)).
Axiom mod_isum_z :
forall (i:Z) (k:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
((int.EuclideanDivision.mod1 i (power 2%Z k)) =
(ind_isum
(fun (l:Z) =>
(((getbv (int_to_bv i n)) (l + (n - k)%Z)%Z) *
(power 2%Z ((k - l)%Z - 1%Z)%Z))%Z)
0%Z k)).
Axiom div_isum :
forall (i:Z) (k:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
((int.EuclideanDivision.div i (power 2%Z k)) =
(ind_isum
(fun (l:Z) =>
(((getbv (int_to_bv i n)) l) *
(power 2%Z (((n - 1%Z)%Z - k)%Z - l)%Z))%Z)
0%Z (n - k)%Z)).
Axiom int_to_bv_div_mod :
forall (i:Z) (k:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
((int_to_bv i n) =
(make_bv
(fun (k1:Z) =>
(int.EuclideanDivision.div
(int.EuclideanDivision.mod1 i (power 2%Z (n - k1)%Z))
(power 2%Z ((n - k1)%Z - 1%Z)%Z)))
n)).
Axiom int_to_bv_value :
forall (i:Z) (n:Z) (k:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((0%Z <= k)%Z /\ (k < n)%Z) ->
(((getbv (int_to_bv i n)) k) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z)).
Axiom int_to_bv_zero :
forall (n:Z), forall (k:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
(((getbv (int_to_bv 0%Z n)) k) = 0%Z).
Axiom int_to_sum :
forall (i:Z) (n:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
(i =
(ind_isum
(fun (k:Z) =>
(((getbv (int_to_bv i n)) k) * (power 2%Z ((n - k)%Z - 1%Z)%Z))%Z)
0%Z n)).
Axiom int_to_bv_transl :
forall (i:Z) (k:Z) (n:Z) (t1:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (n - t1)%Z)%Z) -> ((0%Z < t1)%Z /\ (t1 <= n)%Z) ->
(((getbv
(int_to_bv (int.EuclideanDivision.mod1 i (power 2%Z (n - t1)%Z))
(n - t1)%Z))
k)
= ((getbv (int_to_bv i n)) (k + t1)%Z)).
Parameter bin_to_int: (Z -> Z) -> Z -> Z.
Axiom bin_to_int_def :
forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
((bin_to_int f n) = (bv_to_int (make_bv f n))).
Axiom bin_to_int_spec :
forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
((bin_to_int f n) =
(ind_isum (fun (k:Z) => ((f k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z) 0%Z
n)).
Axiom bin_to_int_spec1 :
forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
(0%Z <= (bin_to_int f n))%Z.
Parameter int_to_bin: Z -> Z -> Z -> Z.
Axiom int_to_bin_def :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_to_bin i n) = (getbv (int_to_bv i n))).
Axiom int_to_bin_spec :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
(i =
(ind_isum
(fun (k:Z) => (((int_to_bin i n) k) * (power 2%Z ((n - 1%Z)%Z - k)%Z))%Z)
0%Z n)).
Axiom int_to_bin_spec1 :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> binary (int_to_bin i n).
Axiom int_to_bin_spec2 :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (k:Z),
((0%Z <= k)%Z /\ (k < n)%Z) ->
(((int_to_bin i n) k) =
(int.EuclideanDivision.mod1
(int.EuclideanDivision.div i (power 2%Z ((n - k)%Z - 1%Z)%Z)) 2%Z)).
Axiom int_to_bv_tail :
forall (i:Z) (n:Z), (n > 1%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_to_bv (tail_bits i n) (n - 1%Z)%Z) = (tail (int_to_bv i n))).
Axiom bound_sum_dec :
forall (bv:bitvec) (i:Z), ((1%Z <= i)%Z /\ (i <= (length bv))%Z) ->
((ind_isum
(fun (l:Z) => (((getbv bv) l) * (power 2%Z ((length bv) - l)%Z))%Z) i
((length bv) + 1%Z)%Z)
< (power 2%Z (((length bv) - i)%Z + 1%Z)%Z))%Z.
Axiom bv_to_int_to_bv :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((bv_to_int (int_to_bv i n)) = i).
Axiom tail_bits_sum :
forall (i:Z) (n:Z), (1%Z < n)%Z -> (0%Z <= i)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((tail_bits i n) =
(ind_isum
(fun (l:Z) =>
(((getbv (int_to_bv i n)) l) * (power 2%Z ((n - 1%Z)%Z - l)%Z))%Z)
1%Z n)).
Axiom int_to_bv_to_int :
forall (bv:bitvec), (1%Z <= (length bv))%Z ->
((int_to_bv (bv_to_int bv) (length bv)) = bv).
Axiom concat_to_int :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
((bv_to_int (concat_l bv i)) =
((bv_to_int bv) + (i * (power 2%Z (length bv)))%Z)%Z).
Axiom bounded_to_int :
forall (bv:bitvec), ((bv_to_int bv) < (power 2%Z (length bv)))%Z.
Axiom int_to_bv_to_int_value :
forall (bv:bitvec) (i:Z), (1%Z <= (length bv))%Z ->
(((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
(((getbv (int_to_bv (bv_to_int bv) (length bv))) i) = ((getbv bv) i))) /\
(~ ((0%Z <= i)%Z /\ (i < (length bv))%Z) ->
(((getbv (int_to_bv (bv_to_int bv) (length bv))) i) = 0%Z)).
Axiom int_to_bv_to_int_gen :
forall (bv:bitvec) (n:Z), (1%Z <= (length bv))%Z -> (n = (length bv)) ->
((int_to_bv (bv_to_int bv) n) = bv).
Axiom bv_to_int_mod :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
((int.EuclideanDivision.mod1 (bv_to_int bv)
(power 2%Z ((length bv) - k)%Z))
=
(ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
k (length bv))).
Axiom bv_to_int_mod_rev :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
k (length bv))
=
(int.EuclideanDivision.mod1 (bv_to_int bv)
(power 2%Z ((length bv) - k)%Z))).
Axiom bv_to_int_mod_gen :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) -> forall (bv:bitvec),
((length bv) = n) ->
((int.EuclideanDivision.mod1 (bv_to_int bv)
(power 2%Z ((length bv) - k)%Z))
=
(ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
k (length bv))).
Axiom to_int_head_tail :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((bv_to_int bv) =
((bv_to_int (tail bv)) +
((head bv) * (power 2%Z ((length bv) - 1%Z)%Z))%Z)%Z).
Axiom to_int_head_tail1 :
forall (bv:bitvec), ((length bv) >= 1%Z)%Z ->
((bv_to_int (tail bv)) =
(int.EuclideanDivision.mod1 (bv_to_int bv)
(power 2%Z ((length bv) - 1%Z)%Z))).
Axiom not_disj :
forall (a:bool) (b:bool), ~ (a = true) -> ~ (b = true) -> ~ (a = true).
Axiom not_disj1 : True.
Parameter my_map:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (a -> b) ->
(set a) -> set b.
Axiom my_map_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ((cardinal u) = 0%Z) ->
((my_map f u) = (empty : set b)).
Axiom my_map_def1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ~ ((cardinal u) = 0%Z) ->
((my_map f u) = (add (f (choose u)) (my_map f (remove (choose u) u)))).
Axiom my_map_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ((my_map f u) = (map f u)).
Axiom my_map_to_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ((my_map f u) = (map f u)).
Axiom map_to_my_map :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:a -> b) (u:set a), ((map f u) = (my_map f u)).
Parameter n_bvs: Z -> set bitvec.
Axiom n_bvs_def :
forall (n:Z), (0%Z <= n)%Z -> (n = 0%Z) ->
((n_bvs n) = (to_set (make_bv (fun (i:Z) => 0%Z) 0%Z))).
Axiom n_bvs_def1 :
forall (n:Z), (0%Z <= n)%Z -> ~ (n = 0%Z) ->
((n_bvs n) =
(union (my_map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
(my_map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))).
Axiom n_bvs_spec :
forall (n:Z), (0%Z <= n)%Z -> forall (f:bitvec), (mem f (n_bvs n)) ->
((length f) = n).
Axiom n_bvs_spec1 :
forall (n:Z), (0%Z <= n)%Z -> forall (f:bitvec), (mem f (n_bvs n)) ->
((length f) = n).
Axiom n_bvs_spec2 :
forall (n:Z), (0%Z <= n)%Z -> forall (f:bitvec), ((length f) = n) ->
mem f (n_bvs n).
Axiom n_bvs_spec3 :
forall (n:Z), (0%Z <= n)%Z -> ((cardinal (n_bvs n)) > 0%Z)%Z.
Axiom n_bvs_node :
forall (n:Z), (0%Z < n)%Z ->
((inter (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
(map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))
= (empty : set bitvec)).
Axiom n_bvs_node1 :
forall (n:Z), (0%Z < n)%Z ->
((union (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
(map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))
= (n_bvs n)).
Axiom injective_node :
forall (n:Z), (0%Z <= n)%Z ->
p_injective (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs n).
Axiom injective_node1 :
forall (n:Z), (0%Z <= n)%Z ->
p_injective (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs n).
Axiom mat_sum_n_bvs_pos :
forall (n:Z) (f:bitvec -> matrix t), (0%Z < n)%Z ->
(constant_size (n_bvs n) f) ->
((mat_sum (n_bvs n) f) =
(add_mat
(mat_sum (n_bvs (n - 1%Z)%Z) (fun (bv:bitvec) => (f (concat_l bv 0%Z))))
(mat_sum (n_bvs (n - 1%Z)%Z) (fun (bv:bitvec) => (f (concat_l bv 1%Z)))))).
Axiom mat_sum_n_bvs_null :
forall (f:bitvec -> matrix t),
((mat_sum (n_bvs 0%Z) f) =
(f (make_bv ((fun (y0:Z) (y1:Z) => (const y0 y1)) 0%Z) 0%Z))).
Axiom mat_sum_n_bvs_null_eq :
forall (f:bitvec -> matrix t) (x:matrix t),
(x = (f (make_bv ((fun (y0:Z) (y1:Z) => (const y0 y1)) 0%Z) 0%Z))) ->
((mat_sum (n_bvs 0%Z) f) = x).
Axiom get_n_bvs : forall (bv:bitvec), mem bv (n_bvs (length bv)).
Axiom get_n_bvs_gen :
forall (bv:bitvec) (l:Z), (l = (length bv)) -> mem bv (n_bvs l).
Axiom set_n_bvs :
forall (bv:bitvec), (mem bv (n_bvs (length bv))) -> forall (i:Z),
~ (0%Z <= i)%Z -> (((getbv bv) i) = 0%Z).
Axiom set_n_bvs1 :
forall (bv:bitvec), (mem bv (n_bvs (length bv))) -> forall (i:Z),
~ (i < (length bv))%Z -> (((getbv bv) i) = 0%Z).
Axiom int_to_bv_n_bvs :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> mem (int_to_bv i n) (n_bvs n).
Axiom n_bvs_def_pos :
forall (n:Z), (0%Z < n)%Z ->
((n_bvs n) =
(union (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs (n - 1%Z)%Z))
(map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs (n - 1%Z)%Z)))).
Axiom map_n_bvs :
forall (n:Z), (0%Z < n)%Z ->
((to_fset 0%Z (power 2%Z n)) =
(map (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n))).
Parameter first_div: bitvec -> bitvec -> Z.
Axiom first_div_spec :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (first_div bv1 bv2))%Z) ->
(((getbv bv1) j) = ((getbv bv2) j)).
Axiom first_div_spec1 :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> ((first_div bv1 bv2) < (length bv1))%Z ->
~ (((getbv bv1) (first_div bv1 bv2)) = ((getbv bv2) (first_div bv1 bv2))).
Axiom first_div_spec2 :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> (0%Z <= (first_div bv1 bv2))%Z.
Axiom first_div_spec3 :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> ((first_div bv1 bv2) < (length bv1))%Z.
Axiom injective_concat :
forall (i:Z) (n:Z), (0%Z <= n)%Z -> ((0%Z <= i)%Z /\ (i <= 1%Z)%Z) ->
p_injective (fun (bv:bitvec) => (concat_l bv i)) (n_bvs n).
Axiom inf_first_div :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> forall (j:Z), (1%Z <= j)%Z ->
~ (((getbv bv1) j) = ((getbv bv2) j)) -> ((first_div bv1 bv2) <= j)%Z.
Axiom first_div_diff :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) ->
~ (((getbv bv1) (first_div bv1 bv2)) = ((getbv bv2) (first_div bv1 bv2))).
Axiom exists_first_div :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) ->
exists i:Z,
((0%Z <= i)%Z /\ (i < (length bv1))%Z) /\ (i = (first_div bv1 bv2)).
Axiom set_diff_length :
forall (bv1:bitvec) (bv2:bitvec), ~ ((length bv1) = (length bv2)) ->
~ (bv1 = bv2).
Axiom set_diff_val :
forall (bv1:bitvec) (bv2:bitvec) (i:Z), ((length bv1) = (length bv2)) ->
((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
~ (((getbv bv1) i) = ((getbv bv2) i)) -> ~ (bv1 = bv2).
Parameter fc6: bitvec -> Z -> Z.
Parameter fc7: bitvec -> Z -> Z.
Axiom fc_def6 :
forall (bv:bitvec) (l:Z),
((l < (length bv))%Z ->
(((fc6 bv) l) =
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)) /\
(~ (l < (length bv))%Z -> (((fc6 bv) l) = 0%Z)).
Axiom fc_def7 :
forall (bv:bitvec) (l:Z),
((l < (length bv))%Z ->
(((fc7 bv) l) =
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)) /\
(~ (l < (length bv))%Z -> (((fc7 bv) l) = 0%Z)).
Axiom kth_decomp :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
((bv_to_int bv) =
(((ind_isum (fc6 bv) 0%Z k) +
(((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)%Z
+ (ind_isum (fc7 bv) (k + 1%Z)%Z (length bv)))%Z).
Axiom kth_decomp1 :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
((bv_to_int bv) =
(((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z k)
+ (((getbv bv) k) * (power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)%Z
+
(ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
(k + 1%Z)%Z (length bv)))%Z).
Axiom int_to_bv_prod :
forall (i:Z) (j:Z) (n:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ind_product
(fun (k:Z) =>
(indic ((getbv (int_to_bv i n)) k) ((getbv (int_to_bv j n)) k)))
0%Z n)
= (indic i j)).
Axiom int_to_bv_prod_gen :
forall (i:Z) (n:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ind_product
(fun (k:Z) =>
(indic ((getbv (int_to_bv i n)) k) ((getbv (int_to_bv j n)) k)))
0%Z n)
= (indic i j)).
Axiom kth_decomp_bound_zero :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
(((getbv bv) k) = 0%Z) ->
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z k)
<= (bv_to_int bv))%Z.
Axiom kth_decomp_bound_zero1 :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
(((getbv bv) k) = 0%Z) ->
((bv_to_int bv) <
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z k)
+ (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))%Z)%Z.
Axiom kth_decomp_bound_one :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
(((getbv bv) k) = 1%Z) ->
(((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - 1%Z)%Z - l)%Z))%Z)
0%Z k)
+ (power 2%Z (((length bv) - k)%Z - 1%Z)%Z))%Z
<= (bv_to_int bv))%Z.
Axiom kth_decomp_bound_one1 :
forall (bv:bitvec) (k:Z), ((0%Z <= k)%Z /\ (k < (length bv))%Z) ->
(((getbv bv) k) = 1%Z) ->
((bv_to_int bv) <
((ind_isum
(fun (l:Z) =>
(((getbv bv) l) * (power 2%Z (((length bv) - l)%Z - 1%Z)%Z))%Z)
0%Z k)
+ (power 2%Z ((length bv) - k)%Z))%Z)%Z.
Axiom ang_sum_int_decomp :
forall (bvx:Z -> Z) (k:Z) (n:Z), (0%Z < n)%Z -> (binary bvx) ->
((ang_sum
(fun (x:Z) =>
(int_to_ang (((bvx x) * (power 2%Z ((n - x)%Z - 1%Z)%Z))%Z * k)%Z n))
0%Z n)
= (int_to_ang ((bin_to_int bvx n) * k)%Z n)).
Axiom ang_sum_int_decomp_gen :
forall (bvx:Z -> Z) (n:Z), (0%Z < n)%Z -> (binary bvx) -> forall (k:Z),
((ang_sum
(fun (x:Z) =>
(int_to_ang (((bvx x) * (power 2%Z ((n - x)%Z - 1%Z)%Z))%Z * k)%Z n))
0%Z n)
= (int_to_ang ((bin_to_int bvx n) * k)%Z n)).
Axiom ang_sum_bv_to_int :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (k:Z),
((length x) = n) ->
((ang_sum
(fun (i:Z) =>
(int_to_ang ((((getbv x) i) * (power 2%Z ((n - i)%Z - 1%Z)%Z))%Z * k)%Z
n))
0%Z n)
= (int_to_ang ((bv_to_int x) * k)%Z n)).
Axiom ang_sum_bv_to_int_ :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (k:Z),
((length x) = n) ->
((ang_sum
(fun (i:Z) =>
(int_to_ang ((((getbv x) i) * (power_ 2%Z ((n - i)%Z - 1%Z)%Z))%Z * k)%Z
n))
0%Z n)
= (int_to_ang ((bv_to_int x) * k)%Z n)).
Parameter bv_inversion: bitvec -> bitvec.
Axiom bv_inversion_def :
forall (bv:bitvec),
((bv_inversion bv) =
(make_bv (fun (k:Z) => ((getbv bv) (((length bv) - k)%Z - 1%Z)%Z))
(length bv))).
Axiom bv_inversion_spec :
forall (bv:bitvec), ((length (bv_inversion bv)) = (length bv)).
Axiom bv_inversion_spec1 :
forall (bv:bitvec), forall (k:Z), (in_range (bv_inversion bv) k) ->
(((getbv (bv_inversion bv)) k) =
((getbv bv) (((length bv) - k)%Z - 1%Z)%Z)).
Axiom bv_inversion_value :
forall (bv:bitvec) (i:Z),
(((getbv (bv_inversion bv)) i) =
((getbv bv) (((length bv) - i)%Z - 1%Z)%Z)).
Axiom bv_inversion_invol :
forall (bv:bitvec), ((bv_inversion (bv_inversion bv)) = bv).
Parameter int_bit_inversion: Z -> Z -> Z.
Axiom int_bit_inversion_def :
forall (i:Z) (n:Z), (0%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion i n) = (bv_to_int (bv_inversion (int_to_bv i n)))).
Axiom int_bit_inversion_spec :
forall (i:Z) (n:Z), (0%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
(0%Z <= (int_bit_inversion i n))%Z.
Axiom int_bit_inversion_spec1 :
forall (i:Z) (n:Z), (0%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion i n) < (power 2%Z n))%Z.
Axiom int_bit_inversion_invol :
forall (i:Z) (n:Z), (0%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion (int_bit_inversion i n) n) = i).
Axiom int_bit_inversion_onebit :
forall (i:Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((int_bit_inversion i 1%Z) = i).
Axiom int_bit_inversion_zero :
forall (i:Z) (n:Z), (0%Z < n)%Z -> (0%Z = i) ->
((int_bit_inversion i n) = 0%Z).
Axiom bv_to_int_sum_inversion :
forall (bv:bitvec), ((length bv) > 0%Z)%Z ->
((int_bit_inversion (bv_to_int bv) (length bv)) =
(ind_isum
(fun (k:Z) =>
(((getbv bv) (((length bv) - k)%Z - 1%Z)%Z) *
(power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))).
Axiom bv_to_int_sum_inversion_inc :
forall (bv:bitvec), ((length bv) > 0%Z)%Z ->
((int_bit_inversion (bv_to_int bv) (length bv)) =
(ind_isum (fun (k:Z) => (((getbv bv) k) * (power 2%Z k))%Z) 0%Z
(length bv))).
Axiom inversion_to_int_comm :
forall (bv:bitvec), ((length bv) > 0%Z)%Z ->
((int_to_bv (int_bit_inversion (bv_to_int bv) (length bv)) (length bv)) =
(bv_inversion bv)).
Axiom bv_inversion_sum :
forall (i:Z) (n:Z), (0%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion i n) =
(ind_isum
(fun (k:Z) =>
(((getbv (int_to_bv i n)) ((n - k)%Z - 1%Z)%Z) *
(power 2%Z ((n - 1%Z)%Z - k)%Z))%Z)
0%Z n)).
Axiom bv_to_int_inversion_sum :
forall (bv:bitvec),
((bv_to_int (bv_inversion bv)) =
(ind_isum
(fun (k:Z) =>
(((getbv bv) (((length bv) - k)%Z - 1%Z)%Z) *
(power 2%Z (((length bv) - 1%Z)%Z - k)%Z))%Z)
0%Z (length bv))).
Axiom bv_to_int_bit_inversion :
forall (bv:bitvec), ((length bv) > 0%Z)%Z ->
((bv_to_int (bv_inversion bv)) =
(int_bit_inversion (bv_to_int bv) (length bv))).
Axiom bv_to_int_inversion_sum_inc :
forall (bv:bitvec), ((length bv) > 0%Z)%Z ->
((bv_to_int (bv_inversion bv)) =
(ind_isum (fun (k:Z) => (((getbv bv) k) * (power 2%Z k))%Z) 0%Z
(length bv))).
Axiom bv_m_to_int_bit_inversion :
forall (f:Z -> Z) (n:Z), (0%Z < n)%Z ->
((bv_to_int (bv_inversion (make_bv_m f n))) =
(int_bit_inversion (bv_to_int (make_bv_m f n)) n)).
Axiom int_bit_inversion_tail_bits :
forall (i:Z) (n:Z), (1%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion (tail_bits i n) (n - 1%Z)%Z) =
(ind_isum
(fun (k:Z) =>
(((getbv (int_to_bv i n)) (n - k)%Z) *
(power 2%Z ((n - k)%Z - 1%Z)%Z))%Z)
1%Z n)).
Axiom tail_bits_int_bit_inversion :
forall (bv:Z -> Z) (n:Z), (1%Z < n)%Z ->
((tail_bits (int_bit_inversion (bv_to_int (make_bv_m bv n)) n) n) =
(ind_isum
(fun (k:Z) =>
((int.EuclideanDivision.mod1 (bv ((n - 1%Z)%Z - k)%Z) 2%Z) *
(power 2%Z ((n - k)%Z - 1%Z)%Z))%Z)
1%Z n)).
Axiom int_bit_inversion_ht :
forall (i:Z) (n:Z), (1%Z < n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((int_bit_inversion i n) =
((2%Z * (int_bit_inversion (tail_bits i n) (n - 1%Z)%Z))%Z +
(head_bit i n))%Z).
Axiom bv_inversion_ht :
forall (f:Z -> Z) (n:Z), (1%Z < n)%Z ->
((bv_to_int (bv_inversion (make_bv_m f n))) =
((head (make_bv_m f n)) +
(2%Z * (bv_to_int (bv_inversion (tail (make_bv_m f n)))))%Z)%Z).
Axiom bv_inversion_ht_bv :
forall (bv:bitvec), (1%Z < (length bv))%Z ->
((bv_to_int (bv_inversion bv)) =
((head bv) + (2%Z * (bv_to_int (bv_inversion (tail bv))))%Z)%Z).
Axiom bv_to_int_ht :
forall (f:Z -> Z) (n:Z), (1%Z < n)%Z ->
((bv_to_int (make_bv_m f n)) =
(((power 2%Z (n - 1%Z)%Z) * (head (make_bv_m f n)))%Z +
(bv_to_int (tail (make_bv_m f n))))%Z).
Axiom bv_inversion_mult_ht :
forall (fx:Z -> Z) (fy:Z -> Z) (n:Z), (1%Z < n)%Z ->
(((bv_to_int (make_bv_m fx n)) *
(bv_to_int (bv_inversion (make_bv_m fy n))))%Z
=
((((head (make_bv_m fy n)) * (bv_to_int (make_bv_m fx n)))%Z +
((bv_to_int (tail (make_bv_m fx n))) *
(2%Z * (bv_to_int (bv_inversion (tail (make_bv_m fy n)))))%Z)%Z)%Z
+
((power 2%Z n) *
((head (make_bv_m fx n)) *
(bv_to_int (bv_inversion (tail (make_bv_m fy n)))))%Z)%Z)%Z).
Axiom bv_inversion_mult_ht_bv :
forall (bvx:bitvec) (bvy:bitvec), (1%Z < (length bvx))%Z ->
((length bvx) = (length bvy)) ->
(((bv_to_int bvx) * (bv_to_int (bv_inversion bvy)))%Z =
((((head bvy) * (bv_to_int bvx))%Z +
((bv_to_int (tail bvx)) *
(2%Z * (bv_to_int (bv_inversion (tail bvy))))%Z)%Z)%Z
+
((power 2%Z (length bvx)) *
((head bvx) * (bv_to_int (bv_inversion (tail bvy))))%Z)%Z)%Z).
Axiom real_to_ang_distr_minus :
forall (x:t) (z:t) (t1:t), forall (y:Z), (real_ x) -> (real_ z) ->
(real_ t1) ->
((ang_add (real_to_ang (infix_asdt x (i_to_t y)))
(real_to_ang (infix_asdt (infix_asdt (i_to_t y) (prefix_mndt z)) t1)))
= (ang_mult_int (real_to_ang (infix_mndt x (infix_asdt z t1))) y)).
Axiom ang_sum_int_decomp_gen_rev :
forall (bvx:Z -> Z) (n:Z), (0%Z < n)%Z -> (binary bvx) -> forall (k:Z),
((int_to_ang ((bin_to_int bvx n) * k)%Z n) =
(ang_sum
(fun (x:Z) =>
(int_to_ang (((bvx x) * (power 2%Z ((n - x)%Z - 1%Z)%Z))%Z * k)%Z n))
0%Z n)).
Axiom Ang_mult_int_exp :
forall (o:angle), forall (i:Z),
((ang_exp (ang_mult_int o i)) = (cpower (ang_exp o) i)).
Axiom ang_mult_int_exp_rev :
forall (o:angle) (i:Z),
((cpower (ang_exp o) i) = (ang_exp (ang_mult_int o i))).
Axiom ang_mult_int_add :
forall (o:angle) (i:Z) (i':Z),
((ang_mult_int o (i + i')%Z) =
(ang_add (ang_mult_int o i) (ang_mult_int o i'))).
Axiom ang_mult_int_plus_one :
forall (o:angle) (i:Z),
((ang_add o (ang_mult_int o i)) = (ang_mult_int o (i + 1%Z)%Z)).
Axiom sum_ang_mult_int_e :
forall (o:angle) (f:Z -> Z) (l:Z) (h:Z), (l < h)%Z ->
((ang_sum (fun (i:Z) => (ang_mult_int o (f i))) l h) =
(ang_mult_int o (ind_isum f l h))).
Axiom real_to_ang_sum :
forall (phi:Z -> t) (l:Z) (h:Z), (l < h)%Z ->
(forall (i:Z), ((l <= i)%Z /\ (i < h)%Z) -> real_ (phi i)) ->
((ang_sum (fun (i:Z) => (real_to_ang (phi i))) l h) =
(real_to_ang (ind_sum phi l h))).
Axiom real_to_ang_sum_int :
forall (f:Z -> Z) (l:Z) (h:Z) (x:t), (l < h)%Z -> (real_ x) ->
((ang_sum (fun (i:Z) => (real_to_ang (infix_asdt x (i_to_t (f i))))) l h) =
(real_to_ang (infix_asdt x (i_to_t (ind_isum f l h))))).
Axiom real_to_ang_sum_int_gen :
forall (f:Z -> Z) (l:Z) (h:Z), (l < h)%Z -> forall (x:t), (real_ x) ->
((ang_sum (fun (i:Z) => (real_to_ang (infix_asdt x (i_to_t (f i))))) l h) =
(real_to_ang (infix_asdt x (i_to_t (ind_isum f l h))))).
Axiom real_to_ang_bv_inversion :
forall (ft:Z) (x:t) (y:bitvec), (0%Z < ft)%Z -> (real_ x) ->
((length y) = ft) ->
((ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt (infix_asdt x (i_to_t (power_ 2%Z i)))
(i_to_t ((getbv y) i)))))
0%Z ft)
= (real_to_ang (infix_asdt x (i_to_t (bv_to_int (bv_inversion y)))))).
Axiom ang_mult_int_double :
forall (o:angle) (i:Z),
((ang_mult_int o (2%Z * i)%Z) =
(ang_add (ang_mult_int o i) (ang_mult_int o i))).
Axiom ang_mult_int_inv :
forall (o:angle), ((ang_mult_int o (-1%Z)%Z) = (ang_inv o)).
Axiom ang_mult_int_one :
forall (o:angle) (n:Z), (n = 1%Z) -> ((ang_mult_int o n) = o).
Axiom ang_mult_int_inv_rev :
forall (o:angle), ((ang_inv o) = (ang_mult_int o (-1%Z)%Z)).
Axiom ang_mult_int_comp :
forall (o:angle) (i:Z) (j:Z),
((ang_mult_int (ang_mult_int o i) j) = (ang_mult_int o (i * j)%Z)).
Axiom ang_mult_int_comp_rev :
forall (o:angle) (i:Z) (j:Z),
((ang_mult_int o (i * j)%Z) = (ang_mult_int (ang_mult_int o i) j)).
Axiom add_ang_mult_int :
forall (o:angle) (o':angle) (i:Z),
((ang_add (ang_mult_int o i) (ang_mult_int o' i)) =
(ang_mult_int (ang_add o o') i)).
Axiom sum_ang_mult_int :
forall (f:Z -> angle) (i:Z) (l:Z) (h:Z), (l < h)%Z ->
((ang_sum (fun (x:Z) => (ang_mult_int (f x) i)) l h) =
(ang_mult_int (ang_sum f l h) i)).
Axiom ang_sum_bv_to_int_inversion_pre :
forall (n:Z) (x:bitvec), (0%Z < n)%Z -> ((length x) = n) ->
forall (theta:t), (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (bv_to_int (bv_inversion x))))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt (infix_asdt theta (i_to_t (power_ 2%Z i)))
(i_to_t ((getbv x) i)))))
0%Z n)).
Axiom ang_sum_bv_to_int_inversion :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (theta:t),
((length x) = n) -> (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (bv_to_int (bv_inversion x))))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt (infix_asdt theta (i_to_t (power_ 2%Z i)))
(i_to_t ((getbv x) i)))))
0%Z n)).
Axiom ang_sum_bv_to_int_opp_pre :
forall (n:Z) (x:bitvec), (0%Z < n)%Z -> ((length x) = n) ->
forall (theta:t), (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (-(bv_to_int x))%Z))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt
(infix_asdt theta (i_to_t (power_ 2%Z ((n - i)%Z - 1%Z)%Z)))
(i_to_t (-((getbv x) i))%Z))))
0%Z n)).
Axiom ang_sum_bv_to_int_opp :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (theta:t),
((length x) = n) -> (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (-(bv_to_int x))%Z))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt
(infix_asdt theta (i_to_t (power_ 2%Z ((n - i)%Z - 1%Z)%Z)))
(i_to_t (-((getbv x) i))%Z))))
0%Z n)).
Axiom ang_sum_bv_to_int_mult_pre :
forall (n:Z) (x:bitvec), (0%Z < n)%Z -> ((length x) = n) ->
forall (theta:t), (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (bv_to_int x)))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt
(infix_asdt theta (i_to_t (power_ 2%Z ((n - i)%Z - 1%Z)%Z)))
(i_to_t ((getbv x) i)))))
0%Z n)).
Axiom ang_sum_bv_to_int_mult :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (theta:t),
((length x) = n) -> (real_ theta) ->
((real_to_ang (infix_asdt theta (i_to_t (bv_to_int x)))) =
(ang_sum
(fun (i:Z) =>
(real_to_ang
(infix_asdt
(infix_asdt theta (i_to_t (power_ 2%Z ((n - i)%Z - 1%Z)%Z)))
(i_to_t ((getbv x) i)))))
0%Z n)).
Axiom rewrite_ang_sum_sum_to_bv_and_inversion :
forall (n:Z) (x:bitvec) (y:bitvec), (0%Z < n)%Z -> ((length x) = n) ->
((length y) = n) ->
((ang_sum
(fun (j:Z) =>
(ang_sum
(fun (i:Z) =>
(int_to_ang
(((-((getbv x) i))%Z * ((getbv y) j))%Z *
(power_ 2%Z (((n - i)%Z - 1%Z)%Z + j)%Z))%Z
n))
j n))
0%Z n)
=
(real_to_ang
(infix_sldt
(infix_asdt (i_to_t (-(bv_to_int x))%Z)
(i_to_t (bv_to_int (bv_inversion y))))
(i_to_t (power_ 2%Z n))))).
Parameter odd: Z -> bool.
Axiom odd_def :
forall (n:Z), ((int.EuclideanDivision.mod1 n 2%Z) = 1%Z) ->
((odd n) = true).
Axiom odd_def1 :
forall (n:Z), ~ ((int.EuclideanDivision.mod1 n 2%Z) = 1%Z) ->
((odd n) = false).
Axiom odd_spec :
forall (n:Z), ((odd n) = true) ->
(n = ((2%Z * (int.EuclideanDivision.div n 2%Z))%Z + 1%Z)%Z).
Axiom odd_spec1 :
forall (n:Z), ((odd n) = false) ->
(n = (2%Z * (int.EuclideanDivision.div n 2%Z))%Z).
Parameter even: Z -> bool.
Axiom even_def :
forall (n:Z), ((int.EuclideanDivision.mod1 n 2%Z) = 0%Z) ->
((even n) = true).
Axiom even_def1 :
forall (n:Z), ~ ((int.EuclideanDivision.mod1 n 2%Z) = 0%Z) ->
((even n) = false).
Axiom even_spec : forall (n:Z), ((even n) = true) -> ~ ((odd n) = true).
Axiom even_spec1 : forall (n:Z), ~ ((odd n) = true) -> ((even n) = true).
Axiom even_to_mod :
forall (n:Z), ((even n) = true) ->
((int.EuclideanDivision.mod1 n 2%Z) = 0%Z).
Axiom odd_to_mod :
forall (n:Z), ((odd n) = true) ->
((int.EuclideanDivision.mod1 n 2%Z) = 1%Z).
Axiom even_or_odd : forall (n:Z), ((even n) = true) \/ ((odd n) = true).
Axiom cpower_minus_tone :
forall (n:Z), (0%Z <= n)%Z -> ((even n) = true) ->
((cpower (prefix_mndt tone) n) = tone).
Axiom cpower_minus_tone1 :
forall (n:Z), (0%Z <= n)%Z -> ((odd n) = true) ->
((cpower (prefix_mndt tone) n) = (prefix_mndt tone)).
Axiom cpower_minus_tone_even :
forall (n:Z), (0%Z <= n)%Z -> ((even n) = true) ->
((cpower (prefix_mndt tone) n) = tone).
Axiom cpower_minus_tone_odd :
forall (n:Z), (0%Z <= n)%Z -> ((odd n) = true) ->
((cpower (prefix_mndt tone) n) = (prefix_mndt tone)).
Axiom not_null_powers_squarert_two :
forall (i:Z), (0%Z <= i)%Z -> ~ ((cpower squarert_two i) = tzero).
Parameter pos_coeff: t.
Axiom pos_coeff_def : (pos_coeff = (infix_sldt tone squarert_two)).
Axiom real_pos_coeff : real_ pos_coeff.
Parameter neg_coeff: t.
Axiom neg_coeff_def :
(neg_coeff = (infix_sldt (prefix_mndt tone) squarert_two)).
Axiom coeffs : (neg_coeff = (prefix_mndt pos_coeff)).
Parameter mop: Z -> t.
Axiom mop_def :
forall (i:Z), (0%Z <= i)%Z -> ((mop i) = (cpower (prefix_mndt tone) i)).
Axiom minus_one_power_values :
forall (i:Z), (0%Z <= i)%Z -> ((even i) = true) -> ((mop i) = tone).
Axiom minus_one_power_values1 :
forall (i:Z), (0%Z <= i)%Z -> ((odd i) = true) ->
((mop i) = (prefix_mndt tone)).
Axiom factors_mop :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((mop (i + j)%Z) = (infix_asdt (mop i) (mop j))).
Axiom factors_mop_rev :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((infix_asdt (mop i) (mop j)) = (mop (i + j)%Z)).
Parameter pow_inv_sqrt_2: Z -> t.
Axiom pow_inv_sqrt_2_def :
forall (i:Z), (0%Z <= i)%Z -> ((pow_inv_sqrt_2 i) = (cpower pos_coeff i)).
Axiom pow_inv_sqrt_2_spec :
forall (i:Z), (0%Z <= i)%Z -> real_ (pow_inv_sqrt_2 i).
Axiom pow_inv_sqrt_2_spec1 :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_sqrt_2 i) = (infix_sldt tone (square_rt (i_to_t (power 2%Z i))))).
Axiom pow_inv_sqrt_2_add :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((pow_inv_sqrt_2 (i + j)%Z) =
(infix_asdt (pow_inv_sqrt_2 i) (pow_inv_sqrt_2 j))).
Parameter pow_inv_2: Z -> t.
Axiom pow_inv_2_def :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_2 i) = (infix_sldt tone (i_to_t (power 2%Z i)))).
Axiom pow_inv_2_spec : forall (i:Z), (0%Z <= i)%Z -> real_ (pow_inv_2 i).
Axiom pow_inv_2_spec1 :
forall (i:Z), (0%Z <= i)%Z -> infix_gtdt (pow_inv_2 i) tzero.
Axiom pow_inv_2_spec2 :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_2 i) = (pow_inv_sqrt_2 (2%Z * i)%Z)).
Axiom pow_inv_2_spec3 :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_2 i) = (infix_asdt (pow_inv_sqrt_2 i) (pow_inv_sqrt_2 i))).
Axiom pow_inv_2_scal :
forall (i:Z) (x:matrix t), (0%Z <= i)%Z ->
((infix_asdtdt (pow_inv_2 i) x) =
(infix_asdtdt (pow_inv_sqrt_2 i) (infix_asdtdt (pow_inv_sqrt_2 i) x))).
Axiom pow_inv_2_from_int :
forall (n:Z), (0%Z <= n)%Z ->
((pow_inv_2 n) = (infix_sldt tone (i_to_t (power 2%Z n)))).
Axiom pow_inv_2_add :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((pow_inv_2 (i + j)%Z) = (infix_asdt (pow_inv_2 i) (pow_inv_2 j))).
Axiom pow_inv_2_with_ :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_2 i) = (infix_sldt tone (i_to_t (power_ 2%Z i)))).
Axiom pow_inv_2_to_one :
forall (i:Z), (0%Z <= i)%Z ->
((infix_asdt (i_to_t (power_ 2%Z i)) (pow_inv_2 i)) = tone).
Axiom pow_inv_2_one :
forall (i:Z), (i = 1%Z) ->
((i_to_t (power_ 2%Z i)) = (infix_sldt tone ttwo)).
Axiom pow_inv_2_to_one_gen :
forall (i:Z) (x:t), (0%Z <= i)%Z -> (x = (i_to_t (power_ 2%Z i))) ->
((infix_asdt (pow_inv_2 i) x) = tone).
Axiom pow_inv_to_pow_2 :
forall (k:Z) (l:Z), (0%Z <= l)%Z -> (k >= l)%Z ->
((infix_asdt (pow_inv_2 k) (i_to_t (power_ 2%Z l))) =
(pow_inv_2 (k - l)%Z)).
Parameter neg_pow_inv_sqrt_2: Z -> t.
Axiom neg_pow_inv_sqrt_2_def :
forall (i:Z), (0%Z <= i)%Z ->
((neg_pow_inv_sqrt_2 i) = (cpower neg_coeff i)).
Axiom inv_pow_inv_sqrt_2 :
((infix_asdt (pow_inv_sqrt_2 1%Z) squarert_two) = tone).
Axiom pow_inv_sqrt_2_values :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_sqrt_2 i) = (infix_sldt tone (cpower squarert_two i))).
Axiom neg_pow_inv_sqrt_2_values :
forall (i:Z), (0%Z <= i)%Z ->
((neg_pow_inv_sqrt_2 i) =
(infix_asdt (mop i) (infix_sldt tone (cpower squarert_two i)))).
Axiom ppos_neg_coeff_values :
forall (i:Z), (0%Z <= i)%Z -> ((even i) = true) ->
((pow_inv_sqrt_2 i) = (neg_pow_inv_sqrt_2 i)).
Axiom ppos_neg_coeff_values1 :
forall (i:Z), (0%Z <= i)%Z -> ((odd i) = true) ->
((pow_inv_sqrt_2 i) = (prefix_mndt (neg_pow_inv_sqrt_2 i))).
Axiom ppos_neg_coeff_values2 :
forall (i:Z), (0%Z <= i)%Z ->
((neg_pow_inv_sqrt_2 i) = (infix_asdt (mop i) (pow_inv_sqrt_2 i))).
Parameter pow_inv_sqrt_2_neg: Z -> t.
Axiom pow_inv_sqrt_2_neg_def :
forall (i:Z), (0%Z <= i)%Z ->
((pow_inv_sqrt_2_neg i) = (prefix_mndt (pow_inv_sqrt_2 i))).
Parameter min_set: (set Z) -> Z.
Axiom min_set_def :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> ((cardinal s) = 1%Z) ->
((min_set s) = (choose s)).
Axiom min_set_def1 :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> ~ ((cardinal s) = 1%Z) ->
((min_set s) =
(ZArith.BinInt.Z.min (choose s) (min_set (remove (choose s) s)))).
Axiom min_set_spec :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> mem (min_set s) s.
Axiom min_set_spec1 :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> forall (e1:Z), (mem e1 s) ->
(e1 >= (min_set s))%Z.
Parameter max_set: (set Z) -> Z.
Axiom max_set_def :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> ((cardinal s) = 1%Z) ->
((max_set s) = (choose s)).
Axiom max_set_def1 :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> ~ ((cardinal s) = 1%Z) ->
((max_set s) =
(ZArith.BinInt.Z.max (choose s) (max_set (remove (choose s) s)))).
Axiom max_set_spec :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> mem (max_set s) s.
Axiom max_set_spec1 :
forall (s:set Z), ((cardinal s) > 0%Z)%Z -> forall (e1:Z), (mem e1 s) ->
(e1 <= (max_set s))%Z.
Parameter max3: Z -> Z -> Z -> Z.
Axiom max3_def :
forall (a:Z) (b:Z) (c:Z),
((max3 a b c) = (ZArith.BinInt.Z.max (ZArith.BinInt.Z.max a b) c)).
Axiom max3_spec :
forall (a:Z) (b:Z) (c:Z),
((max3 a b c) = (ZArith.BinInt.Z.max a (ZArith.BinInt.Z.max b c))).
Parameter min_filter: (set Z) -> (Z -> bool) -> Z.
Axiom min_filter_def :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> ((p (min_set s)) = true) ->
((min_filter s p) = (min_set s)).
Axiom min_filter_def1 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) ->
~ ((p (min_set s)) = true) ->
((min_filter s p) = (min_filter (remove (choose s) s) p)).
Axiom min_filter_spec :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) ->
((p (min_filter s p)) = true).
Axiom min_filter_spec1 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> mem (min_filter s p) s.
Axiom min_filter_spec2 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> forall (e1:Z),
(mem e1 s) -> ((p e1) = true) -> (e1 >= (min_filter s p))%Z.
Parameter max_filter: (set Z) -> (Z -> bool) -> Z.
Axiom max_filter_def :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> ((p (max_set s)) = true) ->
((max_filter s p) = (max_set s)).
Axiom max_filter_def1 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) ->
~ ((p (max_set s)) = true) ->
((max_filter s p) = (max_filter (remove (choose s) s) p)).
Axiom max_filter_spec :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) ->
((p (max_filter s p)) = true).
Axiom max_filter_spec1 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> mem (max_filter s p) s.
Axiom max_filter_spec2 :
forall (s:set Z) (p:Z -> bool),
(exists e1:Z, (mem e1 s) /\ ((p e1) = true)) -> forall (e1:Z),
(mem e1 s) -> ((p e1) = true) -> (e1 <= (max_filter s p))%Z.
Axiom appr :
forall (theta:t) (n:Z), (0%Z < n)%Z -> (real_ theta) ->
((infix_lseqdt tzero theta) /\ (infix_lsdt theta tone)) ->
exists k:Z,
(mem k (to_fset 0%Z (n + 1%Z)%Z)) /\
(infix_lseqdt
(modulus (infix_mndt theta (infix_sldt (i_to_t k) (i_to_t n))))
(infix_sldt tone (i_to_t (n * 2%Z)%Z))).
Parameter max_dyadic: Z -> t -> Z.
Parameter result12: Z -> t -> Z -> bool.
Axiom result_def12 :
forall (n:Z) (p:t) (x:Z),
(((result12 n p) x) = true) <->
(infix_lseqdt (infix_asdt (i_to_t x) (pow_inv_2 n)) p).
Axiom max_dyadic_def :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
((max_dyadic n p) =
(max_filter (to_fset 0%Z (power_ 2%Z n)) (result12 n p))).
Axiom max_dyadic_spec :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
(0%Z <= (max_dyadic n p))%Z.
Axiom max_dyadic_spec1 :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
((max_dyadic n p) < (power_ 2%Z n))%Z.
Axiom max_dyadic_spec2 :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
infix_lseqdt (infix_asdt (i_to_t (max_dyadic n p)) (pow_inv_2 n)) p.
Axiom max_dyadic_spec3 :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
infix_gteqdt (infix_asdt (i_to_t ((max_dyadic n p) + 1%Z)%Z) (pow_inv_2 n))
p.
Axiom max_dyadic_spec4 :
forall (n:Z) (p:t), ((infix_lseqdt tzero p) /\ (infix_lsdt p tone)) ->
forall (i:Z), ((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
(infix_lseqdt (infix_asdt (i_to_t i) (pow_inv_2 n)) p) ->
(i <= (max_dyadic n p))%Z.
Axiom rewrite_ang_sum_sum_to_bv_and_inversion_gen :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec) (y:bitvec),
((length x) = n) -> ((length y) = n) ->
((ang_sum
(fun (j:Z) =>
(ang_sum
(fun (i:Z) =>
(int_to_ang
(((-((getbv x) i))%Z * ((getbv y) j))%Z *
(power_ 2%Z (((n - i)%Z - 1%Z)%Z + j)%Z))%Z
n))
j n))
0%Z n)
=
(real_to_ang
(infix_asdt
(infix_asdt (i_to_t (-(bv_to_int x))%Z)
(i_to_t (bv_to_int (bv_inversion y))))
(pow_inv_2 n)))).
Parameter ang_substr: angle -> angle -> angle.
Axiom ang_substr_def :
forall (o:angle) (o':angle), ((ang_substr o o') = (ang_add o (ang_inv o'))).
Axiom ang_substr_inv :
forall (o:angle) (o':angle),
((ang_substr o (ang_mult_int o' (-1%Z)%Z)) = (ang_add o o')).
Axiom ang_mult_int_distr :
forall (o:angle) (o':angle) (n:Z),
((ang_mult_int (ang_add o o') n) =
(ang_add (ang_mult_int o n) (ang_mult_int o' n))).
Axiom ang_mult_int_distr_rev :
forall (o:angle) (o':angle) (n1:Z) (n2:Z),
((ang_add (ang_mult_int o n1) (ang_mult_int o' n2)) =
(ang_mult_int o (n1 + n2)%Z)).
Axiom ang_add_assoc :
forall (o:angle) (o':angle) (o'':angle),
((ang_add o (ang_add o' o'')) = (ang_add (ang_add o o') o'')).
Axiom ang_add_assoc_rev :
forall (o:angle) (o':angle) (o'':angle),
((ang_add (ang_add o o') o'') = (ang_add o (ang_add o' o''))).
Axiom ang_add_own_inv :
forall (o:angle), ((ang_add (ang_mult_int o (-1%Z)%Z) o) = ang_zero).
Parameter concat: bitvec -> bitvec -> bitvec.
Parameter result13: bitvec -> bitvec -> Z -> Z.
Axiom result_def13 :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
((((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
(((result13 bv1 bv2) i) = ((getbv bv2) (i - (length bv1))%Z))) /\
(~ (((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
(((result13 bv1 bv2) i) = ((getbv bv1) i))).
Axiom concat_def :
forall (bv1:bitvec) (bv2:bitvec),
((concat bv1 bv2) =
(make_bv (result13 bv1 bv2) ((length bv1) + (length bv2))%Z)).
Axiom concat_spec :
forall (bv1:bitvec) (bv2:bitvec),
((length (concat bv1 bv2)) = ((length bv1) + (length bv2))%Z).
Axiom concat_spec1 :
forall (bv1:bitvec) (bv2:bitvec), forall (i:Z),
((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv1) i)).
Axiom concat_spec2 :
forall (bv1:bitvec) (bv2:bitvec), forall (i:Z),
((length (concat bv1 bv2)) <= i)%Z ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv1) i)).
Axiom concat_spec3 :
forall (bv1:bitvec) (bv2:bitvec), forall (i:Z),
(((length bv1) <= i)%Z /\ (i < (length (concat bv1 bv2)))%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv2) (i - (length bv1))%Z)).
Axiom concat_length :
forall (bv1:bitvec) (bv2:bitvec),
((length (concat bv1 bv2)) = ((length bv1) + (length bv2))%Z).
Parameter hpart: bitvec -> Z -> bitvec.
Axiom hpart_def :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z ->
((hpart bv m) = (make_bv (getbv bv) m)).
Axiom hpart_spec :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ((length (hpart bv m)) = m).
Axiom hpart_spec1 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ((length bv) = m) ->
((hpart bv m) = bv).
Axiom hpart_spec2 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> forall (k:Z),
((0%Z <= k)%Z /\ (k < m)%Z) -> (((getbv (hpart bv m)) k) = ((getbv bv) k)).
Axiom hpart_spec3 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> forall (k:Z), ~ (0%Z <= k)%Z ->
(((getbv (hpart bv m)) k) = 0%Z).
Axiom hpart_spec4 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> forall (k:Z), ~ (k < m)%Z ->
(((getbv (hpart bv m)) k) = 0%Z).
Axiom hpart_value :
forall (bv:bitvec) (m:Z) (i:Z), (0%Z <= m)%Z ->
(((0%Z <= i)%Z /\ (i < m)%Z) ->
(((getbv (hpart bv m)) i) = ((getbv bv) i))) /\
(~ ((0%Z <= i)%Z /\ (i < m)%Z) -> (((getbv (hpart bv m)) i) = 0%Z)).
Axiom hpart_value_b :
forall (bv:bitvec) (m:Z) (i:Z), ((0%Z <= i)%Z /\ (i < m)%Z) ->
(((getbv (hpart bv m)) i) = ((getbv bv) i)).
Parameter tpart: bitvec -> Z -> bitvec.
Axiom tpart_def :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ((length bv) >= m)%Z ->
((tpart bv m) =
(make_bv (fun (k:Z) => ((getbv bv) (k + m)%Z)) ((length bv) - m)%Z)).
Axiom tpart_def1 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ~ ((length bv) >= m)%Z ->
((tpart bv m) = (make_bv (fun (k:Z) => ((getbv bv) (k + m)%Z)) 0%Z)).
Axiom tpart_spec :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ((length bv) >= m)%Z ->
((length (tpart bv m)) = ((length bv) - m)%Z).
Axiom tpart_spec1 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> ((length bv) < m)%Z ->
((length (tpart bv m)) = 0%Z).
Axiom tpart_spec2 :
forall (bv:bitvec) (m:Z), (0%Z <= m)%Z -> forall (k:Z),
((0%Z <= k)%Z /\ (k < (length (tpart bv m)))%Z) ->
(((getbv (tpart bv m)) k) = ((getbv bv) (k + m)%Z)).
Parameter htpart: bitvec -> Z -> Z -> bitvec.
Axiom htpart_def :
forall (bv:bitvec) (k:Z) (n:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
((htpart bv k n) = (make_bv (fun (i:Z) => ((getbv bv) (k + i)%Z)) n)).
Axiom htpart_spec :
forall (bv:bitvec) (k:Z) (n:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
((length (htpart bv k n)) = n).
Axiom htpart_spec1 :
forall (bv:bitvec) (k:Z) (n:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) ->
(((getbv (htpart bv k n)) i) = ((getbv bv) (k + i)%Z)).
Axiom tpart_value :
forall (bv:bitvec) (m:Z) (i:Z), (0%Z <= m)%Z ->
(((0%Z <= i)%Z /\ (i < ((length bv) - m)%Z)%Z) ->
(((getbv (tpart bv m)) i) = ((getbv bv) (i + m)%Z))) /\
(~ ((0%Z <= i)%Z /\ (i < ((length bv) - m)%Z)%Z) ->
(((getbv (tpart bv m)) i) = 0%Z)).
Axiom tpart_value_b :
forall (bv:bitvec) (m:Z) (i:Z), (0%Z <= m)%Z ->
((0%Z <= i)%Z /\ (i < ((length bv) - m)%Z)%Z) ->
(((getbv (tpart bv m)) i) = ((getbv bv) (i + m)%Z)).
Axiom tpart_length :
forall (bv:bitvec) (m:Z), ((0%Z <= m)%Z /\ (m <= (length bv))%Z) ->
((length (tpart bv m)) = ((length bv) - m)%Z).
Axiom htpart_value :
forall (bv:bitvec) (k:Z) (n:Z) (i:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
(((0%Z <= i)%Z /\ (i < n)%Z) ->
(((getbv (htpart bv k n)) i) = ((getbv bv) (k + i)%Z))) /\
(~ ((0%Z <= i)%Z /\ (i < n)%Z) -> (((getbv (htpart bv k n)) i) = 0%Z)).
Axiom htpart_value_b :
forall (bv:bitvec) (k:Z) (n:Z) (i:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < n)%Z) ->
(((getbv (htpart bv k n)) i) = ((getbv bv) (k + i)%Z)).
Axiom htpart_length :
forall (bv:bitvec) (k:Z) (n:Z), (0%Z <= k)%Z -> (0%Z <= n)%Z ->
((length (htpart bv k n)) = n).
Axiom tpart_length_gen :
forall (bv:bitvec) (m:Z) (l:Z), ((0%Z <= m)%Z /\ (m <= (length bv))%Z) ->
(l = ((length bv) - m)%Z) -> ((length (tpart bv m)) = l).
Axiom concat_value_left :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv1) i)).
Axiom concat_value :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
((((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv2) (i - (length bv1))%Z))) /\
(~ (((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
(((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv1) i))) /\
(~ ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv (concat bv1 bv2)) i) = 0%Z))).
Axiom concat_value_right :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
(((length bv1) <= i)%Z /\ (i < ((length bv1) + (length bv2))%Z)%Z) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv2) (i - (length bv1))%Z)).
Axiom concat_value_out :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
(((length bv1) + (length bv2))%Z < i)%Z ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv1) i)).
Axiom concat_value_tpart :
forall (bv1:bitvec) (bv2:bitvec) (i:Z),
(((length bv1) <= i)%Z /\ (i < (length bv2))%Z) ->
(((getbv (concat bv1 (tpart bv2 (length bv1)))) i) = ((getbv bv2) i)).
Axiom concat_value_ht :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) -> ~ (0%Z <= i)%Z ->
~ ((length bv1) <= i)%Z -> (bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_value_ht1 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) -> ~ (0%Z <= i)%Z ->
(((getbv bv3) i) = ((getbv bv4) i)) -> (bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_value_ht2 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) -> ~ (i < (length bv1))%Z ->
~ ((length bv1) <= i)%Z -> (bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_value_ht3 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) -> ~ (i < (length bv1))%Z ->
(((getbv bv3) i) = ((getbv bv4) i)) -> (bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_value_ht4 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) ->
(((getbv bv1) i) = ((getbv bv4) i)) -> ~ ((length bv1) <= i)%Z ->
(bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_value_ht5 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec) (i:Z),
((0%Z <= i)%Z /\ (i < (length bv3))%Z) ->
(((getbv bv1) i) = ((getbv bv4) i)) ->
(((getbv bv3) i) = ((getbv bv4) i)) -> (bv2 = (tpart bv3 (length bv1))) ->
(((getbv (concat bv1 bv2)) i) = ((getbv bv4) i)).
Axiom concat_ht1 :
forall (bv1:bitvec) (bv2:bitvec) (bv3:bitvec) (bv4:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv bv1) i) = ((getbv bv4) i))) ->
(forall (i:Z), ((length bv1) <= i)%Z ->
(((getbv bv3) i) = ((getbv bv4) i))) ->
((length bv4) = ((length bv1) + (length bv2))%Z) ->
((length bv3) >= ((length bv1) + (length bv2))%Z)%Z ->
(bv2 = (tpart bv3 (length bv1))) -> ((concat bv1 bv2) = bv4).
Axiom set_concat :
forall (bv1:bitvec) (bv2:bitvec) (bv4:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv bv1) i) = ((getbv bv4) i))) ->
(forall (i:Z), ((length bv1) <= i)%Z ->
(((getbv bv2) (i - (length bv1))%Z) = ((getbv bv4) i))) ->
((length bv4) = ((length bv1) + (length bv2))%Z) ->
((concat bv1 bv2) = bv4).
Axiom concat_m :
forall (bv1:bitvec) (bv2:bitvec) (i1:Z) (i2:Z), (i1 > 0%Z)%Z ->
(i2 > 0%Z)%Z -> ((length bv1) = i1) -> ((length bv2) = i2) ->
((concat (make_bv_m (getbv bv1) i1) (make_bv_m (getbv bv2) i2)) =
(make_bv_m (getbv (concat bv1 bv2)) (i1 + i2)%Z)).
Axiom concat_comm :
forall (bv1:bitvec) (bv2:bitvec),
((hpart (concat bv1 bv2) (length bv1)) = bv1).
Axiom concat_comm1 :
forall (bv1:bitvec) (bv2:bitvec),
((tpart (concat bv1 bv2) (length bv1)) = bv2).
Axiom concat_and_rec :
forall (bv:bitvec) (i:Z), ((0%Z <= i)%Z /\ (i <= (length bv))%Z) ->
((concat (hpart bv i) (tpart bv i)) = bv).
Parameter concat_int_bv: bitvec -> Z -> Z -> bitvec.
Axiom concat_int_bv_def :
forall (bv:bitvec) (i:Z) (n:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((concat_int_bv bv i n) = (concat bv (int_to_bv i n))).
Axiom concat_int_to_bv_value :
forall (bv:bitvec) (i:Z) (n:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (length (concat_int_bv bv i n)))%Z) ->
(j < (length bv))%Z ->
(((getbv (concat_int_bv bv i n)) j) = ((getbv bv) j)).
Axiom bv_to_int_concat :
forall (bvx:bitvec) (bvy:bitvec),
((bv_to_int (concat bvx bvy)) =
(((power 2%Z (length bvy)) * (bv_to_int bvx))%Z + (bv_to_int bvy))%Z).
Axiom concat_fin :
forall (f1:Z -> Z) (f2:Z -> Z) (l1:Z) (l2:Z), (l1 >= 0%Z)%Z ->
(l2 >= 0%Z)%Z -> (binary f1) -> (binary f2) ->
((make_bv
((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
(concat_fun y0 y1 y2 y3))
f1)
f2)
l1)
(l1 + l2)%Z)
= (concat (make_bv f1 l1) (make_bv f2 l2))).
Axiom bin_to_int_concat :
forall (f1:Z -> Z) (f2:Z -> Z) (l1:Z) (l2:Z), (l1 >= 0%Z)%Z ->
(l2 >= 0%Z)%Z -> (binary f1) -> (binary f2) ->
((bin_to_int
((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
(concat_fun y0 y1 y2 y3))
f1)
f2)
l1)
(l1 + l2)%Z)
= (((power 2%Z l2) * (bin_to_int f1 l1))%Z + (bin_to_int f2 l2))%Z).
Axiom bijective_concat :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
p_bijective (fun (o:(bitvec* bitvec)%type) => (concat (fir o) (sec o)))
(cartesian_product (n_bvs i) (n_bvs j)) (n_bvs (i + j)%Z).
Axiom bijective_concat1 :
forall (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
p_bijective (fun (x:bitvec) => (hpart x i, tpart x i)) (n_bvs (i + j)%Z)
(cartesian_product (n_bvs i) (n_bvs j)).
Axiom bv_to_int_hpart :
forall (bv:bitvec) (l:Z), ((0%Z <= l)%Z /\ (l <= (length bv))%Z) ->
((bv_to_int (hpart bv l)) =
(int.EuclideanDivision.div (bv_to_int bv) (power 2%Z ((length bv) - l)%Z))).
Axiom bv_to_int_tpart :
forall (bv:bitvec) (l:Z), ((0%Z <= l)%Z /\ (l <= (length bv))%Z) ->
((bv_to_int (tpart bv l)) =
(int.EuclideanDivision.mod1 (bv_to_int bv)
(power 2%Z ((length bv) - l)%Z))).
Parameter is_a_ket: (matrix t) -> Prop.
Axiom Is_a_ket : forall (m:matrix t), (is_a_ket m) -> ((columns m) = 1%Z).
Axiom Is_a_ket1 :
forall (m:matrix t), (is_a_ket m) ->
exists s:Z, (s >= 0%Z)%Z /\ ((rows m) = (power 2%Z s)).
Axiom Is_a_ket2 :
forall (m:matrix t),
(((columns m) = 1%Z) /\
exists s:Z, (s >= 0%Z)%Z /\ ((rows m) = (power 2%Z s))) ->
is_a_ket m.
Parameter xor_i: Z -> Z -> Z.
Axiom xor_i_def :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> (i = 0%Z) -> ((xor_i i i') = i').
Axiom xor_i_def1 :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> ~ (i = 0%Z) ->
((xor_i i i') = (1%Z - i')%Z).
Axiom xor_i_spec :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> (i = 0%Z) -> (i' = 0%Z) ->
((xor_i i i') = 0%Z).
Axiom xor_i_spec1 :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> (i = 0%Z) -> (i' = 1%Z) ->
((xor_i i i') = 1%Z).
Axiom xor_i_spec2 :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> (i = 1%Z) -> (i' = 0%Z) ->
((xor_i i i') = 1%Z).
Axiom xor_i_spec3 :
forall (i:Z) (i':Z), ((0%Z <= i)%Z /\ (i < 2%Z)%Z) ->
((0%Z <= i')%Z /\ (i' < 2%Z)%Z) -> (i = 1%Z) -> (i' = 1%Z) ->
((xor_i i i') = 0%Z).
Parameter is_a_ket_l: (matrix t) -> Z -> Prop.
Axiom is_a_ket_l_def :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> (l >= 0%Z)%Z.
Axiom is_a_ket_l_def1 :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> ((columns m) = 1%Z).
Axiom is_a_ket_l_def2 :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> ((rows m) = (power 2%Z l)).
Axiom is_a_ket_l_def3 :
forall (m:matrix t) (l:Z),
((l >= 0%Z)%Z /\ (((columns m) = 1%Z) /\ ((rows m) = (power 2%Z l)))) ->
is_a_ket_l m l.
Axiom ket_l_rows :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> ((rows m) = (power 2%Z l)).
Axiom ket_l_columns :
forall (m:matrix t), (exists l:Z, is_a_ket_l m l) -> ((columns m) = 1%Z).
Parameter ket_valid_index: (matrix t) -> Z -> Prop.
Axiom ket_valid_index_def :
forall (m:matrix t) (i:Z), (ket_valid_index m i) -> valid_index m i 0%Z.
Axiom ket_valid_index_def1 :
forall (m:matrix t) (i:Z), (valid_index m i 0%Z) -> ket_valid_index m i.
Parameter ket_length: (matrix t) -> Z.
Axiom ket_length_def :
forall (m:matrix t), (is_a_ket m) ->
((ket_length m) = ((binary_length (rows m)) - 1%Z)%Z).
Axiom ket_length_spec :
forall (m:matrix t), (is_a_ket m) -> (0%Z <= (ket_length m))%Z.
Axiom ket_length_spec1 :
forall (m:matrix t), (is_a_ket m) ->
((rows m) = (power 2%Z (ket_length m))).
Parameter get_ket: (matrix t) -> Z -> t.
Axiom get_ket_def :
forall (m:matrix t) (i:Z), ((get_ket m i) = (get m i 0%Z)).
Parameter get_ket_bv: (matrix t) -> bitvec -> t.
Axiom get_ket_bv_def :
forall (x:matrix t) (bv:bitvec), (is_a_ket_l x (length bv)) ->
((get_ket_bv x bv) = (get_ket x (bv_to_int bv))).
Axiom assert_make_ket :
forall (r:Z) (c:Z) (f:Z -> Z -> t) (i:Z), (c = 1%Z) ->
((0%Z <= i)%Z /\ (i < r)%Z) -> ((get_ket (make_f r c f) i) = ((f i) 0%Z)).
Axiom mat_mult_ket_l :
forall (m:matrix t) (k:matrix t) (n:Z), (is_a_ket_l k n) ->
((rows m) = (power 2%Z n)) -> ((columns m) = (power 2%Z n)) ->
is_a_ket_l (mat_mult m k) n.
Axiom ket_kronecker_values :
forall (m:matrix t) (n:matrix t) (i:Z), (is_a_ket m) -> (is_a_ket n) ->
((0%Z <= i)%Z /\ (i < ((rows m) * (rows n))%Z)%Z) ->
((get_ket (kronecker m n) i) =
(infix_asdt (get_ket m (int.EuclideanDivision.div i (rows n)))
(get_ket n (int.EuclideanDivision.mod1 i (rows n))))).
Axiom ket_l_to_ket :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> is_a_ket m.
Axiom ket_l_to_ket1 :
forall (m:matrix t) (l:Z), (is_a_ket_l m l) -> ((ket_length m) = l).
Axiom ket_l_to_ket_gen :
forall (m:matrix t), (exists l:Z, is_a_ket_l m l) -> is_a_ket m.
Axiom ket_to_ket_l :
forall (m:matrix t), (is_a_ket m) -> is_a_ket_l m (ket_length m).
Axiom set_ket_valid_index :
forall (m:matrix t) (i:Z), (is_a_ket m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) -> ket_valid_index m i.
Axiom ket_to_ket_l_l :
forall (m:matrix t) (i:Z), (is_a_ket m) -> ((ket_length m) = i) ->
is_a_ket_l m i.
Axiom set_constant_size_ket :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t),
(forall (e1:a), (mem e1 s) -> is_a_ket (f e1)) ->
(forall (e1:a) (e':a), (mem e1 s) -> (mem e' s) ->
((ket_length (f e1)) = (ket_length (f e')))) ->
constant_size s f.
Parameter ket_norm_l: (matrix t) -> Z -> t.
Axiom ket_norm_l_def :
forall (x:matrix t) (n:Z), (is_a_ket_l x n) ->
((ket_norm_l x n) =
(sum (to_fset 0%Z (power 2%Z n))
(fun (k:Z) =>
(infix_asdt (modulus (get x k 0%Z)) (modulus (get x k 0%Z)))))).
Parameter add_ket: (matrix t) -> (matrix t) -> matrix t.
Axiom add_ket_def :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length m) = (ket_length n)) -> ((add_ket m n) = (add_mat m n)).
Axiom add_ket_spec :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length m) = (ket_length n)) -> is_a_ket (add_ket m n).
Axiom add_ket_spec1 :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length m) = (ket_length n)) ->
((ket_length (add_ket m n)) = (ket_length m)).
Axiom add_ket_spec2 :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length m) = (ket_length n)) -> forall (i:Z),
(ket_valid_index (add_ket m n) i) ->
((get_ket (add_ket m n) i) = (infix_pldt (get_ket m i) (get_ket n i))).
Parameter add_ket_l: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom add_ket_l_def :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
(is_a_ket_l n l) -> ((add_ket_l m n l) = (add_ket m n)).
Axiom add_ket_l_spec :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
(is_a_ket_l n l) -> is_a_ket_l (add_ket_l m n l) l.
Axiom add_ket_l_spec1 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
(is_a_ket_l n l) -> ((ket_length (add_ket_l m n l)) = l).
Axiom add_ket_l_spec2 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ket_l m l) ->
(is_a_ket_l n l) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length (add_ket_l m n l))))%Z) ->
((get_ket (add_ket_l m n l) i) = (infix_pldt (get_ket m i) (get_ket n i))).
Parameter add_ket_l_eq:
(matrix t) -> (matrix t) -> (matrix t) -> (matrix t) -> Z -> unit.
Axiom add_ket_l_eq_def :
forall (m:matrix t) (m':matrix t) (n:matrix t) (n':matrix t) (l:Z),
(is_a_ket_l m l) -> (is_a_ket_l n l) -> (m = m') -> (n = n') ->
((add_ket_l_eq m m' n n' l) = tt).
Axiom add_ket_l_eq_spec :
forall (m:matrix t) (m':matrix t) (n:matrix t) (n':matrix t) (l:Z),
(is_a_ket_l m l) -> (is_a_ket_l n l) -> (m = m') -> (n = n') ->
((((fun (y0:matrix t) (y1:matrix t) (y2:Z) => (add_ket_l y0 y1 y2)) m) n) =
(((fun (y0:matrix t) (y1:matrix t) (y2:Z) => (add_ket_l y0 y1 y2)) m') n')).
Axiom add_ket_l_value :
forall (m:matrix t) (n:matrix t) (l:Z) (i:Z), (is_a_ket_l m l) ->
(is_a_ket_l n l) -> ((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((get_ket (add_ket_l m n l) i) = (infix_pldt (get_ket m i) (get_ket n i))).
Axiom set_equal_ket :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length m) = (ket_length n)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_ket m i) = (get_ket n i))) ->
(m = n).
Axiom set_equal_ket_l :
forall (m:matrix t) (n:matrix t),
(exists l:Z, (is_a_ket_l m l) /\ (is_a_ket_l n l)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_ket m i) = (get_ket n i))) ->
(m = n).
Axiom get_ket_length :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((rows m) = (power 2%Z n)) -> ((ket_length m) = n).
Axiom set_ket_length :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((ket_length m) = n) -> ((rows m) = (power 2%Z n)).
Axiom scalar_ket :
forall (x:matrix t) (a:t), (is_a_ket x) -> is_a_ket (infix_asdtdt a x).
Axiom scalar_ket_length :
forall (m:matrix t) (a:t), (is_a_ket m) ->
((ket_length (infix_asdtdt a m)) = (ket_length m)).
Axiom scalar_ket_valid_index :
forall (m:matrix t) (a:t) (i:Z), (ket_valid_index m i) -> (is_a_ket m) ->
ket_valid_index (infix_asdtdt a m) i.
Axiom scalar_ket_l :
forall (x:matrix t) (l:Z) (a:t), (is_a_ket_l x l) ->
is_a_ket_l (infix_asdtdt a x) l.
Axiom scalar_ket_value :
forall (x:matrix t) (i:Z) (a:t), (is_a_ket x) -> (ket_valid_index x i) ->
((get_ket (infix_asdtdt a x) i) = (infix_asdt a (get_ket x i))).
Axiom scalar_ket_value_rev :
forall (x:matrix t) (i:Z) (a:t), (is_a_ket x) -> (ket_valid_index x i) ->
((infix_asdt a (get_ket x i)) = (get_ket (infix_asdtdt a x) i)).
Axiom add_ket_is_a_ket :
forall (x:matrix t) (y:matrix t), (is_a_ket x) -> (is_a_ket y) ->
((ket_length x) = (ket_length y)) -> is_a_ket (add_mat x y).
Axiom set_ket_length_gen :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((power 2%Z (ket_length m)) = n) -> ((rows m) = n).
Axiom set_is_a_ket :
forall (m:matrix t), ((columns m) = 1%Z) ->
(exists s:Z, (s >= 0%Z)%Z /\ ((rows m) = (power 2%Z s))) -> is_a_ket m.
Axiom set_is_a_ket_l :
forall (m:matrix t) (l:Z), (l >= 0%Z)%Z -> ((columns m) = 1%Z) ->
((rows m) = (power 2%Z l)) -> is_a_ket_l m l.
Axiom set_is_a_ket_p :
forall (m:matrix t) (l:Z), (l >= 0%Z)%Z -> ((columns m) = 1%Z) ->
((rows m) = (power 2%Z l)) -> is_a_ket m.
Axiom get_is_a_ket :
forall (m:matrix t), (is_a_ket m) -> ((columns m) = 1%Z).
Axiom get_is_a_ket1 :
forall (m:matrix t), (is_a_ket m) ->
((rows m) = (power 2%Z (ket_length m))).
Axiom get_ket_columns :
forall (m:matrix t), (is_a_ket m) -> ((columns m) = 1%Z).
Axiom get_ket_rows :
forall (m:matrix t), (is_a_ket m) ->
((rows m) = (power 2%Z (ket_length m))).
Axiom get_ket_rows_gen :
forall (m:matrix t) (i:Z), (is_a_ket m) ->
(i = (power 2%Z (ket_length m))) -> ((rows m) = i).
Axiom get_ket_rows_length :
forall (m:matrix t) (l:Z), (is_a_ket m) -> ((ket_length m) = l) ->
((rows m) = (power 2%Z l)).
Axiom ket_kronecker :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
is_a_ket (kronecker m n).
Axiom ket_kronecker1 :
forall (m:matrix t) (n:matrix t), (is_a_ket m) -> (is_a_ket n) ->
((ket_length (kronecker m n)) = ((ket_length m) + (ket_length n))%Z).
Axiom ket_kronecker_l :
forall (m:matrix t) (n:matrix t) (l:Z) (l':Z), (is_a_ket_l m l) ->
(is_a_ket_l n l') -> is_a_ket_l (kronecker m n) (l + l')%Z.
Axiom set_ket_kron_l :
forall (m:matrix t) (n:matrix t) (l:Z) (l':Z) (l'':Z), (is_a_ket_l m l) ->
(is_a_ket_l n l') -> (l'' = (l + l')%Z) -> is_a_ket_l (kronecker m n) l''.
Parameter ket: Z -> Z -> matrix t.
Axiom ket_def :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((ket n i) = (set1 (make (power 2%Z n) 1%Z tzero) i 0%Z tone)).
Axiom ket_def1 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ~ (0%Z <= i)%Z ->
((ket n i) = (make (power 2%Z n) 1%Z tzero)).
Axiom ket_def2 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ~ (i < (power 2%Z n))%Z ->
((ket n i) = (make (power 2%Z n) 1%Z tzero)).
Axiom ket_spec : forall (n:Z) (i:Z), (0%Z <= n)%Z -> is_a_ket (ket n i).
Axiom ket_spec1 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((ket_length (ket n i)) = n).
Axiom ket_spec2 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((columns (ket n i)) = 1%Z).
Axiom ket_spec3 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((rows (ket n i)) = (power 2%Z n)).
Axiom ket_spec4 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
(valid_index (ket n i) j 0%Z) -> ((get (ket n i) j 0%Z) = (indic j i)).
Axiom ket_spec5 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> forall (j:Z),
(valid_index (ket n i) j 0%Z) -> ~ (i = j) ->
((get (ket n i) j 0%Z) = tzero).
Axiom ket_spec6 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((get (ket n i) i 0%Z) = tone).
Parameter make_ket: Z -> (Z -> t) -> matrix t.
Axiom make_ket_def :
forall (n:Z) (f:Z -> t), (n >= 0%Z)%Z ->
((make_ket n f) = (make_f (power 2%Z n) 1%Z (fun (x:Z) (us:Z) => (f x)))).
Axiom make_ket_spec :
forall (n:Z) (f:Z -> t), (n >= 0%Z)%Z -> is_a_ket_l (make_ket n f) n.
Axiom make_ket_spec1 :
forall (n:Z) (f:Z -> t), (n >= 0%Z)%Z -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((get_ket (make_ket n f) i) = (f i)).
Axiom make_ket_spec2 :
forall (n:Z) (f:Z -> t), (n >= 0%Z)%Z -> forall (i:Z) (j:Z),
(valid_index (make_ket n f) i j) -> ((get (make_ket n f) i j) = (f i)).
Axiom ket_l :
forall (n:Z) (m:Z) (i:Z), (0%Z <= n)%Z -> (n = m) -> is_a_ket_l (ket n i) m.
Axiom ket_eq :
forall (n1:Z) (n2:Z) (i1:Z) (i2:Z), (0%Z <= n1)%Z -> (n1 = n2) ->
(i1 = i2) -> ((ket n1 i1) = (ket n2 i2)).
Axiom ket_rows :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((rows (ket n i)) = (power 2%Z n)).
Axiom ket_columns :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((columns (ket n i)) = 1%Z).
Axiom ket_value :
forall (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((i = j) -> ((get (ket n i) j 0%Z) = tone)) /\
(~ (i = j) -> ((get (ket n i) j 0%Z) = tzero)).
Axiom norm_ket_basis :
forall (n:Z) (i:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((ket_norm_l (ket n i) n) = tone).
Axiom get_ket_ :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_ket m.
Axiom get_ket_1 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((ket_length m) = n).
Axiom get_ket_2 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((columns m) = 1%Z).
Axiom get_ket_3 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((rows m) = (power 2%Z n)).
Axiom get_ket_4 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
(valid_index m j 0%Z) -> ((get m j 0%Z) = (indic j i)).
Axiom get_ket_5 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
(valid_index m j 0%Z) -> ~ (i = j) -> ((get m j 0%Z) = tzero).
Axiom get_ket_6 :
forall (m:matrix t) (i:Z) (n:Z), (m = (ket n i)) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((get m i 0%Z) = tone).
Axiom get_ket_value :
forall (i:Z) (n:Z) (j:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((get (ket n i) j 0%Z) = (indic j i)).
Axiom get_ket_values :
forall (i:Z) (n:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((get (ket n i) j 0%Z) = (indic j i)).
Axiom get_ket_value_z :
forall (i:Z) (n:Z) (j:Z) (z:Z), (z = 0%Z) -> (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((get (ket n i) j z) = (indic j i)).
Axiom get__ket_value :
forall (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((get_ket (ket n i) j) = (indic j i)).
Axiom set_ket :
forall (m:matrix t) (i:Z) (n:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((columns m) = 1%Z) ->
((rows m) = (power 2%Z n)) ->
(forall (j:Z), (valid_index m j 0%Z) -> ((get m j 0%Z) = (indic j i))) ->
(m = (ket n i)).
Axiom kronecker_kets :
forall (i1:Z) (i2:Z) (n1:Z) (n2:Z), (0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
((0%Z <= i1)%Z /\ (i1 < (power 2%Z n1))%Z) ->
((0%Z <= i2)%Z /\ (i2 < (power 2%Z n2))%Z) ->
((kronecker (ket n1 i1) (ket n2 i2)) =
(ket (n1 + n2)%Z ((i1 * (power 2%Z n2))%Z + i2)%Z)).
Axiom kronecker_kets_bin_to_int :
forall (f1:Z -> Z) (f2:Z -> Z) (n1:Z) (n2:Z), (binary f1) -> (binary f2) ->
(0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
((kronecker (ket n1 (bin_to_int f1 n1)) (ket n2 (bin_to_int f2 n2))) =
(ket (n1 + n2)%Z
(((bin_to_int f1 n1) * (power 2%Z n2))%Z + (bin_to_int f2 n2))%Z)).
Parameter ind_basis_mat: Z -> Z -> Z -> Z -> matrix t.
Axiom ind_basis_mat_def :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) ->
((ind_basis_mat i j r c) =
(make_f r c (fun (k:Z) (l:Z) => (indic_2 k i l j)))).
Axiom ind_basis_mat_spec :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> ((rows (ind_basis_mat i j r c)) = r).
Axiom ind_basis_mat_spec1 :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> ((columns (ind_basis_mat i j r c)) = c).
Axiom ind_basis_mat_spec2 :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> forall (k:Z) (l:Z),
(valid_index (ind_basis_mat i j r c) k l) ->
((get (ind_basis_mat i j r c) k l) = (indic_2 k i l j)).
Axiom ind_basis_mat_spec3 :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> forall (o:(Z* Z)%type),
(mem o (mat_indices (ind_basis_mat i j r c))) ->
((get (ind_basis_mat i j r c) (fir o) (sec o)) = tone) -> ((fir o) = i).
Axiom ind_basis_mat_spec4 :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> forall (o:(Z* Z)%type),
(mem o (mat_indices (ind_basis_mat i j r c))) ->
((get (ind_basis_mat i j r c) (fir o) (sec o)) = tone) -> ((sec o) = j).
Axiom ind_basis_mat_spec5 :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> forall (o:(Z* Z)%type),
(mem o (mat_indices (ind_basis_mat i j r c))) ->
(((fir o) = i) /\ ((sec o) = j)) ->
((get (ind_basis_mat i j r c) (fir o) (sec o)) = tone).
Axiom ind_basis_mat_values :
forall (i:Z) (j:Z) (r:Z) (c:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) -> forall (i1:Z) (j1:Z),
((0%Z <= i1)%Z /\ (i1 < r)%Z) -> ((0%Z <= j1)%Z /\ (j1 < c)%Z) ->
((get (ind_basis_mat i j r c) i1 j1) = (indic_2 i i1 j j1)).
Axiom unic_ind_basis_mat :
forall (i1:Z) (j1:Z) (i2:Z) (j2:Z) (r:Z) (c:Z),
((0%Z <= i1)%Z /\ (i1 < r)%Z) -> ((0%Z <= j1)%Z /\ (j1 < c)%Z) ->
((0%Z <= i2)%Z /\ (i2 < r)%Z) -> ((0%Z <= j2)%Z /\ (j2 < c)%Z) ->
((ind_basis_mat i1 j1 r c) = (ind_basis_mat i2 j2 r c)) ->
((i1, j1) = (i2, j2)).
Parameter basis_mat: Z -> Z -> set (matrix t).
Parameter result14: Z -> Z -> (Z* Z)%type -> matrix t.
Axiom result_def14 :
forall (r:Z) (c:Z) (o:(Z* Z)%type),
match o with
| (i, j) =>
((((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
(((result14 r c) o) = (ind_basis_mat i j r c))) /\
(~ (((0%Z <= i)%Z /\ (i < r)%Z) /\ ((0%Z <= j)%Z /\ (j < c)%Z)) ->
(((result14 r c) o) = (make r c tzero)))
end.
Axiom basis_mat_def :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
((basis_mat r c) =
(map (result14 r c) (cartesian_product (to_fset 0%Z r) (to_fset 0%Z c)))).
Axiom basis_mat_spec :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z -> forall (m:matrix t),
(mem m (basis_mat r c)) ->
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < r)%Z) /\
(((0%Z <= j)%Z /\ (j < c)%Z) /\ (m = (ind_basis_mat i j r c))).
Axiom basis_mat_spec1 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z -> forall (m:matrix t),
(exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < r)%Z) /\
(((0%Z <= j)%Z /\ (j < c)%Z) /\ (m = (ind_basis_mat i j r c)))) ->
mem m (basis_mat r c).
Axiom basis_mat_spec2 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
((basis_mat r c) =
(map (fun (o:(Z* Z)%type) => (ind_basis_mat (fir o) (sec o) r c))
(cartesian_product (to_fset 0%Z r) (to_fset 0%Z c)))).
Axiom basis_mat_spec3 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
constant_size (basis_mat r c) (fun (y0:matrix t) => (p_id y0)).
Axiom basis_mat_spec4 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
((s_columns (basis_mat r c) (fun (y0:matrix t) => (p_id y0))) = c).
Axiom basis_mat_spec5 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z ->
((s_rows (basis_mat r c) (fun (y0:matrix t) => (p_id y0))) = r).
Parameter fc8: (matrix t) -> (Z* Z)%type -> bool.
Axiom fc_def8 :
forall (m:matrix t) (x:(Z* Z)%type),
(((fc8 m) x) = true) <-> (eq_t (get m (fir x) (sec x)) tone).
Axiom basis_mat_spec6 :
forall (r:Z) (c:Z), (0%Z < r)%Z -> (0%Z < c)%Z -> forall (m:matrix t),
(mem m (basis_mat r c)) ->
((cardinal (filter (fc8 m) (mat_indices m))) = 1%Z).
Parameter basis_mat_indexes: (matrix t) -> (Z* Z)%type.
Parameter result15: (matrix t) -> (Z* Z)%type -> bool.
Axiom result_def15 :
forall (m:matrix t) (x:(Z* Z)%type),
(((result15 m) x) = true) <->
((mem x (mat_indices m)) /\
(equal m (ind_basis_mat (fir x) (sec x) (rows m) (columns m)))).
Axiom basis_mat_indexes_def :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
((basis_mat_indexes m) = (element (filter (result15 m) (mat_indices m)))).
Axiom basis_mat_indexes_spec :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
(m =
(ind_basis_mat (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))
(rows m) (columns m))).
Axiom basis_mat_indexes_spec1 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
(m =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) =>
(indic_2 (fir (basis_mat_indexes m)) i (sec (basis_mat_indexes m)) j)))).
Axiom basis_mat_indexes_spec2 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
((get m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))) = tone).
Axiom basis_mat_indexes_spec3 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
forall (i:Z) (j:Z), (valid_index m i j) ->
(i = (fir (basis_mat_indexes m))) -> ~ (j = (sec (basis_mat_indexes m))) ->
((get m i j) = tzero).
Axiom basis_mat_indexes_spec4 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
valid_index m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m)).
Axiom get_basis_mat_indexes :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
(m =
(ind_basis_mat (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))
(rows m) (columns m))).
Axiom get_basis_mat_indexes1 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
(m =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) =>
(indic_2 (fir (basis_mat_indexes m)) i (sec (basis_mat_indexes m)) j)))).
Axiom get_basis_mat_indexes2 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
((get m (fir (basis_mat_indexes m)) (sec (basis_mat_indexes m))) = tone).
Axiom get_basis_mat_indexes3 :
forall (m:matrix t), (mem m (basis_mat (rows m) (columns m))) ->
forall (i:Z) (j:Z), (valid_index m i j) ->
~ ((basis_mat_indexes m) = (i, j)) -> ((get m i j) = tzero).
Axiom set_basis_mat_indexes :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
(mem m (basis_mat (rows m) (columns m))) -> ((get m i j) = tone) ->
((basis_mat_indexes m) = (i, j)).
Axiom set_basis_mat_indexes1 :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
(mem m (basis_mat (rows m) (columns m))) -> ((get m i j) = tone) ->
(m = (ind_basis_mat i j (rows m) (columns m))).
Axiom set_basis_mat_indexes2 :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
(mem m (basis_mat (rows m) (columns m))) -> ((get m i j) = tone) ->
(m =
(make_f (rows m) (columns m) (fun (i1:Z) (j1:Z) => (indic_2 i i1 j j1)))).
Axiom set_basis_mat_indexes3 :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
(mem m (basis_mat (rows m) (columns m))) -> ((get m i j) = tone) ->
forall (i1:Z) (j1:Z), (valid_index m i1 j1) -> (i1 = i) -> ~ (j1 = j) ->
((get m i1 j1) = tzero).
Parameter basis_projection: (matrix t) -> Z -> Z -> matrix t.
Axiom basis_projection_def :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((basis_projection m i j) =
(infix_asdtdt (get m i j) (ind_basis_mat i j (rows m) (columns m)))).
Axiom basis_projection_spec :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((rows (basis_projection m i j)) = (rows m)).
Axiom basis_projection_spec1 :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((columns (basis_projection m i j)) = (columns m)).
Axiom basis_projection_spec2 :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((basis_projection m i j) =
(make_f (rows m) (columns m)
(fun (k:Z) (l:Z) => (infix_asdt (get m i j) (indic_2 k i l j))))).
Axiom basis_projection_spec3 :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) ->
((get (basis_projection m i j) i j) = (get m i j)).
Axiom basis_projection_spec4 :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) -> forall (i':Z) (j':Z),
(valid_index (basis_projection m i j) i' j') -> ~ (i' = i) ->
((get (basis_projection m i j) i' j') = tzero).
Axiom basis_projection_spec5 :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
((0%Z <= j)%Z /\ (j < (columns m))%Z) -> forall (i':Z) (j':Z),
(valid_index (basis_projection m i j) i' j') -> ~ (j' = j) ->
((get (basis_projection m i j) i' j') = tzero).
Axiom basis_projection_null :
forall (m:matrix t) (i:Z) (j:Z) (k:Z) (l:Z), (valid_index m i j) ->
(valid_index m k l) -> ~ (i = k) ->
((get (basis_projection m i j) k l) = tzero).
Axiom basis_projection_null1 :
forall (m:matrix t) (i:Z) (j:Z) (k:Z) (l:Z), (valid_index m i j) ->
(valid_index m k l) -> ~ (j = l) ->
((get (basis_projection m i j) k l) = tzero).
Parameter basis_projections: (matrix t) -> set (matrix t).
Parameter result16: (matrix t) -> (Z* Z)%type -> matrix t.
Axiom result_def16 :
forall (m:matrix t) (o:(Z* Z)%type),
((valid_index m (fir o) (sec o)) ->
(((result16 m) o) = (basis_projection m (fir o) (sec o)))) /\
(~ (valid_index m (fir o) (sec o)) -> (((result16 m) o) = m)).
Axiom basis_projections_def :
forall (m:matrix t),
((basis_projections m) = (map (result16 m) (to_indexes m))).
Axiom basis_projections_spec :
forall (m:matrix t),
((basis_projections m) =
(map
((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
(to_indexes m))).
Axiom basis_projections_spec1 :
forall (m:matrix t), forall (e1:matrix t),
(mem e1 (basis_projections m)) -> ((rows e1) = (rows m)).
Axiom basis_projections_spec2 :
forall (m:matrix t), forall (e1:matrix t),
(mem e1 (basis_projections m)) -> ((columns e1) = (columns m)).
Axiom basis_projections_spec3 :
forall (m:matrix t),
constant_size (basis_projections m) (fun (y0:matrix t) => (p_id y0)).
Parameter fc9: (matrix t) -> (Z* Z)%type -> matrix t.
Axiom fc_def9 :
forall (m:matrix t) (o:(Z* Z)%type),
((valid_index m (fir o) (sec o)) ->
(((fc9 m) o) = (basis_projection m (fir o) (sec o)))) /\
(~ (valid_index m (fir o) (sec o)) -> (((fc9 m) o) = m)).
Axiom rewrite_basis_projections :
forall (m:matrix t), ((basis_projections m) = (map (fc9 m) (to_indexes m))).
Parameter indexes_decomp: (matrix t) -> matrix t.
Parameter result17: (matrix t) -> (Z* Z)%type -> matrix t.
Axiom result_def17 :
forall (m:matrix t) (o:(Z* Z)%type),
((mem o (to_indexes m)) ->
(((result17 m) o) = (basis_projection m (fir o) (sec o)))) /\
(~ (mem o (to_indexes m)) -> (((result17 m) o) = m)).
Axiom indexes_decomp_def :
forall (m:matrix t),
((indexes_decomp m) = (mat_sum (to_indexes m) (result17 m))).
Axiom indexes_decomp_spec :
forall (m:matrix t), ((rows (indexes_decomp m)) = (rows m)).
Axiom indexes_decomp_spec1 :
forall (m:matrix t), ((columns (indexes_decomp m)) = (columns m)).
Axiom rewrite_indexes_decomp :
forall (m:matrix t),
((indexes_decomp m) =
(mat_sum (to_indexes m)
(fun (o:(Z* Z)%type) => (basis_projection m (fir o) (sec o))))).
Axiom indexes_decomp_pre :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
((get m i j) =
(sum (to_indexes m)
(fun (o:(Z* Z)%type) => (get (basis_projection m (fir o) (sec o)) i j)))).
Axiom indexes_decomp_pre_gen :
forall (m:matrix t), forall (i:Z) (j:Z), (valid_index m i j) ->
((get m i j) =
(sum (to_indexes m)
(fun (o:(Z* Z)%type) => (get (basis_projection m (fir o) (sec o)) i j)))).
Axiom mat_to_indexes_decomp : forall (m:matrix t), (m = (indexes_decomp m)).
Parameter basis_decomp: (matrix t) -> matrix t.
Axiom basis_decomp_def :
forall (m:matrix t),
((basis_decomp m) =
(mat_sum (basis_projections m) (fun (y0:matrix t) => (p_id y0)))).
Axiom basis_decomp_spec :
forall (m:matrix t), ((rows (basis_decomp m)) = (rows m)).
Axiom basis_decomp_spec1 :
forall (m:matrix t), ((columns (basis_decomp m)) = (columns m)).
Axiom indexes_basis_decomp_equal_pre :
forall (m:matrix t) (i:Z) (j:Z), (valid_index m i j) ->
((get (indexes_decomp m) i j) = (get (basis_decomp m) i j)).
Axiom indexes_basis_decomp_equal :
forall (m:matrix t), ((indexes_decomp m) = (basis_decomp m)).
Axiom mat_to_basis_decomp : forall (m:matrix t), (m = (indexes_decomp m)).
Parameter fc10:
forall {a:Type} {a_WT:WhyType a}, (matrix t) -> (set a) ->
(a -> matrix t) -> a -> matrix t.
Axiom fc_def10 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s:set a) (f:a -> matrix t) (a1:a),
((mem a1 s) -> (((fc10 m s f) a1) = (mat_mult m (f a1)))) /\
(~ (mem a1 s) -> (((fc10 m s f) a1) = m)).
Axiom product_mat_sum_r_pre :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z ->
((mat_mult m (mat_sum s' f)) = (mat_sum s' (fc10 m s f))).
Axiom product_mat_sum_r_pre1 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z ->
((mat_mult m (mat_sum s' f)) =
(mat_sum s' (fun (a1:a) => (mat_mult m (f a1))))).
Axiom product_mat_sum_r_pre2 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z -> ((rows (mat_sum s' f)) = (s_rows s f)).
Axiom product_mat_sum_r_pre3 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z -> ((columns (mat_sum s' f)) = (s_columns s f)).
Axiom product_mat_sum_r_pre4 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z -> ((rows (mat_mult m (mat_sum s' f))) = (rows m)).
Axiom product_mat_sum_r_pre5 :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s':set a) (s:set a) (f:a -> matrix t),
(constant_size s f) -> ((columns m) = (s_rows s f)) -> (subset s' s) ->
((cardinal s') > 0%Z)%Z ->
((columns (mat_mult m (mat_sum s' f))) = (s_columns s f)).
Axiom product_mat_sum_r :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s:set a) (f:a -> matrix t), (constant_size s f) ->
((columns m) = (s_rows s f)) -> ((cardinal s) > 0%Z)%Z ->
((mat_mult m (mat_sum s f)) =
(mat_sum s (fun (a1:a) => (mat_mult m (f a1))))).
Axiom product_mat_sum_r_rev :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix t) (s:set a) (f:a -> matrix t), (constant_size s f) ->
((columns m) = (s_rows s f)) -> ((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (a1:a) => (mat_mult m (f a1)))) =
(mat_mult m (mat_sum s f))).
Axiom p_injective_proj :
forall (m:matrix t),
p_injective
((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
(nonn_mat_subset
((fun (y0:Z -> Z -> matrix t) (y1:(Z* Z)%type) => (couple y0 y1))
((fun (y0:matrix t) (y1:Z) (y2:Z) => (basis_projection y0 y1 y2)) m))
(to_indexes m)).
Axiom mat_decomp_equal_indexes :
forall (m:matrix t), (m = (indexes_decomp m)).
Parameter ket_basis: Z -> set (matrix t).
Axiom ket_basis_def :
forall (n:Z), (0%Z <= n)%Z ->
((ket_basis n) = (basis_mat (power 2%Z n) 1%Z)).
Axiom ket_basis_spec :
forall (n:Z), (0%Z <= n)%Z ->
((ket_basis n) =
(map
(fun (o:(Z* Z)%type) =>
(ind_basis_mat (fir o) (sec o) (power 2%Z n) 1%Z))
(cartesian_product (to_fset 0%Z (power 2%Z n)) (to_fset 0%Z 1%Z)))).
Axiom ket_basis_spec1 :
forall (n:Z), (0%Z <= n)%Z ->
((ket_basis n) = (basis_mat (power 2%Z n) 1%Z)).
Axiom ket_basis_spec2 :
forall (n:Z), (0%Z <= n)%Z -> forall (mat:matrix t),
(mem mat (ket_basis n)) -> ((rows mat) = (power 2%Z n)).
Axiom ket_basis_spec3 :
forall (n:Z), (0%Z <= n)%Z -> forall (mat:matrix t),
(mem mat (ket_basis n)) -> ((columns mat) = 1%Z).
Axiom ket_basis_spec4 :
forall (n:Z), (0%Z <= n)%Z -> forall (mat:matrix t),
(mem mat (ket_basis n)) -> ((rows mat) = (power 2%Z n)).
Axiom ket_basis_spec5 :
forall (n:Z), (0%Z <= n)%Z -> forall (mat:matrix t),
(mem mat (ket_basis n)) -> ((columns mat) = 1%Z).
Axiom ket_basis_spec6 :
forall (n:Z), (0%Z <= n)%Z -> forall (mat:matrix t),
(mem mat (ket_basis n)) ->
exists i:Z, (valid_index mat i 0%Z) /\ ((basis_mat_indexes mat) = (i, 0%Z)).
Axiom unary_ket_basis :
forall (n:Z), (0%Z <= n)%Z ->
((ket_basis n) =
(map (fun (i:Z) => (ind_basis_mat i 0%Z (power 2%Z n) 1%Z))
(to_fset 0%Z (power 2%Z n)))).
Axiom to_ket_basis :
forall (i:Z) (n:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
mem (ind_basis_mat i 0%Z (power 2%Z n) 1%Z) (ket_basis n).
Parameter ket_basis_index: (matrix t) -> Z -> Z.
Axiom ket_basis_index_def :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
((ket_basis_index m n) = (fir (basis_mat_indexes m))).
Axiom ket_basis_index_spec :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
mem (ind_basis_mat (ket_basis_index m n) 0%Z (power 2%Z n) 1%Z)
(ket_basis n).
Axiom ket_basis_index_spec1 :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
(m =
(make_f (rows m) 1%Z
(fun (i:Z) (us:Z) => (indic (ket_basis_index m n) i)))).
Axiom ket_basis_index_spec2 :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
forall (i:Z), (valid_index m i 0%Z) -> ~ (i = (ket_basis_index m n)) ->
((get m i 0%Z) = tzero).
Axiom ket_basis_index_spec3 :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
valid_index m (ket_basis_index m n) 0%Z.
Axiom set_ket_basis :
forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (mem m (ket_basis n)) ->
((get m i 0%Z) = tone) -> ((ket_basis_index m n) = i).
Axiom set_ket_basis1 :
forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (mem m (ket_basis n)) ->
((get m i 0%Z) = tone) -> forall (i1:Z), (valid_index m i1 0%Z) ->
~ (i1 = i) -> ((get m i1 0%Z) = tzero).
Axiom set_ket_basis2 :
forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (mem m (ket_basis n)) ->
((get m i 0%Z) = tone) -> mem m (ket_basis n).
Axiom set_ket_basis3 :
forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (mem m (ket_basis n)) ->
((get m i 0%Z) = tone) ->
(m = (make_f (rows m) (columns m) (fun (i1:Z) (us:Z) => (indic i i1)))).
Axiom from_ket_basis :
forall (n:Z) (m:matrix t), (0%Z <= n)%Z -> (mem m (ket_basis n)) ->
exists i:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(m = (ind_basis_mat i 0%Z (power 2%Z n) 1%Z)).
Axiom int_to_ket_basis :
forall (n:Z) (i:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> mem (ket n i) (ket_basis n).
Parameter is_a_ket_basis_elt: (matrix t) -> Prop.
Axiom is_a_ket_basis_elt_def :
forall (m:matrix t), (is_a_ket_basis_elt m) -> is_a_ket m.
Axiom is_a_ket_basis_elt_def1 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
mem m (ket_basis (ket_length m)).
Axiom is_a_ket_basis_elt_def2 :
forall (m:matrix t),
((is_a_ket m) /\ (mem m (ket_basis (ket_length m)))) ->
is_a_ket_basis_elt m.
Axiom ket_basis_elt_are_kets :
forall (m:matrix t), (is_a_ket_basis_elt m) -> is_a_ket m.
Axiom get_is_a_ket_basis_elt :
forall (m:matrix t), (is_a_ket_basis_elt m) -> is_a_ket m.
Axiom get_is_a_ket_basis_elt1 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
mem m (ket_basis (ket_length m)).
Axiom get_is_a_ket_basis_elt2 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
exists i:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
(m = (ket (ket_length m) i)).
Axiom get_is_a_ket_basis_elt3 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
exists i:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
(((get m i 0%Z) = tone) /\
forall (j:Z),
(((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
~ ((get m j 0%Z) = tzero)) ->
(i = j)).
Axiom get_is_a_ket_basis_elt4 :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (i:Z),
(((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
((get m i 0%Z) = tone)) ->
forall (j:Z),
(((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
~ ((get m j 0%Z) = tzero)) ->
(i = j).
Axiom get_is_a_ket_basis_elt_indic :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
exists i:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
forall (j:Z), ((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((get m j 0%Z) = (indic i j)).
Axiom set_is_a_ket_basis_elt :
forall (m:matrix t), (is_a_ket m) ->
(exists i:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) /\
(m = (ket (ket_length m) i))) ->
is_a_ket_basis_elt m.
Axiom set_is_a_ket_basis_elt_exists :
forall (m:matrix t), (is_a_ket m) ->
(exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
(m =
(make_f (power 2%Z (ket_length m)) 1%Z (fun (i:Z) (us:Z) => (indic i j))))) ->
is_a_ket_basis_elt m.
Axiom ket_func_sets_ket_basis_elts :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_ket_basis_elt (ket n i).
Axiom ket_func_sets_ket_basis_elts1 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((ket_length (ket n i)) = n).
Axiom kronecker_is_a_ket_basis_elt :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) -> is_a_ket_basis_elt (kronecker x y).
Axiom ket_is_a_ket_basis_elt :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_ket_basis_elt (ket n i).
Axiom ket_basis_non_null_val :
forall (m:matrix t) (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (is_a_ket_basis_elt m) ->
((ket_length m) = n) -> ~ ((get m i 0%Z) = tzero) -> (m = (ket n i)).
Parameter ket_to_int: (matrix t) -> Z.
Axiom ket_to_int_spec :
forall (m:matrix t), (is_a_ket_basis_elt m) -> (0%Z <= (ket_to_int m))%Z.
Axiom ket_to_int_spec1 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
((ket_to_int m) < (power 2%Z (ket_length m)))%Z.
Axiom ket_to_int_spec2 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
((get m (ket_to_int m) 0%Z) = tone).
Axiom ket_to_int_spec3 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
(m = (ket (ket_length m) (ket_to_int m))).
Axiom ket_to_int_spec4 :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
(m = (ket (ket_length m) i)) -> (i = (ket_to_int m)).
Axiom ket_to_int_ket :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((ket_to_int (ket n i)) = i).
Parameter bin_to_ket: Z -> (Z -> Z) -> matrix t.
Axiom bin_to_ket_def :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
((bin_to_ket n bvx) = (ket n (bin_to_int bvx n))).
Axiom bin_to_ket_spec :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
is_a_ket_basis_elt (bin_to_ket n bvx).
Axiom bin_to_ket_spec1 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
((ket_length (bin_to_ket n bvx)) = n).
Axiom bin_to_ket_spec2 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
((ket_to_int (bin_to_ket n bvx)) = (bin_to_int bvx n)).
Axiom bin_to_ket_spec3 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
((rows (bin_to_ket n bvx)) = (power 2%Z n)).
Axiom bin_to_ket_spec4 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
((columns (bin_to_ket n bvx)) = 1%Z).
Axiom bin_to_ket_spec5 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
is_a_ket (bin_to_ket n bvx).
Axiom bin_to_ket_spec6 :
forall (n:Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (binary bvx) ->
is_a_ket_l (bin_to_ket n bvx) n.
Axiom bin_to_ket_l :
forall (n:Z) (n':Z) (bvx:Z -> Z), (n >= 0%Z)%Z -> (n = n') ->
(binary bvx) -> is_a_ket_l (bin_to_ket n bvx) n'.
Axiom bin_to_ket_eq :
forall (n1:Z) (n2:Z) (bvx1:Z -> Z) (bvx2:Z -> Z), (n1 >= 0%Z)%Z ->
(binary bvx1) -> (binary bvx2) -> (n2 = n1) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < n1)%Z) -> ((bvx1 i) = (bvx2 i))) ->
((bin_to_ket n1 bvx1) = (bin_to_ket n2 bvx2)).
Axiom kronecker_kets_bin_to_ket :
forall (f1:Z -> Z) (f2:Z -> Z) (n1:Z) (n2:Z), (binary f1) -> (binary f2) ->
(0%Z <= n1)%Z -> (0%Z <= n2)%Z ->
((kronecker (bin_to_ket n1 f1) (bin_to_ket n2 f2)) =
(bin_to_ket (n1 + n2)%Z
((((fun (y0:Z -> Z) (y1:Z -> Z) (y2:Z) (y3:Z) =>
(concat_fun y0 y1 y2 y3))
f1)
f2)
n1))).
Axiom kronecker_ket_to_int :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) -> is_a_ket_basis_elt (kronecker x y).
Axiom kronecker_ket_to_int1 :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) ->
((ket_length (kronecker x y)) = ((ket_length x) + (ket_length y))%Z).
Axiom kronecker_ket_to_int2 :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) ->
((kronecker x y) =
(ket ((ket_length x) + (ket_length y))%Z
(((ket_to_int x) * (power 2%Z (ket_length y)))%Z + (ket_to_int y))%Z)).
Axiom kronecker_ket_to_int3 :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) ->
((ket_to_int (kronecker x y)) =
(((ket_to_int x) * (power 2%Z (ket_length y)))%Z + (ket_to_int y))%Z).
Axiom ket_ket_to_int :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
((ket (ket_length x) (ket_to_int x)) = x).
Axiom ket_ket_to_int_values :
forall (x:matrix t), (is_a_ket_basis_elt x) -> forall (i:Z) (j:Z),
(valid_index x i j) -> ((get x i j) = (indic i (ket_to_int x))).
Parameter ket_basis_projection: (matrix t) -> Z -> matrix t.
Axiom ket_basis_projection_def :
forall (m:matrix t) (j:Z), (is_a_ket m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((ket_basis_projection m j) =
(infix_asdtdt (get m j 0%Z) (ket (ket_length m) j))).
Axiom ket_basis_projection_spec :
forall (m:matrix t) (j:Z), (is_a_ket m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((ket_basis_projection m j) = (basis_projection m j 0%Z)).
Axiom ket_basis_projection_columns :
forall (m:matrix t) (j:Z), (is_a_ket m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((columns (ket_basis_projection m j)) = 1%Z).
Axiom ket_basis_projection_rows :
forall (m:matrix t) (j:Z), (is_a_ket m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((rows (ket_basis_projection m j)) = (rows m)).
Parameter ket_basis_projections: (matrix t) -> set (matrix t).
Parameter result18: (matrix t) -> Z -> matrix t.
Axiom result_def18 :
forall (m:matrix t) (j:Z),
((mem j (to_fset 0%Z (power 2%Z (ket_length m)))) ->
(((result18 m) j) = (ket_basis_projection m j))) /\
(~ (mem j (to_fset 0%Z (power 2%Z (ket_length m)))) ->
(((result18 m) j) = m)).
Axiom ket_basis_projections_def :
forall (m:matrix t), (is_a_ket m) ->
((ket_basis_projections m) =
(map (result18 m) (to_fset 0%Z (power 2%Z (ket_length m))))).
Axiom ket_basis_projections_spec :
forall (m:matrix t), (is_a_ket m) ->
((ket_basis_projections m) = (basis_projections m)).
Parameter ket_basis_projections_antec: (matrix t) -> unit.
Axiom ket_basis_projections_antec_def :
forall (m:matrix t), (is_a_ket m) -> ((ket_basis_projections_antec m) = tt).
Axiom ket_basis_projections_antec_spec :
forall (m:matrix t), (is_a_ket m) -> forall (e1:matrix t),
(mem e1 (ket_basis_projections m)) ->
exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
(e1 = (ket_basis_projection m j)).
Axiom ket_basis_projections_antec_spec1 :
forall (m:matrix t), (is_a_ket m) -> forall (e1:matrix t),
(exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) /\
(e1 = (ket_basis_projection m j))) ->
mem e1 (ket_basis_projections m).
Axiom ket_basis_projections_antec_spec2 :
forall (m:matrix t), (is_a_ket m) -> forall (e1:matrix t),
(mem e1 (ket_basis_projections m)) ->
exists j:Z, exists i:Z,
(valid_index m j i) /\ (e1 = (basis_projection m j i)).
Axiom ket_basis_projections_antec_spec3 :
forall (m:matrix t), (is_a_ket m) -> forall (e1:matrix t),
(exists j:Z, exists i:Z,
(valid_index m j i) /\ (e1 = (basis_projection m j i))) ->
mem e1 (ket_basis_projections m).
Parameter ket_sum:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.
Axiom ket_sum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ket_length (f e1)) = l)) ->
((ket_sum s f) = (mat_sum s f)).
Axiom ket_sum_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ket_length (f e1)) = l)) ->
forall (i:Z), (ket_valid_index (ket_sum s f) i) ->
((get_ket (ket_sum s f) i) = (sum s (fun (e1:a) => (get_ket (f e1) i)))).
Axiom ket_sum_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ket_length (f e1)) = l)) ->
is_a_ket (ket_sum s f).
Axiom ket_sum_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ket_length (f e1)) = l)) ->
forall (e1:a), (mem e1 s) ->
((ket_length (ket_sum s f)) = (ket_length (f e1))).
Parameter ket_sum_l:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
matrix t.
Axiom ket_sum_l_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((ket_sum_l s f l) = (mat_sum s f)).
Axiom ket_sum_l_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
is_a_ket (ket_sum_l s f l).
Axiom ket_sum_l_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) -> forall (i:Z),
(ket_valid_index (ket_sum_l s f l) i) ->
((get_ket (ket_sum_l s f l) i) =
(sum s (fun (e1:a) => (get_ket (f e1) i)))).
Axiom ket_sum_l_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
is_a_ket_l (ket_sum_l s f l) l.
Axiom ket_sum_l_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((ket_length (ket_sum_l s f l)) = l).
Axiom ket_sum_l_rows :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((rows (ket_sum_l s f l)) = (power 2%Z l)).
Axiom ket_sum_l_value :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (j = 0%Z) ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((get (ket_sum_l s f l) i j) = (sum s (fun (e1:a) => (get (f e1) i 0%Z)))).
Axiom get_ket_sum_l_value :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((get_ket (ket_sum_l s f l) i) =
(sum s (fun (e1:a) => (get_ket (f e1) i)))).
Axiom ket_sum_l_columns :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((columns (ket_sum_l s f l)) = 1%Z).
Axiom ket_sum_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a), ((cardinal s) > 1%Z)%Z ->
(forall (e2:a), (mem e2 s) -> is_a_ket (f e2)) -> (constant_size s f) ->
(mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> null_mat (f e')) ->
((ket_sum s f) = (f e1)).
Axiom ket_sum_null :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 1%Z)%Z ->
(l >= 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
(forall (e1:a), (mem e1 s) -> null_mat (f e1)) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) ->
((get_ket (ket_sum_l s f l) j) = tzero).
Axiom ket_sum_l_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a) (l:Z), ((cardinal s) > 1%Z)%Z ->
(forall (e2:a), (mem e2 s) -> is_a_ket_l (f e2) l) -> (mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> null_mat (f e')) ->
((ket_sum_l s f l) = (f e1)).
Axiom ket_sum_ket_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
is_a_ket_l (ket_sum_l s f l) l.
Axiom ket_sum_comp_l :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
((cardinal s) > 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_ket_l (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_ket_l (g e1) l) ->
((ket_sum_l s (fun (k:b) => (add_ket_l (f k) (g k) l)) l) =
(add_ket_l (ket_sum_l s f l) (ket_sum_l s g l) l)).
Axiom ket_sum_comp_l_rev :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
((cardinal s) > 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_ket_l (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_ket_l (g e1) l) ->
((add_ket_l (ket_sum_l s f l) (ket_sum_l s g l) l) =
(ket_sum_l s (fun (k:b) => (add_ket_l (f k) (g k) l)) l)).
Axiom ket_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
(infix_asdtdt a1 (ket_sum_l s f l))).
Axiom scal_ket_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (b:t) (l:Z) (l':Z),
(forall (e1:a), (mem e1 s) ->
exists a1:t,
exists k:matrix t, ((f e1) = (infix_asdtdt a1 k)) /\ (is_a_ket_l k l)) ->
((cardinal s) > 0%Z)%Z -> (l = l') ->
is_a_ket_l (infix_asdtdt b (ket_sum_l s f l)) l'.
Axiom ket_sum_scalar_rev_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((infix_asdtdt a1 (ket_sum_l s f l)) =
(ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l)).
Axiom ket_sum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l:Z),
((cardinal s) > 0%Z)%Z -> (s = s') ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((ket_sum_l s f l) = (ket_sum_l s' g l)).
Axiom ket_sum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l1:Z)
(l2:Z),
((cardinal s) > 0%Z)%Z -> (s = s') -> (l1 = l2) ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((ket_sum_l s f l1) = (ket_sum_l s' g l2)).
Axiom ket_sum_bvs_eq :
forall (n1:Z) (n2:Z) (f:bitvec -> matrix t) (g:bitvec -> matrix t)
(l1:Z) (l2:Z),
(l1 = l2) -> (n1 = n2) -> (n1 >= 0%Z)%Z ->
(forall (e1:bitvec), (mem e1 (n_bvs n1)) -> is_a_ket_l (f e1) l1) ->
(forall (e1:bitvec), (mem e1 (n_bvs n1)) -> ((f e1) = (g e1))) ->
((ket_sum_l (n_bvs n1) f l1) = (ket_sum_l (n_bvs n2) g l2)).
Axiom ket_sum_scal_bvs_eq :
forall (n1:Z) (n2:Z) (f:bitvec -> matrix t) (g:bitvec -> matrix t)
(l1:Z) (l2:Z) (s1:t) (s2:t),
(l1 = l2) -> (n1 = n2) -> (s1 = s2) -> (n1 >= 0%Z)%Z ->
(forall (e1:bitvec), (mem e1 (n_bvs n1)) -> is_a_ket_l (f e1) l1) ->
(forall (e1:bitvec), (mem e1 (n_bvs n1)) -> ((f e1) = (g e1))) ->
((infix_asdtdt s1 (ket_sum_l (n_bvs n1) f l1)) =
(infix_asdtdt s2 (ket_sum_l (n_bvs n2) g l2))).
Axiom ket_sum_sum_bvs_eq :
forall (n1:Z) (n2:Z) (n1':Z) (n2':Z) (f:bitvec -> bitvec -> matrix t)
(g:bitvec -> bitvec -> matrix t) (l1:Z) (l2:Z) (l1':Z) (l2':Z),
((l1 = l2) /\ ((l2 = l1') /\ (l1' = l2'))) -> (n1 = n1') ->
(n1 >= 0%Z)%Z -> (n2 = n2') -> (n2 >= 0%Z)%Z ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> is_a_ket_l ((f e1) e') l1) ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> (((f e1) e') = ((g e1) e'))) ->
((ket_sum_l (n_bvs n1) (fun (k:bitvec) => (ket_sum_l (n_bvs n2) (f k) l1))
l2)
=
(ket_sum_l (n_bvs n1')
(fun (k:bitvec) => (ket_sum_l (n_bvs n2') (g k) l1')) l2')).
Axiom ket_sum_sum_scal_bvs_eq :
forall (n1:Z) (n2:Z) (n1':Z) (n2':Z) (f:bitvec -> bitvec -> matrix t)
(g:bitvec -> bitvec -> matrix t) (l1:Z) (l2:Z) (l1':Z) (l2':Z) (s1:t)
(s2:t),
((l1 = l2) /\ ((l2 = l1') /\ (l1' = l2'))) -> (n1 = n1') ->
(n1 >= 0%Z)%Z -> (n2 = n2') -> (s1 = s2) -> (n2 >= 0%Z)%Z ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> is_a_ket_l ((f e1) e') l1) ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> (((f e1) e') = ((g e1) e'))) ->
((infix_asdtdt s1
(ket_sum_l (n_bvs n1) (fun (k:bitvec) => (ket_sum_l (n_bvs n2) (f k) l1))
l2))
=
(infix_asdtdt s1
(ket_sum_l (n_bvs n1')
(fun (k:bitvec) => (ket_sum_l (n_bvs n2') (g k) l1')) l2'))).
Axiom ket_sum_sum_scal_mult_bvs_eq :
forall (n1:Z) (n2:Z) (n1':Z) (n2':Z) (f:bitvec -> bitvec -> matrix t)
(g:bitvec -> bitvec -> matrix t) (l1:Z) (l2:Z) (l1':Z) (l2':Z) (s1:t)
(s2:t) (s3:t),
((l1 = l2) /\ ((l2 = l1') /\ (l1' = l2'))) -> (n1 = n1') ->
(n1 >= 0%Z)%Z -> (s3 = (infix_asdt s1 s2)) -> (n2 = n2') ->
(n2 >= 0%Z)%Z ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> is_a_ket_l ((f e1) e') l1) ->
(forall (e1:bitvec) (e':bitvec), (mem e1 (n_bvs n1)) ->
(mem e' (n_bvs n2)) -> (((f e1) e') = ((g e1) e'))) ->
((infix_asdtdt s1
(ket_sum_l (n_bvs n1')
(fun (k:bitvec) => (infix_asdtdt s2 (ket_sum_l (n_bvs n2') (f k) l1')))
l2'))
=
(infix_asdtdt s3
(ket_sum_l (n_bvs n1) (fun (k:bitvec) => (ket_sum_l (n_bvs n2) (g k) l1))
l2))).
Axiom ket_sum_l_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) = 1%Z) ->
(is_a_ket_l (f (choose s)) l) -> ((ket_sum_l s f l) = (f (choose s))).
Axiom ket_sum_l_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (e1:a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
~ (mem e1 s) -> (forall (e2:a), (mem e2 s) -> is_a_ket_l (f e2) l) ->
(is_a_ket_l (f e1) l) ->
((ket_sum_l (add e1 s) f l) = (add_ket_l (ket_sum_l s f l) (f e1) l)).
Axiom ket_sum_l_valid_index :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
(forall (e1:a), (mem e1 s) -> ket_valid_index (f e1) i) ->
ket_valid_index (ket_sum_l s f l) i.
Axiom ket_sum_const :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(is_a_ket_l x l) ->
((ket_sum_l s (fun (us:a) => x) l) =
(infix_asdtdt (i_to_t (cardinal s)) x)).
Axiom ket_sum_const_w :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (x:matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(is_a_ket_l x l) ->
((infix_asdtdt (infix_sldt tone (i_to_t (cardinal s)))
(ket_sum_l s (fun (us:a) => x) l))
= x).
Axiom map_ket_sum_l :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:b -> matrix t) (s:set a) (t1:a -> b) (n:Z),
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f (t1 e1)) n) ->
(p_injective t1 s) ->
((ket_sum_l (map t1 s) f n) = (ket_sum_l s (fun (a1:a) => (f (t1 a1))) n)).
Axiom ket_norm_l_unif_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (c:Z) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) = c) -> (forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) n) ->
(forall (e1:a), (mem e1 s) -> ((ket_norm_l (f e1) n) = tone)) ->
((ket_norm_l
(infix_asdtdt (infix_sldt tone (square_rt (i_to_t c))) (ket_sum_l s f n))
n)
= tone).
Axiom ket_sum_partition :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s1:set a) (s2:set a) (f:a -> matrix t) (n:Z),
(0%Z <= n)%Z -> (forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) n) ->
(s = (union s1 s2)) -> ((inter s1 s2) = (empty : set a)) ->
((ket_sum_l s f n) = (add_mat (ket_sum_l s1 f n) (ket_sum_l s2 f n))).
Axiom ket_decomp :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((ket_length m) = n) ->
(m =
(mat_sum (to_fset 0%Z (power 2%Z n))
(fun (j:Z) => (infix_asdtdt (get m j 0%Z) (ket n j))))).
Axiom ket_decomp_bv :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((ket_length m) = n) ->
(m =
(ket_sum_l (n_bvs n)
(fun (bvx:bitvec) =>
(infix_asdtdt (get m (bv_to_int bvx) 0%Z) (ket n (bv_to_int bvx))))
n)).
Axiom ket_recomp :
forall (f:Z -> t) (n:Z), (0%Z <= n)%Z ->
((mat_sum (to_fset 0%Z (power 2%Z n))
(fun (j:Z) => (infix_asdtdt (f j) (ket n j))))
= (make_f (power 2%Z n) 1%Z (fun (x:Z) (us:Z) => (f x)))).
Axiom ket_decomp_quant :
forall (m:matrix t), (is_a_ket m) ->
(m =
(mat_sum (to_fset 0%Z (power 2%Z (ket_length m)))
(fun (j:Z) => (infix_asdtdt (get m j 0%Z) (ket (ket_length m) j))))).
Axiom mat_mult_ket_basis :
forall (m:matrix t) (x:matrix t), (is_a_ket_basis_elt x) ->
(((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
((mat_mult m x) =
(mat_sum (to_fset 0%Z (rows x))
(fun (k:Z) =>
(infix_asdtdt (get m k (ket_to_int x)) (ket (ket_length x) k))))).
Axiom ket_mult_diag :
forall (m:matrix t) (x:matrix t), ((ket_length x) >= 1%Z)%Z ->
(is_a_ket_basis_elt x) -> ((rows m) = (power 2%Z (ket_length x))) ->
((columns m) = (power 2%Z (ket_length x))) ->
(forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length x)))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length x)))%Z) -> ~ (i = j) ->
((get m i j) = tzero)) ->
((mat_mult m x) =
(infix_asdtdt (get m (ket_to_int x) (ket_to_int x))
(ket (ket_length x) (ket_to_int x)))).
Axiom mat_mult_ket_basis_bv :
forall (m:matrix t) (x:matrix t) (n:Z), ((ket_length x) = n) ->
(is_a_ket_basis_elt x) ->
(((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
((mat_mult m x) =
(ket_sum_l (n_bvs n)
(fun (bvx:bitvec) =>
(infix_asdtdt (get m (bv_to_int bvx) (ket_to_int x))
(ket n (bv_to_int bvx))))
n)).
Axiom mat_mult_ket_basis_bv_gen :
forall (m:matrix t) (x:matrix t), (is_a_ket_basis_elt x) ->
(((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
((mat_mult m x) =
(ket_sum_l (n_bvs (ket_length x))
(fun (bvx:bitvec) =>
(infix_asdtdt (get m (bv_to_int bvx) (ket_to_int x))
(ket (ket_length x) (bv_to_int bvx))))
(ket_length x))).
Axiom mat_mult_ket_bv :
forall (m:matrix t) (x:matrix t) (n:Z), (is_a_ket_l x n) ->
(((columns m) = (rows m)) /\
(((rows m) = (rows x)) /\ ((rows x) = (power 2%Z n)))) ->
((mat_mult m x) =
(ket_sum_l (n_bvs n)
(fun (bvx:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int bvx))
(mat_mult m (ket n (bv_to_int bvx)))))
n)).
Axiom mat_mult_ket_bv_gen :
forall (m:matrix t) (x:matrix t), (is_a_ket x) ->
(((columns m) = (rows m)) /\ ((rows m) = (rows x))) ->
((mat_mult m x) =
(ket_sum_l (n_bvs (ket_length x))
(fun (bvx:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int bvx))
(mat_mult m (ket (ket_length x) (bv_to_int bvx)))))
(ket_length x))).
Axiom fun_inversion_pre :
forall (f:Z -> Z) (s:set Z) (s':set Z) (a:Z -> t) (n:Z), (0%Z <= n)%Z ->
((cardinal s) > 0%Z)%Z -> (p_bijective f s s') ->
(subset s (to_fset 0%Z n)) -> (subset s' (to_fset 0%Z n)) ->
((mat_sum s
(fun (j:Z) =>
(infix_asdtdt (a j) (set1 (make n 1%Z tzero) (f j) 0%Z tone))))
=
(mat_sum s'
(fun (j:Z) =>
(infix_asdtdt (a (inv_func f s s' j))
(set1 (make n 1%Z tzero) j 0%Z tone))))).
Axiom ket_fun_inversion :
forall (f:Z -> Z) (a:Z -> t) (m:matrix t) (pow_2_n:Z),
(pow_2_n = (power 2%Z (ket_length m))) -> (is_a_ket m) ->
(pow_2_n > 0%Z)%Z ->
(p_bijective f (to_fset 0%Z pow_2_n) (to_fset 0%Z pow_2_n)) ->
(m =
(mat_sum (to_fset 0%Z pow_2_n)
(fun (j:Z) => (infix_asdtdt (a j) (ket (ket_length m) (f j)))))) ->
(m =
(mat_sum (to_fset 0%Z pow_2_n)
(fun (j:Z) =>
(infix_asdtdt (a (inv_ f (to_fset 0%Z pow_2_n) (to_fset 0%Z pow_2_n) j))
(ket (ket_length m) j))))).
Parameter ket_to_bv: (matrix t) -> bitvec.
Axiom ket_to_bv_def :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
((ket_to_bv x) = (int_to_bv (ket_to_int x) (ket_length x))).
Axiom ket_to_bv_spec :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
((bv_to_int (ket_to_bv x)) = (ket_to_int x)).
Axiom ket_to_bv_spec1 :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
((length (ket_to_bv x)) = (ket_length x)).
Axiom ket_to_bv_spec2 :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
mem (ket_to_bv x) (n_bvs (ket_length x)).
Parameter bv_to_ket: bitvec -> matrix t.
Axiom bv_to_ket_def :
forall (bv:bitvec), ((bv_to_ket bv) = (ket (length bv) (bv_to_int bv))).
Axiom bv_to_ket_spec : forall (bv:bitvec), is_a_ket_basis_elt (bv_to_ket bv).
Axiom bv_to_ket_spec1 :
forall (bv:bitvec), ((ket_to_int (bv_to_ket bv)) = (bv_to_int bv)).
Axiom bv_to_ket_spec2 :
forall (bv:bitvec), ((ket_length (bv_to_ket bv)) = (length bv)).
Axiom bv_to_ket_spec3 :
forall (bv:bitvec), ((rows (bv_to_ket bv)) = (power 2%Z (length bv))).
Axiom bv_to_ket_spec4 : forall (bv:bitvec), ((columns (bv_to_ket bv)) = 1%Z).
Axiom bv_to_ket_spec5 :
forall (bv:bitvec), ((bv_to_ket bv) = (bin_to_ket (length bv) (getbv bv))).
Axiom ket_to_bv_ket_length :
forall (i:Z) (n:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((length (ket_to_bv (ket n i))) = n).
Axiom is_a_ket_l_bv_to_ket :
forall (bv:bitvec) (l:Z), ((length bv) = l) -> is_a_ket_l (bv_to_ket bv) l.
Axiom bin_to_ket_to_bv_to_ket :
forall (f:Z -> Z) (n:Z), (0%Z <= n)%Z -> (binary f) ->
((bin_to_ket n f) = (bv_to_ket (make_bv f n))).
Axiom bin_to_ket_to_bv_to_ket_abs :
forall (f:Z -> Z) (n:Z) (a:bitvec), (0%Z <= n)%Z -> (a = (make_bv f n)) ->
(binary f) -> ((bin_to_ket n f) = (bv_to_ket a)).
Axiom ket_to_int_to_bv_to_ket :
forall (n:Z) (e1:bitvec), (0%Z <= n)%Z -> (mem e1 (n_bvs n)) ->
((ket n (bv_to_int e1)) = (bv_to_ket e1)).
Axiom bv_to_ket_length :
forall (bv:bitvec), ((ket_length (bv_to_ket bv)) = (length bv)).
Axiom is_a_ket_l_bvs :
forall (e1:bitvec) (n:Z), (0%Z <= n)%Z -> (mem e1 (n_bvs n)) ->
is_a_ket_l (bv_to_ket e1) n.
Axiom is_a_ket_l_scal_bvs :
forall (e1:bitvec) (n:Z) (a:t), (0%Z <= n)%Z -> (mem e1 (n_bvs n)) ->
is_a_ket_l (infix_asdtdt a (bv_to_ket e1)) n.
Axiom ket_to_bv_concat :
forall (x:bitvec) (y:bitvec),
((bv_to_ket (concat x y)) = (kronecker (bv_to_ket x) (bv_to_ket y))).
Axiom bv_to_ket_concat_rev :
forall (x:bitvec) (y:bitvec),
((kronecker (bv_to_ket x) (bv_to_ket y)) = (bv_to_ket (concat x y))).
Axiom bv_to_ket_to_bv :
forall (bv:bitvec), ((ket_to_bv (bv_to_ket bv)) = bv).
Axiom ket_to_bv_to_ket :
forall (x:matrix t), (is_a_ket_basis_elt x) ->
((bv_to_ket (ket_to_bv x)) = x).
Axiom bv_to_ket_eq :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (length bv1))%Z) ->
(((getbv bv1) i) = ((getbv bv2) i))) ->
((bv_to_ket bv1) = (bv_to_ket bv2)).
Axiom ket_to_bv_kronecker :
forall (x:matrix t) (y:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_basis_elt y) ->
((ket_to_bv (kronecker x y)) = (concat (ket_to_bv x) (ket_to_bv y))).
Axiom ket_decomp_bv_ket :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ket m) ->
((ket_length m) = n) ->
(m =
(ket_sum_l (n_bvs n)
(fun (bvx:bitvec) =>
(infix_asdtdt (get_ket m (bv_to_int bvx)) (ket n (bv_to_int bvx))))
n)).
Axiom ket_zero : forall (n:Z), (n >= 0%Z)%Z -> is_a_ket_l (ket n 0%Z) n.
Axiom ket_zero1 :
forall (n:Z), (n >= 0%Z)%Z -> is_a_ket_basis_elt (ket n 0%Z).
Axiom ket_zero2 :
forall (n:Z), (n >= 0%Z)%Z ->
((ket_to_bv (ket n 0%Z)) = (make_bv (fun (us:Z) => 0%Z) n)).
Axiom ket_zero3 :
forall (n:Z), (n >= 0%Z)%Z -> forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) ->
(((getbv (ket_to_bv (ket n 0%Z))) i) = 0%Z).
Axiom uniform_ket_norm_l :
forall (x:matrix t) (f:bitvec -> t) (n:Z), (is_a_ket_l x n) ->
(forall (e1:bitvec), (mem e1 (n_bvs n)) -> ((modulus (f e1)) = tone)) ->
(x =
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (x1:bitvec) => (infix_asdtdt (f x1) (bv_to_ket x1))) n))) ->
((ket_norm_l x n) = tone).
Axiom ket_sum_of_scalars :
forall (f:bitvec -> t) (n:Z), (n >= 0%Z)%Z ->
is_a_ket_l
(ket_sum_l (n_bvs n) (fun (x:bitvec) => (infix_asdtdt (f x) (bv_to_ket x)))
n)
n.
Axiom ket_sum_of_scalars1 :
forall (f:bitvec -> t) (n:Z), (n >= 0%Z)%Z -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((get
(ket_sum_l (n_bvs n)
(fun (x:bitvec) => (infix_asdtdt (f x) (bv_to_ket x))) n)
i 0%Z)
= (f (int_to_bv i n))).
Axiom mat_sum_sum_cartesian_product_pre :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (s1:set a) (s2:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(0%Z < r)%Z -> (0%Z < c)%Z ->
(forall (a1:a) (b1:b), (mem a1 s1) -> (mem b1 s2) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a) (b1:b), (mem a1 s1) -> (mem b1 s2) ->
((columns ((f a1) b1)) = c)) ->
((cardinal s1) > 0%Z)%Z -> ((cardinal s2) > 0%Z)%Z ->
((mat_sum s1 (fun (a1:a) => (mat_sum s2 (f a1)))) =
(mat_sum (cartesian_product s1 s2)
(fun (o:(a* b)%type) => ((f (fir o)) (sec o))))).
Axiom mat_sum_comp1 :
forall (f:bitvec -> bitvec -> matrix t) (l:Z) (x:Z) (y:Z), (0%Z <= x)%Z ->
(0%Z <= y)%Z -> (0%Z <= l)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket ((f bvy) bvx)) ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> ((ket_length ((f bvy) bvx)) = l)) ->
((mat_sum (n_bvs y)
(fun (bvy:bitvec) =>
(mat_sum (n_bvs x) (fun (bvx:bitvec) => ((f bvy) bvx)))))
=
(mat_sum (n_bvs (x + y)%Z)
(fun (bv:bitvec) => ((f (hpart bv y)) (tpart bv y))))).
Axiom mat_sum_comp_rev :
forall (f:bitvec -> bitvec -> matrix t) (l:Z) (x:Z) (y:Z), (0%Z <= x)%Z ->
(0%Z <= y)%Z -> (0%Z <= l)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket ((f bvy) bvx)) ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> ((ket_length ((f bvy) bvx)) = l)) ->
((mat_sum (n_bvs (x + y)%Z)
(fun (bv:bitvec) => ((f (hpart bv y)) (tpart bv y))))
=
(mat_sum (n_bvs y)
(fun (bvy:bitvec) =>
(mat_sum (n_bvs x) (fun (bvx:bitvec) => ((f bvy) bvx)))))).
Axiom ket_sum_bin_comp_l :
forall (f:bitvec -> bitvec -> matrix t) (scal:bitvec -> t) (l:Z) (x:Z)
(y:Z),
(0%Z <= x)%Z -> (0%Z <= y)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket_l ((f bvy) bvx) l) ->
((ket_sum_l (n_bvs y)
(fun (bvy:bitvec) =>
(infix_asdtdt (scal bvy)
(ket_sum_l (n_bvs x) (fun (bvx:bitvec) => ((f bvy) bvx)) l)))
l)
=
(ket_sum_l (n_bvs (x + y)%Z)
(fun (bv:bitvec) =>
(infix_asdtdt (scal (hpart bv y)) ((f (hpart bv y)) (tpart bv y))))
l)).
Axiom ket_sum_bin_comp :
forall (f:bitvec -> bitvec -> matrix t) (l:Z) (x:Z) (y:Z), (0%Z <= x)%Z ->
(0%Z <= y)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket_l ((f bvy) bvx) l) ->
((ket_sum_l (n_bvs y)
(fun (bvy:bitvec) =>
(ket_sum_l (n_bvs x) (fun (bvx:bitvec) => ((f bvy) bvx)) l))
l)
=
(ket_sum_l (n_bvs (x + y)%Z)
(fun (bv:bitvec) => ((f (hpart bv y)) (tpart bv y))) l)).
Axiom ket_sum_bin_comp_rev :
forall (f:bitvec -> bitvec -> matrix t) (l:Z) (x:Z) (y:Z), (0%Z <= x)%Z ->
(0%Z <= y)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket_l ((f bvy) bvx) l) ->
((ket_sum_l (n_bvs (x + y)%Z)
(fun (bv:bitvec) => ((f (hpart bv y)) (tpart bv y))) l)
=
(ket_sum_l (n_bvs y)
(fun (bvy:bitvec) =>
(ket_sum_l (n_bvs x) (fun (bvx:bitvec) => ((f bvy) bvx)) l))
l)).
Axiom ket_sum_bin_comp_rev_ :
forall (f:bitvec -> bitvec -> matrix t) (l:Z) (x:Z) (y:Z), (0%Z <= x)%Z ->
(0%Z <= y)%Z ->
(forall (bvx:bitvec) (bvy:bitvec), (mem bvx (n_bvs x)) ->
(mem bvy (n_bvs y)) -> is_a_ket_l ((f bvx) bvy) l) ->
((ket_sum_l (n_bvs (x + y)%Z)
(fun (bv:bitvec) => ((f (hpart bv x)) (tpart bv x))) l)
=
(ket_sum_l (n_bvs x)
(fun (bvx:bitvec) =>
(ket_sum_l (n_bvs y) (fun (bvy:bitvec) => ((f bvx) bvy)) l))
l)).
Axiom ket_sum_bv_to_ints :
forall (n:Z) (f:bitvec -> matrix t) (g:Z -> matrix t), (n >= 0%Z)%Z ->
(forall (x:bitvec), ((length x) = n) -> ((f x) = (g (bv_to_int x)))) ->
((ket_sum_l (n_bvs n) f n) = (ket_sum_l (to_fset 0%Z (power 2%Z n)) g n)).
Axiom ket_sum_sum_rev :
forall (f:bitvec -> bitvec -> matrix t) (sx:set bitvec) (sy:set bitvec)
(l:Z),
(0%Z <= l)%Z -> (forall (x:bitvec), (mem x sx) -> ((length x) = l)) ->
(forall (y:bitvec), (mem y sy) -> ((length y) = l)) ->
(forall (x:bitvec) (y:bitvec), ((length x) = l) -> ((length y) = l) ->
is_a_ket_l ((f x) y) l) ->
((ket_sum_l sx (fun (x:bitvec) => (ket_sum_l sy (f x) l)) l) =
(ket_sum_l sy
(fun (y:bitvec) => (ket_sum_l sx (fun (x:bitvec) => ((f x) y)) l)) l)).
Axiom get_ket_sum :
forall (f:bitvec -> t) (n:Z) (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (n >= 0%Z)%Z ->
((get_ket
(ket_sum_l (n_bvs n)
(fun (y:bitvec) => (infix_asdtdt (f y) (bv_to_ket y))) n)
i)
= (f (int_to_bv i n))).
Axiom get_ket_scalar :
forall (x:matrix t) (a:t) (i:Z),
((0%Z <= i)%Z /\ (i < (ket_length x))%Z) ->
((get_ket (infix_asdtdt a x) i) = (infix_asdt a (get_ket x i))).
Axiom get_ket_scalar_zero :
forall (x:matrix t) (a:t),
((get_ket (infix_asdtdt a x) 0%Z) = (infix_asdt a (get_ket x 0%Z))).
Axiom ket_sum_sum_complex :
forall (f:bitvec -> bitvec -> t) (sx:set bitvec) (sy:set bitvec) (l:Z),
(0%Z <= l)%Z -> (forall (x:bitvec), (mem x sx) -> ((length x) = l)) ->
(forall (y:bitvec), (mem y sy) -> ((length y) = l)) ->
((ket_sum_l sx
(fun (x:bitvec) =>
(ket_sum_l sy (fun (y:bitvec) => (infix_asdtdt ((f x) y) (bv_to_ket y)))
l))
l)
=
(ket_sum_l sy
(fun (y:bitvec) =>
(infix_asdtdt (sum sx (fun (x:bitvec) => ((f x) y))) (bv_to_ket y)))
l)).
Axiom gate : Type.
Parameter gate_WhyType : WhyType gate.
Existing Instance gate_WhyType.
Parameter size: gate -> Z.
Axiom size_spec : forall (c:gate), ((size c) >= 0%Z)%Z.
Parameter range: gate -> Z.
Axiom range_spec : forall (c:gate), ((range c) >= 0%Z)%Z.
Parameter basis_ket: gate -> bitvec -> bitvec -> bitvec.
Axiom basis_ket_spec :
forall (c:gate) (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = (range c)) -> ((length (basis_ket c x y)) = (size c)).
Parameter basis_ket_i: gate -> bitvec -> bitvec -> Z -> Z.
Axiom basis_ket_i_def :
forall (c:gate) (x:bitvec) (y:bitvec) (i:Z),
((basis_ket_i c x y i) = ((getbv (basis_ket c x y)) i)).
Axiom basis_ket_i_spec :
forall (c:gate) (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = (range c)) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((basis_ket_i c x y i) = ((getbv (basis_ket c x y)) i)).
Axiom basis_ket_from_i :
forall (c:gate) (x:bitvec) (y:bitvec) (z:bitvec),
((length x) = (size c)) -> ((length y) = (range c)) ->
((length z) = (size c)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(((getbv z) i) = (basis_ket_i c x y i))) ->
((basis_ket c x y) = z).
Parameter ang_ind_i: gate -> bitvec -> bitvec -> Z -> angle.
Parameter ang_ind_bound: gate -> Z.
Parameter ang_ind: gate -> bitvec -> bitvec -> angle.
Axiom ang_ind_def :
forall (c:gate) (x:bitvec) (y:bitvec),
((ang_ind c x y) =
(ang_sum
((((fun (y0:gate) (y1:bitvec) (y2:bitvec) (y3:Z) =>
(ang_ind_i y0 y1 y2 y3))
c)
x)
y)
0%Z (ang_ind_bound c))).
Parameter ang_ind_exp: gate -> bitvec -> bitvec -> t.
Axiom ang_ind_exp_def :
forall (c:gate) (x:bitvec) (y:bitvec),
((ang_ind_exp c x y) = (ang_exp (ang_ind c x y))).
Parameter phase: angle -> gate.
Axiom phase_spec : forall (o:angle), ((range (phase o)) = 0%Z).
Axiom phase_spec1 : forall (o:angle), ((size (phase o)) = 1%Z).
Axiom phase_spec2 :
forall (o:angle), forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) ->
((length y) = 0%Z) -> ((basis_ket (phase o) x y) = x).
Axiom phase_spec3 :
forall (o:angle), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = 1%Z) -> ((length y) = 0%Z) -> (i = 0%Z) ->
((basis_ket_i (phase o) x y i) = ((getbv x) i)).
Axiom phase_spec4 : forall (o:angle), ((ang_ind_bound (phase o)) = 1%Z).
Axiom phase_spec5 :
forall (o:angle), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = 1%Z) -> ((length y) = 0%Z) -> (i = 0%Z) ->
((ang_ind_i (phase o) x y i) = o).
Axiom phase_spec6 :
forall (o:angle), forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) ->
((length y) = 0%Z) -> ((ang_ind (phase o) x y) = o).
Parameter rz: angle -> gate.
Axiom rz_spec : forall (o:angle), ((range (rz o)) = 0%Z).
Axiom rz_spec1 : forall (o:angle), ((size (rz o)) = 1%Z).
Axiom rz_spec2 :
forall (o:angle), forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) ->
((length y) = 0%Z) -> ((basis_ket (rz o) x y) = x).
Axiom rz_spec3 :
forall (o:angle), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = 1%Z) -> ((length y) = 0%Z) -> (i = 0%Z) ->
((basis_ket_i (rz o) x y i) = ((getbv x) i)).
Axiom rz_spec4 :
forall (o:angle), forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) ->
((length y) = 0%Z) ->
((ang_ind (rz o) x y) = (phase_inv_ (1%Z - ((getbv x) 0%Z))%Z o)).
Axiom rz_spec5 : forall (o:angle), ((ang_ind_bound (rz o)) = 1%Z).
Axiom rz_spec6 :
forall (o:angle), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = 1%Z) -> ((length y) = 0%Z) -> (i = 0%Z) ->
((ang_ind_i (rz o) x y i) = (phase_inv_ (1%Z - ((getbv x) i))%Z o)).
Parameter hadamard: gate.
Axiom hadamard_def : ((range hadamard) = 1%Z).
Axiom hadamard_def1 : ((size hadamard) = 1%Z).
Axiom hadamard_def2 :
forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) -> ((length y) = 1%Z) ->
((basis_ket hadamard x y) = y).
Axiom hadamard_def3 :
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = 1%Z) ->
((length y) = 1%Z) -> (i = 0%Z) ->
((basis_ket_i hadamard x y i) = ((getbv y) i)).
Axiom hadamard_def4 :
forall (x:bitvec) (y:bitvec), ((length x) = 1%Z) -> ((length y) = 1%Z) ->
((ang_ind hadamard x y) =
(int_to_ang (((getbv x) 0%Z) * ((getbv y) 0%Z))%Z 1%Z)).
Axiom hadamard_def5 : ((ang_ind_bound hadamard) = 1%Z).
Axiom hadamard_def6 :
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = 1%Z) ->
((length y) = 1%Z) -> (i = 0%Z) ->
((ang_ind_i hadamard x y i) =
(int_to_ang (((getbv x) i) * ((getbv y) i))%Z 1%Z)).
Parameter cnot: gate.
Axiom cnot_def : ((range cnot) = 0%Z).
Axiom cnot_def1 : ((size cnot) = 2%Z).
Axiom cnot_def2 :
forall (x:bitvec) (y:bitvec), ((length x) = 2%Z) -> ((length y) = 0%Z) ->
((((getbv x) 0%Z) = 0%Z) -> ((basis_ket cnot x y) = x)) /\
(~ (((getbv x) 0%Z) = 0%Z) ->
((((getbv x) 1%Z) = 0%Z) -> ((basis_ket cnot x y) = (int_to_bv 3%Z 2%Z))) /\
(~ (((getbv x) 1%Z) = 0%Z) ->
((basis_ket cnot x y) = (int_to_bv 2%Z 2%Z)))).
Axiom cnot_def3 :
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = 2%Z) ->
((length y) = 1%Z) -> (i = 0%Z) ->
((basis_ket_i cnot x y i) = ((getbv x) i)).
Axiom cnot_def4 :
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = 2%Z) ->
((length y) = 1%Z) -> (i = 1%Z) ->
((basis_ket_i cnot x y i) = (xor_i ((getbv x) 0%Z) ((getbv x) i))).
Axiom cnot_def5 :
forall (x:bitvec) (y:bitvec), ((length x) = 2%Z) -> ((length y) = 0%Z) ->
((ang_ind cnot x y) = ang_zero).
Axiom cnot_def6 : ((ang_ind_bound cnot) = 1%Z).
Axiom cnot_def7 :
forall (x:bitvec) (y:bitvec), ((length x) = 2%Z) -> ((length y) = 0%Z) ->
((ang_ind_i cnot x y 0%Z) = ang_zero).
Parameter parallel: gate -> gate -> gate.
Axiom parallel_spec :
forall (d:gate) (e1:gate),
((size (parallel d e1)) = ((size d) + (size e1))%Z).
Axiom parallel_spec1 :
forall (d:gate) (e1:gate),
((range (parallel d e1)) = ((range d) + (range e1))%Z).
Axiom parallel_spec2 :
forall (d:gate) (e1:gate), forall (x:bitvec) (y:bitvec),
((length x) = (size (parallel d e1))) ->
((length y) = (range (parallel d e1))) ->
((basis_ket (parallel d e1) x y) =
(concat (basis_ket d (hpart x (size d)) (hpart y (range d)))
(basis_ket e1 (tpart x (size d)) (tpart y (range d))))).
Axiom parallel_spec3 :
forall (d:gate) (e1:gate), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = (size (parallel d e1))) ->
((length y) = (range (parallel d e1))) ->
((0%Z <= i)%Z /\ (i < ((size d) + (size e1))%Z)%Z) ->
((i < (size d))%Z ->
((basis_ket_i (parallel d e1) x y i) =
(basis_ket_i d (hpart x (size d)) (hpart y (range d)) i))) /\
(~ (i < (size d))%Z ->
((basis_ket_i (parallel d e1) x y i) =
(basis_ket_i e1 (tpart x (size d)) (tpart y (range d)) (i - (size d))%Z))).
Axiom parallel_spec4 :
forall (d:gate) (e1:gate),
((ang_ind_bound (parallel d e1)) =
((ang_ind_bound d) + (ang_ind_bound e1))%Z).
Axiom parallel_spec5 :
forall (d:gate) (e1:gate), forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = (size (parallel d e1))) ->
((length y) = (range (parallel d e1))) ->
((0%Z <= i)%Z /\ (i < ((range d) + (range e1))%Z)%Z) ->
((i < (ang_ind_bound d))%Z ->
((ang_ind_i (parallel d e1) x y i) =
(ang_ind_i d (hpart x (size d)) (hpart y (range d)) i))) /\
(~ (i < (ang_ind_bound d))%Z ->
((ang_ind_i (parallel d e1) x y i) =
(ang_ind_i e1 (tpart x (size d)) (tpart y (range d)) (i - (range d))%Z))).
Axiom parallel_spec6 :
forall (d:gate) (e1:gate), forall (x:bitvec) (y:bitvec),
((length x) = (size (parallel d e1))) ->
((length y) = (range (parallel d e1))) ->
((ang_ind (parallel d e1) x y) =
(ang_add (ang_ind d (hpart x (size d)) (hpart y (range d)))
(ang_ind e1 (tpart x (size d)) (tpart y (range d))))).
Parameter sequence: gate -> gate -> gate.
Axiom sequence_spec :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
((range (sequence d e1)) = ((range d) + (range e1))%Z).
Axiom sequence_spec1 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
((size (sequence d e1)) = (size d)).
Axiom sequence_spec2 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
forall (x:bitvec) (y:bitvec), ((length x) = (size (sequence d e1))) ->
((length y) = (range (sequence d e1))) ->
((basis_ket (sequence d e1) x y) =
(basis_ket e1 (basis_ket d x (hpart y (range d))) (tpart y (range d)))).
Axiom sequence_spec3 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = (size (sequence d e1))) ->
((length y) = (range (sequence d e1))) ->
((0%Z <= i)%Z /\ (i < (size d))%Z) ->
((basis_ket_i (sequence d e1) x y i) =
(basis_ket_i e1 (basis_ket d x (hpart y (range d))) (tpart y (range d)) i)).
Axiom sequence_spec4 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
((ang_ind_bound (sequence d e1)) =
((ang_ind_bound d) + (ang_ind_bound e1))%Z).
Axiom sequence_spec5 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = (size (sequence d e1))) ->
((length y) = (range (sequence d e1))) ->
((0%Z <= i)%Z /\ (i < (ang_ind_bound (sequence d e1)))%Z) ->
((i < (ang_ind_bound d))%Z ->
((ang_ind_i (sequence d e1) x y i) =
(ang_ind_i d x (hpart y (range d)) i))) /\
(~ (i < (ang_ind_bound d))%Z ->
((ang_ind_i (sequence d e1) x y i) =
(ang_ind_i e1 (basis_ket d x (hpart y (range d))) (tpart y (range d))
(i - (range d))%Z))).
Axiom sequence_spec6 :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
forall (x:bitvec) (y:bitvec), ((length x) = (size (sequence d e1))) ->
((length y) = (range (sequence d e1))) ->
((ang_ind (sequence d e1) x y) =
(ang_add (ang_ind d x (hpart y (range d)))
(ang_ind e1 (basis_ket d x (hpart y (range d))) (tpart y (range d))))).
Parameter mat_sem: gate -> matrix t.
Axiom mat_sem_spec :
forall (c:gate), ((columns (mat_sem c)) = (power 2%Z (size c))).
Axiom mat_sem_spec1 :
forall (c:gate), ((rows (mat_sem c)) = (power 2%Z (size c))).
Parameter path_sum_scheme_unit:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> bitvec -> matrix t.
Axiom path_sum_scheme_unit_def :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:bitvec),
(range1 >= 0%Z)%Z -> ((length x) = size1) ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme_unit a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a x) y)) (bv_to_ket ((k x) y))))
size1))).
Axiom path_sum_scheme_unit_spec :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:bitvec),
(range1 >= 0%Z)%Z -> ((length x) = size1) ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
is_a_ket_l (path_sum_scheme_unit a k size1 range1 x) size1.
Parameter path_sum_scheme:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> (matrix t) -> matrix t.
Axiom path_sum_scheme_def :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z))
(path_sum_scheme_unit a k size1 range1 (hpart z size1))))
size1)).
Axiom path_sum_scheme_spec :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
is_a_ket_l (path_sum_scheme a k size1 range1 x) size1.
Axiom path_sum_scheme_spec1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z))
(path_sum_scheme_unit a k size1 range1 z)))
size1)).
Axiom path_sum_scheme_basis :
forall (a:bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec), forall (size1:Z) (range1:Z),
forall (x:matrix t), (is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
(is_a_ket_basis_elt x) ->
((path_sum_scheme a k size1 range1 x) =
(path_sum_scheme_unit a k size1 range1 (ket_to_bv x))).
Axiom set_path_sum_basis :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (is_a_ket_basis_elt x) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(path_sum_scheme_unit a k size1 range1 (ket_to_bv x))).
Axiom mat_sem_sequence :
forall (d:gate) (e1:gate), ((size d) = (size e1)) ->
((mat_sem (sequence d e1)) = (mat_mult (mat_sem e1) (mat_sem d))).
Axiom mat_sem_par :
forall (d:gate) (e1:gate),
((mat_sem (parallel d e1)) = (kronecker (mat_sem d) (mat_sem e1))).
Axiom path_sum_decomp :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z))
(path_sum_scheme a k size1 range1 (bv_to_ket z))))
size1)).
Axiom get_path_sum_basis :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:bitvec),
((length x) = size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme_unit a k size1 range1 x) =
(path_sum_scheme a k size1 range1 (bv_to_ket x))).
Parameter correct_path_sum_unit:
gate -> (bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) ->
Z -> bitvec -> Prop.
Axiom correct_path_sum_unit_def :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
(correct_path_sum_unit c a k range1 x) -> forall (x1:bitvec) (y:bitvec),
((length x1) = (size c)) -> ((length y) = range1) ->
((length ((k x1) y)) = (size c)).
Axiom correct_path_sum_unit_def1 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
(correct_path_sum_unit c a k range1 x) -> (range1 >= 0%Z)%Z.
Axiom correct_path_sum_unit_def2 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
(correct_path_sum_unit c a k range1 x) -> ((length x) = (size c)).
Axiom correct_path_sum_unit_def3 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
(correct_path_sum_unit c a k range1 x) ->
((mat_mult (mat_sem c) (bv_to_ket x)) =
(path_sum_scheme_unit a k (size c) range1 x)).
Axiom correct_path_sum_unit_def4 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
((forall (x1:bitvec) (y:bitvec), ((length x1) = (size c)) ->
((length y) = range1) -> ((length ((k x1) y)) = (size c))) /\
((range1 >= 0%Z)%Z /\
(((length x) = (size c)) /\
((mat_mult (mat_sem c) (bv_to_ket x)) =
(path_sum_scheme_unit a k (size c) range1 x))))) ->
correct_path_sum_unit c a k range1 x.
Parameter correct_path_sum:
gate -> (bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) ->
Z -> Prop.
Axiom correct_path_sum_def :
forall (c:gate), forall (a:bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec), forall (range1:Z),
(correct_path_sum c a k range1) -> forall (x:bitvec) (y:bitvec),
((length x) = (size c)) -> ((length y) = range1) ->
((length ((k x) y)) = (size c)).
Axiom correct_path_sum_def1 :
forall (c:gate), forall (a:bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec), forall (range1:Z),
(correct_path_sum c a k range1) -> (range1 >= 0%Z)%Z.
Axiom correct_path_sum_def2 :
forall (c:gate), forall (a:bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec), forall (range1:Z),
(correct_path_sum c a k range1) -> forall (x:matrix t),
(is_a_ket_l x (size c)) ->
((mat_mult (mat_sem c) x) = (path_sum_scheme a k (size c) range1 x)).
Axiom correct_path_sum_def3 :
forall (c:gate), forall (a:bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec), forall (range1:Z),
((forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> ((length ((k x) y)) = (size c))) /\
((range1 >= 0%Z)%Z /\
forall (x:matrix t), (is_a_ket_l x (size c)) ->
((mat_mult (mat_sem c) x) = (path_sum_scheme a k (size c) range1 x)))) ->
correct_path_sum c a k range1.
Axiom correct_path_sum_basis :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:bitvec),
((length x) = (size c)) -> (correct_path_sum c a k range1) ->
correct_path_sum_unit c a k range1 x.
Axiom correct_main_path_sum :
forall (c:gate),
correct_path_sum c
((fun (y0:gate) (y1:bitvec) (y2:bitvec) => (ang_ind y0 y1 y2)) c)
((fun (y0:gate) (y1:bitvec) (y2:bitvec) => (basis_ket y0 y1 y2)) c)
(range c).
Axiom set_correct_main_path_sum :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> (((a x) y) = (ang_ind c x y))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> (((b x) y) = (basis_ket c x y))) ->
(r = (range c)) -> correct_path_sum c a b r.
Parameter pat_sem: gate -> (matrix t) -> matrix t.
Axiom pat_sem_def :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
((pat_sem c x) =
(path_sum_scheme
((fun (y0:gate) (y1:bitvec) (y2:bitvec) => (ang_ind y0 y1 y2)) c)
((fun (y0:gate) (y1:bitvec) (y2:bitvec) => (basis_ket y0 y1 y2)) c)
(size c) (range c) x)).
Axiom pat_sem_spec :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
is_a_ket_l (pat_sem c x) (size c).
Axiom pat_sem_decomp :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
((pat_sem c x) =
(ket_sum_l (n_bvs (size c))
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z)) (pat_sem c (bv_to_ket z))))
(size c))).
Axiom pat_sem_unit :
forall (c:gate) (x:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_l x (size c)) ->
((pat_sem c x) =
(infix_asdtdt (pow_inv_sqrt_2 (range c))
(ket_sum_l (n_bvs (range c))
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp (ang_ind c (ket_to_bv x) y))
(bv_to_ket (basis_ket c (ket_to_bv x) y))))
(size c)))).
Parameter sem: gate -> (matrix t) -> (matrix t) -> Prop.
Axiom def_sem :
forall (c:gate), forall (x:matrix t) (y:matrix t), (sem c x y) ->
is_a_ket_l x (size c).
Axiom def_sem1 :
forall (c:gate), forall (x:matrix t) (y:matrix t), (sem c x y) ->
((pat_sem c x) = y).
Axiom def_sem2 :
forall (c:gate), forall (x:matrix t) (y:matrix t),
((is_a_ket_l x (size c)) /\ ((pat_sem c x) = y)) -> sem c x y.
Axiom sem_ket_l :
forall (c:gate) (x:matrix t) (y:matrix t), (sem c x y) ->
is_a_ket_l y (size c).
Axiom pat_to_mat_sem :
forall (c:gate) (x:matrix t) (y:matrix t), (is_a_ket_l x (size c)) ->
((pat_sem c x) = y) -> ((mat_mult (mat_sem c) x) = y).
Axiom mat_to_pat_sem :
forall (c:gate) (x:matrix t) (y:matrix t), (is_a_ket_l x (size c)) ->
((mat_mult (mat_sem c) x) = y) -> ((pat_sem c x) = y).
Axiom sem_to_mat :
forall (c:gate) (x:matrix t) (y:matrix t), (sem c x y) ->
((mat_mult (mat_sem c) x) = y).
Axiom sem_to_pat :
forall (c:gate) (x:matrix t) (y:matrix t), (sem c x y) ->
((pat_sem c x) = y).
Axiom mat_to_sem :
forall (c:gate) (x:matrix t) (y:matrix t), (is_a_ket_l x (size c)) ->
((mat_mult (mat_sem c) x) = y) -> sem c x y.
Axiom pat_to_sem :
forall (c:gate) (x:matrix t) (y:matrix t), (is_a_ket_l x (size c)) ->
((pat_sem c x) = y) -> sem c x y.
Axiom add_sem :
forall (c:gate) (x:matrix t) (x':matrix t) (y:matrix t) (y':matrix t),
(sem c x y) -> (sem c x' y') -> sem c (add_mat x x') (add_mat y y').
Axiom pat_sem_add :
forall (c:gate) (x:matrix t) (x':matrix t) (y:matrix t) (y':matrix t),
((pat_sem c x) = y) -> ((pat_sem c x') = y') ->
((pat_sem c (add_mat x x')) = (add_mat y y')).
Axiom scal_sem :
forall (c:gate) (x:matrix t) (y:matrix t) (sc:t), (sem c x y) ->
sem c (infix_asdtdt sc x) (infix_asdtdt sc y).
Axiom pat_sem_scal_ :
forall (c:gate) (x:matrix t) (y:matrix t) (sc:t),
(is_a_ket_l x (size c)) -> ((pat_sem c x) = y) ->
((pat_sem c (infix_asdtdt sc x)) = (infix_asdtdt sc y)).
Axiom pat_sem_scal :
forall (c:gate) (x:matrix t) (sc:t), (is_a_ket_l x (size c)) ->
((pat_sem c (infix_asdtdt sc x)) = (infix_asdtdt sc (pat_sem c x))).
Axiom comp_sem :
forall (c:gate) (c':gate) (x:matrix t) (y:matrix t) (z:matrix t),
((size c) = (size c')) -> (sem c x y) -> (sem c' y z) ->
sem (sequence c c') x z.
Axiom pat_sem_comp :
forall (c:gate) (c':gate) (x:matrix t) (y:matrix t) (z:matrix t),
((size c) = (size c')) -> ((pat_sem c x) = y) -> ((pat_sem c' y) = z) ->
((pat_sem (sequence c c') x) = z).
Axiom par_sem :
forall (c:gate) (c':gate) (x:matrix t) (y:matrix t) (z:matrix t)
(t1:matrix t),
(sem c x y) -> (sem c' z t1) ->
sem (parallel c c') (kronecker x z) (kronecker y t1).
Axiom sum_sem :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (s:set a) (f:a -> matrix t) (g:a -> matrix t),
((cardinal s) >= 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> sem c (f e1) (g e1)) ->
sem c (ket_sum_l s f (size c)) (ket_sum_l s g (size c)).
Axiom sum_sem_gen :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (s:set a) (f:a -> matrix t) (g:a -> matrix t) (l1:Z) (l2:Z),
((cardinal s) >= 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> sem c (f e1) (g e1)) -> (l1 = (size c)) ->
(l2 = (size c)) -> sem c (ket_sum_l s f l1) (ket_sum_l s g l2).
Axiom sum_scal_sem :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (s:set a) (f:a -> matrix t) (h:a -> matrix t) (g:a -> t),
((cardinal s) >= 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> sem c (f e1) (h e1)) ->
sem c (ket_sum_l s (fun (e1:a) => (infix_asdtdt (g e1) (f e1))) (size c))
(ket_sum_l s (fun (e1:a) => (infix_asdtdt (g e1) (h e1))) (size c)).
Axiom scal_pat_sem :
forall (c:gate) (x:matrix t) (sc:t),
((pat_sem c (infix_asdtdt sc x)) = (infix_asdtdt sc (pat_sem c x))).
Axiom comp_sem_scal :
forall (c:gate) (c':gate) (x:matrix t) (y:matrix t) (z:matrix t) (a:t),
((size c) = (size c')) -> (sem c x y) -> (sem c' y z) ->
sem (sequence c c') (infix_asdtdt a x) (infix_asdtdt a z).
Axiom comp_sem_add :
forall (c:gate) (c':gate) (x:matrix t) (x':matrix t) (y:matrix t)
(y':matrix t) (z:matrix t) (z':matrix t),
((size c) = (size c')) -> (sem c x y) -> (sem c x' y') -> (sem c' y z) ->
(sem c' y' z') -> sem (sequence c c') (add_mat x x') (add_mat z z').
Axiom comp_sem_sum :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (c':gate) (f:a -> matrix t) (g:a -> matrix t)
(h:a -> matrix t) (s:set a),
((cardinal s) > 0%Z)%Z -> ((size c) = (size c')) ->
(forall (e1:a), (mem e1 s) -> sem c (f e1) (g e1)) ->
(forall (e1:a), (mem e1 s) -> sem c' (g e1) (h e1)) ->
sem (sequence c c') (ket_sum_l s f (size c)) (ket_sum_l s h (size c)).
Axiom comp_sem_basis :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (c':gate) (g:a -> matrix t) (h:a -> matrix t) (s:set a)
(x:matrix t),
((cardinal s) > 0%Z)%Z -> ((size c) = (size c')) ->
(sem c x (ket_sum_l s g (size c))) ->
(forall (e1:a), (mem e1 s) -> sem c' (g e1) (h e1)) ->
sem (sequence c c') x (ket_sum_l s h (size c)).
Axiom sem_decomp :
forall (c:gate) (f:bitvec -> matrix t) (x:matrix t),
(forall (x1:bitvec), ((length x1) = (size c)) ->
sem c (bv_to_ket x1) (f x1)) ->
sem c x
(ket_sum_l (n_bvs (size c))
(fun (j:bitvec) => (infix_asdtdt (get_ket_bv x j) (f j))) (size c)).
Axiom pat_sem_sum :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (s:set a) (f:a -> matrix t) (g:a -> matrix t) (n:Z),
((cardinal s) >= 1%Z)%Z -> (n = (size c)) ->
(forall (x:a), (mem x s) -> is_a_ket_l (f x) (size c)) ->
(forall (x:a), (mem x s) -> ((pat_sem c (f x)) = (g x))) ->
((pat_sem c (ket_sum_l s f n)) = (ket_sum_l s g n)).
Axiom pat_sem_sum_ :
forall {a:Type} {a_WT:WhyType a},
forall (c:gate) (s:set a) (f:a -> matrix t) (n:Z),
((cardinal s) >= 1%Z)%Z -> (n = (size c)) ->
(forall (x:a), (mem x s) -> is_a_ket_l (f x) (size c)) ->
((pat_sem c (ket_sum_l s f n)) =
(ket_sum_l s (fun (x:a) => (pat_sem c (f x))) n)).
Axiom set_correct_path_sum :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(r >= 0%Z)%Z ->
(forall (x:bitvec), ((length x) = (size c)) ->
correct_path_sum_unit c a k r x) ->
correct_path_sum c a k r.
Axiom get_correct_path_sum :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> (r >= 0%Z)%Z.
Axiom get_correct_path_sum1 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:bitvec), ((length x) = (size c)) ->
correct_path_sum_unit c a k r x.
Axiom get_correct_path_sum2 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:bitvec) (y:bitvec),
((length x) = (size c)) -> ((length y) = r) ->
((length ((k x) y)) = (size c)).
Axiom get_correct_path_sum3 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:bitvec), ((length x) = (size c)) ->
((mat_mult (mat_sem c) (bv_to_ket x)) =
(path_sum_scheme_unit a k (size c) r x)).
Axiom get_correct_path_sum4 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:bitvec), ((length x) = (size c)) ->
((mat_mult (mat_sem c) (bv_to_ket x)) =
(infix_asdtdt (pow_inv_sqrt_2 r)
(ket_sum_l (n_bvs r)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a x) y)) (bv_to_ket ((k x) y))))
(size c)))).
Axiom set_sem_by_main_basis :
forall (c:gate) (f:bitvec -> matrix t) (r:Z) (s:Z) (x:matrix t),
(is_a_ket_l x s) -> (is_a_ket_basis_elt x) ->
(forall (y:bitvec), ((length y) = r) ->
((f y) =
(infix_asdtdt (ang_exp (ang_ind c (ket_to_bv x) y))
(bv_to_ket (basis_ket c (ket_to_bv x) y))))) ->
(r = (range c)) -> (s = (size c)) ->
sem c x (infix_asdtdt (pow_inv_sqrt_2 r) (ket_sum_l (n_bvs r) f s)).
Axiom set_correct_path_sum_sim :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(a':bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(k':bitvec -> bitvec -> bitvec) (range1:Z) (range':Z),
(range1 >= 0%Z)%Z -> (range1 = range') ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> (((a x) y) = ((a' x) y))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> ((length ((k' x) y)) = (size c))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(((getbv ((k x) y)) i) = ((getbv ((k' x) y)) i))) ->
(correct_path_sum c a k range1) -> correct_path_sum c a' k' range'.
Axiom path_sum_equiv :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(a':bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(k':bitvec -> bitvec -> bitvec) (range1:Z) (range':Z),
(range1 >= 0%Z)%Z -> (range1 = range') ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> (((a x) y) = ((a' x) y))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> (((k x) y) = ((k' x) y))) ->
(correct_path_sum c a k range1) -> correct_path_sum c a' k' range'.
Axiom path_sum_equiv1 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(a':bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(k':bitvec -> bitvec -> bitvec) (range1:Z) (range':Z),
(range1 >= 0%Z)%Z -> (range1 = range') ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> (((a x) y) = ((a' x) y))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) -> (((k x) y) = ((k' x) y))) ->
(correct_path_sum c a' k' range') -> correct_path_sum c a k range1.
Axiom correct_seq :
forall (c:gate) (c':gate),
forall (a:bitvec -> bitvec -> angle) (a':bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec) (k':bitvec -> bitvec -> bitvec),
forall (range1:Z) (range':Z), (correct_path_sum c a k range1) ->
(correct_path_sum c' a' k' range') ->
correct_path_sum (sequence c c')
(fun (x:bitvec) (y:bitvec) =>
(ang_add ((a x) (hpart y range1))
((a' ((k x) (hpart y range1))) (tpart y range1))))
(fun (x:bitvec) (y:bitvec) =>
((k' ((k x) (hpart y range1))) (tpart y range1)))
(range1 + range')%Z.
Axiom set_correct_seq :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> angle)
(a:bitvec -> bitvec -> angle) (a':bitvec -> bitvec -> angle)
(bse:bitvec -> bitvec -> bitvec) (b:bitvec -> bitvec -> bitvec)
(b':bitvec -> bitvec -> bitvec) (s:Z) (rse:Z) (r:Z) (r':Z),
(0%Z <= r)%Z -> (0%Z <= r')%Z ->
(((size c) = (size c')) /\ ((size c') = s)) ->
(correct_path_sum c a b r) -> (correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec), ((length x) = s) -> ((length y) = rse) ->
(((ase x) y) =
(ang_add ((a x) (hpart y r)) ((a' ((b x) (hpart y r))) (tpart y r))))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = s) -> ((length y) = rse) ->
(((bse x) y) = ((b' ((b x) (hpart y r))) (tpart y r)))) ->
(rse = (r + r')%Z) -> correct_path_sum (sequence c c') ase bse rse.
Axiom correct_par :
forall (c:gate) (c':gate),
forall (a:bitvec -> bitvec -> angle) (a':bitvec -> bitvec -> angle),
forall (k:bitvec -> bitvec -> bitvec) (k':bitvec -> bitvec -> bitvec),
forall (range1:Z) (range':Z), (correct_path_sum c a k range1) ->
(correct_path_sum c' a' k' range') ->
correct_path_sum (parallel c c')
(fun (x:bitvec) (y:bitvec) =>
(ang_add ((a (hpart x (size c))) (hpart y range1))
((a' (tpart x (size c))) (tpart y range1))))
(fun (x:bitvec) (y:bitvec) =>
(concat ((k (hpart x (size c))) (hpart y range1))
((k' (tpart x (size c))) (tpart y range1))))
(range1 + range')%Z.
Axiom set_correct_par :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> angle)
(a:bitvec -> bitvec -> angle) (a':bitvec -> bitvec -> angle)
(bse:bitvec -> bitvec -> bitvec) (b:bitvec -> bitvec -> bitvec)
(b':bitvec -> bitvec -> bitvec) (s:Z) (rse:Z) (r:Z) (r':Z),
(0%Z <= r)%Z -> (0%Z <= r')%Z -> (correct_path_sum c a b r) ->
(correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec), ((length x) = s) -> ((length y) = rse) ->
(((ase x) y) =
(ang_add ((a (hpart x (size c))) (hpart y r))
((a' (tpart x (size c))) (tpart y r))))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = s) -> ((length y) = rse) ->
(((bse x) y) =
(concat ((b (hpart x (size c))) (hpart y r))
((b' (tpart x (size c))) (tpart y r))))) ->
(rse = (r + r')%Z) -> (s = ((size c) + (size c'))%Z) ->
correct_path_sum (parallel c c') ase bse rse.
Axiom correct_to_pat_sem :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:matrix t),
(is_a_ket_l x (size c)) ->
((path_sum_scheme a k (size c) r x) = (pat_sem c x)).
Axiom correct_to_mat_sem :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:matrix t),
(is_a_ket_l x (size c)) ->
((path_sum_scheme a k (size c) r x) = (mat_mult (mat_sem c) x)).
Axiom correct_to_sem :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a k r) -> forall (x:matrix t) (y:matrix t),
(is_a_ket_l x (size c)) -> ((path_sum_scheme a k (size c) r x) = y) ->
sem c x y.
Axiom mat_sem_to_correct :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(r >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> ((length ((k x) y)) = (size c))) ->
(forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
((path_sum_scheme a k (size c) r x) = (mat_mult (mat_sem c) x))) ->
correct_path_sum c a k r.
Axiom pat_sem_to_correct :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(r >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> ((length ((k x) y)) = (size c))) ->
(forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
((path_sum_scheme a k (size c) r x) = (pat_sem c x))) ->
correct_path_sum c a k r.
Axiom sem_to_correct :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (r:Z),
(r >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> ((length ((k x) y)) = (size c))) ->
(forall (x:matrix t) (y:matrix t), (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) -> ((path_sum_scheme a k (size c) r x) = y) ->
sem c x y) ->
correct_path_sum c a k r.
Parameter correct_path_sum_i:
gate -> (bitvec -> bitvec -> Z -> angle) -> Z -> Z ->
(bitvec -> bitvec -> Z -> Z) -> Z -> Prop.
Axiom correct_path_sum_i_spec :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(0%Z <= (((k x) y) i))%Z.
Axiom correct_path_sum_i_spec1 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((k x) y) i) < 2%Z)%Z.
Axiom correct_path_sum_i_spec2 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(make_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1.
Axiom correct_path_sum_i_spec3 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
((forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(0%Z <= (((k x) y) i))%Z /\ ((((k x) y) i) < 2%Z)%Z) /\
(correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(make_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1)) ->
correct_path_sum_i c a l h k range1.
Axiom set_correct_path_sum_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(0%Z <= (((k x) y) i))%Z /\ ((((k x) y) i) < 2%Z)%Z) ->
(correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(make_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1) ->
correct_path_sum_i c a l h k range1.
Axiom correct_path_sum_i_main :
forall (c:gate) (h':Z) (r':Z), (h' = (ang_ind_bound c)) ->
(r' = (range c)) ->
correct_path_sum_i c
((fun (y0:gate) (y1:bitvec) (y2:bitvec) (y3:Z) => (ang_ind_i y0 y1 y2 y3))
c)
0%Z h'
((fun (y0:gate) (y1:bitvec) (y2:bitvec) (y3:Z) =>
(basis_ket_i y0 y1 y2 y3))
c)
r'.
Axiom correct_path_sum_i_to_sem_basis :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z) (x:matrix t)
(f:bitvec -> matrix t),
(correct_path_sum_i c a l h k range1) -> (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) ->
(forall (y:bitvec), ((length y) = range1) ->
((f y) =
(infix_asdtdt (ang_exp (ang_sum ((a (ket_to_bv x)) y) l h))
(bv_to_ket (make_bv ((k (ket_to_bv x)) y) (size c)))))) ->
sem c x
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1) f (size c))).
Axiom correct_path_sum_i_to_sem_basis_gen :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z)
(f:bitvec -> bitvec -> matrix t),
(correct_path_sum_i c a l h k range1) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = range1) ->
(((f x) y) =
(infix_asdtdt (ang_exp (ang_sum ((a x) y) l h))
(bv_to_ket (make_bv ((k x) y) (size c)))))) ->
forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1) (f (ket_to_bv x)) (size c))).
Axiom get_correct_path_sum_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) -> (range1 >= 0%Z)%Z.
Axiom get_correct_path_sum_i1 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
(0%Z <= (((k x) y) i))%Z.
Axiom get_correct_path_sum_i2 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = range1) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((k x) y) i) < 2%Z)%Z.
Axiom get_correct_path_sum_i3 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(make_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1.
Axiom get_correct_path_sum_i4 :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(makes_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1.
Parameter sequence_spec_i:
gate -> gate -> (bitvec -> bitvec -> Z -> angle) ->
(bitvec -> bitvec -> Z -> angle) -> (bitvec -> bitvec -> Z -> angle) ->
Z -> Z -> Z -> (bitvec -> bitvec -> Z -> Z) ->
(bitvec -> bitvec -> Z -> Z) -> (bitvec -> bitvec -> Z -> Z) -> Z ->
Z -> Z -> gate.
Axiom sequence_spec_i_def :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l z b r) ->
(correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
(((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) =
(((a' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
((sequence_spec_i c c' ase a a' l z h bse b b' rse r r') = (sequence c c')).
Axiom sequence_spec_i_spec :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l z b r) ->
(correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
(((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) =
(((a' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
correct_path_sum_i (sequence_spec_i c c' ase a a' l z h bse b b' rse r r')
ase l h bse rse.
Axiom sequence_spec_i_spec1 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l z b r) ->
(correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
(((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) =
(((a' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
((size (sequence_spec_i c c' ase a a' l z h bse b b' rse r r')) = (size c)).
Axiom sequence_spec_i_spec2 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l z b r) ->
(correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
(((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) =
(((a' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
((sequence_spec_i c c' ase a a' l z h bse b b' rse r r') = (sequence c c')).
Parameter sequence_spec_i_r:
gate -> gate -> (bitvec -> bitvec -> Z -> angle) ->
(bitvec -> bitvec -> Z -> angle) -> (bitvec -> bitvec -> angle) ->
Z -> Z -> (bitvec -> bitvec -> Z -> Z) -> (bitvec -> bitvec -> Z -> Z) ->
(bitvec -> bitvec -> bitvec) -> Z -> Z -> Z -> gate.
Axiom sequence_spec_i_r_def :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (a:bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b':bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum c a b r) ->
(correct_path_sum_i c' a' (l + 1%Z)%Z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b' ((b x) (hpart y r))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) -> ((((ase x) y) l) = ((a x) (hpart y r)))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> (((l + 1%Z)%Z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' ((b x) (hpart y r))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((sequence_spec_i_r c c' ase a' a l h bse b' b rse r r') =
(sequence_spec_i c c' ase (fun (x:bitvec) (y:bitvec) (i:Z) => ((a x) y))
a' l (l + 1%Z)%Z h bse
(fun (x:bitvec) (y:bitvec) (i:Z) => ((getbv ((b x) y)) i)) b' rse r r')).
Axiom sequence_spec_i_r_spec :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (a:bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b':bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum c a b r) ->
(correct_path_sum_i c' a' (l + 1%Z)%Z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b' ((b x) (hpart y r))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) -> ((((ase x) y) l) = ((a x) (hpart y r)))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> (((l + 1%Z)%Z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' ((b x) (hpart y r))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
correct_path_sum_i (sequence_spec_i_r c c' ase a' a l h bse b' b rse r r')
ase l h bse rse.
Axiom sequence_spec_i_r_spec1 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (a:bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b':bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum c a b r) ->
(correct_path_sum_i c' a' (l + 1%Z)%Z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b' ((b x) (hpart y r))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) -> ((((ase x) y) l) = ((a x) (hpart y r)))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> (((l + 1%Z)%Z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' ((b x) (hpart y r))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((size (sequence_spec_i_r c c' ase a' a l h bse b' b rse r r')) = (size c)).
Axiom sequence_spec_i_r_spec2 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (a:bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b':bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum c a b r) ->
(correct_path_sum_i c' a' (l + 1%Z)%Z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b' ((b x) (hpart y r))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) -> ((((ase x) y) l) = ((a x) (hpart y r)))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> (((l + 1%Z)%Z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' ((b x) (hpart y r))) (tpart y r)) i))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((sequence_spec_i_r c c' ase a' a l h bse b' b rse r r') = (sequence c c')).
Parameter sequence_spec_i_l:
gate -> gate -> (bitvec -> bitvec -> Z -> angle) ->
(bitvec -> bitvec -> Z -> angle) -> (bitvec -> bitvec -> angle) ->
Z -> Z -> (bitvec -> bitvec -> Z -> Z) -> (bitvec -> bitvec -> Z -> Z) ->
(bitvec -> bitvec -> bitvec) -> Z -> Z -> Z -> gate.
Axiom sequence_spec_i_l_def :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l (h - 1%Z)%Z b r) ->
(correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
((getbv ((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r))) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < (h - 1%Z)%Z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) ->
((((ase x) y) (h - 1%Z)%Z) =
((a' (make_bv (fun (i:Z) => (((b x) (hpart y r)) i)) (size c)))
(tpart y r)))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((sequence_spec_i_l c c' ase a a' l h bse b b' rse r r') =
(sequence_spec_i c c' ase a
(fun (x:bitvec) (y:bitvec) (i:Z) => ((a' x) y)) l (h - 1%Z)%Z h bse b
(fun (x:bitvec) (y:bitvec) (i:Z) => ((getbv ((b' x) y)) i)) rse r r')).
Axiom sequence_spec_i_l_spec :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l (h - 1%Z)%Z b r) ->
(correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
((getbv ((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r))) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < (h - 1%Z)%Z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) ->
((((ase x) y) (h - 1%Z)%Z) =
((a' (make_bv (fun (i:Z) => (((b x) (hpart y r)) i)) (size c)))
(tpart y r)))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
correct_path_sum_i (sequence_spec_i_l c c' ase a a' l h bse b b' rse r r')
ase l h bse rse.
Axiom sequence_spec_i_l_spec1 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l (h - 1%Z)%Z b r) ->
(correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
((getbv ((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r))) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < (h - 1%Z)%Z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) ->
((((ase x) y) (h - 1%Z)%Z) =
((a' (make_bv (fun (i:Z) => (((b x) (hpart y r)) i)) (size c)))
(tpart y r)))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((size (sequence_spec_i_l c c' ase a a' l h bse b b' rse r r')) = (size c)).
Axiom sequence_spec_i_l_spec2 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> angle)
(l:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> bitvec) (rse:Z)
(r:Z) (r':Z),
((size c) = (size c')) -> (correct_path_sum_i c a l (h - 1%Z)%Z b r) ->
(correct_path_sum c' a' b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) =
((getbv ((b' (make_bv ((b x) (hpart y r)) (size c))) (tpart y r))) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < (h - 1%Z)%Z)%Z) ->
((((ase x) y) i) = (((a x) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = rse) ->
((((ase x) y) (h - 1%Z)%Z) =
((a' (make_bv (fun (i:Z) => (((b x) (hpart y r)) i)) (size c)))
(tpart y r)))) ->
(rse = (r + r')%Z) -> (l < h)%Z ->
((sequence_spec_i_l c c' ase a a' l h bse b b' rse r r') = (sequence c c')).
Parameter parallel_spec_i:
gate -> gate -> (bitvec -> bitvec -> Z -> angle) ->
(bitvec -> bitvec -> Z -> angle) -> (bitvec -> bitvec -> Z -> angle) ->
Z -> Z -> Z -> (bitvec -> bitvec -> Z -> Z) ->
(bitvec -> bitvec -> Z -> Z) -> (bitvec -> bitvec -> Z -> Z) -> Z ->
Z -> Z -> gate.
Axiom parallel_spec_i_def :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
(correct_path_sum_i c a l z b r) -> (correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' (tpart x (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
(((size c) <= i)%Z /\ (i < ((size c) + (size c'))%Z)%Z) ->
((((bse x) y) i) =
(((b' (tpart x (size c))) (tpart y r)) (i - (size c))%Z))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
((parallel_spec_i c c' ase a a' l z h bse b b' rse r r') = (parallel c c')).
Axiom parallel_spec_i_spec :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
(correct_path_sum_i c a l z b r) -> (correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' (tpart x (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
(((size c) <= i)%Z /\ (i < ((size c) + (size c'))%Z)%Z) ->
((((bse x) y) i) =
(((b' (tpart x (size c))) (tpart y r)) (i - (size c))%Z))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
correct_path_sum_i (parallel c c') ase l h bse rse.
Axiom parallel_spec_i_spec1 :
forall (c:gate) (c':gate) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (a':bitvec -> bitvec -> Z -> angle)
(l:Z) (z:Z) (h:Z) (bse:bitvec -> bitvec -> Z -> Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z) (r':Z),
(correct_path_sum_i c a l z b r) -> (correct_path_sum_i c' a' z h b' r') ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((l <= i)%Z /\ (i < z)%Z) ->
((((ase x) y) i) = (((a (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((z <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a' (tpart x (size c))) (tpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((bse x) y) i) = (((b (hpart x (size c))) (hpart y r)) i))) ->
(forall (x:bitvec) (y:bitvec) (i:Z),
((length x) = ((size c) + (size c'))%Z) -> ((length y) = rse) ->
(((size c) <= i)%Z /\ (i < ((size c) + (size c'))%Z)%Z) ->
((((bse x) y) i) =
(((b' (tpart x (size c))) (tpart y r)) (i - (size c))%Z))) ->
(rse = (r + r')%Z) -> ((l <= z)%Z /\ (z <= h)%Z) ->
((size (parallel_spec_i c c' ase a a' l z h bse b b' rse r r')) =
((size c) + (size c'))%Z).
Axiom replace_ang_ind_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z) (l':Z) (h':Z)
(b:bitvec -> bitvec -> Z -> Z) (r:Z),
(correct_path_sum_i c a l h b r) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) ->
((ang_sum ((a x) y) l h) = (ang_sum ((a' x) y) l' h'))) ->
correct_path_sum_i c a' l' h' b r.
Axiom replace_ang_ind_i_eq :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(b:bitvec -> bitvec -> Z -> Z) (r:Z),
(correct_path_sum_i c a l h b r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = (size c)) ->
((length y) = r) -> ((l <= i)%Z /\ (i < h)%Z) ->
((((a x) y) i) = (((a' x) y) i))) ->
correct_path_sum_i c a' l h b r.
Axiom replace_ket_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (r:Z),
(correct_path_sum_i c a l h b r) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = r) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((b x) y) i) = (((b' x) y) i))) ->
correct_path_sum_i c a l h b' r.
Axiom set_sum_i_sim :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z) (l':Z) (h':Z)
(b:bitvec -> bitvec -> Z -> Z) (b':bitvec -> bitvec -> Z -> Z) (r:Z)
(r':Z),
(correct_path_sum_i c a l h b r) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) ->
((ang_sum ((a x) y) l h) = (ang_sum ((a' x) y) l' h'))) ->
(forall (x:bitvec) (y:bitvec) (i:Z), ((length x) = (size c)) ->
((length y) = r) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((b x) y) i) = (((b' x) y) i))) ->
(r = r') -> correct_path_sum_i c a' l' h' b' r'.
Axiom set_correct_path_sum_i_cardone :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z) (l':Z)
(h':Z) (b:bitvec -> bitvec -> Z -> Z) (r:Z),
(correct_path_sum_i c a l h b r) -> ((l' + 1%Z)%Z = h') ->
correct_path_sum_i c
(fun (x:bitvec) (y:bitvec) (us:Z) =>
(ang_sum (fun (j:Z) => (((a x) y) j)) l h))
l' h' b r.
Axiom set_sem_by_sim_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (bound:Z)
(k:bitvec -> bitvec -> Z -> Z) (x:matrix t) (f:bitvec -> matrix t),
(is_a_ket_basis_elt x) -> (is_a_ket_l x (size c)) ->
(bound = (ang_ind_bound c)) ->
(forall (x1:bitvec) (y:bitvec), forall (i:Z), ((length x1) = (size c)) ->
((length y) = (range c)) -> ((0%Z <= i)%Z /\ (i < bound)%Z) ->
((ang_ind_i c x1 y i) = (((a x1) y) i))) ->
(forall (x1:bitvec) (y:bitvec) (i:Z), ((length x1) = (size c)) ->
((length y) = (range c)) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((k x1) y) i) = (basis_ket_i c x1 y i))) ->
(forall (y:bitvec), ((length y) = (range c)) ->
((f y) =
(infix_asdtdt (ang_exp (ang_sum ((a (ket_to_bv x)) y) 0%Z bound))
(bv_to_ket (make_bv ((k (ket_to_bv x)) y) (size c)))))) ->
sem c x
(infix_asdtdt (pow_inv_sqrt_2 (range c))
(ket_sum_l (n_bvs (range c)) f (size c))).
Axiom set_correct_path_sum_by_i :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(k:bitvec -> bitvec -> Z -> Z) (range1:Z),
(correct_path_sum_i c a l h k range1) ->
correct_path_sum c
(fun (x:bitvec) (y:bitvec) => (ang_sum (fun (i:Z) => (((a x) y) i)) l h))
(fun (x:bitvec) (y:bitvec) =>
(make_bv (fun (i:Z) => (((k x) y) i)) (size c)))
range1.
Parameter place: gate -> Z -> Z -> gate.
Axiom place_spec :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
((range (place c k n)) = (range c)).
Axiom place_spec1 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
((size (place c k n)) = n).
Axiom place_spec2 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = (range c)) -> ((0%Z <= i)%Z /\ (i < n)%Z) ->
(((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((basis_ket_i (place c k n) x y i) =
(basis_ket_i c (htpart x k (size c)) y (i - k)%Z))) /\
(~ ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((basis_ket_i (place c k n) x y i) = ((getbv x) i))).
Parameter fc11: gate -> Z -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def11 :
forall (c:gate) (k:Z) (x:bitvec) (y:bitvec) (i:Z),
(((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((fc11 c k x y) i) = (basis_ket_i c (htpart x k (size c)) y (i - k)%Z))) /\
(~ ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((fc11 c k x y) i) = ((getbv x) i))).
Axiom place_spec3 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
forall (x:bitvec) (y:bitvec), ((length x) = n) ->
((length y) = (range c)) ->
((basis_ket (place c k n) x y) = (make_bv (fc11 c k x y) n)).
Axiom place_spec4 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
forall (x:bitvec) (y:bitvec), ((length x) = n) ->
((length y) = (ang_ind_bound c)) ->
((ang_ind (place c k n) x y) = (ang_ind c (htpart x k (size c)) y)).
Parameter place_i:
gate -> Z -> Z -> (bitvec -> bitvec -> Z -> angle) -> Z -> Z ->
(bitvec -> bitvec -> Z -> Z) -> Z -> gate.
Axiom place_i_spec :
forall (c:gate) (k:Z) (n:Z) (a:bitvec -> bitvec -> Z -> angle) (l:Z)
(h:Z) (b:bitvec -> bitvec -> Z -> Z) (r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z ->
(correct_path_sum_i c a l h b r) -> ((size (place_i c k n a l h b r)) = n).
Parameter fc12:
gate -> Z -> (bitvec -> bitvec -> Z -> Z) -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def12 :
forall (c:gate) (k:Z) (b:bitvec -> bitvec -> Z -> Z) (x:bitvec) (y:bitvec)
(i:Z),
(((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((((fc12 c k b) x) y) i) = (((b (htpart x k (size c))) y) (i - k)%Z))) /\
(~ ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((((fc12 c k b) x) y) i) = ((getbv x) i))).
Axiom place_i_spec1 :
forall (c:gate) (k:Z) (n:Z) (a:bitvec -> bitvec -> Z -> angle) (l:Z)
(h:Z) (b:bitvec -> bitvec -> Z -> Z) (r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z ->
(correct_path_sum_i c a l h b r) ->
correct_path_sum_i (place_i c k n a l h b r)
(fun (x:bitvec) (y:bitvec) (i:Z) => (((a (htpart x k (size c))) y) i)) l h
(fc12 c k b) r.
Axiom place_i_spec2 :
forall (c:gate) (k:Z) (n:Z) (a:bitvec -> bitvec -> Z -> angle) (l:Z)
(h:Z) (b:bitvec -> bitvec -> Z -> Z) (r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z ->
(correct_path_sum_i c a l h b r) ->
((place_i c k n a l h b r) = (place c k n)).
Parameter place_spec_i:
gate -> Z -> Z -> (bitvec -> bitvec -> Z -> angle) ->
(bitvec -> bitvec -> Z -> angle) -> Z -> Z ->
(bitvec -> bitvec -> Z -> Z) -> (bitvec -> bitvec -> Z -> Z) -> Z ->
Z -> gate.
Axiom place_spec_i_def :
forall (c:gate) (k:Z) (n:Z) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(bse:bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z -> (rse = r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((((bse x) y) i) = (((b (htpart x k (size c))) y) (i - k)%Z))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < k)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> (((k + (size c))%Z <= i)%Z /\ (i < n)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a (htpart x k (size c))) y) i))) ->
(correct_path_sum_i c a l h b r) ->
((place_spec_i c k n ase a l h bse b rse r) = (place_i c k n a l h b r)).
Axiom place_spec_i_spec :
forall (c:gate) (k:Z) (n:Z) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(bse:bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z -> (rse = r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((((bse x) y) i) = (((b (htpart x k (size c))) y) (i - k)%Z))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < k)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> (((k + (size c))%Z <= i)%Z /\ (i < n)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a (htpart x k (size c))) y) i))) ->
(correct_path_sum_i c a l h b r) ->
((size (place_spec_i c k n ase a l h bse b rse r)) = n).
Axiom place_spec_i_spec1 :
forall (c:gate) (k:Z) (n:Z) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(bse:bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z -> (rse = r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((((bse x) y) i) = (((b (htpart x k (size c))) y) (i - k)%Z))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < k)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> (((k + (size c))%Z <= i)%Z /\ (i < n)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a (htpart x k (size c))) y) i))) ->
(correct_path_sum_i c a l h b r) ->
((place_spec_i c k n ase a l h bse b rse r) = (place c k n)).
Axiom place_spec_i_spec2 :
forall (c:gate) (k:Z) (n:Z) (ase:bitvec -> bitvec -> Z -> angle)
(a:bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(bse:bitvec -> bitvec -> Z -> Z) (b:bitvec -> bitvec -> Z -> Z) (rse:Z)
(r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (l < h)%Z -> (rse = r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
((((bse x) y) i) = (((b (htpart x k (size c))) y) (i - k)%Z))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((0%Z <= i)%Z /\ (i < k)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> (((k + (size c))%Z <= i)%Z /\ (i < n)%Z) ->
((((bse x) y) i) = ((getbv x) i))) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = rse) -> ((l <= i)%Z /\ (i < h)%Z) ->
((((ase x) y) i) = (((a (htpart x k (size c))) y) i))) ->
(correct_path_sum_i c a l h b r) ->
correct_path_sum_i (place_spec_i c k n ase a l h bse b rse r) ase l h bse
rse.
Parameter fc13:
gate -> Z -> (bitvec -> bitvec -> bitvec) -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def13 :
forall (c:gate) (k:Z) (b:bitvec -> bitvec -> bitvec) (x:bitvec) (y:bitvec)
(i:Z),
(((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((fc13 c k b x y) i) = ((getbv ((b (htpart x k (size c))) y)) (i - k)%Z))) /\
(~ ((k <= i)%Z /\ (i < (k + (size c))%Z)%Z) ->
(((fc13 c k b x y) i) = ((getbv x) i))).
Axiom place_comp_scheme :
forall (c:gate) (k:Z) (n:Z) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (correct_path_sum c a b r) ->
correct_path_sum (place c k n)
(fun (x:bitvec) (y:bitvec) => ((a (htpart x k (size c))) y))
(fun (x:bitvec) (y:bitvec) => (make_bv (fc13 c k b x y) n)) r.
Axiom place_kron :
forall (c:gate) (k:Z) (n:Z) (x:matrix t) (y:matrix t) (y':matrix t)
(z:matrix t),
(k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z -> (is_a_ket_l x k) ->
(is_a_ket_l y (size c)) -> (is_a_ket_l z ((n - (size c))%Z - k)%Z) ->
(sem c y y') ->
sem (place c k n) (kronecker x (kronecker y z))
(kronecker x (kronecker y' z)).
Axiom place_kron_left :
forall (c:gate) (n:Z) (y:matrix t) (y':matrix t) (z:matrix t),
(n >= (size c))%Z -> (is_a_ket_l y (size c)) ->
(is_a_ket_l z (n - (size c))%Z) -> (sem c y y') ->
sem (place c 0%Z n) (kronecker y z) (kronecker y' z).
Axiom place_kron_left_basis_gen :
forall (c:gate) (n:Z), (n >= (size c))%Z ->
forall (y:matrix t) (y':matrix t) (z:matrix t), (is_a_ket_l y (size c)) ->
(is_a_ket_basis_elt y) -> (is_a_ket_l z (n - (size c))%Z) ->
(sem c y y') -> sem (place c 0%Z n) (kronecker y z) (kronecker y' z).
Axiom place_kron_right :
forall (c:gate) (k:Z) (n:Z) (x:matrix t) (y:matrix t) (y':matrix t),
(n = ((size c) + k)%Z) -> (is_a_ket_l x k) -> (is_a_ket_l y (size c)) ->
(sem c y y') -> sem (place c k n) (kronecker x y) (kronecker x y').
Axiom place_kron_left_gen :
forall (c:gate) (n:Z), (n >= (size c))%Z ->
forall (y:matrix t) (y':matrix t) (z:matrix t),
(is_a_ket_l z (n - (size c))%Z) -> (sem c y y') ->
sem (place c 0%Z n) (kronecker y z) (kronecker y' z).
Axiom place_kron_right_gen :
forall (c:gate) (k:Z) (n:Z), (n = ((size c) + k)%Z) ->
forall (y:matrix t) (y':matrix t) (x:matrix t), (is_a_ket_l x k) ->
(sem c y y') -> sem (place c k n) (kronecker x y) (kronecker x y').
Parameter cont: gate -> Z -> Z -> Z -> gate.
Axiom cont_spec :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (bv:bitvec), ((length bv) = n) -> (((getbv bv) co) = 0%Z) ->
sem (cont c co ft n) (bv_to_ket bv) (bv_to_ket bv).
Axiom cont_spec1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (bv:bitvec), ((length bv) = n) -> (((getbv bv) co) = 1%Z) ->
sem (cont c co ft n) (bv_to_ket bv) (pat_sem (place c ft n) (bv_to_ket bv)).
Axiom cont_spec2 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
((size (cont c co ft n)) = n).
Axiom cont_spec3 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (bv:bitvec), ((length bv) = n) ->
(((getbv bv) co) = 0%Z) ->
sem (cont c co ft n) (bv_to_ket bv) (bv_to_ket bv).
Axiom cont_spec4 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (bv:bitvec), ((length bv) = n) ->
(((getbv bv) co) = 1%Z) ->
sem (cont c co ft n) (bv_to_ket bv) (pat_sem (place c ft n) (bv_to_ket bv)).
Axiom cont_spec5 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> ((size (cont c co ft n)) = n).
Axiom mat_cont :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (x:matrix t), (is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 0%Z) -> sem (cont c co ft n) x x.
Axiom mat_cont1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (x:matrix t), (is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 1%Z) ->
sem (cont c co ft n) x (pat_sem (place c ft n) x).
Axiom mat_cont2 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (x:matrix t), (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 0%Z) ->
sem (cont c co ft n) x x.
Axiom mat_cont3 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (x:matrix t), (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 1%Z) ->
sem (cont c co ft n) x (pat_sem (place c ft n) x).
Axiom pat_cont :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (bv:bitvec), ((length bv) = n) -> (((getbv bv) co) = 0%Z) ->
((pat_sem (cont c co ft n) (bv_to_ket bv)) = (bv_to_ket bv)).
Axiom pat_cont1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (bv:bitvec), ((length bv) = n) -> (((getbv bv) co) = 1%Z) ->
((pat_sem (cont c co ft n) (bv_to_ket bv)) =
(pat_sem (place c ft n) (bv_to_ket bv))).
Axiom pat_cont2 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (bv:bitvec), ((length bv) = n) ->
(((getbv bv) co) = 0%Z) ->
((pat_sem (cont c co ft n) (bv_to_ket bv)) = (bv_to_ket bv)).
Axiom pat_cont3 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (bv:bitvec), ((length bv) = n) ->
(((getbv bv) co) = 1%Z) ->
((pat_sem (cont c co ft n) (bv_to_ket bv)) =
(pat_sem (place c ft n) (bv_to_ket bv))).
Axiom pat_cont_ketz :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (x:matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 0%Z) -> ((pat_sem (cont c co ft n) x) = x).
Axiom pat_cont_ketz1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (x:matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 0%Z) ->
((pat_sem (cont c co ft n) x) = x).
Axiom pat_cont_keto :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (x:matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 1%Z) ->
((pat_sem (cont c co ft n) x) = (pat_sem (place c ft n) x)).
Axiom pat_cont_keto1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (x:matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 1%Z) ->
((pat_sem (cont c co ft n) x) = (pat_sem (place c ft n) x)).
Axiom pat_cont_ketz_gen :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (x:matrix t), (is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 0%Z) -> ((pat_sem (cont c co ft n) x) = x).
Axiom pat_cont_ketz_gen1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (x:matrix t), (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 0%Z) ->
((pat_sem (cont c co ft n) x) = x).
Axiom pat_cont_keto_gen :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (x:matrix t), (is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 1%Z) ->
((pat_sem (cont c co ft n) x) = (pat_sem (place c ft n) x)).
Axiom pat_cont_keto_gen1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (x:matrix t), (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 1%Z) ->
((pat_sem (cont c co ft n) x) = (pat_sem (place c ft n) x)).
Axiom cont_ketz_gen :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
forall (x:matrix t), (is_a_ket_l x n) -> (is_a_ket_basis_elt x) ->
(((getbv (ket_to_bv x)) co) = 0%Z) -> sem (cont c co ft n) x x.
Axiom cont_ketz_gen1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> forall (x:matrix t), (is_a_ket_l x n) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 0%Z) ->
sem (cont c co ft n) x x.
Axiom cont_keto_gen :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (f:bitvec -> matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
(forall (x:bitvec), ((length x) = n) ->
sem (place c ft n) (bv_to_ket x) (f x)) ->
~ (ft <= co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((getbv x) co) = 1%Z) -> sem (cont c co ft n) (bv_to_ket x) (f x).
Axiom cont_keto_gen1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z) (f:bitvec -> matrix t),
((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
(forall (x:bitvec), ((length x) = n) ->
sem (place c ft n) (bv_to_ket x) (f x)) ->
((ft + (size c))%Z <= co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((getbv x) co) = 1%Z) -> sem (cont c co ft n) (bv_to_ket x) (f x).
Parameter diag_mat: Z -> (Z -> t) -> matrix t.
Axiom diag_mat_def :
forall (n:Z) (f:Z -> t), (n > 0%Z)%Z ->
((diag_mat n f) =
(make_f n n (fun (i:Z) (j:Z) => (infix_asdt (f i) (indic i j))))).
Axiom diag_mat_spec :
forall (n:Z) (f:Z -> t), (n > 0%Z)%Z -> forall (i:Z) (j:Z),
(((0%Z <= i)%Z /\ (i < n)%Z) /\ ((0%Z <= j)%Z /\ (j < n)%Z)) ->
~ (i = j) -> ((get (diag_mat n f) i j) = tzero).
Axiom diag_mat_spec1 :
forall (n:Z) (f:Z -> t), (n > 0%Z)%Z -> forall (i:Z) (j:Z),
(((0%Z <= i)%Z /\ (i < n)%Z) /\ ((0%Z <= j)%Z /\ (j < n)%Z)) -> (i = j) ->
((get (diag_mat n f) i j) = (f i)).
Axiom diag_mat_values :
forall (n:Z) (f:Z -> t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < n)%Z) ->
((0%Z <= j)%Z /\ (j < n)%Z) ->
((get (diag_mat n f) i j) = (infix_asdt (f i) (indic i j))).
Axiom diag_mat_eq :
forall (f:Z -> t) (g:Z -> t) (n:Z), (n > 0%Z)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> ((f i) = (g i))) ->
((diag_mat n f) = (diag_mat n g)).
Axiom mat_mult_diag :
forall (m:matrix t) (f:Z -> t),
((mat_mult m (diag_mat (columns m) f)) =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) => (infix_asdt (get m i j) (f j))))).
Axiom diag_mult_mat :
forall (m:matrix t) (f:Z -> t),
((mat_mult (diag_mat (rows m) f) m) =
(make_f (rows m) (columns m)
(fun (i:Z) (j:Z) => (infix_asdt (get m i j) (f i))))).
Axiom diag_mult_diag :
forall (f:Z -> t) (g:Z -> t) (n:Z), (n > 0%Z)%Z ->
((mat_mult (diag_mat n f) (diag_mat n g)) =
(diag_mat n (fun (i:Z) => (infix_asdt (f i) (g i))))).
Axiom ind_product_re :
forall (f:Z -> Z -> t) (i:Z) (j:Z) (n:Z), (i < j)%Z -> forall (k:Z),
((0%Z <= k)%Z /\ (k < n)%Z) ->
((ind_product (fun (i1:Z) => ((f i1) k)) i (j + 1%Z)%Z) =
(infix_asdt (ind_product (fun (i1:Z) => ((f i1) k)) i j) ((f j) k))).
Axiom int_mat_diag_prod :
forall (f:Z -> Z -> t) (i:Z) (j:Z) (n:Z), (n > 0%Z)%Z -> (i <= j)%Z ->
((int_mat_prod (fun (k:Z) => (diag_mat n (f k))) i j) =
(diag_mat n
(fun (k:Z) => (ind_product (fun (l:Z) => ((f l) k)) i (j + 1%Z)%Z)))).
Parameter diag_two_mat: Z -> (Z -> Z -> Z -> t) -> matrix t.
Parameter result19: Z -> (Z -> Z -> Z -> t) -> Z -> Z -> t.
Axiom result_def19 :
forall (n:Z) (f:Z -> Z -> Z -> t) (i:Z) (j:Z),
((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
((((result19 n f) i) j) =
(infix_asdt (indic (tail_bits i n) (tail_bits j n))
(((f (head_bit i n)) (head_bit j n)) (tail_bits i n))))) /\
(~ (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
((((result19 n f) i) j) = tzero)).
Axiom diag_two_mat_def :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((diag_two_mat n f) = (make_f (power 2%Z n) (power 2%Z n) (result19 n f))).
Axiom diag_two_mat_spec :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((rows (diag_two_mat n f)) = (power 2%Z n)).
Axiom diag_two_mat_spec1 :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((columns (diag_two_mat n f)) = (power 2%Z n)).
Axiom diag_two_mat_spec2 :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((diag_two_mat n f) =
(make_f (power 2%Z n) (power 2%Z n)
(fun (i:Z) (j:Z) =>
(infix_asdt (indic (tail_bits i n) (tail_bits j n))
(((f (head_bit i n)) (head_bit j n)) (tail_bits i n)))))).
Parameter two_bloc_diag_mat: Z -> (Z -> Z -> Z -> t) -> matrix t.
Parameter result20: Z -> (Z -> Z -> Z -> t) -> Z -> Z -> t.
Axiom result_def20 :
forall (n:Z) (f:Z -> Z -> Z -> t) (i:Z) (j:Z),
((((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
((((result20 n f) i) j) =
(infix_asdt (indic (head_bit i n) (head_bit j n))
(((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))))) /\
(~ (((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z)) ->
((((result20 n f) i) j) = tzero)).
Axiom two_bloc_diag_mat_def :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((two_bloc_diag_mat n f) =
(make_f (power 2%Z n) (power 2%Z n) (result20 n f))).
Axiom two_bloc_diag_mat_spec :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((rows (two_bloc_diag_mat n f)) = (power 2%Z n)).
Axiom two_bloc_diag_mat_spec1 :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((columns (two_bloc_diag_mat n f)) = (power 2%Z n)).
Axiom two_bloc_diag_mat_spec2 :
forall (n:Z) (f:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((two_bloc_diag_mat n f) =
(make_f (power 2%Z n) (power 2%Z n)
(fun (i:Z) (j:Z) =>
(infix_asdt (indic (head_bit i n) (head_bit j n))
(((f (head_bit i n)) (tail_bits i n)) (tail_bits j n)))))).
Axiom two_bloc_diag_two_val :
forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> Z -> Z -> t) (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> (n >= 2%Z)%Z ->
((get (mat_mult (two_bloc_diag_mat n f) (diag_two_mat n g)) i j) =
(infix_asdt (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))
(((g (head_bit i n)) (head_bit j n)) (tail_bits j n)))).
Axiom two_bloc_diag_two :
forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> Z -> Z -> t), (n >= 2%Z)%Z ->
((mat_mult (two_bloc_diag_mat n f) (diag_two_mat n g)) =
(make_f (power 2%Z n) (power 2%Z n)
(fun (i:Z) (j:Z) =>
(infix_asdt (((f (head_bit i n)) (tail_bits i n)) (tail_bits j n))
(((g (head_bit i n)) (head_bit j n)) (tail_bits j n)))))).
Axiom two_bloc_mult_diag :
forall (n:Z) (f:Z -> Z -> Z -> t) (g:Z -> t), (n >= 2%Z)%Z ->
((mat_mult (two_bloc_diag_mat n f) (diag_mat (power 2%Z n) g)) =
(two_bloc_diag_mat n
(fun (hi:Z) (ti:Z) (tj:Z) =>
(infix_asdt (((f hi) ti) tj) (g (ht_to_int hi tj n)))))).
Axiom kronecker_scalar_distr :
forall (m:matrix t) (n:matrix t) (a:t),
((kronecker (infix_asdtdt a m) n) = (infix_asdtdt a (kronecker m n))).
Axiom kronecker_scalar_distr_r :
forall (m:matrix t) (n:matrix t) (a:t),
((kronecker m (infix_asdtdt a n)) = (infix_asdtdt a (kronecker m n))).
Axiom kronecker_scalars :
forall (m:matrix t) (n:matrix t) (a:t) (b:t),
((kronecker (infix_asdtdt a m) (infix_asdtdt b n)) =
(infix_asdtdt (infix_asdt a b) (kronecker m n))).
Parameter mat_k_id: (matrix t) -> Z -> matrix t.
Axiom mat_k_id_def :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((mat_k_id m n) = (kronecker m (identity n))).
Axiom mat_k_id_spec :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((mat_k_id m n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns m) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.mod1 i (power 2%Z n))
(int.EuclideanDivision.mod1 j (power 2%Z n)))
(get m (int.EuclideanDivision.div i (power 2%Z n))
(int.EuclideanDivision.div j (power 2%Z n))))))).
Axiom mat_k_id_values :
forall (m:matrix t) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((columns m) * (power 2%Z n))%Z)%Z) ->
((get (mat_k_id m n) i j) =
(infix_asdt
(indic (int.EuclideanDivision.mod1 i (power 2%Z n))
(int.EuclideanDivision.mod1 j (power 2%Z n)))
(get m (int.EuclideanDivision.div i (power 2%Z n))
(int.EuclideanDivision.div j (power 2%Z n))))).
Axiom mat_k_id_rows :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((rows (mat_k_id m n)) = ((rows m) * (power 2%Z n))%Z).
Axiom mat_k_id_columns :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns (mat_k_id m n)) = ((columns m) * (power 2%Z n))%Z).
Parameter id_k_mat: (matrix t) -> Z -> matrix t.
Axiom id_k_mat_def :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((id_k_mat m n) = (kronecker (identity n) m)).
Axiom id_k_mat_spec :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((id_k_mat m n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns m) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.div i (rows m))
(int.EuclideanDivision.div j (columns m)))
(get m (int.EuclideanDivision.mod1 i (rows m))
(int.EuclideanDivision.mod1 j (columns m))))))).
Axiom id_k_mat_values :
forall (m:matrix t) (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((columns m) * (power 2%Z n))%Z)%Z) ->
((get (id_k_mat m n) i j) =
(infix_asdt
(indic (int.EuclideanDivision.div i (rows m))
(int.EuclideanDivision.div j (columns m)))
(get m (int.EuclideanDivision.mod1 i (rows m))
(int.EuclideanDivision.mod1 j (columns m))))).
Axiom id_k_mat_rows :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z ->
((rows (id_k_mat m n)) = ((rows m) * (power 2%Z n))%Z).
Axiom id_k_mat_columns :
forall (m:matrix t) (n:Z), (0%Z < n)%Z ->
((columns (id_k_mat m n)) = ((columns m) * (power 2%Z n))%Z).
Parameter mat_prod_k_id: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom mat_prod_k_id_def :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((mat_prod_k_id m o n) = (kronecker (mat_mult m o) (identity n))).
Axiom mat_prod_k_id_spec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((mat_prod_k_id m o n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.mod1 i (power 2%Z n))
(int.EuclideanDivision.mod1 j (power 2%Z n)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
(get o k (int.EuclideanDivision.div j (power 2%Z n)))))
0%Z (columns m)))))).
Parameter id_k_mat_prod: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom id_k_mat_prod_def :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((id_k_mat_prod m o n) = (kronecker (identity n) (mat_mult m o))).
Axiom id_k_mat_prod_spec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((id_k_mat_prod m o n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.div i (rows m))
(int.EuclideanDivision.div j (columns o)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
(get o k (int.EuclideanDivision.mod1 j (columns o)))))
0%Z (columns m)))))).
Axiom filter_sum_mod_indic :
forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (n > 0%Z)%Z -> (v > 0%Z)%Z ->
((0%Z <= p)%Z /\ (p < v)%Z) ->
((sum (to_fset 0%Z (v * n)%Z)
(fun (k:Z) =>
(infix_asdt (indic (int.EuclideanDivision.mod1 k v) p)
(g (int.EuclideanDivision.div k v)))))
= (sum (to_fset 0%Z n) g)).
Axiom filter_sum_indic_div :
forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (n > 0%Z)%Z -> (v > 0%Z)%Z ->
((0%Z <= p)%Z /\ (p < n)%Z) ->
((sum (to_fset 0%Z (v * n)%Z)
(fun (k:Z) =>
(infix_asdt (g (int.EuclideanDivision.mod1 k v))
(indic (int.EuclideanDivision.div k v) p))))
= (sum (to_fset 0%Z v) g)).
Axiom filtered_ind_sum_mod_indic :
forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (n > 0%Z)%Z -> (v > 0%Z)%Z ->
((0%Z <= p)%Z /\ (p < v)%Z) ->
((ind_sum
(fun (k:Z) =>
(infix_asdt (indic (int.EuclideanDivision.mod1 k v) p)
(g (int.EuclideanDivision.div k v))))
0%Z (v * n)%Z)
= (ind_sum g 0%Z n)).
Axiom filtered_ind_sum_indic_div :
forall (v:Z) (n:Z) (p:Z) (g:Z -> t), (n > 0%Z)%Z -> (v > 0%Z)%Z ->
((0%Z <= p)%Z /\ (p < n)%Z) ->
((ind_sum
(fun (k:Z) =>
(infix_asdt (g (int.EuclideanDivision.mod1 k v))
(indic (int.EuclideanDivision.div k v) p)))
0%Z (v * n)%Z)
= (ind_sum g 0%Z v)).
Axiom prod_mat_k_id_pre :
forall (m:matrix t) (o:matrix t) (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((columns o) * (power 2%Z n))%Z)%Z) ->
((get (mat_mult (mat_k_id m n) (mat_k_id o n)) i j) =
(infix_asdt
(indic (int.EuclideanDivision.mod1 i (power 2%Z n))
(int.EuclideanDivision.mod1 j (power 2%Z n)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
(get o k (int.EuclideanDivision.div j (power 2%Z n)))))
0%Z (columns m)))).
Parameter prod_mat_k_id: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom prod_mat_k_id_def :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((prod_mat_k_id m o n) = (mat_mult (mat_k_id m n) (mat_k_id o n))).
Axiom prod_mat_k_id_spec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((prod_mat_k_id m o n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.mod1 i (power 2%Z n))
(int.EuclideanDivision.mod1 j (power 2%Z n)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.div i (power 2%Z n)) k)
(get o k (int.EuclideanDivision.div j (power 2%Z n)))))
0%Z (columns m)))))).
Axiom prod_mat_k_id_dec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) -> ((prod_mat_k_id m o n) = (mat_prod_k_id m o n)).
Axiom k_id_prod_mat_pre :
forall (m:matrix t) (o:matrix t) (i:Z) (j:Z) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((0%Z <= i)%Z /\ (i < ((rows m) * (power 2%Z n))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((columns o) * (power 2%Z n))%Z)%Z) ->
((get (mat_mult (id_k_mat m n) (id_k_mat o n)) i j) =
(infix_asdt
(indic (int.EuclideanDivision.div i (rows m))
(int.EuclideanDivision.div j (columns o)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
(get o k (int.EuclideanDivision.mod1 j (columns o)))))
0%Z (columns m)))).
Parameter k_id_prod_mat: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom k_id_prod_mat_def :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((k_id_prod_mat m o n) = (mat_mult (id_k_mat m n) (id_k_mat o n))).
Axiom k_id_prod_mat_spec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) ->
((k_id_prod_mat m o n) =
(make_f ((rows m) * (power 2%Z n))%Z ((columns o) * (power 2%Z n))%Z
(fun (i:Z) (j:Z) =>
(infix_asdt
(indic (int.EuclideanDivision.div i (rows m))
(int.EuclideanDivision.div j (columns o)))
(ind_sum
(fun (k:Z) =>
(infix_asdt (get m (int.EuclideanDivision.mod1 i (rows m)) k)
(get o k (int.EuclideanDivision.mod1 j (columns o)))))
0%Z (columns m)))))).
Axiom k_id_prod_mat_dec :
forall (m:matrix t) (o:matrix t) (n:Z), (0%Z <= n)%Z ->
((columns m) = (rows o)) -> ((k_id_prod_mat m o n) = (id_k_mat_prod m o n)).
Axiom split_ne_pre :
forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z)
(i:Z) (j:Z),
(0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
((0%Z <= i)%Z /\ (i < ((power 2%Z nr1) * (power 2%Z nr2))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((power 2%Z nc1) * (power 2%Z nc2))%Z)%Z) ->
((get (mat_mult (id_k_mat m1 nr2) (mat_k_id m2 nc1)) i j) =
(get (kronecker m2 m1) i j)).
Axiom split_nw_pre :
forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z)
(i:Z) (j:Z),
(0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
((0%Z <= i)%Z /\ (i < ((power 2%Z nr1) * (power 2%Z nr2))%Z)%Z) ->
((0%Z <= j)%Z /\ (j < ((power 2%Z nc1) * (power 2%Z nc2))%Z)%Z) ->
((get (mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) i j) =
(get (kronecker m1 m2) i j)).
Axiom split_ne :
forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
(0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
((mat_mult (id_k_mat m1 nr2) (mat_k_id m2 nc1)) = (kronecker m2 m1)).
Axiom split_nw :
forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
(0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
((mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) = (kronecker m1 m2)).
Axiom shift_k_id :
forall (m1:matrix t) (m2:matrix t) (nc1:Z) (nc2:Z) (nr1:Z) (nr2:Z),
(0%Z <= nr1)%Z -> (0%Z <= nr2)%Z -> (0%Z <= nc1)%Z -> (0%Z <= nc2)%Z ->
((columns m1) = (power 2%Z nc1)) -> ((columns m2) = (power 2%Z nc2)) ->
((rows m1) = (power 2%Z nr1)) -> ((rows m2) = (power 2%Z nr2)) ->
((mat_mult (mat_k_id m1 nr2) (id_k_mat m2 nc1)) =
(mat_mult (id_k_mat m2 nr1) (mat_k_id m1 nc2))).
Axiom kronecker_mult_commut :
forall (a:matrix t) (b:matrix t) (c:matrix t) (d:matrix t) (ra:Z) (ca:Z)
(cc:Z) (rb:Z) (cb:Z) (cd:Z),
(0%Z <= ra)%Z -> (0%Z <= ca)%Z -> (0%Z <= cc)%Z -> (0%Z <= rb)%Z ->
(0%Z <= cb)%Z -> (0%Z <= cd)%Z -> ((rows a) = (power 2%Z ra)) ->
((columns a) = (power 2%Z ca)) -> ((rows c) = (power 2%Z ca)) ->
((columns c) = (power 2%Z cc)) -> ((rows b) = (power 2%Z rb)) ->
((columns b) = (power 2%Z cb)) -> ((rows d) = (power 2%Z cb)) ->
((columns d) = (power 2%Z cd)) ->
((mat_mult (kronecker a b) (kronecker c d)) =
(kronecker (mat_mult a c) (mat_mult b d))).
Parameter isa_square: (matrix t) -> Prop.
Axiom isa_square_def :
forall (m:matrix t), (isa_square m) -> ((rows m) = (columns m)).
Axiom isa_square_def1 :
forall (m:matrix t), ((rows m) = (columns m)) -> isa_square m.
Parameter pow2dim: (matrix t) -> Prop.
Axiom pow2dim_def :
forall (m:matrix t), (pow2dim m) ->
exists i:Z, exists j:Z,
((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j)).
Axiom pow2dim_def1 :
forall (m:matrix t),
(exists i:Z, exists j:Z,
((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j))) ->
pow2dim m.
Parameter pow2dim_square: (matrix t) -> Prop.
Axiom pow2dim_square_def :
forall (m:matrix t), (pow2dim_square m) ->
exists i:Z, ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z i)).
Axiom pow2dim_square_def1 :
forall (m:matrix t),
(exists i:Z, ((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z i))) ->
pow2dim_square m.
Axiom pow_2dim_kets : forall (m:matrix t), (is_a_ket m) -> pow2dim m.
Parameter lnr: (matrix t) -> Z.
Axiom lnr_spec :
forall (m:matrix t), (pow2dim m) -> ((rows m) = (power 2%Z (lnr m))).
Axiom lnr_spec1 : forall (m:matrix t), (pow2dim m) -> ((lnr m) >= 0%Z)%Z.
Parameter lnc: (matrix t) -> Z.
Axiom lnc_spec :
forall (m:matrix t), (pow2dim m) -> ((columns m) = (power 2%Z (lnc m))).
Axiom lnc_spec1 : forall (m:matrix t), (pow2dim m) -> ((lnc m) >= 0%Z)%Z.
Axiom get_pow2dim :
forall (m:matrix t), (pow2dim m) ->
exists i:Z, exists j:Z,
((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j)).
Axiom set_pow2dim :
forall (m:matrix t),
(exists i:Z, exists j:Z,
((rows m) = (power 2%Z i)) /\ ((columns m) = (power 2%Z j))) ->
pow2dim m.
Axiom get_pow2dim_elt :
forall (m:matrix t) (i:Z) (j:Z), (pow2dim m) -> ((lnr m) = i) ->
((lnc m) = j) -> ((rows m) = (power 2%Z i)).
Axiom get_pow2dim_elt1 :
forall (m:matrix t) (i:Z) (j:Z), (pow2dim m) -> ((lnr m) = i) ->
((lnc m) = j) -> ((columns m) = (power 2%Z j)).
Axiom set_pow2dim_elt :
forall (m:matrix t) (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((rows m) = (power 2%Z i)) -> ((columns m) = (power 2%Z j)) -> pow2dim m.
Axiom set_pow2dim_elt1 :
forall (m:matrix t) (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((rows m) = (power 2%Z i)) -> ((columns m) = (power 2%Z j)) ->
((lnr m) = i).
Axiom set_pow2dim_elt2 :
forall (m:matrix t) (i:Z) (j:Z), (0%Z <= i)%Z -> (0%Z <= j)%Z ->
((rows m) = (power 2%Z i)) -> ((columns m) = (power 2%Z j)) ->
((lnc m) = j).
Parameter mat_size: (matrix t) -> Z.
Axiom mat_size_def :
forall (m:matrix t), (isa_square m) -> ((mat_size m) = (rows m)).
Axiom mat_size_spec :
forall (m:matrix t), (isa_square m) -> ((mat_size m) = (rows m)).
Axiom mat_size_spec1 :
forall (m:matrix t), (isa_square m) -> ((mat_size m) = (columns m)).
Axiom get_square :
forall (m:matrix t), (isa_square m) -> ((rows m) = (columns m)).
Axiom set_square :
forall (m:matrix t), ((rows m) = (columns m)) -> isa_square m.
Axiom set_square_elt :
forall (m:matrix t) (i:Z), ((rows m) = i) -> ((columns m) = i) ->
isa_square m.
Axiom set_square_elt1 :
forall (m:matrix t) (i:Z), ((rows m) = i) -> ((columns m) = i) ->
((mat_size m) = i).
Axiom get_square_elt :
forall (m:matrix t) (i:Z), (isa_square m) -> ((mat_size m) = i) ->
((rows m) = i).
Axiom get_square_elt1 :
forall (m:matrix t) (i:Z), (isa_square m) -> ((mat_size m) = i) ->
((columns m) = i).
Axiom pow2dim_square_dec :
forall (m:matrix t), (isa_square m) -> (pow2dim m) -> pow2dim_square m.
Axiom dec_pow2dim_square :
forall (m:matrix t), (pow2dim_square m) -> isa_square m.
Axiom dec_pow2dim_square1 :
forall (m:matrix t), (pow2dim_square m) -> pow2dim m.
Parameter ln_size: (matrix t) -> Z.
Axiom ln_size_def :
forall (m:matrix t), (pow2dim_square m) -> ((ln_size m) = (lnr m)).
Axiom ln_size_spec :
forall (m:matrix t), (pow2dim_square m) -> ((ln_size m) = (lnc m)).
Axiom ln_size_spec1 :
forall (m:matrix t), (pow2dim_square m) ->
((rows m) = (power 2%Z (ln_size m))).
Axiom ln_size_spec2 :
forall (m:matrix t), (pow2dim_square m) ->
((columns m) = (power 2%Z (ln_size m))).
Axiom set_ln_size_lnc :
forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((lnc m) = i) ->
((ln_size m) = i).
Axiom set_ln_size_lnr :
forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((lnr m) = i) ->
((ln_size m) = i).
Axiom set_ln_size_columns :
forall (m:matrix t) (i:Z), (0%Z <= i)%Z -> (pow2dim_square m) ->
((columns m) = (power 2%Z i)) -> ((ln_size m) = i).
Axiom set_ln_size_rows :
forall (m:matrix t) (i:Z), (0%Z <= i)%Z -> (pow2dim_square m) ->
((rows m) = (power 2%Z i)) -> ((ln_size m) = i).
Axiom set_pow2dim_square :
forall (m:matrix t),
(exists i:Z, ((rows m) = (columns m)) /\ ((columns m) = (power 2%Z i))) ->
pow2dim_square m.
Axiom set_pow2dim_square_elt :
forall (m:matrix t) (i:Z), (0%Z <= i)%Z ->
(((rows m) = (columns m)) /\ ((columns m) = (power 2%Z i))) ->
pow2dim_square m.
Axiom set_pow2dim_square_elt1 :
forall (m:matrix t) (i:Z), (0%Z <= i)%Z ->
(((rows m) = (columns m)) /\ ((columns m) = (power 2%Z i))) ->
((ln_size m) = i).
Axiom get_pow2dim_square_elt :
forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((ln_size m) = i) ->
((rows m) = (power 2%Z i)).
Axiom get_pow2dim_square_elt1 :
forall (m:matrix t) (i:Z), (pow2dim_square m) -> ((ln_size m) = i) ->
((columns m) = (power 2%Z i)).
Axiom kronecker_mult_commut_p :
forall (a:matrix t) (b:matrix t) (c:matrix t) (d:matrix t),
((columns a) = (rows c)) -> ((columns b) = (rows d)) -> (pow2dim a) ->
(pow2dim b) -> (pow2dim c) -> (pow2dim d) ->
((mat_mult (kronecker a b) (kronecker c d)) =
(kronecker (mat_mult a c) (mat_mult b d))).
Axiom kronecker_mult_commut_p_quant :
forall (a:matrix t) (b:matrix t), (pow2dim a) -> (pow2dim b) ->
forall (c:matrix t) (d:matrix t), ((columns a) = (rows c)) ->
((columns b) = (rows d)) -> (pow2dim c) -> (pow2dim d) ->
((mat_mult (kronecker a b) (kronecker c d)) =
(kronecker (mat_mult a c) (mat_mult b d))).
Axiom kronecker_add_distr_l :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((rows (kronecker (add_mat m n) o)) = ((rows m) * (rows o))%Z).
Axiom kronecker_add_distr_l1 :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((columns (kronecker (add_mat m n) o)) = ((columns m) * (columns o))%Z).
Axiom kronecker_add_distr_l2 :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((kronecker (add_mat m n) o) = (add_mat (kronecker m o) (kronecker n o))).
Axiom kronecker_add_distr_r :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((kronecker o (add_mat m n)) = (add_mat (kronecker o m) (kronecker o n))).
Axiom kronecker_add_distr_r1 :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((rows (kronecker o (add_mat m n))) = ((rows m) * (rows o))%Z).
Axiom kronecker_add_distr_r2 :
forall (m:matrix t) (n:matrix t) (o:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((columns (kronecker o (add_mat m n))) = ((columns m) * (columns o))%Z).
Axiom kronecker_sum_distr_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((columns (mat_sum s (fun (k:a) => (kronecker (f k) m)))) =
(columns ((fun (k:a) => (kronecker (f k) m)) (choose s)))).
Axiom kronecker_sum_distr_l1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((columns ((fun (k:a) => (kronecker (f k) m)) (choose s))) =
((columns m) * (columns (f (choose s))))%Z).
Axiom kronecker_sum_distr_l2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((rows (mat_sum s (fun (k:a) => (kronecker (f k) m)))) =
(rows ((fun (k:a) => (kronecker (f k) m)) (choose s)))).
Axiom kronecker_sum_distr_l3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((rows ((fun (k:a) => (kronecker (f k) m)) (choose s))) =
((rows m) * (rows (f (choose s))))%Z).
Axiom kronecker_sum_distr_l4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((kronecker (mat_sum s f) m) =
(mat_sum s (fun (k:a) => (kronecker (f k) m)))).
Axiom kronecker_sum_distr_r :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((columns (mat_sum s (fun (k:a) => (kronecker m (f k))))) =
(columns ((fun (k:a) => (kronecker m (f k))) (choose s)))).
Axiom kronecker_sum_distr_r1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((columns ((fun (k:a) => (kronecker m (f k))) (choose s))) =
((columns m) * (columns (f (choose s))))%Z).
Axiom kronecker_sum_distr_r2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((rows (mat_sum s (fun (k:a) => (kronecker m (f k))))) =
(rows ((fun (k:a) => (kronecker m (f k))) (choose s)))).
Axiom kronecker_sum_distr_r3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((rows ((fun (k:a) => (kronecker m (f k))) (choose s))) =
((rows m) * (rows (f (choose s))))%Z).
Axiom kronecker_sum_distr_r4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((kronecker m (mat_sum s f)) =
(mat_sum s (fun (k:a) => (kronecker m (f k))))).
Axiom mat_sum_scalar1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t), (constant_size s f) ->
((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (k:a) => (infix_asdtdt a1 (f k)))) =
(infix_asdtdt a1 (mat_sum s f))).
Axiom kronecker_sum_distr_sc :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (a1:t),
(constant_size s f) -> ((cardinal s) > 0%Z)%Z ->
((mat_sum s (fun (k:a) => (kronecker (infix_asdtdt a1 (f k)) m))) =
(infix_asdtdt a1 (mat_sum s (fun (k:a) => (kronecker (f k) m))))).
Axiom kronecker_ket_sum_distr_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z)
(l1 + l2)%Z.
Axiom kronecker_ket_sum_distr_l1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
((kronecker (ket_sum_l s f l1) m) =
(ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z)).
Axiom kronecker_ket_sum_distr_l_nol :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket m) ->
((cardinal s) > 0%Z)%Z ->
is_a_ket_l
(ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + (ket_length m))%Z)
(l1 + (ket_length m))%Z.
Axiom kronecker_ket_sum_distr_l_nol1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket m) ->
((cardinal s) > 0%Z)%Z ->
((kronecker (ket_sum_l s f l1) m) =
(ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + (ket_length m))%Z)).
Axiom kronecker_ket_sum_distr_l_rew :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket m) ->
((cardinal s) > 0%Z)%Z ->
((kronecker (ket_sum_l s f l1) m) =
(ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + (ket_length m))%Z)).
Axiom kronecker_ket_sum_distr_r :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z)
(l1 + l2)%Z.
Axiom kronecker_ket_sum_distr_r1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
((kronecker m (ket_sum_l s f l1)) =
(ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z)).
Axiom kronecker_ket_sum_distr_l_rev :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z)
(l1 + l2)%Z.
Axiom kronecker_ket_sum_distr_l_rev1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
((ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z) =
(kronecker (ket_sum_l s f l1) m)).
Axiom kronecker_ket_sum_distr_r_rev :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
is_a_ket_l (ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z)
(l1 + l2)%Z.
Axiom kronecker_ket_sum_distr_r_rev1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
((ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + l2)%Z) =
(kronecker m (ket_sum_l s f l1))).
Axiom kronecker_ket_sum_distr_r_rew :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (l1:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket m) ->
((cardinal s) > 0%Z)%Z ->
((kronecker m (ket_sum_l s f l1)) =
(ket_sum_l s (fun (k:a) => (kronecker m (f k))) (l1 + (ket_length m))%Z)).
Axiom ket_sum_scalar :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((ket_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
(infix_asdtdt a1 (ket_sum_l s f l))).
Axiom kronecker_ket_sum_distr_sc :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (m:matrix t) (a1:t) (l1:Z) (l2:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) l1) -> (is_a_ket_l m l2) ->
((cardinal s) > 0%Z)%Z ->
((ket_sum_l s (fun (k:a) => (kronecker (infix_asdtdt a1 (f k)) m))
(l1 + l2)%Z)
=
(infix_asdtdt a1
(ket_sum_l s (fun (k:a) => (kronecker (f k) m)) (l1 + l2)%Z))).
Axiom kronecker_decomp_r :
forall (m:matrix t) (n:matrix t) (lm:Z) (ln:Z), (is_a_ket_l m lm) ->
(is_a_ket_l n ln) ->
((kronecker m n) =
(ket_sum_l (n_bvs ln)
(fun (x:bitvec) =>
(infix_asdtdt (get_ket n (bv_to_int x)) (kronecker m (bv_to_ket x))))
(lm + ln)%Z)).
Axiom kronecker_decomp_l :
forall (m:matrix t) (n:matrix t) (lm:Z) (ln:Z), (is_a_ket_l m lm) ->
(is_a_ket_l n ln) ->
((kronecker m n) =
(ket_sum_l (n_bvs lm)
(fun (x:bitvec) =>
(infix_asdtdt (get_ket m (bv_to_int x)) (kronecker (bv_to_ket x) n)))
(lm + ln)%Z)).
Axiom kronecker_ket_sum_distr_double :
forall (i:Z) (j:Z) (f:bitvec -> matrix t) (g:bitvec -> matrix t) (l1:Z)
(l2:Z),
(0%Z <= i)%Z -> (0%Z <= j)%Z ->
(forall (bv:bitvec), (mem bv (n_bvs i)) -> is_a_ket_l (f bv) l1) ->
(forall (bv:bitvec), (mem bv (n_bvs j)) -> is_a_ket_l (g bv) l2) ->
((kronecker (ket_sum_l (n_bvs i) f l1) (ket_sum_l (n_bvs j) g l2)) =
(ket_sum_l (n_bvs (i + j)%Z)
(fun (k:bitvec) => (kronecker (f (hpart k i)) (g (tpart k i))))
(l1 + l2)%Z)).
Axiom kronecker_sem_decomp_r :
forall (c:gate) (m1:matrix t) (m2:matrix t) (f:bitvec -> matrix t) (s2:Z),
(is_a_ket_l m1 ((size c) - s2)%Z) ->
(forall (x:bitvec), ((length x) = s2) ->
sem c (kronecker m1 (bv_to_ket x)) (f x)) ->
(is_a_ket_l m2 s2) ->
sem c (kronecker m1 m2)
(ket_sum_l (n_bvs s2)
(fun (x:bitvec) => (infix_asdtdt (get_ket m2 (bv_to_int x)) (f x)))
(size c)).
Axiom kronecker_sem_decomp_r1 :
forall (c:gate) (m1:matrix t) (m2:matrix t) (f:bitvec -> matrix t) (s2:Z),
(is_a_ket_l m1 ((size c) - s2)%Z) ->
(forall (x:bitvec), ((length x) = s2) ->
sem c (kronecker m1 (bv_to_ket x)) (f x)) ->
(is_a_ket_l m2 s2) ->
sem c (kronecker m1 m2)
(ket_sum_l (n_bvs s2)
(fun (x:bitvec) =>
(infix_asdtdt (get_ket m2 (bv_to_int x))
(pat_sem c (kronecker m1 (bv_to_ket x)))))
(size c)).
Axiom kronecker_sem_decomp_l :
forall (c:gate) (m1:matrix t) (m2:matrix t) (f:bitvec -> matrix t) (s1:Z),
(is_a_ket_l m2 ((size c) - s1)%Z) ->
(forall (x:bitvec), ((length x) = s1) ->
sem c (kronecker (bv_to_ket x) m2) (f x)) ->
(is_a_ket_l m1 s1) ->
sem c (kronecker m1 m2)
(ket_sum_l (n_bvs s1)
(fun (x:bitvec) => (infix_asdtdt (get_ket m1 (bv_to_int x)) (f x)))
(size c)).
Axiom kronecker_sem_decomp_l1 :
forall (c:gate) (m1:matrix t) (m2:matrix t) (f:bitvec -> matrix t) (s1:Z),
(is_a_ket_l m2 ((size c) - s1)%Z) ->
(forall (x:bitvec), ((length x) = s1) ->
sem c (kronecker (bv_to_ket x) m2) (f x)) ->
(is_a_ket_l m1 s1) ->
sem c (kronecker m1 m2)
(ket_sum_l (n_bvs s1)
(fun (x:bitvec) =>
(infix_asdtdt (get_ket m1 (bv_to_int x))
(pat_sem c (kronecker (bv_to_ket x) m2))))
(size c)).
Axiom sem_kronecker_decomp_l :
forall (c:gate) (m1:matrix t) (m2:matrix t) (y:matrix t)
(f:bitvec -> matrix t) (s2:Z),
(forall (x:bitvec), ((length x) = (size c)) -> sem c (bv_to_ket x) (f x)) ->
(sem c m1 y) -> (is_a_ket_l m2 s2) ->
((kronecker y m2) =
(ket_sum_l (n_bvs (size c))
(fun (x:bitvec) =>
(infix_asdtdt (get_ket m1 (bv_to_int x)) (kronecker (f x) m2)))
((size c) + s2)%Z)).
Axiom sem_kronecker_decomp_r :
forall (c:gate) (m1:matrix t) (m2:matrix t) (y:matrix t)
(f:bitvec -> matrix t) (s1:Z),
(forall (x:bitvec), ((length x) = (size c)) -> sem c (bv_to_ket x) (f x)) ->
(sem c m2 y) -> (is_a_ket_l m1 s1) ->
((kronecker m1 y) =
(ket_sum_l (n_bvs (size c))
(fun (x:bitvec) =>
(infix_asdtdt (get_ket m2 (bv_to_int x)) (kronecker m1 (f x))))
((size c) + s1)%Z)).
Axiom cont_kron_left_contz :
forall (c:gate) (co:Z) (n:Z) (x:matrix t) (y:matrix t),
(((size c) <= co)%Z /\ (co < n)%Z) -> (is_a_ket_l x (size c)) ->
(is_a_ket_l y (n - (size c))%Z) -> (is_a_ket_basis_elt y) ->
(((getbv (ket_to_bv y)) (co - (size c))%Z) = 0%Z) ->
sem (cont c co 0%Z n) (kronecker x y) (kronecker x y).
Axiom cont_kron_left_conto :
forall (c:gate) (co:Z) (n:Z) (f:bitvec -> matrix t) (x:matrix t)
(y:matrix t),
(((size c) <= co)%Z /\ (co < n)%Z) -> (is_a_ket_l x (size c)) ->
(is_a_ket_l y (n - (size c))%Z) -> (is_a_ket_basis_elt y) ->
(((getbv (ket_to_bv y)) (co - (size c))%Z) = 1%Z) ->
(forall (z:bitvec), ((length z) = (size c)) -> sem c (bv_to_ket z) (f z)) ->
sem (cont c co 0%Z n) (kronecker x y) (kronecker (pat_sem c x) y).
Axiom cont_kron_right_contz :
forall (c:gate) (co:Z) (n:Z) (x:matrix t) (y:matrix t),
((0%Z <= co)%Z /\ (co < (n - (size c))%Z)%Z) ->
(is_a_ket_l x (n - (size c))%Z) -> (is_a_ket_l y (size c)) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 0%Z) ->
sem (cont c co (n - (size c))%Z n) (kronecker x y) (kronecker x y).
Axiom cont_kron_right_conto :
forall (c:gate) (co:Z) (n:Z) (f:bitvec -> matrix t) (x:matrix t)
(y:matrix t),
((0%Z <= co)%Z /\ (co < (n - (size c))%Z)%Z) ->
(is_a_ket_l x (n - (size c))%Z) -> (is_a_ket_l y (size c)) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) co) = 1%Z) ->
(forall (z:bitvec), ((length z) = (size c)) -> sem c (bv_to_ket z) (f z)) ->
sem (cont c co (n - (size c))%Z n) (kronecker x y)
(kronecker x (pat_sem c y)).
Axiom cont_kron_gen_right :
forall (circ:gate) (c:Z) (ft:Z) (n:Z) (y:matrix t) (z:matrix t),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(sem circ y z) -> forall (x:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_l x ft) -> (((getbv (ket_to_bv x)) c) = 0%Z) ->
sem (cont circ c ft n) (kronecker x y) (kronecker x y).
Axiom cont_kron_gen_right1 :
forall (circ:gate) (c:Z) (ft:Z) (n:Z) (y:matrix t) (z:matrix t),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(sem circ y z) -> forall (x:matrix t), (is_a_ket_basis_elt x) ->
(is_a_ket_l x ft) -> (((getbv (ket_to_bv x)) c) = 1%Z) ->
sem (cont circ c ft n) (kronecker x y) (kronecker x z).
Parameter place_hadamard: Z -> Z -> gate.
Axiom place_hadamard_def :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
((place_hadamard k n) = (place hadamard k n)).
Axiom place_hadamard_spec :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
((range (place_hadamard k n)) = 1%Z).
Axiom place_hadamard_spec1 :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
((size (place_hadamard k n)) = n).
Axiom place_hadamard_spec2 :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = n) ->
((length y) = 1%Z) -> ((0%Z <= i)%Z /\ (i < n)%Z) ->
((i = k) -> ((basis_ket_i (place_hadamard k n) x y i) = ((getbv y) 0%Z))) /\
(~ (i = k) -> ((basis_ket_i (place_hadamard k n) x y i) = ((getbv x) i))).
Parameter fc14: Z -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def14 :
forall (k:Z) (x:bitvec) (y:bitvec) (i:Z),
((i = k) -> (((fc14 k x y) i) = ((getbv y) 0%Z))) /\
(~ (i = k) -> (((fc14 k x y) i) = ((getbv x) i))).
Axiom place_hadamard_spec3 :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
forall (x:bitvec) (y:bitvec), ((length x) = n) -> ((length y) = 1%Z) ->
((basis_ket (place_hadamard k n) x y) = (make_bv (fc14 k x y) n)).
Axiom place_hadamard_spec4 :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
forall (x:bitvec) (y:bitvec), ((length x) = n) -> ((length y) = 1%Z) ->
((ang_ind (place_hadamard k n) x y) =
(int_to_ang (((getbv x) k) * ((getbv y) 0%Z))%Z 1%Z)).
Axiom place_hadamard_spec5 :
forall (k:Z) (n:Z), ((0%Z <= k)%Z /\ (k < n)%Z) ->
forall (x:bitvec) (y:bitvec), forall (m:Z), (m >= 1%Z)%Z ->
((length x) = n) -> ((length y) = 1%Z) ->
((ang_ind (place_hadamard k n) x y) =
(int_to_ang
((((getbv x) k) * ((getbv y) 0%Z))%Z * (power_ 2%Z (m - 1%Z)%Z))%Z m)).
Parameter bv_get:
forall {a:Type} {a_WT:WhyType a}, (matrix a) -> bitvec -> bitvec -> a.
Axiom bv_get_def :
forall {a:Type} {a_WT:WhyType a},
forall (m:matrix a) (x:bitvec) (y:bitvec),
((bv_get m x y) = (get m (bv_to_int x) (bv_to_int y))).
Parameter bv_make:
forall {a:Type} {a_WT:WhyType a}, (bitvec -> bitvec -> a) -> Z -> Z ->
matrix a.
Axiom bv_make_def :
forall {a:Type} {a_WT:WhyType a},
forall (f:bitvec -> bitvec -> a) (size1:Z) (range1:Z), (0%Z <= size1)%Z ->
(0%Z <= range1)%Z ->
((bv_make f size1 range1) =
(make_f (power 2%Z size1) (power 2%Z range1)
(fun (i:Z) (j:Z) => ((f (int_to_bv i size1)) (int_to_bv j range1))))).
Axiom bv_make_spec :
forall {a:Type} {a_WT:WhyType a},
forall (f:bitvec -> bitvec -> a) (size1:Z) (range1:Z), (0%Z <= size1)%Z ->
(0%Z <= range1)%Z -> forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) ->
((bv_get (bv_make f size1 range1) x y) = ((f x) y)).
Axiom bv_make_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (f:bitvec -> bitvec -> a) (size1:Z) (range1:Z), (0%Z <= size1)%Z ->
(0%Z <= range1)%Z -> ((rows (bv_make f size1 range1)) = (power 2%Z size1)).
Axiom bv_make_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (f:bitvec -> bitvec -> a) (size1:Z) (range1:Z), (0%Z <= size1)%Z ->
(0%Z <= range1)%Z ->
((columns (bv_make f size1 range1)) = (power 2%Z range1)).
Axiom bk_func : Type.
Parameter bk_func_WhyType : WhyType bk_func.
Existing Instance bk_func_WhyType.
Parameter mat_k: bk_func -> matrix bitvec.
Parameter size_k: bk_func -> Z.
Parameter range_k: bk_func -> Z.
Axiom bk_func'invariant : forall (self:bk_func), ((size_k self) >= 0%Z)%Z.
Axiom bk_func'invariant1 : forall (self:bk_func), ((range_k self) >= 0%Z)%Z.
Axiom bk_func'invariant2 :
forall (self:bk_func), ((rows (mat_k self)) = (power 2%Z (size_k self))).
Axiom bk_func'invariant3 :
forall (self:bk_func),
((columns (mat_k self)) = (power 2%Z (range_k self))).
Axiom bk_func'invariant4 :
forall (self:bk_func), forall (x:bitvec) (y:bitvec),
((length x) = (size_k self)) -> ((length y) = (range_k self)) ->
((length (bv_get (mat_k self) x y)) = (size_k self)).
Parameter get_k: bk_func -> bitvec -> bitvec -> bitvec.
Axiom get_k_def :
forall (k:bk_func) (x:bitvec) (y:bitvec),
((get_k k x y) = (bv_get (mat_k k) x y)).
Axiom get_k_spec :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) -> ((length (get_k k x y)) = (size_k k)).
Parameter get_k_int: bk_func -> bitvec -> bitvec -> Z.
Axiom get_k_int_def :
forall (k:bk_func) (x:bitvec) (y:bitvec),
((get_k_int k x y) = (bv_to_int (get_k k x y))).
Axiom get_k_int_spec :
forall (k:bk_func) (x:bitvec) (y:bitvec),
((get_k_int k x y) = (bv_to_int (bv_get (mat_k k) x y))).
Axiom get_k_int_spec1 :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) -> (0%Z <= (get_k_int k x y))%Z.
Axiom get_k_int_spec2 :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) ->
((get_k_int k x y) < (power 2%Z (size_k k)))%Z.
Parameter get_k_ket: bk_func -> bitvec -> bitvec -> matrix t.
Axiom get_k_ket_def :
forall (k:bk_func) (x:bitvec) (y:bitvec),
((get_k_ket k x y) = (bv_to_ket (get_k k x y))).
Axiom get_k_ket_spec :
forall (k:bk_func) (x:bitvec) (y:bitvec),
((get_k_ket k x y) = (bv_to_ket (bv_get (mat_k k) x y))).
Axiom get_k_ket_spec1 :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) -> is_a_ket_l (get_k_ket k x y) (size_k k).
Axiom get_k_ket_spec2 :
forall (k:bk_func) (x:bitvec) (y:bitvec),
is_a_ket_basis_elt (get_k_ket k x y).
Axiom get_k_ket_spec3 :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) ->
((get_k_ket k x y) = (ket (size_k k) (get_k_int k x y))).
Axiom get_k_ket_is_a_ket_l :
forall (k:bk_func) (x:bitvec) (y:bitvec) (l:Z), ((length x) = l) ->
((length y) = (range_k k)) -> (l = (size_k k)) ->
is_a_ket_l (get_k_ket k x y) l.
Axiom get_k_length :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) -> ((length (get_k k x y)) = (size_k k)).
Parameter get_ki: bk_func -> bitvec -> bitvec -> Z -> Z.
Axiom get_ki_def :
forall (k:bk_func) (x:bitvec) (y:bitvec) (i:Z),
((get_ki k x y i) = ((getbv (get_k k x y)) i)).
Axiom get_ki_spec :
forall (k:bk_func) (x:bitvec) (y:bitvec) (i:Z),
((get_ki k x y i) = ((getbv (bv_get (mat_k k) x y)) i)).
Axiom length_bk :
forall (k:bk_func) (x:bitvec) (y:bitvec), ((length x) = (size_k k)) ->
((length y) = (range_k k)) -> ((length (get_k k x y)) = (size_k k)).
Parameter make_k: (bitvec -> bitvec -> bitvec) -> Z -> Z -> bk_func.
Axiom make_k_spec :
forall (f:bitvec -> bitvec -> bitvec) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((f x) y)) = size1)) ->
forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((get_k (make_k f size1 range1) x y) = ((f x) y)).
Axiom make_k_spec1 :
forall (f:bitvec -> bitvec -> bitvec) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((f x) y)) = size1)) ->
((mat_k (make_k f size1 range1)) = (bv_make f size1 range1)).
Axiom make_k_spec2 :
forall (f:bitvec -> bitvec -> bitvec) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((f x) y)) = size1)) ->
((size_k (make_k f size1 range1)) = size1).
Axiom make_k_spec3 :
forall (f:bitvec -> bitvec -> bitvec) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((f x) y)) = size1)) ->
((range_k (make_k f size1 range1)) = range1).
Axiom angle_func : Type.
Parameter angle_func_WhyType : WhyType angle_func.
Existing Instance angle_func_WhyType.
Parameter mat_a: angle_func -> matrix angle.
Parameter size_a: angle_func -> Z.
Parameter range_a: angle_func -> Z.
Axiom angle_func'invariant :
forall (self:angle_func), ((size_a self) >= 0%Z)%Z.
Axiom angle_func'invariant1 :
forall (self:angle_func), ((range_a self) >= 0%Z)%Z.
Axiom angle_func'invariant2 :
forall (self:angle_func), ((rows (mat_a self)) = (power 2%Z (size_a self))).
Axiom angle_func'invariant3 :
forall (self:angle_func),
((columns (mat_a self)) = (power 2%Z (range_a self))).
Parameter get_a: angle_func -> bitvec -> bitvec -> angle.
Axiom get_a_def :
forall (k:angle_func) (x:bitvec) (y:bitvec),
((get_a k x y) = (bv_get (mat_a k) x y)).
Parameter get_ac: angle_func -> bitvec -> bitvec -> t.
Axiom get_ac_def :
forall (k:angle_func) (x:bitvec) (y:bitvec),
((get_ac k x y) = (ang_exp (bv_get (mat_a k) x y))).
Parameter gen_ket: angle_func -> Prop.
Axiom gen_ket_def :
forall (a:angle_func), (gen_ket a) -> ((range_a a) = 0%Z).
Axiom gen_ket_def1 : forall (a:angle_func), ((range_a a) = 0%Z) -> gen_ket a.
Parameter make_a: (bitvec -> bitvec -> angle) -> Z -> Z -> angle_func.
Axiom make_a_spec :
forall (f:bitvec -> bitvec -> angle) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z -> forall (x:bitvec) (y:bitvec),
((length x) = size1) -> ((length y) = range1) ->
((get_a (make_a f size1 range1) x y) = ((f x) y)).
Axiom make_a_spec1 :
forall (f:bitvec -> bitvec -> angle) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z -> forall (x:bitvec) (y:bitvec),
((length x) = size1) -> ((length y) = range1) ->
((get_ac (make_a f size1 range1) x y) = (ang_exp ((f x) y))).
Axiom make_a_spec2 :
forall (f:bitvec -> bitvec -> angle) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
((mat_a (make_a f size1 range1)) = (bv_make f size1 range1)).
Axiom make_a_spec3 :
forall (f:bitvec -> bitvec -> angle) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
((size_a (make_a f size1 range1)) = size1).
Axiom make_a_spec4 :
forall (f:bitvec -> bitvec -> angle) (size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
((range_a (make_a f size1 range1)) = range1).
Parameter k_seq: bk_func -> bk_func -> bk_func.
Axiom k_seq_def :
forall (k1:bk_func) (k2:bk_func), ((size_k k1) = (size_k k2)) ->
((k_seq k1 k2) =
(make_k
(fun (x:bitvec) (y:bitvec) =>
(get_k k2 (get_k k1 x (hpart y (range_k k1))) (tpart y (range_k k1))))
(size_k k1) ((range_k k1) + (range_k k2))%Z)).
Axiom k_seq_spec :
forall (k1:bk_func) (k2:bk_func), ((size_k k1) = (size_k k2)) ->
forall (x:bitvec) (y:bitvec), ((length x) = (size_k k1)) ->
((length y) = ((range_k k1) + (range_k k2))%Z) ->
((get_k (k_seq k1 k2) x y) =
(get_k k2 (get_k k1 x (hpart y (range_k k1))) (tpart y (range_k k1)))).
Axiom k_seq_spec1 :
forall (k1:bk_func) (k2:bk_func), ((size_k k1) = (size_k k2)) ->
((size_k (k_seq k1 k2)) = (size_k k1)).
Axiom k_seq_spec2 :
forall (k1:bk_func) (k2:bk_func), ((size_k k1) = (size_k k2)) ->
((range_k (k_seq k1 k2)) = ((range_k k1) + (range_k k2))%Z).
Axiom k_seq_spec3 :
forall (k1:bk_func) (k2:bk_func), ((size_k k1) = (size_k k2)) ->
forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = (size_k k1)) ->
((length y) = ((range_k k1) + (range_k k2))%Z) ->
((0%Z <= i)%Z /\ (i < ((range_k k1) + (range_k k2))%Z)%Z) ->
((get_ki (k_seq k1 k2) x y i) =
(get_ki k2 (get_k k1 x (hpart y (range_k k1))) (tpart y (range_k k1)) i)).
Parameter k_par: bk_func -> bk_func -> bk_func.
Axiom k_par_def :
forall (k1:bk_func) (k2:bk_func),
((k_par k1 k2) =
(make_k
(fun (x:bitvec) (y:bitvec) =>
(concat (get_k k1 (hpart x (size_k k1)) (hpart y (range_k k1)))
(get_k k2 (tpart x (size_k k1)) (tpart y (range_k k1)))))
((size_k k1) + (size_k k2))%Z ((range_k k1) + (range_k k2))%Z)).
Axiom k_par_spec :
forall (k1:bk_func) (k2:bk_func),
((size_k (k_par k1 k2)) = ((size_k k1) + (size_k k2))%Z).
Axiom k_par_spec1 :
forall (k1:bk_func) (k2:bk_func),
((range_k (k_par k1 k2)) = ((range_k k1) + (range_k k2))%Z).
Axiom k_par_spec2 :
forall (k1:bk_func) (k2:bk_func), forall (x:bitvec) (y:bitvec),
((length x) = ((size_k k1) + (size_k k2))%Z) ->
((length y) = ((range_k k1) + (range_k k2))%Z) ->
((get_k (k_par k1 k2) x y) =
(concat (get_k k1 (hpart x (size_k k1)) (hpart y (range_k k1)))
(get_k k2 (tpart x (size_k k1)) (tpart y (range_k k1))))).
Axiom k_par_spec3 :
forall (k1:bk_func) (k2:bk_func), forall (x:bitvec) (y:bitvec),
forall (i:Z), ((length x) = ((size_k k1) + (size_k k2))%Z) ->
((length y) = ((range_k k1) + (range_k k2))%Z) ->
((0%Z <= i)%Z /\ (i < (size_k k1))%Z) ->
((get_ki (k_par k1 k2) x y i) =
(get_ki k1 (hpart x (size_k k1)) (hpart y (range_k k1)) i)).
Axiom k_par_spec4 :
forall (k1:bk_func) (k2:bk_func), forall (x:bitvec) (y:bitvec),
forall (i:Z), ((length x) = ((size_k k1) + (size_k k2))%Z) ->
((length y) = ((range_k k1) + (range_k k2))%Z) ->
(((size_k k1) <= i)%Z /\ (i < ((size_k k1) + (size_k k2))%Z)%Z) ->
((get_ki (k_par k1 k2) x y i) =
(get_ki k2 (tpart x (size_k k1)) (tpart y (range_k k1))
(i - (size_k k1))%Z)).
Parameter a_seq: angle_func -> angle_func -> bk_func -> angle_func.
Axiom a_seq_def :
forall (a1:angle_func) (a2:angle_func) (k1:bk_func),
(((size_a a1) = (size_a a2)) /\ ((size_a a2) = (size_k k1))) ->
((range_a a1) = (range_k k1)) ->
((a_seq a1 a2 k1) =
(make_a
(fun (x:bitvec) (y:bitvec) =>
(ang_add (get_a a1 x (hpart y (range_a a1)))
(get_a a2 (get_k k1 x (hpart y (range_a a1))) (tpart y (range_a a1)))))
(size_a a1) ((range_a a1) + (range_a a2))%Z)).
Axiom a_seq_spec :
forall (a1:angle_func) (a2:angle_func) (k1:bk_func),
(((size_a a1) = (size_a a2)) /\ ((size_a a2) = (size_k k1))) ->
((range_a a1) = (range_k k1)) -> ((size_a (a_seq a1 a2 k1)) = (size_a a1)).
Axiom a_seq_spec1 :
forall (a1:angle_func) (a2:angle_func) (k1:bk_func),
(((size_a a1) = (size_a a2)) /\ ((size_a a2) = (size_k k1))) ->
((range_a a1) = (range_k k1)) ->
((range_a (a_seq a1 a2 k1)) = ((range_a a1) + (range_a a2))%Z).
Axiom a_seq_spec2 :
forall (a1:angle_func) (a2:angle_func) (k1:bk_func),
(((size_a a1) = (size_a a2)) /\ ((size_a a2) = (size_k k1))) ->
((range_a a1) = (range_k k1)) -> forall (x:bitvec) (y:bitvec),
((length x) = (size_a a1)) ->
((length y) = ((range_a a1) + (range_a a2))%Z) ->
((get_a (a_seq a1 a2 k1) x y) =
(ang_add (get_a a1 x (hpart y (range_a a1)))
(get_a a2 (get_k k1 x (hpart y (range_a a1))) (tpart y (range_a a1))))).
Axiom a_seq_spec3 :
forall (a1:angle_func) (a2:angle_func) (k1:bk_func),
(((size_a a1) = (size_a a2)) /\ ((size_a a2) = (size_k k1))) ->
((range_a a1) = (range_k k1)) -> forall (x:bitvec) (y:bitvec),
((length x) = (size_a a1)) ->
((length y) = ((range_a a1) + (range_a a2))%Z) ->
((get_ac (a_seq a1 a2 k1) x y) =
(infix_asdt (get_ac a1 x (hpart y (range_a a1)))
(get_ac a2 (get_k k1 x (hpart y (range_a a1))) (tpart y (range_a a1))))).
Parameter a_par: angle_func -> angle_func -> angle_func.
Axiom a_par_def :
forall (a1:angle_func) (a2:angle_func),
((a_par a1 a2) =
(make_a
(fun (x:bitvec) (y:bitvec) =>
(ang_add (get_a a1 (hpart x (size_a a1)) (hpart y (range_a a1)))
(get_a a2 (tpart x (size_a a1)) (tpart y (range_a a1)))))
((size_a a1) + (size_a a2))%Z ((range_a a1) + (range_a a2))%Z)).
Axiom a_par_spec :
forall (a1:angle_func) (a2:angle_func),
((size_a (a_par a1 a2)) = ((size_a a1) + (size_a a2))%Z).
Axiom a_par_spec1 :
forall (a1:angle_func) (a2:angle_func),
((range_a (a_par a1 a2)) = ((range_a a1) + (range_a a2))%Z).
Axiom a_par_spec2 :
forall (a1:angle_func) (a2:angle_func), forall (x:bitvec) (y:bitvec),
((length x) = ((size_a a1) + (size_a a2))%Z) ->
((length y) = ((range_a a1) + (range_a a2))%Z) ->
((get_a (a_par a1 a2) x y) =
(ang_add (get_a a1 (hpart x (size_a a1)) (hpart y (range_a a1)))
(get_a a2 (tpart x (size_a a1)) (tpart y (range_a a1))))).
Axiom a_par_spec3 :
forall (a1:angle_func) (a2:angle_func), forall (x:bitvec) (y:bitvec),
((length x) = ((size_a a1) + (size_a a2))%Z) ->
((length y) = ((range_a a1) + (range_a a2))%Z) ->
((get_ac (a_par a1 a2) x y) =
(infix_asdt (get_ac a1 (hpart x (size_a a1)) (hpart y (range_a a1)))
(get_ac a2 (tpart x (size_a a1)) (tpart y (range_a a1))))).
Parameter flat: gate -> Prop.
Axiom flat_def :
forall (c:gate), (flat c) ->
exists a:bitvec -> angle, exists b:bitvec -> bitvec,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z.
Axiom flat_def1 :
forall (c:gate),
(exists a:bitvec -> angle, exists b:bitvec -> bitvec,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
flat c.
Axiom set_flat :
forall (c:gate) (a:bitvec -> angle) (b:bitvec -> bitvec),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
flat c.
Axiom get_flat :
forall (c:gate), (flat c) ->
exists a:bitvec -> angle, exists b:bitvec -> bitvec,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z.
Axiom flat_phase : forall (o:angle), flat (phase o).
Axiom flat_rz : forall (o:angle), flat (rz o).
Axiom flat_cnot : flat cnot.
Axiom seq_pres_flat_pre :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle)
(b:bitvec -> bitvec) (b':bitvec -> bitvec),
((size c) = (size c')) ->
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => (b' x)) 0%Z) ->
correct_path_sum (sequence c c')
(fun (x:bitvec) (us:bitvec) => (ang_add (a x) (a' (b x))))
(fun (x:bitvec) (us:bitvec) => (b' (b x))) 0%Z.
Axiom seq_pres_flat_pre1 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle)
(b:bitvec -> bitvec) (b':bitvec -> bitvec),
((size c) = (size c')) ->
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => (b' x)) 0%Z) ->
flat (sequence c c').
Axiom par_pres_flat_pre :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle)
(b:bitvec -> bitvec) (b':bitvec -> bitvec),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => (b' x)) 0%Z) ->
correct_path_sum (parallel c c')
(fun (x:bitvec) (us:bitvec) =>
(ang_add (a (hpart x (size c))) (a' (tpart x (size c)))))
(fun (x:bitvec) (us:bitvec) =>
(concat (b (hpart x (size c))) (b' (tpart x (size c)))))
0%Z.
Axiom par_pres_flat_pre1 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle)
(b:bitvec -> bitvec) (b':bitvec -> bitvec),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => (b' x)) 0%Z) ->
flat (parallel c c').
Parameter flat_ang: gate -> bitvec -> angle.
Parameter flat_ket: gate -> bitvec -> bitvec.
Axiom flat_ket_spec :
forall (c:gate), (flat c) -> forall (x:bitvec), ((length x) = (size c)) ->
((length ((flat_ket c) x)) = (size c)).
Axiom flat_correct :
forall (c:gate), (flat c) ->
correct_path_sum c (fun (x:bitvec) (us:bitvec) => ((flat_ang c) x))
(fun (x:bitvec) (us:bitvec) => ((flat_ket c) x)) 0%Z.
Axiom seq_pres_flat :
forall (c:gate) (c':gate), ((size c) = (size c')) -> (flat c) ->
(flat c') -> flat (sequence c c').
Axiom diag_pres_flat :
forall (c:gate) (c':gate), (flat c) -> (flat c') -> flat (parallel c c').
Axiom flat_ang_phase :
forall (o:angle), ((flat_ang (phase o)) = (fun (us:bitvec) => o)).
Axiom flat_ang_rz :
forall (o:angle),
((flat_ang (rz o)) =
(fun (x:bitvec) => (phase_inv_ (1%Z - ((getbv x) 0%Z))%Z o))).
Axiom flat_ang_cnot : ((flat_ang cnot) = (fun (us:bitvec) => ang_zero)).
Axiom flat_ang_sequence :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ang (sequence c c')) =
(fun (x:bitvec) =>
(ang_add ((flat_ang c) x) ((flat_ang c') ((flat_ket c') x))))).
Axiom flat_ang_parallel :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ang (parallel c c')) =
(fun (x:bitvec) =>
(ang_add ((flat_ang c) (hpart x (size c)))
((flat_ang c') (tpart x (size c)))))).
Axiom flat_ket_phase :
forall (o:angle), ((flat_ket (phase o)) = (fun (i:bitvec) => i)).
Axiom flat_ket_rz :
forall (o:angle), ((flat_ket (rz o)) = (fun (i:bitvec) => i)).
Axiom flat_ket_cnot :
let fc15 := flat_ket cnot in
forall (x:bitvec),
(((0%Z <= (bv_to_int x))%Z /\ ((bv_to_int x) < 2%Z)%Z) -> ((fc15 x) = x)) /\
(~ ((0%Z <= (bv_to_int x))%Z /\ ((bv_to_int x) < 2%Z)%Z) ->
(((bv_to_int x) = 2%Z) -> ((fc15 x) = (int_to_bv 3%Z 2%Z))) /\
(~ ((bv_to_int x) = 2%Z) -> ((fc15 x) = (int_to_bv 2%Z 2%Z)))).
Axiom flat_ket_sequence :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ket (sequence c c')) =
(fun (x:bitvec) => ((flat_ket c') ((flat_ket c') x)))).
Axiom flat_ket_parallel :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ket (parallel c c')) =
(fun (x:bitvec) =>
(concat ((flat_ket c) (hpart x (size c)))
((flat_ket c') (tpart x (size c)))))).
Parameter f_sequence: gate -> gate -> gate.
Axiom f_sequence_def :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size c) = (size c')) -> ((f_sequence c c') = (sequence c c')).
Axiom f_sequence_spec :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size c) = (size c')) -> ((size (f_sequence c c')) = (size c)).
Axiom f_sequence_spec1 :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size c) = (size c')) -> flat (f_sequence c c').
Axiom f_sequence_spec2 :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size c) = (size c')) ->
((flat_ang (f_sequence c c')) =
(fun (x:bitvec) =>
(ang_add ((flat_ang c) x) ((flat_ang c') ((flat_ket c') x))))).
Axiom f_sequence_spec3 :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size c) = (size c')) ->
((flat_ket (f_sequence c c')) =
(fun (x:bitvec) => ((flat_ket c') ((flat_ket c) x)))).
Parameter f_parallel: gate -> gate -> gate.
Axiom f_parallel_def :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((f_parallel c c') = (parallel c c')).
Axiom f_parallel_spec :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((size (f_parallel c c')) = ((size c) + (size c'))%Z).
Axiom f_parallel_spec1 :
forall (c:gate) (c':gate), (flat c) -> (flat c') -> flat (f_parallel c c').
Axiom f_parallel_spec2 :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ang (f_parallel c c')) =
(fun (x:bitvec) =>
(ang_add ((flat_ang c) (hpart x (size c)))
((flat_ang c') (tpart x (size c)))))).
Axiom f_parallel_spec3 :
forall (c:gate) (c':gate), (flat c) -> (flat c') ->
((flat_ket (f_parallel c c')) =
(fun (x:bitvec) =>
(concat ((flat_ket c) (hpart x (size c)))
((flat_ket c') (tpart x (size c)))))).
Parameter diag: gate -> Prop.
Axiom diag_def :
forall (c:gate), (diag c) ->
exists a:bitvec -> angle,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom diag_def1 :
forall (c:gate),
(exists a:bitvec -> angle,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
diag c.
Axiom set_diag :
forall (c:gate) (a:bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
diag c.
Axiom get_diag :
forall (c:gate), (diag c) ->
exists a:bitvec -> angle,
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom get_diag_sem :
forall (c:gate), (diag c) ->
exists a:bitvec -> angle,
forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x (infix_asdtdt (ang_exp (a (ket_to_bv x))) x).
Axiom set_diag_sem :
forall (c:gate),
(exists a:bitvec -> angle,
forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x (infix_asdtdt (ang_exp (a (ket_to_bv x))) x)) ->
diag c.
Axiom set_diag_sem_elt :
forall (c:gate) (a:bitvec -> angle),
(forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x (infix_asdtdt (ang_exp (a (ket_to_bv x))) x)) ->
diag c.
Parameter diag_ang: gate -> bitvec -> angle.
Axiom diag_correct :
forall (c:gate), (diag c) ->
correct_path_sum c (fun (x:bitvec) (us:bitvec) => ((diag_ang c) x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom diag_sem :
forall (c:gate), (diag c) -> forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp ((diag_ang c) x)) (bv_to_ket x)).
Axiom set_correct_diag_sim :
forall (c:gate) (a:bitvec -> angle), (diag c) ->
(forall (x:bitvec), ((length x) = (size c)) -> (((diag_ang c) x) = (a x))) ->
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom set_correct_diag_sim_i :
forall (c:gate) (a:bitvec -> Z -> angle) (l:Z) (h:Z), (diag c) ->
(l <= h)%Z ->
(forall (x:bitvec), ((length x) = (size c)) ->
(((diag_ang c) x) = (ang_sum (a x) l h))) ->
correct_path_sum_i c (fun (x:bitvec) (us:bitvec) (i:Z) => ((a x) i)) l h
(fun (x:bitvec) (us:bitvec) (i:Z) => ((getbv x) i)) 0%Z.
Axiom set_correct_diag_sim_ :
forall (c:gate) (a:bitvec -> bitvec -> angle), (diag c) ->
(forall (x:bitvec) (y:bitvec) (y':bitvec), (((a x) y) = ((a x) y'))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
(((diag_ang c) x) = ((a x) y))) ->
correct_path_sum c a (fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom correct_to_diag :
forall (c:gate) (a:bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
diag c.
Axiom correct_to_diag1 :
forall (c:gate) (a:bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp (a x)) (bv_to_ket x)).
Axiom diag_sem_inst :
forall (c:gate) (x:bitvec) (a:angle), (diag c) ->
((length x) = (size c)) ->
(sem c (bv_to_ket x) (infix_asdtdt (ang_exp a) (bv_to_ket x))) ->
(a = ((diag_ang c) x)).
Axiom set_diag_eq :
forall (c:gate) (a:bitvec -> angle),
(forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp (a x)) (bv_to_ket x))) ->
diag c.
Axiom set_diag_eq1 :
forall (c:gate) (a:bitvec -> angle),
(forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp (a x)) (bv_to_ket x))) ->
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom set_diag_eq2 :
forall (c:gate) (a:bitvec -> angle),
(forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp (a x)) (bv_to_ket x))) ->
forall (x:bitvec), ((length x) = (size c)) -> ((a x) = ((diag_ang c) x)).
Axiom diag_sem_inst_rev :
forall (c:gate) (x:bitvec) (a:angle), (diag c) ->
((length x) = (size c)) -> (a = ((diag_ang c) x)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp a) (bv_to_ket x)).
Axiom diag_is_flat : forall (c:gate), (diag c) -> flat c.
Axiom diag_phase : forall (o:angle), diag (phase o).
Axiom diag_rz : forall (o:angle), diag (rz o).
Axiom seq_pres_diag_pre :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
((size c) = (size c')) ->
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
correct_path_sum (sequence c c')
(fun (x:bitvec) (us:bitvec) => (ang_add (a x) (a' x)))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom seq_pres_diag_pre1 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
((size c) = (size c')) ->
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
diag (sequence c c').
Axiom seq_pres_diag_pre2 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
((size c) = (size c')) ->
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
forall (x:bitvec), ((length x) = (size (sequence c c'))) ->
(((diag_ang (sequence c c')) x) = (ang_add (a x) (a' x))).
Axiom par_pres_diag_pre :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
correct_path_sum (parallel c c')
(fun (x:bitvec) (us:bitvec) =>
(ang_add (a (hpart x (size c))) (a' (tpart x (size c)))))
(fun (x:bitvec) (us:bitvec) => x) 0%Z.
Axiom par_pres_diag_pre1 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
diag (parallel c c').
Axiom par_pres_diag_pre2 :
forall (c:gate) (c':gate) (a:bitvec -> angle) (a':bitvec -> angle),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
(correct_path_sum c' (fun (x:bitvec) (us:bitvec) => (a' x))
(fun (x:bitvec) (us:bitvec) => x) 0%Z) ->
forall (x:bitvec), ((length x) = (size (parallel c c'))) ->
(((diag_ang (parallel c c')) x) =
(ang_add (a (hpart x (size c))) (a' (tpart x (size c))))).
Parameter diag_sum_scheme_unit: gate -> (matrix t) -> matrix t.
Axiom diag_sum_scheme_unit_def :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) -> (diag c) ->
((diag_sum_scheme_unit c x) =
(infix_asdtdt (ang_exp ((diag_ang c) (ket_to_bv x))) x)).
Axiom diag_sum_scheme_unit_spec :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) -> (diag c) ->
is_a_ket_l (diag_sum_scheme_unit c x) (size c).
Axiom diag_sum_scheme_unit_spec1 :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) -> (diag c) ->
((diag_sum_scheme_unit c x) =
(path_sum_scheme_unit (fun (x1:bitvec) (us:bitvec) => ((diag_ang c) x1))
(fun (x1:bitvec) (us:bitvec) => x1) (size c) 0%Z (ket_to_bv x))).
Axiom diag_sum_scheme_unit_spec2 :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) ->
(is_a_ket_basis_elt x) -> (diag c) ->
is_a_ket_l (diag_sum_scheme_unit c x) (size c).
Parameter diag_sum_scheme: gate -> (matrix t) -> matrix t.
Axiom diag_sum_scheme_def :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) -> (diag c) ->
((diag_sum_scheme c x) =
(ket_sum_l (n_bvs (size c))
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z))
(diag_sum_scheme_unit c (bv_to_ket (hpart z (size c))))))
(size c))).
Axiom diag_sum_scheme_spec :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) -> (diag c) ->
is_a_ket_l (diag_sum_scheme c x) (size c).
Axiom diag_sum_scheme_spec1 :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) -> (diag c) ->
((diag_sum_scheme c x) =
(ket_sum_l (n_bvs (size c))
(fun (z:bitvec) =>
(infix_asdtdt (get_ket x (bv_to_int z))
(diag_sum_scheme_unit c (bv_to_ket z))))
(size c))).
Axiom diag_sum_scheme_spec2 :
forall (c:gate) (x:matrix t), (is_a_ket_l x (size c)) -> (diag c) ->
((diag_sum_scheme c x) =
(path_sum_scheme (fun (x1:bitvec) (us:bitvec) => ((diag_ang c) x1))
(fun (x1:bitvec) (us:bitvec) => x1) (size c) 0%Z x)).
Axiom seq_pres_diag :
forall (c:gate) (c':gate), ((size c) = (size c')) -> (diag c) ->
(diag c') -> diag (sequence c c').
Axiom par_pres_diag :
forall (c:gate) (c':gate), (diag c) -> (diag c') -> diag (parallel c c').
Axiom pat_sem_diag_basis :
forall (c:gate) (x:bitvec), (diag c) -> ((length x) = (size c)) ->
((pat_sem c (bv_to_ket x)) =
(infix_asdtdt (ang_exp ((diag_ang c) x)) (bv_to_ket x))).
Axiom sem_diag_basis :
forall (c:gate) (x:bitvec), (diag c) -> ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp ((diag_ang c) x)) (bv_to_ket x)).
Axiom sem_diag_basis_gen :
forall (c:gate), (diag c) -> forall (x:bitvec), ((length x) = (size c)) ->
sem c (bv_to_ket x) (infix_asdtdt (ang_exp ((diag_ang c) x)) (bv_to_ket x)).
Axiom set_diag_ang :
forall (c:gate) (f:bitvec -> angle),
(forall (x:bitvec), ((length x) = (size c)) ->
((pat_sem c (bv_to_ket x)) = (infix_asdtdt (ang_exp (f x)) (bv_to_ket x)))) ->
diag c.
Axiom set_diag_ang1 :
forall (c:gate) (f:bitvec -> angle),
(forall (x:bitvec), ((length x) = (size c)) ->
((pat_sem c (bv_to_ket x)) = (infix_asdtdt (ang_exp (f x)) (bv_to_ket x)))) ->
forall (x:bitvec), ((length x) = (size c)) -> (((diag_ang c) x) = (f x)).
Axiom set_diag_ang_sem :
forall (c:gate) (f:bitvec -> angle),
(forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x (infix_asdtdt (ang_exp (f (ket_to_bv x))) x)) ->
diag c.
Axiom set_diag_ang_sem1 :
forall (c:gate) (f:bitvec -> angle),
(forall (x:matrix t), (is_a_ket_l x (size c)) -> (is_a_ket_basis_elt x) ->
sem c x (infix_asdtdt (ang_exp (f (ket_to_bv x))) x)) ->
forall (x:bitvec), ((length x) = (size c)) -> (((diag_ang c) x) = (f x)).
Axiom diag_ang_phase :
forall (o:angle), ((diag_ang (phase o)) = (fun (us:bitvec) => o)).
Axiom diag_ang_rz :
forall (o:angle),
((diag_ang (rz o)) =
(fun (x:bitvec) => (phase_inv_ (1%Z - ((getbv x) 0%Z))%Z o))).
Axiom diag_ang_cnot : ((diag_ang cnot) = (fun (us:bitvec) => ang_zero)).
Axiom diag_ang_sequence :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((diag_ang (sequence c c')) =
(fun (x:bitvec) => (ang_add ((diag_ang c) x) ((diag_ang c') x)))).
Axiom diag_ang_parallel :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((diag_ang (parallel c c')) =
(fun (x:bitvec) =>
(ang_add ((diag_ang c) (hpart x (size c)))
((diag_ang c') (tpart x (size c)))))).
Parameter d_sequence: gate -> gate -> gate.
Axiom d_sequence_def :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((size c) = (size c')) -> ((d_sequence c c') = (sequence c c')).
Axiom d_sequence_spec :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((size c) = (size c')) -> ((size (d_sequence c c')) = (size c)).
Axiom d_sequence_spec1 :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((size c) = (size c')) -> diag (d_sequence c c').
Axiom d_sequence_spec2 :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((size c) = (size c')) ->
((diag_ang (d_sequence c c')) =
(fun (x:bitvec) => (ang_add ((diag_ang c) x) ((diag_ang c') x)))).
Axiom d_sequence_eq :
forall (d:gate) (d':gate) (e1:gate) (e':gate), (diag d) -> (diag e1) ->
((size d) = (size e1)) -> (d = d') -> (e1 = e') ->
((d_sequence d e1) = (d_sequence d' e')).
Parameter d_parallel: gate -> gate -> gate.
Axiom d_parallel_def :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((d_parallel c c') = (parallel c c')).
Axiom d_parallel_spec :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((size (d_parallel c c')) = ((size c) + (size c'))%Z).
Axiom d_parallel_spec1 :
forall (c:gate) (c':gate), (diag c) -> (diag c') -> diag (d_parallel c c').
Axiom d_parallel_spec2 :
forall (c:gate) (c':gate), (diag c) -> (diag c') ->
((diag_ang (d_parallel c c')) =
(fun (x:bitvec) =>
(ang_add ((diag_ang c) (hpart x (size c)))
((diag_ang c') (tpart x (size c)))))).
Axiom d_parallel_eq :
forall (d:gate) (d':gate) (e1:gate) (e':gate), (diag d) -> (diag e1) ->
(d = d') -> (e1 = e') -> ((d_parallel d e1) = (d_parallel d' e')).
Parameter d_seq_iter: (Z -> gate) -> Z -> Z -> Z -> gate.
Axiom d_seq_iter_def :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
(j = (i + 1%Z)%Z) -> ((d_seq_iter f d i j) = (f i)).
Axiom d_seq_iter_def1 :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
~ (j = (i + 1%Z)%Z) ->
((d_seq_iter f d i j) =
(d_sequence (d_seq_iter f d i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).
Axiom d_seq_iter_spec :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
diag (d_seq_iter f d i j).
Axiom d_seq_iter_spec1 :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
((size (d_seq_iter f d i j)) = d).
Axiom d_seq_iter_spec2 :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
forall (x:bitvec), ((length x) = d) ->
(((diag_ang (d_seq_iter f d i j)) x) =
(ang_sum (fun (k:Z) => ((diag_ang (f k)) x)) i j)).
Axiom d_seq_iter_one :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), ((i + 1%Z)%Z = j) ->
((size (f i)) = d) -> (diag (f i)) -> ((d_seq_iter f d i j) = (f i)).
Axiom d_seq_iter_plus_one :
forall (f:Z -> gate) (d:Z) (i:Z) (j:Z), ((i + 1%Z)%Z < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
((d_seq_iter f d i j) =
(d_sequence (d_seq_iter f d i (j - 1%Z)%Z) (f (j - 1%Z)%Z))).
Axiom d_seq_iter_eq :
forall (f:Z -> gate) (g:Z -> gate) (d:Z) (i:Z) (j:Z), (i < j)%Z ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((size (f k)) = d)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> diag (f k)) ->
(forall (k:Z), ((i <= k)%Z /\ (k < j)%Z) -> ((f k) = (g k))) ->
((d_seq_iter g d i j) = (d_seq_iter f d i j)).
Parameter rzp: Z -> gate.
Axiom rzp_def :
forall (n:Z), (n >= 0%Z)%Z ->
((rzp n) =
(d_sequence (phase (int_to_ang 1%Z (n + 1%Z)%Z))
(rz (int_to_ang 1%Z (n + 1%Z)%Z)))).
Axiom rzp_spec : forall (n:Z), (n >= 0%Z)%Z -> ((size (rzp n)) = 1%Z).
Axiom rzp_spec1 : forall (n:Z), (n >= 0%Z)%Z -> diag (rzp n).
Axiom rzp_spec2 :
forall (n:Z), (n >= 0%Z)%Z -> forall (x:bitvec), ((length x) = 1%Z) ->
(((diag_ang (rzp n)) x) = (int_to_ang ((getbv x) 0%Z) n)).
Parameter rzp_neg: Z -> gate.
Axiom rzp_neg_def :
forall (n:Z), (n >= 0%Z)%Z ->
((rzp_neg n) =
(d_sequence (phase (int_to_ang (-1%Z)%Z (n + 1%Z)%Z))
(rz (int_to_ang (-1%Z)%Z (n + 1%Z)%Z)))).
Axiom rzp_neg_spec :
forall (n:Z), (n >= 0%Z)%Z -> ((size (rzp_neg n)) = 1%Z).
Axiom rzp_neg_spec1 : forall (n:Z), (n >= 0%Z)%Z -> diag (rzp_neg n).
Axiom rzp_neg_spec2 :
forall (n:Z), (n >= 0%Z)%Z -> forall (x:bitvec), ((length x) = 1%Z) ->
(((diag_ang (rzp_neg n)) x) = (int_to_ang (-((getbv x) 0%Z))%Z n)).
Parameter dplace: gate -> Z -> Z -> gate.
Axiom dplace_def :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
(diag c) -> ((dplace c k n) = (place c k n)).
Axiom dplace_spec :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
(diag c) -> diag (dplace c k n).
Axiom dplace_spec1 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
(diag c) -> ((size (dplace c k n)) = n).
Axiom dplace_spec2 :
forall (c:gate) (k:Z) (n:Z), (k >= 0%Z)%Z -> (n >= ((size c) + k)%Z)%Z ->
(diag c) -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (dplace c k n)) x) = ((diag_ang c) (htpart x k (size c)))).
Parameter dcont: gate -> Z -> Z -> Z -> gate.
Axiom dcont_def :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> ((dcont c co ft n) = (cont c co ft n)).
Axiom dcont_def1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) ->
((dcont c co ft n) = (cont c co ft n)).
Axiom dcont_spec :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> diag (dcont c co ft n).
Axiom dcont_spec1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> ((size (dcont c co ft n)) = n).
Axiom dcont_spec2 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (dcont c co ft n)) x) =
(ang_mult_int ((diag_ang c) (htpart x ft (size c))) ((getbv x) co))).
Axiom dcont_spec3 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> diag (dcont c co ft n).
Axiom dcont_spec4 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> ((size (dcont c co ft n)) = n).
Axiom dcont_spec5 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> forall (x:bitvec),
((length x) = n) ->
(((diag_ang (dcont c co ft n)) x) =
(ang_mult_int ((diag_ang c) (htpart x ft (size c))) ((getbv x) co))).
Parameter d_cont: gate -> Z -> Z -> Z -> gate.
Axiom d_cont_def :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> ((d_cont c co ft n) = (dcont c co ft n)).
Axiom d_cont_def1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) ->
((d_cont c co ft n) = (dcont c co ft n)).
Axiom d_cont_spec :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> diag (d_cont c co ft n).
Axiom d_cont_spec1 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> ((size (d_cont c co ft n)) = n).
Axiom d_cont_spec2 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) -> ~ (ft <= co)%Z ->
(diag c) -> forall (x:bitvec), ((length x) = n) ->
((((getbv x) co) = 1%Z) ->
(((diag_ang (d_cont c co ft n)) x) =
((diag_ang c) (htpart x ft (size c))))) /\
(~ (((getbv x) co) = 1%Z) ->
(((diag_ang (d_cont c co ft n)) x) = ang_zero)).
Axiom d_cont_spec3 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> diag (d_cont c co ft n).
Axiom d_cont_spec4 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> ((size (d_cont c co ft n)) = n).
Axiom d_cont_spec5 :
forall (c:gate) (co:Z) (ft:Z) (n:Z), ((0%Z <= co)%Z /\ (co < n)%Z) ->
((0%Z <= ft)%Z /\ (ft <= (n - (size c))%Z)%Z) ->
((ft + (size c))%Z <= co)%Z -> (diag c) -> forall (x:bitvec),
((length x) = n) ->
((((getbv x) co) = 1%Z) ->
(((diag_ang (d_cont c co ft n)) x) =
((diag_ang c) (htpart x ft (size c))))) /\
(~ (((getbv x) co) = 1%Z) ->
(((diag_ang (d_cont c co ft n)) x) = ang_zero)).
Parameter c_rzp: Z -> Z -> Z -> Z -> gate.
Axiom c_rzp_def :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> ((c_rzp k co ft n) = (dcont (rzp k) co ft n)).
Axiom c_rzp_def1 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> ((c_rzp k co ft n) = (dcont (rzp k) co ft n)).
Axiom c_rzp_spec :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> ((size (c_rzp k co ft n)) = n).
Axiom c_rzp_spec1 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> diag (c_rzp k co ft n).
Axiom c_rzp_spec2 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang (((getbv x) co) * ((getbv x) ft))%Z k)).
Axiom c_rzp_spec3 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang
((((getbv x) co) * ((getbv x) ft))%Z * (power 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_spec4 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang
((((getbv x) co) * ((getbv x) ft))%Z * (power_ 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_spec5 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> ((size (c_rzp k co ft n)) = n).
Axiom c_rzp_spec6 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> diag (c_rzp k co ft n).
Axiom c_rzp_spec7 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang (((getbv x) co) * ((getbv x) ft))%Z k)).
Axiom c_rzp_spec8 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang
((((getbv x) co) * ((getbv x) ft))%Z * (power 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_spec9 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp k co ft n)) x) =
(int_to_ang
((((getbv x) co) * ((getbv x) ft))%Z * (power_ 2%Z (m - k)%Z))%Z m)).
Parameter c_rzp_neg: Z -> Z -> Z -> Z -> gate.
Axiom c_rzp_neg_def :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> ((c_rzp_neg k co ft n) = (dcont (rzp_neg k) co ft n)).
Axiom c_rzp_neg_def1 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> ((c_rzp_neg k co ft n) = (dcont (rzp_neg k) co ft n)).
Axiom c_rzp_neg_spec :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> ((size (c_rzp_neg k co ft n)) = n).
Axiom c_rzp_neg_spec1 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> diag (c_rzp_neg k co ft n).
Axiom c_rzp_neg_spec2 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang ((-((getbv x) co))%Z * ((getbv x) ft))%Z k)).
Axiom c_rzp_neg_spec3 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang
(((-((getbv x) co))%Z * ((getbv x) ft))%Z * (power 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_neg_spec4 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
~ (ft <= co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang
(((-((getbv x) co))%Z * ((getbv x) ft))%Z * (power_ 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_neg_spec5 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> ((size (c_rzp_neg k co ft n)) = n).
Axiom c_rzp_neg_spec6 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> diag (c_rzp_neg k co ft n).
Axiom c_rzp_neg_spec7 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang ((-((getbv x) co))%Z * ((getbv x) ft))%Z k)).
Axiom c_rzp_neg_spec8 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang
(((-((getbv x) co))%Z * ((getbv x) ft))%Z * (power 2%Z (m - k)%Z))%Z m)).
Axiom c_rzp_neg_spec9 :
forall (k:Z) (co:Z) (ft:Z) (n:Z), (k >= 0%Z)%Z -> (n >= 0%Z)%Z ->
((0%Z <= co)%Z /\ (co < n)%Z) -> ((0%Z <= ft)%Z /\ (ft < n)%Z) ->
(ft < co)%Z -> forall (x:bitvec), forall (m:Z), (m >= k)%Z ->
((length x) = n) ->
(((diag_ang (c_rzp_neg k co ft n)) x) =
(int_to_ang
(((-((getbv x) co))%Z * ((getbv x) ft))%Z * (power_ 2%Z (m - k)%Z))%Z m)).
Parameter xx: unit -> gate.
Axiom xx_def :
forall (us:unit),
((xx us) = (sequence hadamard (sequence (rzp 1%Z) hadamard))).
Axiom xx_spec : forall (us:unit), flat (xx us).
Axiom xx_spec1 : forall (us:unit), ((size (xx us)) = 1%Z).
Axiom xx_spec2 :
forall (us:unit), forall (x:bitvec), ((length x) = 1%Z) ->
(((flat_ang (xx us)) x) = ang_zero).
Axiom xx_spec3 :
forall (us:unit), forall (x:bitvec), ((length x) = 1%Z) ->
(((getbv ((flat_ket (xx us)) x)) 0%Z) = (1%Z - ((getbv x) 0%Z))%Z).
Parameter x_kron: Z -> gate.
Axiom x_kron_def :
forall (n:Z), (0%Z < n)%Z -> (n = 1%Z) -> ((x_kron n) = (xx tt)).
Axiom x_kron_def1 :
forall (n:Z), (0%Z < n)%Z -> ~ (n = 1%Z) ->
((x_kron n) = (f_parallel (x_kron (n - 1%Z)%Z) (xx tt))).
Axiom x_kron_spec : forall (n:Z), (0%Z < n)%Z -> flat (x_kron n).
Axiom x_kron_spec1 : forall (n:Z), (0%Z < n)%Z -> ((size (x_kron n)) = n).
Axiom x_kron_spec2 :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), ((length x) = n) ->
(((flat_ang (x_kron n)) x) = ang_zero).
Axiom x_kron_spec3 :
forall (n:Z), (0%Z < n)%Z -> forall (x:bitvec), forall (i:Z),
((length x) = n) -> ((0%Z <= i)%Z /\ (i < n)%Z) ->
(((getbv ((flat_ket (x_kron n)) x)) i) = (1%Z - ((getbv x) i))%Z).
Parameter correct_flat:
gate -> (bitvec -> angle) -> (bitvec -> bitvec) -> Prop.
Axiom correct_flat_def :
forall (c:gate) (a:bitvec -> angle) (b:bitvec -> bitvec),
(correct_flat c a b) ->
correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z.
Axiom correct_flat_def1 :
forall (c:gate) (a:bitvec -> angle) (b:bitvec -> bitvec),
(correct_path_sum c (fun (x:bitvec) (us:bitvec) => (a x))
(fun (x:bitvec) (us:bitvec) => (b x)) 0%Z) ->
correct_flat c a b.
Axiom correct_flat_spec : forall (c:gate), flat c.
Axiom set_correct_flat :
forall (c:gate), (flat c) -> correct_flat c (flat_ang c) (flat_ket c).
Axiom set_correct_diag :
forall (c:gate), (diag c) ->
correct_flat c (diag_ang c) (fun (y:bitvec) => y).
Axiom get_diag_from_correct_flat :
forall (c:gate), (correct_flat c (diag_ang c) (fun (y:bitvec) => y)) ->
diag c.
Axiom get_diag_from_correct_flat1 :
forall (c:gate) (a:bitvec -> angle),
(correct_flat c (diag_ang c) (fun (y:bitvec) => y)) -> forall (x:bitvec),
((length x) = (size c)) -> (((diag_ang c) x) = (a x)).
Parameter flat_sequ:
gate -> gate -> (bitvec -> angle) -> (bitvec -> angle) ->
(bitvec -> angle) -> (bitvec -> bitvec) -> (bitvec -> bitvec) ->
(bitvec -> bitvec) -> Z -> gate.
Axiom flat_sequ_def :
forall (c:gate) (c':gate) (ase:bitvec -> angle) (a:bitvec -> angle)
(a':bitvec -> angle) (bse:bitvec -> bitvec) (b:bitvec -> bitvec)
(b':bitvec -> bitvec) (s:Z),
(flat c) -> (flat c') -> (((size c) = (size c')) /\ ((size c') = s)) ->
(correct_flat c a b) -> (correct_flat c' a' b') ->
(forall (x:bitvec), ((length x) = s) ->
((ase x) = (ang_add (a x) (a' (b x))))) ->
(forall (x:bitvec), ((length x) = s) -> ((bse x) = (b' (b x)))) ->
((flat_sequ c c' ase a a' bse b b' s) = (sequence c c')).
Axiom flat_sequ_spec :
forall (c:gate) (c':gate) (ase:bitvec -> angle) (a:bitvec -> angle)
(a':bitvec -> angle) (bse:bitvec -> bitvec) (b:bitvec -> bitvec)
(b':bitvec -> bitvec) (s:Z),
(flat c) -> (flat c') -> (((size c) = (size c')) /\ ((size c') = s)) ->
(correct_flat c a b) -> (correct_flat c' a' b') ->
(forall (x:bitvec), ((length x) = s) ->
((ase x) = (ang_add (a x) (a' (b x))))) ->
(forall (x:bitvec), ((length x) = s) -> ((bse x) = (b' (b x)))) ->
correct_flat (flat_sequ c c' ase a a' bse b b' s) ase bse.
Axiom flat_sequ_spec1 :
forall (c:gate) (c':gate) (ase:bitvec -> angle) (a:bitvec -> angle)
(a':bitvec -> angle) (bse:bitvec -> bitvec) (b:bitvec -> bitvec)
(b':bitvec -> bitvec) (s:Z),
(flat c) -> (flat c') -> (((size c) = (size c')) /\ ((size c') = s)) ->
(correct_flat c a b) -> (correct_flat c' a' b') ->
(forall (x:bitvec), ((length x) = s) ->
((ase x) = (ang_add (a x) (a' (b x))))) ->
(forall (x:bitvec), ((length x) = s) -> ((bse x) = (b' (b x)))) ->
((size (flat_sequ c c' ase a a' bse b b' s)) = s).
Axiom flat_sequ_spec2 :
forall (c:gate) (c':gate) (ase:bitvec -> angle) (a:bitvec -> angle)
(a':bitvec -> angle) (bse:bitvec -> bitvec) (b:bitvec -> bitvec)
(b':bitvec -> bitvec) (s:Z),
(flat c) -> (flat c') -> (((size c) = (size c')) /\ ((size c') = s)) ->
(correct_flat c a b) -> (correct_flat c' a' b') ->
(forall (x:bitvec), ((length x) = s) ->
((ase x) = (ang_add (a x) (a' (b x))))) ->
(forall (x:bitvec), ((length x) = s) -> ((bse x) = (b' (b x)))) ->
correct_path_sum (flat_sequ c c' ase a a' bse b b' s)
(fun (x:bitvec) (us:bitvec) => (ase x))
(fun (x:bitvec) (us:bitvec) => (bse x)) 0%Z.
Parameter choose_filter:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> bool) -> a.
Axiom choose_filter_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool),
(exists e1:a, (mem e1 s) /\ ((p e1) = true)) -> ((p (choose s)) = true) ->
((choose_filter s p) = (choose s)).
Axiom choose_filter_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool),
(exists e1:a, (mem e1 s) /\ ((p e1) = true)) ->
~ ((p (choose s)) = true) ->
((choose_filter s p) = (choose_filter (remove (choose s) s) p)).
Axiom choose_filter_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool),
(exists e1:a, (mem e1 s) /\ ((p e1) = true)) ->
((p (choose_filter s p)) = true).
Axiom choose_filter_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool),
(exists e1:a, (mem e1 s) /\ ((p e1) = true)) -> mem (choose_filter s p) s.
Parameter my_filter:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> bool) -> set a.
Axiom my_filter_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), (is_empty s) ->
((my_filter s p) = (empty : set a)).
Axiom my_filter_def1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), ~ (is_empty s) ->
((p (choose s)) = true) ->
((my_filter s p) = (add (choose s) (my_filter (remove (choose s) s) p))).
Axiom my_filter_def2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), ~ (is_empty s) ->
~ ((p (choose s)) = true) ->
((my_filter s p) = (my_filter (remove (choose s) s) p)).
Axiom my_filter_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), forall (e1:a), (mem e1 s) ->
((p e1) = true) -> mem e1 (my_filter s p).
Axiom my_filter_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), forall (e1:a), (mem e1 s) ->
(mem e1 (my_filter s p)) -> ((p e1) = true).
Axiom my_filter_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), forall (e1:a), (mem e1 (my_filter s p)) ->
mem e1 s.
Axiom my_filter_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool), (0%Z <= (cardinal (my_filter s p)))%Z.
Axiom my_filter_spec4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool),
((cardinal (my_filter s p)) <= (cardinal s))%Z.
Axiom in_my_filter :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p:a -> bool) (e1:a), (mem e1 s) -> ((p e1) = true) ->
mem e1 (my_filter s p).
Axiom my_filter_inter :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p1:a -> bool) (p2:a -> bool),
(forall (e1:a), (mem e1 s) -> ((p1 e1) = true) -> ~ ((p2 e1) = true)) ->
((inter (my_filter s p1) (my_filter s p2)) = (empty : set a)).
Axiom my_filter_union :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (p1:a -> bool) (p2:a -> bool),
(forall (e1:a), (mem e1 s) -> ~ ((p1 e1) = true) -> ((p2 e1) = true)) ->
((union (my_filter s p1) (my_filter s p2)) = s).
Parameter cascade_cont_rz: Z -> Z -> Z -> Z -> gate.
Parameter result21: Z -> Z -> Z -> gate.
Axiom result_def21 :
forall (t1:Z) (n:Z) (k:Z),
((((t1 + 1%Z)%Z <= k)%Z /\ (k < n)%Z) ->
(((result21 t1 n) k) = (c_rzp_neg ((k - t1)%Z + 1%Z)%Z k t1 n))) /\
(~ (((t1 + 1%Z)%Z <= k)%Z /\ (k < n)%Z) ->
(((result21 t1 n) k) = (rzp 1%Z))).
Axiom cascade_cont_rz_def :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z ->
((cascade_cont_rz first_c t1 l n) =
(d_seq_iter (result21 t1 n) n (t1 + 1%Z)%Z n)).
Parameter result22: Z -> Z -> Z -> gate.
Axiom result_def22 :
forall (t1:Z) (n:Z) (k:Z),
((((t1 + 1%Z)%Z <= k)%Z /\ (k < n)%Z) ->
(((result22 t1 n) k) = (c_rzp_neg ((k - t1)%Z + 1%Z)%Z k t1 n))) /\
(~ (((t1 + 1%Z)%Z <= k)%Z /\ (k < n)%Z) ->
(((result22 t1 n) k) = (rzp 1%Z))).
Axiom cascade_cont_rz_def1 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z ->
((cascade_cont_rz first_c t1 l n) =
(d_seq_iter (result22 t1 n) n (t1 + 1%Z)%Z n)).
Axiom cascade_cont_rz_spec :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z ->
((size (cascade_cont_rz first_c t1 l n)) = n).
Axiom cascade_cont_rz_spec1 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z ->
diag (cascade_cont_rz first_c t1 l n).
Axiom cascade_cont_rz_spec2 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z ->
((cascade_cont_rz first_c t1 l n) =
(d_seq_iter (fun (k:Z) => (c_rzp_neg ((k - t1)%Z + 1%Z)%Z k t1 n)) n
(t1 + 1%Z)%Z n)).
Axiom cascade_cont_rz_spec3 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z -> forall (x:bitvec),
((length x) = n) ->
(((diag_ang (cascade_cont_rz first_c t1 l n)) x) =
(ang_sum
(fun (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv x) t1))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(t1 + 1%Z)%Z n)).
Axiom cascade_cont_rz_spec4 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z ->
~ (t1 <= ((first_c + l)%Z - 1%Z)%Z)%Z ->
correct_path_sum_i (cascade_cont_rz first_c t1 l n)
(fun (x:bitvec) (us:bitvec) (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv x) t1))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(t1 + 1%Z)%Z n (fun (x:bitvec) (us:bitvec) (i:Z) => ((getbv x) i)) 0%Z.
Axiom cascade_cont_rz_spec5 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z ->
((size (cascade_cont_rz first_c t1 l n)) = n).
Axiom cascade_cont_rz_spec6 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z ->
diag (cascade_cont_rz first_c t1 l n).
Axiom cascade_cont_rz_spec7 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z ->
((cascade_cont_rz first_c t1 l n) =
(d_seq_iter (fun (k:Z) => (c_rzp_neg ((k - t1)%Z + 1%Z)%Z k t1 n)) n
(t1 + 1%Z)%Z n)).
Axiom cascade_cont_rz_spec8 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z -> forall (x:bitvec),
((length x) = n) ->
(((diag_ang (cascade_cont_rz first_c t1 l n)) x) =
(ang_sum
(fun (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv x) t1))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(t1 + 1%Z)%Z n)).
Axiom cascade_cont_rz_spec9 :
forall (first_c:Z) (t1:Z) (l:Z) (n:Z), (0%Z < l)%Z ->
((0%Z <= first_c)%Z /\ (first_c < n)%Z) ->
((0%Z <= t1)%Z /\ (t1 < (n - 1%Z)%Z)%Z) ->
(((first_c + l)%Z - 1%Z)%Z < n)%Z -> (t1 < first_c)%Z ->
correct_path_sum_i (cascade_cont_rz first_c t1 l n)
(fun (x:bitvec) (us:bitvec) (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv x) t1))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(t1 + 1%Z)%Z n (fun (x:bitvec) (us:bitvec) (i:Z) => ((getbv x) i)) 0%Z.
Parameter qft_rev_line: Z -> Z -> gate.
Axiom qft_rev_line_def :
forall (t1:Z) (n:Z), ((0%Z <= t1)%Z /\ (t1 < n)%Z) -> (t1 = (n - 1%Z)%Z) ->
((qft_rev_line t1 n) = (place_hadamard t1 n)).
Parameter result23: Z -> bitvec -> bitvec -> Z -> Z.
Parameter result24: Z -> bitvec -> bitvec -> Z -> Z.
Axiom result_def23 :
forall (t1:Z) (x:bitvec) (y:bitvec) (i:Z),
((i = t1) -> (((((result23 t1) x) y) i) = ((getbv y) 0%Z))) /\
(~ (i = t1) -> (((((result23 t1) x) y) i) = ((getbv x) i))).
Axiom result_def24 :
forall (t1:Z) (x:bitvec) (y:bitvec) (i:Z),
((i = t1) -> (((result24 t1 x y) i) = ((getbv y) 0%Z))) /\
(~ (i = t1) -> (((result24 t1 x y) i) = ((getbv x) i))).
Axiom qft_rev_line_def1 :
forall (t1:Z) (n:Z), ((0%Z <= t1)%Z /\ (t1 < n)%Z) ->
~ (t1 = (n - 1%Z)%Z) ->
((qft_rev_line t1 n) =
(sequence_spec_i_r (place_hadamard t1 n)
(cascade_cont_rz (t1 + 1%Z)%Z t1 (n - (t1 + 1%Z)%Z)%Z n)
(fun (x:bitvec) (y:bitvec) (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv y) 0%Z))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(fun (x:bitvec) (us:bitvec) (k:Z) =>
(int_to_ang
(((-((getbv x) k))%Z * ((getbv x) t1))%Z *
(power_ 2%Z (((n - k)%Z - 1%Z)%Z + t1)%Z))%Z
n))
(fun (x:bitvec) (y:bitvec) =>
(int_to_ang
(((-((getbv x) t1))%Z * ((getbv y) 0%Z))%Z *
(power_ 2%Z (n - 1%Z)%Z))%Z
n))
t1 n (result23 t1) (fun (x:bitvec) (us:bitvec) (i:Z) => ((getbv x) i))
(fun (x:bitvec) (y:bitvec) => (make_bv (result24 t1 x y) n)) 1%Z 1%Z 0%Z)).
Axiom qft_rev_line_spec :
forall (t1:Z) (n:Z), ((0%Z <= t1)%Z /\ (t1 < n)%Z) ->
((size (qft_rev_line t1 n)) = n).
Parameter fc15: Z -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def15 :
forall (t1:Z) (x:bitvec) (y:bitvec) (i:Z),
((i = t1) -> (((((fc15 t1) x) y) i) = ((getbv y) 0%Z))) /\
(~ (i = t1) -> (((((fc15 t1) x) y) i) = ((getbv x) i))).
Axiom qft_rev_line_spec1 :
forall (t1:Z) (n:Z), ((0%Z <= t1)%Z /\ (t1 < n)%Z) ->
correct_path_sum_i (qft_rev_line t1 n)
(fun (x:bitvec) (y:bitvec) (i:Z) =>
(int_to_ang
(((-((getbv x) i))%Z * ((getbv y) 0%Z))%Z *
(power_ 2%Z (((n - i)%Z - 1%Z)%Z + t1)%Z))%Z
n))
t1 n (fc15 t1) 1%Z.
Parameter fc16: Z -> bitvec -> bitvec -> Z -> Z.
Axiom fc_def16 :
forall (t1:Z) (x:bitvec) (y:bitvec) (i:Z),
((i = t1) -> (((fc16 t1 x y) i) = ((getbv y) 0%Z))) /\
(~ (i = t1) -> (((fc16 t1 x y) i) = ((getbv x) i))).
Axiom rewrite_rev_qft_line :
forall (t1:Z) (n:Z), ((0%Z <= t1)%Z /\ (t1 < n)%Z) ->
correct_path_sum (qft_rev_line t1 n)
(fun (x:bitvec) (y:bitvec) =>
(ang_sum
(fun (i:Z) =>
(int_to_ang
(((-((getbv x) i))%Z * ((getbv y) 0%Z))%Z *
(power_ 2%Z (((n - i)%Z - 1%Z)%Z + t1)%Z))%Z
n))
t1 n))
(fun (x:bitvec) (y:bitvec) => (make_bv (fc16 t1 x y) n)) 1%Z.
Parameter qft_rev: Z -> gate.
Axiom qft_rev_spec : forall (n:Z), (0%Z < n)%Z -> ((size (qft_rev n)) = n).
Axiom qft_rev_spec1 :
forall (n:Z), (0%Z < n)%Z ->
correct_path_sum_i (qft_rev n)
(fun (x:bitvec) (y:bitvec) (j:Z) =>
(ang_sum
(fun (i:Z) =>
(int_to_ang
(((-((getbv x) i))%Z * ((getbv y) j))%Z *
(power_ 2%Z (((n - i)%Z - 1%Z)%Z + j)%Z))%Z
n))
j n))
0%Z n (fun (us:bitvec) (y:bitvec) (i:Z) => ((getbv y) i)) n.
Parameter eigen: gate -> (matrix t) -> angle -> Prop.
Axiom eigen_def :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
sem c x (infix_asdtdt (ang_exp o) x).
Axiom eigen_def1 :
forall (c:gate) (x:matrix t) (o:angle),
(sem c x (infix_asdtdt (ang_exp o) x)) -> eigen c x o.
Axiom eigen_depth :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
((size c) = (ket_length x)).
Axiom eigen_scal :
forall (c:gate) (a:angle) (x:matrix t) (o:angle), (eigen c x o) ->
eigen c (infix_asdtdt (ang_exp a) x) o.
Parameter eigen_comp: gate -> gate -> (matrix t) -> angle -> angle -> gate.
Axiom eigen_comp_def :
forall (c:gate) (c':gate) (x:matrix t) (o:angle) (o':angle),
((size c) = (size c')) -> (eigen c x o) -> (eigen c' x o') ->
((eigen_comp c c' x o o') = (sequence c c')).
Axiom eigen_comp_spec :
forall (c:gate) (c':gate) (x:matrix t) (o:angle) (o':angle),
((size c) = (size c')) -> (eigen c x o) -> (eigen c' x o') ->
((size (eigen_comp c c' x o o')) = (size c)).
Axiom eigen_comp_spec1 :
forall (c:gate) (c':gate) (x:matrix t) (o:angle) (o':angle),
((size c) = (size c')) -> (eigen c x o) -> (eigen c' x o') ->
eigen (eigen_comp c c' x o o') x (ang_add o o').
Parameter eigen_square: gate -> (matrix t) -> angle -> gate.
Axiom eigen_square_def :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
((eigen_square c x o) = (eigen_comp c c x o o)).
Axiom eigen_square_spec :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
((size (eigen_square c x o)) = (size c)).
Axiom eigen_square_spec1 :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
eigen (eigen_square c x o) x (ang_add o o).
Axiom eigen_square_spec2 :
forall (c:gate) (x:matrix t) (o:angle), (eigen c x o) ->
((eigen_square c x o) = (sequence c c)).
Parameter pow_pow_2: gate -> Z -> (matrix t) -> angle -> gate.
Axiom pow_pow_2_def :
forall (c:gate) (p:Z) (x:matrix t) (o:angle), (0%Z <= p)%Z ->
(eigen c x o) -> (p = 0%Z) -> ((pow_pow_2 c p x o) = c).
Axiom pow_pow_2_def1 :
forall (c:gate) (p:Z) (x:matrix t) (o:angle), (0%Z <= p)%Z ->
(eigen c x o) -> ~ (p = 0%Z) ->
((pow_pow_2 c p x o) =
(eigen_square (pow_pow_2 c (p - 1%Z)%Z x o) x
(ang_mult_int o (power 2%Z (p - 1%Z)%Z)))).
Axiom pow_pow_2_spec :
forall (c:gate) (p:Z) (x:matrix t) (o:angle), (0%Z <= p)%Z ->
(eigen c x o) -> ((size (pow_pow_2 c p x o)) = (size c)).
Axiom pow_pow_2_spec1 :
forall (c:gate) (p:Z) (x:matrix t) (o:angle), (0%Z <= p)%Z ->
(eigen c x o) -> eigen (pow_pow_2 c p x o) x (ang_mult_int o (power 2%Z p)).
Parameter control_eigen: gate -> (matrix t) -> angle -> Z -> Z -> Z -> gate.
Axiom control_eigen_def :
forall (circ:gate) (y:matrix t) (o:angle) (c:Z) (ft:Z) (n:Z),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(eigen circ y o) -> ((control_eigen circ y o c ft n) = (cont circ c ft n)).
Axiom control_eigen_spec :
forall (circ:gate) (y:matrix t) (o:angle) (c:Z) (ft:Z) (n:Z),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(eigen circ y o) -> ((size (control_eigen circ y o c ft n)) = n).
Axiom control_eigen_spec1 :
forall (circ:gate) (y:matrix t) (o:angle) (c:Z) (ft:Z) (n:Z),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(eigen circ y o) -> forall (x:matrix t), (is_a_ket_l x ft) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) c) = 0%Z) ->
sem (control_eigen circ y o c ft n) (kronecker x y) (kronecker x y).
Axiom control_eigen_spec2 :
forall (circ:gate) (y:matrix t) (o:angle) (c:Z) (ft:Z) (n:Z),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(eigen circ y o) -> forall (x:matrix t), (is_a_ket_l x ft) ->
(is_a_ket_basis_elt x) -> (((getbv (ket_to_bv x)) c) = 1%Z) ->
sem (control_eigen circ y o c ft n) (kronecker x y)
(kronecker x (infix_asdtdt (ang_exp o) y)).
Axiom control_eigen_spec3 :
forall (circ:gate) (y:matrix t) (o:angle) (c:Z) (ft:Z) (n:Z),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(eigen circ y o) -> forall (x:bitvec), ((length x) = ft) ->
sem (control_eigen circ y o c ft n) (kronecker (bv_to_ket x) y)
(kronecker (bv_to_ket x)
(infix_asdtdt (ang_exp (ang_mult_int o ((getbv x) c))) y)).
Parameter control_eigen_scal:
gate -> (matrix t) -> Z -> Z -> Z -> angle -> angle -> gate.
Axiom control_eigen_scal_def :
forall (circ:gate) (y:matrix t) (c:Z) (ft:Z) (n:Z) (o:angle) (o':angle),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(n >= 0%Z)%Z -> (eigen circ y o') ->
((control_eigen_scal circ y c ft n o o') =
(control_eigen circ (infix_asdtdt (ang_exp o) y) o' c ft n)).
Axiom control_eigen_scal_spec :
forall (circ:gate) (y:matrix t) (c:Z) (ft:Z) (n:Z) (o:angle) (o':angle),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(n >= 0%Z)%Z -> (eigen circ y o') ->
((size (control_eigen_scal circ y c ft n o o')) = (ft + (size circ))%Z).
Axiom control_eigen_scal_spec1 :
forall (circ:gate) (y:matrix t) (c:Z) (ft:Z) (n:Z) (o:angle) (o':angle),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(n >= 0%Z)%Z -> (eigen circ y o') ->
((control_eigen_scal circ y c ft n o o') = (cont circ c ft n)).
Axiom control_eigen_scal_spec2 :
forall (circ:gate) (y:matrix t) (c:Z) (ft:Z) (n:Z) (o:angle) (o':angle),
((0%Z <= c)%Z /\ (c < ft)%Z) -> (n = (ft + (size circ))%Z) ->
(n >= 0%Z)%Z -> (eigen circ y o') -> forall (x:bitvec),
((length x) = ft) ->
sem (control_eigen_scal circ y c ft n o o')
(kronecker (infix_asdtdt (ang_exp o) (bv_to_ket x)) y)
(kronecker
(infix_asdtdt (ang_exp (ang_add o (ang_mult_int o' ((getbv x) c))))
(bv_to_ket x))
y).
Parameter control_eigen_seq_test:
(Z -> gate) -> (Z -> Z) -> Z -> Z -> Z -> Z -> gate.
Axiom control_eigen_seq_test_def :
forall (fcirc:Z -> gate) (fc17:Z -> Z) (ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z -> (forall (i:Z), ((size (fcirc i)) = s)) -> (bound = 1%Z) ->
((control_eigen_seq_test fcirc fc17 ft bound s n) =
(cont (fcirc 0%Z) (fc17 0%Z) ft (ft + s)%Z)).
Axiom control_eigen_seq_test_def1 :
forall (fcirc:Z -> gate) (fc17:Z -> Z) (ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z -> (forall (i:Z), ((size (fcirc i)) = s)) ->
~ (bound = 1%Z) ->
((control_eigen_seq_test fcirc fc17 ft bound s n) =
(sequence (control_eigen_seq_test fcirc fc17 ft (bound - 1%Z)%Z s n)
(cont (fcirc (bound - 1%Z)%Z) (fc17 (bound - 1%Z)%Z) ft n))).
Axiom control_eigen_seq_test_spec :
forall (fcirc:Z -> gate) (fc17:Z -> Z) (ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z -> (forall (i:Z), ((size (fcirc i)) = s)) ->
((size (control_eigen_seq_test fcirc fc17 ft bound s n)) = (ft + s)%Z).
Parameter control_eigen_seq_pre:
(Z -> gate) -> (matrix t) -> (Z -> angle) -> (Z -> Z) -> Z -> Z ->
Z -> Z -> bitvec -> gate.
Axiom control_eigen_seq_pre_def :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z) (x:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((length x) = ft) -> (bound = 1%Z) ->
((control_eigen_seq_pre fcirc y fk fc17 ft bound s n x) =
(control_eigen (fcirc 0%Z) y (fk 0%Z) (fc17 0%Z) ft (ft + s)%Z)).
Axiom control_eigen_seq_pre_def1 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z) (x:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((length x) = ft) -> ~ (bound = 1%Z) ->
((control_eigen_seq_pre fcirc y fk fc17 ft bound s n x) =
(sequence (control_eigen_seq_pre fcirc y fk fc17 ft (bound - 1%Z)%Z s n x)
(control_eigen_scal (fcirc (bound - 1%Z)%Z) y (fc17 (bound - 1%Z)%Z) ft n
(ang_sum (fun (i:Z) => (ang_mult_int (fk i) ((getbv x) (fc17 i)))) 0%Z
(bound - 1%Z)%Z)
(fk (bound - 1%Z)%Z)))).
Axiom control_eigen_seq_pre_spec :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z) (x:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((length x) = ft) ->
((size (control_eigen_seq_pre fcirc y fk fc17 ft bound s n x)) =
(ft + s)%Z).
Axiom control_eigen_seq_pre_spec1 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z) (x:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((length x) = ft) ->
sem (control_eigen_seq_pre fcirc y fk fc17 ft bound s n x)
(kronecker (bv_to_ket x) y)
(kronecker
(infix_asdtdt
(ang_exp
(ang_sum (fun (i:Z) => (ang_mult_int (fk i) ((getbv x) (fc17 i)))) 0%Z
bound))
(bv_to_ket x))
y).
Axiom control_eigen_seq_pre_spec2 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z) (x:bitvec),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((length x) = ft) ->
((control_eigen_seq_pre fcirc y fk fc17 ft bound s n x) =
(control_eigen_seq_test fcirc fc17 ft bound s n)).
Parameter control_eigen_seq:
(Z -> gate) -> (matrix t) -> (Z -> angle) -> (Z -> Z) -> Z -> Z ->
Z -> Z -> gate.
Axiom control_eigen_seq_def :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((control_eigen_seq fcirc y fk fc17 ft bound s n) =
(control_eigen_seq_test fcirc fc17 ft bound s n)).
Axiom control_eigen_seq_spec :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
forall (x:bitvec), ((length x) = ft) ->
((control_eigen_seq fcirc y fk fc17 ft bound s n) =
(control_eigen_seq_pre fcirc y fk fc17 ft bound s n x)).
Axiom control_eigen_seq_spec1 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((size (control_eigen_seq fcirc y fk fc17 ft bound s n)) = (ft + s)%Z).
Axiom control_eigen_seq_spec2 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> angle) (fc17:Z -> Z)
(ft:Z) (bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> eigen (fcirc i) y (fk i)) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
forall (x:bitvec), ((length x) = ft) ->
sem (control_eigen_seq fcirc y fk fc17 ft bound s n)
(kronecker (bv_to_ket x) y)
(kronecker
(infix_asdtdt
(ang_exp
(ang_sum (fun (i:Z) => (ang_mult_int (fk i) ((getbv x) (fc17 i)))) 0%Z
bound))
(bv_to_ket x))
y).
Parameter control_eigen_seq_real:
(Z -> gate) -> (matrix t) -> (Z -> t) -> (Z -> Z) -> Z -> Z -> Z ->
Z -> gate.
Parameter result25: (Z -> t) -> Z -> angle.
Axiom result_def25 :
forall (fk:Z -> t) (k:Z),
((real_ (fk k)) -> (((result25 fk) k) = (real_to_ang (fk k)))) /\
(~ (real_ (fk k)) -> (((result25 fk) k) = ang_zero)).
Axiom control_eigen_seq_real_def :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> t) (fc17:Z -> Z) (ft:Z)
(bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> real_ (fk i)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
eigen (fcirc i) y (real_to_ang (fk i))) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((control_eigen_seq_real fcirc y fk fc17 ft bound s n) =
(control_eigen_seq fcirc y (result25 fk) fc17 ft bound s n)).
Axiom control_eigen_seq_real_spec :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> t) (fc17:Z -> Z) (ft:Z)
(bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> real_ (fk i)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
eigen (fcirc i) y (real_to_ang (fk i))) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
((size (control_eigen_seq_real fcirc y fk fc17 ft bound s n)) = (ft + s)%Z).
Axiom control_eigen_seq_real_spec1 :
forall (fcirc:Z -> gate) (y:matrix t) (fk:Z -> t) (fc17:Z -> Z) (ft:Z)
(bound:Z) (s:Z) (n:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
(0%Z <= (fc17 i))%Z /\ ((fc17 i) < ft)%Z) ->
((0%Z < bound)%Z /\ (bound <= ft)%Z) -> (s >= 0%Z)%Z -> (n = (ft + s)%Z) ->
(0%Z <= n)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) -> real_ (fk i)) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < bound)%Z) ->
eigen (fcirc i) y (real_to_ang (fk i))) ->
(forall (i:Z), ((size (fcirc i)) = s)) -> (is_a_ket_l y s) ->
forall (x:bitvec), ((length x) = ft) ->
sem (control_eigen_seq_real fcirc y fk fc17 ft bound s n)
(kronecker (bv_to_ket x) y)
(kronecker
(infix_asdtdt
(ang_exp
(ang_sum
(fun (i:Z) =>
(real_to_ang (infix_asdt (fk i) (i_to_t ((getbv x) (fc17 i))))))
0%Z bound))
(bv_to_ket x))
y).
Parameter cascade_cont_pow: gate -> Z -> (matrix t) -> t -> gate.
Parameter result26: gate -> Z -> (matrix t) -> t -> Z -> gate.
Axiom result_def26 :
forall (circ:gate) (ft:Z) (y:matrix t) (theta:t) (i:Z),
((((ft - i)%Z - 1%Z)%Z >= 0%Z)%Z ->
(((result26 circ ft y theta) i) =
(pow_pow_2 circ ((ft - i)%Z - 1%Z)%Z y (real_to_ang theta)))) /\
(~ (((ft - i)%Z - 1%Z)%Z >= 0%Z)%Z ->
(((result26 circ ft y theta) i) =
(pow_pow_2 circ 0%Z y (real_to_ang theta)))).
Axiom cascade_cont_pow_def :
forall (circ:gate) (ft:Z) (y:matrix t) (theta:t), (1%Z <= ft)%Z ->
(real_ theta) -> (eigen circ y (real_to_ang theta)) ->
((cascade_cont_pow circ ft y theta) =
(control_eigen_seq_real (result26 circ ft y theta) y
(fun (i:Z) =>
(infix_asdt theta (i_to_t (power_ 2%Z ((ft - i)%Z - 1%Z)%Z))))
(fun (i:Z) => i) ft ft (size circ) (ft + (size circ))%Z)).
Axiom cascade_cont_pow_spec :
forall (circ:gate) (ft:Z) (y:matrix t) (theta:t), (1%Z <= ft)%Z ->
(real_ theta) -> (eigen circ y (real_to_ang theta)) ->
((size (cascade_cont_pow circ ft y theta)) = (ft + (size circ))%Z).
Axiom cascade_cont_pow_spec1 :
forall (circ:gate) (ft:Z) (y:matrix t) (theta:t), (1%Z <= ft)%Z ->
(real_ theta) -> (eigen circ y (real_to_ang theta)) -> forall (x:bitvec),
((length x) = ft) ->
sem (cascade_cont_pow circ ft y theta) (kronecker (bv_to_ket x) y)
(kronecker
(infix_asdtdt
(ang_exp (real_to_ang (infix_asdt theta (i_to_t (bv_to_int x)))))
(bv_to_ket x))
y).
Axiom sum_ket_zero :
forall (n:Z), (n >= 0%Z)%Z -> forall (y:bitvec),
((ang_sum
(fun (i:Z) =>
(int_to_ang (((getbv (ket_to_bv (ket n 0%Z))) i) * ((getbv y) i))%Z 1%Z))
0%Z n)
= ang_zero).
Parameter repeat_had: Z -> gate.
Axiom repeat_had_def :
forall (n:Z), (n >= 1%Z)%Z -> (n = 1%Z) -> ((repeat_had n) = hadamard).
Axiom repeat_had_def1 :
forall (n:Z), (n >= 1%Z)%Z -> ~ (n = 1%Z) ->
((repeat_had n) = (parallel (repeat_had (n - 1%Z)%Z) hadamard)).
Axiom repeat_had_spec :
forall (n:Z), (n >= 1%Z)%Z -> ((size (repeat_had n)) = n).
Axiom repeat_had_spec1 :
forall (n:Z), (n >= 1%Z)%Z -> ((range (repeat_had n)) = n).
Axiom repeat_had_spec2 :
forall (n:Z), (n >= 1%Z)%Z -> forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = n) -> ((length y) = n) -> ((0%Z <= i)%Z /\ (i < n)%Z) ->
((basis_ket_i (repeat_had n) x y i) = ((getbv y) i)).
Axiom repeat_had_spec3 :
forall (n:Z), (n >= 1%Z)%Z -> ((ang_ind_bound (repeat_had n)) = n).
Axiom repeat_had_spec4 :
forall (n:Z), (n >= 1%Z)%Z -> forall (x:bitvec) (y:bitvec), forall (i:Z),
((length x) = n) -> ((length y) = n) -> ((0%Z <= i)%Z /\ (i < n)%Z) ->
((ang_ind_i (repeat_had n) x y i) =
(int_to_ang (((getbv x) i) * ((getbv y) i))%Z 1%Z)).
Axiom repeat_had_spec5 :
forall (n:Z), (n >= 1%Z)%Z ->
sem (repeat_had n) (ket n 0%Z)
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n) (fun (y0:bitvec) => (bv_to_ket y0)) n)).
Axiom repeat_had_spec6 :
forall (n:Z), (n >= 1%Z)%Z -> ((ang_ind_bound (repeat_had n)) = n).
Parameter cc_rz: Z -> gate.
Axiom cc_rz_def :
forall (n:Z), (n >= 2%Z)%Z -> (n = 2%Z) ->
((cc_rz n) = (c_rzp 1%Z 0%Z 1%Z n)).
Axiom cc_rz_def1 :
forall (n:Z), (n >= 2%Z)%Z -> ~ (n = 2%Z) ->
((cc_rz n) = (d_cont (cc_rz (n - 1%Z)%Z) 0%Z 1%Z n)).
Axiom cc_rz_spec : forall (n:Z), (n >= 2%Z)%Z -> ((size (cc_rz n)) = n).
Axiom cc_rz_spec1 : forall (n:Z), (n >= 2%Z)%Z -> diag (cc_rz n).
Axiom cc_rz_spec2 :
forall (n:Z), (n >= 2%Z)%Z -> forall (x:bitvec), ((length x) = n) ->
((forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
(((diag_ang (cc_rz n)) x) = ang_minus_one)) /\
(~ (forall (j:Z), ((0%Z <= j)%Z /\ (j < n)%Z) -> (((getbv x) j) = 1%Z)) ->
(((diag_ang (cc_rz n)) x) = ang_zero)).
Axiom cc_rz_spec3 :
forall (n:Z), (n >= 2%Z)%Z -> forall (x:bitvec), ((length x) = n) ->
(((diag_ang (cc_rz n)) x) =
(ang_mult_int ang_minus_one (ind_iproduct (getbv x) 0%Z n))).
Parameter x_cc_rz: Z -> gate.
Axiom x_cc_rz_def :
forall (n:Z), (n >= 2%Z)%Z ->
((x_cc_rz n) =
(flat_sequ (x_kron n) (cc_rz n)
(fun (x:bitvec) =>
(ang_mult_int ang_minus_one
(ind_iproduct (fun (i:Z) => (1%Z - ((getbv x) i))%Z) 0%Z n)))
(flat_ang (x_kron n)) (diag_ang (cc_rz n))
(fun (x:bitvec) => (make_bv (fun (i:Z) => (1%Z - ((getbv x) i))%Z) n))
(flat_ket (x_kron n)) (fun (x:bitvec) => x) n)).
Axiom x_cc_rz_spec : forall (n:Z), (n >= 2%Z)%Z -> ((size (x_cc_rz n)) = n).
Axiom x_cc_rz_spec1 : forall (n:Z), (n >= 2%Z)%Z -> flat (x_cc_rz n).
Axiom x_cc_rz_spec2 :
forall (n:Z), (n >= 2%Z)%Z ->
correct_flat (x_cc_rz n)
(fun (x:bitvec) =>
(ang_mult_int ang_minus_one
(ind_iproduct (fun (i:Z) => (1%Z - ((getbv x) i))%Z) 0%Z n)))
(fun (x:bitvec) => (make_bv (fun (i:Z) => (1%Z - ((getbv x) i))%Z) n)).
Parameter diff_pre: Z -> gate.
Axiom diff_pre_def :
forall (n:Z), (n >= 2%Z)%Z ->
((diff_pre n) =
(flat_sequ (x_cc_rz n) (x_kron n)
(fun (x:bitvec) =>
(ang_mult_int ang_minus_one
(ind_iproduct (fun (j:Z) => (1%Z - ((getbv x) j))%Z) 0%Z n)))
(fun (x:bitvec) =>
(ang_mult_int ang_minus_one
(ind_iproduct (fun (i:Z) => (1%Z - ((getbv x) i))%Z) 0%Z n)))
(flat_ang (x_kron n)) (fun (x:bitvec) => x)
(fun (x:bitvec) => (make_bv (fun (i:Z) => (1%Z - ((getbv x) i))%Z) n))
(flat_ket (x_kron n)) n)).
Axiom diff_pre_spec :
forall (n:Z), (n >= 2%Z)%Z -> ((size (diff_pre n)) = n).
Axiom diff_pre_spec1 : forall (n:Z), (n >= 2%Z)%Z -> diag (diff_pre n).
Axiom diff_pre_spec2 :
forall (n:Z), (n >= 2%Z)%Z ->
correct_flat (diff_pre n)
(fun (x:bitvec) =>
(ang_mult_int ang_minus_one
(ind_iproduct (fun (j:Z) => (1%Z - ((getbv x) j))%Z) 0%Z n)))
(fun (x:bitvec) => x).
Parameter adjoint: (matrix t) -> matrix t.
Axiom adjoint_def :
forall (m:matrix t),
((adjoint m) =
(make_f (columns m) (rows m) (fun (x:Z) (y:Z) => (conjugate (get m y x))))).
Axiom adjoint_spec : forall (m:matrix t), ((rows (adjoint m)) = (columns m)).
Axiom adjoint_spec1 :
forall (m:matrix t), ((columns (adjoint m)) = (rows m)).
Axiom adjoint_spec2 :
forall (m:matrix t), forall (i:Z) (j:Z), (valid_index (adjoint m) i j) ->
valid_index m j i.
Axiom adjoint_spec3 :
forall (m:matrix t), forall (i:Z) (j:Z), (valid_index m j i) ->
valid_index (adjoint m) i j.
Axiom adjoint_spec4 :
forall (m:matrix t), forall (i:Z) (j:Z), (valid_index (adjoint m) i j) ->
((get (adjoint m) i j) = (conjugate (get m j i))).
Axiom adjoint_rows : forall (m:matrix t), ((rows (adjoint m)) = (columns m)).
Axiom adjoint_columns :
forall (m:matrix t), ((columns (adjoint m)) = (rows m)).
Axiom adjoint_value :
forall (m:matrix t) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (columns m))%Z) ->
((0%Z <= j)%Z /\ (j < (rows m))%Z) ->
((get (adjoint m) i j) = (conjugate (get m j i))).
Axiom adjoint_values :
forall (m:matrix t), forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (columns m))%Z) ->
((0%Z <= j)%Z /\ (j < (rows m))%Z) ->
((get (adjoint m) i j) = (conjugate (get m j i))).
Axiom adjoint_invol : forall (m:matrix t), ((adjoint (adjoint m)) = m).
Axiom get_adjoint :
forall (m:matrix t) (n:matrix t), ((rows m) = (columns n)) ->
((columns m) = (rows n)) ->
(forall (i:Z) (j:Z), (valid_index m i j) ->
((get m i j) = (conjugate (get n j i)))) ->
((adjoint m) = n).
Axiom set_adjoint :
forall (m:matrix t) (n:matrix t), ((rows m) = (columns n)) ->
((columns m) = (rows n)) ->
(forall (i:Z) (j:Z), (valid_index m i j) ->
((get m i j) = (conjugate (get n j i)))) ->
(m = (adjoint n)).
Parameter is_a_bra: (matrix t) -> Prop.
Axiom is_a_bra_def : forall (m:matrix t), (is_a_bra m) -> ((rows m) = 1%Z).
Axiom is_a_bra_def1 :
forall (m:matrix t), (is_a_bra m) ->
exists s:Z, (s >= 0%Z)%Z /\ ((columns m) = (power 2%Z s)).
Axiom is_a_bra_def2 :
forall (m:matrix t),
(((rows m) = 1%Z) /\
exists s:Z, (s >= 0%Z)%Z /\ ((columns m) = (power 2%Z s))) ->
is_a_bra m.
Parameter is_a_bra_l: (matrix t) -> Z -> Prop.
Axiom is_a_bra_l_def :
forall (m:matrix t) (l:Z), (is_a_bra_l m l) -> (l >= 0%Z)%Z.
Axiom is_a_bra_l_def1 :
forall (m:matrix t) (l:Z), (is_a_bra_l m l) -> ((rows m) = 1%Z).
Axiom is_a_bra_l_def2 :
forall (m:matrix t) (l:Z), (is_a_bra_l m l) ->
((columns m) = (power 2%Z l)).
Axiom is_a_bra_l_def3 :
forall (m:matrix t) (l:Z),
((l >= 0%Z)%Z /\ (((rows m) = 1%Z) /\ ((columns m) = (power 2%Z l)))) ->
is_a_bra_l m l.
Axiom bra_l_is_a_bra :
forall (m:matrix t), (exists l:Z, (l >= 0%Z)%Z /\ (is_a_bra_l m l)) ->
is_a_bra m.
Axiom set_is_a_bra :
forall (m:matrix t), ((rows m) = 1%Z) ->
(exists s:Z, (s >= 0%Z)%Z /\ ((columns m) = (power 2%Z s))) -> is_a_bra m.
Axiom set_is_a_bra_l :
forall (m:matrix t) (l:Z), (l >= 0%Z)%Z -> ((rows m) = 1%Z) ->
((columns m) = (power 2%Z l)) -> is_a_bra_l m l.
Axiom set_is_a_bra_p :
forall (m:matrix t) (l:Z), (l >= 0%Z)%Z -> ((rows m) = 1%Z) ->
((columns m) = (power 2%Z l)) -> is_a_bra m.
Parameter bra_to_ket_pre: (matrix t) -> matrix t.
Axiom bra_to_ket_pre_def :
forall (m:matrix t), (is_a_bra m) -> ((bra_to_ket_pre m) = (adjoint m)).
Axiom bra_to_ket_pre_spec :
forall (m:matrix t), (is_a_bra m) -> is_a_ket (bra_to_ket_pre m).
Parameter bra_length: (matrix t) -> Z.
Axiom bra_length_def :
forall (m:matrix t), (is_a_bra m) ->
((bra_length m) = (ket_length (bra_to_ket_pre m))).
Axiom bra_length_spec :
forall (m:matrix t), (is_a_bra m) -> ((bra_length m) >= 0%Z)%Z.
Axiom bra_length_spec1 :
forall (m:matrix t), (is_a_bra m) ->
((columns m) = (power 2%Z (bra_length m))).
Axiom bra_length_spec2 :
forall (m:matrix t), (is_a_bra m) -> is_a_bra_l m (bra_length m).
Axiom bra_l_length :
forall (m:matrix t) (l:Z), (l >= 0%Z)%Z -> (is_a_bra_l m l) ->
((bra_length m) = l).
Axiom get_bra_rows : forall (m:matrix t), (is_a_bra m) -> ((rows m) = 1%Z).
Axiom get_bra_columns :
forall (m:matrix t), (is_a_bra m) ->
((columns m) = (power 2%Z (bra_length m))).
Axiom get_is_a_bra : forall (m:matrix t), (is_a_bra m) -> ((rows m) = 1%Z).
Axiom get_is_a_bra1 :
forall (m:matrix t), (is_a_bra m) ->
((columns m) = (power 2%Z (bra_length m))).
Axiom get_bra_length :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_bra m) ->
((columns m) = (power 2%Z n)) -> ((bra_length m) = n).
Axiom set_bra_length :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_bra m) ->
((bra_length m) = n) -> ((columns m) = (power 2%Z n)).
Parameter get_bra: (matrix t) -> Z -> t.
Axiom get_bra_def :
forall (m:matrix t) (i:Z), (is_a_bra m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (get m 0%Z i)).
Axiom get_to_get_bra :
forall (m:matrix t) (i:Z) (j:Z), (is_a_bra m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) -> (i = 0%Z) ->
((get m i j) = (get_bra m j)).
Axiom get_to_get_ket :
forall (m:matrix t) (i:Z) (j:Z), (is_a_ket m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) -> (j = 0%Z) ->
((get m i j) = (get_ket m i)).
Axiom get_to_get_bra_gen :
forall (m:matrix t), (is_a_bra m) -> forall (i:Z) (j:Z), (i = 0%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) ->
((get m i j) = (get_bra m j)).
Axiom get_to_get_ket_gen :
forall (m:matrix t), (is_a_ket m) -> forall (i:Z) (j:Z), (j = 0%Z) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get m i j) = (get_ket m i)).
Parameter bra_to_ket: (matrix t) -> matrix t.
Axiom bra_to_ket_def :
forall (m:matrix t), (is_a_bra m) -> ((bra_to_ket m) = (adjoint m)).
Axiom bra_to_ket_spec :
forall (m:matrix t), (is_a_bra m) -> ((rows (bra_to_ket m)) = (columns m)).
Axiom bra_to_ket_spec1 :
forall (m:matrix t), (is_a_bra m) -> ((columns (bra_to_ket m)) = 1%Z).
Axiom bra_to_ket_spec2 :
forall (m:matrix t), (is_a_bra m) -> ((bra_to_ket m) = (bra_to_ket_pre m)).
Axiom bra_to_ket_spec3 :
forall (m:matrix t), (is_a_bra m) -> is_a_ket (bra_to_ket m).
Axiom bra_to_ket_spec4 :
forall (m:matrix t), (is_a_bra m) ->
((ket_length (bra_to_ket m)) = (bra_length m)).
Axiom bra_to_ket_spec5 :
forall (m:matrix t), (is_a_bra m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_ket (bra_to_ket m) i) = (conjugate (get_bra m i))).
Axiom get_bra_to_get_ket :
forall (m:matrix t) (i:Z), (is_a_bra m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (conjugate (get_ket (adjoint m) i))).
Axiom bra_length_to_ket_length :
forall (m:matrix t), (is_a_bra m) ->
((bra_length m) = (ket_length (adjoint m))).
Axiom bra_to_ket_to_adjoint :
forall (m:matrix t), (is_a_bra m) -> ((adjoint m) = (bra_to_ket m)).
Parameter is_a_bra_basis_elt: (matrix t) -> Prop.
Axiom is_a_bra_basis_elt_def :
forall (m:matrix t), (is_a_bra_basis_elt m) -> is_a_bra m.
Axiom is_a_bra_basis_elt_def1 :
forall (m:matrix t), (is_a_bra_basis_elt m) ->
is_a_ket_basis_elt (bra_to_ket m).
Axiom is_a_bra_basis_elt_def2 :
forall (m:matrix t),
((is_a_bra m) /\ (is_a_ket_basis_elt (bra_to_ket m))) ->
is_a_bra_basis_elt m.
Axiom set_is_a_bra_basis_elt_p :
forall (m:matrix t) (j:Z), (is_a_bra m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (indic i j))) ->
is_a_bra_basis_elt m.
Axiom set_is_a_bra_basis_elt :
forall (m:matrix t), (is_a_bra m) ->
(exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) /\
forall (i:Z), ((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (indic i j))) ->
is_a_bra_basis_elt m.
Axiom get_is_a_bra_basis_elt :
forall (m:matrix t), (is_a_bra m) -> (is_a_bra_basis_elt m) ->
exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) /\
forall (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (indic i j)).
Parameter bra: Z -> Z -> matrix t.
Axiom bra_def :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((bra n i) = (adjoint (ket n i))).
Axiom bra_spec : forall (n:Z) (i:Z), (0%Z <= n)%Z -> is_a_bra (bra n i).
Axiom bra_spec1 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_bra_l (bra n i) n.
Axiom bra_spec2 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((bra_length (bra n i)) = n).
Axiom bra_spec3 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((columns (bra n i)) = (power 2%Z n)).
Axiom bra_spec4 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> ((rows (bra n i)) = 1%Z).
Axiom bra_spec5 :
forall (n:Z) (i:Z), (0%Z <= n)%Z -> forall (j:Z),
(valid_index (bra n i) 0%Z j) -> ((get (bra n i) 0%Z j) = (indic j i)).
Axiom bra_spec6 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((get_bra (bra n i) j) = (indic j i)).
Axiom bra_spec7 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> forall (j:Z),
(valid_index (bra n i) 0%Z j) -> ~ (i = j) ->
((get_bra (bra n i) j) = tzero).
Axiom bra_spec8 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((get_bra (bra n i) i) = tone).
Axiom bra_spec9 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_bra_l (bra n i) n.
Axiom bra_spec10 :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> is_a_bra_basis_elt (bra n i).
Axiom bra_is_a_bra_basis_elt :
forall (m:matrix t) (n:Z) (i:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
(n >= 0%Z)%Z -> (m = (bra n i)) -> is_a_bra_basis_elt m.
Axiom bra_rows :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> ((rows (bra n i)) = 1%Z).
Axiom bra_columns :
forall (n:Z) (i:Z), (0%Z <= n)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((columns (bra n i)) = (power 2%Z n)).
Axiom bra_value :
forall (n:Z) (i:Z) (j:Z), (0%Z <= n)%Z ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((i = j) -> ((get (bra n i) 0%Z j) = tone)) /\
(~ (i = j) -> ((get (bra n i) 0%Z j) = tzero)).
Axiom real_values_ket_basis_elt :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) -> real_ (get_ket m i).
Axiom real_values_bra_basis_elt :
forall (m:matrix t), (is_a_bra_basis_elt m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) -> real_ (get_bra m i).
Axiom get_bra_to_get_ket_basis :
forall (m:matrix t) (i:Z), (is_a_bra_basis_elt m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_bra m i) = (get_ket (adjoint m) i)).
Axiom bra_to_ket_basis :
forall (m:matrix t), (is_a_bra_basis_elt m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length m)))%Z) ->
((get_ket (bra_to_ket m) i) = (get_bra m i)).
Parameter bra_valid_index: (matrix t) -> Z -> Prop.
Axiom bra_valid_index_def :
forall (m:matrix t) (j:Z), (bra_valid_index m j) -> is_a_bra m.
Axiom bra_valid_index_def1 :
forall (m:matrix t) (j:Z), (bra_valid_index m j) -> (0%Z <= j)%Z.
Axiom bra_valid_index_def2 :
forall (m:matrix t) (j:Z), (bra_valid_index m j) ->
(j < (power 2%Z (bra_length m)))%Z.
Axiom bra_valid_index_def3 :
forall (m:matrix t) (j:Z),
((is_a_bra m) /\ ((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z)) ->
bra_valid_index m j.
Axiom set_bra_valid_index :
forall (m:matrix t) (j:Z), (is_a_bra m) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (bra_length m)))%Z) -> bra_valid_index m j.
Axiom get_bra_valid_index :
forall (m:matrix t) (j:Z), (bra_valid_index m j) -> is_a_bra m.
Axiom get_bra_valid_index1 :
forall (m:matrix t) (j:Z), (bra_valid_index m j) -> (0%Z <= j)%Z.
Axiom get_bra_valid_index2 :
forall (m:matrix t) (j:Z), (bra_valid_index m j) ->
(j < (power 2%Z (bra_length m)))%Z.
Axiom bra_valid_index_to_valid_index :
forall (m:matrix t) (j:Z), (is_a_bra m) -> (bra_valid_index m j) ->
valid_index m 0%Z j.
Axiom valid_index_to_bra_valid_index :
forall (m:matrix t) (j:Z), (is_a_bra m) -> (valid_index m 0%Z j) ->
bra_valid_index m j.
Parameter bra_to_int: (matrix t) -> Z.
Axiom bra_to_int_def :
forall (m:matrix t), (is_a_bra m) -> (is_a_bra_basis_elt m) ->
((bra_to_int m) = (ket_to_int (bra_to_ket m))).
Axiom bra_to_int_spec :
forall (m:matrix t), (is_a_bra m) -> (is_a_bra_basis_elt m) ->
(m = (bra (bra_length m) (bra_to_int m))).
Axiom bra_to_int_to_ket_to_int :
forall (m:matrix t), (is_a_bra m) -> (is_a_bra_basis_elt m) ->
((bra_to_int m) = (ket_to_int (bra_to_ket m))).
Parameter ket_to_bra: (matrix t) -> matrix t.
Axiom ket_to_bra_def :
forall (m:matrix t), (is_a_ket m) -> ((ket_to_bra m) = (adjoint m)).
Axiom ket_to_bra_spec :
forall (m:matrix t), (is_a_ket m) ->
is_a_bra_l (ket_to_bra m) (ket_length m).
Axiom ket_to_bra_spec1 :
forall (m:matrix t), (is_a_ket m) ->
((bra_length (ket_to_bra m)) = (ket_length m)).
Axiom ket_to_bra_spec2 :
forall (m:matrix t), (is_a_ket m) -> ((rows (ket_to_bra m)) = 1%Z).
Axiom ket_to_bra_spec3 :
forall (m:matrix t), (is_a_ket m) -> ((columns (ket_to_bra m)) = (rows m)).
Axiom ket_to_bra_spec4 :
forall (m:matrix t), (is_a_ket m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_bra (ket_to_bra m) i) = (conjugate (get_ket m i))).
Axiom ket_to_bra_to_adjoint :
forall (m:matrix t), (is_a_ket m) -> ((adjoint m) = (ket_to_bra m)).
Axiom get_ket_to_get_bra :
forall (m:matrix t) (i:Z), (is_a_ket m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_ket m i) = (conjugate (get_bra (adjoint m) i))).
Axiom ket_length_to_bra_length :
forall (m:matrix t), (is_a_ket m) ->
((ket_length m) = (bra_length (adjoint m))).
Axiom get_ket_to_get_bra_basis :
forall (m:matrix t) (i:Z), (is_a_ket_basis_elt m) ->
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_ket m i) = (get_bra (adjoint m) i)).
Axiom ket_to_int_to_bra_to_int :
forall (m:matrix t), (is_a_ket m) -> (is_a_ket_basis_elt m) ->
((ket_to_int m) = (bra_to_int (ket_to_bra m))).
Axiom ket_to_bra_basis :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((get_bra (ket_to_bra m) i) = (get_ket m i)).
Axiom ket_to_bra_to_ket :
forall (m:matrix t), (is_a_ket m) -> ((bra_to_ket (ket_to_bra m)) = m).
Axiom bra_to_ket_to_bra :
forall (m:matrix t), (is_a_bra m) -> ((ket_to_bra (bra_to_ket m)) = m).
Axiom scalar_bra :
forall (x:matrix t) (a:t), (is_a_bra x) -> is_a_bra (infix_asdtdt a x).
Axiom scalar_bra_length :
forall (m:matrix t) (a:t), (is_a_bra m) ->
((bra_length (infix_asdtdt a m)) = (bra_length m)).
Axiom scalar_bra_valid_index :
forall (m:matrix t) (a:t) (i:Z), (bra_valid_index m i) -> (is_a_bra m) ->
bra_valid_index (infix_asdtdt a m) i.
Axiom scalar_bra_l :
forall (x:matrix t) (l:Z) (a:t), (is_a_bra_l x l) ->
is_a_bra_l (infix_asdtdt a x) l.
Parameter bra_sum:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.
Axiom bra_sum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra (f e1)) ->
(exists l:Z,
(l >= 0%Z)%Z /\ forall (e1:a), (mem e1 s) -> ((bra_length (f e1)) = l)) ->
((bra_sum s f) = (mat_sum s f)).
Axiom bra_sum_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra (f e1)) ->
(exists l:Z,
(l >= 0%Z)%Z /\ forall (e1:a), (mem e1 s) -> ((bra_length (f e1)) = l)) ->
is_a_bra (bra_sum s f).
Axiom bra_sum_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra (f e1)) ->
(exists l:Z,
(l >= 0%Z)%Z /\ forall (e1:a), (mem e1 s) -> ((bra_length (f e1)) = l)) ->
forall (e1:a), (mem e1 s) ->
((bra_length (bra_sum s f)) = (bra_length (f e1))).
Axiom bra_sum_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra (f e1)) ->
(exists l:Z,
(l >= 0%Z)%Z /\ forall (e1:a), (mem e1 s) -> ((bra_length (f e1)) = l)) ->
forall (i:Z), (bra_valid_index (bra_sum s f) i) ->
((get_bra (bra_sum s f) i) = (sum s (fun (e1:a) => (get_bra (f e1) i)))).
Parameter bra_sum_l:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
matrix t.
Axiom bra_sum_l_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
((bra_sum_l s f l) = (mat_sum s f)).
Axiom bra_sum_l_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
((bra_sum_l s f l) = (bra_sum s f)).
Axiom bra_sum_l_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) -> forall (i:Z),
(bra_valid_index (bra_sum_l s f l) i) ->
((get_bra (bra_sum_l s f l) i) =
(sum s (fun (e1:a) => (get_bra (f e1) i)))).
Axiom bra_sum_l_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
is_a_bra_l (bra_sum_l s f l) l.
Axiom bra_sum_l_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
((bra_length (bra_sum_l s f l)) = l).
Axiom bra_sum_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a), ((cardinal s) > 1%Z)%Z ->
(forall (e2:a), (mem e2 s) -> is_a_bra (f e2)) -> (constant_size s f) ->
(mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> null_mat (f e')) ->
((bra_sum s f) = (f e1)).
Axiom bra_sum_null :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
(forall (e1:a), (mem e1 s) -> null_mat (f e1)) -> forall (j:Z),
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) ->
((get_bra (bra_sum_l s f l) j) = tzero).
Axiom bra_sum_l_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 1%Z)%Z ->
(forall (e2:a), (mem e2 s) -> is_a_bra_l (f e2) l) -> (mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> null_mat (f e')) ->
((bra_sum_l s f l) = (f e1)).
Axiom bra_sum_bra_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
is_a_bra_l (bra_sum_l s f l) l.
Parameter add_bra: (matrix t) -> (matrix t) -> matrix t.
Axiom add_bra_def :
forall (m:matrix t) (n:matrix t), (is_a_bra m) -> (is_a_bra n) ->
((bra_length m) = (bra_length n)) -> ((add_bra m n) = (add_mat m n)).
Axiom add_bra_spec :
forall (m:matrix t) (n:matrix t), (is_a_bra m) -> (is_a_bra n) ->
((bra_length m) = (bra_length n)) -> is_a_bra (add_bra m n).
Axiom add_bra_spec1 :
forall (m:matrix t) (n:matrix t), (is_a_bra m) -> (is_a_bra n) ->
((bra_length m) = (bra_length n)) ->
((bra_length (add_bra m n)) = (bra_length m)).
Axiom add_bra_spec2 :
forall (m:matrix t) (n:matrix t), (is_a_bra m) -> (is_a_bra n) ->
((bra_length m) = (bra_length n)) -> forall (i:Z),
(bra_valid_index (add_bra m n) i) ->
((get_bra (add_bra m n) i) = (infix_pldt (get_bra m i) (get_bra n i))).
Parameter add_bra_l: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom add_bra_l_def :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_bra_l m l) ->
(is_a_bra_l n l) -> ((add_bra_l m n l) = (add_mat m n)).
Axiom add_bra_l_spec :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_bra_l m l) ->
(is_a_bra_l n l) -> is_a_bra_l (add_bra_l m n l) l.
Axiom add_bra_l_spec1 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_bra_l m l) ->
(is_a_bra_l n l) -> ((bra_length (add_bra_l m n l)) = l).
Axiom add_bra_l_spec2 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_bra_l m l) ->
(is_a_bra_l n l) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (bra_length (add_bra_l m n l))))%Z) ->
((get_bra (add_bra_l m n l) i) = (infix_pldt (get_bra m i) (get_bra n i))).
Axiom add_bra_l_spec3 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_bra_l m l) ->
(is_a_bra_l n l) -> ((add_bra_l m n l) = (add_bra m n)).
Axiom bra_sum_comp_l :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_bra_l (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_bra_l (g e1) l) ->
((bra_sum_l s (fun (k:b) => (add_bra_l (f k) (g k) l)) l) =
(add_bra_l (bra_sum_l s f l) (bra_sum_l s g l) l)).
Axiom bra_sum_comp_l_rev :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_bra_l (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_bra_l (g e1) l) ->
((add_bra_l (bra_sum_l s f l) (bra_sum_l s g l) l) =
(bra_sum_l s (fun (k:b) => (add_bra_l (f k) (g k) l)) l)).
Axiom bra_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((bra_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
(infix_asdtdt a1 (bra_sum_l s f l))).
Axiom scal_bra_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (b:t) (l:Z) (l':Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) ->
exists a1:t,
exists k:matrix t, ((f e1) = (infix_asdtdt a1 k)) /\ (is_a_bra_l k l)) ->
((cardinal s) > 0%Z)%Z -> (l = l') ->
is_a_bra_l (infix_asdtdt b (bra_sum_l s f l)) l'.
Axiom bra_sum_scalar_rev_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((infix_asdtdt a1 (bra_sum_l s f l)) =
(bra_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l)).
Axiom bra_sum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l:Z),
(l >= 0%Z)%Z -> ((cardinal s) > 0%Z)%Z -> (s = s') ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((bra_sum_l s f l) = (bra_sum_l s' g l)).
Axiom bra_sum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l1:Z)
(l2:Z),
(l1 >= 0%Z)%Z -> ((cardinal s) > 0%Z)%Z -> (s = s') -> (l1 = l2) ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l1) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((bra_sum_l s f l1) = (bra_sum_l s' g l2)).
Axiom bra_sum_l_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) = 1%Z) ->
(is_a_bra_l (f (choose s)) l) -> ((bra_sum_l s f l) = (f (choose s))).
Axiom bra_sum_l_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (e1:a) (f:a -> matrix t) (l:Z), ((cardinal s) > 1%Z)%Z ->
~ (mem e1 s) -> (forall (e2:a), (mem e2 s) -> is_a_bra_l (f e2) l) ->
(is_a_bra_l (f e1) l) ->
((bra_sum_l (add e1 s) f l) = (add_bra_l (bra_sum_l s f l) (f e1) l)).
Axiom bra_sum_l_valid_index :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_bra_l (f e1) l) ->
(forall (e1:a), (mem e1 s) -> bra_valid_index (f e1) i) ->
bra_valid_index (bra_sum_l s f l) i.
Parameter is_a_ketbra_n: (matrix t) -> Z -> Prop.
Axiom is_a_ketbra_n_def :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) -> (n >= 0%Z)%Z.
Axiom is_a_ketbra_n_def1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((columns m) = (power 2%Z n)).
Axiom is_a_ketbra_n_def2 :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((rows m) = (power 2%Z n)).
Axiom is_a_ketbra_n_def3 :
forall (m:matrix t) (n:Z),
((n >= 0%Z)%Z /\
(((columns m) = (power 2%Z n)) /\ ((rows m) = (power 2%Z n)))) ->
is_a_ketbra_n m n.
Parameter is_a_ketbra: (matrix t) -> Prop.
Axiom is_a_ketbra_def :
forall (m:matrix t), (is_a_ketbra m) ->
exists s:Z, (s >= 0%Z)%Z /\ (is_a_ketbra_n m s).
Axiom is_a_ketbra_def1 :
forall (m:matrix t), (exists s:Z, (s >= 0%Z)%Z /\ (is_a_ketbra_n m s)) ->
is_a_ketbra m.
Parameter ketbra_size: (matrix t) -> Z.
Axiom ketbra_size_def :
forall (m:matrix t), (is_a_ketbra m) ->
((ketbra_size m) = (ket_length (make (rows m) 1%Z tzero))).
Axiom ketbra_size_spec :
forall (m:matrix t), (is_a_ketbra m) ->
((ketbra_size m) = ((binary_length (rows m)) - 1%Z)%Z).
Axiom ketbra_size_spec1 :
forall (m:matrix t), (is_a_ketbra m) -> ((ketbra_size m) >= 0%Z)%Z.
Axiom ketbra_size_spec2 :
forall (m:matrix t), (is_a_ketbra m) ->
((columns m) = (power 2%Z (ketbra_size m))).
Axiom ketbra_size_spec3 :
forall (m:matrix t), (is_a_ketbra m) ->
((rows m) = (power 2%Z (ketbra_size m))).
Axiom ketbra_size_spec4 :
forall (m:matrix t), (is_a_ketbra m) -> is_a_ketbra_n m (ketbra_size m).
Axiom get_ketbra_size :
forall (m:matrix t) (n:Z), (is_a_ketbra m) -> (n >= 0%Z)%Z ->
((ketbra_size m) = n) -> ((columns m) = (power 2%Z n)).
Axiom get_ketbra_size1 :
forall (m:matrix t) (n:Z), (is_a_ketbra m) -> (n >= 0%Z)%Z ->
((ketbra_size m) = n) -> ((rows m) = (power 2%Z n)).
Axiom ketbra_n_to_ket_size :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) -> (n >= 0%Z)%Z ->
((ketbra_size m) = n).
Axiom set_ketbra_size :
forall (m:matrix t) (n:Z), (n >= 0%Z)%Z -> ((columns m) = (power 2%Z n)) ->
((rows m) = (power 2%Z n)) -> ((ketbra_size m) = n).
Axiom set_columns_ketbra :
forall (m:matrix t) (n:Z), (is_a_ketbra m) -> ((ketbra_size m) = n) ->
((columns m) = (power 2%Z n)).
Axiom set_rows_ketbra :
forall (m:matrix t) (n:Z), (is_a_ketbra m) -> ((ketbra_size m) = n) ->
((rows m) = (power 2%Z n)).
Axiom set_columns_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((columns m) = (power 2%Z n)).
Axiom set_rows_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((rows m) = (power 2%Z n)).
Axiom get_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) -> is_a_ketbra m.
Axiom get_ketbra_n1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) -> (n >= 0%Z)%Z.
Axiom get_ketbra_n2 :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((columns m) = (power 2%Z n)).
Axiom get_ketbra_n3 :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((rows m) = (power 2%Z n)).
Axiom set_ketbra_n :
forall (m:matrix t) (n:Z), (n >= 0%Z)%Z -> ((columns m) = (power 2%Z n)) ->
((rows m) = (power 2%Z n)) -> is_a_ketbra_n m n.
Axiom get_ketbra :
forall (m:matrix t), (is_a_ketbra m) -> is_a_ketbra_n m (ketbra_size m).
Axiom get_ketbra1 :
forall (m:matrix t), (is_a_ketbra m) ->
exists n:Z,
(n >= 0%Z)%Z /\
(((columns m) = (power 2%Z n)) /\ ((rows m) = (power 2%Z n))).
Axiom get_ketbra2 :
forall (m:matrix t), (is_a_ketbra m) -> is_a_ketbra_n m (ketbra_size m).
Axiom set_ketbra :
forall (m:matrix t),
(((ketbra_size m) >= 0%Z)%Z /\
(((columns m) = (power 2%Z (ketbra_size m))) /\
((rows m) = (power 2%Z (ketbra_size m))))) ->
is_a_ketbra m.
Axiom ketbra_n_is_a_ketbra :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) -> is_a_ketbra m.
Parameter is_a_ketbra_basis_elt_n: (matrix t) -> Z -> Prop.
Axiom is_a_ketbra_basis_elt_n_def :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_n m n.
Axiom is_a_ketbra_basis_elt_n_def1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z)) ->
(((i = k) /\ (j = l)) -> ((get m k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get m k l) = tzero))).
Axiom is_a_ketbra_basis_elt_n_def2 :
forall (m:matrix t) (n:Z),
((is_a_ketbra_n m n) /\
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z)) ->
(((i = k) /\ (j = l)) /\ ((get m k l) = tone)) \/
(~ ((i = k) /\ (j = l)) /\ ((get m k l) = tzero)))) ->
is_a_ketbra_basis_elt_n m n.
Parameter is_a_ketbra_basis_elt: (matrix t) -> Prop.
Axiom is_a_ketbra_basis_elt_def :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
exists n:Z, is_a_ketbra_basis_elt_n m n.
Axiom is_a_ketbra_basis_elt_def1 :
forall (m:matrix t), (exists n:Z, is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_basis_elt m.
Axiom get_ketbra_basis_elt_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) -> (n >= 0%Z)%Z.
Axiom get_ketbra_basis_elt_n1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z)) ->
(((i = k) /\ (j = l)) -> ((get m k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get m k l) = tzero))).
Axiom get_ketbra_basis_elt_n2 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
((rows m) = (power 2%Z n)).
Axiom get_ketbra_basis_elt_n3 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
((columns m) = (power 2%Z n)).
Axiom get_ketbra_basis_elt_n4 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_n m n.
Axiom get_ketbra_basis_elt_n5 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) -> is_a_ketbra m.
Axiom get_ketbra_basis_elt_n6 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_basis_elt m.
Axiom get_ketbra_basis_elt_n7 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
((ketbra_size m) = n).
Axiom set_ketbra_basis_elt_n :
forall (m:matrix t) (n:Z), (n >= 0%Z)%Z ->
(((rows m) = (power 2%Z n)) /\
(((columns m) = (power 2%Z n)) /\
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z)) ->
(((i = k) /\ (j = l)) /\ ((get m k l) = tone)) \/
(~ ((i = k) /\ (j = l)) /\ ((get m k l) = tzero))))) ->
is_a_ketbra_basis_elt_n m n.
Axiom get_ketbra_basis_elt :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
is_a_ketbra_n m (ketbra_size m).
Axiom get_ketbra_basis_elt1 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
exists n:Z,
((columns m) = (power 2%Z n)) /\
(((rows m) = (power 2%Z n)) /\
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z)) ->
(((i = k) /\ (j = l)) -> ((get m k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get m k l) = tzero)))).
Axiom get_ketbra_basis_elt2 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) -> is_a_ketbra m.
Axiom set_ketbra_basis_elt :
forall (m:matrix t),
(((ketbra_size m) >= 0%Z)%Z /\
(((columns m) = (power 2%Z (ketbra_size m))) /\
(((rows m) = (power 2%Z (ketbra_size m))) /\
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z (ketbra_size m)))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z (ketbra_size m)))%Z) /\
forall (k:Z) (l:Z),
(((0%Z <= k)%Z /\ (k < (power 2%Z (ketbra_size m)))%Z) /\
((0%Z <= l)%Z /\ (l < (power 2%Z (ketbra_size m)))%Z)) ->
(((i = k) /\ (j = l)) /\ ((get m k l) = tone)) \/
(~ ((i = k) /\ (j = l)) /\ ((get m k l) = tzero)))))) ->
is_a_ketbra_basis_elt m.
Axiom ketbra_basis_elt_n_is_a_ketbra_basis_element :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_basis_elt m.
Axiom ketbra_basis_elt_n_is_a_ketbra_basis_element1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
(n = (ketbra_size m)).
Axiom ketbra_basis_elt_is_a_ketbra_basis_element_n :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
is_a_ketbra_basis_elt_n m (ketbra_size m).
Axiom ketbra_basis_elt_n_is_a_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
is_a_ketbra_n m n.
Axiom ketbra_basis_elt_n_is_a_ketbra :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) -> is_a_ketbra m.
Axiom ketbra_basis_elt_is_a_ketbra :
forall (m:matrix t), (is_a_ketbra_basis_elt m) -> is_a_ketbra m.
Axiom rows_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((rows m) = (power 2%Z n)).
Axiom columns_ketbra_n :
forall (m:matrix t) (n:Z), (is_a_ketbra_n m n) ->
((columns m) = (power 2%Z n)).
Axiom ketbra_basis_element_has_decomp :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
(is_a_ketbra_n m n) ->
exists i:Z, exists j:Z,
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) /\
(((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) /\
(m = (kronecker (ket n i) (bra n j)))).
Axiom ketbra_basis_element_has_decomp1 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
(is_a_ketbra_n m n) ->
exists k:matrix t, exists b:matrix t,
(is_a_bra_l b n) /\
((is_a_bra_basis_elt b) /\
((is_a_ket_l k n) /\ ((is_a_ket_basis_elt k) /\ (m = (kronecker k b))))).
Axiom ketbra_basis_element_has_decomp2 :
forall (m:matrix t) (n:Z), (is_a_ketbra_basis_elt_n m n) ->
(is_a_ketbra_n m n) ->
exists o:(Z* Z)%type,
(mem o
(cartesian_product (to_fset 0%Z (power 2%Z (ketbra_size m)))
(to_fset 0%Z (power 2%Z (ketbra_size m))))) /\
(equal m
(kronecker (ket (ketbra_size m) (fir o)) (bra (ketbra_size m) (sec o)))).
Axiom pre_injective_bv_to_int :
forall (bv1:bitvec) (bv2:bitvec), ((length bv1) = (length bv2)) ->
~ (bv1 = bv2) -> ~ ((bv_to_int bv1) = (bv_to_int bv2)).
Axiom injective_bv_to_int :
forall (n:Z), (0%Z <= n)%Z ->
p_injective (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n).
Axiom bijective_to_int :
forall (n:Z), (0%Z < n)%Z ->
p_bijective (fun (y0:bitvec) => (bv_to_int y0)) (n_bvs n)
(to_fset 0%Z (power 2%Z n)).
Axiom n_bvs_card :
forall (n:Z), (0%Z <= n)%Z -> ((cardinal (n_bvs n)) = (power 2%Z n)).
Axiom concat_first_term_zero :
forall (e1:bitvec) (i:Z), (0%Z <= i)%Z ->
(mem e1 (map (fun (bv:bitvec) => (concat_l bv 0%Z)) (n_bvs i))) ->
(((getbv e1) 0%Z) = 0%Z).
Axiom concat_first_term_one :
forall (e1:bitvec) (i:Z), (0%Z <= i)%Z ->
(mem e1 (map (fun (bv:bitvec) => (concat_l bv 1%Z)) (n_bvs i))) ->
(((getbv e1) 0%Z) = 1%Z).
Axiom geometric_series_bv :
forall (a:t) (q:t) (n:Z), (n >= 1%Z)%Z ->
((sum (n_bvs n)
(fun (i:bitvec) => (infix_asdt a (cpower q (bv_to_int i)))))
=
(infix_sldt (infix_asdt a (infix_mndt tone (cpower q (power_ 2%Z n))))
(infix_mndt tone q))).
Axiom geometric_series_bv_init_one :
forall (q:t) (n:Z), (n >= 1%Z)%Z ->
((sum (n_bvs n) (fun (i:bitvec) => (cpower q (bv_to_int i)))) =
(infix_sldt (infix_mndt tone (cpower q (power_ 2%Z n)))
(infix_mndt tone q))).
Axiom bv_sum_to_int_sum :
forall (n:Z) (f:Z -> t) (g:bitvec -> t),
(forall (x:bitvec), ((length x) = n) -> ((g x) = (f (bv_to_int x)))) ->
((sum (n_bvs n) g) = (sum (to_fset 0%Z (power 2%Z n)) f)).
Axiom sum_concat :
forall (f:bitvec -> matrix t) (i:Z) (r:Z) (c:Z), (i > 0%Z)%Z ->
(forall (bv:bitvec), ((rows (f bv)) = r)) ->
(forall (bv:bitvec), ((columns (f bv)) = c)) ->
((mat_sum (n_bvs i)
(fun (bv:bitvec) =>
(add_mat (f (concat_l bv 0%Z)) (f (concat_l bv 1%Z)))))
= (mat_sum (n_bvs (i + 1%Z)%Z) f)).
Parameter ketbra_pre: Z -> Z -> Z -> matrix t.
Axiom ketbra_pre_spec :
forall (n:Z) (i:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra_size (ketbra_pre n i j)) = n).
Axiom ketbra_pre_spec1 :
forall (n:Z) (i:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> forall (k:Z) (l:Z),
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) ->
(((i = k) /\ (j = l)) -> ((get (ketbra_pre n i j) k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get (ketbra_pre n i j) k l) = tzero)).
Axiom ketbra_pre_spec2 :
forall (n:Z) (i:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra_pre n i j) = (ind_basis_mat i j (power 2%Z n) (power 2%Z n))).
Axiom ketbra_pre_spec3 :
forall (n:Z) (i:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> forall (y:matrix t),
(is_a_ket_l y n) ->
((mat_mult (ketbra_pre n i j) y) = (infix_asdtdt (get_ket y j) (ket n i))).
Axiom ketbra_pre_spec4 :
forall (n:Z) (i:Z) (j:Z), (n > 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra_pre n i j) = (kronecker (ket n i) (bra n j))).
Parameter ketbra: Z -> Z -> Z -> matrix t.
Axiom ketbra_def :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra n i j) = (kronecker (ket n i) (bra n j))).
Axiom ketbra_spec :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra_size (ketbra n i j)) = n).
Axiom ketbra_spec1 :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((rows (ketbra n i j)) = (power 2%Z n)).
Axiom ketbra_spec2 :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((columns (ketbra n i j)) = (power 2%Z n)).
Axiom ketbra_spec3 :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> forall (k:Z) (l:Z),
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) ->
(((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tzero)).
Axiom ketbra_spec4 :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((ketbra n i j) = (ind_basis_mat i j (power 2%Z n) (power 2%Z n))).
Axiom ketbra_spec5 :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> forall (y:matrix t),
(is_a_ket_l y n) ->
((mat_mult (ketbra n i j) y) = (infix_asdtdt (get_ket y j) (ket n i))).
Axiom ketbra_rows :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((rows (ketbra n i j)) = (power 2%Z n)).
Axiom ketbra_columns :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((columns (ketbra n i j)) = (power 2%Z n)).
Axiom ketbra_is_a_ketbra_n :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> is_a_ketbra_n (ketbra n i j) n.
Axiom ketbra_value :
forall (n:Z) (i:Z) (j:Z) (k:Z) (l:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) ->
(((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tzero)).
Axiom ketbra_values :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> forall (k:Z) (l:Z),
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) ->
(((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tone)) /\
(~ ((i = k) /\ (j = l)) -> ((get (ketbra n i j) k l) = tzero)).
Axiom ketbra_adjoint :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((adjoint (ketbra n i j)) = (ketbra n j i)).
Parameter ketbra_to_int_couple: (matrix t) -> (Z* Z)%type.
Parameter result27: (matrix t) -> (Z* Z)%type -> bool.
Axiom result_def27 :
forall (m:matrix t) (x:(Z* Z)%type),
(((result27 m) x) = true) <->
(equal m
(kronecker (ket (ketbra_size m) (fir x)) (bra (ketbra_size m) (sec x)))).
Axiom ketbra_to_int_couple_def :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((ketbra_to_int_couple m) =
(choose_filter
(cartesian_product (to_fset 0%Z (power 2%Z (ketbra_size m)))
(to_fset 0%Z (power 2%Z (ketbra_size m))))
(result27 m))).
Axiom ketbra_to_int_couple_spec :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(m =
(kronecker (ket (ketbra_size m) (fir (ketbra_to_int_couple m)))
(bra (ketbra_size m) (sec (ketbra_to_int_couple m))))).
Axiom ketbra_to_int_couple_spec1 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(0%Z <= (fir (ketbra_to_int_couple m)))%Z.
Axiom ketbra_to_int_couple_spec2 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((fir (ketbra_to_int_couple m)) < (power 2%Z (ketbra_size m)))%Z.
Axiom ketbra_to_int_couple_spec3 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(0%Z <= (sec (ketbra_to_int_couple m)))%Z.
Axiom ketbra_to_int_couple_spec4 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((sec (ketbra_to_int_couple m)) < (power 2%Z (ketbra_size m)))%Z.
Parameter ketbra_to_int_rows: (matrix t) -> Z.
Axiom ketbra_to_int_rows_def :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((ketbra_to_int_rows m) = (fir (ketbra_to_int_couple m))).
Axiom ketbra_to_int_rows_spec :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(0%Z <= (ketbra_to_int_rows m))%Z.
Axiom ketbra_to_int_rows_spec1 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((ketbra_to_int_rows m) < (power 2%Z (ketbra_size m)))%Z.
Axiom ketbra_to_int_rows_spec2 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
exists j:Z,
((0%Z <= j)%Z /\ (j < (power 2%Z (ketbra_size m)))%Z) /\
(m =
(kronecker (ket (ketbra_size m) (ketbra_to_int_rows m))
(bra (ketbra_size m) j))).
Parameter ketbra_to_int_col: (matrix t) -> Z.
Axiom ketbra_to_int_col_def :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((ketbra_to_int_col m) = (sec (ketbra_to_int_couple m))).
Axiom ketbra_to_int_col_spec :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(0%Z <= (ketbra_to_int_col m))%Z.
Axiom ketbra_to_int_col_spec1 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
((ketbra_to_int_col m) < (power 2%Z (ketbra_size m)))%Z.
Axiom ketbra_to_int_col_spec2 :
forall (m:matrix t), (is_a_ketbra_basis_elt m) ->
(m =
(kronecker (ket (ketbra_size m) (ketbra_to_int_rows m))
(bra (ketbra_size m) (ketbra_to_int_col m)))).
Axiom correct_ketbra_basis_decomp :
forall (m:matrix t) (n:Z), (0%Z <= n)%Z -> (is_a_ketbra_basis_elt_n m n) ->
(m = (ketbra n (ketbra_to_int_rows m) (ketbra_to_int_col m))).
Axiom ketbra_diff_r :
forall (n:Z) (i:Z) (j:Z) (k:Z) (l:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) -> (n >= 0%Z)%Z -> ~ (i = k) ->
((get (ketbra n i j) k l) = tzero).
Axiom ketbra_diff_c :
forall (n:Z) (i:Z) (j:Z) (k:Z) (l:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) -> (n >= 0%Z)%Z -> ~ (j = l) ->
((get (ketbra n i j) k l) = tzero).
Axiom ketbra_eq :
forall (n:Z) (i:Z) (j:Z) (k:Z) (l:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((0%Z <= l)%Z /\ (l < (power 2%Z n))%Z) -> (n >= 0%Z)%Z -> (i = k) ->
(j = l) -> ((get (ketbra n i j) k l) = tone).
Axiom ketbra_to_ind_basis :
forall (n:Z) (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> (n >= 0%Z)%Z ->
((ketbra n i j) = (ind_basis_mat i j (power 2%Z n) (power 2%Z n))).
Parameter projection: (matrix t) -> matrix t.
Axiom projection_def :
forall (m:matrix t), (is_a_ket m) ->
((projection m) = (kronecker m (adjoint m))).
Axiom projection_spec :
forall (m:matrix t), (is_a_ket m) ->
is_a_ketbra_n (projection m) (ket_length m).
Axiom projection_spec1 :
forall (m:matrix t), (is_a_ket m) -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((get (projection m) i j) =
(infix_asdt (get_ket m i) (conjugate (get_ket m j)))).
Axiom projection_spec2 :
forall (m:matrix t), (is_a_ket m) ->
((rows (projection m)) = (power 2%Z (ket_length m))).
Axiom projection_spec3 :
forall (m:matrix t), (is_a_ket m) ->
((columns (projection m)) = (power 2%Z (ket_length m))).
Axiom projection_decomp :
forall (m:matrix t), (is_a_ket m) ->
((projection m) = (kronecker m (adjoint m))).
Axiom projection_value :
forall (m:matrix t) (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) -> (is_a_ket m) ->
((get (projection m) i j) =
(infix_asdt (get_ket m i) (conjugate (get_ket m j)))).
Axiom auto_adjoint_proj :
forall (m:matrix t), (is_a_ket m) ->
((adjoint (projection m)) = (projection m)).
Parameter projection_n: (matrix t) -> Z -> matrix t.
Axiom projection_n_def :
forall (m:matrix t) (l:Z), (0%Z <= l)%Z -> (is_a_ket_l m l) ->
((projection_n m l) = (projection m)).
Axiom projection_n_spec :
forall (m:matrix t) (l:Z), (0%Z <= l)%Z -> (is_a_ket_l m l) ->
is_a_ketbra_n (projection_n m l) l.
Axiom projection_n_spec1 :
forall (m:matrix t) (l:Z), (0%Z <= l)%Z -> (is_a_ket_l m l) ->
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < (power 2%Z (ket_length m)))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z (ket_length m)))%Z) ->
((get (projection_n m l) i j) =
(infix_asdt (get_ket m i) (conjugate (get_ket m j)))).
Parameter projection_basis: (matrix t) -> matrix t.
Axiom projection_basis_def :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
((projection_basis m) = (projection m)).
Axiom projection_basis_spec :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
((projection_basis m) = (kronecker m (adjoint m))).
Axiom projection_basis_spec1 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
((projection_basis m) =
(ketbra (ket_length m) (ket_to_int m) (ket_to_int m))).
Axiom projection_basis_spec2 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
is_a_ketbra_n (projection_basis m) (ket_length m).
Axiom projection_basis_spec3 :
forall (m:matrix t), (is_a_ket_basis_elt m) ->
is_a_ketbra_basis_elt (projection_basis m).
Axiom projection_basis_spec4 :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (i:Z) (j:Z),
(valid_index (projection_basis m) i j) ->
(((i = (ket_to_int m)) /\ (j = (ket_to_int m))) ->
((get (projection_basis m) i j) = tone)) /\
(~ ((i = (ket_to_int m)) /\ (j = (ket_to_int m))) ->
((get (projection_basis m) i j) = tzero)).
Axiom projection_basis_spec5 :
forall (m:matrix t), (is_a_ket_basis_elt m) -> forall (y:matrix t),
(is_a_ket_l y (ket_length m)) ->
((mat_mult (projection_basis m) y) =
(infix_asdtdt (get_ket y (ket_to_int m))
(ket (ket_length m) (ket_to_int m)))).
Parameter is_diagonal: (matrix t) -> Prop.
Parameter fc17: (Z -> t) -> Z -> Z -> t.
Axiom fc_def17 :
forall (f:Z -> t) (i:Z) (j:Z),
((i = j) -> ((((fc17 f) i) j) = (f i))) /\
(~ (i = j) -> ((((fc17 f) i) j) = tzero)).
Axiom is_diagonal_def :
forall (m:matrix t), (is_diagonal m) ->
exists f:Z -> t, (m = (make_f (rows m) (rows m) (fc17 f))).
Parameter fc18: (Z -> t) -> Z -> Z -> t.
Axiom fc_def18 :
forall (f:Z -> t) (i:Z) (j:Z),
((i = j) -> ((((fc18 f) i) j) = (f i))) /\
(~ (i = j) -> ((((fc18 f) i) j) = tzero)).
Axiom is_diagonal_def1 :
forall (m:matrix t),
(exists f:Z -> t, (m = (make_f (rows m) (rows m) (fc18 f)))) ->
is_diagonal m.
Parameter diag_mat1: (Z -> t) -> Z -> matrix t.
Parameter result28: (Z -> t) -> Z -> Z -> t.
Axiom result_def28 :
forall (f:Z -> t) (i:Z) (j:Z),
((i = j) -> ((((result28 f) i) j) = (f i))) /\
(~ (i = j) -> ((((result28 f) i) j) = tzero)).
Axiom diag_mat_def1 :
forall (f:Z -> t) (s:Z), (0%Z < s)%Z ->
((diag_mat1 f s) = (make_f s s (result28 f))).
Axiom diag_mat_spec2 :
forall (f:Z -> t) (s:Z), (0%Z < s)%Z -> is_diagonal (diag_mat1 f s).
Axiom diag_mat_spec3 :
forall (f:Z -> t) (s:Z), (0%Z < s)%Z -> ((rows (diag_mat1 f s)) = s).
Axiom diag_mat_spec4 :
forall (f:Z -> t) (s:Z), (0%Z < s)%Z -> ((columns (diag_mat1 f s)) = s).
Parameter diagonal: (matrix t) -> Z -> t.
Axiom diagonal_def :
forall (m:matrix t) (i:Z), ((0%Z <= i)%Z /\ (i < (rows m))%Z) ->
(is_diagonal m) -> ((diagonal m i) = (get m i i)).
Axiom diag_mat_add :
forall (f:Z -> t) (g:Z -> t) (h:Z -> t) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
((infix_pldt (f i) (g i)) = (h i))) ->
((add_mat (diag_mat1 f s) (diag_mat1 g s)) = (diag_mat1 h s)).
Axiom diag_mat_subst :
forall (f:Z -> t) (g:Z -> t) (h:Z -> t) (s:Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
((infix_mndt (f i) (g i)) = (h i))) ->
((diag_mat1 h s) = (mat_substr (diag_mat1 f s) (diag_mat1 g s))).
Axiom diag_mat_scal :
forall (f:Z -> t) (g:Z -> t) (s:Z) (a:t),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) ->
((g i) = (infix_asdt a (f i)))) ->
((diag_mat1 g s) = (infix_asdtdt a (diag_mat1 f s))).
Axiom diag_mat_eq1 :
forall (f:Z -> t) (g:Z -> t) (s:Z) (s':Z),
(forall (i:Z), ((0%Z <= i)%Z /\ (i < s)%Z) -> ((f i) = (g i))) ->
(s = s') -> ((diag_mat1 f s) = (diag_mat1 g s')).
Parameter id_mat: Z -> matrix t.
Axiom id_mat_def :
forall (n:Z), (n >= 1%Z)%Z ->
((id_mat n) = (diag_mat1 (fun (i:Z) => tone) n)).
Axiom id_mat_spec :
forall (n:Z), (n >= 1%Z)%Z -> forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) ->
((diagonal (id_mat n) i) = tone).
Axiom id_mat_spec1 : forall (n:Z), (n >= 1%Z)%Z -> ((rows (id_mat n)) = n).
Axiom id_mat_spec2 :
forall (n:Z), (n >= 1%Z)%Z -> ((columns (id_mat n)) = n).
Axiom set_id_mat :
forall (n:Z) (f:Z -> t), (n >= 0%Z)%Z ->
(forall (i:Z), ((0%Z <= i)%Z /\ (i < n)%Z) -> ((f i) = tone)) ->
((diag_mat1 f n) = (id_mat n)).
Axiom id_mat_prod_r :
forall (n:Z) (m:matrix t), (n >= 1%Z)%Z -> ((rows m) = n) ->
((mat_mult (id_mat n) m) = m).
Axiom id_mat_prod_l :
forall (n:Z) (m:matrix t), (n >= 1%Z)%Z -> ((columns m) = n) ->
((mat_mult m (id_mat n)) = m).
Parameter projection_basis_l: (matrix t) -> Z -> Z -> matrix t.
Axiom projection_basis_l_def :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> ((projection_basis_l m i l) = (projection m)).
Axiom projection_basis_l_spec :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> ((projection_basis_l m i l) = (projection_basis m)).
Axiom projection_basis_l_spec1 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) ->
((projection_basis_l m i l) = (ketbra l (ket_to_int m) (ket_to_int m))).
Axiom projection_basis_l_spec2 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) ->
((projection_basis_l m i l) = (kronecker m (adjoint m))).
Axiom projection_basis_l_spec3 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) ->
((projection_basis_l m i l) = (kronecker (ket l i) (bra l i))).
Axiom projection_basis_l_spec4 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> ((projection_basis_l m i l) = (projection_n m l)).
Axiom projection_basis_l_spec5 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> ((projection_basis_l m i l) = (projection_basis m)).
Axiom projection_basis_l_spec6 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> is_a_ketbra_basis_elt (projection_basis_l m i l).
Axiom projection_basis_l_spec7 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> ((projection_basis_l m i l) = (ketbra l i i)).
Axiom projection_basis_l_spec8 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> forall (i1:Z) (j:Z),
(valid_index (projection_basis_l m i l) i1 j) ->
(((i1 = (ket_to_int m)) /\ (j = (ket_to_int m))) ->
((get (projection_basis_l m i l) i1 j) = tone)) /\
(~ ((i1 = (ket_to_int m)) /\ (j = (ket_to_int m))) ->
((get (projection_basis_l m i l) i1 j) = tzero)).
Axiom projection_basis_l_spec9 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) -> forall (y:matrix t), (is_a_ket_l y l) ->
((mat_mult (projection_basis_l m i l) y) =
(infix_asdtdt (get_ket y i) (ket l i))).
Parameter fc19: Z -> Z -> t.
Axiom fc_def19 :
forall (i:Z) (j:Z),
((j = i) -> (((fc19 i) j) = tone)) /\ (~ (j = i) -> (((fc19 i) j) = tzero)).
Axiom projection_basis_l_spec10 :
forall (m:matrix t) (i:Z) (l:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> (m = (ket l i)) ->
(is_a_ket_l m l) ->
((projection_basis_l m i l) = (diag_mat1 (fc19 i) (power 2%Z l))).
Parameter ket_projection_basis: Z -> Z -> matrix t.
Axiom ket_projection_basis_def :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (projection_basis_l (ket l i) i l)).
Axiom ket_projection_basis_spec :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (projection_basis (ket l i))).
Axiom ket_projection_basis_spec1 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (kronecker (ket l i) (bra l i))).
Axiom ket_projection_basis_spec2 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
is_a_ketbra_basis_elt (ket_projection_basis l i).
Axiom ket_projection_basis_spec3 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (ketbra l i i)).
Axiom ket_projection_basis_spec4 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (projection (ket l i))).
Axiom ket_projection_basis_spec5 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((rows (ket_projection_basis l i)) = (power 2%Z l)).
Axiom ket_projection_basis_spec6 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((columns (ket_projection_basis l i)) = (power 2%Z l)).
Axiom ket_projection_basis_spec7 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) -> forall (y:matrix t),
(is_a_ket_l y l) ->
((mat_mult (ket_projection_basis l i) y) =
(infix_asdtdt (get_ket y i) (ket l i))).
Parameter fc20: Z -> Z -> t.
Axiom fc_def20 :
forall (i:Z) (j:Z),
((j = i) -> (((fc20 i) j) = tone)) /\ (~ (j = i) -> (((fc20 i) j) = tzero)).
Axiom ket_projection_basis_spec8 :
forall (l:Z) (i:Z), (l >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((ket_projection_basis l i) = (diag_mat1 (fc20 i) (power 2%Z l))).
Parameter braket: Z -> Z -> Z -> matrix t.
Axiom braket_def :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((braket n i j) = (mat_mult (bra n i) (ket n j))).
Axiom braket_spec :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((i = j) -> ((braket n i j) = (make 1%Z 1%Z tone))) /\
(~ (i = j) -> ((braket n i j) = (make 1%Z 1%Z tzero))).
Axiom braket_rows :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> ((rows (braket n i j)) = 1%Z).
Axiom braket_columns :
forall (n:Z) (i:Z) (j:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> ((columns (braket n i j)) = 1%Z).
Axiom braket_value :
forall (n:Z) (i:Z) (j:Z) (k:Z) (l:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < 1%Z)%Z) -> ((0%Z <= j)%Z /\ (j < 1%Z)%Z) ->
((0%Z <= k)%Z /\ (k < 1%Z)%Z) -> ((0%Z <= l)%Z /\ (l < 1%Z)%Z) ->
((i = j) -> ((get (braket n i j) k l) = tone)) /\
(~ (i = j) -> ((get (braket n i j) k l) = tzero)).
Axiom ketbraket_b :
forall (n:Z) (i:Z) (j:Z) (k:Z), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((k = j) -> ((mat_mult (ketbra n i j) (ket n k)) = (ket n i))) /\
(~ (k = j) ->
((mat_mult (ketbra n i j) (ket n k)) = (make (power 2%Z n) 1%Z tzero))).
Axiom ketbraket :
forall (n:Z) (i:Z) (j:Z) (y:matrix t), (n >= 0%Z)%Z ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) -> (is_a_ket_l y n) ->
((mat_mult (ketbra n i j) y) = (infix_asdtdt (get y j 0%Z) (ket n i))).
Axiom ketbraket_b_gen :
forall (n:Z), (n >= 0%Z)%Z -> forall (i:Z) (j:Z) (k:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
((0%Z <= k)%Z /\ (k < (power 2%Z n))%Z) ->
((k = j) -> ((mat_mult (ketbra n i j) (ket n k)) = (ket n i))) /\
(~ (k = j) ->
((mat_mult (ketbra n i j) (ket n k)) = (make (power 2%Z n) 1%Z tzero))).
Axiom scalar_ketbra :
forall (x:matrix t) (a:t), (is_a_ketbra x) ->
is_a_ketbra (infix_asdtdt a x).
Axiom scalar_ketbra_n :
forall (x:matrix t) (a:t) (n:Z), (n >= 0%Z)%Z -> (is_a_ketbra_n x n) ->
is_a_ketbra_n (infix_asdtdt a x) n.
Axiom scalar_ketbra_size :
forall (m:matrix t) (a:t), (is_a_ketbra m) ->
((ketbra_size (infix_asdtdt a m)) = (ketbra_size m)).
Axiom scalar_valid_index :
forall (m:matrix t) (a:t) (i:Z) (j:Z), (valid_index m i j) ->
(is_a_ketbra m) -> valid_index (infix_asdtdt a m) i j.
Axiom scalar_ketbra_l :
forall (x:matrix t) (l:Z) (a:t), (is_a_ketbra_n x l) ->
is_a_ketbra_n (infix_asdtdt a x) l.
Parameter ketbra_sum:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> matrix t.
Axiom ketbra_sum_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ketbra_size (f e1)) = l)) ->
((ketbra_sum s f) = (mat_sum s f)).
Axiom ketbra_sum_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ketbra_size (f e1)) = l)) ->
forall (i:Z) (j:Z), (valid_index (ketbra_sum s f) i j) ->
((get (ketbra_sum s f) i j) = (sum s (fun (e1:a) => (get (f e1) i j)))).
Axiom ketbra_sum_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ketbra_size (f e1)) = l)) ->
is_a_ketbra (ketbra_sum s f).
Axiom ketbra_sum_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ketbra_size (f e1)) = l)) ->
forall (e1:a), (mem e1 s) ->
((ketbra_size (ketbra_sum s f)) = (ketbra_size (f e1))).
Axiom mat_sum_to_ketbra_sum :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:matrix t), ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra (f e1)) ->
(exists l:Z, forall (e1:a), (mem e1 s) -> ((ketbra_size (f e1)) = l)) ->
(a1 = (mat_sum s f)) -> (a1 = (ketbra_sum s f)).
Parameter ketbra_sum_l:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
matrix t.
Axiom ketbra_sum_l_def :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((ketbra_sum_l s f l) = (mat_sum s f)).
Axiom ketbra_sum_l_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
forall (i:Z) (j:Z), (valid_index (ketbra_sum_l s f l) i j) ->
((get (ketbra_sum_l s f l) i j) = (sum s (fun (e1:a) => (get (f e1) i j)))).
Axiom ketbra_sum_l_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
is_a_ketbra_n (ketbra_sum_l s f l) l.
Axiom ketbra_sum_l_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((ketbra_size (ketbra_sum_l s f l)) = l).
Axiom ketbra_sum_l_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((columns (ketbra_sum_l s f l)) = (power 2%Z l)).
Axiom ketbra_sum_l_spec4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((rows (ketbra_sum_l s f l)) = (power 2%Z l)).
Axiom ketbra_sum_l_rows :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((rows (ketbra_sum_l s f l)) = (power 2%Z l)).
Axiom ketbra_sum_l_value :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z) (i:Z) (j:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) ->
((get (ketbra_sum_l s f l) i j) = (sum s (fun (e1:a) => (get (f e1) i j)))).
Axiom ketbra_sum_l_columns :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((columns (ketbra_sum_l s f l)) = (power 2%Z l)).
Axiom mat_sum_to_ketbra_sum_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:matrix t) (l:Z),
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
(a1 = (mat_sum s f)) -> (a1 = (ketbra_sum s f)).
Axiom ketbra_sum_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a), ((cardinal s) > 1%Z)%Z ->
(forall (e2:a), (mem e2 s) -> is_a_ketbra (f e2)) -> (constant_size s f) ->
(mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> null_mat (f e')) ->
((ketbra_sum s f) = (f e1)).
Axiom ketbra_sum_null :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) > 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
(forall (e1:a), (mem e1 s) -> null_mat (f e1)) -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) ->
((get (ketbra_sum_l s f l) i j) = tzero).
Axiom ketbra_sum_l_null_but_maybe_one_elt :
forall {a:Type} {a_WT:WhyType a},
forall (f:a -> matrix t) (s:set a) (e1:a) (l:Z), ((cardinal s) > 1%Z)%Z ->
(l >= 0%Z)%Z -> (forall (e2:a), (mem e2 s) -> is_a_ketbra_n (f e2) l) ->
(mem e1 s) ->
(forall (e':a), (mem e' s) -> ~ (e1 = e') -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) -> ((get (f e') i j) = tzero)) ->
((ketbra_sum_l s f l) = (f e1)).
Axiom mat_mult_ketbra_sum_out :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (y:matrix t) (n:Z), (0%Z <= n)%Z ->
((cardinal s) > 0%Z)%Z -> (is_a_ket_l y n) ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) n) ->
((mat_mult (ketbra_sum_l s f n) y) =
(ket_sum_l s (fun (e1:a) => (mat_mult (f e1) y)) n)).
Axiom ketbra_sum_ketbra_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
(l >= 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
is_a_ketbra_n (ketbra_sum_l s f l) l.
Parameter add_ketbra: (matrix t) -> (matrix t) -> matrix t.
Axiom add_ketbra_def :
forall (m:matrix t) (n:matrix t), (is_a_ketbra m) -> (is_a_ketbra n) ->
((ketbra_size m) = (ketbra_size n)) -> ((add_ketbra m n) = (add_mat m n)).
Axiom add_ketbra_spec :
forall (m:matrix t) (n:matrix t), (is_a_ketbra m) -> (is_a_ketbra n) ->
((ketbra_size m) = (ketbra_size n)) -> is_a_ketbra (add_ketbra m n).
Axiom add_ketbra_spec1 :
forall (m:matrix t) (n:matrix t), (is_a_ketbra m) -> (is_a_ketbra n) ->
((ketbra_size m) = (ketbra_size n)) ->
((ketbra_size (add_ketbra m n)) = (ketbra_size m)).
Axiom add_ketbra_spec2 :
forall (m:matrix t) (n:matrix t), (is_a_ketbra m) -> (is_a_ketbra n) ->
((ketbra_size m) = (ketbra_size n)) -> forall (i:Z) (j:Z),
(valid_index (add_ketbra m n) i j) ->
((get (add_ketbra m n) i j) = (infix_pldt (get m i j) (get n i j))).
Parameter add_ketbra_l: (matrix t) -> (matrix t) -> Z -> matrix t.
Axiom add_ketbra_l_def :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ketbra_n m l) ->
(is_a_ketbra_n n l) -> ((add_ketbra_l m n l) = (add_mat m n)).
Axiom add_ketbra_l_spec :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ketbra_n m l) ->
(is_a_ketbra_n n l) -> ((add_ketbra_l m n l) = (add_ketbra m n)).
Axiom add_ketbra_l_spec1 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ketbra_n m l) ->
(is_a_ketbra_n n l) -> is_a_ketbra_n (add_ketbra_l m n l) l.
Axiom add_ketbra_l_spec2 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ketbra_n m l) ->
(is_a_ketbra_n n l) -> ((ketbra_size (add_ketbra_l m n l)) = l).
Axiom add_ketbra_l_spec3 :
forall (m:matrix t) (n:matrix t) (l:Z), (is_a_ketbra_n m l) ->
(is_a_ketbra_n n l) -> forall (i:Z) (j:Z),
((0%Z <= i)%Z /\ (i < (power 2%Z l))%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z l))%Z) ->
((get (add_ketbra_l m n l) i j) = (infix_pldt (get m i j) (get n i j))).
Axiom ketbra_sum_comp_l :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
((cardinal s) > 0%Z)%Z -> (l >= 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_ketbra_n (g e1) l) ->
((ketbra_sum_l s (fun (k:b) => (add_ketbra_l (f k) (g k) l)) l) =
(add_ketbra_l (ketbra_sum_l s f l) (ketbra_sum_l s g l) l)).
Axiom ketbra_sum_comp_l_rev :
forall {b:Type} {b_WT:WhyType b},
forall (s:set b) (f:b -> matrix t) (g:b -> matrix t) (l:Z),
((cardinal s) > 0%Z)%Z -> (l >= 0%Z)%Z ->
(forall (e1:b), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
(forall (e1:b), (mem e1 s) -> is_a_ketbra_n (g e1) l) ->
((add_ketbra_l (ketbra_sum_l s f l) (ketbra_sum_l s g l) l) =
(ketbra_sum_l s (fun (k:b) => (add_ketbra_l (f k) (g k) l)) l)).
Axiom ketbra_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((ketbra_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l) =
(infix_asdtdt a1 (ketbra_sum_l s f l))).
Axiom scal_ketbra_sum_scalar_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (b:t) (l:Z) (l':Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) ->
exists a1:t,
exists k:matrix t, ((f e1) = (infix_asdtdt a1 k)) /\ (is_a_ketbra_n k l)) ->
((cardinal s) > 0%Z)%Z -> (l = l') ->
is_a_ketbra_n (infix_asdtdt b (ketbra_sum_l s f l)) l'.
Axiom ketbra_sum_scalar_rev_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (a1:t) (l:Z), (l >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
((cardinal s) > 0%Z)%Z ->
((infix_asdtdt a1 (ketbra_sum_l s f l)) =
(ketbra_sum_l s (fun (k:a) => (infix_asdtdt a1 (f k))) l)).
Axiom ketbra_sum_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l:Z),
(l >= 0%Z)%Z -> ((cardinal s) > 0%Z)%Z -> (s = s') ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((ketbra_sum_l s f l) = (ketbra_sum_l s' g l)).
Axiom ketbra_sum_eq_gen :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (s':set a) (f:a -> matrix t) (g:a -> matrix t) (l1:Z)
(l2:Z),
(l1 >= 0%Z)%Z -> ((cardinal s) > 0%Z)%Z -> (s = s') -> (l1 = l2) ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) l1) ->
(forall (a1:a), (mem a1 s) -> ((f a1) = (g a1))) ->
((ketbra_sum_l s f l1) = (ketbra_sum_l s' g l2)).
Axiom ketbra_sum_l_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (l:Z), (l >= 0%Z)%Z ->
((cardinal s) = 1%Z) -> (is_a_ketbra_n (f (choose s)) l) ->
((ketbra_sum_l s f l) = (f (choose s))).
Axiom ketbra_sum_l_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (e1:a) (f:a -> matrix t) (l:Z), ((cardinal s) > 0%Z)%Z ->
~ (mem e1 s) -> (forall (e2:a), (mem e2 s) -> is_a_ketbra_n (f e2) l) ->
(is_a_ketbra_n (f e1) l) ->
((ketbra_sum_l (add e1 s) f l) =
(add_ketbra_l (ketbra_sum_l s f l) (f e1) l)).
Parameter mat_sum_d:
forall {a:Type} {a_WT:WhyType a}, (set a) -> (a -> matrix t) -> Z ->
Z -> matrix t.
Axiom mat_sum_d_spec :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((rows (mat_sum_d s f r c)) = r).
Axiom mat_sum_d_spec1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((columns (mat_sum_d s f r c)) = c).
Axiom mat_sum_d_spec2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum_d s f r c) i j) ->
((get (mat_sum_d s f r c) i j) = (sum s (fun (k:a) => (get (f k) i j)))).
Axiom mat_sum_d_spec3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum_d s f r c) i j) -> (0%Z <= i)%Z.
Axiom mat_sum_d_spec4 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum_d s f r c) i j) -> (i < r)%Z.
Axiom mat_sum_d_spec5 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum_d s f r c) i j) -> (0%Z <= j)%Z.
Axiom mat_sum_d_spec6 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
forall (i:Z) (j:Z), (valid_index (mat_sum_d s f r c) i j) -> (j < c)%Z.
Axiom mat_sum_d_spec7 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((cardinal s) > 0%Z)%Z -> ((mat_sum_d s f r c) = (mat_sum s f)).
Axiom mat_sum_d_rows :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((rows (mat_sum_d s f r c)) = r).
Axiom mat_sum_d_columns :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((columns (mat_sum_d s f r c)) = c).
Axiom mat_sum_d_valid_index :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(valid_index (mat_sum_d s f r c) i j) -> (0%Z <= i)%Z.
Axiom mat_sum_d_valid_index1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(valid_index (mat_sum_d s f r c) i j) -> (i < r)%Z.
Axiom mat_sum_d_valid_index2 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(valid_index (mat_sum_d s f r c) i j) -> (0%Z <= j)%Z.
Axiom mat_sum_d_valid_index3 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(valid_index (mat_sum_d s f r c) i j) -> (j < c)%Z.
Axiom mat_sum_d_valid_i :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(exists j:Z, valid_index (mat_sum_d s f r c) i j) -> (0%Z <= i)%Z.
Axiom mat_sum_d_valid_i1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(exists j:Z, valid_index (mat_sum_d s f r c) i j) ->
(i < (rows (mat_sum_d s f r c)))%Z.
Axiom mat_sum_d_valid_j :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(exists i:Z, valid_index (mat_sum_d s f r c) i j) -> (0%Z <= j)%Z.
Axiom mat_sum_d_valid_j1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
(exists i:Z, valid_index (mat_sum_d s f r c) i j) ->
(j < (columns (mat_sum_d s f r c)))%Z.
Axiom mat_sum_d_value :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z) (i:Z) (j:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((0%Z <= i)%Z /\ (i < r)%Z) -> ((0%Z <= j)%Z /\ (j < c)%Z) ->
((get (mat_sum_d s f r c) i j) = (sum s (fun (k:a) => (get (f k) i j)))).
Axiom mat_sum_to_d :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum s f) = (mat_sum_d s f r c)).
Axiom mat_sum_no_d :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s f r c) = (mat_sum s f)).
Axiom mat_sum_d_to_ket_sum_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), ((cardinal s) > 0%Z)%Z ->
(n >= 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = (power 2%Z n))) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = 1%Z)) ->
((mat_sum_d s f (power 2%Z n) 1%Z) = (ket_sum_l s f n)).
Axiom mat_sum_d_to_ketbra_sum_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = (power 2%Z n))) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = (power 2%Z n))) ->
((mat_sum_d s f (power 2%Z n) (power 2%Z n)) = (ketbra_sum_l s f n)).
Axiom ket_sum_l_to_mat_sum_d :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = (power 2%Z n))) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = 1%Z)) ->
((ket_sum_l s f n) = (mat_sum_d s f (power 2%Z n) 1%Z)).
Axiom bra_sum_l_to_mat_sum_d :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = 1%Z)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = (power 2%Z n))) ->
((bra_sum_l s f n) = (mat_sum_d s f 1%Z (power 2%Z n))).
Axiom mat_sum_d_to_bra_sum_l :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = 1%Z)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = (power 2%Z n))) ->
((bra_sum_l s f n) = (mat_sum_d s f 1%Z (power 2%Z n))).
Axiom ketbra_sum_l_to_mat_sum_d :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = (power 2%Z n))) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = (power 2%Z n))) ->
((ketbra_sum_l s f n) = (mat_sum_d s f (power 2%Z n) (power 2%Z n))).
Axiom mat_sum_d_cardone :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) = 1%Z) -> ((rows (f (choose s))) = r) ->
((columns (f (choose s))) = c) -> ((mat_sum_d s f r c) = (f (choose s))).
Axiom mat_sum_d_cardzero :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) = 0%Z) ->
((mat_sum_d s f r c) = (make r c tzero)).
Axiom mat_sum_d_eq :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (g:a -> matrix t) (r:Z) (c:Z) (r':Z)
(c':Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal s) >= 0%Z)%Z -> (r = r') ->
(c = c') -> (forall (e1:a), (mem e1 s) -> ((f e1) = (g e1))) ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s f r c) = (mat_sum_d s g r' c')).
Axiom mat_sum_d_plus_one :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> ((cardinal s) >= 1%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s f r c) =
(add_mat (f (choose s)) (mat_sum_d (remove (choose s) s) f r c))).
Axiom sum_sum_switch :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> t), ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
((sum sa (fun (a1:a) => (sum sb (f a1)))) =
(sum sb (fun (b1:b) => (sum sa (fun (a1:a) => ((f a1) b1)))))).
Parameter mat_sum_sum_d:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(set b) -> (a -> b -> matrix t) -> Z -> Z -> matrix t.
Parameter result29:
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b}, (set a) ->
(set b) -> (a -> b -> matrix t) -> Z -> Z -> a -> matrix t.
Axiom result_def29 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z) (a1:a),
((mem a1 sa) -> (((result29 sa sb f r c) a1) = (mat_sum_d sb (f a1) r c))) /\
(~ (mem a1 sa) -> (((result29 sa sb f r c) a1) = (make r c tzero))).
Axiom mat_sum_sum_d_def :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
((mat_sum_sum_d sa sb f r c) = (mat_sum_d sa (result29 sa sb f r c) r c)).
Axiom mat_sum_sum_d_spec :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
((mat_sum_sum_d sa sb f r c) =
(mat_sum_d sa (fun (a1:a) => (mat_sum_d sb (f a1) r c)) r c)).
Axiom mat_sum_sum_d_spec1 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
((rows (mat_sum_sum_d sa sb f r c)) = r).
Axiom mat_sum_sum_d_spec2 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
((columns (mat_sum_sum_d sa sb f r c)) = c).
Axiom mat_sum_sum_d_spec3 :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < r)%Z) ->
((0%Z <= j)%Z /\ (j < c)%Z) ->
((get (mat_sum_sum_d sa sb f r c) i j) =
(sum sa (fun (a1:a) => (sum sb (fun (b1:b) => (get ((f a1) b1) i j)))))).
Axiom mat_sum_sum_d_switch :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z -> ((cardinal sa) > 0%Z)%Z ->
((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((rows ((f a1) b1)) = r)) ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
((columns ((f a1) b1)) = c)) ->
((mat_sum_d sa
(fun (a1:a) => (mat_sum_d sb (fun (b1:b) => ((f a1) b1)) r c)) r c)
=
(mat_sum_d sb
(fun (b1:b) => (mat_sum_d sa (fun (a1:a) => ((f a1) b1)) r c)) r c)).
Axiom kron_assoc_mult :
forall (a:matrix t) (b:matrix t) (c:matrix t),
(((rows a) = (columns b)) /\
(((columns b) = (rows c)) /\ ((rows c) = (columns c)))) ->
(((columns a) = (rows b)) /\ ((rows b) = 1%Z)) ->
((kronecker a (mat_mult b c)) = (mat_mult (kronecker a b) c)).
Axiom mult_assoc_kron :
forall (a:matrix t) (b:matrix t) (c:matrix t),
(((rows b) = (columns c)) /\
(((columns c) = (rows a)) /\ ((rows a) = (columns a)))) ->
(((columns b) = (rows c)) /\ ((rows c) = 1%Z)) ->
((mat_mult a (kronecker b c)) = (kronecker (mat_mult a b) c)).
Axiom mat_sum_d_to_ket_sum_l1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z),
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) n) -> (0%Z <= n)%Z ->
((cardinal s) > 0%Z)%Z ->
((mat_sum_d s f (power 2%Z n) 1%Z) = (ket_sum_l s f n)).
Axiom mat_sum_d_to_ketbra_sum_l1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z),
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) n) -> (0%Z <= n)%Z ->
((cardinal s) > 0%Z)%Z ->
((mat_sum_d s f (power 2%Z n) (power 2%Z n)) = (ketbra_sum_l s f n)).
Parameter get_ket_bv1: (matrix t) -> bitvec -> t.
Axiom get_ket_bv_def1 :
forall (k:matrix t) (x:bitvec), (is_a_ket k) ->
((length x) = (ket_length k)) -> ((length x) = (ket_length k)) ->
((get_ket_bv1 k x) = (get_ket k (bv_to_int x))).
Axiom get_ket_to_get_ket_bv :
forall (k:matrix t) (i:Z) (n:Z), (is_a_ket_l k n) ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) ->
((get_ket k i) = (get_ket_bv1 k (int_to_bv i n))).
Axiom get_to_get_ket_bv :
forall (k:matrix t) (i:Z) (j:Z) (n:Z), (is_a_ket_l k n) ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (j = 0%Z) ->
((get k i j) = (get_ket_bv1 k (int_to_bv i n))).
Axiom get_ket_bv_to_get :
forall (k:matrix t) (i:Z) (j:Z) (n:Z), (is_a_ket_l k n) ->
((0%Z <= i)%Z /\ (i < (power 2%Z n))%Z) -> (j = 0%Z) ->
((get_ket_bv1 k (int_to_bv i n)) = (get k i j)).
Axiom ket_sum_l_to_mat_sum_d1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), ((cardinal s) > 0%Z)%Z ->
(0%Z <= n)%Z -> (forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) n) ->
((ket_sum_l s f n) = (mat_sum_d s f (power 2%Z n) 1%Z)).
Axiom ketbra_sum_l_to_mat_sum_d1 :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), ((cardinal s) > 0%Z)%Z ->
(0%Z <= n)%Z -> (forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) n) ->
((ketbra_sum_l s f n) = (mat_sum_d s f (power 2%Z n) (power 2%Z n))).
Axiom ket_sum_sum_as_mat :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal sa) > 0%Z)%Z -> ((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
is_a_ket_l ((f a1) b1) n) ->
((ket_sum_l sa (fun (a1:a) => (ket_sum_l sb (f a1) n)) n) =
(mat_sum_d sa (fun (a1:a) => (mat_sum_d sb (f a1) (power 2%Z n) 1%Z))
(power 2%Z n) 1%Z)).
Axiom ket_sum_sum_d_switch :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal sa) > 0%Z)%Z -> ((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
is_a_ket_l ((f a1) b1) n) ->
((ket_sum_l sa (fun (a1:a) => (ket_sum_l sb (f a1) n)) n) =
(ket_sum_l sb (fun (b1:b) => (ket_sum_l sa (fun (a1:a) => ((f a1) b1)) n))
n)).
Axiom ketbra_sum_sum_as_mat :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal sa) > 0%Z)%Z -> ((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
is_a_ketbra_n ((f a1) b1) n) ->
((ketbra_sum_l sa (fun (a1:a) => (ketbra_sum_l sb (f a1) n)) n) =
(mat_sum_d sa
(fun (a1:a) => (mat_sum_d sb (f a1) (power 2%Z n) (power 2%Z n)))
(power 2%Z n) (power 2%Z n))).
Axiom ketbra_sum_sum_d_switch :
forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (sa:set a) (sb:set b) (f:a -> b -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal sa) > 0%Z)%Z -> ((cardinal sb) > 0%Z)%Z ->
(forall (a1:a), forall (b1:b), (mem a1 sa) -> (mem b1 sb) ->
is_a_ketbra_n ((f a1) b1) n) ->
((ketbra_sum_l sa (fun (a1:a) => (ketbra_sum_l sb (f a1) n)) n) =
(ketbra_sum_l sb
(fun (b1:b) => (ketbra_sum_l sa (fun (a1:a) => ((f a1) b1)) n)) n)).
Axiom pre_reqs_of_size_range :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec) (y:bitvec), (mem e1 (n_bvs size1)) ->
(mem y (n_bvs range1)) ->
is_a_ket_l (infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))) size1.
Axiom pre_reqs_of_size_range1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec) (y:bitvec), (mem e1 (n_bvs size1)) ->
(mem y (n_bvs range1)) ->
is_a_ket_l
(infix_asdtdt (get x (bv_to_int e1) 0%Z)
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))
size1.
Axiom pre_reqs_of_size_range2 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec) (y:bitvec), (mem e1 (n_bvs size1)) ->
(mem y (n_bvs range1)) ->
is_a_ket_l
(infix_asdtdt (get x (bv_to_int e1) 0%Z)
(infix_asdtdt (pow_inv_sqrt_2 range1)
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y)))))
size1.
Axiom pre_reqs_of_size :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec), (mem e1 (n_bvs size1)) ->
is_a_ket_l
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (get x (bv_to_int e1) 0%Z)
(infix_asdtdt (pow_inv_sqrt_2 range1)
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))))
size1)
size1.
Axiom pre_reqs_of_size1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec), (mem e1 (n_bvs size1)) ->
is_a_ket_l
(infix_asdtdt (get x (bv_to_int e1) 0%Z)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))
size1))
size1.
Axiom pre_reqs_of_size2 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec), (mem e1 (n_bvs size1)) ->
is_a_ket_l
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))
size1)
size1.
Axiom pre_reqs_of_size3 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (e1:bitvec), (mem e1 (n_bvs size1)) ->
is_a_ket_l
(infix_asdtdt (get x (bv_to_int e1) 0%Z)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (pow_inv_sqrt_2 range1)
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y)))))
size1))
size1.
Axiom pre_reqs_of_range :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (y:bitvec), (mem y (n_bvs range1)) ->
is_a_ket_l
(ket_sum_l (n_bvs size1)
(fun (e1:bitvec) =>
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))
size1)
size1.
Axiom pre_reqs_of_range1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
forall (y:bitvec), (mem y (n_bvs range1)) ->
is_a_ket_l
(infix_asdtdt (get x (bv_to_int y) 0%Z)
(ket_sum_l (n_bvs size1)
(fun (e1:bitvec) =>
(infix_asdtdt (ang_exp ((a e1) y)) (bv_to_ket ((k e1) y))))
size1))
size1.
Axiom sop_angle_in :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (get x (bv_to_int z) 0%Z)
(infix_asdtdt (pow_inv_sqrt_2 range1)
(infix_asdtdt (ang_exp ((a z) y)) (bv_to_ket ((k z) y))))))
size1))
size1)).
Axiom sop_size_range :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (get x (bv_to_int z) 0%Z)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y)) (bv_to_ket ((k z) y))))
size1)))
size1))).
Axiom sop_range_size :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (get x (bv_to_int z) 0%Z)
(infix_asdtdt (ang_exp ((a z) y)) (bv_to_ket ((k z) y)))))
size1))
size1))).
Axiom sop_ketbra_in :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y))
(mat_mult (ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z)) x)))
size1))
size1))).
Axiom sop_ketbra_range_size_pre :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y))
(mat_mult (ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z)) x)))
size1))
size1))).
Axiom sop_ketbra_range_size :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (x:matrix t),
(is_a_ket_l x size1) -> (range1 >= 0%Z)%Z ->
(forall (x1:bitvec) (y:bitvec), ((length x1) = size1) ->
((length y) = range1) -> ((length ((k x1) y)) = size1)) ->
((path_sum_scheme a k size1 range1 x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(mat_mult
(infix_asdtdt (ang_exp ((a z) y))
(ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z)))
x))
size1))
size1))).
Parameter ketbra_sop:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> matrix t.
Parameter result30:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> bitvec -> bitvec -> matrix t.
Parameter result31:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> bitvec -> matrix t.
Axiom result_def30 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (z:bitvec) (y:bitvec),
(((length y) = range1) ->
(((result30 a k size1 range1 z) y) =
(infix_asdtdt (ang_exp ((a z) y))
(ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z))))) /\
(~ ((length y) = range1) ->
(((result30 a k size1 range1 z) y) = (ket size1 0%Z))).
Axiom result_def31 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (z:bitvec),
(((length z) = size1) ->
(((result31 a k size1 range1) z) =
(ketbra_sum_l (n_bvs range1) (result30 a k size1 range1 z) size1))) /\
(~ ((length z) = size1) ->
(((result31 a k size1 range1) z) = (ket size1 0%Z))).
Axiom ketbra_sop_def :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((ketbra_sop a k size1 range1) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ketbra_sum_l (n_bvs size1) (result31 a k size1 range1) size1))).
Axiom ketbra_sop_spec :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
is_a_ketbra_n (ketbra_sop a k size1 range1) size1.
Axiom ketbra_sop_spec1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((rows (ketbra_sop a k size1 range1)) = (power 2%Z size1)).
Axiom ketbra_sop_spec2 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((columns (ketbra_sop a k size1 range1)) = (power 2%Z size1)).
Axiom ketbra_sop_spec3 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((ketbra_sop a k size1 range1) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ketbra_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(ketbra_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y))
(ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z))))
size1))
size1))).
Axiom ketbra_sop_spec4 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
forall (x:matrix t), (is_a_ket_l x size1) ->
((mat_mult (ketbra_sop a k size1 range1) x) =
(path_sum_scheme a k size1 range1 x)).
Parameter ketbra_sop_rs:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> matrix t.
Parameter result32:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
bitvec -> bitvec -> matrix t.
Parameter result33:
(bitvec -> bitvec -> angle) -> (bitvec -> bitvec -> bitvec) -> Z ->
Z -> bitvec -> matrix t.
Axiom result_def32 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (y:bitvec) (z:bitvec),
(((length z) = size1) ->
(((result32 a k size1 y) z) =
(infix_asdtdt (ang_exp ((a z) y))
(ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z))))) /\
(~ ((length z) = size1) -> (((result32 a k size1 y) z) = (ket size1 0%Z))).
Axiom result_def33 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z) (y:bitvec),
(((length y) = range1) ->
(((result33 a k size1 range1) y) =
(ketbra_sum_l (n_bvs size1) (result32 a k size1 y) size1))) /\
(~ ((length y) = range1) ->
(((result33 a k size1 range1) y) = (ket size1 0%Z))).
Axiom ketbra_sop_rs_def :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((ketbra_sop_rs a k size1 range1) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ketbra_sum_l (n_bvs range1) (result33 a k size1 range1) size1))).
Axiom ketbra_sop_rs_spec :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((ketbra_sop_rs a k size1 range1) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ketbra_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(ketbra_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y))
(ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z))))
size1))
size1))).
Axiom ketbra_sop_rs_spec1 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
((ketbra_sop_rs a k size1 range1) = (ketbra_sop a k size1 range1)).
Axiom ketbra_sop_rs_spec2 :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
forall (x:matrix t), (is_a_ket_l x size1) ->
((mat_mult (ketbra_sop_rs a k size1 range1) x) =
(path_sum_scheme a k size1 range1 x)).
Axiom ketbra_sop_mult :
forall (a:bitvec -> bitvec -> angle) (k:bitvec -> bitvec -> bitvec)
(size1:Z) (range1:Z),
(size1 >= 0%Z)%Z -> (range1 >= 0%Z)%Z ->
(forall (x:bitvec) (y:bitvec), ((length x) = size1) ->
((length y) = range1) -> ((length ((k x) y)) = size1)) ->
forall (x:matrix t), (is_a_ket_l x size1) ->
((mat_mult (ketbra_sop a k size1 range1) x) =
(infix_asdtdt (pow_inv_sqrt_2 range1)
(ket_sum_l (n_bvs size1)
(fun (z:bitvec) =>
(ket_sum_l (n_bvs range1)
(fun (y:bitvec) =>
(infix_asdtdt (ang_exp ((a z) y))
(mat_mult (ketbra size1 (bv_to_int ((k z) y)) (bv_to_int z)) x)))
size1))
size1))).
Axiom correct_ketbra_sop :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:matrix t),
(is_a_ket_l x (size c)) -> (correct_path_sum c a k range1) ->
sem c x (mat_mult (ketbra_sop a k (size c) range1) x).
Axiom correct_ketbra_sop_rs :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(k:bitvec -> bitvec -> bitvec) (range1:Z) (x:matrix t),
(is_a_ket_l x (size c)) -> (correct_path_sum c a k range1) ->
sem c x (mat_mult (ketbra_sop_rs a k (size c) range1) x).
Axiom adjoint_scalar :
forall (m:matrix t) (a:t),
((adjoint (infix_asdtdt a m)) = (infix_asdtdt (conjugate a) (adjoint m))).
Axiom adjoint_real_scalar :
forall (m:matrix t) (a:t), (real_ a) ->
((adjoint (infix_asdtdt a m)) = (infix_asdtdt a (adjoint m))).
Axiom adjoint_eq :
forall (m:matrix t) (n:matrix t), (m = n) -> ((adjoint m) = (adjoint n)).
Parameter real_mat: (matrix t) -> Prop.
Axiom real_mat_def :
forall (m:matrix t), (real_mat m) -> forall (i:Z) (j:Z),
(valid_index m i j) -> real_ (get m i j).
Axiom real_mat_def1 :
forall (m:matrix t),
(forall (i:Z) (j:Z), (valid_index m i j) -> real_ (get m i j)) ->
real_mat m.
Axiom real_value :
forall (m:matrix t) (i:Z) (j:Z), (real_mat m) -> (valid_index m i j) ->
real_ (get m i j).
Axiom add_adjoint :
forall (m:matrix t) (n:matrix t), ((rows m) = (rows n)) ->
((columns m) = (columns n)) ->
((adjoint (add_mat m n)) = (add_mat (adjoint m) (adjoint n))).
Axiom sum_d_adjoint :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s (fun (e1:a) => (adjoint (f e1))) c r) =
(adjoint (mat_sum_d s f r c))).
Axiom sum_d_adjoint_rev :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (r:Z) (c:Z), (r > 0%Z)%Z ->
(c > 0%Z)%Z -> (forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((adjoint (mat_sum_d s f r c)) =
(mat_sum_d s (fun (e1:a) => (adjoint (f e1))) c r)).
Axiom ketbra_sum_l_adjoint :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ketbra_n (f e1) n) ->
((adjoint (ketbra_sum_l s f n)) =
(ketbra_sum_l s (fun (e1:a) => (adjoint (f e1))) n)).
Axiom ket_sum_l_adjoint :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (f:a -> matrix t) (n:Z), (n >= 0%Z)%Z ->
((cardinal s) > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> is_a_ket_l (f e1) n) ->
((adjoint (ket_sum_l s f n)) =
(bra_sum_l s (fun (e1:a) => (adjoint (f e1))) n)).
Axiom sum_d_scal_adjoint :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (scal:a -> t) (f:a -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s (fun (e1:a) => (infix_asdtdt (scal e1) (adjoint (f e1)))) c
r)
=
(adjoint
(mat_sum_d s (fun (e1:a) => (infix_asdtdt (conjugate (scal e1)) (f e1)))
r c))).
Axiom sum_d_scal_adjoint_ :
forall {a:Type} {a_WT:WhyType a},
forall (s:set a) (scal:a -> t) (f:a -> matrix t) (r:Z) (c:Z),
(r > 0%Z)%Z -> (c > 0%Z)%Z ->
(forall (e1:a), (mem e1 s) -> ((rows (f e1)) = r)) ->
(forall (e1:a), (mem e1 s) -> ((columns (f e1)) = c)) ->
((mat_sum_d s
(fun (e1:a) => (infix_asdtdt (conjugate (scal e1)) (adjoint (f e1)))) c
r)
=
(adjoint
(mat_sum_d s (fun (e1:a) => (infix_asdtdt (scal e1) (f e1))) r c))).
Axiom mat_mult_adjoint :
forall (m:matrix t) (n:matrix t), ((columns n) = (rows m)) ->
((mat_mult (adjoint m) (adjoint n)) = (adjoint (mat_mult n m))).
Axiom kronecker_adjoint :
forall (m:matrix t) (n:matrix t),
((kronecker (adjoint m) (adjoint n)) = (adjoint (kronecker m n))).
Axiom had_adjoint : ((adjoint (mat_sem hadamard)) = (mat_sem hadamard)).
Axiom projector_transformation :
forall (a:matrix t) (k:matrix t) (l:Z), (l >= 0%Z)%Z -> (is_a_ket_l k l) ->
(is_a_ketbra_n a l) ->
((projection (mat_mult a k)) =
(mat_mult a (mat_mult (projection k) (adjoint a)))).
Axiom prod_own_adjoint :
forall (m:matrix t), ((mat_mult m (adjoint m)) = (id_mat (rows m))).
Parameter reverse: gate -> gate.
Axiom reverse_spec :
forall (c:gate), forall (x:matrix t) (y:matrix t), (sem c x y) ->
sem (reverse c) y x.
Axiom reverse_spec1 :
forall (c:gate), forall (x:matrix t) (y:matrix t), (sem (reverse c) y x) ->
sem c x y.
Axiom reverse_spec2 :
forall (c:gate), ((mat_sem (reverse c)) = (adjoint (mat_sem c))).
Axiom are_different :
forall (a:matrix t) (b:matrix t) (i:Z) (j:Z) (c:Z) (n:Z), (0%Z <= n)%Z ->
(((rows a) = (rows b)) /\ ((rows b) = c)) ->
(((columns a) = (columns b)) /\ ((columns b) = (power 2%Z n))) ->
((0%Z <= i)%Z /\ (i < c)%Z) -> ((0%Z <= j)%Z /\ (j < (power 2%Z n))%Z) ->
~ ((get a i j) = (get b i j)) ->
exists x:matrix t,
(is_a_ket_l x n) /\
((is_a_ket_basis_elt x) /\ ~ ((mat_mult a x) = (mat_mult b x))).
Axiom mat_to_ket_eq_pre :
forall (m:matrix t) (n:matrix t) (c:Z) (size1:Z), (0%Z <= size1)%Z ->
((rows m) = c) -> ((rows n) = c) -> ((columns m) = (power 2%Z size1)) ->
((columns n) = (power 2%Z size1)) ->
(forall (x:matrix t), (is_a_ket_l x size1) -> (is_a_ket_basis_elt x) ->
((mat_mult m x) = (mat_mult n x))) ->
forall (i:Z) (j:Z), ((0%Z <= i)%Z /\ (i < c)%Z) ->
((0%Z <= j)%Z /\ (j < (power 2%Z size1))%Z) -> ((get m i j) = (get n i j)).
Axiom mat_to_ket_eq :
forall (m:matrix t) (n:matrix t) (c:Z) (size1:Z), (0%Z <= size1)%Z ->
((rows m) = c) -> ((rows n) = c) -> ((columns m) = (power 2%Z size1)) ->
((columns n) = (power 2%Z size1)) ->
(forall (x:matrix t), (is_a_ket_l x size1) -> (is_a_ket_basis_elt x) ->
((mat_mult m x) = (mat_mult n x))) ->
(m = n).
Axiom path_sum_scheme_to_mat :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a b r) -> ((mat_sem c) = (ketbra_sop a b (size c) r)).
Axiom path_sum_scheme_to_mat1 :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a b r) ->
((mat_sem c) = (ketbra_sop_rs a b (size c) r)).
Axiom mat_to_path_sum_scheme :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a b r) -> ((ketbra_sop a b (size c) r) = (mat_sem c)).
Axiom mat_to_path_sum_scheme_rev :
forall (c:gate) (a:bitvec -> bitvec -> angle)
(b:bitvec -> bitvec -> bitvec) (r:Z),
((ketbra_sop a b (size c) r) = (mat_sem c)) -> correct_path_sum c a b r.
Axiom diag_circ_to_mat :
forall (c:gate), (diag c) ->
((mat_sem c) =
(diag_mat1 (fun (i:Z) => (ang_exp ((diag_ang c) (int_to_bv i (size c)))))
(power 2%Z (size c)))).
Parameter conj_ang_func:
(bitvec -> bitvec -> angle) -> bitvec -> bitvec -> angle.
Axiom conj_ang_func_def :
forall (a:bitvec -> bitvec -> angle) (x:bitvec) (y:bitvec),
((conj_ang_func a x y) = (ang_inv ((a x) y))).
Parameter conj_func_i:
(bitvec -> bitvec -> Z -> angle) -> bitvec -> bitvec -> Z -> angle.
Axiom conj_func_i_def :
forall (a:bitvec -> bitvec -> Z -> angle) (x:bitvec) (y:bitvec) (i:Z),
((conj_func_i a x y i) = (ang_inv (((a x) y) i))).
Axiom set_correct_path_sum_reverse :
forall (c:gate) (a':bitvec -> bitvec -> angle)
(a:bitvec -> bitvec -> angle) (b:bitvec -> bitvec -> bitvec) (r:Z),
(correct_path_sum c a b r) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> (((a' x) y) = (ang_inv ((a x) y)))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> (((a x) y) = ((a y) x))) ->
(forall (x:bitvec) (y:bitvec), ((length x) = (size c)) ->
((length y) = r) -> (((b x) y) = y)) ->
correct_path_sum (reverse c) a' b r.
Axiom set_correct_path_sum_i_reverse :
forall (c:gate) (a:bitvec -> bitvec -> Z -> angle)
(a':bitvec -> bitvec -> Z -> angle) (l:Z) (h:Z)
(b:bitvec -> bitvec -> Z -> Z) (r:Z),
(correct_path_sum_i c a l h b r) ->
(forall (x:bitvec) (y:bitvec), forall (i:Z), ((length x) = (size c)) ->
((length y) = r) -> ((0%Z <= i)%Z /\ (i < (size c))%Z) ->
((((a' x) y) i) = (ang_inv (((a x) y) i)))) ->
correct_path_sum_i (reverse c) a' l h b r.
Parameter diff_pre_to_mat: Z -> matrix t.
Axiom diff_pre_to_mat_def :
forall (n:Z), (n >= 2%Z)%Z ->
((diff_pre_to_mat n) = (mat_sem (diff_pre n))).
Axiom diff_pre_to_mat_spec :
forall (n:Z), (n >= 2%Z)%Z -> ((rows (diff_pre_to_mat n)) = (power 2%Z n)).
Axiom diff_pre_to_mat_spec1 :
forall (n:Z), (n >= 2%Z)%Z ->
((columns (diff_pre_to_mat n)) = (power 2%Z n)).
Axiom diff_pre_to_mat_spec2 :
forall (n:Z), (n >= 2%Z)%Z -> is_diagonal (diff_pre_to_mat n).
Axiom diff_pre_to_mat_spec3 :
forall (n:Z), (n >= 2%Z)%Z ->
((diff_pre_to_mat n) =
(diag_mat1
(fun (x:Z) =>
(ang_exp
(ang_mult_int ang_minus_one
(ind_iproduct (fun (j:Z) => (1%Z - ((getbv (int_to_bv x n)) j))%Z) 0%Z
n))))
(power 2%Z n))).
Axiom diff_pre_to_mat_spec4 :
forall (n:Z), (n >= 2%Z)%Z ->
((diff_pre_to_mat n) =
(mat_substr (infix_asdtdt ttwo (ket_projection_basis n 0%Z))
(id_mat (power 2%Z n)))).
Parameter superposition: Z -> gate.
Axiom superposition_def :
forall (n:Z), (n >= 1%Z)%Z -> (n = 1%Z) -> ((superposition n) = hadamard).
Axiom superposition_def1 :
forall (n:Z), (n >= 1%Z)%Z -> ~ (n = 1%Z) ->
((superposition n) = (parallel (superposition (n - 1%Z)%Z) hadamard)).
Axiom superposition_spec :
forall (n:Z), (n >= 1%Z)%Z -> ((superposition n) = (repeat_had n)).
Axiom superposition_spec1 :
forall (n:Z), (n >= 1%Z)%Z ->
((pat_sem (superposition n) (ket n 0%Z)) =
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n) (fun (y0:bitvec) => (bv_to_ket y0)) n))).
Axiom superposition_spec2 :
forall (n:Z), (n >= 1%Z)%Z -> ((size (superposition n)) = n).
Axiom superposition_spec3 :
forall (n:Z), (n >= 1%Z)%Z ->
((adjoint (mat_sem (superposition n))) = (mat_sem (superposition n))).
Parameter superposition_state: Z -> matrix t.
Axiom superposition_state_def :
forall (n:Z), (n >= 1%Z)%Z ->
((superposition_state n) = (pat_sem (superposition n) (ket n 0%Z))).
Axiom superposition_state_spec :
forall (n:Z), (n >= 1%Z)%Z ->
((superposition_state n) =
(mat_mult (mat_sem (superposition n)) (ket n 0%Z))).
Axiom superposition_state_spec1 :
forall (n:Z), (n >= 1%Z)%Z ->
((superposition_state n) =
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n) (fun (y0:bitvec) => (bv_to_ket y0)) n))).
Axiom superposition_state_spec2 :
forall (n:Z), (n >= 1%Z)%Z ->
((superposition_state n) =
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (to_fset 0%Z (power 2%Z n))
((fun (y0:Z) (y1:Z) => (ket y0 y1)) n) n))).
Axiom superposition_state_spec3 :
forall (n:Z), (n >= 1%Z)%Z -> is_a_ket_l (superposition_state n) n.
Axiom ket_sum_bv_to_ints1 :
forall (n:Z) (f:bitvec -> matrix t) (g:Z -> matrix t), (n >= 0%Z)%Z ->
(forall (x:bitvec), ((length x) = n) -> ((f x) = (g (bv_to_int x)))) ->
((ket_sum_l (n_bvs n) f n) = (ket_sum_l (to_fset 0%Z (power 2%Z n)) g n)).
Parameter diff_pre_had: Z -> gate.
Axiom diff_pre_had_def :
forall (n:Z), (n >= 2%Z)%Z ->
((diff_pre_had n) = (sequence (diff_pre n) (superposition n))).
Axiom diff_pre_had_spec :
forall (n:Z), (n >= 2%Z)%Z -> ((size (diff_pre_had n)) = n).
Axiom diff_pre_had_spec1 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff_pre_had n)) =
(mat_mult (mat_sem (superposition n))
(mat_substr (infix_asdtdt ttwo (ket_projection_basis n 0%Z))
(id_mat (power 2%Z n))))).
Axiom diff_pre_had_spec2 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff_pre_had n)) =
(mat_substr
(mat_mult (mat_sem (superposition n))
(infix_asdtdt ttwo (ket_projection_basis n 0%Z)))
(mat_mult (mat_sem (superposition n)) (id_mat (power 2%Z n))))).
Axiom diff_pre_had_spec3 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff_pre_had n)) =
(mat_substr
(mat_mult (mat_sem (superposition n))
(infix_asdtdt ttwo (ket_projection_basis n 0%Z)))
(mat_sem (superposition n)))).
Parameter diff1: Z -> gate.
Axiom diff_def :
forall (n:Z), (n >= 2%Z)%Z ->
((diff1 n) = (sequence (superposition n) (diff_pre_had n))).
Axiom diff_spec3 : forall (n:Z), (n >= 2%Z)%Z -> ((size (diff1 n)) = n).
Axiom diff_spec4 :
forall (n:Z), (n >= 2%Z)%Z -> ((rows (mat_sem (diff1 n))) = (power 2%Z n)).
Axiom diff_spec5 :
forall (n:Z), (n >= 2%Z)%Z ->
((columns (mat_sem (diff1 n))) = (power 2%Z n)).
Axiom diff_spec6 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff1 n)) =
(mat_mult
(mat_substr
(mat_mult (mat_sem (superposition n))
(infix_asdtdt ttwo (ket_projection_basis n 0%Z)))
(mat_sem (superposition n)))
(mat_sem (superposition n)))).
Axiom diff_spec7 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff1 n)) =
(mat_substr
(mat_mult
(mat_mult (mat_sem (superposition n))
(infix_asdtdt ttwo (ket_projection_basis n 0%Z)))
(mat_sem (superposition n)))
(mat_mult (mat_sem (superposition n)) (mat_sem (superposition n))))).
Axiom diff_spec8 :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff1 n)) =
(mat_substr
(infix_asdtdt ttwo
(mat_mult
(mat_mult (mat_sem (superposition n)) (ket_projection_basis n 0%Z))
(mat_sem (superposition n))))
(id_mat (power 2%Z n)))).
Axiom diff_rewrite :
forall (n:Z), (n >= 2%Z)%Z ->
((mat_sem (diff1 n)) =
(mat_substr (infix_asdtdt ttwo (projection (superposition_state n)))
(id_mat (power 2%Z n)))).
Parameter discard:
(matrix t) -> (matrix t) -> (matrix t) -> Z -> Z -> matrix t.
Axiom discard_def :
forall (x:matrix t) (y:matrix t) (z:matrix t) (k:Z) (n:Z),
(is_a_ket_l x k) -> (is_a_ket_l y (n - k)%Z) -> (z = (kronecker x y)) ->
((discard x y z k n) = x).
Axiom discard_spec :
forall (x:matrix t) (y:matrix t) (z:matrix t) (k:Z) (n:Z),
(is_a_ket_l x k) -> (is_a_ket_l y (n - k)%Z) -> (z = (kronecker x y)) ->
is_a_ket_l (discard x y z k n) k.
Parameter proba_measure: (matrix t) -> Z -> Z -> t.
Axiom proba_measure_def :
forall (x:matrix t) (i:Z) (n:Z), (is_a_ket_l x n) ->
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((proba_measure x i n) = (cpower (modulus (get x i 0%Z)) 2%Z)).
Axiom proba_measure_spec :
forall (x:matrix t) (i:Z) (n:Z), (is_a_ket_l x n) ->
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((proba_measure x i n) = (cpower (modulus (get_ket x i)) 2%Z)).
Parameter proba_measure_sat_p: (matrix t) -> Z -> (Z -> bool) -> t.
Parameter result34: (matrix t) -> Z -> Z -> t.
Axiom result_def34 :
forall (x:matrix t) (n:Z) (k:Z),
(((0%Z <= k)%Z /\ (k < (power_ 2%Z n))%Z) ->
(((result34 x n) k) = (proba_measure x k n))) /\
(~ ((0%Z <= k)%Z /\ (k < (power_ 2%Z n))%Z) ->
(((result34 x n) k) = tzero)).
Axiom proba_measure_sat_p_def :
forall (x:matrix t) (n:Z) (f:Z -> bool), (is_a_ket_l x n) ->
((proba_measure_sat_p x n f) =
(sum (my_filter (to_fset 0%Z (power_ 2%Z n)) f) (result34 x n))).
Axiom proba_measure_sat_p_spec :
forall (x:matrix t) (n:Z) (f:Z -> bool), (is_a_ket_l x n) ->
((proba_measure_sat_p x n f) =
(sum (my_filter (to_fset 0%Z (power_ 2%Z n)) f)
(fun (k:Z) => (proba_measure x k n)))).
Axiom proba_measure_from_sum :
forall (x:matrix t) (i:Z) (n:Z) (f:bitvec -> t), (is_a_ket_l x n) ->
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
(x =
(ket_sum_l (n_bvs n)
(fun (k:bitvec) => (infix_asdtdt (f k) (bv_to_ket k))) n)) ->
((proba_measure x i n) = (cpower (modulus (f (int_to_bv i n))) 2%Z)).
Axiom proba_measure_sat_p_const :
forall (x:matrix t) (n:Z) (f:Z -> bool) (t1:t) (t':t), (is_a_ket_l x n) ->
(t' =
(infix_asdt t1
(i_to_t (cardinal (my_filter (to_fset 0%Z (power_ 2%Z n)) f))))) ->
(forall (i:Z), ((f i) = true) ->
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) -> ((proba_measure x i n) = t1)) ->
((proba_measure_sat_p x n f) = t').
Axiom proba_measure_from_sum_partition :
forall (x:matrix t) (s1:set Z) (s2:set Z) (i:Z) (n:Z) (scal1:t) (scal2:t)
(f1:Z -> t) (f2:Z -> t),
((union s1 s2) = (to_fset 0%Z (power 2%Z n))) ->
((inter s1 s2) = (empty : set Z)) -> (real_ scal1) -> (real_ scal2) ->
(is_a_ket_l x n) -> ((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
(x =
(add_mat
(infix_asdtdt scal1
(ket_sum_l s1 (fun (k:Z) => (infix_asdtdt (f1 k) (ket n k))) n))
(infix_asdtdt scal2
(ket_sum_l s2 (fun (k:Z) => (infix_asdtdt (f2 k) (ket n k))) n)))) ->
((mem i s1) ->
((proba_measure x i n) = (cpower (infix_asdt scal1 (f1 i)) 2%Z))) /\
(~ (mem i s1) ->
((proba_measure x i n) = (cpower (infix_asdt scal2 (f2 i)) 2%Z))).
Axiom proba_measure_from_sum_partition_gen :
forall (x:matrix t) (s1:set Z) (s2:set Z) (n:Z) (scal1:t) (scal2:t),
((union s1 s2) = (to_fset 0%Z (power 2%Z n))) ->
((inter s1 s2) = (empty : set Z)) -> (real_ scal1) -> (real_ scal2) ->
(is_a_ket_l x n) ->
(x =
(add_mat
(infix_asdtdt scal1
(ket_sum_l s1 ((fun (y0:Z) (y1:Z) => (ket y0 y1)) n) n))
(infix_asdtdt scal2
(ket_sum_l s2 ((fun (y0:Z) (y1:Z) => (ket y0 y1)) n) n)))) ->
forall (i:Z), ((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((mem i s1) -> ((proba_measure x i n) = (cpower scal1 2%Z))) /\
(~ (mem i s1) -> ((proba_measure x i n) = (cpower scal2 2%Z))).
Axiom proba_measure_from_sum_sum :
forall (x:matrix t) (l:Z) (n:Z) (f:bitvec -> bitvec -> t),
(is_a_ket_l x n) -> ((0%Z <= l)%Z /\ (l < (power_ 2%Z n))%Z) ->
(x =
(ket_sum_l (n_bvs n)
(fun (k:bitvec) =>
(ket_sum_l (n_bvs n)
(fun (l1:bitvec) => (infix_asdtdt ((f k) l1) (bv_to_ket l1))) n))
n)) ->
((proba_measure x l n) =
(cpower
(modulus (sum (n_bvs n) (fun (k:bitvec) => ((f k) (int_to_bv l n)))))
2%Z)).
Axiom proba_measure_from_scal_sum_sum :
forall (x:matrix t) (i:Z) (n:Z) (f:bitvec -> bitvec -> t) (s:t) (s2:t),
(is_a_ket_l x n) -> ((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
(real_ s) ->
(x =
(infix_asdtdt s
(ket_sum_l (n_bvs n)
(fun (k:bitvec) =>
(ket_sum_l (n_bvs n)
(fun (l:bitvec) => (infix_asdtdt ((f k) l) (bv_to_ket l))) n))
n))) ->
(s2 = (cpower s 2%Z)) ->
((proba_measure x i n) =
(infix_asdt s2
(cpower
(modulus (sum (n_bvs n) (fun (k:bitvec) => ((f k) (int_to_bv i n)))))
2%Z))).
Axiom proba_measure_from_scal_sum_sum_gen :
forall (x:matrix t) (n:Z) (f:bitvec -> bitvec -> t) (s:t) (s2:t),
(real_ s) ->
(x =
(infix_asdtdt s
(ket_sum_l (n_bvs n)
(fun (k:bitvec) =>
(ket_sum_l (n_bvs n)
(fun (l:bitvec) => (infix_asdtdt ((f k) l) (bv_to_ket l))) n))
n))) ->
(s2 = (cpower s 2%Z)) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((proba_measure x i n) =
(infix_asdt s2
(cpower
(modulus (sum (n_bvs n) (fun (k:bitvec) => ((f k) (int_to_bv i n)))))
2%Z))).
Axiom proba_measure_from_scal_sum_sum_gen1 :
forall (x:matrix t) (n:Z) (f:bitvec -> bitvec -> t) (s:t) (s2:t),
(real_ s) ->
(x =
(infix_asdtdt s
(ket_sum_l (n_bvs n)
(fun (k:bitvec) =>
(ket_sum_l (n_bvs n)
(fun (l:bitvec) => (infix_asdtdt ((f k) l) (bv_to_ket l))) n))
n))) ->
(s2 = (cpower s 2%Z)) -> forall (i:Z),
((0%Z <= i)%Z /\ (i < (power_ 2%Z n))%Z) ->
((proba_measure x i n) =
(infix_asdt s2
(cpower
(modulus
(sum (to_fset 0%Z (power_ 2%Z n))
(fun (k:Z) => ((f (int_to_bv k n)) (int_to_bv i n)))))
2%Z))).
Parameter qbit_zero: unit -> matrix t.
Axiom qbit_zero_def : forall (us:unit), ((qbit_zero us) = (ket 1%Z 0%Z)).
Axiom qbit_zero_spec : forall (us:unit), is_a_ket_l (qbit_zero us) 1%Z.
Axiom qbit_zero_spec1 : forall (us:unit), ((rows (qbit_zero us)) = 2%Z).
Axiom qbit_zero_spec2 : forall (us:unit), ((columns (qbit_zero us)) = 1%Z).
Axiom qbit_zero_spec3 :
forall (us:unit), ((get (qbit_zero us) 0%Z 0%Z) = tone).
Axiom qbit_zero_spec4 :
forall (us:unit), ((get (qbit_zero us) 1%Z 0%Z) = tzero).
Parameter qbit_one: unit -> matrix t.
Axiom qbit_one_def : forall (us:unit), ((qbit_one us) = (ket 1%Z 1%Z)).
Axiom qbit_one_spec : forall (us:unit), is_a_ket_l (qbit_one us) 1%Z.
Axiom qbit_one_spec1 : forall (us:unit), ((rows (qbit_one us)) = 2%Z).
Axiom qbit_one_spec2 : forall (us:unit), ((columns (qbit_one us)) = 1%Z).
Axiom qbit_one_spec3 :
forall (us:unit), ((get (qbit_one us) 0%Z 0%Z) = tzero).
Axiom qbit_one_spec4 :
forall (us:unit), ((get (qbit_one us) 1%Z 0%Z) = tone).
Parameter qbit_plus: unit -> matrix t.
Axiom qbit_plus_def :
forall (us:unit), ((qbit_plus us) = (pat_sem hadamard (qbit_zero tt))).
Axiom qbit_plus_spec : forall (us:unit), is_a_ket_l (qbit_plus us) 1%Z.
Axiom qbit_plus_spec1 : forall (us:unit), ((rows (qbit_plus us)) = 2%Z).
Axiom qbit_plus_spec2 : forall (us:unit), ((columns (qbit_plus us)) = 1%Z).
Axiom qbit_plus_spec3 :
forall (us:unit),
((get_ket (qbit_plus us) 0%Z) = (infix_sldt tone squarert_two)).
Axiom qbit_plus_spec4 :
forall (us:unit),
((get_ket (qbit_plus us) 1%Z) =
(prefix_mndt (infix_sldt tone squarert_two))).
Axiom qbit_plus_spec5 :
forall (us:unit),
((qbit_plus us) =
(infix_asdtdt (infix_sldt tone squarert_two)
(add_mat (ket 0%Z 1%Z) (ket 1%Z 1%Z)))).
Parameter qbit_minus: unit -> matrix t.
Axiom qbit_minus_def :
forall (us:unit), ((qbit_minus us) = (pat_sem hadamard (qbit_one tt))).
Axiom qbit_minus_spec : forall (us:unit), is_a_ket_l (qbit_minus us) 1%Z.
Axiom qbit_minus_spec1 : forall (us:unit), ((rows (qbit_minus us)) = 2%Z).
Axiom qbit_minus_spec2 : forall (us:unit), ((columns (qbit_minus us)) = 1%Z).
Axiom qbit_minus_spec3 :
forall (us:unit),
((get_ket (qbit_minus us) 0%Z) = (infix_sldt tone squarert_two)).
Axiom qbit_minus_spec4 :
forall (us:unit),
((get_ket (qbit_minus us) 1%Z) =
(prefix_mndt (infix_sldt tone squarert_two))).
Axiom qbit_minus_spec5 :
forall (us:unit),
((qbit_minus us) =
(infix_asdtdt (infix_sldt tone squarert_two)
(mat_substr (ket 0%Z 1%Z) (ket 1%Z 1%Z)))).
Axiom set_equal_qbit :
forall (a:matrix t) (b:matrix t), (is_a_ket_l a 1%Z) ->
(is_a_ket_l b 1%Z) -> ((get_ket a 0%Z) = (get_ket b 0%Z)) ->
((get_ket a 1%Z) = (get_ket b 1%Z)) -> (a = b).
Parameter xor_qbits: (matrix t) -> (matrix t) -> matrix t.
Parameter result35: (matrix t) -> (matrix t) -> Z -> t.
Axiom result_def35 :
forall (x:matrix t) (y:matrix t) (i:Z),
((i = 0%Z) ->
(((result35 x y) i) =
(infix_pldt (infix_asdt (get_ket x 0%Z) (get_ket y 0%Z))
(infix_asdt (get_ket x 1%Z) (get_ket y 1%Z))))) /\
(~ (i = 0%Z) ->
(((result35 x y) i) =
(infix_pldt (infix_asdt (get_ket x 0%Z) (get_ket y 1%Z))
(infix_asdt (get_ket x 1%Z) (get_ket y 0%Z))))).
Axiom xor_qbits_def :
forall (x:matrix t) (y:matrix t), (is_a_ket_l x 1%Z) ->
(is_a_ket_l y 1%Z) -> ((xor_qbits x y) = (make_ket 1%Z (result35 x y))).
Axiom xor_qbits_spec :
forall (x:matrix t) (y:matrix t), (is_a_ket_l x 1%Z) ->
(is_a_ket_l y 1%Z) -> is_a_ket_l (xor_qbits x y) 1%Z.
Axiom xor_qbits_spec1 :
forall (x:matrix t) (y:matrix t), (is_a_ket_l x 1%Z) ->
(is_a_ket_l y 1%Z) -> (is_a_ket_basis_elt x) -> (is_a_ket_basis_elt y) ->
((xor_qbits x y) = (ket 1%Z (xor_i (ket_to_int x) (ket_to_int y)))).
Axiom xor_qbits_spec2 :
forall (x:matrix t) (y:matrix t), (is_a_ket_l x 1%Z) ->
(is_a_ket_l y 1%Z) ->
((get_ket (xor_qbits x y) 0%Z) =
(infix_pldt (infix_asdt (get_ket x 0%Z) (get_ket y 0%Z))
(infix_asdt (get_ket x 1%Z) (get_ket y 1%Z)))).
Axiom xor_qbits_spec3 :
forall (x:matrix t) (y:matrix t), (is_a_ket_l x 1%Z) ->
(is_a_ket_l y 1%Z) ->
((get_ket (xor_qbits x y) 1%Z) =
(infix_pldt (infix_asdt (get_ket x 0%Z) (get_ket y 1%Z))
(infix_asdt (get_ket x 1%Z) (get_ket y 0%Z)))).
Axiom repeat_had_hops :
forall (n:Z), (n >= 1%Z)%Z -> ((size (repeat_had n)) = n).
Axiom repeat_had_hops1 :
forall (n:Z), (n >= 1%Z)%Z -> ((range (repeat_had n)) = n).
Axiom repeat_had_hops2 :
forall (n:Z), (n >= 1%Z)%Z -> forall (x:bitvec) (y:bitvec),
((length x) = n) -> ((length y) = n) ->
((basis_ket (repeat_had n) x y) = y).
Axiom repeat_had_hops3 :
forall (n:Z), (n >= 1%Z)%Z -> forall (x:bitvec) (y:bitvec),
((length x) = n) -> ((length y) = n) ->
((ang_ind (repeat_had n) x y) =
(int_to_ang
(ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n) 1%Z)).
Axiom repeat_had_basis :
forall (n:Z) (x:matrix t), (n >= 1%Z)%Z -> (is_a_ket_basis_elt x) ->
((ket_length x) = n) ->
sem (repeat_had n) x
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(cpower (prefix_mndt tone)
(ind_isum (fun (i:Z) => (((getbv (ket_to_bv x)) i) * ((getbv y) i))%Z)
0%Z n))
(bv_to_ket y)))
n)).
Axiom repeat_had_bv :
forall (n:Z) (x:bitvec), (n >= 1%Z)%Z -> ((length x) = n) ->
sem (repeat_had n) (bv_to_ket x)
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(cpower (prefix_mndt tone)
(ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n))
(bv_to_ket y)))
n)).
Axiom repeat_had_bv_gen :
forall (n:Z), (n >= 1%Z)%Z -> forall (x:bitvec), ((length x) = n) ->
sem (repeat_had n) (bv_to_ket x)
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(cpower (prefix_mndt tone)
(ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n))
(bv_to_ket y)))
n)).
Parameter constant_bin: (bitvec -> Z) -> Z -> Prop.
Axiom constant_bin_def :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) -> (1%Z <= n)%Z.
Axiom constant_bin_def1 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) -> forall (x:bitvec),
((length x) = n) -> (0%Z <= (f x))%Z.
Axiom constant_bin_def2 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) -> forall (x:bitvec),
((length x) = n) -> ((f x) < 2%Z)%Z.
Axiom constant_bin_def3 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) -> forall (x:bitvec),
((length x) = n) -> forall (x1:bitvec) (y:bitvec),
(((length x1) = (length y)) /\ ((length y) = n)) -> ((f x1) = (f y)).
Axiom constant_bin_def4 :
forall (f:bitvec -> Z) (n:Z),
((1%Z <= n)%Z /\
forall (x:bitvec), ((length x) = n) ->
((0%Z <= (f x))%Z /\ ((f x) < 2%Z)%Z) /\
forall (x1:bitvec) (y:bitvec),
(((length x1) = (length y)) /\ ((length y) = n)) -> ((f x1) = (f y))) ->
constant_bin f n.
Parameter balanced_bin: (bitvec -> Z) -> Z -> Prop.
Axiom balanced_bin_def :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) -> (1%Z <= n)%Z.
Axiom balanced_bin_def1 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) -> forall (x:bitvec),
((length x) = n) -> (0%Z <= (f x))%Z.
Axiom balanced_bin_def2 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) -> forall (x:bitvec),
((length x) = n) -> ((f x) < 2%Z)%Z.
Parameter fc21: (bitvec -> Z) -> bitvec -> bool.
Parameter fc22: (bitvec -> Z) -> bitvec -> bool.
Axiom fc_def21 :
forall (f:bitvec -> Z) (x:bitvec), (((fc21 f) x) = true) <-> ((f x) = 0%Z).
Axiom fc_def22 :
forall (f:bitvec -> Z) (x:bitvec), (((fc22 f) x) = true) <-> ((f x) = 1%Z).
Axiom balanced_bin_def3 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) -> forall (x:bitvec),
((length x) = n) ->
((cardinal (my_filter (n_bvs n) (fc21 f))) =
(cardinal (my_filter (n_bvs n) (fc22 f)))).
Parameter fc23: (bitvec -> Z) -> bitvec -> bool.
Axiom fc_def23 :
forall (f:bitvec -> Z) (x:bitvec), (((fc23 f) x) = true) <-> ((f x) = 1%Z).
Axiom balanced_bin_def4 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) -> forall (x:bitvec),
((length x) = n) ->
((cardinal (my_filter (n_bvs n) (fc23 f))) = (power 2%Z (n - 1%Z)%Z)).
Parameter fc24: (bitvec -> Z) -> bitvec -> bool.
Parameter fc25: (bitvec -> Z) -> bitvec -> bool.
Parameter fc26: (bitvec -> Z) -> bitvec -> bool.
Axiom fc_def24 :
forall (f:bitvec -> Z) (x:bitvec), (((fc24 f) x) = true) <-> ((f x) = 0%Z).
Axiom fc_def25 :
forall (f:bitvec -> Z) (x:bitvec), (((fc25 f) x) = true) <-> ((f x) = 1%Z).
Axiom fc_def26 :
forall (f:bitvec -> Z) (x:bitvec), (((fc26 f) x) = true) <-> ((f x) = 1%Z).
Axiom balanced_bin_def5 :
forall (f:bitvec -> Z) (n:Z),
((1%Z <= n)%Z /\
forall (x:bitvec), ((length x) = n) ->
((0%Z <= (f x))%Z /\ ((f x) < 2%Z)%Z) /\
(((cardinal (my_filter (n_bvs n) (fc24 f))) =
(cardinal (my_filter (n_bvs n) (fc25 f)))) /\
((cardinal (my_filter (n_bvs n) (fc26 f))) = (power 2%Z (n - 1%Z)%Z)))) ->
balanced_bin f n.
Parameter fc27: (bitvec -> Z) -> bitvec -> bool.
Parameter fc28: (bitvec -> Z) -> bitvec -> bool.
Axiom fc_def27 :
forall (f:bitvec -> Z) (x:bitvec), (((fc27 f) x) = true) <-> ((f x) = 0%Z).
Axiom fc_def28 :
forall (f:bitvec -> Z) (x:bitvec), (((fc28 f) x) = true) <-> ((f x) = 1%Z).
Axiom balanced_sum :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) ->
((cardinal (my_filter (n_bvs n) (fc27 f))) =
(cardinal (my_filter (n_bvs n) (fc28 f)))).
Axiom balanced_sum1 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) ->
((sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))) =
tzero).
Axiom balanced_sum2 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) ->
((modulus
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))))
= tzero).
Axiom balanced_sum3 :
forall (f:bitvec -> Z) (n:Z), (balanced_bin f n) ->
((cpower
(modulus
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))))
2%Z)
= tzero).
Axiom constant_sum :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) ->
forall (x:bitvec) (y:bitvec),
(((length x) = (length y)) /\ ((length y) = n)) -> ((f x) = (f y)).
Axiom constant_sum1 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) ->
((sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))) =
(infix_asdt (i_to_t (power 2%Z n))
(cpower (prefix_mndt tone) (f (choose (n_bvs n)))))).
Axiom constant_sum2 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) ->
((modulus
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))))
= (i_to_t (power 2%Z n))).
Axiom constant_sum3 : True.
Axiom constant_sum4 :
forall (f:bitvec -> Z) (n:Z), (constant_bin f n) ->
((cpower
(modulus
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x)))))
2%Z)
= (i_to_t (power 2%Z (n * 2%Z)%Z))).
Parameter deutsch_oracle: (bitvec -> Z) -> Z -> gate.
Axiom deutsch_oracle_spec :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
((size (deutsch_oracle f n)) = (n + 1%Z)%Z).
Axiom deutsch_oracle_spec1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
forall (x:bitvec), forall (y:matrix t), (is_a_ket_l y 1%Z) ->
sem (deutsch_oracle f n) (kronecker (bv_to_ket x) y)
(kronecker (bv_to_ket x) (xor_qbits (ket 1%Z (f x)) y)).
Axiom deutsch_oracle_spec2 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
((size (deutsch_oracle f n)) = (n + 1%Z)%Z).
Axiom deutsch_oracle_spec3 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
forall (x:bitvec), forall (y:matrix t), (is_a_ket_l y 1%Z) ->
sem (deutsch_oracle f n) (kronecker (bv_to_ket x) y)
(kronecker (bv_to_ket x) (xor_qbits (ket 1%Z (f x)) y)).
Parameter dj_pre: (bitvec -> Z) -> Z -> gate.
Axiom dj_pre_def :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
((dj_pre f n) = (sequence (repeat_had (n + 1%Z)%Z) (deutsch_oracle f n))).
Axiom dj_pre_def1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
((dj_pre f n) = (sequence (repeat_had (n + 1%Z)%Z) (deutsch_oracle f n))).
Axiom dj_pre_spec :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
((size (dj_pre f n)) = (n + 1%Z)%Z).
Axiom dj_pre_spec1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
sem (dj_pre f n) (kronecker (ket n 0%Z) (qbit_one tt))
(kronecker
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (x:bitvec) =>
(infix_asdtdt (cpower (prefix_mndt tone) (f x)) (bv_to_ket x)))
n))
(qbit_minus tt)).
Axiom dj_pre_spec2 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
((size (dj_pre f n)) = (n + 1%Z)%Z).
Axiom dj_pre_spec3 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
sem (dj_pre f n) (kronecker (ket n 0%Z) (qbit_one tt))
(kronecker
(infix_asdtdt (pow_inv_sqrt_2 n)
(ket_sum_l (n_bvs n)
(fun (x:bitvec) =>
(infix_asdtdt (cpower (prefix_mndt tone) (f x)) (bv_to_ket x)))
n))
(qbit_minus tt)).
Parameter dj_output: (bitvec -> Z) -> Z -> matrix t.
Axiom dj_output_def :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z ->
((dj_output f n) =
(ket_sum_l (n_bvs n)
(fun (x:bitvec) =>
(infix_asdtdt (cpower (prefix_mndt tone) (f x))
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(cpower (prefix_mndt tone)
(ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n))
(bv_to_ket y)))
n)))
n)).
Axiom dj_output_spec :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> is_a_ket_l (dj_output f n) n.
Axiom dj_output_spec1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z ->
((dj_output f n) =
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(sum (n_bvs n)
(fun (x:bitvec) =>
(cpower (prefix_mndt tone)
((ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n) +
(f x))%Z)))
(bv_to_ket y)))
n)).
Axiom dj_output_spec2 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z ->
((get_ket (dj_output f n) 0%Z) =
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x))))).
Parameter dj: (bitvec -> Z) -> Z -> gate.
Axiom dj_def :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
((dj f n) = (sequence (dj_pre f n) (place (repeat_had n) 0%Z (n + 1%Z)%Z))).
Axiom dj_def1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
((dj f n) = (sequence (dj_pre f n) (place (repeat_had n) 0%Z (n + 1%Z)%Z))).
Axiom dj_spec :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (constant_bin f n) ->
sem (dj f n) (kronecker (ket n 0%Z) (qbit_one tt))
(kronecker (infix_asdtdt (pow_inv_2 n) (dj_output f n)) (qbit_minus tt)).
Axiom dj_spec1 :
forall (f:bitvec -> Z) (n:Z), (1%Z <= n)%Z -> (balanced_bin f n) ->
sem (dj f n) (kronecker (ket n 0%Z) (qbit_one tt))
(kronecker (infix_asdtdt (pow_inv_2 n) (dj_output f n)) (qbit_minus tt)).
Parameter f: bitvec -> Z.
Parameter n: Z.
Axiom H : (1%Z <= n)%Z.
Axiom H1 : ~ (constant_bin f n) -> balanced_bin f n.
Axiom H2 : is_a_ket_l (dj_output f n) n.
Axiom H3 :
((dj_output f n) =
(ket_sum_l (n_bvs n)
(fun (y:bitvec) =>
(infix_asdtdt
(sum (n_bvs n)
(fun (x:bitvec) =>
(cpower (prefix_mndt tone)
((ind_isum (fun (i:Z) => (((getbv x) i) * ((getbv y) i))%Z) 0%Z n) +
(f x))%Z)))
(bv_to_ket y)))
n)).
Axiom H4 :
((get_ket (dj_output f n) 0%Z) =
(sum (n_bvs n) (fun (x:bitvec) => (cpower (prefix_mndt tone) (f x))))).
Parameter result36: t.
Axiom result_def36 : (result36 = (proba_measure (dj_output f n) 0%Z n)).
Axiom H5 : (result36 = (cpower (modulus (get_ket (dj_output f n) 0%Z)) 2%Z)).
Axiom H6 : (constant_bin f n) -> (result36 = tone).
Axiom H7 : balanced_bin f n.
(* Why3 goal *)
Theorem G : balanced_bin f n.
Proof.
Qed.
|
{"author": "Heim-AI", "repo": "qbricks.github.io", "sha": "0aed52b81eab137cb3dde15d02ed59a36e532247", "save_path": "github-repos/coq/Heim-AI-qbricks.github.io", "path": "github-repos/coq/Heim-AI-qbricks.github.io/qbricks.github.io-0aed52b81eab137cb3dde15d02ed59a36e532247/Case_studies/deutsch-jozsa/deutschmnjozsa_Deutsch_josza_G_1.v"}
|
# -*- coding: utf-8 -*-
r"""
A Francy Widget for the Jupyter Notebook.
AUTHORS ::
Odile Bénassy
"""
from ipywidgets import register
from ipywidgets.widgets.widget_string import Text
from traitlets import Any
try:
from .francy_adapter import FrancyAdapter
except:
from francy_adapter import FrancyAdapter # for doctesting
@register
class FrancyWidget(Text):
r"""
Francy widget.
Test:
>>> from networkx import Graph
>>> G = Graph([(1, 2), (2, 3), (3, 4)])
>>> w = FrancyWidget(G)
>>> w.make_json()
>>> len(w.adapter.canvas.graph.nodes)
4
"""
value = Any() # should be a networkx graph
adapter = FrancyAdapter()
def __init__(self, obj=None, title="", counter=-1, menus=[], messages=[],
node_options=None, link_options=None, **kws):
r"""
Test:
>>> from networkx import Graph
>>> G = Graph([(1, 2), (2, 3), (3, 4)])
>>> w = FrancyWidget(G)
>>> w.value.__class__
<class 'networkx.classes.graph.Graph'>
"""
super(FrancyWidget, self).__init__()
self.value = obj
self.title = title
if counter > -1:
self.adapter.counter = counter
self.test_json = False
if 'test_json' in kws and kws['test_json']:
self.test_json = True
del kws['test_json']
self.menus = menus
self.messages = messages
self.node_options = node_options # A function: node object -> dict of options
self.link_options = link_options # A function: link object -> dict of options
self.draw_kws = kws # width, height ..
self.json_data = None
def validate(self, obj, obj_class=None):
r"""
Validate object type.
"""
if self.test_json:
import json
try:
json.loads(obj)
except IOError:
return False
else:
return True
if obj_class:
return issubclass(obj.__class__, obj_class)
try:
from sage.all import SageObject
return issubclass(obj.__class__, SageObject)
except:
return False
def set_value(self, obj, **kws):
r"""
Check compatibility, then set editor value.
Test:
>>> from networkx import Graph
>>> G = Graph([(1, 2), (2, 3), (3, 4)])
>>> w = FrancyWidget()
>>> w.set_value(G)
>>> len(w.canvas_id)
32
"""
if self.value and not self.validate(obj, self.value.__class__):
raise ValueError("Object %s is not compatible." % str(obj))
self.value = obj
self.make_json()
if not self.test_json:
self.canvas_id = self.adapter.canvas.id
def make_json(self):
r"""
Make JSON output for the display.
Test:
>>> from networkx import Graph
>>> G = Graph([(1, 2), (2, 3), (3, 4)])
>>> def node_options(n):
... options = {}
... options['type'] = 'square'
... options['modal_menus'] = [{
... 'title': 'cardinality',
... 'funcname': 'cardinality',
... 'is_method': True
... }]
... return options
>>> w = FrancyWidget(G, base_id='mycanvas', title="A small, but rich graph", node_options=node_options)
>>> w.make_json()
>>> w.json_data
'{"version": "1.1.3", "mime": "application/vnd.francy+json", "canvas": {"id": "mycanvas", "title": "A small, but rich graph", "width": 800.0, "height": 100.0, "zoomToFit": true, "texTypesetting": false, "graph": {"id": "mycanvas_graph2", "simulation": true, "collapsed": true, "drag": false, "showNeighbours": false, "nodes": {"mycanvas_node3": {"id": "mycanvas_node3", "x": 0, "y": 0, "type": "square", "size": 10, "title": "1", "color": "", "highlight": true, "layer": 3, "parent": "", "menus": {"mycanvas_menu4": {"id": "mycanvas_menu4", "title": "cardinality", "callback": {"id": "mycanvas_callback4", "funcname": "cardinality", "trigger": "click", "knownArgs": ["python", "<object>"], "requiredArgs": {}}, "menus": {}, "messages": {}}}, "messages": {}, "callbacks": {}}, "mycanvas_node4": {"id": "mycanvas_node4", "x": 0, "y": 0, "type": "square", "size": 10, "title": "2", "color": "", "highlight": true, "layer": 4, "parent": "", "menus": {"mycanvas_menu5": {"id": "mycanvas_menu5", "title": "cardinality", "callback": {"id": "mycanvas_callback5", "funcname": "cardinality", "trigger": "click", "knownArgs": ["python", "<object>"], "requiredArgs": {}}, "menus": {}, "messages": {}}}, "messages": {}, "callbacks": {}}, "mycanvas_node5": {"id": "mycanvas_node5", "x": 0, "y": 0, "type": "square", "size": 10, "title": "3", "color": "", "highlight": true, "layer": 5, "parent": "", "menus": {"mycanvas_menu6": {"id": "mycanvas_menu6", "title": "cardinality", "callback": {"id": "mycanvas_callback6", "funcname": "cardinality", "trigger": "click", "knownArgs": ["python", "<object>"], "requiredArgs": {}}, "menus": {}, "messages": {}}}, "messages": {}, "callbacks": {}}, "mycanvas_node6": {"id": "mycanvas_node6", "x": 0, "y": 0, "type": "square", "size": 10, "title": "4", "color": "", "highlight": true, "layer": 6, "parent": "", "menus": {"mycanvas_menu7": {"id": "mycanvas_menu7", "title": "cardinality", "callback": {"id": "mycanvas_callback7", "funcname": "cardinality", "trigger": "click", "knownArgs": ["python", "<object>"], "requiredArgs": {}}, "menus": {}, "messages": {}}}, "messages": {}, "callbacks": {}}}, "links": {"mycanvas_edge7": {"source": "mycanvas_node3", "weight": 1, "color": "", "target": "mycanvas_node4", "id": "mycanvas_edge7"}, "mycanvas_edge8": {"source": "mycanvas_node4", "weight": 1, "color": "", "target": "mycanvas_node5", "id": "mycanvas_edge8"}, "mycanvas_edge9": {"source": "mycanvas_node5", "weight": 1, "color": "", "target": "mycanvas_node6", "id": "mycanvas_edge9"}}, "type": "undirected"}, "menus": {}, "messages": {}}}'
"""
if self.test_json:
self.json_data = self.value
else:
self.json_data = self.adapter.to_json(
self.value,
title=self.title,
menus=self.menus,
messages=self.messages,
node_options=self.node_options,
link_options=self.link_options,
**self.draw_kws
)
def _ipython_display_(self, **kws):
"""Called when `IPython.display.display` is called on the widget."""
if self._view_name is not None:
plaintext = repr(self)
if len(plaintext) > 110:
plaintext = plaintext[:110] + '…'
if not self.json_data:
self.make_json()
# The 'application/vnd.francy+json' mimetype has not been registered yet.
# See the registration process and naming convention at
# http://tools.ietf.org/html/rfc6838
# and the currently registered mimetypes at
# http://www.iana.org/assignments/media-types/media-types.xhtml.
data = {
'text/plain': plaintext,
'application/vnd.francy+json': self.json_data
}
display(data, raw=True) # noqa
self._handle_displayed(**kws)
|
{"hexsha": "5bf9c5a3f19420b36edc7a550ed4ad333ca97e21", "size": 7370, "ext": "py", "lang": "Python", "max_stars_repo_path": "francy_widget/francy_widget.py", "max_stars_repo_name": "zerline/sage-francy", "max_stars_repo_head_hexsha": "876419b73788e2e635bea2c2d4c49866e6cf8fc4", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-05-07T10:28:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-11T16:07:09.000Z", "max_issues_repo_path": "francy_widget/francy_widget.py", "max_issues_repo_name": "zerline/sage-francy", "max_issues_repo_head_hexsha": "876419b73788e2e635bea2c2d4c49866e6cf8fc4", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "francy_widget/francy_widget.py", "max_forks_repo_name": "zerline/sage-francy", "max_forks_repo_head_hexsha": "876419b73788e2e635bea2c2d4c49866e6cf8fc4", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-05-27T13:55:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-29T12:31:43.000Z", "avg_line_length": 46.6455696203, "max_line_length": 2574, "alphanum_fraction": 0.5538670285, "include": true, "reason": "from sage,from networkx", "num_tokens": 1972}
|
import torch
import random
import numpy as np
class GeneratorData(object):
def __init__(self, training_data_path, tokens=None, start_token='<',
end_token='>', max_len=120, use_cuda=None, **kwargs):
super(GeneratorData, self).__init__()
if 'cols_to_read' not in kwargs:
kwargs['cols_to_read'] = []
data = read_object_property_file(training_data_path,
**kwargs)
self.start_token = start_token
self.end_token = end_token
self.file = []
for i in range(len(data)):
if len(data[i]) <= max_len:
self.file.append(self.start_token + data[i] + self.end_token)
self.file_len = len(self.file)
self.all_characters, self.char2idx, \
self.n_characters = tokenize(self.file, tokens)
self.use_cuda = use_cuda
if self.use_cuda is None:
self.use_cuda = torch.cuda.is_available()
def load_dictionary(self, tokens, char2idx):
self.all_characters = tokens
self.char2idx = char2idx
self.n_characters = len(tokens)
def random_chunk(self):
index = random.randint(0, self.file_len-1)
return self.file[index]
def char_tensor(self, string):
tensor = torch.zeros(len(string)).long()
for c in range(len(string)):
tensor[c] = self.all_characters.index(string[c])
if self.use_cuda:
return torch.tensor(tensor).cuda()
else:
return torch.tensor(tensor)
def random_training_set(self, smiles_augmentation):
chunk = self.random_chunk()
if smiles_augmentation is not None:
chunk = '<' + smiles_augmentation.randomize_smiles(chunk[1:-1]) + '>'
inp = self.char_tensor(chunk[:-1])
target = self.char_tensor(chunk[1:])
return inp, target
def read_sdf_file(self, path, fields_to_read):
raise NotImplementedError
def update_data(self, path):
self.file, success = read_smi_file(path, unique=True)
self.file_len = len(self.file)
assert success
def read_object_property_file(path, delimiter=',', cols_to_read=[0, 1],
keep_header=False):
f = open(path, 'r')
reader = csv.reader(f, delimiter=delimiter)
data_full = np.array(list(reader))
if keep_header:
start_position = 0
else:
start_position = 1
assert len(data_full) > start_position
data = [[] for _ in range(len(cols_to_read))]
for i in range(len(cols_to_read)):
col = cols_to_read[i]
data[i] = data_full[start_position:, col]
f.close()
if len(cols_to_read) == 1:
data = data[0]
return data
def tokenize(smiles, tokens=None):
"""
Returns list of unique tokens, token-2-index dictionary and number of
unique tokens from the list of SMILES
Parameters
----------
smiles: list
list of SMILES strings to tokenize.
tokens: list, str (default None)
list of unique tokens
Returns
-------
tokens: list
list of unique tokens/SMILES alphabet.
token2idx: dict
dictionary mapping token to its index.
num_tokens: int
number of unique tokens.
"""
if tokens is None:
tokens = list(set(''.join(smiles)))
tokens = list(np.sort(tokens))
tokens = ''.join(tokens)
token2idx = dict((token, i) for i, token in enumerate(tokens))
num_tokens = len(tokens)
return tokens, token2idx, num_tokens
def estimate_and_update(generator, n_to_generate, **kwargs):
generated = []
pbar = tqdm(range(n_to_generate))
for i in pbar:
pbar.set_description("Generating molecules...")
generated.append(generator.evaluate(gen_data, predict_len=120)[1:-1])
unique_smiles = list(np.unique(generated))[1:]
return unique_smiles
|
{"hexsha": "feae7a81cc113cda5939af74bee054c649a7d587", "size": 4037, "ext": "py", "lang": "Python", "max_stars_repo_path": "ml_models/files/util_funcs.py", "max_stars_repo_name": "joeym-09/Synbiolic", "max_stars_repo_head_hexsha": "8a81e362b40b8497124318b42439df8c0e560adf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-31T03:55:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-19T15:14:01.000Z", "max_issues_repo_path": "ml_models/files/util_funcs.py", "max_issues_repo_name": "joeymach/Synbiolic", "max_issues_repo_head_hexsha": "8a81e362b40b8497124318b42439df8c0e560adf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-16T17:17:18.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T17:20:18.000Z", "max_forks_repo_path": "ml_models/files/util_funcs.py", "max_forks_repo_name": "joeymach/Synbiolic", "max_forks_repo_head_hexsha": "8a81e362b40b8497124318b42439df8c0e560adf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-04-05T18:56:34.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-31T00:33:20.000Z", "avg_line_length": 33.6416666667, "max_line_length": 81, "alphanum_fraction": 0.5987119148, "include": true, "reason": "import numpy", "num_tokens": 887}
|
"""
Utility functions related to concat
"""
import numpy as np
import pandas.core.common as com
import pandas.tslib as tslib
from pandas import compat
from pandas.compat import map
def get_dtype_kinds(l):
"""
Parameters
----------
l : list of arrays
Returns
-------
a set of kinds that exist in this list of arrays
"""
typs = set()
for arr in l:
dtype = arr.dtype
if com.is_categorical_dtype(dtype):
typ = 'category'
elif com.is_sparse(arr):
typ = 'sparse'
elif com.is_datetimetz(arr):
typ = 'datetimetz'
elif com.is_datetime64_dtype(dtype):
typ = 'datetime'
elif com.is_timedelta64_dtype(dtype):
typ = 'timedelta'
elif com.is_object_dtype(dtype):
typ = 'object'
elif com.is_bool_dtype(dtype):
typ = 'bool'
else:
typ = dtype.kind
typs.add(typ)
return typs
def _get_series_result_type(result):
"""
return appropriate class of Series concat
input is either dict or array-like
"""
if isinstance(result, dict):
# concat Series with axis 1
if all(com.is_sparse(c) for c in compat.itervalues(result)):
from pandas.sparse.api import SparseDataFrame
return SparseDataFrame
else:
from pandas.core.frame import DataFrame
return DataFrame
elif com.is_sparse(result):
# concat Series with axis 1
from pandas.sparse.api import SparseSeries
return SparseSeries
else:
from pandas.core.series import Series
return Series
def _get_frame_result_type(result, objs):
"""
return appropriate class of DataFrame-like concat
if any block is SparseBlock, return SparseDataFrame
otherwise, return 1st obj
"""
if any(b.is_sparse for b in result.blocks):
from pandas.sparse.api import SparseDataFrame
return SparseDataFrame
else:
return objs[0]
def _concat_compat(to_concat, axis=0):
"""
provide concatenation of an array of arrays each of which is a single
'normalized' dtypes (in that for example, if it's object, then it is a
non-datetimelike and provide a combined dtype for the resulting array that
preserves the overall dtype if possible)
Parameters
----------
to_concat : array of arrays
axis : axis to provide concatenation
Returns
-------
a single array, preserving the combined dtypes
"""
# filter empty arrays
# 1-d dtypes always are included here
def is_nonempty(x):
try:
return x.shape[axis] > 0
except Exception:
return True
nonempty = [x for x in to_concat if is_nonempty(x)]
# If all arrays are empty, there's nothing to convert, just short-cut to
# the concatenation, #3121.
#
# Creating an empty array directly is tempting, but the winnings would be
# marginal given that it would still require shape & dtype calculation and
# np.concatenate which has them both implemented is compiled.
typs = get_dtype_kinds(to_concat)
# these are mandated to handle empties as well
if 'datetime' in typs or 'datetimetz' in typs or 'timedelta' in typs:
return _concat_datetime(to_concat, axis=axis, typs=typs)
elif 'sparse' in typs:
return _concat_sparse(to_concat, axis=axis, typs=typs)
elif 'category' in typs:
return _concat_categorical(to_concat, axis=axis)
if not nonempty:
# we have all empties, but may need to coerce the result dtype to
# object if we have non-numeric type operands (numpy would otherwise
# cast this to float)
typs = get_dtype_kinds(to_concat)
if len(typs) != 1:
if (not len(typs - set(['i', 'u', 'f'])) or
not len(typs - set(['bool', 'i', 'u']))):
# let numpy coerce
pass
else:
# coerce to object
to_concat = [x.astype('object') for x in to_concat]
return np.concatenate(to_concat, axis=axis)
def _concat_categorical(to_concat, axis=0):
"""Concatenate an object/categorical array of arrays, each of which is a
single dtype
Parameters
----------
to_concat : array of arrays
axis : int
Axis to provide concatenation in the current implementation this is
always 0, e.g. we only have 1D categoricals
Returns
-------
Categorical
A single array, preserving the combined dtypes
"""
from pandas.core.categorical import Categorical
def convert_categorical(x):
# coerce to object dtype
if com.is_categorical_dtype(x.dtype):
return x.get_values()
return x.ravel()
if get_dtype_kinds(to_concat) - set(['object', 'category']):
# convert to object type and perform a regular concat
return _concat_compat([np.array(x, copy=False, dtype=object)
for x in to_concat], axis=0)
# we could have object blocks and categoricals here
# if we only have a single categoricals then combine everything
# else its a non-compat categorical
categoricals = [x for x in to_concat if com.is_categorical_dtype(x.dtype)]
# validate the categories
categories = categoricals[0]
rawcats = categories.categories
for x in categoricals[1:]:
if not categories.is_dtype_equal(x):
raise ValueError("incompatible categories in categorical concat")
# we've already checked that all categoricals are the same, so if their
# length is equal to the input then we have all the same categories
if len(categoricals) == len(to_concat):
# concating numeric types is much faster than concating object types
# and fastpath takes a shorter path through the constructor
return Categorical(np.concatenate([x.codes for x in to_concat],
axis=0),
rawcats, ordered=categoricals[0].ordered,
fastpath=True)
else:
concatted = np.concatenate(list(map(convert_categorical, to_concat)),
axis=0)
return Categorical(concatted, rawcats)
def union_categoricals(to_union):
"""
Combine list-like of Categoricals, unioning categories. All
must have the same dtype, and none can be ordered.
.. versionadded 0.18.2
Parameters
----------
to_union : list-like of Categoricals
Returns
-------
Categorical
A single array, categories will be ordered as they
appear in the list
Raises
------
TypeError
If any of the categoricals are ordered or all do not
have the same dtype
ValueError
Emmpty list of categoricals passed
"""
from pandas import Index, Categorical
if len(to_union) == 0:
raise ValueError('No Categoricals to union')
first = to_union[0]
if any(c.ordered for c in to_union):
raise TypeError("Can only combine unordered Categoricals")
if not all(com.is_dtype_equal(c.categories.dtype, first.categories.dtype)
for c in to_union):
raise TypeError("dtype of categories must be the same")
cats = first.categories
unique_cats = cats.append([c.categories for c in to_union[1:]]).unique()
categories = Index(unique_cats)
new_codes = []
for c in to_union:
indexer = categories.get_indexer(c.categories)
new_codes.append(indexer.take(c.codes))
codes = np.concatenate(new_codes)
return Categorical(codes, categories=categories, ordered=False,
fastpath=True)
def _concat_datetime(to_concat, axis=0, typs=None):
"""
provide concatenation of an datetimelike array of arrays each of which is a
single M8[ns], datetimet64[ns, tz] or m8[ns] dtype
Parameters
----------
to_concat : array of arrays
axis : axis to provide concatenation
typs : set of to_concat dtypes
Returns
-------
a single array, preserving the combined dtypes
"""
def convert_to_pydatetime(x, axis):
# coerce to an object dtype
# if dtype is of datetimetz or timezone
if x.dtype.kind == com._NS_DTYPE.kind:
if getattr(x, 'tz', None) is not None:
x = x.asobject.values
else:
shape = x.shape
x = tslib.ints_to_pydatetime(x.view(np.int64).ravel())
x = x.reshape(shape)
elif x.dtype == com._TD_DTYPE:
shape = x.shape
x = tslib.ints_to_pytimedelta(x.view(np.int64).ravel())
x = x.reshape(shape)
if axis == 1:
x = np.atleast_2d(x)
return x
if typs is None:
typs = get_dtype_kinds(to_concat)
# must be single dtype
if len(typs) == 1:
if 'datetimetz' in typs:
# datetime with no tz should be stored as "datetime" in typs,
# thus no need to care
# we require ALL of the same tz for datetimetz
tzs = set([str(x.tz) for x in to_concat])
if len(tzs) == 1:
from pandas.tseries.index import DatetimeIndex
new_values = np.concatenate([x.tz_localize(None).asi8
for x in to_concat])
return DatetimeIndex(new_values, tz=list(tzs)[0])
elif 'datetime' in typs:
new_values = np.concatenate([x.view(np.int64) for x in to_concat],
axis=axis)
return new_values.view(com._NS_DTYPE)
elif 'timedelta' in typs:
new_values = np.concatenate([x.view(np.int64) for x in to_concat],
axis=axis)
return new_values.view(com._TD_DTYPE)
# need to coerce to object
to_concat = [convert_to_pydatetime(x, axis) for x in to_concat]
return np.concatenate(to_concat, axis=axis)
def _concat_sparse(to_concat, axis=0, typs=None):
"""
provide concatenation of an sparse/dense array of arrays each of which is a
single dtype
Parameters
----------
to_concat : array of arrays
axis : axis to provide concatenation
typs : set of to_concat dtypes
Returns
-------
a single array, preserving the combined dtypes
"""
from pandas.sparse.array import SparseArray, _make_index
def convert_sparse(x, axis):
# coerce to native type
if isinstance(x, SparseArray):
x = x.get_values()
x = x.ravel()
if axis > 0:
x = np.atleast_2d(x)
return x
if typs is None:
typs = com.get_dtype_kinds(to_concat)
if len(typs) == 1:
# concat input as it is if all inputs are sparse
# and have the same fill_value
fill_values = set(c.fill_value for c in to_concat)
if len(fill_values) == 1:
sp_values = [c.sp_values for c in to_concat]
indexes = [c.sp_index.to_int_index() for c in to_concat]
indices = []
loc = 0
for idx in indexes:
indices.append(idx.indices + loc)
loc += idx.length
sp_values = np.concatenate(sp_values)
indices = np.concatenate(indices)
sp_index = _make_index(loc, indices, kind=to_concat[0].sp_index)
return SparseArray(sp_values, sparse_index=sp_index,
fill_value=to_concat[0].fill_value)
# input may be sparse / dense mixed and may have different fill_value
# input must contain sparse at least 1
sparses = [c for c in to_concat if com.is_sparse(c)]
fill_values = [c.fill_value for c in sparses]
sp_indexes = [c.sp_index for c in sparses]
# densify and regular concat
to_concat = [convert_sparse(x, axis) for x in to_concat]
result = np.concatenate(to_concat, axis=axis)
if not len(typs - set(['sparse', 'f', 'i'])):
# sparsify if inputs are sparse and dense numerics
# first sparse input's fill_value and SparseIndex is used
result = SparseArray(result.ravel(), fill_value=fill_values[0],
kind=sp_indexes[0])
else:
# coerce to object if needed
result = result.astype('object')
return result
|
{"hexsha": "53db9ddf79a5c277d004ba0f8f22512c4bc9949a", "size": 12481, "ext": "py", "lang": "Python", "max_stars_repo_path": "pandas/types/concat.py", "max_stars_repo_name": "ranaroussi/pandas", "max_stars_repo_head_hexsha": "8f8d75d315f5a61bbf2060ff821bff9b282a1582", "max_stars_repo_licenses": ["PSF-2.0", "Apache-2.0", "BSD-2-Clause", "MIT", "BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-30T14:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-30T14:53:47.000Z", "max_issues_repo_path": "pandas/types/concat.py", "max_issues_repo_name": "ranaroussi/pandas", "max_issues_repo_head_hexsha": "8f8d75d315f5a61bbf2060ff821bff9b282a1582", "max_issues_repo_licenses": ["PSF-2.0", "Apache-2.0", "BSD-2-Clause", "MIT", "BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pandas/types/concat.py", "max_forks_repo_name": "ranaroussi/pandas", "max_forks_repo_head_hexsha": "8f8d75d315f5a61bbf2060ff821bff9b282a1582", "max_forks_repo_licenses": ["PSF-2.0", "Apache-2.0", "BSD-2-Clause", "MIT", "BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-30T14:53:50.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-30T14:53:50.000Z", "avg_line_length": 31.6776649746, "max_line_length": 79, "alphanum_fraction": 0.6118099511, "include": true, "reason": "import numpy", "num_tokens": 2868}
|
// Copyright (c) 2019 Graphcore Ltd. All rights reserved.
#define BOOST_TEST_MODULE ScatterTest
#include <poplibs_support/TestDevice.hpp>
#include <iostream>
#include <boost/test/unit_test.hpp>
#include <poplar/Engine.hpp>
#include <popops/ElementWise.hpp>
#include <popops/Scatter.hpp>
#include <popops/codelets.hpp>
#include <poputil/TileMapping.hpp>
#include <poputil/exceptions.hpp>
using namespace poplar;
using namespace poplar::program;
using namespace poputil;
using namespace popops;
using namespace poplibs_support;
template <typename T, std::size_t N1, std::size_t N2, std::size_t N3>
std::array<T, N1> deviceScatter(
std::array<T, N1> in, std::vector<std::size_t> in_shape,
std::array<int, N2> indices, std::vector<std::size_t> indices_shape,
std::array<T, N3> updates, std::vector<std::size_t> updates_shape,
std::size_t index_vector_dim, std::vector<unsigned> update_window_dims,
std::vector<std::size_t> insert_window_dims,
std::vector<unsigned> scatter_dims_to_operand_dims) {
auto device = createTestDevice(TEST_TARGET, 1, 4);
Graph graph(device.getTarget());
auto seq = Sequence();
popops::addCodelets(graph);
Tensor tIn = graph.addVariable(equivalent_device_type<T>().value, in_shape);
Tensor tIndices =
graph.addVariable(equivalent_device_type<int>().value, indices_shape);
Tensor tUpdates =
graph.addVariable(equivalent_device_type<T>().value, updates_shape);
poputil::mapTensorLinearly(graph, tIn);
poputil::mapTensorLinearly(graph, tIndices);
poputil::mapTensorLinearly(graph, tUpdates);
BOOST_REQUIRE_EQUAL(tIn.numElements(), N1);
BOOST_REQUIRE_EQUAL(tIndices.numElements(), N2);
BOOST_REQUIRE_EQUAL(tUpdates.numElements(), N3);
popops::UpdateComputationFunc update = [](Graph &g, Tensor &a, Tensor &b,
Sequence &prog) {
return add(g, a, b, prog);
};
scatter(graph, tIn, tIndices, tUpdates, index_vector_dim, update_window_dims,
insert_window_dims, scatter_dims_to_operand_dims, update, seq);
graph.createHostWrite("in", tIn);
graph.createHostWrite("indices", tIndices);
graph.createHostWrite("update", tUpdates);
graph.createHostRead("out", tIn);
std::array<T, N1> out;
Engine eng(graph, seq);
device.bind([&](const Device &d) {
eng.load(d);
eng.writeTensor("in", in.data(), in.data() + in.size());
eng.writeTensor("indices", indices.data(), indices.data() + indices.size());
eng.writeTensor("update", updates.data(), updates.data() + updates.size());
eng.run();
eng.readTensor("out", out.data(), out.data() + out.size());
});
return out;
}
// Test that the scatter sums the elements of the update tensor
BOOST_AUTO_TEST_CASE(ScatterUpdateTestCase0) {
std::array<int, 1> operand = {0};
std::array<int, 9> indices = {0, 0, 0, 0, 0, 0, 0, 0, 0};
std::array<int, 9> updates = {1, 2, 3, 4, 5, 6, 7, 8, 9};
std::array<int, 1> result = {45};
BOOST_TEST(deviceScatter(operand, {1}, indices, {9}, updates, {9}, 1, {1},
{0}, {0}) == result,
boost::test_tools::per_element());
}
|
{"hexsha": "6665f3b1ec124d81c8051e4c6421b5a652432460", "size": 3128, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/popops/ScatterUpdateTest.cpp", "max_stars_repo_name": "graphcore/poplibs", "max_stars_repo_head_hexsha": "3fe5a3ecafe995eddb72675d1b4a7af8a622009e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 95.0, "max_stars_repo_stars_event_min_datetime": "2020-07-06T17:11:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T14:42:28.000Z", "max_issues_repo_path": "tests/popops/ScatterUpdateTest.cpp", "max_issues_repo_name": "giantchen2012/poplibs", "max_issues_repo_head_hexsha": "2bc6b6f3d40863c928b935b5da88f40ddd77078e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/popops/ScatterUpdateTest.cpp", "max_forks_repo_name": "giantchen2012/poplibs", "max_forks_repo_head_hexsha": "2bc6b6f3d40863c928b935b5da88f40ddd77078e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 14.0, "max_forks_repo_forks_event_min_datetime": "2020-07-15T12:32:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-26T14:58:45.000Z", "avg_line_length": 35.5454545455, "max_line_length": 80, "alphanum_fraction": 0.6870204604, "num_tokens": 858}
|
// Copyright (c) 2018-present Baidu, Inc. All Rights Reserved.
//
// 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.
#include "cluster_manager.h"
#include "table_manager.h"
#include <boost/algorithm/string.hpp>
#include <gflags/gflags.h>
#include "meta_server.h"
#include "region_manager.h"
#include "meta_util.h"
#include "meta_rocksdb.h"
namespace baikaldb {
DEFINE_int32(migrate_percent, 60, "migrate percent. default:60%");
DEFINE_int32(error_judge_percent, 10, "error judge percen. default:10");
DEFINE_int32(error_judge_number, 3, "error judge number. default:3");
DEFINE_int32(disk_used_percent, 80, "disk used percent. default:80%");
DECLARE_int32(store_heart_beat_interval_us);
DECLARE_int32(store_dead_interval_times);
DECLARE_int32(store_faulty_interval_times);
DECLARE_string(default_logical_room);
DECLARE_string(default_physical_room);
void ClusterManager::process_cluster_info(google::protobuf::RpcController* controller,
const pb::MetaManagerRequest* request,
pb::MetaManagerResponse* response,
google::protobuf::Closure* done) {
brpc::ClosureGuard done_guard(done);
uint64_t log_id = 0;
if (controller != NULL) {
brpc::Controller* cntl =
static_cast<brpc::Controller*>(controller);
if (cntl->has_log_id()) {
log_id = cntl->log_id();
}
}
switch (request->op_type()) {
case pb::OP_ADD_LOGICAL:
case pb::OP_DROP_LOGICAL: {
if (!request->has_logical_rooms()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no logic room", request->op_type(), log_id);
return;
}
_meta_state_machine->process(controller, request, response, done_guard.release());
return;
}
case pb::OP_ADD_PHYSICAL:
case pb::OP_DROP_PHYSICAL:{
if (!request->has_physical_rooms()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no physical room", request->op_type(), log_id);
return;
}
_meta_state_machine->process(controller, request, response, done_guard.release());
return;
}
case pb::OP_ADD_INSTANCE:
case pb::OP_DROP_INSTANCE:
case pb::OP_UPDATE_INSTANCE: {
if (!request->has_instance()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no instance info", request->op_type(), log_id);
return;
}
_meta_state_machine->process(controller, request, response, done_guard.release());
return;
}
case pb::OP_MOVE_PHYSICAL: {
if (!request->has_move_physical_request()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no move physical request", request->op_type(), log_id);
return;
}
_meta_state_machine->process(controller, request, response, done_guard.release());
return;
}
default:{
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "wrong op_type", request->op_type(), log_id);
return;
}
}
}
void ClusterManager::add_logical(const pb::MetaManagerRequest& request, braft::Closure* done) {
pb::LogicalRoom pb_logical;
//校验合法性,构造rocksdb里的value
for (auto add_room : request.logical_rooms().logical_rooms()) {
if (_logical_physical_map.count(add_room)) {
DB_WARNING("request logical room:%s has been existed", add_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "phyical room already exist");
return;
}
pb_logical.add_logical_rooms(add_room);
}
for (auto& already_room : _logical_physical_map) {
pb_logical.add_logical_rooms(already_room.first);
}
// 构造 rocksdb的key和value
std::string value;
if (!pb_logical.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request:%s",
request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
auto ret = MetaRocksdb::get_instance()->put_meta_info(construct_logical_key(), value);
if (ret < 0) {
DB_FATAL("add phyical room:%s to rocksdb fail", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
BAIDU_SCOPED_LOCK(_physical_mutex);
for (auto add_room : request.logical_rooms().logical_rooms()) {
_logical_physical_map[add_room] = std::set<std::string>();
}
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("add logical room success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::drop_logical(const pb::MetaManagerRequest& request, braft::Closure* done) {
auto tmp_map = _logical_physical_map;
for (auto drop_room : request.logical_rooms().logical_rooms()) {
if (!_logical_physical_map.count(drop_room)) {
DB_WARNING("request logical room:%s not existed", drop_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical room not exist");
return;
}
if (_logical_physical_map[drop_room].size() != 0) {
DB_WARNING("request logical room:%s has physical room", drop_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical has physical");
return;
}
tmp_map.erase(drop_room);
}
std::vector<std::string> drop_logical_keys;
for (auto drop_room : request.logical_rooms().logical_rooms()) {
drop_logical_keys.push_back(construct_physical_key(drop_room));
}
pb::LogicalRoom pb_logical;
for (auto& logical_room : tmp_map) {
pb_logical.add_logical_rooms(logical_room.first);
}
std::string value;
if (!pb_logical.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
auto ret = MetaRocksdb::get_instance()->write_meta_info(
std::vector<std::string>{construct_logical_key()},
std::vector<std::string>{value},
drop_logical_keys);
if (ret < 0) {
DB_WARNING("drop logical room:%s to rocksdb fail", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
BAIDU_SCOPED_LOCK(_physical_mutex);
_logical_physical_map = tmp_map;
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("drop logical room success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::add_physical(const pb::MetaManagerRequest& request, braft::Closure* done) {
auto& logical_physical_room = request.physical_rooms();
std::string logical_room = logical_physical_room.logical_room();
//逻辑机房不存在则报错,需要去添加逻辑机房
if (!_logical_physical_map.count(logical_room)) {
DB_WARNING("logical room:%s not exist", logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical not exist");
return;
}
pb::PhysicalRoom pb_physical;
pb_physical.set_logical_room(logical_room);
for (auto& add_room : logical_physical_room.physical_rooms()) {
if (_physical_info.find(add_room) != _physical_info.end()) {
DB_WARNING("physical room:%s already exist", add_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical already exist");
return;
}
pb_physical.add_physical_rooms(add_room);
}
for (auto& already_room : _logical_physical_map[logical_room]) {
pb_physical.add_physical_rooms(already_room);
}
//写入rocksdb中
std::string value;
if (!pb_physical.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request: %s", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
auto ret = MetaRocksdb::get_instance()->put_meta_info(construct_physical_key(logical_room), value);
if (ret < 0) {
DB_WARNING("add logical room: %s to rocksdb fail",
request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
{
BAIDU_SCOPED_LOCK(_physical_mutex);
for (auto& add_room : logical_physical_room.physical_rooms()) {
_logical_physical_map[logical_room].insert(add_room);
_physical_info[add_room] = logical_room;
}
}
{
BAIDU_SCOPED_LOCK(_instance_mutex);
for (auto& add_room : logical_physical_room.physical_rooms()) {
_physical_instance_map[add_room] = std::set<std::string>();
}
}
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("add physical room success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::drop_physical(const pb::MetaManagerRequest& request, braft::Closure* done) {
auto& logical_physical_room = request.physical_rooms();
std::string logical_room = logical_physical_room.logical_room();
//逻辑机房不存在则报错
if (!_logical_physical_map.count(logical_room)) {
DB_WARNING("logical room:%s not exist", logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical not exist");
return;
}
auto tmp_physical_rooms = _logical_physical_map[logical_room];
for (auto drop_room : logical_physical_room.physical_rooms()) {
//物理机房不存在
if (_physical_info.find(drop_room) == _physical_info.end()) {
DB_WARNING("physical room:%s not exist", drop_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical not exist");
return;
}
if (_physical_info[drop_room] != logical_room) {
DB_WARNING("physical room:%s not belong to logical_room:%s",
drop_room.c_str(), logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical not exist");
return;
}
//物理机房下不能有实例
if (_physical_instance_map.count(drop_room) > 0
&& _physical_instance_map[drop_room].size() != 0) {
DB_WARNING("physical room:%s has instance", drop_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical has instance");
return;
}
tmp_physical_rooms.erase(drop_room);
}
pb::PhysicalRoom pb_physical;
pb_physical.set_logical_room(logical_room);
for (auto& left_room : tmp_physical_rooms) {
pb_physical.add_physical_rooms(left_room);
}
//写入rocksdb中
std::string value;
if (!pb_physical.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
// write date to rocksdb
auto ret = MetaRocksdb::get_instance()->put_meta_info(construct_physical_key(logical_room), value);
if (ret < 0) {
DB_WARNING("add phyical room:%s to rocksdb fail",
request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
{
BAIDU_SCOPED_LOCK(_physical_mutex);
for (auto& drop_room : logical_physical_room.physical_rooms()) {
_physical_info.erase(drop_room);
_logical_physical_map[logical_room].erase(drop_room);
}
}
{
BAIDU_SCOPED_LOCK(_instance_mutex);
for (auto& drop_room : logical_physical_room.physical_rooms()) {
_physical_instance_map.erase(drop_room);
}
}
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("drop physical room success, request:%s", request.ShortDebugString().c_str());
}
//MetaServer内部自己调用自己的这个接口,也可以作为外部接口使用
void ClusterManager::add_instance(const pb::MetaManagerRequest& request, braft::Closure* done) {
auto& instance_info = const_cast<pb::InstanceInfo&>(request.instance());
std::string address = instance_info.address();
std::string physical_room = instance_info.physical_room();
if (!instance_info.has_physical_room() || instance_info.physical_room().size() == 0) {
auto ret = get_physical_room(address, physical_room);
if (ret < 0) {
DB_WARNING("get physical room fail when add instance, instance:%s", address.c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "instance to hostname fail");
return;
}
}
instance_info.set_physical_room(physical_room);
if (_physical_info.find(physical_room) != _physical_info.end()) {
instance_info.set_logical_room(_physical_info[physical_room]);
} else {
DB_FATAL("get logical room for physical room: %s fail", physical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "physical to logical fail");
return;
}
//合法性检查
//物理机房不存在
if (_physical_info.find(physical_room) == _physical_info.end()) {
DB_WARNING("physical room:%s not exist, instance:%s",
physical_room.c_str(),
address.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical room not exist");
return;
}
//实例已经存在
if (_instance_info.find(address) != _instance_info.end()) {
DB_WARNING("instance:%s has already exist", address.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "instance already exist");
return;
}
//写入rocksdb中
std::string value;
if (!instance_info.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
// write date to rocksdb
auto ret = MetaRocksdb::get_instance()->put_meta_info(construct_instance_key(address), value);
if (ret < 0) {
DB_WARNING("add instance:%s to rocksdb fail", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
BAIDU_SCOPED_LOCK(_instance_mutex);
_instance_physical_map[address] = physical_room;
_physical_instance_map[physical_room].insert(address);
Instance instance_mem(instance_info);
_instance_info[address] = instance_mem;
if (_instance_regions_map.find(address) == _instance_regions_map.end()) {
_instance_regions_map[address] = std::unordered_map<int64_t, std::vector<int64_t>>{};
}
if (_instance_regions_count_map.find(address) == _instance_regions_count_map.end()) {
_instance_regions_count_map[address] = std::unordered_map<int64_t, int64_t>{};
}
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("add instance success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::drop_instance(const pb::MetaManagerRequest& request, braft::Closure* done) {
std::string address = request.instance().address();
//合法性检查
//实例不存在
if (_instance_info.find(address) == _instance_info.end()) {
DB_WARNING("instance:%s not exist", address.c_str());
//IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "instance not exist");
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
return;
}
std::string physical_room = _instance_info[address].physical_room;
// write date to rocksdb
auto ret = MetaRocksdb::get_instance()->delete_meta_info(
std::vector<std::string>{construct_instance_key(address)});
if (ret < 0) {
DB_WARNING("drop instance:%s to rocksdb fail, err_mes:%s", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存值
BAIDU_SCOPED_LOCK(_instance_mutex);
_instance_physical_map.erase(address);
_instance_info.erase(address);
_instance_regions_map.erase(address);
_instance_regions_count_map.erase(address);
if (_physical_instance_map.find(physical_room) != _physical_instance_map.end()) {
_physical_instance_map[physical_room].erase(address);
}
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("drop instance success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::update_instance(const pb::MetaManagerRequest& request, braft::Closure* done) {
std::string address = request.instance().address();
//实例不存在
if (_instance_info.find(address) == _instance_info.end()) {
DB_WARNING("instance:%s not exist", address.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "instance not exist");
return;
}
auto& instance_info = const_cast<pb::InstanceInfo&>(request.instance());
if (!instance_info.has_capacity()) {
instance_info.set_capacity(_instance_info[address].capacity);
}
if (!instance_info.has_used_size()) {
instance_info.set_used_size(_instance_info[address].used_size);
}
if (!instance_info.has_resource_tag()) {
instance_info.set_resource_tag(_instance_info[address].resource_tag);
}
//这两个信息不允许改
instance_info.set_status(_instance_info[address].instance_status.state);
instance_info.set_physical_room(_instance_info[address].physical_room);
instance_info.set_logical_room(_physical_info[_instance_info[address].physical_room]);
std::string value;
if (!instance_info.SerializeToString(&value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
// write date to rocksdb
auto ret = MetaRocksdb::get_instance()->put_meta_info(construct_instance_key(address), value);
if (ret < 0) {
DB_WARNING("add phyical room:%s to rocksdb fail", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
BAIDU_SCOPED_LOCK(_instance_mutex);
_instance_info[address].capacity = instance_info.capacity();
_instance_info[address].used_size = instance_info.used_size();
_instance_info[address].resource_tag = instance_info.resource_tag();
IF_DONE_SET_RESPONSE(done, pb::SUCCESS, "success");
DB_NOTICE("modify tage success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::move_physical(const pb::MetaManagerRequest& request, braft::Closure* done) {
std::string physical_room = request.move_physical_request().physical_room();
std::string new_logical_room = request.move_physical_request().new_logical_room();
std::string old_logical_room = request.move_physical_request().old_logical_room();
if (!_logical_physical_map.count(new_logical_room)) {
DB_WARNING("new logical room:%s not exist", new_logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical not exist");
return;
}
if (!_logical_physical_map.count(old_logical_room)) {
DB_WARNING("old logical room:%s not exist", old_logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "logical not exist");
return;
}
if (!_physical_info.count(physical_room)) {
DB_WARNING("physical room:%s not exist", physical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR, "physical room not exist");
return;
}
if (_physical_info[physical_room] != old_logical_room) {
DB_WARNING("physical room:%s not belong to old logical room:%s",
physical_room.c_str(), old_logical_room.c_str());
IF_DONE_SET_RESPONSE(done, pb::INPUT_PARAM_ERROR,
"physical room not belong to old logical room");
return;
}
std::vector<std::string> put_keys;
std::vector<std::string> put_values;
pb::PhysicalRoom old_physical_pb;
old_physical_pb.set_logical_room(old_logical_room);
for (auto& physical : _logical_physical_map[old_logical_room]) {
if (physical != physical_room) {
old_physical_pb.add_physical_rooms(physical);
}
}
std::string old_physical_value;
if (!old_physical_pb.SerializeToString(&old_physical_value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
put_keys.push_back(construct_physical_key(old_logical_room));
put_values.push_back(old_physical_value);
pb::PhysicalRoom new_physical_pb;
new_physical_pb.set_logical_room(new_logical_room);
for (auto& physical : _logical_physical_map[new_logical_room]) {
new_physical_pb.add_physical_rooms(physical);
}
new_physical_pb.add_physical_rooms(physical_room);
std::string new_physical_value;
if (!new_physical_pb.SerializeToString(&new_physical_value)) {
DB_WARNING("request serializeToArray fail, request:%s",request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::PARSE_TO_PB_FAIL, "serializeToArray fail");
return;
}
put_keys.push_back(construct_physical_key(new_logical_room));
put_values.push_back(new_physical_value);
auto ret = MetaRocksdb::get_instance()->put_meta_info(put_keys, put_values);
if (ret < 0) {
DB_WARNING("logic move room:%s to rocksdb fail", request.ShortDebugString().c_str());
IF_DONE_SET_RESPONSE(done, pb::INTERNAL_ERROR, "write db fail");
return;
}
//更新内存信息
BAIDU_SCOPED_LOCK(_physical_mutex);
_physical_info[physical_room] = new_logical_room;
_logical_physical_map[new_logical_room].insert(physical_room);
_logical_physical_map[old_logical_room].erase(physical_room);
DB_NOTICE("move physical success, request:%s", request.ShortDebugString().c_str());
}
void ClusterManager::set_instance_migrate(const pb::MetaManagerRequest* request,
pb::MetaManagerResponse* response,
uint64_t log_id) {
response->set_op_type(request->op_type());
response->set_errcode(pb::SUCCESS);
response->set_errmsg("PROCESSING");
if (_meta_state_machine != NULL && !_meta_state_machine->is_leader()) {
ERROR_SET_RESPONSE(response, pb::NOT_LEADER, "not leader", request->op_type(), log_id)
response->set_leader(butil::endpoint2str(_meta_state_machine->get_leader()).c_str());
return;
}
if (!request->has_instance()) {
//ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no instance", request->op_type(), log_id)
response->set_errmsg("ALLOWED");
return;
}
std::string instance = request->instance().address();
auto ret = set_migrate_for_instance(instance);
if (ret < 0) {
response->set_errmsg("ALLOWED");
return;
}
std::vector<int64_t> region_ids;
RegionManager::get_instance()->get_region_ids(instance, region_ids);
if (region_ids.size() == 0) {
response->set_errmsg("ALLOWED");
return;
}
//RegionManager::get_instance()->delete_all_region_for_store(instance, pb::MIGRATE);
}
void ClusterManager::set_instance_full(const pb::MetaManagerRequest* request,
pb::MetaManagerResponse* response,
uint64_t log_id) {
response->set_op_type(request->op_type());
response->set_errcode(pb::SUCCESS);
response->set_errmsg("sucess");
if (_meta_state_machine != NULL && !_meta_state_machine->is_leader()) {
ERROR_SET_RESPONSE(response, pb::NOT_LEADER, "not leader", request->op_type(), log_id)
response->set_leader(butil::endpoint2str(_meta_state_machine->get_leader()).c_str());
return;
}
if (!request->has_instance()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no instance", request->op_type(), log_id)
response->set_errmsg("no instance");
return;
}
std::string instance = request->instance().address();
auto ret = set_full_for_instance(instance);
if (ret < 0) {
response->set_errmsg("instance not exist");
return;
}
}
void ClusterManager::set_instance_no_full(const pb::MetaManagerRequest* request,
pb::MetaManagerResponse* response,
uint64_t log_id) {
response->set_op_type(request->op_type());
response->set_errcode(pb::SUCCESS);
response->set_errmsg("sucess");
if (_meta_state_machine != NULL && !_meta_state_machine->is_leader()) {
ERROR_SET_RESPONSE(response, pb::NOT_LEADER, "not leader", request->op_type(), log_id)
response->set_leader(butil::endpoint2str(_meta_state_machine->get_leader()).c_str());
return;
}
if (!request->has_instance()) {
ERROR_SET_RESPONSE(response, pb::INPUT_PARAM_ERROR, "no instance", request->op_type(), log_id)
response->set_errmsg("no instance");
return;
}
std::string instance = request->instance().address();
auto ret = set_no_full_for_instance(instance);
if (ret < 0) {
response->set_errmsg("instance not exist");
return;
}
}
void ClusterManager::process_baikal_heartbeat(const pb::BaikalHeartBeatRequest* /*request*/,
pb::BaikalHeartBeatResponse* response) {
auto idc_info_ptr = response->mutable_idc_info();
{
BAIDU_SCOPED_LOCK(_physical_mutex);
for (auto& logical_physical_mapping : _logical_physical_map) {
auto logical_physical_map = idc_info_ptr->add_logical_physical_map();
logical_physical_map->set_logical_room(logical_physical_mapping.first);
for (auto& physical_room : logical_physical_mapping.second) {
logical_physical_map->add_physical_rooms(physical_room);
}
}
}
{
BAIDU_SCOPED_LOCK(_instance_mutex);
for (auto& instance_physical_pair : _instance_physical_map) {
auto instance = idc_info_ptr->add_instance_infos();
instance->set_address(instance_physical_pair.first);
instance->set_physical_room(instance_physical_pair.second);
}
}
}
void ClusterManager::process_instance_heartbeat_for_store(const pb::InstanceInfo& instance_heart_beat) {
auto ret = update_instance_info(instance_heart_beat);
if (ret == 0) {
return;
}
//构造请求
pb::MetaManagerRequest request;
request.set_op_type(pb::OP_ADD_INSTANCE);
pb::InstanceInfo* instance_info = request.mutable_instance();
*instance_info = instance_heart_beat;
process_cluster_info(NULL, &request, NULL, NULL);
}
void ClusterManager::process_peer_heartbeat_for_store(const pb::StoreHeartBeatRequest* request,
pb::StoreHeartBeatResponse* response) {
std::string instance = request->instance_info().address();
std::string logical_room = get_logical_room(instance);
std::string resource_tag = request->instance_info().resource_tag();
std::unordered_map<int64_t, std::vector<int64_t>> table_regions;
std::unordered_map<int64_t, int64_t> table_region_counts;
if (!request->has_need_peer_balance() || !request->need_peer_balance()) {
return;
}
for (auto& peer_info : request->peer_infos()) {
table_regions[peer_info.table_id()].push_back(peer_info.region_id());
}
for (auto& table_region : table_regions) {
table_region_counts[table_region.first] = table_region.second.size();
}
set_instance_regions(instance, table_regions, table_region_counts);
if (!_meta_state_machine->whether_can_decide()) {
DB_WARNING("meta state machine can not make decision, resource_tag: %s, instance: %s",
resource_tag.c_str(), instance.c_str());
return;
}
if (!_meta_state_machine->get_load_balance(resource_tag)) {
DB_WARNING("meta state machine close peer load balance, resource_tag: %s, instance: %s",
resource_tag.c_str(), instance.c_str());
return;
}
DB_WARNING("peer load balance, instance_info: %s, resource_tag: %s",
instance.c_str(), resource_tag.c_str());
int64_t instance_count_for_logical = get_instance_count(resource_tag, logical_room);
int64_t instance_count = get_instance_count(resource_tag);
//peer均衡是先增加后减少, 代表这个表需要有多少个region先add_peer
std::unordered_map<int64_t, int64_t> add_peer_counts;
std::unordered_map<int64_t, std::string> logical_rooms;
std::unordered_map<int64_t, int64_t> table_average_counts;
for (auto& table_region : table_regions) {
int64_t average_peer_count = INT_FAST64_MAX;
int64_t table_id = table_region.first;
int64_t total_peer_count;
bool replica_dists = TableManager::get_instance()->whether_replica_dists(table_id);
if (replica_dists) {
total_peer_count = get_peer_count(table_id, logical_room);
} else {
total_peer_count = get_peer_count(table_id);
}
int64_t total_instance_count = 0;
if (replica_dists) {
total_instance_count = instance_count_for_logical;
} else {
total_instance_count = instance_count;
}
if (total_instance_count != 0) {
average_peer_count = total_peer_count / total_instance_count;
}
if (total_instance_count != 0 && total_peer_count % total_instance_count != 0) {
average_peer_count++;
}
if (table_region.second.size() > (size_t)(average_peer_count + average_peer_count * 5 / 100)) {
add_peer_counts[table_id] = table_region.second.size() - average_peer_count;
table_average_counts[table_id] = average_peer_count;
if (replica_dists) {
logical_rooms[table_id] = logical_room;
} else {
logical_rooms[table_id] = "";
}
}
}
for (auto& add_peer_count : add_peer_counts) {
DB_WARNING("instance: %s should add peer count for peer_load_balance, "
"table_id: %ld, add_peer_count: %ld, logical_room: %s",
instance.c_str(),
add_peer_count.first, add_peer_count.second, logical_rooms[add_peer_count.first].c_str());
}
if (add_peer_counts.size() > 0) {
RegionManager::get_instance()->peer_load_balance(add_peer_counts,
table_regions,
instance,
resource_tag,
logical_rooms,
table_average_counts);
} else {
DB_WARNING("instance: %s has been peer_load_balance, no need migrate", instance.c_str());
}
}
void ClusterManager::store_healthy_check_function() {
//判断全部以resource_tag的维度独立判断
std::unordered_map<std::string, int64_t> total_store_num;
std::unordered_map<std::string, int64_t> faulty_store_num;
std::unordered_map<std::string, int64_t> dead_store_num;
std::unordered_map<std::string, std::vector<std::string>> dead_stores;
std::unordered_map<std::string, std::vector<std::string>> full_stores;
std::unordered_map<std::string, std::vector<std::string>> migrate_stores;
{
BAIDU_SCOPED_LOCK(_instance_mutex);
for (auto& instance_pair : _instance_info) {
auto& status = instance_pair.second.instance_status;
std::string resource_tag = instance_pair.second.resource_tag;
total_store_num[resource_tag]++;
if (status.state == pb::MIGRATE) {
migrate_stores[resource_tag].push_back(instance_pair.first);
continue;
}
int64_t last_timestamp = status.timestamp;
if ((butil::gettimeofday_us() - last_timestamp) >
FLAGS_store_heart_beat_interval_us * FLAGS_store_dead_interval_times) {
status.state = pb::DEAD;
dead_stores[resource_tag].push_back(instance_pair.first);
DB_WARNING("instance:%s is dead, resource_tag: %s", instance_pair.first.c_str(), resource_tag.c_str());
std::vector<int64_t> region_ids;
RegionManager::get_instance()->get_region_ids(instance_pair.first, region_ids);
if (region_ids.size() != 0) {
dead_store_num[resource_tag]++;
}
continue;
}
if ((butil::gettimeofday_us() - last_timestamp) >
FLAGS_store_heart_beat_interval_us * FLAGS_store_faulty_interval_times) {
status.state = pb::FAULTY;
DB_WARNING("instance:%s is faulty, resource_tag: %s", instance_pair.first.c_str(), resource_tag.c_str());
faulty_store_num[resource_tag]++;
continue;
}
//如果实例状态都正常的话,再判断是否因为容量问题需要做迁移
//if (instance.capacity == 0) {
// DB_FATAL("instance:%s capactiy is 0", instance.address.c_str());
// continue;
//}
//暂时不考虑容量问题,该检查先关闭(liuhuicong)
//if (instance.used_size * 100 / instance.capacity >=
// FLAGS_migrate_percent) {
// DB_WARNING("instance:%s is full", instance_pair.first.c_str());
// full_stores.push_back(instance_pair.first);
//}
}
}
//防止误判,比例过大,则暂停操作
for (auto& dead_store_pair : dead_stores) {
std::string resource_tag = dead_store_pair.first;
if (total_store_num.find(resource_tag) == total_store_num.end()) {
continue;
}
if ((dead_store_num[resource_tag] + faulty_store_num[resource_tag]) * 100
/ total_store_num[resource_tag] >= FLAGS_error_judge_percent
&& (dead_store_num[resource_tag] + faulty_store_num[resource_tag]) >= FLAGS_error_judge_number) {
DB_FATAL("has too much dead and faulty instance, may be error judge, resource_tag: %s", resource_tag.c_str());
for (auto& dead_store : dead_store_pair.second) {
RegionManager::get_instance()->print_region_ids(dead_store);
}
dead_stores[resource_tag].clear();
migrate_stores[resource_tag].clear();
continue;
}
}
//如果store实例死掉,则删除region
for (auto& store_pair : dead_stores) {
for (auto& store : store_pair.second) {
DB_WARNING("store:%s is dead, resource_tag: %s",
store.c_str(), store_pair.first.c_str());
if (_meta_state_machine->get_migrate(store_pair.first)) {
//RegionManager::get_instance()->add_peer_for_dead_store(store, pb::DEAD);
RegionManager::get_instance()->delete_all_region_for_store(store, pb::DEAD);
}
}
}
for (auto& store_pair : migrate_stores) {
for (auto& store : store_pair.second) {
DB_WARNING("store:%s is migrating, resource_tag: %s",
store.c_str(), store_pair.first.c_str());
if (_meta_state_machine->get_migrate(store_pair.first)) {
//RegionManager::get_instance()->add_peer_for_dead_store(store, pb::MIGRATE);
RegionManager::get_instance()->delete_all_region_for_store(store, pb::MIGRATE);
}
}
}
//若实例满,则做实例迁移
//for (auto& full_store : full_stores) {
// DB_FATAL("store:%s is full, resource_tag", full_store.second.c_str(),
// full_store.first.c_str());
// SchemaManager->migirate_region_for_store(full_store);
//}
}
//从少于平均peer数量的实例中随机选择一个
//如果average_count == 0, 则选择最少数量peer的实例返回
int ClusterManager::select_instance_min(const std::string& resource_tag,
const std::set<std::string>& exclude_stores,
int64_t table_id,
const std::string& logical_room,
std::string& selected_instance,
int64_t average_count) {
selected_instance.clear();
BAIDU_SCOPED_LOCK(_instance_mutex);
if (_instance_info.size() == 0) {
DB_FATAL("there is no instance");
return -1;
}
int64_t max_region_count = INT_FAST64_MAX;
std::vector<std::string> candicate_instances;
for (auto& instance_count : _instance_regions_count_map) {
std::string instance = instance_count.first;
if (false == whether_legal_for_select_instance(instance, resource_tag, exclude_stores, logical_room)) {
continue;
}
if (instance_count.second.find(table_id) == instance_count.second.end()) {
if (average_count == 0) {
selected_instance = instance;
break;
} else {
candicate_instances.push_back(instance);
continue;
}
}
if (average_count != 0 && instance_count.second[table_id] < average_count) {
candicate_instances.push_back(instance);
}
if (instance_count.second[table_id] < max_region_count) {
selected_instance = instance;
max_region_count = instance_count.second[table_id];
}
}
//从小于平均peer数量的实例中随机选择一个
if (candicate_instances.size() != 0) {
size_t random_index = butil::fast_rand() % candicate_instances.size();
selected_instance = candicate_instances[random_index];
}
if (selected_instance.size() == 0) {
return -1;
}
_instance_regions_count_map[selected_instance][table_id]++;
DB_WARNING("select instance min, resource_tag: %s, table_id: %ld, logical_room: %s,"
" average_count: %ld, candicate_instance_size: %d, selected_instance: %s",
resource_tag.c_str(), table_id, logical_room.c_str(), average_count,
candicate_instances.size(), selected_instance.c_str());
return 0;
}
//todo, 暂时未考虑机房,后期需要考虑尽量不放在同一个机房
int ClusterManager::select_instance_rolling(const std::string& resource_tag,
const std::set<std::string>& exclude_stores,
const std::string& logical_room,
std::string& selected_instance) {
selected_instance.clear();
BAIDU_SCOPED_LOCK(_instance_mutex);
if (_instance_info.size() == 0) {
DB_FATAL("there is no instance");
return -1;
}
auto iter = _instance_info.find(_last_rolling_instance);
//取出迭代器的下一个元素
if (iter == _instance_info.end() || (++iter) == _instance_info.end()) {
iter = _instance_info.begin();
}
size_t instance_count = _instance_info.size();
size_t rolling_times = 0;
for (; rolling_times < instance_count; ++iter, ++rolling_times) {
if (iter == _instance_info.end()) {
iter = _instance_info.begin();
}
if (false == whether_legal_for_select_instance(iter->first, resource_tag, exclude_stores, logical_room)) {
continue;
}
//选择该实例
selected_instance = iter->first;
//更新last_rolling_instance
_last_rolling_instance = selected_instance;
break;
}
if (selected_instance.empty()) {
DB_FATAL("select instance fail, has no legal store, resource_tag:%s", resource_tag.c_str());
return -1;
}
return 0;
}
int ClusterManager::load_snapshot() {
_physical_info.clear();
_logical_physical_map.clear();
_instance_physical_map.clear();
_physical_instance_map.clear();
_instance_info.clear();
_instance_regions_map.clear();
_instance_regions_count_map.clear();
DB_WARNING("cluster manager begin load snapshot");
{
BAIDU_SCOPED_LOCK(_physical_mutex);
_physical_info[FLAGS_default_physical_room] =
FLAGS_default_logical_room;
_logical_physical_map[FLAGS_default_logical_room] =
std::set<std::string>{FLAGS_default_physical_room};
}
{
BAIDU_SCOPED_LOCK(_instance_mutex);
_physical_instance_map[FLAGS_default_logical_room] = std::set<std::string>();
}
//创建一个snapshot
rocksdb::ReadOptions read_options;
read_options.prefix_same_as_start = true;
read_options.total_order_seek = false;
RocksWrapper* db = RocksWrapper::get_instance();
std::unique_ptr<rocksdb::Iterator> iter(
db->new_iterator(read_options, db->get_meta_info_handle()));
iter->Seek(MetaServer::CLUSTER_IDENTIFY);
std::string logical_prefix = MetaServer::CLUSTER_IDENTIFY;
logical_prefix += MetaServer::LOGICAL_CLUSTER_IDENTIFY + MetaServer::LOGICAL_KEY;
std::string physical_prefix = MetaServer::CLUSTER_IDENTIFY;
physical_prefix += MetaServer::PHYSICAL_CLUSTER_IDENTIFY;
std::string instance_prefix = MetaServer::CLUSTER_IDENTIFY;
instance_prefix += MetaServer::INSTANCE_CLUSTER_IDENTIFY;
int ret = 0;
for (; iter->Valid(); iter->Next()) {
if (iter->key().starts_with(instance_prefix)) {
ret = load_instance_snapshot(instance_prefix, iter->key().ToString(), iter->value().ToString());
} else if (iter->key().starts_with(physical_prefix)) {
ret = load_physical_snapshot(physical_prefix, iter->key().ToString(), iter->value().ToString());
} else if (iter->key().starts_with(logical_prefix)) {
ret = load_logical_snapshot(logical_prefix, iter->key().ToString(), iter->value().ToString());
} else {
DB_FATAL("unsupport cluster info when load snapshot, key:%s", iter->key().data());
}
if (ret != 0) {
DB_FATAL("ClusterManager load snapshot fail, key:%s", iter->key().data());
return -1;
}
}
return 0;
}
bool ClusterManager::whether_legal_for_select_instance(
const std::string& candicate_instance,
const std::string& resource_tag,
const std::set<std::string>& exclude_stores,
const std::string& logical_room) {
if (_instance_info.find(candicate_instance) == _instance_info.end()) {
return false;
}
if (logical_room.size() != 0
&& _instance_info[candicate_instance].logical_room != logical_room) {
return false;
}
if (_instance_info[candicate_instance].instance_status.state != pb::NORMAL
|| _instance_info[candicate_instance].resource_tag != resource_tag
|| _instance_info[candicate_instance].capacity == 0) {
return false;
}
if (exclude_stores.count(candicate_instance) != 0) {
return false;
}
if ((_instance_info[candicate_instance].used_size * 100 / _instance_info[candicate_instance].capacity) >
FLAGS_disk_used_percent) {
DB_WARNING("instance:%s left size is not enough, used_size:%ld, capactity:%ld",
candicate_instance.c_str(),
_instance_info[candicate_instance].used_size,
_instance_info[candicate_instance].capacity);
return false;
}
return true;
}
int ClusterManager::load_instance_snapshot(const std::string& instance_prefix,
const std::string& key,
const std::string& value) {
std::string address(key, instance_prefix.size());
pb::InstanceInfo instance_pb;
if (!instance_pb.ParseFromString(value)) {
DB_FATAL("parse from pb fail when load instance snapshot, key:%s", key.c_str());
return -1;
}
DB_WARNING("instance_pb:%s", instance_pb.ShortDebugString().c_str());
std::string physical_room = instance_pb.physical_room();
if (physical_room.size() == 0) {
instance_pb.set_physical_room(FLAGS_default_physical_room);
}
if (!instance_pb.has_logical_room()) {
if (_physical_info.find(physical_room) != _physical_info.end()) {
instance_pb.set_logical_room(_physical_info[physical_room]);
} else {
//TODO 是否需要出错
DB_FATAL("get logical room for physical room: %s fail", physical_room.c_str());
}
}
BAIDU_SCOPED_LOCK(_instance_mutex);
_instance_info[address] = Instance(instance_pb);
_instance_physical_map[address] = instance_pb.physical_room();
_physical_instance_map[instance_pb.physical_room()].insert(address);
if (_instance_regions_map.find(address) == _instance_regions_map.end()) {
_instance_regions_map[address] = std::unordered_map<int64_t, std::vector<int64_t>>{};
}
if (_instance_regions_count_map.find(address) == _instance_regions_count_map.end()) {
_instance_regions_count_map[address] = std::unordered_map<int64_t, int64_t>{};
}
return 0;
}
int ClusterManager::load_physical_snapshot(const std::string& physical_prefix,
const std::string& key,
const std::string& value) {
pb::PhysicalRoom physical_logical_pb;
if (!physical_logical_pb.ParseFromString(value)) {
DB_FATAL("parse from pb fail when load physical snapshot, key:%s", key.c_str());
return -1;
}
DB_WARNING("physical_logical_info:%s", physical_logical_pb.ShortDebugString().c_str());
BAIDU_SCOPED_LOCK(_physical_mutex);
std::string logical_room = physical_logical_pb.logical_room();
std::set<std::string> physical_rooms;
for (auto& physical_room : physical_logical_pb.physical_rooms()) {
physical_rooms.insert(physical_room);
_physical_info[physical_room] = logical_room;
_physical_instance_map[physical_room] = std::set<std::string>{};
}
_logical_physical_map[logical_room] = physical_rooms;
return 0;
}
int ClusterManager::load_logical_snapshot(const std::string& logical_prefix,
const std::string& key,
const std::string& value) {
pb::LogicalRoom logical_info;
if (!logical_info.ParseFromString(value)) {
DB_FATAL("parse from pb fail when load logical snapshot, key:%s", key.c_str());
return -1;
}
DB_WARNING("logical_info:%s", logical_info.ShortDebugString().c_str());
BAIDU_SCOPED_LOCK(_physical_mutex);
for (auto logical_room : logical_info.logical_rooms()) {
_logical_physical_map[logical_room] = std::set<std::string>{};
}
return 0;
}
}//namespace
/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
|
{"hexsha": "80c7a81cebe88680b1c2df0722aee29b62599f9c", "size": 47670, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/meta_server/cluster_manager.cpp", "max_stars_repo_name": "lvxinup/BaikalDB", "max_stars_repo_head_hexsha": "e1ca1e273156e64fd0c3aef047d6d9b639be0c7b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-12-12T02:57:32.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-12T02:57:32.000Z", "max_issues_repo_path": "src/meta_server/cluster_manager.cpp", "max_issues_repo_name": "lvxinup/BaikalDB", "max_issues_repo_head_hexsha": "e1ca1e273156e64fd0c3aef047d6d9b639be0c7b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/meta_server/cluster_manager.cpp", "max_forks_repo_name": "lvxinup/BaikalDB", "max_forks_repo_head_hexsha": "e1ca1e273156e64fd0c3aef047d6d9b639be0c7b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8870056497, "max_line_length": 122, "alphanum_fraction": 0.6532829872, "num_tokens": 10927}
|
# Create by Packetsss
# Personal use is allowed
# Commercial use is prohibited
r"""
USAGE:
python .\utils\plot.py --log-dir "path/to/log
"""
import argparse
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from typing import Callable, List, Optional, Tuple
from stable_baselines3.common.monitor import load_results
X_TIMESTEPS = "timesteps"
X_EPISODES = "episodes"
X_WALLTIME = "walltime_hrs"
POSSIBLE_X_AXES = [X_TIMESTEPS, X_EPISODES, X_WALLTIME]
EPISODES_WINDOW = 100
def moving_average(values, window):
"""
Smooth values by doing a moving average
:param values: (numpy array)
:param window: (int)
:return: (numpy array)
"""
weights = np.repeat(1.0, window) / window
return np.convolve(values, weights, 'valid')
def simple_plot_results(log_folder, title='Learning Curve'):
"""
plot the results
:param log_folder: (str) the save location of the results to plot
:param title: (str) the title of the task to plot
"""
x, y = ts2xy(load_results(log_folder), 'timesteps')
print(y[0])
y = moving_average(y, window=50)
# Truncate x
x = x[len(x) - len(y):]
fig = plt.figure(title)
plt.plot(x, y)
plt.xlabel('Number of Timesteps')
plt.ylabel('Rewards')
plt.title(title + " Smoothed")
plt.show()
def rolling_window(array: np.ndarray, window: int) -> np.ndarray:
"""
Apply a rolling window to a np.ndarray
:param array: the input Array
:param window: length of the rolling window
:return: rolling window on the input array
"""
shape = array.shape[:-1] + (array.shape[-1] - window + 1, window)
strides = array.strides + (array.strides[-1],)
return np.lib.stride_tricks.as_strided(array, shape=shape, strides=strides)
def window_func(var_1: np.ndarray, var_2: np.ndarray, window: int, func: Callable) -> Tuple[np.ndarray, np.ndarray]:
"""
Apply a function to the rolling window of 2 arrays
:param var_1: variable 1
:param var_2: variable 2
:param window: length of the rolling window
:param func: function to apply on the rolling window on variable 2 (such as np.mean)
:return: the rolling output with applied function
"""
var_2_window = rolling_window(var_2, window)
function_on_var2 = func(var_2_window, axis=-1)
return var_1[window - 1 :], function_on_var2
def ts2xy(data_frame: pd.DataFrame, x_axis: str) -> Tuple[np.ndarray, np.ndarray]:
"""
Decompose a data frame variable to x ans ys
:param data_frame: the input data
:param x_axis: the axis for the x and y output
(can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
:return: the x and y output
"""
if x_axis == X_TIMESTEPS:
x_var = np.cumsum(data_frame.l.values)
y_var = data_frame.r.values
elif x_axis == X_EPISODES:
x_var = np.arange(len(data_frame))
y_var = data_frame.r.values
elif x_axis == X_WALLTIME:
# Convert to hours
x_var = data_frame.t.values / 3600.0
y_var = data_frame.r.values
else:
raise NotImplementedError
return x_var, y_var
def plot_curves(
xy_list: List[Tuple[np.ndarray, np.ndarray]], x_axis: str, title: str, use_line: bool, figsize: Tuple[int, int] = (8, 6)
) -> None:
"""
plot the curves
:param xy_list: the x and y coordinates to plot
:param x_axis: the axis for the x and y output
(can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
:param title: the title of the plot
:param figsize: Size of the figure (width, height)
"""
plt.figure(title, figsize=figsize)
max_x = max(xy[0][-1] for xy in xy_list)
min_x = 0
for (_, (x, y)) in enumerate(xy_list):
if use_line:
plt.plot(x, y, color="#8fc5e3", linewidth=10)
else:
plt.scatter(x, y, s=3, color="#8fc5e3")
# Do not plot the smoothed curve at all if the timeseries is shorter than window size.
# Compute and plot rolling mean with window of size EPISODE_WINDOW
x, y_mean = window_func(x, y, EPISODES_WINDOW, np.mean)
plt.plot(x, y_mean, color="#3882ab", linewidth=2.0)
plt.xlim(min_x, max_x)
plt.title(title)
plt.xlabel(x_axis)
plt.ylabel("Episode Rewards")
plt.tight_layout()
def plot_results(
dirs: List[str], num_timesteps: Optional[int], x_axis: str, task_name: str, use_line: bool, figsize: Tuple[int, int] = (8, 6)
) -> None:
"""
Plot the results using csv files from ``Monitor`` wrapper.
:param dirs: the save location of the results to plot
:param num_timesteps: only plot the points below this value
:param x_axis: the axis for the x and y output
(can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
:param task_name: the title of the task to plot
:param figsize: Size of the figure (width, height)
"""
data_frames = []
for folder in dirs:
data_frame = load_results(folder)
if num_timesteps is not None:
data_frame = data_frame[data_frame.l.cumsum() <= num_timesteps]
data_frames.append(data_frame)
xy_list = [ts2xy(data_frame, x_axis) for data_frame in data_frames]
plot_curves(xy_list, x_axis, title=task_name, use_line=use_line, figsize=figsize)
plt.show()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='A3C')
parser.add_argument(
'--log-dir',
type=str,
default="logs/td3")
parser.add_argument(
'--simple',
type=bool,
default=False)
parser.add_argument(
'--use-line',
type=bool,
default=False)
args = parser.parse_args()
if args.simple:
simple_plot_results(args.log_dir)
else:
plot_results([args.log_dir], np.inf, X_TIMESTEPS, "Model Performance", args.use_line)
|
{"hexsha": "c7e5a6480f073f80efdc6a9b52328dd3861c8425", "size": 5942, "ext": "py", "lang": "Python", "max_stars_repo_path": "Python Tutorial Reinforcement Learning/9_muzero/games/utils/plot.py", "max_stars_repo_name": "PaulPan00/donkey_wrapper", "max_stars_repo_head_hexsha": "a03cf0f42f65625fbce792b06c98acd153c5d6c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-03-26T01:42:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-11T16:17:42.000Z", "max_issues_repo_path": "Python Tutorial Reinforcement Learning/9_muzero/games/utils/plot.py", "max_issues_repo_name": "packetsss/Python", "max_issues_repo_head_hexsha": "a03cf0f42f65625fbce792b06c98acd153c5d6c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Python Tutorial Reinforcement Learning/9_muzero/games/utils/plot.py", "max_forks_repo_name": "packetsss/Python", "max_forks_repo_head_hexsha": "a03cf0f42f65625fbce792b06c98acd153c5d6c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2021-04-06T06:55:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-03T11:26:38.000Z", "avg_line_length": 32.8287292818, "max_line_length": 129, "alphanum_fraction": 0.6600471222, "include": true, "reason": "import numpy", "num_tokens": 1602}
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import data.set.pointwise.smul
import group_theory.submonoid.membership
import order.well_founded_set
/-! # Pointwise instances on `submonoid`s and `add_submonoid`s
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file provides:
* `submonoid.has_inv`
* `add_submonoid.has_neg`
and the actions
* `submonoid.pointwise_mul_action`
* `add_submonoid.pointwise_mul_action`
which matches the action of `mul_action_set`.
These are all available in the `pointwise` locale.
Additionally, it provides various degrees of monoid structure:
* `add_submonoid.has_one`
* `add_submonoid.has_mul`
* `add_submonoid.mul_one_class`
* `add_submonoid.semigroup`
* `add_submonoid.monoid`
which is available globally to match the monoid structure implied by `submodule.idem_semiring`.
## Implementation notes
Most of the lemmas in this file are direct copies of lemmas from `algebra/pointwise.lean`.
While the statements of these lemmas are defeq, we repeat them here due to them not being
syntactically equal. Before adding new lemmas here, consider if they would also apply to the action
on `set`s.
-/
open set
variables {α : Type*} {G : Type*} {M : Type*} {R : Type*} {A : Type*}
variables [monoid M] [add_monoid A]
/-! Some lemmas about pointwise multiplication and submonoids. Ideally we put these in
`group_theory.submonoid.basic`, but currently we cannot because that file is imported by this. -/
namespace submonoid
open_locale pointwise
variables {s t u : set M}
@[to_additive]
lemma mul_subset {S : submonoid M} (hs : s ⊆ S) (ht : t ⊆ S) : s * t ⊆ S :=
by { rintro _ ⟨p, q, hp, hq, rfl⟩, exact submonoid.mul_mem _ (hs hp) (ht hq) }
@[to_additive]
lemma mul_subset_closure (hs : s ⊆ u) (ht : t ⊆ u) : s * t ⊆ submonoid.closure u :=
mul_subset (subset.trans hs submonoid.subset_closure) (subset.trans ht submonoid.subset_closure)
@[to_additive]
lemma coe_mul_self_eq (s : submonoid M) : (s : set M) * s = s :=
begin
ext x,
refine ⟨_, λ h, ⟨x, 1, h, s.one_mem, mul_one x⟩⟩,
rintro ⟨a, b, ha, hb, rfl⟩,
exact s.mul_mem ha hb
end
@[to_additive]
lemma closure_mul_le (S T : set M) : closure (S * T) ≤ closure S ⊔ closure T :=
Inf_le $ λ x ⟨s, t, hs, ht, hx⟩, hx ▸ (closure S ⊔ closure T).mul_mem
(set_like.le_def.mp le_sup_left $ subset_closure hs)
(set_like.le_def.mp le_sup_right $ subset_closure ht)
@[to_additive]
lemma sup_eq_closure (H K : submonoid M) : H ⊔ K = closure (H * K) :=
le_antisymm
(sup_le
(λ h hh, subset_closure ⟨h, 1, hh, K.one_mem, mul_one h⟩)
(λ k hk, subset_closure ⟨1, k, H.one_mem, hk, one_mul k⟩))
(by conv_rhs { rw [← closure_eq H, ← closure_eq K] }; apply closure_mul_le)
@[to_additive]
lemma pow_smul_mem_closure_smul {N : Type*} [comm_monoid N] [mul_action M N]
[is_scalar_tower M N N] (r : M) (s : set N) {x : N} (hx : x ∈ closure s) :
∃ n : ℕ, r ^ n • x ∈ closure (r • s) :=
begin
apply @closure_induction N _ s
(λ (x : N), ∃ n : ℕ, r ^ n • x ∈ closure (r • s)) _ hx,
{ intros x hx,
exact ⟨1, subset_closure ⟨_, hx, by rw pow_one⟩⟩ },
{ exact ⟨0, by simpa using one_mem _⟩ },
{ rintro x y ⟨nx, hx⟩ ⟨ny, hy⟩,
use nx + ny,
convert mul_mem hx hy,
rw [pow_add, smul_mul_assoc, mul_smul, mul_comm, ← smul_mul_assoc, mul_comm] }
end
variables [group G]
open_locale pointwise
/-- The submonoid with every element inverted. -/
@[to_additive /-" The additive submonoid with every element negated. "-/]
protected def has_inv : has_inv (submonoid G) :=
{ inv := λ S,
{ carrier := (S : set G)⁻¹,
one_mem' := show (1 : G)⁻¹ ∈ S, by { rw inv_one, exact S.one_mem },
mul_mem' := λ a b (ha : a⁻¹ ∈ S) (hb : b⁻¹ ∈ S), show (a * b)⁻¹ ∈ S,
by { rw mul_inv_rev, exact S.mul_mem hb ha } } }
localized "attribute [instance] submonoid.has_inv" in pointwise
open_locale pointwise
@[simp, to_additive] lemma coe_inv (S : submonoid G) : ↑(S⁻¹) = (S : set G)⁻¹ := rfl
@[simp, to_additive] lemma mem_inv {g : G} {S : submonoid G} : g ∈ S⁻¹ ↔ g⁻¹ ∈ S := iff.rfl
@[to_additive] instance : has_involutive_inv (submonoid G) :=
set_like.coe_injective.has_involutive_inv _ $ λ _, rfl
@[simp, to_additive] lemma inv_le_inv (S T : submonoid G) : S⁻¹ ≤ T⁻¹ ↔ S ≤ T :=
set_like.coe_subset_coe.symm.trans set.inv_subset_inv
@[to_additive] lemma inv_le (S T : submonoid G) : S⁻¹ ≤ T ↔ S ≤ T⁻¹ :=
set_like.coe_subset_coe.symm.trans set.inv_subset
/-- `submonoid.has_inv` as an order isomorphism. -/
@[to_additive /-" `add_submonoid.has_neg` as an order isomorphism "-/, simps]
def inv_order_iso : submonoid G ≃o submonoid G :=
{ to_equiv := equiv.inv _,
map_rel_iff' := inv_le_inv }
@[to_additive] lemma closure_inv (s : set G) : closure s⁻¹ = (closure s)⁻¹ :=
begin
apply le_antisymm,
{ rw [closure_le, coe_inv, ←set.inv_subset, inv_inv],
exact subset_closure },
{ rw [inv_le, closure_le, coe_inv, ←set.inv_subset],
exact subset_closure }
end
@[simp, to_additive]
lemma inv_inf (S T : submonoid G) : (S ⊓ T)⁻¹ = S⁻¹ ⊓ T⁻¹ :=
set_like.coe_injective set.inter_inv
@[simp, to_additive]
lemma inv_sup (S T : submonoid G) : (S ⊔ T)⁻¹ = S⁻¹ ⊔ T⁻¹ :=
(inv_order_iso : submonoid G ≃o submonoid G).map_sup S T
@[simp, to_additive]
lemma inv_bot : (⊥ : submonoid G)⁻¹ = ⊥ :=
set_like.coe_injective $ (set.inv_singleton 1).trans $ congr_arg _ inv_one
@[simp, to_additive]
lemma inv_top : (⊤ : submonoid G)⁻¹ = ⊤ :=
set_like.coe_injective $ set.inv_univ
@[simp, to_additive]
lemma inv_infi {ι : Sort*} (S : ι → submonoid G) : (⨅ i, S i)⁻¹ = ⨅ i, (S i)⁻¹ :=
(inv_order_iso : submonoid G ≃o submonoid G).map_infi _
@[simp, to_additive]
lemma inv_supr {ι : Sort*} (S : ι → submonoid G) : (⨆ i, S i)⁻¹ = ⨆ i, (S i)⁻¹ :=
(inv_order_iso : submonoid G ≃o submonoid G).map_supr _
end submonoid
namespace submonoid
section monoid
variables [monoid α] [mul_distrib_mul_action α M]
/-- The action on a submonoid corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_mul_action : mul_action α (submonoid M) :=
{ smul := λ a S, S.map (mul_distrib_mul_action.to_monoid_End _ M a),
one_smul := λ S, by { ext, simp, },
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f : monoid.End M, S.map f) (monoid_hom.map_mul _ _ _)).trans
(S.map_map _ _).symm,}
localized "attribute [instance] submonoid.pointwise_mul_action" in pointwise
open_locale pointwise
@[simp] lemma coe_pointwise_smul (a : α) (S : submonoid M) : ↑(a • S) = a • (S : set M) := rfl
lemma smul_mem_pointwise_smul (m : M) (a : α) (S : submonoid M) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set M))
lemma mem_smul_pointwise_iff_exists (m : M) (a : α) (S : submonoid M) :
m ∈ a • S ↔ ∃ (s : M), s ∈ S ∧ a • s = m :=
(set.mem_smul_set : m ∈ a • (S : set M) ↔ _)
@[simp] lemma smul_bot (a : α) : a • (⊥ : submonoid M) = ⊥ := map_bot _
lemma smul_sup (a : α) (S T : submonoid M) : a • (S ⊔ T) = a • S ⊔ a • T := map_sup _ _ _
lemma smul_closure (a : α) (s : set M) : a • closure s = closure (a • s) :=
monoid_hom.map_mclosure _ _
instance pointwise_central_scalar [mul_distrib_mul_action αᵐᵒᵖ M] [is_central_scalar α M] :
is_central_scalar α (submonoid M) :=
⟨λ a S, congr_arg (λ f : monoid.End M, S.map f) $ monoid_hom.ext $ by exact op_smul_eq_smul _⟩
end monoid
section group
variables [group α] [mul_distrib_mul_action α M]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff {a : α} {S : submonoid M} {x : M} :
a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff
lemma mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : submonoid M} {x : M} :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem
lemma mem_inv_pointwise_smul_iff {a : α} {S : submonoid M} {x : M} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff
@[simp] lemma pointwise_smul_le_pointwise_smul_iff {a : α} {S T : submonoid M} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff
lemma pointwise_smul_subset_iff {a : α} {S T : submonoid M} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff
lemma subset_pointwise_smul_iff {a : α} {S T : submonoid M} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff
end group
section group_with_zero
variables [group_with_zero α] [mul_distrib_mul_action α M]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : submonoid M)
(x : M) : a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff₀ ha (S : set M) x
lemma mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : submonoid M) (x : M) :
x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff₀ ha (S : set M) x
@[simp] lemma pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : submonoid M} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff₀ ha
lemma pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : submonoid M} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff₀ ha
lemma le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : submonoid M} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff₀ ha
end group_with_zero
open_locale pointwise
@[to_additive]
lemma mem_closure_inv {G : Type*} [group G] (S : set G) (x : G) :
x ∈ submonoid.closure S⁻¹ ↔ x⁻¹ ∈ submonoid.closure S :=
by rw [closure_inv, mem_inv]
end submonoid
namespace add_submonoid
section monoid
variables [monoid α] [distrib_mul_action α A]
/-- The action on an additive submonoid corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_mul_action : mul_action α (add_submonoid A) :=
{ smul := λ a S, S.map (distrib_mul_action.to_add_monoid_End _ A a),
one_smul := λ S, (congr_arg (λ f : add_monoid.End A, S.map f)
(monoid_hom.map_one _)).trans S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f : add_monoid.End A, S.map f) (monoid_hom.map_mul _ _ _)).trans
(S.map_map _ _).symm,}
localized "attribute [instance] add_submonoid.pointwise_mul_action" in pointwise
open_locale pointwise
@[simp] lemma coe_pointwise_smul (a : α) (S : add_submonoid A) : ↑(a • S) = a • (S : set A) := rfl
lemma smul_mem_pointwise_smul (m : A) (a : α) (S : add_submonoid A) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set A))
lemma mem_smul_pointwise_iff_exists (m : A) (a : α) (S : add_submonoid A) :
m ∈ a • S ↔ ∃ (s : A), s ∈ S ∧ a • s = m :=
(set.mem_smul_set : m ∈ a • (S : set A) ↔ _)
@[simp] lemma smul_bot (a : α) : a • (⊥ : add_submonoid A) = ⊥ := map_bot _
lemma smul_sup (a : α) (S T : add_submonoid A) : a • (S ⊔ T) = a • S ⊔ a • T := map_sup _ _ _
@[simp] lemma smul_closure (a : α) (s : set A) : a • closure s = closure (a • s) :=
add_monoid_hom.map_mclosure _ _
instance pointwise_central_scalar [distrib_mul_action αᵐᵒᵖ A] [is_central_scalar α A] :
is_central_scalar α (add_submonoid A) :=
⟨λ a S, congr_arg (λ f : add_monoid.End A, S.map f) $
add_monoid_hom.ext $ by exact op_smul_eq_smul _⟩
end monoid
section group
variables [group α] [distrib_mul_action α A]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff {a : α} {S : add_submonoid A} {x : A} :
a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff
lemma mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : add_submonoid A} {x : A} :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem
lemma mem_inv_pointwise_smul_iff {a : α} {S : add_submonoid A} {x : A} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff
@[simp] lemma pointwise_smul_le_pointwise_smul_iff {a : α} {S T : add_submonoid A} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff
lemma pointwise_smul_le_iff {a : α} {S T : add_submonoid A} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff
lemma le_pointwise_smul_iff {a : α} {S T : add_submonoid A} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff
end group
section group_with_zero
variables [group_with_zero α] [distrib_mul_action α A]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : add_submonoid A)
(x : A) : a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff₀ ha (S : set A) x
lemma mem_pointwise_smul_iff_inv_smul_mem₀ {a : α} (ha : a ≠ 0) (S : add_submonoid A) (x : A) :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem₀ ha (S : set A) x
lemma mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : add_submonoid A) (x : A) :
x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff₀ ha (S : set A) x
@[simp] lemma pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : add_submonoid A} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff₀ ha
lemma pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : add_submonoid A} :
a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff₀ ha
lemma le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : add_submonoid A} :
S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff₀ ha
end group_with_zero
end add_submonoid
/-! ### Elementwise monoid structure of additive submonoids
These definitions are a cut-down versions of the ones around `submodule.has_mul`, as that API is
usually more useful. -/
namespace add_submonoid
open_locale pointwise
section add_monoid_with_one
variables [add_monoid_with_one R]
instance : has_one (add_submonoid R) :=
⟨(nat.cast_add_monoid_hom R).mrange⟩
theorem one_eq_mrange :
(1 : add_submonoid R) = (nat.cast_add_monoid_hom R).mrange := rfl
lemma nat_cast_mem_one (n : ℕ) : (n : R) ∈ (1 : add_submonoid R) := ⟨_, rfl⟩
@[simp] lemma mem_one {x : R} : x ∈ (1 : add_submonoid R) ↔ ∃ n : ℕ, ↑n = x := iff.rfl
theorem one_eq_closure : (1 : add_submonoid R) = closure {1} :=
begin
simp only [closure_singleton_eq, mul_one, one_eq_mrange],
congr' 1 with n,
simp,
end
theorem one_eq_closure_one_set : (1 : add_submonoid R) = closure 1 := one_eq_closure
end add_monoid_with_one
section non_unital_non_assoc_semiring
variables [non_unital_non_assoc_semiring R]
/-- Multiplication of additive submonoids of a semiring R. The additive submonoid `S * T` is the
smallest R-submodule of `R` containing the elements `s * t` for `s ∈ S` and `t ∈ T`. -/
instance : has_mul (add_submonoid R) :=
⟨λ M N, ⨆ s : M, N.map $ add_monoid_hom.mul s.1⟩
theorem mul_mem_mul {M N : add_submonoid R} {m n : R} (hm : m ∈ M) (hn : n ∈ N) : m * n ∈ M * N :=
(le_supr _ ⟨m, hm⟩ : _ ≤ M * N) ⟨n, hn, rfl⟩
theorem mul_le {M N P : add_submonoid R} : M * N ≤ P ↔ ∀ (m ∈ M) (n ∈ N), m * n ∈ P :=
⟨λ H m hm n hn, H $ mul_mem_mul hm hn,
λ H, supr_le $ λ ⟨m, hm⟩, map_le_iff_le_comap.2 $ λ n hn, H m hm n hn⟩
@[elab_as_eliminator] protected theorem mul_induction_on
{M N : add_submonoid R}
{C : R → Prop} {r : R} (hr : r ∈ M * N)
(hm : ∀ (m ∈ M) (n ∈ N), C (m * n))
(ha : ∀ x y, C x → C y → C (x + y)) : C r :=
(@mul_le _ _ _ _ ⟨C, ha, by simpa only [zero_mul] using hm _ (zero_mem _) _ (zero_mem _)⟩).2 hm hr
open_locale pointwise
-- this proof is copied directly from `submodule.span_mul_span`
theorem closure_mul_closure (S T : set R) : closure S * closure T = closure (S * T) :=
begin
apply le_antisymm,
{ rw mul_le, intros a ha b hb,
apply closure_induction ha,
work_on_goal 1 { intros, apply closure_induction hb,
work_on_goal 1 { intros, exact subset_closure ⟨_, _, ‹_›, ‹_›, rfl⟩ } },
all_goals { intros, simp only [mul_zero, zero_mul, zero_mem,
left_distrib, right_distrib, mul_smul_comm, smul_mul_assoc];
solve_by_elim [add_mem _ _, zero_mem _]
{ max_depth := 4, discharger := tactic.interactive.apply_instance } } },
{ rw closure_le, rintros _ ⟨a, b, ha, hb, rfl⟩,
exact mul_mem_mul (subset_closure ha) (subset_closure hb) }
end
lemma mul_eq_closure_mul_set (M N : add_submonoid R) : M * N = closure (M * N) :=
by rw [←closure_mul_closure, closure_eq, closure_eq]
@[simp] theorem mul_bot (S : add_submonoid R) : S * ⊥ = ⊥ :=
eq_bot_iff.2 $ mul_le.2 $ λ m hm n hn, by rw [add_submonoid.mem_bot] at hn ⊢; rw [hn, mul_zero]
@[simp] theorem bot_mul (S : add_submonoid R) : ⊥ * S = ⊥ :=
eq_bot_iff.2 $ mul_le.2 $ λ m hm n hn, by rw [add_submonoid.mem_bot] at hm ⊢; rw [hm, zero_mul]
@[mono] theorem mul_le_mul {M N P Q : add_submonoid R} (hmp : M ≤ P) (hnq : N ≤ Q) :
M * N ≤ P * Q :=
mul_le.2 $ λ m hm n hn, mul_mem_mul (hmp hm) (hnq hn)
theorem mul_le_mul_left {M N P : add_submonoid R} (h : M ≤ N) : M * P ≤ N * P :=
mul_le_mul h (le_refl P)
theorem mul_le_mul_right {M N P : add_submonoid R} (h : N ≤ P) : M * N ≤ M * P :=
mul_le_mul (le_refl M) h
lemma mul_subset_mul {M N : add_submonoid R} : (↑M : set R) * (↑N : set R) ⊆ (↑(M * N) : set R) :=
by { rintros _ ⟨i, j, hi, hj, rfl⟩, exact mul_mem_mul hi hj }
end non_unital_non_assoc_semiring
section non_unital_non_assoc_ring
variables [non_unital_non_assoc_ring R]
/-- `add_submonoid.has_pointwise_neg` distributes over multiplication.
This is available as an instance in the `pointwise` locale. -/
protected def has_distrib_neg : has_distrib_neg (add_submonoid R) :=
{ neg := has_neg.neg,
neg_mul := λ x y, begin
refine le_antisymm
(mul_le.2 $ λ m hm n hn, _)
((add_submonoid.neg_le _ _).2 $ mul_le.2 $ λ m hm n hn, _);
simp only [add_submonoid.mem_neg, ←neg_mul] at *,
{ exact mul_mem_mul hm hn },
{ exact mul_mem_mul (neg_mem_neg.2 hm) hn },
end,
mul_neg := λ x y, begin
refine le_antisymm
(mul_le.2 $ λ m hm n hn, _)
((add_submonoid.neg_le _ _).2 $ mul_le.2 $ λ m hm n hn, _);
simp only [add_submonoid.mem_neg, ←mul_neg] at *,
{ exact mul_mem_mul hm hn,},
{ exact mul_mem_mul hm (neg_mem_neg.2 hn) },
end,
..add_submonoid.has_involutive_neg }
localized "attribute [instance] add_submonoid.has_distrib_neg" in pointwise
end non_unital_non_assoc_ring
section non_assoc_semiring
variables [non_assoc_semiring R]
instance : mul_one_class (add_submonoid R) :=
{ one := 1,
mul := (*),
one_mul := λ M, by rw [one_eq_closure_one_set, ←closure_eq M, closure_mul_closure, one_mul],
mul_one := λ M, by rw [one_eq_closure_one_set, ←closure_eq M, closure_mul_closure, mul_one] }
end non_assoc_semiring
section non_unital_semiring
variables [non_unital_semiring R]
instance : semigroup (add_submonoid R) :=
{ mul := (*),
mul_assoc := λ M N P,
le_antisymm (mul_le.2 $ λ mn hmn p hp,
suffices M * N ≤ (M * (N * P)).comap (add_monoid_hom.mul_right p), from this hmn,
mul_le.2 $ λ m hm n hn, show m * n * p ∈ M * (N * P), from
(mul_assoc m n p).symm ▸ mul_mem_mul hm (mul_mem_mul hn hp))
(mul_le.2 $ λ m hm np hnp,
suffices N * P ≤ (M * N * P).comap (add_monoid_hom.mul_left m), from this hnp,
mul_le.2 $ λ n hn p hp, show m * (n * p) ∈ M * N * P, from
mul_assoc m n p ▸ mul_mem_mul (mul_mem_mul hm hn) hp) }
end non_unital_semiring
section semiring
variables [semiring R]
instance : monoid (add_submonoid R) :=
{ one := 1,
mul := (*),
..add_submonoid.semigroup,
..add_submonoid.mul_one_class }
lemma closure_pow (s : set R) : ∀ n : ℕ, closure s ^ n = closure (s ^ n)
| 0 := by rw [pow_zero, pow_zero, one_eq_closure_one_set]
| (n + 1) := by rw [pow_succ, pow_succ, closure_pow, closure_mul_closure]
lemma pow_eq_closure_pow_set (s : add_submonoid R) (n : ℕ) : s ^ n = closure ((s : set R) ^ n) :=
by rw [←closure_pow, closure_eq]
lemma pow_subset_pow {s : add_submonoid R} {n : ℕ} : (↑s : set R)^n ⊆ ↑(s^n) :=
(pow_eq_closure_pow_set s n).symm ▸ subset_closure
end semiring
end add_submonoid
namespace set.is_pwo
variables [ordered_cancel_comm_monoid α] {s : set α}
@[to_additive]
lemma submonoid_closure (hpos : ∀ x : α, x ∈ s → 1 ≤ x) (h : s.is_pwo) :
is_pwo ((submonoid.closure s) : set α) :=
begin
rw submonoid.closure_eq_image_prod,
refine (h.partially_well_ordered_on_sublist_forall₂ (≤)).image_of_monotone_on _,
exact λ l1 hl1 l2 hl2 h12, h12.prod_le_prod' (λ x hx, hpos x $ hl2 x hx)
end
end set.is_pwo
|
{"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/group_theory/submonoid/pointwise.lean"}
|
[STATEMENT]
lemma aform_val_msum_aform:
assumes "degree_aform f \<le> n"
shows "aform_val e (msum_aform n f g) = aform_val e f + aform_val (\<lambda>i. e (i + n)) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. aform_val e (msum_aform n f g) = aform_val e f + aform_val (\<lambda>i. e (i + n)) g
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
degree_aform f \<le> n
goal (1 subgoal):
1. aform_val e (msum_aform n f g) = aform_val e f + aform_val (\<lambda>i. e (i + n)) g
[PROOF STEP]
by (auto simp: pdevs_val_msum_pdevs aform_val_def)
|
{"llama_tokens": 263, "file": "Affine_Arithmetic_Affine_Form", "length": 2}
|
'''
We replicate the structure of an MA(q) model with a neural network here,
simulate a simple AR(1) processs and fit said model to it.
'''
from __future__ import print_function
import numpy as np
from neuralforecast.models import NeuralMA
from neuralforecast.data_generator import arma_sample
np.random.seed(337)
sample = arma_sample(n=510, ar=[0.9], ma=[0.0])
q = 10
nma = NeuralMA(q)
nma.fit(sample, batch_size=32, nb_epoch=50)
score = nma.evaluate()
print(score)
nma.plot_predictions('fit_ma.png')
|
{"hexsha": "74c468371a3d430353e7110282f7ae34879814ed", "size": 508, "ext": "py", "lang": "Python", "max_stars_repo_path": "examples/ma.py", "max_stars_repo_name": "maxpumperla/neuralforecast", "max_stars_repo_head_hexsha": "61d730a28454f89843defb823430daee2ff64912", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2016-05-10T04:55:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-24T14:11:18.000Z", "max_issues_repo_path": "examples/ma.py", "max_issues_repo_name": "Julian0C/neuralforecast", "max_issues_repo_head_hexsha": "61d730a28454f89843defb823430daee2ff64912", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/ma.py", "max_forks_repo_name": "Julian0C/neuralforecast", "max_forks_repo_head_hexsha": "61d730a28454f89843defb823430daee2ff64912", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2016-06-22T11:32:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-24T19:34:25.000Z", "avg_line_length": 22.0869565217, "max_line_length": 72, "alphanum_fraction": 0.7578740157, "include": true, "reason": "import numpy", "num_tokens": 135}
|
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 20 22:02:27 2020
@author: Yuri
Frequcnsies in [radians/s]
"""
import numpy as np
import math
from math import pi
from math import tan
from math import sin
def timetofreqspectrumFun(Wpars, Freqs, modelting, Pars):
# y = np.zeros([len(Freqs),2])
y = np.full([len(Freqs), 2], np.nan)
if modelting == 'sPLR' or modelting == 'sPLReta' or modelting == 'mPLR' or modelting == 'sPLRdouble':
# plr_par = [E1f; alpha; nu; Einf]
E1t = Wpars[0]
alpha = Wpars[1]
Einf = Wpars[2]
nu = 0 # newtonian viscosity
if modelting == 'mPLR':
powerlaw2 = [Wpars[1], Wpars[0], 1, Pars['dTmPLR'], Wpars[2]]
plr_fun = lambda time, parplr: parplr[0] + (parplr[1]-parplr[0])/(parplr[2]+time/parplr[3])**parplr[4]
# Et = plr_fun(powerlaw2,Timefull)
E1t = plr_fun(powerlaw2, 1)
alpha = Wpars[2]
if modelting == 'sPLReta':
nu = Wpars[2]
Einf = 0
E1w = (E1t-Einf)*pi/2/sin(alpha*pi/2)/math.gamma(alpha) # checked
y[:, 0] = E1w*(Freqs**alpha)+Einf
y[:, 1] = E1w*tan(pi*alpha/2)*(Freqs**alpha)+nu*Freqs
elif modelting == 'SLS':
# y = Einf + (E0-Einf).*exp(-x./(tau);
E0 = Wpars[0]
Einf = Wpars[1]
Ed = E0 - Einf
tau = Wpars[2]
# SLS_Estor= SLSPar(1)+(SLSPar(2)-SLSPar(1)).*(Freq.*SLSPar(3)).^2./(1+(Freq.*SLSPar(3)).^2);
# SLS_Eloss=(SLSPar(2)-SLSPar(1)).*(Freq.*SLSPar(3))./(1+(Freq.*SLSPar(3)).^2);
y[:, 0] = Einf+Ed*(Freqs*tau)**2/(1+(Freqs*tau)**2)
y[:, 1] = Ed*(Freqs*tau)/(1+(Freqs*tau)**2)
return y
if __name__ == '__main__':
import matplotlib.pyplot as plt
from Pars_class import Pars_gen
# Wpars = [1000, 500, 0.2]
Pars = Pars_gen()
Freqs = np.array([100, 200])
Freqs = np.logspace(np.log10(0.1), np.log10(100), num=10)
Wpars = [1000, 0.1, 10]
contact_time = 0.1
Freq = np.array([1/contact_time])
modelting = 'sPLReta'
y = timetofreqspectrumFun(Wpars, Freqs, modelting, Pars)
plt.loglog(Freqs, y[:, 0])+plt.loglog(Freqs, y[:, 1])
|
{"hexsha": "12f52d0e81da62647612ecf92314e98ff16934d7", "size": 2237, "ext": "py", "lang": "Python", "max_stars_repo_path": "timetofreqspectrumFun.py", "max_stars_repo_name": "yu-efremov/ViscoIndent", "max_stars_repo_head_hexsha": "b9658509fdf9ed232cf682cb554f668572735e4d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-12-02T16:19:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T13:26:53.000Z", "max_issues_repo_path": "timetofreqspectrumFun.py", "max_issues_repo_name": "yu-efremov/ViscoIndent", "max_issues_repo_head_hexsha": "b9658509fdf9ed232cf682cb554f668572735e4d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "timetofreqspectrumFun.py", "max_forks_repo_name": "yu-efremov/ViscoIndent", "max_forks_repo_head_hexsha": "b9658509fdf9ed232cf682cb554f668572735e4d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-03T15:17:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T15:17:58.000Z", "avg_line_length": 32.4202898551, "max_line_length": 115, "alphanum_fraction": 0.5377738042, "include": true, "reason": "import numpy", "num_tokens": 826}
|
import data.nat.basic
import .ch01_basics
open basics (evenb oddb sub_two leb)
open nat (add mul)
namespace poly
/-
Inductive boollist : Type :=
| bool_nil
| bool_cons (b : bool) (l : boollist).
-/
inductive boollist : Type
| bool_nil
| bool_cons (b : bool) (l : boollist)
/-
Inductive list (X:Type) : Type :=
| nil
| cons (x : X) (l : list X).
-/
/- needing to already move to gadt syntax is annoying -/
inductive list (α : Type) : Type
| nil : list
| cons (a : α) (l : list) : list
open poly.list
/-
Check list.
(* ===> list : Type -> Type *)
-/
#check list
/-
Check (nil nat).
(* ===> nil nat : list nat *)
-/
#check @nil ℕ
/-
Check (cons nat 3 (nil nat)).
(* ===> cons nat 3 (nil nat) : list nat *)
-/
#check (cons 3 nil)
/-
Check nil.
(* ===> nil : forall X : Type, list X *)
-/
#check nil
/-
Check cons.
(* ===> cons : forall X : Type, X -> list X -> list X *)
-/
#check cons
/-
Check (cons nat 2 (cons nat 1 (nil nat))).
-/
#check (cons 2 (cons 1 nil))
/-
Fixpoint repeat (X : Type) (x : X) (count : nat) : list X :=
match count with
| 0 ⇒ nil X
| S count' ⇒ cons X x (repeat X x count')
end.
-/
def repeat (α : Type) (a : α) : ℕ → list α
| 0 := nil
| (n + 1) := cons a (repeat n)
/-
Example test_repeat1 :
repeat nat 4 2 = cons nat 4 (cons nat 4 (nil nat)).
Proof. reflexivity. Qed.
-/
example : repeat ℕ 4 2 = cons 4 (cons 4 nil) := rfl
/-
Example test_repeat2 :
repeat bool false 1 = cons bool false (nil bool).
Proof. reflexivity. Qed.
-/
example : repeat bool ff 1 = cons ff nil := rfl
/-
Inductive mumble : Type :=
| a
| b (x : mumble) (y : nat)
| c.
Inductive grumble (X:Type) : Type :=
| d (m : mumble)
| e (x : X).
-/
/- i don't want to lose the ability to use a/b in prod -/
namespace mumble_grumble
inductive mumble : Type
| a
| b (x : mumble) (y : ℕ)
| c
inductive grumble (α : Type) : Type
| d (m : mumble) : grumble
| e (a : α) : grumble
open mumble
open grumble
#check d (b a 5)
#check @d mumble (b a 5)
#check @d bool (b a 5)
#check @e mumble (b c 0)
-- #check @e bool (b c 0)
#check c
end mumble_grumble
/-
Fixpoint repeat' X x count : list X :=
match count with
| 0 ⇒ nil X
| S count' ⇒ cons X x (repeat' X x count')
end.
-/
def repeat' (α a) : ∀count, list α
| 0 := nil
| (count + 1) := cons a (repeat' count)
/-
Check repeat'.
(* ===> forall X : Type, X -> nat -> list X *)
Check repeat.
(* ===> forall X : Type, X -> nat -> list X *)
-/
/-
Fixpoint repeat'' X x count : list X :=
match count with
| 0 ⇒ nil _
| S count' ⇒ cons _ x (repeat'' _ x count')
end.
-/
def repeat'' {α} (a) : ∀count, list α
| 0 := @nil _
| (count + 1) := cons a (repeat'' count)
/-
Definition list123 :=
cons nat 1 (cons nat 2 (cons nat 3 (nil nat))).
-/
def list123 := cons 1 (cons 2 (cons 3 nil))
/-
Definition list123' :=
cons _ 1 (cons _ 2 (cons _ 3 (nil _))).
-/
def list123' := @cons _ 1 (@cons _ 2 (@cons _ 3 (@nil _)))
/-
Arguments nil {X}.
Arguments cons {X} _ _.
Arguments repeat {X} x count.
Definition list123'' := cons 1 (cons 2 (cons 3 nil)).
-/
/-
arguments doesn't appear to exist in lean
-/
/-
let's go one step further
-/
variables {α β γ : Type}
/-
Fixpoint repeat''' {X : Type} (x : X) (count : nat) : list X :=
match count with
| 0 ⇒ nil
| S count' ⇒ cons x (repeat''' x count')
end.
-/
/-
Inductive list' {X:Type} : Type :=
| nil'
| cons' (x : X) (l : list').
-/
inductive list' : Type
| nil' : list'
| cons' : α → list'
/-
Fixpoint app {X : Type} (l1 l2 : list X)
: (list X) :=
match l1 with
| nil ⇒ l2
| cons h t ⇒ cons h (app t l2)
end.
Fixpoint rev {X:Type} (l:list X) : list X :=
match l with
| nil ⇒ nil
| cons h t ⇒ app (rev t) (cons h nil)
end.
Fixpoint length {X : Type} (l : list X) : nat :=
match l with
| nil ⇒ 0
| cons _ l' ⇒ S (length l')
end.
Example test_rev1 :
rev (cons 1 (cons 2 nil)) = (cons 2 (cons 1 nil)).
Proof. reflexivity. Qed.
Example test_rev2:
rev (cons true nil) = cons true nil.
Proof. reflexivity. Qed.
Example test_length1: length (cons 1 (cons 2 (cons 3 nil))) = 3.
Proof. reflexivity. Qed.
-/
/-
to add something beyond polymorphism to this chapter,
let's also use generalized field notation
-/
def list.append : list α → list α → list α
| nil l₂ := l₂
| (cons h t) l₂ := cons h (t.append l₂)
def list.reverse : list α → list α
| nil := nil
| (cons h t) := t.reverse.append (cons h nil)
def list.length : list α → ℕ
| nil := 0
| (cons _ t) := t.length + 1
example :
(cons 1 (cons 2 nil)).reverse = cons 2 (cons 1 nil) := rfl
example : (cons tt nil).reverse = cons tt nil := rfl
example : (cons 1 (cons 2 (cons 3 nil))).length = 3 := rfl
/-
Definition mynil : list nat := nil.
-/
def mynil : list ℕ := nil
/-
Check @nil.
Definition mynil' := @nil nat.
-/
#check @nil
def mynil' := @nil ℕ
/-
Notation "x :: y" := (cons x y)
(at level 60, right associativity).
Notation "[ ]" := nil.
Notation "[ x ; .. ; y ]" := (cons x .. (cons y []) ..).
Notation "x ++ y" := (app x y)
(at level 60, right associativity).
-/
local infixr :: := cons
local notation `[` l:(foldr `, ` (h t, cons h t) nil `]`) := l
local infixr ++ := list.append
/-
Theorem app_nil_r : ∀(X:Type), ∀l:list X,
l ++ [] = l.
Proof.
(* FILL IN HERE *) Admitted.
Theorem app_assoc : ∀A (l m n:list A),
l ++ m ++ n = (l ++ m) ++ n.
Proof.
(* FILL IN HERE *) Admitted.
Lemma app_length : ∀(X:Type) (l1 l2 : list X),
length (l1 ++ l2) = length l1 + length l2.
Proof.
(* FILL IN HERE *) Admitted.
-/
theorem cons_append (a : α) (l₁ l₂) : (a::l₁) ++ l₂ = a::(l₁ ++ l₂) := rfl
theorem append_nil (l : list α) : l ++ [] = l :=
begin
induction l with a l ih,
refl,
rw cons_append,
rw ih,
end
theorem nil_append (l : list α) : [] ++ l = l := rfl
theorem append_assoc (l m n : list α) : l ++ (m ++ n) = (l ++ m) ++ n :=
begin
induction l with a l ih,
refl,
rw [cons_append, cons_append, cons_append],
rw ih,
end
theorem length_nil : (@nil α).length = 0 := rfl
theorem length_cons (a : α) (l) : (a::l).length = l.length + 1 := rfl
lemma length_append (l₁ l₂ : list α) :
(l₁ ++ l₂).length = l₁.length + l₂.length :=
begin
induction l₁ with n l ih,
rw nil_append,
rw length_nil,
rw zero_add,
rw cons_append,
rw [length_cons, length_cons],
rw ih,
rw [add_assoc _ 1, add_comm 1, add_assoc],
end
/-
Theorem rev_app_distr: ∀X (l1 l2 : list X),
rev (l1 ++ l2) = rev l2 ++ rev l1.
Proof.
(* FILL IN HERE *) Admitted.
Theorem rev_involutive : ∀X : Type, ∀l : list X,
rev (rev l) = l.
Proof.
(* FILL IN HERE *) Admitted.
-/
open poly.list (reverse)
theorem reverse_append (l₁ l₂ : list α) :
(l₁ ++ l₂).reverse = l₂.reverse ++ l₁.reverse :=
begin
induction l₁ with a l₁ ih,
rw nil_append,
rw reverse,
rw append_nil,
rw cons_append,
rw [reverse, reverse],
rw ih,
rw append_assoc,
end
theorem reverse_involutive (l : list α) : reverse (reverse l) = l :=
begin
induction l with n l ih,
refl,
rw reverse,
rw reverse_append,
rw ih,
refl,
end
/-
Inductive prod (X Y : Type) : Type :=
| pair (x : X) (y : Y).
Arguments pair {X} {Y} _ _.
-/
/- something else new -/
structure prod (α β : Type) : Type := (fst : α) (snd : β)
open poly.prod
/-
Notation "( x , y )" := (pair x y).
-/
/-
this is going to break (update : yep, {} break typeclass stuff)
local should be fine though
i don't see anything like coq's scope in lean
-/
local notation {x, y} := prod.mk x y
local infix × := prod
/-
Definition fst {X Y : Type} (p : X * Y) : X :=
match p with
| (x, y) ⇒ x
end.
Definition snd {X Y : Type} (p : X * Y) : Y :=
match p with
| (x, y) ⇒ y
end.
-/
#check fst
#check snd
/-
Fixpoint combine {X Y : Type} (lx : list X) (ly : list Y)
: list (X*Y) :=
match lx, ly with
| [], _ ⇒ []
| _, [] ⇒ []
| x :: tx, y :: ty ⇒ (x, y) :: (combine tx ty)
end.
-/
def combine : list α → list β → list (α × β)
| [] _ := []
| (a::ta) [] := []
| (a::ta) (b::tb) := {a, b}::combine ta tb
/-
Compute (combine [1;2] [false;false;true;true]).
-/
#check @combine
#reduce combine [1, 2] [ff, ff, tt, tt]
/-
Fixpoint split {X Y : Type} (l : list (X*Y))
: (list X) * (list Y)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example test_split:
split [(1,false);(2,false)] = ([1;2],[false;false]).
Proof.
(* FILL IN HERE *) Admitted.
-/
/- lean caches so this won't be exponential -/
/- unfortunately lean seems incapable of unfolding this -/
def split' : list (α × β) → list α × list β
| [] := {[], []}
| ({a, b}::l) := {a::(split' l).fst, b::(split' l).snd}
/- can also uses explicit induction to clearly be linear -/
def split (l : list (α × β)) : list α × list β :=
begin
induction l with h t ih,
exact {[], []},
exact {h.fst::ih.fst, h.snd::ih.snd},
end
example : split [{1, ff}, {2, ff}] = {[1, 2], [ff, ff]} := rfl
/-
Module OptionPlayground.
Inductive option (X:Type) : Type :=
| Some (x : X)
| None.
Arguments Some {X} _.
Arguments None {X}.
End OptionPlayground.
-/
inductive option (α : Type) : Type
| none : option
| some (a : α) : option
open poly.option
/-
Fixpoint nth_error {X : Type} (l : list X) (n : nat)
: option X :=
match l with
| [] ⇒ None
| a :: l' ⇒ if n =? O then Some a else nth_error l' (pred n)
end.
Example test_nth_error1 : nth_error [4;5;6;7] 0 = Some 4.
Example test_nth_error2 : nth_error [[1];[2]] 1 = Some [2].
Example test_nth_error3 : nth_error [true] 2 = None.
-/
def nth_error : list α → ℕ → option α
| [] _ := none
| (h::_) 0 := some h
| (_::t) (n + 1) := nth_error t n
example : nth_error [4,5,6,7] 0 = some 4 := rfl
example : nth_error [[1],[2]] 1 = some [2] := rfl
example : nth_error [tt] 2 = none := rfl
/-
Definition hd_error {X : Type} (l : list X) : option X
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
-/
def hd_error : list α → option α
| [] := none
| (h::_) := some h
/-
Check @hd_error.
Example test_hd_error1 : hd_error [1;2] = Some 1.
(* FILL IN HERE *) Admitted.
Example test_hd_error2 : hd_error [[1];[2]] = Some [1].
(* FILL IN HERE *) Admitted.
-/
#check @hd_error
example : hd_error [1,2] = some 1 := rfl
example : hd_error [[1], [2]] = some [1] := rfl
/-
Definition doit3times {X:Type} (f:X→X) (n:X) : X :=
f (f (f n)).
-/
def doit3times {α : Type} (f: α → α) (n : α) : α :=
f (f (f n))
/-
Check @doit3times.
(* ===> doit3times : forall X : Type, (X -> X) -> X -> X *)
Example test_doit3times: doit3times minustwo 9 = 3.
Proof. reflexivity. Qed.
Example test_doit3times': doit3times negb true = false.
Proof. reflexivity. Qed.
-/
#check @doit3times
example : doit3times sub_two 9 = 3 := rfl
example : doit3times bnot tt = ff := rfl
/-
Fixpoint filter {X:Type} (test: X→bool) (l:list X)
: (list X) :=
match l with
| [] ⇒ []
| h :: t ⇒ if test h then h :: (filter test t)
else filter test t
end.
-/
def list.filter {α : Type} (test : α → bool)
: list α → list α
| [] := []
| (h::t) := if test h then h::t.filter else t.filter
/-
Example test_filter1: filter evenb [1;2;3;4] = [2;4].
Proof. reflexivity. Qed.
Definition length_is_1 {X : Type} (l : list X) : bool :=
(length l) =? 1.
Example test_filter2:
filter length_is_1
[ [1; 2]; [3]; [4]; [5;6;7]; []; [8] ]
= [ [3]; [4]; [8] ].
Proof. reflexivity. Qed.
-/
example : [1, 2, 3, 4].filter evenb = [2,4] := rfl
def length_is_1 {α : Type} (l : list α) : bool :=
list.length l =? 1
example : [[1, 2], [3], [4], [5, 6, 7], [], [8]].filter length_is_1
= [[3], [4], [8]] := rfl
/-
Definition countoddmembers' (l:list nat) : nat :=
length (filter oddb l).
Example test_countoddmembers'1: countoddmembers' [1;0;3;1;4;5] = 4.
Proof. reflexivity. Qed.
Example test_countoddmembers'2: countoddmembers' [0;2;4] = 0.
Proof. reflexivity. Qed.
Example test_countoddmembers'3: countoddmembers' nil = 0.
Proof. reflexivity. Qed.
-/
open poly.list (filter length)
def countoddmembers := length ∘ (filter oddb)
example : countoddmembers [1, 0, 3, 1, 4, 5] = 4 := rfl
example : countoddmembers [0,2,4] = 0 := rfl
example : countoddmembers [] = 0 := rfl
/-
Example test_anon_fun':
doit3times (fun n ⇒ n * n) 2 = 256.
Proof. reflexivity. Qed.
-/
/- commenting out as this is murdering my computer... -/
-- example : doit3times (λ (n : int), n * n) 2 = 256 := rfl
/-
Example test_filter2':
filter (fun l ⇒ (length l) =? 1)
[ [1; 2]; [3]; [4]; [5;6;7]; []; [8] ]
= [ [3]; [4]; [8] ].
Proof. reflexivity. Qed.
-/
example :
[[1, 2], [3], [4], [5, 6, 7], [], [8]].filter (λ l, l.length =? 1)
= [[3], [4], [8]] := rfl
/-
Definition filter_even_gt7 (l : list nat) : list nat
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example test_filter_even_gt7_1 :
filter_even_gt7 [1;2;6;9;10;3;12;8] = [10;12;8].
(* FILL IN HERE *) Admitted.
Example test_filter_even_gt7_2 :
filter_even_gt7 [5;2;6;19;129] = [].
(* FILL IN HERE *) Admitted.
-/
def filter_even_gt₇ := filter (λ n, evenb n && leb 7 n)
example :
filter_even_gt₇ [1, 2, 6, 9, 10, 3, 12, 8] = [10, 12, 8] := rfl
example : filter_even_gt₇ [5, 2, 6, 19, 129] = [] := rfl
/-
Definition partition {X : Type}
(test : X → bool)
(l : list X)
: list X * list X
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example test_partition1: partition oddb [1;2;3;4;5] = ([1;3;5], [2;4]).
(* FILL IN HERE *) Admitted.
Example test_partition2: partition (fun x ⇒ false) [5;9;0] = ([], [5;9;0]).
(* FILL IN HERE *) Admitted.
-/
/- reminder: the translation will be linear -/
def list.partition (test : α → bool) : list α → list α × list α
| [] := {[], []}
| (h::t) := if test h
then {h::t.partition.fst, t.partition.snd}
else {t.partition.fst, h::t.partition.snd}
example :
[1,2,3,4,5].partition oddb = {[1, 3, 5], [2, 4]} := rfl
example :
[5,9,0].partition (λ _, ff) = {[], [5, 9, 0]} := rfl
/-
Fixpoint map {X Y: Type} (f:X→Y) (l:list X) : (list Y) :=
match l with
| [] ⇒ []
| h :: t ⇒ (f h) :: (map f t)
end.
-/
def list.map (f : α → β) : list α → list β
| [] := []
| (h::t) := f h :: t.map
/-
Example test_map1: map (fun x ⇒ plus 3 x) [2;0;2] = [5;3;5].
Proof. reflexivity. Qed.
-/
example : [2, 0, 2].map (λx, 3 + x) = [5, 3, 5] := rfl
/-
Example test_map2:
map oddb [2;1;2;5] = [false;true;false;true].
Proof. reflexivity. Qed.
-/
example : [2, 1, 2, 5].map oddb = [ff, tt, ff, tt] := rfl
/-
Example test_map3:
map (fun n ⇒ [evenb n;oddb n]) [2;1;2;5]
= [[true;false];[false;true];[true;false];[false;true]].
Proof. reflexivity. Qed.
-/
example : [2, 1, 2, 5].map (λn, [evenb n, oddb n])
= [[tt, ff], [ff, tt], [tt, ff], [ff, tt]] := rfl
/-
Theorem map_rev : ∀(X Y : Type) (f : X → Y) (l : list X),
map f (rev l) = rev (map f l).
Proof.
(* FILL IN HERE *) Admitted.
-/
open poly.list (map)
lemma map_append (f : α → β) (l₁ l₂ : list α) :
(l₁ ++ l₂).map f = l₁.map f ++ l₂.map f :=
begin
induction l₁ with a l₁ ih,
refl,
rw cons_append,
rw [map, map],
rw ih,
rw cons_append,
end
def map_reverse (f : α → β) (l : list α) :
l.reverse.map f = (l.map f).reverse :=
begin
induction l with a l ih,
refl,
rw map,
rw [reverse, reverse],
rw map_append,
rw ih,
refl,
end
/-
Fixpoint flat_map {X Y: Type} (f: X → list Y) (l: list X)
: (list Y)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example test_flat_map1:
flat_map (fun n ⇒ [n;n;n]) [1;5;4]
= [1; 1; 1; 5; 5; 5; 4; 4; 4].
(* FILL IN HERE *) Admitted.
-/
/- i don't love the order that lean uses -/
def list.bind : list α → (α → list β) → list β
| [] f := []
| (h::t) f := f h ++ t.bind f
example : [1, 5, 4].bind (λn, [n, n, n])
= [1, 1, 1, 5, 5, 5, 4, 4, 4] := rfl
/-
Definition option_map {X Y : Type} (f : X → Y) (xo : option X)
: option Y :=
match xo with
| None ⇒ None
| Some x ⇒ Some (f x)
end.
-/
def option.bind : option α → (α → β) → option β
| none f := none
| (some a) f := some (f a)
/-
Fixpoint fold {X Y: Type} (f: X→Y→Y) (l: list X) (b: Y)
: Y :=
match l with
| nil ⇒ b
| h :: t ⇒ f h (fold f t b)
end.
-/
def list.foldr (f: α → β → β) (b : β) : list α → β
| [] := b
| (a::t) := f a t.foldr
def list.foldl (f: α → β → α) : α → list β → α
| a [] := a
| a (b::t) := t.foldl (f a b)
/-
Check (fold andb).
(* ===> fold andb : list bool -> bool -> bool *)
Example fold_example1 :
fold mult [1;2;3;4] 1 = 24.
Example fold_example2 :
fold andb [true;true;false;true] true = false.
Example fold_example3 :
fold app [[1];[];[2;3];[4]] [] = [1;2;3;4].
-/
open poly.list (foldr)
#check foldr band
example : [1, 2, 3, 4].foldr mul 1 = 24 := rfl
example : [tt, tt, ff, tt].foldr band tt = ff := rfl
/-
why is this ambiguous?
type class resolution fails if using has_append.append
-/
example : [[1], [], [2, 3], [4]].foldr list.append [] = [1, 2, 3, 4] := rfl
/-
Definition constfun {X: Type} (x: X) : nat→X :=
fun (k:nat) ⇒ x.
Definition ftrue := constfun true.
Example constfun_example1 : ftrue 0 = true.
Proof. reflexivity. Qed.
Example constfun_example2 : (constfun 5) 99 = 5.
-/
def constfun (a: α) : ℕ → α := λ_, a
def ftrue := constfun tt
example : ftrue 0 = tt := rfl
example : constfun 5 99 = 5 := rfl
/-
Check plus.
(* ==> nat -> nat -> nat *)
-/
#check add
/-
Definition plus3 := plus 3.
Check plus3.
Example test_plus3 : plus3 4 = 7.
Proof. reflexivity. Qed.
Example test_plus3' : doit3times plus3 0 = 9.
Proof. reflexivity. Qed.
Example test_plus3'' : doit3times (plus 3) 0 = 9.
Proof. reflexivity. Qed.
-/
def add₃ := add 3
example : add₃ 4 = 7 := rfl
example : doit3times add₃ 0 = 9 := rfl
example : doit3times (add 3) 0 = 9 := rfl
/-
Definition fold_length {X : Type} (l : list X) : nat :=
fold (fun _ n ⇒ S n) l 0.
Example test_fold_length1 : fold_length [4;7;0] = 3.
-/
def fold_length (l : list α) : ℕ := l.foldr (λ_ n, n + 1) 0
example : fold_length [4, 7, 0] = 3 := rfl
/-
Theorem fold_length_correct : ∀X (l : list X),
fold_length l = length l.
Proof.
(* FILL IN HERE *) Admitted.
-/
theorem fold_length_correct (l : list α) : fold_length l = l.length :=
begin
induction l with a l ih,
refl,
rw length,
rw fold_length at ih ⊢,
rw foldr,
rw ih,
end
/-
Definition fold_map {X Y: Type} (f: X → Y) (l: list X) : list Y
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
-/
def fold_map (f : α → β) (l : list α) : list β :=
l.foldr (λ h b, f h :: b) []
theorem fold_map_correct (f : α → β) (l : list α) :
fold_map f l = l.map f :=
begin
induction l with h t ih,
refl,
rw map,
rw fold_map at ih ⊢,
rw foldr,
rw ih,
end
/-
Definition prod_curry {X Y Z : Type}
(f : X * Y → Z) (x : X) (y : Y) : Z := f (x, y).
-/
def function.curry (f : α × β → γ) (a : α) (b : β) : γ := f {a, b}
/-
Definition prod_uncurry {X Y Z : Type}
(f : X → Y → Z) (p : X * Y) : Z
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
-/
def function.uncurry (f : α → β → γ) (p : α × β) : γ := f p.fst p.snd
/-
Example test_map1': map (plus 3) [2;0;2] = [5;3;5].
Proof. reflexivity. Qed.
-/
example : [2, 0, 2].map (add 3) = [5, 3, 5] := rfl
/-
Check @prod_curry.
Check @prod_uncurry.
Theorem uncurry_curry : ∀(X Y Z : Type)
(f : X → Y → Z)
x y,
prod_curry (prod_uncurry f) x y = f x y.
Proof.
(* FILL IN HERE *) Admitted.
Theorem curry_uncurry : ∀(X Y Z : Type)
(f : (X * Y) → Z) (p : X * Y),
prod_uncurry (prod_curry f) p = f p.
Proof.
(* FILL IN HERE *) Admitted.
-/
open poly.function
#check @curry
#check @uncurry
theorem uncurry_curry (f : α → β → γ) (a : α) (b : β) :
curry (uncurry f) a b = f a b := rfl
theorem curry_uncurry (f : α × β → γ) (p : α × β) :
uncurry (curry f) p = f p :=
begin
cases p with a b,
refl,
end
/-
Definition cnat := ∀X : Type, (X → X) → X → X.
-/
def cnat := ∀α : Type, (α → α) → α → α
/-
Definition one : cnat :=
fun (X : Type) (f : X → X) (x : X) ⇒ f x.
-/
def one : cnat := λ_ f, f
/-
Definition two : cnat :=
fun (X : Type) (f : X → X) (x : X) ⇒ f (f x).
-/
def two : cnat := λ_ f, f ∘ f
/-
Definition zero : cnat :=
fun (X : Type) (f : X → X) (x : X) ⇒ x.
-/
def zero : cnat := λ_ f x, x
/-
Definition three : cnat := @doit3times.
-/
def three : cnat := @doit3times
/-
Definition succ (n : cnat) : cnat
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example succ_1 : succ zero = one.
Proof. (* FILL IN HERE *) Admitted.
Example succ_2 : succ one = two.
Proof. (* FILL IN HERE *) Admitted.
Example succ_3 : succ two = three.
Proof. (* FILL IN HERE *) Admitted.
-/
def succ (n : cnat) : cnat := λα f x, f (n α f x)
example : succ zero = one := rfl
example : succ one = two := rfl
example : succ two = three := rfl
/-
Definition plus (n m : cnat) : cnat
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example plus_1 : plus zero one = one.
Proof. (* FILL IN HERE *) Admitted.
Example plus_2 : plus two three = plus three two.
Proof. (* FILL IN HERE *) Admitted.
Example plus_3 :
plus (plus two two) three = plus one (plus three three).
Proof. (* FILL IN HERE *) Admitted.
-/
def plus (m n : cnat) : cnat := λα f x, m α f (n α f x)
example : plus zero one = one := rfl
example : plus two three = plus three two := rfl
example : plus (plus two two) three = plus one (plus three three) := rfl
/-
Definition mult (n m : cnat) : cnat
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example mult_1 : mult one one = one.
Proof. (* FILL IN HERE *) Admitted.
Example mult_2 : mult zero (plus three three) = zero.
Proof. (* FILL IN HERE *) Admitted.
Example mult_3 : mult two three = plus three three.
Proof. (* FILL IN HERE *) Admitted.
-/
def mult (m n : cnat) : cnat := λα f x, m α (n α f) x
example : mult one one = one := rfl
example : mult zero (plus three three) = zero := rfl
example : mult two three = plus three three := rfl
/-
Definition exp (n m : cnat) : cnat
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
Example exp_1 : exp two two = plus two two.
Proof. (* FILL IN HERE *) Admitted.
Example exp_2 : exp three zero = one.
Proof. (* FILL IN HERE *) Admitted.
Example exp_3 : exp three two = plus (mult two (mult two two)) one.
Proof. (* FILL IN HERE *) Admitted.
-/
def exp (m n : cnat) : cnat := λα f x, n (α → α) (m α) f x
example : exp two two = plus two two := rfl
example : exp three zero = one := rfl
example : exp three two = plus (mult two (mult two two)) one := rfl
end poly
|
{"author": "michens", "repo": "learn-lean", "sha": "f38fc342780ddff5a164a18e5482163dea506ccd", "save_path": "github-repos/lean/michens-learn-lean", "path": "github-repos/lean/michens-learn-lean/learn-lean-f38fc342780ddff5a164a18e5482163dea506ccd/sf/v1/ch04_poly.lean"}
|
"""Summary
"""
import os
import yaml
import getopt
import sys
import time
import numpy as np
from tensorflow.keras import backend as K
from action_predict_attention import action_prediction
# from new_model import NewModel, HybridModel, MultiRNN3D, MultiRNN3D_MATT
from jaad_data import JAAD
# if use PIE data:
from pie_data import PIE
import tensorflow as tf
import wandb
gpus = tf.config.experimental.list_physical_devices('GPU')
assert len(gpus) > 0, "Not enough GPU hardware devices available"
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
tf.config.experimental.set_virtual_device_configuration(
gpu,
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=8192)] # TODO using too much memory?
)
def write_to_yaml(yaml_path=None, data=None):
"""
Write model to yaml results file
Args:
model_path (None, optional): Description
data (None, optional): results from the run
Deleted Parameters:
exp_type (str, optional): experiment type
overwrite (bool, optional): whether to overwrite the results if the model exists
"""
with open(yaml_path, 'w') as yamlfile:
yaml.dump(data, yamlfile)
def start_wandb(config, dataset_name, model_name, backbonename=''):
wandb_run = wandb.init(project='pcip', entity='sgt390', reinit=True, config=config)
wandb.run.name = f'{model_name}_{dataset_name}_{backbonename}'
return wandb_run
def stop_wandb(wandb_run):
wandb_run.finish()
def run(config_file=None):
"""
Run train and test on the dataset with parameters specified in configuration file.
Args:
config_file: path to configuration file in yaml format
dataset: dataset to train and test the model on (pie, jaad_beh or jaad_all)
"""
print(config_file)
# Read default Config file
configs_default = 'config_files/configs_default.yaml'
with open(configs_default, 'r') as f:
configs = yaml.safe_load(f)
with open(config_file, 'r') as f:
model_configs = yaml.safe_load(f)
# Update configs based on the model configs
for k in ['model_opts', 'net_opts']:
if k in model_configs:
configs[k].update(model_configs[k])
# Calculate min track size
tte = configs['model_opts']['time_to_event'] if isinstance(configs['model_opts']['time_to_event'], int) else \
configs['model_opts']['time_to_event'][1]
configs['data_opts']['min_track_size'] = configs['model_opts']['obs_length'] + tte
# update model and training options from the config file
for dataset_idx, dataset in enumerate(model_configs['exp_opts']['datasets']):
configs['data_opts']['sample_type'] = 'beh' if 'beh' in dataset else 'all'
configs['model_opts']['overlap'] = 0.6 if 'pie' in dataset else 0.8
configs['model_opts']['dataset'] = dataset.split('_')[0]
configs['train_opts']['batch_size'] = model_configs['exp_opts']['batch_size'][dataset_idx]
configs['train_opts']['lr'] = model_configs['exp_opts']['lr'][dataset_idx]
configs['train_opts']['epochs'] = model_configs['exp_opts']['epochs'][dataset_idx]
configs['train_opts']['learning_scheduler'] = {'learning_scheduler':{'early_stop':{'min_delta': 0.015, 'patience':5, 'restore_best_weights': True}}}
# configs['train_opts']['learning_scheduler'] = set(model_configs['exp_opts']['learning_scheduler'][dataset_idx]) if 'learning_scheduler' in model_configs['exp_opts'] else None
model_name = configs['model_opts']['model']
# Remove speed in case the dataset is jaad
if 'RNN' in model_name and 'jaad' in dataset:
configs['model_opts']['obs_input_type'] = configs['model_opts']['obs_input_type']
for k, v in configs.items():
print(k, v)
# set batch size
if model_name in ['ConvLSTM']:
configs['train_opts']['batch_size'] = 2
if model_name in ['C3D', 'I3D']:
configs['train_opts']['batch_size'] = 4
if model_name in ['PCPA']:
configs['train_opts']['batch_size'] = 1
if 'MultiRNN' in model_name:
configs['train_opts']['batch_size'] = 8
if model_name in ['TwoStream']:
configs['train_opts']['batch_size'] = 16
if configs['model_opts']['dataset'] == 'pie':
# imdb = PIE(data_path=os.environ.copy()['PIE_PATH'])
imdb = PIE(data_path='./PIE/')
elif configs['model_opts']['dataset'] == 'jaad':
# if use docker:
# imdb = JAAD(data_path=os.environ.copy()['JAAD_PATH'])
# if use local path
imdb = JAAD(data_path='./JAAD/')
# log run (requires "wandb login")
wandb_run = start_wandb(config=configs['data_opts'], dataset_name=dataset, model_name=model_name, backbonename=configs['net_opts']['backbone'])
wandb.config.update(configs['model_opts'])
wandb.config.update(configs['train_opts'])
# get sequences - beh or all
beh_seq_train = imdb.generate_data_trajectory_sequence('train', **configs['data_opts'])
# beh_seq_val = None
# Uncomment the line below touse validation set
beh_seq_val = imdb.generate_data_trajectory_sequence('val', **configs['data_opts'])
beh_seq_test = imdb.generate_data_trajectory_sequence('test', **configs['data_opts']) ## load_dataset
# get the model
method_class = action_prediction(configs['model_opts']['model'])(**configs['net_opts'])
# train and save the model
saved_files_path = method_class.train(beh_seq_train, beh_seq_val, **configs['train_opts'],
model_opts=configs['model_opts'])
# test and evaluate the model
acc, auc, f1, precision, recall = method_class.test(beh_seq_test, saved_files_path)
# save the results
data = {}
data['results'] = {}
data['results']['acc'] = float(acc)
data['results']['auc'] = float(auc)
data['results']['f1'] = float(f1)
data['results']['precision'] = float(precision)
data['results']['recall'] = float(recall)
write_to_yaml(yaml_path=os.path.join(saved_files_path, 'results.yaml'), data=data)
wandb.summary['test_acc'] = data['results']['acc']
wandb.summary['test_auc'] = data['results']['auc']
wandb.summary['test_f1'] = data['results']['f1']
wandb.summary['test_precision'] = data['results']['precision']
wandb.summary['test_recall'] = data['results']['recall']
# stop logging
stop_wandb(wandb_run)
data = configs
write_to_yaml(yaml_path=os.path.join(saved_files_path, 'configs.yaml'), data=data)
print('Model saved to {}'.format(saved_files_path))
def usage():
"""
Prints help
"""
print('Benchmark for evaluating pedestrian action prediction.')
print('Script for training and testing models.')
print('Usage: python train_test.py [options]')
print('Options:')
print('-h, --help\t\t', 'Displays this help')
print('-c, --config_file\t', 'Path to config file')
print()
if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['help', 'config_file'])
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
config_file = None
model_name = None
dataset = None
for o, a in opts:
if o in ["-h", "--help"]:
usage()
sys.exit(2)
elif o in ['-c', '--config_file']:
config_file = a
# if neither the config file or model name are provided
if not config_file:
print('\x1b[1;37;41m' + 'ERROR: Provide path to config file!' + '\x1b[0m')
usage()
sys.exit(2)
run(config_file=config_file)
|
{"hexsha": "366a36ed3a4af883221962fa01cc1641c6ee9918", "size": 7896, "ext": "py", "lang": "Python", "max_stars_repo_path": "train_test_attention.py", "max_stars_repo_name": "sgt390/Pedestrian_Crossing_Intention_Prediction", "max_stars_repo_head_hexsha": "ef1a956ae603b8d042253a225744a88bf07c30a4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "train_test_attention.py", "max_issues_repo_name": "sgt390/Pedestrian_Crossing_Intention_Prediction", "max_issues_repo_head_hexsha": "ef1a956ae603b8d042253a225744a88bf07c30a4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "train_test_attention.py", "max_forks_repo_name": "sgt390/Pedestrian_Crossing_Intention_Prediction", "max_forks_repo_head_hexsha": "ef1a956ae603b8d042253a225744a88bf07c30a4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6, "max_line_length": 184, "alphanum_fraction": 0.6393110436, "include": true, "reason": "import numpy", "num_tokens": 1882}
|
"""
Author: Shraey Bhatia
Date: October 2016
File: train_svm_model.py
This file is to generate the trained svm model. You can specify your own datset. By default
will take our dataset. Note a trained svm model for our datset is already in place in model_run/support_files.
You will need binary svm_learn from SVM rank. URL probvided in readme. Update the path here if different.
"""
from collections import defaultdict, Counter
import pandas as pd
import numpy as np
import os
import re
from scipy.spatial.distance import cosine
import networkx as nx
import pickle
#Global parameters for the model.
path_svm_learn = "model_run/support_files/svm_rank_learn" # path to learn SVM ranker binary file. You will need to download it.
output_svm_model = "svm_model" # name and location to put trained SVM model.
path_pagerank = "model_run/support_files/pagerank-titles-sorted.txt" # Path to pagerank file.
path_graph_cent = "model_run/support_files/graph_cent.pickle" # Path to graph-centrality file.
topic_data = "dataset/topics.csv" # The toopic datset. it conatains all topic terms.
topic_labels = "dataset/annotated_dataset.csv" # This is the label datset. It has 19 candidate labels for each topic.
svm_hyperparameter = 0.1 # The SVM hyperparameter.
# reading in topic terms.
topics = pd.read_csv(topic_data)
try:
new_frame= topics.drop('domain',1)
topic_list = new_frame.set_index('topic_id').T.to_dict('list')
except:
topic_list = topics.set_index('topic_id').T.to_dict('list')
# Reading in topic labels.
topic_labels = pd.read_csv(topic_labels, sep ="\t")
topic_labels_without_topic_id= list(topic_labels)
topic_labels_without_topic_id.remove('topic_id')
topic_labels['total'] = topic_labels[topic_labels_without_topic_id].sum(axis=1)
num_raters =topic_labels.count(axis=1) - 3
topic_labels['avg'] = topic_labels['total']/ num_raters
topic_groups = topic_labels.groupby('topic_id')
labels_list =[]
for group in topic_groups:
temp2 =[]
temp =list(group[1].label)
for elem in temp:
elem = elem.replace(" ","_")
temp2.append(elem)
labels_list.append(temp2)
# Reading in pageranks and converting it into a dictionary.
f2 = open(path_pagerank,'r')
p_rank_dict ={}
for line in f2:
word = line.split()
p_rank_dict[word[1].lower()] = word[0]
print( "page Rank model loaded" )
# Method to get letter trigrams for topic terms.
def get_topic_lt(elem):
tot_list =[]
for item in elem:
trigrams = [item[i:i+3] for i in range(0, len(item) - 2)]
tot_list = tot_list + trigrams
x = Counter(tot_list)
total = sum(x.values(), 0.0)
for key in x:
x[key] /= total
return x
"""
This method will be used to get first feature of letter trigrams for candidate labels and then rank them.
It use cosine similarity to get a score between a letter trigram vector of label candidate and vector of
topic terms.The ranks are given based on that score.
"""
def get_lt_ranks(lab_list,num):
topic_ls = get_topic_lt(topic_list[num])
val_dict = {}
val_list =[]
final_list=[]
for item in lab_list:
trigrams = [item[i:i+3] for i in range(0, len(item) - 2)] #Letter trigram for candidate label.
label_cnt = Counter(trigrams)
total = sum(label_cnt.values(), 0.0)
for key in label_cnt:
label_cnt[key] /= total
tot_keys = list(set(list(topic_ls.keys()) + list(label_cnt.keys())))
listtopic = []
listlabel = []
for elem in tot_keys:
if elem in topic_ls:
listtopic.append(topic_ls[elem])
else:
listtopic.append(0.0)
if elem in label_cnt:
listlabel.append(label_cnt[elem])
else:
listlabel.append(0.0)
val = 1 - cosine(np.array(listtopic),np.array(listlabel)) # Cosine Similarity
val_list.append((item,val))
rank_val = [i[1] for i in val_list]
arr = np.array(rank_val)
order = arr.argsort()
ranks = order.argsort()
for i,elem in enumerate(val_list):
final_list.append((elem[0],ranks[i],int(num)))
return final_list
# Generates letter trigram feature
temp_lt =[]
for j in range(0,len(topic_list)):
temp_lt.append(get_lt_ranks(labels_list[j],j))
letter_trigram_feature = [item for sublist in temp_lt for item in sublist]
print( "Letter trigram feature generated" )
# Changes the format of letter trigram into a dict of dict.
def change_format(f1):
lt_dict =defaultdict(dict)
for elem in f1:
x,y,z = elem
lt_dict[z][x] = y
return lt_dict
lt_dict = change_format(letter_trigram_feature)
"""
This method will be used to get feature of graph centrality scores for candidate labels and then rank them.
It uses pickled dictionary created from upsupervised_labels_db.py
"""
def dd(): # redefining dd to retrive it as pickle
"""
module level function for nested defaulctdict
"""
return defaultdict(float)
with open(path_graph_cent, 'rb') as handle:
graph_cent_dict = pickle.load(handle)
"""
This method is to prepare all features. It will take in dictionary of letter trigram, pagerank, list of
all columns for the datframe and name of features. It will generate four features in the dataframe namely
Pagerank, letter trigram, Topic overlap and Number of words in a label. Additionally DataFrame will also be given
the label name, topic_id and an avg_val which is average annotator value. This annotator avlue is calculated from
the candidate label datset and is used to train the SVM model.
"""
def prepare_features(letter_tg_dict,page_rank_dict,graph_cent_dict,cols,feature_names):
frame =pd.DataFrame()
for x in range(0,len(letter_tg_dict)):
a = letter_tg_dict[x]
temp_frame=pd.DataFrame()
for k in a:
new_list =[] # The list created to get values for dataframe.
new_list.append(k) # Candidate label name
new_list.append(x) # Topic_id
temp_val = a[k] # letter trigram feature
new_list.append(temp_val)
try:
pagerank = page_rank_dict[k] #Page Rank Feature
pagerank = float(pagerank)
except:
pagerank = np.nan
new_list.append(pagerank)
word_labels = k.split("_")
com_word_length = len(set(word_labels).intersection(set(topic_list[x]))) # Topic overlap feature
lab_length = len(word_labels) #Num of words in candidate label feature
new_list.append(lab_length)
new_list.append(com_word_length)
try:
graph_cent_score = graph_cent_dict[x][k] #Page Rank Feature
graph_cent_score = float(graph_cent_score)
except:
graph_cent_score = 0
new_list.append(graph_cent_score)
t_label = k.replace("_"," ")
val = topic_labels[(topic_labels['topic_id'] == x) & (topic_labels['label'] == t_label)]['avg'].values[0] #The annotator value.
new_list.append(val)
temp = pd.Series(new_list,index =cols)
temp_frame = temp_frame.append(temp,ignore_index =True)
temp_frame = temp_frame.fillna(0)
for item in feature_names:
temp_frame[item] = (temp_frame[item] - temp_frame[item].mean())/\
(temp_frame[item].max() - temp_frame[item].min()) #Feature normalization per topic.
frame = frame.append(temp_frame,ignore_index =True)
return frame
cols = ['label','topic_id','letter_trigram','prank','lab_length','common_words', 'graph_cent','avg_val'] # Name of columns in DataFrame
features =['letter_trigram','prank','lab_length','common_words', 'graph_cent'] # Feature names
# This function converts the dataset into a format which is taken by SVM ranker.
def convert_dataset(train,feature_names):
train_list=[]
for i in range(len(train)):
mystring = str(train[i:i+1]["avg_val"].values[0]) + " "+"qid:"+str(int(train[i:i+1]["topic_id"].values[0]))
for j,item in enumerate(feature_names):
mystring = mystring + " "+str(j+1)+":" +str(train[i:i+1][item].values[0])
mystring = mystring +" # "+train[i:i+1]['label'].values[0]
train_list.append(mystring)
return train_list
feature_dataset =prepare_features(lt_dict,p_rank_dict,graph_cent_dict,cols,features)
print( "\n" )
print( "All features generated" )
train_list = convert_dataset(feature_dataset,features)
print( "\n" )
print( "Preparing for generating SVM rank model" )
# This method generates the trained SVM file using SVM ranker learn,
def generate_svmrank(train_set):
h = open("train_temp.dat","w")
for item in train_set:
h.write("%s\n" % item)
h.close()
query = path_svm_learn +" -c "+str(svm_hyperparameter) +" train_temp.dat "+output_svm_model
os.system(query)
query2 = "rm train_temp.dat" # Delete temporary file created.
os.system(query2)
generate_svmrank(train_list)
|
{"hexsha": "c4b1f2d9f4c52c5520675cde0e755054080e01b6", "size": 9060, "ext": "py", "lang": "Python", "max_stars_repo_path": "train_svm_model.py", "max_stars_repo_name": "wpfjtmwls/CookieMonster", "max_stars_repo_head_hexsha": "2215d20d4fcf9482d988eb89dbb4d998794aae7b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-22T16:47:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-22T16:47:33.000Z", "max_issues_repo_path": "train_svm_model.py", "max_issues_repo_name": "wpfjtmwls/CookieMonster", "max_issues_repo_head_hexsha": "2215d20d4fcf9482d988eb89dbb4d998794aae7b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "train_svm_model.py", "max_forks_repo_name": "wpfjtmwls/CookieMonster", "max_forks_repo_head_hexsha": "2215d20d4fcf9482d988eb89dbb4d998794aae7b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0672268908, "max_line_length": 139, "alphanum_fraction": 0.6785871965, "include": true, "reason": "import numpy,from scipy,import networkx", "num_tokens": 2193}
|
import pytest
import numpy as np
import numpy.testing as npt
import toppra as ta
import toppra.constraint as constraint
from toppra.constants import JACC_MAXU
@pytest.fixture(params=[1, 2, 6], name='acceleration_pc_data')
def create_acceleration_pc_fixtures(request):
""" Parameterized Acceleration path constraint.
Return:
-------
data: A tuple. Contains path, ss, alim.
pc: A `PathConstraint`.
"""
if request.param == 1: # Scalar
pi = ta.PolynomialPath([1, 2, 3]) # 1 + 2s + 3s^2
ss = np.linspace(0, 1, 3)
alim = (np.r_[-1., 1]).reshape(1, 2) # Scalar case
pc_vel = constraint.JointAccelerationConstraint(alim)
data = (pi, ss, alim)
return data, pc_vel
if request.param == 2:
coeff = [[1., 2, 3], [-2., -3., 4., 5.]]
pi = ta.PolynomialPath(coeff)
ss = np.linspace(0, 0.75, 4)
alim = np.array([[-1., 2], [-2., 2]])
pc_vel = constraint.JointAccelerationConstraint(alim)
data = (pi, ss, alim)
return data, pc_vel
if request.param == 6:
np.random.seed(10)
N = 20
way_pts = np.random.randn(10, 6)
pi = ta.SplineInterpolator(np.linspace(0, 1, 10), way_pts)
ss = np.linspace(0, 1, N + 1)
vlim_ = np.random.rand(6)
alim = np.vstack((-vlim_, vlim_)).T
pc_vel = constraint.JointAccelerationConstraint(alim)
data = (pi, ss, alim)
return data, pc_vel
def test_constraint_type(acceleration_pc_data):
""" Syntactic correct.
"""
data, pc = acceleration_pc_data
assert pc.get_constraint_type() == constraint.ConstraintType.CanonicalLinear
def test_constraint_params(acceleration_pc_data):
""" Test constraint satisfaction with cvxpy.
"""
data, constraint = acceleration_pc_data
path, ss, alim = data
# An user of the class
a, b, c, F, g, ubound, xbound = constraint.compute_constraint_params(path, ss, 1.0)
assert xbound is None
N = ss.shape[0] - 1
dof = path.dof
ps = path.evald(ss)
pss = path.evaldd(ss)
F_actual = np.vstack((np.eye(dof), - np.eye(dof)))
g_actual = np.hstack((alim[:, 1], - alim[:, 0]))
npt.assert_allclose(F, F_actual)
npt.assert_allclose(g, g_actual)
for i in range(0, N + 1):
npt.assert_allclose(a[i], ps[i])
npt.assert_allclose(b[i], pss[i])
npt.assert_allclose(c[i], np.zeros_like(ps[i]))
assert ubound is None
assert xbound is None
def test_wrong_dimension(acceleration_pc_data):
data, pc = acceleration_pc_data
path_wrongdim = ta.SplineInterpolator(np.linspace(0, 1, 5), np.random.randn(5, 10))
with pytest.raises(ValueError) as e_info:
pc.compute_constraint_params(path_wrongdim, np.r_[0, 0.5, 1], 1.0)
assert e_info.value.args[0] == "Wrong dimension: constraint dof ({:d}) not equal to path dof ({:d})".format(
pc.get_dof(), 10
)
|
{"hexsha": "c0621f529421cb16b4eb7d116b58c8dc2538902b", "size": 2945, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/constraint/test_joint_acceleration.py", "max_stars_repo_name": "mrunaljsarvaiya/toppra", "max_stars_repo_head_hexsha": "468d81d23f37fdee06ea1aa3f1d445d747fad7f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/constraint/test_joint_acceleration.py", "max_issues_repo_name": "mrunaljsarvaiya/toppra", "max_issues_repo_head_hexsha": "468d81d23f37fdee06ea1aa3f1d445d747fad7f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/constraint/test_joint_acceleration.py", "max_forks_repo_name": "mrunaljsarvaiya/toppra", "max_forks_repo_head_hexsha": "468d81d23f37fdee06ea1aa3f1d445d747fad7f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.329787234, "max_line_length": 112, "alphanum_fraction": 0.6213921902, "include": true, "reason": "import numpy", "num_tokens": 872}
|
/*
* Copyright (C) 2019, Xilinx Inc - All rights reserved
* Xilinx Resource Manger U30 Encoder Plugin
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located 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.
*/
#ifndef _CODEC_ENCODER_XRM_PLG_U30_HPP_
#define _CODEC_ENCODER_XRM_PLG_U30_HPP_
//#include <string.h>
#include <stdio.h>
#include <syslog.h>
#include <vector>
#include <tuple>
#include <string>
#include <xrm.h>
#include <xrm_error.h>
#include <xrm_limits.h>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree_serialization.hpp>
#define XRM_PLUGIN_U30_ENC_ID 4
#define MAX_CH_SIZE 4096
#define MAX_OUT_ELEMENTS 64
#define U30_ENC_MAXCAPACITY (1920*1080*60*4)
#define U30_LA_MAXCAPACITY (1920*1080*60*2)
namespace pt = boost::property_tree;
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
struct FrameRate
{
int32_t numerator;
int32_t denominator;
};
struct Resolution
{
int32_t width;
int32_t height;
FrameRate frame_rate;
};
struct ResourceData
{
string function;
string format;
int32_t channel_load;
int32_t lookahead_load;
Resolution in_res;
vector<Resolution> out_res;
};
struct ParamsData
{
int32_t job_count;
};
int32_t xrmU30EncPlugin_api_version(void);
int32_t xrmU30EncPlugin_get_plugin_id(void);
int32_t xrmU30EncPlugin_calcPercent(xrmPluginFuncParam* param);
uint32_t extData[4];
xrmPluginData xrmU30EncPlugin{xrmU30EncPlugin_get_plugin_id, xrmU30EncPlugin_api_version, xrmU30EncPlugin_calcPercent, NULL, NULL,NULL,NULL,NULL,NULL,NULL,extData[4] };
#ifdef __cplusplus
}
#endif
#endif //_CODEC_ENCODER_XRM_PLG_U30_HPP_
|
{"hexsha": "ba6424bda07a81ce50e790d5c8462ec4cccecc1b", "size": 2474, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "codec-encoder-xrm-plg-u30.hpp", "max_stars_repo_name": "Xilinx/codec-encoder-xrm-plg-u30", "max_stars_repo_head_hexsha": "fcba0e2ca5125760212f2a22b3039911d7a61c15", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "codec-encoder-xrm-plg-u30.hpp", "max_issues_repo_name": "Xilinx/codec-encoder-xrm-plg-u30", "max_issues_repo_head_hexsha": "fcba0e2ca5125760212f2a22b3039911d7a61c15", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "codec-encoder-xrm-plg-u30.hpp", "max_forks_repo_name": "Xilinx/codec-encoder-xrm-plg-u30", "max_forks_repo_head_hexsha": "fcba0e2ca5125760212f2a22b3039911d7a61c15", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4888888889, "max_line_length": 169, "alphanum_fraction": 0.7073565077, "num_tokens": 608}
|
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
from torch.nn import functional as F
from Relation_batch import *
# Recurrent neural network (many-to-many)
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, num_layers, num_classes, batch=4, df=64, dk=32, Nr=4, use_LSTM=True):
super(RNN, self).__init__()
self.df = df
self.dk = dk
self.Nr = Nr
self.atom_num = 37
self.use_LSTM = use_LSTM
self.input_size = input_size
self.hidden_size = hidden_size
self.num_layers = num_layers
self.num_classes = num_classes
self.batch = batch
self.hidden = self.init_hidden()
# FC layer to joints and bones, to transform normalized atom feature to high dimension
self.fc_joints = nn.Linear(6, self.df)
self.fc_bones = nn.Linear(9, self.df)
# Relation module on Atom features
self.relation1 = RelationModule(n_relations = self.Nr, appearance_feature_dim=self.df,key_feature_dim = self.dk, num_parts=self.atom_num)
self.FC_relation1 = nn.Linear(self.df, self.df)
# transform atom feature matrix to class feature matrix, [N, appearance_feature_dim]
#self.W_c = nn.Parameter(nn.init.uniform_(torch.empty(self.num_classes, self.atom_num), -1/np.sqrt(self.atom_num), 1/np.sqrt(self.atom_num)))
self.W_c = nn.Linear(self.atom_num, self.num_classes, bias=False)
# Relation module on class features
self.relation2 = RelationModule(n_relations = self.Nr, appearance_feature_dim=self.df,key_feature_dim = self.dk, num_parts=self.num_classes)
self.temp_relation2 = TemporalRelation(feat_dim = self.df) # temporal relation module to smooth the class-level feature, with the two t-1, t+1 attention feature and current feature
self.FC_relation2 = nn.Linear(self.df, self.df)
self.FC_temp2 = nn.Linear(self.df, self.df)
# classifiers
self.tanh = nn.Tanh()
self.relu = nn.ReLU()
self.fc_out = nn.ModuleList()
if self.use_LSTM:
self.lstm_out = nn.ModuleList()
for i in range(self.num_classes):
if self.use_LSTM:
self.lstm_out.append(nn.LSTM(self.df, self.hidden_size, self.num_layers, batch_first=True))
self.fc_out.append(nn.Linear(self.hidden_size, 1))
else:
self.fc_out.append(nn.Linear(self.df, 1))
def init_hidden(self):
'''
Initialize hidden state parameter for backend LSTM
h_0, c_0 of shape (num_layers * num_directions, batch, hidden_size):
'''
h0 = nn.init.xavier_uniform_(torch.empty(self.num_layers, 1, self.hidden_size)).cuda()
c0 = nn.init.xavier_uniform_(torch.empty(self.num_layers, 1, self.hidden_size)).cuda()
return (Variable(h0), Variable(c0))
def atom_FC(self, x):
'''
Input: (batch_size, seq_length, 273) 273 = 20*6 + 17*9
Output: (batch_size, seq_length, 37, df)
'''
batch_size, seq_length, feat_num = x.size()
joints = torch.reshape(x[:,:,0:20*6], (batch_size, seq_length, 20, 6))
bones = torch.reshape(x[:,:,20*6:], (batch_size, seq_length, 17, 9))
# normalize the offset of joints and bones
joints[:, :, :, 3:] = F.normalize(joints[:, :, :, 3:], p=1, dim=2)
bones[:, : , :, 6:] = F.normalize(bones[:, : , :, 6:], p=1, dim=2)
return self.tanh(torch.cat((self.fc_joints(joints), self.fc_bones(bones)), -2))
def forward(self, x):
'''
Take batch of frames as input to compute attention weight
'''
atom_feats = self.atom_FC(x) # (batch_size, seq_length, 37, df)
relation_feats = [] # relation features
T = atom_feats.size()[1] # sequence length
for i in range(T//self.batch+1):
#print('batch: %d/%d' % (i*self.batch, T))
start_t = i*self.batch # start frame of batch forward
end_t = min(((i+1)*self.batch, T)) # end frame of batch forward
if start_t == end_t: # start frame == end_frame, do not need another batch
break
atoms = self.relation1((atom_feats[0,start_t:end_t,:,:])) # [B, N_atoms, df]
atoms = self.relu(self.FC_relation1(atoms)) # [B, N_atoms, df]
atoms = self.W_c(atoms.permute(0, 2, 1).contiguous()) # [B, df, N_classes]
atoms = atoms.permute(0, 2, 1).contiguous() # [B, N_classes, df]
class_feats = self.relation2((atoms)) # [B, N_classes, df]
#print(class_feats.size())
relation_feats.append(class_feats)
relation_feature = torch.cat(relation_feats,dim=0) # [t, N_classes, df]
relation_feature = self.relu(self.FC_relation2(relation_feature)) # FC after RM
relation_feature = self.tanh(self.FC_temp2(self.temp_relation2(relation_feature))) # FC after TM
relation_feature = relation_feature.view(1, atom_feats.size()[1], self.num_classes, self.df) # [batch_size, t, num_classes, df]
pred = []
for i in range(self.num_classes):
if self.use_LSTM:
out, _ = self.lstm_out[i](relation_feature[:,:,i,:])
#out, _ = self.lstm_out[i](relation_feature[:,:,i,:], self.hidden)
pred.append(self.tanh(self.fc_out[i](out)))
else:
pred.append(self.tanh(self.fc_out[i](relation_feature[:,:,i,:])))
out = torch.stack(pred, dim=-1) # [batch_size, t, 1, num_classes]
out = out.view(1, atom_feats.size()[1], -1)
return out
|
{"hexsha": "7bc1a789f4f3bce72d2767d42a0cfd1f20593745", "size": 5697, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/model_ST.py", "max_stars_repo_name": "weiyi1991/UA_Concurrent", "max_stars_repo_head_hexsha": "11238c778c60095abf326800d6e6a13a643bf071", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/model_ST.py", "max_issues_repo_name": "weiyi1991/UA_Concurrent", "max_issues_repo_head_hexsha": "11238c778c60095abf326800d6e6a13a643bf071", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-09-02T12:24:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T12:24:59.000Z", "max_forks_repo_path": "src/model_ST.py", "max_forks_repo_name": "weiyi1991/UA_Concurrent", "max_forks_repo_head_hexsha": "11238c778c60095abf326800d6e6a13a643bf071", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5391304348, "max_line_length": 188, "alphanum_fraction": 0.6143584343, "include": true, "reason": "import numpy", "num_tokens": 1439}
|
from vbhmm.hmm.vbhmm import VBHMM
import numpy as np
import matplotlib.pyplot as plt
from time import time
import sys
sys.path.append('.')
# data = np.load('vbhmm/data/hmm_data.npz')
# labels, obs = data['labels'], data['obs']
# obs = [obs]
data = np.load('vbhmm/data/params.npz', allow_pickle=True)
sigs, mus, obs, labels = data['sigs'], data['mus'], data['obs'], data['labels']
# obs = np.loadtxt('vbhmm/data/data_ball/1/positions.txt')
# obs = [obs]
# np.random.seed(133232)
np.random.seed(1336)
num_states = 5
obs_dim = obs[0].shape[1]
# Set priors
init_prior = {'omega0': np.ones(num_states) / num_states}
transition_prior = {'omega0': np.ones((num_states, num_states)) / num_states}
observation_prior = {'W0': np.eye((obs_dim)),
'nu0': 3,
'm0': np.zeros(obs_dim),
'beta0': 0.05}
vbhmm = VBHMM(obs=list(obs), n_states=num_states, act={}, init_prior=init_prior,
trans_prior=transition_prior, obs_prior=observation_prior)
log_liks = []
start = time()
log_liks = vbhmm.em(list(obs), n_iter=100)
print("Duration: {}".format( time() - start))
pi = np.exp(vbhmm.init_model.log_prob)
trans_prob = np.exp(vbhmm.trans_model.log_prob)
# obs_probs = np.exp(vbhmm.obs_model.log_likelihood(obs))
delta, predicted_sequence = vbhmm.viterbi(list(obs))
print("Predicted: \n", predicted_sequence[0])
print("True: \n", labels[0])
# plt.plot(log_liks)
# plt.show()
|
{"hexsha": "bf377b730e709f5b1e838c3a023ce3a7b9c6aa69", "size": 1439, "ext": "py", "lang": "Python", "max_stars_repo_path": "sds_bayesian_numpy/tests/test_vbhmm.py", "max_stars_repo_name": "thlautenschlaeger/sds", "max_stars_repo_head_hexsha": "710e7c6b1b15afd0476b6f0f60c03415571bebeb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sds_bayesian_numpy/tests/test_vbhmm.py", "max_issues_repo_name": "thlautenschlaeger/sds", "max_issues_repo_head_hexsha": "710e7c6b1b15afd0476b6f0f60c03415571bebeb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sds_bayesian_numpy/tests/test_vbhmm.py", "max_forks_repo_name": "thlautenschlaeger/sds", "max_forks_repo_head_hexsha": "710e7c6b1b15afd0476b6f0f60c03415571bebeb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2156862745, "max_line_length": 80, "alphanum_fraction": 0.6685198054, "include": true, "reason": "import numpy", "num_tokens": 418}
|
C
C
real*4 function ct_standard( rgb, ci, cimin, cimax )
C ----------------------------------------------------
C
C Function defining an standard colour-scale.
C
C defining:
C x = (ci-cimin)/(cimax-cimin)
C then:
C red = sin(power(red)*x)**2,
C green = sin(power(green)*x)**2,
C blue = sin(power(blue)*x)**2
*-
include '../include/tv_modify.inc'
integer rgb, ci, cimin, cimax
real*4 x
x = (float(ci-cimin)/float(cimax-cimin))
ct_standard = (sin( col_index(rgb)*x ))**2
end
|
{"hexsha": "4326ebb85a638053a72fcba507d68c19a24cd188", "size": 606, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "graphic_lib/ct_standard.f", "max_stars_repo_name": "CavendishAstrophysics/anmap", "max_stars_repo_head_hexsha": "efb611d7f80a3d14dc55e46cd01e8a622f6fd294", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-09-01T12:40:45.000Z", "max_stars_repo_stars_event_max_datetime": "2015-09-01T12:40:45.000Z", "max_issues_repo_path": "graphic_lib/ct_standard.f", "max_issues_repo_name": "CavendishAstrophysics/anmap", "max_issues_repo_head_hexsha": "efb611d7f80a3d14dc55e46cd01e8a622f6fd294", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graphic_lib/ct_standard.f", "max_forks_repo_name": "CavendishAstrophysics/anmap", "max_forks_repo_head_hexsha": "efb611d7f80a3d14dc55e46cd01e8a622f6fd294", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.25, "max_line_length": 59, "alphanum_fraction": 0.4702970297, "num_tokens": 164}
|
import numpy as np
import pandas as pd
# adding path to GPR_for_IM directory in order to import relevant scripts
import sys
sys.path.append('../')
import pk_tools as pk
def test_pk_perp_run():
#### Loading data ####
data = pd.read_pickle('../Data/data.pkl')
HI_data = data.beam.HI
#### Calculating power spectrum ####
# Dimension of data cube:
lx, ly, lz = 1000,1000, 924.78 #Mpc/h
nx, ny, nz = 256, 256, 285
# weighting and window function:
w = W = np.ones((nx,ny,nz))
# minimum and maximum k in each direction:
kmin_perp = 2*np.pi/np.sqrt(lx**2 + ly**2)
kmax_perp = 0.4
# set width of k bins to be 2*kmin
dk_perp = 2*kmin_perp
# number of k bins:
nkbin_perp = int((kmax_perp-kmin_perp)/dk_perp)
# setting array of k bin edges:
kbins_perp = np.arange(kmin_perp,kmax_perp,dk_perp)
# calculating spherically averaged power spectrum
HI_pk_perp = pk.PerpPk(HI_data, nx, ny, nz, lx, ly, lz, kbins_perp, w, W)[0]
#### Comparing with hardcoded result ####
hardcoded_result = np.load('hardcoded_results/pk_perp_result.npy')
ratio = HI_pk_perp/hardcoded_result
# asserting their differences aren't > 1%
# (some differences should be present because GPR is stochastic)
assert all([a == 1 for a in ratio])
|
{"hexsha": "bdb2e5e73e748a671d15ad7c1db53e29c5abd225", "size": 1326, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_pk_perp.py", "max_stars_repo_name": "LBJ-Wade/gpr4im", "max_stars_repo_head_hexsha": "c1ea849b4af7807cd3928b86b3692bd272e6f7d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-05-28T01:35:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T10:16:43.000Z", "max_issues_repo_path": "tests/test_pk_perp.py", "max_issues_repo_name": "LBJ-Wade/gpr4im", "max_issues_repo_head_hexsha": "c1ea849b4af7807cd3928b86b3692bd272e6f7d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/test_pk_perp.py", "max_forks_repo_name": "LBJ-Wade/gpr4im", "max_forks_repo_head_hexsha": "c1ea849b4af7807cd3928b86b3692bd272e6f7d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-05-28T07:22:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-11T10:08:25.000Z", "avg_line_length": 30.1363636364, "max_line_length": 80, "alphanum_fraction": 0.6553544495, "include": true, "reason": "import numpy", "num_tokens": 402}
|
# Note that this will erase your nvidia cache, ~/.nv/ComputeCache This may or may not be an undesirable side-effect for you. For example, cutorch will take 1-2 minutes or so to start after this cache has been emptied.
from __future__ import print_function, division
import time
import string
import random
import numpy as np
import pyopencl as cl
import subprocess
import os
from os.path import join
from gpuexperiments.callkernel import call_cl_kernel
#import gpuexperiments.cpu_check
from gpuexperiments.timecheck import inittime, timecheck
from lib_clgpuexp import clearComputeCache, getPtx, timeKernel, buildKernel, initClGpu
initClGpu()
sources = {
'kernel01': r"""
kernel void kernel01(global float *d, global float *out) {
float a = 0.0f;
a += 1.0f;
}
"""
,
'kernel02': r"""
kernel void kernel02(global float *d, global float *out) {
float a = 0.0f;
a += 1.0f;
a += 1.0f;
a += 1.0f;
a += 1.0f;
}
"""
,
'kernel03': r"""
kernel void kernel03(global float *d, global float *out) {
float a = 0.0f;
a += 1.0f;
a += 1.0f;
a += 1.0f;
a += 1.0f;
d[0] = a;
}
"""
,
'kernel04': r"""
kernel void kernel04(global float *data, global float *out) {
int a = 1;
a += 1;
int b = 1;
int c = 1;
int d = 1;
data[0] = a;
data[0] = b;
data[0] = c;
data[0] = d;
}
"""
,
'kernel05': r"""
kernel void kernel05(global float *data, global float *out) {
int a = 1;
a += 1;
int b = 1;
int c = 1;
int d = 1;
//data[0] = a;
//data[0] = b;
//data[0] = c;
//data[0] = d;
}
"""
,
'kernel06': r"""
kernel void kernel06(global float *data, global float *out) {
int a = 1;
a += 1;
int b = 1;
int c = 1;
int d = 1;
data[0] = a;
//data[0] = b;
//data[0] = c;
//data[0] = d;
}
"""
,
'kernel07': r"""
kernel void kernel07(global float *data, global float *out) {
int a = 3;
a += 1;
int b = 5;
int c = 6;
int d = 7;
data[0] = a;
data[0] = b;
data[0] = c;
data[0] = d;
}
"""
,
'kernel08': r"""
kernel void kernel08(global int *data, global float *out) {
int a = 3;
a += 1;
int b = 5;
int c = 6;
int d = 7;
data[0] = a;
data[0] = b;
data[0] = c;
data[0] = d;
}
"""
,
'kernel09': r"""
kernel void kernel09(global int *data, global int *out) {
data[get_global_id(0)] = 3;
}
"""
,
'kernel10': r"""
kernel void kernel10(global int *data, global int *out) {
data[get_local_id(0)] = 3;
}
"""
,
'kernel11': r"""
kernel void kernel11(global int *data, global int *out) {
data[get_global_id(0) << 1] = 3;
}
"""
,
'kernel12': r"""
kernel void kernel12(global int *data, global int *out) {
data[get_local_id(0) << 7] = 3;
}
"""
,
'kernel13': r"""
kernel void kernel13(global int *data, global int *out) {
data[(get_local_id(0) << 7) + 0] = 3;
data[(get_local_id(0) << 7) + 1] = 4;
data[(get_local_id(0) << 7) + 2] = 5;
data[(get_local_id(0) << 7) + 3] = 6;
}
"""
,
'kernel14': r"""
kernel void kernel14(global int *data, global int *out) {
int tid = get_local_id(0);
data[(tid << 7) + 0] = 3;
data[(tid << 7) + 1] = 4;
data[(tid << 7) + 2] = 5;
data[(tid << 7) + 3] = 6;
}
"""
,
'kernel15': r"""
kernel void kernel15(global int *data, global int *out) {
int tid = get_local_id(0);
int offset = (tid << 7);
data[offset + 0] = 3;
data[offset + 1] = 4;
data[offset + 2] = 5;
data[offset + 3] = 6;
}
"""
,
'kernel16': r"""
kernel void kernel16(global int *data, global int *out) {
int tid = get_local_id(0);
int offset = tid;
data[offset + 0] = 3;
data[offset + 1] = 4;
data[offset + 2] = 5;
data[offset + 3] = 6;
}
"""
,
'kernel17': r"""
kernel void kernel17(global int *data, global int *out) {
local int foo[32];
foo[0] = 31;
}
"""
,
'kernel18': r"""
kernel void kernel18(global int *data, global int *out) {
int a = 31;
a += 1;
local int foo[32];
foo[0] = a;
}
"""
,
'kernel19': r"""
kernel void kernel19(global int *data, global int *out) {
int a = 31;
int b = 5;
a += b;
local int foo[32];
foo[0] = a;
}
"""
,
'kernel20': r"""
kernel void kernel20(global int *data, global int *out) {
int a = 31;
for(int i = 0; i < 4; i++) {
a += 1;
}
int b = 5;
a += b;
local int foo[32];
foo[0] = a;
}
"""
,
'kernel21': r"""
kernel void kernel21(global int *data, global int *out) {
int gid = get_global_id(0);
data[0] = gid;
}
"""
,
'kernel22': r"""
kernel void kernel22(global int *data, global int *out) {
int gid = get_global_id(0);
data[gid] = gid;
}
"""
,
'kernel23': r"""
kernel void kernel23(global int *data, global int *out) {
int tid = get_local_id(0);
data[0] = tid;
}
"""
,
'kernel24': r"""
kernel void kernel24(global int *data, global int *out) {
int tid = get_local_id(0);
data[tid] = tid;
}
"""
,
'kernel25': r"""
kernel void kernel25(global int *data, global int *out) {
data[0] = 5;
}
"""
,
'kernel26': r"""
kernel void kernel26(global int *data, global int *out) {
int tid = get_local_id(0);
data[0] = tid;
data[0] = tid;
}
"""
,
'kernel27': r"""
kernel void kernel27(global int *data, global int *out) {
int tid = get_local_id(0);
data[0] = tid;
data[0] = get_local_id(0);
}
"""
,
'kernel28': r"""
kernel void kernel28(global int *data, global int *out) {
int gid = get_global_id(0);
data[gid % 1024 * 1024] = gid;
}
"""
,
'kernel29': r"""
kernel void kernel29(global int *data, global int *out) {
int gid = get_global_id(0);
data[(gid << 1) % 1024 * 1024] = gid;
}
"""
,
'kernel30': r"""
kernel void kernel30(global int *data, global int *out) {
int gid = get_global_id(0);
data[(gid << 2) % 1024 * 1024] = gid;
}
"""
,
'kernel31': r"""
kernel void kernel31(global int *data, global int *out) {
int gid = get_global_id(0);
data[(gid << 3) % 1024 * 1024] = gid;
}
"""
,
'kernel32': r"""
kernel void kernel32(global int *data, global int *out) {
int gid = get_global_id(0);
data[(gid << 4) % (1024 * 1024)] = gid;
}
"""
}
#sources = {'kernel1': kernel1, 'kernel2': kernel2, 'kernel3': kernel3}
#kernels = {}
#for name, source in ({'1': kernel1, '2': kernel2, '3': kernel3}).items():
# # -cl-mad-enable -cl-fast-relaxed-math -cl-no-signed-zeros
# kernels[name] = cl.Program(ctx, source).build(options='-cl-opt-disable').__getattr__('mykernel')
times = []
for name, source in sorted(sources.items()):
clearComputeCache()
kernel = buildKernel(name, source, options='-cl-opt-disable')
print('built kernel')
for it in range(3):
t = timeKernel(name, kernel, grid_x=1024*1024, block_x=32)
# times[name] = t
times.append({'name': name, 'time': t})
print(getPtx(name))
print('name\t\ttot ms')
for timeinfo in times:
print('%s\t%.1f' % (timeinfo['name'], timeinfo['time']))
|
{"hexsha": "a74e6b79d71bd419696ad6fe959e8732e782e60d", "size": 6967, "ext": "py", "lang": "Python", "max_stars_repo_path": "gpuexperiments/old/optimization_shortcutting.py", "max_stars_repo_name": "hughperkins/gpu-experiments", "max_stars_repo_head_hexsha": "3e5064e45682494be97190558807672b602f1c76", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-07-05T05:52:18.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-14T07:35:36.000Z", "max_issues_repo_path": "gpuexperiments/old/optimization_shortcutting.py", "max_issues_repo_name": "hughperkins/gpu-experiments", "max_issues_repo_head_hexsha": "3e5064e45682494be97190558807672b602f1c76", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gpuexperiments/old/optimization_shortcutting.py", "max_forks_repo_name": "hughperkins/gpu-experiments", "max_forks_repo_head_hexsha": "3e5064e45682494be97190558807672b602f1c76", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6735905045, "max_line_length": 219, "alphanum_fraction": 0.5617913019, "include": true, "reason": "import numpy", "num_tokens": 2419}
|
using Performance
using BenchmarkTools
using Test
@testset "structs" begin
##
## https://docs.julialang.org/en/v1/manual/performance-tips/#Type-declarations
##
# Unfortunately, this problem is not Revise-friendly. You'll have to restart your
# Julia session when you make substantive changes to the source code.
#
# Also, this problem uses an AbstractArray type as an example, but the lessons
# apply to almost any `struct`. One specific feature, though, is that
# `AbstractArray` has a standard
# [interface](https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array)
# that you may need to learn for this problem. Not very many types in Julia are this well
# standardized, but it's a good model for how to think about composability
# and extensability more generally, two key goals for "good" code.
a = DefaultArray([10, 20, 30], 0)
@test @inferred(a[2]) === 20
@test @inferred(a[4]) === 0
# This one is trickier. See https://docs.julialang.org/en/v1/manual/constructors/#Parametric-Constructors
# for help. See `?promote_type` as a hint for crafting your solution.
a = DefaultArray(Float32[10, 20, 30], 0)
@test @inferred(a[2]) === 20.0f0
@test @inferred(a[4]) === 0.0f0
a = DefaultArray(Float32[10, 20, 30], nothing)
@test eltype(a) === Union{Nothing, Float32}
end
|
{"hexsha": "756ecfb5c685663d4469de16d8530f98af7357d7", "size": 1376, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/structs.jl", "max_stars_repo_name": "nlaird/Performance.jl", "max_stars_repo_head_hexsha": "16b222fd1df7c5055ed6285377cca91aefb5a75b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2021-11-01T14:23:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:34:44.000Z", "max_issues_repo_path": "test/structs.jl", "max_issues_repo_name": "nlaird/Performance.jl", "max_issues_repo_head_hexsha": "16b222fd1df7c5055ed6285377cca91aefb5a75b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/structs.jl", "max_forks_repo_name": "nlaird/Performance.jl", "max_forks_repo_head_hexsha": "16b222fd1df7c5055ed6285377cca91aefb5a75b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-16T16:51:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-16T16:51:02.000Z", "avg_line_length": 45.8666666667, "max_line_length": 109, "alphanum_fraction": 0.6896802326, "num_tokens": 394}
|
import numpy as np
from .VariableUnitTest import VariableUnitTest
from gwlfe import enums
from gwlfe.Input.WaterBudget import Grow
class TestGrow(VariableUnitTest):
def test_Grow(self):
z = self.z
np.testing.assert_array_almost_equal(
Grow.Grow_f(z.Grow_0),
Grow.Grow(z.Grow_0) == enums.GROWING_SEASON, decimal=7)
|
{"hexsha": "07fac60a1108b0531ebcae83d1c68792a9d88d66", "size": 362, "ext": "py", "lang": "Python", "max_stars_repo_path": "test/unittests/test_Grow.py", "max_stars_repo_name": "rajadain/gwlf-e", "max_stars_repo_head_hexsha": "ba2fb9dbc08a3d7a4ced4b83b6f0f1307814e2a3", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unittests/test_Grow.py", "max_issues_repo_name": "rajadain/gwlf-e", "max_issues_repo_head_hexsha": "ba2fb9dbc08a3d7a4ced4b83b6f0f1307814e2a3", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unittests/test_Grow.py", "max_forks_repo_name": "rajadain/gwlf-e", "max_forks_repo_head_hexsha": "ba2fb9dbc08a3d7a4ced4b83b6f0f1307814e2a3", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.1333333333, "max_line_length": 67, "alphanum_fraction": 0.7071823204, "include": true, "reason": "import numpy", "num_tokens": 92}
|
import socket
import cv2
import numpy as np
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#ソケットオブジェクト作成
soc.connect(("127.0.0.1", 9001))#サーバー側のipと使用するポート(ポートはサーバーと同じにする。)
print("接続完了")
while(1):
data = soc.recv(921600)#引数は下記注意点参照
data = np.fromstring(data, dtype=np.uint8)#バイトデータ→ndarray変換
data = np.reshape(data,(480,640,3))#形状復元(これがないと一次元行列になってしまう。) reshapeの第二引数の(480,640,3)は引数は送られてくる画像の形状
cv2.imshow("", data)
k = cv2.waitKey(1)
if k == 13:
break
cv2.destroyAllWindows() # 作成したウィンドウを破棄
'''
https://qiita.com/DIODE/items/cb19d0f7d699c19cf4b2
'''
|
{"hexsha": "2cef898029950deee6b17cd7778cdbe152859009", "size": 598, "ext": "py", "lang": "Python", "max_stars_repo_path": "sample/imageClient.py", "max_stars_repo_name": "jettom/JtSpider", "max_stars_repo_head_hexsha": "7e2cb32415ca5d439b117c0277a7f7b2b27fa0bf", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-01-25T12:54:24.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-25T12:54:24.000Z", "max_issues_repo_path": "sample/imageClient.py", "max_issues_repo_name": "jettom/JtSpider", "max_issues_repo_head_hexsha": "7e2cb32415ca5d439b117c0277a7f7b2b27fa0bf", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sample/imageClient.py", "max_forks_repo_name": "jettom/JtSpider", "max_forks_repo_head_hexsha": "7e2cb32415ca5d439b117c0277a7f7b2b27fa0bf", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-16T01:18:25.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-16T01:18:25.000Z", "avg_line_length": 21.3571428571, "max_line_length": 105, "alphanum_fraction": 0.7073578595, "include": true, "reason": "import numpy", "num_tokens": 285}
|
module SemiLattice where
open import Prelude
open import PartialOrder as PO
import Chain
private
module IsSemiLat
{A : Set}(po : PartialOrder A)(_⊓_ : A -> A -> A) where
private open module PO = PartialOrder po
record IsSemiLattice : Set where
field
⊓-lbL : forall {x y} -> (x ⊓ y) ≤ x
⊓-lbR : forall {x y} -> (x ⊓ y) ≤ y
⊓-glb : forall {x y z} -> z ≤ x -> z ≤ y -> z ≤ (x ⊓ y)
open IsSemiLat public
record SemiLattice (A : Set) : Set1 where
field
po : PartialOrder A
_⊓_ : A -> A -> A
prf : IsSemiLattice po _⊓_
module SemiLat {A : Set}(L : SemiLattice A) where
private module SL = SemiLattice L
private module SLPO = POrder SL.po
private module IsSL = IsSemiLattice SL.po SL._⊓_ SL.prf
open SLPO public
open SL public hiding (prf)
open IsSL public
private open module C≤ = Chain _≤_ (\x -> ≤-refl) (\x y z -> ≤-trans)
renaming (_===_ to _-≤-_; chain>_ to trans>_)
⊓-commute : forall {x y} -> (x ⊓ y) == (y ⊓ x)
⊓-commute = ≤-antisym lem lem
where
lem : forall {x y} -> (x ⊓ y) ≤ (y ⊓ x)
lem = ⊓-glb ⊓-lbR ⊓-lbL
⊓-assoc : forall {x y z} -> (x ⊓ (y ⊓ z)) == ((x ⊓ y) ⊓ z)
⊓-assoc = ≤-antisym lem₁ lem₂
where
lem₁ : forall {x y z} -> (x ⊓ (y ⊓ z)) ≤ ((x ⊓ y) ⊓ z)
lem₁ = ⊓-glb (⊓-glb ⊓-lbL (≤-trans ⊓-lbR ⊓-lbL))
(≤-trans ⊓-lbR ⊓-lbR)
lem₂ : forall {x y z} -> ((x ⊓ y) ⊓ z) ≤ (x ⊓ (y ⊓ z))
lem₂ = ⊓-glb (≤-trans ⊓-lbL ⊓-lbL)
(⊓-glb (≤-trans ⊓-lbL ⊓-lbR) ⊓-lbR)
⊓-idem : forall {x} -> (x ⊓ x) == x
⊓-idem = ≤-antisym ⊓-lbL (⊓-glb ≤-refl ≤-refl)
≤⊓-L : forall {x y} -> (x ≤ y) ⇐⇒ ((x ⊓ y) == x)
≤⊓-L = (fwd , bwd)
where
fwd = \x≤y -> ≤-antisym ⊓-lbL (⊓-glb ≤-refl x≤y)
bwd = \x⊓y=x -> ≤-trans (==≤-R x⊓y=x) ⊓-lbR
≤⊓-R : forall {x y} -> (y ≤ x) ⇐⇒ ((x ⊓ y) == y)
≤⊓-R {x}{y} = (fwd , bwd)
where
lem : (y ≤ x) ⇐⇒ ((y ⊓ x) == y)
lem = ≤⊓-L
fwd = \y≤x -> ==-trans ⊓-commute (fst lem y≤x)
bwd = \x⊓y=y -> snd lem (==-trans ⊓-commute x⊓y=y)
⊓-monotone-R : forall {a} -> Monotone (\x -> a ⊓ x)
⊓-monotone-R x≤y = ⊓-glb ⊓-lbL (≤-trans ⊓-lbR x≤y)
⊓-monotone-L : forall {a} -> Monotone (\x -> x ⊓ a)
⊓-monotone-L {a}{x}{y} x≤y =
trans> x ⊓ a
-≤- a ⊓ x by ==≤-L ⊓-commute
-≤- a ⊓ y by ⊓-monotone-R x≤y
-≤- y ⊓ a by ==≤-L ⊓-commute
≤⊓-compat : forall {w x y z} -> w ≤ y -> x ≤ z -> (w ⊓ x) ≤ (y ⊓ z)
≤⊓-compat {w}{x}{y}{z} w≤y x≤z =
trans> w ⊓ x
-≤- w ⊓ z by ⊓-monotone-R x≤z
-≤- y ⊓ z by ⊓-monotone-L w≤y
⊓-cong : forall {w x y z} -> w == y -> x == z -> (w ⊓ x) == (y ⊓ z)
⊓-cong wy xz = ≤-antisym (≤⊓-compat (==≤-L wy) (==≤-L xz))
(≤⊓-compat (==≤-R wy) (==≤-R xz))
⊓-cong-L : forall {x y z} -> x == y -> (x ⊓ z) == (y ⊓ z)
⊓-cong-L xy = ⊓-cong xy ==-refl
⊓-cong-R : forall {x y z} -> x == y -> (z ⊓ x) == (z ⊓ y)
⊓-cong-R xy = ⊓-cong ==-refl xy
|
{"hexsha": "1b05377a3f6d6dbe285aa9616964f13937efaea6", "size": 2992, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/lattice/SemiLattice.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/lattice/SemiLattice.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/lattice/SemiLattice.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.92, "max_line_length": 71, "alphanum_fraction": 0.452540107, "num_tokens": 1475}
|
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from compas.geometry import Frame
from compas.geometry import Transformation
from pytest import fixture
from pytest import raises
from compas_mobile_robot_reloc.xforms import _coerce_cg_xform
from compas_mobile_robot_reloc.xforms import worldxy_to_robot_base_xform
from compas_mobile_robot_reloc.xforms import xform_to_xyz_quaternion
@fixture
def rcf():
return Frame([100, 100, 100], [1, 0, 0], [0, 0, 1])
@fixture
def rcf_matrix():
return [
[1.0, 0.0, 0.0, -100],
[0.0, 0.0, 1.0, -100],
[0.0, -1.0, 0.0, 100],
[0.0, 0.0, 0.0, 1.0],
]
@fixture
def rcf_xform():
# def rcf_xform(rcf_matrix):
M = [
[1.0, 0.0, 0.0, -100],
[0.0, 0.0, 1.0, -100],
[0.0, -1.0, 0.0, 100],
[0.0, 0.0, 0.0, 1.0],
]
return Transformation.from_matrix(M)
@fixture
def rcf_xyz_quaternion():
return [-100, -100, 100, 0.707, -0.707, 0, 0]
def test__coerce_cg_xform_cg_xform():
T = Transformation()
assert T == _coerce_cg_xform(T)
def test__coerce_cg_xform_ndarray(rcf_matrix):
try:
import numpy as np
_array = np.array(rcf_matrix)
assert isinstance(_coerce_cg_xform(_array), Transformation)
except ImportError:
pass
def test__coerce_cg_xform_none():
with raises(TypeError):
_coerce_cg_xform(None)
def test__coerce_cg_xform_invalid_sequence():
with raises(TypeError):
_coerce_cg_xform([None])
def test_worldxy_to_robot_base_xform(rcf, rcf_xform):
assert worldxy_to_robot_base_xform(rcf) == rcf_xform
def test_xform_to_xyz_quaternion(rcf_matrix, rcf_xyz_quaternion):
computed_quaternion = xform_to_xyz_quaternion(rcf_matrix)
try:
from pytest import approx
assert approx(computed_quaternion, abs=1e-3) == rcf_xyz_quaternion
except ImportError: # IPY
rounded_actual_result = [round(v, 3) for v in computed_quaternion]
assert rounded_actual_result == rcf_xyz_quaternion
|
{"hexsha": "eb4536a35751d2640337c692452d427542fd411b", "size": 2088, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_xforms.py", "max_stars_repo_name": "gramaziokohler/total_station_robot_localization", "max_stars_repo_head_hexsha": "aa4baa070d4d93a8058a0286615580ed8f95567f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/test_xforms.py", "max_issues_repo_name": "gramaziokohler/total_station_robot_localization", "max_issues_repo_head_hexsha": "aa4baa070d4d93a8058a0286615580ed8f95567f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 27, "max_issues_repo_issues_event_min_datetime": "2020-12-22T13:20:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-04T23:04:51.000Z", "max_forks_repo_path": "tests/test_xforms.py", "max_forks_repo_name": "gramaziokohler/total_station_robot_localization", "max_forks_repo_head_hexsha": "aa4baa070d4d93a8058a0286615580ed8f95567f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-26T02:59:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-26T02:59:59.000Z", "avg_line_length": 23.2, "max_line_length": 74, "alphanum_fraction": 0.6882183908, "include": true, "reason": "import numpy", "num_tokens": 647}
|
[STATEMENT]
lemma fpxs_val_compose_power [simp]:
assumes "r > 0"
shows "fpxs_val (fpxs_compose_power f r) = fpxs_val f * r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
[PROOF STEP]
proof (cases "f = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. f = 0 \<Longrightarrow> fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
2. f \<noteq> 0 \<Longrightarrow> fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
[PROOF STEP]
case [simp]: False
[PROOF STATE]
proof (state)
this:
f \<noteq> 0
goal (2 subgoals):
1. f = 0 \<Longrightarrow> fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
2. f \<noteq> 0 \<Longrightarrow> fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
[PROOF STEP]
proof (intro antisym)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. fpxs_val (fpxs_compose_power f r) \<le> fpxs_val f * r
2. fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)
[PROOF STEP]
show "fpxs_val (fpxs_compose_power f r) \<le> fpxs_val f * r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_val (fpxs_compose_power f r) \<le> fpxs_val f * r
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < r
goal (1 subgoal):
1. fpxs_val (fpxs_compose_power f r) \<le> fpxs_val f * r
[PROOF STEP]
by (intro fpxs_val_leI) (simp add: fpxs_nth_val_nonzero)
[PROOF STATE]
proof (state)
this:
fpxs_val (fpxs_compose_power f r) \<le> fpxs_val f * r
goal (1 subgoal):
1. fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)
[PROOF STEP]
show "fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)
[PROOF STEP]
proof (intro fpxs_val_geI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. fpxs_compose_power f r \<noteq> 0
2. \<And>ra. ra < fpxs_val f * r \<Longrightarrow> fpxs_nth (fpxs_compose_power f r) ra = (0::'a)
[PROOF STEP]
show "fpxs_nth (fpxs_compose_power f r) r' = 0" if "r' < fpxs_val f * r" for r'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_nth (fpxs_compose_power f r) r' = (0::'a)
[PROOF STEP]
unfolding fpxs_nth_compose_power[OF assms]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fpxs_nth f (r' / r) = (0::'a)
[PROOF STEP]
by (rule fpxs_nth_below_val) (use that assms in \<open>auto simp: field_simps\<close>)
[PROOF STATE]
proof (state)
this:
?r' < fpxs_val f * r \<Longrightarrow> fpxs_nth (fpxs_compose_power f r) ?r' = (0::'a)
goal (1 subgoal):
1. fpxs_compose_power f r \<noteq> 0
[PROOF STEP]
qed (use assms in auto)
[PROOF STATE]
proof (state)
this:
fpxs_val f * r \<le> fpxs_val (fpxs_compose_power f r)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
goal (1 subgoal):
1. f = 0 \<Longrightarrow> fpxs_val (fpxs_compose_power f r) = fpxs_val f * r
[PROOF STEP]
qed auto
|
{"llama_tokens": 1507, "file": "Formal_Puiseux_Series_Formal_Puiseux_Series", "length": 16}
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
""" sick, the spectroscopic inference crank. """
__author__ = "Andy Casey <arc@ast.cam.ac.uk>"
import argparse
import cPickle as pickle
import logging
import os
from glob import glob
import numpy as np
import yaml
import json
import sick
logger = logging.getLogger("sick")
def parser(input_args=None):
"""
Command line parser for *sick*.
"""
parser = argparse.ArgumentParser(
description="sick, the spectroscopic inference crank", epilog="Use "
"'sick-model COMMAND -h' for information on a specific command."
" Documentation and examples available at "
"https://github.com/andycasey/sick")
# Create a parent subparser.
parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument(
"-v", "--verbose", dest="verbose", action="store_true", default=False,
help="Vebose logging mode.")
parent_parser.add_argument(
"--clobber", dest="clobber", action="store_true", default=False,
help="Overwrite existing files if they already exist.")
parent_parser.add_argument(
"--debug", dest="debug", action="store_true", default=False,
help="Enable debug mode. Any suppressed exception will be re-raised.")
parent_parser.add_argument(
"-o", "--output_dir", dest="output_dir", nargs="?", type=str,
help="Directory for the files that will be created. If not given, this"
" defaults to the current working directory.", default=os.getcwd())
# Create subparsers.
subparsers = parser.add_subparsers(title="command", dest="command",
description="Specify the action to perform.")
# Create parser for the aggregate command
aggregate_parser = subparsers.add_parser(
"aggregate", parents=[parent_parser],
help="Aggregate many result files into a single tabular FITS file.")
aggregate_parser.add_argument("output_filename", type=str, nargs=1,
help="Output filename to aggregate results into.")
aggregate_parser.add_argument("result_filenames", nargs="+",
help="The YAML result filenames to combine.")
aggregate_parser.set_defaults(func=aggregate)
# Create parser for the estimate command
estimate_parser = subparsers.add_parser(
"estimate", parents=[parent_parser],
help="Compute a point estimate of the model parameters given the data.")
estimate_parser.add_argument(
"model", type=str,
help="The model filename in YAML-style formatting.")
estimate_parser.add_argument(
"spectrum_filenames", nargs="+",
help="Filenames of (observed) spectroscopic data.")
estimate_parser.add_argument(
"--filename-prefix", "-p", dest="filename_prefix",
type=str, help="The filename prefix to use for the output files.")
estimate_parser.add_argument(
"--no-plots", dest="plotting", action="store_false", default=True,
help="Disable plotting.")
estimate_parser.add_argument(
"--plot-format", "-pf", dest="plot_format", action="store", type=str,
default="png", help="Format for output plots (default: %(default)s)")
estimate_parser.add_argument(
"-r", dest="read_from_filename", action="store", type=bool,
default=False, help="Read spectrum paths from a filename.")
estimate_parser.set_defaults(func=estimate)
# Create parser for the optimise command
optimise_parser = subparsers.add_parser(
"optimise", parents=[parent_parser],
help="Optimise the model parameters, given the data.")
optimise_parser.add_argument(
"model", type=str,
help="The model filename in YAML-style formatting.")
optimise_parser.add_argument(
"spectrum_filenames", nargs="+",
help="Filenames of (observed) spectroscopic data.")
optimise_parser.add_argument(
"--filename-prefix", "-p", dest="filename_prefix", type=str,
help="The filename prefix to use for the output files.")
optimise_parser.add_argument(
"--no-plots", dest="plotting", action="store_false", default=True,
help="Disable plotting.")
optimise_parser.add_argument(
"--plot-format", "-pf", dest="plot_format", action="store", type=str,
default="png", help="Format for output plots (default: %(default)s)")
optimise_parser.add_argument(
"-r", dest="read_from_filename", action="store", type=bool,
default=False, help="Read spectrum paths from a filename.")
optimise_parser.set_defaults(func=optimise)
# Create parser for the infer command
infer_parser = subparsers.add_parser(
"infer", parents=[parent_parser],
help="Infer the model parameters, given the data.")
infer_parser.add_argument(
"model", type=str,
help="The model filename in YAML-style formatting.")
infer_parser.add_argument(
"spectrum_filenames", nargs="+",
help="Filenames of (observed) spectroscopic data.")
infer_parser.add_argument(
"--filename-prefix", "-p", dest="filename_prefix", type=str,
help="The filename prefix to use for the output files.")
infer_parser.add_argument(
"--no-chains", dest="save_chain_files", action="store_false",
default=True, help="Do not save the chains to disk.", )
infer_parser.add_argument(
"--no-plots", dest="plotting", action="store_false", default=True,
help="Disable plotting.")
infer_parser.add_argument(
"--plot-format", "-pf", dest="plot_format", action="store", type=str,
default="png", help="Format for output plots (default: %(default)s)")
infer_parser.add_argument(
"-r", dest="read_from_filename", action="store", type=bool,
default=False, help="Read spectrum paths from a filename.")
infer_parser.set_defaults(func=infer)
args = parser.parse_args(input_args)
logger.setLevel(logging.DEBUG if args.verbose else logging.INFO)
# Check plot formats.
if args.command.lower() in ("estimate", "optimise", "infer") \
and args.plotting:
import matplotlib.pyplot as plt
fig = plt.figure()
available = fig.canvas.get_supported_filetypes().keys()
plt.close(fig)
if args.plot_format.lower() not in available:
raise ValueError("plotting format {0} is unavailable: Options are:"\
" {1}".format(args.plot_format.lower(), ", ".join(available)))
# Create a default filename prefix based on the input filename arguments
if args.command.lower() in ("estimate", "optimise", "infer") \
and args.filename_prefix is None \
and not args.read_from_filename:
args.filename_prefix = _default_output_prefix(args.spectrum_filenames)
handler = logging.FileHandler("{}.log".format(
os.path.join(args.output_dir, args.filename_prefix)))
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
else:
args.filename_prefix = ""
return args
class loopify(object):
def __init__(self, function):
self.function = function
def __call__(self, args):
if args.read_from_filename:
# Read the filenames in from the first file given.
# Turn off read_from filename
# For each row in that file:
# + Generate a filename prefix and create a logging handler.
# + Set the spectrum filename to be the filenames in that row
# + Run the function on that file
raise a
# Check if args has a read_from_filename. If so then we should read
# the filenames from each line, run the function on that, and move on.
self.function(args)
def _announce_theta(theta):
"""
Announce theta values to the log.
"""
c = 299792.458 # km/s
is_a_redshift = lambda p: p == "z" or p[:2] == "z_"
for parameter, value in theta.items():
try:
value[0]
except (IndexError, TypeError):
message = "\t{0}: {1:.3f}".format(parameter, value)
if is_a_redshift(parameter):
message += " [{0:.1f} km/s]".format(value * c)
else:
# (MAP, u_pos, u_neg)
message = "\t{0}: {1:.3f} ({2:+.3f}, {3:+.3f})".format(parameter,
value[0], value[1], value[2])
if is_a_redshift(parameter):
message += " [{0:.1f} ({1:+.1f}, {2:+.1f}) km/s]".format(
value[0] * c, value[1] * c, value[2] * c)
logger.info(message)
def _prefix(args, f, char="-"):
return os.path.join(args.output_dir, char.join([args.filename_prefix, f]))
def _ok_to_clobber(args, filenames, char="-"):
if args.clobber:
return True
paths = [_prefix(args, _, char=char) for _ in filenames]
exists = map(os.path.exists, paths)
if any(exists):
raise IOError("expected output filename(s) already exist and we have "
"been told not to clobber them: {}".format(", ".join(
[path for path, e in zip(paths, exists) if e])))
return True
def _default_output_prefix(filenames):
"""
Return a default filename prefix for output files based on the input files.
:param filenames:
The input filename(s):
:type filenames:
str or list of str
:returns:
The extensionless common prefix of the input filenames:
:rtype:
str
"""
if isinstance(filenames, (str, )):
filenames = [filenames]
common_prefix, ext = os.path.splitext(os.path.commonprefix(
map(os.path.basename, filenames)))
common_prefix = common_prefix.rstrip("_-")
return common_prefix if len(common_prefix) > 0 else "sick"
def _pre_solving(args, expected_output_files):
# Check that it will be OK to clobber existing files.
_ok_to_clobber(args, expected_output_files)
# Load the model and data.
data = map(sick.specutils.Spectrum1D.load, args.spectrum_filenames)
model = sick.models.Model(args.model)
logger.info("Model configuration:")
map(logger.info, yaml.safe_dump(model._configuration, stream=None,
allow_unicode=True, default_flow_style=False).split("\n"))
logger.info("Model parameters ({}):".format(len(model.parameters)))
logger.info(", ".join(model.parameters))
# Define headers that we want in the results filename
metadata = {
"model": model.hash,
"input_filenames": ", ".join(args.spectrum_filenames),
"sick_version": sick.__version__,
"headers": {}
}
sn_values = []
for spectrum in data:
sn_values.extend(spectrum.flux/(spectrum.variance**0.5))
metadata["SNR"] = np.nanmedian(sn_values)
# Get some headers from the first spectrum.
for header in ("RA", "DEC", "COMMENT", "ELAPSED", "FIBRE_NUM", "LAT_OBS",
"LONG_OBS", "MAGNITUDE","NAME", "OBJECT", "UTEND", "UTDATE", "UTSTART",
"V_HELIO", "V_BARY"):
metadata["headers"][header] = data[0].headers.get(header, None)
return (model, data, metadata)
def _write_output(filename, output):
#with open(filename, "w+") as fp:
# yaml.safe_dump(metadata, stream=fp, allow_unicode=True,
# default_flow_style=False)
with open(filename, "w+") as fp:
pickle.dump(output, fp, -1)
logger.info("Results written to {}".format(filename))
return True
def estimate(args, **kwargs):
"""
Return a point estimate of the model parameters theta given the data.
"""
expected_output_files = kwargs.pop("expected_output_files", None)
if not expected_output_files:
expected_output_files = ["estimate.pkl"]
if args.plotting:
expected_output_files.extend(
["projection-estimate.{}".format(args.plot_format)])
model, data, metadata = _pre_solving(args, expected_output_files)
try:
theta, chisq, dof, model_fluxes = model.estimate(data, full_output=True,
debug=args.debug)
except:
logger.exception("Failed to estimate model parameters")
raise
logger.info("Estimated model parameters are:")
_announce_theta(theta)
logger.info("With a chi-sq value of {0:.1f} (reduced {1:.1f}; DOF {2:.1f})"\
.format(chisq, chisq/dof, dof))
metadata["estimated"] = {
"theta": theta,
"chi_sq": chisq,
"dof": dof,
"r_chi_sq": chisq/dof
}
if args.plotting:
fig = sick.plot.spectrum(data, model_flux=model_fluxes)
filename = _prefix(args, "projection-estimate.{}".format(
args.plot_format))
fig.savefig(filename)
logger.info("Created figure {}".format(filename))
if kwargs.pop("__return_result", False):
return (model, data, metadata, theta)
# Write the result to file.
_write_output(_prefix(args, "estimate.pkl"), metadata)
return None
def optimise(args, **kwargs):
"""
Optimise the model parameters.
"""
expected_output_files = kwargs.pop("expected_output_files", None)
if not expected_output_files:
expected_output_files = ["optimised.pkl"]
if args.plotting:
expected_output_files.extend([
"projection-estimate.{}".format(args.plot_format),
"projection-optimised.{}".format(args.plot_format)
])
# Estimate the model parameters, unless they are already specified.
model = sick.models.Model(args.model)
initial_theta = model._configuration.get("initial_theta", {})
if len(set(model.parameters).difference(initial_theta)) == 0:
model, data, metadata = _pre_solving(args, expected_output_files)
else:
model, data, metadata, initial_theta = estimate(args,
expected_output_files=expected_output_files, __return_result=True)
try:
theta, chisq, dof, model_fluxes = model.optimise(data,
initial_theta=initial_theta, full_output=True, debug=args.debug)
except:
logger.exception("Failed to optimise model parameters")
raise
metadata["optimised"] = {
"theta": theta,
"chi_sq": chisq,
"dof": dof,
"r_chi_sq": chisq/dof
}
logger.info("Optimised model parameters are:")
_announce_theta(theta)
logger.info("With a chi-sq value of {0:.1f} (reduced {1:.1f}; DOF {2:.1f})"\
.format(chisq, chisq/dof, dof))
if args.plotting:
fig = sick.plot.spectrum(data, model_flux=model_fluxes)
filename = _prefix(args, "projection-optimised.{}".format(
args.plot_format))
fig.savefig(filename)
logger.info("Created figure {}".format(filename))
if kwargs.pop("__return_result", False):
return (model, data, metadata, theta)
# Write the results to file.
_write_output(_prefix(args, "optimised.pkl"), metadata)
return None
def infer(args):
"""
Infer the model parameters.
"""
expected_output_files = ["inferred.pkl"]
if args.plotting:
expected_output_files.extend([each.format(args.plot_format) \
for each in "chain.{}", "corner.{}", "acceptance-fractions.{}",
"autocorrelation.{}"])
# Optimise them first.
model, data, metadata, optimised_theta = optimise(args,
expected_output_files=expected_output_files, __return_result=True)
# Get the inference parameters from the model configuration.
kwargs = model._configuration.get("infer", {})
[kwargs.pop(k, None) \
for k in ("debug", "full_output", "initial_proposal", "data")]
try:
theta, chains, lnprobability, acceptance_fractions, sampler, info_dict \
= model.infer(data, initial_proposal=optimised_theta,
full_output=True, debug=args.debug,
__keep_convolution_functions=True,
__show_progress_bar=True, **kwargs)
except:
logger.exception("Failed to infer model parameters")
raise
metadata["inferred"] = {
"theta": theta,
"chi_sq": info_dict["chi_sq"],
"dof": info_dict["dof"],
"r_chi_sq": info_dict["chi_sq"]/info_dict["dof"]
}
logger.info("Inferred parameters are:")
_announce_theta(theta)
# Write the results to file.
_write_output(_prefix(args, "inferred.pkl"), metadata)
# Write the chains, etc to disk.
if args.save_chain_files:
filename = _prefix(args, "chains.pkl")
with open(filename, "wb") as f:
pickle.dump(
(chains, lnprobability, acceptance_fractions, info_dict), f, -1)
logger.info("Saved chains to {}".format(filename))
# Make plots.
if args.plotting:
burn = info_dict["burn"]
# Any truth values to plot?
truths = model._configuration.get("truths", None)
if truths:
truths = [truths.get(p, np.nan) for p in model.parameters]
# Labels?
labels = model._configuration.get("labels", {})
labels = [labels.get(p, p) for p in info_dict["parameters"]]
# Acceptance fractions.
fig = sick.plot.acceptance_fractions(acceptance_fractions,
burn=burn)
_ = _prefix(args, "acceptance-fractions.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved acceptance fractions figure to {}".format(_))
# Autocorrelation.
fig = sick.plot.normalised_autocorrelation_function(chains, burn=burn)
_ = _prefix(args, "auto-correlation.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved auto-correlation figure to {}".format(_))
# Chains.
fig = sick.plot.chains(chains, labels=labels, burn=burn,
truths=truths)
_ = _prefix(args, "chains.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved chains figure to {}".format(_))
# Corner plots (astrophysical + all).
N = len(model.grid_points.dtype.names)
fig = sick.plot.corner(chains[:, burn:, :N].reshape(-1, N),
labels=labels, truths=truths[:N] if truths else None)
_ = _prefix(args, "corner.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved corner plot (astrophysical parameters) to {}"\
.format(_))
if len(model.parameters) > N:
fig = sick.plot.corner(chains[:, burn:, :].reshape(-1, len(theta)),
labels=labels, truths=truths)
_ = _prefix(args, "corner-all.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved corner plot (all parameters) to {}".format(_))
# Projections.
# Note here we need to scale the chains back to redshift so the data
# are generated properly.
fig = sick.plot.projection(data, model,
chains=chains[:, burn:, :]/info_dict["scales"],
parameters=theta.keys())
_ = _prefix(args, "projection.{}".format(args.plot_format))
fig.savefig(_)
logger.info("Saved projection plot to {}".format(_))
model._destroy_convolution_functions()
return None
def aggregate(args):
"""
Aggregate the results from multiple analyses into a single file.
"""
_ok_to_clobber(args, [args.output_filename[0]], "")
logger.debug("Aggregating to {}".format(args.output_filename[0]))
from astropy.table import Table
# What header keys should be passed to the final table?
header_keys = ["RA", "DEC", "NAME", "OBJECT", "MAGNITUDE",
"UTSTART", "UTEND", "UTDATE", "V_HELIO", "V_BARY"]
def load_result_file(filename, debug):
loader = yaml.load if filename.lower().endswith(".yaml") else pickle.load
with open(filename, "r") as fp:
try:
result = loader(fp)
except:
logger.exception("Could not read results filename: {}".format(
filename))
if debug: raise
else:
logger.debug("Successfully loaded results from {}".format(
filename))
return result
# Dows the first result actually exist, or is it a wildname mask?
if not os.path.exists(args.result_filenames[0]):
args.result_filenames = glob(args.result_filenames[0])
# Load the first set of results to get the parameter names.
first_results = load_result_file(args.result_filenames[0], True)
parameters = set(first_results["estimated"]["theta"].keys() \
+ first_results.get("optimised", {}).get("theta", {}).keys() \
+ first_results.get("inferred", {}).get("theta", {}).keys())
# Grab headers that exist.
header_keys = [k for k in header_keys if k in first_results["headers"]]
def default_values(stage):
keys = "chi_sq dof r_chi_sq".split()
default = dict(zip(["{0}_{1}".format(stage, key) for key in keys],
[np.nan] * len(keys)))
default["theta"] = dict(zip(
["{0}_{1}".format(stage, parameter) for parameter in parameters],
[np.nan] * len(parameters)))
return default
def extract_values(result, stage, parameter_prefixes=None):
_ = {
"{}_chi_sq".format(stage): result.get("chi_sq", np.nan),
"{}_dof".format(stage): result.get("dof", np.nan),
"{}_r_chi_sq".format(stage): result.get("r_chi_sq", np.nan)
}
_.update(dict(zip(
["{0}_{1}".format(stage, parameter) for parameter in parameters],
[result["theta"].get(param, np.nan) for param in parameters])))
if parameter_prefixes is not None:
for prefix in parameter_prefixes:
_.update(dict(zip(
["_".join([stage, prefix, parameter]) \
for parameter in parameters],
[result.get("{0}_{1}".format(prefix, parameter), np.nan) \
for parameter in parameters])))
return _
rows = []
columns = [] + header_keys + ["SNR", "model", "sick_version", "results_filename"]
for i, filename in enumerate(args.result_filenames):
result = load_result_file(filename, debug=args.debug)
logger.debug("Loaded results from {}".format(filename))
# Header information.
row = dict(zip(header_keys,
[result["headers"].get(k, None) for k in header_keys]))
row.update({
"model": result["model"],
"sick_version": result["sick_version"],
"results_filename": filename,
"SNR": result["SNR"]
})
# Include estimated values (which should always be present)
estimated = extract_values(result["estimated"], "estimated")
row.update(estimated)
# Include optimised values, if they exist.
optimised = extract_values(
result.get("optimised", default_values("optimised")), "optimised")
row.update(optimised)
# Include inferred values, if they exist.
inferred = extract_values(
result.get("inferred", default_values("inferred")), "inferred",
parameter_prefixes=["u_pos", "u_neg", "n_eff"])
row.update(inferred)
rows.append(row)
for each in (estimated, optimised, inferred):
columns += sorted(each.keys())
table = Table(rows=rows, names=columns)
try:
table.write(args.output_filename[0], overwrite=args.clobber)
except TypeError:
table.write(args.output_filename[0])
logger.info("Results from {0} files aggregated and saved to {1}".format(
len(args.result_filenames), args.output_filename[0]))
def main():
""" Parse arguments and execute the correct sub-parser. """
args = parser()
return args.func(args)
if __name__ == "__main__":
main()
|
{"hexsha": "67876cf2ba5aafdb10785604c89ff72908fd5a7b", "size": 24078, "ext": "py", "lang": "Python", "max_stars_repo_path": "sick/clis/run.py", "max_stars_repo_name": "andycasey/sick", "max_stars_repo_head_hexsha": "6c37686182794c4cafea45abf7062b30b789b1a2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2015-10-05T15:09:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-24T04:46:37.000Z", "max_issues_repo_path": "sick/clis/run.py", "max_issues_repo_name": "andycasey/sick", "max_issues_repo_head_hexsha": "6c37686182794c4cafea45abf7062b30b789b1a2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-05-18T11:34:04.000Z", "max_issues_repo_issues_event_max_datetime": "2016-05-17T02:28:52.000Z", "max_forks_repo_path": "sick/clis/run.py", "max_forks_repo_name": "andycasey/sick", "max_forks_repo_head_hexsha": "6c37686182794c4cafea45abf7062b30b789b1a2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-06-08T12:16:36.000Z", "max_forks_repo_forks_event_max_datetime": "2016-06-08T12:16:36.000Z", "avg_line_length": 35.8303571429, "max_line_length": 85, "alphanum_fraction": 0.6254256998, "include": true, "reason": "import numpy,from astropy", "num_tokens": 5451}
|
import logging
from typing import List, Dict, Tuple, Optional, Any
import numpy as np
OUT_RECALL = 0.9
OUT_PRECISION = 0.8
logger = logging.getLogger(__name__)
def span_to_label(tokens: List[str],
labeled_spans: Dict[Tuple[int, int], Any]) -> List[str]:
"""
Convert label spans to
:param tokens: a list of tokens
:param labeled_spans: a list of tuples (start_idx, end_idx, label)
:return: a list of string labels
"""
if labeled_spans:
assert list(labeled_spans.keys())[-1][1] <= len(tokens), ValueError("label spans out of scope!")
labels = ['O'] * len(tokens)
for (start, end), label in labeled_spans.items():
if type(label) == list or type(label) == tuple:
lb = label[0][0]
else:
lb = label
labels[start] = 'B-' + lb
if end - start > 1:
labels[start + 1: end] = ['I-' + lb] * (end - start - 1)
return labels
def label_to_span(labels: List[str],
scheme: Optional[str] = 'BIO') -> dict:
"""
convert labels to spans
:param labels: a list of labels
:param scheme: labeling scheme, in ['BIO', 'BILOU'].
:return: labeled spans, a list of tuples (start_idx, end_idx, label)
"""
assert scheme in ['BIO', 'BILOU'], ValueError("unknown labeling scheme")
labeled_spans = dict()
i = 0
while i < len(labels):
if labels[i] == 'O':
i += 1
continue
else:
if scheme == 'BIO':
if labels[i][0] == 'B':
start = i
lb = labels[i][2:]
i += 1
try:
while labels[i][0] == 'I':
i += 1
end = i
labeled_spans[(start, end)] = lb
except IndexError:
end = i
labeled_spans[(start, end)] = lb
i += 1
# this should not happen
elif labels[i][0] == 'I':
i += 1
elif scheme == 'BILOU':
if labels[i][0] == 'U':
start = i
end = i + 1
lb = labels[i][2:]
labeled_spans[(start, end)] = lb
i += 1
elif labels[i][0] == 'B':
start = i
lb = labels[i][2:]
i += 1
try:
while labels[i][0] != 'L':
i += 1
end = i
labeled_spans[(start, end)] = lb
except IndexError:
end = i
labeled_spans[(start, end)] = lb
break
i += 1
else:
i += 1
return labeled_spans
def initialise_transmat(observations,
label_set,
src_idx=None):
"""
initialize transition matrix
:param src_idx: the index of the source of which the transition statistics is computed.
If None, use all sources
:param label_set: a set of all possible label_set
:param observations: n_instances X seq_len X n_src X d_obs
:return: initial transition matrix and transition counts
"""
n_src = observations[0].shape[1]
trans_counts = np.zeros((len(label_set), len(label_set)))
if src_idx is not None:
for obs in observations:
for k in range(0, len(obs) - 1):
trans_counts[obs[k, src_idx].argmax(), obs[k + 1, src_idx].argmax()] += 1
else:
for obs in observations:
for k in range(0, len(obs) - 1):
for z in range(n_src):
trans_counts[obs[k, z].argmax(), obs[k + 1, z].argmax()] += 1
# update transition matrix with prior knowledge
for i, label in enumerate(label_set):
if label.startswith("B-") or label.startswith("I-"):
trans_counts[i, label_set.index("I-" + label[2:])] += 1
elif i == 0 or label.startswith("I-"):
for j, label2 in enumerate(label_set):
if j == 0 or label2.startswith("B-"):
trans_counts[i, j] += 1
transmat_prior = trans_counts + 1
# initialize transition matrix with dirichlet distribution
transmat_ = np.vstack([np.random.dirichlet(trans_counts2 + 1E-10)
for trans_counts2 in trans_counts])
return transmat_, transmat_prior
def initialise_emissions(observations,
label_set,
sources,
src_priors,
strength=1000):
"""
initialize emission matrices
:param sources: source names
:param src_priors: source priors
:param label_set: a set of all possible label_set
:param observations: n_instances X seq_len X n_src X d_obs
:param strength: Don't know what this is for
:return: initial emission matrices and emission counts?
"""
obs_counts = np.zeros((len(sources), len(label_set)), dtype=np.float64)
# extract the total number of observations for each prior
for obs in observations:
obs_counts += obs.sum(axis=0)
for source_index, source in enumerate(sources):
# increase p(O)
obs_counts[source_index, 0] += 1
# increase the "reasonable" observations
for pos_index, pos_label in enumerate(label_set[1:]):
if pos_label[2:] in src_priors[source]:
obs_counts[source_index, pos_index] += 1
# construct probability distribution from counts
obs_probs = obs_counts / (obs_counts.sum(axis=1, keepdims=True) + 1E-3)
# initialize emission matrix
matrix = np.zeros((len(sources), len(label_set), len(label_set)))
for source_index, source in enumerate(sources):
for pos_index, pos_label in enumerate(label_set):
# Simple case: set P(O=x|Y=x) to be the recall
recall = 0
if pos_index == 0:
recall = OUT_RECALL
elif pos_label[2:] in src_priors[source]:
_, recall = src_priors[source][pos_label[2:]]
matrix[source_index, pos_index, pos_index] = recall
for pos_index2, pos_label2 in enumerate(label_set):
if pos_index2 == pos_index:
continue
elif pos_index2 == 0:
precision = OUT_PRECISION
elif pos_label2[2:] in src_priors[source]:
precision, _ = src_priors[source][pos_label2[2:]]
else:
precision = 1.0
# Otherwise, we set the probability to be inversely proportional to the precision
# and the (unconditional) probability of the observation
error_prob = (1 - recall) * (1 - precision) * (0.001 + obs_probs[source_index, pos_index2])
# We increase the probability for boundary errors (i.e. I-ORG -> B-ORG)
if pos_index > 0 and pos_index2 > 0 and pos_label[2:] == pos_label2[2:]:
error_prob *= 5
# We increase the probability for errors with same boundary (i.e. I-ORG -> I-GPE)
if pos_index > 0 and pos_index2 > 0 and pos_label[0] == pos_label2[0]:
error_prob *= 2
matrix[source_index, pos_index, pos_index2] = error_prob
error_indices = [i for i in range(len(label_set)) if i != pos_index]
error_sum = matrix[source_index, pos_index, error_indices].sum()
matrix[source_index, pos_index, error_indices] /= (error_sum / (1 - recall) + 1E-5)
emission_priors = matrix * strength
emission_probs = matrix
return emission_probs, emission_priors
|
{"hexsha": "a329702d3804a4ae4099468f2112006961098f28", "size": 7968, "ext": "py", "lang": "Python", "max_stars_repo_path": "wrench/seq_labelmodel/chmm_src/Src/DataAssist.py", "max_stars_repo_name": "Stranger469/ARS2", "max_stars_repo_head_hexsha": "b6d62b66997180abe01b676d5359c20daa42b7ad", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-24T04:01:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-24T04:01:08.000Z", "max_issues_repo_path": "wrench/seq_labelmodel/chmm_src/Src/DataAssist.py", "max_issues_repo_name": "yinkaiw/wrench", "max_issues_repo_head_hexsha": "f20135eb9b1d51b5bad92b3a910efd92235df356", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "wrench/seq_labelmodel/chmm_src/Src/DataAssist.py", "max_forks_repo_name": "yinkaiw/wrench", "max_forks_repo_head_hexsha": "f20135eb9b1d51b5bad92b3a910efd92235df356", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5849056604, "max_line_length": 107, "alphanum_fraction": 0.5292419679, "include": true, "reason": "import numpy", "num_tokens": 1861}
|
import numpy as np
class MeanShift:
def __init__(self, radius=2):
self.radius = radius
def fit(self, data):
centroids = self.initialize_starting_centroids(data)
self.centroids = self.make_centroids(centroids, data)
def initialize_starting_centroids(self, data):
centroids = {}
for i in range(len(data)):
centroids[i] = data[i]
return centroids
def make_centroids(self, centroids, data):
while True:
new_centroids = self.find_new_centroids(centroids, data)
unique_centroids = self.remove_duplicate_centroids(new_centroids)
prev_centroids = dict(centroids)
centroids = self.set_unique_centroids_as_final_centroids(unique_centroids)
is_optimized = self.check_if_optimized(centroids, prev_centroids)
if is_optimized:
break
return centroids
def find_new_centroids(self, centroids, data):
new_centroids = []
for i in centroids:
centroid = centroids[i]
in_bandwith = self.fill_in_bandiwth_with_features_in_radius(centroid, data)
new_centroid = self.find_average_number(in_bandwith)
new_centroids.append(tuple(new_centroid))
return new_centroids
def find_average_number(self, in_bandwith):
return np.average(in_bandwith, axis=0)
def fill_in_bandiwth_with_features_in_radius(self, centroid, data):
in_bandwith = []
for featureset in data:
if self.is_in_radius_number(featureset, centroid):
in_bandwith.append(featureset)
return in_bandwith
def is_in_radius_number(self, featureset, centroid):
if np.linalg.norm(featureset - centroid) < self.radius:
return True
else:
return False
def remove_duplicate_centroids(self, new_centroids):
return sorted(list(set(new_centroids)))
def set_unique_centroids_as_final_centroids(self, uniques):
centroids = {}
for i in range(len(uniques)):
centroids[i] = np.array(uniques[i])
return centroids
def check_if_optimized(self, centroids, prev_centroids):
optimized = True
# check is it optimized
for i in centroids:
if not np.array_equal(centroids[i], prev_centroids[i]):
optimized = False
break
return optimized
|
{"hexsha": "3da7fc4300dabd09ec4c470043ea127780e60a3b", "size": 2450, "ext": "py", "lang": "Python", "max_stars_repo_path": "EyePatterns/clustering_algorithms/custom_mean_shift.py", "max_stars_repo_name": "Sale1996/Pattern-detection-of-eye-tracking-scanpaths", "max_stars_repo_head_hexsha": "15c832f26dce98bb95445f9f39f454f99bbb6029", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-07T08:02:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-07T08:02:30.000Z", "max_issues_repo_path": "EyePatterns/clustering_algorithms/custom_mean_shift.py", "max_issues_repo_name": "Sale1996/Pattern-detection-of-eye-tracking-scanpaths", "max_issues_repo_head_hexsha": "15c832f26dce98bb95445f9f39f454f99bbb6029", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EyePatterns/clustering_algorithms/custom_mean_shift.py", "max_forks_repo_name": "Sale1996/Pattern-detection-of-eye-tracking-scanpaths", "max_forks_repo_head_hexsha": "15c832f26dce98bb95445f9f39f454f99bbb6029", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0277777778, "max_line_length": 87, "alphanum_fraction": 0.646122449, "include": true, "reason": "import numpy", "num_tokens": 516}
|
\section{Blockchain}\label{sec:blockchain}
Recently, cryptocurrency has attracted extensive attention from both the industry and the academy. Bitcoin, often called the first cryptocurrency, had massive success, with the capital market coming to \$ 10 billion in 2016 \cite{coindesk}. Blockchain is the central mechanism of Bitcoin and was first proposed in 2008 and implemented in 2009 \cite{nakamoto2008bitcoin}. The blockchain can be considered a public ledger, in which All committed transactions are stored in a block chain. This chain grows continuously when new blocks are attached to it \cite{zheng2016blockchain}.
At the origin of the blockchain is the Bitcoin protocol, proposed by Satoshi Nakamoto \cite{nakamoto2008bitcoin}. This article proposes a \ac{P2P} network where transactions with the cryptocurrency bitcoin, proposed by customers, are received by servers, who will decide, through a consensus protocol based on cryptographic challenges, on the order in which they will be carried out and permanently stored in a chain of blocks, replicated on each server. According to \citeonline{FORMIGONI2017}, it was the creation of a digital currency that worked in a P2P network that allowed the sending of online payments in a completely secure way, without the involvement of financial institutions, for all participants from the web. In this sense, blockchain was created motivated by an efficient, economical, reliable, and secure system to conduct and record financial transactions. Hence the question: what is the relationship between blockchain and Bitcoin? Blockchain is the platform used for the operation of the Bitcoin network and several other cryptocurrencies.
While the system of financial institutions that serve as third parties reliable processors for processing payments work well for most still suffers from the shortcomings inherent in the model based on confidence. In addition, the cost of mediation increases transaction costs, limiting the minimum practical size of the transaction and eliminating the possibility of occasional small transactions. To solve these problems, \cite{nakamoto2008bitcoin} defined an electronic payment system called Bitcoin based on cryptographic proof rather than reliability, allowing either party to be willing to transact directly without the need for a reliable third party.
This revolution began with a new marginal economy on the Internet. Bitcoin emerges as an alternative currency issued and not backed by a central authority but by automated consensus among networked users. However, its true uniqueness lay in the fact that it did not require that users trust each other. Through self-policing algorithmically, any malicious attempt to circumvent the system would be rejected. In a precise and technical definition, Bitcoin is digital money transacted via the Internet in a decentralized system without bail, using a ledger called blockchain. It is a new way of combining peer-to-peer file sharing rent with public key encryption \cite{swan2015blockchain}.
For \cite{swan2015blockchain}, besides the currency ( "Blockchain 1.0"), smart contracts ("2.0") demonstrate how the blockchain is in a position to become the fifth disruptive computing paradigm after mainframes, PCs, Internet, and mobile/ social networks. Bitcoin is starting to become a digital currency, but the technology blockchain behind it can be much more significant.
The rapid growth in blockchain technology adoption and the development of applications based on this technology have revolutionized financial services industries. In addition to bitcoin, typical applications of blockchain usage vary from proprietary networks used to process financial claims, insurance claims to platforms that can issue and trade equity and corporate bonds \cite{michael2018blockchain}.
Blockchain exists with real-world implementations beyond cryptocurrencies, and these solutions deliver potent benefits to healthcare organizations, bankers, retailers, and consumers. The potential benefits of blockchain are more than just economic. They extend to the political, humanitarian, social, and scientific domains. Specific groups are already harnessing their technological capacity to solve real-world problems \cite{michael2018blockchain}.
\subsection{Blockchain Properties}\label{sec:propriedades}
Blockchain technology has key features such as centralization, persistence, anonymity, and auditability. Blockchain can function in a decentralized environment that is activated by integrating several key technologies such as cryptographic hash, digital signature (based on asymmetric encryption), and distributed consensus engine. With blockchain technology, a transaction may occur in a decentralized manner. As a result, blockchain can significantly save costs and improve efficiency \cite{zheng2016blockchain}. The primary properties of the blockchain are considered innovative and enable rapid adoption for technology \cite{greve2018blockchain}:
\begin{itemize}
\item Decentralization: Applications and systems run in a distributed manner, through the establishment of trust between the parties, without the need for a trusted intermediary entity. This is the primary motivator for the growing interest in the blockchain.
\item Availability and integrity: All datasets and transactions are securely replicated in different nodes to keep the system available and consistent.
\item Transparency and auditability: All transactions recorded in the ledger are public and can be verified and audited. Furthermore, technology codes are often open, verifiable.
\item Immutability and Irrefutability: Transactions recorded in the ledger are immutable. Once registered, they cannot be refuted. Updates are possible based on the generation of new transactions and the realization of a new consensus.
\item Privacy and Anonymity: It is possible to offer privacy to users without the third parties involved having access and control of their data. In technology, each user manages their keys, and each server node stores only encrypted fragments of user data. Transactions are somewhat anonymous, based on the address of those involved in the blockchain.
\item Disintermediation: Blockchain enables the integration between different systems directly and efficiently. Thus, it is considered a connector of complex systems (systems of systems), allowing the elimination of intermediaries to simplify the design of systems and processes.
\item Cooperation and Incentives: Offer of an incentive-based business model in the light of game theory. On-demand consensus is now offered as a service at different levels and scopes.
\end{itemize}
|
{"hexsha": "9e273b7131db099296131a5ea0d6f68b19392364", "size": 6665, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/2_THEORETICAL_BACKGROUND/sections/3_blockchain.tex", "max_stars_repo_name": "juniorug/Master-thesis", "max_stars_repo_head_hexsha": "c7e7e1da620ea717619c058c170db46cee8e9970", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/2_THEORETICAL_BACKGROUND/sections/3_blockchain.tex", "max_issues_repo_name": "juniorug/Master-thesis", "max_issues_repo_head_hexsha": "c7e7e1da620ea717619c058c170db46cee8e9970", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/2_THEORETICAL_BACKGROUND/sections/3_blockchain.tex", "max_forks_repo_name": "juniorug/Master-thesis", "max_forks_repo_head_hexsha": "c7e7e1da620ea717619c058c170db46cee8e9970", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 201.9696969697, "max_line_length": 1062, "alphanum_fraction": 0.8289572393, "num_tokens": 1239}
|
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from __future__ import division
import numpy as np
from testing import *
from pyecs import *
from pycompupipe.other import Event
from pycompupipe.components import (
GuiManager,GuiElement,
Selectable, FetchMouseCallbacksWhileSelected,
SelectedWhileMouseDown, Draggable)
import mock
class TestDraggable():
def test_selected_callbacks(self):
Component._reset_global()
e = Entity()
s = e.add_component(Selectable())
draggable = e.add_component(Draggable())
assert draggable.dragging == False
mocked_drag = mock.MagicMock()
mocked_drop = mock.MagicMock()
e.register_callback("drag", mocked_drag)
e.register_callback("drop", mocked_drop)
s.select()
assert draggable.dragging == True
assert mocked_drag.called
s.deselect()
assert draggable.dragging == False
assert mocked_drop.called
def test_moving(self):
Component._reset_global()
Selectable._reset_global()
e0 = Entity()
e0.add_component(GuiManager())
e1 = e0.add_entity(Entity())
gui = e1.add_component(GuiElement((0,0),(10,10)))
s = e1.add_component(Selectable())
e1.add_component(SelectedWhileMouseDown())
e1.add_component(FetchMouseCallbacksWhileSelected())
e0.fire_callbacks("awake")
draggable = e1.add_component(Draggable(0))
cursor_start = (5,5) # inside of gui element
# generate random walk
n = 30
dxy = np.random.normal(0,5,(n,2))
dxy[0] = 0
xy = np.cumsum(dxy,axis=0) + cursor_start
xy = np.round(xy)
# start dragging
e0.fire_callbacks("mousebuttondown",Event(pos=xy[0],button=1))
assert draggable.dragging == True
assert gui.position[0] == 0
assert gui.position[1] == 0
np.testing.assert_almost_equal(draggable.last_pos, xy[0])
# move around n times with random walk
# omit first pos, as these is for initial buttondown
for i in range(1,n-1):
e0.fire_callbacks("mousemotion",Event(pos=xy[i]))
# assert gui element was moved
assert gui.position[0] == xy[i,0] - cursor_start[0]
assert gui.position[1] == xy[i,1] - cursor_start[1]
# end moving by releasing the mouse button
e0.fire_callbacks("mousebuttonup",Event(pos=xy[-1]))
# NOTE: the position from mousebuttonup won't be used
# for moving, because gui element is deselected
assert gui.position[0] == xy[-2,0] - cursor_start[0]
assert gui.position[1] == xy[-2,1] - cursor_start[1]
assert draggable.dragging == False
t = TestDraggable()
t.test_moving()
|
{"hexsha": "d79ae7298f57b746be26a896aacc84e656c77dc0", "size": 2826, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/components/gui/interaction/test_draggable.py", "max_stars_repo_name": "xaedes/PyCompuPipe", "max_stars_repo_head_hexsha": "c5243a875bb007fc67b02e1ed08b1d62b6ddc483", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-12-22T16:59:08.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-22T16:59:08.000Z", "max_issues_repo_path": "tests/components/gui/interaction/test_draggable.py", "max_issues_repo_name": "xaedes/PyCompuPipe", "max_issues_repo_head_hexsha": "c5243a875bb007fc67b02e1ed08b1d62b6ddc483", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2016-01-06T13:06:43.000Z", "max_issues_repo_issues_event_max_datetime": "2016-01-07T11:58:16.000Z", "max_forks_repo_path": "tests/components/gui/interaction/test_draggable.py", "max_forks_repo_name": "xaedes/PyCompuPipe", "max_forks_repo_head_hexsha": "c5243a875bb007fc67b02e1ed08b1d62b6ddc483", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4, "max_line_length": 70, "alphanum_fraction": 0.6242038217, "include": true, "reason": "import numpy", "num_tokens": 680}
|
/**
* @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may find a copy of the License in the LICENCE file.
*
* 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.
*
* @file JPetGeomMappingTest.cpp
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE JPetGeomMappingTest
#include "JPetGeomMapping/JPetGeomMapping.h"
#include "JPetParamGetterAscii/JPetParamGetterAscii.h"
#include "JPetParamManager/JPetParamManager.h"
#include <boost/test/unit_test.hpp>
const std::string dataDir = "unitTestData/JPetGeomMappingTest/";
const std::string dataFileName = dataDir + "data.json";
struct myFixture
{
myFixture() : fparamManagerInstance(new JPetParamGetterAscii(dataFileName)) { fparamManagerInstance.fillParameterBank(1); }
~myFixture() {}
JPetParamManager fparamManagerInstance;
};
BOOST_AUTO_TEST_SUITE(FirstSuite)
BOOST_FIXTURE_TEST_CASE(mappingFirst, myFixture)
{
auto bank = fparamManagerInstance.getParamBank();
auto mapping = JPetGeomMapping(bank);
BOOST_REQUIRE_EQUAL(mapping.getLayersCount(), 3u);
JPetLayer layerOK(1, true, "Layer01", 42.5);
JPetLayer layerWrong(2, true, "Layer02", 50);
BOOST_REQUIRE_EQUAL(mapping.getLayerNumber(layerOK), 1u);
BOOST_REQUIRE_EQUAL(mapping.getLayerNumber(layerWrong), JPetGeomMapping::kBadLayerNumber);
BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(0), JPetGeomMapping::kBadSlotNumber);
BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(1), 2u);
BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(2), 1u);
auto sizes = mapping.getLayersSizes();
BOOST_REQUIRE(!sizes.empty());
BOOST_REQUIRE_EQUAL(sizes.size(), 3u);
}
BOOST_FIXTURE_TEST_CASE(getSlotNumber, myFixture)
{
auto bank = fparamManagerInstance.getParamBank();
auto mapping = JPetGeomMapping(bank);
JPetLayer layerOK(1, true, "Layer01", 42.5);
JPetLayer layerWrong(2, true, "Layer02", 50);
JPetBarrelSlot slotOK1(1, true, "C1_C2", 0, 1);
slotOK1.setLayer(layerOK);
JPetBarrelSlot slotOK2(2, true, "C3_C4", 90, 1);
slotOK2.setLayer(layerOK);
JPetBarrelSlot slotWrong(3, true, "C2AA", 5, 9);
BOOST_REQUIRE_EQUAL(mapping.getSlotNumber(slotOK1), 1u);
BOOST_REQUIRE_EQUAL(mapping.getSlotNumber(slotOK2), 2u);
BOOST_REQUIRE_EQUAL(mapping.getSlotNumber(slotWrong), JPetGeomMapping::kBadSlotNumber);
}
BOOST_AUTO_TEST_CASE(emptyBank)
{
JPetParamBank bank;
auto mapping = JPetGeomMapping(bank);
BOOST_REQUIRE(mapping.getTOMBMapping().empty());
}
BOOST_FIXTURE_TEST_CASE(minimalBank, myFixture)
{
auto bank = fparamManagerInstance.getParamBank();
auto mapper = JPetGeomMapping(bank);
auto mapping = mapper.getTOMBMapping();
BOOST_REQUIRE(!mapping.empty());
BOOST_REQUIRE_EQUAL(mapping.size(), 5u);
auto layer = 1;
auto slot = 1;
auto side = JPetPM::SideB;
auto thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapping.count(std::make_tuple(layer, slot, side, thresholdNumber)), 1u);
auto result_tomb = mapping.at(std::make_tuple(layer, slot, side, thresholdNumber));
BOOST_REQUIRE_EQUAL(result_tomb, 1);
layer = 1;
slot = 1;
side = JPetPM::SideA;
thresholdNumber = 1;
result_tomb = mapping.at(std::make_tuple(layer, slot, side, thresholdNumber));
BOOST_REQUIRE_EQUAL(result_tomb, 2);
layer = 1;
slot = 2;
side = JPetPM::SideA;
thresholdNumber = 1;
result_tomb = mapping.at(std::make_tuple(layer, slot, side, thresholdNumber));
BOOST_REQUIRE_EQUAL(result_tomb, 3);
layer = 1;
slot = 2;
side = JPetPM::SideB;
thresholdNumber = 1;
result_tomb = mapping.at(std::make_tuple(layer, slot, side, thresholdNumber));
BOOST_REQUIRE_EQUAL(result_tomb, 4);
layer = 2;
slot = 1;
side = JPetPM::SideA;
thresholdNumber = 1;
result_tomb = mapping.at(std::make_tuple(layer, slot, side, thresholdNumber));
BOOST_REQUIRE_EQUAL(result_tomb, 10);
}
BOOST_FIXTURE_TEST_CASE(getTOMB, myFixture)
{
auto bank = fparamManagerInstance.getParamBank();
auto mapper = JPetGeomMapping(bank);
auto layer = 1;
auto slot = 1;
auto side = JPetPM::SideB;
auto thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapper.getTOMB(layer, slot, side, thresholdNumber), 1);
layer = 1;
slot = 1;
side = JPetPM::SideA;
thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapper.getTOMB(layer, slot, side, thresholdNumber), 2);
layer = 1;
slot = 2;
side = JPetPM::SideA;
thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapper.getTOMB(layer, slot, side, thresholdNumber), 3);
layer = 1;
slot = 2;
side = JPetPM::SideB;
thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapper.getTOMB(layer, slot, side, thresholdNumber), 4);
layer = 2;
slot = 1;
side = JPetPM::SideA;
thresholdNumber = 1;
BOOST_REQUIRE_EQUAL(mapper.getTOMB(layer, slot, side, thresholdNumber), 10);
}
BOOST_AUTO_TEST_CASE(TestOfLargeBarrelJson)
{
JPetParamManager fparamManagerInstance(new JPetParamGetterAscii("unitTestData/JPetGeomMappingTest/large_barrel.json"));
fparamManagerInstance.fillParameterBank(43);
auto bank = fparamManagerInstance.getParamBank();
auto mapper = JPetGeomMapping(bank);
auto tombMap = mapper.getTOMBMapping();
BOOST_REQUIRE(!tombMap.empty());
BOOST_REQUIRE_EQUAL(tombMap.size(), 1536u);
}
BOOST_FIXTURE_TEST_CASE(radiusOfLayer, myFixture)
{
auto bank = fparamManagerInstance.getParamBank();
auto mapper = JPetGeomMapping(bank);
BOOST_REQUIRE_EQUAL(mapper.getRadiusOfLayer(1), 42.5);
BOOST_REQUIRE_EQUAL(mapper.getRadiusOfLayer(2), 46.75);
BOOST_REQUIRE_EQUAL(mapper.getRadiusOfLayer(3), 57.5);
BOOST_REQUIRE_EQUAL(mapper.getRadiusOfLayer(4), 0.);
BOOST_REQUIRE_EQUAL(mapper.getRadiusOfLayer(-1), 0.);
}
BOOST_AUTO_TEST_SUITE_END()
|
{"hexsha": "499cde6a5c66bda7897b0aeccb7736e32e520ff5", "size": 5996, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/Core/JPetGeomMapping/JPetGeomMappingTest.cpp", "max_stars_repo_name": "BlurredChoise/j-pet-framework", "max_stars_repo_head_hexsha": "f6728e027fae2b6ac0bdf274141254689894aa08", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10.0, "max_stars_repo_stars_event_min_datetime": "2016-07-04T14:54:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-11T14:19:29.000Z", "max_issues_repo_path": "tests/Core/JPetGeomMapping/JPetGeomMappingTest.cpp", "max_issues_repo_name": "BlurredChoise/j-pet-framework", "max_issues_repo_head_hexsha": "f6728e027fae2b6ac0bdf274141254689894aa08", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 119.0, "max_issues_repo_issues_event_min_datetime": "2016-06-17T20:22:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T08:50:22.000Z", "max_forks_repo_path": "tests/Core/JPetGeomMapping/JPetGeomMappingTest.cpp", "max_forks_repo_name": "BlurredChoise/j-pet-framework", "max_forks_repo_head_hexsha": "f6728e027fae2b6ac0bdf274141254689894aa08", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2016-06-17T17:56:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-30T22:20:19.000Z", "avg_line_length": 32.5869565217, "max_line_length": 125, "alphanum_fraction": 0.7521681121, "num_tokens": 1686}
|
import json
import pickle
import fire
import matplotlib.image as mpimg
import numpy as np
from cidan.LSSC.functions.data_manipulation import load_tif_stack, \
reshape_to_2d_over_time
from cidan.TimeTrace.spatial_temporal_denoising import calculate_spatial_time_denoising
from plotting_functions import time_graph
"""
--input_file /Users/sschickler/Code_Devel/HigleyData/File1_CPn_l5_gcamp6s_lan.tif
--eigen_norm_path /Users/sschickler/Code_Devel/LSSC-python/plotting_functions/data/cidan/File1_CPn_l5_gcamp6s_lan.tif300/embedding_norm_images/embedding_norm_image.png
--output test.pickle
--rois /Users/sschickler/Code_Devel/LSSC-python/plotting_functions/data/cidan/File1_CPn_l5_gcamp6s_lan.tif300/roi_list.json
--input_file /Users/sschickler/Code_Devel/HigleyData/File5_l23_gcamp6s_lan.tif
--eigen_norm_path /Users/sschickler/Code_Devel/LSSC-python/plotting_functions/data/cidan_worse/File5_l23_gcamp6s_lan.tif10021/embedding_norm_images/embedding_norm_image.png
--output test.pickle
--rois /Users/sschickler/Code_Devel/LSSC-python/plotting_functions/data/cidan_worse/File5_l23_gcamp6s_lan.tif10021/roi_list.json
"""
def extract_time_trace(input_file, rois, output, eigen_norm_path):
data = load_tif_stack(path=input_file, convert_to_32=False)
data = data.astype(float)
data[data > 2 ** 15 + 512] = 2 ** 15 + 512
data = data - 2 ** 15
data[data < 0] = 0
data = data[500:1500, 10:245, 10: 245]
# tiffile.imsave("test.tif",data.astype(np.float32))
# data_2 = reshape_to_2d_over_time(data)
with open(rois, "rb") as file:
rois = json.load(file)
test = np.zeros((235, 235))
eigen_norm = mpimg.imread(eigen_norm_path)
rois_processed = [[[x[0] - 10, x[1] - 10] for x in roi["coordinates"] if
235 > x[0] - 10 >= 0 and 235 > x[1] - 10 >= 0] for roi in
rois]
for num, pixels in enumerate(rois_processed):
for x in pixels:
test[x[0], x[1]] = 1
rois_processed_1d = [[x[1] + x[0] * 235 for x in roi] for roi in rois_processed]
time_traces, background = calculate_spatial_time_denoising(data, rois_processed,
# calculate_neuropil((235, 235),
# rois_processed_1d,
# test.reshape(
# (-1)),
# neuropil_boundary=0),
eigen_norm)
roi_traces = []
for roi in rois_processed_1d:
roi_traces.append(np.mean(reshape_to_2d_over_time(data)[roi], axis=0))
select_thing = [42, 43, 96]
mean = np.vstack([roi_traces[x] for x in select_thing] + [
np.mean(np.mean(data, axis=1), axis=1).reshape((1, -1))])
time_traces = time_traces[select_thing]
time_traces = np.vstack([time_traces, background.reshape((1, -1))])
print("STD True", mean.std(axis=1))
print("STD spatial", time_traces.std(axis=1))
print("Mean True", mean.mean(axis=1))
print("Mean spatial", time_traces.mean(axis=1))
import pandas as pd
test = pd.DataFrame.from_dict(
{"STD Mean trace": mean.std(axis=1),
"STD spatial": time_traces.std(axis=1),
"Mean mean trace": mean.mean(axis=1),
"Mean spatial": time_traces.mean(axis=1)})
with open(output, "wb") as file:
pickle.dump({"spatialtime": time_traces, "mean": mean}, file, protocol=4)
time_graph.create_graph(output, "File5.png")
if __name__ == '__main__':
fire.Fire(extract_time_trace)
|
{"hexsha": "d8ec230b31f6f84f10c2433358cc3757a9d2645a", "size": 3795, "ext": "py", "lang": "Python", "max_stars_repo_path": "explorations/time_trace_extract_test.py", "max_stars_repo_name": "Mishne-Lab/cidan", "max_stars_repo_head_hexsha": "3f579b6d5a49e17690e9aa07dfb60d3e8c05e681", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-24T17:47:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-20T16:19:53.000Z", "max_issues_repo_path": "explorations/time_trace_extract_test.py", "max_issues_repo_name": "Mishne-Lab/CIDAN", "max_issues_repo_head_hexsha": "30d1176773e3ad0f236ba342cba48c89492f4e63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-08-18T16:42:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-18T20:58:12.000Z", "max_forks_repo_path": "explorations/time_trace_extract_test.py", "max_forks_repo_name": "Mishne-Lab/cidan", "max_forks_repo_head_hexsha": "3f579b6d5a49e17690e9aa07dfb60d3e8c05e681", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-12T18:47:22.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-12T18:47:22.000Z", "avg_line_length": 46.8518518519, "max_line_length": 173, "alphanum_fraction": 0.6229249012, "include": true, "reason": "import numpy", "num_tokens": 1026}
|
""" file management, copying etc. """
import inspect
import json
import os
from shutil import copyfile
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from stable_baselines3.common.monitor import load_results
from .utils import plot_curves, ts2xy
def write_env_config(destination_directory, vec_env, updated_config=None):
"""Write configurations to file."""
try:
signature = inspect.getargspec(vec_env.venv.envs[0].env.__init__)
except:
# not using vec env
signature = inspect.getargspec(vec_env.__init__)
# print('signature', signature)
# print('config', os.path.join(destination_directory,"env_configs.txt"))
with open(os.path.join(destination_directory, "env_configs.txt"), "w") as outfile:
args_dict = {}
# skip urdf root and config file (should be obvious from context) for json
for i, k, v in zip(range(len(signature.defaults)), signature.args[1:], signature.defaults):
# print(k,v)
outfile.write(str(k) + " " + str(v) + "\n")
if i > 2:
args_dict[k] = v
if updated_config:
args_dict.update(updated_config)
# print(args_dict)
# print('config json', os.path.join(destination_directory,'env_configs.json'))
with open(os.path.join(destination_directory, "env_configs.json"), "w") as outfile:
json.dump(args_dict, outfile)
##########################################################################################################
# Stable baselines
##########################################################################################################
def get_latest_model(path):
"""Returns most recent model saved in path directory."""
files = os.listdir(path)
paths = [os.path.join(path, basename) for basename in files if basename.endswith(".zip")]
return max(paths, key=os.path.getctime)
def read_env_config(directory):
"""Read environment configuration from directory."""
with open(os.path.join(directory, "env_configs.json")) as f:
env_config = json.load(f)
return env_config
# stable baselines 3
def get_sorted_dirs(path):
files = os.listdir(path)
print("files", files)
dirs = [os.path.join(path, basename) for basename in files if os.path.isdir(os.path.join(path, basename))]
print("dirs", dirs)
# and basename is not '__pycache__'
if "__pycache__" in dirs:
dirs.remove("__pycache__")
return sorted(dirs, key=os.path.getctime)
def load_all_results(path):
"""Read all monitor files recursively, concatenate data together, plot."""
tslist = []
xaxis = "timesteps"
# get in order 0... N gas dirs
gas_dirs = get_sorted_dirs(path)
print("gas dirs", gas_dirs)
# each gas dir may have multiple directories w monitor files, depending on performance
for gas_dir in gas_dirs:
trial_dirs = get_sorted_dirs(gas_dir)
print("trial dirs", trial_dirs)
# extract monitor from each
for trial_dir in trial_dirs:
# for folder in dirs:
timesteps = load_results(trial_dir)
# if num_timesteps is not None:
timesteps = timesteps[timesteps.l.cumsum() <= 10e10]
tslist.append(timesteps)
# iterate through and concatenate data
xy_list = [ts2xy(timesteps_item, xaxis) for timesteps_item in tslist]
xy_list = concatenate_xy(xy_list)
plot_curves(xy_list, xaxis, "A1 Ep Rewards")
plt.ylabel("Episode Rewards")
xy_list = [ts2xy(timesteps_item, xaxis, True) for timesteps_item in tslist]
xy_list = concatenate_xy(xy_list)
plot_curves(xy_list, xaxis, "A1 Ep Len")
plt.ylabel("Episode Length")
def concatenate_xy(xy_list):
curr_t = xy_list[0][0]
curr_x = xy_list[0][1]
new_xy = [np.array([0]), np.array([0])]
for xy in xy_list:
new_xy[0] = np.concatenate((np.array(new_xy[0]), np.array(xy[0]) + new_xy[0][-1]))
new_xy[1] = np.concatenate((np.array(new_xy[1]), xy[1]))
return [tuple(new_xy)]
##########################################################################################################
# rllib
##########################################################################################################
def get_latest_directory(path):
"""Returns most recent directory in path."""
files = os.listdir(path)
paths = [os.path.join(path, f) for f in files if os.path.isdir(os.path.join(path, f))]
paths = [path for path in paths if "__pycache__" not in path]
return max(paths, key=os.path.getctime)
def get_latest_model_rllib(path):
"""Returns most recent model saved in path directory."""
checkpoint = get_latest_directory(path)
files = os.listdir(checkpoint)
paths = [
os.path.join(checkpoint, file)
for file in files
if (file.startswith("checkpoint") and not file.endswith(".tune_metadata"))
]
print(paths)
return paths[0]
|
{"hexsha": "5bbc9bb822f6005406b9ea69ac9af3d687e2f443", "size": 4950, "ext": "py", "lang": "Python", "max_stars_repo_path": "quadruped_spring/utils/file_utils.py", "max_stars_repo_name": "francescovezzi/quadruped_spring", "max_stars_repo_head_hexsha": "23848496ac7a4508e8a0f527e961c7956fd12f95", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-21T22:30:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T12:59:25.000Z", "max_issues_repo_path": "quadruped_spring/utils/file_utils.py", "max_issues_repo_name": "francescovezzi/quadruped_spring", "max_issues_repo_head_hexsha": "23848496ac7a4508e8a0f527e961c7956fd12f95", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-28T09:22:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T16:44:46.000Z", "max_forks_repo_path": "quadruped_spring/utils/file_utils.py", "max_forks_repo_name": "francescovezzi/quadruped_spring", "max_forks_repo_head_hexsha": "23848496ac7a4508e8a0f527e961c7956fd12f95", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3970588235, "max_line_length": 110, "alphanum_fraction": 0.6111111111, "include": true, "reason": "import numpy", "num_tokens": 1106}
|
"""
This code is a extension version of KNNGraph + SEAL, which aims to incorporate metric learning to compute the
distance while constructing the KNN Graph.
"""
import torch
import torch_geometric.nn
from torch.nn import BCEWithLogitsLoss
import torch.nn.functional as F
from torch_geometric import seed_everything
from torch_geometric.nn import Node2Vec
from torch_geometric.loader import DataLoader
from torch_geometric.data import Data
from torch_geometric.datasets import Planetoid
from torch_geometric.utils import train_test_split_edges, add_self_loops, negative_sampling,\
coalesce, from_networkx, to_scipy_sparse_matrix, k_hop_subgraph, to_undirected
from sklearn.metrics import roc_auc_score, average_precision_score
from scipy.sparse.csgraph import shortest_path
from torch_geometric.transforms import KNNGraph
from tensorboardX import SummaryWriter
from models import DGCNN
import os
import time
import pickle
import pandas as pd
import numpy as np
from tqdm import tqdm
import scipy.sparse as sp
from itertools import chain
import argparse
import os.path as osp
import warnings
warnings.filterwarnings('ignore')
# class KNNGraph(object):
# def __init__(self, k, loop=False, force_undirected=False, flow='source_to_target'):
# super(KNNGraph, self).__init__()
# self.k = k
# self.loop = loop
# self.force_undirected = force_undirected
# self.flow = flow
#
# def __call__(self, data):
# data.edge_attr = None
# batch = data.batch if 'batch' in data else None
# edge_index = torch_geometric.nn.knn_graph(data.pos, self.k, batch, loop=self.loop, flow=self.flow)
#
# if self.force_undirected:
# edge_index = to_undirected(edge_index, num_nodes=data.num_nodes)
#
# data.edge_index = edge_index
#
# def __repr__(self):
# return '{}(k={})'.format(self.__class__.__name__, self.k)
def load_data(dataset):
if dataset == 'cora':
dataset = Planetoid(root='../data/Planetoid', name='Cora')[0]
dataset.one_hot_y = F.one_hot(dataset.y).to(torch.float)
dataset.train_mask = dataset.val_mask = dataset.test_mask = None
return dataset
elif dataset == 'pubmed':
dataset = Planetoid('../data/Planetoid', 'PubMed')[0]
dataset.one_hot_y = F.one_hot(dataset.y).to(torch.float)
dataset.train_mask = dataset.val_mask = dataset.test_mask = None
return dataset
elif dataset == 'airport':
data_path = '/root/libisheng/HUAWEI/code/hgcn/data/airport'
dataset_str = 'airport'
graph = pickle.load(open(osp.join(data_path, dataset_str + '.p'), 'rb'))
dataset = from_networkx(graph)
dataset.x = dataset.feat
dataset.feat = None
return dataset
elif dataset == 'disease':
path = '../data/disease_lp/'
edges = pd.read_csv(path + 'disease_lp.edges.csv')
labels = np.load(path + 'disease_lp.labels.npy')
features = sp.load_npz(path + 'disease_lp.feats.npz').todense()
dataset = Data(
x=torch.tensor(features, dtype=torch.float),
edge_index=torch.tensor(edges.values).t().contiguous(),
one_hot_y=F.one_hot(torch.tensor(labels))
)
return dataset
else:
raise ValueError('Invalid dataset!')
def drnl_node_labeling(edge_index, src, dst, num_nodes=None):
global max_z
# Double-radius node labeling (DRNL).
src, dst = (dst, src) if src > dst else (src, dst)
adj = to_scipy_sparse_matrix(edge_index, num_nodes=num_nodes).tocsr()
idx = list(range(src)) + list(range(src + 1, adj.shape[0]))
adj_wo_src = adj[idx, :][:, idx]
idx = list(range(dst)) + list(range(dst + 1, adj.shape[0]))
adj_wo_dst = adj[idx, :][:, idx]
dist2src = shortest_path(adj_wo_dst, directed=False, unweighted=True,
indices=src)
dist2src = np.insert(dist2src, dst, 0, axis=0)
dist2src = torch.from_numpy(dist2src)
dist2dst = shortest_path(adj_wo_src, directed=False, unweighted=True,
indices=dst - 1)
dist2dst = np.insert(dist2dst, src, 0, axis=0)
dist2dst = torch.from_numpy(dist2dst)
dist = dist2src + dist2dst
dist_over_2, dist_mod_2 = dist // 2, dist % 2
z = 1 + torch.min(dist2src, dist2dst)
z += dist_over_2 * (dist_over_2 + dist_mod_2 - 1)
z[src] = 1.
z[dst] = 1.
z[torch.isnan(z)] = 0.
max_z = max(int(z.max()), max_z)
return z.to(torch.long)
def extract_enclosing_subgraphs(data, link_index, edge_index, y):
data_list = []
for src, dst in tqdm(link_index.t().tolist(), desc='Extracting...'):
# src: source dst: destination
sub_nodes, sub_edge_index, mapping, _ = k_hop_subgraph(
[src, dst], num_hops=2, edge_index=edge_index, relabel_nodes=True, num_nodes=data.num_nodes
)
src, dst = mapping.tolist()
# remove target link from the subgraph
mask1 = (sub_edge_index[0] != src) | (sub_edge_index[1] != dst)
mask2 = (sub_edge_index[0] != dst) | (sub_edge_index[1] != src)
sub_edge_index = sub_edge_index[:, mask1 & mask2]
# calculate node labeling
z = drnl_node_labeling(sub_edge_index, src, dst, num_nodes=sub_nodes.size(0))
sub_data = Data(x=data.x[sub_nodes], z=z, edge_index=sub_edge_index, y=y, sub_nodes_index=sub_nodes)
if 'one_hot_y' in data.keys:
sub_data.one_hot_y = data.one_hot_y[sub_nodes]
if 'pretrained_features' in data.keys:
sub_data.pretrained_features = data.pretrained_features[sub_nodes]
data_list.append(sub_data)
return data_list
def extract_subgraphs(data, use_label: bool, use_feat: bool):
print('=' * 50)
print('Starting extracting subgraphs...')
train_pos_list = extract_enclosing_subgraphs(
data, data.train_pos_edge_index, data.edge_index, 1
)
train_neg_list = extract_enclosing_subgraphs(
data, data.train_neg_edge_index, data.edge_index, 0
)
val_pos_list = extract_enclosing_subgraphs(
data, data.val_pos_edge_index, data.edge_index, 1
)
val_neg_list = extract_enclosing_subgraphs(
data, data.val_neg_edge_index, data.edge_index, 0
)
test_pos_list = extract_enclosing_subgraphs(
data, data.test_pos_edge_index, data.edge_index, 1
)
test_neg_list = extract_enclosing_subgraphs(
data, data.test_neg_edge_index, data.edge_index, 0
)
print('Finished extracting subgraphs.')
print('=' * 50)
for data in chain(train_pos_list, train_neg_list, val_pos_list, val_neg_list, test_pos_list, test_neg_list):
# data.x = torch.cat((F.one_hot(data.z, max_z + 1).to(torch.float), data.knn_emb), dim=1)
if use_feat and 'x' in data.keys:
data.x = torch.cat((data.x, F.one_hot(data.z, max_z+1).to(torch.float)), dim=1)
else:
data.x = F.one_hot(data.z, max_z + 1).to(torch.float)
data.z = None
if use_label and 'one_hot_y' in data.keys:
data.x = torch.cat((data.x, data.one_hot_y), dim=1)
data.one_hot_y = None
return train_pos_list + train_neg_list, val_pos_list + val_neg_list, test_pos_list + test_neg_list
def train_node2vec_emb(data):
print('=' * 50)
print('Start train node2vec model on the knn graph.')
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
model = Node2Vec(data.edge_index, embedding_dim=32, walk_length=10, context_size=5, walks_per_node=10,
num_negative_samples=1, p=1, q=1, sparse=False, num_nodes=data.num_nodes).to(device)
loader = model.loader(batch_size=128, shuffle=True, num_workers=4)
optimizer = torch.optim.Adam(list(model.parameters()), lr=0.001)
minimal_loss = 1e9
patience = 0
patience_threshold = 10
for epoch in range(1, 201):
model.train()
total_loss = 0
for pos_rw, neg_rw in loader:
optimizer.zero_grad()
loss = model.loss(pos_rw.to(device), neg_rw.to(device))
loss.backward()
optimizer.step()
total_loss += loss.item()
loss = total_loss / len(loader)
if loss < minimal_loss:
minimal_loss = loss
patience = 0
else:
patience += 1
if patience >= patience_threshold:
print('Early Stop.')
break
print("Epoch: {:02d}, loss: {:.4f}".format(epoch, loss))
print('Finished training.')
print('=' * 50)
return model()
def train(model, train_loader, device, optimizer, train_dataset):
model.train()
total_loss = 0
for data in train_loader:
data = data.to(device)
optimizer.zero_grad()
logits = model(data.x, data.edge_index, data.batch)
loss = BCEWithLogitsLoss()(logits.view(-1), data.y.to(torch.float))
loss.backward()
optimizer.step()
total_loss += loss.item() * data.num_graphs
return total_loss / len(train_dataset)
@torch.no_grad()
def test(loader, model, device):
model.eval()
y_pred, y_true = [], []
for data in loader:
data = data.to(device)
logits = model(data.x, data.edge_index, data.batch)
y_pred.append(logits.view(-1).cpu())
y_true.append(data.y.view(-1).cpu().to(torch.float))
return roc_auc_score(torch.cat(y_true), torch.cat(y_pred)), \
average_precision_score(torch.cat(y_true), torch.cat(y_pred))
def construct_KNN_graph(dataset, weight):
dataset.pos = torch.mm(dataset.x, weight)
k = int(dataset.num_edges / dataset.num_nodes) + 1
trans = KNNGraph(k, loop=False, force_undirected=True)
knn_graph = trans(dataset.clone())
return knn_graph
def run():
parser = argparse.ArgumentParser('Configurations for SEAL with data augmentations')
parser.add_argument('--dataset', default='cora', type=str)
parser.add_argument('--use_label', action='store_true',
help='whether to use label information as additional features')
parser.add_argument('--epochs', default=401, type=int, help='training epochs')
parser.add_argument('--cuda', default=torch.cuda.is_available(), type=bool)
parser.add_argument('--lr', default=0.0001, type=float, help='learning rate')
parser.add_argument('--wd', default=5e-4, type=float, help='weight decaying')
parser.add_argument('--val_ratio', default=0.05, type=float, help='validation links ratio')
parser.add_argument('--test_ratio', default=0.10, type=float, help='test link ratio')
parser.add_argument('--bs', default=32, type=int, help='batch size')
parser.add_argument('--use_feat', action='store_true', help='whether to use original feature')
parser.add_argument('--knn_usage', default='add_feat', choices=['add_feat', 'concat_graph'])
parser.add_argument('--patience', default=20, type=int, help='early stop steps')
args = parser.parse_args()
print(args)
dataset = load_data(args.dataset)
# train/val/test split
data = train_test_split_edges(dataset, val_ratio=args.val_ratio, test_ratio=args.test_ratio)
edge_index, _ = add_self_loops(data.train_pos_edge_index)
data.train_neg_edge_index = negative_sampling(
edge_index=edge_index,
num_nodes=data.num_nodes,
num_neg_samples=data.train_pos_edge_index.size(1)
)
data.edge_index = data.train_pos_edge_index
train_graphs, val_graphs, test_graphs = extract_subgraphs(data, args.use_label, args.use_feat)
device = torch.device('cuda:0' if args.cuda else 'cpu')
model = DGCNN(train_graphs, hidden_channels=32, num_layers=3).to(device)
weight1 = torch.nn.Parameter(torch.randn(dataset.num_features, 32), requires_grad=True)
optimizer = torch.optim.Adam([{'params': weight1}, {'params': model.parameters()}], lr=args.lr,
weight_decay=args.wd)
best_val_auc = test_auc = test_ap = 0
patience = 0
for epoch in range(1, args.epochs):
knn_graph = construct_KNN_graph(dataset, weight1)
knn_emb = train_node2vec_emb(knn_graph)
train_loader = DataLoader(train_graphs, batch_size=args.bs, shuffle=True)
val_loader = DataLoader(val_graphs, batch_size=args.bs, shuffle=False)
test_loader = DataLoader(test_graphs, batch_size=args.bs, shuffle=False)
loss = train(model, train_loader, device, optimizer, train_graphs)
val_auc, val_ap = test(val_loader, model, device)
if val_auc > best_val_auc:
best_val_auc = val_auc
test_auc, test_ap = test(test_loader, model, device)
patience = 0
# saving model parameters
state = {'model': model.state_dict(), 'auc': test_auc, 'ap': test_ap, 'epoch': epoch}
save_path = '../checkpoint/KNN-SEAL/'
if not osp.exists(save_path):
os.mkdir(save_path)
torch.save(state, osp.join(save_path, args.dataset + '-' + 'ckpt.pth'))
else:
patience += 1
if patience >= args.patience:
print('Early Stop! Best Val AUC: {:.4f}, Test AUC: {:.4f}'.format(best_val_auc, test_auc))
break
print(f'Epoch: {epoch:02d}, Loss: {loss:.4f}, Val_AUC: {val_auc:.4f}, Val_AP: {val_ap:.4f}, '
f'Test_AUC: {test_auc:.4f}, Test_AP: {test_ap:.4f}')
if __name__ == '__main__':
max_z = 0
seed_everything(11)
run()
|
{"hexsha": "c7a1fbb29dda1afa1e3e96778dc4252ada0fcefc", "size": 13839, "ext": "py", "lang": "Python", "max_stars_repo_path": "code/MLKG+SEAL.py", "max_stars_repo_name": "BishengLi0327/Topology-Restoration-Based-on-GNN", "max_stars_repo_head_hexsha": "99ede7abbab1ce06f094d79ad18e58f30fc7fc4b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-17T06:41:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T06:41:04.000Z", "max_issues_repo_path": "code/MLKG+SEAL.py", "max_issues_repo_name": "BishengLi0327/Topology-Restoration-Based-on-GNN", "max_issues_repo_head_hexsha": "99ede7abbab1ce06f094d79ad18e58f30fc7fc4b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/MLKG+SEAL.py", "max_forks_repo_name": "BishengLi0327/Topology-Restoration-Based-on-GNN", "max_forks_repo_head_hexsha": "99ede7abbab1ce06f094d79ad18e58f30fc7fc4b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.54, "max_line_length": 113, "alphanum_fraction": 0.6426042344, "include": true, "reason": "import numpy,import scipy,from scipy", "num_tokens": 3391}
|
#redirect Howard Johnson Hotel
|
{"hexsha": "e971b23d852c380d0a4014e9824726e41d1e2fc7", "size": 31, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "lab/davisWiki/Howard_Johnson_Inn.f", "max_stars_repo_name": "voflo/Search", "max_stars_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab/davisWiki/Howard_Johnson_Inn.f", "max_issues_repo_name": "voflo/Search", "max_issues_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab/davisWiki/Howard_Johnson_Inn.f", "max_forks_repo_name": "voflo/Search", "max_forks_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.5, "max_line_length": 30, "alphanum_fraction": 0.8387096774, "num_tokens": 6}
|
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import numpy as np
import reagent.core.types as rlt
import torch
import torch.nn as nn
from reagent.core.dataclasses import field
from reagent.model_utils.seq2slate_utils import Seq2SlateMode
from reagent.models.seq2slate import Seq2SlateTransformerNet
from reagent.optimizer.union import Optimizer__Union
from reagent.training.reagent_lightning_module import ReAgentLightningModule
from sklearn.metrics import (
average_precision_score,
dcg_score,
ndcg_score,
roc_auc_score,
)
logger = logging.getLogger(__name__)
class Seq2SlatePairwiseAttnTrainer(ReAgentLightningModule):
"""
Seq2Slate without a decoder learned in a supervised learning fashion (
https://arxiv.org/pdf/1904.06813.pdf )
"""
def __init__(
self,
seq2slate_net: Seq2SlateTransformerNet,
slate_size: int,
calc_cpe: bool,
policy_optimizer: Optimizer__Union = field( # noqa: B008
default_factory=Optimizer__Union.default
),
) -> None:
super().__init__()
self.seq2slate_net = seq2slate_net
self.slate_size = slate_size
self.calc_cpe = calc_cpe
self.policy_optimizer = policy_optimizer
self.log_softmax = nn.LogSoftmax(dim=1)
self.kl_loss = nn.KLDivLoss(reduction="batchmean")
def configure_optimizers(self):
optimizers = []
optimizers.append(
self.policy_optimizer.make_optimizer_scheduler(
self.seq2slate_net.parameters()
)
)
return optimizers
def train_step_gen(
self, training_batch: rlt.PreprocessedRankingInput, batch_idx: int
):
assert type(training_batch) is rlt.PreprocessedRankingInput
# shape: batch_size, tgt_seq_len
encoder_scores = self.seq2slate_net(
training_batch, mode=Seq2SlateMode.ENCODER_SCORE_MODE
).encoder_scores
assert encoder_scores.requires_grad
loss = self.kl_loss(
self.log_softmax(encoder_scores), training_batch.position_reward
)
detached_loss = loss.detach().cpu()
self.reporter.log(train_cross_entropy_loss=detached_loss)
yield loss
# pyre-ignore inconsistent override because lightning doesn't use types
def validation_step(self, batch: rlt.PreprocessedRankingInput, batch_idx: int):
# pyre-fixme[16]: `Optional` has no attribute `shape`.
batch_size = batch.position_reward.shape[0]
# shape: batch_size, tgt_seq_len
encoder_scores = self.seq2slate_net(
batch, mode=Seq2SlateMode.ENCODER_SCORE_MODE
).encoder_scores
assert (
encoder_scores.shape[1] == batch.position_reward.shape[1] == self.slate_size
)
ce_loss = self.kl_loss(
self.log_softmax(encoder_scores), batch.position_reward
).item()
if not self.calc_cpe:
self.reporter.log(eval_cross_entropy_loss=ce_loss)
return
# shape: batch_size, tgt_seq_len
ranking_output = self.seq2slate_net(
batch, mode=Seq2SlateMode.RANK_MODE, greedy=True
)
# pyre-fixme[16]: `int` has no attribute `cpu`.
ranked_idx = (ranking_output.ranked_tgt_out_idx - 2).cpu().numpy()
# pyre-fixme[58]: `-` is not supported for operand types
# `Optional[torch.Tensor]` and `int`.
logged_idx = (batch.tgt_out_idx - 2).cpu().numpy()
score_bar = np.arange(self.slate_size, 0, -1)
batch_dcg = []
batch_ndcg = []
batch_mean_ap = []
batch_auc = []
batch_base_dcg = []
batch_base_ndcg = []
batch_base_map = []
batch_base_auc = []
for i in range(batch_size):
# no positive label in the slate or slate labels are all positive
# pyre-fixme[16]: `Optional` has no attribute `__getitem__`.
if (not torch.any(batch.position_reward[i].bool())) or (
torch.all(batch.position_reward[i].bool())
):
continue
ranked_scores = np.zeros(self.slate_size)
ranked_scores[ranked_idx[i]] = score_bar
truth_scores = np.zeros(self.slate_size)
truth_scores[logged_idx[i]] = batch.position_reward[i].cpu().numpy()
base_scores = np.zeros(self.slate_size)
base_scores[logged_idx[i]] = score_bar
# average_precision_score accepts 1D arrays
# dcg & ndcg accepts 2D arrays
batch_mean_ap.append(average_precision_score(truth_scores, ranked_scores))
batch_base_map.append(average_precision_score(truth_scores, base_scores))
batch_auc.append(roc_auc_score(truth_scores, ranked_scores))
batch_base_auc.append(roc_auc_score(truth_scores, base_scores))
ranked_scores = np.expand_dims(ranked_scores, axis=0)
truth_scores = np.expand_dims(truth_scores, axis=0)
base_scores = np.expand_dims(base_scores, axis=0)
batch_dcg.append(dcg_score(truth_scores, ranked_scores))
batch_ndcg.append(ndcg_score(truth_scores, ranked_scores))
batch_base_dcg.append(dcg_score(truth_scores, base_scores))
batch_base_ndcg.append(ndcg_score(truth_scores, base_scores))
self.reporter.log(
eval_cross_entropy_loss=ce_loss,
eval_dcg=torch.mean(torch.tensor(batch_dcg)).reshape(1),
eval_ndcg=torch.mean(torch.tensor(batch_ndcg)).reshape(1),
eval_mean_ap=torch.mean(torch.tensor(batch_mean_ap)).reshape(1),
eval_auc=torch.mean(torch.tensor(batch_auc)).reshape(1),
eval_base_dcg=torch.mean(torch.tensor(batch_base_dcg)).reshape(1),
eval_base_ndcg=torch.mean(torch.tensor(batch_base_ndcg)).reshape(1),
eval_base_map=torch.mean(torch.tensor(batch_base_map)).reshape(1),
eval_base_auc=torch.mean(torch.tensor(batch_base_auc)).reshape(1),
)
|
{"hexsha": "bb160253d88f19e38a1dbf160a3d6d513b1143b7", "size": 6103, "ext": "py", "lang": "Python", "max_stars_repo_path": "reagent/training/ranking/seq2slate_attn_trainer.py", "max_stars_repo_name": "dmitryvinn/ReAgent", "max_stars_repo_head_hexsha": "f98825b9d021ec353a1f9087840a05fea259bf42", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1156, "max_stars_repo_stars_event_min_datetime": "2019-10-02T12:15:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T16:01:27.000Z", "max_issues_repo_path": "reagent/training/ranking/seq2slate_attn_trainer.py", "max_issues_repo_name": "dmitryvinn/ReAgent", "max_issues_repo_head_hexsha": "f98825b9d021ec353a1f9087840a05fea259bf42", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 448, "max_issues_repo_issues_event_min_datetime": "2019-10-03T13:40:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T07:49:15.000Z", "max_forks_repo_path": "reagent/training/ranking/seq2slate_attn_trainer.py", "max_forks_repo_name": "dmitryvinn/ReAgent", "max_forks_repo_head_hexsha": "f98825b9d021ec353a1f9087840a05fea259bf42", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 214, "max_forks_repo_forks_event_min_datetime": "2019-10-13T13:28:33.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T04:11:52.000Z", "avg_line_length": 39.6298701299, "max_line_length": 88, "alphanum_fraction": 0.6616418155, "include": true, "reason": "import numpy", "num_tokens": 1402}
|
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 19 19:16:33 2018
@author: solis
Funciones que realizan en análisis de una serie temporal (piezométrica) en
puntos que tienen definidos umbrales de referencia
"""
import log_file as lf
FLOAT_PRECISION = 'float64'
file_xml_ini = 'piezo_CTH.xml'
def select_project(filename=file_xml_ini):
"""
lee el fichero xml FILENAME, muestra los proyectos para que el usuario
escoja uno de ellos
input
FILENAME: fichero xml de estructura adecuada situada donde se encuentran
los scripts del programa
return:
el proyecto seleccionado por el usuario con un árbol xml
"""
import xml.etree.ElementTree as ET
tree = ET.parse(filename)
root = tree.getroot()
print('Projects in ' + filename)
projects = []
for i, project in enumerate(root.findall('project')):
projects.append(project)
print(i, end=' ')
print('. ' + project.get('name'))
print('Select project number:', end=' ')
choice = input()
return projects[int(choice)]
def control_umbrales(project):
"""
selecciona los datos y hace los análisis
input:
project: tag proyecto seleccionado
"""
from os.path import join
import pyodbc
import numpy as np
import piezo_CTH_parameters as par
import db_con_str
db = project.find('db').text.strip()
tag_pozos = project.findall('point')
tag_umbrales = project.findall('umbral')
cods_u = [tag_u.get('cod').strip() for tag_u in tag_umbrales]
params_u = [tag_u.get('parametro').strip() for tag_u in tag_umbrales]
selected2xy = [int(tag_u.get('selected2xy')) for tag_u in tag_umbrales]
selects_dp = [tag_u.find('select_data_param').text.strip()
for tag_u in tag_umbrales]
select_umbral = project.find('select_umbral').text.strip()
fecha1 = str_to_date(par.fecha1)
fecha2 = str_to_date(par.fecha2)
headers = ['Id pozo', 'Nombre', 'X m', 'Y m', 'Z msnm']
for param_u in params_u:
headers.append('Umbral m ' + param_u)
headers.append('Media m ' + param_u)
headers.append('Media - umbral m ' + param_u)
headers.append('Últ. medida - umbral m ' + param_u)
headers.append('Índice ' + param_u)
headers.append('Oscilación máx NP m')
fmt1 = '{}\t{}\t'+3*'{:0.2f}\t'
# ojo, si se modifican las columnas media, media-umbral y Ultmed-umbral
# hay que cambiar posiblemente fmt2
fmt2 = 3*'\t{:0.2f}'+'\t'
pozos_iue, pozos_iud, values_iue, values_iud = [], [], [], []
fo = open(join(par.dir_out, par.file_out), 'w')
fo.write('\t'.join(headers) + '\n')
con = pyodbc.connect(db_con_str.con_str(db))
cur = con.cursor()
for tag in tag_pozos:
cod = tag.get('cod').strip()
print(cod)
i = 0
maximun = -99999999.
minimun = 99999999.
n_series = 0
for cod_u, param_u, select_dp, toxy in zip(cods_u, params_u,
selects_dp,
selected2xy):
if toxy == 1:
if param_u == 'CNP ND':
pozos = pozos_iud
indexes = values_iud
elif param_u == 'CNP NE':
pozos = pozos_iue
indexes = values_iue
cur.execute(select_umbral, (cod, cod_u, param_u))
row = cur.fetchone()
if row is None:
raise ValueError('{} no tiene umbrales de {} {}'
.format(cod, cod_u, param_u))
toponimia = row.TOPONIMIA
x = row.X_UTM
y = row.Y_UTM
z = row.Z
umbral = row.UMBRAL
cur.execute(select_dp, (cod, fecha1, fecha2))
tmp = [row.CNP for row in cur]
cnp = np.array(tmp, dtype=FLOAT_PRECISION)
if cnp.size > 0:
n_series += 1
mean = np.mean(cnp)
maximun = max(maximun, np.max(cnp))
minimun = min(minimun, np.min(cnp))
else:
lf.write('{}; no tiene datos {}, {} entre las fechas {} y {}'
.format(cod, cod_u, param_u,
fecha1.strftime('%d/%m/%Y'),
fecha2.strftime('%d/%m/%Y')))
if i == 0:
fo.write(fmt1.format(cod, toponimia, x, y, z))
fo.write('{:0.2f}'.format(umbral))
if cnp.size > 0:
y1 = cnp[-1]
fo.write(fmt2.format(mean, mean-umbral, mean-y1))
else:
fo.write('\tNaN\tNaN\tNaN\t')
# clasificación del comportamiento piezométrico
if cnp.size > 2:
median = np.median(cnp[:-1]) - umbral
cnp_index = par.coef1 * median + par.coef2 * (cnp[-1] - umbral)
fo.write('{:0.2f}\t'.format(cnp_index))
else:
cnp_index = None
fo.write('NaN\t')
if toxy == 1:
pozos.append(cod)
indexes.append(cnp_index)
i += 1
if i == len(cods_u):
if n_series > 0:
rango = abs(maximun - minimun)
fo.write('{:0.2f}\n'.format(rango))
else:
fo.write('NaN\n')
con.close()
fo.close()
boreholes, ines, inds = [], [], []
if pozos_iue:
for pozo, ne, nd in zip(pozos_iue, values_iue, values_iud):
if ne is None or nd is None:
continue
boreholes.append(pozo)
ines.append(ne)
inds.append(nd)
_made_xy_graph(boreholes, ines, inds)
def str_to_date(sdate: str):
"""
a partir de un str con formato "dd/mm/yyyy" devuelve un objeto date
"""
from datetime import date
if sdate == 'now':
sdate = date.today().strftime('%d/%m/%Y')
ws = sdate.split('/')
try:
return date(int(ws[2]), int(ws[1]), int(ws[0]))
except Exception as error:
raise ValueError('La fecha {} no es válida'.format(sdate))
def dif_grapfs(project):
"""
graba gráficos de diferencias (serie -piezométrica- - umbral)
input:
project: tag proyecto seleccionado
"""
from os.path import join
import numpy as np
import pyodbc
import piezo_CTH_parameters as par
import db_con_str
from piezo_CTH_XY import Time_series, XYt_1
lf.write('\n Gráficos de diferencias')
db = project.find('db').text.strip()
tag_pozos = project.findall('point')
tag_umbrales = project.findall('umbral')
cods_u = [tag_u.get('cod').strip() for tag_u in tag_umbrales]
params_u = [tag_u.get('parametro').strip() for tag_u in tag_umbrales]
selects_dp = [tag_u.find('select_data_param').text.strip()
for tag_u in tag_umbrales]
ylegends = [tag_u.get('ylegend').strip()
for tag_u in tag_umbrales]
select_umbral = project.find('select_umbral').text.strip()
fecha1 = str_to_date(par.fecha1)
fecha2 = str_to_date(par.fecha2)
con = pyodbc.connect(db_con_str.con_str(db))
cur = con.cursor()
print('gráficos xy')
for tag in tag_pozos:
cod = tag.get('cod').strip()
print(cod)
for cod_u, param_u, select_dp, ylegend in zip(cods_u, params_u,
selects_dp,
ylegends):
cur.execute(select_umbral, (cod, cod_u, param_u))
row = cur.fetchone()
if row is None:
raise ValueError('{} no tiene umbrales de {} {}'
.format(cod, cod_u, param_u))
toponimia = row.TOPONIMIA
umbral = row.UMBRAL
cur.execute(select_dp, (cod, fecha1, fecha2))
rows = [row for row in cur]
if len(rows) < 2:
lf.write('{}; tiene < 2 datos {}, {} entre las fechas {} y {}'
.format(cod, cod_u, param_u,
fecha1.strftime('%d/%m/%Y'),
fecha2.strftime('%d/%m/%Y')))
continue
fechas = [row.FECHA for row in rows]
values = [row.CNP for row in rows]
values = np.array(values, dtype=FLOAT_PRECISION)
values = values - umbral
s1 = Time_series(fechas, values, ylegend, '.')
stitle = '{} ({})\nDiferencia serie vs umbral {} ({})' \
.format(cod, toponimia, param_u, cod_u)
tmp = cod + '_' + param_u + '_' + cod_u + '.png'
tmp2 = tmp.replace(' ', '_')
file_name = tmp2.replace('/', '_')
dst = join(par.dir_out, file_name)
XYt_1([s1], stitle, ylegend, dst)
con.close()
def _made_xy_graph(pozos, values_iue, values_iud):
"""
hace un gáfico de valores del índice para estáticos y dinámicos
"""
import matplotlib.pyplot as plt
from os.path import join
from piezo_CTH_parameters import dir_out
name_graph = '_XY_INDICES.png'
dst = join(dir_out, name_graph)
print(name_graph)
fig, ax = plt.subplots()
ivalues_iue = sorted(range(len(values_iue)), key=values_iue.__getitem__)
for i in ivalues_iue:
if values_iue[i] is not None and values_iud[i] is not None:
ax.scatter(values_iue[i], values_iud[i], label=pozos[i])
ax.set_title('Caracterización piezométrica')
plt.xlabel('IUNE (m)')
plt.ylabel('IUND (m)')
plt.legend(loc='upper left', ncol=3, fontsize=9, bbox_to_anchor=(0, 0),
borderaxespad=4.0)
plt.tight_layout()
plt.grid(True)
fig.savefig(dst)
plt.close('all')
|
{"hexsha": "878749daf60cca15d211b55236d92ef40afb5681", "size": 10176, "ext": "py", "lang": "Python", "max_stars_repo_path": "piezo_CTH.py", "max_stars_repo_name": "solisgb/PIEZO-THRESHOLDS", "max_stars_repo_head_hexsha": "2c7c5f296a8c58b8e36c93940774e7626f96664e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "piezo_CTH.py", "max_issues_repo_name": "solisgb/PIEZO-THRESHOLDS", "max_issues_repo_head_hexsha": "2c7c5f296a8c58b8e36c93940774e7626f96664e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "piezo_CTH.py", "max_forks_repo_name": "solisgb/PIEZO-THRESHOLDS", "max_forks_repo_head_hexsha": "2c7c5f296a8c58b8e36c93940774e7626f96664e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2626262626, "max_line_length": 80, "alphanum_fraction": 0.5285966981, "include": true, "reason": "import numpy", "num_tokens": 2609}
|
using DataFrames
using KernelDensity
KWArgT = Union{Dict, NamedTuple, Nothing}
update_args(args::Union{Dict, NamedTuple}, update::Nothing) = args
update_args(args::Union{Dict, NamedTuple}, update::Union{Dict, NamedTuple}) =
merge([Dict{Symbol, Any}(zip(keys(d), values(d))) for d in (args, update)]...)
estimate_density_kde(coords::Array{Float64, 2}, points::Array{Float64, 2}, bandwidth::T where T <: Real)::Vector{Float64} =
InterpKDE(kde((coords[1,:], coords[2,:]), bandwidth=(Float64(bandwidth), Float64(bandwidth)))).itp.(points[1,:], points[2,:])
function val_range(arr::AT where AT <: AbstractArray{<:Real})
if length(arr) == 0
return (nothing, nothing)
end
min_val, max_val = arr[1], arr[1]
for v in arr
min_val = fmin(min_val, v)
max_val = fmax(max_val, v)
end
return min_val, max_val
end
count_array(values::VT where VT<: AbstractVector{<:Integer}, args...; max_value::Union{<:Integer, Nothing}=nothing, kwargs...) =
count_array!(zeros(Int, max_value !== nothing ? max_value : maximum(values)), values, args...; erase_counts=false, kwargs...)
function count_array!(counts::VT1 where VT1 <: AbstractVector{<:Integer}, values::VT2 where VT2 <: AbstractVector{<:Integer}; drop_zero::Bool=false, erase_counts::Bool=true)
if erase_counts
counts .= 0
end
has_zero = false
for v in values
if v == 0
has_zero = true
continue
end
counts[v] += 1
end
if !drop_zero && has_zero
@warn "Array has zero values. It was ignored."
end
return counts
end
function count_array!(counts::VT1 where VT1 <: AbstractVector{RT}, values::VT2 where VT2 <: AbstractVector{<:Integer}, weights::VT3 where VT3 <: AbstractVector{RT};
drop_zero::Bool=false, erase_counts::Bool=true) where RT<:Real
if erase_counts
counts .= 0
end
has_zero = false
for i in 1:length(values)
v = values[i]
if v == 0
has_zero = true
continue
end
counts[v] += weights[i]
end
if !drop_zero && has_zero
@warn "Array has zero values. It was ignored."
end
return counts
end
function prob_array(values::Union{Array{Int, 1}, SubArray{Int,1}}; max_value::Union{Int, Nothing}=nothing, smooth::Float64=0.0)
if max_value === nothing
max_value = maximum(values)
end
sum_value = length(values) + max_value * smooth
counts = fill(smooth / sum_value, max_value)
for v in values
counts[v] += 1.0 / sum_value
end
return counts
end
function prob_array!(counts::Union{Array{Float64, 1}, SubArray{Float64,1}}, values::Array{Int, 1}; smooth::Float64=0.0)
sum_value = length(values) + length(counts) * smooth
counts .= smooth / sum_value
for v in values
counts[v] += 1.0 / sum_value
end
return counts
end
function split(vector::T where T <: AbstractVector; n_parts::Int)
offset = ceil(Int, length(vector) / n_parts)
return [vector[n:min(n + offset - 1, length(vector))] for n in 1:offset:length(vector)]
end
trim_mean(x::Array{T, 1} where T <: Real; prop::Float64=0.2) = mean(trim(x; prop=prop))
function split(array::T where T <: AbstractVector{TV}, factor::T2 where T2 <: AbstractVector{<:Integer}; max_factor::Union{Int, Nothing}=nothing, drop_zero::Bool=false)::Array{Vector{TV}, 1} where TV
@assert length(array) == length(factor)
if max_factor === nothing
max_factor = maximum(factor)
end
splitted = [TV[] for i in 1:max_factor]
for i in 1:length(array)
if drop_zero && factor[i] == 0
continue
end
push!(splitted[factor[i]], array[i])
end
return splitted
end
split(array::UnitRange{Int64}, factor::Array{Int64,1}; kwargs...) = split(collect(array), factor; kwargs...)
split_ids(factor::Array{Int, 1}; kwargs...) = split(1:length(factor), factor; kwargs...)
split(df::DataFrame, factor::Symbol; kwargs...) = split(df, Array(df[!, factor]); kwargs...)
split(df::DataFrame, factor::Array{Int, 1}; kwargs...) = [df[ids, :] for ids in split(1:size(df, 1), factor; kwargs...)]
function interpolate_linear(x::T, x_start::T, x_end::T; y_start::T=1.0, y_end::T=0.0)::Float64 where T<:Real
if x < x_start
return y_start
elseif x > x_end
return y_end
end
return y_start + (x - x_start) / (x_end - x_start) * (y_end - y_start)
end
function is_point_in_polygon(point::Union{Vector{T1}, Tuple{T1, T1}} where T1 <: Real, poly::Array{Vector{T2}, 1} where T2 <: Real,
borders::Union{Array{Vector{T3},1}, Nothing} where T3 = nothing)
if borders !== nothing && (borders[1][1] > point[1] || borders[1][2] > point[2] || borders[2][1] < point[1] || borders[2][2] < point[2])
return false
end
j = length(poly)
c = false
for i in 1:length(poly)
if ((poly[i][2] > point[2]) != (poly[j][2] > point[2])) &&
(point[1] < poly[i][1] + (poly[j][1] - poly[i][1]) * (point[2] - poly[i][2]) / (poly[j][2] - poly[i][2]))
c = !c
end
j = i
end
return c
end
"""Golden section search
to find the minimum of f on [a,b]
opt_func: a strictly unimodal function on [a,b]
Returns: tuple with the optimal parameter and the optimal function value
"""
function linsearch_gs(opt_func::Function, a::T, b::T; tol=1e-3) where T<: Real
gr = (sqrt(5) + 1) / 2
c = b - (b - a) / gr
d = a + (b - a) / gr
while abs(c - d) > tol
if opt_func(c) < opt_func(d)
b = d
else
a = c
end
# We recompute both c and d here to avoid loss of precision which may lead to incorrect results or infinite loop
c = b - (b - a) / gr
d = a + (b - a) / gr
end
return (b + a) / 2, opt_func((b + a) / 2)
end
function trace_values_along_line(arr::Matrix{T}, start_x::Int, start_y::Int, end_x::Int, end_y::Int)::Vector{T} where T <: Real
@assert all([end_y, end_x] .<= size(arr))
@assert all([start_y, start_x] .<= size(arr))
@assert all([start_y, start_x] .> 0)
@assert all([end_y, end_x] .> 0)
a = (end_y - start_y) / (end_x - start_x)
b = end_y - a * end_x
dx = sign(end_x - start_x)
dy = sign(end_y - start_y)
x, y = start_x, start_y
vals = [arr[start_y, start_x]]
while (x != end_x) | (y != end_y)
if (abs((a * x + b) - (y + dy)) < abs((a * (x + dx) + b) - y)) || dx == 0
y += dy
else
x += dx
end
push!(vals, arr[y, x])
end
return vals
end
@inline @fastmath function fmax(v1::T, v2::T) where T <: Real
v1 > v2 ? v1 : v2
end
@inline @fastmath function fmin(v1::T, v2::T) where T <: Real
v1 < v2 ? v1 : v2
end
function estimate_difference_l0(m1::Matrix{Float64}, m2::Matrix{Float64}; col_weights::Union{Nothing, Vector{Float64}}=nothing, change_threshold::Float64=1e-7)::Tuple{Float64, Float64}
max_diff = 0.0
n_changed = 0
if !all(size(m1) .== size(m2))
error("Matrices must be of the same size")
end
@inbounds for ci in 1:size(m1, 2)
c_max = 0.0
for ri in 1:size(m1, 1)
c_max = fmax(abs(m1[ri, ci] - m2[ri, ci]), c_max)
end
if col_weights !== nothing
c_max *= col_weights[ci]
end
if c_max > change_threshold
n_changed += 1
end
max_diff = fmax(c_max, max_diff)
end
return max_diff, n_changed / size(m1, 2)
end
function pairwise_jaccard(values::Array{Vector{Int}, 1}, min_dist::Float64=0.0001)::Matrix{Float64}
dist_mat = zeros(length(values), length(values))
for i1 in 1:length(values)
s1 = values[i1]
for i2 in (i1+1):length(values)
s2 = values[i2]
inter_len = 0
for v in s1
if v in s2
inter_len += 1
end
end
dist_mat[i1, i2] = dist_mat[i2, i1] = fmax(1.0 - length(inter_len) / (length(s1) + length(s2) - inter_len), min_dist)
end
end
return dist_mat
end
### Statistics
@inline function fsample(w::Vector{Float64})::Int
n = length(w)
if n == 0
error("Empty vector for sampling")
end
t = rand(Random.GLOBAL_RNG) * sum(w)
i = 1
cw = w[1]
while cw < t && i < length(w)
i += 1
@inbounds cw += w[i]
end
return i
end
@inline @inbounds fsample(arr::Vector{Int}, w::Vector{Float64})::Int = arr[fsample(w)]
"""
It works only for large samples with more or less uniform weights
"""
function wmedian(values::Vector{T} where T <: Real, weights::Vector{Float64}; ord::Vector{Int}=sortperm(values))::Float64
w_avg = sum(weights) / 2
w_cur = 0.0
for i in ord
w_cur += weights[i]
if w_cur >= w_avg
return values[i]
end
end
if any(isnan.(weights))
error("NaNs are presented in weights for wmedian")
end
end
wmad(values::Vector{T} where T <: Real, weights::Vector{Float64}; ord::Vector{Int}=sortperm(values))::Float64 =
wmad(values, weights, wmedian(values, weights, ord=ord))
"""
It works only for large samples with more or less uniform weights
"""
wmad(values::Vector{T} where T <: Real, weights::Vector{Float64}, m::Float64)::Float64 =
1.4826 * wmedian(abs.(values .- m), weights)
function wmean(values::Vector{T} where T <: Real, weights::T1 where T1 <: AbstractVector{Float64}; non_zero_ids::T2 where T2 <: AbstractArray{Int} = 1:length(values))
s, ws = 0.0, 0.0
for i in non_zero_ids
s += values[i] * weights[i]
ws += weights[i]
end
return s / ws
end
function wmean_std(values::Vector{T0} where T0 <: Real, weights::T1 where T1 <: AbstractVector{Float64}; non_zero_ids::T2 where T2 <: AbstractArray{Int} = 1:length(values))
m = wmean(values, weights; non_zero_ids=non_zero_ids)
s, ws = 0.0, 0.0
for i in non_zero_ids
dv = (values[i] - m)
s += dv * dv * weights[i]
ws += weights[i]
end
return m, sqrt(s / ws)
end
function upscale(image::T where T <: AbstractMatrix{TR}, ratio::Int64) where TR <: Real
res_img = zeros(TR, size(image) .* ratio)
ct = 1
for c in 1:size(image, 2)
for m1 in 1:ratio
rt = 1
for r in 1:size(image, 1)
for m2 in 1:ratio
res_img[rt, ct] = image[r, c]
rt += 1
end
end
ct += 1
end
end
return res_img
end
|
{"hexsha": "0be7dc376bb541fafa53082ea4fa9d9c42ba3e81", "size": 10556, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/utils/utils.jl", "max_stars_repo_name": "YinuoJin/Baysor", "max_stars_repo_head_hexsha": "a7ee9bd8e38c6c572dcd20f0dc0bbd6591c87d37", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/utils.jl", "max_issues_repo_name": "YinuoJin/Baysor", "max_issues_repo_head_hexsha": "a7ee9bd8e38c6c572dcd20f0dc0bbd6591c87d37", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/utils.jl", "max_forks_repo_name": "YinuoJin/Baysor", "max_forks_repo_head_hexsha": "a7ee9bd8e38c6c572dcd20f0dc0bbd6591c87d37", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8192090395, "max_line_length": 199, "alphanum_fraction": 0.5934065934, "num_tokens": 3239}
|
from hydroDL import kPath, utils
from hydroDL.app import waterQuality
from hydroDL.master import basins
from hydroDL.data import usgs, gageII, gridMET, ntn
from hydroDL.master import slurm
from hydroDL.post import axplot, figplot
import numpy as np
import matplotlib.pyplot as plt
import os
import pandas as pd
codeLst = sorted(usgs.varC)
ep = 500
reTest = False
wqData = waterQuality.DataModelWQ('sbW')
siteNoLst = wqData.info.siteNo.unique()
nSite = len(siteNoLst)
dataName = 'sbW'
labelLst = ['ntnq']
corrMat = np.full([nSite, len(codeLst), 4], np.nan)
dirWrtds = os.path.join(kPath.dirWQ, 'modelStat', 'WRTDS')
dfCorr = pd.read_csv(os.path.join(
dirWrtds, '{}-{}-corr'.format('Y1', 'Y2')), index_col=0)
corrMat[:, :, 0] = dfCorr[codeLst].values
dirWrtds = os.path.join(kPath.dirWQ, 'modelStat', 'WRTDS-F')
dfCorr = pd.read_csv(os.path.join(
dirWrtds, '{}-{}-corr'.format('Y1', 'Y2')), index_col=0)
corrMat[:, :, 1] = dfCorr[codeLst].values
# single
for iLab, label in enumerate(labelLst):
for iCode, code in enumerate(codeLst):
trainSet = '{}-Y1'.format(code)
testSet = '{}-Y2'.format(code)
outName = '{}-{}-{}-{}'.format(dataName, code, label, trainSet)
master = basins.loadMaster(outName)
ic = wqData.varC.index(code)
# for iT, subset in enumerate([trainSet, testSet]):
subset = testSet
yP, ycP = basins.testModel(
outName, subset, wqData=wqData, ep=ep, reTest=reTest)
ind = wqData.subset[subset]
info = wqData.info.iloc[ind].reset_index()
p = ycP[:, master['varYC'].index(code)]
o = wqData.c[ind, ic]
for iS, siteNo in enumerate(siteNoLst):
indS = info[info['siteNo'] == siteNo].index.values
rmse, corr = utils.stat.calErr(p[indS], o[indS])
corrMat[iS, iCode, iLab+2] = corr
# plot box
labLst1 = [usgs.codePdf.loc[code]['shortName'] +
'\n'+code for code in codeLst]
labLst2 = ['WRTDS', 'LSTM', 'LSTM + Forcing']
dataBox = list()
for k in range(len(codeLst)):
code = codeLst[k]
temp = list()
for i in [0, 2]:
temp.append(corrMat[:, k, i])
dataBox.append(temp)
fig = figplot.boxPlot(dataBox, label1=labLst1, widths=0.5, cLst='bgr',
label2=labLst2, figsize=(12, 4), yRange=[0, 1])
# fig = figplot.boxPlot(dataBox, label1=labLst1, widths=0.5,
# label2=labLst2, figsize=(12, 4), sharey=False)
fig.show()
|
{"hexsha": "8621f72b881f76404f35e7b49d0aaeecc013cb63", "size": 2454, "ext": "py", "lang": "Python", "max_stars_repo_path": "app/waterQual/stableSites/sbW/box_WRTDS.py", "max_stars_repo_name": "fkwai/geolearn", "max_stars_repo_head_hexsha": "30cb4353d22af5020a48100d07ab04f465a315b0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/waterQual/stableSites/sbW/box_WRTDS.py", "max_issues_repo_name": "fkwai/geolearn", "max_issues_repo_head_hexsha": "30cb4353d22af5020a48100d07ab04f465a315b0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/waterQual/stableSites/sbW/box_WRTDS.py", "max_forks_repo_name": "fkwai/geolearn", "max_forks_repo_head_hexsha": "30cb4353d22af5020a48100d07ab04f465a315b0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-04-04T02:45:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-19T09:41:39.000Z", "avg_line_length": 35.5652173913, "max_line_length": 71, "alphanum_fraction": 0.6344743276, "include": true, "reason": "import numpy", "num_tokens": 803}
|
#! /usr/bin/env python
import numpy as np
import json,cv2,os,time,glob,copy,re
from color import *
def cv2ver():
major = cv2.__version__.split('.')[0]
return int(major)
class ImageSource:
EmptyData = {
"frames": [],
"input_file": ""
}
EmptyFrame = {
"frame_id": 0,
"frame_rois": []
}
def __init__(self, videoname,jsonname):
self.videoInputEnable = False
self.roisInputEnable = False
self.isAvi = False
self.openVideo(videoname)
self.openRoiJson(jsonname)
def openVideo(self,videoname):
self.videofile = videoname
filename,ext = os.path.splitext(self.videofile)
self.jsonfile = filename + '.json'
ext = ext.lower()
if ext == '.avi':
self.openVideoAvi(videoname)
elif ext == '.bmp' or ext == '.jpg' or ext == '.png':
self.openVideoImg(videoname)
def openVideoAvi(self,videoname):
try:
self.cap = cv2.VideoCapture(videoname)
if cv2ver() == 3:
self.fcnt = self.cap.get(cv2.CAP_PROP_FRAME_COUNT)
else:
self.fcnt = self.cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)
self.isAvi = True
self.videoInputEnable = True
self.createEmptyData(self.fcnt)
except:
self.videoInputEnable = False
def file2list(self,filename):
dirname = os.path.dirname(filename)
basename = os.path.basename(filename)
# replace digits with ? in basename
chars = list(basename)
newChars = []
for c in chars:
if c.isdigit():
newChars.append('?')
else:
newChars.append(c)
basename = ''.join(newChars)
return sorted(glob.glob(dirname+'/'+basename))
def openVideoImg(self,imgname):
self.videoList = self.file2list(imgname)
self.fcnt = len(self.videoList)
self.videoInputEnable = True
self.isAvi = False
self.createEmptyData(self.fcnt)
def openImgDir(self,dirname):
filelist = sorted(glob.glob(dirname+'/*'))
if len(filelist) > 0:
self.openVideoImg(filelist[0])
def openRoiJson(self,jsonname):
self.jsonfile = jsonname
try:
with open(jsonname) as fd:
self.data = json.load(fd)
self.fcntRois = len(self.data['frames'])
self.roisInputEnable = True
except:
self.roisInputEnable = False
if self.roisInputEnable:
self.labels = self.getLabelFromData(self.data)
else:
self.labels = [('Unsorted',-1),
('Negative',0)]
def openRoiTxt(self,txtname):
txtlist = self.file2list(txtname)
if self.fcnt != len(txtlist):
print('Error: mismatch')
return
self.createEmptyData(self.fcnt)
frameid = 0
for afile in txtlist:
with open(afile) as fd:
lines = fd.readlines()
roiid = 0
for line in lines:
words = line.split()
try:
(x,y,w,h) = (int(words[0]),int(words[1]),int(words[2]),int(words[3]))
except:
continue
self.data['frames'][frameid]['frame_rois'].append(
{
"roi_score": -1.0,
"roi_h": h,
"roi_x": x,
"roi_y": y,
"roi_label": {
"label_id": 1,
"label_name": "true"
},
"roi_w": w,
"roi_id": roiid
}
)
roiid += 1
frameid += 1
def updateInfoFromDir(self,dirname):
dirlist = sorted(glob.glob(dirname+'/*'))
for subdir in dirlist:
label_name = os.path.basename(subdir)
if not os.path.isdir(subdir):
continue
files = glob.glob(subdir+'/*')
for file in files:
file = os.path.basename(file)
nums = re.findall(r'[\d]+',file) # 1234_4567 => ('1234','4567')
if len(nums) != 2:
continue
fnum = int(nums[0])
roi_id = int(nums[1])
#print(fnum,roi_id,label_name)
ret,label_id = self.getLabelId(label_name)
if ret:
rois = self.data['frames'][fnum]['frame_rois']
for roi in rois:
if roi['roi_id'] == roi_id:
roi['roi_label']['label_id'] = label_id
roi['roi_label']['label_name'] = label_name
#print('update: fnum=%d roi_id=%d label=%s (%d)'%
# (fnum,roi_id,label_name,label_id))
def createEmptyData(self,fcnt):
data = copy.deepcopy(ImageSource.EmptyData)
for i in range(int(fcnt)):
frame = copy.deepcopy(ImageSource.EmptyFrame)
frame["frame_id"] = i
data["frames"].append(frame)
self.data = data
self.roisInputEnable = True
def getSize(self):
""" return image size """
if self.videoInputEnable:
if self.isAvi:
if cv2ver() == 3:
width = self.cap.get(cv2.CAP_PROP_FRAME_WIDTH) # float
height = self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # float
else:
width = self.cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH) # float
height = self.cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT) # float
else:
img = cv2.imread(self.videoList[0])
height, width = img.shape[:2]
return (int(width),int(height))
else:
return (640,480)
def getFrameCount(self):
if self.videoInputEnable:
return self.fcnt
else:
return 100
def getImage(self,fnum):
""" return (true/false, rois) """
if self.videoInputEnable:
if self.isAvi:
if cv2ver() == 3:
self.cap.set(cv2.CAP_PROP_POS_FRAMES,fnum)
else:
self.cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES,fnum)
return self.cap.read()
else:
img = cv2.imread(self.videoList[fnum])
return True,img
return (False,[])
def getRois(self,fnum):
""" return (true/false, rois) """
if self.roisInputEnable:
try:
js = self.data['frames'][fnum]['frame_rois']
return (True,js)
except:
pass
return (False,[])
def saveJson(self):
if not self.roisInputEnable:
return
filename,ext = os.path.splitext(self.jsonfile)
timestamp = time.strftime("%Y%m%d%H%M%S")
newname = filename+'_'+timestamp+ext
with open(newname,'w') as fp:
json.dump(self.data,fp,sort_keys=True,indent=4, separators=(',', ': '))
def openLabel(self,filename):
with open(filename) as fd:
typedata = json.load(fd)
self.labels = []
self.labels.append(('Unsorted',-1))
for key,value in typedata['neg_dics'].iteritems():
self.labels.append((str(key),value))
for key,value in typedata['pos_dics'].iteritems():
self.labels.append((str(key),value))
def getLabelFromData(self,data):
frames = data['frames'] # frame list
labels = {}
for frame in frames:
rois = frame['frame_rois']
for roi in rois:
label_id = roi['roi_label']['label_id']
label_name = str(roi['roi_label']['label_name'])
labels[label_name] = label_id
return [(key,id) for key,id in labels.iteritems()]
def updateRoiLabel(self):
if not self.roisInputEnable:
return
for frame in self.data["frames"]:
rois = frame["frame_rois"]
for roi in rois:
labelname = roi["roi_label"]["label_name"]
ret,id = self.getLabelId(labelname)
if ret and id >= 0:
roi["roi_label"]["label_id"] = id
def getLabelNameList(self):
return [key for key,id in self.labels]
def getLabelId(self,labelname):
for key,id in self.labels:
if key == labelname:
return True,id
return False,-1
def saveMask(self):
if not self.videoInputEnable:
return
if not self.roisInputEnable:
return
# save images to a directory
filename,ext = os.path.splitext(self.videofile)
if os.path.exists(filename):
if not os.path.isdir(filename):
print('Error: ' + filename + ' is not a directory')
return
else:
os.makedirs(filename)
(imgw,imgh) = self.getSize()
for fm in self.data['frames']:
fnum = fm['frame_id']
rois = fm['frame_rois']
# create frame and paint rois on it
size = (imgh,imgw,1)
img = np.zeros(size,np.int16)
for roi in rois:
x0 = roi['roi_x']
y0 = roi['roi_y']
x1 = roi['roi_x'] + roi['roi_w'] - 1
y1 = roi['roi_y'] + roi['roi_h'] - 1
id = roi['roi_label']['label_id']
cv2.rectangle(img,(x0,y0),(x1,y1),id+128,-1)
# save frame to file
imgname = "%s/%04d.png"%(filename,fnum)
#print(imgname)
cv2.imwrite(imgname,img)
def saveVideo(self):
if not self.videoInputEnable:
return
if not self.roisInputEnable:
return
# save images to a directory
filename,ext = os.path.splitext(self.videofile)
if os.path.exists(filename):
if not os.path.isdir(filename):
print('Error: ' + filename + ' is not a directory')
return
else:
os.makedirs(filename)
(imgw,imgh) = self.getSize()
for fnum in range(int(self.fcnt)):
statV,img = self.getImage(fnum)
statR,rois = self.getRois(fnum)
if not statV or not statR:
continue
for roi in rois:
label_id = roi['roi_label']['label_id']
if label_id <= 0:
continue
color = ColorTable[getColor(label_id)]
x0 = roi['roi_x']
y0 = roi['roi_y']
x1 = x0+roi['roi_w']-1
y1 = y0+roi['roi_h']-1
cv2.rectangle(img,(x0,y0),(x1,y1),color,1)
# save frame to file
imgname = "%s/img%04d.jpg"%(filename,fnum)
print(imgname)
cv2.imwrite(imgname,img)
if __name__ == "__main__":
src = ImageSource('00161_raw.avi','objects_00161.json')
print (src.getSize())
print (src.getFrameCount())
fnum = 0
while (1):
ret,frame,js = src.getFrame(fnum)
fnum += 1
if(not ret):
break
for roi in js:
x0 = roi['roi_x']
y0 = roi['roi_y']
x1 = roi['roi_x'] + roi['roi_w'] - 1
y1 = roi['roi_y'] + roi['roi_h'] - 1
cv2.rectangle(frame,(x0,y0),(x1,y1),(0,256,0),1)
cv2.imshow('frame',frame);
cv2.waitKey(33);
|
{"hexsha": "e0dd2cc0d901b131fa572cfaee8c71565d83b128", "size": 12336, "ext": "py", "lang": "Python", "max_stars_repo_path": "plugins/flask/annotator/ImageSource.py", "max_stars_repo_name": "readicculus/VIAME", "max_stars_repo_head_hexsha": "3e65fa4ec9139f73f8f9f4b3c0f1b18ba6209733", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plugins/flask/annotator/ImageSource.py", "max_issues_repo_name": "readicculus/VIAME", "max_issues_repo_head_hexsha": "3e65fa4ec9139f73f8f9f4b3c0f1b18ba6209733", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plugins/flask/annotator/ImageSource.py", "max_forks_repo_name": "readicculus/VIAME", "max_forks_repo_head_hexsha": "3e65fa4ec9139f73f8f9f4b3c0f1b18ba6209733", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.3621169916, "max_line_length": 90, "alphanum_fraction": 0.4755188067, "include": true, "reason": "import numpy", "num_tokens": 2786}
|
'''
Created on Jun 12, 2013
Modelled upon LpdFemDataReceiver.py
@author: ckd27546
'''
from lpd.gui.data_containers import LpdImageContainer, LpdFrameContainer
import os, sys, time, socket
import numpy as np
from PyQt4 import QtCore
# Import HDF5 Library; Disable its use if library not installed on PC
try:
import h5py
except:
# "No HDF5 Library detected - Disabling file writing"
bHDF5 = False
else:
# "HDF5 Library present."
bHDF5 = True
#Display received data in plots
b_display_plot_data = True
# Debugging enabled if set above 0
bDebug = 0
class LpdFemDataReceiver(QtCore.QObject):
def __init__(self, live_view_signal, listen_addr, listen_port, num_frames, cached_params, app_main):
try:
super(LpdFemDataReceiver, self).__init__()
self.num_frames = num_frames
self.app_main = app_main
self.debugLevel = cached_params['debugLevel']
# Create UDP recevier, frame processor and data monitor objects
self.udp_receiver = UdpReceiver(listen_addr, listen_port, num_frames)
self.frame_processor = FrameProcessor(num_frames, cached_params, live_view_signal)
# Create threads to run them in
self.udp_receiver_thread = QtCore.QThread()
self.frame_processor_thread = QtCore.QThread()
# Move objects into threads
self.udp_receiver.moveToThread(self.udp_receiver_thread)
self.frame_processor.moveToThread(self.frame_processor_thread)
# Connect thread start signal of UDP receiver to receive loop function
self.udp_receiver_thread.started.connect(self.udp_receiver.receiveLoop)
# Connect data RX signal from UDP receiver to handleDataRx slot in frame processor
self.udp_receiver.connect(self.udp_receiver, QtCore.SIGNAL("dataRxSignal"), self.frame_processor.processFrame)
# Start the frame processor thread up
self.frame_processor_thread.start()
# Start the UDP receiver thread up
self.udp_receiver_thread.start()
except Exception as e:
print "LpdFemDataReceiver got exception during initialisation: %s" % e
raise(e)
def awaitCompletion(self):
if self.debugLevel > 0:
print "Waiting for frame processing to complete"
while self.frame_processor.frames_handled < self.num_frames and self.app_main.abort_run == False:
time.sleep(0.1)
if self.app_main.abort_run:
print "Run aborted by user"
if self.debugLevel > 0:
print "Frame processor handled all frames, terminating data receiver threads"
#TODO: Close udp_receiver's socket? - Success
self.udp_receiver.closeConnection()
self.frame_processor_thread.quit()
self.udp_receiver_thread.quit()
self.frame_processor_thread.wait()
self.udp_receiver_thread.wait()
try:
print "Average frame UDP receive time : %f secs" % (self.udp_receiver.total_receive_time / self.udp_receiver.frame_count)
print "Average frame processing time : %f secs" % (self.frame_processor.total_processing_time / self.frame_processor.frames_handled)
except Exception as e:
print >> sys.stderr, "Got exception", e
if self.debugLevel > 0:
print "awaitCompletion() finished"
class UdpReceiver(QtCore.QObject):
def __init__(self, listen_addr, listen_port, num_frames):
super(UdpReceiver, self).__init__()
# Initialise variables used by processRxData
self.first_frm_num = -1
self.packet_number = -1
self.frame_count = 0
self.num_frames = num_frames
self.total_receive_time = 0.0
# Bind to UDP receive socket
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((listen_addr, listen_port))
print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
print "UDP Receiver thread listening on address %s port %s (%i frame(s)/file)" % (listen_addr, listen_port, num_frames)
def closeConnection(self):
self.sock.close()
def receiveLoop(self):
try:
while self.frame_count < self.num_frames:
foundEof = 0
lpdFrame = LpdFrameContainer(self.frame_count)
while foundEof == 0:
stream = self.sock.recv(9000)
foundEof = self.processRxData(lpdFrame, stream)
if foundEof:
# Complete frame received, transmit frame along with meta data saved in LpdFrameContainer object
#print >> sys.stderr, "Frame %d receive complete" % lpdFrame.frame_number
self.emit(QtCore.SIGNAL("dataRxSignal"), lpdFrame)
self.frame_count += 1
self.total_receive_time += (lpdFrame.time_stamp_eof - lpdFrame.time_stamp_sof)
except Exception as e:
print "UDP receiver event loop got an exception: %s" % e
raise(e)
#print >> sys.stderr, "Receiver thread completed"
def processRxData(self, lpd_frame, data):
'''
Processes received data packets, decoding the Train Transfer Protocol information
to construct completed frames (trains)
'''
try:
# Extract Trailer information
trailerInfo = np.zeros(2, dtype=np.uint32)
trailerInfo = np.fromstring(data[-8:], dtype=np.uint32)
# Extract train/frame number (the second last 32 bit word from the raw data)
frameNumber = trailerInfo[0]
# Extract packet number (last 32 bit word)
packetNumber = trailerInfo[1] & 0x3FFFFFFF
# Extract Start Of Frame, End of Frame
sof = (trailerInfo[1] >> (31)) & 0x1
eof = (trailerInfo[1] >> (30)) & 0x1
#TODO: Restore this link if frame number coming from fem before absolute?
# frame_number = train number relative to execution of this software
#lpd_frame.frame_number = frame_number
if self.first_frm_num == -1:
self.first_frm_num = frameNumber
frameNumber = frameNumber - self.first_frm_num
# Compare this packet number against the previous packet number
if packetNumber != (self.packet_number +1):
# packet numbering not consecutive
if packetNumber > self.packet_number:
# this packet lost between this packet and the last packet received
print "Warning: Previous packet number: %3i while current packet number: %3i" % (self.packet_number, packetNumber)
# Update current packet number
self.packet_number = packetNumber
# Timestamp start of frame (when we received first data of train)
if sof == 1:
lpd_frame.time_stamp_sof = time.time()
# It's the start of a new train, clear any data left from previous train..
lpd_frame.raw_image_data = ""
if eof == 1:
lpd_frame.time_stamp_eof = time.time()
# Append current packet data onto raw image omitting trailer info
lpd_frame.raw_image_data += data[0:-8]
return eof
except Exception as e:
print "processRxData() error: ", e
return -1
class FrameProcessor(QtCore.QObject):
AsicTypeSuperModule = 0
AsicTypeSingleAsic = 1
AsicTypeTwoTile = 2
AsicTypeAloneFem = 3
AsicTypeRawData = 4
def __init__(self, num_frames, cached_params, live_view_signal):
QtCore.QObject.__init__(self)
self.num_frames = num_frames
self.evr_data = None
#Only allow writing of HDF5 files if h5py library installed..
if bHDF5:
self.fileWriteEnable = cached_params['fileWriteEnable']
else:
self.fileWriteEnable = False
self.dataFilePath = cached_params['dataFilePath']
self.liveViewDivisor = cached_params['liveViewDivisor']
self.liveViewOffset = cached_params['liveViewOffset']
#asicModuleType: 0: super module 1: single ASIC (redundant?) 2: 2-tile module 3: stand-alone fem (4: raw data ?)
self.asicModuleType = cached_params['asicModuleType']
self.debugLevel = cached_params['debugLevel']
if self.debugLevel > 1:
print "num_frames: ", self.num_frames
print "fileWrite: ", self.fileWriteEnable
print "dataFilePath: ", self.dataFilePath
print "liveViewDivisor: ", self.liveViewDivisor
print "liveViewOffset: ", self.liveViewOffset
print "asicModuleType: ", self.asicModuleType
print "debugLevel: ", self.debugLevel
self.liveViewSignal = live_view_signal
# Run start time
self.tstart = time.time()
# Initialise counters
self.frames_handled = 0
self.images_written = 0
self.data_bytes_received = 0
self.total_processing_time = 0.0
# Define plotted image dimensions:
if self.asicModuleType == FrameProcessor.AsicTypeSuperModule:
self.nrows = 32*8 # 32 rows * 8 ASICs = 256
self.ncols = 256 # 16 columns/ASIC, 8 ASICs / sensor, 2 sensors / Row: 16 x 8 x 2 = 256 columns
elif self.asicModuleType == FrameProcessor.AsicTypeSingleAsic:
self.nrows = 32 # 32 rows
self.ncols = 16 # 16 columns
elif self.asicModuleType == FrameProcessor.AsicTypeTwoTile:
self.nrows = 32 # 32 rows
self.ncols = 256 # 16 columns/ASIC, 8 ASICs / sensor, 2 sensors / Row: 16 x 8 x 2 = 256 columns
elif self.asicModuleType == FrameProcessor.AsicTypeAloneFem:
self.nrows = 32 # 32 rows
self.ncols = 128 # 16 columns/ASIC, 8 ASICs / sensor: 16 x 8 = 128 columns
if self.asicModuleType == FrameProcessor.AsicTypeRawData:
self.nrows = 256 # 32 rows * 8 ASICs = 256
self.ncols = 256 # 16 columns/ASIC, 8 ASICs / sensor, 2 sensors / Row: 16 x 8 x 2 = 256 columns
# Define Module and Full Lpd size (Module differs if 2-tile, SuperMod, Fem, etc)
self.image_module_size = self.nrows * self.ncols
self.image_full_lpd_size = 256 * 256
# Create an image array to contain the elements of the module type
# Super Module = (32 x 8 x 16 x 16) = 65536 elements
# 2Tile System = (32 * 16 * 16) = 8192 elements
self.image_array = np.zeros(self.image_module_size, dtype=np.uint16)
# Create HDF file if requested
if self.fileWriteEnable:
self.createDataFile(cached_params)
def createDataFile(self, cached_params):
'''
Creates and HDF5 data file and internal structure, sets up metadata in file
'''
fileName = self.dataFilePath
postFix = 0
# Check if filename already exists; amend if it does
while os.path.exists(fileName):
fileName = self.dataFilePath[:-5] + str("_") + str(postFix) + self.dataFilePath[-5:]
postFix += 1
try:
self.hdf_file = h5py.File(fileName, 'w')
except Exception as e:
print "Failed to open HDF file with error: %s" % e
raise(e)
else:
if self.debugLevel > 0:
print "Created HDF5 data file: %s " % fileName
# Create group structure
self.lpd_group = self.hdf_file.create_group('lpd')
self.meta_group = self.lpd_group.create_group('metadata')
self.data_group = self.lpd_group.create_group('data')
# Create data group entries
self.image_ds = self.data_group.create_dataset('image', (1, self.nrows, self.ncols), 'uint16', chunks=(1, self.nrows, self.ncols),
maxshape=(None,self.nrows, self.ncols))
self.time_stamp_ds = self.data_group.create_dataset('timeStamp', (1,), 'float64', maxshape=(None,))
self.train_number_ds = self.data_group.create_dataset('trainNumber', (1,), 'uint32', maxshape=(None,))
self.image_number_ds = self.data_group.create_dataset('imageNumber', (1,), 'uint32', maxshape=(None,))
# Build metadata attributes from cached parameters
for param, val in cached_params.iteritems():
self.meta_group.attrs[param] = val
def processFrame(self, lpd_frame):
#print >> sys.stderr, "Frame processor thread receiver frame number", lpd_frame.frame_number, 'raw data length', len(lpd_frame.raw_image_data)
self.data_bytes_received += len(lpd_frame.raw_image_data)
# Capture time of starting processing
startTime = time.time()
# Simultaneously extract 16 bit pixel data from raw 32 bit words and swap the byte order
# eg: ABCD => DCBA
self.pixel_data = np.fromstring(lpd_frame.raw_image_data, dtype=np.dtype('<i2'))
# Define variables that increase with each loop iteration
currentImage = 0
bNextImageAvailable = True
# Loop over the specified number of plots
while bNextImageAvailable:
imageOffset = self.image_full_lpd_size * currentImage
# Get the first image of the image
bNextImageAvailable = self.unpackImage(imageOffset)
# Mask out gain bits from data
# TODO REMOVE THIS
#self.image_array = self.image_array & 0xfff
# Write image to file if selected
if self.fileWriteEnable:
self.image_ds.resize((self.images_written+1, self.nrows, self.ncols))
self.image_ds[self.images_written,...] = self.image_array
self.time_stamp_ds.resize((self.images_written+1, ))
self.time_stamp_ds[self.images_written] = lpd_frame.time_stamp_sof
self.train_number_ds.resize((self.images_written+1, ))
self.train_number_ds[self.images_written] = lpd_frame.frame_number
self.image_number_ds.resize((self.images_written+1, ))
self.image_number_ds[self.images_written] = currentImage
# Send signal to update plotted graph at appropriate rate
if (self.images_written - self.liveViewOffset) % self.liveViewDivisor == 0:
lpdImage = LpdImageContainer(0, lpd_frame.frame_number, currentImage) # 0 = runNumber, not used
lpdImage.image_array = self.image_array.copy()
self.liveViewSignal.emit(lpdImage)
# Clear data before next iteration (but after data written to file)
self.image_array.fill(0)
# Increment current image
currentImage += 1
self.images_written += 1
# 'Reset' raw_image_data variable - WHY??
lpd_frame.raw_image_data = lpd_frame.raw_image_data[0:0]
endTime = time.time()
self.total_processing_time += (endTime - startTime)
#print "Total frame processing time = %f secs" % (endTime - startTime)
self.frames_handled += 1
#if self.frames_handled >= self.num_frames:
# print >> sys.stderr, "Frame processor thread processed all frames, quitting"
def unpackImage(self, image_offset):
""" Extracts one image beginning at argument image_offset in the member array
self.pixel_data array. Returns boolean bImageAvailable indicating whether
the current image is the last image in the data
"""
# Boolean variable to track whether there is a image after this one in the data
bNextImageAvailable = False
# Check Asic Module type to determine how to process data
if self.asicModuleType == FrameProcessor.AsicTypeRawData:
# Raw data - no not re-order
self.image_array = self.pixel_data[image_offset:image_offset + self.image_full_lpd_size].reshape(256, 256)
else:
# Not raw data, proceed to reorder data
numAsicCols = 16
numAsicRows = 8
numAsics = numAsicCols * numAsicRows
numColsPerAsic = 16
numRowsPerAsic = 32
numPixelsPerAsic = numColsPerAsic * numRowsPerAsic
numPixels = numAsics * numPixelsPerAsic
# Create linear array for unpacked pixel data
self.image_lpd_full_array = np.zeros(numPixels, dtype=np.uint16)
self.image_lpd_full_array = np.reshape(self.image_lpd_full_array, (numAsicRows * numRowsPerAsic, numAsicCols * numColsPerAsic))
rawOffset = image_offset
try:
for asicRow in xrange(numRowsPerAsic):
for asicCol in xrange(numColsPerAsic):
self.image_lpd_full_array[asicRow::numRowsPerAsic, asicCol::numColsPerAsic] = self.pixel_data[rawOffset:(rawOffset + numAsics)].reshape(8,16)
rawOffset += numAsics
except IndexError:
print "Image Processing Error @ %6i %6i %6i %6i %6i %6i " % ( asicRow, numRowsPerAsic, asicCol, numColsPerAsic, rawOffset, numAsics )
except Exception as e:
print "Error while extracting image: ", e, " -> imgOffset: ", image_offset
# Module specific data processing
if self.asicModuleType == FrameProcessor.AsicTypeSuperModule:
# Super Module - Image now upside down, reverse the order
self.image_lpd_full_array[:,:] = self.image_lpd_full_array[::-1,:]
self.image_array = self.image_lpd_full_array.copy()
elif self.asicModuleType == FrameProcessor.AsicTypeTwoTile:
#Two Tile
# Create array for 2 Tile data; reshape into two dimensional array
self.image_array = np.zeros(self.image_module_size, dtype=np.uint16)
self.image_array = self.image_array.reshape(32, 256)
# Copy the two Tiles that exists in the two tile system
try:
# LHS Tile located in the second ASIC row, second ASIC column
self.image_array[0:32, 0:128] = self.image_lpd_full_array[32:32+32, 256-1:128-1:-1]
# RHS Tile located in the seventh ASIC row, second ASIC column
self.image_array[0:32, 128:256] = self.image_lpd_full_array[192:192+32, 256-1:128-1:-1]
except Exception as e:
print "Error accessing 2 Tile data: ", e
print "image_offset: ", image_offset
sys.exit()
# Last image in the data?
try:
self.pixel_data[image_offset + self.image_full_lpd_size]
# Will only get here if there is a next image available..
bNextImageAvailable = True
except IndexError:
pass # Last Image in this train detected
return bNextImageAvailable
|
{"hexsha": "60744495de15159bac1949bb1b658b41d4e381fc", "size": 20180, "ext": "py", "lang": "Python", "max_stars_repo_path": "app/lpd/tests/redundant_files/uni_receive.py", "max_stars_repo_name": "stfc-aeg/lpd-detector", "max_stars_repo_head_hexsha": "7bc0d9700a3d3992a4541f05e1434aba0d056dcc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/lpd/tests/redundant_files/uni_receive.py", "max_issues_repo_name": "stfc-aeg/lpd-detector", "max_issues_repo_head_hexsha": "7bc0d9700a3d3992a4541f05e1434aba0d056dcc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2018-10-04T07:36:22.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-18T13:10:42.000Z", "max_forks_repo_path": "app/lpd/tests/redundant_files/uni_receive.py", "max_forks_repo_name": "stfc-aeg/lpd-detector", "max_forks_repo_head_hexsha": "7bc0d9700a3d3992a4541f05e1434aba0d056dcc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8450106157, "max_line_length": 165, "alphanum_fraction": 0.5939048563, "include": true, "reason": "import numpy", "num_tokens": 4456}
|
import os
import sys
import re
import contextlib
import numpy as np
import cv2
import easygui
from imgphon import imgphon
def interface(windowName, canvas, tp, frame_index, file_name, result_dict, clicks_list, working_dir, sort_fn, label_num_constr: int, ext):
output_imgs_dir = "output_imgs"
with contextlib.suppress(FileExistsError):
os.mkdir(os.path.join(working_dir, output_imgs_dir))
shouldReload = False
output_img_name = str(file_name) + "-" + str(frame_index) + "-" + str(tp)
while True:
cv2.imshow(windowName, canvas)
key = cv2.waitKey(1) & 0xFF # ASCII code of pressed key
if key == 110: # [N] to next
if label_num_constr and (len(clicks_list) != label_num_constr):
shouldReload = True
break
cv2.imwrite(os.path.join(working_dir, output_imgs_dir,
output_img_name + ext), canvas)
result_dict[tp] = sort_fn(clicks_list)
break
elif key == 114: # [R] to reload
shouldReload = True
break
elif key == 113: # [Q] to quit
if label_num_constr and (len(clicks_list) == label_num_constr):
cv2.imwrite(os.path.join(working_dir,
output_imgs_dir, output_img_name + ext), canvas)
result_dict[tp] = sort_fn(clicks_list)
cv2.destroyAllWindows()
np.save(os.path.join(working_dir,
"result_dict.npy"), result_dict, allow_pickle=True)
os.remove("temp.bmp")
sys.exit(0)
cv2.destroyAllWindows()
return (shouldReload, result_dict)
def paint_dot(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
cv2.circle(param[0], (x, y), 3, (60, 20, 220), -1)
param[1].append((x, y))
def label_single(frame_index: int, vid_path: str, total_frames_count: int, result_dict: dict, working_dir: str, sort_fn, label_num_constr: int, ext, tp_list):
shouldReload = True
tp = tp_list[frame_index - 1]
file_name = os.path.basename(vid_path)
imgphon.get_video_frame(vid_path, tp)
m_clicks_list = []
while shouldReload:
curr_frame = cv2.imread("temp.bmp")
windowName = "(Frame " + str(frame_index) + " of " + str(total_frames_count) + ") " + str(file_name) + " @ " + str(tp) + \
" Sec | [R] Reload | [N] Save & Next | [Q] Save & Quit"
cv2.namedWindow(windowName)
cv2.moveWindow(windowName, 320, 180)
cv2.setMouseCallback(windowName, paint_dot,
(curr_frame, m_clicks_list))
interface_return = interface(windowName, curr_frame,
tp, frame_index, file_name, result_dict, m_clicks_list, working_dir, sort_fn, label_num_constr, ext)
shouldReload = interface_return[0]
if shouldReload:
m_clicks_list = []
os.remove("temp.bmp")
return interface_return[1]
def label_multiple(start_pt: int, tp_list: list, vid_path: str, result_dict: dict, working_dir: str, sort_fn, label_num_constr: int, ext):
total_frames_count = str(len(tp_list))
tp_index = start_pt
while tp_index < len(tp_list):
m_tp_index = tp_index + 1
new_result_dict = label_single(
m_tp_index, vid_path, total_frames_count, result_dict, working_dir, sort_fn, label_num_constr, ext, tp_list)
result_dict = new_result_dict
tp_index += 1
def sort_lip_coords(tmp_l):
def take_x(elem):
return elem[0]
tmp_l.sort(key=take_x)
left = tmp_l[0]
right = tmp_l[3]
if tmp_l[1][1] < tmp_l[2][1]:
upper = tmp_l[1]
lower = tmp_l[2]
else:
upper = tmp_l[2]
lower = tmp_l[1]
tmp_dict = {"leftx": left[0],
"lefty": left[1],
"rightx": right[0],
"righty": right[1],
"upperx": upper[0],
"uppery": upper[1],
"lowerx": lower[0],
"lowery": lower[1]}
return tmp_dict
|
{"hexsha": "d58bb3b7f9587a8c566562d2b699946903ae2b94", "size": 4119, "ext": "py", "lang": "Python", "max_stars_repo_path": "imgphon/handlabel.py", "max_stars_repo_name": "shunjiewang/imgphon", "max_stars_repo_head_hexsha": "b7d82c1dde39a332191e40dc87e88248ac300b4c", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "imgphon/handlabel.py", "max_issues_repo_name": "shunjiewang/imgphon", "max_issues_repo_head_hexsha": "b7d82c1dde39a332191e40dc87e88248ac300b4c", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "imgphon/handlabel.py", "max_forks_repo_name": "shunjiewang/imgphon", "max_forks_repo_head_hexsha": "b7d82c1dde39a332191e40dc87e88248ac300b4c", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.8173913043, "max_line_length": 158, "alphanum_fraction": 0.5931051226, "include": true, "reason": "import numpy", "num_tokens": 1059}
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
# ==============================================================================
#
# This file contains functions reltated to input handling. This code was
# adapted from the on in TextUserInterfaces.jl.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
################################################################################
# Constants
################################################################################
include("keycodes.jl")
################################################################################
# Functions
################################################################################
"""
_jlgetch(stream::IO)
Wait for an keystroke in the stream `stream` and return it (see
[`Keystroke`](@ref)).
"""
function _jlgetch((@nospecialize stream::IO))
c_raw = read(stream, UInt8)::UInt8
c::UInt32 = UInt32(c_raw)
nc::Int32 = 0
if c == 27
s = string(Char(c))
# Read the entire sequence limited to 10 characters.
for i = 1:10
stream.buffer.size == i && break
nc = read(stream, Char)::Char
s *= string(Char(nc))
haskey(keycodes, s) && break
end
if length(s) == 1
return Keystroke(raw = s, value = :esc)
elseif haskey(keycodes, s)
aux = keycodes[s]
return Keystroke(
raw = s,
value = aux.value,
alt = aux.alt,
ctrl = aux.ctrl,
shift = aux.shift
)
else
return Keystroke(raw = s, value = :undefined)
end
elseif c == nocharval
return Keystroke(raw = string(c), value = :undefined)
elseif 192 <= c <= 223 # utf8 based logic starts here
bs1 = UInt8(c)
bs2 = read(stream, UInt8)::UInt8
return Keystroke(
raw = string(bs1) * ", " * string(bs2),
value = String([bs1, bs2])
)
elseif c < 192 || c > 253
if c == 4
return Keystroke(raw = string(c), value = :eot)
elseif c == 9
return Keystroke(raw = string(c), value = :tab)
elseif c == 10
return Keystroke(raw = string(c), value = :enter)
elseif c == 13
return Keystroke(raw = string(c), value = :enter)
elseif c == 21
return Keystroke(raw = string(c), value = :shiftin)
elseif c == 127
return Keystroke(raw = string(c), value = :backspace)
elseif c == 410
return Keystroke(raw = string(c), value = :resize)
else
return Keystroke(raw = string(c), value = string(Char(c)))
end
elseif 224 <= c <= 239
bs1 = UInt8(c)
bs2 = read(stream, UInt8)::UInt8
bs3 = read(stream, UInt8)::UInt8
return Keystroke(
raw = string(bs1) * ", " *
string(bs2) * ", " *
string(bs3),
value = String([bs1, bs2, bs3])
)
elseif 240 <= c <= 247
bs1 = UInt8(c)
bs2 = read(stream, UInt8)::UInt8
bs3 = read(stream, UInt8)::UInt8
bs4 = read(stream, UInt8)::UInt8
return Keystroke(
raw = string(bs1) * ", " *
string(bs2) * ", " *
string(bs3) * ", " *
string(bs4),
value = String([bs1, bs2, bs3, bs4])
)
elseif 248 <= c <= 251
bs1 = UInt8(c)
bs2 = read(stream, UInt8)::UInt8
bs3 = read(stream, UInt8)::UInt8
bs4 = read(stream, UInt8)::UInt8
bs5 = read(stream, UInt8)::UInt8
return Keystroke(
raw = string(bs1) * ", " *
string(bs2) * ", " *
string(bs3) * ", " *
string(bs4) * ", " *
string(bs5),
value = String([bs1, bs2, bs3, bs4, bs5])
)
elseif 252 <= c <= 253
bs1 = UInt8(c)
bs2 = read(stream, UInt8)::UInt8
bs3 = read(stream, UInt8)::UInt8
bs4 = read(stream, UInt8)::UInt8
bs5 = read(stream, UInt8)::UInt8
bs6 = read(stream, UInt8)::UInt8
return Keystroke(
raw = string(bs1) * ", " *
string(bs2) * ", " *
string(bs3) * ", " *
string(bs4) * ", " *
string(bs5) * ", " *
string(bs6),
value = String([bs1, bs2, bs3, bs4, bs5, bs6])
)
end
return Keystroke(value = :undefined)
end
|
{"hexsha": "fa2df1f752ecc08106db08e3e37cc41f672fa2dc", "size": 4722, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/input/input.jl", "max_stars_repo_name": "TheCedarPrince/TerminalPager.jl", "max_stars_repo_head_hexsha": "a94d727d20310076697ceb7b18c6dccf9e85363f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 61, "max_stars_repo_stars_event_min_datetime": "2021-04-18T20:36:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T16:43:39.000Z", "max_issues_repo_path": "src/input/input.jl", "max_issues_repo_name": "TheCedarPrince/TerminalPager.jl", "max_issues_repo_head_hexsha": "a94d727d20310076697ceb7b18c6dccf9e85363f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2021-04-19T02:19:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T21:42:31.000Z", "max_forks_repo_path": "src/input/input.jl", "max_forks_repo_name": "TheCedarPrince/TerminalPager.jl", "max_forks_repo_head_hexsha": "a94d727d20310076697ceb7b18c6dccf9e85363f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-04-24T02:04:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-07T04:39:33.000Z", "avg_line_length": 33.020979021, "max_line_length": 80, "alphanum_fraction": 0.4127488352, "num_tokens": 1214}
|
# Copyright (C) 2020-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Federated averaging module."""
from .interface import AggregationFunctionInterface
import numpy as np
def weighted_average(tensors, weights):
"""Compute average."""
return np.average(tensors, weights=weights, axis=0)
class WeightedAverage(AggregationFunctionInterface):
"""Weighted average aggregation."""
def call(self, local_tensors, *_):
"""Aggregate tensors.
Args:
agg_tensor_dict: Dict of (collaborator name, tensor) pairs to aggregate.
weights: array of floats representing data partition (sum up to 1)
db_iterator: iterator over history of all tensors.
Columns: ['tensor_name', 'round', 'tags', 'nparray']
tensor_name: name of the tensor
fl_round: round number
tags: tuple of tags for this tensor
"""
tensors, weights = zip(*[(x.tensor, x.weight) for x in local_tensors])
return weighted_average(tensors, weights)
|
{"hexsha": "e7ab596b4d5965ab6cfcebaaa076ed76fb25c861", "size": 1058, "ext": "py", "lang": "Python", "max_stars_repo_path": "openfl/component/aggregation_functions/weighted_average.py", "max_stars_repo_name": "walteriviera/openfl", "max_stars_repo_head_hexsha": "1f5d6e7b7131dd519baf51ecdb9ab29de0e9308b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "openfl/component/aggregation_functions/weighted_average.py", "max_issues_repo_name": "walteriviera/openfl", "max_issues_repo_head_hexsha": "1f5d6e7b7131dd519baf51ecdb9ab29de0e9308b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "openfl/component/aggregation_functions/weighted_average.py", "max_forks_repo_name": "walteriviera/openfl", "max_forks_repo_head_hexsha": "1f5d6e7b7131dd519baf51ecdb9ab29de0e9308b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0625, "max_line_length": 84, "alphanum_fraction": 0.6644612476, "include": true, "reason": "import numpy", "num_tokens": 229}
|
import numpy as np
import pandas as pd
import niimpy.preprocessing.survey
df1 = pd.DataFrame(
{"time": ['2019-01-01']*3 + ['2019-01-02']*3 + ['2019-01-03']*3,
"answer": [0, 1, 2, 3, 4, 5, 6, 7, np.nan],
"id": ["S1_1", "S1_2", "S1_3"] * 3,
})
df1['time'] = pd.to_datetime(df1['time'])
df1 = df1.set_index('time')
def test_sum_survey_scores():
df = df1.copy()
results = niimpy.preprocessing.survey.sum_survey_scores(df, 'S1')
assert results.loc['2019-01-01']['score'] == 3
assert results.loc['2019-01-02']['score'] == 12
assert np.isnan(results.loc['2019-01-03']['score'])
df['user'] = 'some_user'
results = niimpy.preprocessing.survey.sum_survey_scores(df, 'S1')
print(results)
results = results.loc['some_user']
assert results.loc['2019-01-01']['score'] == 3
assert results.loc['2019-01-02']['score'] == 12
assert np.isnan(results.loc['2019-01-03']['score'])
def test_sum_survey_scores_indexonly():
df = df1.copy()
df.index.name = None
results = niimpy.preprocessing.survey.sum_survey_scores(df, 'S1')
assert results.loc['2019-01-01']['score'] == 3
assert results.loc['2019-01-02']['score'] == 12
assert np.isnan(results.loc['2019-01-03']['score'])
|
{"hexsha": "8c649104623eebd00db9b5a20d04b77faf3637c9", "size": 1263, "ext": "py", "lang": "Python", "max_stars_repo_path": "niimpy/preprocessing/test_survey.py", "max_stars_repo_name": "lnknguyen/niimpy", "max_stars_repo_head_hexsha": "2aebd1d59b0b7562103128d5eaff90f20091f6fd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "niimpy/preprocessing/test_survey.py", "max_issues_repo_name": "lnknguyen/niimpy", "max_issues_repo_head_hexsha": "2aebd1d59b0b7562103128d5eaff90f20091f6fd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "niimpy/preprocessing/test_survey.py", "max_forks_repo_name": "lnknguyen/niimpy", "max_forks_repo_head_hexsha": "2aebd1d59b0b7562103128d5eaff90f20091f6fd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.575, "max_line_length": 72, "alphanum_fraction": 0.6199524941, "include": true, "reason": "import numpy", "num_tokens": 409}
|
program make_starmask
use fieldinfo_
use sub_
implicit none
! idum: set arbitrary value for initial seed for ran2
integer :: idum=-152103
! inf: input file of shear distribution
! outf: mask field [1:ni,1:nj](real)
! outf2: flag data describing which data is masked or not [1:ntot] (logical*1)
! if (flag(n)=.true.) n-th data is masked
character(100) :: inf,outf,outf2
integer :: i,j
real, pointer :: mask(:,:),pos(:,:)
logical*1, pointer :: flag(:)
call getarg(1,inf)
call getarg(2,outf)
call getarg(3,outf2)
call readdata(inf,pos)
call maskdata(pos,flag,idum)
call densassign(pos,flag,mask)
call outmask(mask,outf)
call outflag(outf2,flag)
contains
subroutine readdata(inf,pos)
use fieldinfo_
implicit none
integer :: n
real, pointer :: pos(:,:)
character :: inf*100
write(*,*) 'read data from ',inf(1:len_trim(inf))
allocate(pos(ntot,2))
open(1,file=inf,status='old',form='unformatted')
read(1) pos
close(1)
end subroutine readdata
subroutine outflag(outf,flag)
logical*1, pointer :: flag(:)
character :: outf*100
write(*,*) 'output flag:',outf(1:len_trim(outf))
open(2,file=outf,status='unknown',form='unformatted')
write(2) flag
close(2)
deallocate(flag)
end subroutine outflag
subroutine densassign(pos,flag,mask)
use fieldinfo_
use sub_
implicit none
integer :: i,j,i1,j1,idum,n
real :: x,y,fx,fy
real, pointer :: mask(:,:),pos(:,:)
logical*1, pointer :: flag(:)
allocate(mask(ni,nj))
mask=0.
do n=1,ntot
if (flag(n)) cycle
i=int(pos(n,1))+1
j=int(pos(n,2))+1
mask(i,j)=mask(i,j)+1.
enddo
close(1)
deallocate(pos)
end subroutine densassign
subroutine maskdata(pos,flag,idum)
use fieldinfo_
use maskinfo_
use sub_
implicit none
integer :: i,j,n,nmask,nm,next
real :: hpos(2),hsize,ssize(2) ! in unit of grid
integer, intent(inout) :: idum
real, pointer :: pos(:,:)
integer, pointer :: num(:,:),pnum(:,:,:)
logical*1, pointer :: flag(:)
allocate(flag(ntot))
flag=.false.
call fieldassign(pos,num,pnum)
next=0
nmask=nint(ntot*fmask)
write(*,*) nmask
do while (next<nmask)
hpos(1)=ran2(idum)*ni
hpos(2)=ran2(idum)*nj
hsize=(hmin+(hmax-hmin)*ran2(idum)**4)*amin2grid
call starmask(hsize,hpos,pos,num,pnum,flag,next)
if (hsize>rsmin*amin2grid) then
ssize(1)=hsize*xrec
ssize(2)=hsize*yrec
call recmask(ssize,hpos,pos,num,pnum,flag,next)
endif
enddo
call zpad(pos,num,pnum,flag,next,idum)
deallocate(num,pnum)
write(*,*) 'unmasked fraction:',1-float(next)/float(ntot)
end subroutine maskdata
subroutine outmask(mask,outf)
implicit none
real, pointer :: mask(:,:)
character(100) :: outf
write(*,*) 'output mask:',outf(1:len_trim(outf))
open(2,file=outf,status='unknown',form='unformatted')
write(2) mask
close(2)
deallocate(mask)
end subroutine outmask
subroutine fieldassign(pos,num,pnum)
implicit none
integer :: i,j,n,nmax
real, pointer :: pos(:,:)
integer, pointer :: num(:,:),pnum(:,:,:)
allocate(num(ni,nj))
num=0
do n=1,ntot
i=int(pos(n,1))+1
j=int(pos(n,2))+1
num(i,j)=num(i,j)+1
enddo
nmax=0
do j=1,nj
do i=1,ni
if (num(i,j)>nmax) nmax=num(i,j)
enddo
enddo
write(*,*) 'maximum number of galaxies per pixel',nmax
allocate(pnum(ni,nj,nmax))
num=0
do n=1,ntot
i=int(pos(n,1))+1
j=int(pos(n,2))+1
num(i,j)=num(i,j)+1
pnum(i,j,num(i,j))=n
enddo
end subroutine fieldassign
subroutine starmask(hsize,hpos,pos,num,pnum,flag,next)
use fieldinfo_
use sub_
implicit none
integer :: i,j,imin,imax,jmin,jmax,n
integer, intent(inout) :: next
real :: r
real, intent(in) :: hsize,hpos(2)
real, pointer :: pos(:,:)
integer, pointer :: num(:,:),pnum(:,:,:)
logical*1, pointer :: flag(:)
imin=int(hpos(1)-hsize)
imax=int(hpos(1)+hsize)+1
jmin=int(hpos(2)-hsize)
jmax=int(hpos(2)+hsize)+1
do i=imin,imax
do j=jmin,jmax
if ((i<1).or.(i>ni)) cycle
if ((j<1).or.(j>nj)) cycle
do n=1,num(i,j)
if (flag(pnum(i,j,n))) cycle
r=dist(hpos,pos(pnum(i,j,n),:),2)
if (r<hsize) then
next=next+1
flag(pnum(i,j,n))=.true.
endif
enddo
enddo
enddo
end subroutine starmask
subroutine recmask(ssize,hpos,pos,num,pnum,flag,next)
use fieldinfo_
implicit none
integer :: i,j,imin,imax,jmin,jmax,n
integer, intent(inout) :: next
real, intent(in) :: ssize(2),hpos(2)
real :: dx,dy
real, pointer :: pos(:,:)
integer, pointer :: num(:,:),pnum(:,:,:)
logical*1, pointer :: flag(:)
imin=int(hpos(1)-ssize(1))
imax=int(hpos(1)+ssize(1))+1
jmin=int(hpos(2)-ssize(2))
jmax=int(hpos(2)+ssize(2))+1
do i=imin,imax
do j=jmin,jmax
if ((i<1).or.(i>ni)) cycle
if ((j<1).or.(j>nj)) cycle
do n=1,num(i,j)
if (flag(pnum(i,j,n))) cycle
dx=abs(pos(pnum(i,j,n),1)-hpos(1))
dy=abs(pos(pnum(i,j,n),2)-hpos(2))
if ((dx<ssize(1)).and.(dy<ssize(2))) then
next=next+1
flag(pnum(i,j,n))=.true.
endif
enddo
enddo
enddo
end subroutine recmask
subroutine zpad(pos,num,pnum,flag,next,idum)
use fieldinfo_
use maskinfo_
use sub_
implicit none
integer :: i,j,n,i2,i2max
integer, intent(inout) :: idum,next
integer, parameter :: nisim=2048,njsim=nisim
real :: x
real, pointer :: pos(:,:)
integer, pointer :: num(:,:),pnum(:,:,:)
logical*1, pointer :: flag(:)
i2max=max(nint(1./(zwidth*ni)),1)
do i=1,ni
do i2=1,i2max
if (ran2(idum)<=zfrac) then
x=(i-1)+(i2-0.5)/float(i2max)
do j=1,nj
do n=1,num(i,j)
if (flag(pnum(i,j,n))) cycle
if (abs(pos(pnum(i,j,n),1)-x)<zwidth*ni/2.) then
flag(pnum(i,j,n))=.true.
next=next+1
endif
enddo
enddo
endif
enddo
enddo
end subroutine zpad
end program make_starmask
|
{"hexsha": "3ad747248029785d7f6ba4ae5137be24ef1d484d", "size": 6549, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "starmask.f90", "max_stars_repo_name": "chiaki-hikage/pseudoCl_flatsky", "max_stars_repo_head_hexsha": "9bcef43a78346d4062756f9798ec0cf66fd61e5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "starmask.f90", "max_issues_repo_name": "chiaki-hikage/pseudoCl_flatsky", "max_issues_repo_head_hexsha": "9bcef43a78346d4062756f9798ec0cf66fd61e5f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "starmask.f90", "max_forks_repo_name": "chiaki-hikage/pseudoCl_flatsky", "max_forks_repo_head_hexsha": "9bcef43a78346d4062756f9798ec0cf66fd61e5f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3892857143, "max_line_length": 81, "alphanum_fraction": 0.5571843029, "num_tokens": 2112}
|
from easydict import EasyDict as edict
import numpy as np
__C = edict()
cfg = __C
__C.TRAIN = edict()
__C.IMG_WIDTH = 300
__C.IMG_HEIGHT = 300
__C.IMG_CHANNEL = 3
__C.CLASS_NUM = 21
__C.BACKGROUND_ID = 0
# training settings
__C.TRAIN.LEARNING_RATE = 0.001 / 4
__C.TRAIN.MOMENTUM = 0.9
__C.TRAIN.BATCH_SIZE = 32
__C.TRAIN.NUM_PASS = 200
__C.TRAIN.L2REGULARIZATION = 0.0005 * 4
__C.TRAIN.LEARNING_RATE_DECAY_A = 0.1
__C.TRAIN.LEARNING_RATE_DECAY_B = 16551 * 80
__C.TRAIN.LEARNING_RATE_SCHEDULE = 'discexp'
__C.NET = edict()
# configuration for multibox_loss_layer
__C.NET.MBLOSS = edict()
__C.NET.MBLOSS.OVERLAP_THRESHOLD = 0.5
__C.NET.MBLOSS.NEG_POS_RATIO = 3.0
__C.NET.MBLOSS.NEG_OVERLAP = 0.5
# configuration for detection_map
__C.NET.DETMAP = edict()
__C.NET.DETMAP.OVERLAP_THRESHOLD = 0.5
__C.NET.DETMAP.EVAL_DIFFICULT = False
__C.NET.DETMAP.AP_TYPE = "11point"
# configuration for detection_output_layer
__C.NET.DETOUT = edict()
__C.NET.DETOUT.CONFIDENCE_THRESHOLD = 0.01
__C.NET.DETOUT.NMS_THRESHOLD = 0.45
__C.NET.DETOUT.NMS_TOP_K = 400
__C.NET.DETOUT.KEEP_TOP_K = 200
# configuration for priorbox_layer from conv4_3
__C.NET.CONV4 = edict()
__C.NET.CONV4.PB = edict()
__C.NET.CONV4.PB.MIN_SIZE = [30]
__C.NET.CONV4.PB.ASPECT_RATIO = [2.]
__C.NET.CONV4.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
# configuration for priorbox_layer from fc7
__C.NET.FC7 = edict()
__C.NET.FC7.PB = edict()
__C.NET.FC7.PB.MIN_SIZE = [60]
__C.NET.FC7.PB.MAX_SIZE = [114]
__C.NET.FC7.PB.ASPECT_RATIO = [2., 3.]
__C.NET.FC7.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
# configuration for priorbox_layer from conv6_2
__C.NET.CONV6 = edict()
__C.NET.CONV6.PB = edict()
__C.NET.CONV6.PB.MIN_SIZE = [114]
__C.NET.CONV6.PB.MAX_SIZE = [168]
__C.NET.CONV6.PB.ASPECT_RATIO = [2., 3.]
__C.NET.CONV6.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
# configuration for priorbox_layer from conv7_2
__C.NET.CONV7 = edict()
__C.NET.CONV7.PB = edict()
__C.NET.CONV7.PB.MIN_SIZE = [168]
__C.NET.CONV7.PB.MAX_SIZE = [222]
__C.NET.CONV7.PB.ASPECT_RATIO = [2., 3.]
__C.NET.CONV7.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
# configuration for priorbox_layer from conv8_2
__C.NET.CONV8 = edict()
__C.NET.CONV8.PB = edict()
__C.NET.CONV8.PB.MIN_SIZE = [222]
__C.NET.CONV8.PB.MAX_SIZE = [276]
__C.NET.CONV8.PB.ASPECT_RATIO = [2., 3.]
__C.NET.CONV8.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
# configuration for priorbox_layer from pool6
__C.NET.POOL6 = edict()
__C.NET.POOL6.PB = edict()
__C.NET.POOL6.PB.MIN_SIZE = [276]
__C.NET.POOL6.PB.MAX_SIZE = [330]
__C.NET.POOL6.PB.ASPECT_RATIO = [2., 3.]
__C.NET.POOL6.PB.VARIANCE = [0.1, 0.1, 0.2, 0.2]
|
{"hexsha": "318b9ae6798be4855b9fdabdee85f690eb3139bc", "size": 2573, "ext": "py", "lang": "Python", "max_stars_repo_path": "Demo/linux/ssd/models/vgg_ssd_net/config/pascal_voc_conf.py", "max_stars_repo_name": "daming-lu/Mobile", "max_stars_repo_head_hexsha": "849dbd3cd9076102d509ef054b8b3da72ed608a2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 70, "max_stars_repo_stars_event_min_datetime": "2017-08-14T05:11:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T01:39:01.000Z", "max_issues_repo_path": "Demo/linux/ssd/models/vgg_ssd_net/config/pascal_voc_conf.py", "max_issues_repo_name": "daming-lu/Mobile", "max_issues_repo_head_hexsha": "849dbd3cd9076102d509ef054b8b3da72ed608a2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 66, "max_issues_repo_issues_event_min_datetime": "2017-09-12T08:09:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-22T11:34:21.000Z", "max_forks_repo_path": "Demo/linux/ssd/models/vgg_ssd_net/config/pascal_voc_conf.py", "max_forks_repo_name": "daming-lu/Mobile", "max_forks_repo_head_hexsha": "849dbd3cd9076102d509ef054b8b3da72ed608a2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 29, "max_forks_repo_forks_event_min_datetime": "2017-07-28T03:09:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T01:43:08.000Z", "avg_line_length": 27.9673913043, "max_line_length": 48, "alphanum_fraction": 0.7232802176, "include": true, "reason": "import numpy", "num_tokens": 1068}
|
@testset "LinkedList" begin
@testset "l1" begin
l = list([1,2,3]...)
@test length(l) == 3
@test head(l) == 1
@test head(tail(l)) == 2
end
end
|
{"hexsha": "aa72bfa7b1d23f4f27e868fb6e42b0c40a723057", "size": 184, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/test_list.jl", "max_stars_repo_name": "swairshah/DataStructs.jl", "max_stars_repo_head_hexsha": "7f4503bd2d2557ff5d6868e93dec3661eba347ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/test_list.jl", "max_issues_repo_name": "swairshah/DataStructs.jl", "max_issues_repo_head_hexsha": "7f4503bd2d2557ff5d6868e93dec3661eba347ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-06-01T00:06:14.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-17T00:07:05.000Z", "max_forks_repo_path": "test/test_list.jl", "max_forks_repo_name": "swairshah/DataStructs.jl", "max_forks_repo_head_hexsha": "7f4503bd2d2557ff5d6868e93dec3661eba347ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.7272727273, "max_line_length": 32, "alphanum_fraction": 0.4673913043, "num_tokens": 66}
|
import numpy as np
def join_1d_np():
print("Concetante 1-D Arrays")
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.concatenate((arr1, arr2))
print("Array after concetenate")
print(arr)
def join_2d_np():
print("Concetante 2-D Arrays")
arr1 = np.array([[1, 2], [3, 4]])
arr2 = np.array([[5, 6], [7, 8]])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.concatenate((arr1, arr2), axis=1)
print("Array after concetenate")
print(arr)
def stack_np():
print("Concetante stack method")
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.stack((arr1, arr2), axis=1)
print("Array after concetenate")
print(arr)
def stack_row_np():
print("to stack along rows")
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.hstack((arr1, arr2))
print("Array after concetenate")
print(arr)
def stack_colmn_np():
print("to stack along columns")
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.vstack((arr1, arr2))
print("Array after concetenate")
print(arr)
def stack_height_np():
print("to stack along height")
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
print("First Array")
print(arr1)
print("second Array")
print(arr2)
arr = np.dstack((arr1, arr2))
print("Array after concetenate")
print(arr)
if __name__ == "__main__":
join_1d_np()
print("\n")
join_2d_np()
print("\n")
stack_np()
print("\n")
stack_row_np()
print("\n")
stack_colmn_np()
print("\n")
stack_height_np
|
{"hexsha": "5cb99172774c1e2caca99c5db5d580610e6cf482", "size": 1993, "ext": "py", "lang": "Python", "max_stars_repo_path": "Numpy/10_Join_Numpy.py", "max_stars_repo_name": "ajeyln/W3_School_Python_Coding", "max_stars_repo_head_hexsha": "cfc598d5d0e96072303846b07b5c2b6f11d72690", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Numpy/10_Join_Numpy.py", "max_issues_repo_name": "ajeyln/W3_School_Python_Coding", "max_issues_repo_head_hexsha": "cfc598d5d0e96072303846b07b5c2b6f11d72690", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numpy/10_Join_Numpy.py", "max_forks_repo_name": "ajeyln/W3_School_Python_Coding", "max_forks_repo_head_hexsha": "cfc598d5d0e96072303846b07b5c2b6f11d72690", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.4470588235, "max_line_length": 46, "alphanum_fraction": 0.58203713, "include": true, "reason": "import numpy", "num_tokens": 640}
|
import numpy as np
import matplotlib.pyplot as mp
import matplotlib.cm as mpcm
import matplotlib.colors as mpc
import scipy.stats as ss
# plotting settings
lw = 1.5
mp.rc('font', family = 'serif')
mp.rcParams['text.latex.preamble'] = [r'\boldmath']
mp.rcParams['axes.linewidth'] = lw
mp.rcParams['lines.linewidth'] = lw
cm = mpcm.get_cmap('plasma')
# datafiles
ppds = ['cmb', 'loc']
sums = ['ptes', 'prs']
# posterior summaries
post_means = np.genfromtxt('gw_grb_h_0_posterior_means.csv', \
delimiter=',')
post_vars = np.genfromtxt('gw_grb_h_0_posterior_vars.csv', \
delimiter=',')
n_h_0_true = post_means.shape[0]
n_bs = post_means.shape[1]
print n_bs
h_0_true_col = [cm(col) for col in np.linspace(0.2, 0.8, n_h_0_true)]
fig, axes = mp.subplots(1, 2, figsize=(12, 5))
for i in range(n_h_0_true):
print '* H_0 = {:5.2f}'.format(post_means[i, 0])
to_print = 'posterior mean = {:5.2f} +/- {:4.2f}'
print to_print.format(np.mean(post_means[i, 1:]), \
np.std(post_means[i, 1:]))
to_print = 'posterior sigma = {:5.2f} +/- {:4.2f}'
print to_print.format(np.mean(np.sqrt(post_vars[i, 1:])), \
np.std(np.sqrt(post_vars[i, 1:])))
kde = ss.gaussian_kde(post_means[i, 1:])
grid = np.linspace(np.min(post_means[i, 1:]), \
np.max(post_means[i, 1:]), \
1000)
axes[0].plot(grid, kde.evaluate(grid), color=h_0_true_col[i])
axes[0].axvline(post_means[i, 0], color=h_0_true_col[i], ls='--')
kde = ss.gaussian_kde(np.sqrt(post_vars[i, 1:]))
grid = np.linspace(np.min(np.sqrt(post_vars[i, 1:])), \
np.max(np.sqrt(post_vars[i, 1:])), \
1000)
axes[1].plot(grid, kde.evaluate(grid), color=h_0_true_col[i], \
label=r'$H_0 = {:5.2f}$'.format(post_vars[i, 0]))
axes[0].set_xlabel(r'$\bar{H}_0$', fontsize=18)
axes[0].set_ylabel(r'${\rm Pr}(\bar{H}_0)$', fontsize=18)
axes[0].tick_params(axis='both', which='major', labelsize=12)
axes[1].set_xlabel(r'$\sigma_{H_0}$', fontsize=18)
axes[1].set_ylabel(r'${\rm Pr}(\sigma_{H_0})$', fontsize=18)
axes[1].tick_params(axis='both', which='major', labelsize=12)
axes[1].legend(loc='upper right', fontsize=14)
fig.suptitle('Bootstrap-Averaged Posterior Means / Sigmas', \
fontsize=18)
fig.savefig('gw_grd_h_0_bs_avg_posterior_moments.pdf', \
bbox_inches = 'tight')
mp.close(fig)
# PPD summaries
for i in range(len(ppds)):
for j in range(len(sums)):
# read data
fname = 'gw_grb_h_0_' + ppds[i] + '_ppd_' + sums[j]
data = np.genfromtxt(fname + '.csv', delimiter=',')
n_bs = data.shape[1]
print n_bs
# plot
n_h_0_true = data.shape[0]
fig, axes = mp.subplots(1, n_h_0_true, \
figsize=(6 * n_h_0_true, 5))
if ppds[i] == 'cmb':
fig.suptitle(r'$\hat{H}_0^{\rm CMB}\, {\rm Prediction}$', \
fontsize=18)
else:
fig.suptitle(r'$\hat{H}_0^{\rm CDL}\, {\rm Prediction}$', \
fontsize=18)
if sums[j] == 'ptes':
x_label = r'$p$'
y_label = r'${\rm Pr}(p)$'
else:
x_label = r'$\rho$'
y_label = r'${\rm Pr}(\rho)$'
for k in range(n_h_0_true):
kde = ss.gaussian_kde(data[k, 1:])
grid = np.linspace(np.min(data[k, 1:]), \
np.max(data[k, 1:]), \
1000)
axes[k].plot(grid, kde.evaluate(grid), color=cm(0.5))
axes[k].set_xlabel(x_label, fontsize=18)
axes[k].set_ylabel(y_label, fontsize=18)
axes[k].tick_params(axis='both', which='major', labelsize=12)
axes[k].set_title(r'$H_0 = {:5.2f}$'.format(data[k, 0]), \
fontsize=18)
# finish plot
fig.savefig(fname + '.pdf', bbox_inches = 'tight')
mp.close(fig)
# quick check of required numbers of samples
def rho(d, n, var_ratio, n_event_ref, n_event):
d_n_event = n_event_ref / n_event
return np.exp(-0.5 * rho_num(d, n, d_n_event) / \
rho_den(var_ratio, d_n_event))
def rho_num(d, n, d_n_event):
if d > 0.0:
return (d - n * np.sqrt(d_n_event)) ** 2
else:
return (d + n * np.sqrt(d_n_event)) ** 2
def rho_den(var_ratio, d_n_event):
return var_ratio + d_n_event
def num_ratio(d, n, m, var_ratio):
term = (m ** 2 * var_ratio - d ** 2)
print term
return [((-n * d - \
np.sqrt((n * d) ** 2 - term * (m ** 2 - n ** 2))) / \
term) ** 2, \
((-n * d + \
np.sqrt((n * d) ** 2 - term * (m ** 2 - n ** 2))) / \
term) ** 2]
n_ref = 51.0
mu_obs = np.array([67.81, 73.24])
sig_obs = np.array([0.92, 1.74])
n_sigma_sv = 1.0
n_sigma_thresh = 3.0
n_sigma_diff = [(mu_obs[1] - mu_obs[0]) / np.sqrt(post_vars[i, 1]), \
(mu_obs[0] - mu_obs[1]) / np.sqrt(post_vars[i, 1])]
var_ratio = [sig_obs[1] ** 2 / post_vars[i, 1], \
sig_obs[0] ** 2 / post_vars[i, 1]]
print n_sigma_diff
print var_ratio
n_req = np.zeros(2)
n_req[0] = n_ref * num_ratio(n_sigma_diff[0], n_sigma_sv, \
n_sigma_thresh, var_ratio[0])[0]
ln_rho = -2.0 * np.log(rho(n_sigma_diff[0], n_sigma_sv, \
var_ratio[0], n_ref, n_req[0]))
print n_req[0], ln_rho, n_sigma_thresh ** 2
n_req[1] = n_ref * num_ratio(n_sigma_diff[1], n_sigma_sv, \
n_sigma_thresh, var_ratio[1])[1]
ln_rho = -2.0 * np.log(rho(n_sigma_diff[1], n_sigma_sv, \
var_ratio[1], n_ref, n_req[1]))
print n_req[1], ln_rho, n_sigma_thresh ** 2
n_grid = np.arange(n_ref, 5000.0)
mp.loglog(n_grid, rho_num(n_sigma_diff[0], n_sigma_sv, n_ref / n_grid), 'r', lw=1.0)
mp.plot(n_grid, 1.0 / rho_den(var_ratio[0], n_ref / n_grid), 'g', lw=1.0)
mp.plot(n_grid, 1.0 / rho_den(var_ratio[1], n_ref / n_grid), 'b', lw=1.0)
mp.plot(n_grid, -2.0 * np.log(rho(n_sigma_diff[0], n_sigma_sv, var_ratio[0], \
n_ref, n_grid)), 'g')
mp.plot(n_grid, -2.0 * np.log(rho(n_sigma_diff[1], n_sigma_sv, var_ratio[1], \
n_ref, n_grid)), 'b')
mp.axhline(n_sigma_thresh ** 2, color='k', linestyle='-.')
mp.axvline(n_req[0], color='g', linestyle='-.')
mp.axvline(n_req[1], color='b', linestyle='-.')
mp.xlabel(r'$N$')
mp.ylabel(r'$f(N)$')
mp.xlim(n_ref, 5000)
mp.ylim(0.3, 40.0)
mp.savefig('gw_grb_h_0_ppd_samp_var_limits.pdf', bbox_inches='tight')
mp.show()
exit()
print num_ratio(4.53, n_sigma_sv, n_sigma_thresh, 2.1)
print 5.43, mu_obs[1] - mu_obs[0]
print 1.2, np.sqrt(post_vars[i, 1])
print 5.43 / 1.2, n_sigma_diff[0]
m = 3.0
n = 1.0
d = 3.77 # 4.53
vrat = 1.46 # 2.1
print ((d*n+np.sqrt((d*n)**2-(vrat*m**2-d**2)*(m**2-n**2)))/(vrat*m**2-d**2))**2
|
{"hexsha": "8373339dd9a549bf7c7f2156eb693bffea51c85a", "size": 6207, "ext": "py", "lang": "Python", "max_stars_repo_path": "gw_grb_h_0_ppd_summaries.py", "max_stars_repo_name": "KamshatTazhenova/hh0", "max_stars_repo_head_hexsha": "c71845056c5a108cb95654b1a1012d63034541c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2017-07-04T06:56:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T08:35:48.000Z", "max_issues_repo_path": "gw_grb_h_0_ppd_summaries.py", "max_issues_repo_name": "KamshatTazhenova/hh0", "max_issues_repo_head_hexsha": "c71845056c5a108cb95654b1a1012d63034541c2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gw_grb_h_0_ppd_summaries.py", "max_forks_repo_name": "KamshatTazhenova/hh0", "max_forks_repo_head_hexsha": "c71845056c5a108cb95654b1a1012d63034541c2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-07-07T10:00:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-08T09:38:25.000Z", "avg_line_length": 33.7336956522, "max_line_length": 84, "alphanum_fraction": 0.6246173675, "include": true, "reason": "import numpy,import scipy", "num_tokens": 2273}
|
[STATEMENT]
lemma add_canc1: "D x y \<Longrightarrow> rquot (x \<cdot> y) x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. D x y \<Longrightarrow> rquot (x \<oplus> y) x = y
[PROOF STEP]
using rquot_prop
[PROOF STATE]
proof (prove)
using this:
D ?x ?z \<and> ?y = ?x \<oplus> ?z \<Longrightarrow> ?z = rquot ?y ?x
goal (1 subgoal):
1. D x y \<Longrightarrow> rquot (x \<oplus> y) x = y
[PROOF STEP]
by simp
|
{"llama_tokens": 177, "file": "PSemigroupsConvolution_Partial_Semigroups", "length": 2}
|
export ElectronSite,
electronSites
struct ElectronSite <: Site
s::Index
ElectronSite(I::Index) = new(I)
end
ElectronSite(n::Int) = ElectronSite(Index(4,"Site,Electron,n=$n"))
function electronSites(N::Int;kwargs...)::SiteSet
sites = SiteSet(N)
for n=1:N
set(sites,n,ElectronSite(n))
end
return sites
end
function operator(site::ElectronSite,
opname::AbstractString)::ITensor
s = site.s
sP = prime(site.s)
Emp = s(1)
EmpP = sP(1)
Up = s(2)
UpP = sP(2)
Dn = s(3)
DnP = sP(3)
UpDn = s(4)
UpDnP = sP(4)
Op = ITensor(dag(s), s')
if opname == "Nup"
Op[Up, UpP] = 1.
Op[UpDn, UpDnP] = 1.
elseif opname == "Ndn"
Op[Dn, DnP] = 1.
Op[UpDn, UpDnP] = 1.
elseif opname == "Ntot"
Op[Up, UpP] = 1.
Op[Dn, DnP] = 1.
Op[UpDn, UpDnP] = 2.
elseif opname == "Cup" || opname == "Aup"
Op[Up, EmpP] = 1.
Op[UpDn, DnP] = 1.
elseif opname == "Cdagup" || opname == "Adagup"
Op[Emp, UpP] = 1.
Op[Dn, UpDnP] = 1.
elseif opname == "Cdn" || opname == "Adn"
Op[Dn, EmpP] = 1.
Op[UpDn, UpP] = 1.
elseif opname == "Cdagdn" || opname == "Adagdn"
Op[Emp, DnP] = 1.
Op[Up, UpDnP] = 1.
elseif opname == "FermiPhase" || opname == "FP"
Op[Up, UpP] = -1.
Op[Emp, EmpP] = 1.
Op[Dn, DnP] = -1.
Op[UpDn, UpDnP] = 1.
elseif opname == "Fup"
Op[Emp, EmpP] = 1.
Op[Up, UpP] = -1.
Op[Dn, DnP] = 1.
Op[UpDn, UpDnP] = -1.
elseif opname == "Fdn"
Op[Emp, EmpP] = 1.
Op[Up, UpP] = 1.
Op[Dn, DnP] = -1.
Op[UpDn, UpDnP] = -1.
elseif opname == "Sᶻ" || opname == "Sz"
Op[Up, UpP] = 0.5
Op[Dn, DnP] = -0.5
elseif opname == "Sˣ" || opname == "Sx"
Op[Up, DnP] = 1.0
Op[Dn, UpP] = 1.0
elseif opname == "S⁺" || opname == "Splus"
Op[Dn, UpP] = 1.
elseif opname == "S⁻" || opname == "Sminus"
Op[Up, DnP] = 1.
elseif opname == "Emp" || opname == "0"
pEmp = ITensor(s)
pEmp[Emp] = 1.
return pEmp
elseif opname == "Up" || opname == "↑"
pU = ITensor(s)
pU[Up] = 1.
return pU
elseif opname == "Dn" || opname == "↓"
pD = ITensor(s)
pD[Dn] = 1.
return pD
elseif opname == "UpDn" || opname == "↑↓"
pUD = ITensor(s)
pUD[UpDn] = 1.
return pUD
else
throw(ArgumentError("Operator name $opname not recognized for ElectronSite"))
end
return Op
end
|
{"hexsha": "0918b7c337fd475a1e566afb8a43ae1c23bf4b6c", "size": 2629, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/physics/sitesets/electron.jl", "max_stars_repo_name": "Roger-luo/ITensors.jl", "max_stars_repo_head_hexsha": "8b3d7fca9cd0856d8119f5d712b675b023d563a1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/physics/sitesets/electron.jl", "max_issues_repo_name": "Roger-luo/ITensors.jl", "max_issues_repo_head_hexsha": "8b3d7fca9cd0856d8119f5d712b675b023d563a1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/physics/sitesets/electron.jl", "max_forks_repo_name": "Roger-luo/ITensors.jl", "max_forks_repo_head_hexsha": "8b3d7fca9cd0856d8119f5d712b675b023d563a1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0297029703, "max_line_length": 85, "alphanum_fraction": 0.4747052111, "num_tokens": 1043}
|
import pickle
import numpy as np
import os.path
class MNIST:
def __init__(self):
self.dataset = {}
self.path = os.path.dirname(os.path.abspath(__file__))
def _load_img(self, filename):
with open(filename, 'rb') as file:
data = np.frombuffer(file.read(), np.uint8, offset=16)
return data.reshape(-1, 784)
def _load_label(self, filename):
with open(filename, 'rb') as file:
labels = np.frombuffer(file.read(), np.uint8, offset=8)
return labels
def _creat_pickle(self):
self.dataset['train_img'] = self._load_img(self.path + '/train-images.idx3-ubyte')
self.dataset['train_label'] = self._load_label(self.path + '/train-labels.idx1-ubyte')
self.dataset['test_img'] = self._load_img(self.path + '/t10k-images.idx3-ubyte')
self.dataset['test_label'] = self._load_label(self.path + '/t10k-labels.idx1-ubyte')
with open(self.path + '/mnist.pkl', 'wb') as file:
pickle.dump(self.dataset, file, -1)
def _one_hot_label(self, X):
T = np.zeros((X.size, 10))
for idx, row in enumerate(T):
row[X[idx]] = 1
return T
def load_data(self, normalize=True, flatten=False, one_hot_label=False, option='train', **kwargs):
'''
## Arguments
normalize : if true, normalize the input pixel
one_hot_label : if true, creat one hot label
flatten : if true, load the image as a line
option: select option
train: return train data only\n
test: return test data only\n
both: return both train and test data
'''
if not os.path.exists(self.path + '/mnist.pkl'):
self._creat_pickle()
with open(self.path + '/mnist.pkl', 'rb') as file:
dataset = pickle.load(file)
if normalize:
for i in ('train_img', 'test_img'):
dataset[i] = dataset[i].astype(np.float32)
dataset[i] /= 255.0
dataset[i] += 0.01
if one_hot_label:
dataset['train_label'] = self._one_hot_label(dataset['train_label'])
dataset['test_label'] = self._one_hot_label(dataset['test_label'])
if not flatten:
for i in ('train_img', 'test_img'):
dataset[i] = dataset[i].reshape(-1, 1, 28, 28)
if option == 'train':
return (dataset['train_img'], dataset['train_label'])
elif option == 'test':
return (dataset['test_img'], dataset['test_label'])
elif option == 'both':
return (dataset['train_img'], dataset['train_label']), (dataset['test_img'], dataset['test_label'])
|
{"hexsha": "e0e6273c98237521544de244a611a3f8c0a82806", "size": 2748, "ext": "py", "lang": "Python", "max_stars_repo_path": "agent/data/MNIST/mnist.py", "max_stars_repo_name": "kashu98/Deep-Agent", "max_stars_repo_head_hexsha": "04dc5f8d1dc6963f1bf075cd3e67dcb39784a861", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agent/data/MNIST/mnist.py", "max_issues_repo_name": "kashu98/Deep-Agent", "max_issues_repo_head_hexsha": "04dc5f8d1dc6963f1bf075cd3e67dcb39784a861", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agent/data/MNIST/mnist.py", "max_forks_repo_name": "kashu98/Deep-Agent", "max_forks_repo_head_hexsha": "04dc5f8d1dc6963f1bf075cd3e67dcb39784a861", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7042253521, "max_line_length": 112, "alphanum_fraction": 0.5742358079, "include": true, "reason": "import numpy", "num_tokens": 659}
|
import numpy as np
def aggregate_loss_dict(agg_loss_dict):
mean_vals = {}
for output in agg_loss_dict:
for key in output:
mean_vals[key] = mean_vals.setdefault(key, []) + [output[key]]
for key in mean_vals:
if len(mean_vals[key]) > 0:
mean_vals[key] = sum(mean_vals[key]) / len(mean_vals[key])
else:
print(f'{key} has no value')
mean_vals[key] = 0
return mean_vals
def compute_cosine_weights(x):
""" Computes weights to be used in the id loss function with minimum value of 0.5 and maximum value of 1. """
values = np.abs(x.cpu().detach().numpy())
assert np.min(values) >= 0. and np.max(values) <= 1., "Input values should be between 0. and 1!"
weights = 0.25 * (np.cos(np.pi * values)) + 0.75
return weights
|
{"hexsha": "678806c7c4c8b4272a7e144636aa8a89e4d0008c", "size": 741, "ext": "py", "lang": "Python", "max_stars_repo_path": "utils/train_utils.py", "max_stars_repo_name": "thienquang199x/SAM", "max_stars_repo_head_hexsha": "c18ab4eee23ee5196d772b5f57d6bf6e2708b262", "max_stars_repo_licenses": ["Apache-2.0", "BSD-2-Clause", "MIT"], "max_stars_count": 351, "max_stars_repo_stars_event_min_datetime": "2021-02-04T17:49:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T16:23:37.000Z", "max_issues_repo_path": "utils/train_utils.py", "max_issues_repo_name": "thienquang199x/SAM", "max_issues_repo_head_hexsha": "c18ab4eee23ee5196d772b5f57d6bf6e2708b262", "max_issues_repo_licenses": ["Apache-2.0", "BSD-2-Clause", "MIT"], "max_issues_count": 45, "max_issues_repo_issues_event_min_datetime": "2021-02-05T12:05:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T07:01:19.000Z", "max_forks_repo_path": "utils/train_utils.py", "max_forks_repo_name": "thienquang199x/SAM", "max_forks_repo_head_hexsha": "c18ab4eee23ee5196d772b5f57d6bf6e2708b262", "max_forks_repo_licenses": ["Apache-2.0", "BSD-2-Clause", "MIT"], "max_forks_count": 72, "max_forks_repo_forks_event_min_datetime": "2021-02-06T16:29:55.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-19T10:15:26.000Z", "avg_line_length": 29.64, "max_line_length": 110, "alphanum_fraction": 0.681511471, "include": true, "reason": "import numpy", "num_tokens": 214}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.