text
stringlengths 0
1.25M
| meta
stringlengths 47
1.89k
|
|---|---|
"""
This Python script calculates the Street-Network Disconnectedness index (SNDi).
Journal article: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0223078
Authors: Christopher Barrington-Leigh and Adam Millard-Ball
Date: November 26, 2019
Adapted for momepy by: Andres Morfin Veytia
Date: September 25, 2021
"""
'''
TODO:
Step 1: copy over hardcoded values (DONE!)
Step 2: calculate all metrics
a) merge all degree-2 edges (DONE!)
b) calculate nodal degree metrics (DONE!)
c) calculate circuity metrics
d) calculate bridge metrics (TODO: Adapt to multigraphs)
e) calculate non-cycle metrics (TODO: Adapt to multigraphs)
f) calculate sinuosity metrics (DONE!)
Step 3: calculate SNDI
'''
import numpy as np
from numpy import Inf
import math
import geopandas as gpd
import pandas as pd
import networkx as nx
import libpysal
from .utils import nx_to_gdf, gdf_to_nx
from .graph import mean_node_degree, node_degree
from .preprocessing import remove_false_nodes
from .shape import Linearity
import time
def SNDi(street_graph):
'''
PART 1
process graph
TODO: future input either gdf or graph
'''
# convert to gdf, only need lines
lines = nx_to_gdf(street_graph, points=False)
'''
PART 2
mean, standard deviation, and PCA1 values for GADM dataset https://gitlab.com/cpbl/global-sprawl-2020
'''
# nodal degree (negative)
mean_nodal_degree = -2.8303675378032223
std_nodal_degree = 0.3429680685039067
pca1_nodal_degree = 0.3493185
# dead ends
mean_frc_dead_ends = 0.1938995209875757
std_frc_dead_ends = 0.12799681159868687
pca1_frc_dead_ends = 0.34891059999999996
# log circuity 0-0.5 km
mean_log_circuity_1 = 0.17186301207993082
std_log_circuity_1 = 0.08438691033187842
pca1_log_circuity_1 = 0.2702526
# log circuity 0.5-1 km
mean_log_circuity_2 = 0.15163308503586118
std_log_circuity_2 = 0.06012702604377113
pca1_log_circuity_2 = 0.2956021
# log circuity 1-1.5 km
mean_log_circuity_3 = 0.1326839886337719
std_log_circuity_3 = 0.04275427261228078
pca1_log_circuity_3 = 0.2868906
# log circuity 1.5-2 km
mean_log_circuity_4 = 0.10899568877464477
std_log_circuity_4 = 0.02797831394141562
pca1_log_circuity_4 = 0.25418209999999997
# log circuity 2-2.5 km
mean_log_circuity_5 = 0.07702766891890014
std_log_circuity_5 = 0.01748327463656427
pca1_log_circuity_5 = 0.1882174
# log circuity 2.5-3 km
mean_log_circuity_6 = 0.03958868880572528
std_log_circuity_6 = 0.011484248546405224
pca1_log_circuity_6 = 0.11011389999999999
# fraction bridges (length)
mean_frc_bridges_length= 0.04576044830113072
std_frc_bridges_length = 0.09259988437312076
pca1_frc_bridges_length = 0.22149539999999998
# fraction bridges (N edges)
mean_frc_bridges_N = 0.1831914893399157
std_frc_bridges_N = 0.14273719661948095
pca1_frc_bridges_N = 0.28478059999999994
# fraction non-cycle (length)
mean_frc_non_cycle_length = 0.1683625923750888
std_frc_non_cycle_length = 0.15402234858926675
pca1_frc_non_cycle_length = 0.3198946
# fraction non-cycle (N edges)
mean_frc_non_cycle_N = 0.1831914893399157
std_frc_non_cycle_N = 0.14273719661948095
pca1_frc_non_cycle_N = 0.3792382
# log sinuosity
mean_log_sinuosity = 0.034455048569152755
std_log_sinuosity = 0.026418496738454776
pca1_log_sinuosity = 0.1582431
'''
PART 3
calculate NODAL DEGREE METRICS
'''
# remove and merge all degree-2 nodes from gdf and convert to graph (Note not working for Multigraph)
lines = remove_false_nodes(lines)
street_graph = gdf_to_nx(lines, multigraph=False)
# add nodal degree to graph attributes
street_graph = node_degree(street_graph)
# get array of node degrees.
array_deg = np.array(list(dict(street_graph.nodes('degree')).values()))
# change all values > 4 to 4
array_deg[array_deg > 4] = 4
# get fraction of type of nodes. There is only 1,3,4
frc_node_deg_1 = np.count_nonzero(array_deg == 1)/array_deg.size
frc_node_deg_3 = np.count_nonzero(array_deg == 3)/array_deg.size
frc_node_deg_4 = np.count_nonzero(array_deg == 4)/array_deg.size
# TESTING: frc_node_deg_1 + frc_node_deg_3 + frc_node_deg_4 should equal 1
# fraction of degree 1 or 3
frc_node_deg_1_3 = frc_node_deg_1 + frc_node_deg_3
# get fraction of dead ends (I think number of node dead ends is equal to number of edge dead ends?)
N_node_dead_ends = np.count_nonzero(array_deg == 1)
frc_node_dead_ends = N_node_dead_ends/array_deg.size
# Negative nodal degree
# cannot use momepy function (mean_node_degree) because we need to set any node with degree > 4 equal to 4
neg_mean_nodal_degree = -np.mean(array_deg)
'''
PART 4
calculate DENDRICITY METRICS
'''
# get total number of edges
N_edges = lines.shape[0]
# create dictionary to assign edge attributes. Make everything a cycle to start
edge_dendricity = dict([(tuple(edge),'C') for edge in street_graph.edges()])
# get bridges
bridges = list(nx.bridges(street_graph))
# Assign B value to bridge edges
for edge in bridges:
edge_dendricity[tuple(edge)]='B'
# find degree 1 nodes for dead ends
deg_1_nodes = [node for node, attr in street_graph.nodes(data=True) if attr['degree']==1]
# Assign D value to dead end edges
for node in deg_1_nodes:
edge = list(street_graph.edges(node))[0]
edge_dendricity[tuple(edge)]='D'
# get fraction of edge dead ends
N_dead_ends = len(deg_1_nodes)
frc_edge_dead_ends = N_dead_ends/N_edges
# get number/fraction of bridges TODO: only working with Graph and not Multigraphs. Subtract number of dead-ends
N_bridges = len(bridges) - N_dead_ends
frc_edge_bridges = N_bridges/N_edges
# get number/fraction of self loops TODO: only working with Graph and not Multigraphs
self_loops = list(nx.selfloop_edges(street_graph))
# Assign B value to bridge edges
for edge in self_loops:
edge_dendricity[tuple(edge)]='S'
N_self_loops = len(self_loops)
frc_edge_self_loops = N_self_loops/N_edges
# get number/fraction of cycles and non_cycles
N_cycles = N_edges - N_dead_ends - N_bridges - N_self_loops
frc_edge_cylces = N_cycles/N_edges
frc_edge_non_cycles = 1 - frc_edge_cylces
# set dendricity attributes to graph
nx.set_edge_attributes(street_graph, edge_dendricity, 'dendricity')
# convert back to gdf for edges
lines = nx_to_gdf(street_graph, points=False)
# length of all edges
total_length = np.sum(lines.geometry.length)
# length of cycles
cycle_length = np.sum(lines[lines['dendricity']=='C'].geometry.length)
frc_length_cycle = cycle_length/total_length
# length of self loops
self_loop_length = np.sum(lines[lines['dendricity']=='S'].geometry.length)
frc_length_self_loops = self_loop_length/total_length
# length of dead ends
dead_ends_length = np.sum(lines[lines['dendricity']=='D'].geometry.length)
frc_length_dead_ends = dead_ends_length/total_length
# length of bridges
bridges_length = np.sum(lines[lines['dendricity']=='B'].geometry.length)
frc_length_bridges = bridges_length/total_length
# get cycle/non-cycle lenghs
frc_length_non_cycle = frc_length_self_loops + frc_length_dead_ends + frc_length_bridges
# TEST this should always equal 1 :frc_length_non_cycle + frc_length_cycle
'''
PART 5
calculate sinuosity
'''
# sinuosity is quite similar to mm.linearity. It is just the inverse of it and summed
log_sinuosity = np.log(1 / Linearity(lines, aggregate=True).aggregated)
'''
PART 6
calculate circuity metrics
TODO: jsut need one function
'''
# get node list
node_list = street_graph.nodes
# euclidean distance matrix from node to node
eucl_dist_matrix = libpysal.cg.distance_matrix(np.asarray(node_list), p=2.0)
# set anything farher away than 3km to zero
bool_0_3000 = np.array(np.where(eucl_dist_matrix < 3000, 1, 0), dtype=bool)
eucl_dist_matrix = eucl_dist_matrix[bool_0_3000]
# get shortest path distance matrix from all nodes to all nodes (TODO: THIS IS BOTTLENECK)
df = pd.DataFrame.from_dict(dict(nx.all_pairs_dijkstra_path_length(street_graph, weight='mm_len')))
path_dist_matrix = df.reindex(index=node_list, columns=node_list).to_numpy()
path_dist_matrix = np.nan_to_num(path_dist_matrix, posinf=0, neginf=0)
path_dist_matrix = path_dist_matrix[bool_0_3000]
# 0-500 meter circuity
circuity_0_500 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[0, 500])
if round(circuity_0_500, 2):
log_circuity_0_500 = np.log(circuity_0_500)
else:
log_circuity_0_500 = 0
print('WARNING: No nodes within 0-500 meters of each other')
# 500-1000 meter circuity
circuity_500_1000 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[500, 1000])
if round(circuity_500_1000, 2):
log_circuity_500_1000 = np.log(circuity_500_1000)
else:
log_circuity_500_1000 = 0
print('WARNING: No nodes within 500-1000 meters of each other')
# 1000-1500 meter circuity
circuity_1000_1500 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[1000, 1500])
if round(circuity_1000_1500, 2):
log_circuity_1000_1500 = np.log(circuity_1000_1500)
else:
log_circuity_1000_1500 = 0
print('WARNING: No nodes within 1000-1500 meters of each other')
# 1500-2000 meter circuity
circuity_1500_2000 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[1500, 2000])
if round(circuity_1500_2000, 2):
log_circuity_1500_2000 = np.log(circuity_1500_2000)
else:
log_circuity_1500_2000 = 0
print('WARNING: No nodes within 1500-2000 meters of each other')
# 2000-2500 meter circuity
circuity_2000_2500 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[2000, 2500])
if round(circuity_2000_2500, 2):
log_circuity_2000_2500 = np.log(circuity_2000_2500)
else:
log_circuity_2000_2500 = 0
print('WARNING: No nodes within 2000-2500 meters of each other')
# 2500-3000 meter circuity
circuity_2500_3000 = circuity_band(path_dist_matrix, eucl_dist_matrix, band=[2500, 3000])
if round(circuity_2500_3000, 2):
log_circuity_2500_3000 = np.log(circuity_2500_3000)
else:
log_circuity_2500_3000 = 0
print('WARNING: No nodes within 2500-3000 meters of each other')
'''
PART 7
calculate PCA1
'''
PCA1_1 = pca1_nodal_degree*(neg_mean_nodal_degree - mean_nodal_degree)/std_nodal_degree
PCA1_2 = pca1_frc_dead_ends*(frc_node_dead_ends - mean_frc_dead_ends)/std_frc_dead_ends
PCA1_3 = pca1_log_circuity_1*(log_circuity_0_500 - mean_log_circuity_1)/std_log_circuity_1
PCA1_4 = pca1_log_circuity_2*(log_circuity_500_1000 - mean_log_circuity_2)/std_log_circuity_2
PCA1_5 = pca1_log_circuity_3*(log_circuity_1000_1500 - mean_log_circuity_3)/std_log_circuity_3
PCA1_6 = pca1_log_circuity_4*(log_circuity_1500_2000 - mean_log_circuity_4)/std_log_circuity_4
PCA1_7 = pca1_log_circuity_5*(log_circuity_2000_2500 - mean_log_circuity_5)/std_log_circuity_5
PCA1_8 = pca1_log_circuity_6*(log_circuity_2500_3000 - mean_log_circuity_6)/std_log_circuity_6
PCA1_9 = pca1_frc_bridges_length*(frc_length_bridges - mean_frc_bridges_length)/std_frc_bridges_length
PCA1_10 = pca1_frc_bridges_N*(frc_edge_bridges - mean_frc_bridges_N)/std_frc_bridges_N
PCA1_11 = pca1_frc_non_cycle_length*(frc_length_non_cycle - mean_frc_non_cycle_length)/std_frc_non_cycle_length
PCA1_12 = pca1_frc_non_cycle_N*(frc_edge_non_cycles - mean_frc_non_cycle_N)/std_frc_non_cycle_N
PCA1_13 = pca1_log_sinuosity*(log_sinuosity - mean_log_sinuosity)/std_log_sinuosity
PCA1 = PCA1_1 + PCA1_2 + PCA1_3 + PCA1_4 + PCA1_5 + PCA1_6 + PCA1_7 + PCA1_8 + PCA1_9 + PCA1_10 + PCA1_11 + PCA1_12 + PCA1_13
'''
PART 8
calculate SNDi
'''
SNDi = PCA1 + 3.0
print(f'Mean nodal degree (-) is: {neg_mean_nodal_degree}')
print('-------------------------------------------------')
print(f'Fraction of node dead ends is: {frc_node_dead_ends}')
print('-------------------------------------------------')
print(f'Fraction of bridges length is: {frc_length_bridges}')
print('-------------------------------------------------')
print(f'Fraction of bridges N edges is: {frc_edge_bridges}')
print('-------------------------------------------------')
print(f'Fraction of non-cylce length is: {frc_length_non_cycle}')
print('-------------------------------------------------')
print(f'Fraction of bridges N edges is: {frc_edge_non_cycles}')
print('-------------------------------------------------')
print(f'Log of sinuosity is: {log_sinuosity}')
print('-------------------------------------------------')
print(f'Log of circuity 0-500 is: {log_circuity_0_500}')
print('-------------------------------------------------')
print(f'Log of circuity 500-1000 is: {log_circuity_500_1000}')
print('-------------------------------------------------')
print(f'Log of circuity 1000-1500 is: {log_circuity_1000_1500}')
print('-------------------------------------------------')
print(f'Log of circuity 1500-2000 is: {log_circuity_1500_2000}')
print('-------------------------------------------------')
print(f'Log of circuity 2000-2500 is: {log_circuity_2000_2500}')
print('-------------------------------------------------')
print(f'Log of circuity 2500-3000 is: {log_circuity_2500_3000}')
return SNDi
def circuity_band(path_dist, eucl_dist, band=[0, 500]):
# get boolean array within using euclidean
bool_band = np.array(np.where((eucl_dist > band[0]) & (eucl_dist <= band[1]), 1, 0), dtype=bool)
# select based on bool and sum
path_sum = np.sum(path_dist[bool_band])
eucl_sum = np.sum(eucl_dist[bool_band])
# replace all infinity with zero
if round(eucl_sum, 2):
circuity_band = path_sum/eucl_sum
else:
circuity_band = 0
print(f'WARNING: No nodes within {band[0]}-{band[1]} meters of each other')
return circuity_band
|
{"hexsha": "ef297266410c55f78bfa054308026b20aee0da26", "size": 14428, "ext": "py", "lang": "Python", "max_stars_repo_path": "momepy/sndi.py", "max_stars_repo_name": "amorfinv/momepy", "max_stars_repo_head_hexsha": "6741471bdaf2bfa0d94f3ed4724dd464129db32b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-27T04:01:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-27T04:01:17.000Z", "max_issues_repo_path": "momepy/sndi.py", "max_issues_repo_name": "amorfinv/momepy", "max_issues_repo_head_hexsha": "6741471bdaf2bfa0d94f3ed4724dd464129db32b", "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": "momepy/sndi.py", "max_forks_repo_name": "amorfinv/momepy", "max_forks_repo_head_hexsha": "6741471bdaf2bfa0d94f3ed4724dd464129db32b", "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.0899742931, "max_line_length": 129, "alphanum_fraction": 0.695522595, "include": true, "reason": "import numpy,from numpy,import networkx", "num_tokens": 4476}
|
import os
import logging
import datetime
import gc
import joblib
import tqdm
import tempfile
import math
import numpy as np
import torch
import torchvision
import skimage
import skimage.io
import skimage.transform
import skimage.measure
import skimage.morphology
import justdeepit.utils
from justdeepit.models.abstract import ModuleTemplate
logger = logging.getLogger(__name__)
class REBNCONV(torch.nn.Module):
def __init__(self,in_ch=3, out_ch=3, dirate=1):
super(REBNCONV, self).__init__()
self.conv_s1 = torch.nn.Conv2d(in_ch, out_ch, 3, padding=1 * dirate, dilation=1 * dirate)
self.bn_s1 = torch.nn.BatchNorm2d(out_ch)
self.relu_s1 = torch.nn.ReLU(inplace=True)
def forward(self,x):
hx = x
xout = self.relu_s1(self.bn_s1(self.conv_s1(hx)))
return xout
def _upsample_like(src,tar):
src = torch.nn.functional.interpolate(src,size=tar.shape[2:], mode='bilinear', align_corners=True)
return src
### RSU-7 ###
class RSU7(torch.nn.Module):
def __init__(self, in_ch=3, mid_ch=12, out_ch=3):
super(RSU7,self).__init__()
self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1)
self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1)
self.pool1 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool2 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool3 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool4 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool5 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv6 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.rebnconv7 = REBNCONV(mid_ch, mid_ch, dirate=2)
self.rebnconv6d = REBNCONV(mid_ch*2,mid_ch, dirate=1)
self.rebnconv5d = REBNCONV(mid_ch*2,mid_ch, dirate=1)
self.rebnconv4d = REBNCONV(mid_ch*2,mid_ch, dirate=1)
self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch, dirate=1)
self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch, dirate=1)
self.rebnconv1d = REBNCONV(mid_ch*2,out_ch, dirate=1)
def forward(self,x):
hx = x
hxin = self.rebnconvin(hx)
hx1 = self.rebnconv1(hxin)
hx = self.pool1(hx1)
hx2 = self.rebnconv2(hx)
hx = self.pool2(hx2)
hx3 = self.rebnconv3(hx)
hx = self.pool3(hx3)
hx4 = self.rebnconv4(hx)
hx = self.pool4(hx4)
hx5 = self.rebnconv5(hx)
hx = self.pool5(hx5)
hx6 = self.rebnconv6(hx)
hx7 = self.rebnconv7(hx6)
hx6d = self.rebnconv6d(torch.cat((hx7, hx6), 1))
hx6dup = _upsample_like(hx6d,hx5)
hx5d = self.rebnconv5d(torch.cat((hx6dup, hx5), 1))
hx5dup = _upsample_like(hx5d,hx4)
hx4d = self.rebnconv4d(torch.cat((hx5dup, hx4), 1))
hx4dup = _upsample_like(hx4d,hx3)
hx3d = self.rebnconv3d(torch.cat((hx4dup, hx3), 1))
hx3dup = _upsample_like(hx3d,hx2)
hx2d = self.rebnconv2d(torch.cat((hx3dup, hx2), 1))
hx2dup = _upsample_like(hx2d,hx1)
hx1d = self.rebnconv1d(torch.cat((hx2dup, hx1), 1))
return hx1d + hxin
### RSU-6 ###
class RSU6(torch.nn.Module):
def __init__(self, in_ch=3, mid_ch=12, out_ch=3):
super(RSU6,self).__init__()
self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1)
self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1)
self.pool1 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool2 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool3 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool4 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.rebnconv6 = REBNCONV(mid_ch, mid_ch, dirate=2)
self.rebnconv5d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv4d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1)
def forward(self,x):
hx = x
hxin = self.rebnconvin(hx)
hx1 = self.rebnconv1(hxin)
hx = self.pool1(hx1)
hx2 = self.rebnconv2(hx)
hx = self.pool2(hx2)
hx3 = self.rebnconv3(hx)
hx = self.pool3(hx3)
hx4 = self.rebnconv4(hx)
hx = self.pool4(hx4)
hx5 = self.rebnconv5(hx)
hx6 = self.rebnconv6(hx5)
hx5d = self.rebnconv5d(torch.cat((hx6, hx5), 1))
hx5dup = _upsample_like(hx5d, hx4)
hx4d = self.rebnconv4d(torch.cat((hx5dup, hx4), 1))
hx4dup = _upsample_like(hx4d, hx3)
hx3d = self.rebnconv3d(torch.cat((hx4dup, hx3), 1))
hx3dup = _upsample_like(hx3d, hx2)
hx2d = self.rebnconv2d(torch.cat((hx3dup, hx2), 1))
hx2dup = _upsample_like(hx2d, hx1)
hx1d = self.rebnconv1d(torch.cat((hx2dup, hx1), 1))
return hx1d + hxin
### RSU-5 ###
class RSU5(torch.nn.Module):
def __init__(self, in_ch=3, mid_ch=12, out_ch=3):
super(RSU5,self).__init__()
self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1)
self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1)
self.pool1 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool2 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool3 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=2)
self.rebnconv4d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1)
def forward(self,x):
hx = x
hxin = self.rebnconvin(hx)
hx1 = self.rebnconv1(hxin)
hx = self.pool1(hx1)
hx2 = self.rebnconv2(hx)
hx = self.pool2(hx2)
hx3 = self.rebnconv3(hx)
hx = self.pool3(hx3)
hx4 = self.rebnconv4(hx)
hx5 = self.rebnconv5(hx4)
hx4d = self.rebnconv4d(torch.cat((hx5, hx4), 1))
hx4dup = _upsample_like(hx4d, hx3)
hx3d = self.rebnconv3d(torch.cat((hx4dup, hx3), 1))
hx3dup = _upsample_like(hx3d, hx2)
hx2d = self.rebnconv2d(torch.cat((hx3dup, hx2), 1))
hx2dup = _upsample_like(hx2d, hx1)
hx1d = self.rebnconv1d(torch.cat((hx2dup, hx1), 1))
return hx1d + hxin
### RSU-4 ###
class RSU4(torch.nn.Module):
def __init__(self, in_ch=3, mid_ch=12, out_ch=3):
super(RSU4,self).__init__()
self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1)
self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1)
self.pool1 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.pool2 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1)
self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=2)
self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1)
self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1)
def forward(self,x):
hx = x
hxin = self.rebnconvin(hx)
hx1 = self.rebnconv1(hxin)
hx = self.pool1(hx1)
hx2 = self.rebnconv2(hx)
hx = self.pool2(hx2)
hx3 = self.rebnconv3(hx)
hx4 = self.rebnconv4(hx3)
hx3d = self.rebnconv3d(torch.cat((hx4, hx3), 1))
hx3dup = _upsample_like(hx3d, hx2)
hx2d = self.rebnconv2d(torch.cat((hx3dup, hx2), 1))
hx2dup = _upsample_like(hx2d, hx1)
hx1d = self.rebnconv1d(torch.cat((hx2dup, hx1), 1))
return hx1d + hxin
### RSU-4F ###
class RSU4F(torch.nn.Module):
def __init__(self, in_ch=3, mid_ch=12, out_ch=3):
super(RSU4F,self).__init__()
self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1)
self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1)
self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=2)
self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=4)
self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=8)
self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=4)
self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=2)
self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1)
def forward(self,x):
hx = x
hxin = self.rebnconvin(hx)
hx1 = self.rebnconv1(hxin)
hx2 = self.rebnconv2(hx1)
hx3 = self.rebnconv3(hx2)
hx4 = self.rebnconv4(hx3)
hx3d = self.rebnconv3d(torch.cat((hx4, hx3), 1))
hx2d = self.rebnconv2d(torch.cat((hx3d, hx2), 1))
hx1d = self.rebnconv1d(torch.cat((hx2d, hx1), 1))
return hx1d + hxin
##### U^2-Net ####
class U2NET(torch.nn.Module):
def __init__(self,in_ch=3,out_ch=1):
super(U2NET, self).__init__()
self.stage1 = RSU7(in_ch, 32, 64)
self.pool12 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.stage2 = RSU6(64, 32, 128)
self.pool23 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.stage3 = RSU5(128, 64, 256)
self.pool34 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.stage4 = RSU4(256, 128, 512)
self.pool45 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.stage5 = RSU4F(512, 256, 512)
self.pool56 = torch.nn.MaxPool2d(2, stride=2, ceil_mode=True)
self.stage6 = RSU4F(512, 256, 512)
# decoder
self.stage5d = RSU4F(1024, 256, 512)
self.stage4d = RSU4(1024, 128, 256)
self.stage3d = RSU5(512, 64, 128)
self.stage2d = RSU6(256, 32, 64)
self.stage1d = RSU7(128, 16, 64)
self.side1 = torch.nn.Conv2d(64, out_ch, 3, padding=1)
self.side2 = torch.nn.Conv2d(64, out_ch, 3, padding=1)
self.side3 = torch.nn.Conv2d(128, out_ch, 3, padding=1)
self.side4 = torch.nn.Conv2d(256, out_ch, 3, padding=1)
self.side5 = torch.nn.Conv2d(512, out_ch, 3, padding=1)
self.side6 = torch.nn.Conv2d(512, out_ch, 3, padding=1)
self.outconv = torch.nn.Conv2d(6 * out_ch, out_ch, 1)
# use for loss function
self.bce_loss_ = torch.nn.BCELoss(reduction='mean')
def forward(self,x):
hx = x
hx1 = self.stage1(hx)
hx = self.pool12(hx1)
hx2 = self.stage2(hx)
hx = self.pool23(hx2)
hx3 = self.stage3(hx)
hx = self.pool34(hx3)
hx4 = self.stage4(hx)
hx = self.pool45(hx4)
hx5 = self.stage5(hx)
hx = self.pool56(hx5)
hx6 = self.stage6(hx)
hx6up = _upsample_like(hx6, hx5)
hx5d = self.stage5d(torch.cat((hx6up, hx5), 1))
hx5dup = _upsample_like(hx5d, hx4)
hx4d = self.stage4d(torch.cat((hx5dup, hx4), 1))
hx4dup = _upsample_like(hx4d, hx3)
hx3d = self.stage3d(torch.cat((hx4dup, hx3), 1))
hx3dup = _upsample_like(hx3d, hx2)
hx2d = self.stage2d(torch.cat((hx3dup, hx2), 1))
hx2dup = _upsample_like(hx2d, hx1)
hx1d = self.stage1d(torch.cat((hx2dup, hx1), 1))
d1 = self.side1(hx1d)
d2 = self.side2(hx2d)
d2 = _upsample_like(d2, d1)
d3 = self.side3(hx3d)
d3 = _upsample_like(d3, d1)
d4 = self.side4(hx4d)
d4 = _upsample_like(d4, d1)
d5 = self.side5(hx5d)
d5 = _upsample_like(d5, d1)
d6 = self.side6(hx6)
d6 = _upsample_like(d6, d1)
d0 = self.outconv(torch.cat((d1, d2, d3, d4, d5, d6), 1))
return torch.sigmoid(d0), torch.sigmoid(d1), torch.sigmoid(d2), torch.sigmoid(d3), torch.sigmoid(d4), torch.sigmoid(d5), torch.sigmoid(d6)
def bce_loss(self, d0, d1, d2, d3, d4, d5, d6, labels_v):
# labels_v has 3 channels, but only the first one contain data
loss0 = self.bce_loss_(d0, labels_v[:, [0], :, :])
loss1 = self.bce_loss_(d1, labels_v[:, [0], :, :])
loss2 = self.bce_loss_(d2, labels_v[:, [0], :, :])
loss3 = self.bce_loss_(d3, labels_v[:, [0], :, :])
loss4 = self.bce_loss_(d4, labels_v[:, [0], :, :])
loss5 = self.bce_loss_(d5, labels_v[:, [0], :, :])
loss6 = self.bce_loss_(d6, labels_v[:, [0], :, :])
loss = loss0 + loss1 + loss2 + loss3 + loss4 + loss5 + loss6
return loss0, loss
class TrainDatasetLoader(torch.utils.data.Dataset):
def __init__(self, dataset, transform=None):
self.images, self.labels = self.__parse_dataset(dataset)
self.transform = transform
def __len__(self):
return len(self.images)
def __getitem__(self, i):
x = {'image': self.__get_image(i), 'label': self.__get_label(i)}
if self.transform:
x = self.transform(x)
return x
def __parse_dataset(self, dataset):
images = []
labels = []
with open(dataset, 'r') as infh:
for line in infh:
d = line.replace('\n', '').split('\t')
images.append(d[0])
if (len(d) > 1):
if d[1] != '':
labels.append(d[1])
# valid dataset
if (len(labels) > 0) and (len(labels) != len(images)):
raise ValueError('The number of labels do not equal to the number of images!')
return images, labels
def __get_image(self, i):
image = skimage.io.imread(self.images[i])
if (len(image.shape) == 2):
image = image[:, :, np.newaxis]
elif (len(image.shape) == 3):
pass
else:
raise ValueError('Irregular images!')
return image
def __get_label(self, i):
if (len(self.labels) == 0):
label = np.zeros(image.shape)
else:
label = skimage.io.imread(self.labels[i])
if (len(label.shape) == 2):
label = label[:, :, np.newaxis]
return label
class InferenceDatasetLoader(torch.utils.data.Dataset):
def __init__(self, image_fpath, transform=None):
self.images = image_fpath
self.transform = transform
def __len__(self):
return len(self.images)
def __getitem__(self, i):
x = {
'image': skimage.io.imread(self.images[i]) if isinstance(self.images[i], str) else self.images[i],
'label': None
}
if self.transform is not None:
x = self.transform(x)
return x
class ToTensor():
def __init__(self):
pass
def __call__(self, sample):
return {'image': torch.from_numpy(sample['image'].transpose((2, 0, 1))).type(torch.FloatTensor),
'label': torch.from_numpy(sample['label'].transpose((2, 0, 1))).type(torch.FloatTensor) if sample['label'] is not None else torch.from_numpy(np.array([np.nan]))}
class Normalize():
def __init__(self):
pass
def __call__(self, sample):
image = sample['image'] / np.max(sample['image'])
image_std = np.zeros((image.shape[0], image.shape[1], 3))
if image.shape[2] == 1:
image_std[:, :, 0] = (image[: ,:, 0] - 0.485) / 0.229
image_std[:, :, 1] = (image[: ,:, 0] - 0.485) / 0.229
image_std[:, :, 2] = (image[: ,:, 0] - 0.485) / 0.229
else:
image_std[:, :, 0] = (image[: ,:, 0] - 0.485) / 0.229
image_std[:, :, 1] = (image[: ,:, 1] - 0.456) / 0.224
image_std[:, :, 2] = (image[: ,:, 2] - 0.406) / 0.225
# label has 3 channels, but only use the first channel
label_std = None
if sample['label'] is not None:
label_std = np.zeros(sample['label'].shape)
label_std[:, :, 0] = sample['label'][:, :, 0] + 0.0
if (np.max(label_std) > 1e-6):
label_std = label_std / np.max(label_std)
return {'image': image_std, 'label': label_std}
class Resize():
def __init__(self, crop_size):
self.crop_size = crop_size
def __call__(self, sample):
image = skimage.transform.resize(sample['image'], (self.crop_size, self.crop_size), mode='constant', order=0, preserve_range=True)
label = skimage.transform.resize(sample['label'], (self.crop_size, self.crop_size), mode='constant', order=0, preserve_range=True) if sample['label'] is not None else None
return {'image': image, 'label': label}
class RandomScaledCrop():
def __init__(self, crop_size):
self.crop_size = crop_size
def __call__(self, sample):
img = sample['image']
bg = sample['label']
# random scales
s = np.random.uniform(0.6, 1 / 0.6, 1)[0]
img = skimage.transform.resize(img, (int(img.shape[0] * s), int(img.shape[1] * s)), mode='constant', order=0, preserve_range=True)
bg = skimage.transform.resize(bg, (int(bg.shape[0] * s), int(bg.shape[1] * s)), mode='constant', order=0, preserve_range=True)
if np.random.rand() > 0.5:
img = np.flipud(img)
bg = np.flipud(bg)
if np.random.rand() > 0.5:
img = np.fliplr(img)
bg = np.fliplr(bg)
# if the input image is too small, use it withouth agumentation
if (img.shape[0] < self.crop_size) or (img.shape[1] < self.crop_size):
img_crop = skimage.transform.resize(img, (self.crop_size, self.crop_size), mode='constant', order=0, preserve_range=True)
bg_crop = skimage.transform.resize(bg, (self.crop_size, self.crop_size), mode='constant', order=0, preserve_range=True)
# if the input image is enough large, randomly crop a image from the original image
else:
# randomly select an angle for rotation
theta = np.random.randint(0, 90, 1)[0]
# calculate the width (height) for cropping
crop_width = int(np.ceil(self.crop_size * np.cos(np.radians(theta)) + self.crop_size * np.sin(np.radians(theta))))
# if images is too small to rotate, then do not rotate
if (img.shape[0] < crop_width + 10) or (img.shape[1] < crop_width + 10):
crop_width = self.crop_size
theta = 0
# calculate coordinates for cropping
w = np.random.randint(0, img.shape[0] - crop_width)
h = np.random.randint(0, img.shape[1] - crop_width)
# crop image
img_crop = img[w:(w + crop_width + 5), h:(h + crop_width + 5)]
bg_crop = bg[w:(w + crop_width + 5), h:(h + crop_width + 5)]
# rotate the cropped images
if theta != 0:
rotate_center = (int(img_crop.shape[0] / 2), int(img_crop.shape[1] / 2))
img_crop = skimage.transform.rotate(img_crop, theta, resize=False, center=None)
bg_crop = skimage.transform.rotate(bg_crop, theta, resize=False, center=None)
img_crop = self.__center_crop(img_crop, self.crop_size, self.crop_size)
bg_crop = self.__center_crop(bg_crop, self.crop_size, self.crop_size)
return {'image': img_crop, 'label': bg_crop}
def __center_crop(self, img, crop_width, crop_height):
w = img.shape[0]
h = img.shape[0]
img_crop = img[int((w - crop_width) // 2):int((w + crop_width) // 2),
int((h - crop_height) // 2):int((h + crop_height) // 2)]
return img_crop
class U2Net(ModuleTemplate):
"""U\ :sup:`2`-Net class for model training and object segmentation
The :class:`U2Net <justdeepit.models.sod.U2Net>` class implements basic methods
to train U\ :sup:`2`-Net and perform object segmentation.
"""
def __init__(self, model_weight=None, workspace=None):
# load model
self.model = U2NET(3, 1)
if model_weight is not None:
self.model.load_state_dict(torch.load(model_weight, map_location='cpu'))
# workspace
self.tempd = None
if workspace is None:
self.tempd = tempfile.TemporaryDirectory()
self.workspace = self.tempd.name
else:
self.workspace = workspace
logger.info('Set workspace at `{}`.'.format(self.workspace))
# transform
self.transform_train = None
self.transform_valid = None
def __del__(self):
try:
if self.tempd is not None:
self.tempd.cleanup()
except:
pass
def __get_device(self, gpu=1):
device = 'cpu'
if gpu > 0:
if torch.cuda.is_available():
device = 'cuda:0'
device = torch.device(device)
return device
def __normPRED(self, d):
ma = torch.max(d)
mi = torch.min(d)
dn = (d-mi)/(ma-mi)
return dn
def train(self, train_data_fpath, batch_size=8, epoch=10000, lr=0.001, cpu=8, gpu=1,
strategy='resizing', window_size=320):
"""Train model
Method :func:`train` is used for
training U\ :sup:`2`-Net using *resizing* or *random cropping* approach.
The *resizing* approach scales the original image to 288 × 288 pixels for training,
whereas *random cropping* randomly crops small square areas from the original image,
and resizes the areas to 288 × 288 pixels for training.
The size of the square areas can be specified by the user
according to the characteristics of the target task.
The default size of the cropped square area is 320 x 320 pixels.
Args:
train_data_fpath (str): A path to the tab-separeted file which contains the two columns.
On each line, the first column records a path to a training image,
and the second column records a path to the corresponding mask image.
temp_dpath (str): A path to save the checkpoint during model training.
If ``None``, the checkpoint will be not saved.
batch_size (int): Number of batch size.
Note that a large number of batch size may cause out of memory error.
epoch (int): Number of epochs.
epoch (float): Learning rate.
cpu (int): Number of CPUs are used for prerpocessing training images.
gpu (int): Number of GPUs are uesd for traininng model.
strategy (str): Strategy for model trainig. One of ``resizing`` or ``randomcrop`` can be specified.
window_size (int): The width of images should be randomly cropped from the original images
when ``randomcrop`` srategy was selected.
"""
if not torch.cuda.is_available():
gpu = 0
if torch.cuda.device_count() < gpu:
gpu = torch.cuda.device_count()
device = self.__get_device(gpu)
self.model = self.model.to(device)
transform = None
if strategy == 'randomcrop':
transform = torchvision.transforms.Compose([
RandomScaledCrop(window_size),
Resize(288),
Normalize(),
ToTensor()
])
elif strategy == 'resizing':
transform = torchvision.transforms.Compose([
Resize(288),
Normalize(),
ToTensor()
])
else:
raise ValueError('Undefined strategy for transforming training images.')
train_dataset = TrainDatasetLoader(train_data_fpath, transform=transform)
train_dataloader = torch.utils.data.DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=cpu)
optimizer = torch.optim.Adam(self.model.parameters(), lr=lr, betas=(0.9, 0.999), eps=1e-08, weight_decay=0)
for i in range(1, epoch + 1):
self.model.train()
running_loss = running_tar_loss = 0
for data in train_dataloader:
inputs, labels = data['image'], data['label']
if False:
# to show image for debugging, comment out the ToTensor and Normalize in transforms
logger.debug(inputs.to('cpu').detach().numpy().copy())
logger.debug(labels.to('cpu').detach().numpy().copy())
logger.debug(np.max(labels.to('cpu').detach().numpy().copy()))
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
ax1.imshow(inputs.to('cpu').detach().numpy().copy()[0,:,:,:].astype(np.uint8))
ax2.imshow(labels.to('cpu').detach().numpy().copy()[0,:,:,:].astype(np.uint8))
plt.show()
inputs = inputs.to(device)
labels = labels.to(device)
inputs_v = torch.autograd.Variable(inputs, requires_grad=False)
labels_v = torch.autograd.Variable(labels, requires_grad=False)
optimizer.zero_grad()
d0, d1, d2, d3, d4, d5, d6 = self.model(inputs_v)
loss2, loss = self.model.bce_loss(d0, d1, d2, d3, d4, d5, d6, labels_v)
loss.backward()
optimizer.step()
running_loss += loss.data.item()
running_tar_loss += loss2.data.item()
del d0, d1, d2, d3, d4, d5, d6, loss2, loss
if i % 20 == 0 or i == epoch:
logger.info('{:s} - [epoch: {:3d}/{:3d}] train loss: {:3f}, tar loss: {:3f} '.format(
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), i, epoch,
running_loss / len(train_dataset), running_tar_loss / len(train_dataset)))
if self.workspace is not None:
if i % 100 == 0:
torch.save(self.model.state_dict(),
os.path.join(self.workspace, 'u2net_weights_chk.{:010}.pth'.format(i)))
self.model = self.model.to(torch.device('cpu'))
def save(self, weight_fpath):
torch.save(self.model.to('cpu').state_dict(), weight_fpath)
def inference(self, image_path, strategy='resizing', batch_size=8, cpu=4, gpu=1,
window_size=320,
u_cutoff=0.1, image_opening_kernel=0, image_closing_kernel=0):
"""Object Segmentation
Method :func:`inference` performs
salient object detection through *resizing* or *sliding* approach.
The *resizing* approach resizes the original image to 288 × 288 pixels for model training.
On the other hand, *sliding* crops adjacent square areas from the original image
for input to the model,
and the outputs are merged into a single image.
The size of the square areas can be specified by the user,
but it is recommended to use the value specified by ``window_size`` for training.
Args:
image_path (str): A path to a image file, a list of image files,
or a path to a directory which contains multiple images.
strategy (str): Strategy for model trainig. One of ``resizing`` or ``slide`` can be specified.
output_type (str): Output format.
batch_size (int): Number of batch size. Note that a large number of
batch size may cause out of memory error.
epoch (int): Number of epochs.
cpu (int): Number of CPUs are used for prerpocessing training images.
gpu (int): Number of GPUs are used for object segmentation.
window_size (int): The width of images should be cropped from the original images
when ``slide`` srategy was selected.
u_cutoff (float): A threshold to cutoff U2Net outputs. Values higher than this threshold
are considering as detected objects.
image_opening_kernel (int): The kernel size for image closing
to remove the noise that detected as object.
image_closing_kernel (int): The kernel size for image opening
to remove the small bubbles in object.
Returns:
array: mask image or mask annotations.
"""
# cpu/gpu
if not torch.cuda.is_available():
gpu = 0
if torch.cuda.device_count() < gpu:
gpu = torch.cuda.device_count()
# strategy
if strategy == 'auto':
if (image.shape[0] < 640) or (image.shape[0] < 640):
strategy = 'resizing'
else:
strategy = 'slide'
# query images
images_fpath = []
if isinstance(image_path, list):
images_fpath = image_path
elif os.path.isfile(image_path):
images_fpath = [image_path]
else:
for f in glob.glob(os.path.join(image_path, '*')):
if os.path.splitext(f)[1].lower() in ['.jpg', '.png', '.tiff']:
images_fpath.append(f)
# model
device = self.__get_device(gpu)
self.model = self.model.to(device)
self.model.eval()
# transform
transform = torchvision.transforms.Compose([
Resize(288),
Normalize(),
ToTensor()
])
# detection
pred_masks = []
if strategy[0:5] == 'resiz':
pred_masks = self.__inference_subset(images_fpath, transform, device, batch_size, cpu, u_cutoff)
elif strategy[0:4] == 'slid':
# perform prediction one-by-one
for image_fpath in tqdm.tqdm(images_fpath, desc='Processed images: ', leave=True):
tqdm_desc = ''
image_blocks, blocks_info = self.__slice_image(image_fpath, window_size)
pred_mask_blocks = self.__inference_subset(image_blocks, transform, device, batch_size, cpu, u_cutoff, 'Inferencing sliced blocks', False)
pred_masks.append(self.__merge_sliced_images(pred_mask_blocks, blocks_info))
else:
raise NotImplementedError('Only resizing and sliding approaches can be used during detection.')
self.model = self.model.to(torch.device('cpu'))
if cpu == 1:
imganns = []
for i in tqdm.tqdm(range(len(pred_masks)), desc='Post-processed images: '):
imganns.append(self._inference_post_process(
images_fpath[i], pred_masks[i], u_cutoff, image_opening_kernel, image_closing_kernel))
else:
imganns = joblib.Parallel(n_jobs=cpu)(
joblib.delayed(self._inference_post_process)(
images_fpath[i], pred_masks[i], u_cutoff, image_opening_kernel, image_closing_kernel
) for i in tqdm.tqdm(range(len(pred_masks)), desc='Post-processed images: '))
imganns = justdeepit.utils.ImageAnnotations(imganns)
if len(imganns) == 1:
return imganns[0]
else:
return imganns
def _inference_post_process(self, image_fpath, pred_mask, u_cutoff, image_opening_kernel, image_closing_kernel):
input_image_shape = skimage.io.imread(image_fpath).shape
pred_mask = skimage.transform.resize(pred_mask, (input_image_shape[0], input_image_shape[1]),
mode='constant', order=0, preserve_range=True)
pred_mask[(pred_mask > u_cutoff)] = 1
# opening and closing preocess
if image_opening_kernel > 0:
pred_mask = skimage.morphology.opening(pred_mask,
skimage.morphology.square(image_opening_kernel))
if image_closing_kernel > 0:
pred_mask = skimage.morphology.closing(pred_mask,
skimage.morphology.square(image_closing_kernel))
return justdeepit.utils.ImageAnnotation(image_fpath, pred_mask, 'array')
def __slice_image(self, image_fpath, window_size):
input_image = skimage.io.imread(image_fpath)
images = []
blocks_info = {'image_shape': input_image.shape,
'slide_window_size': window_size,
'xy': []}
# generate small blocks from the original image
step_size = window_size - math.ceil(window_size / 5)
n_w_steps = math.ceil(input_image.shape[0] / step_size)
n_h_steps = math.ceil(input_image.shape[1] / step_size)
for w in range(n_w_steps):
for h in range(n_h_steps):
w_from = int(step_size * w)
w_to = w_from + window_size
h_from = int(step_size * h)
h_to = h_from + window_size
if w_to > input_image.shape[0]:
w_from = input_image.shape[0] - window_size
w_to = input_image.shape[0]
if h_to > input_image.shape[1]:
h_from = input_image.shape[1] - window_size
h_to = input_image.shape[1]
images.append(input_image[w_from:w_to, h_from:h_to].copy())
blocks_info['xy'].append([w_from, w_to, h_from, h_to])
return images, blocks_info
def __merge_sliced_images(self, pred_mask_blocks, blocks_info):
pred_mask = np.zeros((blocks_info['image_shape'][0], blocks_info['image_shape'][1]))
for pred_grid, xy in zip(pred_mask_blocks, blocks_info['xy']):
pred_grid = skimage.transform.resize(pred_grid,
(blocks_info['slide_window_size'], blocks_info['slide_window_size']),
mode='constant', order=0, preserve_range=True)
pred_mask[xy[0]:xy[1], xy[2]:xy[3]] = np.maximum(pred_grid, pred_mask[xy[0]:xy[1], xy[2]:xy[3]])
return pred_mask
def __inference_subset(self, images_fpath, transform, device, batch_size, cpu, u_cutoff,
tqdm_desc='Processed batches: ', tqdm_leave=True):
valid_image = InferenceDatasetLoader(images_fpath, transform)
valid_dataloader = torch.utils.data.DataLoader(valid_image, batch_size=batch_size, num_workers=cpu)
pred_masks = []
for data in tqdm.tqdm(valid_dataloader, desc=tqdm_desc, leave=tqdm_leave):
inputs, labels = data['image'], data['label']
inputs = inputs.to(device)
inputs_v = torch.autograd.Variable(inputs, requires_grad=False)
d1,d2,d3,d4,d5,d6,d7 = self.model(inputs_v)
pred = self.__normPRED(d1[:, 0, :, :])
pred = pred.cpu().data.numpy()
pred_masks.extend(pred)
return pred_masks
|
{"hexsha": "4a72a2903dadfbcaab7f46a6cb00ebcc7716cff6", "size": 36378, "ext": "py", "lang": "Python", "max_stars_repo_path": "justdeepit/models/utils/u2net.py", "max_stars_repo_name": "biunit/agrolens", "max_stars_repo_head_hexsha": "4ffe4ec47c0eb1149b81b745dc8ba3a6e7caedab", "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": "justdeepit/models/utils/u2net.py", "max_issues_repo_name": "biunit/agrolens", "max_issues_repo_head_hexsha": "4ffe4ec47c0eb1149b81b745dc8ba3a6e7caedab", "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": "justdeepit/models/utils/u2net.py", "max_forks_repo_name": "biunit/agrolens", "max_forks_repo_head_hexsha": "4ffe4ec47c0eb1149b81b745dc8ba3a6e7caedab", "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.3701298701, "max_line_length": 179, "alphanum_fraction": 0.5745230634, "include": true, "reason": "import numpy", "num_tokens": 9892}
|
#ifndef __IRODS_FIRST_CLASS_OBJECT_HPP__
#define __IRODS_FIRST_CLASS_OBJECT_HPP__
// =-=-=-=-=-=-=-
#include "irods_log.hpp"
#include "irods_resource_types.hpp"
#include "irods_network_types.hpp"
// =-=-=-=-=-=-=-
// irods includes
#include "rcConnect.h"
// =-=-=-=-=-=-=-
// boost includs
#include <boost/shared_ptr.hpp>
namespace irods {
// =-=-=-=-=-=-=-
// base class for all object types
class first_class_object {
public:
// =-=-=-=-=-=-=-
// Constructors
first_class_object() {};
// =-=-=-=-=-=-=-
// Destructor
virtual ~first_class_object() {};
// =-=-=-=-=-=-=-
// plugin resolution operators
virtual error resolve(
const std::string&, // plugin interface
plugin_ptr& ) = 0; // resolved plugin
// =-=-=-=-=-=-=-
// accessor for rule engine variables
virtual error get_re_vars( keyValPair_t& ) = 0;
}; // class first_class_object
/// =-=-=-=-=-=-=-
/// @brief shared pointer to first_class_object
typedef boost::shared_ptr< first_class_object > first_class_object_ptr;
}; // namespace irods
#endif // __IRODS_FIRST_CLASS_OBJECT_HPP__
|
{"hexsha": "db6180541f338e9365a9642db2ae302eabde29d5", "size": 1253, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "iRODS/lib/core/include/irods_first_class_object.hpp", "max_stars_repo_name": "iychoi/cyverse-irods", "max_stars_repo_head_hexsha": "0070b8677a82e763f1d940ae6537b1c8839a628a", "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": "iRODS/lib/core/include/irods_first_class_object.hpp", "max_issues_repo_name": "iychoi/cyverse-irods", "max_issues_repo_head_hexsha": "0070b8677a82e763f1d940ae6537b1c8839a628a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 7.0, "max_issues_repo_issues_event_min_datetime": "2019-12-02T17:55:49.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-02T17:55:59.000Z", "max_forks_repo_path": "iRODS/lib/core/include/irods_first_class_object.hpp", "max_forks_repo_name": "iychoi/cyverse-irods", "max_forks_repo_head_hexsha": "0070b8677a82e763f1d940ae6537b1c8839a628a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2015-02-19T18:30:33.000Z", "max_forks_repo_forks_event_max_datetime": "2015-02-19T18:30:33.000Z", "avg_line_length": 24.0961538462, "max_line_length": 75, "alphanum_fraction": 0.5530726257, "num_tokens": 288}
|
function y = poly_env( p, x )
%POLY_ENV Evaluate the convex or concave envelope of a polynomial.
% POLY_ENV( P, X ) uses a semidefinite program to compute the value of the
% convex or concave envelope of the polynomial represented by the vector
% P. The format of the vector P is identical to that required by POLYVAL,
% with two additional restrictions. First, the elements of P must be real
% and finite. Second, the length of P must 0, 2, or odd (1,3,5,...)
%
% If the polynomial described by P is convex or concave, then a call to
% POLY_ENV( P, X ) produces the same result as POLYVAL( P, X ).
%
% POLY_ENV looks at the first nonzero element of P (presumably, but not
% necessarily, P(1)) to determine if a convex or concave envelope is to
% be selected. If P(1)>0, then a convex envelope is produced---i.e., the
% function that is the tightest convex lower bound for POLYVAL(P,X).
% Otherwise, a concave envelope is produced---the function that is the
% tightest concave upper bound for POLYVAL(P,X).
%
% If the degree N of P is odd---except for the special case N==1---no
% proper convex/concave envelope exists. Therefore, POLY_ENV returns an
% error in such cases.
%
% If X is an array, the result will be computed elementwise.
%
% Disciplined convex programming information:
% POLY_ENV(P,X) is convex or concave and nonmotonic in X; therefore,
% in CVX expressions, X must be affine, unless the polynomial
% described by P has a degree of 0 or 1. P must be constant.
%
% Check the polynomial
%
sp = size( p );
if isempty( p ),
p = zeros( 1, 0 );
elseif ~isa( p, 'double' ) || ~isreal( p ) || length( sp ) > 2 || ~any( sp == 1 ),
cvx_throw( 'First argument must be a non-empty real vector.' );
elseif any( isnan( p ) | isinf( p ) ),
cvx_throw( 'First argument must not contain Inf or NaN.' );
end
n = prod( sp );
if n > 2 && rem( n, 2 ) == 0,
cvx_throw( 'The length of the vector p must be odd.' );
end
%
% Check the second argument
%
if n > 1 && ( ~cvx_isaffine( x ) || ~isreal( x ) ),
cvx_throw( 'The second argument must be real and affine.' );
end
%
% Handle the special cases
%
sx = size( x );
ndxs = find( p );
if isempty( ndxs ),
y = zeros( sx );
return
else
for k = ndxs(:)',
pt = p( k : end );
if ~any( isinf( pt ./ pt(1) ) ),
p = pt;
break;
end
end
end
n = length( p );
switch n,
case 0,
y = zeros(sx);
return
case 1,
y = p(1) * ones(sx);
return
case 2,
y = p(1) * x + p(2);
return
case 3,
% Quadratic
b2a = p(2) ./ ( 2 * p(1) );
y = p(1) * ( square( x + b2a ) - b2a * b2a ) + p(3);
return
otherwise,
if all( p(2:end) == 0 ),
y = p(1) * ( x .^ (n-1) ) + p(end);
return
end
end
%
% Build and solve the SDP
%
degr = n - 1;
deg2 = 0.5 * degr + 1;
nv = prod( sx );
psign = sign(p(1));
p = psign * reshape( p, 1, n );
cvx_begin sdp
variable y(sx);
variable P(deg2,deg2,sx) hankel;
if cvx_isconstant( x )
minimize(sum(y)); %#ok
else
minimize(y); %#ok
end
P >= 0; %#ok
1 == P(1,1,:); %#ok
x == reshape( P(2,1,:), sx ); %#ok
y == reshape( p(end:-1:1) * [ reshape( P(1,:,:), deg2, nv ) ; reshape( P(2:end,end,:), deg2-1, nv ) ], sx ); %#ok
cvx_end
y = cvx_optval * psign;
% Copyright 2005-2014 CVX Research, Inc.
% See the file LICENSE.txt for full copyright information.
% The command 'cvx_where' will show where this file is located.
|
{"author": "yu-jiang", "repo": "radpbook", "sha": "88b9fa7d0a541099cdd1ac29383c89e087d1d895", "save_path": "github-repos/MATLAB/yu-jiang-radpbook", "path": "github-repos/MATLAB/yu-jiang-radpbook/radpbook-88b9fa7d0a541099cdd1ac29383c89e087d1d895/tools/cvx-w64/cvx/functions/poly_env.m"}
|
#ifndef ASLAM_BACKEND_DV_MATRIX_HPP
#define ASLAM_BACKEND_DV_MATRIX_HPP
#include <aslam/backend/JacobianContainer.hpp>
#include <boost/shared_ptr.hpp>
#include <set>
namespace aslam {
namespace backend {
/**
* \class MatrixExpressionNode
* \brief The superclass of all classes representing transformations.
*/
class MatrixExpressionNode
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
MatrixExpressionNode();
virtual ~MatrixExpressionNode();
/// \brief Evaluate the transformation matrix.
Eigen::Matrix3d toMatrix3x3();
/// \brief Evaluate the Jacobians
void evaluateJacobians(JacobianContainer & outJacobians) const;
/// \brief Evaluate the Jacobians and apply the chain rule.
void evaluateJacobians(JacobianContainer & outJacobians,
const Eigen::MatrixXd & applyChainRule) const;
void getDesignVariables(DesignVariable::set_t & designVariables) const;
protected:
// These functions must be implemented by child classes.
virtual Eigen::Matrix3d toMatrix3x3Implementation() = 0;
virtual void evaluateJacobiansImplementation(JacobianContainer & outJacobians) const = 0;
virtual void evaluateJacobiansImplementation(JacobianContainer & outJacobians,
const Eigen::MatrixXd & applyChainRule) const = 0;
virtual void getDesignVariablesImplementation(
DesignVariable::set_t & designVariables) const = 0;
};
} // namespace backend
} // namespace aslam
#endif /* ASLAM_BACKEND_DV_MATRIX_HPP */
|
{"hexsha": "8ed6f24348d75a445d9863475208be613b54e29a", "size": 1418, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "aslam_optimizer/aslam_backend_expressions/include/aslam/backend/MatrixExpressionNode.hpp", "max_stars_repo_name": "PushyamiKaveti/kalibr", "max_stars_repo_head_hexsha": "d8bdfc59ee666ef854012becc93571f96fe5d80c", "max_stars_repo_licenses": ["BSD-4-Clause"], "max_stars_count": 2690.0, "max_stars_repo_stars_event_min_datetime": "2015-01-07T03:50:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T20:27:01.000Z", "max_issues_repo_path": "aslam_optimizer/aslam_backend_expressions/include/aslam/backend/MatrixExpressionNode.hpp", "max_issues_repo_name": "PushyamiKaveti/kalibr", "max_issues_repo_head_hexsha": "d8bdfc59ee666ef854012becc93571f96fe5d80c", "max_issues_repo_licenses": ["BSD-4-Clause"], "max_issues_count": 481.0, "max_issues_repo_issues_event_min_datetime": "2015-01-27T10:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T14:02:41.000Z", "max_forks_repo_path": "aslam_optimizer/aslam_backend_expressions/include/aslam/backend/MatrixExpressionNode.hpp", "max_forks_repo_name": "PushyamiKaveti/kalibr", "max_forks_repo_head_hexsha": "d8bdfc59ee666ef854012becc93571f96fe5d80c", "max_forks_repo_licenses": ["BSD-4-Clause"], "max_forks_count": 1091.0, "max_forks_repo_forks_event_min_datetime": "2015-01-26T21:21:13.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T01:55:33.000Z", "avg_line_length": 28.9387755102, "max_line_length": 90, "alphanum_fraction": 0.793370945, "num_tokens": 317}
|
import sys
import glob
import os
import numpy as np
import multiprocessing as mp
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from scipy.interpolate import make_interp_spline,BSpline
#from scipy.misc import imresize
#from scipy.misc import imsave
from PIL import Image
from imageio import imwrite
def cal_hist(wgafile,num_images):
print(wgafile)
A = mpimg.imread(wgafile)
hist,bins = np.histogram(A.ravel(),255,[1,255])
return hist
def new_hist(varuse,wgafile,path4,path4a):
print(wgafile)
hgram4 = varuse / sum(varuse)
A = mpimg.imread(wgafile)
hist,bins = np.histogram(A.ravel(),256,[0,255])
hist_cum = np.cumsum(hist)
a = np.array(hist[0])
b = hgram4*(sum(hist)-hist[0])
hgram4a = np.concatenate((a,b),axis=None)
constructed = np.array([])
for i in range(256):
constructed = np.concatenate((constructed,np.array(i*np.ones(int(np.round(hgram4a[i]))))),axis=None)
InCaseShort = 255 * np.ones(300)
constructed = np.concatenate((constructed,InCaseShort),axis=None)
new = np.array(range(256))
for i in range(256):
if i == 0:
first = 0
else:
first = hist_cum[i-1]
second = hist_cum[i]
result = np.average(constructed[first:second])
new[i] = np.round(result)
B = A.ravel()
C = new[B]
C = C.reshape(6400,6400)
C = np.uint8(C)
#D = imresize(C,(640,640))
D = np.array(Image.fromarray(C).resize((640,640)))
name = wgafile.split('\\')
name = name[-1]
#!!!!!!
#Important: need to double check whether the file name should start with 0 or 1.
imwrite(path4 + name , C)
imwrite(path4a + name , D)
return 0
#def main(argment):
#if "__name__" == "__main__":
expfolder = 'Y:\\Chenghang\\06_Testing\\GUI_test\\analysis\\'
#expfolder = argment
path3 = expfolder + 'unaligned\\conv_488\\'
wgafiles = glob.glob(path3 + '*.tif')
num_images = len(wgafiles)
hy4c = np.zeros([num_images,255])
Orders = range(num_images)
i = 0
for x in wgafiles:
hy4c[i] = cal_hist(x,num_images)
i = i+1
#pool = mp.Pool(processes = 12)
#print('Starting histogram extraction')
#hy4c = [pool.apply(cal_hist,args = (x,num_images)) for x in wgafiles]
#print('Hitogram extraction done!')
x_hist = np.arange(1,256,1)
x_sec = np.arange(1,num_images+1,1)
cnt = 0
hy4cb = np.zeros([num_images,255])
for file in wgafiles:
hy4cb[cnt,:] = hy4c[cnt]/sum(hy4c[cnt])
cnt = cnt + 1
chan = hy4cb
Number = range(255)
varuse4 = np.zeros([num_images,255])
list_x = range(num_images)
#Some warnings here when using test num_images = 4.
for i in Number:
poly = np.polyfit(list_x, chan[:,i],4)
poly_y = np.poly1d(poly)(list_x)
varuse4[:,i] = poly_y
path4 = expfolder + 'unaligned\\for_align\\'
path4a = expfolder + 'unaligned\\for_align_ds\\'
if not os.path.exists(path4):
os.mkdir(path4)
os.mkdir(path4a)
print('Starting rendering images')
i = 0
for wgafile in wgafiles:
new_hist(varuse4[i,:],wgafile,path4,path4a)
i = i+1
#temp = [pool.apply_async(new_hist,args = (x,y,path4,path4a)) for x,y in zip(varuse4,wgafiles)]
print('Done!, close the parallel processing pool')
#pool.close()
|
{"hexsha": "2fb45e4df130b34cbe072e763fc896bcbd9a1e42", "size": 3210, "ext": "py", "lang": "Python", "max_stars_repo_path": "analysis_scripts/ex_wga_norm_thresh.py", "max_stars_repo_name": "SpeerLab/STORM-UI-", "max_stars_repo_head_hexsha": "232752dfa11e0fd2f4fda9fe0db36ac3ceb953d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-03T11:59:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-03T11:59:40.000Z", "max_issues_repo_path": "analysis_scripts/ex_wga_norm_thresh.py", "max_issues_repo_name": "SpeerLab/STORM-UI", "max_issues_repo_head_hexsha": "232752dfa11e0fd2f4fda9fe0db36ac3ceb953d3", "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": "analysis_scripts/ex_wga_norm_thresh.py", "max_forks_repo_name": "SpeerLab/STORM-UI", "max_forks_repo_head_hexsha": "232752dfa11e0fd2f4fda9fe0db36ac3ceb953d3", "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.6724137931, "max_line_length": 108, "alphanum_fraction": 0.6595015576, "include": true, "reason": "import numpy,from scipy", "num_tokens": 968}
|
# test_stats.py collects trial avg progress reversal/recovery stats
import cv2
import os
import re
import argparse
import numpy as np
from scipy import stats
from utils import get_prediction_vis
from logger import Logger
if __name__ == '__main__':
# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--data_dir', required=True, help='path to logged run')
parser.add_argument('-s', dest='start_trial', type=int, action='store', default=0, help='Trial to start from, default is 0.')
parser.add_argument('-t', dest='num_trials', type=int, action='store', default=None, help='Number of trials to evaluate from start, default is all trials.')
parser.add_argument('-v', dest='success_height', type=float, action='store', default=4.0, help='Max height (number of task progress steps) for considering a trial successful, default is 4, such as a stack of 4 blocks.')
parser.add_argument('-e', dest='epsilon', type=float, action='store', default=0.1, help='Permissible height error margin, i.e. default .1 will count 3.9 as a full stack of 4 when success_height is 4.')
parser.add_argument('-i', dest='ignore_trial', type=int, action='store', default=None, help='Trial to ignore, default is None, first trial will be 0 (beware! live run printouts start at 1 in main.py).')
args = parser.parse_args()
# load executed actions
action_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'executed-action.log.txt'))
# get all heightmap paths
heightmap_paths = os.listdir(os.path.join(args.data_dir, 'data', 'depth-heightmaps'))
# filter out the initially saved heightmaps and get the full path
heightmap_paths = sorted([os.path.join(args.data_dir, 'data', 'depth-heightmaps', h) \
for h in heightmap_paths if '0.depth' in h])
kwargs = {'delimiter': ' ', 'ndmin': 2}
iteration = int(np.loadtxt(os.path.join(args.data_dir, 'transitions', 'iteration.log.txt'), **kwargs)[0, 0])
stack_height_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'stack-height.log.txt'), **kwargs)
stack_height_log = stack_height_log[0:iteration]
stack_height_log = stack_height_log.tolist()
partial_stack_success_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'partial-stack-success.log.txt'), **kwargs)
partial_stack_success_log = partial_stack_success_log[0:iteration]
partial_stack_success_log = partial_stack_success_log.tolist()
place_success_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'place-success.log.txt'), **kwargs)
place_success_log = place_success_log[0:iteration]
place_success_log = place_success_log.tolist()
trial_success_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'trial-success.log.txt'), **kwargs)
trial_success_log = trial_success_log[0:iteration]
trial_success_log = trial_success_log.tolist()
if os.path.exists(os.path.join(args.data_dir, 'transitions', 'clearance.log.txt')):
clearance_log = np.loadtxt(os.path.join(args.data_dir, 'transitions', 'clearance.log.txt'), **kwargs).astype(np.int64)
clearance_log = clearance_log.tolist()
unstack = re.search('unstack', args.data_dir, re.IGNORECASE)
# update the reward values for a whole trial, not just recent time steps
end = int(clearance_log[-1][0])
start_trial = args.start_trial
clearance_length = len(clearance_log)
num_trials = clearance_length - 1 # the code typically collects one more trial than needed
print('clearance_length (total number of trials saved): ' + str(clearance_length) + ' start trial: ' + str(start_trial))
if args.num_trials is not None:
num_trials = min(args.num_trials, clearance_length - start_trial)
epsilon = args.epsilon
success_height = args.success_height
print('num_trials (total number of trials to evaluate): ' + str(num_trials))
max_heights = []
progress_reversals = []
recoveries = []
successful_trials = []
trial_start = 0
efficiency_actions_six = 0
efficiency_actions_four = 0
for i in range(start_trial, start_trial + num_trials):
trial_successful = 0
trial_end = clearance_log[i][0]
progress_reversal = 0.
stack_height = 1
print('----------\ntrial num: ' + str(i))
print('start: ' + str(trial_start) + ' trial end: ' + str(trial_end ))
if trial_start == trial_end:
print('TRIAL ' + str(i) + ' IS EMPTY, skipping')
continue
if args.ignore_trial is not None and i == args.ignore_trial:
print('TRIAL ' + str(i) + ' IS BEING IGNORED, skipping')
continue
trial_heights = np.array(stack_height_log[trial_start: trial_end])
print(trial_heights)
if unstack and len(trial_heights) == 1:
# special case for unstacking task where the trial ends immediately
progress_reversal = 1.
max_heights += [1]
else:
max_heights += [np.max(trial_heights)]
for j in range(trial_start, max(trial_start, trial_end - 1)):
# allow a little bit of leeway, 0.1 progress, to consider something a reversal
if stack_height_log[j][0] - epsilon > stack_height_log[j+1][0]:
progress_reversal = 1.
print('trial ' + str(i) + ' progress reversal at overall step: ' + str(j) + ' (this trial step: ' + str(j - trial_start) + ') because ' +
str(stack_height_log[j][0] ) + ' - ' + str(epsilon) + ' > ' + str(stack_height_log[j+1][0]))
progress_reversals += [progress_reversal]
if trial_end == len(trial_success_log):
# workaround for when the very last trial would be indexed past the end
trial_end -= 1
trial_successful = trial_success_log[trial_end] > trial_success_log[trial_start]
# if i == 6: # special one-time workaround for 2021-02-28-14-27-07_Real-Unstacking-Imitation trial 6 (one indexed trial 7), to correct saved results typo to match video results
# progress_reversal = 1.
# max_heights[-1] = 3
# trial_successful = 0
print('log indicates trial success') if trial_successful else print('log indicates trial failure')
if unstack and not trial_successful and len(trial_heights) > 1 and max_heights[-1] == 4.:
# special case for unstack failures, sometimes progress of 4 gets logged after a topple
print('unstack correction max height: ' + str(max_heights[-1]) + ' to ' + str(trial_heights[-2]))
max_heights[-1] = float(trial_heights[-2])
successful_trials += [trial_successful]
if progress_reversal == 1.:
recoveries += [1.] if trial_successful == 1 else [0.]
# workaround failed trials that end in fewer actions than would be possible to optimally succeed
efficiency_actions_six += len(trial_heights) if trial_successful == 1 else max(len(trial_heights), 6)
efficiency_actions_four += len(trial_heights) if trial_successful == 1 else max(len(trial_heights), 4)
trial_start = trial_end
max_heights = np.array(max_heights)
max_heights_rounded = np.rint(max_heights)
print('------------------------------')
print('data dir: ' + str(args.data_dir))
print('max_heights, the highest height in each trial: ' + str(max_heights))
print('max_heights_rounded, the highest height in each trial: ' + str(max_heights_rounded))
print('logged trial success in trial_success_log.txt: ' + str(successful_trials))
print('trials (success_height - epsilon) height or higher, another way of counting trial successes: ' + str(max_heights >= (success_height - epsilon)))
print('reversals: ' + str(progress_reversals))
print('recoveries: ' + str(recoveries))
print('total trials: ' + str(clearance_length) + ' (clearance_length, total number of trials)')
print('num trials evaluated: ' + str(num_trials) + ' start trial: ' + str(start_trial))
if args.ignore_trial is not None:
print('Trial ' + str(args.ignore_trial) + ' ignored, typically due to a simulator or physical robot problem.')
print('avg max height: ' + str(np.mean(max_heights)) + ' (higher is better, find max height for each trial, then average those values)')
print('avg max progress: ' + str(np.mean(max_heights_rounded)/success_height) + ' (higher is better, (avg(round(max_heights))/' + str(success_height) + '))')
print('standard deviation of max progress normalized to 0 to 1: ' + str(np.std(max_heights_rounded)/success_height))
print('standard error of max progress normalized to 0 to 1: ' + str(stats.sem(max_heights_rounded)/success_height))
print('avg reversals: ' + str(np.mean(progress_reversals)) + ' (lower is better)')
print('avg recoveries: ' + str(np.mean(recoveries)) + ' (higher is better, no need for recovery attempts is best)')
print('avg logged trial success: ' + str(np.mean(successful_trials)) + " (successful trials according to trial_success_log.txt)")
print('avg trial success: ' + str(np.mean(max_heights >= (success_height - epsilon))) + ' (higher is better, (success_height - epsilon) height or higher)')
print('action efficiency with 6 action per trial optimum: ' + str((6.*num_trials)/efficiency_actions_six) + ' action efficiency with 4 action per trial optimum: ' + str((4.*num_trials)/efficiency_actions_four))
print('data dir: ' + str(args.data_dir))
# if end <= len(stack_height_log):
# # First entry won't be zero...
# if clearance_length == 1:
# start = 0
# else:
# start = int(clearance_log[-2][0])
# new_log_values = []
# future_r = None
# # going backwards in time from most recent to oldest step
# for i in range(start, end):
# # iterate through heightmaps in data/depth_heightmaps
# for ind, h in enumerate(heightmap_paths):
# # make sure we break if we run out of logged actions (in case run ended unexpectedly)
# if ind >= len(action_log):
# break
# # load img
# img = cv2.imread(h)
# img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
# # visualize best pix ind
# img_viz = get_prediction_vis(np.ones_like(img), img, action_log[ind][1:],
# specific_rotation=action_log[ind][1], num_rotations=16)
# # write img_viz (use same img name as heightmap name)
# cv2.imwrite(os.path.join(args.data_dir, 'visualizations', h.split('/')[-1]), img_viz)
|
{"hexsha": "23ddc0dbee4f403497cb9489bf90e938a7c8a36d", "size": 10752, "ext": "py", "lang": "Python", "max_stars_repo_path": "test_stats.py", "max_stars_repo_name": "Pandinosaurus/good_robot", "max_stars_repo_head_hexsha": "61217d65f040d536e54804150ce8abcf97343410", "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": "test_stats.py", "max_issues_repo_name": "Pandinosaurus/good_robot", "max_issues_repo_head_hexsha": "61217d65f040d536e54804150ce8abcf97343410", "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": "test_stats.py", "max_forks_repo_name": "Pandinosaurus/good_robot", "max_forks_repo_head_hexsha": "61217d65f040d536e54804150ce8abcf97343410", "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": 58.7540983607, "max_line_length": 254, "alphanum_fraction": 0.6626674107, "include": true, "reason": "import numpy,from scipy", "num_tokens": 2648}
|
"""
PolyaGammaPSWSampler(b::Int, z::Real)
PSW sampler ([1]) for a Polya-Gamma distribution with parameters `b` and `z`,
and Laplace transform
```math
\\mathcal{L}(t) = \\cosh^b(z) \\cosh^{-b}(\\sqrt{2t + z^2})
```
References
* [1] <https://doi.org/10.1080/01621459.2013.829001>
"""
struct PolyaGammaPSWSampler{T <: Real} <: Sampleable{Univariate, Continuous}
b::Int
z::T
end
function Base.rand(rng::AbstractRNG, s::PolyaGammaPSWSampler)
out = 0.0
for _ in 1:s.b
out += rpg_devroye_1(rng, s.z)
end
return out
end
function rpg_devroye_1(rng::AbstractRNG, z::Real)
t = 0.64
z = abs(z) * 0.5
yz = π^2 / 8 + z^2 / 2
while true
if rand(rng) < mass_texpon(z, t)
x = t + randexp(rng) / yz
else
x = rtigauss(rng, z, t)
end
s = acoef(0, x, t)
y = s * rand(rng)
n = 0
while true
n += 1
if n % 2 == 1
s -= acoef(n, x, t)
y <= s && return x / 4
else
s += acoef(n, x, t)
y > s && break
end
end
end
end
function mass_texpon(z::Real, t::Real)
yz = π^2 / 8 + z^2 / 2
b = inv(sqrt(t)) * (t * z - 1)
a = -inv(sqrt(t)) * (t * z + 1)
t0 = log(yz) + yz * t
tb = t0 - z + normlogcdf(b)
ta = t0 + z + normlogcdf(a)
qdivp = fourinvπ * (exp(tb) + exp(ta))
return 1.0 / (1.0 + qdivp)
end
function rtigauss(rng::AbstractRNG, z::Real, t::Real)
z = abs(z)
μ = inv(z)
x = t + 1.0
if μ > t
α = 0.0
while rand(rng) > α
e1 = randexp(rng)
e2 = randexp(rng)
while e1^2 > (2 * e2 / t)
e1 = randexp(rng)
e2 = randexp(rng)
end
x = t / (1 + t * e1)^2
α = exp(-0.5 * z^2 * x)
end
else
while x > t
y = randn(rng)^2
x = μ + μ^2 * y / 2 - μ * √(4 * μ * y + (μ * y)^2) / 2
if rand(rng) > μ / (μ + x)
x = μ^2 / x
end
end
end
return x
end
function acoef(n::Int, x::Real, t::Real)
if x > t
π * (n + 0.5) * exp(-(n + 0.5)^2 * π^2 * x / 2)
else
2 / x / √x / sqrthalfπ * (n + 0.5) * exp(-2 * (n + 0.5)^2 / x)
end
end
function Distributions.mean(s::PolyaGammaPSWSampler)
s.b * inv(2.0 * s.z) * tanh(s.z / 2.0)
end
function Distributions.var(s::PolyaGammaPSWSampler)
s.b * inv(4 * s.z^3) * (sinh(s.z) - s.z) * (sech(s.z / 2)^2)
end
|
{"hexsha": "6e2e56fa355097f685a392e427d42d143e70e845", "size": 2657, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/polyagammapswsampler.jl", "max_stars_repo_name": "igutierrezm/PolyaGammaSamplers.jl", "max_stars_repo_head_hexsha": "f176bd8e98dd78c70e755c39f48ba7318f74503f", "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/polyagammapswsampler.jl", "max_issues_repo_name": "igutierrezm/PolyaGammaSamplers.jl", "max_issues_repo_head_hexsha": "f176bd8e98dd78c70e755c39f48ba7318f74503f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-09-29T22:18:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-29T22:18:18.000Z", "max_forks_repo_path": "src/polyagammapswsampler.jl", "max_forks_repo_name": "igutierrezm/PolyaGammaSamplers.jl", "max_forks_repo_head_hexsha": "f176bd8e98dd78c70e755c39f48ba7318f74503f", "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": 24.6018518519, "max_line_length": 78, "alphanum_fraction": 0.434324426, "num_tokens": 970}
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*
*************************************************************/
#ifndef INCLUDED_SLIDESHOW_VIEWAPPLETSHAPE_HXX
#define INCLUDED_SLIDESHOW_VIEWAPPLETSHAPE_HXX
#include <basegfx/range/b2drectangle.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include "viewlayer.hxx"
namespace com { namespace sun { namespace star {
namespace frame {
class XSynchronousFrameLoader;
class XFrame;
}
namespace uno {
class XComponentContext;
}
namespace drawing {
class XShape;
}}}}
namespace slideshow
{
namespace internal
{
/** This class is the viewable representation of a draw
document's applet object, associated to a specific View
The class is able to render the associated applet on View
implementations.
*/
class ViewAppletShape : private boost::noncopyable
{
public:
/** Create a ViewAppletShape for the given View
@param rViewLayer
The associated View object.
@param rxShape
The associated Shape
@param rServiceName
The service name to use, when actually creating the
viewer component
@param pPropCopyTable
Table of plain ASCII property names, to copy from
xShape to applet.
@param nNumPropEntries
Number of property table entries (in pPropCopyTable)
*/
ViewAppletShape( const ViewLayerSharedPtr& rViewLayer,
const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape >& rxShape,
const ::rtl::OUString& rServiceName,
const char** pPropCopyTable,
sal_Size nNumPropEntries,
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext >& rxContext );
/** destroy the object
*/
virtual ~ViewAppletShape();
/** Query the associated view layer of this shape
*/
ViewLayerSharedPtr getViewLayer() const;
// animation methods
//------------------------------------------------------------------
/** Notify the ViewShape that an animation starts now
This method enters animation mode on the associate
target view. The shape can be animated in parallel on
different views.
@param rBounds
The current applet shape bounds
@return whether the mode change finished successfully.
*/
bool startApplet( const ::basegfx::B2DRectangle& rBounds );
/** Notify the ViewShape that it is no longer animated
This methods ends animation mode on the associate
target view
*/
void endApplet();
// render methods
//------------------------------------------------------------------
/** Render the ViewShape
This method renders the ViewAppletShape on the associated view.
@param rBounds
The current applet shape bounds
@return whether the rendering finished successfully.
*/
bool render( const ::basegfx::B2DRectangle& rBounds ) const;
/** Resize the ViewShape
This method resizes the ViewAppletShape on the
associated view. It does not render.
@param rBounds
The current applet shape bounds
@return whether the resize finished successfully.
*/
bool resize( const ::basegfx::B2DRectangle& rBounds ) const;
private:
ViewLayerSharedPtr mpViewLayer;
/// the actual viewer component for this applet
::com::sun::star::uno::Reference<
::com::sun::star::frame::XSynchronousFrameLoader> mxViewer;
/// the frame containing the applet
::com::sun::star::uno::Reference<
::com::sun::star::frame::XFrame> mxFrame;
::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext> mxComponentContext;
};
typedef ::boost::shared_ptr< ViewAppletShape > ViewAppletShapeSharedPtr;
}
}
#endif /* INCLUDED_SLIDESHOW_VIEWAPPLETSHAPE_HXX */
|
{"hexsha": "5a37d35318bfd9cf518d387472f613f03ef504bd", "size": 5611, "ext": "hxx", "lang": "C++", "max_stars_repo_path": "main/slideshow/source/engine/shapes/viewappletshape.hxx", "max_stars_repo_name": "Grosskopf/openoffice", "max_stars_repo_head_hexsha": "93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 679.0, "max_stars_repo_stars_event_min_datetime": "2015-01-06T06:34:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T01:06:03.000Z", "max_issues_repo_path": "main/slideshow/source/engine/shapes/viewappletshape.hxx", "max_issues_repo_name": "Grosskopf/openoffice", "max_issues_repo_head_hexsha": "93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 102.0, "max_issues_repo_issues_event_min_datetime": "2017-11-07T08:51:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-17T12:13:49.000Z", "max_forks_repo_path": "main/slideshow/source/engine/shapes/viewappletshape.hxx", "max_forks_repo_name": "Grosskopf/openoffice", "max_forks_repo_head_hexsha": "93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 331.0, "max_forks_repo_forks_event_min_datetime": "2015-01-06T11:40:55.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T04:07:51.000Z", "avg_line_length": 33.8012048193, "max_line_length": 95, "alphanum_fraction": 0.5521297451, "num_tokens": 1078}
|
module Milann
using Flux
import Flux.Tracker: data, @grad, track
using Statistics
# This implemens a MIL version where the bag instances are stored in a continuous tensor and bags are delimited by ranges.
export RangeMIL, segmax, segmean, segmax_naive, segmean_naive, segmaxmean
struct RangeMIL
premodel
aggregation
postmodel
end
@Flux.treelike RangeMIL
function (m::RangeMIL)(X::AbstractArray, B::AbstractArray)
(nfeatures, ninsts), nbags = size(X), length(B)
# X: nfeatures x ninsts, B: nbags
Ypre = m.premodel(X)
# Ypre: npremodeloutput x ninstances
Yagg = m.aggregation(Ypre, B)
# Yagg: npremodeloutput x nbags
m.postmodel(Yagg)
end
"""
segmax(X, segments)
Compute segmented maximum for instances `X` and bags indexed by `segments`.
"""
function segmax(X, segments)
Y = similar(X, size(X, 1), length(segments))
# naive approach, fast on CPU
# for (i, seg) in enumerate(segments)
# Y[:, i:i] .= mean(view(X, :, seg), dims=2)
# end
# sliced approach much better for GPU
Y .= 0
mlen = maximum(length.(segments))
for i in 1:mlen
Yindices = [j for (j, e) in enumerate(segments) if length(e) >= i]
Xindices = map(q -> first(q) + i - 1, filter(e -> length(e) >= i, segments))
Y[:, Yindices] = max.(view(Y, :, Yindices), view(X, :, Xindices))
end
Y
end
"""
segmax_idx(X, segments)
Compute segmented maximum for instances `X` and bags indexed by `segments`. Same as segmax, but returns also the indices of maxima in input (used for grad computation).
"""
function segmax_idx(X, segments)
Y = similar(X, size(X, 1), length(segments))
Y2 = similar(X, size(Y)...) # twice the memmory!
idxs = similar(X, size(Y)...)
Y .= -Inf
Y2 .= NaN
idxs .= 0
mlen = maximum(length.(segments))
for i in 1:mlen
Yindices = [j for (j, e) in enumerate(segments) if length(e) >= i]
Xindices = map(q -> first(q) + i - 1, filter(e -> length(e) >= i, segments))
Y2[:, Yindices] = max.(view(Y, :, Yindices), view(X, :, Xindices))
idxs[:, Yindices] += view(Y, :, Yindices) .!= view(Y2, :, Yindices) # has been max increased since last iteration?
tmp = Y; Y = Y2; Y2 = tmp # just copy references
end
# idxs now holds indices of maxima relative to bags, make them relative to inputs
offsets = first.(segments) .- 1 # first indices in X minus 1
Y, Int.(cpu(idxs) .+ reshape(offsets, 1, length(offsets)))
end
segmax(X::TrackedArray, segments) = track(segmax, X, segments)
function dsegmax(Δ, segments, idxs)
grads = similar(Δ, size(Δ, 1), last(last(segments)))
grads .= 0
for (i, row) in enumerate(eachrow(idxs))
# @show size(row), minimum(row), size(Δ)
grads[i, row] .= Δ[i, :]
end
grads, nothing
end
@grad function segmax(X, segments)
Y, idxs = segmax_idx(data(X), segments)
Y, Δ -> dsegmax(Δ, segments, idxs)
end
"""
segmean(X, segments)
Compute segmented mean for instances `X` and bags indexed by `segments`.
"""
function segmean(X, segments)
Y = similar(X, size(X, 1), length(segments))
# naive approach, fast on CPU
# for (i, seg) in enumerate(segments)
# Y[:, i:i] .= mean(view(X, :, seg), dims=2)
# end
# sliced approach much better for GPU
Y .= 0
mlen = maximum(length.(segments))
for i in 1:mlen
Yindices = [j for (j, e) in enumerate(segments) if length(e) >= i]
Xindices = map(q -> first(q) + i - 1, filter(e -> length(e) >= i, segments))
Y[:, Yindices] += view(X, :, Xindices)
end
Y ./= reshape(gpu(length.(segments)), 1, length(segments))
Y
end
segmean(X::TrackedArray, segments) = track(segmean, X, segments)
function dsegmean(Δ, segments)
grads = similar(Δ, size(Δ, 1), last(last(segments)))
# naive approach, fast on CPU
# for (i, seg) in enumerate(segments)
# grads[:, seg] .= view(Δ, :,i) / length(seg)
# end
# sliced approach much better for GPU
mlen = maximum(length.(segments))
for i in 1:mlen
Yindices = [j for (j, e) in enumerate(segments) if length(e) >= i]
Xindices = map(q -> first(q) + i - 1, filter(e -> length(e) >= i, segments))
grads[:, Xindices] .= view(Δ, :, Yindices)
end
for i in 2:mlen # normalization
Xindices = vcat((collect(seg) for seg in segments if length(seg) == i)...)
if length(Xindices) > 0
grads[:, Xindices] ./= i
end
end
grads, nothing
end
@grad segmean(X, segments) = segmean(data(X), segments), Δ -> dsegmean(Δ, segments)
"""
segmax_naive(X, segments)
Segmented maximum: naive reference implementation using default AD.
"""
function segmax_naive(X, segments)
hcat((maximum(X[:,s], dims=ndims(X)) for s in segments)...)
end
"""
segmean_naive(X, segments)
Segmented mean: naive reference implementation using default AD.
"""
function segmean_naive(X, segments)
hcat((mean(X[:,s], dims=ndims(X)) for s in segments)...)
end
"""
segmaxmean(X, segments)
Combine `segmax` and `segmean`.
"""
segmaxmean(X, segments) = vcat(segmax(X, segments), segmean(X, segments))
end # module
|
{"hexsha": "dd39ad1d78f26013d882695695ac7d455ba4cbb0", "size": 5288, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/Milann.jl", "max_stars_repo_name": "dhonza/Milann.jl", "max_stars_repo_head_hexsha": "2edb44a14e03f2d09cb567988e52648f6a35cbb8", "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/Milann.jl", "max_issues_repo_name": "dhonza/Milann.jl", "max_issues_repo_head_hexsha": "2edb44a14e03f2d09cb567988e52648f6a35cbb8", "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/Milann.jl", "max_forks_repo_name": "dhonza/Milann.jl", "max_forks_repo_head_hexsha": "2edb44a14e03f2d09cb567988e52648f6a35cbb8", "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": 30.2171428571, "max_line_length": 168, "alphanum_fraction": 0.6106278366, "num_tokens": 1575}
|
c Subroutine to remove duplicate data from claremorris(auto)
c AJ_Kettle, Dec18/2017
SUBROUTINE clean_daydata(l_mlent,s_filename,s_filename_test,
+ l_datalines_pre,s_vec_stnnum_pre,
+ s_vec_date_pre,s_vec_time_pre,
+ f_vec_rain_mm_pre,f_vec_maxdy_c_pre,f_vec_mindy_c_pre,
+ f_vec_airt_k_pre,
+ l_datalines,s_vec_stnnum,
+ s_vec_date,s_vec_time,
+ f_vec_rain_mm,f_vec_maxdy_c,f_vec_mindy_c,
+ f_vec_airt_k)
IMPLICIT NONE
c************************************************************************
c Declare variables
INTEGER :: l_mlent
INTEGER :: i,j,k,ii,jj,kk
CHARACTER(LEN=300) :: s_filename
CHARACTER(LEN=300) :: s_filename_test
c preliminary data
INTEGER :: l_datalines_pre
CHARACTER(LEN=8) :: s_vec_stnnum_pre(l_mlent)
CHARACTER(LEN=10) :: s_vec_date_pre(l_mlent)
CHARACTER(LEN=8) :: s_vec_time_pre(l_mlent)
REAL :: f_vec_rain_mm_pre(l_mlent)
REAL :: f_vec_maxdy_c_pre(l_mlent)
REAL :: f_vec_mindy_c_pre(l_mlent)
c data after correction for duplicates
INTEGER :: l_datalines
CHARACTER(LEN=8) :: s_vec_stnnum(l_mlent)
CHARACTER(LEN=10) :: s_vec_date(l_mlent)
CHARACTER(LEN=8) :: s_vec_time(l_mlent)
REAL :: f_vec_rain_mm(l_mlent)
REAL :: f_vec_maxdy_c(l_mlent)
REAL :: f_vec_mindy_c(l_mlent)
REAL :: f_vec_airt_k_pre(l_mlent)
REAL :: f_vec_airt_k(l_mlent)
CHARACTER(LEN=10) :: s_date_single
CHARACTER(LEN=4) :: s_year
CHARACTER(LEN=2) :: s_month
CHARACTER(LEN=2) :: s_day
INTEGER :: i_vec_flag(l_mlent)
INTEGER :: i_accum
c************************************************************************
print*,'just entered clean_daydata'
c print*,'s_filename',TRIM(s_filename)
c print*,'s_filename_test',TRIM(s_filename_test)
c CALL SLEEP(1)
IF (TRIM(s_filename).EQ.TRIM(s_filename_test)) THEN
c print*,'match found'
c CALL SLEEP(5)
i_accum=0
DO i=1,l_datalines_pre
i_vec_flag(i)=0
s_date_single=s_vec_date_pre(i)
s_year =s_date_single(1:4)
s_month=s_date_single(6:7)
s_day =s_date_single(9:10)
IF (s_date_single.EQ.'2011/08/30') THEN
i_accum=i_accum+1
i_vec_flag(i)=i_accum
c print*,'match x found'
ENDIF
ENDDO
ii=1
DO i=1,l_datalines_pre
c Criterion to remove 2nd case of aug30 2011
c IF (LEN_TRIM(s_vec_time_pre(i)).NE.0) THEN
IF (i_vec_flag(i).LT.1) THEN
s_vec_stnnum(ii) =s_vec_stnnum_pre(i)
s_vec_date(ii) =s_vec_date_pre(i)
s_vec_time(ii) =s_vec_time_pre(i)
f_vec_rain_mm(ii)=f_vec_rain_mm_pre(i)
f_vec_maxdy_c(ii)=f_vec_maxdy_c_pre(i)
f_vec_mindy_c(ii)=f_vec_mindy_c_pre(i)
f_vec_airt_k(ii) =f_vec_airt_k_pre(i)
ii=ii+1
ENDIF
IF (i_vec_flag(i).EQ.2) THEN
print*,'duplicate found'
ENDIF
ENDDO
l_datalines=l_datalines_pre-1
c print*,'l_datalines...',l_datalines,l_datalines_pre
ENDIF
IF (.NOT.(TRIM(s_filename).EQ.TRIM(s_filename_test))) THEN
l_datalines=l_datalines_pre
DO i=1,l_datalines
s_vec_stnnum(i) =s_vec_stnnum_pre(i)
s_vec_date(i) =s_vec_date_pre(i)
s_vec_time(i) =s_vec_time_pre(i)
f_vec_rain_mm(i)=f_vec_rain_mm_pre(i)
f_vec_maxdy_c(i)=f_vec_maxdy_c_pre(i)
f_vec_mindy_c(i)=f_vec_mindy_c_pre(i)
f_vec_airt_k(i) =f_vec_airt_k_pre(i)
ENDDO
ENDIF
c************************************************************************
c print*,'just leaving clean_daydata'
RETURN
END
|
{"hexsha": "ace05386ea64ca0e26a4cf8f8253cdd1e7109438", "size": 4250, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "Github_meteireann_daily_monthly/Subroutine/clean_daydata.f", "max_stars_repo_name": "ajkettle/glamod-nuim", "max_stars_repo_head_hexsha": "beb37a3c2acab3f334918dda3e366c7882cc0960", "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": "Github_meteireann_daily_monthly/Subroutine/clean_daydata.f", "max_issues_repo_name": "ajkettle/glamod-nuim", "max_issues_repo_head_hexsha": "beb37a3c2acab3f334918dda3e366c7882cc0960", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 23, "max_issues_repo_issues_event_min_datetime": "2022-01-28T13:57:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T09:34:41.000Z", "max_forks_repo_path": "Github_meteireann_daily_monthly/Subroutine/clean_daydata.f", "max_forks_repo_name": "ajkettle/glamod-nuim", "max_forks_repo_head_hexsha": "beb37a3c2acab3f334918dda3e366c7882cc0960", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-01-24T12:06:06.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-24T12:06:06.000Z", "avg_line_length": 34.2741935484, "max_line_length": 74, "alphanum_fraction": 0.5357647059, "num_tokens": 1185}
|
@def Ax_min begin #(U)
# minimum longitudinal acceleration for given speed
Ax_min = Array(Float64,(length(U),1))
for i in eachindex(U)
Ax_min[i,1] = AXC[5]*U[i]^3 + AXC[6]*U[i]^2 + AXC[7]*U[i] + AXC[8]
end
Ax_min
end
|
{"hexsha": "5165a408325a1aca9d7e746904431f1c8a576f29", "size": 225, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/Three_DOF/Ax_min.jl", "max_stars_repo_name": "ChrisRackauckas/VehicleModels.jl", "max_stars_repo_head_hexsha": "1d55b456bd1693f143f6e4153a4b2b61bc978228", "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/Three_DOF/Ax_min.jl", "max_issues_repo_name": "ChrisRackauckas/VehicleModels.jl", "max_issues_repo_head_hexsha": "1d55b456bd1693f143f6e4153a4b2b61bc978228", "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/Three_DOF/Ax_min.jl", "max_forks_repo_name": "ChrisRackauckas/VehicleModels.jl", "max_forks_repo_head_hexsha": "1d55b456bd1693f143f6e4153a4b2b61bc978228", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-02-08T11:37:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-05T17:04:37.000Z", "avg_line_length": 22.5, "max_line_length": 68, "alphanum_fraction": 0.6444444444, "num_tokens": 88}
|
import time
import rospy
import rospkg
import os
import sys
import numpy as np
import tensorflow as tf
from styx_msgs.msg import TrafficLight
from io import StringIO
MINIMUM_CONFIDENCE = 0.4
class TLClassifier(object):
def __init__(self, simulator):
# current_path = os.path.dirname(os.path.realpath(__file__))
self.simulator_used = simulator
# We support two different frozen graphes which are trained with
# real car camera data and with data from the simulator. Depending
# where the application is executed (car or simulator) different
# models are loaded.
if (self.simulator_used == 1):
model_path = 'light_classification/classifiers/inference_graph_sim.pb'
else:
model_path = 'light_classification/classifiers/inference_graph_real.pb'
rospy.logwarn('model path {0}'.format(model_path))
detection_graph = self.load_graph(model_path)
# The input placeholder for the image.
# `get_tensor_by_name` returns the Tensor with the associated name in the Graph.
self.image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
self.detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
self.detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
# The classification of the object (integer id).
self.detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
self.sess = tf.Session(graph=detection_graph)
def load_graph(self, graph_file):
# Loads a frozen TF inference graph
graph = tf.Graph()
with graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(graph_file, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
return graph
def get_classification(self, image):
"""Determines the color of the traffic light in the image
Args:
image (cv::Mat): image containing the traffic light
Returns:
int: ID of traffic light color (specified in styx_msgs/TrafficLight)
"""
# Load a sample image
image_expanded = np.expand_dims(image, axis=0)
result = TrafficLight.UNKNOWN
# Perform detection
(boxes, scores, classes) = self.sess.run([self.detection_boxes, self.detection_scores,
self.detection_classes],
feed_dict={self.image_tensor: image_expanded})
# Remove unnecessary dimensions
scores = np.squeeze(scores)
classes = np.squeeze(classes)
# Debug classifications
# rospy.logwarn('TF classes {0} and scores {1}'.format(classes, scores))
# Find traffic light with highest confidence level
conv_level = MINIMUM_CONFIDENCE
score = 0
for i in range(boxes.shape[0]):
if scores[i] > conv_level:
conv_level = scores[i]
if classes[i] == 2: #'Green':
result = TrafficLight.GREEN
elif classes[i] == 4: #'Red':
result = TrafficLight.RED
elif classes[i] == 3: #'Yellow':
result = TrafficLight.YELLOW
score = scores[i]
# Debug traffic light output - Red: 0, 1: Yellow, 2: Green, 4: Unknown
# rospy.logwarn('Traffic light {0} ({1})'.format(result, score))
return result
|
{"hexsha": "478e55204ccd9674d3919014d3981adbbd847c1c", "size": 3953, "ext": "py", "lang": "Python", "max_stars_repo_path": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_stars_repo_name": "dalacan/Project-Capstone", "max_stars_repo_head_hexsha": "714751b2644b945d86acdd0a9980435e2806f1d9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-01T08:14:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T08:14:07.000Z", "max_issues_repo_path": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_issues_repo_name": "dalacan/Project-Capstone", "max_issues_repo_head_hexsha": "714751b2644b945d86acdd0a9980435e2806f1d9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-04-02T02:55:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-07T15:39:05.000Z", "max_forks_repo_path": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_forks_repo_name": "dalacan/Project-Capstone", "max_forks_repo_head_hexsha": "714751b2644b945d86acdd0a9980435e2806f1d9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-03-28T00:38:23.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-08T09:11:57.000Z", "avg_line_length": 36.2660550459, "max_line_length": 95, "alphanum_fraction": 0.6228181128, "include": true, "reason": "import numpy", "num_tokens": 819}
|
"""
Ajay Kc
013213328
EE381
Project 4 Part 1
The problem plots a probability distribution function of S, where S is a Random Variable of sum
of the widths of n books. The value of n is 1,5,10,and 15. For each value of n, the experimental
PDF and normal distribution function is calculated.
"""
import numpy as np
import math
import matplotlib.pyplot as plt
mean = (1+3)/2
standard_deviation = math.sqrt(((3-1)**2)/12)
def getRVMean(n):
return n*mean
def getRVSd(n):
return standard_deviation*math.sqrt(n)
def simulateRV(n):
RV = []
for i in range(0,10000):
thickness = np.random.uniform(1,3,n)
RV.append(thickness.sum())
return RV
def plotFunctions(RV,n):
a = 1; b =3 #a = min width; b = max width
nbooks =n; nbins=30; #Number of books; Number of bins
edgecolor = 'w'; #Color seperating bars in the bargraph
#
#Create bins and histogram
bins = [float(x) for x in np.linspace(nbooks*a, nbooks*b, nbins+1)]
h1, bin_edges = np.histogram(RV, bins, density = True)
#Define points on the horizontal axis
be1 = bin_edges[0:np.size(bin_edges)-1]
be2 = bin_edges[1:np.size(bin_edges)]
b1 = (be1+be2)/2
barwidth = b1[1]-b1[0] #Width of bars in the bargraph
figureOne = plt.figure(1)
xlabel = "Book stack height for n="+str(n)+" books"
plt.xlabel(xlabel, fontsize = 20)
plt.ylabel("PDF", fontsize = 20)
plt.title("PDF of book stack height and comparison with Gaussian",fontsize=20)
plt.bar(b1,h1,width = barwidth, edgecolor=edgecolor)
normalDist = []
for i in range(0,len(b1)):
normalDist.append((1 / (getRVSd(n) * math.sqrt(2 * math.pi))) * math.exp(
-((b1[i] - getRVMean(n)) ** 2) / (2 * getRVSd(n) ** 2)))
plt.plot(b1,normalDist,color='r')
plt.show()
#For 1 book
RV = simulateRV(1)
plotFunctions(RV,1)
#For 5 books
RV = simulateRV(5)
plotFunctions(RV,5)
#For 10 books
RV = simulateRV(10)
plotFunctions(RV,10)
#For 15 books
RV = simulateRV(15)
plotFunctions(RV,15)
|
{"hexsha": "d1727b5dfd5045ee6a511416c3e7987301d7c0f4", "size": 2018, "ext": "py", "lang": "Python", "max_stars_repo_path": "CentralLimitTheorem/ExponentiallyDistributedRV.py", "max_stars_repo_name": "ajaykc7/PythonProjects", "max_stars_repo_head_hexsha": "01c5be78ffb0af9bda56e7b892a559a9453c1492", "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": "CentralLimitTheorem/ExponentiallyDistributedRV.py", "max_issues_repo_name": "ajaykc7/PythonProjects", "max_issues_repo_head_hexsha": "01c5be78ffb0af9bda56e7b892a559a9453c1492", "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": "CentralLimitTheorem/ExponentiallyDistributedRV.py", "max_forks_repo_name": "ajaykc7/PythonProjects", "max_forks_repo_head_hexsha": "01c5be78ffb0af9bda56e7b892a559a9453c1492", "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": 26.9066666667, "max_line_length": 97, "alphanum_fraction": 0.6575817641, "include": true, "reason": "import numpy", "num_tokens": 633}
|
import numpy as np
import pytest
import autogalaxy as ag
grid = np.array([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0], [2.0, 4.0]])
class TestEllipticalGaussian:
def test__deflections_correct_values(self):
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.05263),
intensity=1.0,
sigma=3.0,
mass_to_light_ratio=1.0,
)
deflections = gaussian.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
assert deflections[0, 0] == pytest.approx(1.024423, 1.0e-4)
assert deflections[0, 1] == pytest.approx(0.0, 1.0e-4)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.111111),
intensity=1.0,
sigma=5.0,
mass_to_light_ratio=1.0,
)
deflections = gaussian.deflections_from_grid(grid=np.array([[0.5, 0.2]]))
assert deflections[0, 0] == pytest.approx(0.554062, 1.0e-4)
assert deflections[0, 1] == pytest.approx(0.177336, 1.0e-4)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.111111),
intensity=1.0,
sigma=5.0,
mass_to_light_ratio=2.0,
)
deflections = gaussian.deflections_from_grid(grid=np.array([[0.5, 0.2]]))
assert deflections[0, 0] == pytest.approx(1.108125, 1.0e-4)
assert deflections[0, 1] == pytest.approx(0.35467, 1.0e-4)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.111111),
intensity=2.0,
sigma=5.0,
mass_to_light_ratio=1.0,
)
deflections = gaussian.deflections_from_grid(grid=np.array([[0.5, 0.2]]))
assert deflections[0, 0] == pytest.approx(1.10812, 1.0e-4)
assert deflections[0, 1] == pytest.approx(0.35467, 1.0e-4)
def test__deflections_via_integrator_and_analytic_agree(self):
gaussian = ag.mp.EllipticalGaussian(
centre=(0.4, 0.2),
elliptical_comps=(0.0, 0.17647),
intensity=1.0,
sigma=10.0,
mass_to_light_ratio=1.0,
)
grid = ag.Grid2D.uniform(
shape_native=(3, 3), pixel_scales=0.1, origin=(1.0, 1.0)
)
deflections_via_analytic = gaussian.deflections_from_grid(grid=grid)
deflections_via_integrator = gaussian.deflections_from_grid_via_integrator(
grid=grid
)
assert deflections_via_analytic == pytest.approx(
deflections_via_integrator, 1.0e-2
)
gaussian = ag.mp.EllipticalGaussian(
centre=(-0.7, -0.4),
elliptical_comps=(0.0, 0.05263),
intensity=3.0,
sigma=15.0,
mass_to_light_ratio=7.0,
)
grid = ag.Grid2D.uniform(
shape_native=(3, 3), pixel_scales=0.1, origin=(1.0, 1.0)
)
deflections_via_analytic = gaussian.deflections_from_grid(grid=grid)
deflections_via_integrator = gaussian.deflections_from_grid_via_integrator(
grid=grid
)
assert deflections_via_analytic == pytest.approx(
deflections_via_integrator, 1.0e-2
)
def test__intensity_and_convergence_match_for_mass_light_ratio_1(self):
gaussian_light_profile = ag.lp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.333333),
intensity=2.0,
sigma=3.0,
)
gaussian_mass_profile = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.333333),
intensity=2.0,
sigma=3.0,
mass_to_light_ratio=1.0,
)
intensity = gaussian_light_profile.image_from_grid(grid=np.array([[1.0, 0.0]]))
convergence = gaussian_mass_profile.convergence_from_grid(
grid=np.array([[1.0, 0.0]])
)
print(intensity, convergence)
assert (intensity == convergence).all()
def test__image_from_grid_radii__correct_value(self):
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.0), intensity=1.0, sigma=1.0
)
intensity = gaussian.image_from_grid_radii(grid_radii=1.0)
assert intensity == pytest.approx(0.60653, 1e-2)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.0), intensity=2.0, sigma=1.0
)
intensity = gaussian.image_from_grid_radii(grid_radii=1.0)
assert intensity == pytest.approx(2.0 * 0.60653, 1e-2)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.0), intensity=1.0, sigma=2.0
)
intensity = gaussian.image_from_grid_radii(grid_radii=1.0)
assert intensity == pytest.approx(0.882496, 1e-2)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.0), intensity=1.0, sigma=2.0
)
intensity = gaussian.image_from_grid_radii(grid_radii=3.0)
assert intensity == pytest.approx(0.32465, 1e-2)
def test__convergence_from_grid__correct_value(self):
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
sigma=1.0,
mass_to_light_ratio=1.0,
)
convergence = gaussian.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(0.60653, 1e-2)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
sigma=1.0,
mass_to_light_ratio=2.0,
)
convergence = gaussian.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 0.60653, 1e-2)
gaussian = ag.mp.EllipticalGaussian(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.333333),
intensity=2.0,
sigma=3.0,
mass_to_light_ratio=4.0,
)
convergence = gaussian.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(7.88965, 1e-2)
class TestSersic:
def test__convergence_correct_values(self):
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[0.0, 1.5]]))
assert convergence == pytest.approx(4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=6.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[0.0, 1.5]]))
assert convergence == pytest.approx(2.0 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=2.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[0.0, 1.5]]))
assert convergence == pytest.approx(2.0 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
assert convergence == pytest.approx(5.38066670129, 1e-3)
def test__convergence_from_grid_gaussians__correct_values(self):
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.5]])
)
assert convergence == pytest.approx(4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=6.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.5]])
)
assert convergence == pytest.approx(2.0 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=2.0,
)
convergence = sersic.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.5]])
)
assert convergence == pytest.approx(2.0 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
convergence = sersic.convergence_from_grid_via_gaussians(
grid=np.array([[1.0, 0.0]])
)
assert convergence == pytest.approx(5.38066670129, 1e-3)
def test__deflections_via_integrator__correct_values(self):
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
deflections = sersic.deflections_from_grid_via_integrator(
grid=np.array([[0.1625, 0.1625]])
)
assert deflections[0, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(0.79374, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
deflections = sersic.deflections_from_grid_via_integrator(
grid=ag.Grid2DIrregular([(0.1625, 0.1625), (0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(0.79374, 1e-3)
assert deflections[1, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[1, 1] == pytest.approx(0.79374, 1e-3)
def test__deflections_from_grid_close_to_integrator__correct_values(self):
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
deflections = sersic.deflections_from_grid(grid=np.array([[0.1625, 0.1625]]))
assert deflections[0, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(0.79374, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
deflections = sersic.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625), (0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(0.79374, 1e-3)
assert deflections[1, 0] == pytest.approx(1.1446, 1e-3)
assert deflections[1, 1] == pytest.approx(0.79374, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=10.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
deflections = sersic.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625), (0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(2.0 * 1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(2.0 * 0.79374, 1e-3)
assert deflections[1, 0] == pytest.approx(2.0 * 1.1446, 1e-3)
assert deflections[1, 1] == pytest.approx(2.0 * 0.79374, 1e-3)
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=2.0,
)
deflections = sersic.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625), (0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(2.0 * 1.1446, 1e-3)
assert deflections[0, 1] == pytest.approx(2.0 * 0.79374, 1e-3)
assert deflections[1, 0] == pytest.approx(2.0 * 1.1446, 1e-3)
assert deflections[1, 1] == pytest.approx(2.0 * 0.79374, 1e-3)
def test__convergence__change_geometry(self):
sersic_0 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalSersic(centre=(1.0, 1.0))
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 1.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 0.0]]))
assert convergence_0 == convergence_1
sersic_0 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == convergence_1
sersic_0 = ag.mp.EllipticalSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
sersic_1 = ag.mp.EllipticalSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == convergence_1
def test__deflections__change_geometry(self):
sersic_0 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalSersic(centre=(1.0, 1.0))
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 1.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 0.0]]))
assert deflections_0[0, 0] == pytest.approx(-deflections_1[0, 0], 1e-4)
assert deflections_0[0, 1] == pytest.approx(-deflections_1[0, 1], 1e-4)
sersic_0 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalSersic(centre=(0.0, 0.0))
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
sersic_0 = ag.mp.EllipticalSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
sersic_1 = ag.mp.EllipticalSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
)
spherical = ag.mp.EllipticalSersic(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
# assert elliptical.potential_from_grid(grid=grid) == spherical.potential_from_grid(grid=grid)
np.testing.assert_almost_equal(
elliptical.deflections_from_grid_via_integrator(grid=grid),
spherical.deflections_from_grid_via_integrator(grid=grid),
)
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
sersic = ag.mp.EllipticalSersic()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
sersic = ag.mp.EllipticalSersic()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
class TestExponential:
def test__convergence_correct_values(self):
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
assert convergence == pytest.approx(4.9047, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=4.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=2.0,
)
convergence = exponential.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(4.8566, 1e-3)
def test__convergence_from_grid_via_gaussians__correct_values(self):
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid_via_gaussians(
grid=np.array([[1.0, 0.0]])
)
assert convergence == pytest.approx(4.9047, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=4.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(2.0 * 4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=2.0,
)
convergence = exponential.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(2.0 * 4.8566, 1e-3)
exponential = ag.mp.EllipticalExponential(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = exponential.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(4.8566, 1e-3)
def test__deflections_via_integrator__correct_values(self):
exponential = ag.mp.EllipticalExponential(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
mass_to_light_ratio=1.0,
)
deflections = exponential.deflections_from_grid_via_integrator(
grid=np.array([[0.1625, 0.1625]])
)
assert deflections[0, 0] == pytest.approx(0.90493, 1e-3)
assert deflections[0, 1] == pytest.approx(0.62569, 1e-3)
exponential = ag.mp.EllipticalExponential(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
mass_to_light_ratio=1.0,
)
deflections = exponential.deflections_from_grid_via_integrator(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(0.90493, 1e-3)
assert deflections[0, 1] == pytest.approx(0.62569, 1e-3)
def test__deflections_from_grid_close_to_integrator_correct_values(self):
exponential = ag.mp.EllipticalExponential(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
mass_to_light_ratio=1.0,
)
deflections = exponential.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
assert deflections[0, 0] == pytest.approx(0.90493, 1e-3)
assert deflections[0, 1] == pytest.approx(0.62569, 1e-3)
exponential = ag.mp.EllipticalExponential(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
mass_to_light_ratio=1.0,
)
deflections = exponential.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(0.90493, 1e-3)
assert deflections[0, 1] == pytest.approx(0.62569, 1e-3)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalExponential(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
mass_to_light_ratio=1.0,
)
spherical = ag.mp.EllipticalExponential(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
mass_to_light_ratio=1.0,
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
exponential = ag.mp.EllipticalExponential()
convergence = exponential.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = exponential.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = exponential.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
exponential = ag.mp.EllipticalExponential()
convergence = exponential.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = exponential.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = exponential.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
class TestDevVaucouleurs:
def test__convergence_correct_values(self):
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
assert convergence == pytest.approx(5.6697, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=4.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=2.0,
)
convergence = dev.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=0.6,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(0.351797, 1e-3)
def test__convergence_from_grid_via_gaussians__correct_values(self):
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid_via_gaussians(
grid=np.array([[1.0, 0.0]])
)
assert convergence == pytest.approx(5.6697, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=4.0,
effective_radius=3.0,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(2.0 * 7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
elliptical_comps=(0.0, -0.333333),
intensity=2.0,
effective_radius=3.0,
mass_to_light_ratio=2.0,
)
convergence = dev.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(2.0 * 7.4455, 1e-3)
dev = ag.mp.EllipticalDevVaucouleurs(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=0.6,
mass_to_light_ratio=1.0,
)
convergence = dev.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(0.351797, 1e-3)
def test__deflections_via_integrator__correct_values(self):
dev = ag.mp.EllipticalDevVaucouleurs(
centre=(0.4, 0.2),
elliptical_comps=(0.0180010, 0.0494575),
intensity=2.0,
effective_radius=0.8,
mass_to_light_ratio=3.0,
)
deflections = dev.deflections_from_grid_via_integrator(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(-24.528, 1e-3)
assert deflections[0, 1] == pytest.approx(-3.37605, 1e-3)
def test__deflections_from_grid_close_to_integrator__correct_values(self):
dev = ag.mp.EllipticalDevVaucouleurs(
centre=(0.4, 0.2),
elliptical_comps=(0.0180010, 0.0494575),
intensity=2.0,
effective_radius=0.8,
mass_to_light_ratio=3.0,
)
deflections = dev.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
# assert deflections[0, 0] == pytest.approx(-24.528, 1e-3)
# assert deflections[0, 1] == pytest.approx(-3.37605, 1e-3)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalDevVaucouleurs(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
mass_to_light_ratio=1.0,
)
spherical = ag.mp.EllipticalDevVaucouleurs(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
mass_to_light_ratio=1.0,
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
dev_vaucouleurs = ag.mp.EllipticalDevVaucouleurs()
convergence = dev_vaucouleurs.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = dev_vaucouleurs.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = dev_vaucouleurs.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
dev_vaucouleurs = ag.mp.EllipticalDevVaucouleurs()
convergence = dev_vaucouleurs.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = dev_vaucouleurs.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = dev_vaucouleurs.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
class TestSersicMassRadialGradient:
def test__convergence_correct_values(self):
# ((axis_ratio*radius/effective_radius)**-mass_to_light_gradient) = (1/0.6)**-1.0 = 0.6
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=0.6,
sersic_index=4.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(0.6 * 0.351797, 1e-3)
# ((axis_ratio*radius/effective_radius)**-mass_to_light_gradient) = (1.5/2.0)**1.0 = 0.75
sersic = ag.mp.EllipticalSersicRadialGradient(
elliptical_comps=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=-1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[1.5, 0.0]]))
assert convergence == pytest.approx(0.75 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersicRadialGradient(
elliptical_comps=(0.0, 0.0),
intensity=6.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=-1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[1.5, 0.0]]))
assert convergence == pytest.approx(2.0 * 0.75 * 4.90657319276, 1e-3)
sersic = ag.mp.EllipticalSersicRadialGradient(
elliptical_comps=(0.0, 0.0),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=2.0,
mass_to_light_gradient=-1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[1.5, 0.0]]))
assert convergence == pytest.approx(2.0 * 0.75 * 4.90657319276, 1e-3)
# ((axis_ratio*radius/effective_radius)**-mass_to_light_gradient) = ((0.5*1.41)/2.0)**-1.0 = 2.836
sersic = ag.mp.EllipticalSersicRadialGradient(
elliptical_comps=(0.0, 0.333333),
intensity=3.0,
effective_radius=2.0,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=1.0,
)
convergence = sersic.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
assert convergence == pytest.approx(2.836879 * 5.38066670129, abs=2e-01)
def test__deflections_via_integrator__correct_values(self):
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=1.0,
)
deflections = sersic.deflections_via_integrator_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
assert deflections[0, 0] == pytest.approx(3.60324873535244, 1e-3)
assert deflections[0, 1] == pytest.approx(2.3638898009652, 1e-3)
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=-1.0,
)
deflections = sersic.deflections_via_integrator_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(0.97806399756448, 1e-3)
assert deflections[0, 1] == pytest.approx(0.725459334118341, 1e-3)
def test__deflections_from_grid_using_mge__same_as_integrator__correct_values(self):
# sersic = ag.mp.EllipticalSersicRadialGradient(
# centre=(-0.4, -0.2),
# elliptical_comps=(-0.07142, -0.085116),
# intensity=5.0,
# effective_radius=0.2,
# sersic_index=2.0,
# mass_to_light_ratio=1.0,
# mass_to_light_gradient=1.0,
# )
#
# deflections = sersic.deflections_from_grid(grid=np.array([[0.1625, 0.1625]]))
#
# assert deflections[0, 0] == pytest.approx(3.60324873535244, 1e-3)
# assert deflections[0, 1] == pytest.approx(2.3638898009652, 1e-3)
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=-1.0,
)
deflections = sersic.deflections_from_grid(
grid=ag.Grid2DIrregular([(0.1625, 0.1625)])
)
assert deflections[0, 0] == pytest.approx(0.97806399756448, 1e-3)
assert deflections[0, 1] == pytest.approx(0.725459334118341, 1e-3)
def test__compare_to_sersic(self):
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=1.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=0.0,
)
sersic_deflections = sersic.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
exponential = ag.mp.EllipticalExponential(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
mass_to_light_ratio=1.0,
)
exponential_deflections = exponential.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
assert sersic_deflections[0, 0] == pytest.approx(
exponential_deflections[0, 0], 1e-3
)
assert sersic_deflections[0, 0] == pytest.approx(0.90493, 1e-3)
assert sersic_deflections[0, 1] == pytest.approx(
exponential_deflections[0, 1], 1e-3
)
assert sersic_deflections[0, 1] == pytest.approx(0.62569, 1e-3)
sersic = ag.mp.EllipticalSersicRadialGradient(
centre=(0.4, 0.2),
elliptical_comps=(0.0180010, 0.0494575),
intensity=2.0,
effective_radius=0.8,
sersic_index=4.0,
mass_to_light_ratio=3.0,
mass_to_light_gradient=0.0,
)
sersic_deflections = sersic.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
dev = ag.mp.EllipticalDevVaucouleurs(
centre=(0.4, 0.2),
elliptical_comps=(0.0180010, 0.0494575),
intensity=2.0,
effective_radius=0.8,
mass_to_light_ratio=3.0,
)
dev_deflections = dev.deflections_from_grid(grid=np.array([[0.1625, 0.1625]]))
# assert sersic_deflections[0, 0] == pytest.approx(dev_deflections[0, 0], 1e-3)
# assert sersic_deflections[0, 0] == pytest.approx(-24.528, 1e-3)
# assert sersic_deflections[0, 1] == pytest.approx(dev_deflections[0, 1], 1e-3)
# assert sersic_deflections[0, 1] == pytest.approx(-3.37605, 1e-3)
sersic_grad = ag.mp.EllipticalSersicRadialGradient(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=0.0,
)
sersic_grad_deflections = sersic_grad.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
sersic = ag.mp.EllipticalSersic(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
effective_radius=0.2,
sersic_index=2.0,
mass_to_light_ratio=1.0,
)
sersic_deflections = sersic.deflections_from_grid(
grid=np.array([[0.1625, 0.1625]])
)
assert sersic_deflections[0, 0] == pytest.approx(
sersic_grad_deflections[0, 0], 1e-3
)
assert sersic_deflections[0, 0] == pytest.approx(1.1446, 1e-3)
assert sersic_deflections[0, 1] == pytest.approx(
sersic_grad_deflections[0, 1], 1e-3
)
assert sersic_deflections[0, 1] == pytest.approx(0.79374, 1e-3)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalSersicRadialGradient(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=1.0,
)
spherical = ag.mp.EllipticalSersicRadialGradient(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
mass_to_light_gradient=1.0,
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
# assert elliptical.potential_from_grid(grid=grid) == spherical.potential_from_grid(grid=grid)
assert (
elliptical.deflections_from_grid(grid=grid)
== spherical.deflections_from_grid(grid=grid)
).all()
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
sersic = ag.mp.EllipticalSersicRadialGradient()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid(grid=grid)
assert deflections.shape_native == (2, 2)
sersic = ag.mp.EllipticalSersicRadialGradient()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid(grid=grid)
assert deflections.shape_native == (2, 2)
class TestCoreSersic:
def test__convergence_correct_values(self):
core_sersic = ag.mp.EllipticalCoreSersic(
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=5.0,
sersic_index=4.0,
radius_break=0.01,
intensity_break=0.1,
gamma=1.0,
alpha=1.0,
mass_to_light_ratio=1.0,
)
convergence = core_sersic.convergence_from_grid(grid=np.array([[0.0, 0.01]]))
assert convergence == pytest.approx(0.1, 1e-3)
core_sersic = ag.mp.EllipticalCoreSersic(
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=5.0,
sersic_index=4.0,
radius_break=0.01,
intensity_break=0.1,
gamma=1.0,
alpha=1.0,
mass_to_light_ratio=2.0,
)
convergence = core_sersic.convergence_from_grid(grid=np.array([[0.0, 0.01]]))
assert convergence == pytest.approx(0.2, 1e-3)
def test__convergence_from_grid_via_gaussians__same_as_convergence_from_grid(self):
core_sersic = ag.mp.EllipticalCoreSersic(
elliptical_comps=(0.2, 0.4),
intensity=1.0,
effective_radius=5.0,
sersic_index=4.0,
radius_break=0.01,
intensity_break=0.1,
gamma=1.0,
alpha=1.0,
mass_to_light_ratio=1.0,
)
convergence = core_sersic.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
convergence_via_gaussians = core_sersic.convergence_from_grid_via_gaussians(
grid=np.array([[0.0, 1.0]])
)
assert convergence == pytest.approx(convergence_via_gaussians, 1e-3)
def test__deflections_from_grid__correct_values(self):
sersic = ag.mp.EllipticalCoreSersic(
centre=(1.0, 2.0),
elliptical_comps=ag.convert.elliptical_comps_from(axis_ratio=0.5, phi=70.0),
intensity=1.0,
intensity_break=0.45,
effective_radius=0.5,
radius_break=0.01,
gamma=0.0,
alpha=2.0,
sersic_index=2.2,
)
deflections = sersic.deflections_from_grid(grid=np.array([[2.5, -2.5]]))
assert deflections[0, 0] == pytest.approx(0.0015047, 1e-4)
assert deflections[0, 1] == pytest.approx(-0.004493, 1e-4)
sersic = ag.mp.EllipticalCoreSersic(
centre=(1.0, 2.0),
elliptical_comps=ag.convert.elliptical_comps_from(axis_ratio=0.5, phi=70.0),
intensity=2.0,
intensity_break=0.45,
effective_radius=0.5,
radius_break=0.01,
gamma=0.0,
alpha=2.0,
sersic_index=2.2,
)
deflections = sersic.deflections_from_grid(grid=np.array([[2.5, -2.5]]))
assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4)
assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4)
sersic = ag.mp.EllipticalCoreSersic(
centre=(1.0, 2.0),
elliptical_comps=ag.convert.elliptical_comps_from(axis_ratio=0.5, phi=70.0),
intensity=1.0,
intensity_break=0.45,
effective_radius=0.5,
radius_break=0.01,
gamma=0.0,
alpha=2.0,
sersic_index=2.2,
mass_to_light_ratio=2.0,
)
deflections = sersic.deflections_from_grid(grid=np.array([[2.5, -2.5]]))
assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4)
assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4)
def test__convergence__change_geometry(self):
sersic_0 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalCoreSersic(centre=(1.0, 1.0))
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 1.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 0.0]]))
assert convergence_0 == convergence_1
sersic_0 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == convergence_1
sersic_0 = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
sersic_1 = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
convergence_0 = sersic_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = sersic_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == convergence_1
def test__deflections__change_geometry(self):
sersic_0 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalCoreSersic(centre=(1.0, 1.0))
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 1.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 0.0]]))
assert deflections_0[0, 0] == pytest.approx(-deflections_1[0, 0], 1e-4)
assert deflections_0[0, 1] == pytest.approx(-deflections_1[0, 1], 1e-4)
sersic_0 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
sersic_1 = ag.mp.EllipticalCoreSersic(centre=(0.0, 0.0))
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
sersic_0 = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
sersic_1 = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
deflections_0 = sersic_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = sersic_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
)
spherical = ag.mp.EllipticalCoreSersic(
centre=(0.0, 0.0),
intensity=1.0,
effective_radius=1.0,
sersic_index=4.0,
mass_to_light_ratio=1.0,
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
# assert elliptical.potential_from_grid(grid=grid) == spherical.potential_from_grid(grid=grid)
np.testing.assert_almost_equal(
elliptical.deflections_from_grid_via_integrator(grid=grid),
spherical.deflections_from_grid_via_integrator(grid=grid),
)
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
sersic = ag.mp.EllipticalCoreSersic()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
sersic = ag.mp.EllipticalCoreSersic()
convergence = sersic.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = sersic.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = sersic.deflections_from_grid_via_integrator(grid=grid)
assert deflections.shape_native == (2, 2)
class TestChameleon:
def test__convergence_correct_values(self):
chameleon = ag.mp.EllipticalChameleon(
elliptical_comps=(0.0, 0.0),
intensity=1.0,
core_radius_0=0.1,
core_radius_1=0.3,
mass_to_light_ratio=2.0,
)
convergence = chameleon.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence == pytest.approx(2.0 * 0.018605, 1e-3)
chameleon = ag.mp.EllipticalChameleon(
elliptical_comps=(0.5, 0.0),
intensity=3.0,
core_radius_0=0.2,
core_radius_1=0.4,
mass_to_light_ratio=1.0,
)
convergence = chameleon.convergence_from_grid(grid=np.array([[0.0, 1.5]]))
assert convergence == pytest.approx(0.007814, 1e-3)
def test__deflections_correct_values(self):
chameleon = ag.mp.EllipticalChameleon(
centre=(-0.4, -0.2),
elliptical_comps=(-0.07142, -0.085116),
intensity=5.0,
core_radius_0=0.2,
core_radius_1=0.4,
mass_to_light_ratio=3.0,
)
deflections = chameleon.deflections_from_grid(grid=np.array([[0.1625, 0.1625]]))
assert deflections[0, 0] == pytest.approx(2.12608, 1e-3)
assert deflections[0, 1] == pytest.approx(1.55252, 1e-3)
def test__convergence__change_geometry(self):
chameleon_0 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), intensity=3.0, core_radius_0=0.2, core_radius_1=0.4
)
chameleon_1 = ag.mp.EllipticalChameleon(
centre=(1.0, 1.0), intensity=3.0, core_radius_0=0.2, core_radius_1=0.4
)
convergence_0 = chameleon_0.convergence_from_grid(grid=np.array([[1.0, 1.0]]))
convergence_1 = chameleon_1.convergence_from_grid(grid=np.array([[0.0, 0.0]]))
assert convergence_0 == pytest.approx(convergence_1, 1.0e-6)
chameleon_0 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), intensity=3.0, core_radius_0=0.2, core_radius_1=0.4
)
chameleon_1 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), intensity=3.0, core_radius_0=0.2, core_radius_1=0.4
)
convergence_0 = chameleon_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = chameleon_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == pytest.approx(convergence_1, 1.0e-4)
chameleon_0 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
chameleon_1 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
convergence_0 = chameleon_0.convergence_from_grid(grid=np.array([[1.0, 0.0]]))
convergence_1 = chameleon_1.convergence_from_grid(grid=np.array([[0.0, 1.0]]))
assert convergence_0 == pytest.approx(convergence_1, 1.0e-4)
def test__deflections__change_geometry(self):
chameleon_0 = ag.mp.EllipticalChameleon(centre=(0.0, 0.0))
chameleon_1 = ag.mp.EllipticalChameleon(centre=(1.0, 1.0))
deflections_0 = chameleon_0.deflections_from_grid(grid=np.array([[1.0, 1.0]]))
deflections_1 = chameleon_1.deflections_from_grid(grid=np.array([[0.0, 0.0]]))
assert deflections_0[0, 0] == pytest.approx(-deflections_1[0, 0], 1e-4)
assert deflections_0[0, 1] == pytest.approx(-deflections_1[0, 1], 1e-4)
chameleon_0 = ag.mp.EllipticalChameleon(centre=(0.0, 0.0))
chameleon_1 = ag.mp.EllipticalChameleon(centre=(0.0, 0.0))
deflections_0 = chameleon_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = chameleon_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
chameleon_0 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), elliptical_comps=(0.0, 0.111111)
)
chameleon_1 = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), elliptical_comps=(0.0, -0.111111)
)
deflections_0 = chameleon_0.deflections_from_grid(grid=np.array([[1.0, 0.0]]))
deflections_1 = chameleon_1.deflections_from_grid(grid=np.array([[0.0, 1.0]]))
assert deflections_0[0, 0] == pytest.approx(deflections_1[0, 1], 1e-4)
assert deflections_0[0, 1] == pytest.approx(deflections_1[0, 0], 1e-4)
def test__spherical_and_elliptical_identical(self):
elliptical = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0),
elliptical_comps=(0.0, 0.0),
intensity=1.0,
mass_to_light_ratio=1.0,
)
spherical = ag.mp.EllipticalChameleon(
centre=(0.0, 0.0), intensity=1.0, mass_to_light_ratio=1.0
)
assert (
elliptical.convergence_from_grid(grid=grid)
== spherical.convergence_from_grid(grid=grid)
).all()
# assert elliptical.potential_from_grid(grid=grid) == spherical.potential_from_grid(grid=grid)
np.testing.assert_almost_equal(
elliptical.deflections_from_grid(grid=grid),
spherical.deflections_from_grid(grid=grid),
)
def test__outputs_are_autoarrays(self):
grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0, sub_size=1)
chameleon = ag.mp.EllipticalChameleon()
convergence = chameleon.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = chameleon.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = chameleon.deflections_from_grid(grid=grid)
assert deflections.shape_native == (2, 2)
chameleon = ag.mp.EllipticalChameleon()
convergence = chameleon.convergence_from_grid(grid=grid)
assert convergence.shape_native == (2, 2)
# potential = chameleon.potential_from_grid(
# grid=grid)
#
# assert potential.shape == (2, 2)
deflections = chameleon.deflections_from_grid(grid=grid)
assert deflections.shape_native == (2, 2)
|
{"hexsha": "1bd7e4b589944d17cda55876e1afa4c04e40d962", "size": 59281, "ext": "py", "lang": "Python", "max_stars_repo_path": "test_autogalaxy/unit/profiles/mass_profiles/test_stellar_mass_profiles.py", "max_stars_repo_name": "jonathanfrawley/PyAutoGalaxy_copy", "max_stars_repo_head_hexsha": "1cedbfdcf65020538128163f7d8a7f8e169646e0", "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_autogalaxy/unit/profiles/mass_profiles/test_stellar_mass_profiles.py", "max_issues_repo_name": "jonathanfrawley/PyAutoGalaxy_copy", "max_issues_repo_head_hexsha": "1cedbfdcf65020538128163f7d8a7f8e169646e0", "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_autogalaxy/unit/profiles/mass_profiles/test_stellar_mass_profiles.py", "max_forks_repo_name": "jonathanfrawley/PyAutoGalaxy_copy", "max_forks_repo_head_hexsha": "1cedbfdcf65020538128163f7d8a7f8e169646e0", "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.8711764706, "max_line_length": 107, "alphanum_fraction": 0.5755469712, "include": true, "reason": "import numpy", "num_tokens": 17512}
|
from IPython.display import HTML
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
from IPython.display import YouTubeVideo
from scipy.spatial.distance import pdist, squareform
from scipy.cluster.hierarchy import linkage, dendrogram
from matplotlib.colors import ListedColormap
import networkx as nx
import urllib
import os as os
import pandas as pd
import numpy as np
import itertools
import networkx as nx
from bokeh.io import show, output_file
from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, TapTool, BoxSelectTool, BoxZoomTool, ResetTool, PanTool, WheelZoomTool
import bokeh.models.graphs as graphs
#from bokeh.model.graphs import from_networkx, NodesAndLinkedEdges, EdgesAndLinkedNodes
from bokeh.palettes import Spectral4
#######################################################################################################
#######################################################################################################
def run_classification_model(model_data, cv, rf, virus_df):
from HPnex import functions as f
#predictors = [
# 'jaccard', 'betweeness_diff', 'in_same_cluster', 'degree_diff',
# 'FamilyMatch', 'PubMed_diff', 'PubMed_Search_ln1', 'PubMed_Search_ln2', 'neighbors_n',
# 'adamic_adar', 'resource', 'preferential_attach'
#]
predictors = [
'jaccard', 'betweeness_diff', 'in_same_cluster', 'degree_diff',
'FamilyMatch', 'PubMed_diff', 'PubMed_Search_ln1', 'PubMed_Search_ln2'
]
# datasets for sklearn
Y = model_data["label"].values
X = model_data[list(predictors)].values
#### Standardize continuous variables
from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
from pandas_ml import ConfusionMatrix
scaler = StandardScaler()
X_std = scaler.fit_transform(X)
data_processed = pd.DataFrame(X_std, columns=predictors)
#data_processed.head()
### Encoding categorical variables
le = preprocessing.LabelEncoder()
le.fit(virus_df.viral_family.unique())
model_data['F1'] = le.transform(model_data.ViralFamily1.fillna('Not_Assinged'))
model_data['F2'] = le.transform(model_data.ViralFamily2.fillna('Not_Assinged'))
data_processed['F1'] = model_data.F1
data_processed['F2'] = model_data.F2
data_processed.fillna(0, inplace=True)
### Running cross validation scores and predictions
from sklearn.model_selection import StratifiedKFold ,cross_val_score, train_test_split, cross_val_predict
from sklearn.metrics import classification_report, f1_score, accuracy_score, confusion_matrix, precision_recall_fscore_support
scores = cross_val_score(rf, data_processed, Y, cv=cv)
print('\nAccuracy of model on cross validation dataset while training')
print("Accuracy: %0.6f (+/- %0.6f)" % (scores.mean(), scores.std() * 2))
y_pred = cross_val_predict(rf, data_processed, Y, cv=cv)
print ('accuracy', accuracy_score(Y, y_pred))
print(
'\nprecision = positive predictive value\nrecall = sensitivity\nf-1 Score = harmonic average of precision and racall\nsupport = n\n'
)
print (classification_report(Y, y_pred))
cr = precision_recall_fscore_support(Y, y_pred)
confusion_matrix = ConfusionMatrix(Y, y_pred)
confusion_matrix.plot(
backend='seaborn', normalized=False, cmap='Blues', annot=True, fmt='d')
plt.show()
data_processed['Virus1'] = model_data.Virus1
data_processed['Virus2'] = model_data.Virus2
data_processed['Prediction'] = y_pred
return data_processed, scores, confusion_matrix, cr
#######################################################################################################
#######################################################################################################
def generate_data_for_multilabel_model(training_network, training_network_data, i,
BPnx, data_path, virus_df, dictionary, Species_file_name, plot= False):
from HPnex import functions as f
IUCN = pd.read_csv(data_path+ Species_file_name)
IUCN["ScientificName"] = IUCN["Genus"].map(str) +' '+IUCN["Species"]
IUCN.loc[IUCN.ScientificName== 'Homo sapiens', 'Order'] = 'Humans'
print('we have ' + str(len(training_network.edges)) + ' edges in training network (1 to 5 groups)')
## randomly assigning groups to all edges to remove
## Copying Gc to Go
Go = training_network.copy()
# remove group 1
ebunch = ((u, v) for u, v, d in Go.edges(data=True)
if d['remove_group'] == i)
Go.remove_edges_from(ebunch)
print('we have ' + str(len(Go.edges)) + ' edges in observed network ' + str(i))
net_name = 'Observed network ' + str(i)
print (net_name)
if plot:
f.plot_unipartite_network(
title=net_name,
network=Go,
network_name=net_name,
layout_func='fruchterman_reingold')
""" Develop Dataset for the Go """
print('\nDevelop Dataset for the Go\n')
"""STEP 2"""
vlist = list(Go.nodes())
"""STEP 3"""
d = pd.DataFrame(list(itertools.combinations(vlist, 2)))
d.columns = ['Virus1', 'Virus2']
"""STEP 4"""
def get_n_shared_hosts(c):
return len(list(nx.common_neighbors(BPnx, c['Virus1'], c['Virus2'])))
d['n_shared_hosts_c'] = d.apply(get_n_shared_hosts, axis=1)
def addsharedhosts(c):
return sorted(nx.common_neighbors(BPnx, c['Virus1'], c['Virus2']))
d["shared_hosts_c"] = d.apply(addsharedhosts, axis=1)
print ('getting Order and Family values for shared hosts')
def getOrders (c):
orderlist = []
if len(c.shared_hosts_c) > 0:
for h in (c.shared_hosts_c):
try:
orderlist.append(IUCN.loc[IUCN['ScientificName'] == h, 'Order'].iloc[0])
except:
orderlist.append('MatchNotFound')
return orderlist
d['orders_label'] = d.apply(getOrders, axis=1)
"""STEP 5"""
ebunch = ((u, v) for u, v, d in training_network.edges(data=True)
if d['remove_group'] == i)
to_remove = pd.DataFrame(list(ebunch))
to_remove.columns = ['Virus1', 'Virus2']
to_remove['n_shared_hosts'] = 0
to_remove['shared_hosts'] = [list() for x in range(len(to_remove.index))]
"""STEP 6"""
m = pd.merge(d, to_remove, on=['Virus1', 'Virus2'], how='left')
m.n_shared_hosts.fillna(m.n_shared_hosts_c, inplace=True)
m.shared_hosts.fillna(m.shared_hosts_c, inplace=True)
print("\nCalculating topographical features for 'Go'\n")
Go_data = f.calculate_features_taxa_level(
data_frame=m,
network=Go,
taxa_level = 'Genus',
Species_file_name='\IUCN Mammals, Birds, Reptiles, and Amphibians.csv',
data_path=data_path,
virus_df=virus_df)
print("\nGenerating model data lables for 'Go'\n")
"""STEP 8"""
model_data = Go_data[Go_data.n_shared_hosts == 0]## Crucial step: Go_data has all pairs but those pairs from removed edges will have zero as their n_shared host along with known negatives
model_data['label'] = np.where(model_data['n_shared_hosts_c'] > 0, 1, 0)
model_data[
'PubMedSeach_sum'] = model_data.PubMed_Search_ln1 + model_data.PubMed_Search_ln2
from sklearn.metrics import classification_report, f1_score
from sklearn.model_selection import StratifiedKFold, StratifiedShuffleSplit
#def run_mulitlabel_model(model_data, cv, rf, virus_df, Gc_data):
#predictors = [
# 'jaccard', 'betweeness_diff', 'in_same_cluster', 'degree_diff',
# 'FamilyMatch', 'PubMed_diff', 'PubMed_Search_ln1', 'PubMed_Search_ln2', 'neighbors_n',
# 'adamic_adar', 'resource', 'preferential_attach'
#]
predictors = [
'jaccard', 'betweeness_diff', 'in_same_cluster', 'degree_diff',
'FamilyMatch', 'PubMed_diff', 'PubMed_Search_ln1', 'PubMed_Search_ln2'
]
import sklearn
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.multioutput import MultiOutputClassifier
from sklearn.linear_model import SGDClassifier
from sklearn.ensemble import ExtraTreesClassifier, RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import accuracy_score
from sklearn.svm import SVC, LinearSVC
from sklearn import preprocessing
from sklearn_pandas import DataFrameMapper
from sklearn.metrics import classification_report, f1_score, accuracy_score, confusion_matrix
# datasets for sklearn
#ml = MultiLabelBinarizer().fit(Gc_data.shared_hosts.apply(lambda y: ['No_Sharing'] if len(y)==0 else y))
#model_data['shared_hosts_label'] = model_data['shared_hosts_c'].apply(lambda y: ['No_Sharing'] if len(y)==0 else y)
model_data['shared_hosts_label'] = model_data['shared_hosts_c'].apply(lambda y: ['No_Sharing'] if len(y)==0 else y)
Y_ml_df = model_data['shared_hosts_label'].apply(str).str.strip("['']").str.replace("'", "").str.strip().str.split(', ', expand = True)
Y_ml_df = Y_ml_df.replace(dictionary)
X = model_data[list(predictors)].values
#### Standardize continuous variables
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_std = scaler.fit_transform(X)
data_processed = pd.DataFrame(X_std, columns=predictors)
#data_processed.head()
### Encoding categorical variables
le = preprocessing.LabelEncoder()
le.fit(virus_df.viral_family.unique())
model_data['F1'] = le.transform(model_data.ViralFamily1.fillna('Not_Assinged'))
model_data['F2'] = le.transform(model_data.ViralFamily2.fillna('Not_Assinged'))
data_processed['F1'] = model_data.F1
data_processed['F2'] = model_data.F2
data_processed.fillna(0, inplace=True)
return model_data, data_processed, Y_ml_df
#######################################################################################################
#######################################################################################################
def run_multilabel_model(model_data, cv, rf, Y_ml):
from HPnex import functions as f
from sklearn.model_selection import cross_val_predict, cross_val_score
from sklearn.multioutput import MultiOutputClassifier
multi_target_classifier = MultiOutputClassifier(rf, n_jobs=1)
print('\nCross validation score stared')
cv_scores = cross_val_score(estimator=multi_target_classifier,
X=model_data,
y=Y_ml,
cv=cv)
print('\nAccuracy of model on cross validation dataset while training')
print("Accuracy: %0.6f (+/- %0.6f)" % (cv_scores.mean(), cv_scores.std() * 2))
print('\nCross validation prediction started')
preds_multilable = cross_val_predict(estimator=multi_target_classifier,
X=model_data,
y=Y_ml,
cv=cv)
#print('\nCross validation prediction of probability started')
#preds_multilable_proba = cross_val_predict(estimator=multi_target_classifier,
# X=model_data,
# y=Y_ml,
# cv=cv, method = 'predic_proba')
return cv_scores, preds_multilable, Y_ml
#######################################################################################################
#######################################################################################################
#######################################################################################################
#######################################################################################################
|
{"hexsha": "0fa3bb2ef7e4beb73e5859c379ea294100b44979", "size": 12023, "ext": "py", "lang": "Python", "max_stars_repo_path": "HPnex/classification.py", "max_stars_repo_name": "PanditPranav/PREDICT_network_analysis", "max_stars_repo_head_hexsha": "8e7d24b3e549c818c99fb132ac7e190d6561df6f", "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": "HPnex/classification.py", "max_issues_repo_name": "PanditPranav/PREDICT_network_analysis", "max_issues_repo_head_hexsha": "8e7d24b3e549c818c99fb132ac7e190d6561df6f", "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": "HPnex/classification.py", "max_forks_repo_name": "PanditPranav/PREDICT_network_analysis", "max_forks_repo_head_hexsha": "8e7d24b3e549c818c99fb132ac7e190d6561df6f", "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.9093851133, "max_line_length": 191, "alphanum_fraction": 0.6181485486, "include": true, "reason": "import numpy,from scipy,import networkx", "num_tokens": 2717}
|
import numpy as np
from standard import config, DataManager, AbstractExchange
class SimulationExchange(AbstractExchange.AbstractExchange):
def __init__(self, wallets: dict):
if 'USD' not in wallets:
wallets['USD'] = 0
self.dm = DataManager.DataManager(start_date=config.start_date_test,
end_date=config.end_date_test,
train_test_ratio=0,
max_size_of_database=config.max_size_of_trade_set,
bad_coins=config.bad_coins)
# self.dm.initialize(config.db_path)
self.dm._load_databases(config.db_path)
self.wallets = wallets
self.time_index = 0
for coin in set(self.wallets.keys()).difference(self.dm.df.columns.levels[0]).difference(['USD']):
self.wallets.pop(coin)
super(SimulationExchange, self).__init__()
def get_wallets(self):
return self.wallets
def buy_order(self, coin, money):
money = min(self.wallets['USD'], money)
if not np.all(self.get_status(coin) == -1) and money > 0:
money, volume = self.volume_x_buy(money, self.get_status(coin))
self.wallets['USD'] = money
self.wallets[coin] += volume
return volume
else:
return 0
def sell_order(self, coin, volume):
volume = min(self.wallets[coin], volume)
if not np.all(self.get_status(coin) == -1) and volume > 0:
money, volume = self.price_x_sell(volume, self.get_status(coin))
self.wallets[coin] = volume
self.wallets['USD'] += money
return money
else:
return 0
def record_log(self):
super(SimulationExchange, self).record_log()
self.log_times.append(self.dm.df.index[self.time_index])
def _update_money(self):
self.money = 0
for k, w in self.wallets.items():
# assert w > 0
if not np.all(self.get_status(k) == -1) and np.all(np.isfinite(self.get_status(k)[:, 0])) and w > 0:
self.money += self.price_x_sell(w, self.get_status(k))[0]
if self.money == 0:
self.money = self.log_money[-1]
return self.money
def _update_portfolio_fraction(self):
wallets_fraction = self.wallets.copy()
for k, w in self.wallets.items():
if not np.all(self.get_status(k) == -1):
wallets_fraction[k] = self.price_x_sell(w, self.get_status(k))[0] / self.money
return wallets_fraction
def next(self):
self.record_log()
self.time_index += 1
return self.time_index < iter(self.dm._book_orders.values()).__next__().shape[0]
def get_status(self, coin: str):
if coin == 'USD':
return self._USD
return self.dm._book_orders[coin][self.time_index]
def get_book_orders(self):
book_orders = self.dm.get_book_orders(self.time_index)
if 'USD' not in book_orders:
book_orders['USD'] = self._USD
return book_orders
def get_book_orders_and_time(self):
return self.dm.df.index[self.time_index], self.get_book_orders()
def main():
ex = SimulationExchange({})
if __name__ == '__main__1':
main()
|
{"hexsha": "7eb5da4029116e0d0c495b7122482cfde4158253", "size": 3361, "ext": "py", "lang": "Python", "max_stars_repo_path": "standard/SimulationExchange.py", "max_stars_repo_name": "vt-technologies-us/cryptobeet", "max_stars_repo_head_hexsha": "db1ac3c72774baea908f1c1fcdd3d3219175a812", "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": "standard/SimulationExchange.py", "max_issues_repo_name": "vt-technologies-us/cryptobeet", "max_issues_repo_head_hexsha": "db1ac3c72774baea908f1c1fcdd3d3219175a812", "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": "standard/SimulationExchange.py", "max_forks_repo_name": "vt-technologies-us/cryptobeet", "max_forks_repo_head_hexsha": "db1ac3c72774baea908f1c1fcdd3d3219175a812", "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": 32.6310679612, "max_line_length": 112, "alphanum_fraction": 0.5894079143, "include": true, "reason": "import numpy", "num_tokens": 754}
|
import numpy as np
import pandas as pd
from pathlib import Path
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from com_cheese_api.cmm.utl.file import FileReader
from com_cheese_api.ext.db import url, db, openSession, engine
from konlpy.tag import Okt
from collections import Counter
from wordcloud import WordCloud
import seaborn as sns
from sqlalchemy import func
from sqlalchemy.ext.declarative import declarative_base
from sklearn.model_selection import train_test_split
from sklearn.model_selection import KFold # k value is understood as count
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestClassifier # rforest
from sklearn.tree import DecisionTreeClassifier # dtree
from sklearn.naive_bayes import GaussianNB # nb
from sklearn.neighbors import KNeighborsClassifier # knn
from sklearn.svm import SVC # svm
import os
import json
# 코드 실행시 생성되는 파일목록
# user_df.csv
# user_df 등 user csv 데이터의 컬럼명이 user_index -> user_no로 바뀜, 고쳐야 함
class OrderDfo:
def __init__(self):
self.fileReader = FileReader()
# self.data = os.path.join(os.path.abspath(os.path.dirname(__file__))+'/m_data')
self.data = os.path.join('com_cheese_api/cop/ord/order/data')
self.odf = None
def new(self):
user = 'users.csv'
cheese = pd.read_csv('com_cheese_api/cop/itm/cheese/data/cheese_data.csv')
this = self.fileReader
this.user = self.new_model(user) # payload
print(this)
category_count = OrderDfo.category_count(this.user)
item_count = OrderDfo.item_count(this.user, category_count)
this.user = OrderDfo.change_to_cheese(cheese, item_count)
print(f'######## 치즈 상품 대체 체크 ##########')
print(this)
this = OrderDfo.user_gender_nominal(this)
this = OrderDfo.cheese_rank_ordinal(this)
# print(min(this.user['user_age'])) # 고객 최소 나이 : 10
# print(max(this.user['user_age'])) # 고객 최대 나이 : 80
# this = OrderDfo.user_age_nominal(this)
print(f'######## age 전처리 체크 ##########')
print(this.user.head(10))
# this = OrderDfo.cheese_code_numeric(this)
# this = OrderDfo.cheese_code_ordinal(this)
this = OrderDfo.buy_count_numeric(this)
# this = OrderDfo.cheese_category_nominal(this)
# this = OrderDfo.cheese_texture_nominal(this)
print(f'######## cheese, count 전처리 체크 ##########')
print(this.user.head(10))
this = OrderDfo.user_price_numeric(this)
this = OrderDfo.total_buy_price(this)
# print(f'Preprocessing User Dataset : {this.user}')
print(f'######## train na 체크 ##########')
print(f'{this.user.isnull().sum()}')
print(f'######## test na 체크 ##########')
print(f'{this.user.isnull().sum()}')
print(f'######## data type 체크 ##########')
print(this.user.dtypes)
self.odf = pd.DataFrame(
{
# 'order_no': this.user.order_no, # duplicate 오류
'user_id': this.user.user_id,
'cheese_id': this.user.cheese_id,
'buy_count': this.user.buy_count,
'total_price': this.user.total_price
}
)
self.odf.to_csv(os.path.join('com_cheese_api/cop/ord/order/data', 'user_order.csv'), index=False, encoding='utf-8-sig')
print(f'######## 최종 user DF 결과 ##########')
print(self.odf)
return self.odf
################## 데이터 불러오기 & 생성 & featrue 제거 ###################
# self, 메모리에 적재
def new_model(self, payload):
this = self.fileReader
this.data = self.data
this.fname = payload
print(f'{self.data}')
print(f'{this.fname}')
return pd.read_csv(Path(self.data, this.fname))
####################### 원본 데이터를 치즈 구매 데이터 변환 #######################
# 밑에 make_barplot()을 이용해서 시각화 가능.
@staticmethod
def find_requency(data, column1, column2):
count_size = data[column1].groupby(data[column2]).count().reset_index(name='counts')
count_size['rank'] = count_size['counts'].rank(ascending=False)
show_barplot = OrderDfo.make_barplot(column2, 'counts', count_size)
return count_size
@staticmethod
def category_count(data) -> object:
sub_size = data['buy_count'].groupby(data['sub1_category']).sum().reset_index(name='sub1_counts')
sub_size['sub1_rank'] = sub_size['sub1_counts'].rank(ascending=False)
# barplot = OrderDfo.make_barplot('sub1_category', 'sub1_counts', sub_size)
return sub_size
@staticmethod
def item_count(data, category_count):
item_size = data['buy_count'].groupby([data['sub1_category'],data['sub2_category']]).sum().reset_index(name='sub2_counts')
item_size['sub2_rank'] = item_size['sub2_counts'].rank(ascending=False, method="dense")
category_item_rank = pd.merge(category_count, item_size, on='sub1_category', how='right')
user_item_rank = pd.merge(data, category_item_rank, on='sub2_category', how='left')
# print(user_item_rank)
user_items_ranks = user_item_rank.drop(['sub1_category_y'], axis=1)
users_item_data = user_items_ranks.rename(columns={'sub1_category_x': 'sub1_category'})
# print(users_item_data)
return users_item_data
@staticmethod
def change_to_cheese(data, item_count):
cheese_df = data.rename(columns={'ranking': 'sub2_rank'})
user_cheese_merge = pd.merge(item_count, cheese_df, on='sub2_rank', how='left')
user_data1 = user_cheese_merge.drop(['item_code', 'item_name', 'item_add_name', 'category_x',\
'sub1_category', 'sub2_category', 'item_brand', 'sub1_counts', 'sub1_rank',\
'sub2_counts', 'buy_price'], axis=1)
user_data2 = user_data1.drop(['country', 'matching', 'content', 'img'], axis=1)
user_data_fin = user_data2.rename(columns={'Unnamed: 0_x': 'order_no', 'Unnamed: 0_y': 'cheese_code',\
'brand': 'cheese_brand', 'name': 'cheese_name', 'price': 'cheese_one_price',\
'sub2_rank': 'cheese_rank', 'category_y': 'cheese_category', 'texture': 'cheese_texture', 'types': 'cheese_types'})
# print(list(users_cheese_merge))
# print(user_data_fin)
# user_data_fin.to_csv(os.path.join('com_cheese_api/cop/ord/order/data', 'user_df.csv'), index=False, encoding='utf-8-sig')
return user_data_fin
####################### 데이터 정제 #######################
@staticmethod
def cheese_rank_ordinal(this) -> object:
return this
@staticmethod
def user_gender_nominal(this) -> object:
gender_mapping = {'M': 0, 'F': 1}
this.user['gender'] = this.user['user_gender'].map(gender_mapping)
this.user = this.user # overriding
# this.user.to_csv(os.path.join('data', 'check11.csv'), index=False, encoding='utf-8-sig')
return this
@staticmethod
def cheese_code_numeric(this) -> object:
this.user['cheese_id'] = this.user['cheese_id'].str.replace('p', '')
return this
@staticmethod
def user_price_numeric(this) -> object:
this.user['cheese_one_price'] = this.user['cheese_one_price'].str.replace(',', '')
this.user['cheese_one_price'] = this.user['cheese_one_price'].str.replace('원', '')
this.user = this.user.astype({'cheese_one_price': int})
this.user = this.user
return this
@staticmethod
def cheese_code_ordinal(this) -> object:
return this
@staticmethod
def total_buy_price(this) -> object:
this.user['total_price'] = this.user['cheese_one_price'] * this.user['buy_count']
return this
@staticmethod
def buy_count_numeric(this) -> object:
return this
'''
order_no user_id password gender age cheese_name cheese_texture cheese_category buy_count total_price
0 0 2391853 1 M 40 리코타 치즈 후레쉬치즈 리코타 1 4600
1 1 1799897 1 F 40 리코타 치즈 후레쉬치즈 리코타 1 4600
2 2 1614947 1 F 50 모짜렐라 후레쉬치즈 모짜렐라 1 5500
3 3 1614947 1 F 50 모짜렐라 후레쉬치즈 모짜렐라 1 5500
4 4 1614947 1 F 50 모짜렐라 후레쉬치즈 모짜렐라 5 24500
... ... ... ... ... ... ... ... ... ... ...
36868 36868 6159545 1 F 30 캄보졸라 치즈 소프트치즈 블루치즈 1 6400
36869 36869 1942828 1 M 40 덴마크 까망베르 치즈 소프트치즈 까망베르 1 4165
36870 36870 1942828 1 M 40 덴마크 까망베르 치즈 소프트치즈 까망베르 1 4165
36871 36871 6284056 1 M 30 락토스프리 모짜렐라 후레쉬치즈 모짜렐라 2 11400
36872 36872 1306045 1 F 40 리코타 치즈 후레쉬치즈 리코타 1 4600
[36873 rows x 10 columns]
'''
# if __name__ == '__main__':
# OrderDfo = OrderDfo()
# OrderDfo.new()
|
{"hexsha": "b5e329d8880faded2bdfccbbe428bab789c3e61e", "size": 9458, "ext": "py", "lang": "Python", "max_stars_repo_path": "proj/cheese-emp-ai/com_cheese_api/cop/ord/order/model/order_dfo.py", "max_stars_repo_name": "youjeong2/EMP", "max_stars_repo_head_hexsha": "1afdf2789b09e55e4f6a2241a2cc2d0d1b607d9e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-17T06:37:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-17T06:37:50.000Z", "max_issues_repo_path": "proj/cheese-emp-ai/com_cheese_api/cop/ord/order/model/order_dfo.py", "max_issues_repo_name": "youjeong2/EMP", "max_issues_repo_head_hexsha": "1afdf2789b09e55e4f6a2241a2cc2d0d1b607d9e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-26T06:06:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-26T06:06:41.000Z", "max_forks_repo_path": "proj/cheese-emp-ai/com_cheese_api/cop/ord/order/model/order_dfo.py", "max_forks_repo_name": "youjeong2/EMP", "max_forks_repo_head_hexsha": "1afdf2789b09e55e4f6a2241a2cc2d0d1b607d9e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-10-05T08:19:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-17T06:37:52.000Z", "avg_line_length": 42.4125560538, "max_line_length": 159, "alphanum_fraction": 0.5807781772, "include": true, "reason": "import numpy", "num_tokens": 2629}
|
"""
Cauchy(μ, σ)
The *Cauchy distribution* with location `μ` and scale `σ` has probability density function
```math
f(x; \\mu, \\sigma) = \\frac{1}{\\pi \\sigma \\left(1 + \\left(\\frac{x - \\mu}{\\sigma} \\right)^2 \\right)}
```
```julia
Cauchy() # Standard Cauchy distribution, i.e. Cauchy(0, 1)
Cauchy(u) # Cauchy distribution with location u and unit scale, i.e. Cauchy(u, 1)
Cauchy(u, b) # Cauchy distribution with location u and scale b
params(d) # Get the parameters, i.e. (u, b)
location(d) # Get the location parameter, i.e. u
scale(d) # Get the scale parameter, i.e. b
```
External links
* [Cauchy distribution on Wikipedia](http://en.wikipedia.org/wiki/Cauchy_distribution)
"""
struct Cauchy{T<:Real} <: ContinuousUnivariateDistribution
μ::T
σ::T
function Cauchy{T}(μ::T, σ::T) where T
@check_args(Cauchy, σ > zero(σ))
new{T}(μ, σ)
end
end
Cauchy(μ::T, σ::T) where {T<:Real} = Cauchy{T}(μ, σ)
Cauchy(μ::Real, σ::Real) = Cauchy(promote(μ, σ)...)
Cauchy(μ::Integer, σ::Integer) = Cauchy(Float64(μ), Float64(σ))
Cauchy(μ::Real) = Cauchy(μ, 1.0)
Cauchy() = Cauchy(0.0, 1.0)
@distr_support Cauchy -Inf Inf
#### Conversions
function convert(::Type{Cauchy{T}}, μ::Real, σ::Real) where T<:Real
Cauchy(T(μ), T(σ))
end
function convert(::Type{Cauchy{T}}, d::Cauchy{S}) where {T <: Real, S <: Real}
Cauchy(T(d.μ), T(d.σ))
end
#### Parameters
location(d::Cauchy) = d.μ
scale(d::Cauchy) = d.σ
params(d::Cauchy) = (d.μ, d.σ)
@inline partype(d::Cauchy{T}) where {T<:Real} = T
#### Statistics
mean(d::Cauchy{T}) where {T<:Real} = T(NaN)
median(d::Cauchy) = d.μ
mode(d::Cauchy) = d.μ
var(d::Cauchy{T}) where {T<:Real} = T(NaN)
skewness(d::Cauchy{T}) where {T<:Real} = T(NaN)
kurtosis(d::Cauchy{T}) where {T<:Real} = T(NaN)
entropy(d::Cauchy) = log4π + log(d.σ)
#### Functions
zval(d::Cauchy, x::Real) = (x - d.μ) / d.σ
xval(d::Cauchy, z::Real) = d.μ + z * d.σ
pdf(d::Cauchy, x::Real) = 1 / (π * scale(d) * (1 + zval(d, x)^2))
logpdf(d::Cauchy, x::Real) = - (log1psq(zval(d, x)) + logπ + log(d.σ))
function cdf(d::Cauchy, x::Real)
μ, σ = params(d)
invπ * atan2(x - μ, σ) + 1//2
end
function ccdf(d::Cauchy, x::Real)
μ, σ = params(d)
invπ * atan2(μ - x, σ) + 1//2
end
function quantile(d::Cauchy, p::Real)
μ, σ = params(d)
μ + σ * tan(π * (p - 1//2))
end
function cquantile(d::Cauchy, p::Real)
μ, σ = params(d)
μ + σ * tan(π * (1//2 - p))
end
mgf(d::Cauchy{T}, t::Real) where {T<:Real} = t == zero(t) ? one(T) : T(NaN)
cf(d::Cauchy, t::Real) = exp(im * (t * d.μ) - d.σ * abs(t))
#### Fitting
# Note: this is not a Maximum Likelihood estimator
function fit(::Type{Cauchy}, x::AbstractArray{T}) where T<:Real
l, m, u = quantile(x, [0.25, 0.5, 0.75])
Cauchy(m, (u - l) / 2)
end
|
{"hexsha": "34a06952ee5566d35d4a85889da5829b39d2d9fe", "size": 2821, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/univariate/continuous/cauchy.jl", "max_stars_repo_name": "ludkinm/Distributions.jl", "max_stars_repo_head_hexsha": "7ec5b512139e8fb0a46b7a283d42d95a7b540bd0", "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/univariate/continuous/cauchy.jl", "max_issues_repo_name": "ludkinm/Distributions.jl", "max_issues_repo_head_hexsha": "7ec5b512139e8fb0a46b7a283d42d95a7b540bd0", "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/univariate/continuous/cauchy.jl", "max_forks_repo_name": "ludkinm/Distributions.jl", "max_forks_repo_head_hexsha": "7ec5b512139e8fb0a46b7a283d42d95a7b540bd0", "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": 25.1875, "max_line_length": 109, "alphanum_fraction": 0.5863169089, "num_tokens": 1135}
|
import os
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import svm, datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, accuracy_score, mean_absolute_error, mean_squared_error
from sklearn.utils.multiclass import unique_labels
from sklearn.metrics import precision_recall_fscore_support
global fig_mx
global train_acc, train_loss, test_acc, test_loss, whether_first
train_accs = []
train_losses = []
test_accs = []
test_losses = []
epochs = []
whether_first = 1
import matplotlib
from mpl_toolkits.axes_grid1 import AxesGrid
# https://stackoverflow.com/questions/7404116/defining-the-midpoint-of-a-colormap-in-matplotlib
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'):
'''
Function to offset the "center" of a colormap. Useful for
data with a negative min and positive max and you want the
middle of the colormap's dynamic range to be at zero.
Input
-----
cmap : The matplotlib colormap to be altered
start : Offset from lowest point in the colormap's range.
Defaults to 0.0 (no lower offset). Should be between
0.0 and `midpoint`.
midpoint : The new center of the colormap. Defaults to
0.5 (no shift). Should be between 0.0 and 1.0. In
general, this should be 1 - vmax / (vmax + abs(vmin))
For example if your data range from -15.0 to +5.0 and
you want the center of the colormap at 0.0, `midpoint`
should be set to 1 - 5/(5 + 15)) or 0.75
stop : Offset from highest point in the colormap's range.
Defaults to 1.0 (no upper offset). Should be between
`midpoint` and 1.0.
'''
cdict = {
'red': [],
'green': [],
'blue': [],
'alpha': []
}
# regular index to compute the colors
reg_index = np.linspace(start, stop, 257)
# shifted index to match the data
shift_index = np.hstack([
np.linspace(0.0, midpoint, 128, endpoint=False),
np.linspace(midpoint, 1.0, 129, endpoint=True)
])
for ri, si in zip(reg_index, shift_index):
r, g, b, a = cmap(ri)
cdict['red'].append((si, r, r))
cdict['green'].append((si, g, g))
cdict['blue'].append((si, b, b))
cdict['alpha'].append((si, a, a))
newcmap = matplotlib.colors.LinearSegmentedColormap(name, cdict)
plt.register_cmap(cmap=newcmap)
return newcmap
def draw_graph(epoch_all, epoch_now, train_acc, train_loss, test_acc, test_loss, training_name, save_place='./'):
global whether_first, fig1, fig2
train_accs.append(train_acc)
train_losses.append(train_loss)
test_accs.append(test_acc)
test_losses.append(test_loss)
epochs.append(epoch_now)
if whether_first == 0:
plt.close(fig1)
plt.close(fig2)
fig1 = plt.figure()
plt.ylim(0.45, 1.0)
plt.plot(epochs, train_accs, 'bo', label='Training acc')
plt.plot(epochs, test_accs, 'b', label='Test acc')
plt.title('Training and test accuracy; '+ training_name)
plt.grid(b=True)
plt.tick_params(labelsize=15)
plt.legend(fontsize=15)
fig2 = plt.figure()
plt.plot(epochs, train_losses, 'ro', label='Training loss')
plt.plot(epochs, test_losses, 'r', label='Test loss')
plt.title('Training and test loss; ' + training_name)
plt.grid(b=True)
plt.tick_params(labelsize=15)
plt.legend(fontsize=15)
#plt.pause(0.1) # to show updating process
whether_first = 0
#if epoch_now >= epoch_all-1:
fig1.savefig('Training and test accuracy; '+ training_name)
fig2.savefig('Training and test loss; ' + training_name)
fig1.savefig(save_place + 'Training and test accuracy; '+ training_name)
fig2.savefig(save_place + 'Training and test loss; ' + training_name)
# https://funatsu-lab.github.io/open-course-ware/basic-theory/accuracy-index/#how-to-check-rmse-mae-yyplot
# http://www.yamamo10.jp/yamamoto/comp/Python/library/Matplotlib/scatter/index.php
from scipy.stats import gaussian_kde
def yyplot_density(y_obs, y_pred, binary_name, save_place='./'): #y_obs and y_pred must be numpy array
xy = np.vstack([y_obs, y_pred])
# if there's too many points, this will limit it.
if xy.shape[1] > 100000:
limit = xy.shape[1]/10
xy = np.vstack([y_obs[:int(limit)], y_pred[:int(limit)]])
z = gaussian_kde(xy)(xy)
idx = z.argsort()
x,y,z = y_obs[idx],y_pred[idx],z[idx]
yvalues = np.concatenate([y_obs.flatten(), y_pred.flatten()])
ymin, ymax, yrange = np.amin(yvalues), np.amax(yvalues), np.ptp(yvalues)
fig = plt.figure(figsize=(8, 8))
plt.scatter(x, y, c=z)
plt.plot([ymin - yrange * 0.01, ymax + yrange * 0.01], [ymin - yrange * 0.01, ymax + yrange * 0.01], color="navy")
plt.xlim(ymin - yrange * 0.01, ymax + yrange * 0.01)
plt.ylim(ymin - yrange * 0.01, ymax + yrange * 0.01)
plt.xlabel('y_observed', fontsize=24)
plt.ylabel('y_predicted', fontsize=24)
plt.xticks( np.arange(min(np.max(y_obs),np.max(y_pred)), max(np.max(y_obs),np.max(y_pred)), 1.0) )
plt.yticks( np.arange(min(np.max(y_obs),np.max(y_pred)), max(np.max(y_obs),np.max(y_pred)), 1.0) )
plt.grid(b=True)
if binary_name == True:
plt.title('Train;Observed-Predicted Plot', fontsize=24)
else:
plt.title('Test;Observed-Predicted Plot', fontsize=24)
plt.tick_params(labelsize=16)
if binary_name == True:
fig.savefig('Train;Observed-Predicted-Plot.png')
fig.savefig(save_place + 'Train;Observed-Predicted-Plot.png')
else:
fig.savefig('Test;Observed-Predicted-Plot.png')
fig.savefig(save_place + 'Test;Observed-Predicted-Plot.png')
plt.close(fig)
# https://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html#sphx-glr-auto-examples-model-selection-plot-confusion-matrix-py
def plot_confusion_matrix(y_true, y_pred, classes, save_caption,
save_place='./',
normalize=False,
cmap=plt.cm.Blues
):
"""
This function prints and plots the confusion matrix.
Normalization can be applied by setting `normalize=True`.
"""
global fig_mx
cm = confusion_matrix(y_true, y_pred)
indices = precision_recall_fscore_support(y_true, y_pred, average="macro")
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
accuracy = accuracy_score(y_true, y_pred)
accuracy_1err_ok = accuracy_score(y_true, y_pred) + accuracy_score(y_true, list(map(lambda x: x+1, y_pred))) + accuracy_score(y_true, list(map(lambda x: x-1, y_pred)))
accuracy_2err_ok = accuracy_1err_ok + accuracy_score(y_true, list(map(lambda x: x+2, y_pred))) + accuracy_score(y_true, list(map(lambda x: x-2, y_pred)))
mse = mean_squared_error(y_true, y_pred)
if normalize:
title = 'Normalized:accuracy={:.3f},+-1={:.3f},+-2={:.3f},MSE={:.3f}'.format(accuracy, accuracy_1err_ok, accuracy_2err_ok, mse)
else:
title = 'accuracy={:.3f},+-1={:.3f},+-2={:.3f},MSE={:.3f}'.format(accuracy, accuracy_1err_ok, accuracy_2err_ok, mse)
fig_mx, ax = plt.subplots()
im = ax.imshow(cm, interpolation='nearest', cmap=cmap, vmax=10) # change vmax
ax.figure.colorbar(im, ax=ax)
# We want to show all ticks...
ax.set(xticks=np.arange(cm.shape[1]),
yticks=np.arange(cm.shape[0]),
# ... and label them with the respective list entries
xticklabels=classes, yticklabels=classes,
title=title,
ylabel='True label',
xlabel='Predicted label')
# Rotate the tick labels and set their alignment.
plt.setp(ax.get_xticklabels(), rotation=45, ha="right",
rotation_mode="anchor")
# Loop over data dimensions and create text annotations.
fmt = '.2f' if normalize else 'd'
thresh = cm.max() / 2.
for i in range(cm.shape[0]):
for j in range(cm.shape[1]):
ax.text(j, i, format(cm[i, j], fmt),
ha="center", va="center", fontsize=11,
color="white" if cm[i, j] > thresh else "black")
fig_mx.tight_layout()
fig_mx.savefig(save_place + 'confusion_matrix;' + os.path.basename(save_caption) + '.png')
fig_mx.savefig('confusion_matrix;' + os.path.basename(save_caption) + '.png')
plt.close(fig_mx)
acc = 0
cnt = 0
for i in range(len(y_true)):
acc += y_pred[i]
cnt += 1
result4 = "accuracy: {}\n".format(accuracy)
result5 = "accuracy (accepting +-1 error): {}\n".format(accuracy_1err_ok)
result6 = "accuracy (accepting +-2 error): {}\n".format(accuracy_2err_ok)
result7 = "MAE: {}\n".format(mean_absolute_error(y_true, y_pred))
result8 = "MSE: {}\n".format(mse)
result9 = "RMSE: {}\n".format(np.sqrt(mean_squared_error(y_true, y_pred)))
f = open(save_place + 'result;' + os.path.basename(save_caption) + '.txt', 'w')
f2 = open('result;' + os.path.basename(save_caption) + '.txt', 'w')
f.write(result4)
f2.write(result4)
f.write(result5)
f2.write(result5)
f.write(result6)
f2.write(result6)
f.write(result7)
f2.write(result7)
f.write(result8)
f2.write(result8)
f.write(result9)
f2.write(result9)
f.close()
f2.close()
return ax
if __name__ == '__main__': #this is for draw_graph debug
yyplot_density(np.array([0,-1,2,0,1,2,0,3,2]), np.array([-1,1,0,2,2,1,1,3,0]), "trial") #y_obs and y_pred must be numpy array
epoch = 5
train_acc4debug = [0.1, 0.2, 0.5, 0.6, 0.9]
train_loss4debug = [5, 4, 3, 3, 1]
test_acc4debug = [0.1, 0.3, 0.3, 0.5, 0.6]
test_loss4debug = [5, 5, 4, 4, 3]
for i in range(5):
draw_graph(epoch, i, train_acc4debug[i], train_loss4debug[i], test_acc4debug[i], test_loss4debug[i], "debug")
# note: you just need to give value for acc&loss, not list
pass
plot_confusion_matrix([0,1,2,0,1,2,0,1,2], [2,1,0,2,2,1,1,0,0], ["blue","red","green"], "trial", save_place='./', normalize=False, cmap=plt.cm.Blues)
|
{"hexsha": "58e3b0090b68e6f507f2944dce0c64c7b229636e", "size": 10148, "ext": "py", "lang": "Python", "max_stars_repo_path": "draw_graphs.py", "max_stars_repo_name": "ba-san/DL-CV-tools", "max_stars_repo_head_hexsha": "ae5895a189fde39abe342ec19eaca2f388504b48", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-05-22T09:15:40.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T09:15:40.000Z", "max_issues_repo_path": "draw_graphs.py", "max_issues_repo_name": "ba-san/DL-CV-tools", "max_issues_repo_head_hexsha": "ae5895a189fde39abe342ec19eaca2f388504b48", "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": "draw_graphs.py", "max_forks_repo_name": "ba-san/DL-CV-tools", "max_forks_repo_head_hexsha": "ae5895a189fde39abe342ec19eaca2f388504b48", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-19T10:19:55.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-19T10:19:55.000Z", "avg_line_length": 37.1721611722, "max_line_length": 171, "alphanum_fraction": 0.6492905006, "include": true, "reason": "import numpy,from scipy", "num_tokens": 2910}
|
# Network representation learning with Line algorithm
# Author: Sebastian Haslebacher 2021-12-22
import networkx as nx # https://networkx.org/documentation/stable/tutorial.html
import numpy as np
import random
import argparse
import pickle
class Sampler:
"""
Maintains data-structure for negative sampling.
"""
def __init__(self, G):
self.G = G
self.nodes = []
for node in G.nodes:
deg = (int)(np.ceil(np.power(G.degree[node], 3/4)))
for _ in range(deg):
self.nodes.append(node)
random.shuffle(self.nodes)
self.current = 0
def draw(self, K):
samples = []
for k in range(K):
if(self.current == len(self.nodes)):
random.shuffle(self.nodes)
self.current = 0
samples.append(self.nodes[self.current])
self.current += 1
return samples
def sig(x):
"""
Sigmoid-function.
"""
return (1 / (1 + np.exp(-x)))
def line_first_order(G, timesteps, K, d, eps=0.1):
"""
G: networkx graph
timesteps: number of optimisation steps
K: number of negative edges for every positive edge
d: dimensionality of embeddings
"""
E = {}
for node in G.nodes:
E[node] = np.random.rand(d) - 0.5
edges = [(e[0], e[1]) for e in G.edges]
sampler = Sampler(G)
# asynchronous SGD to learn embeddings
count = 0
N = timesteps
while(count < N):
random.shuffle(edges)
for u, v in edges:
neg_nbrs = sampler.draw(K)
# update according to the (positive) edge
del_u = E[v] * (1 - sig(np.dot(E[v], E[u])))
del_v = E[u] * (1 - sig(np.dot(E[v], E[u])))
# updates for negative edges
for nbr in neg_nbrs:
del_u -= E[nbr] * (1 - sig(-np.dot(E[nbr], E[u]))) / K
del_v -= E[nbr] * (1 - sig(-np.dot(E[v], E[nbr]))) / K
# only update one of the two endpoints
coin = random.randint(0, 1)
if(coin):
E[u] += eps * del_u
else:
E[v] += eps * del_v
if ((count + 1) % 10000 == 0):
print('Completed %d out of %d optimisation steps'%(count + 1, N))
count += 1
if count >= N:
break
return E
def main(args):
# https://networkx.org/documentation/stable/reference/readwrite/gpickle.html
G = nx.read_gpickle(args.graph_path)
print('Loaded graph with %d nodes and %d edges'%(len(G.nodes), len(G.edges)))
print('Start to learn Line-1 embeddings')
E = line_first_order(G, args.timesteps, args.K, args.d)
with open(args.output_path, 'wb') as handle:
pickle.dump(E, handle)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='learn network representations with Line')
# command-line arguments
parser.add_argument('graph_path', type=str,
help='path to pickle-file of networkx graph', action='store')
parser.add_argument('output_path', type=str,
help='path to output file where represenations are stored', action='store')
parser.add_argument('--seed', dest='seed', type=int,
help='fix random seeds', action='store', default=1)
parser.add_argument('-T', dest='timesteps', type=int,
help='number of optimisation steps', action='store', default=1)
parser.add_argument('-K', dest='K', type=int,
help='number of negative samples for every edge', action='store', default=5)
parser.add_argument('-d', dest='d', type=int,
help='dimensionality of embeddings', action='store', default=128)
args = parser.parse_args()
random.seed(args.seed)
np.random.seed(args.seed)
main(args)
|
{"hexsha": "9f3782e517f1dea43774318f5bb70c4ddf3ecdf0", "size": 3828, "ext": "py", "lang": "Python", "max_stars_repo_path": "Line-1/main.py", "max_stars_repo_name": "Manu-Fraile/Network-Representation-Learning", "max_stars_repo_head_hexsha": "d84414c144cc6146d406e606ed5be8120d4244a9", "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": "Line-1/main.py", "max_issues_repo_name": "Manu-Fraile/Network-Representation-Learning", "max_issues_repo_head_hexsha": "d84414c144cc6146d406e606ed5be8120d4244a9", "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": "Line-1/main.py", "max_forks_repo_name": "Manu-Fraile/Network-Representation-Learning", "max_forks_repo_head_hexsha": "d84414c144cc6146d406e606ed5be8120d4244a9", "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": 33.2869565217, "max_line_length": 91, "alphanum_fraction": 0.5760188088, "include": true, "reason": "import numpy,import networkx", "num_tokens": 956}
|
import collections
import sys
import numpy as np
from typing import Any, Callable, List, Union, Sequence, Optional
from torch.utils.data import Subset
from monai.data import CacheDataset
from generator_coords import CoordsGenerator
class BrainCacheDataset(CacheDataset):
"""General purpose dataset class with several data sources `list_data`."""
def __init__(
self,
data: Sequence,
transform: Union[Sequence[Callable], Callable],
list_shape: List[int],
list_sub_shape: List[int],
num_workers: Optional[int] = None,
cache_rate: float = 1.0,
cache_num: int = sys.maxsize,
n_subvolumes: int = None,
copy_cache: bool = True,
progress: bool = True,
mode: str = "train",
input_key: str = "images",
output_key: str = "nii_labels",
):
"""
Args:
list_data (List[Dict]): list of dicts, that stores
you data annotations,
(for example path to images, labels, bboxes, etc.)
transform (callable): transforms to use on dict.
(for example normalize image, add blur, crop/resize/etc)
list_shape (List[int]):
list_sub_shape (List[int]):
"""
super().__init__(data, transform, cache_num, cache_rate,
num_workers, progress, copy_cache)
self.generator = CoordsGenerator(
list_shape=list_shape, list_sub_shape=list_sub_shape
)
self.mode = mode
self.subvolume_shape = np.array(list_sub_shape)
self.subjects = len(self.data)
self.n_subvolumes = n_subvolumes
self.input_key = input_key
self.output_key = output_key
def __len__(self) -> int:
"""
Returns:
int: length of the dataset
"""
return self.n_subvolumes * len(self.data)
def __getitem__(self, index: Union[int, slice, Sequence[int]]) -> Any:
"""Gets element of the dataset.
Args:
index (int): index of the element in the dataset
Returns:
List of elements by index
"""
if isinstance(index, slice):
start, stop, step = index.indices(len(self))
indices = range(start, stop, step)
return Subset(dataset=self, indices=indices)
if isinstance(index, collections.abc.Sequence):
return Subset(dataset=self, indices=index)
batch_list = []
subject_id = index // self.n_subvolumes
subj_data_dict = self._transform(subject_id)
coords_index = index % self.n_subvolumes
coords = self.generator.get_coordinates(mode="test")
if len(coords) > 1:
if self.mode in ["train", "validation"] or coords_index >= len(coords):
coords = self.generator.get_coordinates()
else:
coords = np.expand_dims(coords[coords_index], 0)
batch_list.append(
self.__crop__(subj_data_dict, coords))
return batch_list
def __crop__(self, dict_, coords):
"""Get crop of images.
Args:
dict_ (List[Dict]): list of dicts, that stores
you data annotations,
(for example path to images, labels, bboxes, etc.)
coords (callable): coords of crops
Returns:
crop images
"""
output = {}
output_labels_list = []
output_images_list = []
for start_end in coords:
for key, dict_key in dict_.items():
if key == self.input_key:
output_images_list.append(
dict_key[
:,
start_end[0][0] : start_end[0][1],
start_end[1][0] : start_end[1][1],
start_end[2][0] : start_end[2][1],
],
)
elif key == self.output_key:
output_labels_list.append(
dict_key[
:,
start_end[0][0] : start_end[0][1],
start_end[1][0] : start_end[1][1],
start_end[2][0] : start_end[2][1],
],
)
output_images = np.concatenate(output_images_list)
output_labels = np.concatenate(output_labels_list)
output[self.input_key] = output_images
output[self.output_key] = output_labels.squeeze()
output["coords"] = coords
return output
|
{"hexsha": "6a6e5abc05db4fe84b9270346de3a9a52687efd5", "size": 4750, "ext": "py", "lang": "Python", "max_stars_repo_path": "training/brain_dataset_cache.py", "max_stars_repo_name": "ssktotoro/neuro", "max_stars_repo_head_hexsha": "2d6d4cd060ee368d67c3437cac2b64eeb7d7180c", "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": "training/brain_dataset_cache.py", "max_issues_repo_name": "ssktotoro/neuro", "max_issues_repo_head_hexsha": "2d6d4cd060ee368d67c3437cac2b64eeb7d7180c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-11-09T06:07:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-12T03:16:38.000Z", "max_forks_repo_path": "training/brain_dataset_cache.py", "max_forks_repo_name": "ssktotoro/neuro", "max_forks_repo_head_hexsha": "2d6d4cd060ee368d67c3437cac2b64eeb7d7180c", "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": 35.7142857143, "max_line_length": 83, "alphanum_fraction": 0.5332631579, "include": true, "reason": "import numpy", "num_tokens": 964}
|
!! Copyright (C) Stichting Deltares, 2012-2016.
!!
!! This program is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License version 3,
!! as published by the Free Software Foundation.
!!
!! This program is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
!!
!! contact: delft3d.support@deltares.nl
!! Stichting Deltares
!! P.O. Box 177
!! 2600 MH Delft, The Netherlands
!!
!! All indications and logos of, and references to registered trademarks
!! of Stichting Deltares remain the property of Stichting Deltares. All
!! rights reserved.
subroutine dlwqh6 ( noseg , notot , isys , nsys , conc , &
& sol , amass2 , dmps , intopt , isdmp )
! Deltares Software Centre
!>\File Puts the steady state solution in the concentration array
! Created : June 1988 by Leo Postma as dlwq63.f
! Modified : March 2011, Leo Postma : for iterative GMRES solver
use timers ! WAQ performance timers
implicit none
! Arguments :
! Kind Function Name Description
integer(4), intent(in ) :: noseg !< Number of computational volumes
integer(4), intent(in ) :: notot !< Total number of substances
integer(4), intent(in ) :: isys !< First substance to update
integer(4), intent(in ) :: nsys !< Total number of substances to update
real (4), intent(inout) :: conc (notot,noseg) !< Target array for update
real (8), intent(inout) :: sol (nsys ,noseg) !< Solution matrix for the nsys substances
real (4), intent(inout) :: amass2(notot, 5 ) !< Mass accumulation array
real (4), intent(inout) :: dmps (notot, * ) !< Dumped segment fluxes if intopt > 7
integer(4), intent(in ) :: intopt !< Integration sub options
integer(4), intent(in ) :: isdmp (noseg) !< Pointer dumped segments
! Local declarations
integer(4) iseg, i, ip ! loop variables
! The WAQ-timer
integer(4) ithandl /0/
if ( timon ) call timstrt ( "dlwqh6", ithandl )
! put result in concentration array
if ( .not. btest(intopt,3) ) then
do iseg = 1, noseg
do i = isys, isys+nsys-1
amass2( i , 2 ) = amass2( i, 2 ) + conc(i,iseg)*sol(i-isys+1,iseg)
conc ( i , iseg ) = sol(i-isys+1,iseg)
sol ( i-isys+1, iseg ) = 0.0d00
enddo
enddo
else
do iseg = 1, noseg
ip = isdmp(iseg)
do i = isys, isys+nsys-1
amass2( i , 2 ) = amass2( i, 2 ) + conc(i,iseg)*sol(i-isys+1,iseg)
if ( ip .gt. 0 ) then
dmps( i, ip ) = dmps( i, ip ) + conc(i,iseg)*sol(i-isys+1,iseg)
endif
conc ( i , iseg ) = sol(i-isys+1,iseg)
sol ( i-isys+1, iseg ) = 0.0d00
enddo
enddo
endif
if ( timon ) call timstop ( ithandl )
return
end
|
{"hexsha": "05d4666ebd6e24fd19cf415aaf0974e54a5d8dba", "size": 3525, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "docker/water/delft3d/tags/v6686/src/engines_gpl/waq/packages/waq_kernel/src/waq_kernel/dlwqh6.f90", "max_stars_repo_name": "liujiamingustc/phd", "max_stars_repo_head_hexsha": "4f815a738abad43531d02ac66f5bd0d9a1def52a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-01-06T03:01:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T03:02:55.000Z", "max_issues_repo_path": "docker/water/delft3d/tags/v6686/src/engines_gpl/waq/packages/waq_kernel/src/waq_kernel/dlwqh6.f90", "max_issues_repo_name": "liujiamingustc/phd", "max_issues_repo_head_hexsha": "4f815a738abad43531d02ac66f5bd0d9a1def52a", "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": "docker/water/delft3d/tags/v6686/src/engines_gpl/waq/packages/waq_kernel/src/waq_kernel/dlwqh6.f90", "max_forks_repo_name": "liujiamingustc/phd", "max_forks_repo_head_hexsha": "4f815a738abad43531d02ac66f5bd0d9a1def52a", "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.7362637363, "max_line_length": 99, "alphanum_fraction": 0.5574468085, "num_tokens": 1023}
|
# make heat maps for paper
library(ggplot2)
library(reshape2)
library(RColorBrewer)
library(scales)
# read in files
OTUtables <- list.files(path='.', pattern='.csv', full.names=T)
Data1_OTU_wgs_16s <- read.csv(OTUtables[1], header=T)
Data2_OTU_wgs_microb <- read.csv(OTUtables[2], header=T)
Data3_OTU_metabar <- read.csv(OTUtables[3], header=T)
Data5_OTU_wgs_refmapped <- read.csv(OTUtables[4], header=T)
# format tables - from matrix to df
data1 <- melt(Data1_OTU_wgs_16s); colnames(data1) <- c('Site', 'Order', 'NumReads')
data2 <- melt(Data2_OTU_wgs_microb); colnames(data2) <- c('Site', 'Order', 'NumReads')
data3 <- melt(Data3_OTU_metabar); colnames(data3) <- c('Site', 'Order', 'NumReads')
data5 <- melt(Data5_OTU_wgs_refmapped); colnames(data5) <- c('Site', 'Order', 'NumReads')
# clean up files
# data1 should not have Stamenopiles (euk) for the singlem results
data1_clean <- data1[data1$Order!='Stramenopiles', ]
# ---- as bar plots ----
order.cols.dat1 <- length(unique(data1_clean$Order))
ordercolors.dat1 <- colorRampPalette(brewer.pal(8, "Set1"))(order.cols.dat1)
order.cols.dat2 <- length(unique(data2$Order))
ordercolors.dat2 <- colorRampPalette(brewer.pal(8, "Set1"))(order.cols.dat2)
order.cols.dat3 <- length(unique(data3$Order))
ordercolors.dat3 <- colorRampPalette(brewer.pal(8, "Set1"))(order.cols.dat3)
order.cols.dat5 <- length(unique(data5$Order))
ordercolors.dat5 <- colorRampPalette(brewer.pal(8, "Set1"))(order.cols.dat5)
ggplot(data1_clean, aes(x=Site, y=NumReads, fill=factor(Order))) +
geom_bar(stat="identity", colour="black") +
scale_fill_manual(values=ordercolors.dat1) +
scale_y_continuous(labels=scales::comma) +
ggtitle('Data1_OTU_wgs_16s') +
ylab('Number of seq reads') +
xlab('Sample') +
guides(fill=guide_legend(title="Order")) +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data1_OTU_wgs_16s_barplot.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data2, aes(x=Site, y=NumReads, fill=factor(Order))) +
geom_bar(stat="identity", colour="black") +
scale_fill_manual(values=ordercolors.dat2) +
scale_y_continuous(labels=scales::comma) +
ggtitle('Data2_OTU_wgs_microb') +
ylab('Number of seq reads') +
xlab('Sample') +
guides(fill=guide_legend(title="Order")) +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data2_OTU_wgs_microb_barplot.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data3, aes(x=Site, y=NumReads, fill=factor(Order))) +
geom_bar(stat="identity", colour="black") +
scale_fill_manual(values=ordercolors.dat3) +
scale_y_continuous(labels=scales::comma) +
ggtitle('Data3_OTU_metabar') +
ylab('Number of seq reads') +
xlab('Sample') +
guides(fill=guide_legend(title="Order")) +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data3_OTU_metabar_barplot.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data5, aes(x=Site, y=NumReads, fill=factor(Order))) +
geom_bar(stat="identity", colour="black") +
scale_fill_manual(values=ordercolors.dat5) +
scale_y_continuous(labels=scales::comma) +
ggtitle('Data5_OTU_wgs_refmapped') +
ylab('Number of seq reads') +
xlab('Sample') +
guides(fill=guide_legend(title="Order")) +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data5_OTU_wgs_refmapped_barplot.jpg', height=8, width=20, units='in', dpi=600)
# ---- as heat maps ----
# make 0 counts NA's so they can be plotted as white boxes in tile plots
data1_clean[data1_clean == 0] <- NA
data2[data2==0] <- NA
data3[data3==0] <- NA
data5[data5==0] <- NA
ggplot(data1_clean, aes(x=Site, y=factor(Order))) +
geom_tile(aes(fill=NumReads), col='grey') +
scale_fill_gradientn(colors=viridis_pal()(20),
limits=c(0, max(data1_clean$NumReads)),
na.value='white',
labels=comma) +
ggtitle('Data1_OTU_wgs_16s') +
ylab('Taxonomic Order') +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data1_OTU_wgs_16s_heatmap.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data2, aes(x=Site, y=factor(Order))) +
geom_tile(aes(fill=NumReads), col='grey') +
scale_fill_gradientn(colors=viridis_pal()(20),
limits=c(0, max(data2$NumReads)),
na.value='white',
labels=comma) +
ggtitle('Data2_OTU_wgs_microb') +
ylab('Taxonomic Order') +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data2_OTU_wgs_microb_heatmap.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data3, aes(x=Site, y=factor(Order))) +
geom_tile(aes(fill=NumReads), col='grey') +
scale_fill_gradientn(colors=viridis_pal()(20),
limits=c(0, max(data3$NumReads)),
na.value='white',
labels=comma) +
ggtitle('Data3_OTU_metabar') +
ylab('Taxonomic Order') +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data3_OTU_metabar_heatmap.jpg', height=8, width=10, units='in', dpi=600)
ggplot(data5, aes(x=Site, y=factor(Order))) +
geom_tile(aes(fill=NumReads), col='grey') +
scale_fill_gradientn(colors=viridis_pal()(20),
limits=c(0, max(data5$NumReads)),
na.value='white',
labels=comma) +
ggtitle('Data5_OTU_wgs_refmapped') +
ylab('Taxonomic Order') +
theme(axis.text.x=element_text(angle=45, hjust=1, size=10),
axis.text.y=element_text(size=10),
axis.title=element_text(size=15, face='bold'))
ggsave('Data5_OTU_wgs_refmapped_heatmap.jpg', height=15, width=10, units='in', dpi=600)
|
{"hexsha": "2d8056f3b3793d42d0a6d1a5ae9c514182227bc6", "size": 6315, "ext": "r", "lang": "R", "max_stars_repo_path": "Scripts_to_compare_dats/heatmap_plts.r", "max_stars_repo_name": "marisalim/EverestMetagenomics2020", "max_stars_repo_head_hexsha": "18fa4355d5f89614ad6bfde402e3db18f2f4dd8c", "max_stars_repo_licenses": ["CC0-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": "Scripts_to_compare_dats/heatmap_plts.r", "max_issues_repo_name": "marisalim/EverestMetagenomics2020", "max_issues_repo_head_hexsha": "18fa4355d5f89614ad6bfde402e3db18f2f4dd8c", "max_issues_repo_licenses": ["CC0-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": "Scripts_to_compare_dats/heatmap_plts.r", "max_forks_repo_name": "marisalim/EverestMetagenomics2020", "max_forks_repo_head_hexsha": "18fa4355d5f89614ad6bfde402e3db18f2f4dd8c", "max_forks_repo_licenses": ["CC0-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": 43.5517241379, "max_line_length": 89, "alphanum_fraction": 0.6780680918, "num_tokens": 1936}
|
#!/usr/bin/env python3
import jax.numpy as np
from jax.ops import index_update
from jax.ops import index
from compas.numerical import connectivity_matrix
__all__ = ["ForceDensity", "force_equilibrium"]
class ForceDensity():
"""
A callable-object version of the force density method.
"""
def __call__(self, q, network):
"""
Do FD directly from information pertaining a network.
"""
params = [np.array(param) for param in network.fd_parameters()]
xyz, lengths, forces, residuals = force_equilibrium(q, *params)
fd_state = {"xyz": xyz, "lengths": lengths, "forces": forces, "residuals": residuals}
return fd_state
def force_equilibrium(q, edges, xyz, free, fixed, loads):
"""
Jax-based force density method.
"""
c_matrix = connectivity_matrix(edges, "list")
c_matrix = np.array(c_matrix)
c_matrix_t = np.transpose(c_matrix)
c_free = c_matrix[:, free]
c_fixed = c_matrix[:, fixed]
c_free_t = np.transpose(c_free)
q_matrix = np.diag(q)
A = c_free_t @ q_matrix @ c_free
b = loads[free, :] - c_free_t @ q_matrix @ c_fixed @ xyz[fixed, :]
x = np.linalg.solve(A, b)
xyz = index_update(xyz, index[free, :], x)
lengths = np.linalg.norm(c_matrix @ xyz, axis=1)
forces = q * lengths # there is a bug in forces
residuals = loads - c_matrix_t @ q_matrix @ c_matrix @ xyz
return xyz, lengths, forces, residuals
|
{"hexsha": "6c409c1a6e12e4877d7d1f73f01c2ad31f6c46bd", "size": 1456, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/force_density/equilibrium.py", "max_stars_repo_name": "arpastrana/force_density", "max_stars_repo_head_hexsha": "0ceab89a8b125d9b6dbd410ba28c55df17135a89", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-14T06:33:31.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-14T06:33:31.000Z", "max_issues_repo_path": "src/force_density/equilibrium.py", "max_issues_repo_name": "arpastrana/force_density", "max_issues_repo_head_hexsha": "0ceab89a8b125d9b6dbd410ba28c55df17135a89", "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/force_density/equilibrium.py", "max_forks_repo_name": "arpastrana/force_density", "max_forks_repo_head_hexsha": "0ceab89a8b125d9b6dbd410ba28c55df17135a89", "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": 26.962962963, "max_line_length": 93, "alphanum_fraction": 0.6504120879, "include": true, "reason": "import jax,from jax", "num_tokens": 374}
|
# -*- coding: utf-8 -*-
# @Author: Mariia Popova
# @Email: theo.lemaire@epfl.ch
# @Date: 2020-02-27 21:24:05
# @Last Modified by: Theo Lemaire
# @Last Modified time: 2020-07-21 16:15:20
import numpy as np
from ..core import PointNeuron, addSonicFeatures
@addSonicFeatures
class MRGNode(PointNeuron):
''' Mammalian myelinated fiber node.
Reference:
*McIntyre, C.C., Richardson, A.G., and Grill, W.M. (2002). Modeling the excitability
of mammalian nerve fibers: influence of afterpotentials on the recovery cycle.
J. Neurophysiol. 87, 995–1006.*
'''
# Mechanism name
name = 'MRGnode'
# ------------------------------ Biophysical parameters ------------------------------
# Resting parameters
Cm0 = 2e-2 # Membrane capacitance (F/m2)
Vm0 = -80. # Membrane potential (mV)
# Reversal potentials (mV)
ENa = 50. # Sodium
EK = -90. # Potassium
ELeak = -90. # Non-specific leakage
# Maximal channel conductances (S/m2)
gNafbar = 3e4 # Fast Sodium
gNapbar = 100. # Persistent Sodium
gKsbar = 800. # Slow Potassium
gLeak = 70. # Non-specific leakage
# Additional parameters
# celsius = 36.0 # Temperature (Celsius)
celsius_Schwarz = 20.0 # Temperature in Schwarz 1995 (Celsius)
celsius_Ks = 36.0 # Temperature used for Ks channels (unknown ref.)
mhshift = 3. # m and h gates voltage shift (mV)
vtraub = -80. # Reference voltage for the definition of the s rate constants (mV)
# ------------------------------ States names & descriptions ------------------------------
states = {
'm': 'iNaf activation gate',
'h': 'iNaf inactivation gate',
'p': 'iNap activation gate',
's': 'iKs activation gate',
}
# ------------------------------ Gating states kinetics ------------------------------
def __new__(cls):
cls.q10_mp = 2.2**((cls.celsius - cls.celsius_Schwarz) / 10) # from Schwarz 1987
cls.q10_h = 2.9**((cls.celsius - cls.celsius_Schwarz) / 10) # from Schwarz 1987
cls.q10_s = 3.0**((cls.celsius - cls.celsius_Ks) / 10) # from ???
return super(MRGNode, cls).__new__(cls)
# iNaf kinetics: adapted from Schwarz 1995, with notable changes:
# - Q10 correction to account for temperature adaptation from 20 degrees reference
# - 3 mV offset to m and h gates to shift voltage dependence in the hyperpolarizing direction,
# to increase the conduction velocity and strength-duration time constant (from McIntyre 2002)
# - increase in tau_h to slow down inactivation (achieved through alphah?)
@classmethod
def alpham(cls, Vm):
Vm += cls.mhshift
return cls.q10_mp * 1.86 * cls.vtrap(-(Vm + 18.4), 10.3) * 1e3 # s-1
@classmethod
def betam(cls, Vm):
Vm += cls.mhshift
return cls.q10_mp * 0.086 * cls.vtrap(Vm + 22.7, 9.16) * 1e3 # s-1
@classmethod
def alphah(cls, Vm):
Vm += cls.mhshift
return cls.q10_h * 0.062 * cls.vtrap(Vm + 111.0, 11.0) * 1e3 # s-1
@classmethod
def betah(cls, Vm):
Vm += cls.mhshift
return cls.q10_h * 2.3 / (1 + np.exp(-(Vm + 28.8) / 13.4)) * 1e3 # s-1
# iNap kinetics: adapted from ???, with notable changes:
# - Q10 correction to account for temperature adaptation from 20 degrees reference
# - increase in tau_p in order to extend the duration and amplitude of the DAP.
@classmethod
def alphap(cls, Vm):
return cls.q10_mp * 0.01 * cls.vtrap(-(Vm + 27.), 10.2) * 1e3 # s-1
@classmethod
def betap(cls, Vm):
return cls.q10_mp * 0.00025 * cls.vtrap(Vm + 34., 10.) * 1e3 # s-1
# iKs kinetics: adapted from ???, with notable changes:
# - Q10 correction to account for temperature adaptation from 36 degrees reference
# - increase in tau_s in order to to create an AHP that matches experimental records.
@classmethod
def alphas(cls, Vm):
Vm -= cls.vtraub
return cls.q10_s * 0.3 / (1 + np.exp(-(Vm - 27.) / 5.)) * 1e3 # s-1
@classmethod
def betas(cls, Vm):
Vm -= cls.vtraub
return cls.q10_s * 0.03 / (1 + np.exp(-(Vm + 10.) / 1.)) * 1e3 # s-1
# ------------------------------ States derivatives ------------------------------
@classmethod
def derStates(cls):
return {
'm': lambda Vm, x: cls.alpham(Vm) * (1 - x['m']) - cls.betam(Vm) * x['m'],
'h': lambda Vm, x: cls.alphah(Vm) * (1 - x['h']) - cls.betah(Vm) * x['h'],
'p': lambda Vm, x: cls.alphap(Vm) * (1 - x['p']) - cls.betap(Vm) * x['p'],
's': lambda Vm, x: cls.alphas(Vm) * (1 - x['s']) - cls.betas(Vm) * x['s'],
}
# ------------------------------ Steady states ------------------------------
@classmethod
def steadyStates(cls):
return {
'm': lambda Vm: cls.alpham(Vm) / (cls.alpham(Vm) + cls.betam(Vm)),
'h': lambda Vm: cls.alphah(Vm) / (cls.alphah(Vm) + cls.betah(Vm)),
'p': lambda Vm: cls.alphap(Vm) / (cls.alphap(Vm) + cls.betap(Vm)),
's': lambda Vm: cls.alphas(Vm) / (cls.alphas(Vm) + cls.betas(Vm)),
}
# ------------------------------ Membrane currents ------------------------------
@classmethod
def iNaf(cls, m, h, Vm):
''' fast Sodium current. '''
return cls.gNafbar * m**3 * h * (Vm - cls.ENa) # mA/m2
@classmethod
def iNap(cls, p, Vm):
''' persistent Sodium current. '''
return cls.gNapbar * p**3 * (Vm - cls.ENa) # mA/m2
@classmethod
def iKs(cls, s, Vm):
''' slow Potassium current '''
return cls.gKsbar * s * (Vm - cls.EK) # mA/m2
@classmethod
def iLeak(cls, Vm):
''' non-specific leakage current '''
return cls.gLeak * (Vm - cls.ELeak) # mA/m2
@classmethod
def currents(cls):
return {
'iNaf': lambda Vm, x: cls.iNaf(x['m'], x['h'], Vm),
'iNap': lambda Vm, x: cls.iNap(x['p'], Vm),
'iKs': lambda Vm, x: cls.iKs(x['s'], Vm),
'iLeak': lambda Vm, _: cls.iLeak(Vm)
}
def chooseTimeStep(self):
''' neuron-specific time step for fast dynamics. '''
return super().chooseTimeStep() * 1e-2
|
{"hexsha": "2463d484db03fc58d52b119e08ddf85492e5bef0", "size": 6336, "ext": "py", "lang": "Python", "max_stars_repo_path": "PySONIC/neurons/mrg.py", "max_stars_repo_name": "scbao/pysonic", "max_stars_repo_head_hexsha": "b4ccaf49772d55f632a0995c411d1cc042d71903", "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": "PySONIC/neurons/mrg.py", "max_issues_repo_name": "scbao/pysonic", "max_issues_repo_head_hexsha": "b4ccaf49772d55f632a0995c411d1cc042d71903", "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": "PySONIC/neurons/mrg.py", "max_forks_repo_name": "scbao/pysonic", "max_forks_repo_head_hexsha": "b4ccaf49772d55f632a0995c411d1cc042d71903", "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.6242774566, "max_line_length": 100, "alphanum_fraction": 0.5422979798, "include": true, "reason": "import numpy", "num_tokens": 2012}
|
from __future__ import print_function
from orphics import maps,io,cosmology,stats
from pixell import enmap
import numpy as np
import os,sys
from soapack import interfaces as sints
from actsims import noise
froot = "/scratch/r/rbond/msyriac/data/scratch/tilec/test_lfi_v2_00_0000_deep56/"
kroot = "/scratch/r/rbond/msyriac/data/depot/tilec/test_lfi_v2_00_0000_deep56/"
droot = "/scratch/r/rbond/msyriac/data/depot/tilec/test_lfi_data_deep56/"
lroot = "/scratch/r/rbond/msyriac/data/depot/tilec/test_lfi_v3_00_0000_deep56/"
mask = sints.get_act_mr3_crosslinked_mask("deep56")
shape,wcs = mask.shape,mask.wcs
w2 = np.mean(mask**2.)
qids = 'p01,p02,p03'.split(',')
bin_edges = np.arange(20,6000,40)
modlmap = mask.modlmap()
binner = stats.bin2D(modlmap,bin_edges)
arraynames = {'p01':'030','p02':'044','p03':'070'}
dm = sints.PlanckHybrid(region=mask)
for qid in qids:
split = enmap.read_map("%ssplit_%s.fits" % (froot,qid))
#io.hplot(enmap.downgrade(split,4),"split_%s" % qid)
arrayname = arraynames[qid]
wts = dm.get_splits_ivar(arrayname)[0,:,0,...]
coadd,_ = noise.get_coadd(split[:,0,...],wts,axis=0) * mask
pl = io.Plotter(xyscale='linlog',xlabel='l',ylabel='C')
kmap = enmap.fft(coadd,normalize='phys')
p2d = np.real(kmap*kmap.conj())/w2
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='sim power')
kcoadd = enmap.enmap(np.load("%skcoadd_%s.npy" % (kroot,qid)),wcs)
p2d = np.real(kcoadd*kcoadd.conj())/w2
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='sim power 2')
p2d = enmap.enmap(np.load("%stilec_hybrid_covariance_%s_%s.npy" % (kroot,qid,qid)),wcs)
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='sim cov')
kcoadd = enmap.enmap(np.load("%skcoadd_%s.npy" % (droot,qid)),wcs)
p2d = np.real(kcoadd*kcoadd.conj())/w2
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='data power',ls='--')
p2d = enmap.enmap(np.load("%stilec_hybrid_covariance_%s_%s.npy" % (droot,qid,qid)),wcs)
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='data cov',ls='--')
p2d = enmap.read_fits("/scratch/r/rbond/msyriac/dump/smoothed_beamed_%s_%s.fits" % (qid,qid))
cents,p1d = binner.bin(p2d)
pl.add(cents,p1d,label='sim S cov smoothed',ls='--')
pl._ax.set_xlim(10,1000)
pl._ax.set_ylim(1e-3,10)
pl.vline(x=80)
pl.done("lfi_power_comp_%s.png" % qid)
|
{"hexsha": "921a7ed82b5fc3a6a789280b3fa358024cf969f6", "size": 2405, "ext": "py", "lang": "Python", "max_stars_repo_path": "bin/debug_lfi.py", "max_stars_repo_name": "ACTCollaboration/tilec", "max_stars_repo_head_hexsha": "11ed8d027ad6ffac09b3e291a047f33e97673f14", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-04T14:51:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-04T14:51:44.000Z", "max_issues_repo_path": "bin/debug_lfi.py", "max_issues_repo_name": "ACTCollaboration/tilec", "max_issues_repo_head_hexsha": "11ed8d027ad6ffac09b3e291a047f33e97673f14", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-09-03T22:19:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-13T12:38:08.000Z", "max_forks_repo_path": "bin/debug_lfi.py", "max_forks_repo_name": "ACTCollaboration/tilec", "max_forks_repo_head_hexsha": "11ed8d027ad6ffac09b3e291a047f33e97673f14", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-10T14:51:11.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-10T14:51:11.000Z", "avg_line_length": 30.8333333333, "max_line_length": 97, "alphanum_fraction": 0.6794178794, "include": true, "reason": "import numpy", "num_tokens": 870}
|
#! /usr/bin/env python3
from Planet import *
import Universe
import ui
from random import randint
import numpy as np
import pygame
from pygame.locals import *
# name pos vel radius color surface_gravity
p1 = Planet("walnut", (640, 360), (2, 0), 50, (0, 0, 255), 7000)
p2 = Planet("bruh", (640, 450), (-400, 0), 15, (0, 255, 0), 10)
p3 = Planet("raq", (800, 200), (-200, -200), 30, (255, 0, 0), 200)
p4 = Planet("moon", (800, 155), (-290, -160), 5, (115, 115, 115), 50)
p5 = Planet("luis", (700, 255), (-290, -160), 5, (115, 115, 115), 50)
all_planets: [Planet] = [p1, p2, p3, p4, p5]
radius: int = 20
def rand_color():
return (randint(0, 255), randint(0, 255), randint(0, 255))
#--------------#
# pygame stuff #
#--------------#
pygame.init()
pygame.font.init()
default_font = pygame.font.get_default_font()
font_renderer = pygame.font.Font(default_font, 12)
clock = pygame.time.Clock()
window = (1280, 720)
screen = pygame.display.set_mode(window)
center = (90, window[1] - 170)
box_pos = (10, window[1] - 250)
angle = (center[0], center[1] - 70)
box = ui.draw_planet_picker(box_pos, center, (115,115,115), (75,75,75), screen)
multiplier: float = 0
last_event = 0
running = True
pause = True
while running:
screen.fill((0, 0, 0))
dt = clock.tick()
last_event += dt
# draw connecting lines between planets
# ui.draw_planet_connecting_lines(all_planets, (255,255,255), screen)
# do physics on all planets
for planet in all_planets:
if (not pause):
planet.update_velocity(all_planets, Universe.TIME_STEP)
planet.update_position(Universe.TIME_STEP)
pygame.draw.circle(screen, planet.get_color(), planet.get_pos(), planet.get_radius())
pygame.draw.line(screen, (115, 115, 115), planet.get_pos(), vec_add(planet.get_pos(), vec_mul(planet.get_vel(), 30)))
text = font_renderer.render(planet.name, True, (255, 255, 255))
screen.blit(text, planet.get_pos())
# box = pygame.draw.rect(screen, (115, 115, 115), (10, window[1] - 260, 160, window[1] - 10))
# pygame.draw.circle(screen, (75, 75, 75), box_pos, 70)
angle = ui.planet_picker(box_pos, angle, (115,115,115), (75,75,75), screen)
# draw circle around cursor
if (box.collidepoint(pygame.mouse.get_pos()) == False):
pygame.draw.circle(screen, (255, 255, 255), pygame.mouse.get_pos(), radius, width=1)
if (pygame.mouse.get_pressed()[0] and last_event > 250):
all_planets.append(Planet("unnamed", pygame.mouse.get_pos(), vec_mul(vec_nrm(vec_sub(angle, center)), randint(100, 400)), radius, rand_color(), 15))
last_event = 0
# flip the display
pygame.display.flip()
# check if user closed game
for event in pygame.event.get():
if event.type == QUIT:
print("quitting game...")
running = False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
if event.key == K_SPACE:
pause ^= 1
elif event.type == MOUSEBUTTONDOWN:
if event.button == 4:
radius += 2
if event.button == 5:
if (radius - 2) > 0:
radius -= 2
pygame.quit()
|
{"hexsha": "8f471e95b22439266150a180371b76a46af0c6c9", "size": 3332, "ext": "py", "lang": "Python", "max_stars_repo_path": "py_impl/space.py", "max_stars_repo_name": "taidanh/space-simulation", "max_stars_repo_head_hexsha": "fa116c12dc5b90c8f64cad4c6f70c116cae211f5", "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": "py_impl/space.py", "max_issues_repo_name": "taidanh/space-simulation", "max_issues_repo_head_hexsha": "fa116c12dc5b90c8f64cad4c6f70c116cae211f5", "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": "py_impl/space.py", "max_forks_repo_name": "taidanh/space-simulation", "max_forks_repo_head_hexsha": "fa116c12dc5b90c8f64cad4c6f70c116cae211f5", "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.4339622642, "max_line_length": 161, "alphanum_fraction": 0.593637455, "include": true, "reason": "import numpy", "num_tokens": 973}
|
# International_Standard.py:
# Created: Mar, 2014, SUAVE Team
# Modified: Jan, 2016, M. Vegh
# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------
import numpy as np
from SUAVE.Attributes.Atmospheres import Atmosphere
from SUAVE.Attributes.Gases import Air
from SUAVE.Attributes.Atmospheres.Earth import US_Standard_1976
# ----------------------------------------------------------------------
# Classes
# ----------------------------------------------------------------------
# from background research, this appears true
class International_Standard(US_Standard_1976):
""" International_Standard.py: International Standard Atmosphere (ISO2533:1975) """
def __defaults__(self):
self.tag = 'International Standard Atmosphere'
# ----------------------------------------------------------------------
|
{"hexsha": "d0ee6cd5703765b7e12ed1bbf8f1582174417b33", "size": 931, "ext": "py", "lang": "Python", "max_stars_repo_path": "References/Geovana Neves/TCC_Geovana_Neves_GitHub/SUAVE_modifications/SUAVE-feature-constant_throttle_EAS/trunk/SUAVE/Attributes/Atmospheres/Earth/International_Standard.py", "max_stars_repo_name": "Vinicius-Tanigawa/Undergraduate-Research-Project", "max_stars_repo_head_hexsha": "e92372f07882484b127d7affe305eeec2238b8a9", "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": "References/Geovana Neves/TCC_Geovana_Neves_GitHub/SUAVE_modifications/SUAVE-feature-constant_throttle_EAS/trunk/SUAVE/Attributes/Atmospheres/Earth/International_Standard.py", "max_issues_repo_name": "Vinicius-Tanigawa/Undergraduate-Research-Project", "max_issues_repo_head_hexsha": "e92372f07882484b127d7affe305eeec2238b8a9", "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": "References/Geovana Neves/TCC_Geovana_Neves_GitHub/SUAVE_modifications/SUAVE-feature-constant_throttle_EAS/trunk/SUAVE/Attributes/Atmospheres/Earth/International_Standard.py", "max_forks_repo_name": "Vinicius-Tanigawa/Undergraduate-Research-Project", "max_forks_repo_head_hexsha": "e92372f07882484b127d7affe305eeec2238b8a9", "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.8076923077, "max_line_length": 87, "alphanum_fraction": 0.4672395274, "include": true, "reason": "import numpy", "num_tokens": 156}
|
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2018, Bielefeld University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Bielefeld University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Authors: Robert Haschke */
#include <moveit/task_constructor/stages/simple_grasp.h>
#include <moveit/task_constructor/stages/compute_ik.h>
#include <moveit/task_constructor/stages/modify_planning_scene.h>
#include <moveit/task_constructor/stages/move_to.h>
#include <moveit/task_constructor/solvers/joint_interpolation.h>
#include <moveit/planning_scene/planning_scene.h>
#include <Eigen/Geometry>
#include <eigen_conversions/eigen_msg.h>
namespace moveit {
namespace task_constructor {
namespace stages {
SimpleGraspBase::SimpleGraspBase(const std::string& name) : SerialContainer(name) {
PropertyMap& p = properties();
p.declare<std::string>("eef", "end-effector to grasp with");
p.declare<std::string>("object", "object to grasp");
}
// TODO: Use AttachedBody's detach_posture_ to store the inverse grasping trajectory to re-open the gripper.
void SimpleGraspBase::setup(std::unique_ptr<Stage>&& generator, bool forward) {
// properties provided by the grasp generator via its Interface or its PropertyMap
const std::set<std::string>& grasp_prop_names = { "object", "eef", "pregrasp", "grasp" };
// insert children at end / front, i.e. normal or reverse order
int insertion_position = forward ? -1 : (generator ? 1 : 0);
if (generator) {
// forward properties from generator's to IK's solution (bottom -> up)
generator->setForwardedProperties(grasp_prop_names);
// allow inheritance in top -> down fashion as well
generator->properties().configureInitFrom(Stage::PARENT, { "object", "eef" });
auto ik = new ComputeIK("compute ik", std::move(generator));
ik->setForwardedProperties(grasp_prop_names); // continue forwarding generator's properties
PropertyMap& p = ik->properties();
p.declare<std::string>("object");
p.configureInitFrom(Stage::INTERFACE, { "target_pose" }); // derived from child's solution
p.configureInitFrom(Stage::PARENT, { "max_ik_solutions", "timeout", "object" }); // derived from parent
p.configureInitFrom(Stage::PARENT | Stage::INTERFACE, { "eef", "ik_frame" }); // derive from both
p.exposeTo(properties(), { "max_ik_solutions", "timeout", "ik_frame" });
insert(std::unique_ptr<ComputeIK>(ik), 0); // ComputeIK always goes upfront
}
{
auto allow_touch = new ModifyPlanningScene(forward ? "allow object collision" : "forbid object collision");
allow_touch->setForwardedProperties(grasp_prop_names); // continue forwarding generator's properties
PropertyMap& p = allow_touch->properties();
p.declare<std::string>("eef");
p.declare<std::string>("object");
p.configureInitFrom(Stage::PARENT | Stage::INTERFACE, { "eef", "object" });
allow_touch->setCallback([forward](const planning_scene::PlanningScenePtr& scene, const PropertyMap& p) {
collision_detection::AllowedCollisionMatrix& acm = scene->getAllowedCollisionMatrixNonConst();
const std::string& eef = p.get<std::string>("eef");
const std::string& object = p.get<std::string>("object");
acm.setEntry(object, scene->getRobotModel()->getEndEffector(eef)->getLinkModelNamesWithCollisionGeometry(),
forward);
});
insert(std::unique_ptr<ModifyPlanningScene>(allow_touch), insertion_position);
}
{
auto planner = std::make_shared<solvers::JointInterpolationPlanner>();
auto move = new MoveTo(forward ? "close gripper" : "open gripper", planner);
move->setForwardedProperties(grasp_prop_names); // continue forwarding generator's properties
auto group_initializer = [this](const PropertyMap& parent_map) -> boost::any {
const std::string& eef = parent_map.get<std::string>("eef");
const moveit::core::JointModelGroup* jmg = model_->getEndEffector(eef);
return jmg->getName();
};
PropertyMap& p = move->properties();
p.property("group").configureInitFrom(Stage::PARENT | Stage::INTERFACE, group_initializer);
p.property("goal").configureInitFrom(Stage::PARENT | Stage::INTERFACE, forward ? "grasp" : "pregrasp");
p.exposeTo(properties(), { "group", "goal" });
insert(std::unique_ptr<MoveTo>(move), insertion_position);
}
{
auto attach = new ModifyPlanningScene(forward ? "attach object" : "detach object");
attach->setForwardedProperties(grasp_prop_names); // continue forwarding generator's properties
PropertyMap& p = attach->properties();
p.declare<std::string>("eef");
p.declare<std::string>("object");
p.configureInitFrom(Stage::PARENT | Stage::INTERFACE, { "eef", "object" });
attach->setCallback([forward](const planning_scene::PlanningScenePtr& scene, const PropertyMap& p) {
const std::string& eef = p.get<std::string>("eef");
moveit_msgs::AttachedCollisionObject obj;
obj.object.operation =
forward ? (int8_t)moveit_msgs::CollisionObject::ADD : (int8_t)moveit_msgs::CollisionObject::REMOVE;
obj.link_name = scene->getRobotModel()->getEndEffector(eef)->getEndEffectorParentGroup().second;
obj.object.id = p.get<std::string>("object");
scene->processAttachedCollisionObjectMsg(obj);
});
insert(std::unique_ptr<ModifyPlanningScene>(attach), insertion_position);
}
}
void SimpleGraspBase::init(const moveit::core::RobotModelConstPtr& robot_model) {
model_ = robot_model;
SerialContainer::init(robot_model);
}
void SimpleGraspBase::setIKFrame(const Eigen::Isometry3d& pose, const std::string& link) {
geometry_msgs::PoseStamped pose_msg;
pose_msg.header.frame_id = link;
tf::poseEigenToMsg(pose, pose_msg.pose);
setIKFrame(pose_msg);
}
SimpleGrasp::SimpleGrasp(std::unique_ptr<Stage>&& generator, const std::string& name) : SimpleGraspBase(name) {
setup(std::move(generator), true);
}
SimpleUnGrasp::SimpleUnGrasp(std::unique_ptr<Stage>&& generator, const std::string& name) : SimpleGraspBase(name) {
setup(std::move(generator), false);
}
} // namespace stages
} // namespace task_constructor
} // namespace moveit
|
{"hexsha": "a07ebdc795996c06fe3fd93b4341e21c2429c940", "size": 7602, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "core/src/stages/simple_grasp.cpp", "max_stars_repo_name": "cpt-yoshi/moveit_task_constructor", "max_stars_repo_head_hexsha": "4aeab27ba3bed47453ffab0b454eb6eb09b54e4f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6.0, "max_stars_repo_stars_event_min_datetime": "2018-08-13T12:55:18.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-18T19:56:21.000Z", "max_issues_repo_path": "core/src/stages/simple_grasp.cpp", "max_issues_repo_name": "cpt-yoshi/moveit_task_constructor", "max_issues_repo_head_hexsha": "4aeab27ba3bed47453ffab0b454eb6eb09b54e4f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 20.0, "max_issues_repo_issues_event_min_datetime": "2017-11-13T08:40:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T13:54:17.000Z", "max_forks_repo_path": "core/src/stages/simple_grasp.cpp", "max_forks_repo_name": "cpt-yoshi/moveit_task_constructor", "max_forks_repo_head_hexsha": "4aeab27ba3bed47453ffab0b454eb6eb09b54e4f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8.0, "max_forks_repo_forks_event_min_datetime": "2020-11-27T12:36:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-25T07:18:34.000Z", "avg_line_length": 46.9259259259, "max_line_length": 115, "alphanum_fraction": 0.7249408051, "num_tokens": 1866}
|
[STATEMENT]
lemma set_foldr_Cons:
"set (foldr (\<lambda>x xs. if P x xs then x # xs else xs) as []) \<subseteq> set as"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (foldr (\<lambda>x xs. if P x xs then x # xs else xs) as []) \<subseteq> set as
[PROOF STEP]
by(induct as) auto
|
{"llama_tokens": 115, "file": "Containers_RBT_Set2", "length": 1}
|
from torchvision import datasets, transforms
from base import BaseDataLoader
import torch.utils.data as Data
import scipy.io
import torch
# MNIST数据集
class MnistDataLoader(BaseDataLoader):
"""
MNIST data loading demo using BaseDataLoader
"""
def __init__(self, data_dir, batch_size, shuffle=True, validation_split=0.0, num_workers=1, training=True):
trsfm = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))
])
self.data_dir = data_dir
self.dataset = datasets.MNIST(self.data_dir, train=training, download=True, transform=trsfm)
super().__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
# MIT-BIH数据集
class MitbihDataLoader(BaseDataLoader):
def __init__(self, data_dir, batch_size, shuffle=True, validation_split=0.0, num_workers=1, training=True):
self.data_dir = data_dir
data = scipy.io.loadmat(self.data_dir)
if training:
x = torch.from_numpy(data['X_train'])
y = torch.from_numpy(data['Y_train']).permute(1, 0)
else:
x = torch.from_numpy(data['X_test'])
y = torch.from_numpy(data['Y_test']).permute(1, 0)
x = x.float()
x = x.permute(0, 2, 1)
# x = x.reshape(-1, 1, x.shape[1], x.shape[2])
y = y.squeeze()
y = y.long()
self.dataset = Data.TensorDataset(x, y)
super().__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
|
{"hexsha": "6cbb7ce9f8b562e46af01beb58565c1b5f04d243", "size": 1530, "ext": "py", "lang": "Python", "max_stars_repo_path": "data_loader/data_loaders.py", "max_stars_repo_name": "Liut2016/ecg-ssl", "max_stars_repo_head_hexsha": "c7092f0eb079199066b6dd733280cf7308932918", "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": "data_loader/data_loaders.py", "max_issues_repo_name": "Liut2016/ecg-ssl", "max_issues_repo_head_hexsha": "c7092f0eb079199066b6dd733280cf7308932918", "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": "data_loader/data_loaders.py", "max_forks_repo_name": "Liut2016/ecg-ssl", "max_forks_repo_head_hexsha": "c7092f0eb079199066b6dd733280cf7308932918", "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.3170731707, "max_line_length": 111, "alphanum_fraction": 0.6477124183, "include": true, "reason": "import scipy", "num_tokens": 389}
|
#!/usr/bin/env python
# coding: utf-8
# <img src="imagenes/rn3.png" width="200">
# <img src="http://www.identidadbuho.uson.mx/assets/letragrama-rgb-150.jpg" width="200">
# # [Curso de Redes Neuronales](https://curso-redes-neuronales-unison.github.io/Temario/)
#
# # Una sola neurona logística
#
# [**Julio Waissman Vilanova**](http://mat.uson.mx/~juliowaissman/), 17 de septiembre de 2018.
#
# En esta libreta vamos a revisar los aspectos básicos del aprendizaje para una sola neurona de salida logística, sin capas ocultas y usando el criterio de pérdida de entropia en dos clases. El algoritmo es sencillo pero es importante entenderlo bien antes de pasar a cosas más complicadas.
#
# Empecemos por inicializar los modulos que vamos a requerir.
# In[ ]:
get_ipython().run_line_magic('matplotlib', 'inline')
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Image # Esto es para desplegar imágenes en la libreta
plt.rcParams['figure.figsize'] = (20,10)
plt.style.use('ggplot')
# ## 1. Función logística, función de pérdida y gradiente de la función de costo
# La función logística está dada por
#
# $$
# g(z) = \frac{1}{1 + e^{-z}},
# $$
#
# la cual es importante que podamos calcular en forma vectorial. Si bien el calculo es de una sola linea, el uso de estas funciones auxiliares facilitan la legibilidad del código.
#
# #### Desarrolla la función logística, la cual se calcule para todos los elementos de un ndarray.
# In[ ]:
def logistica(z):
"""
Calcula la función logística para cada elemento de z
@param z: un ndarray
@return: un ndarray de las mismas dimensiones que z
"""
# Introduce código aqui (una linea de código)
#---------------------------------------------------
return 1/(1 + np.exp(-z))
#---------------------------------------------------
# prueba que efectivamente funciona la función implementada
# si el assert es falso regresa un error de aserción (el testunit de los pobres)
assert (np.abs(logistica(np.array([-1, 0, 1])) - np.array([ 0.26894142, 0.5, 0.73105858]))).sum() < 1e-6
# Para probar la función vamos a graficar la función logística en el intervalo [-5, 5]
# In[ ]:
z = np.linspace(-5, 5, 100)
plt.plot( z, logistica(z))
plt.title(u'Función logística', fontsize=20)
plt.xlabel(r'$z$', fontsize=20)
plt.ylabel(r'$\frac{1}{1 + \exp(-z)}$', fontsize=26)
# Una vez establecida la función logística, vamos a implementar la función de pérdida *sin regularizar* que se utiliza típicamente en clasificación binaria, la cual está dada por
#
# $$
# Loss(w, b) = -\frac{1}{M} \sum_{i=1}^M \left[ y^{(i)}\log(a^{(i)}) + (1 - y^{(i)})\log(1 - a^{(i)})\right],
# $$
#
# donde
#
# $$
# a^{(i)} = g(z^{(i)}), \quad\quad z^{(i)} = w^T x^{(i)} + b
# $$
#
# las cuales fueron ecuaciones revisadas en clase.
#
# #### Implementa la función de pérdida para un conjunto de aprendizaje.
# In[ ]:
def Loss(x, y, w, b):
"""
Calcula el costo de una w dada para el conjunto dee entrenamiento dado por y y x
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param w: un ndarray de dimensión (n, ) con los pesos
@param b: un flotante con el sesgo
@return: un flotante con el valor de pérdida
"""
M = x.shape[0]
#------------------------------------------------------------------------
sigma = logistica(x @ w + b)
return (1/M)*(np.sum(-y*np.log(sigma)-(1-y)*np.log(1-sigma)))
#------------------------------------------------------------------------
# Otra vez el testunit del pobre (ya lo calcule yo, pero puedes hacerlo a mano para estar seguro)
w = np.array([1])
b = 1.0
x = np.array([[10],
[-5]])
y1 = np.array([1, 0])
y2 = np.array([0, 1])
y3 = np.array([0, 0])
y4 = np.array([1, 1])
assert abs(Loss(x, y1, w, b) - 0.01) < 1e-2
assert abs(Loss(x, y2, w, b) - 7.5) < 1e-2
assert abs(Loss(x, y3, w, b) - 5.5) < 1e-2
assert abs(Loss(x, y4, w, b) - 2.0) < 1e-2
# De la misma manera, para poder implementar las funciones de aprendizaje, vamos a implementar el gradiente de la función de pérdida. El gradiente de la función de pérdida respecto a $\omega$ es (como lo vimos en clase) el siguiente:
#
# $$
# \frac{\partial Loss(w, b)}{\partial w_j} = -\frac{1}{M} \sum_{i=1}^M \left(y^{(i)} - a^{(i)}\right)x_j^{(i)}
# $$
#
# $$
# \frac{\partial Loss(w, b)}{\partial b} = -\frac{1}{M} \sum_{i=1}^M \left(y^{(i)} - a^{(i)}\right)
# $$
#
# y a partir de las ecuaciones individuales de puede obtener $\nabla Loss(\omega)$, la cual no la vamos a escribir en la libreta para que revisen en sus notas como se puede resolver este problema en forma matricial.
#
# #### IImplementa (con operaciones matriciales) el calculo del gradiente de la función de pérdida.
# In[ ]:
def gradiente(x, y, w, b):
"""
Calcula el gradiente de la función de pérdida para clasificación binaria,
utilizando una neurona logística, para w y b y conociendo un conjunto de aprendizaje.
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param w: un ndarray de dimensión (n, ) con los pesos
@param b: un flotante con el sesgo
@return: dw, db, un ndarray de mismas dimensiones que w y un flotnte con el cálculo de
la dervada evluada en el punto w y b
"""
M = x.shape[0]
#------------------------------------------------------------------------
# Agregua aqui tu código
a = logistica(x @ w + b)
e = y-a
return -x.T @ e / M, -e.mean()
#------------------------------------------------------------------------
return dw, db
# Otra vez el testunit del pobre (ya lo calcule yo, pero puedes hacerlo a mano para estar seguro)
w = np.array([1])
b = 1.0
x = np.array([[10],
[-5]])
y1 = np.array([1, 0])
y2 = np.array([0, 1])
y3 = np.array([0, 0])
y4 = np.array([1, 1])
assert abs(0.00898475 - gradiente(x, y1, w, b)[1]) < 1e-4
assert abs(7.45495097 - gradiente(x, y2, w, b)[0]) < 1e-4
assert abs(4.95495097 - gradiente(x, y3, w, b)[0]) < 1e-4
assert abs(-0.49101525 - gradiente(x, y4, w, b)[1]) < 1e-4
# ## 2. Descenso de gradiente
# Ahora vamos a desarrollar las funciones necesarias para realizar el entrenamiento y encontrar la mejor $\omega$ de acuero a la función de costos y un conjunto de datos de aprendizaje.
#
# Para este problema, vamos a utilizar una base de datos sintética proveniente del curso de [Andrew Ng](www.andrewng.org/) que se encuentra en [Coursera](https://www.coursera.org). Supongamos que pertenecemos al departamente de servicios escolares de la UNISON y vamos a modificar el procedimiento de admisión. En lugar de utilizar un solo exámen (EXCOBA) y la información del cardex de la preparatoria, hemos decidido aplicar dos exámenes, uno sicométrico y otro de habilidades estudiantiles. Dichos exámenes se han aplicado el último año aunque no fueron utilizados como criterio. Así, tenemos un historial entre estudiantes aceptados y resultados de los dos exámenes. El objetivo es hacer un método de regresión que nos permita hacer la admisión a la UNISON tomando en cuenta únicamente los dos exámenes y simplificar el proceso. *Recuerda que esto no es verdad, es solo un ejercicio*.
#
# Bien, los datos se encuentran en el archivo `admision.txt` el cual se encuentra en formato `cvs` (osea los valores de las columnas separados por comas. Vamos a leer los datos y graficar la información para entender un poco los datos.
# In[ ]:
datos = np.loadtxt('datos/admision.txt', comments='%', delimiter=',')
x, y = datos[:,0:-1], datos[:,-1]
plt.plot(x[y == 1, 0], x[y == 1, 1], 'sr', label='aceptados')
plt.plot(x[y == 0, 0], x[y == 0, 1], 'ob', label='rechazados')
plt.title(u'Ejemplo sintético para regresión logística')
plt.xlabel(u'Calificación del primer examen')
plt.ylabel(u'Calificación del segundo examen')
plt.axis([20, 100, 20, 100])
plt.legend(loc=0)
# Vistos los datos un clasificador lineal podría ser una buena solución. Ahora vamos a implementar el método de descenso de gradiente, casi de la misma manera que lo implementamos para regresión lineal (por lotes)
#
# #### Implementa el descenso de gradiente para el problema de regresión logística en modo batch.
# In[ ]:
def descenso_rl_lotes(x, y, alpha, max_iter=int(1e4), tol=1e-4, historial=False):
"""
Descenso de gradiente por lotes para resolver el problema de regresión logística con un conjunto de aprendizaje
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param alpha: Un flotante (típicamente pequeño) con la tasa de aprendizaje
@param tol: Un flotante pequeño como criterio de paro. Por default 1e-4
@param max_iter: Máximo numero de iteraciones. Por default 1e4
@param historial: Un booleano para saber si guardamos el historial de la función de pérdida o no
@return: w, b, perdida_hist donde w es ndarray de dimensión (n, ) con los pesos; el flotante b
con el sesgo y perdida_hist, un ndarray de dimensión (max_iter,) con el valor de la función
de pérdida en cada iteración. Si historial == True, entonces perdida_hist = None.
"""
M, n = x.shape
w = np.zeros(n)
b = 0.0
if historial:
perdida_hist = np.zeros(max_iter)
perdida_hist[0] = Loss(x, y, w, b)
else:
perdida_hist = None
for epoch in range(1, max_iter):
#--------------------------------------------------------------
# Agregar aqui tu código
#
# Recuerda utilizar las funciones que ya has desarrollado
J = Loss ( x, y, w, b)
dw,db = gradiente(x,y,w,b)
w+= -dw*alpha
b+= -db*alpha
if J < tol:
return w, b, perdida_hist
if historial:
perdida_hist[epoch] = J
#--------------------------------------------------------------
return w, b, perdida_hist
# Para probar la función de aprendizaje, vamos a aplicarla a nuestro problema de admisión. Primero recuerda que tienes que hacer una exploración para encontrar el mejor valor de $\epsilon$. Así que utiliza el código de abajo para ajustar $\alpha$.
# In[ ]:
alpha = 1e-6
mi = 50
_, _, perdida_hist = descenso_rl_lotes(x, y, alpha, max_iter=mi, tol=1e-4, historial=True)
plt.plot(np.arange(mi), perdida_hist)
plt.title(r'Evolucion del valor de la función de pérdida en las primeras iteraciones con $\alpha$ = ' + str(alpha))
plt.xlabel('iteraciones')
plt.ylabel('perdida')
# Una vez encontrado el mejor $\epsilon$, entonces podemos calcular $\omega$ (esto va a tardar bastante), recuerda que el costo final debe de ser lo más cercano a 0 posible, así que agrega cuantas iteraciones sean necesarias (a partir de una función de pérdida con un valor de al rededor de 0.22 ya está bien):
# In[ ]:
w, b, _ = descenso_rl_lotes(x, y, alpha, max_iter = 1000000)
print("Los pesos obtenidos son: \n{}".format(w))
print("El sesgo obtenidos es: \n{}".format(b))
print("El valor final de la función de pérdida es: {}".format(Loss(x, y, w, b)))
# Es interesante ver como el descenso de gradiente no es muy eficiente en este tipo de problemas, a pesar de ser problemas de optimización convexos.
#
# Bueno, este método nos devuelve $\omega$, pero esto no es suficiente para decir que tenemos un clasificador, ya que un método de clasificación se compone de dos métodos, uno para **aprender** y otro para **predecir**.
#
# Recuerda que $a^{(i)} = \Pr[y^{(i)} = 1 | x^{(i)} ; w, b]$, y a partir de esta probabilidad debemos tomar una desición. Igualmente recuerda que para tomar la desicion no necesitamos calcular el valor de la logística, si conocemos el umbral.
# #### Desarrolla una función de predicción.
# In[ ]:
def predictor(x, w, b):
"""
Predice los valores de y_hat (que solo pueden ser 0 o 1), utilizando el criterio MAP.
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param w: un ndarray de dimensión (n, ) con los pesos
@param b: un flotante con el sesgo
@return: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0 con la salida estimada
"""
#-------------------------------------------------------------------------------------
# Agrega aqui tu código sin utilizar la función logística
salida_estimada = x @ w + b
return salida_estimada >= 0.5
#--------------------------------------------------------------------------------------
# ¿Que tan bueno es este clasificador? ¿Es que implementamos bien el método?
#
# Vamos a contestar esto por partes. Primero, vamos a graficar los mismos datos pero vamos a agregar la superficie de separación, la cual en este caso sabemos que es una linea recta. Como sabemos el criterio para decidir si un punto pertenece a la clase distinguida o no es si el valor de $w^T x^{(i)} + b \ge 0$, por lo que la frontera entre la región donde se escoge una clase de otra se encuentra en:
#
# $$
# 0 = b + w_1 x_1 + w_2 x_2,
# $$
#
# y despejando:
#
# $$
# x_2 = -\frac{b}{w_2} -\frac{w_1}{w_2}x_1
# $$
#
# son los pares $(x_1, x_2)$ los valores en la forntera. Al ser estos (en este caso) una linea recta solo necesitamos dos para graficar la superficie de separación.
#
# In[ ]:
x1_frontera = np.array([20, 100]) #Los valores mínimo y máximo que tenemos en la gráfica de puntos
x2_frontera = -(b / w[1]) - (w[0] / w[1]) * x1_frontera
plt.plot(x[y == 1, 0], x[y == 1, 1], 'sr', label='aceptados')
plt.plot(x[y == 0, 0], x[y == 0, 1], 'ob', label='rechazados')
plt.plot(x1_frontera, x2_frontera, 'm')
plt.title(u'Ejemplo sintético para regresión logística')
plt.xlabel(u'Calificación del primer examen')
plt.ylabel(u'Calificación del segundo examen')
plt.axis([20, 100, 20, 100])
plt.legend(loc=0)
# Y para que tengas una idea de lo que debería de salir, anexo una figura obtenida con el código que yo hice:
# In[ ]:
Image(filename='imagenes/ejemplo_logistica.png')
# ## 3. Clasificación polinomial
#
# Como podemos ver en la gráfica de arriba, parece ser que la regresión logística aceptaría a algunos estudiantes rechazados y rechazaría a algunos que si fueron en realidad aceptados. En todo método de clasificación hay un grado de error, y eso es parte del poder de generalización de los métodos.
#
# Sin embargo, una simple inspección visual muestra que, posiblemente, la regresión lineal no es la mejor solución, ya que la frontera entre las dos clases parece ser más bien una curva.
#
# ¿Que tal si probamos con un clasificador cuadrático? Un clasificador cuadrático no es más que la regresión lineal pero a la que se le agregan todos los atributos que sean una combinación de dos de los atributos.
#
# Por ejemplo, si un ejemplo $x = (x_1, x_2, x_3)^T$ se aumenta con todas sus componentes cuadráticas, entonces tenemos los atributos
#
# $$
# \phi_2(x) = (x_1, x_2, x_3, x_1 x_2, x_1 x_3, x_2 x_3, x_1^2, x_2^2, x_3^2)^T.
# $$
#
# De la misma manera se pueden obtener clasificadores de orden tres, cuatro, cinco, etc. En general a estos clasificadores se les conoce como **clasificadores polinomiales**. Ahora, para entender bien la idea, vamos a resolver el problema anterior con un clasificador de orden 2.
#
# Sin embargo, si luego se quiere hacer el reconocimiento de otros objetos, o cambiar el orden del polinomio, pues se requeriría de reclcular cada vez la expansión polinomial. Vamos a generalizar la obtención de atributos polinomiales con la función `map_poly`, la cual la vamos a desarrollar a continuación.
#
# En este caso, la normalización de los datos es muy importante, por lo que se agregan las funciones pertinentes.
#
# In[ ]:
from itertools import combinations_with_replacement
def map_poly(grad, x):
"""
Encuentra las características polinomiales hasta el grado grad de la matriz de datos x,
asumiendo que x[:n, 0] es la expansión de orden 1 (los valores de cada atributo)
@param grad: un entero positivo con el grado de expansión
@param x: un ndarray de dimension (M, n) donde n es el número de atributos
@return: un ndarray de dimensión (M, n_phi) donde
n_phi = \sum_{i = 1}^grad fact(i + n - 1)/(fact(i) * fact(n - 1))
"""
if int(grad) < 2:
raise ValueError('grad debe de ser mayor a 1')
M, n = x.shape
atrib = x.copy()
x_phi = x.copy()
for i in range(2, int(grad) + 1):
for comb in combinations_with_replacement(range(n), i):
x_phi = np.c_[x_phi, np.prod(atrib[:, comb], axis=1)]
return x_phi
def medias_std(x):
"""
Obtiene un vector de medias y desviaciones estandar para normalizar
@param x: Un ndarray de (M, n) con una matriz de diseño
@return: mu, des_std dos ndarray de dimensiones (n, ) con las medias y desviaciones estandar
"""
return np.mean(x, axis=0), np.std(x, axis=0)
def normaliza(x, mu, des_std):
"""
Normaliza los datos x
@param x: un ndarray de dimension (M, n) con la matriz de diseño
@param mu: un ndarray (n, ) con las medias
@param des_std: un ndarray (n, ) con las desviaciones estandard
@return: un ndarray (M, n) con x normalizado
"""
return (x - mu) / des_std
# **Realiza la clasificación de los datos utilizando un clasificador cuadrático (recuerda ajustar primero el valor de $\alpha$)**
# In[ ]:
# Encuentra phi_x (x son la expansión polinomial de segundo orden, utiliza la función map_poly
phi_x = map_poly(2, x) #--Agrega el código aqui--
mu, de = medias_std(phi_x)
phi_x_norm = normaliza(phi_x, mu, de)
# Utiliza la regresión logística
alpha = 1 #--Agrega el dato aqui--
max_iter = 50#--Agrega el dato aqui--
_, _, hist_loss = descenso_rl_lotes(phi_x_norm, y, alpha, max_iter, historial=True)
plt.plot(range(len(hist_loss)), hist_loss)
plt.xlabel('epochs')
plt.ylabel('Loss')
plt.title('Evaluación del parámetro alpha')
# In[ ]:
w_norm, b_norm, _ = descenso_rl_lotes(phi_x_norm, y, alpha, 1000)
print("Los pesos obtenidos son: \n{}".format(w_norm))
print("El sesgo obtenidos es: \n{}".format(b_norm))
print("El valor final de la función de pérdida es: {}".format(Loss(phi_x_norm, y, w_norm, b_norm)))
# donde se puede encontrar un valor de pérdida de aproximadamente 0.03.
#
# Esto lo tenemos que graficar. Pero graficar la separación de datos en una proyección en las primeras dos dimensiones, no es tan sencillo como lo hicimos con una separación lineal, así que vamos atener que generar un `contour`, y sobre este graficar los datos. Para esto vamos a desarrollar una función.
# In[ ]:
def plot_separacion2D(x, y, grado, mu, de, w, b):
"""
Grafica las primeras dos dimensiones (posiciones 1 y 2) de datos en dos dimensiones
extendidos con un clasificador polinomial así como la separación dada por theta_phi
"""
if grado < 2:
raise ValueError('Esta funcion es para graficar separaciones con polinomios mayores a 1')
x1_min, x1_max = np.min(x[:,0]), np.max(x[:,0])
x2_min, x2_max = np.min(x[:,1]), np.max(x[:,1])
delta1, delta2 = (x1_max - x1_min) * 0.1, (x2_max - x2_min) * 0.1
spanX1 = np.linspace(x1_min - delta1, x1_max + delta1, 600)
spanX2 = np.linspace(x2_min - delta2, x2_max + delta2, 600)
X1, X2 = np.meshgrid(spanX1, spanX2)
X = normaliza(map_poly(grado, np.c_[X1.ravel(), X2.ravel()]), mu, de)
Z = predictor(X, w, b)
Z = Z.reshape(X1.shape[0], X1.shape[1])
# plt.contour(X1, X2, Z, linewidths=0.2, colors='k')
plt.contourf(X1, X2, Z, 1, cmap=plt.cm.binary_r)
plt.plot(x[y > 0.5, 0], x[y > 0.5, 1], 'sr', label='clase positiva')
plt.plot(x[y < 0.5, 0], x[y < 0.5, 1], 'oy', label='clase negativa')
plt.axis([spanX1[0], spanX1[-1], spanX2[0], spanX2[-1]])
# Y ahora vamos a probar la función `plot_separacion2D` con los datos de entrenamiento. El comando tarda, ya que estamos haciendo un grid de 200 $\times$ 200, y realizando evaluaciones individuales.
# In[ ]:
plot_separacion2D(x, y, 2, mu, de, w_norm, b_norm)
plt.title(u"Separación con un clasificador cuadrático")
plt.xlabel(u"Calificación del primer examen")
plt.ylabel(u"Calificación del segundo examen")
# Y para dar una idea de lo que debería de salir, anexo una figura tal como me salió a mi
# In[ ]:
Image(filename='imagenes/ejemplo_cuad.png')
# Como podemos ver, un clasificador polinomial de orden 2 clasifica mejor los datos de aprendizaje, y además parece suficientemente simple para ser la mejor opción para hacer la predicción. Claro, esto lo sabemos porque pudimos visualizar los datos, y en el fondo estamos haciendo trampa, al seleccionar la expansión polinomial a partir de una inspección visual de los datos.
#
# Tomemos ahora una base de datos que si bien es sintética es representativa de una familia de problemas a resolver. Supongamos que estámos opimizando la fase de pruebas dentro de la linea de producción de la empresa Microprocesadores del Noroeste S.A. de C.V.. La idea es reducir el banco de pruebas de cada nuevo microprocesador fabricado y en lugar de hacer 50 pruebas, reducirlas a 2. En el conjunto de datos tenemos los valores que obtuvo cada componente en las dos pruebas seleccionadas, y la decisión que se tomo con cada dispositivo (esta desición se tomo con el banco de 50 reglas). Los datos los podemos visualizar a continuación.
# In[ ]:
datos = np.loadtxt('datos/prod_test.txt', comments='%', delimiter=',')
x, y = datos[:,0:-1], datos[:,-1]
plt.plot(x[y == 1, 0], x[y == 1, 1], 'or', label='cumple calidad')
plt.plot(x[y == 0, 0], x[y == 0, 1], 'ob', label='rechazado')
plt.title(u'Ejemplo de pruebas de un producto')
plt.xlabel(u'Valor obtenido en prueba 1')
plt.ylabel(u'Valor obtenido en prueba 2')
#plt.axis([20, 100, 20, 100])
plt.legend(loc=0)
# Cláramente este problema no se puede solucionar con un clasificador lineal (1 orden), por lo que hay que probar otros tipos de clasificadores.
#
# **Completa el código para hacer regresión polinomial para polinomios de orden 2, 4, 6 y 8, y muestra los resultados en una figura. Recuerda que este ejercicio puede tomar bastante tiempo de cómputo. Posiblemente tengas que hacer ajustes en el código para manejar diferentes valores de alpha y max_iter de acuerdo a cada caso**
# In[ ]:
for (i, grado) in enumerate([2, 6, 10, 14]):
# Genera la expansión polinomial
# --- Agregar código aquí ---
phi_x = map_poly(grado,x)
# Normaliza
# --- Agregar código aquí ---
mean, std = medias_std(phi_x)
phi_x_norm = normaliza(phi_x, mean, std)
# Entrena
# --- Agregar código aquí ---
alpha = 0.1
max_iter = 60000
w_norm, b_norm, perdida_h = descenso_rl_lotes(phi_x_norm, y, alpha, max_iter)
# Muestra resultados con plot_separacion2D
plt.subplot(2, 2, i + 1)
plt.title("Polinomio de grado {}".format(grado))
# --- Agregar codigo aquí ---
plot_separacion2D(x, y, grado, mean, std, w_norm, b_norm)
# y un resultado parcial (no verifiqué el mínimo global en los cuatro casos) es el que pongo en la figura siguente:
# In[ ]:
Image(filename='imagenes/ejemplo_poly.png')
# ## 4. Regularización
#
# Como podemos ver del ejercicio anterior, es dificil determinar el grado del polinomio, y en algunos casos es demasiado general (subaprendizaje) y en otros demasiado específico (sobreaprendizaje). ¿Que podría ser la solución?, bueno, una solución posible es utilizar un polinomio de alto grado (o relativamente alto), y utilizar la **regularización** para controlar la generalización del algoritmo, a través de una variable $\lambda$.
#
# Recordemos, la función de costos de la regresión logística con regularización es:
#
# $$
# costo(w, b) = Loss(w, b) + \frac{\lambda}{M} regu(w),
# $$
#
# donde $regu(w)$ es una regularización, la cual puede ser $L_1$, $L_2$ u otras, tal como vimos en clase. Como en la libreta de regresión lineal ya algo se hizo con la regularización, aqui nos vamos a pasar directamente a calcular el costo, el gradiente regularizado y la modificación al método de descenso de grdiente por lotes que tenemos programado.
#
# **Completa el siguiente código, utilizando una regularización en $L_2$**
#
# In[ ]:
def costo(x, y, w, b, lambd):
"""
Calcula el costo de una w dada para el conjunto dee entrenamiento dado por y y x,
usando regularización
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param w: un ndarray de dimensión (n, ) con los pesos
@param b: un flotante con el sesgo
@param lambd: un flotante con el valor de lambda en la regularizacion
@return: un flotante con el valor de pérdida
"""
M = x.shape[0]
#------------------------------------------------------------------------
# Agregua aqui tu código
return Loss(x,y,w,b) + (lambd / M) * w.T @ w
#------------------------------------------------------------------------
def grad_regu(x, y, w, b, lambd):
"""
Calcula el gradiente de la función de costo regularizado para clasificación binaria,
utilizando una neurona logística, para w y b y conociendo un conjunto de aprendizaje.
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param w: un ndarray de dimensión (n, ) con los pesos
@param b: un flotante con el sesgo
@param lambd: un flotante con el peso de la regularización
@return: dw, db, un ndarray de mismas dimensiones que w y un flotnte con el cálculo de
la dervada evluada en el punto w y b
"""
M = x.shape[0]
#------------------------------------------------------------------------
# Agregua aqui tu código
a = logistica(x @ w + b)
e = y-a
return (-x.T @ e + lambd*w)/ M, -e.mean()
#------------------------------------------------------------------------
return dw, db
def desc_lotes_regu(x, y, alpha, lambd, max_iter=int(1e4), tol=1e-4, historial=False):
"""
Descenso de gradiente por lotes para resolver el problema de regresión logística con un conjunto de aprendizaje
@param x: un ndarray de dimensión (M, n) con la matriz de diseño
@param y: un ndarray de dimensión (M, ) donde cada entrada es 1.0 o 0.0
@param alpha: Un flotante (típicamente pequeño) con la tasa de aprendizaje
@param lambd: Un flotante con el valor de la regularización
@param max_iter: Máximo numero de iteraciones. Por default 1e4
@param tol: Un flotante pequeño como criterio de paro. Por default 1e-4
@param historial: Un booleano para saber si guardamos el historial de la función de pérdida o no
@return: w, b, perdida_hist donde w es ndarray de dimensión (n, ) con los pesos; el flotante b
con el sesgo y perdida_hist, un ndarray de dimensión (max_iter,) con el valor de la función
de pérdida en cada iteración. Si historial == True, entonces perdida_hist = None.
"""
M, n = x.shape
w = 0 * np.random.random(n) - 0.1
b = 0 * np.random.random() - 0.1
if historial:
perdida_hist = np.zeros(max_iter)
perdida_hist[0] = costo(x, y, w, b, lambd)
else:
perdida_hist = None
for iter in range(1, max_iter):
#--------------------------------------------------------------
# Agregar aqui tu código
#
# Recuerda utilizar las funciones que ya has desarrollado
J = costo( x, y, w, b,lambd)
dw,db = grad_regu(x,y,w,b,lambd)
w+= -dw*alpha
b+= -db*alpha
if J < tol:
return w, b, perdida_hist
if historial:
perdida_hist[iter] = J
#--------------------------------------------------------------
return w, b, perdida_hist
#
# **Desarrolla las funciones y scriprs necesarios para realizar la regresión logística con un polinomio de grado 14 y con cuatro valores de regularización diferentes. Grafica la superficie de separación para cuatro valores diferentes de $\lambda$. Escribe tus conclusiones**
# In[ ]:
phi_x = map_poly(14, x)
mu, de = medias_std(phi_x)
phi_x_norm = normaliza(phi_x, mu, de)
for (i, lambd) in enumerate([0, 1, 10, 100]):
# Normaliza
# --- Agregar código aquí ---
# Entrena
# --- Agregar código aquí ---
w_norm, b_norm, perdida_hist = desc_lotes_regu(phi_x_norm, y, alpha, lambd, max_iter, historial=True)
# Muestra resultados con plot_separacion2D
plt.subplot(2, 2, i + 1)
plt.title("Polinomio de grado 14, regu = {}.".format(lambd))
# --- Agregar codigo aquí ---
plot_separacion2D(x, y, grado, mu, de, w_norm, b_norm)
# y tambien pongo unos resultados preliminares para que los contrasten con los suyos.
# In[ ]:
Image(filename='imagenes/ejemplo_regu.png')
|
{"hexsha": "9209415253b73d67124fcfb34fbf054c6afb1397", "size": 29266, "ext": "py", "lang": "Python", "max_stars_repo_path": "regresion-logistica/neurona_logistica.py", "max_stars_repo_name": "LuiGiovanni/LibretasRedesNeuronales", "max_stars_repo_head_hexsha": "31206dedea3880febd9d81179b2b3a29e21892b0", "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": "regresion-logistica/neurona_logistica.py", "max_issues_repo_name": "LuiGiovanni/LibretasRedesNeuronales", "max_issues_repo_head_hexsha": "31206dedea3880febd9d81179b2b3a29e21892b0", "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": "regresion-logistica/neurona_logistica.py", "max_forks_repo_name": "LuiGiovanni/LibretasRedesNeuronales", "max_forks_repo_head_hexsha": "31206dedea3880febd9d81179b2b3a29e21892b0", "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.2832214765, "max_line_length": 888, "alphanum_fraction": 0.6517118841, "include": true, "reason": "import numpy", "num_tokens": 8685}
|
# Copyright 2017 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
#
# 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.
# ==============================================================================
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.compiler.tests import xla_test
from tensorflow.python.platform import googletest
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
class Ipu64BitTest(xla_test.XLATestCase):
def testAdd(self):
with ops.device("/device:IPU:0"):
with self.session() as sess:
pa = array_ops.placeholder(np.int64, [2, 2], name="a")
pb = array_ops.placeholder(np.int64, [2, 2], name="b")
output = pa + pb
fd = {pa: [[1, 1], [2, 3]], pb: [[0, 1], [4, 5]]}
result = sess.run(output, fd)
self.assertAllClose(result, [[1, 2], [6, 8]])
fd = {pa: [[0, 0], [1, 1]], pb: [[2, 1], [4, 5]]}
result = sess.run(output, fd)
self.assertAllClose(result, [[2, 1], [5, 6]])
def testSubConstant(self):
with ops.device("/device:IPU:0"):
with self.session() as sess:
pa = array_ops.placeholder(np.int64, [2, 2], name="a")
pb = array_ops.constant([[1, 2], [3, 4]], dtype=np.int64)
output = pa - pb
fd = {pa: [[1, 1], [2, 3]]}
result = sess.run(output, fd)
self.assertAllClose(result, [[0, -1], [-1, -1]])
fd = {pa: [[0, 0], [4, 4]]}
result = sess.run(output, fd)
self.assertAllClose(result, [[-1, -2], [1, 0]])
if __name__ == "__main__":
googletest.main()
|
{"hexsha": "e3cf55f86a00966863061d07b54850d3922213a6", "size": 2165, "ext": "py", "lang": "Python", "max_stars_repo_path": "tensorflow/compiler/plugin/poplar/tests/64_bit_test.py", "max_stars_repo_name": "chenzhengda/tensorflow", "max_stars_repo_head_hexsha": "8debb698097670458b5f21d728bc6f734a7b5a53", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 74, "max_stars_repo_stars_event_min_datetime": "2020-07-06T17:11:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:31:28.000Z", "max_issues_repo_path": "tensorflow/compiler/plugin/poplar/tests/64_bit_test.py", "max_issues_repo_name": "chenzhengda/tensorflow", "max_issues_repo_head_hexsha": "8debb698097670458b5f21d728bc6f734a7b5a53", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-10-13T23:25:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T06:54:48.000Z", "max_forks_repo_path": "tensorflow/compiler/plugin/poplar/tests/64_bit_test.py", "max_forks_repo_name": "chenzhengda/tensorflow", "max_forks_repo_head_hexsha": "8debb698097670458b5f21d728bc6f734a7b5a53", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2020-07-08T07:27:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-27T08:54:27.000Z", "avg_line_length": 34.9193548387, "max_line_length": 80, "alphanum_fraction": 0.6161662818, "include": true, "reason": "import numpy", "num_tokens": 594}
|
#include <angles/angles.h>
#include <pluginlib/class_list_macros.h>
#include <backward_local_planner/backward_local_planner.h>
#include <visualization_msgs/MarkerArray.h>
#include <boost/intrusive_ptr.hpp>
//register this planner as a BaseLocalPlanner plugin
PLUGINLIB_EXPORT_CLASS(backward_local_planner::BackwardLocalPlanner, nav_core::BaseLocalPlanner)
namespace backward_local_planner
{
/**
******************************************************************************************************************
* BackwardLocalPlanner()
******************************************************************************************************************
*/
BackwardLocalPlanner::BackwardLocalPlanner()
: paramServer_(ros::NodeHandle("~BackwardLocalPlanner"))
{
}
/**
******************************************************************************************************************
* ~BackwardLocalPlanner()
******************************************************************************************************************
*/
BackwardLocalPlanner::~BackwardLocalPlanner()
{
}
void BackwardLocalPlanner::initialize(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros)
{
this->costmapRos_ = costmap_ros;
this->initialize();
}
void BackwardLocalPlanner::initialize()
{
k_rho_ = -1.0;
k_alpha_ = 0.5;
k_betta_ = -1.0; // set to zero means that orientation is not important
carrot_angular_distance_ = 0.5;
f = boost::bind(&BackwardLocalPlanner::reconfigCB, this, _1, _2);
paramServer_.setCallback(f);
this->currentPoseIndex_ = 0;
ros::NodeHandle nh("~/BackwardLocalPlanner");
nh.param("pure_spinning_straight_line_mode", pureSpinningMode_, true);
nh.param("yaw_goal_tolerance", yaw_goal_tolerance_, 0.05);
nh.param("xy_goal_tolerance", xy_goal_tolerance_, 0.10);
nh.param("k_rho", k_rho_,k_rho_);
nh.param("carrot_distance", carrot_distance_, carrot_distance_);
nh.param("carrot_angular_distance", carrot_angular_distance_, carrot_angular_distance_);
nh.param("max_linear_x_speed", max_linear_x_speed_, 1.0);
nh.param("max_angular_z_speed", max_angular_z_speed_, 2.0);
goalMarkerPublisher_ = nh.advertise<visualization_msgs::MarkerArray>("goal_marker", 1);
}
/**
******************************************************************************************************************
* initialize()
******************************************************************************************************************
*/
void BackwardLocalPlanner::initialize(std::string name, tf::TransformListener* tf, costmap_2d::Costmap2DROS* costmap_ros)
{
this->costmapRos_ = costmap_ros;
this->initialize();
}
/**
******************************************************************************************************************
* createCarrotGoal()
******************************************************************************************************************
*/
bool BackwardLocalPlanner::createCarrotGoal(const tf::Stamped<tf::Pose>& tfpose)
{
bool ok = false;
bool pureSpinning=false;
double angle = tf::getYaw(tfpose.getRotation());
if(!pureSpinningMode_)
{
if(currentPoseIndex_<=1)
{
double angle = tf::getYaw(tfpose.getRotation());
/*
//closest dist
double mindist = std::numeric_limits<double>::max();
int closestIndex = 1;
for(int i=1;i< backwardsPlanPath_.size();i++)
{
auto& pose = backwardsPlanPath_[i];
const geometry_msgs::Point& p = pose.pose.position;
// take error from the current position to the path point
double dx = p.x - tfpose.getOrigin().x();
double dy = p.y - tfpose.getOrigin().y();
double dist = sqrt(dx * dx + dy * dy);
if(dist < mindist)
{
closestIndex = i;
mindist = dist;
}
}*/
auto& closestPose = backwardsPlanPath_[1];
tf::Quaternion q;
tf::quaternionMsgToTF(closestPose.pose.orientation, q);
double pangle = tf::getYaw(q);
double angular_error = angles::shortest_angular_distance(pangle, angle);
ROS_WARN("pure spinning stage, angle: %lf threshold: %lf", angular_error, carrot_angular_distance_);
if(fabs(angular_error) >= carrot_angular_distance_)
{
ok = true;
currentPoseIndex_ = 1;
pureSpinning=true;
initialPureSpinningStage_=true;
}
else
{
ok = true;
currentPoseIndex_++;
initialPureSpinningStage_=false;
pureSpinning=false;
//exit(0);
}
}
}
if(!pureSpinning)
{
pureSpinning = false;
// iterate the point from the current position and backward until reaching a new goal point in the path
for (; !ok && currentPoseIndex_ < backwardsPlanPath_.size(); currentPoseIndex_++)
{
auto& pose = backwardsPlanPath_[currentPoseIndex_];
const geometry_msgs::Point& p = pose.pose.position;
tf::Quaternion q;
tf::quaternionMsgToTF(pose.pose.orientation, q);
// take error from the current position to the path point
double dx = p.x - tfpose.getOrigin().x();
double dy = p.y - tfpose.getOrigin().y();
double dist = sqrt(dx * dx + dy * dy);
double pangle = tf::getYaw(q);
double angular_error = angles::shortest_angular_distance(pangle + alpha_offset_, angle);
// target pose found
if (dist >= carrot_distance_ )
{
ok = true;
ROS_INFO("target dist: %lf / %lf", dist, carrot_distance_);
ROS_INFO("Retracting: %lf/100", 100.0 * currentPoseIndex_ / (double)backwardsPlanPath_.size());
currentPoseIndex_--;
}
}
}
if (currentPoseIndex_ >= backwardsPlanPath_.size())
{
currentPoseIndex_ = backwardsPlanPath_.size() -1;
ok = true;
}
ROS_INFO("current index: %d", currentPoseIndex_);
return pureSpinning;
}
/**
******************************************************************************************************************
* defaultBackwardCmd()
******************************************************************************************************************
*/
void BackwardLocalPlanner::defaultBackwardCmd(const tf::Stamped<tf::Pose>& tfpose, double vetta, double gamma, double alpha_error, geometry_msgs::Twist& cmd_vel)
{
cmd_vel.linear.x = vetta;
cmd_vel.angular.z = gamma;
auto& finalgoal = backwardsPlanPath_.back();
double gdx = finalgoal.pose.position.x - tfpose.getOrigin().x();
double gdy = finalgoal.pose.position.y - tfpose.getOrigin().y();
double goaldist = sqrt(gdx*gdx + gdy*gdy);
if(goaldist < this->xy_goal_tolerance_ && alpha_error < this->yaw_goal_tolerance_) // 5cm
{
goalReached_=true;
backwardsPlanPath_.clear();
}
}
/**
******************************************************************************************************************
* pureSpinningCmd()
******************************************************************************************************************
*/
void BackwardLocalPlanner::pureSpinningCmd(const tf::Stamped<tf::Pose>& tfpose, double vetta, double gamma, double alpha_error, double betta_error, double rho_error, geometry_msgs::Twist& cmd_vel)
{
if (rho_error > 0.02)
{
vetta = k_rho_ * rho_error;
gamma = k_alpha_ * alpha_error;
}
else if (fabs(betta_error) >= 0.01)
{
vetta = 0;
gamma = k_betta_*betta_error;
}
else if (currentPoseIndex_ >= backwardsPlanPath_.size() - 1)
{
vetta = 0;
gamma = 0;
goalReached_=true;
ROS_INFO_STREAM("BACKWARD LOCAL PLANNER END: rhoerror: " << rho_error);
}
cmd_vel.linear.x = vetta;
cmd_vel.angular.z = gamma;
}
// MELODIC
#if ROS_VERSION_MINIMUM(1,13,0)
tf::Stamped<tf::Pose> optionalRobotPose(costmap_2d::Costmap2DROS* costmapRos)
{
geometry_msgs::PoseStamped paux;
costmapRos->getRobotPose(paux);
tf::Stamped<tf::Pose> tfpose;
tf::poseStampedMsgToTF(paux, tfpose);
return tfpose;
}
#else
// INDIGO AND PREVIOUS
tf::Stamped<tf::Pose> optionalRobotPose( costmap_2d::Costmap2DROS* costmapRos)
{
tf::Stamped<tf::Pose> tfpose;
costmapRos->getRobotPose(tfpose);
return tfpose;
}
#endif
/**
******************************************************************************************************************
* computeVelocityCommands()
******************************************************************************************************************
*/
bool BackwardLocalPlanner::computeVelocityCommands(geometry_msgs::Twist& cmd_vel)
{
ROS_DEBUG("LOCAL PLANNER LOOP");
geometry_msgs::PoseStamped paux;
tf::Stamped<tf::Pose> tfpose = optionalRobotPose(costmapRos_);
tf::Quaternion q = tfpose.getRotation();
bool initialPureSpinningDefaultMovement = createCarrotGoal(tfpose);
const geometry_msgs::PoseStamped& goalpose = backwardsPlanPath_[currentPoseIndex_];
ROS_INFO_STREAM("goal pose current index: " << goalpose);
const geometry_msgs::Point& goalposition = goalpose.pose.position;
tf::Quaternion goalQ;
tf::quaternionMsgToTF(goalpose.pose.orientation, goalQ);
//goal orientation (global frame)
double betta = tf::getYaw(goalQ);
betta = betta + betta_offset_;
double dx = goalposition.x - tfpose.getOrigin().x();
double dy = goalposition.y - tfpose.getOrigin().y();
//distance error to the targetpoint
double rho_error = sqrt(dx * dx + dy * dy);
//heading to goal angle
double theta = tf::getYaw(q);
double alpha = atan2(dy, dx);
alpha = alpha + alpha_offset_;
double alpha_error = angles::shortest_angular_distance(alpha, theta);
double betta_error = angles::shortest_angular_distance(betta, theta);
double vetta = k_rho_ * rho_error;
double gamma = k_alpha_ * alpha_error + k_betta_ * betta_error;
if (pureSpinningMode_)
{
this->pureSpinningCmd(tfpose,vetta,gamma, alpha_error, betta_error, rho_error, cmd_vel);
}
else
{
// this is recomendable to start the initial motion looking to the goal
ROS_WARN("pure spinning: %d", initialPureSpinningDefaultMovement);
if(initialPureSpinningDefaultMovement)
{
vetta = 0;
}
this->defaultBackwardCmd(tfpose, vetta,gamma, alpha_error, cmd_vel);
}
if (cmd_vel.linear.x > max_linear_x_speed_)
{
cmd_vel.linear.x = max_linear_x_speed_;
}
else if(cmd_vel.linear.x < -max_linear_x_speed_)
{
cmd_vel.linear.x = -max_linear_x_speed_;
}
if(cmd_vel.angular.z > max_angular_z_speed_)
{
cmd_vel.angular.z = max_angular_z_speed_;
}
else if(cmd_vel.angular.z < -max_angular_z_speed_)
{
cmd_vel.angular.z = - max_angular_z_speed_;
}
publishGoalMarker(goalposition.x, goalposition.y, betta);
ROS_INFO_STREAM("local planner," << std::endl
<< " pureSpiningMode: "<< pureSpinningMode_ <<std::endl
<< " theta: " << theta << std::endl
<< " betta: " << theta << std::endl
<< " err_x: " << dx << std::endl
<< " err_y:" << dy << std::endl
<< " rho_error:" << rho_error << std::endl
<< " alpha_error:" << alpha_error << std::endl
<< " betta_error:" << betta_error << std::endl
<< " vetta:" << vetta << std::endl
<< " gamma:" << gamma);
//cmd_vel.linear.x=0;
//cmd_vel.angular.z = 0;
return true;
}
/**
******************************************************************************************************************
* reconfigCB()
******************************************************************************************************************
*/
void BackwardLocalPlanner::reconfigCB(backward_local_planner::BackwardLocalPlannerConfig& config, uint32_t level)
{
ROS_INFO("Backward planner reconfigure Request");
k_alpha_ = config.k_alpha;
k_betta_ = config.k_betta;
k_rho_ = config.k_rho;
//alpha_offset_ = config.alpha_offset;
//betta_offset_ = config.betta_offset;
carrot_distance_ = config.carrot_distance;
carrot_angular_distance_ = config.carrot_angular_distance;
}
/**
******************************************************************************************************************
* isGoalReached()
******************************************************************************************************************
*/
bool BackwardLocalPlanner::isGoalReached()
{
return goalReached_;
}
/**
******************************************************************************************************************
* setPlan()
******************************************************************************************************************
*/
bool BackwardLocalPlanner::setPlan(const std::vector<geometry_msgs::PoseStamped>& plan)
{
initialPureSpinningStage_=true;
goalReached_ = false;
backwardsPlanPath_ = plan;
/*
std::stringstream ss;
for(auto& p: plan)
{
ss << p;
}
ROS_WARN_STREAM("Backward Local Planner - plan path - " << ss.str());
*/
return true;
}
/**
******************************************************************************************************************
* publishGoalMarker()
******************************************************************************************************************
*/
void BackwardLocalPlanner::publishGoalMarker(double x, double y, double phi)
{
visualization_msgs::Marker marker;
marker.header.frame_id = "/odom";
marker.header.stamp = ros::Time::now ();
marker.ns = "my_namespace2";
marker.id = 0;
marker.type = visualization_msgs::Marker::ARROW;
marker.action = visualization_msgs::Marker::ADD;
marker.scale.x = 0.05;
marker.scale.y = 0.15;
marker.scale.z = 0.05;
marker.color.a = 1.0;
marker.color.r = 1;
marker.color.g = 0;
marker.color.b = 0;
geometry_msgs::Point start,end;
start.x = x;
start.y = y;
end.x = x + 0.5 * cos(phi);
end.y = y + 0.5 * sin(phi);
marker.points.push_back(start);
marker.points.push_back(end);
visualization_msgs::MarkerArray ma;
ma.markers.push_back(marker);
goalMarkerPublisher_.publish(ma);
}
}
|
{"hexsha": "631d2fa5f125184595d6b9d9876b3a78cc68eacc", "size": 15104, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "smacc_client_library/smacc_navigation/backward_local_planner/src/backward_curved_local_planner.cpp", "max_stars_repo_name": "NEU-ZJX/SMACC", "max_stars_repo_head_hexsha": "cac82a606a5456194e2ca1e404cf9fef66e78e6e", "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": "smacc_client_library/smacc_navigation/backward_local_planner/src/backward_curved_local_planner.cpp", "max_issues_repo_name": "NEU-ZJX/SMACC", "max_issues_repo_head_hexsha": "cac82a606a5456194e2ca1e404cf9fef66e78e6e", "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": "smacc_client_library/smacc_navigation/backward_local_planner/src/backward_curved_local_planner.cpp", "max_forks_repo_name": "NEU-ZJX/SMACC", "max_forks_repo_head_hexsha": "cac82a606a5456194e2ca1e404cf9fef66e78e6e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2020-04-30T00:10:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-30T00:10:52.000Z", "avg_line_length": 33.865470852, "max_line_length": 196, "alphanum_fraction": 0.5156912076, "num_tokens": 3231}
|
""" Optimizations of the expression tree representation for better CSE
opportunities.
"""
from sympy.core import Add, Basic, Expr, Mul, S
from sympy.core.exprtools import factor_terms
from sympy.utilities.iterables import preorder_traversal
class Neg(Expr):
""" Stub to hold negated expression.
"""
__slots__ = []
def sub_pre(e):
""" Replace Add(x, Mul(NegativeOne(-1), y)) with Sub(x, y).
"""
# make canonical, first
adds = {}
for a in e.atoms(Add):
adds[a] = a.could_extract_minus_sign()
e = e.subs([(a, Mul(-1, -a, evaluate=False)
if adds[a] else a) for a in adds])
# now replace any persisting Adds, a, that can have -1 extracted with Neg(-a)
if isinstance(e, Basic):
reps = dict([(a, Neg(-a)) for a in e.atoms(Add)
if adds.get(a, a.could_extract_minus_sign())])
e = e.xreplace(reps)
return e
def sub_post(e):
""" Replace Neg(x) with -x.
"""
replacements = []
for node in preorder_traversal(e):
if isinstance(node, Neg):
replacements.append((node, -node.args[0]))
for node, replacement in replacements:
e = e.xreplace({node: replacement})
return e
default_optimizations = [
(sub_pre, sub_post),
(factor_terms, None),
]
|
{"hexsha": "a74c5b1eefb546108a76fe5d5e2ae544dabba244", "size": 1295, "ext": "py", "lang": "Python", "max_stars_repo_path": "sympy/simplify/cse_opts.py", "max_stars_repo_name": "goodok/sympy", "max_stars_repo_head_hexsha": "de84ed2139125a755ea7b6ba91d945d9fbbe5ed9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-05-11T12:26:38.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-19T00:11:03.000Z", "max_issues_repo_path": "sympy/simplify/cse_opts.py", "max_issues_repo_name": "goodok/sympy", "max_issues_repo_head_hexsha": "de84ed2139125a755ea7b6ba91d945d9fbbe5ed9", "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": "sympy/simplify/cse_opts.py", "max_forks_repo_name": "goodok/sympy", "max_forks_repo_head_hexsha": "de84ed2139125a755ea7b6ba91d945d9fbbe5ed9", "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.7777777778, "max_line_length": 81, "alphanum_fraction": 0.616988417, "include": true, "reason": "from sympy", "num_tokens": 339}
|
import argparse
import json
import pickle as pkl
from os.path import basename
import numpy as np
def parse_argument():
parser = argparse.ArgumentParser("Convert json gt to roidb")
parser.add_argument("--json", type=str, required=True)
args = parser.parse_args()
return args.json
def json_to_roidb(json_path):
with open(json_path) as f:
json_gt = json.load(f)
for obj in json_gt:
obj["gt_class"] = np.array(obj["gt_class"], dtype=np.float32)
obj["gt_bbox"] = np.array(obj["gt_bbox"], dtype=np.float32)
with open("data/cache/%s.roidb" % basename(json_path).replace("json", "roidb"), "wb") as fout:
pkl.dump(json_gt, fout)
if __name__ == "__main__":
json_to_roidb(parse_argument())
|
{"hexsha": "f38f3d629456089d29d286078b62d2a6ab466732", "size": 751, "ext": "py", "lang": "Python", "max_stars_repo_path": "utils/json_to_roidb.py", "max_stars_repo_name": "winnerineast/simpledet", "max_stars_repo_head_hexsha": "cb25cea2bf0df9cc7de008c853cf4bcb4f09415d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3195, "max_stars_repo_stars_event_min_datetime": "2019-01-29T09:08:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T08:20:44.000Z", "max_issues_repo_path": "utils/json_to_roidb.py", "max_issues_repo_name": "winnerineast/simpledet", "max_issues_repo_head_hexsha": "cb25cea2bf0df9cc7de008c853cf4bcb4f09415d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 275, "max_issues_repo_issues_event_min_datetime": "2019-01-29T10:16:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-15T17:56:39.000Z", "max_forks_repo_path": "utils/json_to_roidb.py", "max_forks_repo_name": "winnerineast/simpledet", "max_forks_repo_head_hexsha": "cb25cea2bf0df9cc7de008c853cf4bcb4f09415d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 563, "max_forks_repo_forks_event_min_datetime": "2019-01-29T09:32:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T06:58:01.000Z", "avg_line_length": 25.8965517241, "max_line_length": 98, "alphanum_fraction": 0.6750998668, "include": true, "reason": "import numpy", "num_tokens": 194}
|
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
%
\documentclass[
]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
colorlinks=true,
linkcolor=Maroon,
filecolor=Maroon,
citecolor=Blue,
urlcolor=Blue,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{255,255,255}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.75,0.01,0.01}{\textbf{\colorbox[rgb]{0.97,0.90,0.90}{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.79,0.38,0.79}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.00,0.34,0.68}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.69,0.50,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.39,0.29,0.61}{\textbf{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.57,0.30,0.62}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.54,0.53,0.53}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.00,0.58,1.00}{#1}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.67,0.33,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.12,0.11,0.11}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.00,0.34,0.68}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.69,0.50,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.38,0.47,0.50}{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.75,0.01,0.01}{\underline{#1}}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.58,1.00}{\textbf{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.69,0.50,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.39,0.29,0.61}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{1.00,0.33,0.00}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.69,0.50,0.00}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.12,0.11,0.11}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.12,0.11,0.11}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.12,0.11,0.11}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.43,0.16}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.00,0.43,0.16}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.34,0.68}{\colorbox[rgb]{0.88,0.91,0.97}{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.24,0.68,0.91}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{1.00,0.33,0.00}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.75,0.01,0.01}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.34,0.68}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.75,0.01,0.01}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.75,0.01,0.01}{#1}}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\usepackage[normalem]{ulem}
% Avoid problems with \sout in headers with hyperref
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifluatex
\usepackage{selnolig} % disable illegal ligatures
\fi
\author{}
\date{}
\begin{document}
\useunder{\uline}{\ulined}{}
\hypertarget{oldnew-title}{%
\section{\texorpdfstring{{\color{RedOrange}\sout{{Old}}{\ulined{}New}}
Title}{OldNew Title}}\label{oldnew-title}}
{\color{Maroon}\sout{{\includegraphics{minus.png}}}}
{\color{OliveGreen}\ulined{}\includegraphics{plus.png}}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
Lorem ipsum dolor {\color{OliveGreen}\ulined{}sit }amet
\item
{\color{OliveGreen}\ulined{}\href{https://en.wikipedia.org/wiki/Lorem_ipsum}{consectetur
adipiscing elit}}
\item
Lorem{\color{Maroon}\sout{{ ipsum}}} dolor sit amet
\end{enumerate}
I really love \emph{italic
{\color{RedOrange}\sout{{fonts}}{\ulined{}font-styles}}}
{\color{RedOrange}\sout{{here.}}{\ulined{}there.}}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{ print("Hello")}
\StringTok{{-}print("world.")}
\VariableTok{+print("world!")}
\NormalTok{ print("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt")}
\end{Highlighting}
\end{Shaded}
Don't go around saying {\color{Maroon}\sout{{to people that }}}the world
owes you a living. The world owes you nothing. It was here first.
{\color{RedOrange}\sout{{One}}{\ulined{}Only one}} thing is impossible
for God: To find{\color{OliveGreen}\ulined{} any} sense in any copyright
law on the planet. Truth is stranger than fiction, but it is because
Fiction is obliged to stick to possibilities; Truth isn't.
\end{document}
|
{"hexsha": "3a9b4bd470155d6386c813f68554079c33a59493", "size": 6539, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "test/diff.tex", "max_stars_repo_name": "davidar/pandiff", "max_stars_repo_head_hexsha": "d1d468b2c4d81c622ff431ef718b1bf0daaa03db", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 163, "max_stars_repo_stars_event_min_datetime": "2018-05-01T14:00:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T04:09:35.000Z", "max_issues_repo_path": "test/diff.tex", "max_issues_repo_name": "sthagen/davidar-pandiff", "max_issues_repo_head_hexsha": "d1d468b2c4d81c622ff431ef718b1bf0daaa03db", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2018-09-15T07:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-06T08:14:13.000Z", "max_forks_repo_path": "test/diff.tex", "max_forks_repo_name": "sthagen/davidar-pandiff", "max_forks_repo_head_hexsha": "d1d468b2c4d81c622ff431ef718b1bf0daaa03db", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2019-01-10T18:35:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-15T20:29:58.000Z", "avg_line_length": 41.1257861635, "max_line_length": 111, "alphanum_fraction": 0.7262578376, "num_tokens": 2391}
|
/**
* .file test/exces/entity.cpp
* .brief Test case for entity type and related functionality.
*
* .author Matus Chochlik
*
* Copyright 2011-2013 Matus Chochlik. 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)
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE EXCES_Entity
#include <boost/test/unit_test.hpp>
#include <exces/entity.hpp>
#include <vector>
BOOST_AUTO_TEST_SUITE(Entity)
BOOST_AUTO_TEST_CASE(Entity_default_construction)
{
exces::entity<>::type e;
(void)(e);
}
BOOST_AUTO_TEST_CASE(Entity_copy_construction)
{
exces::entity<>::type e1;
exces::entity<>::type e2 = e1;
(void)(e2);
}
BOOST_AUTO_TEST_CASE(Entity_identity)
{
exces::entity<>::type e1, e2;
BOOST_CHECK(e1 != e2);
exces::entity<>::type e1_c = e1;
BOOST_CHECK(e1 == e1_c);
}
BOOST_AUTO_TEST_CASE(Entity_identity_2)
{
std::vector<exces::entity<>::type> ev(1000);
auto b = ev.begin(), e = ev.end();
auto i = b;
while(i != e)
{
auto j = i;
++j;
while(j != e)
{
BOOST_CHECK(*i != *j);
++j;
}
++i;
}
}
BOOST_AUTO_TEST_SUITE_END()
|
{"hexsha": "2abfef00f33fc3f848d64d3f95a468652c061579", "size": 1166, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/exces/entity.cpp", "max_stars_repo_name": "matus-chochlik/exces", "max_stars_repo_head_hexsha": "50b57ce4c9f6c41ab2eacfae054529cbbe6164c0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-03-26T20:51:36.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-26T20:51:36.000Z", "max_issues_repo_path": "test/exces/entity.cpp", "max_issues_repo_name": "matus-chochlik/exces", "max_issues_repo_head_hexsha": "50b57ce4c9f6c41ab2eacfae054529cbbe6164c0", "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/exces/entity.cpp", "max_forks_repo_name": "matus-chochlik/exces", "max_forks_repo_head_hexsha": "50b57ce4c9f6c41ab2eacfae054529cbbe6164c0", "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": 18.8064516129, "max_line_length": 68, "alphanum_fraction": 0.6861063465, "num_tokens": 355}
|
using ConvDiffMIPDECO
using Test
using jInv.Mesh
domain = [0. 3. 0 1. 0 2.]
n = 3*[7 9 12] .- 1
M = getRegularMesh(domain,n)
Mass, Mass_const, SM = getFEMMatrices3D(M)
e = ones(prod(M.n.+1))
@test abs(prod((domain[2:2:end]-domain[1:2:end])) - dot(e,Mass*e))/dot(e,Mass*e) < 1e-2
f = getFEMsource3D(M)
v = Mass_const*f
u = SM\v
|
{"hexsha": "6949f734b49d4a4ed83dc127318925d5c1541ca6", "size": 339, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/testFEM3D.jl", "max_stars_repo_name": "JuliaInv/ConvDiffMIPDECO", "max_stars_repo_head_hexsha": "95a3aead09d34811c4c2ca14279df93a0b40ecdb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-16T19:08:09.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-16T19:08:09.000Z", "max_issues_repo_path": "test/testFEM3D.jl", "max_issues_repo_name": "JuliaInv/ConvDiffMIPDECO", "max_issues_repo_head_hexsha": "95a3aead09d34811c4c2ca14279df93a0b40ecdb", "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/testFEM3D.jl", "max_forks_repo_name": "JuliaInv/ConvDiffMIPDECO", "max_forks_repo_head_hexsha": "95a3aead09d34811c4c2ca14279df93a0b40ecdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-08T11:13:38.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-08T11:13:38.000Z", "avg_line_length": 22.6, "max_line_length": 87, "alphanum_fraction": 0.6312684366, "num_tokens": 144}
|
program demo_system_perm
use M_system, only : system_perm, system_stat
use,intrinsic :: iso_fortran_env, only : int64
implicit none
character(len=4096) :: string
integer(kind=int64) :: values(13)
integer :: ierr
character(len=:),allocatable :: perms
values=0
! get pathname from command line
call get_command_argument(1, string)
! get pathname information
call system_stat(string,values,ierr)
if(ierr.eq.0)then
! convert permit mode to a string
perms=system_perm(values(3))
! print permits as a string, decimal value, and octal value
write(*,'("for ",a," permits[",a,"]",1x,i0,1x,o0)') &
& trim(string),perms,values(3),values(3)
endif
end program demo_system_perm
|
{"hexsha": "ad26fd329e14bceef0461797b1040fe8af0af05b", "size": 946, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "example/demo_system_perm.f90", "max_stars_repo_name": "urbanjost/M_system", "max_stars_repo_head_hexsha": "5d419badbe993538ddca866e951d19d5c73d1fff", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2019-12-16T20:00:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-20T13:11:10.000Z", "max_issues_repo_path": "docs/fpm-ford/src/demo_system_perm.f90", "max_issues_repo_name": "urbanjost/M_system", "max_issues_repo_head_hexsha": "5d419badbe993538ddca866e951d19d5c73d1fff", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2021-01-28T13:26:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-17T01:44:35.000Z", "max_forks_repo_path": "example/demo_system_perm.f90", "max_forks_repo_name": "urbanjost/M_system", "max_forks_repo_head_hexsha": "5d419badbe993538ddca866e951d19d5c73d1fff", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-03-01T11:34:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-27T15:19:11.000Z", "avg_line_length": 43.0, "max_line_length": 75, "alphanum_fraction": 0.5317124736, "num_tokens": 212}
|
from time import time
from scipy.special import comb as scipy_choose
import math
import numpy as np
class timer:
def __init__(self, name="timer"):
self.name = name
def __enter__(self):
print("timing: %s"%self.name)
self.starttime = time()
def __exit__(self, type, value, traceback):
endtime = time()
self.total_time = endtime-self.starttime
print("runtime=%s"%(self.total_time))
print()
with timer("scipy"):
for i in range(1000):
for j in range(i):
scipy_choose(i,j)
|
{"hexsha": "18f2899a2661db583cff7e1eda988de7297f6fd6", "size": 565, "ext": "py", "lang": "Python", "max_stars_repo_path": "choose38.py", "max_stars_repo_name": "hugoleeney/python_benchmarks", "max_stars_repo_head_hexsha": "941077974df24d2288a5b3ca6003fc67b50a7b27", "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": "choose38.py", "max_issues_repo_name": "hugoleeney/python_benchmarks", "max_issues_repo_head_hexsha": "941077974df24d2288a5b3ca6003fc67b50a7b27", "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": "choose38.py", "max_forks_repo_name": "hugoleeney/python_benchmarks", "max_forks_repo_head_hexsha": "941077974df24d2288a5b3ca6003fc67b50a7b27", "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.7307692308, "max_line_length": 48, "alphanum_fraction": 0.614159292, "include": true, "reason": "import numpy,from scipy", "num_tokens": 140}
|
# -*- coding:utf-8 -*-
"""
"""
import numpy as np
from hypernets.utils import logging
logger = logging.get_logger(__name__)
#
# _STRATEGY_THRESHOLD = 'threshold'
# _STRATEGY_QUANTILE = 'quantile'
# _STRATEGY_NUMBER = 'number'
# _STRATEGY_DEFAULT = _STRATEGY_THRESHOLD
#
# _DEFAULT_THRESHOLD = 0.8
# _DEFAULT_QUANTILE = 0.8
# _DEFAULT_TOP_PERCENT = 0.2
#
#
# def detect_strategy(strategy, threshold=None, quantile=None, number=None):
# if strategy is None:
# if threshold is not None:
# strategy = _STRATEGY_THRESHOLD
# elif number is not None:
# strategy = _STRATEGY_NUMBER
# elif quantile is not None:
# strategy = _STRATEGY_QUANTILE
# else:
# strategy = _STRATEGY_DEFAULT
#
# if strategy == _STRATEGY_THRESHOLD:
# if threshold is None:
# threshold = _DEFAULT_THRESHOLD
# assert 0 < threshold < 1.0
# elif strategy == _STRATEGY_NUMBER:
# if number is None:
# number = _DEFAULT_TOP_PERCENT
# elif strategy == _STRATEGY_QUANTILE:
# if quantile is None:
# quantile = _DEFAULT_QUANTILE
# assert 0 < quantile < 1.0
# else:
# raise ValueError(f'Unsupported strategy: {strategy}')
#
# return strategy, threshold, quantile, number
#
#
# def sample_by_pseudo_labeling(X_test, classes, proba, strategy,
# threshold=None, quantile=None, number=None):
# assert len(classes) == proba.shape[-1] > 1
#
# strategy, threshold, quantile, number = \
# detect_strategy(strategy, threshold=threshold, quantile=quantile, number=number)
# if strategy == _STRATEGY_NUMBER and isinstance(number, float) and 0 < number < 1:
# proba_shape = dex.compute(proba.shape)[0] if dex.is_dask_object(proba) else proba.shape
# number = int(proba_shape[0] / proba_shape[1] * _DEFAULT_TOP_PERCENT)
# if number < 10:
# number = 10
#
# if dex.is_dask_dataframe(X_test):
# fn = _sample_by_dask
# else:
# fn = _sample_by_sk
#
# r = fn(X_test, classes, proba, strategy, threshold, quantile, number)
# if logger.is_info_enabled():
# if dex.is_dask_object(r[1]):
# y = dex.compute(r[1])[0]
# else:
# y = r[1]
# logger.info(f'extract pseudo labeling samples (strategy={strategy}): {Counter(y)}')
#
# return r
#
#
# def _sample_by_sk(X_test, classes, proba, strategy, threshold, quantile, number):
# mx = proba.max(axis=1, keepdims=True)
# proba = np.where(proba < mx, 0, proba)
#
# if strategy is None or strategy == _STRATEGY_THRESHOLD:
# selected = (proba >= threshold)
# elif strategy == _STRATEGY_NUMBER:
# pos = proba.shape[0] - number
# i = np.argsort(np.argsort(proba, axis=0), axis=0)
# selected = np.logical_and(i >= pos, proba > 0)
# elif strategy == _STRATEGY_QUANTILE:
# qs = np.nanquantile(np.where(proba > 0, proba, np.nan), quantile, axis=0)
# selected = (proba >= qs)
# else:
# raise ValueError(f'Unsupported strategy: {strategy}')
#
# pred = (selected * np.arange(1, len(classes) + 1)).max(axis=1) - 1
# idx = np.argwhere(pred >= 0).ravel()
#
# X_pseudo = X_test.iloc[idx] if hasattr(X_test, 'iloc') else X_test[idx]
# y_pseudo = np.take(np.array(classes), pred[idx], axis=0)
#
# return X_pseudo, y_pseudo
#
#
# def _sample_by_dask(X_test, classes, proba, strategy, threshold, quantile, number):
# da = dex.da
# mx = proba.max(axis=1, keepdims=True)
# proba = da.where(proba < mx, 0, proba)
# proba = dex.make_chunk_size_known(proba)
#
# if strategy is None or strategy == _STRATEGY_THRESHOLD:
# selected = (proba >= threshold)
# elif strategy == _STRATEGY_NUMBER:
# if proba.numblocks[0] > 1:
# proba = proba.rechunk(proba.shape)
# selected = proba.map_blocks(_select_top, number, meta=np.array((), np.bool))
# elif strategy == _STRATEGY_QUANTILE:
# qs = []
# for i in range(proba.shape[-1]):
# c = proba[:, i]
# ci = da.argwhere(c > 0)
# ci = dex.make_chunk_size_known(ci).ravel()
# t = c[ci]
# qs.append(da.percentile(t, quantile * 100))
# qs = dex.compute(qs)[0]
# selected = (proba >= np.array(qs).ravel())
# else:
# raise ValueError(f'Unsupported strategy: {strategy}')
#
# pred = (selected * np.arange(1, len(classes) + 1)).max(axis=1) - 1
# idx = da.argwhere(pred >= 0)
# idx = dex.make_chunk_size_known(idx).ravel()
#
# if dex.is_dask_dataframe(X_test):
# X_test_values = X_test.to_dask_array(lengths=True)
# X_test_values = X_test_values[idx]
# X_pseudo = dex.dd.from_dask_array(X_test_values, columns=X_test.columns,
# meta=X_test._meta)
# else:
# X_pseudo = X_test[idx]
# y_pseudo = da.take(np.array(classes), pred[idx], axis=0)
#
# return X_pseudo, y_pseudo
#
#
# def _select_top(chunk, number):
# pos = chunk.shape[0] - number
# i = np.argsort(np.argsort(chunk, axis=0), axis=0)
# result = np.logical_and(i >= pos, chunk > 0)
# return result
#
class PseudoLabeling:
DEFAULT_STRATEGY_SETTINGS = dict(
default_strategy='threshold',
default_threshold=0.8,
default_quantile=0.8,
default_number=0.2,
)
def __init__(self, strategy, threshold=None, quantile=None, number=None):
strategy, threshold, quantile, number = \
self.detect_strategy(strategy, threshold=threshold, quantile=quantile, number=number)
self.strategy = strategy
self.threshold = threshold
self.quantile = quantile
self.number = number
@staticmethod
def detect_strategy(strategy, threshold=None, quantile=None, number=None):
from .toolbox import ToolBox
return ToolBox.detect_strategy(strategy, threshold=threshold, quantile=quantile, number=number,
**PseudoLabeling.DEFAULT_STRATEGY_SETTINGS)
def select(self, X_test, classes, proba):
assert len(classes) == proba.shape[-1] > 1
from .toolbox import ToolBox
mx = proba.max(axis=1, keepdims=True)
proba = np.where(proba < mx, 0, proba)
if self.strategy is None or self.strategy == ToolBox.STRATEGY_THRESHOLD:
selected = (proba >= self.threshold)
elif self.strategy == ToolBox.STRATEGY_NUMBER:
if isinstance(self.number, float) and 0 < self.number < 1:
number = int(proba.shape[0] / proba.shape[1] * self.number)
if number < 10:
number = 10
else:
number = int(self.number)
pos = proba.shape[0] - number
i = np.argsort(np.argsort(proba, axis=0), axis=0)
selected = np.logical_and(i >= pos, proba > 0)
elif self.strategy == ToolBox.STRATEGY_QUANTILE:
qs = np.nanquantile(np.where(proba > 0, proba, np.nan), self.quantile, axis=0)
selected = (proba >= qs)
else:
raise ValueError(f'Unsupported strategy: {self.strategy}')
pred = (selected * np.arange(1, len(classes) + 1)).max(axis=1) - 1
idx = np.argwhere(pred >= 0).ravel()
X_pseudo = X_test.iloc[idx] if hasattr(X_test, 'iloc') else X_test[idx]
y_pseudo = np.take(np.array(classes), pred[idx], axis=0)
if logger.is_info_enabled():
uniques = np.unique(y_pseudo, return_counts=True)
value_counts = {k: n for k, n in zip(uniques[0], uniques[1])}
logger.info(f'extract pseudo labeling samples (strategy={self.strategy}): {value_counts}')
return X_pseudo, y_pseudo
|
{"hexsha": "a9f69eeb1669ebc82173ee2c8d008b0465f4dd86", "size": 7854, "ext": "py", "lang": "Python", "max_stars_repo_path": "hypernets/tabular/pseudo_labeling.py", "max_stars_repo_name": "DataCanvasIO/Hypernets", "max_stars_repo_head_hexsha": "4dd8b9846a3e205f03a23a770169cd1d14a98f03", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1080, "max_stars_repo_stars_event_min_datetime": "2020-06-22T07:44:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T07:46:48.000Z", "max_issues_repo_path": "hypernets/tabular/pseudo_labeling.py", "max_issues_repo_name": "DataCanvasIO/Hypernets", "max_issues_repo_head_hexsha": "4dd8b9846a3e205f03a23a770169cd1d14a98f03", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2020-08-06T02:06:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T03:34:35.000Z", "max_forks_repo_path": "hypernets/tabular/pseudo_labeling.py", "max_forks_repo_name": "DataCanvasIO/Hypernets", "max_forks_repo_head_hexsha": "4dd8b9846a3e205f03a23a770169cd1d14a98f03", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 170, "max_forks_repo_forks_event_min_datetime": "2020-08-14T08:39:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T12:58:17.000Z", "avg_line_length": 36.3611111111, "max_line_length": 103, "alphanum_fraction": 0.6049146931, "include": true, "reason": "import numpy", "num_tokens": 2094}
|
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/config.hpp>
#ifdef BOOST_MSVC
# pragma warning(disable: 4244) // no conversion warnings, please
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/functional/forward_adapter.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/blank.hpp>
#include <boost/noncopyable.hpp>
#include <memory>
template <class Base = boost::blank>
class test_func : public Base
{
int val;
public:
test_func(int v) : val(v) { }
template<class B>
test_func(test_func<B> const & that)
: val(that.val)
{ }
template<class B> friend class test_func;
int operator()(int & l, int const & r) const
{
return l=r+val;
}
long operator()(int & l, int const & r)
{
return -(l=r+val);
}
char operator()(int& l, int& r)
{
return l=r+val;
}
template <typename Sig>
struct result
{
typedef void type;
};
// ensure result_of argument types are what's expected
// note: this is *not* how client code should look like
template <class Self>
struct result< Self const(int&,int const&) > { typedef int type; };
template <class Self>
struct result< Self(int&,int const&) > { typedef long type; };
template <class Self>
struct result< Self(int&,int&) > { typedef char type; };
};
enum { int_, long_, char_ };
int type_of(int) { return int_; }
int type_of(long) { return long_; }
int type_of(char) { return char_; }
int main()
{
{
using boost::is_same;
using boost::result_of;
typedef boost::forward_adapter< test_func<> > f;
// lvalue,rvalue
BOOST_TEST(( is_same<
result_of< f(int&, int) >::type, long >::value ));
BOOST_TEST(( is_same<
result_of< f const (int&, int) >::type, int >::value ));
// lvalue,const lvalue
BOOST_TEST(( is_same<
result_of< f(int&, int const &) >::type, long >::value ));
BOOST_TEST(( is_same<
result_of< f const (int&, int const &) >::type, int >::value ));
// lvalue,lvalue
BOOST_TEST(( is_same<
result_of< f(int&, int&) >::type, char >::value ));
// result_of works differently for C++11 here, so compare
// with using it against test_func.
BOOST_TEST(( is_same<
result_of< f const (int&, int&) >::type,
result_of< test_func<> const (int&, int&)>::type >::value ));
}
{
using boost::noncopyable;
using boost::forward_adapter;
int x = 0;
test_func<noncopyable> f(7);
forward_adapter< test_func<> > func(f);
forward_adapter< test_func<noncopyable> & > func_ref(f);
forward_adapter< test_func<noncopyable> & > const func_ref_c(f);
forward_adapter< test_func<> const > func_c(f);
forward_adapter< test_func<> > const func_c2(f);
forward_adapter< test_func<noncopyable> const & > func_c_ref(f);
BOOST_TEST( type_of( func(x,1) ) == long_ );
BOOST_TEST( type_of( func_ref(x,1) ) == long_ );
BOOST_TEST( type_of( func_ref_c(x,1) ) == long_ );
BOOST_TEST( type_of( func_c(x,1) ) == int_ );
BOOST_TEST( type_of( func_c2(x,1) ) == int_ );
BOOST_TEST( type_of( func_c_ref(x,1) ) == int_ );
BOOST_TEST( type_of( func(x,x) ) == char_ );
BOOST_TEST( func(x,1) == -8 );
BOOST_TEST( func_ref(x,1) == -8 );
BOOST_TEST( func_ref_c(x,1) == -8 );
BOOST_TEST( func_c(x,1) == 8 );
BOOST_TEST( func_c2(x,1) == 8 );
BOOST_TEST( func_c_ref(x,1) == 8 );
}
return boost::report_errors();
}
|
{"hexsha": "b18f41095eec594c02e1bc3ee72b6caf9f9a78a7", "size": 4050, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "deps/src/boost_1_65_1/libs/functional/forward/test/forward_adapter.cpp", "max_stars_repo_name": "shreyasvj25/turicreate", "max_stars_repo_head_hexsha": "32e84ca16aef8d04aff3d49ae9984bd49326bffd", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-12-15T20:03:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-15T20:03:51.000Z", "max_issues_repo_path": "deps/src/boost_1_65_1/libs/functional/forward/test/forward_adapter.cpp", "max_issues_repo_name": "shreyasvj25/turicreate", "max_issues_repo_head_hexsha": "32e84ca16aef8d04aff3d49ae9984bd49326bffd", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3.0, "max_issues_repo_issues_event_min_datetime": "2021-09-08T02:18:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T00:39:44.000Z", "max_forks_repo_path": "deps/src/boost_1_65_1/libs/functional/forward/test/forward_adapter.cpp", "max_forks_repo_name": "shreyasvj25/turicreate", "max_forks_repo_head_hexsha": "32e84ca16aef8d04aff3d49ae9984bd49326bffd", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2020-10-21T17:46:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T17:46:28.000Z", "avg_line_length": 30.223880597, "max_line_length": 80, "alphanum_fraction": 0.5691358025, "num_tokens": 1036}
|
"""
Creates an augmented version of the Labeled Faces in the Wild dataset.
Run with:
python generate_dataset.py --path="/foo/bar/lfw"
"""
from __future__ import print_function, division
import os
import random
import re
import numpy as np
from scipy import misc
from ImageAugmenter import create_aug_matrices
from skimage import transform as tf
import argparse
random.seed(43)
np.random.seed(43)
# specs from http://conradsanderson.id.au/lfwcrop/
CROP_UPPER_LEFT_CORNER_X = 83
CROP_UPPER_LEFT_CORNER_Y = 92
CROP_LOWER_RIGHT_CORNER_X = 166
CROP_LOWER_RIGHT_CORNER_Y = 175
WRITE_AUG = True
WRITE_UNAUG = True
WRITE_AUG_TO = "out_aug_64x64"
WRITE_UNAUG_TO = "out_unaug_64x64"
SCALE = 64
AUGMENTATIONS = 19
def main():
"""Main method that reads the images, augments and saves them."""
parser = argparse.ArgumentParser(description="Create augmented version of LFW.")
parser.add_argument("--path", required=True, help="Path to your LFW dataset directory")
args = parser.parse_args()
ds = Dataset([args.path])
print("Found %d images total." % (len(ds.fps),))
for img_idx, image in enumerate(ds.get_images()):
print("Image %d..." % (img_idx,))
augmentations = augment(image, n=AUGMENTATIONS, hflip=True, vflip=False,
#scale_to_percent=(0.85, 1.1), scale_axis_equally=True,
scale_to_percent=(0.82, 1.10), scale_axis_equally=True,
rotation_deg=8, shear_deg=0,
translation_x_px=5, translation_y_px=5,
brightness_change=0.1, noise_mean=0.0, noise_std=0.00)
faces = [image]
faces.extend(augmentations)
for aug_idx, face in enumerate(faces):
crop = face[CROP_UPPER_LEFT_CORNER_Y:CROP_LOWER_RIGHT_CORNER_Y+1,
CROP_UPPER_LEFT_CORNER_X:CROP_LOWER_RIGHT_CORNER_X+1,
...]
#misc.imshow(face)
#misc.imshow(crop)
filename = "{:0>6}_{:0>3}.jpg".format(img_idx, aug_idx)
if WRITE_UNAUG and aug_idx == 0:
face_scaled = misc.imresize(crop, (SCALE, SCALE))
misc.imsave(os.path.join(WRITE_UNAUG_TO, filename), face_scaled)
if WRITE_AUG:
face_scaled = misc.imresize(crop, (SCALE, SCALE))
misc.imsave(os.path.join(WRITE_AUG_TO, filename), face_scaled)
print("Finished.")
def augment(image, n,
hflip=False, vflip=False, scale_to_percent=1.0, scale_axis_equally=True,
rotation_deg=0, shear_deg=0, translation_x_px=0, translation_y_px=0,
brightness_change=0.0, noise_mean=0.0, noise_std=0.0):
"""Augment an image n times.
Args:
n Number of augmentations to generate.
hflip Allow horizontal flipping (yes/no).
vflip Allow vertical flipping (yes/no)
scale_to_percent How much scaling/zooming to allow. Values are around 1.0.
E.g. 1.1 is -10% to +10%
E.g. (0.7, 1.05) is -30% to 5%.
scale_axis_equally Whether to enforce equal scaling of x and y axis.
rotation_deg How much rotation to allow. E.g. 5 is -5 degrees to +5 degrees.
shear_deg How much shearing to allow.
translation_x_px How many pixels of translation along the x axis to allow.
translation_y_px How many pixels of translation along the y axis to allow.
brightness_change How much change in brightness to allow. Values are around 0.0.
E.g. 0.2 is -20% to +20%.
noise_mean Mean value of gaussian noise to add.
noise_std Standard deviation of gaussian noise to add.
Returns:
List of numpy arrays
"""
assert n >= 0
result = []
if n == 0:
return result
width = image.shape[0]
height = image.shape[1]
matrices = create_aug_matrices(n, img_width_px=width, img_height_px=height,
scale_to_percent=scale_to_percent,
scale_axis_equally=scale_axis_equally,
rotation_deg=rotation_deg,
shear_deg=shear_deg,
translation_x_px=translation_x_px,
translation_y_px=translation_y_px)
for i in range(n):
img = np.copy(image)
matrix = matrices[i]
# random horizontal / vertical flip
if hflip and random.random() > 0.5:
img = np.fliplr(img)
if vflip and random.random() > 0.5:
img = np.flipud(img)
# random brightness adjustment
by_percent = random.uniform(1.0 - brightness_change, 1.0 + brightness_change)
img = img * by_percent
# gaussian noise
# numpy requires a std above 0
if noise_std > 0:
img = img + (255 * np.random.normal(noise_mean, noise_std, (img.shape)))
# clip to 0-255
img = np.clip(img, 0, 255).astype(np.uint8)
arr = tf.warp(img, matrix, mode="constant") # projects to float 0-1
img = np.array(arr * 255, dtype=np.uint8)
result.append(img)
return result
class Dataset(object):
"""Helper class to handle the loading of the LFW dataset dataset."""
def __init__(self, dirs):
"""Instantiate a dataset object.
Args:
dirs List of filepaths to directories. Direct subdirectories will be read.
"""
self.dirs = dirs
self.fps = self.get_filepaths(self.get_direct_subdirectories(dirs))
def get_direct_subdirectories(self, dirs):
"""Find all direct subdirectories of a list of directories.
Args:
dirs List of directories to search in.
Returns:
Set of paths to directories
"""
result = []
result.extend(dirs)
for fp_dir in dirs:
subdirs = [name for name in os.listdir(fp_dir) if os.path.isdir(os.path.join(fp_dir, name))]
subdirs = [os.path.join(fp_dir, name) for name in subdirs]
result.extend(subdirs)
return set(result)
def get_filepaths(self, dirs):
"""Find all jpg-images in provided filepaths.
Args:
dirs List of paths to directories to search in.
Returns:
List of filepaths
"""
result = []
for fp_dir in dirs:
fps = [f for f in os.listdir(fp_dir) if os.path.isfile(os.path.join(fp_dir, f))]
fps = [os.path.join(fp_dir, f) for f in fps]
fps_img = [fp for fp in fps if re.match(r".*\.jpg$", fp)]
if len(fps) != len(fps_img):
print("[Warning] directory '%s' contained %d files with extension differing from 'jpg'" % (fp_dir, len(fps)-len(fps_img)))
result.extend(fps_img)
if len(result) < 1:
print("[Warning] [Dataset] No images of extension *.ppm found in given directories.")
return result
def get_images(self, start_at=None, count=None):
"""Returns a generator of images.
Args:
start_at Index of first image to return or None.
count Maximum number of images to return or None.
Returns:
Generator of images (numpy arrays).
"""
start_at = 0 if start_at is None else start_at
end_at = len(self.fps) if count is None else start_at+count
for fp in self.fps[start_at:end_at]:
image = misc.imread(fp)
yield image
if __name__ == "__main__":
main()
|
{"hexsha": "cb53a4325ab2810412ba71eec8398d9ff9fb7071", "size": 7921, "ext": "py", "lang": "Python", "max_stars_repo_path": "dataset/generate_dataset.py", "max_stars_repo_name": "Gufra-Ycyr/face-generator2", "max_stars_repo_head_hexsha": "c721c152a4fa922a3cd802f55831e38f5d503709", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-09T01:07:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-19T18:53:44.000Z", "max_issues_repo_path": "dataset/generate_dataset.py", "max_issues_repo_name": "donPabloNow/face-generator", "max_issues_repo_head_hexsha": "42ffd44addde2f41899ff2056e387a012778d1cf", "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": "dataset/generate_dataset.py", "max_forks_repo_name": "donPabloNow/face-generator", "max_forks_repo_head_hexsha": "42ffd44addde2f41899ff2056e387a012778d1cf", "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.4132653061, "max_line_length": 138, "alphanum_fraction": 0.5818709759, "include": true, "reason": "import numpy,from scipy", "num_tokens": 1844}
|
import time
from dataclasses import dataclass
from pathlib import Path
import logging
import math
import numpy as np
import networkx as nx
import igraph as ig
from typing import List, Dict, Tuple, Union, ClassVar
from os.path import join
import matplotlib.pyplot as plt
import pickle
import seaborn as sns
from collections import Counter
def dump_pickle(obj, fname):
logging.error(f'Dumping pickle at {fname!r}')
pickle.dump(obj, open(fname, 'wb'))
return
def load_pickle(fname):
return pickle.load(open(fname, 'rb'))
def get_graph(gname: str, basedir: str) -> Tuple[nx.Graph, str]:
if gname == 'sample':
g = nx.Graph()
g.add_nodes_from(range(5), value='blue')
g.add_nodes_from(range(5, 9), value='red')
g.add_edges_from([(0, 1), (0, 3), (0, 4),
(1, 2), (1, 4), (1, 5),
(2, 3), (2, 4), (2, 8),
(3, 4),
(5, 6), (5, 7), (5, 8),
(6, 7), (6, 8),
(7, 8)]) # properly labeled
g.name = 'sample'
elif gname.endswith('.gpickle'):
g = nx.read_gpickle(gname)
g.name = Path(gname).stem
else:
if gname in ('waterloo', 'grenoble', 'uppsala'):
g = nx.read_gpickle(f'../snap_data/cleaned/{gname}_lcc_attr.gpickle')
try:
g = nx.read_gml(join(basedir, 'input', f'{gname}.gml'))
except Exception:
path = join(basedir, 'input', f'{gname}.g')
g = nx.read_edgelist(path, nodetype=int, create_using=nx.Graph())
g.remove_edges_from(nx.selfloop_edges(g))
if not nx.is_connected(g):
nodes_lcc = max(nx.connected_components(g), key=len)
g = g.subgraph(nodes_lcc).copy()
name = g.name
g = nx.convert_node_labels_to_integers(g, label_attribute='orig_label')
g.name = name
logging.error(f'{gname!r}, n = {g.order():,d}, m = {g.size():,d}')
return g, 'value'
def draw_igraph(ig_g, color_map=None, bbox=(0, 0, 100, 100)):
if color_map is not None:
vals = ig_g.vs['value']
vertex_color = [color_map[val] for val in vals]
else:
vertex_color = ['black' for v in ig_g.vs]
fig = ig.plot(ig_g, bbox=bbox, vertex_color=vertex_color, )
return fig
def igraph_read_gml(fname):
ig_g: ig.Graph = ig.Graph.Read_GML(fname)
vertex_attrs = ig_g.vs.attributes()
keep = 'id', 'value'
# turn everything into int, and drop anything that is not '
for vertex_attr in vertex_attrs:
if vertex_attr not in keep:
del ig_g.vs[vertex_attr]
else:
ig_g.vs[vertex_attr] = list(map(lambda x: int(x), ig_g.vs[vertex_attr]))
return ig_g
def draw_networkx_graph(nx_g: nx.Graph, color_map=None, node_color=None, ax=None, pos=None):
if color_map is not None:
vals = nx.get_node_attributes(nx_g, 'value').values()
node_color = [color_map[val] for val in vals]
else:
if node_color is None: node_color = 'silver'
node_shape = 'o' if nx_g.order() == 4 else 's'
if pos is None:
pos = nx.spring_layout(nx_g)
if ax is None: ax = plt.gca()
# pos = nx.rescale_layout_dict(pos, scale=0.2)
ax.margins(0.4)
ax.set_axis_off()
nx.draw_networkx(nx_g, pos=pos, ax=ax,
node_color=node_color, node_size=300, edgecolors='black', node_shape=node_shape,
edge_color='black', width=2, with_labels=False)
return
def networkx_to_igraph(nx_g):
vals_dict = nx.get_node_attributes(nx_g, 'value')
mapping = {uniq_val: i for i, uniq_val in enumerate(set(vals_dict.values()))}
_vals = {n: mapping[v] for n, v in vals_dict.items()}
nx.set_node_attributes(nx_g, name='_value', values=_vals)
return ig.Graph.from_networkx(nx_g)
def get_color_mapping(ig_g: ig.Graph):
# returns a color mapping for all the unique values in the graph
vals = ig_g.vs['value']
palette = sns.color_palette('pastel', len(set(vals)))
mapping = {uniq_val: col for uniq_val, col in zip(set(vals), palette)}
return mapping
class MotifCounter:
"""
Class for counting motifs - both regular and colored
"""
ISOCLASS_DICT = {
2: {1: 'edge (g_21)'},
3: {2: '2-star (g_32)', 3: 'tri (g_31)'},
4: {6: '4-path (g_46)', 4: '3-star (g_45)', 10: '4-clique (g_41)',
8: '4-cycle (g_44)', 7: '4-tailed-tri (g_43)', 9: '4-chordal-cycle (g_42)'}
}
def __init__(self, name: str, input_graph: ig.Graph, basedir: str) -> None:
self.basedir = basedir
self.name: str = name
self.ig_g: ig.Graph = input_graph
self.color_map = get_color_mapping(ig_g=self.ig_g)
self.motif_hashes: Dict[str, Motif] = {} # key: WL(motif) , val: (motif_graph, freq)
self.sorted_motifs: List[Motif] = [] # all motifs sorted by freq
return
def __repr__(self) -> str:
return str(self)
def __str__(self) -> str:
st = f'name: {self.name!r}\t n: {self.ig_g.vcount():,d}\t m: {self.ig_g.ecount():,d}\n'
st += ',\t'.join(f'({motif.size}) {motif.name!r} {motif.freq:,d}x' for motif in list(self.motif_hashes.values())[: 5])
return st
def plot_motifs(self, top_k=20):
assert len(self.motif_hashes) != 0
nrows = min(4, int(math.sqrt(len(self.motif_hashes))))
ncols = top_k // nrows
fig, axs = plt.subplots(nrows=nrows, ncols=ncols)
if ncols == 1: axs = np.array([axs])
axs = axs.flatten()
axs = axs[: top_k] # plot the top k most freq motifs
fig.set_size_inches(ncols * 2.5, nrows * 2.5)
suptitle = f'{self.name}\t\tn={self.ig_g.vcount():,d}\t\tm={self.ig_g.ecount():,d}\t\t{len(self.color_map.keys())} attributes'.expandtabs()
if len(self.sorted_motifs) == 0:
self.sorted_motifs = sorted(self.motif_hashes.values(), reverse=True)
for motif, ax in zip(self.sorted_motifs, axs):
color_map = self.color_map if motif.is_colored else None
motif.plot(ax=ax, color_map=color_map)
plt.suptitle(suptitle, fontsize=18, y=0.99)
plt.tight_layout(h_pad=4, w_pad=2)
plt.show()
return
def count(self, ks=(3, 4), overwrite=True) -> None:
fname = Path(join(self.basedir, 'output', 'motifs', f'{self.name}_motif_hash.pkl'))
if fname.exists() and not overwrite:
print(f'Existing Motif pickle found at {fname.stem!r}, skipping')
self.motif_hashes = load_pickle(fname)
else:
for k in ks:
assert k in (3, 4), 'k must be 3 or 4'
self.ig_g.motifs_randesu(size=k, callback=self.callback)
dump_pickle(self.motif_hashes, fname)
return
def callback(self, ig_g: ig.Graph, nodes_in_motif: List[int], iso_class: int):
k = len(nodes_in_motif)
motif_sg: ig.Graph = ig_g.subgraph(nodes_in_motif)
motif_sg_nx = motif_sg.to_networkx()
motif_hash_normal = nx.weisfeiler_lehman_graph_hash(motif_sg_nx)
motif_hash_colored = nx.weisfeiler_lehman_graph_hash(motif_sg_nx, node_attr='value')
if motif_hash_normal not in self.motif_hashes:
motif = Motif(graph=self.name, name=MotifCounter.ISOCLASS_DICT[k][iso_class], size=k,
iso_class=iso_class, freq=0, is_colored=False, sg_nx=motif_sg_nx, m=motif_sg_nx.size())
self.motif_hashes[motif_hash_normal] = motif
self.motif_hashes[motif_hash_normal].freq += 1 # increase the freq
if motif_hash_colored not in self.motif_hashes:
motif = Motif(graph=self.name, name=MotifCounter.ISOCLASS_DICT[k][iso_class], size=k,
iso_class=iso_class, freq=0, is_colored=True, sg_nx=motif_sg_nx, m=motif_sg_nx.size())
self.motif_hashes[motif_hash_colored] = motif
self.motif_hashes[motif_hash_colored].freq += 1 # increase the freq
return
@dataclass
class Motif:
"""
A class for motifs
"""
graph: str
name: str
iso_class: int
size: int
sg_nx: nx.Graph
m: int
is_colored: bool
freq: int
NODE_POS: ClassVar[Dict] = {0: (0.0, 0.0), 1: (1.0, 0.0), 2: (1.0, 1.0), 3: (0.0, 1.0)}
def __eq__(self, other):
return hash(self) == hash(other)
def __hash__(self):
if self.is_colored:
wl_hash = nx.weisfeiler_lehman_graph_hash(self.sg_nx, node_attr='value')
else:
wl_hash = nx.weisfeiler_lehman_graph_hash(self.sg_nx)
return wl_hash
def __gt__(self, other):
return self.freq > other.freq
def plot(self, ax, color_map):
pos = Motif.NODE_POS
title = f'{self.name} {self.freq:,d}x'
draw_networkx_graph(self.sg_nx, ax=ax, pos=pos, color_map=color_map)
ax.set_title(title)
return
def main():
basedir = '/data/ssikdar/Attributed-VRG/'
names = ['karate', 'football', 'polbooks', 'wisconsin', 'texas', 'cornell',
'polblogs', 'cora', 'citeseer', 'film', 'chameleon', 'pubmed', 'squirrel']
for name in names[: 5]:
graph_filename = join(basedir, 'input', f'{name}.gml')
print(f'Reading ', name)
ig_g: ig.Graph = igraph_read_gml(graph_filename)
mc = MotifCounter(name=name, input_graph=ig_g, basedir=basedir)
start = time.perf_counter()
mc.count(ks=[3, 4], overwrite=False)
# mc.plot_motifs()
end = time.perf_counter()
print(f'Counting motifs for {name!r} took {end - start:.2g} sec')
break
return
if __name__ == '__main__':
main()
|
{"hexsha": "0862390ccdbd91ccc8b3db2cfeeca9f0ce5bcfe4", "size": 9719, "ext": "py", "lang": "Python", "max_stars_repo_path": "VRG/src/subgraph_enumeration.py", "max_stars_repo_name": "satyakisikdar/Attributed-VRG", "max_stars_repo_head_hexsha": "502375d6a62eb84563c2fb6786e2c257edc32e0c", "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": "VRG/src/subgraph_enumeration.py", "max_issues_repo_name": "satyakisikdar/Attributed-VRG", "max_issues_repo_head_hexsha": "502375d6a62eb84563c2fb6786e2c257edc32e0c", "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": "VRG/src/subgraph_enumeration.py", "max_forks_repo_name": "satyakisikdar/Attributed-VRG", "max_forks_repo_head_hexsha": "502375d6a62eb84563c2fb6786e2c257edc32e0c", "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.4645390071, "max_line_length": 147, "alphanum_fraction": 0.603971602, "include": true, "reason": "import numpy,import networkx", "num_tokens": 2817}
|
# pylint: disable=missing-function-docstring, missing-module-docstring/
import numpy as np
from pyccel.decorators import inline
pi = 3.14159
@inline
def get_powers(s : int):
return s, s*s, s*s*s
@inline
def power_4(s : int):
tmp = s*s
return tmp*tmp
@inline
def f(s : int):
return power_4(s) / 2
@inline
def sin_base_1(d : float):
return np.sin(2*pi*d)
@inline
def fill_pi(a : 'float[:]'):
pi = 3.14159
for i in range(a.shape[0]):
a[i] = pi
def not_inline():
return 1.602e-19
@inline
def positron_charge():
return -not_inline()
if __name__ == '__main__':
print(get_powers(3))
a,b,c = get_powers(4)
print(a,b,c)
print(power_4(5))
print(f(3))
print(sin_base_1(0.5))
print(sin_base_1(0.7))
arr = np.empty(4)
fill_pi(arr)
print(arr)
|
{"hexsha": "e983886ddf06ea5192b71b99fabaecc0b4b1fccb", "size": 822, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/pyccel/scripts/decorators_inline.py", "max_stars_repo_name": "nandiniraja348/pyccel", "max_stars_repo_head_hexsha": "d857efcb8ff327f72473daeb86903c7e9ef93a36", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-08-31T14:11:55.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-05T04:47:58.000Z", "max_issues_repo_path": "tests/pyccel/scripts/decorators_inline.py", "max_issues_repo_name": "nandiniraja348/pyccel", "max_issues_repo_head_hexsha": "d857efcb8ff327f72473daeb86903c7e9ef93a36", "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/pyccel/scripts/decorators_inline.py", "max_forks_repo_name": "nandiniraja348/pyccel", "max_forks_repo_head_hexsha": "d857efcb8ff327f72473daeb86903c7e9ef93a36", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-02-13T23:46:49.000Z", "max_forks_repo_forks_event_max_datetime": "2018-02-13T23:46:49.000Z", "avg_line_length": 17.125, "max_line_length": 71, "alphanum_fraction": 0.6228710462, "include": true, "reason": "import numpy", "num_tokens": 274}
|
#include <boost/qvm/mat_traits_defaults.hpp>
|
{"hexsha": "5c2c16ce5328a38a5fe34c129c492200bccd614d", "size": 45, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/boost_qvm_mat_traits_defaults.hpp", "max_stars_repo_name": "miathedev/BoostForArduino", "max_stars_repo_head_hexsha": "919621dcd0c157094bed4df752b583ba6ea6409e", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 10.0, "max_stars_repo_stars_event_min_datetime": "2018-03-17T00:58:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-06T02:48:49.000Z", "max_issues_repo_path": "src/boost_qvm_mat_traits_defaults.hpp", "max_issues_repo_name": "miathedev/BoostForArduino", "max_issues_repo_head_hexsha": "919621dcd0c157094bed4df752b583ba6ea6409e", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-03-26T15:17:35.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:55:08.000Z", "max_forks_repo_path": "src/boost_qvm_mat_traits_defaults.hpp", "max_forks_repo_name": "miathedev/BoostForArduino", "max_forks_repo_head_hexsha": "919621dcd0c157094bed4df752b583ba6ea6409e", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 4.0, "max_forks_repo_forks_event_min_datetime": "2019-05-28T21:06:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-06T03:06:52.000Z", "avg_line_length": 22.5, "max_line_length": 44, "alphanum_fraction": 0.8222222222, "num_tokens": 10}
|
import warnings
import numpy as np
import pytest
import theano
import theano.tensor as tt
from theano import config, scalar
from theano.gof import Apply, Op, Type, utils
from theano.tensor.basic import _allclose
@pytest.fixture(scope="module", autouse=True)
def set_theano_flags():
with theano.change_flags(compute_test_value="raise"):
yield
# Used in TestComputeTestValue.test_no_perform
class IncOneC(Op):
"""
An Op with only a C (c_code) implementation
"""
__props__ = ()
def make_node(self, input):
input = scalar.as_scalar(input)
output = input.type()
return Apply(self, [input], [output])
def c_code_cache_version(self):
return (1,)
def c_code(self, node, name, inputs, outputs, sub):
(x,) = inputs
(z,) = outputs
return f"{z} = {x} + 1;"
class TestComputeTestValue:
def test_destroy_map(self):
class SomeType(Type):
def filter(self, data, strict=False, allow_downcast=None):
return data
class InplaceOp(Op):
__props__ = ()
def __init__(self, inplace):
if inplace:
self.destroy_map = {0: [0]}
super().__init__()
def make_node(self, input):
return Apply(self, [input], [input.type()])
def perform(self, node, inputs, outputs):
outputs[0][0] = inputs[0]
test_input = SomeType()()
orig_object = object()
test_input.tag.test_value = orig_object
res = InplaceOp(False)(test_input)
assert res.tag.test_value is orig_object
res = InplaceOp(True)(test_input)
assert res.tag.test_value is not orig_object
def test_variable_only(self):
x = tt.matrix("x")
x.tag.test_value = np.random.rand(3, 4).astype(config.floatX)
y = tt.matrix("y")
y.tag.test_value = np.random.rand(4, 5).astype(config.floatX)
# should work
z = tt.dot(x, y)
assert hasattr(z.tag, "test_value")
f = theano.function([x, y], z)
assert _allclose(f(x.tag.test_value, y.tag.test_value), z.tag.test_value)
# this test should fail
y.tag.test_value = np.random.rand(6, 5).astype(config.floatX)
with pytest.raises(ValueError):
tt.dot(x, y)
def test_compute_flag(self):
x = tt.matrix("x")
y = tt.matrix("y")
y.tag.test_value = np.random.rand(4, 5).astype(config.floatX)
# should skip computation of test value
theano.config.compute_test_value = "off"
z = tt.dot(x, y)
assert not hasattr(z.tag, "test_value")
# should fail when asked by user
theano.config.compute_test_value = "raise"
with pytest.raises(ValueError):
tt.dot(x, y)
# test that a warning is raised if required
theano.config.compute_test_value = "warn"
warnings.simplefilter("error", UserWarning)
try:
with pytest.raises(UserWarning):
tt.dot(x, y)
finally:
# Restore the default behavior.
# TODO There is a cleaner way to do this in Python 2.6, once
# Theano drops support of Python 2.4 and 2.5.
warnings.simplefilter("default", UserWarning)
def test_string_var(self):
x = tt.matrix("x")
x.tag.test_value = np.random.rand(3, 4).astype(config.floatX)
y = tt.matrix("y")
y.tag.test_value = np.random.rand(4, 5).astype(config.floatX)
z = theano.shared(np.random.rand(5, 6).astype(config.floatX))
# should work
out = tt.dot(tt.dot(x, y), z)
assert hasattr(out.tag, "test_value")
tf = theano.function([x, y], out)
assert _allclose(tf(x.tag.test_value, y.tag.test_value), out.tag.test_value)
def f(x, y, z):
return tt.dot(tt.dot(x, y), z)
# this test should fail
z.set_value(np.random.rand(7, 6).astype(config.floatX))
with pytest.raises(ValueError):
f(x, y, z)
def test_shared(self):
x = tt.matrix("x")
x.tag.test_value = np.random.rand(3, 4).astype(config.floatX)
y = theano.shared(np.random.rand(4, 6).astype(config.floatX), "y")
# should work
z = tt.dot(x, y)
assert hasattr(z.tag, "test_value")
f = theano.function([x], z)
assert _allclose(f(x.tag.test_value), z.tag.test_value)
# this test should fail
y.set_value(np.random.rand(5, 6).astype(config.floatX))
with pytest.raises(ValueError):
tt.dot(x, y)
def test_ndarray(self):
x = np.random.rand(2, 3).astype(config.floatX)
y = theano.shared(np.random.rand(3, 6).astype(config.floatX), "y")
# should work
z = tt.dot(x, y)
assert hasattr(z.tag, "test_value")
f = theano.function([], z)
assert _allclose(f(), z.tag.test_value)
# this test should fail
x = np.random.rand(2, 4).astype(config.floatX)
with pytest.raises(ValueError):
tt.dot(x, y)
def test_empty_elemwise(self):
x = theano.shared(np.random.rand(0, 6).astype(config.floatX), "x")
# should work
z = (x + 2) * 3
assert hasattr(z.tag, "test_value")
f = theano.function([], z)
assert _allclose(f(), z.tag.test_value)
def test_constant(self):
x = tt.constant(np.random.rand(2, 3), dtype=config.floatX)
y = theano.shared(np.random.rand(3, 6).astype(config.floatX), "y")
# should work
z = tt.dot(x, y)
assert hasattr(z.tag, "test_value")
f = theano.function([], z)
assert _allclose(f(), z.tag.test_value)
# this test should fail
x = tt.constant(np.random.rand(2, 4), dtype=config.floatX)
with pytest.raises(ValueError):
tt.dot(x, y)
def test_incorrect_type(self):
x = tt.vector("x")
with pytest.raises(TypeError):
# Incorrect shape for test value
x.tag.test_value = np.empty((2, 2))
x = tt.fmatrix("x")
with pytest.raises(TypeError):
# Incorrect dtype (float64) for test value
x.tag.test_value = np.random.rand(3, 4)
def test_overided_function(self):
# We need to test those as they mess with Exception
# And we don't want the exception to be changed.
x = tt.matrix()
x.tag.test_value = np.zeros((2, 3), dtype=config.floatX)
y = tt.matrix()
y.tag.test_value = np.zeros((2, 2), dtype=config.floatX)
with pytest.raises(ValueError):
x.__mul__(y)
def test_scan(self):
# Test the compute_test_value mechanism Scan.
k = tt.iscalar("k")
A = tt.vector("A")
k.tag.test_value = 3
A.tag.test_value = np.random.rand(5).astype(config.floatX)
def fx(prior_result, A):
return prior_result * A
# Symbolic description of the result
result, updates = theano.scan(
fn=fx, outputs_info=tt.ones_like(A), non_sequences=A, n_steps=k
)
# We only care about A**k, but scan has provided us with A**1 through A**k.
# Discard the values that we don't care about. Scan is smart enough to
# notice this and not waste memory saving them.
final_result = result[-1]
assert hasattr(final_result.tag, "test_value")
def test_scan_err1(self):
# This test should fail when building fx for the first time
k = tt.iscalar("k")
A = tt.matrix("A")
k.tag.test_value = 3
A.tag.test_value = np.random.rand(5, 3).astype(config.floatX)
def fx(prior_result, A):
return tt.dot(prior_result, A)
with pytest.raises(ValueError) as e:
theano.scan(fn=fx, outputs_info=tt.ones_like(A), non_sequences=A, n_steps=k)
assert str(e.traceback[0].path).endswith("test_compute_test_value.py")
# We should be in the "fx" function defined above
assert e.traceback[2].name == "fx"
def test_scan_err2(self):
# This test should not fail when building fx for the first time,
# but when calling the scan's perform()
k = tt.iscalar("k")
A = tt.matrix("A")
k.tag.test_value = 3
A.tag.test_value = np.random.rand(5, 3).astype(config.floatX)
def fx(prior_result, A):
return tt.dot(prior_result, A)
with pytest.raises(ValueError):
theano.scan(
fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k
)
with pytest.raises(ValueError, match="^could not broadcast input"):
theano.scan(
fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k
)
def test_no_c_code(self):
class IncOnePython(Op):
"""
An Op with only a Python (perform) implementation
"""
__props__ = ()
def make_node(self, input):
input = scalar.as_scalar(input)
output = input.type()
return Apply(self, [input], [output])
def perform(self, node, inputs, outputs):
(input,) = inputs
(output,) = outputs
output[0] = input + 1
i = scalar.int32("i")
i.tag.test_value = 3
o = IncOnePython()(i)
# Check that the c_code function is not implemented
with pytest.raises((NotImplementedError, utils.MethodNotDefined)):
o.owner.op.c_code(o.owner, "o", ["x"], "z", {"fail": ""})
assert hasattr(o.tag, "test_value")
assert o.tag.test_value == 4
@pytest.mark.skipif(
not theano.config.cxx, reason="G++ not available, so we need to skip this test."
)
def test_no_perform(self):
i = scalar.int32("i")
i.tag.test_value = 3
# Class IncOneC is defined outside of the TestComputeTestValue
# so it can be pickled and unpickled
o = IncOneC()(i)
# Check that the perform function is not implemented
with pytest.raises((NotImplementedError, utils.MethodNotDefined)):
o.owner.op.perform(o.owner, 0, [None])
assert hasattr(o.tag, "test_value")
assert o.tag.test_value == 4
def test_disabled_during_compilation(self):
# We test that it is disabled when we include deep copy in the code
# This don't test that it is disabled during optimization, but the code do it.
init_Mu1 = theano.shared(np.zeros((5,), dtype=config.floatX)).dimshuffle("x", 0)
theano.function([], outputs=[init_Mu1])
|
{"hexsha": "92bc235c9224727b47b6e257c81acd54e0d23a26", "size": 10761, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/gof/test_compute_test_value.py", "max_stars_repo_name": "MarcoGorelli/Theano-PyMC", "max_stars_repo_head_hexsha": "55ef0e6b7380e062bdd09fcd7f820643f8521fb0", "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": "tests/gof/test_compute_test_value.py", "max_issues_repo_name": "MarcoGorelli/Theano-PyMC", "max_issues_repo_head_hexsha": "55ef0e6b7380e062bdd09fcd7f820643f8521fb0", "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": "tests/gof/test_compute_test_value.py", "max_forks_repo_name": "MarcoGorelli/Theano-PyMC", "max_forks_repo_head_hexsha": "55ef0e6b7380e062bdd09fcd7f820643f8521fb0", "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": 32.8079268293, "max_line_length": 88, "alphanum_fraction": 0.5844252393, "include": true, "reason": "import numpy,import theano,from theano", "num_tokens": 2617}
|
#! /usr/bin/env python
"""
Spatial adjust and test precision
"""
import numpy as np
from sklearn import linear_model
from sklearn import cross_validation
from sklearn.metrics import explained_variance_score
from sklearn.metrics import mean_squared_error
import argparse, sys, csv, os, time
def getArgs():
parser = argparse.ArgumentParser(
description = """Affine spatial transformation with simulated error"""
)
parser.add_argument(
"-c",
"--controlPoints",
type = str,
required = True,
help = "Control points csv file. See README doc for formating instructions."
)
parser.add_argument(
"-u",
"--unprojectPoints",
type = str,
required = True,
help = "Unprojected points on plot coordinate system"
)
parser.add_argument(
"-x",
"--xname",
type = str,
required = True,
help = "field name for x-coordinate in unprojected points file"
)
parser.add_argument(
"-y",
"--yname",
type = str,
required = True,
help = "field name for y-coordinate in unprojected points file"
)
parser.add_argument(
"-i",
"--uid",
type = str,
required = True,
help = "field name for unique identifier of point in unprojected points file"
)
parser.add_argument(
"-n",
"--nsims",
type = str,
required = False,
help = """Number of simulations"""
)
parser.add_argument(
"-o",
"--output",
type = str,
required = True,
help = """Output file prefix"""
)
return parser.parse_args()
def getIndex(header, item):
for i, elem in enumerate(header):
if elem.lower() == item.lower():
return i
return None
def getData(path, fields):
""" reads in a CSV file and returns data table for analysis """
data = []
with open(path, 'rUb') as f:
indata = csv.reader(f)
var_indices = []
for i, line in enumerate(indata):
if i == 0:
header = line
continue
if 'NA' in line:
continue # remove lines with NA's
data.append(line)
data = np.array(data, dtype=np.float64)
#print header
indices = np.array([getIndex(header, item) for item in fields])
header = [header[i] for i in indices]
data = data[:, indices]
return header, data
def getControl(path):
data = []
with open(path, "rU") as f:
for i, line in enumerate(f):
ls = line.strip().split(',')
if i == 0:
continue
data.append(ls)
data = np.array(data, dtype=np.float64)
return data
def writeOut(data, header, filename):
if header is not None:
print "\nInitializing {0} file output".format(filename)
with open(filename, "w") as f:
header_str = ",".join(header)+"\n"
f.write(header_str)
for line in data:
row = ",".join([str(elem) for elem in line])+"\n"
f.write(row)
else:
print "\nInitializing {0} file output".format(filename)
with open(filename, "a") as f:
for line in data:
row = ",".join([str(elem) for elem in line])+"\n"
f.write(row)
print "Wrote {0} to disk\n".format(filename)
def affine_parameterization(utm_e, utm_n, x, y):
X = np.column_stack((x, y))
#print X
affine_x = linear_model.LinearRegression().fit(X, utm_e)
affine_y = linear_model.LinearRegression().fit(X, utm_n)
print affine_x.score(X, utm_e)
print affine_x.coef_
#print affine_x.get_params()
print np.sqrt(mean_squared_error(utm_e, affine_x.predict(X)))
print affine_y.score(X, utm_n)
print affine_y.coef_
#print affine_y.get_params()
print np.sqrt(mean_squared_error(utm_n, affine_y.predict(X)))
return affine_x, affine_y
def affine_transformation(X_unprj, affine_x, affine_y, args, header):
# Affine transformation parameterized.
# Project unprojected points to UTM coordinate space
x_pred = affine_x.predict(X_unprj)
y_pred = affine_y.predict(X_unprj)
#print x_pred, y_pred
return x_pred, y_pred
if __name__ == "__main__":
t_i = time.time()
args = getArgs()
initDir = os.getcwd()
fields = [
args.uid,
args.xname,
args.yname
]
header, data = getData(args.unprojectPoints, fields)
print header, data
np.random.seed(10)
cp = getControl(args.controlPoints)
print cp
print cp.shape
if cp.shape[1] == 6 and args.nsims is not None:
sim = True
print "Will simulate {} realizations of corners.".format(args.nsims)
elif args.nsims is None:
sim = False
elif cp.shape[1] == 4:
sim = False
if args.nsims is not None:
print "Cannot simulate error because no utm_e and utm_n se's"
print "are included in control points file."
else:
print "Incorrect dimensions for control points csv."
raise Exception
# Affine Spatial Transformation Parameterization
# x' = Ax + By + C
# y' = Dx + Ey + F
#print cp[:,0:4]
utm_e, utm_n, x, y = cp[:,0], cp[:,1], cp[:,2], cp[:,3]
affine_x, affine_y = affine_parameterization(utm_e, utm_n, x, y ) # utm_e, utm_n, x, y
# data, affine_x, affine_y, args, header
uids = data[:, getIndex(header, args.uid)]
gx = data[:, getIndex(header, args.xname)]
gy = data[:, getIndex(header, args.yname)]
X_unprj = np.column_stack(
(
gx,
gy
)
)
x_pred, y_pred = affine_transformation(X_unprj, affine_x, affine_y, args, header)
projected_data = np.column_stack(
(
uids,
gx,
gy,
x_pred,
y_pred
)
)
projected_data_header = ["uid", "gx", "gy", "x_pred", "y_pred"]
writeOut(projected_data, projected_data_header, args.output+"-projected.csv") # data, header, filename
# Simulated locations
if sim:
# error cols 4 and 5 from cp csv
utm_se_e = cp[:,4]
utm_se_n = cp[:,5]
sim_data_header = ["iter", "uid", "gx", "gy", "x_pred", "y_pred"]
for i in range(int(args.nsims)):
print "Simulation number {}".format(i+1)
evec = np.zeros(cp.shape[0])
nvec = np.zeros(cp.shape[0])
for j, row in enumerate(cp):
evec[j] = np.random.normal(row[0],row[4], 1)
nvec[j] = np.random.normal(row[1],row[5], 1)
affine_x, affine_y = affine_parameterization(evec, nvec, x, y)
x_pred, y_pred = affine_transformation(X_unprj, affine_x, affine_y, args, header)
iteration = i + np.zeros(x_pred.shape[0])
sim_data = np.column_stack(
(
iteration,
uids,
gx,
gy,
x_pred,
y_pred
)
)
if i == 0:
writeOut(sim_data, sim_data_header, args.output+"-sim.csv") # data, header, filename
else:
writeOut(sim_data, None, args.output+"-sim.csv") # data, header, filename
t_f = time.time()
print "Spatially adjusted data in {} seconds".format(t_f - t_i)
|
{"hexsha": "bcb692bb9aa8114502c54435e5e15d9a4c3ac5d0", "size": 6314, "ext": "py", "lang": "Python", "max_stars_repo_path": "afproj.py", "max_stars_repo_name": "africker/afproj-1", "max_stars_repo_head_hexsha": "91568a12708f7a3d2eaddf112060d957c2a3e5e9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-03-01T00:43:33.000Z", "max_stars_repo_stars_event_max_datetime": "2015-03-01T00:43:33.000Z", "max_issues_repo_path": "afproj.py", "max_issues_repo_name": "africker/afproj-1", "max_issues_repo_head_hexsha": "91568a12708f7a3d2eaddf112060d957c2a3e5e9", "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": "afproj.py", "max_forks_repo_name": "africker/afproj-1", "max_forks_repo_head_hexsha": "91568a12708f7a3d2eaddf112060d957c2a3e5e9", "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.7368421053, "max_line_length": 103, "alphanum_fraction": 0.6683560342, "include": true, "reason": "import numpy", "num_tokens": 1838}
|
"""{ATAM} Active Transport Modelling Functions"""
# Dependencies
import os
import pandas as pd
import numpy as np
import csv
import networkx as nx
# Model class
class Model:
"Model class"
# Init
def __init__(self, run_name):
# Name
self.run_name = run_name
# Input files (set as placeholders)
self.network_input_file = ""
self.connectors_input_file = ""
self.walk_demand_input_file = ""
self.cycle_demand_input_file = ""
# Directory structure
self.base_dir = os.getcwd()
self.input_dir = os.path.join(self.base_dir, '01_inputs')
self.scripts_dir = os.path.join(self.base_dir, '02_scripts')
self.output_dir = os.path.join(self.base_dir, '03_outputs')
self.run_output_dir = self.safe_create_directory(os.path.join(self.output_dir, run_name))
# Greeting (just for fun)
def greet(self):
print("Hello, I'm ATAM!")
# Print self info
def attributes(self):
print("Run name:", self.run_name)
print("Base directory:", self.base_dir)
print("Inputs directory:", self.input_dir)
print("Outputs directory:", self.output_dir)
print("Run Outputs directory:", self.run_output_dir)
print("Network Inputs:", self.network_input_file)
print("Connectors Inputs:", self.connectors_input_file)
print("Cycle Demand Inputs:", self.cycle_demand_input_file)
print("Walk Demand Inputs:", self.walk_demand_input_file)
# Create directory
def safe_create_directory(self, dir_path):
isExist = os.path.exists(dir_path)
if not isExist:
# Create a new directory because it does not exist
os.makedirs(dir_path)
print("New directory created: ", dir_path)
return dir_path
# Get Network as a pandas DataFrame
def get_network(self):
# Prescribed direction links
self.network_input_fp = os.path.join(self.input_dir, '02_network', self.network_input_file)
print("Network input file:", self.network_input_fp)
self.network_inputs_df = pd.read_csv(self.network_input_fp)
self.network_columns = self.network_inputs_df.columns.tolist()
print("Network columns: ", self.network_columns)
# Create links in opposite direction
self.opposite_direction_df = pd.read_csv(self.network_input_fp)
self.opposite_direction_df.rename(columns={
"i_node": "j_node",
"i_node_x": "j_node_x",
"i_node_y": "j_node_y",
"j_node": "i_node",
"j_node_x": "i_node_x",
"j_node_y": "i_node_y",
}, inplace=True)
self.opposite_direction_df = self.opposite_direction_df[self.network_columns]
self.full_network_df = pd.concat([self.opposite_direction_df, self.network_inputs_df])
return self.full_network_df
# Get Centroid Connectors as a pandas DataFrame
def get_connectors(self):
# Prescribed direction connectors
self.connectors_input_fp = os.path.join(self.input_dir, '03_connectors', self.connectors_input_file)
print("Connectors input file:", self.connectors_input_fp)
self.connectors_input_df = pd.read_csv(self.connectors_input_fp)
self.connectors_input_df.rename(columns={
"zone_id": "i_node",
"zone_x": "i_node_x",
"zone_y": "i_node_y",
"node_id": "j_node",
"node_x": "j_node_x",
"node_y": "j_node_y",
}, inplace=True)
self.connector_columns = self.connectors_input_df.columns.tolist()
print("Connector (renamed) columns: ", self.connector_columns)
# Opposite direction connectors
self.opposite_direction_connectors_df = pd.read_csv(self.connectors_input_fp)
self.opposite_direction_connectors_df.rename(columns={
"zone_id": "j_node",
"zone_x": "j_node_x",
"zone_y": "j_node_y",
"node_id": "i_node",
"node_x": "i_node_x",
"node_y": "i_node_y"
}, inplace=True)
self.opposite_direction_connectors_df = self.opposite_direction_connectors_df[self.connector_columns]
self.full_connectors_df = pd.concat([self.opposite_direction_connectors_df, self.connectors_input_df])
return self.full_connectors_df
# Build network graph
def build_network_graph(self, network_df, connectors_df):
# Concat network_df and connectors_df
network_df['edge_type'] = "network"
connectors_df['edge_type'] = "connector"
self.graph_network_df = pd.concat([network_df, connectors_df])
self.graph_network_df = self.graph_network_df[['i_node', 'j_node', 'cost_minutes', 'length_metres', 'edge_type','WKT']]
# Export graph to CSV
graph_csv_fp = os.path.join(self.run_output_dir, 'network_graph.csv')
self.graph_network_df.to_csv(graph_csv_fp, index=False)
print("Exported network graph to ", graph_csv_fp)
# Greate graph
self.G = nx.from_pandas_edgelist(
self.graph_network_df,
source='i_node',
target='j_node',
edge_attr=['cost_minutes'],
create_using=nx.DiGraph
)
return self.graph_network_df
# Get demand as a pandas DataFrame
def get_demand(self, demand_input_fp):
self.demand_input_fp = os.path.join(self.input_dir, '04_demand', demand_input_fp)
print("Demand input file:", self.demand_input_fp)
self.demand_df = pd.read_csv(self.demand_input_fp)
self.demand_columns = self.demand_df.columns.tolist()
print("Demand columns: ", self.demand_columns)
return self.demand_df
# Assign demand to network
def get_path(self, origin_zone, dest_zone, demand, cost_attribute):
# Get path
node_path = nx.dijkstra_path(self.G, origin_zone, dest_zone, cost_attribute)
# Post-process results into df
df = pd.DataFrame()
df['i_node'] = node_path[:-1]
df['j_node'] = node_path[1:]
df['origin_zone'] = origin_zone
df['dest_zone'] = dest_zone
df['demand'] = demand
df['segment_num'] = np.arange(df.shape[0])
df['segment_num'] = df['segment_num']+1
#Join all network attributes to the results df
self.last_path_output_df = pd.merge(
df,
self.graph_network_df,
how='inner',
left_on=['i_node', 'j_node'],
right_on = ['i_node', 'j_node']
)
return self.last_path_output_df
# Assign demand matrix
def assign_demand(self, demand_df):
self.path_outputs_df = pd.DataFrame()
for index, row in demand_df.iterrows():
origin_zone = row['origin_zone']
dest_zone = row['dest_zone']
demand = row['demand']
cost_attribute='cost_minutes'
print(index, ": orig=", origin_zone, ", dest=", dest_zone, ", demand=",demand)
try:
self.get_path(origin_zone, dest_zone, demand, cost_attribute)
self.path_outputs_df = pd.concat([self.path_outputs_df, self.last_path_output_df])
except:
print(" An error occurred skimming origin {}, destination {}".format(origin_zone, dest_zone))
# Format output
self.path_outputs_df['od_pair'] = self.path_outputs_df['origin_zone'].astype(str) + "_" + self.path_outputs_df['dest_zone'].astype(str)
# Export dataframe to CSV
path_output_csv_fp = os.path.join(self.run_output_dir, 'path_outputs.csv')
self.path_outputs_df.to_csv(path_output_csv_fp, index=False)
print("Exported paths to ", path_output_csv_fp)
return self.path_outputs_df
# Process link volume outputs from path file
def output_link_results(self, paths_file):
# Summarise paths to links and sum demand
path_df = pd.read_csv(paths_file)
self.links_df = path_df.groupby(['i_node', 'j_node', 'length_metres', 'WKT']).sum('demand')
self.links_df.reset_index(inplace=True)
self.links_df['person_km'] = self.links_df['demand'] * (self.links_df['length_metres'].astype(float)/1000)
self.links_df = self.links_df[['i_node', 'j_node', 'length_metres', 'WKT', 'demand', 'person_km']]
# Export dataframe to CSV
self.link_output_csv_fp = os.path.join(self.run_output_dir, 'link_outputs.csv')
self.links_df.to_csv(self.link_output_csv_fp, index=False)
print("Exported link volumes to ", self.link_output_csv_fp)
return self.links_df
# Process cost matrix output from path file
def output_cost_matrix(self, paths_file):
path_df = pd.read_csv(paths_file)
self.matrix_df = path_df.groupby(['od_pair','origin_zone', 'dest_zone']).agg({'demand':'mean', 'length_metres':'sum'})
self.matrix_df.reset_index(inplace=True)
self.matrix_df = self.matrix_df[['origin_zone', 'dest_zone','demand','length_metres']]
# Export dataframe to CSV
self.matrix_output_csv_fp = os.path.join(self.run_output_dir, 'matrix_outputs.csv')
self.matrix_df.to_csv(self.matrix_output_csv_fp, index=False)
print("Exported matrix output to ", self.matrix_output_csv_fp)
return self.matrix_df
# Process Select Link Analysis ("SLA") output from path file
def run_select_link_analysis(self, paths_file, i_node, j_node, location_desc):
self.sla_output_dir = self.safe_create_directory(os.path.join(self.run_output_dir, 'select_link_analysis'))
path_df = pd.read_csv(paths_file)
ij_string = str(i_node)+"_"+str(j_node)
# Filter paths to where i_node and j_node are the selected link
paths_step1_df = path_df[path_df['i_node']==i_node]
paths_step2_df = paths_step1_df[paths_step1_df['j_node']==j_node]
# Get list of origin_zone and dest_zone for those paths
self.sla_od_pairs_df = paths_step2_df.groupby(['origin_zone', 'dest_zone']).sum()
self.sla_od_pairs_df.reset_index(inplace=True)
self.sla_od_pairs_df = self.sla_od_pairs_df[['origin_zone', 'dest_zone']]
self.sla_od_pairs_df['location_desc'] = location_desc
# Export Path Detailed Outputs
self.sla_od_pairs_csv_fp = os.path.join(self.sla_output_dir, 'sla_{}_od_pairs.csv'.format(ij_string))
self.sla_od_pairs_df.to_csv(self.sla_od_pairs_csv_fp, index=False)
print("Exported SLA OD Pairs to ", self.sla_od_pairs_csv_fp)
# Get full paths for SLA OD pairs
self.sla_paths_df = pd.merge(
path_df, # Path outputs df
self.sla_od_pairs_df, # dataframe with OD pairs using selected link
how='inner',
left_on=['origin_zone', 'dest_zone'],
right_on = ['origin_zone', 'dest_zone']
)
# Export Path Detailed Outputs
self.sla_paths_csv_fp = os.path.join(self.sla_output_dir, 'sla_{}_path_outputs.csv'.format(ij_string))
self.sla_paths_df.to_csv(self.sla_paths_csv_fp, index=False)
print("Exported SLA paths to ", self.sla_paths_csv_fp)
# Summarise SLA paths to links and sum demand
self.sla_links_df = self.sla_paths_df.groupby(['location_desc','i_node', 'j_node', 'length_metres', 'WKT']).sum('demand')
self.sla_links_df.reset_index(inplace=True)
self.sla_links_df['person_km'] = self.sla_links_df['demand'] * (self.sla_links_df['length_metres'].astype(float)/1000)
self.sla_links_df = self.sla_links_df[['location_desc','i_node', 'j_node', 'length_metres', 'WKT', 'demand', 'person_km']]
# Export dataframe to CSV
self.sla_link_output_csv_fp = os.path.join(self.sla_output_dir, 'sla_{}_link_outputs.csv'.format(ij_string))
self.sla_links_df.to_csv(self.sla_link_output_csv_fp, index=False)
print("Exported SLA link volumes to ", self.sla_link_output_csv_fp)
return self.sla_od_pairs_df, self.sla_paths_df, self.sla_links_df
# Run a batch of select link analyses
def select_link_analysis(self, paths_file):
self.sla_input_file = os.path.join(self.input_dir, '05_analysis', 'sla_links.csv')
sla_input_df = pd.read_csv(self.sla_input_file)
self.all_sla_od_pairs_df = pd.DataFrame()
self.all_sla_paths_df = pd.DataFrame()
self.all_sla_links_df = pd.DataFrame()
for index, row in sla_input_df.iterrows():
i_node = row['i_node']
j_node = row['j_node']
location_desc = row['location_desc']
paths_file = paths_file
print(index, ": i_node=", i_node, ", j_node=", j_node, ", location_desc=",location_desc)
try:
self.sla_od_pairs_df, self.sla_paths_df, self.sla_links_df = self.run_select_link_analysis(paths_file, i_node, j_node, location_desc)
self.all_sla_od_pairs_df = pd.concat([self.sla_od_pairs_df, self.all_sla_od_pairs_df])
self.all_sla_paths_df = pd.concat([self.sla_paths_df, self.all_sla_paths_df])
self.all_sla_links_df = pd.concat([self.sla_links_df, self.all_sla_links_df])
except:
print(" An error occurred: {}".format(Exception))
# Export dataframes to CSV
all_sla_od_pairs_fp = os.path.join(self.run_output_dir, 'sla_od_pairs.csv')
self.all_sla_od_pairs_df.to_csv(all_sla_od_pairs_fp, index=False)
all_sla_paths_fp = os.path.join(self.run_output_dir, 'sla_paths.csv')
self.all_sla_paths_df.to_csv(all_sla_paths_fp, index=False)
all_sla_links_fp = os.path.join(self.run_output_dir, 'sla_links.csv')
self.all_sla_links_df.to_csv(all_sla_links_fp, index=False)
return self.all_sla_paths_df
|
{"hexsha": "6839e24cf1f47ce04a292b09073c8e1118be17ec", "size": 14291, "ext": "py", "lang": "Python", "max_stars_repo_path": "brisbane/02_scripts/model_functions.py", "max_stars_repo_name": "atam-analytics/atam", "max_stars_repo_head_hexsha": "1d1502c43a20f13147af178098b8a3dd740a72f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-11T05:03:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-11T05:03:41.000Z", "max_issues_repo_path": "brisbane/02_scripts/model_functions.py", "max_issues_repo_name": "peterstephan/atam", "max_issues_repo_head_hexsha": "1d1502c43a20f13147af178098b8a3dd740a72f2", "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": "brisbane/02_scripts/model_functions.py", "max_forks_repo_name": "peterstephan/atam", "max_forks_repo_head_hexsha": "1d1502c43a20f13147af178098b8a3dd740a72f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-26T01:40:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T01:40:07.000Z", "avg_line_length": 43.4376899696, "max_line_length": 149, "alphanum_fraction": 0.6407529214, "include": true, "reason": "import numpy,import networkx", "num_tokens": 3283}
|
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras.utils import to_categorical
from keras.preprocessing import image
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from tqdm import tqdm
train = pd.read_csv('dataset.csv') # reading the csv file
train.head() # printing first five rows of the file
print(train.columns)
train_image = []
for i in tqdm(range(train.shape[0])):
img = image.load_img(train['image'][i],target_size=(64,64,3))
img = image.img_to_array(img)
img = img/255
train_image.append(img)
X = np.array(train_image)
print(X.shape)
y = np.array(train.drop(['image'],axis=1))
print(y.shape)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42, test_size=0.3)
model = Sequential()
model.add(Conv2D(filters=8, kernel_size=(3, 3), activation="relu", input_shape=(64,64,3)))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(filters=16, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(filters=32, kernel_size=(3, 3), activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(filters=32, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(2, activation='sigmoid'))
model.summary()
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(X_train, y_train, epochs=10, validation_data=(X_test, y_test), batch_size=16)
model.save("helmet_mask_model.h5")
|
{"hexsha": "8e004e1d6ca10dde2ba1b1a67ff51d5e9e9f69c5", "size": 1931, "ext": "py", "lang": "Python", "max_stars_repo_path": "interview/task2/model_building.py", "max_stars_repo_name": "st186/Task_for_ComputerVision", "max_stars_repo_head_hexsha": "c48b5667acec60f28e504432863a96336d4d6679", "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": "interview/task2/model_building.py", "max_issues_repo_name": "st186/Task_for_ComputerVision", "max_issues_repo_head_hexsha": "c48b5667acec60f28e504432863a96336d4d6679", "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": "interview/task2/model_building.py", "max_forks_repo_name": "st186/Task_for_ComputerVision", "max_forks_repo_head_hexsha": "c48b5667acec60f28e504432863a96336d4d6679", "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.6557377049, "max_line_length": 90, "alphanum_fraction": 0.7332988089, "include": true, "reason": "import numpy", "num_tokens": 528}
|
[STATEMENT]
lemma INF_limit_inter:
assumes hyp: "\<exists>\<^sub>\<infinity> n. w n \<in> S"
and fin: "finite (S \<inter> range w)"
shows "\<exists>a. a \<in> limit w \<inter> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>a. a \<in> limit w \<inter> S
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
assume contra: "\<not>(\<exists>a. a \<in> limit w \<inter> S)"
[PROOF STATE]
proof (state)
this:
\<nexists>a. a \<in> limit w \<inter> S
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
hence "\<forall>a\<in>S. finite {n. w n = a}"
[PROOF STATE]
proof (prove)
using this:
\<nexists>a. a \<in> limit w \<inter> S
goal (1 subgoal):
1. \<forall>a\<in>S. finite {n. w n = a}
[PROOF STEP]
by (auto simp add: limit_def Inf_many_def)
[PROOF STATE]
proof (state)
this:
\<forall>a\<in>S. finite {n. w n = a}
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
with fin
[PROOF STATE]
proof (chain)
picking this:
finite (S \<inter> range w)
\<forall>a\<in>S. finite {n. w n = a}
[PROOF STEP]
have "finite (UN a:S \<inter> range w. {n. w n = a})"
[PROOF STATE]
proof (prove)
using this:
finite (S \<inter> range w)
\<forall>a\<in>S. finite {n. w n = a}
goal (1 subgoal):
1. finite (\<Union>a\<in>S \<inter> range w. {n. w n = a})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (\<Union>a\<in>S \<inter> range w. {n. w n = a})
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite (\<Union>a\<in>S \<inter> range w. {n. w n = a})
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
have "(UN a:S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<Union>a\<in>S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Union>a\<in>S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Union>a\<in>S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
note hyp
[PROOF STATE]
proof (state)
this:
\<exists>\<^sub>\<infinity>n. w n \<in> S
goal (1 subgoal):
1. \<nexists>a. a \<in> limit w \<inter> S \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite (\<Union>a\<in>S \<inter> range w. {n. w n = a})
(\<Union>a\<in>S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}
\<exists>\<^sub>\<infinity>n. w n \<in> S
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
finite (\<Union>a\<in>S \<inter> range w. {n. w n = a})
(\<Union>a\<in>S \<inter> range w. {n. w n = a}) = {n. w n \<in> S}
\<exists>\<^sub>\<infinity>n. w n \<in> S
goal (1 subgoal):
1. False
[PROOF STEP]
by (simp add: Inf_many_def)
[PROOF STATE]
proof (state)
this:
False
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 1425, "file": null, "length": 16}
|
require(httr)
data = '{"keywords":"php","page":1,"searchMode":1}'
res <- httr::POST(url = 'http://us.jooble.org/api/xxxxxxxxxxxxxxxx', body = data)
|
{"hexsha": "991ab6270e18720cb13355b3a792b842740208f1", "size": 150, "ext": "r", "lang": "R", "max_stars_repo_path": "fixtures/r/post_xpost.r", "max_stars_repo_name": "kado0413/curlconverter", "max_stars_repo_head_hexsha": "a532bd415853f350198d891e14c59babed16902e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4955, "max_stars_repo_stars_event_min_datetime": "2015-01-02T09:04:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-06T03:54:43.000Z", "max_issues_repo_path": "fixtures/r/post_xpost.r", "max_issues_repo_name": "kado0413/curlconverter", "max_issues_repo_head_hexsha": "a532bd415853f350198d891e14c59babed16902e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 242, "max_issues_repo_issues_event_min_datetime": "2015-03-27T05:59:11.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T08:36:05.000Z", "max_forks_repo_path": "fixtures/r/post_xpost.r", "max_forks_repo_name": "kado0413/curlconverter", "max_forks_repo_head_hexsha": "a532bd415853f350198d891e14c59babed16902e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 504, "max_forks_repo_forks_event_min_datetime": "2015-01-02T16:04:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-01T03:43:55.000Z", "avg_line_length": 25.0, "max_line_length": 81, "alphanum_fraction": 0.6533333333, "num_tokens": 46}
|
[STATEMENT]
lemma Lambert_W'_asymp_equiv'_at_left_0 [asymp_equiv_intros]:
"Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (-x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
have "(\<lambda>x. Lambert_W' x - ln (-x)) \<in> \<Theta>[at_left 0](\<lambda>x. -ln (-ln (-x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<lambda>x. Lambert_W' x - ln (- x)) \<in> \<Theta>[at_left 0](\<lambda>x. - ln (- ln (- x)))
[PROOF STEP]
by (intro asymp_equiv_imp_bigtheta Lambert_W'_asymp_equiv_at_left_0)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. Lambert_W' x - ln (- x)) \<in> \<Theta>[at_left 0](\<lambda>x. - ln (- ln (- x)))
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. Lambert_W' x - ln (- x)) \<in> \<Theta>[at_left 0](\<lambda>x. - ln (- ln (- x)))
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
have "(\<lambda>x::real. -ln (-ln (-x))) \<in> o[at_left 0](\<lambda>x. ln (-x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<lambda>x. - ln (- ln (- x))) \<in> o[at_left 0](\<lambda>x. ln (- x))
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. - ln (- ln (- x))) \<in> o[at_left 0](\<lambda>x. ln (- x))
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. Lambert_W' x - ln (- x)) \<in> o[at_left 0](\<lambda>x. ln (- x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. Lambert_W' x - ln (- x)) \<in> o[at_left 0](\<lambda>x. ln (- x))
goal (1 subgoal):
1. Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
[PROOF STEP]
by (simp add: asymp_equiv_altdef)
[PROOF STATE]
proof (state)
this:
Lambert_W' \<sim>[at_left 0] (\<lambda>x. ln (- x))
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 995, "file": "Lambert_W_Lambert_W", "length": 10}
|
// Copyright (c) 2019 fortiss GmbH, Julian Bernhard, Klemens Esterle, Patrick Hart, Tobias Kessler
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#ifndef MODULES_WORLD_WORLD_HPP_
#define MODULES_WORLD_WORLD_HPP_
#include <unordered_map>
#include <map>
#include <vector>
#include <utility>
#include "modules/world/opendrive/opendrive.hpp"
#include <boost/geometry/index/rtree.hpp>
#include "modules/world/map/roadgraph.hpp"
#include "modules/world/objects/agent.hpp"
#include "modules/world/objects/object.hpp"
#include "modules/world/evaluation/base_evaluator.hpp"
namespace modules {
namespace world {
using world::objects::Agent;
using world::objects::AgentId;
using world::objects::AgentPtr;
using world::objects::ObjectPtr;
using world::evaluation::EvaluatorPtr;
typedef std::unordered_map<AgentId, AgentPtr> AgentMap;
typedef std::unordered_map<AgentId, ObjectPtr> ObjectMap;
typedef std::map<std::string,
modules::world::evaluation::EvaluationReturn> EvaluationMap;
using rtree_agent_model = \
boost::geometry::model::box<modules::geometry::Point2d>;
using rtree_agent_id = AgentId;
using rtree_agent_value = std::pair<rtree_agent_model, rtree_agent_id>;
using rtree_agent = boost::geometry::index::rtree<rtree_agent_value,
boost::geometry::index::linear<16, 4> >;
class World : public commons::BaseType {
public:
explicit World(commons::Params *params);
explicit World(const std::shared_ptr<World>& world);
virtual ~World() {}
//! Getter
double get_world_time() const { return world_time_; }
world::map::MapInterfacePtr get_map() const { return map_; }
AgentMap get_agents() const { return agents_; }
AgentPtr get_agent(AgentId id) const {
auto agent_it = agents_.find(id);
if (agent_it != agents_.end()) {
return agents_.at(id);
} else {
return AgentPtr(nullptr);
}
}
ObjectMap get_objects() const { return objects_; }
std::map<std::string,
EvaluatorPtr> get_evaluators() const { return evaluators_; }
bool get_remove_agents() const { return remove_agents_; }
void set_map(const world::map::MapInterfacePtr& map) { map_ = map;}
std::pair<modules::geometry::Point2d,
modules::geometry::Point2d> bounding_box() const {
return map_->BoundingBox();
}
void add_agent(const AgentPtr& agent);
void add_object(const ObjectPtr& object);
void add_evaluator(const std::string& name, const EvaluatorPtr& evaluator);
void clear_evaluators() { evaluators_.clear(); }
void clear_agents() { agents_.clear(); }
void clear_objects() { objects_.clear(); }
void clear_all() {
clear_agents();
clear_objects();
evaluators_.clear();
}
EvaluationMap Evaluate() const;
bool Valid() const;
std::vector<ObservedWorld> Observe(const std::vector<AgentId>& agent_ids);
void Step(const float& delta_time);
void UpdateHorizonDrivingCorridors();
void DoPlanning(const float& delta_time);
void DoExecution(const float& delta_time);
void UpdateAgentRTree();
void RemoveOutOfMapAgents();
AgentMap GetNearestAgents(const modules::geometry::Point2d& position,
const unsigned int& num_agents) const;
AgentMap GetAgentsIntersectingPolygon(
const modules::geometry::Polygon& polygon) const;
virtual std::shared_ptr<World> Clone() const;
std::shared_ptr<World> WorldExecutionAtTime(
const float& execution_time) const;
private:
world::map::MapInterfacePtr map_;
AgentMap agents_;
ObjectMap objects_;
std::map<std::string, EvaluatorPtr> evaluators_;
double world_time_;
bool remove_agents_;
rtree_agent rtree_agents_;
};
typedef std::shared_ptr<world::World> WorldPtr;
inline WorldPtr World::Clone() const {
WorldPtr new_world = std::make_shared<World>(*this);
new_world->clear_all();
for (auto agent = agents_.begin(); agent != agents_.end(); ++agent) {
new_world->add_agent(
std::dynamic_pointer_cast<Agent>(agent->second->Clone()));
}
for (auto object = objects_.begin(); object != objects_.end(); ++object) {
new_world->add_object(object->second->Clone());
}
return new_world;
}
} // namespace world
} // namespace modules
#endif // MODULES_WORLD_WORLD_HPP_
|
{"hexsha": "922b43e7c6d150cad5b8905390a3ca2a15f83c4d", "size": 4291, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "modules/world/world.hpp", "max_stars_repo_name": "cirrostratus1/bark", "max_stars_repo_head_hexsha": "6629a9bbc455d0fd708e09bb8e162425e62c4165", "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": "modules/world/world.hpp", "max_issues_repo_name": "cirrostratus1/bark", "max_issues_repo_head_hexsha": "6629a9bbc455d0fd708e09bb8e162425e62c4165", "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": "modules/world/world.hpp", "max_forks_repo_name": "cirrostratus1/bark", "max_forks_repo_head_hexsha": "6629a9bbc455d0fd708e09bb8e162425e62c4165", "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": 30.8705035971, "max_line_length": 98, "alphanum_fraction": 0.7187135866, "num_tokens": 1059}
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.
from PIL import Image
import requests
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
from torchvision import transforms
from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder
from torch_mlir.passmanager import PassManager
from torch_mlir_e2e_test.linalg_on_tensors_backends import refbackend
from module import Net
import sys
import numpy as np
import skimage.io
mb = ModuleBuilder()
def mnist(pretrained=False, **kwargs):
"""Constructs a mnist-18 model.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = Net()
model.load_state_dict(torch.load("mnist_cnn_wt.pt"))
return model
class MnistModule(torch.nn.Module):
def __init__(self):
super().__init__()
self.mnist = mnist(pretrained=True)
self.train(False)
def forward(self, img):
return self.mnist.forward(img)
# MNIST sample images
IMAGE_URLS = [
'https://i.imgur.com/SdYYBDt.png', # 0
'https://i.imgur.com/Wy7mad6.png', # 1
'https://i.imgur.com/nhBZndj.png', # 2
'https://i.imgur.com/V6XeoWZ.png', # 3
'https://i.imgur.com/EdxBM1B.png', # 4
'https://i.imgur.com/zWSDIuV.png', # 5
'https://i.imgur.com/Y28rZho.png', # 6
'https://i.imgur.com/6qsCz2W.png', # 7
'https://i.imgur.com/BVorzCP.png', # 8
'https://i.imgur.com/vt5Edjb.png', # 9
]
def load_images():
"""Load MNIST sample images from the web and return them in an array.
Returns:
Numpy array of size (10, 28, 28, 1) with MNIST sample images.
"""
images = np.zeros((10, 28, 28, 1))
for idx, url in enumerate(IMAGE_URLS):
images[idx, :, :, 0] = skimage.io.imread(url)
return images[0,:,:,:]
def load_and_preprocess_image(img_url: str):
#img = Image.open(img).convert("RGB")
#images = np.zeros((10, 28, 28, 1))
#for idx, url in enumerate(IMAGE_URLS):
# images[idx, :, :, 0] = skimage.io.imread(url)
image=skimage.io.imread(img_url)
# preprocessing pipeline
preprocess=transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))
])
img_preprocessed = preprocess(image)
return torch.unsqueeze(img_preprocessed, 0)
def top1_possibilities(res):
_, indexes = torch.sort(res, descending=True)
percentage = torch.nn.functional.softmax(res, dim=1)[0] * 100
top1 = [(labels[idx], percentage[idx].item()) for idx in indexes[0][:1]]
return top1
def predictions(torch_func, jit_func, img, labels):
golden_prediction = top1_possibilities(torch_func(img))
print("PyTorch prediction")
print(golden_prediction)
prediction = top1_possibilities(torch.from_numpy(jit_func(img.numpy())))
print("torch-mlir prediction")
print(prediction)
processedImage=IMAGE_URLS[5] # specify the image url number that you want to set as the input
print("load image from " + processedImage, file=sys.stderr)
img = load_and_preprocess_image(processedImage)
labels = ['0','1','2','3','4','5','6','7','8','9']
test_module = MnistModule()
class_annotator = ClassAnnotator()
recursivescriptmodule = torch.jit.script(test_module)
#torch.jit.save(recursivescriptmodule, "/tmp/foo.pt")
class_annotator.exportNone(recursivescriptmodule._c._type())
class_annotator.exportPath(recursivescriptmodule._c._type(), ["forward"])
class_annotator.annotateArgs(
recursivescriptmodule._c._type(),
["forward"],
[
None,
([-1, -1, -1, -1], torch.float32, True),
],
)
# TODO: Automatically handle unpacking Python class RecursiveScriptModule into the underlying ScriptModule.
print("import mnist module")
mb.import_module(recursivescriptmodule._c, class_annotator)
#print(mb.module)
original_output = sys.stdout
with open('mnist_torchscript_import.mlir', 'w') as f:
sys.stdout = f
print(mb.module)
sys.stdout = original_output
print('write imported torchscript module done')
backend = refbackend.RefBackendLinalgOnTensorsBackend()
with mb.module.context:
pm = PassManager.parse('torchscript-module-to-torch-backend-pipeline,torch-backend-to-linalg-on-tensors-backend-pipeline')
pm.run(mb.module)
print('pass manager done')
compiled = backend.compile(mb.module)
print('backend compile done')
original_output = sys.stdout
with open('mnist_compiled.mlir', 'w') as f:
sys.stdout = f
print(compiled)
sys.stdout = original_output
print('write compiled mnist module done')
jit_module = backend.load(compiled)
print(img.type)
predictions(test_module.forward, jit_module.forward, img, labels)
|
{"hexsha": "a0e39293a8b90ecb9d13649b5b8df9293adef007", "size": 4887, "ext": "py", "lang": "Python", "max_stars_repo_path": "examples/mnist/torchscript_mnist_e2e.py", "max_stars_repo_name": "JasonMaojinsong/torch-mlir", "max_stars_repo_head_hexsha": "d50d3a5b1d1fa34f73e5107bf72d2d19430a08a2", "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": "examples/mnist/torchscript_mnist_e2e.py", "max_issues_repo_name": "JasonMaojinsong/torch-mlir", "max_issues_repo_head_hexsha": "d50d3a5b1d1fa34f73e5107bf72d2d19430a08a2", "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": "examples/mnist/torchscript_mnist_e2e.py", "max_forks_repo_name": "JasonMaojinsong/torch-mlir", "max_forks_repo_head_hexsha": "d50d3a5b1d1fa34f73e5107bf72d2d19430a08a2", "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": 32.58, "max_line_length": 126, "alphanum_fraction": 0.7061591979, "include": true, "reason": "import numpy", "num_tokens": 1300}
|
using HybridSystems
using Polyhedra
using SwitchOnSafety
using Test
include("solvers.jl")
include("jsr.jl")
include("invariant.jl")
include("../examples/run_examples.jl")
|
{"hexsha": "5fbf9a416a3d511b68352f596ec6bf515a16ce53", "size": 174, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/runtests.jl", "max_stars_repo_name": "blegat/SwitchOnSafety.jl", "max_stars_repo_head_hexsha": "c5461c0d9fbdf63ed0fb284962808b963d218070", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-11-24T10:29:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T15:10:52.000Z", "max_issues_repo_path": "test/runtests.jl", "max_issues_repo_name": "blegat/SwitchedSystems.jl", "max_issues_repo_head_hexsha": "88c6c64f7499de1fc8b039cfc2da393778f1e4c4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-02T09:26:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T15:14:00.000Z", "max_forks_repo_path": "test/runtests.jl", "max_forks_repo_name": "blegat/SwitchedSystems.jl", "max_forks_repo_head_hexsha": "88c6c64f7499de1fc8b039cfc2da393778f1e4c4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-11-29T13:44:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-15T11:08:56.000Z", "avg_line_length": 14.5, "max_line_length": 38, "alphanum_fraction": 0.775862069, "num_tokens": 46}
|
# -*- coding: utf-8 -*-
import os
import sys
# ensure `tests` directory path is on top of Python's module search
filedir = os.path.dirname(__file__)
sys.path.insert(0, filedir)
while filedir in sys.path[1:]:
sys.path.pop(sys.path.index(filedir)) # avoid duplication
import pytest
import numpy as np
from copy import deepcopy
from backend import Adam
from backend import AE_CONFIGS, notify, make_autoencoder
from backend import _init_session, _get_test_names
from deeptrain import introspection
#### CONFIGURE TESTING #######################################################
tests_done = {}
CONFIGS = deepcopy(AE_CONFIGS)
del CONFIGS['traingen']['logs_dir'] # unused
del CONFIGS['traingen']['best_models_dir'] # unused
def init_session(C, weights_path=None, loadpath=None, model=None):
return _init_session(C, weights_path=weights_path, loadpath=loadpath,
model=model, model_fn=make_autoencoder)
_tg = init_session(CONFIGS) # save time on redundant re-init's
_tg.train()
###############################################################################
@notify(tests_done)
def test_gather_over_dataset():
_tg.gradient_norm_over_dataset(n_iters=None, prog_freq=3)
_tg.gradient_norm_over_dataset(n_iters=None, prog_freq=3, norm_fn=np.abs)
_tg.gradient_sum_over_dataset(n_iters=5, prog_freq=3)
x, y, sw = _tg.get_data()
_tg.compute_gradient_norm(x, y, sw) # not gather, but test anyway
@notify(tests_done)
def test_print_dead_nan():
def _test_print_nan_weights():
C = deepcopy(CONFIGS)
C['model']['optimizer'] = Adam(lr=1e9)
tg = init_session(C)
tg.train()
tg.check_health()
def _test_print_dead_weights():
C = deepcopy(CONFIGS)
C['model']['optimizer'] = Adam(lr=1e-4)
tg = init_session(C)
tg.train()
tg.check_health(dead_threshold=.1)
tg.check_health(notify_detected_only=False)
tg.check_health(notify_detected_only=False, dead_threshold=.5,
dead_notify_above_frac=2)
_test_print_nan_weights()
_test_print_dead_weights()
@notify(tests_done)
def test_compute_gradient_norm():
dg = _tg.datagen
_tg.compute_gradient_norm(dg.batch, dg.batch, scope='global', norm_fn=np.abs)
@notify(tests_done)
def test_grads_fn():
dg = _tg.datagen
grads_fn = introspection._make_gradients_fn(_tg.model, 0, mode="outputs")
_ = grads_fn(dg.batch, dg.batch, sw=None)
_ = grads_fn([dg.batch], [dg.batch], sw=None)
@notify(tests_done)
def test_info_and_interrupt_status():
_tg.info()
_tg._train_postiter_processed = False
_tg._train_loop_done = True
_tg.interrupt_status()
_tg._train_loop_done = False
_tg.interrupt_status()
_tg._val_loop_done = True
_tg._train_loop_done = False
_tg.interrupt_status()
_tg._train_loop_done = True
_tg._val_postiter_processed = True
_tg.interrupt_status()
_tg._val_postiter_processed = False
_tg.interrupt_status()
_tg._val_loop_done = False
_tg.interrupt_status()
tests_done.update({name: None for name in _get_test_names(__name__)})
if __name__ == '__main__':
pytest.main([__file__, "-s"])
|
{"hexsha": "1ca282af95292079f389f3a3586f710829ce4dae", "size": 3216, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/introspection_test.py", "max_stars_repo_name": "Mario-Kart-Felix/deeptrain", "max_stars_repo_head_hexsha": "45e066e9aa97c16780682d62250516c7d64d9897", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2020-09-15T14:27:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-30T09:43:09.000Z", "max_issues_repo_path": "tests/introspection_test.py", "max_issues_repo_name": "adbmd/deeptrain", "max_issues_repo_head_hexsha": "fd412e68e23bce0d9997b0a619a6887ad557067e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-09-18T00:44:17.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-18T14:06:00.000Z", "max_forks_repo_path": "tests/introspection_test.py", "max_forks_repo_name": "adbmd/deeptrain", "max_forks_repo_head_hexsha": "fd412e68e23bce0d9997b0a619a6887ad557067e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-09-17T16:56:28.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-30T03:23:31.000Z", "avg_line_length": 28.7142857143, "max_line_length": 81, "alphanum_fraction": 0.6766169154, "include": true, "reason": "import numpy", "num_tokens": 800}
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from generate_all_def import read_one_hot_feature_list
import pickle
import numpy as np
from sklearn import svm
from sklearn.ensemble import RandomForestClassifier
import sklearn.model_selection as ms # import cross_val_scores
import csv
from sklearn.metrics import confusion_matrix, make_scorer
from sklearn.model_selection import StratifiedKFold
from sklearn.preprocessing import normalize
import os
import argparse
DATA_DIR = '../data/'
parser = argparse.ArgumentParser(
description='Parse arguments (see description in source file)')
parser.add_argument('--dataset-fpath', default='dataset_1111.csv', type=str)
parser.add_argument('--dump-mode', action='store_true')
parser.add_argument('--suffix', type=str)
args = parser.parse_args()
DUMP_MODE = args.dump_mode
COMPUTE_CV = True
data_file = DATA_DIR + args.dataset_fpath
one_hot_feature_list = read_one_hot_feature_list(data_file)
events = sorted(list(one_hot_feature_list["FEATURE_NODE_CATEGORY"]))
tag_1 = sorted(list(one_hot_feature_list["FEATURE_FIRST_PARENT_TAG_NAME"]))
tag_2 = sorted(
list(one_hot_feature_list["FEATURE_FIRST_PARENT_SIBLING_TAG_NAME"]))
tag_3 = sorted(list(one_hot_feature_list["FEATURE_SECOND_PARENT_TAG_NAME"]))
tag_4 = sorted(
list(one_hot_feature_list["FEATURE_SECOND_PARENT_SIBLING_TAG_NAME"]))
def transform_row(row):
global tag_1, tag_2, tag_3, tag_4, events
row[13] = events.index(row[13])
if row[23] in tag_1:
row[23] = tag_1.index(row[23])
elif row[23].strip() == '':
row[23] = 0
else:
row[23] = 1
if row[26] in tag_2:
row[26] = tag_2.index(row[26])
elif row[26].strip() == '':
row[26] = 0
else:
row[26] = 1
if row[42] in tag_3:
row[42] = tag_3.index(row[42])
elif row[42].strip() == '':
row[42] = 0
else:
row[42] = 1
if row[45] in tag_4:
row[45] = tag_4.index(row[45])
elif row[45].strip() == '':
row[45] = 0
else:
row[45] = 1
row[4] = round(float(row[4]), 3)
row[5] = round(float(row[5]), 3)
row[10] = round(float(row[10]), 3)
row[32] = round(float(row[32]), 3)
row[51] = round(float(row[51]), 3)
return row
def cv_confusion_matrix(clf, X, y, folds=10):
skf = StratifiedKFold(n_splits=folds)
cv_iter = skf.split(X, y)
cms = []
for train, test in cv_iter:
clf.fit(X[train], y[train])
res = clf.predict(X[test])
cm = confusion_matrix(y[test], res, labels=clf.classes_)
cms.append(cm)
print(clf.classes_)
return np.sum(np.array(cms), axis=0)
to_exclude = {0, 1, 9, 31, 50}
TestFileCsvReader = csv.reader(open(data_file, 'r'), delimiter=',')
testdata = []
labels = []
TestdataIds = []
next(TestFileCsvReader)
for row in TestFileCsvReader:
row = transform_row(row)
d = [element for i, element in enumerate(row[:-1]) if i not in to_exclude]
testdata.append(np.array(d))
labels.append(row[-1])
print("[INFO] Size of dataset: %d" % len(testdata))
if DUMP_MODE:
# n_estimators is numTree. max_features is numFeatures
clf = RandomForestClassifier(
n_estimators=100, max_depth=None, random_state=1, criterion="entropy")
clf.fit(np.asarray(testdata), np.asarray(labels))
if DUMP_MODE:
with open("../model/rf.pkl", 'wb') as fout:
pickle.dump(clf, fout)
else:
with open("../model/rf.pkl", 'rb') as fin:
clf = pickle.load(fin)
if not DUMP_MODE:
clf_res = clf.predict(np.asarray(testdata))
clf_res = list(map(lambda e: str(e) + "\n", clf_res))
with open(DATA_DIR + "%s_model_output.txt" % args.suffix, 'w') as fout:
fout.writelines(clf_res)
print("[INFO] Output produced and dumped.")
if COMPUTE_CV:
scores = cv_confusion_matrix(
clf, np.asarray(testdata), np.asarray(labels), 10
)
print(scores)
tp = scores[0][0]
tn = scores[1][1]
fp = scores[1][0]
fn = scores[0][1]
accuracy = round(((tp+tn)*1.0/(tp+tn+fp+fn) * 1.0)*100, 2)
FPR = round(((fp)*1.0/(tn+fp)*1.0)*100, 2)
Recall = round(((tp)*1.0/(tp+fn)*1.0)*100, 2)
precesion = round(((tp)*1.0/(tp+fp)*1.0)*100, 2)
print("[INFO] ACCURACY:" + str(accuracy))
print("[INFO] FPR:" + str(FPR))
print("[INFO] Recall:" + str(Recall))
print("[INFO] Precision:" + str(precesion))
|
{"hexsha": "01e1e4b235f7748044b5f421d292ba5710faf604", "size": 4437, "ext": "py", "lang": "Python", "max_stars_repo_path": "attack-adgraph-pipeline/script/classifier.py", "max_stars_repo_name": "seclab-ucr/A4", "max_stars_repo_head_hexsha": "1cb3fec31d9e5e9eb2fb448e28b11ce3641b72cc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-12-25T02:29:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T02:12:30.000Z", "max_issues_repo_path": "attack-adgraph-pipeline/script/classifier.py", "max_issues_repo_name": "seclab-ucr/A4", "max_issues_repo_head_hexsha": "1cb3fec31d9e5e9eb2fb448e28b11ce3641b72cc", "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": "attack-adgraph-pipeline/script/classifier.py", "max_forks_repo_name": "seclab-ucr/A4", "max_forks_repo_head_hexsha": "1cb3fec31d9e5e9eb2fb448e28b11ce3641b72cc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-01T07:12:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T07:12:57.000Z", "avg_line_length": 29.1907894737, "max_line_length": 78, "alphanum_fraction": 0.6398467433, "include": true, "reason": "import numpy", "num_tokens": 1283}
|
import feedparser
import pprint
import requests
import pandas as pd
import numpy as np
def loadFiles( codes ):
"""Devuelve una lista de dataframes para solo codigo"""
#codes = ['Est_Mercat_Immobiliari_Lloguer_Mitja_Mensual']
parameters = {'rows': '1000'}
url = 'http://opendata-ajuntament.barcelona.cat/data/api/3/action/package_search'
response = requests.get(url,params=parameters)
catalogo = pd.DataFrame(response.json()['result']['results'])
i = 0
for index, row in catalogo.iterrows():
if i== 0:
fuente_datos = pd.DataFrame(row['resources'])
fuente_datos['code'] = row['code']
i = 1
aux = pd.DataFrame(row['resources'])
aux['code'] = row['code']
fuente_datos = fuente_datos.append(aux)
fuente_datos = fuente_datos[['code','size', 'description', 'format' , 'downloads_absolute', 'token_required', 'url', 'name']]
data = []
for i in range(len(codes)):
datasets_info = fuente_datos[fuente_datos['code'] == codes[i]]
tables = []
for j in range(len(datasets_info)):
tables.append(pd.read_csv(datasets_info['url'][j]))
data = pd.concat(tables)
return(data)
|
{"hexsha": "35a8d8d538185caf0b8596014301a7c41345de6c", "size": 1217, "ext": "py", "lang": "Python", "max_stars_repo_path": "loadFiles.py", "max_stars_repo_name": "djangosee/housing", "max_stars_repo_head_hexsha": "7ab172127967b8440bdc841d087ae84141b8e683", "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": "loadFiles.py", "max_issues_repo_name": "djangosee/housing", "max_issues_repo_head_hexsha": "7ab172127967b8440bdc841d087ae84141b8e683", "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": "loadFiles.py", "max_forks_repo_name": "djangosee/housing", "max_forks_repo_head_hexsha": "7ab172127967b8440bdc841d087ae84141b8e683", "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": 32.0263157895, "max_line_length": 130, "alphanum_fraction": 0.6343467543, "include": true, "reason": "import numpy", "num_tokens": 310}
|
using Test
include("reduce.jl")
if capability(device()) < v"3.0"
@warn("this example requires a newer GPU")
exit(0)
end
len = 10^7
input = ones(Int32, len)
output = similar(input)
# CPU
cpu_val = reduce(+, input)
# CUDAnative
let
gpu_input = CuTestArray(input)
gpu_output = CuTestArray(output)
gpu_reduce(+, gpu_input, gpu_output)
gpu_val = Array(gpu_output)[1]
@assert cpu_val == gpu_val
end
|
{"hexsha": "1961cbcb65b5e690c0d027d61c0b4f61b2657651", "size": 426, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "examples/reduce/verify.jl", "max_stars_repo_name": "chengchingwen/CUDAnative.jl", "max_stars_repo_head_hexsha": "d4861f5244c7c8172bf0d05d026aee41cb470e51", "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": "examples/reduce/verify.jl", "max_issues_repo_name": "chengchingwen/CUDAnative.jl", "max_issues_repo_head_hexsha": "d4861f5244c7c8172bf0d05d026aee41cb470e51", "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/reduce/verify.jl", "max_forks_repo_name": "chengchingwen/CUDAnative.jl", "max_forks_repo_head_hexsha": "d4861f5244c7c8172bf0d05d026aee41cb470e51", "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": 17.04, "max_line_length": 46, "alphanum_fraction": 0.6737089202, "num_tokens": 128}
|
[STATEMENT]
lemma true_clss_mset_set[simp]: "finite CC \<Longrightarrow> I \<Turnstile>m mset_set CC \<longleftrightarrow> I \<Turnstile>s CC"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. finite CC \<Longrightarrow> (I \<Turnstile>m mset_set CC) = (I \<Turnstile>s CC)
[PROOF STEP]
unfolding true_clss_def true_cls_mset_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. finite CC \<Longrightarrow> Multiset.Ball (mset_set CC) ((\<Turnstile>) I) = Ball CC ((\<Turnstile>) I)
[PROOF STEP]
by auto
|
{"llama_tokens": 204, "file": "Ordered_Resolution_Prover_Herbrand_Interpretation", "length": 2}
|
from abc import ABC, abstractmethod
import numpy as np
class Ship(ABC):
def __init__(self):
self.x = np.zeros(2)
self.controls = {
'N': self.north,
'S': self.south,
'E': self.east,
'W': self.west,
'L': self.left,
'R': self.right,
'F': self.forward
}
def displacement(self):
return np.sum(np.abs(self.x))
def move(self, inst, mag):
if not isinstance(mag, float):
mag = float(mag)
return self.controls[inst](mag)
def west(self, mag):
return self.east(-mag)
def south(self, mag):
return self.north(-mag)
def right(self, mag):
return self.left(-mag)
def travel(self, instructions):
for instruction in instructions:
inst, mag = instruction[0], instruction[1:]
self.move(inst, mag)
return self
@abstractmethod
def north(self, mag):
pass
@abstractmethod
def east(self, mag):
pass
@abstractmethod
def left(self, mag):
pass
@abstractmethod
def forward(self, mag):
pass
class BearingShip(Ship):
def __init__(self, *args, **kwargs):
self.theta = 0.0
super().__init__(*args, **kwargs)
def north(self, mag):
self.x[1] += mag
return self
def east(self, mag):
self.x[0] += mag
return self
def left(self, mag):
self.theta += mag * np.pi / 180
return self
def forward(self, mag):
self.x += mag * np.array([np.cos(self.theta), np.sin(self.theta)])
return self
class WaypointShip(Ship):
def __init__(self, *args, **kwargs):
self.wp = np.array([10, 1])
super().__init__(*args, **kwargs)
def north(self, mag):
self.wp[1] += mag
return self
def east(self, mag):
self.wp[0] += mag
return self
def left(self, mag):
self.wp = self.rotate(self.wp - self.x, mag) + self.x
return self
def forward(self, mag):
if mag <= 0:
return self
else:
delta = self.wp - self.x
self.x = self.wp
self.wp = self.x + delta
return self.forward(mag - 1)
def rotate(self, vec, theta):
cos, sin = np.cos(theta * np.pi / 180), np.sin(theta * np.pi / 180)
return np.dot(np.array([[cos, -sin], [sin, cos]]), vec)
def main():
with open("input.txt") as handle:
instructions = handle.readlines()
bship = BearingShip().travel(instructions)
wship = WaypointShip().travel(instructions)
print("Part I: ", bship.displacement())
print("Part II:", wship.displacement())
Ship.register(BearingShip)
Ship.register(WaypointShip)
if __name__ == '__main__':
main()
|
{"hexsha": "524eafbf32fac47bae76a52df159d65f85322eb5", "size": 2844, "ext": "py", "lang": "Python", "max_stars_repo_path": "2020/12/solution.py", "max_stars_repo_name": "dglmoore/advent-of-code", "max_stars_repo_head_hexsha": "ca6e39a842a84ad5271891535c9323e057261d44", "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": "2020/12/solution.py", "max_issues_repo_name": "dglmoore/advent-of-code", "max_issues_repo_head_hexsha": "ca6e39a842a84ad5271891535c9323e057261d44", "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": "2020/12/solution.py", "max_forks_repo_name": "dglmoore/advent-of-code", "max_forks_repo_head_hexsha": "ca6e39a842a84ad5271891535c9323e057261d44", "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": 22.0465116279, "max_line_length": 75, "alphanum_fraction": 0.5407876231, "include": true, "reason": "import numpy", "num_tokens": 720}
|
(*
(C) Copyright 2010, COQTAIL team
Project Info: http://sourceforge.net/projects/coqtail/
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*)
Require Export Complex.
Require Import Cpow_plus.
Lemma Rdiv_1 : forall r : R, (r/1)%R = r.
Proof.
intros. field.
Qed.
Ltac ring_simpl1 :=
match goal with
| id : _|- _ => (ring_simplify in id) ; generalize dependent id
end
with ring_simpl := unfold Rdiv in * ; unfold Cdiv in * ;
do 10 (try ring_simpl1) ; intros ; try ring_simplify.
Ltac apply_tactic1 := fun tactic =>
match goal with
| id : _|- _ => (apply tactic in id)
end.
(* begin hide *)
(** Tactic CusingR2 to simplify some expressions and to go in R *)
(*
********************************************
Warning ! these tactics were written to avoid very long
normalization. It should be improved or deleted !
The reader is strongly advised not to use this tactic because
of very long computation.
********************************************
*)
Ltac CusingRR2 := simpl in * ;
try rewrite <- Ceq in * ; unfold Cdiv in * ; unfold Cconj in * ; unfold Cminus in * ;
unfold Rdiv in * ;
try rewrite Rplus_0_l ; try rewrite Rplus_0_r ;
try rewrite Cadd_0_l ; try rewrite Cadd_0_r ;
try rewrite Rmult_0_l ; try rewrite Rmult_0_r ;
try rewrite Cmult_0_l ; try rewrite Cmult_0_r ;
try rewrite Rmult_0_l ; try rewrite Rmult_0_r ;
try rewrite <- Cre_add_compat in * ;
try rewrite Cim_add_compat in * ; try rewrite Cre_INC_INR in * ;
try rewrite <- Cre_opp_compat in * ; try rewrite Cim_INC in * ;
try rewrite Cpow_Cim_0 in * ;
try rewrite Cpow_Cre_0 in * ;
try rewrite Cim_inv_INC in *
with CusingRR3 := repeat CusingRR2.
Ltac CusingR_rec2 := unfold not in *;
match goal with
(* destruct complex *)
| id:C |- _ => destruct id ; try CusingR_rec2
(* logical destruct in goal *)
| id: _|- _ -> _ => intros ; try CusingR_rec2
| id: _|- _ /\ _ => split ; try CusingR_rec2
| id: _ /\ _ |- _ => destruct id ; CusingRR3 ; try CusingR_rec2
| id: _ \/ _ |- _ => destruct id ; CusingRR3 ; try CusingR_rec2
(* false*)
| id: _ |- False => (apply id ; CusingR2)
| id: _|- _ \/ _ => try ((left ; CusingR2 ; fail) || (right ; CusingR2 ; fail)) ; simpl in *
| _ => simpl in *
end
with
CusingR2 := intros ; CusingRR3 ; CusingR_rec2 ; subst.
(* end hide *)
(** Proof of existence of a squareroot *)
(* begin hide*)
Lemma Rle_Rminus: forall a b : R, a <= b -> 0 <= b - a.
Proof.
intuition. unfold "<=" in *. elim H ; intros. left ; apply Rlt_Rminus. assumption.
right. rewrite H0. ring.
Qed.
Lemma Croot_sqrt_pos : forall a b : R, 0 <= (sqrt (a * a + b * b) - a) / 2.
Proof.
intros.
unfold Rdiv. replace 0%R with (0 * /2)%R by field. apply Rmult_le_compat_r.
fourier. apply Rle_Rminus.
apply Rle_trans with (Rabs a).
split_Rabs. fourier. intuition.
apply Rsqr_incr_0_var. rewrite Rsqr_sqrt.
rewrite <- Rsqr_abs. replace (Rsqr a) with (a * a)%R by intuition.
replace (a * a)%R with ((a * a) + 0)%R by intuition.
rewrite Rplus_assoc. apply Rplus_le_compat_l.
replace (0 + b * b)%R with (Rsqr b) by intuition.
intuition. apply (Cnorm_sqr_pos a b). apply sqrt_positivity.
apply (Cnorm_sqr_pos a b).
Qed.
Lemma Croot_sqrt_pos_plus : forall a b : R, 0 <= (sqrt (a * a + b * b) + a) / 2.
Proof.
intros.
unfold Rdiv. replace 0%R with (0 * /2)%R by field. apply Rmult_le_compat_r.
fourier. replace a with (--a)%R by intuition. apply Rle_Rminus.
apply Rle_trans with (Rabs a).
split_Rabs. fourier. intuition. fourier.
replace (--a)%R with a by intuition.
apply Rsqr_incr_0_var. rewrite Rsqr_sqrt.
rewrite <- Rsqr_abs. replace (Rsqr a) with (a * a)%R by intuition.
replace (a * a)%R with ((a * a) + 0)%R by intuition.
rewrite Rplus_assoc. apply Rplus_le_compat_l.
replace (0 + b * b)%R with (Rsqr b) by intuition.
intuition. apply (Cnorm_sqr_pos a b). apply sqrt_positivity.
apply (Cnorm_sqr_pos a b).
Qed.
Lemma sqrt_square2 : forall a : R, (a >= 0 -> (sqrt a) ^ 2 = a)%R.
Proof.
intros.
simpl. rewrite Rmult_1_r. apply sqrt_sqrt. intuition.
Qed.
(* end hide *)
Lemma Croot_pol_2 : forall z : C, {z1 | z1 ^ 2 = z}.
Proof.
intros.
destruct z as (a, b).
destruct (Rlt_le_dec b 0).
(* case b < 0 *)
exists (sqrt ( (sqrt ( a * a + b * b) + a)/2),
- sqrt ( (sqrt ( a * a + b * b) - a)/2))%R.
CusingR_simpl ; ring_simplify.
(* real part *)
repeat rewrite sqrt_square2. field. destruct (Croot_sqrt_pos a b). intuition. intuition.
destruct (Croot_sqrt_pos_plus a b). intuition. intuition.
(* imaginary part *)
rewrite Rmult_assoc. rewrite <- sqrt_mult.
field_simplify ((sqrt (a * a + b * b) + a) / 2 * ((sqrt (a * a + b * b) - a) / 2))%R.
rewrite sqrt_square2. field_simplify ((a * a + b * b - a ^ 2) / 4)%R.
unfold Rdiv. replace (/4)%R with (/2 * /2)%R by field. rewrite sqrt_mult.
replace (sqrt (/2 * /2))%R with (/2)%R by (rewrite sqrt_square ; try reflexivity ; fourier).
replace (b ^ 2)%R with (-b * -b)%R by ring. rewrite sqrt_square.
field. fourier.
replace (b ^ 2)%R with (Rsqr b) by (simpl ; rewrite Rmult_1_r ; intuition).
intuition. fourier. apply Rle_ge . apply (Cnorm_sqr_pos a b).
apply Croot_sqrt_pos_plus. apply Croot_sqrt_pos.
(* case b >= 0 *)
exists (sqrt ( (sqrt ( a * a + b * b) + a)/2),
sqrt ( (sqrt ( a * a + b * b) - a)/2))%R.
CusingR_simpl ; ring_simplify.
(* real part *)
repeat rewrite sqrt_square2. field.
apply Rle_ge. apply Croot_sqrt_pos.
apply Rle_ge. apply Croot_sqrt_pos_plus.
(* imaginary part *)
rewrite Rmult_assoc.
repeat rewrite <- sqrt_mult.
field_simplify ((sqrt (a * a + b * b) + a) / 2 * ((sqrt (a * a + b * b) - a) / 2))%R.
repeat rewrite sqrt_square2.
field_simplify ((a * a + b * b - a ^ 2) / 4)%R.
unfold Rdiv. replace (/4)%R with (/2 * /2)%R by field. rewrite sqrt_mult.
replace (sqrt (/2 * /2))%R with (/2)%R by (rewrite sqrt_square ; try reflexivity ; fourier).
replace (b ^ 2)%R with (b * b)%R by ring. rewrite sqrt_square.
field. fourier.
replace (b ^ 2)%R with (Rsqr b) by (simpl ; rewrite Rmult_1_r ; intuition).
intuition. fourier. apply Rle_ge . apply (Cnorm_sqr_pos a b).
apply Croot_sqrt_pos_plus. apply Croot_sqrt_pos.
Qed.
(* begin hide*)
Lemma sum_f_R0_eq_seq : forall (n : nat) (f g : nat -> R),
(forall m : nat, (m <= n)%nat -> f m = g m) ->
sum_f_R0 f n = sum_f_R0 g n.
Proof.
intros n f g H.
induction n.
simpl. apply H. intuition.
simpl. rewrite IHn. rewrite H with (S n). reflexivity. intuition. intros m H2. apply H. intuition.
Qed.
Lemma Cnorm_sqr_real : forall r9 r10,
(r9 +i r10) <> 0 ->
((r9 + r9) * (r9 + r9) + (r10 + r10) * (r10 + r10))%R <> 0%R.
Proof.
intros a b H Habs.
apply (HC0_norm_R0 ((a + a)%R +i (b + b)%R)) in Habs.
apply H. replace ((a + a)%R +i (b + b)%R) with ((2 +i 0%R) * (a +i b)) in Habs by CusingR_f.
apply Cmult_integral in Habs. destruct Habs ;
assert (H1 : (2 +i 0%R) = 0 -> False) ; CusingR2 ; (fourier || intuition).
Qed.
Lemma Rpow_2_inf_0 : forall x, (x^2 < 0 -> False)%R.
Proof.
intros.
replace (x ^ 2)%R with (Rsqr x) in * by (unfold Rsqr ; simpl ; ring).
assert (Rsqr x >= 0) by (auto with real).
fourier.
Qed.
Lemma Rpow_2_opp_inf_0 : forall x, (-x^2 > 0 -> False)%R.
Proof.
intros.
replace (x ^ 2)%R with (Rsqr x) in * by (unfold Rsqr ; simpl ; ring).
assert (Rsqr x >= 0) by (auto with real).
fourier.
Qed.
(* end hide*)
(** Equality to 0 of a polynom of degree one *)
Lemma Pol_degree_1 : forall a b, (forall x, a * x + b = 0) -> (a = 0 /\ b = 0).
Proof.
intros.
assert (H1 : (a * 0 + b = 0)).
apply H.
assert (H2 : (a * 1 + b = 0)).
apply H.
rewrite Cmult_0_r in H1.
rewrite Cmult_1_r in H2.
rewrite Cadd_0_l in H1.
subst. rewrite Cadd_0_r in H2.
subst.
intuition.
Qed.
(** Unicicty of roots of a polynom of degree two*)
Lemma Cpol_2_root_unicity : forall x1 x2 x3 x4,
(forall x, (x + x1) * (x + x2) = (x + x3) * (x + x4)) ->
(x1 = x3 /\ x2 = x4) \/ (x1 = x4 /\ x2 = x3).
Proof.
intros x1 x2 x3 x4 H.
assert (H1 : (forall x : C, (x + x1) * (x + x2) = (x + x3) * (x + x4)) ->
(forall x, (x1 + x2 - x3 - x4) * x + x1 * x2 - x3 * x4 = 0)).
intros H0 x.
assert (H1 : ((x + x1) * (x + x2) = (x + x3) * (x + x4) ->
(x1 + x2 - x3 - x4) * x + x1 * x2 - x3 * x4 = 0)).
intros H1.
apply Cminus_diag_eq in H1. ring_simplify in H1.
repeat rewrite <- Cmult_add_distr_l in H1.
repeat rewrite <- Cmult_minus_distr_l in H1.
rewrite Cmult_comm in H1.
assumption.
apply H1. apply H0.
assert (H2 : (x1 + x2 - x3 - x4 = 0 /\ x1 * x2 - x3 * x4 = 0)).
apply Pol_degree_1.
intros x.
replace ((x1 + x2 - x3 - x4) * x + (x1 * x2 - x3 * x4)) with
((x1 + x2 - x3 - x4) * x + x1 * x2 - x3 * x4) by ring.
apply H1.
intros x0.
apply H.
destruct H2 as [H0 H2].
assert (H3 : ((-x1 + x1) * (-x1 + x2) = (-x1 + x3) * (-x1 + x4))).
apply H.
assert (H4 : ((-x2 + x1) * (-x2 + x2) = (-x2 + x3) * (-x2 + x4))).
apply H. rewrite Cadd_opp_l in *.
(* From this point we do all in parallel *)
destruct (Ceq_dec x2 x1) ;
rewrite Cmult_0_l in *; rewrite Cmult_0_r in * ;
symmetry in H3 ; symmetry in H4 ;
apply Cmult_integral in H3 ; apply Cmult_integral in H4 ;
destruct H3 as [H3|H3] ; destruct H4 as [H4|H4] ;
rewrite Cadd_comm in * ; apply Cminus_diag_uniq in H3 ;
apply Cminus_diag_uniq in H4 ; subst ; ring_simpl ; intuition.
Qed.
(** Solve a polynom of degree two in the Complex field as a function of delta *)
Lemma Cpol_d_2 : forall a b c delta, (delta = b^2 - 4*a * c) ->
a <> 0 -> Cim a = 0%R -> Cim b = 0%R -> Cim c = 0%R ->
exists x1, exists x2, forall x,
a * x ^ 2 + b * x + c = a * (x + x1) * (x + x2)
/\ ((Cim delta) = 0%R /\ Cre delta > 0%R -> Cim x1 = 0%R /\ Cim x2 = 0%R)
/\ ((Cim delta) = 0%R /\ Cre delta < 0%R -> Cim x1 <> 0%R /\ Cim x2 <> 0%R)
/\ ((Cim delta) = 0%R /\ Cre delta = 0%R -> x1 = x2 /\ Cim x1 = 0%R).
Proof.
intros a b c delta Hdelta Ha Hima Himb Himc.
destruct (Croot_pol_2 delta) as [delta1 Hsquare].
exists (( b / (a + a) - delta1 / (a + a))).
exists (( b / (a + a) + delta1 / (a + a))).
intros x.
repeat split. unfold Cdiv. ring_simplify.
rewrite Hsquare. rewrite Hdelta.
unfold Cminus. repeat rewrite Cadd_assoc.
apply Cadd_eq_compat_l.
ring_simplify. rewrite Rplus_0_l.
assert (H : (2 * 2 = 4)) by (CusingR_simpl ; ring).
rewrite <- H. replace (2, 0%R) with (IRC 2) by (reflexivity).
replace (a + a) with (2 * a) by (CusingR_simpl ; ring).
field. split. assumption. intro H0. rewrite <- Ceq in H0. simpl in H0.
destruct H0. assert (2 <> 0)%R by discrR. intuition.
CusingR2. ring_simpl.
generalize H2. intro H3.
(apply Rmult_integral in H3 ; destruct H3 as [H3|H3]).
(apply Rmult_integral in H3 ; destruct H3 as [H3|H3]).
fourier.
rewrite H3 in *. rewrite <- H1 in H0. ring_simpl.
apply Rpow_2_opp_inf_0 in H0. destruct H0.
rewrite H3. ring.
CusingR2. ring_simpl.
(apply Rmult_integral in H2 ; destruct H2 as [H2|H2]).
(apply Rmult_integral in H2 ; destruct H2 as [H2|H2]).
fourier. rewrite H2 in H1. rewrite <- H1 in H0. ring_simpl.
apply Rpow_2_opp_inf_0 in H0. destruct H0.
rewrite H2. ring.
CusingR2. ring_simpl.
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
fourier.
apply Rinv_neq_0_compat in H0. destruct H0.
intro H8. ring_simplify in H8. apply Rmult_integral in H8. destruct H8 as [H8|H8].
fourier.
replace (r9 ^ 2)%R with (Rsqr r9) in H8 by (unfold Rsqr ; simpl ; ring).
assert (H5 : (r9 = 0)%R). apply Rsqr_0_uniq ; assumption.
rewrite H5 in *. apply Ha. split ; reflexivity.
assumption.
rewrite H0 in *. ring_simpl. rewrite <- H2 in H1.
apply Rpow_2_inf_0 in H1. destruct H1. reflexivity.
CusingR2. ring_simpl.
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
apply Rmult_integral in H0 ; destruct H0 as [H0|H0].
fourier.
apply Rinv_neq_0_compat in H0. destruct H0.
intro H8. ring_simplify in H8. apply Rmult_integral in H8. destruct H8 as [H8|H8].
fourier.
replace (r9 ^ 2)%R with (Rsqr r9) in H8 by (unfold Rsqr ; simpl ; ring).
assert (H5 : (r9 = 0)%R). apply Rsqr_0_uniq ; assumption.
rewrite H5 in *. apply Ha. split ; reflexivity.
assumption.
rewrite H0 in *. ring_simpl. rewrite <- H2 in H1.
apply Rpow_2_inf_0 in H1. destruct H1.
reflexivity. unfold Cminus. apply Cadd_eq_compat_l.
assert (H0 : (delta = 0)) by (rewrite <- Ceq ; intuition).
rewrite H0 in *.
assert (H1 : delta1 = 0). simpl in Hsquare. rewrite Cmult_1_r in Hsquare.
apply Cmult_integral in Hsquare. destruct Hsquare ; assumption.
rewrite H1. unfold Cdiv. ring.
CusingR2. ring_simpl.
apply Rmult_integral in H2 ; destruct H2 as [H2|H2].
apply Rmult_integral in H2 ; destruct H2 as [H2|H2].
fourier.
rewrite H2 in *. ring_simplify in H1.
rewrite <- H1 in H0. replace (r2 ^ 2)%R with (Rsqr r2) in H0 by (unfold Rsqr ; simpl ; ring).
assert (H10 : (r2 = 0)%R). apply Rsqr_0_uniq. apply Ropp_eq_0_compat in H0.
ring_simplify in H0. assumption.
rewrite H10 in *. ring.
rewrite H2 in *. ring.
Qed.
(** Real properties that can be deduced from the resolution of a complex polynom*)
Lemma Cpol_2_real_delta_pos : forall a b c delta, ((delta = b^2 - 4*a * c ) ->
delta > 0 -> a <> 0 ->
exists x1, exists x2, forall x,
a * x ^ 2 + b * x + c = a * (x + x1) * (x + x2))%R.
Proof.
intros a b c delta deltadef Hdelta Ha.
destruct (Cpol_d_2 (a +i 0%R) (b +i 0%R) (c +i 0%R) (delta +i 0%R)) as [x1 [x2 H1]].
CusingR2.
ring.
ring.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
exists (Cre x1). exists (Cre x2).
assert (HRtoC : (forall x, Cre ((a +i 0%R) * (x +i 0%R) ^ 2 + (b +i 0%R) * (x +i 0%R) + (c +i 0%R)) =
Cre ((a +i 0%R) * ((x +i 0%R) + x1) * ((x +i 0%R) + x2)))).
intros x.
apply Cre_eq_compat. generalize (H1 (x +i 0%R)). intro H0.
destruct H0 as [H2 [H3 [H4 H5]]].
apply H2.
intros x.
generalize (H1 (x +i 0%R)). intro H0.
destruct H0 as [H2 [H3 [H4 H5]]].
assert (HCroot : (Cim x1 = 0%R /\ Cim x2 = 0%R)). apply H3. simpl. split. reflexivity. assumption.
CusingR2. ring_simpl. assumption.
Qed.
Lemma Cpol_2_real_delta_eq_0 : forall a b c delta, ((delta = b^2 - 4*a * c) ->
delta = 0 -> a <> 0 ->
exists x1, exists x2, forall x,
a * x ^ 2 + b * x + c = a * (x + x1) * (x + x2))%R.
Proof.
intros a b c delta deltadef Hdelta Ha.
destruct (Cpol_d_2 (a +i 0%R) (b +i 0%R) (c +i 0%R) (delta +i 0%R)) as [x1 [x2 H1]].
CusingR2.
ring.
ring.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
exists (Cre x1). exists (Cre x2).
assert (HRtoC : (forall x, Cre ((a +i 0%R) * (x +i 0%R) ^ 2 + (b +i 0%R) * (x +i 0%R) + (c +i 0%R)) =
Cre ((a +i 0%R) * ((x +i 0%R) + x1) * ((x +i 0%R) + x2)))).
intros x.
apply Cre_eq_compat. generalize (H1 (x +i 0%R)). intro H0.
destruct H0 as [H2 [H3 [H4 H5]]].
apply H2.
intros x.
generalize (H1 (x +i 0%R)). intro H0.
destruct H0 as [H2 [H3 [H4 H5]]].
assert (HCroot : (x1 = x2 /\ Cim x1 = 0%R)). apply H5. simpl. split. reflexivity. assumption.
CusingR2. subst. ring_simpl. assumption.
Qed.
Lemma Cpol_2_real_delta_eq_neg : forall a b c delta, ((delta = b^2 - 4*a * c) ->
delta < 0 -> a <> 0 ->
~ (exists x1, exists x2, forall x,
a * x ^ 2 + b * x + c = a * (x + x1) * (x + x2)))%R.
Proof.
intros a b c delta deltadef Hdelta Ha.
destruct (Cpol_d_2 (a +i 0%R) (b +i 0%R) (c +i 0%R) (delta +i 0%R)) as [x1 [x2 H1]].
CusingR2.
ring.
ring.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
CusingR2.
reflexivity.
intro H.
destruct H as (x3, H) . destruct H as (x4, H).
assert (forall x : C, (a +i 0%R) * x ^ 2 + (b +i 0%R) * x + (c +i 0%R) =
(a +i 0%R) * (x + x1) * (x + x2)).
intro x.
generalize (H1 x). intros H0.
destruct H0 as [H2 [H3 [H4 H5]]].
apply H2.
assert (H10 : forall x : C, (a +i 0%R) * x ^ 2 + (b +i 0%R) * x + (c +i 0%R) =
(a +i 0%R) * (x + (x3 +i 0%R)) * (x + (x4 +i 0%R))).
intros x.
destruct x as (r, r0).
rewrite <- Ceq. split.
simpl. ring_simplify.
generalize (H r). intro H15. ring_simplify in H15.
replace (a * r ^ 2 - a * r0 ^ 2 + r * b + c)%R with ((a * r ^ 2 + r * b + c) - a* r0^2)%R by ring.
rewrite H15. ring.
simpl. ring_simplify.
generalize (H 1%R). intro H15. ring_simplify in H15.
generalize (H 0%R). intro H16. ring_simplify in H16.
rewrite <- H16 in H15. ring_simplify in H15.
rewrite <- Rmult_plus_distr_l in H15.
rewrite Rplus_comm in H15. symmetry in H15. rewrite Rplus_comm in H15.
apply Rplus_eq_reg_l in H15. rewrite Rplus_comm in H15.
apply Rplus_eq_reg_l in H15.
rewrite <- H15. ring.
assert (Htra : (x1 = (x3 +i 0%R) /\ x2 = (x4 +i 0%R) \/ x1 = (x4 +i 0%R) /\ x2 = (x3 +i 0%R))).
assert (forall x : C, (x + (x3 +i 0%R)) * (x + (x4 +i 0%R)) = (x + x1) * (x + x2)).
intro x. apply Cmult_eq_reg_l with (a +i 0%R).
CusingR2. reflexivity. generalize (H0 x). generalize (H10 x).
intros abs1 abs2.
ring_simplify in abs1 ; ring_simplify in abs2 ; ring_simplify.
rewrite <- abs1. rewrite abs2. reflexivity.
apply Cpol_2_root_unicity.
intros x. rewrite H2. reflexivity.
generalize (H1 0). intros Hdeltas.
destruct Hdeltas as [H2 [H3 [H4 H5]]].
clear H3 H5 H2.
assert (Habss : (Cim x1 <> 0%R /\ Cim x2 <> 0%R)).
apply H4. intuition. clear H4.
destruct Habss as (Habss1, Habss2).
destruct Htra as [[Htra1 Htra2]|[Htra1 Htra2]].
rewrite <- Ceq in Htra1.
destruct Htra1 as (Htra1, Htraabs).
simpl in Htraabs.
apply Habss1. assumption.
rewrite <- Ceq in Htra1.
destruct Htra1 as (Htra1, Htraabs).
simpl in Htraabs.
apply Habss1. assumption.
Qed.
Lemma Cfpol_root : forall a b c delta, ((delta = b^2 - 4*a * c) ->
delta >= 0 -> a <> 0 -> exists x, a * x ^ 2 + b * x + c = 0)%R.
Proof.
intros a b c delta Hdelta deltapos Ha.
destruct deltapos.
destruct (Cpol_2_real_delta_pos a b c delta) as [x H0].
assumption. assumption. assumption.
destruct H0 as (x1, H0).
exists (-x1)%R. rewrite H0. ring.
destruct (Cpol_2_real_delta_eq_0 a b c delta) as [x2 H5].
assumption. assumption. assumption.
destruct H5 as (x1, H0).
exists (-x1)%R. rewrite H0. ring.
Qed.
Lemma Cpol_pos : forall a b c delta, (delta = b^2 - 4*a * c)%R ->
a <> 0%R ->
(forall x, 0 <> a*x*x+b*x+c)%R -> delta < 0%R.
intros a b c delta Hdelta Ha.
intro Hpoly.
destruct (total_order_T delta 0) as [[H|H]|H].
assumption.
destruct (Cfpol_root a b c delta).
assumption. intuition. assumption.
destruct (Hpoly x). ring_simplify. symmetry.
ring_simplify in H0. assumption.
destruct (Cfpol_root a b c delta).
assumption. intuition. assumption.
destruct (Hpoly x). ring_simplify. symmetry.
ring_simplify in H0. assumption.
Qed.
Lemma Pos_poly_del : forall a b c : R,
a <> 0%R -> a > 0%R -> (forall x, 0 <= a*x*x+b*x+c) -> b^2 - 4*a*c <=0.
Proof.
intros a b c Ha Haa Hpoly.
pose ( b^2 - 4*a*c)%R as delta.
destruct (total_order_T delta 0) as [[H|H]|H].
intuition. intuition.
destruct (Cfpol_root a b c delta).
reflexivity.
intuition.
assumption.
assert (H1 : (exists x1, exists x2, forall x,
a * x ^ 2 + b * x + c = a * (x + x1) * (x + x2))%R).
apply Cpol_2_real_delta_pos with delta.
ring_simplify.
reflexivity.
assumption.
assumption.
destruct H1 as [x1 [x2 H1]].
assert (H9 : (0 > a * ( -(x1 + x2)/2 + x1) * ( - (x1 + x2)/2 + x2))%R).
replace ((- (x1 + x2) / 2 + x1))%R with ((x1 - x2) /2)%R by field.
replace ((- (x1 + x2) / 2 + x2))%R with (-(x1 - x2) /2)%R by field.
replace (a * ((x1 - x2) / 2) * (- (x1 - x2) / 2))%R with ( ((x1 - x2) / 2)^2 * (-a))%R by field.
replace 0%R with ( ((x1 - x2) / 2) ^ 2 * 0 )%R by ring.
apply Rmult_gt_compat_l.
assert (H10 : (x1 <> x2)).
intro H11. rewrite H11 in H1.
assert ((a * 0 ^ 2 + b * 0 + c)%R = (a * (0 + x2) * (0 + x2)))%R.
apply H1.
assert ((a * 1 ^ 2 + b * 1 + c)%R = (a * (1 + x2) * (1 + x2)))%R.
apply H1.
ring_simpl.
rewrite <- H2 in H3. unfold delta in H.
replace (a + b + c)%R with (c + a + b)%R in H3 by ring.
replace (c + 2 * a * x2 +a)%R with (c + a + 2 * a * x2)%R in H3 by ring.
apply Rplus_eq_reg_l in H3. subst.
replace ((2 * a * x2) ^ 2 - 4 * a * (a * x2 ^ 2))%R with (0)%R in H by ring .
fourier.
replace (((x1 - x2) / 2) ^ 2)%R with (Rsqr (((x1 - x2) / 2))) by (unfold Rsqr ; simpl ; ring).
apply Rlt_0_sqr.
intro H30. replace 0%R with (0/2)%R in H30 by field.
unfold Rdiv in *. rewrite Rmult_comm in H30.
symmetry in H30. rewrite Rmult_comm in H30.
apply Rmult_eq_reg_l in H30.
apply H10. symmetry in H30. auto with *.
apply Rinv_neq_0_compat.
discrR.
intuition.
assert ( 0 <= a * (- (x1 + x2) / 2 + x1) * (- (x1 + x2) / 2 + x2)).
rewrite <- H1. replace ( (- (x1 + x2) / 2) ^ 2)%R with ((- (x1 + x2) / 2) * (- (x1 + x2) / 2) )%R by ring.
rewrite <- Rmult_assoc. apply Hpoly.
fourier.
Qed.
Require Import Cpolar.
Require Import Cexp.
Open Scope C_scope.
Lemma ast_fun_pos : forall n r, (n > 0)%nat -> r > 0 -> (r + 1) ^ n - r > 0.
Proof.
intros n r Hn Hr.
induction Hn.
simpl. ring_simplify. fourier.
simpl. rewrite Rmult_plus_distr_r. replace 0%R with (0 + 0)%R by intuition.
unfold Rminus. rewrite Rplus_assoc. apply Rplus_lt_compat.
apply Rmult_gt_0_compat.
assumption.
apply pow_lt. fourier.
rewrite Rmult_1_l. apply IHHn.
Qed.
(** ** Every positive real has a n root *)
Lemma exist_root_n_pos : forall r n, r >= 0 -> (n > 0)%nat -> {root | root ^ n = r}%R.
Proof.
intros r n Hr Hn.
pose (f := (fun x => x ^ n - r)%R).
assert (Cont_pow : forall x, continuity_pt f x).
unfold f. intros x. reg.
destruct (total_order_T r 0) as [[order|order]|order].
fourier.
exists 0. rewrite order.
rewrite pow_ne_zero. reflexivity.
intuition.
assert (Hsup0 : r+1 > 0) by fourier.
assert (Hpos : forall n, (n > 0)%nat -> (r + 1) ^ n - r > 0).
intros n1 Hn1. apply ast_fun_pos. assumption. assumption.
assert (Hneg : 0 ^ n - r < 0). rewrite pow_ne_zero. fourier.
intuition.
generalize (IVT (fun x => x ^ n - r) 0 (r + 1) Cont_pow Hsup0 Hneg)%R.
intros H. destruct H as (x, H).
apply Hpos. assumption.
exists x. intuition.
Qed.
(** ** Every complex has a n root *)
Lemma exist_root_n : forall n z, (n > 0)%nat -> {root | root ^ n = z}.
Proof.
intros n z Hn.
destruct (polar z) as [r [theta Hrt]].
destruct Hrt as [Hrpos [Htheta Hpol]].
rewrite Cmult_IRC_compat_l in Hpol.
rewrite <- Cexp_trigo_compat in Hpol.
destruct (exist_root_n_pos r n Hrpos) as (root_real, Hreal).
apply Hn.
exists ( root_real * Cexp ((0 +i theta ) / INC n)).
rewrite Cpow_mul_distr_l.
rewrite IRC_pow_compat. rewrite Hreal. rewrite <- Cexp_mult.
field_simplify (INC n * ((0 +i theta) / INC n)).
unfold Cdiv. rewrite Cinv_1. rewrite Cmult_1_r.
apply Hpol.
apply not_0_INC. intuition.
Qed.
|
{"author": "coqtail", "repo": "coqtail", "sha": "96799cc6901b9cdb1c5f47add0f9cd6584fdd389", "save_path": "github-repos/coq/coqtail-coqtail", "path": "github-repos/coq/coqtail-coqtail/coqtail-96799cc6901b9cdb1c5f47add0f9cd6584fdd389/rls/rls1/Complex/Croot_n.v"}
|
#== # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
#
# Auxiliary functions to pretty print tables.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ==#
export @ptconfclean, @ptconf, @pt
# Global configuration object.
const _pt_conf = PrettyTablesConf()
"""
@ptconfclean()
Clean all global configurations to pretty print tables using the macro `@pt`.
"""
macro ptconfclean()
return :(clear_pt_conf!(_pt_conf))
end
"""
@ptconf(expr...)
Add configurations in `expr` to be used with the macro `@pt`.
The expression format must be:
keyword1 = value1 keyword2 = value2 ...
in which the keywords can be any other possible keyword that can be used in the
function `pretty_table`.
!!! warning
If a keyword is not supported by the function `pretty_table`, then no error
message is printed when calling `@ptconf`. However, an error will be thrown
when `@pt` is called.
"""
macro ptconf(expr...)
kws = Expr[]
for ex in expr
# If the head is :(=), then it must be a configuration. Notice that we
# will ignore everything that is not an expression like `a = b`.
if (ex isa Expr) && (ex.head == :(=))
push!(kws, Expr(:kw, ex.args[1], ex.args[2]))
end
end
return :(set_pt_conf!(_pt_conf, $(kws...)))
end
"""
@pt(expr...)
Pretty print tables in `expr` to `stdout` using the global configurations
selected with the macro `@ptconf`.
Multiple tables can be printed by passing multiple expressions like:
@pt table1 table2 table3
The user can select the table header by passing the expression:
:header = [<Vector with the header>]
Notice that the header is valid only for the next printed table. Hence:
@pt :header = header1 table1 :header = header2 table2 table3
will print `table1` using `header1`, `table2` using `header2`, and `table3`
using the default header.
# Examples
```julia
julia> @ptconf tf = simple
julia> @pt :header = ["Time","Velocity"] [1:1:10 ones(10)] :header = ["Time","Position"] [1:1:10 1:1:10]
======= ===========
Time Velocity
======= ===========
1.0 1.0
2.0 1.0
3.0 1.0
4.0 1.0
5.0 1.0
6.0 1.0
7.0 1.0
8.0 1.0
9.0 1.0
10.0 1.0
======= ===========
======= ===========
Time Position
======= ===========
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
======= ===========
julia> @pt ones(3,3) + I + [1 2 3; 4 5 6; 7 8 9]
========= ======== =========
Col. 1 Col. 2 Col. 3
========= ======== =========
3.0 3.0 4.0
5.0 7.0 7.0
8.0 9.0 11.0
========= ======== =========
```
# Remarks
When more than one table is passed to this macro, then multiple calls to
`pretty_table` will occur. Hence, the cropping algorithm will behave exactly the
same as printing the tables separately.
"""
macro pt(expr...)
exprs = Expr[]
header = nothing
for ex in expr
# If the head is :(=) and the argument is `:header`, then we must set
# the header.
if (ex isa Expr) && (ex.head == :(=)) && (ex.args[1] == :(:header))
header = esc(ex.args[2])
# If it is not, then we assume that it is a table to be printed.
else
# Assemble the arguments.
args = Expr[]
header != nothing && push!(args, header)
if isempty(args)
expr = :(pretty_table_with_conf(_pt_conf, $(esc(ex)) ))
else
expr = :(pretty_table_with_conf(_pt_conf, $(esc(ex)), $(args...)))
end
push!(exprs, expr)
header = nothing
end
end
return Expr(:block, exprs...)
end
|
{"hexsha": "53328e7fe2ce7f84dbbabc623886edd76e66e974", "size": 3913, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/helpers.jl", "max_stars_repo_name": "charleskawczynski/PrettyTables.jl", "max_stars_repo_head_hexsha": "0ab64207f0689e35ad2e3e807ca1d2dc1357c7b8", "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/helpers.jl", "max_issues_repo_name": "charleskawczynski/PrettyTables.jl", "max_issues_repo_head_hexsha": "0ab64207f0689e35ad2e3e807ca1d2dc1357c7b8", "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/helpers.jl", "max_forks_repo_name": "charleskawczynski/PrettyTables.jl", "max_forks_repo_head_hexsha": "0ab64207f0689e35ad2e3e807ca1d2dc1357c7b8", "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": 24.7658227848, "max_line_length": 104, "alphanum_fraction": 0.5154612829, "num_tokens": 1168}
|
# coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# 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.
"""Implements the changes required for SAC for the DrQ Algorithm.
Reference paper:
https://arxiv.org/pdf/2004.13649.pdf
"""
import gin
import numpy as np
import tensorflow as tf
from tf_agents.agents import tf_agent
from tf_agents.agents.sac import sac_agent
from tf_agents.policies import actor_policy
from tf_agents.trajectories import trajectory
from tf_agents.utils import common
from tf_agents.utils import nest_utils
@gin.configurable
class DrQSacAgent(sac_agent.SacAgent):
"""A SAC Agent."""
def __init__(self,
time_step_spec,
action_spec,
critic_network,
actor_network,
actor_optimizer,
critic_optimizer,
alpha_optimizer,
actor_loss_weight=1.0,
critic_loss_weight=1.0,
alpha_loss_weight=1.0,
actor_policy_ctor=actor_policy.ActorPolicy,
critic_network_2=None,
target_critic_network=None,
target_critic_network_2=None,
actor_update_frequency=2,
target_update_tau=1.0,
target_update_period=1,
td_errors_loss_fn=tf.math.squared_difference,
gamma=1.0,
reward_scale_factor=1.0,
initial_log_alpha=np.log(0.1),
use_log_alpha_in_alpha_loss=False,
num_augmentations=2,
target_entropy=None,
gradient_clipping=None,
debug_summaries=False,
summarize_grads_and_vars=False,
train_step_counter=None,
name=None):
"""Creates a SAC Agent.
Args:
time_step_spec: A `TimeStep` spec of the expected time_steps.
action_spec: A nest of BoundedTensorSpec representing the actions.
critic_network: A function critic_network((observations, actions)) that
returns the q_values for each observation and action.
actor_network: A function actor_network(observation, action_spec) that
returns action distribution.
actor_optimizer: The optimizer to use for the actor network.
critic_optimizer: The default optimizer to use for the critic network.
alpha_optimizer: The default optimizer to use for the alpha variable.
actor_loss_weight: The weight on actor loss.
critic_loss_weight: The weight on critic loss.
alpha_loss_weight: The weight on alpha loss.
actor_policy_ctor: The policy class to use.
critic_network_2: (Optional.) A `tf_agents.network.Network` to be used as
the second critic network during Q learning. The weights from
`critic_network` are copied if this is not provided.
target_critic_network: (Optional.) A `tf_agents.network.Network` to be
used as the target critic network during Q learning. Every
`target_update_period` train steps, the weights from `critic_network`
are copied (possibly withsmoothing via `target_update_tau`) to `
target_critic_network`. If `target_critic_network` is not provided, it
is created by making a copy of `critic_network`, which initializes a new
network with the same structure and its own layers and weights.
Performing a `Network.copy` does not work when the network instance
already has trainable parameters (e.g., has already been built, or when
the network is sharing layers with another). In these cases, it is up
to you to build a copy having weights that are not shared with the
original `critic_network`, so that this can be used as a target network.
If you provide a `target_critic_network` that shares any weights with
`critic_network`, a warning will be logged but no exception is thrown.
target_critic_network_2: (Optional.) Similar network as
target_critic_network but for the critic_network_2. See documentation
for target_critic_network. Will only be used if 'critic_network_2' is
also specified.
actor_update_frequency: Frequency to calculate and update the actor and
alpha values.
target_update_tau: Factor for soft update of the target networks.
target_update_period: Period for soft update of the target networks.
td_errors_loss_fn: A function for computing the elementwise TD errors
loss.
gamma: A discount factor for future rewards.
reward_scale_factor: Multiplicative scale for the reward.
initial_log_alpha: Initial value for log_alpha.
use_log_alpha_in_alpha_loss: A boolean, whether using log_alpha or alpha
in alpha loss. Certain implementations of SAC use log_alpha as log
values are generally nicer to work with.
num_augmentations: K value in the original paper.
target_entropy: The target average policy entropy, for updating alpha. The
default value is negative of the total number of actions.
gradient_clipping: Norm length to clip gradients.
debug_summaries: A bool to gather debug summaries.
summarize_grads_and_vars: If True, gradient and network variable summaries
will be written during training.
train_step_counter: An optional counter to increment every time the train
op is run. Defaults to the global_step.
name: The name of this agent. All variables in this module will fall under
that name. Defaults to the class name.
"""
super(DrQSacAgent, self).__init__(
time_step_spec=time_step_spec,
action_spec=action_spec,
critic_network=critic_network,
actor_network=actor_network,
actor_optimizer=actor_optimizer,
critic_optimizer=critic_optimizer,
alpha_optimizer=alpha_optimizer,
actor_loss_weight=actor_loss_weight,
critic_loss_weight=critic_loss_weight,
alpha_loss_weight=alpha_loss_weight,
actor_policy_ctor=actor_policy_ctor,
critic_network_2=critic_network_2,
target_critic_network=target_critic_network,
target_critic_network_2=target_critic_network_2,
target_update_tau=target_update_tau,
target_update_period=target_update_period,
td_errors_loss_fn=td_errors_loss_fn,
gamma=gamma,
reward_scale_factor=reward_scale_factor,
initial_log_alpha=initial_log_alpha,
use_log_alpha_in_alpha_loss=use_log_alpha_in_alpha_loss,
target_entropy=target_entropy,
gradient_clipping=gradient_clipping,
debug_summaries=debug_summaries,
summarize_grads_and_vars=summarize_grads_and_vars,
train_step_counter=train_step_counter,
name=name)
self._actor_update_frequency = actor_update_frequency
# We use the observation in the trajectory as the first augmentation.
self._num_augmentations = num_augmentations
if num_augmentations > 1:
augmented_obs_spec = tuple([
dict(pixels=self.collect_data_spec.observation['pixels'])
for _ in range(num_augmentations - 1)
])
self._train_argspec = dict(
augmented_obs=augmented_obs_spec,
augmented_next_obs=augmented_obs_spec)
def _initialize(self):
# Call the target updater once here to avoid having it trigger on the first
# train call. Instead it will start counding down the target_update_period
# when training begins.
self._update_target()
super(DrQSacAgent, self)._initialize()
@common.function(autograph=True)
def _train(self, experience, weights, augmented_obs=None,
augmented_next_obs=None):
"""Returns a train op to update the agent's networks.
This method trains with the provided batched experience.
Args:
experience: A time-stacked trajectory object. If augmentations > 1 then a
tuple of the form: ``` (trajectory, [augmentation_1, ... ,
augmentation_{K-1}]) ``` is expected.
weights: Optional scalar or elementwise (per-batch-entry) importance
weights.
augmented_obs: List of length num_augmentations - 1 of random crops of the
trajectory's observation.
augmented_next_obs: List of length num_augmentations - 1 of random crops
of the trajectory's next_observation.
Returns:
A train_op.
Raises:
ValueError: If optimizers are None and no default value was provided to
the constructor.
"""
squeeze_time_dim = not self._critic_network_1.state_spec
time_steps, policy_steps, next_time_steps = (
trajectory.experience_to_transitions(experience, squeeze_time_dim))
actions = policy_steps.action
trainable_critic_variables = (
self._critic_network_1.trainable_variables +
self._critic_network_2.trainable_variables)
with tf.GradientTape(watch_accessed_variables=False) as tape:
assert trainable_critic_variables, ('No trainable critic variables to '
'optimize.')
tape.watch(trainable_critic_variables)
critic_loss = self._critic_loss_weight * self.critic_loss(
time_steps,
actions,
next_time_steps,
augmented_obs,
augmented_next_obs,
td_errors_loss_fn=self._td_errors_loss_fn,
gamma=self._gamma,
reward_scale_factor=self._reward_scale_factor,
weights=weights,
training=True)
tf.debugging.check_numerics(critic_loss, 'Critic loss is inf or nan.')
critic_grads = tape.gradient(critic_loss, trainable_critic_variables)
self._apply_gradients(critic_grads, trainable_critic_variables,
self._critic_optimizer)
total_loss = critic_loss
actor_loss = tf.constant(0.0, tf.float32)
alpha_loss = tf.constant(0.0, tf.float32)
with tf.name_scope('Losses'):
tf.compat.v2.summary.scalar(
name='critic_loss', data=critic_loss, step=self.train_step_counter)
# Only perform actor and alpha updates periodically
if self.train_step_counter % self._actor_update_frequency == 0:
trainable_actor_variables = self._actor_network.trainable_variables
with tf.GradientTape(watch_accessed_variables=False) as tape:
assert trainable_actor_variables, ('No trainable actor variables to '
'optimize.')
tape.watch(trainable_actor_variables)
actor_loss = self._actor_loss_weight * self.actor_loss(
time_steps, weights=weights)
tf.debugging.check_numerics(actor_loss, 'Actor loss is inf or nan.')
actor_grads = tape.gradient(actor_loss, trainable_actor_variables)
self._apply_gradients(actor_grads, trainable_actor_variables,
self._actor_optimizer)
alpha_variable = [self._log_alpha]
with tf.GradientTape(watch_accessed_variables=False) as tape:
assert alpha_variable, 'No alpha variable to optimize.'
tape.watch(alpha_variable)
alpha_loss = self._alpha_loss_weight * self.alpha_loss(
time_steps, weights=weights)
tf.debugging.check_numerics(alpha_loss, 'Alpha loss is inf or nan.')
alpha_grads = tape.gradient(alpha_loss, alpha_variable)
self._apply_gradients(alpha_grads, alpha_variable, self._alpha_optimizer)
with tf.name_scope('Losses'):
tf.compat.v2.summary.scalar(
name='actor_loss', data=actor_loss, step=self.train_step_counter)
tf.compat.v2.summary.scalar(
name='alpha_loss', data=alpha_loss, step=self.train_step_counter)
total_loss = critic_loss + actor_loss + alpha_loss
self.train_step_counter.assign_add(1)
self._update_target()
# NOTE: Consider keeping track of previous actor/alpha loss.
extra = sac_agent.SacLossInfo(
critic_loss=critic_loss, actor_loss=actor_loss, alpha_loss=alpha_loss)
return tf_agent.LossInfo(loss=total_loss, extra=extra)
@common.function(autograph=True)
def critic_loss(self,
time_steps,
actions,
next_time_steps,
augmented_obs,
augmented_next_obs,
td_errors_loss_fn,
gamma=1.0,
reward_scale_factor=1.0,
weights=None,
training=False):
"""Computes the critic loss for SAC training.
Args:
time_steps: A batch of timesteps.
actions: A batch of actions.
next_time_steps: A batch of next timesteps.
augmented_obs: List of observations.
augmented_next_obs: List of next_observations.
td_errors_loss_fn: A function(td_targets, predictions) to compute
elementwise (per-batch-entry) loss.
gamma: Discount for future rewards.
reward_scale_factor: Multiplicative factor to scale rewards.
weights: Optional scalar or elementwise (per-batch-entry) importance
weights.
training: Whether this loss is being used for training.
Returns:
critic_loss: A scalar critic loss.
"""
with tf.name_scope('critic_loss'):
nest_utils.assert_same_structure(actions, self.action_spec)
nest_utils.assert_same_structure(time_steps, self.time_step_spec)
nest_utils.assert_same_structure(next_time_steps, self.time_step_spec)
td_targets = self._compute_td_targets(next_time_steps,
reward_scale_factor, gamma)
# Compute td_targets with augmentations.
for i in range(self._num_augmentations - 1):
augmented_next_time_steps = next_time_steps._replace(
observation=augmented_next_obs[i])
augmented_td_targets = self._compute_td_targets(
augmented_next_time_steps, reward_scale_factor, gamma)
td_targets = td_targets + augmented_td_targets
# Average td_target estimation over augmentations.
if self._num_augmentations > 1:
td_targets = td_targets / self._num_augmentations
pred_td_targets1, pred_td_targets2, critic_loss = (
self._compute_prediction_critic_loss(
(time_steps.observation, actions), td_targets, time_steps,
training, td_errors_loss_fn))
# Add Q Augmentations to the critic loss.
for i in range(self._num_augmentations - 1):
augmented_time_steps = time_steps._replace(observation=augmented_obs[i])
_, _, loss = (
self._compute_prediction_critic_loss(
(augmented_time_steps.observation, actions), td_targets,
augmented_time_steps, training, td_errors_loss_fn))
critic_loss = critic_loss + loss
agg_loss = common.aggregate_losses(
per_example_loss=critic_loss,
sample_weight=weights,
regularization_loss=(self._critic_network_1.losses +
self._critic_network_2.losses))
critic_loss = agg_loss.total_loss
self._critic_loss_debug_summaries(td_targets, pred_td_targets1,
pred_td_targets2)
return critic_loss
def _compute_td_targets(self, next_time_steps, reward_scale_factor, gamma):
next_actions, next_log_pis = self._actions_and_log_probs(next_time_steps)
target_input = (next_time_steps.observation, next_actions)
target_q_values1, unused_network_state1 = self._target_critic_network_1(
target_input, next_time_steps.step_type, training=False)
target_q_values2, unused_network_state2 = self._target_critic_network_2(
target_input, next_time_steps.step_type, training=False)
target_q_values = (
tf.minimum(target_q_values1, target_q_values2) -
tf.exp(self._log_alpha) * next_log_pis)
return tf.stop_gradient(reward_scale_factor * next_time_steps.reward +
gamma * next_time_steps.discount * target_q_values)
def _compute_prediction_critic_loss(self, pred_input, td_targets, time_steps,
training, td_errors_loss_fn):
pred_td_targets1, _ = self._critic_network_1(
pred_input, time_steps.step_type, training=training)
pred_td_targets2, _ = self._critic_network_2(
pred_input, time_steps.step_type, training=training)
critic_loss1 = td_errors_loss_fn(td_targets, pred_td_targets1)
critic_loss2 = td_errors_loss_fn(td_targets, pred_td_targets2)
critic_loss = critic_loss1 + critic_loss2
if nest_utils.is_batched_nested_tensors(
time_steps, self.time_step_spec, num_outer_dims=2):
# Sum over the time dimension.
critic_loss = tf.reduce_sum(input_tensor=critic_loss, axis=1)
return pred_td_targets1, pred_td_targets2, critic_loss
|
{"hexsha": "230bfece16b20efe55718a5e3cdd2624cce4dd4c", "size": 17282, "ext": "py", "lang": "Python", "max_stars_repo_path": "pse/dm_control/agents/drq_sac_agent.py", "max_stars_repo_name": "pedersor/google-research", "max_stars_repo_head_hexsha": "6fa751dd261b3f6d918fd2cd35efef5d8bf3eea6", "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": "pse/dm_control/agents/drq_sac_agent.py", "max_issues_repo_name": "pedersor/google-research", "max_issues_repo_head_hexsha": "6fa751dd261b3f6d918fd2cd35efef5d8bf3eea6", "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": "pse/dm_control/agents/drq_sac_agent.py", "max_forks_repo_name": "pedersor/google-research", "max_forks_repo_head_hexsha": "6fa751dd261b3f6d918fd2cd35efef5d8bf3eea6", "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": 43.8629441624, "max_line_length": 80, "alphanum_fraction": 0.6991667631, "include": true, "reason": "import numpy", "num_tokens": 3646}
|
push!(LOAD_PATH,"../src/")
using Documenter, FourierAnalysis
makedocs(
sitename="FourierAnalysis",
authors="Marco Congedo, CNRS, France",
modules=[FourierAnalysis],
pages = [
"index.md",
"Main Module" => "MainModule.md",
"Tapering Window" => "tapers.md",
"frequency domain" => Any[
"Spectral Estimations" => "spectra.md",
"Cross-Spectral Matrices" => "crossspectra.md",
"Coherence Matrices" => "coherence.md",
"Goertzel's Algorithms" => "goertzel.md",
],
"time-frequency(TF) domain" => Any[
"TF Representations" => "timefrequency.md",
"TF Univariate Measures" => "timefrequencyuni.md",
"TF Bivariate Measures " => "timefrequencybi.md",
],
"utilities" => Any[
"Plots" => "plots.md",
"Tools" => "tools.md",
"FFTW planners" => "fftw.md",
"Filter Banks" => "filters.md",
"Hilbert Transform" => "hilbert.md",
]
]
)
# fix
deploydocs(
# root
# target = "build", # add this folder to .gitignore!
repo = "github.com/Marco-Congedo/FourierAnalysis.jl.git",
# branch = "gh-pages",
# osname = "linux",
# deps = Deps.pip("pygments", "mkdocs"),
# devbranch = "dev",
# devurl = "dev",
# versions = ["stable" => "v^", "v#.#", devurl => devurl],
)
|
{"hexsha": "29233fb3e496a137ff7c300abebe8ac23c7f5812", "size": 1540, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "docs/make.jl", "max_stars_repo_name": "laborg/FourierAnalysis.jl", "max_stars_repo_head_hexsha": "7ef12fa0dc8254fdcd501d41a1d93e9d5317ab71", "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": "docs/make.jl", "max_issues_repo_name": "laborg/FourierAnalysis.jl", "max_issues_repo_head_hexsha": "7ef12fa0dc8254fdcd501d41a1d93e9d5317ab71", "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": "docs/make.jl", "max_forks_repo_name": "laborg/FourierAnalysis.jl", "max_forks_repo_head_hexsha": "7ef12fa0dc8254fdcd501d41a1d93e9d5317ab71", "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": 33.4782608696, "max_line_length": 77, "alphanum_fraction": 0.4844155844, "num_tokens": 385}
|
\name{circos.genomicInitialize}
\alias{circos.genomicInitialize}
\title{
Initialize circular plot with any genomic data
}
\description{
Initialize circular plot with any genomic data
}
\usage{
circos.genomicInitialize(data, sector.names = NULL, major.by = NULL,
plotType = c("axis", "labels"), tickLabelsStartFromZero = TRUE,
axis.labels.cex = 0.4*par("cex"), labels.cex = 0.8*par("cex"),
track.height = NULL, ...)
}
\arguments{
\item{data}{A data frame containing genomic data.
}
\item{sector.names}{Labels for each sectors which will be drawn along each sector. It will not modify values of sector index.
}
\item{major.by}{Increment of major ticks. It is calculated automatically if the value is not set (about every 10 degrees there is a major tick).
}
\item{plotType}{If it is not \code{NULL}, there will create a new track containing axis and names for sectors.
This argument controls which part should be drawn, \code{axis} for genomic axis and \code{labels} for chromosome names
}
\item{tickLabelsStartFromZero}{Whether axis tick labels start from 0? This will only affect the axis labels while not affect x-values in cells.
}
\item{axis.labels.cex}{the font size for the axis tick labels.
}
\item{labels.cex}{the font size for the labels.
}
\item{track.height}{If \code{PlotType} is not \code{NULL}, height of the annotation track.
}
\item{...}{Pass to \code{\link{circos.initialize}}
}
}
\details{
The function will initialize circular plot from genomic data. If \code{plotType} is set with value in \code{axis} or \code{labels}, there will
create a new track.
The order of sectors related to data structure of \code{data}. If the first column in \code{data} is a factor, the order of sectors
is \code{levels(data[[1]])}; If the first column is just a simple vector, the order of sectors is \code{unique(data[[1]]}.
For more details on initializing genomic plot, please refer to the vignettes.
}
\references{
Gu, Z. (2014) circlize implements and enhances circular visualization in R. Bioinformatics.
}
\examples{
\dontrun{
df = read.cytoband()$df
circos.genomicInitialize(df)
df = data.frame(name = c("TP53", "TP63", "TP73"),
start = c(7565097, 189349205, 3569084),
end = c(7590856, 189615068, 3652765),
stringsAsFactors = FALSE)
circos.genomicInitialize(df)
circos.clear()
circos.genomicInitialize(df, major.by = 10000)
circos.clear()
circos.genomicInitialize(df, plotType = "labels")
circos.clear()
circos.genomicInitialize(df, sector.names = c("tp53", "tp63", "tp73"))
circos.clear()
circos.genomicInitialize(df, sector.names = c("tp53x", "tp63x", "tp73"))
circos.clear()
df[[1]] = factor(df[[1]], levels = c("TP73", "TP63", "TP53"))
circos.genomicInitialize(df)
circos.clear()
}
}
|
{"hexsha": "7be93587c17343a615d3cf7f689766844ba44e2c", "size": 2793, "ext": "rd", "lang": "R", "max_stars_repo_path": "man/circos.genomicInitialize.rd", "max_stars_repo_name": "calpan/circlize", "max_stars_repo_head_hexsha": "33f8f23663768367188e50e93d3f9b2b57edd0e7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-09-16T12:30:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-16T12:30:47.000Z", "max_issues_repo_path": "man/circos.genomicInitialize.rd", "max_issues_repo_name": "Nexller/circlize", "max_issues_repo_head_hexsha": "71df6b5316680dcee4d39d3ac7c224fcfc32439b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-08-16T14:55:12.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-16T14:55:12.000Z", "max_forks_repo_path": "man/circos.genomicInitialize.rd", "max_forks_repo_name": "Nexller/circlize", "max_forks_repo_head_hexsha": "71df6b5316680dcee4d39d3ac7c224fcfc32439b", "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.2602739726, "max_line_length": 234, "alphanum_fraction": 0.7175080559, "num_tokens": 767}
|
module time_advance
public :: init_time_advance, finish_time_advance
public :: advance_stella
public :: time_gke, time_parallel_nl
public :: checksum
private
interface get_dgdy
module procedure get_dgdy_2d
module procedure get_dgdy_3d
module procedure get_dgdy_4d
end interface
interface get_dgdx
module procedure get_dgdx_2d
module procedure get_dgdx_3d
module procedure get_dgdx_4d
end interface
interface checksum
module procedure checksum_field
module procedure checksum_dist
end interface
logical :: time_advance_initialized = .false.
logical :: wdriftinit = .false.
logical :: wstarinit = .false.
logical :: parnlinit = .false.
logical :: readinit = .false.
logical :: radialinit = .false.
logical :: driftimpinit = .false.
! if .true., dist fn is represented on alpha grid
! if .false., dist fn is given on k-alpha grid
! default is .false.; will only ever be set to
! .true. during full_flux_surface simulations
! logical :: alpha_space = .false.
integer :: explicit_option_switch
integer, parameter :: explicit_option_rk3 = 1, &
explicit_option_rk2 = 2, &
explicit_option_rk4 = 3
real :: xdriftknob, ydriftknob, wstarknob
logical :: flip_flop
complex, dimension(:, :, :), allocatable :: gamtot_drifts!, apar_denom_drifts
complex, dimension(:, :), allocatable :: gamtot3_drifts
! factor multiplying parallel nonlinearity
real, dimension(:, :), allocatable :: par_nl_fac, d_par_nl_fac_dr
! factor multiplying higher order linear term in parallel acceleration
real, dimension(:, :), allocatable :: par_nl_curv, d_par_nl_curv_dr
real, dimension(:), allocatable :: par_nl_driftx, par_nl_drifty
real, dimension(:), allocatable :: d_par_nl_driftx_dr, d_par_nl_drifty_dr
! needed for timing various pieces of gke solve
real, dimension(2, 10) :: time_gke = 0.
real, dimension(2, 2) :: time_parallel_nl = 0.
logical :: debug = .false.
contains
subroutine init_time_advance
use mp, only: proc0
use run_parameters, only: drifts_implicit
use physics_flags, only: radial_variation
use physics_flags, only: include_parallel_nonlinearity
use neoclassical_terms, only: init_neoclassical_terms
use dissipation, only: init_collisions, include_collisions
use parallel_streaming, only: init_parallel_streaming
use mirror_terms, only: init_mirror
use flow_shear, only: init_flow_shear
use sources, only: init_quasineutrality_source, init_source_timeaverage
implicit none
if (time_advance_initialized) return
time_advance_initialized = .true.
debug = debug .and. proc0
!> read time_advance_knobs namelist from the input file;
!> sets the explicit time advance option, as well as allows for scaling of
!> the x and y components of the magnetic drifts and of the drive term
if (debug) write (6, *) 'time_advance::init_time_advance::read_parameters'
call read_parameters
!> allocate distribution function sized arrays needed, e.g., for Runge-Kutta time advance
if (debug) write (6, *) 'time_advance::init_time_advance::allocate_arrays'
call allocate_arrays
!> set up neoclassical corrections to the equilibrium Maxwellian;
!> only calculated/needed when simulating higher order terms in rhostar for intrinsic rotation
if (debug) write (6, *) 'time_advance::init_time_advance::init_neoclassical_terms'
call init_neoclassical_terms
!> calculate the term multiplying dg/dvpa in the mirror term
!> and set up either the semi-Lagrange machinery or the tridiagonal matrix to be inverted
!> if solving implicitly
if (debug) write (6, *) 'time_advance::init_time_advance::init_mirror'
call init_mirror
!> calculate the term multiplying dg/dz in the parallel streaming term
!> and set up the tridiagonal matrix to be inverted if solving implicitly
if (debug) write (6, *) 'time_advance::init_time_advance::init_parstream'
call init_parallel_streaming
!> allocate and calculate the factors multiplying dg/dx, dg/dy, dphi/dx and dphi/dy
!> in the magnetic drift terms
if (debug) write (6, *) 'time_advance::init_time_advance::init_wdrift'
call init_wdrift
!> allocate and calculate the factor multiplying dphi/dy in the gradient drive term
if (debug) write (6, *) 'time_advance::init_time_advance::init_wstar'
call init_wstar
if (debug) write (6, *) 'time_advance::init_time_advance::init_flow_shear'
call init_flow_shear
if (debug) write (6, *) 'time_advance::init_time_advance::init_parallel_nonlinearity'
if (include_parallel_nonlinearity) call init_parallel_nonlinearity
if (debug) write (6, *) 'time_advance::init_time_advance::init_radial_variation'
if (radial_variation) call init_radial_variation
if (debug) write (6, *) 'time_advance::init_time_advance::init_drifts_implicit'
if (drifts_implicit) call init_drifts_implicit
if (include_collisions) then
if (debug) write (6, *) 'time_advance::init_time_advance::init_collisions'
call init_collisions
end if
if (debug) write (6, *) 'time_advance::init_time_advance::init_cfl'
call init_cfl
if (debug) write (6, *) 'time_advance::init_time_advance::init_source_timeaverage'
call init_source_timeaverage
if (debug) write (6, *) 'time_advance::init_time_advance::init_quasineutrality_source'
call init_quasineutrality_source
!call write_drifts
end subroutine init_time_advance
subroutine read_parameters
use file_utils, only: error_unit, input_unit_exist
use text_options, only: text_option, get_option_value
use mp, only: proc0, broadcast
use run_parameters, only: fully_explicit
implicit none
logical :: taexist
type(text_option), dimension(4), parameter :: explicitopts = &
(/text_option('default', explicit_option_rk3), &
text_option('rk3', explicit_option_rk3), &
text_option('rk2', explicit_option_rk2), &
text_option('rk4', explicit_option_rk4)/)
character(10) :: explicit_option
namelist /time_advance_knobs/ xdriftknob, ydriftknob, wstarknob, explicit_option, flip_flop
integer :: ierr, in_file
if (readinit) return
readinit = .true.
if (proc0) then
explicit_option = 'default'
xdriftknob = 1.0
ydriftknob = 1.0
wstarknob = 1.0
flip_flop = .false.
in_file = input_unit_exist("time_advance_knobs", taexist)
if (taexist) read (unit=in_file, nml=time_advance_knobs)
ierr = error_unit()
call get_option_value &
(explicit_option, explicitopts, explicit_option_switch, &
ierr, "explicit_option in time_advance_knobs")
end if
call broadcast(explicit_option_switch)
call broadcast(xdriftknob)
call broadcast(ydriftknob)
call broadcast(wstarknob)
call broadcast(flip_flop)
if (fully_explicit) flip_flop = .false.
end subroutine read_parameters
! subroutine write_drifts
! use dist_fn_arrays, only: wdriftx_g, wdrifty_g
! use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
! use dist_fn_arrays, only: wstar, wstarp
! use dist_fn_arrays, only: wdriftpx_g, wdriftpy_g
! use dist_fn_arrays, only: wdriftpx_phi, wdriftpy_phi
! use zgrid, only: nzgrid
! use stella_layouts, only: vmu_lo
! use file_utils, only: run_name
!
! implicit none
! integer ia, iz, ivmu
! character(len=512) :: filename
! ia=1
! filename=trim(run_name)//".drifts"
! open(3345,file=trim(filename),status='unknown')
! do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
! do iz= -nzgrid, nzgrid
! write(3345,'(10e25.8)') wstar(ia,iz,ivmu),wstarp(ia,iz,ivmu), &
! wdriftx_g(ia,iz,ivmu), wdriftpx_g(ia,iz,ivmu), &
! wdrifty_g(ia,iz,ivmu), wdriftpy_g(ia,iz,ivmu), &
! wdriftx_phi(ia,iz,ivmu), wdriftpx_phi(ia,iz,ivmu), &
! wdrifty_phi(ia,iz,ivmu), wdriftpy_phi(ia,iz,ivmu)
! enddo
! enddo
! close (3345)
! end subroutine write_drifts
subroutine init_wdrift
use mp, only: mp_abort
use physics_flags, only: full_flux_surface
use dist_fn_arrays, only: wdriftx_g, wdrifty_g
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use stella_layouts, only: vmu_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use stella_time, only: code_dt
use species, only: spec
use zgrid, only: nzgrid
use kt_grids, only: nalpha
use stella_geometry, only: cvdrift, gbdrift
use stella_geometry, only: cvdrift0, gbdrift0
use stella_geometry, only: gds23, gds24
use stella_geometry, only: geo_surf, q_as_x
use stella_geometry, only: dxdXcoord, drhodpsi, dydalpha
use vpamu_grids, only: vpa, vperp2
use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac
use neoclassical_terms, only: include_neoclassical_terms
use neoclassical_terms, only: dphineo_dzed, dphineo_drho, dphineo_dalpha
use neoclassical_terms, only: dfneo_dvpa, dfneo_dzed, dfneo_dalpha
implicit none
integer :: ivmu, iv, imu, is
real :: fac
real, dimension(:, :), allocatable :: wcvdrifty, wgbdrifty
real, dimension(:, :), allocatable :: wcvdriftx, wgbdriftx
if (wdriftinit) return
wdriftinit = .true.
!> allocate wdriftx_phi, the factor multiplying dphi/dx in the magnetic drift term
if (.not. allocated(wdriftx_phi)) then
allocate (wdriftx_phi(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
wdriftx_phi = 0.0
end if
!> allocate wdrifty_phi, the factor multiplying dphi/dy in the magnetic drift term
if (.not. allocated(wdrifty_phi)) then
allocate (wdrifty_phi(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
wdrifty_phi = 0.0
end if
!> allocate wdriftx_g, the factor multiplying dg/dx in the magnetic drift term
if (.not. allocated(wdriftx_g)) then
allocate (wdriftx_g(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
wdriftx_g = 0.0
end if
!> allocate wdrifty_g, the factor multiplying dg/dy in the magnetic drift term
if (.not. allocated(wdrifty_g)) then
allocate (wdrifty_g(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
wdrifty_g = 0.0
end if
allocate (wcvdrifty(nalpha, -nzgrid:nzgrid))
allocate (wgbdrifty(nalpha, -nzgrid:nzgrid))
allocate (wcvdriftx(nalpha, -nzgrid:nzgrid))
allocate (wgbdriftx(nalpha, -nzgrid:nzgrid))
! FLAG -- need to deal with shat=0 case. ideally move away from q as x-coordinate
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
iv = iv_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
fac = -ydriftknob * 0.5 * code_dt * spec(is)%tz_psi0
!> this is the curvature drift piece of wdrifty with missing factor of vpa
!> vpa factor is missing to avoid singularity when including
!> non-Maxwellian corrections to equilibrium
wcvdrifty = fac * cvdrift * vpa(iv)
!> this is the grad-B drift piece of wdrifty
wgbdrifty = fac * gbdrift * 0.5 * vperp2(:, :, imu)
wdrifty_g(:, :, ivmu) = wcvdrifty * vpa(iv) + wgbdrifty
!> if including neoclassical correction to equilibrium Maxwellian,
!> then add in v_E^{nc} . grad y dg/dy coefficient here
if (include_neoclassical_terms) then
wdrifty_g(:, :, ivmu) = wdrifty_g(:, :, ivmu) + code_dt * 0.5 * (gds23 * dphineo_dzed &
+ drhodpsi * dydalpha * dphineo_drho)
end if
wdrifty_phi(:, :, ivmu) = spec(is)%zt * (wgbdrifty + wcvdrifty * vpa(iv))
!> if full_flux_surface, evolved distribution function is normalised by a Maxwellian
!> otherwise, it is not; a Maxwellian weighting factor must thus be included
if (.not. full_flux_surface) then
wdrifty_phi(:, :, ivmu) = wdrifty_phi(:, :, ivmu) * maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is)
end if
!> if including neoclassical corrections to equilibrium,
!> add in -(Ze/m) * v_curv/vpa . grad y d<phi>/dy * dF^{nc}/dvpa term
!> and v_E . grad z dF^{nc}/dz (here get the dphi/dy part of v_E)
if (include_neoclassical_terms) then
!> NB: the below neoclassical correction needs to be divided by an equilibrium Maxwellian
!> if running in full flux surface mode
if (full_flux_surface) then
call mp_abort("include_neoclassical_terms=T not currently supported for full_flux_surface=T. aborting")
end if
wdrifty_phi(:, :, ivmu) = wdrifty_phi(:, :, ivmu) &
- 0.5 * spec(is)%zt * dfneo_dvpa(:, :, ivmu) * wcvdrifty &
- code_dt * 0.5 * dfneo_dzed(:, :, ivmu) * gds23
end if
if (q_as_x) then
fac = -xdriftknob * 0.5 * code_dt * spec(is)%tz_psi0
else
fac = -xdriftknob * 0.5 * code_dt * spec(is)%tz_psi0 / geo_surf%shat
end if
!> this is the curvature drift piece of wdriftx with missing factor of vpa
!> vpa factor is missing to avoid singularity when including
!> non-Maxwellian corrections to equilibrium
wcvdriftx = fac * cvdrift0 * vpa(iv)
!> this is the grad-B drift piece of wdriftx
wgbdriftx = fac * gbdrift0 * 0.5 * vperp2(:, :, imu)
wdriftx_g(:, :, ivmu) = wcvdriftx * vpa(iv) + wgbdriftx
!> if including neoclassical correction to equilibrium Maxwellian,
!> then add in v_E^{nc} . grad x dg/dx coefficient here
if (include_neoclassical_terms) then
wdriftx_g(:, :, ivmu) = wdriftx_g(:, :, ivmu) + code_dt * 0.5 * (gds24 * dphineo_dzed &
- dxdXcoord * dphineo_dalpha)
end if
wdriftx_phi(:, :, ivmu) = spec(is)%zt * (wgbdriftx + wcvdriftx * vpa(iv))
!> if full_flux_surface, evolved distribution function is normalised by a Maxwellian
!> otherwise, it is not; a Maxwellian weighting factor must thus be included
if (.not. full_flux_surface) then
wdriftx_phi(:, :, ivmu) = wdriftx_phi(:, :, ivmu) * maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is)
end if
!> if including neoclassical corrections to equilibrium,
!> add in (Ze/m) * v_curv/vpa . grad x d<phi>/dx * dF^{nc}/dvpa term
!> and v_E . grad z dF^{nc}/dz (here get the dphi/dx part of v_E)
!> and v_E . grad alpha dF^{nc}/dalpha (dphi/dx part of v_E)
if (include_neoclassical_terms) then
!> NB: the below neoclassical correction needs to be divided by an equilibrium Maxwellian
!> if running in full flux surface mode
if (full_flux_surface) then
call mp_abort("include_neoclassical_terms=T not currently supported for full_flux_surface=T. aborting")
end if
wdriftx_phi(:, :, ivmu) = wdriftx_phi(:, :, ivmu) &
- 0.5 * spec(is)%zt * dfneo_dvpa(:, :, ivmu) * wcvdriftx &
+ code_dt * 0.5 * (dfneo_dalpha(:, :, ivmu) * dxdXcoord - dfneo_dzed(:, :, ivmu) * gds24)
end if
end do
deallocate (wcvdriftx, wgbdriftx, wcvdrifty, wgbdrifty)
end subroutine init_wdrift
subroutine init_wstar
use mp, only: mp_abort
use stella_layouts, only: vmu_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use stella_time, only: code_dt
use species, only: spec
use zgrid, only: nzgrid
use kt_grids, only: nalpha
use stella_geometry, only: dydalpha, drhodpsi
use vpamu_grids, only: vperp2, vpa
use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac
use dist_fn_arrays, only: wstar
use neoclassical_terms, only: include_neoclassical_terms
use neoclassical_terms, only: dfneo_drho
use physics_flags, only: full_flux_surface
implicit none
integer :: is, imu, iv, ivmu
real, dimension(:, :), allocatable :: energy
if (wstarinit) return
wstarinit = .true.
if (.not. allocated(wstar)) &
allocate (wstar(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc)); wstar = 0.0
allocate (energy(nalpha, -nzgrid:nzgrid))
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
is = is_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
iv = iv_idx(vmu_lo, ivmu)
energy = (vpa(iv)**2 + vperp2(:, :, imu)) * (spec(is)%temp_psi0 / spec(is)%temp)
if (include_neoclassical_terms) then
if (full_flux_surface) then
call mp_abort("include_neoclassical_terms = T not yet supported for full_flux_surface = T. Aborting.")
else
wstar(:, :, ivmu) = dydalpha * drhodpsi * wstarknob * 0.5 * code_dt &
* (maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is) &
* (spec(is)%fprim + spec(is)%tprim * (energy - 1.5)) &
- dfneo_drho(:, :, ivmu))
end if
else
! wstar(:,:,ivmu) = dydalpha*drhodpsi*wstarknob*0.5*code_dt &
! * maxwell_vpa(iv,is)*maxwell_mu(:,:,imu,is)*maxwell_fac(is) &
! * (spec(is)%fprim+spec(is)%tprim*(energy-1.5))
wstar(:, :, ivmu) = dydalpha * drhodpsi * wstarknob * 0.5 * code_dt &
* (spec(is)%fprim + spec(is)%tprim * (energy - 1.5))
end if
if (.not. full_flux_surface) then
wstar(:, :, ivmu) = wstar(:, :, ivmu) * maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is)
end if
end do
deallocate (energy)
end subroutine init_wstar
subroutine init_drifts_implicit
use constants, only: zi
use mp, only: sum_allreduce, mp_abort
use stella_layouts, only: vmu_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use gyro_averages, only: aj0x
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use dist_fn_arrays, only: wdriftx_g, wdrifty_g
use dist_fn_arrays, only: wstar
use fields_arrays, only: gamtot
use fields, only: efac
use run_parameters, only: fphi, fapar, time_upwind
use species, only: spec, has_electron_species
use stella_geometry, only: dl_over_b
use zgrid, only: nzgrid
use vpamu_grids, only: integrate_species
use species, only: spec
use kt_grids, only: naky, nakx, aky, akx, zonal_mode
use physics_flags, only: adiabatic_option_switch
use physics_flags, only: adiabatic_option_fieldlineavg
implicit none
integer :: ivmu, iz, ikx, is, ia, iv, imu
complex :: tmps
complex, dimension(:, :, :), allocatable :: g0
complex, dimension(:, :), allocatable :: wd_g, wd_phi, wstr, tmp
if (driftimpinit) return
driftimpinit = .true.
ia = 1
allocate (wd_g(naky, nakx))
allocate (wd_phi(naky, nakx))
allocate (wstr(naky, nakx))
allocate (tmp(naky, nakx))
if (.not. allocated(gamtot_drifts)) &
allocate (gamtot_drifts(naky, nakx, -nzgrid:nzgrid))
gamtot_drifts = 0.
if (.not. allocated(gamtot3_drifts)) &
allocate (gamtot3_drifts(nakx, -nzgrid:nzgrid))
gamtot3_drifts = 0.
! if (.not.allocated(apar_denom_drifts)) &
! allocate (apar_denom_wstar(naky,nakx,-nzgrid:nzgrid))
! apar_denom_wstar = 0.
if (fphi > epsilon(0.0)) then
allocate (g0(naky, nakx, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
do iz = -nzgrid, nzgrid
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
iv = iv_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
!there terms already contain a factor of code_dt as well as
!a negative sign to account for RHS
wd_g = -zi * (spread(akx, 1, naky) * wdriftx_g(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_g(ia, iz, ivmu))
wd_phi = -zi * (spread(akx, 1, naky) * wdriftx_phi(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_phi(ia, iz, ivmu))
wstr = -zi * spread(aky, 2, nakx) * wstar(ia, iz, ivmu)
g0(:, :, ivmu) = 0.5 * (1.0 + time_upwind) * aj0x(:, :, iz, ivmu)**2 &
* (wd_phi + wstr) / (1.0 + 0.5 * (1.0 + time_upwind) * wd_g)
end do
call integrate_species(g0, iz, spec%z * spec%dens_psi0, gamtot_drifts(:, :, iz))
end do
gamtot_drifts = gamtot_drifts + gamtot
deallocate (g0)
if (.not. has_electron_species(spec)) then
! no need to do anything extra for ky /= 0 because
! already accounted for in gamtot_h
if (adiabatic_option_switch == adiabatic_option_fieldlineavg) then
if (zonal_mode(1)) then
do ikx = 1, nakx
! do not need kx=ky=0 mode
if (abs(akx(ikx)) < epsilon(0.)) cycle
tmps = 1.0 / efac - sum(dl_over_b(ia, :) / gamtot_drifts(1, ikx, :))
gamtot3_drifts(ikx, :) = 1./(gamtot_drifts(1, ikx, :) * tmps)
end do
if (akx(1) < epsilon(0.)) gamtot3_drifts(1, :) = 0.0
end if
end if
end if
end if
deallocate (wd_g, wd_phi, wstr, tmp)
!> @todo -- NEED TO SORT OUT FINITE FAPAR FOR GSTAR
if (fapar > epsilon(0.)) then
write (*, *) 'APAR NOT SETUP FOR GSTAR YET. aborting'
call mp_abort('APAR NOT SETUP FOR GSTAR YET. aborting')
end if
end subroutine init_drifts_implicit
subroutine init_parallel_nonlinearity
use physics_parameters, only: rhostar
use species, only: spec, nspec
use zgrid, only: nztot, nzgrid
use stella_geometry, only: geo_surf, drhodpsi, q_as_x
use stella_geometry, only: gradpar, dbdzed, bmag
use stella_geometry, only: cvdrift, cvdrift0
use stella_geometry, only: dIdrho, dgradpardrho, dBdrho, d2Bdrdth
use stella_geometry, only: dcvdriftdrho, dcvdrift0drho
use physics_flags, only: radial_variation
implicit none
if (.not. allocated(par_nl_fac)) allocate (par_nl_fac(-nzgrid:nzgrid, nspec))
! this is the factor multiplying -dphi/dz * dg/dvpa in the parallel nonlinearity
par_nl_fac = 0.5 * rhostar * spread(spec%stm_psi0 * spec%zt_psi0, 1, nztot) * spread(gradpar, 2, nspec)
if (.not. allocated(par_nl_curv)) allocate (par_nl_curv(-nzgrid:nzgrid, nspec))
! ydriftknob is here because this term comes from bhat x curvature . grad B
par_nl_curv = -ydriftknob * rhostar * geo_surf%rgeo * geo_surf%betaprim * drhodpsi &
* spread(dbdzed(1, :) * gradpar / bmag(1, :), 2, nspec) / spread(spec%zt_psi0, 1, nztot)
if (.not. allocated(par_nl_drifty)) allocate (par_nl_drifty(-nzgrid:nzgrid))
par_nl_drifty = 0.25 * rhostar * cvdrift(1, :)
if (.not. allocated(par_nl_driftx)) allocate (par_nl_driftx(-nzgrid:nzgrid))
if (q_as_x) then
par_nl_driftx = 0.25 * rhostar * cvdrift0(1, :)
else
par_nl_driftx = 0.25 * rhostar * cvdrift0(1, :) / geo_surf%shat
end if
if (radial_variation) then
if (.not. allocated(d_par_nl_fac_dr)) allocate (d_par_nl_fac_dr(-nzgrid:nzgrid, nspec))
! this is the factor multiplying -dphi/dz * dg/dvpa in the parallel nonlinearity
d_par_nl_fac_dr = 0.5 * rhostar * spread(spec%stm_psi0 * spec%zt_psi0, 1, nztot) * spread(dgradpardrho, 2, nspec)
if (.not. allocated(d_par_nl_curv_dr)) allocate (d_par_nl_curv_dr(-nzgrid:nzgrid, nspec))
! ydriftknob is here because this term comes from bhat x curvature . grad B
! handle terms with no zeroes
d_par_nl_curv_dr = par_nl_curv * (dIdrho / geo_surf%rgeo - drhodpsi * geo_surf%d2psidr2 &
- spread(dBdrho / bmag(1, :) + dgradpardrho / gradpar, 2, nspec))
! handle terms with possible zeroes
d_par_nl_curv_dr = d_par_nl_curv_dr &
- ((ydriftknob * rhostar * geo_surf%rgeo * drhodpsi * spread(gradpar / bmag(1, :), 2, nspec)) &
/ spread(spec%zt_psi0, 1, nztot)) &
* (geo_surf%betadbprim * spread(dbdzed(1, :), 2, nspec) &
+ geo_surf%betaprim * spread(d2Bdrdth, 2, nspec))
if (.not. allocated(d_par_nl_drifty_dr)) allocate (d_par_nl_drifty_dr(-nzgrid:nzgrid))
d_par_nl_drifty_dr = 0.25 * rhostar * dcvdriftdrho(1, :)
if (.not. allocated(d_par_nl_drifty_dr)) allocate (d_par_nl_driftx_dr(-nzgrid:nzgrid))
if (q_as_x) then
d_par_nl_driftx_dr = 0.25 * rhostar * dcvdrift0drho(1, :)
else
d_par_nl_driftx_dr = 0.25 * rhostar * dcvdrift0drho(1, :) / geo_surf%shat
end if
end if
parnlinit = .true.
end subroutine init_parallel_nonlinearity
subroutine init_radial_variation
use stella_layouts, only: vmu_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use stella_time, only: code_dt
use species, only: spec, pfac
use zgrid, only: nzgrid
use kt_grids, only: nalpha
use stella_geometry, only: drhodpsi, dydalpha, gfac
use stella_geometry, only: dBdrho, geo_surf, q_as_x
use stella_geometry, only: dcvdriftdrho, dcvdrift0drho
use stella_geometry, only: dgbdriftdrho, dgbdrift0drho
use vpamu_grids, only: vperp2, vpa, mu
use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac
use dist_fn_arrays, only: wstarp
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use dist_fn_arrays, only: wdriftpx_g, wdriftpy_g
use dist_fn_arrays, only: wdriftpx_phi, wdriftpy_phi!, adiabatic_phi
! use neoclassical_terms, only: include_neoclassical_terms
implicit none
integer :: is, imu, iv, ivmu
real :: fac
real, dimension(:, :), allocatable :: energy
real, dimension(:, :), allocatable :: wcvdrifty, wgbdrifty
real, dimension(:, :), allocatable :: wcvdriftx, wgbdriftx
!wstar
if (radialinit) return
radialinit = .true.
allocate (wcvdrifty(nalpha, -nzgrid:nzgrid))
allocate (wgbdrifty(nalpha, -nzgrid:nzgrid))
allocate (wcvdriftx(nalpha, -nzgrid:nzgrid))
allocate (wgbdriftx(nalpha, -nzgrid:nzgrid))
if (.not. allocated(wstarp)) &
allocate (wstarp(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc)); wstarp = 0.0
if (.not. allocated(wdriftpx_phi)) &
allocate (wdriftpx_phi(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
! if (.not.allocated(adiabatic_phi)) &
! allocate (adiabatic_phi(nalpha,-nzgrid:nzgrid,vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (.not. allocated(wdriftpy_phi)) &
allocate (wdriftpy_phi(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (.not. allocated(wdriftpx_g)) &
allocate (wdriftpx_g(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (.not. allocated(wdriftpy_g)) &
allocate (wdriftpy_g(nalpha, -nzgrid:nzgrid, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
allocate (energy(nalpha, -nzgrid:nzgrid))
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
is = is_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
iv = iv_idx(vmu_lo, ivmu)
energy = (vpa(iv)**2 + vperp2(:, :, imu)) * (spec(is)%temp_psi0 / spec(is)%temp)
!FLAG DSO - THIS NEEDS TO BE ADDED SOMEDAY!
!if (include_neoclassical_terms) then
! wstarp(:,:,ivmu) = dydalpha*drhodpsi*wstarknob*0.5*code_dt &
! * (maxwell_vpa(iv)*maxwell_mu(:,:,imu) &
! * (spec(is)%fprim+spec(is)%tprim*(energy-1.5)) &
! - dfneo_drho(:,:,ivmu))
!else
!recall that fprim = -dn/dr and trpim = -dt/dr
wstarp(:, :, ivmu) = -wstarknob * 0.5 * code_dt &
* dydalpha * drhodpsi * maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is) &
* (pfac * (spec(is)%d2ndr2 - (spec(is)%fprim)**2 - (spec(is)%tprim)**2 * energy) &
+ pfac * (spec(is)%d2Tdr2 - (spec(is)%tprim)**2) * (energy - 1.5) &
- gfac * 2 * spec(is)%tprim * mu(imu) * spread(dBdrho, 1, nalpha) &
+ (spec(is)%fprim + spec(is)%tprim * (energy - 1.5)) &
* (pfac * (spec(is)%fprim + spec(is)%tprim * (energy - 1.5)) &
+ gfac * 2 * mu(imu) * spread(dBdrho, 1, nalpha) &
+ gfac * drhodpsi * geo_surf%d2psidr2))
!end if
!wdrift
fac = -ydriftknob * 0.5 * code_dt * spec(is)%tz_psi0
! this is the curvature drift piece of wdrifty with missing factor of vpa
! vpa factor is missing to avoid singularity when including
! non-Maxwellian corrections to equilibrium
wcvdrifty = gfac * fac * dcvdriftdrho * vpa(iv)
! this is the grad-B drift piece of wdrifty
wgbdrifty = gfac * fac * dgbdriftdrho * 0.5 * vperp2(:, :, imu)
wdriftpy_g(:, :, ivmu) = wcvdrifty * vpa(iv) + wgbdrifty
wdriftpy_phi(:, :, ivmu) = spec(is)%zt * (wgbdrifty + wcvdrifty * vpa(iv)) &
* maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is) &
- wdrifty_phi(:, :, ivmu) * (pfac * (spec(is)%fprim + spec(is)%tprim * (energy - 2.5)) &
+ gfac * 2.*mu(imu) * spread(dBdrho, 1, nalpha))
if (q_as_x) then
fac = -xdriftknob * 0.5 * code_dt * spec(is)%tz_psi0
else
fac = -xdriftknob * 0.5 * code_dt * spec(is)%tz_psi0 / geo_surf%shat
end if
! this is the curvature drift piece of wdriftx with missing factor of vpa
! vpa factor is missing to avoid singularity when including
! non-Maxwellian corrections to equilibrium
wcvdriftx = gfac * fac * dcvdrift0drho * vpa(iv)
! this is the grad-B drift piece of wdriftx
wgbdriftx = gfac * fac * dgbdrift0drho * 0.5 * vperp2(:, :, imu)
wdriftpx_g(:, :, ivmu) = wgbdriftx + wcvdriftx * vpa(iv)
wdriftpx_phi(:, :, ivmu) = spec(is)%zt * (wgbdriftx + wcvdriftx * vpa(iv)) &
* maxwell_vpa(iv, is) * maxwell_mu(:, :, imu, is) * maxwell_fac(is) &
- wdriftx_phi(:, :, ivmu) * (pfac * (spec(is)%fprim + spec(is)%tprim * (energy - 2.5)) &
+ gfac * 2.*mu(imu) * spread(dBdrho, 1, nalpha))
! !the next piece is everything under the x derivative, as this needs to be
! !transformed separately
! wdriftpx_phi(:,:,ivmu) = spec(is)%zt*(wgbdriftx + wcvdriftx*vpa(iv)) &
! * maxwell_vpa(iv,is)*maxwell_mu(:,:,imu,is)*maxwell_fac(is)
! !this is variation in the Maxwellian part of the adiabatic response of phi,
! !which needs to be transformed separately before differentiation wrt x
! !the gyroaveraging and quasineutrality is already done in fields
! adiabatic_phi(:,:,ivmu) = -(pfac*(spec(is)%fprim+spec(is)%tprim*(energy-2.5)) &
! +gfac*2.*mu(imu)*spread(dBdrho,1,nalpha))
end do
deallocate (energy, wcvdriftx, wgbdriftx, wcvdrifty, wgbdrifty)
end subroutine init_radial_variation
subroutine allocate_arrays
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky, nakx
use dist_fn_arrays, only: g0, g1, g2, g3
implicit none
if (.not. allocated(g0)) &
allocate (g0(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
g0 = 0.
if (.not. allocated(g1)) &
allocate (g1(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
g1 = 0.
if (.not. allocated(g2)) &
allocate (g2(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
g2 = 0.
if (.not. allocated(g3) .and. explicit_option_switch == explicit_option_rk4) then
allocate (g3(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
g3 = 0.
else
allocate (g3(1, 1, 1, 1, 1))
end if
end subroutine allocate_arrays
subroutine init_cfl
use mp, only: proc0, nproc, max_allreduce, min_allreduce
use mp, only: scope, allprocs, subprocs
use dist_fn_arrays, only: wdriftx_g, wdrifty_g
use stella_time, only: cfl_dt, code_dt, write_dt
use run_parameters, only: cfl_cushion
use physics_flags, only: radial_variation, prp_shear_enabled
use zgrid, only: delzed
use vpamu_grids, only: dvpa
use kt_grids, only: akx, aky, nx, rho
use run_parameters, only: stream_implicit, mirror_implicit, drifts_implicit
use parallel_streaming, only: stream
use parallel_streaming, only: stream_rad_var1, stream_rad_var2
use mirror_terms, only: mirror
use flow_shear, only: prl_shear, shift_times
use file_utils, only: runtype_option_switch, runtype_multibox
use dissipation, only: include_collisions, collisions_implicit
use dissipation, only: vpa_operator, mu_operator
use dissipation, only: cfl_dt_vpadiff, cfl_dt_mudiff
implicit none
real :: cfl_dt_mirror, cfl_dt_stream, cfl_dt_shear
real :: cfl_dt_wdriftx, cfl_dt_wdrifty
real :: zero
real :: wdriftx_max, wdrifty_max
! avoid divide by zero in cfl_dt terms below
zero = 100.*epsilon(0.)
! FLAG -- assuming equal spacing in zed!
if (cfl_dt < 0) cfl_dt = code_dt / cfl_cushion
if (.not. drifts_implicit) then
! get the local max value of wdriftx on each processor
wdriftx_max = maxval(abs(wdriftx_g))
! compare these max values across processors to get global max
if (nproc > 1) then
call max_allreduce(wdriftx_max)
end if
! NB: wdriftx_g has code_dt built-in, which accounts for code_dt factor here
cfl_dt_wdriftx = abs(code_dt) / max(maxval(abs(akx)) * wdriftx_max, zero)
cfl_dt = cfl_dt_wdriftx
end if
cfl_dt_shear = abs(code_dt) / max(maxval(abs(aky)) * maxval(abs(prl_shear)), zero)
cfl_dt = min(cfl_dt, cfl_dt_shear)
if (prp_shear_enabled) then
cfl_dt_shear = minval(shift_times)
cfl_dt = min(cfl_dt, cfl_dt_shear)
end if
if (.not. stream_implicit) then
! NB: stream has code_dt built-in, which accounts for code_dt factor here
cfl_dt_stream = abs(code_dt) * delzed(0) / max(maxval(abs(stream)), zero)
cfl_dt = min(cfl_dt, cfl_dt_stream)
end if
if (.not. mirror_implicit) then
! NB: mirror has code_dt built-in, which accounts for code_dt factor here
cfl_dt_mirror = abs(code_dt) * dvpa / max(maxval(abs(mirror)), zero)
cfl_dt = min(cfl_dt, cfl_dt_mirror)
end if
if (radial_variation) then
!while other quantities should go here, parallel streaming with electrons
!is what will limit us
cfl_dt_stream = abs(code_dt) * delzed(0) / max(maxval(abs(stream_rad_var1)), zero)
cfl_dt_stream = cfl_dt_stream / abs(rho(nx) + zero)
cfl_dt = min(cfl_dt, cfl_dt_stream)
cfl_dt_stream = abs(code_dt) * delzed(0) / max(maxval(abs(stream_rad_var2)), zero)
cfl_dt_stream = cfl_dt_stream / abs(rho(nx) + zero)
cfl_dt = min(cfl_dt, cfl_dt_stream)
end if
if (include_collisions .and. .not. collisions_implicit) then
if (vpa_operator) cfl_dt = min(cfl_dt, cfl_dt_vpadiff)
if (mu_operator) cfl_dt = min(cfl_dt, cfl_dt_mudiff)
end if
if (.not. drifts_implicit) then
! get the local max value of wdrifty on each processor
wdrifty_max = maxval(abs(wdrifty_g))
! compare these max values across processors to get global max
if (nproc > 1) then
call max_allreduce(wdrifty_max)
end if
! NB: wdrifty_g has code_dt built-in, which accounts for code_dt factor here
cfl_dt_wdrifty = abs(code_dt) / max(maxval(abs(aky)) * wdrifty_max, zero)
cfl_dt = min(cfl_dt, cfl_dt_wdrifty)
end if
if (runtype_option_switch == runtype_multibox) call scope(allprocs)
call min_allreduce(cfl_dt)
if (runtype_option_switch == runtype_multibox) call scope(subprocs)
if (proc0) then
write (*, '(A)') "############################################################"
write (*, '(A)') " CFL CONDITION"
write (*, '(A)') "############################################################"
write (*, '(A16)') 'LINEAR CFL_DT: '
if (.not. drifts_implicit) write (*, '(A12,ES12.4)') ' wdriftx: ', cfl_dt_wdriftx
if (.not. drifts_implicit) write (*, '(A12,ES12.4)') ' wdrifty: ', cfl_dt_wdrifty
if (.not. stream_implicit) write (*, '(A12,ES12.4)') ' stream: ', cfl_dt_stream
if (.not. mirror_implicit) write (*, '(A12,ES12.4)') ' mirror: ', cfl_dt_mirror
write (*, *)
end if
if (abs(code_dt) > cfl_dt * cfl_cushion) then
if (proc0) then
write (*, *) 'CHANGING TIME STEP:'
write (*, '(A16, ES10.2E2)') " code_dt:"//REPEAT(' ', 50), code_dt
write (*, '(A16, ES10.2E2)') " cfl_dt:"//REPEAT(' ', 50), cfl_dt
write (*, '(A16, ES10.2E2)') " cfl_cushion:"//REPEAT(' ', 50), cfl_cushion
write (*, '(A65)') ' ==> User-specified delt is larger than cfl_dt*cfl_cushion.'//REPEAT(' ', 50)
write (*, '(A49,ES12.4)') ' ==> Changing code_dt to cfl_dt*cfl_cushion ='//REPEAT(' ', 50), cfl_dt * cfl_cushion
end if
code_dt = sign(1.0, code_dt) * cfl_dt * cfl_cushion
call reset_dt
else if (proc0) then
call write_dt
write (*, *)
end if
end subroutine init_cfl
subroutine reset_dt
use parallel_streaming, only: parallel_streaming_initialized
use parallel_streaming, only: init_parallel_streaming
use dissipation, only: init_collisions, collisions_initialized, include_collisions
use run_parameters, only: stream_implicit, driftkinetic_implicit, drifts_implicit
use response_matrix, only: response_matrix_initialized
use response_matrix, only: init_response_matrix
use mirror_terms, only: mirror_initialized
use mirror_terms, only: init_mirror
use flow_shear, only: flow_shear_initialized
use flow_shear, only: init_flow_shear
use physics_flags, only: radial_variation
use sources, only: init_source_timeaverage
use sources, only: init_quasineutrality_source, qn_source_initialized
implicit none
! need to recompute mirror and streaming terms
! to account for updated code_dt
wdriftinit = .false.
wstarinit = .false.
radialinit = .false.
driftimpinit = .false.
flow_shear_initialized = .false.
mirror_initialized = .false.
parallel_streaming_initialized = .false.
qn_source_initialized = .false.
if (debug) write (6, *) 'time_advance::reset_dt::init_wstar'
call init_wstar
if (debug) write (6, *) 'time_advance::reset_dt::init_wdrift'
call init_wdrift
if (debug) write (6, *) 'time_advance::reset_dt::init_mirror'
call init_mirror
if (debug) write (6, *) 'time_advance::reset_dt::init_parallel_streaming'
call init_parallel_streaming
if (debug) write (6, *) 'time_advance::reset_dt::init_flow_shear'
call init_flow_shear
if (debug) write (6, *) 'time_advance::reset_dt::init_source_timeaverage'
call init_source_timeaverage
if (debug) write (6, *) 'time_advance::reset_dt::init_quasineutrality_source'
call init_quasineutrality_source
if (radial_variation) then
if (debug) write (6, *) 'time_advance::reset_dt::init_radial_variation'
call init_radial_variation
end if
if (drifts_implicit) then
if (debug) write (6, *) 'time_advance::reset_dt::init_drifts_implicit'
call init_drifts_implicit
end if
if (include_collisions) then
if (debug) write (6, *) 'time_advance::reset_dt::init_collisions'
collisions_initialized = .false.
call init_collisions
end if
! do not try to re-init response matrix
! before it has been initialized the first time
if ((stream_implicit .or. driftkinetic_implicit) .and. response_matrix_initialized) then
response_matrix_initialized = .false.
if (debug) write (6, *) 'time_advance::reset_dt::init_response_matrix'
call init_response_matrix
end if
end subroutine reset_dt
subroutine advance_stella(istep)
use dist_fn_arrays, only: gold, gnew
use fields_arrays, only: phi, apar
use fields_arrays, only: phi_old
use fields, only: advance_fields, fields_updated
use run_parameters, only: fully_explicit
use multibox, only: RK_step
use sources, only: include_krook_operator, update_tcorr_krook
use sources, only: include_qn_source, update_quasineutrality_source
use sources, only: remove_zero_projection, project_out_zero
use kt_grids, only: nakx
implicit none
integer, intent(in) :: istep
!> unless running in multibox mode, no need to worry about
!> mb_communicate calls as the subroutine is immediately exited
!> if not in multibox mode.
if (.not. RK_step) then
if (debug) write (*, *) 'time_advance::multibox'
call mb_communicate(gnew)
end if
!> save value of phi
!> for use in diagnostics (to obtain frequency)
phi_old = phi
!> reverse the order of operations every time step
!> as part of alternating direction operator splitting
!> this is needed to ensure 2nd order accuracy in time
if (mod(istep, 2) == 1 .or. .not. flip_flop) then
!> advance the explicit parts of the GKE
if (debug) write (*, *) 'time_advance::advance_explicit'
call advance_explicit(gnew)
! enforce periodicity for zonal mode
! if (zonal_mode(1)) gnew(1,:,-nzgrid,:) = gnew(1,:,nzgrid,:)
!> use operator splitting to separately evolve
!> all terms treated implicitly
if (.not. fully_explicit) call advance_implicit(istep, phi, apar, gnew)
else
if (.not. fully_explicit) call advance_implicit(istep, phi, apar, gnew)
call advance_explicit(gnew)
end if
! presumably this is to do with the radially global version of the code?
! perhaps it could be packaged together with thee update_delay_krook code
! below and made into a single call where all of this happens so that
! users of the flux tube version of the code need not worry about it.
if (remove_zero_projection) then
call project_out_zero(gold, gnew)
fields_updated = .false.
end if
gold = gnew
!> Ensure fields are updated so that omega calculation is correct.
call advance_fields(gnew, phi, apar, dist='gbar')
!update the delay parameters for the Krook operator
if (include_krook_operator) call update_tcorr_krook(gnew)
if (include_qn_source) call update_quasineutrality_source
end subroutine advance_stella
! subroutine advance_explicit (phi, apar, g)
!> advance_explicit takes as input the guiding centre distribution function
!> in k-space and updates it to account for all of the terms in the GKE that
!> are advanced explicitly in time
subroutine advance_explicit(g)
use mp, only: proc0
use job_manage, only: time_message
use zgrid, only: nzgrid
use extended_zgrid, only: periodic
use kt_grids, only: naky
use stella_layouts, only: vmu_lo, iv_idx
use parallel_streaming, only: stream_sign
implicit none
! complex, dimension (:,:,-nzgrid:), intent (in out) :: phi, apar
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
integer :: ivmu, iv, sgn, iky
!> start the timer for the explicit part of the solve
if (proc0) call time_message(.false., time_gke(:, 8), ' explicit')
select case (explicit_option_switch)
case (explicit_option_rk2)
!> SSP RK2
call advance_explicit_rk2(g)
case (explicit_option_rk3)
!> default is SSP RK3
call advance_explicit_rk3(g)
case (explicit_option_rk4)
!> RK4
call advance_explicit_rk4(g)
end select
!> enforce periodicity for periodic (including zonal) modes
do iky = 1, naky
if (periodic(iky)) then
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
iv = iv_idx(vmu_lo, ivmu)
!> stream_sign > 0 corresponds to dz/dt < 0
sgn = stream_sign(iv)
g(iky, :, sgn * nzgrid, :, ivmu) = g(iky, :, -sgn * nzgrid, :, ivmu)
end do
end if
end do
!> stop the timer for the explicit part of the solve
if (proc0) call time_message(.false., time_gke(:, 8), ' explicit')
end subroutine advance_explicit
!> advance_expliciit_rk2 uses strong stability-preserving RK2 to advance one time step
subroutine advance_explicit_rk2(g)
use dist_fn_arrays, only: g0, g1
use zgrid, only: nzgrid
use stella_layouts, only: vmu_lo
use multibox, only: RK_step
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
integer :: icnt
logical :: restart_time_step
!> if CFL condition is violated by nonlinear term
!> then must modify time step size and restart time step
!> assume false and test
restart_time_step = .false.
!> RK_step only true if running in multibox mode
if (RK_step) call mb_communicate(g)
g0 = g
icnt = 1
!> SSP rk3 algorithm to advance explicit part of code
!> if GK equation written as dg/dt = rhs - vpar . grad h,
!> solve_gke returns rhs*dt
do while (icnt <= 2)
select case (icnt)
case (1)
call solve_gke(g0, g1, restart_time_step)
case (2)
g1 = g0 + g1
if (RK_step) call mb_communicate(g1)
call solve_gke(g1, g, restart_time_step)
end select
if (restart_time_step) then
icnt = 1
else
icnt = icnt + 1
end if
end do
!> this is gbar at intermediate time level
g = 0.5 * g0 + 0.5 * (g1 + g)
end subroutine advance_explicit_rk2
!> strong stability-preserving RK3
subroutine advance_explicit_rk3(g)
use dist_fn_arrays, only: g0, g1, g2
use zgrid, only: nzgrid
use stella_layouts, only: vmu_lo
use multibox, only: RK_step
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
integer :: icnt
logical :: restart_time_step
!> if CFL condition is violated by nonlinear term
!> then must modify time step size and restart time step
!> assume false and test
restart_time_step = .false.
!> RK_STEP = false unless in multibox mode
if (RK_step) call mb_communicate(g)
g0 = g
icnt = 1
!> SSP rk3 algorithm to advance explicit part of code
!> if GK equation written as dg/dt = rhs - vpar . grad h,
!> solve_gke returns rhs*dt
do while (icnt <= 3)
select case (icnt)
case (1)
call solve_gke(g0, g1, restart_time_step)
case (2)
g1 = g0 + g1
if (RK_step) call mb_communicate(g1)
call solve_gke(g1, g2, restart_time_step)
case (3)
g2 = g1 + g2
if (RK_step) call mb_communicate(g2)
call solve_gke(g2, g, restart_time_step)
end select
if (restart_time_step) then
icnt = 1
else
icnt = icnt + 1
end if
end do
!> this is gbar at intermediate time level
g = g0 / 3.+0.5 * g1 + (g2 + g) / 6.
end subroutine advance_explicit_rk3
!> standard RK4
subroutine advance_explicit_rk4(g)
use dist_fn_arrays, only: g0, g1, g2, g3
use zgrid, only: nzgrid
use stella_layouts, only: vmu_lo
use multibox, only: RK_step
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
integer :: icnt
logical :: restart_time_step
!> if CFL condition is violated by nonlinear term
!> then must modify time step size and restart time step
!> assume false and test
restart_time_step = .false.
!> RK_step is false unless in multibox mode
if (RK_step) call mb_communicate(g)
g0 = g
icnt = 1
!> RK4 algorithm to advance explicit part of code
!> if GK equation written as dg/dt = rhs - vpar . grad h,
!> solve_gke returns rhs*dt
do while (icnt <= 4)
select case (icnt)
case (1)
call solve_gke(g0, g1, restart_time_step)
case (2)
! g1 is h*k1
g3 = g0 + 0.5 * g1
if (RK_step) call mb_communicate(g3)
call solve_gke(g3, g2, restart_time_step)
g1 = g1 + 2.*g2
case (3)
! g2 is h*k2
g2 = g0 + 0.5 * g2
if (RK_step) call mb_communicate(g2)
call solve_gke(g2, g3, restart_time_step)
g1 = g1 + 2.*g3
case (4)
! g3 is h*k3
g3 = g0 + g3
if (RK_step) call mb_communicate(g3)
call solve_gke(g3, g, restart_time_step)
g1 = g1 + g
end select
if (restart_time_step) then
icnt = 1
else
icnt = icnt + 1
end if
end do
!> this is gbar at intermediate time level
g = g0 + g1 / 6.
end subroutine advance_explicit_rk4
!> solve_gke accepts as argument gin, the guiding centre distribution function in k-space,
!> and returns rhs_ky, the right-hand side of the gyrokinetic equation in k-space;
!> i.e., if dg/dt = r, then rhs_ky = r*dt
subroutine solve_gke(gin, rhs_ky, restart_time_step)
use job_manage, only: time_message
use fields_arrays, only: phi, apar
use stella_layouts, only: vmu_lo
use stella_transforms, only: transform_y2ky
use redistribute, only: gather, scatter
use physics_flags, only: include_parallel_nonlinearity
use physics_flags, only: include_parallel_streaming
use physics_flags, only: include_mirror
use physics_flags, only: nonlinear
use physics_flags, only: full_flux_surface, radial_variation
use physics_parameters, only: g_exb
use zgrid, only: nzgrid, ntubes
use kt_grids, only: ikx_max, ny, naky_all
use kt_grids, only: swap_kxky_back
use run_parameters, only: stream_implicit, mirror_implicit, drifts_implicit
use dissipation, only: include_collisions, advance_collisions_explicit, collisions_implicit
use sources, only: include_krook_operator, add_krook_operator
use parallel_streaming, only: advance_parallel_streaming_explicit
use fields, only: advance_fields, fields_updated, get_radial_correction
use mirror_terms, only: advance_mirror_explicit
use flow_shear, only: advance_parallel_flow_shear
use multibox, only: include_multibox_krook, add_multibox_krook
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(inout) :: gin
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(out), target :: rhs_ky
logical, intent(out) :: restart_time_step
complex, dimension(:, :, :, :, :), allocatable, target :: rhs_y
complex, dimension(:, :, :, :, :), pointer :: rhs
complex, dimension(:, :), allocatable :: rhs_ky_swap
integer :: iz, it, ivmu
rhs_ky = 0.
!> if full_flux_surface = .true., then initially obtain the RHS of the GKE in alpha-space;
!> will later inverse Fourier transform to get RHS in k_alpha-space
if (full_flux_surface) then
!> rhs_ky will always be needed as the array returned by the subroutine,
!> but intermediate array rhs_y (RHS of gke in alpha-space) only needed for full_flux_surface = .true.
allocate (rhs_y(ny, ikx_max, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
rhs_y = 0.
!> rhs is array referred to for both flux tube and full-flux-surface simulations;
!> for full-flux-surface it should point to rhs_y
rhs => rhs_y
else
!> rhs is array referred to for both flux tube and full-flux-surface simulations;
!> for flux tube it should point to rhs_ky
rhs => rhs_ky
end if
!> start with gbar in k-space and (ky,kx,z) local
!> obtain fields corresponding to gbar
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_fields'
call advance_fields(gin, phi, apar, dist='gbar')
if (radial_variation) call get_radial_correction(gin, phi, dist='gbar')
!> default is to continue with same time step size.
!> if estimated CFL condition for nonlinear terms is violated
!> then restart_time_step will be set to .true.
restart_time_step = .false.
!> calculate and add ExB nonlinearity to RHS of GK eqn
!> do this first, as the CFL condition may require a change in time step
!> and thus recomputation of mirror, wdrift, wstar, and parstream
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_ExB_nonlinearity'
if (nonlinear) call advance_ExB_nonlinearity(gin, rhs, restart_time_step)
!> include contribution from the parallel nonlinearity (aka turbulent acceleration)
if (include_parallel_nonlinearity .and. .not. restart_time_step) &
call advance_parallel_nonlinearity(gin, rhs, restart_time_step)
if (.not. restart_time_step) then
!> include contribution from perp flow shear in the parallel component of the toroidal flow
if ((g_exb**2) > epsilon(0.0)) call advance_parallel_flow_shear(rhs)
!> calculate and add mirror term to RHS of GK eqn
if (include_mirror .and. .not. mirror_implicit) then
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_mirror_explicit'
call advance_mirror_explicit(gin, rhs)
end if
if (.not. drifts_implicit) then
!> calculate and add alpha-component of magnetic drift term to RHS of GK eqn
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_wdrifty_explicit'
call advance_wdrifty_explicit(gin, phi, rhs)
!> calculate and add psi-component of magnetic drift term to RHS of GK eqn
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_wdriftx_explicit'
call advance_wdriftx_explicit(gin, phi, rhs)
!> calculate and add omega_* term to RHS of GK eqn
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_wstar_explicit'
call advance_wstar_explicit(phi, rhs)
end if
!> calculate and add contribution from collisions to RHS of GK eqn
if (include_collisions .and. .not. collisions_implicit) call advance_collisions_explicit(gin, phi, rhs)
!> calculate and add parallel streaming term to RHS of GK eqn
if (include_parallel_streaming .and. (.not. stream_implicit)) then
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_parallel_streaming_explicit'
call advance_parallel_streaming_explicit(gin, phi, rhs)
end if
!> if simulating a full flux surface (flux annulus), all terms to this point have been calculated
!> in real-space in alpha (y); transform to kalpha (ky) space before adding to RHS of GKE.
!> NB: it may be that for fully explicit calculation, this transform can be eliminated with additional code changes
if (full_flux_surface) then
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::transform_y2ky'
allocate (rhs_ky_swap(naky_all, ikx_max))
it = 1
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call transform_y2ky(rhs_y(:, :, iz, it, ivmu), rhs_ky_swap)
call swap_kxky_back(rhs_ky_swap, rhs_ky(:, :, iz, it, ivmu))
end do
end do
deallocate (rhs_y, rhs_ky_swap)
end if
if (radial_variation) call advance_radial_variation(gin, rhs)
if (include_krook_operator) call add_krook_operator(gin, rhs)
if (include_multibox_krook) call add_multibox_krook(gin, rhs)
end if
fields_updated = .false.
nullify (rhs)
end subroutine solve_gke
subroutine advance_wstar_explicit(phi, gout)
use mp, only: proc0, mp_abort
use job_manage, only: time_message
use fields, only: get_dchidy
use fields_arrays, only: apar
use stella_layouts, only: vmu_lo
use stella_transforms, only: transform_ky2y
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky, naky_all, nakx, ikx_max, ny
use kt_grids, only: swap_kxky
use physics_flags, only: full_flux_surface
use dist_fn_arrays, only: wstar
implicit none
complex, dimension(:, :, -nzgrid:, :), intent(in) :: phi
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
complex, dimension(:, :, :, :, :), allocatable :: g0, g0y
complex, dimension(:, :), allocatable :: g0_swap
integer :: iz, it, ivmu
!> start timing the time advance due to the driving gradients
if (proc0) call time_message(.false., time_gke(:, 6), ' wstar advance')
allocate (g0(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (debug) write (*, *) 'time_advance::solve_gke::get_dchidy'
!> get d<chi>/dy in k-space
call get_dchidy(phi, apar, g0)
if (full_flux_surface) then
!> assume only a single flux surface simulated
it = 1
allocate (g0y(ny, ikx_max, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
allocate (g0_swap(naky_all, ikx_max))
!> transform d<chi>/dy from k-space to y-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call swap_kxky(g0(:, :, iz, it, ivmu), g0_swap)
call transform_ky2y(g0_swap, g0y(:, :, iz, it, ivmu))
end do
end do
!> multiply d<chi>/dy with omega_* coefficient and add to source (RHS of GK eqn)
! call add_wstar_term_ffs (g0y, gout)
call add_explicit_term_ffs(g0y, wstar, gout)
deallocate (g0y, g0_swap)
else
!> omega_* stays in ky,kx,z space with ky,kx,z local
!> multiply d<chi>/dy with omega_* coefficient and add to source (RHS of GK eqn)
if (debug) write (*, *) 'time_advance::solve_gke::add_wstar_term'
! call add_wstar_term (g0, gout)
call add_explicit_term(g0, wstar(1, :, :), gout)
end if
deallocate (g0)
!> stop timing the time advance due to the driving gradients
if (proc0) call time_message(.false., time_gke(:, 6), ' wstar advance')
end subroutine advance_wstar_explicit
!> advance_wdrifty_explicit subroutine calculates and adds the y-component of the
!> magnetic drift term to the RHS of the GK equation
subroutine advance_wdrifty_explicit(g, phi, gout)
use mp, only: proc0
use stella_layouts, only: vmu_lo
use job_manage, only: time_message
use stella_transforms, only: transform_ky2y
use zgrid, only: nzgrid, ntubes
use kt_grids, only: nakx, ikx_max, naky, naky_all, ny
use kt_grids, only: swap_kxky
use physics_flags, only: full_flux_surface
use gyro_averages, only: gyro_average
use dist_fn_arrays, only: wdrifty_g, wdrifty_phi
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :), intent(in) :: phi
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
integer :: ivmu, iz, it
complex, dimension(:, :, :, :), allocatable :: dphidy
complex, dimension(:, :, :, :, :), allocatable :: g0k, g0y
complex, dimension(:, :), allocatable :: g0k_swap
!> start the timing of the y component of the magnetic drift advance
if (proc0) call time_message(.false., time_gke(:, 4), ' dgdy advance')
allocate (dphidy(naky, nakx, -nzgrid:nzgrid, ntubes))
allocate (g0k(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (debug) write (*, *) 'time_advance::advance_stella::advance_explicit::solve_gke::advance_wdrifty_explicit::get_dgdy'
!> calculate dg/dy in (ky,kx) space
call get_dgdy(g, g0k)
!> calculate dphi/dy in (ky,kx) space
call get_dgdy(phi, dphidy)
if (full_flux_surface) then
!> assume only a single flux surface simulated
it = 1
allocate (g0y(ny, ikx_max, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
allocate (g0k_swap(naky_all, ikx_max))
!> transform dg/dy from k-space to y-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call swap_kxky(g0k(:, :, iz, it, ivmu), g0k_swap)
call transform_ky2y(g0k_swap, g0y(:, :, iz, it, ivmu))
end do
end do
!> add vM . grad y dg/dy term to equation
call add_explicit_term_ffs(g0y, wdrifty_g, gout)
!> get <dphi/dy> in k-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
call gyro_average(dphidy, ivmu, g0k(:, :, :, :, ivmu))
end do
!> transform d<phi>/dy from k-space to y-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call swap_kxky(g0k(:, :, iz, it, ivmu), g0k_swap)
call transform_ky2y(g0k_swap, g0y(:, :, iz, it, ivmu))
end do
end do
!> add vM . grad y d<phi>/dy term to equation
call add_explicit_term_ffs(g0y, wdrifty_phi, gout)
deallocate (g0y, g0k_swap)
else
if (debug) write (*, *) 'time_advance::solve_gke::add_dgdy_term'
! add vM . grad y dg/dy term to equation
call add_explicit_term(g0k, wdrifty_g(1, :, :), gout)
! get <dphi/dy> in k-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
call gyro_average(dphidy, ivmu, g0k(:, :, :, :, ivmu))
end do
! add vM . grad y d<phi>/dy term to equation
call add_explicit_term(g0k, wdrifty_phi(1, :, :), gout)
end if
deallocate (g0k, dphidy)
!> stop the timing of the y component of the magnetic drift advance
if (proc0) call time_message(.false., time_gke(:, 4), ' dgdy advance')
end subroutine advance_wdrifty_explicit
!> advance_wdriftx_explicit subroutine calculates and adds the x-component of the
!> magnetic drift term to the RHS of the GK equation
subroutine advance_wdriftx_explicit(g, phi, gout)
use mp, only: proc0
use stella_layouts, only: vmu_lo
use job_manage, only: time_message
use stella_transforms, only: transform_ky2y
use zgrid, only: nzgrid, ntubes
use kt_grids, only: nakx, ikx_max, naky, naky_all, ny, akx
use kt_grids, only: swap_kxky
use physics_flags, only: full_flux_surface
use gyro_averages, only: gyro_average
use dist_fn_arrays, only: wdriftx_g, wdriftx_phi
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :), intent(in) :: phi
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
integer :: ivmu, iz, it
complex, dimension(:, :, :, :), allocatable :: dphidx
complex, dimension(:, :, :, :, :), allocatable :: g0k, g0y
complex, dimension(:, :), allocatable :: g0k_swap
!> start the timing of the x component of the magnetic drift advance
if (proc0) call time_message(.false., time_gke(:, 5), ' dgdx advance')
!> do not calculate if wdriftx terms are all zero
if (maxval(abs(akx)) < epsilon(0.)) then
if (proc0) call time_message(.false., time_gke(:, 5), ' dgdx advance')
return
end if
allocate (dphidx(naky, nakx, -nzgrid:nzgrid, ntubes))
allocate (g0k(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
if (debug) write (*, *) 'time_advance::solve_gke::get_dgdx'
!> calculate dg/dx in (ky,kx) space
call get_dgdx(g, g0k)
!> calculate dphi/dx in (ky,kx) space
call get_dgdx(phi, dphidx)
if (full_flux_surface) then
!> assume a single flux surface is simulated
it = 1
allocate (g0y(ny, ikx_max, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
allocate (g0k_swap(naky_all, ikx_max))
!> transform dg/dx from k-space to y-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call swap_kxky(g0k(:, :, iz, it, ivmu), g0k_swap)
call transform_ky2y(g0k_swap, g0y(:, :, iz, it, ivmu))
end do
end do
!> add vM . grad x dg/dx term to equation
call add_explicit_term_ffs(g0y, wdriftx_g, gout)
!> get <dphi/dx> in k-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
call gyro_average(dphidx, ivmu, g0k(:, :, :, :, ivmu))
end do
!> transform d<phi>/dx from k-space to y-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do iz = -nzgrid, nzgrid
call swap_kxky(g0k(:, :, iz, it, ivmu), g0k_swap)
call transform_ky2y(g0k_swap, g0y(:, :, iz, it, ivmu))
end do
end do
!> add vM . grad x d<phi>/dx term to equation
call add_explicit_term_ffs(g0y, wdriftx_phi, gout)
deallocate (g0y, g0k_swap)
else
if (debug) write (*, *) 'time_advance::solve_gke::add_dgdx_term'
!> add vM . grad x dg/dx term to equation
call add_explicit_term(g0k, wdriftx_g(1, :, :), gout)
!> get <dphi/dx> in k-space
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
call gyro_average(dphidx, ivmu, g0k(:, :, :, :, ivmu))
end do
!> add vM . grad x d<phi>/dx term to equation
call add_explicit_term(g0k, wdriftx_phi(1, :, :), gout)
end if
deallocate (g0k, dphidx)
!> stop the timing of the x component of the magnetic drift advance
if (proc0) call time_message(.false., time_gke(:, 5), ' dgdx advance')
end subroutine advance_wdriftx_explicit
subroutine advance_ExB_nonlinearity(g, gout, restart_time_step)
use mp, only: proc0, min_allreduce
use mp, only: scope, allprocs, subprocs
use stella_layouts, only: vmu_lo, imu_idx, is_idx
use job_manage, only: time_message
use gyro_averages, only: gyro_average
use fields, only: get_dchidx, get_dchidy
use fields_arrays, only: phi, apar, shift_state
use fields_arrays, only: phi_corr_QN, phi_corr_GA
! use fields_arrays, only: apar_corr_QN, apar_corr_GA
use stella_transforms, only: transform_y2ky, transform_x2kx
use stella_transforms, only: transform_y2ky_xfirst, transform_x2kx_xfirst
use stella_time, only: cfl_dt, code_dt, code_dt_max
use run_parameters, only: cfl_cushion, delt_adjust, fphi
use physics_parameters, only: g_exb, g_exbfac
use zgrid, only: nzgrid, ntubes
use stella_geometry, only: exb_nonlin_fac, exb_nonlin_fac_p, gfac
use kt_grids, only: nakx, ikx_max, naky, naky_all, nx, ny
use kt_grids, only: akx, aky, rho_clamped
use physics_flags, only: full_flux_surface, radial_variation
use physics_flags, only: prp_shear_enabled, hammett_flow_shear
use kt_grids, only: x, swap_kxky, swap_kxky_back
use constants, only: pi, zi
use file_utils, only: runtype_option_switch, runtype_multibox
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
logical, intent(out) :: restart_time_step
complex, dimension(:, :), allocatable :: g0k, g0a, g0k_swap
complex, dimension(:, :), allocatable :: g0kxy, g0xky, prefac
real, dimension(:, :), allocatable :: g0xy, g1xy, bracket
integer :: ivmu, iz, it, imu, is
logical :: yfirst
! alpha-component of magnetic drift (requires ky -> y)
if (proc0) call time_message(.false., time_gke(:, 7), ' ExB nonlinear advance')
if (debug) write (*, *) 'time_advance::solve_gke::advance_ExB_nonlinearity::get_dgdy'
restart_time_step = .false.
! this statement seems to imply that flow shear is not compatible with FFS
! need to check
yfirst = .not. prp_shear_enabled
allocate (g0k(naky, nakx))
allocate (g0a(naky, nakx))
allocate (g0xy(ny, nx))
allocate (g1xy(ny, nx))
allocate (bracket(ny, nx))
allocate (prefac(naky, nx))
if (yfirst) then
allocate (g0k_swap(naky_all, ikx_max))
allocate (g0kxy(ny, ikx_max))
else
allocate (g0xky(naky, nx))
end if
!> compute phase factor needed when running with equilibrium flow shear
prefac = 1.0
if (prp_shear_enabled .and. hammett_flow_shear) then
prefac = exp(-zi * g_exb * g_exbfac * spread(x, 1, naky) * spread(aky * shift_state, 2, nx))
end if
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
do it = 1, ntubes
do iz = -nzgrid, nzgrid
!> compute i*ky*g
call get_dgdy(g(:, :, iz, it, ivmu), g0k)
!> FFT to get dg/dy in (y,x) space
call forward_transform(g0k, g0xy)
!> compute i*kx*<chi>
call get_dchidx(iz, ivmu, phi(:, :, iz, it), apar(:, :, iz, it), g0k)
!> if running with equilibrium flow shear, make adjustment to
!> the term multiplying dg/dy
if (prp_shear_enabled .and. hammett_flow_shear) then
call get_dchidy(iz, ivmu, phi(:, :, iz, it), apar(:, :, iz, it), g0a)
g0k = g0k - g_exb * g_exbfac * spread(shift_state, 2, nakx) * g0a
end if
!> FFT to get d<chi>/dx in (y,x) space
call forward_transform(g0k, g1xy)
!> multiply by the geometric factor appearing in the Poisson bracket;
!> i.e., (dx/dpsi*dy/dalpha)*0.5
g1xy = g1xy * exb_nonlin_fac
!> compute the contribution to the Poisson bracket from dg/dy*d<chi>/dx
bracket = g0xy * g1xy
!> estimate the CFL dt due to the above contribution
cfl_dt = min(cfl_dt, 2.*pi / (maxval(abs(g1xy)) * aky(naky)))
if (radial_variation) then
bracket = bracket + gfac * g0xy * g1xy * exb_nonlin_fac_p * spread(rho_clamped, 1, ny)
call gyro_average(phi_corr_QN(:, :, iz, it), iz, ivmu, g0a)
g0a = fphi * (g0a + phi_corr_GA(:, :, iz, it, ivmu))
call get_dgdx(g0a, g0k)
call forward_transform(g0k, g1xy)
g1xy = g1xy * exb_nonlin_fac
bracket = bracket + g0xy * g1xy
end if
!> estimate the CFL dt due to the above contribution
cfl_dt = min(cfl_dt, 2.*pi / (maxval(abs(g1xy)) * aky(naky)))
!> compute dg/dx in k-space (= i*kx*g)
call get_dgdx(g(:, :, iz, it, ivmu), g0k)
!> if running with equilibrium flow shear, correct dg/dx term
if (prp_shear_enabled .and. hammett_flow_shear) then
call get_dgdy(g(:, :, iz, it, ivmu), g0a)
g0k = g0k - g_exb * g_exbfac * spread(shift_state, 2, nakx) * g0a
end if
!> FFT to get dg/dx in (y,x) space
call forward_transform(g0k, g0xy)
!> compute d<chi>/dy in k-space
call get_dchidy(iz, ivmu, phi(:, :, iz, it), apar(:, :, iz, it), g0k)
!> FFT to get d<chi>/dy in (y,x) space
call forward_transform(g0k, g1xy)
!> multiply by the geometric factor appearing in the Poisson bracket;
!> i.e., (dx/dpsi*dy/dalpha)*0.5
g1xy = g1xy * exb_nonlin_fac
!> compute the contribution to the Poisson bracket from dg/dy*d<chi>/dx
bracket = bracket - g0xy * g1xy
!> estimate the CFL dt due to the above contribution
cfl_dt = min(cfl_dt, 2.*pi / (maxval(abs(g1xy)) * akx(ikx_max)))
if (radial_variation) then
bracket = bracket - gfac * g0xy * g1xy * exb_nonlin_fac_p * spread(rho_clamped, 1, ny)
call gyro_average(phi_corr_QN(:, :, iz, it), iz, ivmu, g0a)
g0a = fphi * (g0a + phi_corr_GA(:, :, iz, it, ivmu))
call get_dgdy(g0a, g0k)
call forward_transform(g0k, g1xy)
g1xy = g1xy * exb_nonlin_fac
bracket = bracket - g0xy * g1xy
end if
!> estimate the CFL dt due to the above contribution
cfl_dt = min(cfl_dt, 2.*pi / (maxval(abs(g1xy)) * akx(ikx_max)))
if (yfirst) then
call transform_x2kx(bracket, g0kxy)
if (full_flux_surface) then
gout(:, :, iz, it, ivmu) = g0kxy
else
call transform_y2ky(g0kxy, g0k_swap)
call swap_kxky_back(g0k_swap, gout(:, :, iz, it, ivmu))
end if
else
call transform_y2ky_xfirst(bracket, g0xky)
g0xky = g0xky / prefac
call transform_x2kx_xfirst(g0xky, gout(:, :, iz, it, ivmu))
end if
end do
end do
! enforce periodicity for zonal mode
! FLAG -- THIS IS PROBABLY NOT NECESSARY (DONE AT THE END OF EXPLICIT ADVANCE)
! AND MAY INDEED BE THE WRONG THING TO DO
gout(1, :, -nzgrid, :, ivmu) = 0.5 * (gout(1, :, nzgrid, :, ivmu) + gout(1, :, -nzgrid, :, ivmu))
gout(1, :, nzgrid, :, ivmu) = gout(1, :, -nzgrid, :, ivmu)
end do
deallocate (g0k, g0a, g0xy, g1xy, bracket)
if (allocated(g0k_swap)) deallocate (g0k_swap)
if (allocated(g0xky)) deallocate (g0xky)
if (allocated(g0kxy)) deallocate (g0kxy)
if (runtype_option_switch == runtype_multibox) call scope(allprocs)
call min_allreduce(cfl_dt)
if (runtype_option_switch == runtype_multibox) call scope(subprocs)
!> check estimated cfl_dt to see if the time step size needs to be changed
if (code_dt > cfl_dt * cfl_cushion) then
if (proc0) then
write (*, *) ' '
write (*, *) 'CHANGING TIME STEP:'
write (*, '(A16, ES10.2E2)') " code_dt:"//REPEAT(' ', 50), code_dt
write (*, '(A16, ES10.2E2)') " cfl_dt:"//REPEAT(' ', 50), cfl_dt
write (*, '(A16, ES10.2E2)') " cfl_cushion:"//REPEAT(' ', 50), cfl_cushion
write (*, '(A16, ES10.2E2)') " delt_adjust:"//REPEAT(' ', 50), delt_adjust
write (*, '(A65)') ' ==> The code_dt is larger than cfl_dt*cfl_cushion.'//REPEAT(' ', 50)
write (*, '(A61,ES12.4)') ' ==> Decreasing code_dt to cfl_dt*cfl_cushion/delt_adjust ='//REPEAT(' ', 50), cfl_dt * cfl_cushion / delt_adjust
write (*, *) ' '
end if
code_dt = cfl_dt * cfl_cushion / delt_adjust
call reset_dt
restart_time_step = .true.
else if (code_dt < min(cfl_dt * cfl_cushion / delt_adjust, code_dt_max)) then
if (proc0) then
write (*, *) ' '
write (*, *) 'CHANGING TIME STEP:'
write (*, '(A16, ES10.2E2)') " code_dt:"//REPEAT(' ', 50), code_dt
write (*, '(A16, ES10.2E2)') " cfl_dt:"//REPEAT(' ', 50), cfl_dt
write (*, '(A16, ES10.2E2)') " cfl_cushion:"//REPEAT(' ', 50), cfl_cushion
write (*, '(A16, ES10.2E2)') " delt_adjust:"//REPEAT(' ', 50), delt_adjust
write (*, '(A65)') ' ==> The code_dt is smaller than cfl_dt*cfl_cushion.'//REPEAT(' ', 50)
write (*, '(A61,ES12.4)') ' ==> Increasing code_dt to cfl_dt*cfl_cushion/delt_adjust ='//REPEAT(' ', 50), cfl_dt * cfl_cushion / delt_adjust
write (*, *) ' '
end if
code_dt = min(cfl_dt * cfl_cushion / delt_adjust, code_dt_max)
call reset_dt
! FLAG -- NOT SURE THIS IS CORRECT
gout = code_dt * gout
else
gout = code_dt * gout
end if
if (proc0) call time_message(.false., time_gke(:, 7), ' ExB nonlinear advance')
contains
subroutine forward_transform(gk, gx)
use stella_transforms, only: transform_ky2y, transform_kx2x
use stella_transforms, only: transform_ky2y_xfirst, transform_kx2x_xfirst
implicit none
complex, dimension(:, :), intent(in) :: gk
real, dimension(:, :), intent(out) :: gx
if (yfirst) then
! we have i*ky*g(kx,ky) for ky >= 0 and all kx
! want to do 1D complex to complex transform in y
! which requires i*ky*g(kx,ky) for all ky and kx >= 0
! use g(kx,-ky) = conjg(g(-kx,ky))
! so i*(-ky)*g(kx,-ky) = -i*ky*conjg(g(-kx,ky)) = conjg(i*ky*g(-kx,ky))
! and i*kx*g(kx,-ky) = i*kx*conjg(g(-kx,ky)) = conjg(i*(-kx)*g(-kx,ky))
! and i*(-ky)*J0(kx,-ky)*phi(kx,-ky) = conjg(i*ky*J0(-kx,ky)*phi(-kx,ky))
! and i*kx*J0(kx,-ky)*phi(kx,-ky) = conjg(i*(-kx)*J0(-kx,ky)*phi(-kx,ky))
! i.e., can calculate dg/dx, dg/dy, d<phi>/dx and d<phi>/dy
! on stella (kx,ky) grid, then conjugate and flip sign of (kx,ky)
! NB: J0(kx,ky) = J0(-kx,-ky)
! TODO DSO: coordinate change for shearing
call swap_kxky(gk, g0k_swap)
call transform_ky2y(g0k_swap, g0kxy)
call transform_kx2x(g0kxy, gx)
else
call transform_kx2x_xfirst(gk, g0xky)
g0xky = g0xky * prefac
call transform_ky2y_xfirst(g0xky, gx)
end if
end subroutine forward_transform
end subroutine advance_ExB_nonlinearity
subroutine advance_parallel_nonlinearity(g, gout, restart_time_step)
use constants, only: zi
use mp, only: proc0, min_allreduce, mp_abort
use mp, only: scope, allprocs, subprocs
use stella_layouts, only: vmu_lo, xyz_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use job_manage, only: time_message
use finite_differences, only: second_order_centered_zed
use finite_differences, only: third_order_upwind
use redistribute, only: gather, scatter
use fields_arrays, only: phi, phi_corr_QN, phi_corr_GA
use stella_transforms, only: transform_ky2y, transform_y2ky
use stella_transforms, only: transform_kx2x, transform_x2kx
use stella_time, only: cfl_dt, code_dt, code_dt_max
use run_parameters, only: cfl_cushion, delt_adjust
use zgrid, only: nzgrid, delzed, ntubes
use extended_zgrid, only: neigen, nsegments, ikxmod
use extended_zgrid, only: iz_low, iz_up
use extended_zgrid, only: periodic
use physics_flags, only: full_flux_surface, radial_variation
use kt_grids, only: akx, aky, nakx, naky, nx, ny, ikx_max
use kt_grids, only: swap_kxky, swap_kxky_back, rho_clamped
use vpamu_grids, only: nvpa, nmu
use vpamu_grids, only: dvpa, vpa, mu
use gyro_averages, only: gyro_average
use parallel_streaming, only: stream_sign
use dist_redistribute, only: xyz2vmu
use file_utils, only: runtype_option_switch, runtype_multibox
use extended_zgrid, only: fill_zed_ghost_zones
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
logical, intent(out) :: restart_time_step
integer :: ivmu, ixyz
integer :: iz, it, iv, imu, is
integer :: iky, ie, iseg
integer :: advect_sign
real, dimension(:), allocatable :: dgdv
real, dimension(:, :, :, :, :), allocatable :: g0xy
real, dimension(:, :, :), allocatable :: gxy_vmulocal
real, dimension(:, :), allocatable :: g1xy, advect_speed
complex, dimension(2) :: gleft, gright
complex, dimension(:, :, :, :), allocatable :: phi_gyro, dphidz
complex, dimension(:, :), allocatable :: g0k, g0kxy, g0k_swap
complex, dimension(:, :), allocatable :: tmp
! alpha-component of magnetic drift (requires ky -> y)
if (proc0) call time_message(.false., time_parallel_nl(:, 1), ' parallel nonlinearity advance')
restart_time_step = .false.
! overview:
! need g and d<phi>/dz in (x,y) space in
! order to upwind dg/dvpa
! 1) transform d<phi>/dz from (kx,ky) to (x,y). layout: vmu_lo
! 2) need sign of parnl advection in xyz_lo (since dg/dvpa
! requires vpa local), so d<phi>/dz(vmu_lo) --> d<phi>/dz(xyz_lo)
! 3) transform g from (kx,ky) to (x,y). layout: vmu_lo
! 4) dg/dvpa requires vpa local, so g(vmu_lo) --> g(xyz_lo)
! 5) calculate dg/dvpa
! 6) multiply dg/dvpa with d<phi>/dz
! 7) product(xyz_lo) --> product(vmu_lo)
! 8) inverse transform product(vmu_lo)
allocate (g0k(naky, nakx))
allocate (g0xy(ny, nx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
allocate (g0kxy(ny, ikx_max))
if (radial_variation) allocate (g1xy(ny, nx))
allocate (phi_gyro(naky, nakx, -nzgrid:nzgrid, ntubes))
allocate (dphidz(naky, nakx, -nzgrid:nzgrid, ntubes))
allocate (g0k_swap(2 * naky - 1, ikx_max))
allocate (tmp(size(gout, 1), size(gout, 2)))
! get d<phi>/dz in vmu_lo
! we will need to transform it to real-space
! as its sign is needed for upwinding of dg/dvpa
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
iv = iv_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
! construct <phi>
dphidz = phi
if (radial_variation) dphidz = dphidz + phi_corr_QN
call gyro_average(dphidz, ivmu, phi_gyro)
if (radial_variation) phi_gyro = phi_gyro + phi_corr_GA(:, :, :, :, ivmu)
do iky = 1, naky
do it = 1, ntubes
do ie = 1, neigen(iky)
do iseg = 1, nsegments(ie, iky)
! first fill in ghost zones at boundaries in g(z)
call fill_zed_ghost_zones(it, iseg, ie, iky, phi_gyro, gleft, gright)
! now get d<phi>/dz
call second_order_centered_zed(iz_low(iseg), iseg, nsegments(ie, iky), &
phi_gyro(iky, ikxmod(iseg, ie, iky), iz_low(iseg):iz_up(iseg), it), &
delzed(0), stream_sign(iv), gleft, gright, periodic(iky), &
dphidz(iky, ikxmod(iseg, ie, iky), iz_low(iseg):iz_up(iseg), it))
end do
end do
end do
end do
if (radial_variation) then
do it = 1, ntubes
do iz = -nzgrid, nzgrid
! use reality to swap from ky >= 0, all kx to kx >= 0 , all ky
call swap_kxky(dphidz(:, :, iz, it), g0k_swap)
! transform in y
call transform_ky2y(g0k_swap, g0kxy)
! transform in x
call transform_kx2x(g0kxy, g1xy)
g0xy(:, :, iz, it, ivmu) = g1xy * (par_nl_fac(iz, is) + d_par_nl_fac_dr(iz, is) * spread(rho_clamped, 1, ny))
g0k = zi * spread(aky, 2, nakx) * phi_gyro(:, :, iz, it)
call swap_kxky(g0k, g0k_swap)
call transform_ky2y(g0k_swap, g0kxy)
call transform_kx2x(g0kxy, g1xy)
g0xy(:, :, iz, it, ivmu) = g0xy(:, :, iz, it, ivmu) &
+ vpa(iv) * g1xy * (par_nl_drifty(iz) + d_par_nl_drifty_dr(iz) * spread(rho_clamped, 1, ny))
g0k = zi * spread(akx, 1, naky) * phi_gyro(:, :, iz, it)
call swap_kxky(g0k, g0k_swap)
call transform_ky2y(g0k_swap, g0kxy)
call transform_kx2x(g0kxy, g1xy)
g0xy(:, :, iz, it, ivmu) = g0xy(:, :, iz, it, ivmu) &
+ vpa(iv) * g1xy * (par_nl_driftx(iz) + d_par_nl_driftx_dr(iz) * spread(rho_clamped, 1, ny))
g0xy(:, :, iz, it, ivmu) = g0xy(:, :, iz, it, ivmu) &
+ vpa(iv) * mu(imu) * (par_nl_curv(iz, is) + d_par_nl_curv_dr(iz, is) * spread(rho_clamped, 1, ny))
end do
end do
else
do it = 1, ntubes
do iz = -nzgrid, nzgrid
g0k = dphidz(:, :, iz, it) * par_nl_fac(iz, is) + vpa(iv) * mu(imu) * par_nl_curv(iz, is) &
+ zi * vpa(iv) * phi_gyro(:, :, iz, it) * (spread(akx, 1, naky) * par_nl_driftx(iz) &
+ spread(aky, 2, nakx) * par_nl_drifty(iz))
! use reality to swap from ky >= 0, all kx to kx >= 0 , all ky
call swap_kxky(g0k, g0k_swap)
! transform in y
call transform_ky2y(g0k_swap, g0kxy)
! transform in x
call transform_kx2x(g0kxy, g0xy(:, :, iz, it, ivmu))
end do
end do
end if
end do
! do not need phi_gyro or dphidz again so deallocate
deallocate (phi_gyro, dphidz)
deallocate (g0k)
if (allocated(g1xy)) deallocate (g1xy)
allocate (gxy_vmulocal(nvpa, nmu, xyz_lo%llim_proc:xyz_lo%ulim_alloc))
allocate (advect_speed(nmu, xyz_lo%llim_proc:xyz_lo%ulim_alloc))
! we now have the advection velocity in vpa in (x,y) space
! next redistribute it so that (vpa,mu) are local
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
call scatter(xyz2vmu, g0xy, gxy_vmulocal)
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
! advect_speed does not depend on vpa
advect_speed = gxy_vmulocal(1, :, :)
! transform g from (kx,ky) to (x,y)
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
call swap_kxky(g(:, :, iz, it, ivmu), g0k_swap)
! transform in y
call transform_ky2y(g0k_swap, g0kxy)
! transform in x
call transform_kx2x(g0kxy, g0xy(:, :, iz, it, ivmu))
end do
end do
end do
! redistribute so that (vpa,mu) local
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
call scatter(xyz2vmu, g0xy, gxy_vmulocal)
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
allocate (dgdv(nvpa))
! we now need to form dg/dvpa and obtain product of dg/dvpa with advection speed
do ixyz = xyz_lo%llim_proc, xyz_lo%ulim_proc
do imu = 1, nmu
! advect_sign set to +/- 1 depending on sign of the parallel nonlinearity
! advection velocity
! NB: advect_sign = -1 corresponds to positive advection velocity
advect_sign = int(sign(1.0, advect_speed(imu, ixyz)))
call third_order_upwind(1, gxy_vmulocal(:, imu, ixyz), dvpa, advect_sign, dgdv)
gxy_vmulocal(:, imu, ixyz) = dgdv * advect_speed(imu, ixyz)
cfl_dt = min(cfl_dt, dvpa / abs(advect_speed(imu, ixyz)))
end do
end do
! finished with dgdv and advect_speed
deallocate (dgdv, advect_speed)
! now that we have the full parallel nonlinearity in (x,y)-space
! need to redistribute so that (x,y) local for transforms
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
call gather(xyz2vmu, gxy_vmulocal, g0xy)
if (proc0) call time_message(.false., time_parallel_nl(:, 2), ' parallel nonlinearity redist')
! finished with gxy_vmulocal
deallocate (gxy_vmulocal)
! g0xy is parallel nonlinearity term with (x,y) on processor
! need to inverse Fourier transform
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
call transform_x2kx(g0xy(:, :, iz, it, ivmu), g0kxy)
if (full_flux_surface) then
gout(:, :, iz, it, ivmu) = gout(:, :, iz, it, ivmu) + code_dt * g0kxy
else
call transform_y2ky(g0kxy, g0k_swap)
call swap_kxky_back(g0k_swap, tmp)
gout(:, :, iz, it, ivmu) = gout(:, :, iz, it, ivmu) + code_dt * tmp
end if
end do
end do
end do
deallocate (g0k_swap, g0kxy, g0xy)
if (runtype_option_switch == runtype_multibox) call scope(allprocs)
call min_allreduce(cfl_dt)
if (runtype_option_switch == runtype_multibox) call scope(subprocs)
if (code_dt > cfl_dt * cfl_cushion) then
if (proc0) then
write (*, *) ' '
write (*, *) 'CHANGING TIME STEP:'
write (*, '(A16, ES10.2E2)') " code_dt:"//REPEAT(' ', 50), code_dt
write (*, '(A16, ES10.2E2)') " cfl_dt:"//REPEAT(' ', 50), cfl_dt
write (*, '(A16, ES10.2E2)') " cfl_cushion:"//REPEAT(' ', 50), cfl_cushion
write (*, '(A16, ES10.2E2)') " delt_adjust:"//REPEAT(' ', 50), delt_adjust
write (*, '(A65)') ' ==> The code_dt is larger than cfl_dt*cfl_cushion.'//REPEAT(' ', 50)
write (*, '(A61,ES12.4)') ' ==> Decreasing code_dt to cfl_dt*cfl_cushion/delt_adjust ='//REPEAT(' ', 50), cfl_dt * cfl_cushion / delt_adjust
write (*, *) ' '
end if
code_dt = cfl_dt * cfl_cushion / delt_adjust
call reset_dt
restart_time_step = .true.
else if (code_dt < min(cfl_dt * cfl_cushion / delt_adjust, code_dt_max)) then
if (proc0) then
write (*, *) ' '
write (*, *) 'CHANGING TIME STEP:'
write (*, '(A16, ES10.2E2)') " code_dt:"//REPEAT(' ', 50), code_dt
write (*, '(A16, ES10.2E2)') " cfl_dt:"//REPEAT(' ', 50), cfl_dt
write (*, '(A16, ES10.2E2)') " cfl_cushion:"//REPEAT(' ', 50), cfl_cushion
write (*, '(A16, ES10.2E2)') " delt_adjust:"//REPEAT(' ', 50), delt_adjust
write (*, '(A65)') ' ==> The code_dt is smaller than cfl_dt*cfl_cushion.'//REPEAT(' ', 50)
write (*, '(A61,ES12.4)') ' ==> Increasing code_dt to cfl_dt*cfl_cushion/delt_adjust ='//REPEAT(' ', 50), cfl_dt * cfl_cushion / delt_adjust
write (*, *) ' '
end if
code_dt = min(cfl_dt * cfl_cushion / delt_adjust, code_dt_max)
call reset_dt
! else
! gout = code_dt*gout
end if
if (proc0) call time_message(.false., time_parallel_nl(:, 1), ' parallel nonlinearity advance')
end subroutine advance_parallel_nonlinearity
subroutine advance_radial_variation(g, gout)
use mp, only: mp_abort, proc0
use job_manage, only: time_message
use fields, only: get_dchidy
use fields_arrays, only: phi, apar
use fields_arrays, only: phi_corr_QN, phi_corr_GA
! use fields_arrays, only: apar_corr_QN, apar_corr_GA
use stella_layouts, only: vmu_lo
use stella_layouts, only: iv_idx, imu_idx, is_idx
use stella_transforms, only: transform_kx2x_xfirst, transform_x2kx_xfirst
use zgrid, only: nzgrid, ntubes
use kt_grids, only: nakx, naky, multiply_by_rho
use gyro_averages, only: gyro_average, gyro_average_j1
use run_parameters, only: fphi
use physics_flags, only: full_flux_surface
use physics_flags, only: include_parallel_streaming, include_mirror
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use dist_fn_arrays, only: wdriftpx_g, wdriftpy_g
use dist_fn_arrays, only: wdriftpx_phi, wdriftpy_phi !, adiabatic_phi
use dist_fn_arrays, only: wstar, wstarp
use mirror_terms, only: add_mirror_radial_variation
use flow_shear, only: prl_shear, prl_shear_p
use parallel_streaming, only: add_parallel_streaming_radial_variation
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: gout
integer :: ia, ivmu, iv, imu, is, iz, it
complex, dimension(:, :), allocatable :: g0k, g1k, g0a
complex, dimension(:, :, :, :, :), allocatable :: g_corr
allocate (g0k(naky, nakx))
allocate (g1k(naky, nakx))
allocate (g0a(naky, nakx))
if (debug) write (*, *) 'time_advance::solve_gke::advance_radial_variation'
if (proc0) call time_message(.false., time_gke(:, 10), ' radial variation advance')
if (include_mirror .or. include_parallel_streaming) then
allocate (g_corr(naky, nakx, -nzgrid:nzgrid, ntubes, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
g_corr = 0.
end if
!grab the mirror and parallel streaming corrections here to save on FFTs
if (include_mirror) then
call add_mirror_radial_variation(g, g_corr)
end if
if (include_parallel_streaming) then
call add_parallel_streaming_radial_variation(g, g_corr, gout)
end if
if (full_flux_surface) then
! FLAG -- ADD SOMETHING HERE
call mp_abort('wstarp term not yet setup for full_flux_surface = .true. aborting.')
end if
ia = 1
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
iv = iv_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
do it = 1, ntubes
do iz = -nzgrid, nzgrid
g0k = 0.
!wstar variation
call get_dchidy(iz, ivmu, phi(:, :, iz, it), apar(:, :, iz, it), g0a)
g0k = g0k + g0a * wstarp(ia, iz, ivmu)
!radial variation in ExB nonlinearity is handled in advance_ExB_nonlinearity
!wdrift(x/y) - g
call get_dgdx(g(:, :, iz, it, ivmu), g0a)
g0k = g0k + g0a * wdriftpx_g(ia, iz, ivmu)
call get_dgdy(g(:, :, iz, it, ivmu), g0a)
g0k = g0k + g0a * wdriftpy_g(ia, iz, ivmu)
!wdrift - phi
call get_dgdx(phi(:, :, iz, it), g1k)
!wdriftx variation
call gyro_average(g1k, iz, ivmu, g0a)
g0k = g0k + g0a * wdriftpx_phi(ia, iz, ivmu)
call get_dgdy(phi(:, :, iz, it), g1k)
!wdrifty variation
call gyro_average(g1k, iz, ivmu, g0a)
g0k = g0k + g0a * wdriftpy_phi(ia, iz, ivmu)
!prl_shear variation
g0k = g0k + g0a * prl_shear_p(ia, iz, ivmu)
!mirror term and/or parallel streaming
if (include_mirror .or. include_parallel_streaming) then
g0k = g0k + g_corr(:, :, iz, it, ivmu)
end if
!inverse and forward transforms
call multiply_by_rho(g0k)
!
!quasineutrality/gyroaveraging
!
call gyro_average(phi_corr_QN(:, :, iz, it), iz, ivmu, g0a)
g0a = fphi * (g0a + phi_corr_GA(:, :, iz, it, ivmu))
!wstar - gyroaverage/quasineutrality variation
call get_dgdy(g0a, g1k)
g0k = g0k + g1k * wstar(ia, iz, ivmu)
!wdrifty gyroaverage/quasineutrality variation
g0k = g0k + g1k * wdrifty_phi(ia, iz, ivmu)
!prl_shear gyroaverage/quasineutrality variation
g0k = g0k + g1k * prl_shear(ia, iz, ivmu)
!wdriftx gyroaverage/quasineutrality variation
call get_dgdx(g0a, g1k)
g0k = g0k + g1k * wdriftx_phi(ia, iz, ivmu)
! !wdriftx F_M/T_s variation
! call gyro_average (phi(:,:,iz,it),iz,ivmu,g0a)
! g0a = adiabatic_phi(ia,iz,ivmu)*g0a
! call multiply_by_rho(g0a)
! call get_dgdx(g0a,g1k)
! g0k = g0k + g1k*wdriftx_phi(ia,iz,ivmu)
gout(:, :, iz, it, ivmu) = gout(:, :, iz, it, ivmu) + g0k
end do
end do
end do
deallocate (g0k, g1k, g0a)
if (allocated(g_corr)) deallocate (g_corr)
if (proc0) call time_message(.false., time_gke(:, 10), ' radial variation advance')
end subroutine advance_radial_variation
!> compute dg/dy in k-space
!> accepts g(ky,kx)
subroutine get_dgdy_2d(g, dgdy)
use constants, only: zi
use kt_grids, only: nakx, aky
implicit none
complex, dimension(:, :), intent(in) :: g
complex, dimension(:, :), intent(out) :: dgdy
dgdy = zi * spread(aky, 2, nakx) * g
end subroutine get_dgdy_2d
!> compute dg/dy in k-space
!> accepts g(ky,kx,z,tube)
subroutine get_dgdy_3d(g, dgdy)
use constants, only: zi
use zgrid, only: nzgrid, ntubes
use kt_grids, only: nakx, aky
implicit none
complex, dimension(:, :, -nzgrid:, :), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :), intent(out) :: dgdy
integer :: it, iz, ikx
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, nakx
dgdy(:, ikx, iz, it) = zi * aky(:) * g(:, ikx, iz, it)
end do
end do
end do
end subroutine get_dgdy_3d
!> compute dg/dy in k-space
!> accepts g(ky,kx,z,tube,(vpa,mu,spec))
subroutine get_dgdy_4d(g, dgdy)
use constants, only: zi
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid, ntubes
use kt_grids, only: nakx, aky
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(out) :: dgdy
integer :: ivmu, ikx, iz, it
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, nakx
dgdy(:, ikx, iz, it, ivmu) = zi * aky(:) * g(:, ikx, iz, it, ivmu)
end do
end do
end do
end do
end subroutine get_dgdy_4d
!> compute dg/dx in k-space
!> accepts g(ky,kx)
subroutine get_dgdx_2d(g, dgdx)
use constants, only: zi
use kt_grids, only: naky, akx
implicit none
complex, dimension(:, :), intent(in) :: g
complex, dimension(:, :), intent(out) :: dgdx
dgdx = zi * spread(akx, 1, naky) * g
end subroutine get_dgdx_2d
!> compute dg/dx in k-space
!> accepts g(ky,kx,z,tube)
subroutine get_dgdx_3d(g, dgdx)
use constants, only: zi
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky, akx, nakx
implicit none
complex, dimension(:, :, -nzgrid:, :), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :), intent(out) :: dgdx
integer :: ikx, iz, it
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, nakx
dgdx(:, ikx, iz, it) = zi * akx(ikx) * g(:, ikx, iz, it)
end do
end do
end do
end subroutine get_dgdx_3d
!> compute dg/dx in k-space
!> accepts g(ky,kx,z,tube,(vpa,mu,spec))
subroutine get_dgdx_4d(g, dgdx)
use constants, only: zi
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky, akx, nakx
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(out) :: dgdx
integer :: ivmu, ikx, iz, it
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, nakx
dgdx(:, ikx, iz, it, ivmu) = zi * akx(ikx) * g(:, ikx, iz, it, ivmu)
end do
end do
end do
end do
end subroutine get_dgdx_4d
subroutine add_explicit_term(g, pre_factor, src)
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky, nakx
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
real, dimension(-nzgrid:, vmu_lo%llim_proc:), intent(in) :: pre_factor
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: src
integer :: ivmu
integer :: iky, ikx, iz, it
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, nakx
do iky = 1, naky
src(iky, ikx, iz, it, ivmu) = src(iky, ikx, iz, it, ivmu) + pre_factor(iz, ivmu) * g(iky, ikx, iz, it, ivmu)
end do
end do
end do
end do
end do
end subroutine add_explicit_term
!> add vM . grad y d<phi>/dy or vM . grad x d<phi>/dx (or equivalents with g) or omega_* * d<phi>/dy term to RHS of GK equation
subroutine add_explicit_term_ffs(g, pre_factor, src)
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid, ntubes
use kt_grids, only: ikx_max, nalpha
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: g
real, dimension(:, -nzgrid:, vmu_lo%llim_proc:), intent(in) :: pre_factor
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: src
integer :: ivmu
integer :: ia, ikx, iz, it
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ikx = 1, ikx_max
do ia = 1, nalpha
src(ia, ikx, iz, it, ivmu) = src(ia, ikx, iz, it, ivmu) + pre_factor(ia, iz, ivmu) * g(ia, ikx, iz, it, ivmu)
end do
end do
end do
end do
end do
end subroutine add_explicit_term_ffs
! subroutine add_wstar_term (g, src)
! use dist_fn_arrays, only: wstar
! use stella_layouts, only: vmu_lo
! use zgrid, only: nzgrid, ntubes
! use kt_grids, only: naky, nakx
! implicit none
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in) :: g
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in out) :: src
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in) :: g
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in out) :: src
! integer :: ivmu, it, iz, ikx
! do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
! do it = 1, ntubes
! do iz = -nzgrid, nzgrid
! do ikx = 1, nakx
! src(:,ikx,iz,it,ivmu) = src(:,ikx,iz,it,ivmu) + wstar(1,iz,ivmu)*g(:,ikx,iz,it,ivmu)
! enddo
! enddo
! enddo
! enddo
! end subroutine add_wstar_term
! subroutine add_wstar_term_ffs (g, src)
! use dist_fn_arrays, only: wstar
! use stella_layouts, only: vmu_lo
! use zgrid, only: nzgrid, ntubes
! use kt_grids, only: naky, ikx_max
! implicit none
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in) :: g
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in out) :: src
! integer :: ivmu, it, iz, ikx
! do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
! do it = 1, ntubes
! do iz = -nzgrid, nzgrid
! do ikx = 1, nakx
! src(:,ikx,iz,it,ivmu) = src(:,ikx,iz,it,ivmu) + wstar(:,iz,ivmu)*g(:,ikx,iz,it,ivmu)
! enddo
! enddo
! enddo
! enddo
! end subroutine add_wstar_term_ffs
subroutine advance_implicit(istep, phi, apar, g)
! subroutine advance_implicit (phi, apar, g)
use mp, only: proc0
use job_manage, only: time_message
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid
use dissipation, only: hyper_dissipation, advance_hyper_dissipation
use physics_flags, only: include_parallel_streaming
use physics_flags, only: radial_variation, full_flux_surface
use physics_flags, only: include_mirror, prp_shear_enabled
use run_parameters, only: stream_implicit, mirror_implicit, drifts_implicit
use parallel_streaming, only: advance_parallel_streaming_implicit
use fields, only: advance_fields, fields_updated
use mirror_terms, only: advance_mirror_implicit
use dissipation, only: collisions_implicit, include_collisions
use dissipation, only: advance_collisions_implicit
use run_parameters, only: driftkinetic_implicit
use flow_shear, only: advance_perp_flow_shear
use multibox, only: RK_step
implicit none
integer, intent(in) :: istep
complex, dimension(:, :, -nzgrid:, :), intent(in out) :: phi, apar
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
! complex, dimension (:,:,-nzgrid:,:,vmu_lo%llim_proc:), intent (in out), target :: g
! complex, dimension (:,:,:,:,:), pointer :: gk, gy
! complex, dimension (:,:,:,:,:), allocatable, target :: g_dual
! ! the 'g' that enters this subroutine may be in alpha-space or kalpha-space
! ! figure out which it is
! if (size(g,1) == naky) then
! alpha_space = .false.
! gk => g
! if (full_flux_surface) then
! allocate (g_dual(nalpha,nakx,-nzgrid:nzgrid,vmu_lo%llim_proc:vmu_lo%ulim_alloc))
! gy => g_dual
! end if
! else
! alpha_space = .true.
! allocate (g_dual(naky,nakx,-nzgrid:nzgrid,vmu_lo%llim_proc:vmu_lo%ulim_alloc))
! gy => g
! gk => g_dual
! end if
! start the timer for the implicit part of the solve
if (proc0) call time_message(.false., time_gke(:, 9), ' implicit')
! reverse the order of operations every time step
! as part of alternating direction operator splitting
! this is needed to ensure 2nd order accuracy in time
! if (mod(istep,2)==0) then
! g^{*} (coming from explicit solve) is input
! get g^{**}, with g^{**}-g^{*} due to mirror term
if (RK_step) call mb_communicate(g)
if (mod(istep, 2) == 1 .or. .not. flip_flop) then
if (prp_shear_enabled) then
call advance_perp_flow_shear(g)
fields_updated = .false.
end if
if (hyper_dissipation) then
! ! for hyper-dissipation, need to be in k-alpha space
! if (alpha_space) call transform_y2ky (gy, gk)
call advance_hyper_dissipation(g)
fields_updated = .false.
end if
if (collisions_implicit .and. include_collisions) then
call advance_fields(g, phi, apar, dist='gbar')
call advance_collisions_implicit(mirror_implicit, phi, apar, g)
fields_updated = .false.
end if
if (mirror_implicit .and. include_mirror) then
! if (full_flux_surface) then
! allocate (gy(ny,nakx,-nzgrid:nzgrid,ntubes,vmu_lo%llim_proc:vmu_lo%ulim_alloc))
! if (.not.alpha_space) call transform_ky2y (g, gy)
! else
! g_mirror => g
! end if
call advance_mirror_implicit(collisions_implicit, g)
fields_updated = .false.
end if
! get updated fields corresponding to advanced g
! note that hyper-dissipation and mirror advances
! depended only on g and so did not need field update
call advance_fields(g, phi, apar, dist='gbar')
! g^{**} is input
! get g^{***}, with g^{***}-g^{**} due to parallel streaming term
if ((stream_implicit .or. driftkinetic_implicit) .and. include_parallel_streaming) then
call advance_parallel_streaming_implicit(g, phi, apar)
if (radial_variation .or. full_flux_surface) fields_updated = .false.
end if
call advance_fields(g, phi, apar, dist='gbar')
if (drifts_implicit) call advance_drifts_implicit(g, phi, apar)
else
! get updated fields corresponding to advanced g
! note that hyper-dissipation and mirror advances
! depended only on g and so did not need field update
call advance_fields(g, phi, apar, dist='gbar')
if (drifts_implicit) call advance_drifts_implicit(g, phi, apar)
! g^{**} is input
! get g^{***}, with g^{***}-g^{**} due to parallel streaming term
if ((stream_implicit .or. driftkinetic_implicit) .and. include_parallel_streaming) then
call advance_parallel_streaming_implicit(g, phi, apar)
if (radial_variation .or. full_flux_surface) fields_updated = .false.
end if
if (mirror_implicit .and. include_mirror) then
call advance_mirror_implicit(collisions_implicit, g)
fields_updated = .false.
end if
if (collisions_implicit .and. include_collisions) then
call advance_fields(g, phi, apar, dist='gbar')
call advance_collisions_implicit(mirror_implicit, phi, apar, g)
fields_updated = .false.
end if
if (hyper_dissipation) then
call advance_hyper_dissipation(g)
fields_updated = .false.
end if
if (prp_shear_enabled) then
call advance_perp_flow_shear(g)
fields_updated = .false.
end if
end if
! stop the timer for the implict part of the solve
if (proc0) call time_message(.false., time_gke(:, 9), ' implicit')
end subroutine advance_implicit
subroutine advance_drifts_implicit(g, phi, apar)
use constants, only: zi
use stella_layouts, only: vmu_lo
use stella_geometry, only: dl_over_b
use run_parameters, only: fphi, fapar, time_upwind
use dist_fn_arrays, only: g1
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use dist_fn_arrays, only: wdriftx_g, wdrifty_g
use dist_fn_arrays, only: wstar
use physics_flags, only: adiabatic_option_switch
use physics_flags, only: adiabatic_option_fieldlineavg
use gyro_averages, only: aj0x, gyro_average
use kt_grids, only: akx, aky, nakx, naky, zonal_mode
use zgrid, only: nzgrid, ntubes
use species, only: spec, has_electron_species
use fields, only: advance_fields
use vpamu_grids, only: integrate_species
implicit none
integer :: ivmu, iz, it, ia, ikx
complex :: tmp
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g
complex, dimension(:, :, -nzgrid:, :), intent(in out) :: phi, apar
complex, dimension(:, :), allocatable :: wd_g, wd_phi, wstr
complex, dimension(:, :, :), allocatable :: gyro_g
ia = 1
allocate (wd_g(naky, nakx))
allocate (wd_phi(naky, nakx))
allocate (wstr(naky, nakx))
! given g^{*}, obtain phi^{*} and apar^{*}
call advance_fields(g, phi, apar, dist='gbar')
! solve for g^inh
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
wd_g = -zi * (spread(akx, 1, naky) * wdriftx_g(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_g(ia, iz, ivmu))
wd_phi = -zi * (spread(akx, 1, naky) * wdriftx_phi(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_phi(ia, iz, ivmu))
wstr = -zi * spread(aky, 2, nakx) * wstar(ia, iz, ivmu)
g1(:, :, iz, it, ivmu) = (g(:, :, iz, it, ivmu) * (1.0 - 0.5 * (1.0 - time_upwind) * wd_g) &
- 0.5 * (1.0 - time_upwind) * (wd_phi + wstr) &
* aj0x(:, :, iz, ivmu) * fphi * phi(:, :, iz, ia)) &
/ (1.0 + 0.5 * (1.0 + time_upwind) * wd_g)
end do
end do
end do
!we have g_inh, now get phi
if (fphi > epsilon(0.0)) then
allocate (gyro_g(naky, nakx, vmu_lo%llim_proc:vmu_lo%ulim_alloc))
do it = 1, ntubes
do iz = -nzgrid, nzgrid
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
call gyro_average(g1(:, :, iz, it, ivmu), iz, ivmu, gyro_g(:, :, ivmu))
end do
call integrate_species(gyro_g, iz, spec%z * spec%dens_psi0, phi(:, :, iz, it))
end do
phi(:, :, :, it) = phi(:, :, :, it) / gamtot_drifts
if (any(real(gamtot_drifts(1, 1, :)) < epsilon(0.))) phi(1, 1, :, it) = 0.0
if (.not. has_electron_species(spec)) then
! no need to do anything extra for ky /= 0 because
! already accounted for in gamtot_h
if (adiabatic_option_switch == adiabatic_option_fieldlineavg) then
if (zonal_mode(1)) then
do ikx = 1, nakx
tmp = sum(dl_over_b(ia, :) * phi(1, ikx, :, it))
phi(1, ikx, :, it) = phi(1, ikx, :, it) + tmp * gamtot3_drifts(ikx, :)
end do
end if
end if
end if
end do
deallocate (gyro_g)
end if
!finally, get g
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
do it = 1, ntubes
do iz = -nzgrid, nzgrid
!these terms already contain a factor of code_dt and a
! negative sign
wd_g = -zi * (spread(akx, 1, naky) * wdriftx_g(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_g(ia, iz, ivmu))
wd_phi = -zi * (spread(akx, 1, naky) * wdriftx_phi(ia, iz, ivmu) &
+ spread(aky, 2, nakx) * wdrifty_phi(ia, iz, ivmu))
wstr = -zi * spread(aky, 2, nakx) * wstar(ia, iz, ivmu)
g(:, :, iz, it, ivmu) = g1(:, :, iz, it, ivmu) &
- 0.5 * (1.0 + time_upwind) * (wd_phi + wstr) &
* aj0x(:, :, iz, ivmu) * fphi * phi(:, :, iz, it) &
/ (1.0 + 0.5 * (1.0 + time_upwind) * wd_g)
end do
end do
end do
deallocate (wd_g, wd_phi, wstr)
end subroutine advance_drifts_implicit
subroutine mb_communicate(g_in)
use mp, only: job
use stella_layouts, only: vmu_lo
use zgrid, only: nzgrid
use multibox, only: multibox_communicate, use_dirichlet_bc, apply_radial_boundary_conditions
use fields, only: fields_updated, advance_fields
use fields_arrays, only: phi, apar
use file_utils, only: runtype_option_switch, runtype_multibox
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in out) :: g_in
if (runtype_option_switch == runtype_multibox) then
if (job /= 1) then
call advance_fields(g_in, phi, apar, dist='gbar')
end if
call multibox_communicate(g_in)
if (job == 1) then
fields_updated = .false.
call advance_fields(g_in, phi, apar, dist='gbar')
end if
else if (use_dirichlet_BC) then
call apply_radial_boundary_conditions(g_in)
fields_updated = .false.
call advance_fields(g_in, phi, apar, dist='gbar')
end if
end subroutine mb_communicate
subroutine checksum_field(field, total)
use zgrid, only: nzgrid, ntubes
use kt_grids, only: naky
use extended_zgrid, only: neigen, nsegments, ikxmod
use extended_zgrid, only: iz_low, iz_up
implicit none
complex, dimension(:, :, -nzgrid:, :), intent(in) :: field
real, intent(out) :: total
integer :: it, iky, ie, iseg
integer :: ikx
total = 0.
do iky = 1, naky
do it = 1, ntubes
do ie = 1, neigen(iky)
iseg = 1
ikx = ikxmod(iseg, ie, iky)
total = total + sum(cabs(field(iky, ikx, iz_low(iseg):iz_up(iseg), it)))
if (nsegments(ie, iky) > 1) then
do iseg = 2, nsegments(ie, iky)
ikx = ikxmod(iseg, ie, iky)
total = total + sum(cabs(field(iky, ikx, iz_low(iseg) + 1:iz_up(iseg), it)))
end do
end if
end do
end do
end do
end subroutine checksum_field
subroutine checksum_dist(dist, total, norm)
use mp, only: sum_allreduce
use zgrid, only: nzgrid, ntubes
use stella_layouts, only: vmu_lo, iv_idx, imu_idx, is_idx
use kt_grids, only: naky, nakx
use vpamu_grids, only: maxwell_vpa, maxwell_mu
implicit none
complex, dimension(:, :, -nzgrid:, :, vmu_lo%llim_proc:), intent(in) :: dist
real, intent(out) :: total
logical, intent(in), optional :: norm
integer :: ivmu, iv, imu, is
integer :: iky, ikx, it
real :: subtotal
complex, dimension(:, :, :, :), allocatable :: dist_single
total = 0.
allocate (dist_single(naky, nakx, -nzgrid:nzgrid, ntubes))
do ivmu = vmu_lo%llim_proc, vmu_lo%ulim_proc
dist_single = dist(:, :, :, :, ivmu)
if (present(norm)) then
if (norm) then
iv = iv_idx(vmu_lo, ivmu)
imu = imu_idx(vmu_lo, ivmu)
is = is_idx(vmu_lo, ivmu)
do it = 1, ntubes
do ikx = 1, nakx
do iky = 1, naky
dist_single(iky, ikx, :, it) = dist_single(iky, ikx, :, it) * maxwell_vpa(iv, is) * maxwell_mu(1, :, imu, is)
end do
end do
end do
else
end if
end if
call checksum(dist_single, subtotal)
total = total + subtotal
end do
deallocate (dist_single)
call sum_allreduce(total)
end subroutine checksum_dist
subroutine finish_time_advance
use stella_transforms, only: finish_transforms
use physics_flags, only: full_flux_surface
use extended_zgrid, only: finish_extended_zgrid
use parallel_streaming, only: finish_parallel_streaming
use mirror_terms, only: finish_mirror
use flow_shear, only: finish_flow_shear
use neoclassical_terms, only: finish_neoclassical_terms
use dissipation, only: finish_dissipation
implicit none
if (full_flux_surface) call finish_transforms
call finish_dissipation
call finish_parallel_nonlinearity
call finish_wstar
call finish_wdrift
call finish_drifts_implicit
call finish_parallel_streaming
call finish_flow_shear
call finish_mirror
call finish_neoclassical_terms
call deallocate_arrays
time_advance_initialized = .false.
readinit = .false.
end subroutine finish_time_advance
subroutine finish_parallel_nonlinearity
implicit none
if (allocated(par_nl_fac)) deallocate (par_nl_fac)
if (allocated(par_nl_curv)) deallocate (par_nl_curv)
if (allocated(par_nl_driftx)) deallocate (par_nl_driftx)
if (allocated(par_nl_drifty)) deallocate (par_nl_drifty)
parnlinit = .false.
end subroutine finish_parallel_nonlinearity
subroutine finish_wdrift
use dist_fn_arrays, only: wdriftx_g, wdrifty_g
use dist_fn_arrays, only: wdriftx_phi, wdrifty_phi
use dist_fn_arrays, only: wdriftpx_g, wdriftpy_g
use dist_fn_arrays, only: wdriftpx_phi, wdriftpy_phi
! use dist_fn_arrays, only: adiabatic_phi
implicit none
if (allocated(wdriftx_g)) deallocate (wdriftx_g)
if (allocated(wdrifty_g)) deallocate (wdrifty_g)
if (allocated(wdriftx_phi)) deallocate (wdriftx_phi)
if (allocated(wdrifty_phi)) deallocate (wdrifty_phi)
if (allocated(wdriftpx_g)) deallocate (wdriftpx_g)
if (allocated(wdriftpy_g)) deallocate (wdriftpy_g)
if (allocated(wdriftpx_phi)) deallocate (wdriftpx_phi)
if (allocated(wdriftpy_phi)) deallocate (wdriftpy_phi)
! if (allocated(adiabatic_phi)) deallocate (adiabatic_phi)
wdriftinit = .false.
end subroutine finish_wdrift
subroutine finish_wstar
use dist_fn_arrays, only: wstar, wstarp
implicit none
if (allocated(wstar)) deallocate (wstar)
if (allocated(wstarp)) deallocate (wstarp)
wstarinit = .false.
end subroutine finish_wstar
subroutine finish_drifts_implicit
implicit none
if (allocated(gamtot_drifts)) deallocate (gamtot_drifts)
if (allocated(gamtot3_drifts)) deallocate (gamtot3_drifts)
driftimpinit = .false.
end subroutine finish_drifts_implicit
subroutine deallocate_arrays
use dist_fn_arrays, only: g0, g1, g2, g3
implicit none
if (allocated(g0)) deallocate (g0)
if (allocated(g1)) deallocate (g1)
if (allocated(g2)) deallocate (g2)
if (allocated(g3)) deallocate (g3)
end subroutine deallocate_arrays
end module time_advance
|
{"hexsha": "8b68d9a08cb1c8e2a347dac9a721ab7b87bac6f3", "size": 124243, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "time_advance.f90", "max_stars_repo_name": "HanneThienpondt/stella-1", "max_stars_repo_head_hexsha": "38282d09b39c1cbd1833c1ab57d602a4015ad5df", "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": "time_advance.f90", "max_issues_repo_name": "HanneThienpondt/stella-1", "max_issues_repo_head_hexsha": "38282d09b39c1cbd1833c1ab57d602a4015ad5df", "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": "time_advance.f90", "max_forks_repo_name": "HanneThienpondt/stella-1", "max_forks_repo_head_hexsha": "38282d09b39c1cbd1833c1ab57d602a4015ad5df", "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.9232542819, "max_line_length": 152, "alphanum_fraction": 0.6027784261, "num_tokens": 37258}
|
from IAlgorithm import IAlgorithm
import numpy as np
__author__ = 'simon'
class Pad(IAlgorithm):
''' Pads the input array using numpy.pad '''
def __init__(self, target_width = None, target_height = None):
self.target_width = target_width
self.target_height = target_height
def _compute(self, blob_generator):
for blob in blob_generator:
if self.target_height:
offset_height = int((self.target_height - blob.data.shape[0]) / 2)
assert offset_height >= 0, 'Input image larger than target height'
target_height = self.target_height
else:
offset_height = 0
target_height = blob.data.shape[0]
if self.target_width:
offset_width = int((self.target_width - blob.data.shape[1]) / 2)
assert offset_width >= 0, 'Input image larger than target width'
target_width = self.target_width
else:
offset_width = 0
target_width = blob.data.shape[1]
embed = np.zeros((target_height,target_width) + blob.data.shape[2:],blob.data.dtype)
embed[offset_height : offset_height + blob.data.shape[0],
offset_width : offset_width + blob.data.shape[1],...] = blob.data
blob.data = embed
yield blob
|
{"hexsha": "7b2696c2217a1cd657cbd8b8e382a91f099f7364", "size": 1406, "ext": "py", "lang": "Python", "max_stars_repo_path": "Pad.py", "max_stars_repo_name": "cvjena/classification_framework_py", "max_stars_repo_head_hexsha": "4d7ef08cad118c8e871b1053e747cc3ad454c009", "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": "Pad.py", "max_issues_repo_name": "cvjena/classification_framework_py", "max_issues_repo_head_hexsha": "4d7ef08cad118c8e871b1053e747cc3ad454c009", "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": "Pad.py", "max_forks_repo_name": "cvjena/classification_framework_py", "max_forks_repo_head_hexsha": "4d7ef08cad118c8e871b1053e747cc3ad454c009", "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": 41.3529411765, "max_line_length": 96, "alphanum_fraction": 0.5846372688, "include": true, "reason": "import numpy", "num_tokens": 289}
|
from __future__ import division
import os
import random
import geopandas
import networkx as nx
import pandas as pd
import shapely
from cea.technologies.network_layout.substations_location import \
calc_substation_location as substation_location
__author__ = "Sebastian Troitzsch"
__copyright__ = "Copyright 2019, Architecture and Building Systems - ETH Zurich"
__credits__ = ["Sebastian Troitzsch", "Sreepathi Bhargava Krishna", "Jimeno A. Fonseca"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Daren Thomas"
__email__ = "thomas@arch.ethz.ch"
__status__ = "Production"
def calc_substation_location(locator):
# pint to function of cea doing this.
input_buildings_shp = locator.get_zone_geometry()
output_substations_shp = locator.get_network_layout_nodes_shapefile("EL", "")
points, poly = substation_location(input_buildings_shp, output_substations_shp, connected_buildings=[])
return (points, poly)
def connect_building_to_grid(locator):
# Import/ export paths
input_substations_shp = locator.get_network_layout_nodes_shapefile("EL", "")
input_streets_shp = locator.get_street_network()
# Import data
building_points = geopandas.GeoDataFrame.from_file(input_substations_shp)
lines = geopandas.GeoDataFrame.from_file(input_streets_shp)
# Create DF for points on line
points_on_line = building_points.copy()
points_on_line.drop(['floors_bg', 'height_bg', 'floors_ag', 'height_ag', ], axis=1, inplace=True)
# points_on_line['Node Type'] = None
for idx, point in points_on_line.iterrows():
points_on_line.loc[idx, 'Building'] = point['Name']
# points_on_line.loc[idx, 'Name'] = point['Name'] + ' Coupling Point'
# Prepare DF for nearest point on line
building_points['min_dist_to_lines'] = 0
building_points['nearest_line'] = None
for idx, point in building_points.iterrows():
distances = lines.distance(point.geometry)
nearest_line_idx = distances.idxmin()
building_points.loc[idx, 'nearest_line'] = nearest_line_idx
building_points.loc[idx, 'min_dist_to_lines'] = lines.distance(point.geometry).min()
# find point on nearest line
project_distances = lines.project(point.geometry)
project_distance_nearest_line = lines.interpolate(project_distances[nearest_line_idx])
points_on_line.loc[idx, 'geometry'] = project_distance_nearest_line[nearest_line_idx]
# Determine Intersections of lines
for idx, line in lines.iterrows():
line.geometry = line.geometry.buffer(0.0001)
line_intersections = lines.intersection(line.geometry)
for index, intersection in line_intersections.iteritems():
if intersection.geom_type == 'LineString' and index != idx:
centroid_buffered = line_intersections[index].centroid.buffer(0.1) # middle of Linestrings
if not points_on_line.intersects(centroid_buffered).any():
index_points_on_line = points_on_line.shape[0] # current number of rows in points_on_line
points_on_line.loc[index_points_on_line, 'geometry'] = line_intersections[index].centroid
points_on_line.loc[index_points_on_line, 'Building'] = None
# Name Points
for idx, point in points_on_line.iterrows():
points_on_line.loc[idx, 'Name'] = 'Node' + str(idx)
points_on_line.loc[idx, 'Node_int'] = int(idx)
# Split Linestrings at points_on_line
tranches_list = []
for idx, line in lines.iterrows():
line_buffered = line.copy()
line_buffered.geometry = line.geometry.buffer(0.0001)
line_point_intersections = points_on_line.intersection(line_buffered.geometry)
filtered_points = line_point_intersections[line_point_intersections.is_empty == False]
start_point = shapely.geometry.Point(line.values[1].xy[0][0], line.values[1].xy[1][0])
distance = filtered_points.distance(start_point)
filtered_points = geopandas.GeoDataFrame(data=filtered_points)
filtered_points['distance'] = distance
filtered_points.sort_values(by='distance', inplace=True)
# Create new Lines
for idx1 in range(0, len(filtered_points) - 1):
start = filtered_points.iloc[idx1][0]
end = filtered_points.iloc[idx1 + 1][0]
newline = shapely.geometry.LineString([start, end])
tranches_list.append(newline)
tranches = geopandas.GeoDataFrame(data=tranches_list)
tranches.columns = ['geometry']
tranches['Name'] = None
tranches['Startnode'] = None
tranches['Endnode'] = None
tranches['Startnode_int'] = None
tranches['Endnode_int'] = None
tranches['Length'] = 0
for idx, tranch in tranches.iterrows():
tranches.loc[idx, 'Name'] = 'tranch' + str(idx)
tranches.loc[idx, 'Length'] = tranch.values[0].length
startnode = tranch.values[0].boundary[0]
endnode = tranch.values[0].boundary[1]
start_intersection = points_on_line.intersection(startnode.buffer(0.1))
end_intersection = points_on_line.intersection(endnode.buffer(0.1))
start_intersection_filtered = start_intersection[start_intersection.is_empty == False]
end_intersection_filtered = end_intersection[end_intersection.is_empty == False]
startnode_index = start_intersection_filtered.index.values[0]
endnode_index = end_intersection_filtered.index.values[0]
tranches.loc[idx, 'Startnode'] = 'Node' + str(start_intersection_filtered.index.values[0])
tranches.loc[idx, 'Endnode'] = 'Node' + str(endnode_index)
tranches.loc[idx, 'Startnode_int'] = int(start_intersection_filtered.index.values[0])
tranches.loc[idx, 'Endnode_int'] = int(endnode_index)
# UTM to LAT, LON
# building_nodes = building_nodes.to_crs("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
# streets = streets.to_crs("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
return (
points_on_line,
tranches
)
def process_network(locator,
points_on_line,
):
building_path = locator.get_total_demand()
building_prop = pd.read_csv(building_path)
# building_prop = building_prop[['Name', 'GRID0_kW']]
building_prop.rename(columns={'Name': 'Building'}, inplace=True)
points_on_line = pd.merge(points_on_line, building_prop, on='Building', how='outer')
# Declare random plant and nodes
points_on_line['Type'] = None
random.seed(1000)
for idx, node in points_on_line.iterrows():
if node['Building'] is not None:
# if random.random() < 0.08:
if idx == 0:
points_on_line.loc[idx, 'Type'] = 'PLANT'
else:
points_on_line.loc[idx, 'Type'] = 'CONSUMER'
return points_on_line
def get_hourly_power_demand_per_building(locator, points_on_line):
hourly_power_demand_per_building = {}
for idx_node, node in points_on_line.iterrows():
if node['Building'] != None:
building_name = node['Building']
hourly_power_demand_per_building[building_name] = pd.read_csv(locator.get_demand_results_file(building_name)
)
return hourly_power_demand_per_building
def create_length_dict(points_on_line, tranches):
G_complete = nx.Graph()
for idx, node in points_on_line.iterrows():
node_type = node['Type']
G_complete.add_node(idx, type=node_type)
for idx, tranch in tranches.iterrows():
start_node_index = tranch['Startnode'][4::]
end_node_index = tranch['Endnode'][4::]
tranch_length = tranch['Length']
G_complete.add_edge(int(start_node_index), int(end_node_index),
weight=tranch_length,
gene=idx,
startnode=start_node_index,
endnode=end_node_index)
idx_nodes_sub = points_on_line[points_on_line['Type'] == 'PLANT'].index
idx_nodes_consum = points_on_line[points_on_line['Type'] == 'CONSUMER'].index
idx_nodes = idx_nodes_sub.append(idx_nodes_consum)
dict_length = {}
dict_path = {}
for idx_node1 in idx_nodes:
dict_length[idx_node1] = {}
dict_path[idx_node1] = {}
for idx_node2 in idx_nodes:
if idx_node1 == idx_node2:
dict_length[idx_node1][idx_node2] = 0.0
else:
nx.shortest_path(G_complete, 0, 1)
dict_path[idx_node1][idx_node2] = nx.shortest_path(G_complete,
source=idx_node1,
target=idx_node2,
weight='weight')
dict_length[idx_node1][idx_node2] = nx.shortest_path_length(G_complete,
source=idx_node1,
target=idx_node2,
weight='weight')
return (
dict_length,
dict_path
)
|
{"hexsha": "e685bd57e86874815fb1d428620997aa9b6965d8", "size": 9267, "ext": "py", "lang": "Python", "max_stars_repo_path": "legacy/flexibility_model/mpc_district/planning_and_operation_preprocess_network.py", "max_stars_repo_name": "AlexJew/CityEnergyAnalyst", "max_stars_repo_head_hexsha": "6eb372c79e5100a2d0abce78561ae368fb409cd1", "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": "legacy/flexibility_model/mpc_district/planning_and_operation_preprocess_network.py", "max_issues_repo_name": "AlexJew/CityEnergyAnalyst", "max_issues_repo_head_hexsha": "6eb372c79e5100a2d0abce78561ae368fb409cd1", "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": "legacy/flexibility_model/mpc_district/planning_and_operation_preprocess_network.py", "max_forks_repo_name": "AlexJew/CityEnergyAnalyst", "max_forks_repo_head_hexsha": "6eb372c79e5100a2d0abce78561ae368fb409cd1", "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.6447368421, "max_line_length": 120, "alphanum_fraction": 0.6520988454, "include": true, "reason": "import networkx", "num_tokens": 2100}
|
[STATEMENT]
lemma exists_a_w:
assumes "symmetric g"
and "forest f"
and "f \<le> --g"
and "regular f"
and "(\<exists>w . minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T)"
and "vector j"
and "regular j"
and "forest h"
and "forest_modulo_equivalence (forest_components h) d"
and "d * top \<le> - j"
and "forest_components h * j = j"
and "f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T"
and "(\<forall> a b . forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> -(forest_components h) \<sqinter> -- g \<and> b \<le> d \<longrightarrow> sum(b \<sqinter> g) \<le> sum(a \<sqinter> g))"
and "regular d"
and "selected_edge h j g \<le> - forest_components f"
and "selected_edge h j g \<noteq> bot"
and "j \<noteq> bot"
and "regular h"
and "h \<le> --g"
shows "\<exists>w. minimum_spanning_forest w g \<and>
f \<sqinter> - (selected_edge h j g)\<^sup>T \<sqinter> - (path f h j g) \<squnion> (f \<sqinter> - (selected_edge h j g)\<^sup>T \<sqinter> (path f h j g))\<^sup>T \<squnion> (selected_edge h j g) \<le> w \<squnion> w\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?p = "path f h j g"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?e = "selected_edge h j g"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?f = "(f \<sqinter> -?e\<^sup>T \<sqinter> -?p) \<squnion> (f \<sqinter> -?e\<^sup>T \<sqinter> ?p)\<^sup>T \<squnion> ?e"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?F = "forest_components f"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?H = "forest_components h"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?ec = "choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
from assms(4)
[PROOF STATE]
proof (chain)
picking this:
regular f
[PROOF STEP]
obtain w where 2: "minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T"
[PROOF STATE]
proof (prove)
using this:
regular f
goal (1 subgoal):
1. (\<And>w. minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms(5)
[PROOF STATE]
proof (prove)
using this:
regular f
\<exists>w. minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. (\<And>w. minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
hence 3: "regular w \<and> regular f \<and> regular ?e"
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. regular w \<and> regular f \<and> regular (selected_edge h j g)
[PROOF STEP]
by (metis assms(4) minarc_regular minimum_spanning_forest_def spanning_forest_def)
[PROOF STATE]
proof (state)
this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 5: "equivalence ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. equivalence (forest_components f)
[PROOF STEP]
using assms(2) forest_components_equivalence
[PROOF STATE]
proof (prove)
using this:
forest f
injective ?x \<Longrightarrow> equivalence (forest_components ?x)
goal (1 subgoal):
1. equivalence (forest_components f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
equivalence (forest_components f)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have "?e\<^sup>T * top * ?e\<^sup>T = ?e\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
[PROOF STEP]
by (metis arc_conv_closed arc_top_arc coreflexive_bot_closed coreflexive_symmetric minarc_arc minarc_bot_iff semiring.mult_not_zero)
[PROOF STATE]
proof (state)
this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
hence "?e\<^sup>T * top * ?e\<^sup>T \<le> -?F"
[PROOF STATE]
proof (prove)
using this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
goal (1 subgoal):
1. (selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T \<le> - forest_components f
[PROOF STEP]
using 5 assms(15) conv_complement conv_isotone
[PROOF STATE]
proof (prove)
using this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
equivalence (forest_components f)
selected_edge h j g \<le> - forest_components f
(- ?x)\<^sup>T = - ?x\<^sup>T
?x \<le> ?y \<Longrightarrow> ?x\<^sup>T \<le> ?y\<^sup>T
goal (1 subgoal):
1. (selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T \<le> - forest_components f
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T \<le> - forest_components f
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
hence 6: "?e * ?F * ?e = bot"
[PROOF STATE]
proof (prove)
using this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T \<le> - forest_components f
goal (1 subgoal):
1. selected_edge h j g * forest_components f * selected_edge h j g = bot
[PROOF STEP]
using assms(2) le_bot triple_schroeder_p
[PROOF STATE]
proof (prove)
using this:
(selected_edge h j g[[top]]) * selected_edge h j g\<^sup>T \<le> - forest_components f
forest f
?a \<le> bot \<Longrightarrow> ?a = bot
(?x * ?y * ?z \<le> - ?w) = ((?x[[?w]]) * ?z\<^sup>T \<le> - ?y)
goal (1 subgoal):
1. selected_edge h j g * forest_components f * selected_edge h j g = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
selected_edge h j g * forest_components f * selected_edge h j g = bot
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?q = "w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?v = "(w \<sqinter> -(top * ?e * w\<^sup>T\<^sup>\<star>)) \<squnion> ?q\<^sup>T"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 7: "regular ?q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
using 3 regular_closed_star regular_conv_closed regular_mult_closed
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular ?x \<Longrightarrow> regular (?x\<^sup>\<star>)
regular ?x \<Longrightarrow> regular (?x\<^sup>T)
\<lbrakk>regular ?x; regular ?y\<rbrakk> \<Longrightarrow> regular (?x * ?y)
goal (1 subgoal):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 8: "injective ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
proof (rule kruskal_exchange_injective_inv_1)
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. injective w
2. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
3. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
4. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
show "injective w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective w
[PROOF STEP]
using 2 minimum_spanning_forest_def spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. injective w
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
injective w
goal (3 subgoals):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
2. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
3. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
2. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
3. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
show "covector (top * ?e * w\<^sup>T\<^sup>\<star>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
by (simp add: covector_mult_closed)
[PROOF STATE]
proof (state)
this:
covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
goal (2 subgoals):
1. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
2. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
2. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
show "top * ?e * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * ?e * w\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
[PROOF STEP]
by (simp add: mult_right_isotone star.right_plus_below_circ mult_assoc)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g * w\<^sup>T\<^sup>\<star> * w\<^sup>T \<le> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
show "coreflexive ((top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T * (top * ?e * w\<^sup>T\<^sup>\<star>) \<sqinter> w\<^sup>T * w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
[PROOF STEP]
by (metis comp_inf.semiring.mult_not_zero forest_bot kruskal_injective_inv_3 minarc_arc minarc_bot_iff minimum_spanning_forest_def semiring.mult_not_zero spanning_forest_def)
[PROOF STATE]
proof (state)
this:
coreflexive ((top * selected_edge h j g * w\<^sup>T\<^sup>\<star>[[top * selected_edge h j g * w\<^sup>T\<^sup>\<star>]]) \<sqinter> (w[[w]]))
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 9: "components g \<le> forest_components ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
proof (rule kruskal_exchange_spanning_inv_1)
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
3. components g \<le> forest_components w
[PROOF STEP]
show "injective (w \<sqinter> - (top *?e * w\<^sup>T\<^sup>\<star>) \<squnion> (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (2 subgoals):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
2. components g \<le> forest_components w
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
2. components g \<le> forest_components w
[PROOF STEP]
show "regular (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
using 7
[PROOF STATE]
proof (prove)
using this:
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
goal (1 subgoal):
1. regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
goal (1 subgoal):
1. components g \<le> forest_components w
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. components g \<le> forest_components w
[PROOF STEP]
show "components g \<le> forest_components w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components w
[PROOF STEP]
using 2 minimum_spanning_forest_def spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. components g \<le> forest_components w
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components w
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 10: "spanning_forest ?v g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
[PROOF STEP]
proof (unfold spanning_forest_def, intro conjI)
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
4. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "injective ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (4 subgoals):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "acyclic ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
proof (rule kruskal_exchange_acyclic_inv_1)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. pd_kleene_allegory_class.acyclic w
2. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
show "pd_kleene_allegory_class.acyclic w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
using 2 minimum_spanning_forest_def spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
pd_kleene_allegory_class.acyclic w
goal (1 subgoal):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
show "covector (top * ?e * w\<^sup>T\<^sup>\<star>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
[PROOF STEP]
by (simp add: covector_mult_closed)
[PROOF STATE]
proof (state)
this:
covector (top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?v \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
proof (rule sup_least)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<le> - - g
2. (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
show "w \<sqinter> - (top * ?e * w\<^sup>T\<^sup>\<star>) \<le> - - g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<le> - - g
[PROOF STEP]
using 7 inf.coboundedI1 minimum_spanning_forest_def spanning_forest_def 2
[PROOF STATE]
proof (prove)
using this:
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
?a \<le> ?c \<Longrightarrow> ?a \<sqinter> ?b \<le> ?c
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<le> - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<le> - - g
goal (1 subgoal):
1. (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
show "(w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
by (metis assms(1) conv_complement conv_isotone inf.coboundedI1 minimum_spanning_forest_def spanning_forest_def)
[PROOF STATE]
proof (state)
this:
(w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "components g \<le> forest_components ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 9
[PROOF STATE]
proof (prove)
using this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "regular ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 3 regular_closed_star regular_conv_closed regular_mult_closed
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular ?x \<Longrightarrow> regular (?x\<^sup>\<star>)
regular ?x \<Longrightarrow> regular (?x\<^sup>T)
\<lbrakk>regular ?x; regular ?y\<rbrakk> \<Longrightarrow> regular (?x * ?y)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 11: "sum (?v \<sqinter> g) = sum (w \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
have "sum (?v \<sqinter> g) = sum (w \<sqinter> -(top * ?e * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum (?q\<^sup>T \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g)
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g)
[PROOF STEP]
by (smt conv_complement conv_top epm_8 inf_import_p inf_top_right regular_closed_top vector_top_closed minimum_spanning_forest_def spanning_forest_def sum_disjoint)
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
have "... = sum (w \<sqinter> -(top * ?e * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum (?q \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g)
[PROOF STEP]
by (simp add: assms(1) sum_symmetric)
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum ((w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
have "... = sum (((w \<sqinter> -(top * ?e * w\<^sup>T\<^sup>\<star>)) \<squnion> ?q) \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g)
[PROOF STEP]
using inf_commute inf_left_commute sum_disjoint
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> ?y = ?y \<sqinter> ?x
?x \<sqinter> (?y \<sqinter> ?z) = ?y \<sqinter> (?x \<sqinter> ?z)
?x \<sqinter> ?y = bot \<Longrightarrow> sum_class.sum ((?x \<squnion> ?y) \<sqinter> ?z) = sum_class.sum (?x \<sqinter> ?z) + sum_class.sum (?y \<sqinter> ?z)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) + sum_class.sum (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
have "... = sum (w \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
using 3 7 8 maddux_3_11_pp
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
?x - ?y \<squnion> (?x - - ?y) = ?x
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 12: "?v \<squnion> ?v\<^sup>T = w \<squnion> w\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
have "?v \<squnion> ?v\<^sup>T = (w \<sqinter> -?q) \<squnion> ?q\<^sup>T \<squnion> (w\<^sup>T \<sqinter> -?q\<^sup>T) \<squnion> ?q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
[PROOF STEP]
using conv_complement conv_dist_inf conv_dist_sup inf_import_p sup_assoc
[PROOF STATE]
proof (prove)
using this:
(- ?x)\<^sup>T = - ?x\<^sup>T
(?x \<sqinter> ?y)\<^sup>T = ?x\<^sup>T \<sqinter> ?y\<^sup>T
(?x \<squnion> ?y)\<^sup>T = ?x\<^sup>T \<squnion> ?y\<^sup>T
?x - ?x \<sqinter> ?y = ?x - ?y
?x \<squnion> ?y \<squnion> ?z = ?x \<squnion> (?y \<squnion> ?z)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
have "... = w \<squnion> w\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> = w \<squnion> w\<^sup>T
[PROOF STEP]
using 3 7 conv_complement conv_dist_inf inf_import_p maddux_3_11_pp sup_monoid.add_assoc sup_monoid.add_commute
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
(- ?x)\<^sup>T = - ?x\<^sup>T
(?x \<sqinter> ?y)\<^sup>T = ?x\<^sup>T \<sqinter> ?y\<^sup>T
?x - ?x \<sqinter> ?y = ?x - ?y
?x - ?y \<squnion> (?x - - ?y) = ?x
?a \<squnion> ?b \<squnion> ?c = ?a \<squnion> (?b \<squnion> ?c)
?a \<squnion> ?b = ?b \<squnion> ?a
goal (1 subgoal):
1. w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> = w \<squnion> w\<^sup>T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w - w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w\<^sup>T - (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<squnion> w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star> = w \<squnion> w\<^sup>T
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 13: "?v * ?e\<^sup>T = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
proof (rule kruskal_reroot_edge)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. injective (selected_edge h j g[[top]])
2. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
show "injective (?e\<^sup>T * top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (selected_edge h j g[[top]])
[PROOF STEP]
using assms(16) minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. injective (selected_edge h j g[[top]])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
injective (selected_edge h j g[[top]])
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
show "pd_kleene_allegory_class.acyclic w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
using 2 minimum_spanning_forest_def spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic w
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
pd_kleene_allegory_class.acyclic w
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have "?v \<sqinter> ?e \<le> ?v \<sqinter> top * ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g
[PROOF STEP]
using inf.sup_right_isotone top_left_mult_increasing
[PROOF STATE]
proof (prove)
using this:
?y \<le> ?x \<Longrightarrow> ?z \<sqinter> ?y \<le> ?z \<sqinter> ?x
?x \<le> top * ?x
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have "... \<le> ?v * (top * ?e)\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
[PROOF STEP]
using covector_restrict_comp_conv covector_mult_closed vector_top_closed
[PROOF STATE]
proof (prove)
using this:
covector ?x \<Longrightarrow> ?y \<sqinter> ?x \<le> ?y * ?x\<^sup>T
covector ?x \<Longrightarrow> covector (?x * ?y)
surjective top
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
[PROOF STEP]
have 14: "?v \<sqinter> ?e = bot"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g = bot
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (top * selected_edge h j g)\<^sup>T
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g = bot
[PROOF STEP]
by (metis conv_dist_comp mult_assoc le_bot mult_left_zero)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g = bot
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?i = "?v \<sqinter> (- ?F) * ?e * top \<sqinter> top * ?e\<^sup>T * ?F"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
let ?w = "(?v \<sqinter> -?i) \<squnion> ?e"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 15: "regular ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
using 3 regular_closed_star regular_conv_closed regular_mult_closed
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular ?x \<Longrightarrow> regular (?x\<^sup>\<star>)
regular ?x \<Longrightarrow> regular (?x\<^sup>T)
\<lbrakk>regular ?x; regular ?y\<rbrakk> \<Longrightarrow> regular (?x * ?y)
goal (1 subgoal):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 16: "?F \<le> -?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have 161: "bijective (?e * top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (selected_edge h j g * top)
[PROOF STEP]
using assms(16) minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. bijective (selected_edge h j g * top)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bijective (selected_edge h j g * top)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "?i \<le> - ?F * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components f * selected_edge h j g * top
[PROOF STEP]
using inf.cobounded2 inf.coboundedI1
[PROOF STATE]
proof (prove)
using this:
?a \<sqinter> ?b \<le> ?b
?a \<le> ?c \<Longrightarrow> ?a \<sqinter> ?b \<le> ?c
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components f * selected_edge h j g * top
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... = - (?F * ?e * top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top = - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
using 161 comp_bijective_complement
[PROOF STATE]
proof (prove)
using this:
bijective (selected_edge h j g * top)
bijective ?y \<Longrightarrow> - ?x * ?y = - (?x * ?y)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top = - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
by (simp add: mult_assoc)
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g * top = - (forest_components f * selected_edge h j g * top)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
have "?i \<le> - (?F * ?e * top)"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
hence 162: "?i \<sqinter> ?F \<le> - (?F * ?e * top)"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
using inf.coboundedI1
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - (forest_components f * selected_edge h j g * top)
?a \<le> ?c \<Longrightarrow> ?a \<sqinter> ?b \<le> ?c
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> - (forest_components f * selected_edge h j g * top)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> - (forest_components f * selected_edge h j g * top)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "?i \<sqinter> ?F \<le> ?F \<sqinter> (top * ?e\<^sup>T * ?F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f
[PROOF STEP]
by (meson inf_le1 inf_le2 le_infI order_trans)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... \<le> ?F * (top * ?e\<^sup>T * ?F)\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T
[PROOF STEP]
by (simp add: covector_mult_closed covector_restrict_comp_conv)
[PROOF STATE]
proof (state)
this:
forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
forest_components f \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... = ?F * ?F\<^sup>T * ?e\<^sup>T\<^sup>T * top\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
[PROOF STEP]
by (simp add: conv_dist_comp mult_assoc)
[PROOF STATE]
proof (state)
this:
forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
forest_components f * (top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... = ?F * ?F * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * forest_components f * selected_edge h j g * top
[PROOF STEP]
by (simp add: conv_dist_comp conv_star_commute)
[PROOF STATE]
proof (state)
this:
forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
forest_components f * forest_components f\<^sup>T * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... = ?F * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * forest_components f * selected_edge h j g * top = forest_components f * selected_edge h j g * top
[PROOF STEP]
by (simp add: 5 preorder_idempotent)
[PROOF STATE]
proof (state)
this:
forest_components f * forest_components f * selected_edge h j g * top = forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
[PROOF STEP]
have "?i \<sqinter> ?F \<le> ?F * ?e * top"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
hence "?i \<sqinter> ?F \<le> ?F * ?e * top \<sqinter> - (?F * ?e * top)"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top
[PROOF STEP]
using 162 inf.bounded_iff
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> - (forest_components f * selected_edge h j g * top)
(?a \<le> ?b \<sqinter> ?c) = (?a \<le> ?b \<and> ?a \<le> ?c)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
have "... = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g * top - forest_components f * selected_edge h j g * top = bot
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> bot
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> bot
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
using le_bot p_antitone_iff pseudo_complement
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> forest_components f \<le> bot
?a \<le> bot \<Longrightarrow> ?a = bot
(?x \<le> - ?y) = (?y \<le> - ?x)
(?x \<sqinter> ?y = bot) = (?x \<le> - ?y)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 17: "?i \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "?i \<le> ?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>
[PROOF STEP]
using 2 8 12
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>
[PROOF STEP]
by (smt inf.sup_right_isotone kruskal_forest_components_inf mult_right_isotone mult_assoc)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = ?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> * (1 \<squnion> (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using star_left_unfold_equal star.circ_right_unfold_1
[PROOF STATE]
proof (prove)
using this:
(1::'a) \<squnion> ?x\<^sup>+ = ?x\<^sup>\<star>
Rf (?x\<^sup>\<star>) ?x = ?x\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = ?v \<sqinter> - ?F * ?e * top \<sqinter> (top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)))
[PROOF STEP]
by (simp add: mult_left_dist_sup mult_assoc)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * Rf ((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star>) (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star>) \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using comp_inf.semiring.distrib_left
[PROOF STATE]
proof (prove)
using this:
?a \<sqinter> (?b \<squnion> ?c) = ?a \<sqinter> ?b \<squnion> ?a \<sqinter> ?c
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> (top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))) = (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using comp_inf.semiring.add_right_mono inf_le2
[PROOF STATE]
proof (prove)
using this:
?a \<le> ?b \<Longrightarrow> ?a \<squnion> ?c \<le> ?b \<squnion> ?c
?x \<sqinter> ?y \<le> ?y
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F\<^sup>T \<sqinter> ?v\<^sup>T)\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by (simp add: conv_dist_inf)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F\<^sup>T\<^sup>\<star> * ?F\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
have "top * ?e\<^sup>T * (?F\<^sup>T \<sqinter> ?v\<^sup>T)\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v) \<le> top * ?e\<^sup>T * ?F\<^sup>T\<^sup>\<star> * ?F\<^sup>\<star> * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using star_isotone
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?x\<^sup>\<star> \<le> ?y\<^sup>\<star>
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by (simp add: comp_isotone)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
hence "?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * (?F\<^sup>T \<sqinter> ?v\<^sup>T)\<^sup>\<star> * (?F \<sqinter> ?v)\<^sup>\<star> * (?F \<sqinter> ?v) \<le> ?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F\<^sup>T\<^sup>\<star> * ?F\<^sup>\<star> * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
using this:
top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using inf.sup_right_isotone
[PROOF STATE]
proof (prove)
using this:
top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
?y \<le> ?x \<Longrightarrow> ?z \<sqinter> ?y \<le> ?z \<sqinter> ?x
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using sup_right_isotone
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
?x \<le> ?y \<Longrightarrow> ?z \<squnion> ?x \<le> ?z \<squnion> ?y
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * (forest_components f\<^sup>T \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T)\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F\<^sup>\<star> * ?F\<^sup>\<star> * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using 5
[PROOF STATE]
proof (prove)
using this:
equivalence (forest_components f)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>T\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * ?F * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by (simp add: assms(2) forest_components_star)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f\<^sup>\<star> * forest_components f\<^sup>\<star> * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star> \<squnion> (?v \<sqinter> - ?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using 5 mult.semigroup_axioms preorder_idempotent semigroup.assoc
[PROOF STATE]
proof (prove)
using this:
equivalence (forest_components f)
semigroup (*)
preorder ?x \<Longrightarrow> idempotent ?x
semigroup ?f \<Longrightarrow> ?f (?f ?a ?b) ?c = ?f ?a (?f ?b ?c)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = top * ?e\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "?e * top * ?e\<^sup>T \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. coreflexive (selected_edge h j g * top * selected_edge h j g\<^sup>T)
[PROOF STEP]
using assms(16) arc_expanded minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
(bijective (?x * top) \<and> bijective (?x[[top]])) = (coreflexive (?x * top * ?x\<^sup>T) \<and> coreflexive ((?x[[top]]) * ?x) \<and> times_top_class.total (top * ?x))
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. coreflexive (selected_edge h j g * top * selected_edge h j g\<^sup>T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coreflexive (selected_edge h j g * top * selected_edge h j g\<^sup>T)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence "?F * ?e * top * ?e\<^sup>T \<le> ?F * 1"
[PROOF STATE]
proof (prove)
using this:
coreflexive (selected_edge h j g * top * selected_edge h j g\<^sup>T)
goal (1 subgoal):
1. forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f * (1::'a)
[PROOF STEP]
by (metis comp_associative comp_isotone mult_semi_associative star.circ_transitive_equal)
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f * (1::'a)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence "?v * ?v\<^sup>T * ?F * ?e * top * ?e\<^sup>T \<le> 1 * ?F * 1"
[PROOF STATE]
proof (prove)
using this:
forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f * (1::'a)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (1::'a) * forest_components f * (1::'a)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f * (1::'a)
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (1::'a) * forest_components f * (1::'a)
[PROOF STEP]
by (smt comp_isotone mult_assoc)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (1::'a) * forest_components f * (1::'a)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence 171: "?v * ?v\<^sup>T * ?F * ?e * top * ?e\<^sup>T \<le> ?F"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (1::'a) * forest_components f * (1::'a)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence "?v * (?F \<sqinter> ?v)\<^sup>T * ?F * ?e * top * ?e\<^sup>T \<le> ?F"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f \<Longrightarrow> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
have "?v * (?F \<sqinter> ?v)\<^sup>T * ?F * ?e * top * ?e\<^sup>T \<le> ?v * ?v\<^sup>T * ?F * ?e * top * ?e\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T
[PROOF STEP]
by (simp add: conv_dist_inf mult_left_isotone mult_right_isotone)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f \<Longrightarrow> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
using 171 order_trans
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
\<lbrakk>?x \<le> ?y; ?y \<le> ?z\<rbrakk> \<Longrightarrow> ?x \<le> ?z
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence 172: "-?F * ((?F \<sqinter> ?v)\<^sup>T * ?F * ?e * top * ?e\<^sup>T)\<^sup>T \<le> -?v"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T * forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T \<le> forest_components f
goal (1 subgoal):
1. - forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by (smt schroeder_4_p comp_associative order_lesseq_imp pp_increasing)
[PROOF STATE]
proof (state)
this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "-?F * ((?F \<sqinter> ?v)\<^sup>T * ?F * ?e * top * ?e\<^sup>T)\<^sup>T = -?F * ?e\<^sup>T\<^sup>T * top\<^sup>T * ?e\<^sup>T * ?F\<^sup>T * (?F \<sqinter> ?v)\<^sup>T\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T
[PROOF STEP]
by (simp add: comp_associative conv_dist_comp)
[PROOF STATE]
proof (state)
this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = -?F * ?e * top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T = - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using 5
[PROOF STATE]
proof (prove)
using this:
equivalence (forest_components f)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T = - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T = - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T * selected_edge h j g\<^sup>T * forest_components f\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>T = - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = -?F * ?e * top * top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
using comp_associative
[PROOF STATE]
proof (prove)
using this:
?x * ?y * ?z = ?x * (?y * ?z)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = -?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by (smt comp_associative comp_inf.star.circ_decompose_9 comp_inf.star_star_absorb comp_inf_covector inf_vector_comp vector_top_closed)
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g * top * top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
have "-?F * ((?F \<sqinter> ?v)\<^sup>T * ?F * ?e * top * ?e\<^sup>T)\<^sup>T = -?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
using this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. - forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence "-?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v) \<le> -?v"
[PROOF STATE]
proof (prove)
using this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 172
[PROOF STATE]
proof (prove)
using this:
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T = - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
- forest_components f * (((forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))[[forest_components f]]) * selected_edge h j g * top * selected_edge h j g\<^sup>T)\<^sup>T \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
hence "?v \<sqinter> -?F * ?e * top \<sqinter> top * ?e\<^sup>T * ?F * (?F \<sqinter> ?v) \<le> bot"
[PROOF STATE]
proof (prove)
using this:
- forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> bot
[PROOF STEP]
by (smt bot_unique inf.sup_monoid.add_commute p_shunting_swap pseudo_complement)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> bot
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> bot
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
using le_bot sup_monoid.add_0_right
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) \<le> bot
?a \<le> bot \<Longrightarrow> ?a = bot
?a \<squnion> bot = ?a
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)) = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... = top * ?e\<^sup>T * (?F \<sqinter> ?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 16
[PROOF STATE]
proof (prove)
using this:
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by (smt comp_inf.coreflexive_comp_inf_complement inf_top_right p_bot pseudo_complement top.extremum)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))\<^sup>T\<^sup>\<star> = top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 18: "?i \<le> top * ?e\<^sup>T * ?w\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "?i \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 17
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using mult_right_isotone conv_isotone star_isotone inf.cobounded2 inf.sup_monoid.add_assoc
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?z * ?x \<le> ?z * ?y
?x \<le> ?y \<Longrightarrow> ?x\<^sup>T \<le> ?y\<^sup>T
?x \<le> ?y \<Longrightarrow> ?x\<^sup>\<star> \<le> ?y\<^sup>\<star>
?a \<sqinter> ?b \<le> ?b
?a \<sqinter> ?b \<sqinter> ?c = ?a \<sqinter> (?b \<sqinter> ?c)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by (simp add: inf.sup_monoid.add_assoc order.eq_iff inf.sup_monoid.add_commute)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * ((?v \<sqinter> -?i) \<squnion> ?e)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using mult_right_isotone conv_isotone star_isotone sup_ge1
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?z * ?x \<le> ?z * ?y
?x \<le> ?y \<Longrightarrow> ?x\<^sup>T \<le> ?y\<^sup>T
?x \<le> ?y \<Longrightarrow> ?x\<^sup>\<star> \<le> ?y\<^sup>\<star>
?x \<le> ?x \<squnion> ?y
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 19: "?i \<le> top * ?e\<^sup>T * ?v\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "?i \<le> top * ?e\<^sup>T * (?F \<sqinter> ?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 17
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?v \<sqinter> -?i)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using mult_right_isotone conv_isotone star_isotone inf.cobounded2 inf.sup_monoid.add_assoc
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?z * ?x \<le> ?z * ?y
?x \<le> ?y \<Longrightarrow> ?x\<^sup>T \<le> ?y\<^sup>T
?x \<le> ?y \<Longrightarrow> ?x\<^sup>\<star> \<le> ?y\<^sup>\<star>
?a \<sqinter> ?b \<le> ?b
?a \<sqinter> ?b \<sqinter> ?c = ?a \<sqinter> (?b \<sqinter> ?c)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by (simp add: inf.sup_monoid.add_assoc order.eq_iff inf.sup_monoid.add_commute)
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
have "... \<le> top * ?e\<^sup>T * (?v)\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using mult_right_isotone conv_isotone star_isotone
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?z * ?x \<le> ?z * ?y
?x \<le> ?y \<Longrightarrow> ?x\<^sup>T \<le> ?y\<^sup>T
?x \<le> ?y \<Longrightarrow> ?x\<^sup>\<star> \<le> ?y\<^sup>\<star>
goal (1 subgoal):
1. top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have 20: "f \<squnion> f\<^sup>T \<le> (?v \<sqinter> -?i \<sqinter> -?i\<^sup>T) \<squnion> (?v\<^sup>T \<sqinter> -?i \<sqinter> -?i\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
proof (rule kruskal_edge_between_components_2)
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
2. injective f
3. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
show "?F \<le> - ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
using 16
[PROOF STATE]
proof (prove)
using this:
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (2 subgoals):
1. injective f
2. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. injective f
2. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
show "injective f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective f
[PROOF STEP]
by (simp add: assms(2))
[PROOF STATE]
proof (state)
this:
injective f
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
show "f \<squnion> f\<^sup>T \<le> w \<sqinter> - (top * ?e * w\<^sup>T\<^sup>\<star>) \<squnion> (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w \<sqinter> - (top * ?e * w\<^sup>T\<^sup>\<star>) \<squnion> (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
using 2 12
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T = w \<squnion> w\<^sup>T
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
[PROOF STEP]
by (metis conv_dist_sup conv_involutive conv_isotone le_supI sup_commute)
[PROOF STATE]
proof (state)
this:
f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
have "minimum_spanning_forest ?w g \<and> ?f \<le> ?w \<squnion> ?w\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
proof (intro conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have 211: "?e\<^sup>T \<le> ?v\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
[PROOF STEP]
proof (rule kruskal_edge_arc_1[where g=g and h="?ec"])
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. selected_edge h j g \<le> - - (choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g)
2. choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
3. symmetric g
4. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
show "?e \<le> -- ?ec"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<le> - - (choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g)
[PROOF STEP]
using minarc_below
[PROOF STATE]
proof (prove)
using this:
minarc ?x \<le> - - ?x
goal (1 subgoal):
1. selected_edge h j g \<le> - - (choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<le> - - (choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g)
goal (4 subgoals):
1. choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
2. symmetric g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
2. symmetric g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
show "?ec \<le> g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
[PROOF STEP]
using assms(4) inf.cobounded2
[PROOF STATE]
proof (prove)
using this:
regular f
?a \<sqinter> ?b \<le> ?b
goal (1 subgoal):
1. choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
[PROOF STEP]
by (simp add: boruvka_inner_invariant_def boruvka_outer_invariant_def conv_dist_inf)
[PROOF STATE]
proof (state)
this:
choose_component (forest_components h) j * - choose_component (forest_components h) j\<^sup>T \<sqinter> g \<le> g
goal (3 subgoals):
1. symmetric g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. symmetric g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
show "symmetric g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. symmetric g
[PROOF STEP]
by (meson assms(1) boruvka_inner_invariant_def boruvka_outer_invariant_def)
[PROOF STATE]
proof (state)
this:
symmetric g
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
show "components g \<le> forest_components (w \<sqinter> - (top * ?e * w\<^sup>T\<^sup>\<star>) \<squnion> (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 9
[PROOF STATE]
proof (prove)
using this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
show "(w \<sqinter> - (top * ?e * w\<^sup>T\<^sup>\<star>) \<squnion> (w \<sqinter> top * ?e * w\<^sup>T\<^sup>\<star>)\<^sup>T) * ?e\<^sup>T = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
goal (2 subgoals):
1. minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have 212: "arc ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
proof (rule boruvka_edge_arc)
[PROOF STATE]
proof (state)
goal (10 subgoals):
1. equivalence (forest_components f)
2. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
4. regular (forest_components f)
5. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
6. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
8. selected_edge h j g * forest_components f * selected_edge h j g = bot
9. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
10. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "equivalence ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. equivalence (forest_components f)
[PROOF STEP]
by (simp add: 5)
[PROOF STATE]
proof (state)
this:
equivalence (forest_components f)
goal (9 subgoals):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
3. regular (forest_components f)
4. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
5. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
7. selected_edge h j g * forest_components f * selected_edge h j g = bot
8. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
9. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (9 subgoals):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
3. regular (forest_components f)
4. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
5. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
7. selected_edge h j g * forest_components f * selected_edge h j g = bot
8. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
9. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "forest ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (8 subgoals):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
2. regular (forest_components f)
3. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
6. selected_edge h j g * forest_components f * selected_edge h j g = bot
7. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
8. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (8 subgoals):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
2. regular (forest_components f)
3. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
6. selected_edge h j g * forest_components f * selected_edge h j g = bot
7. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
8. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "arc ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
[PROOF STEP]
using assms(16) minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
goal (7 subgoals):
1. regular (forest_components f)
2. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
5. selected_edge h j g * forest_components f * selected_edge h j g = bot
6. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
7. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (7 subgoals):
1. regular (forest_components f)
2. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
5. selected_edge h j g * forest_components f * selected_edge h j g = bot
6. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
7. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "regular ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (forest_components f)
[PROOF STEP]
using 3 regular_closed_star regular_conv_closed regular_mult_closed
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular ?x \<Longrightarrow> regular (?x\<^sup>\<star>)
regular ?x \<Longrightarrow> regular (?x\<^sup>T)
\<lbrakk>regular ?x; regular ?y\<rbrakk> \<Longrightarrow> regular (?x * ?y)
goal (1 subgoal):
1. regular (forest_components f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
regular (forest_components f)
goal (6 subgoals):
1. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
4. selected_edge h j g * forest_components f * selected_edge h j g = bot
5. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
6. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (6 subgoals):
1. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
4. selected_edge h j g * forest_components f * selected_edge h j g = bot
5. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
6. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "?F \<le> forest_components (?F \<sqinter> ?v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
[PROOF STEP]
by (simp add: 12 2 8 kruskal_forest_components_inf)
[PROOF STATE]
proof (state)
this:
forest_components f \<le> forest_components (forest_components f \<sqinter> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T))
goal (5 subgoals):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
3. selected_edge h j g * forest_components f * selected_edge h j g = bot
4. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
5. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
3. selected_edge h j g * forest_components f * selected_edge h j g = bot
4. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
5. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "regular ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (4 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
2. selected_edge h j g * forest_components f * selected_edge h j g = bot
3. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
4. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
2. selected_edge h j g * forest_components f * selected_edge h j g = bot
3. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
4. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "?v * ?e\<^sup>T = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (3 subgoals):
1. selected_edge h j g * forest_components f * selected_edge h j g = bot
2. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
3. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. selected_edge h j g * forest_components f * selected_edge h j g = bot
2. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
3. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "?e * ?F * ?e = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g * forest_components f * selected_edge h j g = bot
[PROOF STEP]
by (simp add: 6)
[PROOF STATE]
proof (state)
this:
selected_edge h j g * forest_components f * selected_edge h j g = bot
goal (2 subgoals):
1. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
2. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
2. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "?e\<^sup>T \<le> ?v\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
[PROOF STEP]
using 211
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
goal (1 subgoal):
1. selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star>
goal (1 subgoal):
1. selected_edge h j g \<noteq> bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. selected_edge h j g \<noteq> bot
[PROOF STEP]
show "?e \<noteq> bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<noteq> bot
[PROOF STEP]
by (simp add: assms(16))
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<noteq> bot
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (2 subgoals):
1. minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
show "minimum_spanning_forest ?w g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
[PROOF STEP]
proof (unfold minimum_spanning_forest_def, intro conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "(?v \<sqinter> -?i) * ?e\<^sup>T \<le> ?v * ?e\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T
[PROOF STEP]
using inf_le1 mult_left_isotone
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> ?y \<le> ?x
?x \<le> ?y \<Longrightarrow> ?x * ?z \<le> ?y * ?z
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T
goal (2 subgoals):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
hence "(?v \<sqinter> -?i) * ?e\<^sup>T = bot"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
using 13 le_bot
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
?a \<le> bot \<Longrightarrow> ?a = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T = bot
goal (2 subgoals):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
hence 221: "?e * (?v \<sqinter> -?i)\<^sup>T = bot"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = bot
[PROOF STEP]
using conv_dist_comp conv_involutive conv_bot
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * selected_edge h j g\<^sup>T = bot
(?x * ?y)\<^sup>T = ?y[[?x\<^sup>T]]
?x\<^sup>T\<^sup>T = ?x
symmetric bot
goal (1 subgoal):
1. selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = bot
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = bot
goal (2 subgoals):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have 222: "injective ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
proof (rule injective_sup)
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
2. coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
3. injective (selected_edge h j g)
[PROOF STEP]
show "injective (?v \<sqinter> -?i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
by (simp add: injective_inf_closed)
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (2 subgoals):
1. coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
2. injective (selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
2. injective (selected_edge h j g)
[PROOF STEP]
show "coreflexive (?e * (?v \<sqinter> -?i)\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
using 221
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T = bot
goal (1 subgoal):
1. coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
coreflexive (selected_edge h j g * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. injective (selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. injective (selected_edge h j g)
[PROOF STEP]
show "injective ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (selected_edge h j g)
[PROOF STEP]
by (metis arc_injective minarc_arc coreflexive_bot_closed coreflexive_injective minarc_bot_iff)
[PROOF STATE]
proof (state)
this:
injective (selected_edge h j g)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (2 subgoals):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
2. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
show "spanning_forest ?w g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
[PROOF STEP]
proof (unfold spanning_forest_def, intro conjI)
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
4. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
5. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
show "injective ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
using 222
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (4 subgoals):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
4. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
show "acyclic ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
proof (rule kruskal_exchange_acyclic_inv_2)
[PROOF STATE]
proof (state)
goal (7 subgoals):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
4. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
5. bijective (selected_edge h j g * top)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "acyclic ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (6 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. bijective (selected_edge h j g * top)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (6 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. bijective (selected_edge h j g * top)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "injective ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (5 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. bijective (selected_edge h j g * top)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. bijective (selected_edge h j g * top)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "?i \<le>?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
[PROOF STEP]
using inf.coboundedI1
[PROOF STATE]
proof (prove)
using this:
?a \<le> ?c \<Longrightarrow> ?a \<sqinter> ?b \<le> ?c
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
goal (4 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. bijective (selected_edge h j g * top)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. bijective (selected_edge h j g * top)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "bijective (?i\<^sup>T * top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
using 212
[PROOF STATE]
proof (prove)
using this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (3 subgoals):
1. bijective (selected_edge h j g * top)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. bijective (selected_edge h j g * top)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "bijective (?e * top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (selected_edge h j g * top)
[PROOF STEP]
using 14 212
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g = bot
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (1 subgoal):
1. bijective (selected_edge h j g * top)
[PROOF STEP]
by (smt assms(4) comp_inf.idempotent_bot_closed conv_complement minarc_arc minarc_bot_iff p_bot regular_closed_bot semiring.mult_not_zero symmetric_top_closed)
[PROOF STATE]
proof (state)
this:
bijective (selected_edge h j g * top)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "?i \<le> top * ?e\<^sup>T *?v\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 19
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
show "?v * ?e\<^sup>T * top = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
pd_kleene_allegory_class.acyclic (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "?w \<le> ?v \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
[PROOF STEP]
using inf_le1 sup_left_isotone
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> ?y \<le> ?x
?x \<le> ?y \<Longrightarrow> ?x \<squnion> ?z \<le> ?y \<squnion> ?z
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> --g \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g \<squnion> selected_edge h j g
[PROOF STEP]
using 10 sup_left_isotone spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
?x \<le> ?y \<Longrightarrow> ?x \<squnion> ?z \<le> ?y \<squnion> ?z
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g \<squnion> selected_edge h j g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g \<squnion> selected_edge h j g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g \<squnion> selected_edge h j g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> --g \<squnion> --h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
have 1: "--g \<le> --g \<squnion> --h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - - g \<le> - - g \<squnion> - - h
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- - g \<le> - - g \<squnion> - - h
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
have 2: "?e \<le> --g \<squnion> --h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
by (metis inf.coboundedI1 inf.sup_monoid.add_commute minarc_below order.trans p_dist_inf p_dist_sup sup.cobounded1)
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<le> - - g \<squnion> - - h
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<le> - - g \<squnion> - - h
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
using 1 2
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<le> - - g \<squnion> - - h
- - g \<le> - - g \<squnion> - - h
selected_edge h j g \<le> - - g \<squnion> - - h
goal (1 subgoal):
1. - - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
- - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- - g \<squnion> selected_edge h j g \<le> - - g \<squnion> - - h
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. - - g \<squnion> - - h \<le> - - g
[PROOF STEP]
using assms(18, 19)
[PROOF STATE]
proof (prove)
using this:
regular h
h \<le> - - g
goal (1 subgoal):
1. - - g \<squnion> - - h \<le> - - g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- - g \<squnion> - - h \<le> - - g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
3. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
show "?w \<le> --g"
[PROOF STATE]
proof (prove)
using this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have 223: "?i \<le> (?v \<sqinter> -?i)\<^sup>T\<^sup>\<star> * ?e\<^sup>T * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
proof (rule boruvka_exchange_spanning_inv)
[PROOF STATE]
proof (state)
goal (9 subgoals):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * ?w\<^sup>T\<^sup>\<star>
4. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
5. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
6. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
7. ?w \<le> - - ?g
8. selected_edge h j g \<le> - - ?g
9. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "forest ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (8 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * ?w\<^sup>T\<^sup>\<star>
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
5. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
6. ?w \<le> - - ?g
7. selected_edge h j g \<le> - - ?g
8. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (8 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * ?w\<^sup>T\<^sup>\<star>
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
5. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
6. ?w \<le> - - ?g
7. selected_edge h j g \<le> - - ?g
8. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?v\<^sup>\<star> * ?e\<^sup>T = ?e\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
[PROOF STEP]
by (smt conv_complement conv_dist_comp conv_involutive conv_star_commute dense_pp fc_top regular_closed_top star_absorb)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>\<star> * selected_edge h j g\<^sup>T = selected_edge h j g\<^sup>T
goal (7 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * ?w\<^sup>T\<^sup>\<star>
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
4. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
5. ?w \<le> - - ?g
6. selected_edge h j g \<le> - - ?g
7. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (7 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * ?w\<^sup>T\<^sup>\<star>
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
4. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
5. ?w \<le> - - ?g
6. selected_edge h j g \<le> - - ?g
7. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?i \<le> ?v \<sqinter> top * ?e\<^sup>T * ?w\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 18 inf.sup_monoid.add_assoc
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
?a \<sqinter> ?b \<sqinter> ?c = ?a \<sqinter> (?b \<sqinter> ?c)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T\<^sup>\<star>
goal (6 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
4. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
5. selected_edge h j g \<le> - - ?g
6. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (6 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
4. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
5. selected_edge h j g \<le> - - ?g
6. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "arc ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
using 212
[PROOF STATE]
proof (prove)
using this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (5 subgoals):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
4. selected_edge h j g \<le> - - ?g
5. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
3. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
4. selected_edge h j g \<le> - - ?g
5. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "arc ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
[PROOF STEP]
using assms(16) minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bijective (selected_edge h j g * top) \<and> bijective (selected_edge h j g[[top]])
goal (4 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
3. selected_edge h j g \<le> - - ?g
4. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - ?g
2. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - ?g
3. selected_edge h j g \<le> - - ?g
4. components ?g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?v \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<le> - - g
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. selected_edge h j g \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
2. selected_edge h j g \<le> - - g
3. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?w \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
have 2231: "?e \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<le> - - g
[PROOF STEP]
by (metis inf.boundedE minarc_below pp_dist_inf)
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<le> - - g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
have "?w \<le> ?v \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
[PROOF STEP]
using inf_le1 sup_left_isotone
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> ?y \<le> ?x
?x \<le> ?y \<Longrightarrow> ?x \<squnion> ?z \<le> ?y \<squnion> ?z
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
have "... \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
using 2231 10 spanning_forest_def sup_least
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<le> - - g
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
\<lbrakk>?y \<le> ?x; ?z \<le> ?x\<rbrakk> \<Longrightarrow> ?y \<squnion> ?z \<le> ?x
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> selected_edge h j g \<le> - - g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<le> - - g
goal (2 subgoals):
1. selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. selected_edge h j g \<le> - - g
2. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "?e \<le> --g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<le> - - g
[PROOF STEP]
by (metis inf.boundedE minarc_below pp_dist_inf)
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<le> - - g
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
show "components g \<le> forest_components ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by (simp add: 9)
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "components g \<le> forest_components ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 10 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> forest_components ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
proof (rule kruskal_exchange_forest_components_inv)
[PROOF STATE]
proof (state)
goal (8 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
3. rectangle (selected_edge h j g)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
6. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
8. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (8 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
3. rectangle (selected_edge h j g)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
6. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
8. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "injective ((?v \<sqinter> -?i) \<squnion> ?e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
using 222
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (7 subgoals):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
2. rectangle (selected_edge h j g)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
5. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (7 subgoals):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
2. rectangle (selected_edge h j g)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
5. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "regular ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
using 15
[PROOF STATE]
proof (prove)
using this:
regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (6 subgoals):
1. rectangle (selected_edge h j g)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
4. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (6 subgoals):
1. rectangle (selected_edge h j g)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
4. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "?e * top * ?e = ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. rectangle (selected_edge h j g)
[PROOF STEP]
by (metis arc_top_arc minarc_arc minarc_bot_iff semiring.mult_not_zero)
[PROOF STATE]
proof (state)
this:
rectangle (selected_edge h j g)
goal (5 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
3. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
3. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "?i \<le> top * ?e\<^sup>T * ?v\<^sup>T\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
using 19
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T\<^sup>\<star>
goal (4 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
2. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
2. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "?v * ?e\<^sup>T * top = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
using 13
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) * selected_edge h j g\<^sup>T * top = bot
goal (3 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "injective ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
using 8
[PROOF STATE]
proof (prove)
using this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (1 subgoal):
1. injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
injective (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "?i \<le> ?v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
[PROOF STEP]
by (simp add: le_infI1)
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
show "?i \<le> (?v \<sqinter> -?i)\<^sup>T\<^sup>\<star> * ?e\<^sup>T * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
using 223
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T\<^sup>\<star> * selected_edge h j g\<^sup>T * top
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (2 subgoals):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
2. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
show "components g \<le> forest_components ?w"
[PROOF STATE]
proof (prove)
using this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (1 subgoal):
1. components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
components g \<le> forest_components (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
show "regular ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
using 3 7 regular_conv_closed
[PROOF STATE]
proof (prove)
using this:
regular w \<and> regular f \<and> regular (selected_edge h j g)
regular (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)
regular ?x \<Longrightarrow> regular (?x\<^sup>T)
goal (1 subgoal):
1. regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
regular (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have 224: "?e \<sqinter> g \<noteq> bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g \<sqinter> g \<noteq> bot
[PROOF STEP]
using assms(16) inf.left_commute inf_bot_right minarc_meet_bot
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<noteq> bot
?b \<sqinter> (?a \<sqinter> ?c) = ?a \<sqinter> (?b \<sqinter> ?c)
?x \<sqinter> bot = bot
minarc ?x \<sqinter> ?x = bot \<Longrightarrow> minarc ?x = bot
goal (1 subgoal):
1. selected_edge h j g \<sqinter> g \<noteq> bot
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
selected_edge h j g \<sqinter> g \<noteq> bot
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have 225: "sum (?e \<sqinter> g) \<le> sum (?i \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
[PROOF STEP]
proof (rule a_to_e_in_forest_modulo_equivalence)
[PROOF STATE]
proof (state)
goal (14 subgoals):
1. symmetric g
2. ?f \<le> - - g
3. vector ?j
4. forest ?h
5. forest_modulo_equivalence (forest_components ?h) ?d
6. ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
7. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
8. regular ?d
9. ?j \<noteq> bot
10. selected_edge h j g = selected_edge ?h ?j g
A total of 14 subgoals...
[PROOF STEP]
show "symmetric g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. symmetric g
[PROOF STEP]
using assms(1) boruvka_inner_invariant_def boruvka_outer_invariant_def
[PROOF STATE]
proof (prove)
using this:
symmetric g
boruvka_inner_invariant ?j ?f ?h ?g ?d \<equiv> boruvka_outer_invariant ?f ?g \<and> ?g \<noteq> bot \<and> regular ?d \<and> regular ?j \<and> vector ?j \<and> regular ?h \<and> forest ?h \<and> forest_components ?h * ?j = ?j \<and> forest_modulo_equivalence (forest_components ?h) ?d \<and> ?d * top \<le> - ?j \<and> ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T \<and> (\<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - ?g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> ?g) \<le> sum_class.sum (a \<sqinter> ?g))
boruvka_outer_invariant ?f ?g \<equiv> symmetric ?g \<and> forest ?f \<and> ?f \<le> - - ?g \<and> regular ?f \<and> (\<exists>w. minimum_spanning_forest w ?g \<and> ?f \<le> w \<squnion> w\<^sup>T)
goal (1 subgoal):
1. symmetric g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
symmetric g
goal (13 subgoals):
1. ?f \<le> - - g
2. vector ?j
3. forest ?h
4. forest_modulo_equivalence (forest_components ?h) ?d
5. ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
6. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
7. regular ?d
8. ?j \<noteq> bot
9. selected_edge h j g = selected_edge ?h ?j g
10. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
A total of 13 subgoals...
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (13 subgoals):
1. ?f \<le> - - g
2. vector ?j
3. forest ?h
4. forest_modulo_equivalence (forest_components ?h) ?d
5. ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
6. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
7. regular ?d
8. ?j \<noteq> bot
9. selected_edge h j g = selected_edge ?h ?j g
10. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
A total of 13 subgoals...
[PROOF STEP]
show "j \<noteq> bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. j \<noteq> bot
[PROOF STEP]
by (simp add: assms(17))
[PROOF STATE]
proof (state)
this:
j \<noteq> bot
goal (12 subgoals):
1. ?f \<le> - - g
2. vector j
3. forest ?h
4. forest_modulo_equivalence (forest_components ?h) ?d
5. ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
6. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
7. regular ?d
8. selected_edge h j g = selected_edge ?h j g
9. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
10. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
A total of 12 subgoals...
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (12 subgoals):
1. ?f \<le> - - g
2. vector j
3. forest ?h
4. forest_modulo_equivalence (forest_components ?h) ?d
5. ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
6. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
7. regular ?d
8. selected_edge h j g = selected_edge ?h j g
9. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
10. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
A total of 12 subgoals...
[PROOF STEP]
show "f \<le> -- g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<le> - - g
[PROOF STEP]
by (simp add: assms(3))
[PROOF STATE]
proof (state)
this:
f \<le> - - g
goal (11 subgoals):
1. vector j
2. forest ?h
3. forest_modulo_equivalence (forest_components ?h) ?d
4. f \<squnion> f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
5. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
6. regular ?d
7. selected_edge h j g = selected_edge ?h j g
8. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
9. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
10. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components ?h - - g
A total of 11 subgoals...
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (11 subgoals):
1. vector j
2. forest ?h
3. forest_modulo_equivalence (forest_components ?h) ?d
4. f \<squnion> f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
5. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
6. regular ?d
7. selected_edge h j g = selected_edge ?h j g
8. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
9. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
10. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components ?h - - g
A total of 11 subgoals...
[PROOF STEP]
show "vector j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vector j
[PROOF STEP]
using assms(6) boruvka_inner_invariant_def
[PROOF STATE]
proof (prove)
using this:
vector j
boruvka_inner_invariant ?j ?f ?h ?g ?d \<equiv> boruvka_outer_invariant ?f ?g \<and> ?g \<noteq> bot \<and> regular ?d \<and> regular ?j \<and> vector ?j \<and> regular ?h \<and> forest ?h \<and> forest_components ?h * ?j = ?j \<and> forest_modulo_equivalence (forest_components ?h) ?d \<and> ?d * top \<le> - ?j \<and> ?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T \<and> (\<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - ?g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> ?g) \<le> sum_class.sum (a \<sqinter> ?g))
goal (1 subgoal):
1. vector j
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
vector j
goal (10 subgoals):
1. forest ?h
2. forest_modulo_equivalence (forest_components ?h) ?d
3. f \<squnion> f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
4. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
5. regular ?d
6. selected_edge h j g = selected_edge ?h j g
7. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
8. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
9. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components ?h - - g
10. regular ?h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (10 subgoals):
1. forest ?h
2. forest_modulo_equivalence (forest_components ?h) ?d
3. f \<squnion> f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
4. \<forall>a b. forest_modulo_equivalence_path a b (forest_components ?h) ?d \<and> a \<le> - forest_components ?h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
5. regular ?d
6. selected_edge h j g = selected_edge ?h j g
7. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
8. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components ?h) (?d \<squnion> selected_edge ?h j g)
9. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components ?h - - g
10. regular ?h
[PROOF STEP]
show "forest h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest h
[PROOF STEP]
by (simp add: assms(8))
[PROOF STATE]
proof (state)
this:
forest h
goal (9 subgoals):
1. forest_modulo_equivalence (forest_components h) ?d
2. f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
3. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) ?d \<and> a \<le> - forest_components h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
4. regular ?d
5. selected_edge h j g = selected_edge h j g
6. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
7. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (?d \<squnion> selected_edge h j g)
8. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
9. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (9 subgoals):
1. forest_modulo_equivalence (forest_components h) ?d
2. f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T
3. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) ?d \<and> a \<le> - forest_components h - - g \<and> b \<le> ?d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
4. regular ?d
5. selected_edge h j g = selected_edge h j g
6. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
7. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (?d \<squnion> selected_edge h j g)
8. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
9. regular h
[PROOF STEP]
show " forest_modulo_equivalence (forest_components h) d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_modulo_equivalence (forest_components h) d
[PROOF STEP]
by (simp add: assms(9))
[PROOF STATE]
proof (state)
this:
forest_modulo_equivalence (forest_components h) d
goal (8 subgoals):
1. f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
2. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
3. regular d
4. selected_edge h j g = selected_edge h j g
5. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
6. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
8. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (8 subgoals):
1. f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
2. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
3. regular d
4. selected_edge h j g = selected_edge h j g
5. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
6. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
7. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
8. regular h
[PROOF STEP]
show "f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
[PROOF STEP]
by (simp add: assms(12))
[PROOF STATE]
proof (state)
this:
f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
goal (7 subgoals):
1. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
2. regular d
3. selected_edge h j g = selected_edge h j g
4. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
5. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
7. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (7 subgoals):
1. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
2. regular d
3. selected_edge h j g = selected_edge h j g
4. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
5. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
6. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
7. regular h
[PROOF STEP]
show "\<forall>a b. forest_modulo_equivalence_path a b (?H) d \<and> a \<le> - ?H \<sqinter> - - g \<and> b \<le> d \<longrightarrow> sum (b \<sqinter> g) \<le> sum (a \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
[PROOF STEP]
by (simp add: assms(13))
[PROOF STATE]
proof (state)
this:
\<forall>a b. forest_modulo_equivalence_path a b (forest_components h) d \<and> a \<le> - forest_components h - - g \<and> b \<le> d \<longrightarrow> sum_class.sum (b \<sqinter> g) \<le> sum_class.sum (a \<sqinter> g)
goal (6 subgoals):
1. regular d
2. selected_edge h j g = selected_edge h j g
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
6. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (6 subgoals):
1. regular d
2. selected_edge h j g = selected_edge h j g
3. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
4. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
5. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
6. regular h
[PROOF STEP]
show "regular d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular d
[PROOF STEP]
using assms(14)
[PROOF STATE]
proof (prove)
using this:
regular d
goal (1 subgoal):
1. regular d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
regular d
goal (5 subgoals):
1. selected_edge h j g = selected_edge h j g
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
5. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. selected_edge h j g = selected_edge h j g
2. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
3. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
4. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
5. regular h
[PROOF STEP]
show "?e = ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. selected_edge h j g = selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
selected_edge h j g = selected_edge h j g
goal (4 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
4. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
2. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
3. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
4. regular h
[PROOF STEP]
show "arc ?i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
using 212
[PROOF STATE]
proof (prove)
using this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (1 subgoal):
1. bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
goal (3 subgoals):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
3. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
2. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
3. regular h
[PROOF STEP]
show "forest_modulo_equivalence_path ?i ?e ?H (d \<squnion> ?e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "d\<^sup>T * ?H * ?e = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (d[[forest_components h]]) * selected_edge h j g = bot
[PROOF STEP]
using assms(6, 7, 10 ,11, 17) dT_He_eq_bot le_bot
[PROOF STATE]
proof (prove)
using this:
vector j
regular j
d * top \<le> - j
forest_components h * j = j
j \<noteq> bot
\<lbrakk>vector ?j; regular ?j; ?d * top \<le> - ?j; forest_components ?h * ?j = ?j; ?j \<noteq> bot\<rbrakk> \<Longrightarrow> (?d[[forest_components ?h]]) * selected_edge ?h ?j ?g \<le> bot
?a \<le> bot \<Longrightarrow> ?a = bot
goal (1 subgoal):
1. (d[[forest_components h]]) * selected_edge h j g = bot
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(d[[forest_components h]]) * selected_edge h j g = bot
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence 251: "d\<^sup>T * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * selected_edge h j g = bot
goal (1 subgoal):
1. (d[[forest_components h]]) * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(d[[forest_components h]]) * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "d\<^sup>T * ?H * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (metis assms(8) forest_components_star star.circ_decompose_9 mult_assoc)
[PROOF STATE]
proof (state)
this:
(d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<Longrightarrow> (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
have "d\<^sup>T * ?H * d \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. coreflexive ((d[[forest_components h]]) * d)
[PROOF STEP]
using assms(9) forest_modulo_equivalence_def dTransHd_le_1
[PROOF STATE]
proof (prove)
using this:
forest_modulo_equivalence (forest_components h) d
forest_modulo_equivalence ?x ?d \<equiv> equivalence ?x \<and> coreflexive (?x * ?d[[?x * ?d]]) \<and> coreflexive (?x \<sqinter> ?d * ?d\<^sup>T) \<and> (?x * ?d)\<^sup>+ \<sqinter> ?x \<le> bot
\<lbrakk>equivalence ?H; coreflexive (?H * ?d[[?H * ?d]])\<rbrakk> \<Longrightarrow> coreflexive ((?d[[?H]]) * ?d)
goal (1 subgoal):
1. coreflexive ((d[[forest_components h]]) * d)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coreflexive ((d[[forest_components h]]) * d)
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<Longrightarrow> (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
hence "d\<^sup>T * ?H * d * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
coreflexive ((d[[forest_components h]]) * d)
goal (1 subgoal):
1. (d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (metis mult_left_isotone star.circ_circ_mult star_involutive star_one)
[PROOF STATE]
proof (state)
this:
(d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<Longrightarrow> (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
hence "d\<^sup>T * ?H * ?e \<squnion> d\<^sup>T * ?H * d * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * selected_edge h j g \<squnion> (d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
using 251
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
(d[[forest_components h]]) * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * selected_edge h j g \<squnion> (d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(d[[forest_components h]]) * selected_edge h j g \<squnion> (d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<Longrightarrow> (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
hence "d\<^sup>T * (1 \<squnion> ?H * d * (?H * d)\<^sup>\<star>) * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[forest_components h]]) * selected_edge h j g \<squnion> (d[[forest_components h]]) * d * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[(1::'a) \<squnion> (forest_components h * d)\<^sup>+]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (simp add: comp_associative comp_left_dist_sup semiring.distrib_right)
[PROOF STATE]
proof (state)
this:
(d[[(1::'a) \<squnion> (forest_components h * d)\<^sup>+]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[forest_components h]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<Longrightarrow> (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(d[[(1::'a) \<squnion> (forest_components h * d)\<^sup>+]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (simp add: star_left_unfold_equal)
[PROOF STATE]
proof (state)
this:
(d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?H * d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> ?H * (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(d[[(forest_components h * d)\<^sup>\<star>]]) * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (simp add: mult_right_isotone mult_assoc)
[PROOF STATE]
proof (state)
this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?H * d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> ?H * ?H * (d * ?H)\<^sup>\<star> * ?e"
[PROOF STATE]
proof (prove)
using this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
[PROOF STEP]
by (smt star_slide mult_assoc)
[PROOF STATE]
proof (state)
this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?H * d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> ?H * (d * ?H)\<^sup>\<star> * ?e"
[PROOF STATE]
proof (prove)
using this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
goal (1 subgoal):
1. forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
[PROOF STEP]
by (metis assms(8) forest_components_star star.circ_decompose_9)
[PROOF STATE]
proof (state)
this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?H * d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
goal (1 subgoal):
1. forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
using star_slide
[PROOF STATE]
proof (prove)
using this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> forest_components h * (d * forest_components h)\<^sup>\<star> * selected_edge h j g
(?x * ?y)\<^sup>\<star> * ?x = ?x * (?y * ?x)\<^sup>\<star>
goal (1 subgoal):
1. forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?H * d * (?H * d)\<^sup>\<star> * ?H * ?e \<squnion> ?H * d\<^sup>T * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (forest_components h * d)\<^sup>+ * forest_components h * selected_edge h j g \<squnion> forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (smt le_supI star.circ_loop_fixpoint sup.cobounded2 sup_commute mult_assoc)
[PROOF STATE]
proof (state)
this:
(forest_components h * d)\<^sup>+ * forest_components h * selected_edge h j g \<squnion> forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "(?H * (d \<squnion> d\<^sup>T)) * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(forest_components h * d)\<^sup>+ * forest_components h * selected_edge h j g \<squnion> forest_components h * d\<^sup>T * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_components h * (d \<squnion> d\<^sup>T) * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (simp add: semiring.distrib_left semiring.distrib_right)
[PROOF STATE]
proof (state)
this:
forest_components h * (d \<squnion> d\<^sup>T) * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "(?H * (d \<squnion> d\<^sup>T))\<^sup>\<star> * (?H * d)\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
forest_components h * (d \<squnion> d\<^sup>T) * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (simp add: star_left_induct_mult mult_assoc)
[PROOF STATE]
proof (state)
this:
(forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence 252: "(?H * (d \<squnion> d\<^sup>T))\<^sup>\<star> * ?H * ?e \<le> (?H * d)\<^sup>\<star> * ?H * ?e"
[PROOF STATE]
proof (prove)
using this:
(forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
[PROOF STEP]
by (smt mult_left_dist_sup star.circ_transitive_equal star_slide star_sup_1 mult_assoc)
[PROOF STATE]
proof (state)
this:
(forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "?i \<le> top * ?e\<^sup>T * ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * forest_components f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * forest_components f
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?i\<^sup>T \<le> ?F\<^sup>T * ?e\<^sup>T\<^sup>T * top\<^sup>T"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> top * selected_edge h j g\<^sup>T * forest_components f
goal (1 subgoal):
1. ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T
[PROOF STEP]
by (simp add: conv_dist_comp conv_dist_inf mult_assoc)
[PROOF STATE]
proof (state)
this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
hence "?i\<^sup>T * top \<le> ?F\<^sup>T * ?e\<^sup>T\<^sup>T * top\<^sup>T * top"
[PROOF STATE]
proof (prove)
using this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T
goal (1 subgoal):
1. ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T * top
[PROOF STEP]
using comp_isotone
[PROOF STATE]
proof (prove)
using this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T
\<lbrakk>?x \<le> ?y; ?w \<le> ?z\<rbrakk> \<Longrightarrow> ?x * ?w \<le> ?y * ?z
goal (1 subgoal):
1. ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T * top
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... = ?F\<^sup>T * ?e\<^sup>T\<^sup>T * top\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vector ((forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T)
[PROOF STEP]
by (simp add: vector_mult_closed)
[PROOF STATE]
proof (state)
this:
vector ((forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T)
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vector ((forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T)
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... = ?F * ?e\<^sup>T\<^sup>T * top\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T = forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
[PROOF STEP]
by (simp add: conv_dist_comp conv_star_commute)
[PROOF STATE]
proof (state)
this:
(forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T = forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(forest_components f[[selected_edge h j g\<^sup>T\<^sup>T]]) * top\<^sup>T = forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... = ?F * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * selected_edge h j g * top
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g\<^sup>T\<^sup>T * top\<^sup>T = forest_components f * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... = (?H * (d \<squnion> d\<^sup>T))\<^sup>\<star> * ?H * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components f * selected_edge h j g * top = (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
using assms(2, 8, 12) F_is_H_and_d
[PROOF STATE]
proof (prove)
using this:
forest f
forest h
f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
\<lbrakk>?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T; injective ?f; injective ?h\<rbrakk> \<Longrightarrow> forest_components ?f = (forest_components ?h * (?d \<squnion> ?d\<^sup>T))\<^sup>\<star> * forest_components ?h
goal (1 subgoal):
1. forest_components f * selected_edge h j g * top = (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g * top = (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
forest_components f * selected_edge h j g * top = (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> (?H * d)\<^sup>\<star> * ?H * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
by (simp add: 252 comp_isotone)
[PROOF STATE]
proof (state)
this:
(forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(forest_components h * (d \<squnion> d\<^sup>T))\<^sup>\<star> * forest_components h * selected_edge h j g * top \<le> (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
have "... \<le> (?H * (d \<squnion> ?e))\<^sup>\<star> * ?H * ?e * top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g * top \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
by (simp add: comp_isotone star_isotone)
[PROOF STATE]
proof (state)
this:
(forest_components h * d)\<^sup>\<star> * forest_components h * selected_edge h j g * top \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
have "?i\<^sup>T * top \<le> (?H * (d \<squnion> ?e))\<^sup>\<star> * ?H * ?e * top"
[PROOF STATE]
proof (prove)
using this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
using 212 assms(16) forest_modulo_equivalence_path_def minarc_arc minarc_bot_iff
[PROOF STATE]
proof (prove)
using this:
((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]] \<le> (forest_components h * (d \<squnion> selected_edge h j g))\<^sup>\<star> * forest_components h * selected_edge h j g * top
bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) * top) \<and> bijective (((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)[[top]])
selected_edge h j g \<noteq> bot
forest_modulo_equivalence_path ?a ?b ?H ?d \<equiv> (bijective (?a * top) \<and> bijective (?a[[top]])) \<and> (bijective (?b * top) \<and> bijective (?b[[top]])) \<and> ?a[[top]] \<le> (?H * ?d)\<^sup>\<star> * ?H * ?b * top
?x \<noteq> bot \<longrightarrow> bijective (minarc ?x * top) \<and> bijective (minarc ?x[[top]])
(minarc ?x = bot) = (?x = bot)
goal (1 subgoal):
1. forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
forest_modulo_equivalence_path ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) (selected_edge h j g) (forest_components h) (d \<squnion> selected_edge h j g)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
2. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
2. regular h
[PROOF STEP]
show "?i \<le> - ?H \<sqinter> -- g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
have "forest_components h \<le> forest_components f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. forest_components h \<le> forest_components f
[PROOF STEP]
using assms(2, 8, 12) H_below_F
[PROOF STATE]
proof (prove)
using this:
forest f
forest h
f \<squnion> f\<^sup>T = h \<squnion> h\<^sup>T \<squnion> d \<squnion> d\<^sup>T
\<lbrakk>?f \<squnion> ?f\<^sup>T = ?h \<squnion> ?h\<^sup>T \<squnion> ?d \<squnion> ?d\<^sup>T; injective ?f; injective ?h\<rbrakk> \<Longrightarrow> forest_components ?h \<le> forest_components ?f
goal (1 subgoal):
1. forest_components h \<le> forest_components f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
forest_components h \<le> forest_components f
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
forest_components h \<le> forest_components f
[PROOF STEP]
have 241: "?i \<le> -?H"
[PROOF STATE]
proof (prove)
using this:
forest_components h \<le> forest_components f
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h
[PROOF STEP]
using 16 assms(9) inf.order_lesseq_imp p_antitone_iff
[PROOF STATE]
proof (prove)
using this:
forest_components h \<le> forest_components f
forest_components f \<le> - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
forest_modulo_equivalence (forest_components h) d
(\<forall>z\<le>?x. z \<le> ?y) = (?x \<le> ?y)
(?x \<le> - ?y) = (?y \<le> - ?x)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
have "?i \<le> -- g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - - g
[PROOF STEP]
using 10 inf.coboundedI1 spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) g
?a \<le> ?c \<Longrightarrow> ?a \<sqinter> ?b \<le> ?c
spanning_forest ?f ?g \<equiv> forest ?f \<and> ?f \<le> - - ?g \<and> components ?g \<le> forest_components ?f \<and> regular ?f
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - - g
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - - g
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
using 241 inf_greatest
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - - g
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h
\<lbrakk>?x \<le> ?y; ?x \<le> ?z\<rbrakk> \<Longrightarrow> ?x \<le> ?y \<sqinter> ?z
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<le> - forest_components h - - g
goal (1 subgoal):
1. regular h
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. regular h
[PROOF STEP]
show "regular h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. regular h
[PROOF STEP]
using assms(18)
[PROOF STATE]
proof (prove)
using this:
regular h
goal (1 subgoal):
1. regular h
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
regular h
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "?v \<sqinter> ?e \<sqinter> -?i = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f = bot
[PROOF STEP]
using 14
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g = bot
goal (1 subgoal):
1. (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f = bot
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f = bot
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
hence "sum (?w \<sqinter> g) = sum (?v \<sqinter> -?i \<sqinter> g) + sum (?e \<sqinter> g)"
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f = bot
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g)
[PROOF STEP]
using sum_disjoint inf_commute inf_assoc
[PROOF STATE]
proof (prove)
using this:
(w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> selected_edge h j g - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f = bot
?x \<sqinter> ?y = bot \<Longrightarrow> sum_class.sum ((?x \<squnion> ?y) \<sqinter> ?z) = sum_class.sum (?x \<sqinter> ?z) + sum_class.sum (?y \<sqinter> ?z)
?x \<sqinter> ?y = ?y \<sqinter> ?x
?x \<sqinter> ?y \<sqinter> ?z = ?x \<sqinter> (?y \<sqinter> ?z)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "... \<le> sum (?v \<sqinter> -?i \<sqinter> g) + sum (?i \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
[PROOF STEP]
using 224 225 sum_plus_right_isotone
[PROOF STATE]
proof (prove)
using this:
selected_edge h j g \<sqinter> g \<noteq> bot
sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
?x \<noteq> bot \<and> sum_class.sum ?x \<le> sum_class.sum ?y \<longrightarrow> sum_class.sum ?z + sum_class.sum ?x \<le> sum_class.sum ?z + sum_class.sum ?y
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum (selected_edge h j g \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "... = sum (((?v \<sqinter> -?i) \<squnion> ?i) \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
[PROOF STEP]
using sum_disjoint inf_le2 pseudo_complement
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> ?y = bot \<Longrightarrow> sum_class.sum ((?x \<squnion> ?y) \<sqinter> ?z) = sum_class.sum (?x \<sqinter> ?z) + sum_class.sum (?y \<sqinter> ?z)
?x \<sqinter> ?y \<le> ?y
(?x \<sqinter> ?y = bot) = (?x \<le> - ?y)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) + sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "... = sum ((?v \<squnion> ?i) \<sqinter> (-?i \<squnion> ?i) \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
[PROOF STEP]
by (simp add: sup_inf_distrib2)
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "... = sum ((?v \<squnion> ?i) \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
[PROOF STEP]
using 15
[PROOF STATE]
proof (prove)
using this:
regular ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
[PROOF STEP]
by (metis inf_top_right stone)
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> (- ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
have "... = sum (?v \<sqinter> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
[PROOF STEP]
by (simp add: inf.sup_monoid.add_assoc)
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f) \<sqinter> g) = sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
[PROOF STEP]
have "sum (?w \<sqinter> g) \<le> sum (?v \<sqinter> g)"
[PROOF STATE]
proof (prove)
using this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
goal (1 subgoal):
1. sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
thus "\<forall>u . spanning_forest u g \<longrightarrow> sum (?w \<sqinter> g) \<le> sum (u \<sqinter> g)"
[PROOF STATE]
proof (prove)
using this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
using 2 11 minimum_spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g)
minimum_spanning_forest w g \<and> f \<le> w \<squnion> w\<^sup>T
sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> g) = sum_class.sum (w \<sqinter> g)
minimum_spanning_forest ?f ?g \<equiv> spanning_forest ?f ?g \<and> (\<forall>u. spanning_forest u ?g \<longrightarrow> sum_class.sum (?f \<sqinter> ?g) \<le> sum_class.sum (u \<sqinter> ?g))
goal (1 subgoal):
1. \<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>u. spanning_forest u g \<longrightarrow> sum_class.sum ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) \<sqinter> g) \<le> sum_class.sum (u \<sqinter> g)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "?f \<le> f \<squnion> f\<^sup>T \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> f \<squnion> f\<^sup>T \<squnion> selected_edge h j g
[PROOF STEP]
by (smt conv_dist_inf inf_le1 sup_left_isotone sup_mono inf.order_lesseq_imp)
[PROOF STATE]
proof (state)
this:
f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> f \<squnion> f\<^sup>T \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> f \<squnion> f\<^sup>T \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "... \<le> (?v \<sqinter> -?i \<sqinter> -?i\<^sup>T) \<squnion> (?v\<^sup>T \<sqinter> -?i \<sqinter> -?i\<^sup>T) \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
[PROOF STEP]
using 20 sup_left_isotone
[PROOF STATE]
proof (prove)
using this:
f \<squnion> f\<^sup>T \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
?x \<le> ?y \<Longrightarrow> ?x \<squnion> ?z \<le> ?y \<squnion> ?z
goal (1 subgoal):
1. f \<squnion> f\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f \<squnion> f\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f \<squnion> f\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "... \<le> (?v \<sqinter> -?i) \<squnion> (?v\<^sup>T \<sqinter> -?i \<sqinter> -?i\<^sup>T) \<squnion> ?e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
[PROOF STEP]
by (metis inf.cobounded1 sup_inf_distrib2)
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "... = ?w \<squnion> (?v\<^sup>T \<sqinter> -?i \<sqinter> -?i\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g = w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
by (simp add: sup_assoc sup_commute)
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g = w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<squnion> selected_edge h j g = w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "... \<le> ?w \<squnion> (?v\<^sup>T \<sqinter> -?i\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
using inf.sup_right_isotone inf_assoc sup_right_isotone
[PROOF STATE]
proof (prove)
using this:
?y \<le> ?x \<Longrightarrow> ?z \<sqinter> ?y \<le> ?z \<sqinter> ?x
?x \<sqinter> ?y \<sqinter> ?z = ?x \<sqinter> (?y \<sqinter> ?z)
?x \<le> ?y \<Longrightarrow> ?z \<squnion> ?x \<le> ?z \<squnion> ?y
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T)
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
have "... \<le> ?w \<squnion> ?w\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
using conv_complement conv_dist_inf conv_dist_sup sup_right_isotone
[PROOF STATE]
proof (prove)
using this:
(- ?x)\<^sup>T = - ?x\<^sup>T
(?x \<sqinter> ?y)\<^sup>T = ?x\<^sup>T \<sqinter> ?y\<^sup>T
(?x \<squnion> ?y)\<^sup>T = ?x\<^sup>T \<squnion> ?y\<^sup>T
?x \<le> ?y \<Longrightarrow> ?z \<squnion> ?x \<le> ?z \<squnion> ?y
goal (1 subgoal):
1. w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T)\<^sup>T - ((w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f)\<^sup>T) \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
show "?f \<le> ?w \<squnion> ?w\<^sup>T"
[PROOF STATE]
proof (prove)
using this:
f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g) g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g \<squnion> (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T - (w - top * selected_edge h j g * w\<^sup>T\<^sup>\<star> \<squnion> (w \<sqinter> top * selected_edge h j g * w\<^sup>T\<^sup>\<star>)\<^sup>T) \<sqinter> - forest_components f * selected_edge h j g * top \<sqinter> top * selected_edge h j g\<^sup>T * forest_components f \<squnion> selected_edge h j g)\<^sup>T
goal (1 subgoal):
1. \<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>w. minimum_spanning_forest w g \<and> f - selected_edge h j g\<^sup>T - path f h j g \<squnion> ((f - selected_edge h j g\<^sup>T) \<sqinter> path f h j g)\<^sup>T \<squnion> selected_edge h j g \<le> w \<squnion> w\<^sup>T
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 286295, "file": "Relational_Minimum_Spanning_Trees_Boruvka", "length": 788}
|
import pandas as pd
import numpy as np
import os
import streamlit as st
import streamlit.components.v1 as components
_RELEASE = False
if not _RELEASE:
_attribution_heatmap_table = components.declare_component(
"attribution_heatmap_table", url="http://localhost:3001",
)
else:
parent_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(parent_dir, "frontend/build")
_attribution_heatmap_table = components.declare_component("attribution_heatmap_table", path=build_dir)
def attribution_heatmap_table(data, fmt_data, key=None):
return _attribution_heatmap_table(data=data, fmt_data=fmt_data, default=[], key=key)
if not _RELEASE:
scores = [0.26, 0.77, 0.82, 0.29, 0.53]
attributions = {
"Age": [-0.26, 0.29, -0.82, 0.77, 0.53],
"Duration": [0.26, 0.82, 0.82, -0.25, -0.53],
"Credit Amount": [-0.26, -0.77, 0.77, -0.29, 0.53],
"Score": scores,
}
df_attr = pd.DataFrame(attributions)
features = {
"Age": [32, 45, 40, 24, 50],
"Duration": [20, 30, 31, 15, 19],
"Credit Amount": [1000, 2000, 1500, 500, 800],
"Score": scores,
}
df_features = pd.DataFrame(features)
# send both data frames to frontend
rows = attribution_heatmap_table(data=df_features, fmt_data=df_attr)
if rows:
st.write("You have selected", rows)
|
{"hexsha": "d257175c7fe5a9e52efec72ebe3e9ddd244a20ae", "size": 1383, "ext": "py", "lang": "Python", "max_stars_repo_path": "attribution-heatmap-table/AttributionHeatmapTable/__init__.py", "max_stars_repo_name": "youozhan/component-template", "max_stars_repo_head_hexsha": "e50d272c4b3419934ed9299c8d3ef36ecfa4b138", "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": "attribution-heatmap-table/AttributionHeatmapTable/__init__.py", "max_issues_repo_name": "youozhan/component-template", "max_issues_repo_head_hexsha": "e50d272c4b3419934ed9299c8d3ef36ecfa4b138", "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": "attribution-heatmap-table/AttributionHeatmapTable/__init__.py", "max_forks_repo_name": "youozhan/component-template", "max_forks_repo_head_hexsha": "e50d272c4b3419934ed9299c8d3ef36ecfa4b138", "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": 30.0652173913, "max_line_length": 106, "alphanum_fraction": 0.6522053507, "include": true, "reason": "import numpy", "num_tokens": 421}
|
# Autogenerated wrapper script for Conduit_jll for x86_64-w64-mingw32-cxx11
export libconduit, libconduit_blueprint, libconduit_relay
JLLWrappers.@generate_wrapper_header("Conduit")
JLLWrappers.@declare_library_product(libconduit, "libconduit.dll")
JLLWrappers.@declare_library_product(libconduit_blueprint, "libconduit_blueprint.dll")
JLLWrappers.@declare_library_product(libconduit_relay, "libconduit_relay.dll")
function __init__()
JLLWrappers.@generate_init_header()
JLLWrappers.@init_library_product(
libconduit,
"bin\\libconduit.dll",
RTLD_LAZY | RTLD_DEEPBIND,
)
JLLWrappers.@init_library_product(
libconduit_blueprint,
"bin\\libconduit_blueprint.dll",
RTLD_LAZY | RTLD_DEEPBIND,
)
JLLWrappers.@init_library_product(
libconduit_relay,
"bin\\libconduit_relay.dll",
RTLD_LAZY | RTLD_DEEPBIND,
)
JLLWrappers.@generate_init_footer()
end # __init__()
|
{"hexsha": "c63adf7d304107148f1e611ed78b051b53918989", "size": 962, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/wrappers/x86_64-w64-mingw32-cxx11.jl", "max_stars_repo_name": "JuliaBinaryWrappers/Conduit_jll.jl", "max_stars_repo_head_hexsha": "a3e4cdf579ae4de463a521fe31c45af4635be643", "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/wrappers/x86_64-w64-mingw32-cxx11.jl", "max_issues_repo_name": "JuliaBinaryWrappers/Conduit_jll.jl", "max_issues_repo_head_hexsha": "a3e4cdf579ae4de463a521fe31c45af4635be643", "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/wrappers/x86_64-w64-mingw32-cxx11.jl", "max_forks_repo_name": "JuliaBinaryWrappers/Conduit_jll.jl", "max_forks_repo_head_hexsha": "a3e4cdf579ae4de463a521fe31c45af4635be643", "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": 32.0666666667, "max_line_length": 86, "alphanum_fraction": 0.7463617464, "num_tokens": 263}
|
import torch
from network import PPOACNet
from components import get_ppo_ac_cfg_defaults, Task, Storage, tensor, to_np, random_sample
import numpy as np
hyper_parameter = get_ppo_ac_cfg_defaults().HYPER_PARAMETER.clone()
train_parameter = get_ppo_ac_cfg_defaults().TRAIN_PARAMETER.clone()
class PPOACAgent(torch.nn.Module):
def __init__(self, env_path):
super(PPOACAgent, self).__init__()
self.policy = PPOACNet()
self.task = Task('Reacher', 20, env_path)
self.states = self.task.reset().vector_observations
self.rollout_length = hyper_parameter.ROLLOUT_LENGTH
self.online_rewards = np.zeros(hyper_parameter.AGENTS_NUM)
self.episode_rewards = []
self.total_steps = 0
# self.optimizer = torch.optim.RMSprop(self.policy.total_params, lr=0.0007)
self.optimizer = torch.optim.Adam(self.policy.total_params, lr=1e-4, eps=1e-5)
def step(self):
storage = Storage(self.rollout_length)
states = self.states
for _ in range(self.rollout_length):
prediction = self.policy(states)
next_states, rewards, terminals = self.task.step(to_np(prediction['a']))
self.online_rewards += rewards
for i, terminal in enumerate(terminals):
if terminal:
self.episode_rewards.append(self.online_rewards[i])
self.online_rewards[i] = 0
storage.add(prediction)
storage.add({'r': tensor(rewards).unsqueeze(-1),
'm': tensor(1 - terminals).unsqueeze(-1),
's': tensor(states)})
states = next_states
self.states = states
prediction = self.policy(states)
storage.add(prediction)
storage.placeholder()
returns = prediction['v'].detach()
advantages = tensor(np.zeros((hyper_parameter.AGENTS_NUM, 1)))
for i in reversed(range(self.rollout_length)):
returns = storage.r[i] + hyper_parameter.GAMMA * storage.m[i] * returns
if not hyper_parameter.USE_GAE:
advantages = returns - storage.v[i].detach()
else:
td_error = storage.r[i] + hyper_parameter.GAMMA * storage.m[i] * storage.v[i + 1] - storage.v[i]
advantages = advantages * hyper_parameter.GAE_TAU * hyper_parameter.GAMMA * storage.m[i] + td_error
storage.adv[i] = advantages.detach()
storage.ret[i] = returns.detach()
# log_prob, value, returns, advantages, entropy = storage.cat(['log_pi_a', 'v', 'ret', 'adv', 'ent'])
states, actions, log_probs_old, returns, advantages = storage.cat(['s', 'a', 'log_pi_a', 'ret', 'adv'])
actions = actions.detach()
log_probs_old = log_probs_old.detach()
advantages = (advantages - advantages.mean()) / advantages.std()
for _ in range(hyper_parameter.SURROGATE):
sampler = random_sample(np.arange(states.size(0)), hyper_parameter.BATCHSIZE)
for batch_indices in sampler:
batch_indices = tensor(batch_indices).long()
sampled_states = states[batch_indices]
sampled_actions = actions[batch_indices]
sampled_log_probs_old = log_probs_old[batch_indices]
sampled_returns = returns[batch_indices]
sampled_advantages = advantages[batch_indices]
prediction = self.policy(sampled_states, sampled_actions)
ratio = (prediction['log_pi_a'] - sampled_log_probs_old).exp()
obj = ratio * sampled_advantages
obj_clipped = ratio.clamp(1.0 - hyper_parameter.CLIP_VAL,
1.0 + hyper_parameter.CLIP_VAL) * sampled_advantages
policy_loss = -torch.min(obj, obj_clipped).mean() - hyper_parameter.entropy_weight * prediction['ent'].mean()
value_loss = 0.5 * (sampled_returns - prediction['v']).pow(2).mean()
self.optimizer.zero_grad()
(policy_loss + value_loss).backward()
torch.nn.utils.clip_grad_norm_(self.policy.total_params, train_parameter.Gradient_Clip)
self.optimizer.step()
steps = self.rollout_length * hyper_parameter.AGENTS_NUM
self.total_steps += steps
def save(self, filename):
torch.save(self.policy.state_dict(), filename)
def close(self):
self.task.close()
|
{"hexsha": "f1d7baf1ed284b7b3b628dae40d955bbd7aa3dd3", "size": 4486, "ext": "py", "lang": "Python", "max_stars_repo_path": "agent/PPO_AC_Agent.py", "max_stars_repo_name": "auroua/Udacity_Continuous_Control", "max_stars_repo_head_hexsha": "fcc21f8682b745f55c2900616eac632f430ab828", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-24T13:33:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-24T13:33:52.000Z", "max_issues_repo_path": "agent/PPO_AC_Agent.py", "max_issues_repo_name": "auroua/Udacity_Continuous_Control", "max_issues_repo_head_hexsha": "fcc21f8682b745f55c2900616eac632f430ab828", "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/PPO_AC_Agent.py", "max_forks_repo_name": "auroua/Udacity_Continuous_Control", "max_forks_repo_head_hexsha": "fcc21f8682b745f55c2900616eac632f430ab828", "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": 46.7291666667, "max_line_length": 125, "alphanum_fraction": 0.6221578243, "include": true, "reason": "import numpy", "num_tokens": 957}
|
import unittest
import numpy as np
from iv_jett import iv_init
class TestBetas(unittest.TestCase):
def test_square_instruments(self):
z = np.random.rand(255, 5)
x = np.random.rand(255, 5)
y = np.random.rand(255, 5)
betas = np.linalg.inv(np.transpose(z) @ x) @ np.transpose(z) @ y
x2 = iv_init.estimate_beta_iv(x, z, y, nocons = True)
self.assertIsNone(np.testing.assert_allclose(betas, x2))
def test_large_data(self):
z = np.random.rand(10^8, 2)
x = np.random.rand(10^8, 2)
y = np.random.rand(10^8, 2)
betas = np.linalg.inv(np.transpose(z) @ x) @ np.transpose(z) @ y
x2 = iv_init.estimate_beta_iv(x, z, y, nocons = True)
self.assertIsNone(np.testing.assert_allclose(betas, x2))
if __name__ == "__main__":
unittest.main()
|
{"hexsha": "a7810057af82505f1043c8d0837a2e7f6753ff31", "size": 836, "ext": "py", "lang": "Python", "max_stars_repo_path": "Projects/project_2_packages/iv_jett/test/test_estimates.py", "max_stars_repo_name": "jettpettus/modularizationandtesting", "max_stars_repo_head_hexsha": "16f5e463196f6ab086c9f5b7ecd953f67336bcae", "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": "Projects/project_2_packages/iv_jett/test/test_estimates.py", "max_issues_repo_name": "jettpettus/modularizationandtesting", "max_issues_repo_head_hexsha": "16f5e463196f6ab086c9f5b7ecd953f67336bcae", "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": "Projects/project_2_packages/iv_jett/test/test_estimates.py", "max_forks_repo_name": "jettpettus/modularizationandtesting", "max_forks_repo_head_hexsha": "16f5e463196f6ab086c9f5b7ecd953f67336bcae", "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.8571428571, "max_line_length": 72, "alphanum_fraction": 0.6232057416, "include": true, "reason": "import numpy", "num_tokens": 244}
|
from .header import Header
import astropy.io.fits as pyfits
import numpy
from scipy import ndimage
from scipy import __version__ as scipyversion
from scipy.interpolate import interp1d
class Data(Header):
"""A class which contains the processes for handling spectral data which
is common for handling 1D, 2D and 3D spectra.
Parameters
----------
data : `numpy.ndarray`, optional
A 1D, 2D, or a 3D numpy array containing all the data. The elements
of a 1D array follows the wavelength elements. A 2D array should be
structured such that the different spectra or located along the
first dimension. For a 3D array, the different spectra are
distributed along the second and third dimension.
wave : `numpy.ndarray`, optional
The wavelength at each point of the `data` array.
error : `numpy.ndarray`, optional
The error spectrum, should be of the same shape as `data`.
If `error` equals None, it is assumed the error spectrum is not
known.
mask : `numpy.ndarray`, optional
A boolean array where True represents a masked (invalid) data point
and False a good data point. Should be of the same shape as `data`.
error_weight : `numpy.ndarray`, optional
Unused at the current moment?
normalization : `numpy.ndarray`, optional
An array which is used to normalize the data/error; both data and
error are divided by `normalization`. Should be of the same shape
as `data`.
inst_fwhm : float, optional
The instrumental FWHM in the same units as `wavelength`.
header : Header, optional
Contains information for reading and writing data to and from Fits
files.
"""
def __init__(self, data=None, wave=None, error=None, mask=None, error_weight=None, normalization=None, inst_fwhm=None,
header=None):
Header.__init__(self, header=header)
self._data = data
if data is not None:
self._dim = data.shape
if len(data.shape) == 3:
self._datatype = "CUBE"
self._res_elements = data.shape[0]
self._dim_y = data.shape[1]
self._dim_x = data.shape[2]
elif len(data.shape) == 2:
self._datatype = "RSS"
self._res_elements = data.shape[1]
self._fibers = data.shape[0]
elif len(data.shape) == 1:
self._datatype = "Spectrum1D"
self._pixels = numpy.arange(self._dim[0])
self._wave = wave
self._error = error
self._error_weight = error_weight
self._mask = mask
self._normalization = normalization
self._inst_fwhm = inst_fwhm
def getWave(self):
"""Obtain the wavelength grid as a 1D numpy array."""
return self._wave
def getWaveStep(self):
"""Obtain the step in the wavelength grid, assumption is that the
wavelength grid is linear."""
return numpy.min(self._wave[1:] - self._wave[:-1])
def getShape(self):
"""Obtain the shape of the data."""
return self._dim
def getData(self):
"""Obtain the data as a numpy array."""
return self._data
def setData(self, data):
"""Set the data by providing a numpy array. The array should
be matching the shape of the wavelength grid along the corresponding
axis for Spectrum1D, RSS and Cube data."""
self._data = data
def getError(self):
"""Obtain the error associated to the data as a numpy array."""
return self._error
def setError(self, error):
"""Set the error by providing a numpy array. The array should be of the
same shape as the data."""
self._error = error
def getMask(self):
"""Obtain the mask as a numpy array."""
return self._mask
def setMask(self, mask):
"""Set the mask by providing a numpy array. The mask should be of
the same shape as the data."""
self._mask = mask
def getFWHM(self):
"""Obtain the FWHM of the data, provided in the same units as the
wavelength grid."""
return self._inst_fwhm
def setFWHM(self, FWHM):
"""Set the value of the FWHM of the data."""
self._inst_fwhm = FWHM
def getNormalization(self):
"""Obtain the normalization of the spectrum as a numpy array."""
return self._normalization
def setNormalization(self, normalization):
"""Set the normalization of the spectrum by providing a numpy array.
The array should be of the same shape as the data."""
self._normalization = normalization
def correctError(self, replace_error=1e10):
"""Corrects any negative value in `error` to `replace_error`."""
if self._error is not None:
select = (self._error <= 0.0)
if self._mask is not None:
self._mask[select] = True
self._error[select] = replace_error
def subWaveMask(self, select_wave):
"""Obtain a copy of Spectrum1D within a certain wavelength range by
supplying an index array for obtaining the wanted wavelengths.
Parameters
----------
select_wave : numpy.ndarray
A 1D boolean array where the True value represents which elements
in the `wave`, `data`, `error`, `mask` and `normalization`
Returns
-------
spec : Spectrum1D
A new `Spectrum1D` instance containing only the elements
according to `select_wave`.
"""
[new_error, new_mask, new_fwhm, new_normalization] = [None, None, None, None]
new_wave = self._wave[select_wave]
if self._datatype == "Spectrum1D":
slicer = numpy.s_[select_wave]
elif self._datatype == "RSS":
slicer = numpy.s_[:, select_wave]
elif self._datatype == "CUBE":
slicer = numpy.s_[select_wave, :, :]
new_data = self._data[slicer]
if self._inst_fwhm is not None:
new_fwhm = self._inst_fwhm[slicer]
if self._error is not None:
new_error = self._error[slicer]
if self._mask is not None:
new_mask = self._mask[slicer]
if self.getNormalization() is not None:
new_normalization = self._normalization[slicer]
data_out = Data(wave=new_wave, data=new_data, error=new_error, mask=new_mask,
normalization=new_normalization, inst_fwhm=new_fwhm)
data_out.__class__ = self.__class__
return data_out
def subWaveLimits(self, wave_start=None, wave_end=None):
"""Obtain a copy of Spectrum1D within a certain wavelength range.
Parameters
----------
wave_start : float, optional
The lower limit for the output `Data`.
wave_end : float, optional
The upper limit for the output `Data`.
Returns
-------
data_out : `Data`
The output object where the wavelength cut is applied to.
"""
select = numpy.ones(len(self.getWave()), dtype='bool')
if wave_start is not None:
select[self.getWave() < wave_start] = False
if wave_end is not None:
select[self.getWave() > wave_end] = False
data_out = self.subWaveMask(select)
return data_out
def normalizeSpec(self, pixel_width, mask_norm=None):
"""Normalize the spectrum by applying a running mean filter to the data.
Parameters
----------
pixel_width : int
The length of the running mean filter window.
mask_norm : numpy.ndarray
The 1D boolean numpy array which is added to the mask which is
already in place for the normalization process.
Returns
-------
data_out : `Data`
A new instance where the normalization is applied to.
"""
temp_data = numpy.array(self._data)
axis = 0 if self._datatype == 'CUBE' else -1
if mask_norm is not None:
indices = numpy.indices(self.getWave().shape)[0]
mask_idx = indices[~mask_norm]
if self._datatype == 'RSS':
slicer = numpy.s_[:, ~mask_norm]
left = self._data[:, mask_idx[0]].flatten()
right = self._data[:, mask_idx[-1]].flatten()
elif self._datatype == 'CUBE':
slicer = numpy.s_[~mask_norm, :, :]
left = self._data[mask_idx[0], :, :].flatten()
right = self._data[mask_idx[-1], :, :].flatten()
elif self._datatype == 'Spectrum1D':
slicer = numpy.s_[~mask_norm]
left = self._data[mask_idx[0]]
right = self._data[mask_idx[-1]]
if pixel_width == 0:
temp_data /= numpy.mean(self._data[slicer], axis=axis)
else:
if mask_norm is not None:
if scipyversion < "0.17":
edges = numpy.r_[left * numpy.ones((mask_idx[0] - indices[0], 1)),
right * numpy.ones((indices[-1] - mask_idx[-1], 1))]
if edges.size == 0:
edges = numpy.nan
interp = interp1d(mask_idx, self._data[slicer], axis=axis, bounds_error=False, fill_value=edges)
else:
interp = interp1d(mask_idx, self._data[slicer], axis=axis, bounds_error=False,
fill_value='extrapolate')
temp_data = interp(indices)
mean = ndimage.filters.convolve1d(temp_data, numpy.ones(pixel_width) / pixel_width, axis=axis,
mode='nearest')
select_zero = mean == 0
mean[select_zero] = 1
new_data = self._data / mean
new_error = self._error / numpy.fabs(mean) if self._error is not None else None
data_out = Data(wave=self._wave, data=new_data, error=new_error, mask=self._mask, normalization=mean,
inst_fwhm=self._inst_fwhm)
data_out.__class__ = self.__class__
return data_out
def unnormalizedSpec(self):
"""Remove the normalization from the spectrum.
Returns
-------
data_out : `Data`
A new instance where the normalization is removed from.
"""
data = self._data * self._normalization
if self._error is not None:
error = self._error * numpy.fabs(self._normalization)
else:
error = None
data_out = Data(wave=self._wave, data=data, error=error, mask=self._mask, normalization=None,
inst_fwhm=self._inst_fwhm)
data_out.__class__ = self.__class__
return data_out
def applyNormalization(self, normalization):
"""Apply the normalization to the data and the errors."""
if self._normalization is None:
self._data = self._data / normalization
if self._error is not None:
self._error = self._error / numpy.fabs(normalization)
def setVelSampling(self, vel_sampling):
"""Change the velocity sampling of the spectra (float, km/s)."""
self._vel_sampling = vel_sampling
def getVelSampling(self):
"""Obtain the velocity sampling of the spectra in km/s."""
return self._vel_sampling
def loadFitsData(self, filename, extension_data=None, extension_mask=None, extension_error=None,
extension_errorweight=None, extension_hdr=0):
"""
Load data from a FITS image into a Data object
Parameters
--------------
filename : string
Name or Path of the FITS image from which the data shall be loaded
extension_data : int or string, optional with default: None
Number or name of the FITS extension containing the data
extension_mask : int or string, optional with default: None
Number or name of the FITS extension containing the masked pixels
extension_error : int or string, optional with default: None
Number or string of the FITS extension containing the errors for the values
extension_errorweight : int or string, optional with default: None
Number or string of the FITS extension containing the errorweights that are only present in data
consisting of oversampled spatial information.
extension_hdr : int or string, optional with default: None
Number or name of the FITS extension containing the fits header to be used for the cube information like
wavelength or WCS system.
"""
hdu = pyfits.open(filename)
self._dim = None
if extension_data is None and extension_mask is None and extension_error is None and \
extension_errorweight is None:
if hdu[0].data is not None:
self._data = hdu[0].data
self._dim = self._data.shape
self.setHeader(header=hdu[extension_hdr].header, origin=filename)
try:
self.getHdrValue('ARRAY1')
for i in range(self._dim[0]):
try:
array = self.getHdrValue('ARRAY%d' % (i + 1)).replace(' ', '')
if array == 'SPECTRUM' or array == 'DATA':
self._data = hdu[0].data[i, :]
self._dim = self._data.shape
elif array == 'ERROR':
self._error = hdu[0].data[i, :]
elif array == 'WAVE':
self._wave = hdu[0].data[i, :]
elif array == 'MASK':
self._mask = (hdu[0].data[i, :] >= 1.0)
except KeyError:
pass
if self._wave is None:
try:
wave = (numpy.arange(self._dim[0]) - (self.getHdrValue('CRPIX1') - 1)) * \
self.getHdrValue('CD1_1') + self.getHdrValue('CRVAL1')
except KeyError:
wave = (numpy.arange(self._dim[0]) - (self.getHdrValue('CRPIX1') - 1)) * \
self.getHdrValue('CDELT1') + self.getHdrValue('CRVAL1')
else:
pass
DC_flag = self.getHdrValue('DC-FLAG')
if int(DC_flag) == 1:
self._wave = 10**wave
else:
self._wave = wave
except KeyError:
if len(hdu) > 1:
for i in range(1, len(hdu)):
if hdu[i].header['EXTNAME'].split()[0] == 'ERROR':
self._error = hdu[i].data
elif hdu[i].header['EXTNAME'].split()[0] == 'WAVE':
self._wave = hdu[i].data
elif hdu[i].header['EXTNAME'].split()[0] == 'BADPIX':
self._mask = hdu[i].data.astype('bool')
elif not hdu[1].is_image:
tab = hdu[1].data
try:
self._wave = 10**tab['loglam']
except KeyError:
self._wave = tab['lambda']
try:
self._data = tab['flux']
except KeyError:
self._data = tab['data']
try:
self._error = numpy.sqrt(tab['ivar'])
except KeyError:
try:
self._error = tab['error']
except KeyError:
pass
try:
self._mask = tab['and_mask'] != 0
except KeyError:
try:
self._mask = tab['mask'] != 0
except KeyError:
pass
self._dim = self._data.shape
else:
self.setHeader(header=hdu[extension_hdr].header, origin=filename)
if extension_data is not None:
self._data = hdu[extension_data].data
self._dim = self._data.shape
if extension_mask is not None:
self._mask = hdu[extension_mask].data
self._dim = self._mask.shape
if extension_error is not None:
self._error = hdu[extension_error].data
self._dim = self._error.shape
if extension_error is not None:
self._error_weight = hdu[extension_errorweight].data
self._dim = self._error_weight.shape
hdu.close()
if self._dim is not None:
if len(self._dim) == 3:
self._datatype = "CUBE"
self._res_elements = self._dim[0]
self._dim_y = self._dim[1]
self._dim_x = self._dim[2]
if self._wave is None:
self._wave = numpy.arange(self._res_elements) * self.getHdrValue('CDELT3') + \
self.getHdrValue('CRVAL3')
elif len(self._dim) == 2:
self._datatype = "RSS"
self._res_elements = self._dim[1]
self._fibers = self._dim[0]
if self._wave is None:
self._wave = numpy.arange(self._res_elements) * self.getHdrValue('CDELT1') + \
self.getHdrValue('CRVAL1')
elif len(self._dim) == 1:
self._datatype = "Spectrum1D"
self._pixels = numpy.arange(self._dim[0])
self._res_elements = self._dim[0]
if self._wave is None:
self._wave = numpy.arange(self._res_elements) * self.getHdrValue('CDELT1') + \
self.getHdrValue('CRVAL1')
if extension_hdr is not None:
self.setHeader(hdu[extension_hdr].header, origin=filename)
def loadTxtData(self, filename):
file_in = open(filename)
lines = file_in.readlines()
wave = []
data = []
error = []
mask = []
for i in range(len(lines)):
if '#' not in lines[i][0]:
line = lines[i].split()
wave.append(float(line[0]))
data.append(float(line[1]))
try:
error.append(float(line[2]))
except IndexError:
error.append(1.0)
try:
mask.append(int(line[3]))
except IndexError:
mask.append(False)
self._data = numpy.array(data)
self._dim = self._data.shape
self._wave = numpy.array(wave)
if error is not []:
self._error = numpy.array(error)
if mask is not []:
self._mask = numpy.array(mask).astype('bool')
self._datatype = "Spectrum1D"
self._pixels = numpy.arange(self._dim[0])
self._res_elements = self._dim[0]
def writeFitsData(self, filename, extension_data=None, extension_mask=None, extension_error=None,
extension_errorweight=None, extension_normalization=None, store_wave=False):
"""
Save information of the Data object into a FITS file.
A single or multiple extension file are possible to create.
Parameters
--------------
filename : string
Name or Path of the FITS image from which the data shall be loaded
extension_data : int, optional with default: None
Number of the FITS extension containing the data
extension_mask : int, optional with default: None
Number of the FITS extension containing the masked pixels
extension_error : int, optional with default: None
Number of the FITS extension containing the errors for the values
"""
hdus = [None, None, None, None, None, None] # create empty list for hdu storage
# create primary hdus and image hdus
# data hdu
if extension_data is None and extension_error is None and extension_mask is None and \
extension_errorweight is None and extension_normalization is None:
hdus[0] = pyfits.PrimaryHDU(self._data)
if self._error is not None:
hdus[1] = pyfits.ImageHDU(self._error, name='ERROR')
if self._error_weight is not None:
hdus[2] = pyfits.ImageHDU(self._error_weight, name='ERRWEIGHT')
if self._mask is not None:
hdus[3] = pyfits.ImageHDU(self._mask.astype('uint8'), name='BADPIX')
if self._normalization is not None:
hdus[4] = pyfits.ImageHDU(self._normalization, name='NORMALIZE')
else:
if extension_data == 0:
hdus[0] = pyfits.PrimaryHDU(self._data)
elif extension_data > 0 and extension_data is not None:
hdus[extension_data] = pyfits.ImageHDU(self._data, name='DATA')
# mask hdu
if extension_mask == 0:
hdu = pyfits.PrimaryHDU(self._mask.astype('uint8'))
elif extension_mask > 0 and extension_mask is not None:
hdus[extension_mask] = pyfits.ImageHDU(self._mask.astype('uint8'), name='BADPIX')
# error hdu
if extension_error == 0:
hdu = pyfits.PrimaryHDU(self._error)
elif extension_error > 0 and extension_error is not None:
hdus[extension_error] = pyfits.ImageHDU(self._error, name='ERROR')
if extension_errorweight == 0:
hdu = pyfits.PrimaryHDU(self._error_weight)
elif extension_errorweight > 0 and extension_errorweight is not None:
hdus[extension_errorweight] = pyfits.ImageHDU(self._error_weight, name='ERRWEIGHT')
if extension_normalization == 0:
hdu = pyfits.PrimaryHDU(self._normalization)
elif extension_normalization > 0 and extension_normalization is not None:
hdus[extension_normalization] = pyfits.ImageHDU(self._normalization, name='NORMALIZE')
if store_wave:
hdus[-1] = pyfits.ImageHDU(self._wave, name='WAVE')
# remove not used hdus
for i in range(len(hdus)):
try:
hdus.remove(None)
except:
break
if len(hdus) > 0:
hdu = pyfits.HDUList(hdus) # create an HDUList object
if self._header is not None and not store_wave:
if self._wave is not None:
if self._datatype == 'CUBE':
self.setHdrValue('CRVAL3', self._wave[0])
self.setHdrValue('CDELT3', (self._wave[1] - self._wave[0]))
else:
self.setHdrValue('CRVAL1', self._wave[0])
self.setHdrValue('CDELT1', (self._wave[1] - self._wave[0]))
hdu[0].header = self.getHeader() # add the primary header to the HDU
hdu[0].update_header()
else:
if self._wave is not None and not store_wave:
if self._datatype == 'CUBE':
try:
hdu[0].header.update('CRVAL3', self._wave[0])
except:
hdu[0].header['CRVAL3'] = (self._wave[0])
try:
hdu[0].header.update('CDELT3', self._wave[1] - self._wave[0])
except:
hdu[0].header['CDELT3'] = (self._wave[1] - self._wave[0])
else:
try:
hdu[0].header.update('CRVAL1', self._wave[0])
except:
hdu[0].header['CRVAL1'] = (self._wave[0])
try:
hdu[0].header.update('CDELT1', self._wave[1] - self._wave[0])
except:
hdu[0].header['CDELT1'] = (self._wave[1] - self._wave[0])
hdu.writeto(filename, overwrite=True) # write FITS file to disc
|
{"hexsha": "73250090063febec0f3327f923b46621dc7390a5", "size": 24797, "ext": "py", "lang": "Python", "max_stars_repo_path": "PyParadise/data.py", "max_stars_repo_name": "brandherd/PyParadise", "max_stars_repo_head_hexsha": "1c65bf634e17931f165fd88b9938f604b9371e2e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-01T13:07:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T13:07:54.000Z", "max_issues_repo_path": "PyParadise/data.py", "max_issues_repo_name": "brandherd/PyParadise", "max_issues_repo_head_hexsha": "1c65bf634e17931f165fd88b9938f604b9371e2e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-11-03T02:07:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-14T20:35:04.000Z", "max_forks_repo_path": "PyParadise/data.py", "max_forks_repo_name": "brandherd/PyParadise", "max_forks_repo_head_hexsha": "1c65bf634e17931f165fd88b9938f604b9371e2e", "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": 42.8272884283, "max_line_length": 122, "alphanum_fraction": 0.5426462879, "include": true, "reason": "import numpy,from scipy,import astropy", "num_tokens": 5451}
|
import os
from tqdm import tqdm
import pickle as p
import nltk
from collections import defaultdict
import random
import numpy as np
class Batch:
'''
0. should have extra utterances for padding, hence dimension-0 of utterances and labels
are different. Specifically, utterances.d_0 = labels.d_0 + 2 * (windowSize - 1)
1. all the seqs of a batch should come from one single show
2. test and val also have batch
'''
def __init__(self):
# list of utterances, each utterance is a list [[utt_0], [utt_1], ...]
# all utterances are padded to maxLength using <pad>
self.sequence = []
self.labels = []
# length of each sample in the batch, useful for RNN
self.length = []
# useful for debugging
self.id = -1
class Sample:
def __init__(self):
# raw sentence, use nltk.word_tokenize later
self.utterance = ''
# 0: not a change point
# 1: is a change point
self.label = -1
# sequence: convert utterance to sequence of word ids
self.sequence = []
# true length of this sample, max is self.args.maxLength
self.length = -1
# seq of words
self.words = []
class Show:
def __init__(self):
self.samples = []
self.batches = []
class TextData:
'''
TextData consists of train data, val data and test data
each data consists of several Show object
each Show object consists of several several sample object
each sample object consists of a sentence text and a label
'''
def __init__(self, args):
self.args = args
self.trainShows = []
self.valShows = []
self.testShows = []
self.preTrainedEmbedding = []
# batches for train, val, and test
# note: currently useless, since we want to keep all the batches of a show together during training
self.trainBatches = []
self.valBatches = []
self.textBatches = []
self.word2id = {}
self.id2word = {}
self.word2cnt = defaultdict(int)
self.trainCnt = -1
self.valCnt = -1
self.testCnt = -1
self.batchCnt = 0
# for sentences shorter than self.args.maxLength, pad them
# for words whose occurances are less than 10, pad them to <unknown>
self.PAD_WORD = '<pad>'
self.UNK_WORD = '<unknown>'
self.pad = self.getWordId(self.PAD_WORD)
self.unk = self.getWordId(self.UNK_WORD)
self.createData()
self.createDic()
if self.args.preEmbedding == True:
self.createEmbedding()
cntLength = self.createSeq()
self.avglenth = cntLength*1.0/(self.trainCnt+self.testCnt+self.valCnt)
print('average length = {}'.format(cntLength*1.0/(self.trainCnt+self.valCnt+self.testCnt)))
self.createBatches()
print('number of words = {}'.format(len(self.word2id)))
def createEmbedding(self):
with open(self.args.embeddingFile, 'rb') as embeddingFile:
# a dictionary
# key: word
# value: 200-d embeddings
word2embedding = p.load(embeddingFile)
unknown = np.random.normal(scale=0.5, size=[self.args.embeddingSize]).tolist()
unk_cnt = 0
cnt = 0
for id in range(len(self.id2word)):
word = self.id2word[id]
if word == self.UNK_WORD:
self.preTrainedEmbedding.append(unknown)
cnt += 1
# if we have that embedding
elif word == self.PAD_WORD:
# note: add pad word later, should be untrainable
continue
elif word in word2embedding.keys():
# note: some words do not have pretrained embedding
# note: hence, they are pointed to self.unk
# note: their position should be replace by the words to come
embedding = word2embedding[word]
self.preTrainedEmbedding.append(embedding)
self.word2id[word] = len(self.preTrainedEmbedding)
# if we don't have that embedding, make the word unknown
# note: word2id is violated!
else:
#note, point the word to <unknown>
self.word2id[word] = self.unk
unk_cnt += 1
# note: pad should be added to the head of the array later
self.preTrainedEmbedding = np.array(self.preTrainedEmbedding).astype(np.float32)
print('Total {} unknown words'.format(unk_cnt))
assert cnt == 1
def _create(self, directory, tag):
'''
:param directory: the data directory
:param tag: should be 'train', 'test' or 'val'
:return:
'''
print('creating {} data'.format(tag))
def createSamples(fileName):
file = open(fileName, 'r')
lines = file.readlines()
samples = []
for line in lines:
sample = Sample()
splits = line.split('%$*')
#print(line)
sample.utterance = splits[0].strip()
words = nltk.word_tokenize(sample.utterance)
for word in words:
# note: do not generate wordId here, cnt the occurances first
self.word2cnt[word] += 1
sample.words.append(word) # embedding
sample.label = int(splits[1].strip())
samples.append(sample)
file.close()
return samples
sampleCnt = 0
fileNames = os.listdir(directory)
shows = []
#for fileName in fileNames:
for fileName in tqdm(fileNames):
if tag == 'train':
fileName = os.path.join(self.args.trainData, fileName)
elif tag == 'val':
fileName = os.path.join(self.args.valData, fileName)
elif tag == 'test':
fileName = os.path.join(self.args.testData, fileName)
show = Show()
samples = createSamples(fileName)
sampleCnt += len(samples)
show.samples = samples
shows.append(show)
if tag == 'train':
self.trainShows = shows
elif tag == 'val':
self.valShows = shows
elif tag == 'test':
self.testShows = shows
return sampleCnt
def createDic(self):
'''
create dictionaries
word2id, id2word
:return:
'''
cntLength = 0
print('Creating sequnces of words')
for shows in [self.trainShows, self.testShows, self.valShows]:
for show in tqdm(shows):
for sample in show.samples:
for word in sample.words:
if self.word2cnt[word] < self.args.minOccur:
wordId = self.unk
self.word2id[word] = self.unk
else:
wordId = self.getWordId(word)
def createSeq(self):
'''
create sequence of wordIds, and pad the sequences to maxLength
:return:
'''
cntLength = 0
print('Creating sequnces of words')
for shows in [self.trainShows, self.testShows, self.valShows]:
for show in tqdm(shows):
for sample in show.samples:
for word in sample.words:
wordId = self.word2id[word]
sample.sequence.append(wordId)
cntLength += len(sample.sequence)
#print(len(sample.sequence))
# record true length of each sample
if len(sample.sequence) > self.args.maxLength:
sample.length = self.args.maxLength
else:
sample.length = len(sample.sequence)
while len(sample.sequence) < self.args.maxLength:
sample.sequence.append(self.pad)
# restrict the max length of sequences
sample.sequence = sample.sequence[0:self.args.maxLength]
return cntLength
def createData(self):
self.trainCnt = self._create(self.args.trainData, 'train')
self.valCnt = self._create(self.args.valData, 'val')
self.testCnt = self._create(self.args.testData, 'test')
print('{} training utterances, {} validation utterances, {} test utterances'.format(
self.trainCnt, self.valCnt, self.testCnt
))
def getWordId(self, word):
'''
Create wordId for a word
:param word:
:return: wordId
'''
wordId = self.word2id.get(word, -1)
#self.word2cnt[word] += 1
if wordId == -1:
wordId = len(self.id2word)
self.word2id[word] = wordId
self.id2word[wordId] = word
return wordId
def getWordFromID(self, wordId):
word = self.id2word.get(wordId, "-1")
if word == "-1":
word = "PAD"
return word
def covertIdFeed2Words(self, feed):
passage = []
print(type(feed))
for i, tensor in enumerate(feed):
# print(tensor.name)
if (tensor.name).find("input_utterances") != -1:
sample = feed[tensor]
# print("sample", sample)
for line in sample:
sentence = []
hasSomething = False
for wordId in line:
# print(wordId)
word = self.getWordFromID(wordId)
if word != "<pad>":
sentence.append(word)
hasSomething = True
else:
sentence.append("")
if hasSomething:
passage.append(sentence)
return passage
def getVocabularySize(self):
'''
get vocab size
:return:
'''
size = len(self.word2id)
return size
def shuffle(self, shows):
random.shuffle(shows)
def getShowBatch(self, show):
'''
extract batch from a show
:param show:
:return: list of batch objects
'''
batches_sample = []
batches = []
samples = show.samples
numSamples = len(samples)
for i in range(0, numSamples, self.args.batchSize):
batch_sample = samples[i:min(i+self.args.batchSize, numSamples)]
batches_sample.append(batch_sample)
pad_seq = []
for i in range(self.args.maxLength):
pad_seq.append(self.pad)
pad_seqs = []
for i in range(self.args.uttContextSize-1):
pad_seqs.append(pad_seq)
pad_length = []
# the length of the padding sentence is useless, but do not set it to zero
for i in range(self.args.uttContextSize-1):
pad_length.append(2)
for idx, batch_sample in enumerate(batches_sample):
# this is the first batch of a show
# pad_sentence * (self.uttContextSize - 1) + setences + next_batch_sentence * (self.uttContextSize)
batch = Batch()
batch.id = self.batchCnt
self.batchCnt += 1
if idx == 0:
# extend with padding seqs first
batch.sequence.extend(pad_seqs)
batch.length.extend(pad_length)
else:
# extend with last batch_sample
last_batch_sample = batches_sample[idx-1]
samples_for_padding = last_batch_sample[-(self.args.uttContextSize - 1):]
for sample in samples_for_padding:
batch.sequence.append(sample.sequence)
batch.length.append(sample.length)
# then extend with true seqs
for sample in batch_sample:
batch.sequence.append(sample.sequence)
batch.labels.append(sample.label)
batch.length.append(sample.length)
# this is the last batch of a show, pad with pad seqs
if idx == len(batches_sample)-1:
batch.sequence.extend(pad_seqs)
batch.sequence.append(pad_seq)
batch.length.extend(pad_length)
batch.length.append(2)
else:
# not the last batch of a show, pad with next batch
next_batch_sample = batches_sample[idx+1]
# note restriction: self.args.uttContextSize <= self.args.batchSize
# fixme: self.args.uttContextSize may be too long for next batch
samples_for_padding = next_batch_sample[0:(self.args.uttContextSize)]
for sample in samples_for_padding:
batch.sequence.append(sample.sequence)
batch.length.append(sample.length)
numShorts = (self.args.uttContextSize) - len(samples_for_padding)
while numShorts > 0:
batch.sequence.append(pad_seq)
numShorts -= 1
# check
if len(batch.labels) != len(batch.sequence) - 2*(self.args.uttContextSize - 1) - 1:
print('Wrong padding! batch id = {}'.format(batch.id))
assert False
batches.append(batch)
return batches
def createBatches(self):
'''
create batches for training
:return:
'''
print('Creating batches for train/val/show')
for show in self.trainShows:
show_batches = self.getShowBatch(show)
show.batches = show_batches
self.trainBatches.append(show_batches)
for show in self.testShows:
show_batches = self.getShowBatch(show)
show.batches = show_batches
self.textBatches.append(show_batches)
for show in self.valShows:
show_batches = self.getShowBatch(show)
show.batches = show_batches
self.valBatches.append(show_batches)
def getBatches(self, tag='train'):
'''
:param tag: train or val or test
:return:
'''
assert tag == 'train' or tag == 'val' or tag == 'test'
batches = []
if tag == 'train':
self.shuffle(self.trainShows)
for show in self.trainShows:
batches.extend(show.batches)
if tag == 'test':
#self.shuffle(self.testShows)
for show in self.testShows:
batches.extend(show.batches)
if tag == 'val':
#self.shuffle(self.valShows)
for show in self.valShows:
batches.extend(show.batches)
return batches
|
{"hexsha": "e39b2bf45127b0e9c7e05f7eaf8f346fe691548a", "size": 14987, "ext": "py", "lang": "Python", "max_stars_repo_path": "code/speakerChangeTagger/textData.py", "max_stars_repo_name": "stoplime/OpenAudioAI", "max_stars_repo_head_hexsha": "4ed6fb78b976fd7c4d2b4661849562b28003a2ed", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-28T13:55:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-28T13:55:29.000Z", "max_issues_repo_path": "code/speakerChangeTagger/textData.py", "max_issues_repo_name": "stoplime/OpenAudioAI", "max_issues_repo_head_hexsha": "4ed6fb78b976fd7c4d2b4661849562b28003a2ed", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2018-06-03T23:46:50.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-11T02:54:22.000Z", "max_forks_repo_path": "code/speakerChangeTagger/textData.py", "max_forks_repo_name": "stoplime/OpenAudioAI", "max_forks_repo_head_hexsha": "4ed6fb78b976fd7c4d2b4661849562b28003a2ed", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-06-22T23:22:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-22T23:22:57.000Z", "avg_line_length": 34.373853211, "max_line_length": 111, "alphanum_fraction": 0.5421365183, "include": true, "reason": "import numpy", "num_tokens": 3150}
|
import os
import cv2
import sys
import tensorflow as tf
import numpy as np
from styx_msgs.msg import TrafficLight
TRAFFIC_LIGHT_CLASS = 10
TRAFFIC_LIGHT_MIN_SCORE = 0.80
class TLClassifier(object):
def __init__(self):
script_dir = os.getcwd()
research_dir = os.path.join(script_dir, "research")
slim_dir = os.path.join(research_dir, "slim")
if research_dir not in sys.path:
sys.path.append(research_dir)
if slim_dir not in sys.path:
sys.path.append(slim_dir)
# Load Frozen Model
frozen_model_file = "./model/frozen_inference_graph.pb"
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(frozen_model_file, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
# Load labels
from object_detection.utils import label_map_util
current_dir = os.getcwd()
labels_file = os.path.join(current_dir, "model/mscoco_label_map.pbtxt")
self.category_index = label_map_util.create_category_index_from_labelmap(labels_file, use_display_name=True)
def run_inference_for_single_image(self, image):
from object_detection.utils import ops as utils_ops
with self.detection_graph.as_default():
with tf.Session() as sess:
# Get handles to input and output tensors
ops = tf.get_default_graph().get_operations()
all_tensor_names = {output.name for op in ops for output in op.outputs}
tensor_dict = {}
for key in [
'num_detections', 'detection_boxes', 'detection_scores', 'detection_classes', 'detection_masks'
]:
tensor_name = key + ':0'
if tensor_name in all_tensor_names:
tensor_dict[key] = tf.get_default_graph().get_tensor_by_name(tensor_name)
if 'detection_masks' in tensor_dict:
# The following processing is only for single image
detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0])
detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0])
# Reframe is required to translate mask from box coordinates to image coordinates and fit the image size.
real_num_detection = tf.cast(tensor_dict['num_detections'][0], tf.int32)
detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1])
detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1])
detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(
detection_masks, detection_boxes, image.shape[0], image.shape[1])
detection_masks_reframed = tf.cast(
tf.greater(detection_masks_reframed, 0.5), tf.uint8)
# Follow the convention by adding back the batch dimension
tensor_dict['detection_masks'] = tf.expand_dims(
detection_masks_reframed, 0)
image_tensor = tf.get_default_graph().get_tensor_by_name('image_tensor:0')
# Run inference
output_dict = sess.run(tensor_dict, feed_dict={image_tensor: np.expand_dims(image, 0)})
# all outputs are float32 numpy arrays, so convert types as appropriate
output_dict['num_detections'] = int(output_dict['num_detections'][0])
output_dict['detection_classes'] = output_dict[
'detection_classes'][0].astype(np.uint8)
output_dict['detection_boxes'] = output_dict['detection_boxes'][0]
output_dict['detection_scores'] = output_dict['detection_scores'][0]
if 'detection_masks' in output_dict:
output_dict['detection_masks'] = output_dict['detection_masks'][0]
return output_dict
def get_traffic_light(self, cv2_image, output_dict):
height, width, _ = cv2_image.shape
traffic_light_score = 0
traffic_light_index = None
contrains_traffic_light = np.nonzero(output_dict["detection_classes"] == TRAFFIC_LIGHT_CLASS)
traffic_light_indexes = contrains_traffic_light[0]
for tf_light_index in traffic_light_indexes:
current_score = output_dict['detection_scores'][tf_light_index]
if current_score >= TRAFFIC_LIGHT_MIN_SCORE and current_score >= traffic_light_score:
traffic_light_score = current_score
traffic_light_index = tf_light_index
# No traffic light has been found
if traffic_light_index is None:
return None
# Traffic light found
detection_box = output_dict["detection_boxes"][traffic_light_index]
(ymin, xmin, ymax, xmax) = (int(detection_box[0] * height), int(detection_box[1] * width),
int(detection_box[2] * height), int(detection_box[3] * width))
return cv2_image[ymin:ymax, xmin:xmax]
def get_classification(self, cv2_image):
"""Determines the color of the traffic light in the image
Args:
cv2_image (cv::Mat): image containing the traffic light
Returns:
int: ID of traffic light color (specified in styx_msgs/TrafficLight)
"""
def get_green_mask(img_hsv):
lower_green = np.array([40, 10, 10])
upper_green = np.array([90, 255, 255])
mask = cv2.inRange(img_hsv, lower_green, upper_green)
return mask
def get_red_mask(img_hsv):
# red lower mask (0-10)
lower_red = np.array([20, 1, 150])
upper_red = np.array([30, 120, 255])
mask0 = cv2.inRange(img_hsv, lower_red, upper_red)
# Red upper mask
lower_red = np.array([170, 50, 50])
upper_red = np.array([180, 255, 255])
mask1 = cv2.inRange(img_hsv, lower_red, upper_red)
# join my masks
mask = mask0 + mask1
return mask
def get_traffic_light_color(cv2_image):
# Convert BGR to HSV
img_hsv = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2HSV)
height, width, _ = img_hsv.shape
green_mask = get_green_mask(img_hsv)
red_mask = get_red_mask(img_hsv)
dico = {
TrafficLight.RED: np.count_nonzero(red_mask[0:int(height / 3), :]),
TrafficLight.YELLOW: np.count_nonzero(red_mask[int(height / 3):int(height * 2 / 3), :]),
TrafficLight.GREEN: np.count_nonzero(green_mask[int(height * 2 / 3):height, :])
}
v = list(dico.values())
k = list(dico.keys())
return k[v.index(max(v))]
output_dict = self.run_inference_for_single_image(cv2_image)
traffic_light_image = self.get_traffic_light(cv2_image, output_dict)
# no traffic light found
if traffic_light_image is None:
return TrafficLight.UNKNOWN
return get_traffic_light_color(traffic_light_image)
|
{"hexsha": "95885cb333224f9f31c5012a429102479c9f7583", "size": 7416, "ext": "py", "lang": "Python", "max_stars_repo_path": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_stars_repo_name": "tekisetsu/udacity_capstone", "max_stars_repo_head_hexsha": "b86dc5914c69fdd9ed16eb074c01729d717a5e9e", "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": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_issues_repo_name": "tekisetsu/udacity_capstone", "max_issues_repo_head_hexsha": "b86dc5914c69fdd9ed16eb074c01729d717a5e9e", "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": "ros/src/tl_detector/light_classification/tl_classifier.py", "max_forks_repo_name": "tekisetsu/udacity_capstone", "max_forks_repo_head_hexsha": "b86dc5914c69fdd9ed16eb074c01729d717a5e9e", "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": 43.3684210526, "max_line_length": 125, "alphanum_fraction": 0.615021575, "include": true, "reason": "import numpy", "num_tokens": 1622}
|
[STATEMENT]
lemma Amicable_pair_example_smallest_odd_odd: "12285 Amic 14595"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have A: "set(divisors_nat (12285)) = {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91,
105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (divisors_nat 12285) = {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285}
[PROOF STEP]
by eval
[PROOF STATE]
proof (state)
this:
set (divisors_nat 12285) = {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285}
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have A1: "set(divisors_nat (12285)) = divisor_set 12285"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (divisors_nat 12285) = divisor_set 12285
[PROOF STEP]
using def_equiv_divisor_set
[PROOF STATE]
proof (prove)
using this:
divisor_set ?n = set (divisors_nat ?n)
goal (1 subgoal):
1. set (divisors_nat 12285) = divisor_set 12285
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set (divisors_nat 12285) = divisor_set 12285
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have A2: "\<Sum>{1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273,
315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285} = (26880::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Sum> {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285} = 26880
[PROOF STEP]
by eval
[PROOF STATE]
proof (state)
this:
\<Sum> {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285} = 26880
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have A3: "Esigma 12285 = 26880"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Esigma 12285 = 26880
[PROOF STEP]
using A A1 A2 Esigma_def
[PROOF STATE]
proof (prove)
using this:
set (divisors_nat 12285) = {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285}
set (divisors_nat 12285) = divisor_set 12285
\<Sum> {1, 3, 5, 7, 9, 13, 15, 21, 27, 35, 39, 45, 63, 65, 91, 105, 117, 135, 189, 195, 273, 315, 351, 455, 585, 819, 945, 1365, 1755, 2457, 4095, 12285} = 26880
Esigma ?n \<equiv> \<Sum> (divisor_set ?n)
goal (1 subgoal):
1. Esigma 12285 = 26880
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Esigma 12285 = 26880
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have Q:"Esigma 12285 = Esigma 14595"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
have N: "set(divisors_nat (14595)) =
{ 1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (divisors_nat 14595) = {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595}
[PROOF STEP]
by eval
[PROOF STATE]
proof (state)
this:
set (divisors_nat 14595) = {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595}
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
have N1: "set(divisors_nat (14595)) = divisor_set 14595"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (divisors_nat 14595) = divisor_set 14595
[PROOF STEP]
using def_equiv_divisor_set
[PROOF STATE]
proof (prove)
using this:
divisor_set ?n = set (divisors_nat ?n)
goal (1 subgoal):
1. set (divisors_nat 14595) = divisor_set 14595
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set (divisors_nat 14595) = divisor_set 14595
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
have N2:
"\<Sum>{ 1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595} = (26880::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Sum> {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595} = 26880
[PROOF STEP]
by eval
[PROOF STATE]
proof (state)
this:
\<Sum> {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595} = 26880
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
using A3 N N1 N2 Esigma_def
[PROOF STATE]
proof (prove)
using this:
Esigma 12285 = 26880
set (divisors_nat 14595) = {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595}
set (divisors_nat 14595) = divisor_set 14595
\<Sum> {1, 3, 5, 7, 15, 21, 35, 105, 139, 417, 695, 973, 2085, 2919, 4865, 14595} = 26880
Esigma ?n \<equiv> \<Sum> (divisor_set ?n)
goal (1 subgoal):
1. Esigma 12285 = Esigma 14595
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Esigma 12285 = Esigma 14595
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Esigma 12285 = Esigma 14595
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
have B:"Esigma (12285) = 12285 + 14595"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Esigma 12285 = 12285 + 14595
[PROOF STEP]
using A3
[PROOF STATE]
proof (prove)
using this:
Esigma 12285 = 26880
goal (1 subgoal):
1. Esigma 12285 = 12285 + 14595
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Esigma 12285 = 12285 + 14595
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
using B Q Amicable_pair_def
[PROOF STATE]
proof (prove)
using this:
Esigma 12285 = 12285 + 14595
Esigma 12285 = Esigma 14595
?m Amic ?n \<equiv> ?m = aliquot_sum ?n \<and> ?n = aliquot_sum ?m
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
using Amicable_pair_equiv_def_conv one_le_numeral
[PROOF STATE]
proof (prove)
using this:
Esigma 12285 = 12285 + 14595
Esigma 12285 = Esigma 14595
?m Amic ?n \<equiv> ?m = aliquot_sum ?n \<and> ?n = aliquot_sum ?m
\<lbrakk>1 \<le> ?m; 1 \<le> ?n; Esigma ?m = Esigma ?n \<and> Esigma ?m = ?m + ?n\<rbrakk> \<Longrightarrow> ?m Amic ?n
(1::?'a) \<le> numeral ?n
goal (1 subgoal):
1. 12285 Amic 14595
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
12285 Amic 14595
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 4358, "file": "Amicable_Numbers_Amicable_Numbers", "length": 32}
|
# module Bukdu
import Base: pipeline
"""
pipeline(block::Function, routers...)
"""
function pipeline(block::Function, pipes...)
for pipe::Symbol in pipes
pipelines = get(Routing.routing_pipelines, pipe, [])
push!(pipelines, block)
Routing.routing_pipelines[pipe] = pipelines
end
end
# module Bukdu
|
{"hexsha": "b89b750c30cbdcc9d5c39beedb211b25f63f5cdf", "size": 337, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/pipelines.jl", "max_stars_repo_name": "UnofficialJuliaMirror/Bukdu.jl-3e78a19a-cc83-51d8-955b-515f39fd7955", "max_stars_repo_head_hexsha": "3c2f188e2050873f612c1e356ef5fcfd1de7aacb", "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/pipelines.jl", "max_issues_repo_name": "UnofficialJuliaMirror/Bukdu.jl-3e78a19a-cc83-51d8-955b-515f39fd7955", "max_issues_repo_head_hexsha": "3c2f188e2050873f612c1e356ef5fcfd1de7aacb", "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/pipelines.jl", "max_forks_repo_name": "UnofficialJuliaMirror/Bukdu.jl-3e78a19a-cc83-51d8-955b-515f39fd7955", "max_forks_repo_head_hexsha": "3c2f188e2050873f612c1e356ef5fcfd1de7aacb", "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": 19.8235294118, "max_line_length": 60, "alphanum_fraction": 0.6617210682, "num_tokens": 78}
|
# -*- coding: utf-8 -*-
"""
========================
Gaussian KDE and Extents
========================
Smooth marginalised distributions with a Gaussian KDE, and pick custom extents.
Note that invoking the KDE on large data sets will significantly increase rendering time when
you have a large number of points. You can also pass a float to your KDE to modify the width
of the bandpass by that factor!
You can see the increase in contour smoothness (without broadening) for when you have a
low number of samples in your chains!
"""
import numpy as np
from chainconsumer import ChainConsumer
np.random.seed(0)
data = np.random.multivariate_normal([0.0, 4.0], [[1.0, -0.7], [-0.7, 1.5]], size=3000)
c = ChainConsumer()
c.add_chain(data, name="KDE on")
c.add_chain(data + 1, name="KDE off")
c.add_chain(data + 2, name="KDE x2!")
c.configure(kde=[True, False, 2.0], shade_alpha=0.1, flip=False)
fig = c.plotter.plot(extents=[(-2, 4), (0, 9)])
fig.set_size_inches(3 + fig.get_size_inches()) # Resize fig for doco. You don't need this.
|
{"hexsha": "da592d66719ad8f319c1f19cdb455571ff2d153f", "size": 1039, "ext": "py", "lang": "Python", "max_stars_repo_path": "examples/customisations/plot_kde_extents.py", "max_stars_repo_name": "Jiaming1999/ChainConsumer", "max_stars_repo_head_hexsha": "5606696525d91f11d8093085934fa352b98ce97c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2016-08-31T01:02:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T15:23:29.000Z", "max_issues_repo_path": "examples/customisations/plot_kde_extents.py", "max_issues_repo_name": "Jiaming1999/ChainConsumer", "max_issues_repo_head_hexsha": "5606696525d91f11d8093085934fa352b98ce97c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 86, "max_issues_repo_issues_event_min_datetime": "2016-10-09T23:20:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T09:55:57.000Z", "max_forks_repo_path": "examples/customisations/plot_kde_extents.py", "max_forks_repo_name": "Jiaming1999/ChainConsumer", "max_forks_repo_head_hexsha": "5606696525d91f11d8093085934fa352b98ce97c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2016-08-31T08:35:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-24T16:39:26.000Z", "avg_line_length": 32.46875, "max_line_length": 93, "alphanum_fraction": 0.6891241578, "include": true, "reason": "import numpy", "num_tokens": 286}
|
library(tidyverse)
library(scales)
library(caTools)
cvdata.us <- readRDS('data/cvdata.us.RDS')
# Create a nestedn hierarchy of node structures:
#
# {
# name: "name",
# children: [
# node,
# node,
# ...
# ]
# }
#
# {
# name: "name", value: "value"
# }
#
#
# Division => State => County => [ Cases, Deaths, Cases.Per100K, Deaths.Per100K ]
#
latest <- filter(cvdata.us, Date == max(cvdata.us$Date)) %>% arrange(Division, State, County)
build.hierarchy <- function() {
cvdata.counties <- readRDS('data/cvdata.us.RDS')
cvdata.states <- readRDS('data/cvdata.us.by_state.RDS')
# First make states
latest <- max(cvdata.states$Date)
latest.growth <- sym(paste0('Growth_', ymd(latest)))
latest.cases <- sym(paste0('Cases_', ymd(latest)))
counties <- cvdata.counties %>%
rename(Growth=Cases.Growth5) %>%
pivot_wider(id_cols = c('FIPS', 'County', 'State.Code'),
names_from = 'Date',
values_from = c('Cases','Growth')) %>%
mutate(Cases = !!latest.cases,
Growth = !!latest.growth,
id = paste0("FIPS", FIPS),
State.Code = as.character(State.Code),
County = as.character(County)) %>%
rename(parent=State.Code, name=County)
states <- cvdata.states %>%
mutate(State=as.character(State),
State.Code=as.character(State.Code),
parent = paste0('Region', as.integer(Division))) %>%
select(name=State, id=State.Code, parent) %>%
unique()
# #
# states <- cvdata.states %>%
# rename(Growth=Cases.Growth5) %>%
# pivot_wider(id_cols = c('State','State.Code', 'Division'),
# names_from = 'Date',
# values_from = c('Cases','Growth')) %>%
# mutate(parent = paste0('Region', as.integer(Division)),
# Cases=!!latest.cases,
# Growth=!!latest.growth,
# State.Code = as.character(State.Code),
# State = as.character(State)) %>%
# rename(id=State.Code, name=State) %>%
# select(-Division)
regions <- cvdata.states %>%
select(name = Division) %>%
unique() %>%
mutate(id = paste0('Region', as.integer(name)),
parent = 'flare',
name = as.character(name))
bind_rows(tibble(name='flare', id='flare', parent=''),
regions,
states,
counties) %>%
select(id, name, parent, Cases, Growth, everything())
}
concat <- function(df) {
paste0('{ "name": "flare", "children": [ \n',
split(df, fct_drop(df$Division)) %>%
lapply(function(division) {
paste0(' { "name": "', division$Division[1],'", "children": [\n',
split(division, fct_drop(division$State)) %>%
lapply(function(state){
paste0('{"name": "', state$State[1], '", "children": [\n',
paste0('{"name": "', state$County,
'","value": ', state$Cases,
',"growth": ', pmax(0,state$Cases.Growth5),
'}',
collapse=", "),
'\n]}')
}) %>% str_c(collapse=","),
']}')}) %>% str_c(collapse=","),
'\n]}\n')
}
# write(concat(latest), "cviz/dist/sample.json")
write.csv(build.hierarchy(), "cviz/dist/covid.csv", na="0", row.names = F)
|
{"hexsha": "f34f53f7d9adf42a0550ddfab45e33f1db694dce", "size": 3473, "ext": "r", "lang": "R", "max_stars_repo_path": "tree.r", "max_stars_repo_name": "bkayser/CV19", "max_stars_repo_head_hexsha": "8de30e205e5615be504dc894f4aa1ec4ec6999bf", "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": "tree.r", "max_issues_repo_name": "bkayser/CV19", "max_issues_repo_head_hexsha": "8de30e205e5615be504dc894f4aa1ec4ec6999bf", "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": "tree.r", "max_forks_repo_name": "bkayser/CV19", "max_forks_repo_head_hexsha": "8de30e205e5615be504dc894f4aa1ec4ec6999bf", "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": 32.7641509434, "max_line_length": 94, "alphanum_fraction": 0.5105096458, "num_tokens": 883}
|
#pragma once
#include <gsl\gsl>
#include <winrt\Windows.Foundation.h>
#include <d3d11.h>
#include "DrawableGameComponent.h"
#include "MatrixHelper.h"
#include "DirectionalLight.h"
namespace Library
{
class Texture2D;
class ProxyModel;
}
namespace Rendering
{
class NormalMappingMaterial;
class NormalMappingDemo final : public Library::DrawableGameComponent
{
public:
NormalMappingDemo(Library::Game& game, const std::shared_ptr<Library::Camera>& camera);
NormalMappingDemo(const NormalMappingDemo&) = delete;
NormalMappingDemo(NormalMappingDemo&&) = default;
NormalMappingDemo& operator=(const NormalMappingDemo&) = default;
NormalMappingDemo& operator=(NormalMappingDemo&&) = default;
~NormalMappingDemo();
bool RealNormalMapEnabled() const;
void SetRealNormalMapEnabled(bool enabled);
void ToggleRealNormalMap();
float AmbientLightIntensity() const;
void SetAmbientLightIntensity(float intensity);
float DirectionalLightIntensity() const;
void SetDirectionalLightIntensity(float intensity);
const DirectX::XMFLOAT3& LightDirection() const;
void RotateDirectionalLight(DirectX::XMFLOAT2 amount);
virtual void Initialize() override;
virtual void Update(const Library::GameTime& gameTime) override;
virtual void Draw(const Library::GameTime& gameTime) override;
private:
std::shared_ptr<NormalMappingMaterial> mMaterial;
DirectX::XMFLOAT4X4 mWorldMatrix{ Library::MatrixHelper::Identity };
winrt::com_ptr<ID3D11Buffer> mVertexBuffer;
std::uint32_t mVertexCount{ 0 };
Library::DirectionalLight mDirectionalLight;
std::unique_ptr<Library::ProxyModel> mProxyModel;
std::shared_ptr<Library::Texture2D> mRealNormalMap;
std::shared_ptr<Library::Texture2D> mDefaultNormalMap;
bool mUpdateMaterial{ true };
bool mRealNormalMapEnabled{ true };
};
}
|
{"hexsha": "52f288eb006991c9f185f89e96c9e3a2d246179b", "size": 1815, "ext": "h", "lang": "C", "max_stars_repo_path": "source/6.1_Normal_Mapping/NormalMappingDemo.h", "max_stars_repo_name": "ssshammi/real-time-3d-rendering-with-directx-and-hlsl", "max_stars_repo_head_hexsha": "05a05c5c26784dafa9a89747276f385252951f2f", "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": "source/6.1_Normal_Mapping/NormalMappingDemo.h", "max_issues_repo_name": "ssshammi/real-time-3d-rendering-with-directx-and-hlsl", "max_issues_repo_head_hexsha": "05a05c5c26784dafa9a89747276f385252951f2f", "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": "source/6.1_Normal_Mapping/NormalMappingDemo.h", "max_forks_repo_name": "ssshammi/real-time-3d-rendering-with-directx-and-hlsl", "max_forks_repo_head_hexsha": "05a05c5c26784dafa9a89747276f385252951f2f", "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": 30.7627118644, "max_line_length": 89, "alphanum_fraction": 0.7834710744, "num_tokens": 451}
|
"""
Handle vibrational data info
"""
import os
import numpy
import autofile
import autorun
import automol.geom
import projrot_io
from phydat import phycon
from mechlib.amech_io import printer as ioprinter
from mechlib.amech_io._path import job_path
from mechroutines.pf.models import typ
from mechroutines.pf.models import _tors as tors
def vib_analysis(spc_dct_i, pf_filesystems, spc_mod_dct_i,
run_prefix, zrxn=None):
""" process to get freq
"""
tors_strs = ['']
rotors = tors.build_rotors(
spc_dct_i, pf_filesystems, spc_mod_dct_i)
if typ.nonrigid_tors(spc_mod_dct_i, rotors):
tors_strs = tors.make_hr_strings(rotors)
[_, hr_str, _, prot_str, _] = tors_strs
freqs, imag, tors_zpe, pot_scalef = tors_projected_freqs_zpe(
pf_filesystems, hr_str, prot_str, run_prefix, zrxn=zrxn)
# Make final hindered rotor strings and get corrected tors zpe
if typ.scale_1d(spc_mod_dct_i):
rotors = tors.scale_rotor_pots(rotors, scale_factor=pot_scalef)
tors_strs = tors.make_hr_strings(rotors)
[_, hr_str, _, prot_str, _] = tors_strs
_, _, tors_zpe, _ = tors_projected_freqs_zpe(
pf_filesystems, hr_str, prot_str, run_prefix, zrxn=zrxn)
# Calculate current zpe assuming no freq scaling: tors+projfreq
zpe = tors_zpe + (sum(freqs) / 2.0) * phycon.WAVEN2EH
# For mdhrv model no freqs needed in MESS input, zero out freqs lst
if 'mdhrv' in spc_mod_dct_i['tors']['mod']:
freqs = ()
else:
freqs, imag, zpe = read_harmonic_freqs(
pf_filesystems, run_prefix, zrxn=zrxn)
tors_zpe = 0.0
freqs, zpe = scale_frequencies(
freqs, tors_zpe,
spc_mod_dct_i, scale_method='3c')
return freqs, imag, zpe, tors_strs
def full_vib_analysis(spc_dct_i, pf_filesystems, spc_mod_dct_i,
run_prefix, zrxn=None):
""" process to get freq
"""
tors_strs = ['']
freqs = []
imag = []
tors_zpe = 0.0
scale_factor = 1.0
tors_freqs = []
rt_freqs1 = []
rotors = tors.build_rotors(
spc_dct_i, pf_filesystems, spc_mod_dct_i)
if typ.nonrigid_tors(spc_mod_dct_i, rotors):
tors_strs = tors.make_hr_strings(rotors)
[_, hr_str, _, prot_str, _] = tors_strs
freqs, imag, tors_zpe, pot_scalef = tors_projected_freqs_zpe(
pf_filesystems, hr_str, prot_str, run_prefix, zrxn=zrxn)
# Make final hindered rotor strings and get corrected tors zpe
if typ.scale_1d(spc_mod_dct_i):
rotors = tors.scale_rotor_pots(rotors, scale_factor=pot_scalef)
tors_strs = tors.make_hr_strings(rotors)
[_, hr_str, _, prot_str, _] = tors_strs
freqs, imag, tors_zpe, scale_factor, tors_freqs, rt_freqs1 = tors_projected_freqs(
pf_filesystems, hr_str, prot_str, run_prefix, zrxn=zrxn)
# Calculate current zpe assuming no freq scaling: tors+projfreq
zpe = tors_zpe + (sum(freqs) / 2.0) * phycon.WAVEN2EH
# For mdhrv model no freqs needed in MESS input, zero out freqs lst
if 'mdhrv' in spc_mod_dct_i['tors']['mod']:
freqs = ()
else:
freqs, imag, zpe = read_harmonic_freqs(
pf_filesystems, run_prefix, zrxn=zrxn)
tors_zpe = 0.0
return freqs, imag, tors_zpe, scale_factor, tors_freqs, rt_freqs1
def read_harmonic_freqs(pf_filesystems, run_prefix, zrxn=None):
""" Read the harmonic frequencies for the minimum
energy conformer
"""
# Get the harmonic filesys information
[cnf_fs, harm_path, min_cnf_locs, _, _] = pf_filesystems['harm']
freqs, imag, zpe = read_locs_harmonic_freqs(
cnf_fs, harm_path, min_cnf_locs, run_prefix, zrxn=zrxn)
return freqs, imag, zpe
def read_locs_harmonic_freqs(
cnf_fs, harm_path, cnf_locs, run_prefix, zrxn=None):
""" Read the harmonic frequencies for a specific conformer
"""
# probably should read freqs
# Do the freqs obtain for two species for fake and pst
if cnf_locs is not None:
# Obtain geom and freqs from filesys
geo = cnf_fs[-1].file.geometry.read(cnf_locs)
hess = cnf_fs[-1].file.hessian.read(cnf_locs)
ioprinter.reading('Hessian', cnf_fs[-1].path(cnf_locs))
# Build the run filesystem using locs
fml_str = automol.geom.formula_string(geo)
vib_path = job_path(run_prefix, 'PROJROT', 'FREQ', fml_str)
# Obtain the frequencies
ioprinter.info_message(
'Calling ProjRot to diagonalize Hessian and get freqs...')
script_str = autorun.SCRIPT_DCT['projrot']
freqs, _, imag_freqs, _ = autorun.projrot.frequencies(
script_str, vib_path, [geo], [[]], [hess])
# Calculate the zpve
ioprinter.frequencies(freqs)
zpe = (sum(freqs) / 2.0) * phycon.WAVEN2EH
# Check imaginary frequencies and set freqs
if zrxn is not None:
if len(imag_freqs) > 1:
ioprinter.warning_message(
'Saddle Point has more than',
'one imaginary frequency')
imag = imag_freqs[0]
else:
imag = None
else:
ioprinter.error_message(
'Reference geometry is missing for harmonic frequencies')
return freqs, imag, zpe
def read_anharmon_matrix(pf_filesystems):
""" Read the anharmonicity matrix """
# Set up vpt2 level filesystem for rotational values
[cnf_fs, cnf_path, min_cnf_locs, _, _] = pf_filesystems['vpt2']
if cnf_path:
xmat = cnf_fs[-1].file.anharmonicity_matrix.read(
min_cnf_locs)
ioprinter.reading('Anharm matrix', cnf_path)
else:
ioprinter.error_message('No anharm matrix at path', cnf_path)
return xmat
def tors_projected_freqs_zpe(pf_filesystems, mess_hr_str, projrot_hr_str,
prefix, zrxn=None, conf=None):
""" Get frequencies from one version of ProjRot
"""
ret = tors_projected_freqs(
pf_filesystems, mess_hr_str, projrot_hr_str,
prefix, zrxn=zrxn, conf=conf)
freqs, imag, tors_zpe, scale_factor, _, _ = ret
return freqs, imag, tors_zpe, scale_factor
def tors_projected_freqs(pf_filesystems, mess_hr_str, projrot_hr_str,
prefix, zrxn=None, conf=None):
""" Get frequencies from one version of ProjRot
"""
run_prefix = pf_filesystems['run_prefix']
# Build the filesystems
[harm_cnf_fs, _, harm_min_locs, _, _] = pf_filesystems['harm']
[tors_cnf_fs, _, tors_min_locs, _, _] = pf_filesystems['tors']
if conf:
harm_min_locs = conf[1]
harm_cnf_fs = conf[2]
# Read info from the filesystem that is needed
harm_geo = harm_cnf_fs[-1].file.geometry.read(harm_min_locs)
hess = harm_cnf_fs[-1].file.hessian.read(harm_min_locs)
tors_geo = tors_cnf_fs[-1].file.geometry.read(tors_min_locs)
ioprinter.reading('Hessian', harm_cnf_fs[-1].path(harm_min_locs))
fml_str = automol.geom.formula_string(harm_geo)
vib_path = job_path(
run_prefix, 'PROJROT', 'PROJFREQ', fml_str, print_path=True)
# Read info for the hindered rotors and calculate the ZPVE
ioprinter.info_message(' - Calculating the torsional ZPVES using MESS...')
script_str = autorun.SCRIPT_DCT['messpf']
tors_freqs, _ = autorun.mess.torsions(
script_str, vib_path, tors_geo, mess_hr_str)
tors_zpe = (sum(tors_freqs) / 2.0) * phycon.WAVEN2EH
ioprinter.info_message(
' - Calculating the RT and RT-rotor projected frequencies ProjRot')
# NEW projrot writing
script_str = autorun.SCRIPT_DCT['projrot']
dist_cutoff_dct1 = {('H', 'O'): 2.26767, ('H', 'C'): 2.26767}
dist_cutoff_dct2 = {('H', 'O'): 2.83459, ('H', 'C'): 2.83459, ('C', 'O'): 3.7807}
rotor_dist1_str = projrot_io.writer.projection_distance_aux(
dist_cutoff_dct=dist_cutoff_dct1)
rotor_dist2_str = projrot_io.writer.projection_distance_aux(
dist_cutoff_dct=dist_cutoff_dct2)
aux_dct1 = {'dist_rotpr.dat': rotor_dist1_str}
aux_dct2 = {'dist_rotpr.dat': rotor_dist2_str}
rt_freqs1, rth_freqs1, rt_imag1, _ = autorun.projrot.frequencies(
script_str, vib_path, [harm_geo], [[]], [hess],
rotors_str=projrot_hr_str, aux_dct=aux_dct1)
_, rth_freqs2, rt_imag2, _ = autorun.projrot.frequencies(
script_str, vib_path, [harm_geo], [[]], [hess],
rotors_str=projrot_hr_str, aux_dct=aux_dct2)
# Calculate harmonic ZPVE from all harmonic freqs, including torsionals
harm_zpe = (sum(rt_freqs1) / 2.0) * phycon.WAVEN2EH
ioprinter.info_message(
'harmonic zpe is {} kcal/mol'.format(harm_zpe))
# Calculate harmonic ZPVE from freqs where torsions have been projected out
# Value from both projrot versions, which use different projection schemes
harm_zpe_notors_1 = (sum(rth_freqs1) / 2.0) * phycon.WAVEN2EH
harm_zpe_notors_2 = (sum(rth_freqs2) / 2.0) * phycon.WAVEN2EH
# Calcuate the difference in the harmonic ZPVE from projecting out torsions
harm_tors_zpe = harm_zpe - harm_zpe_notors_1
harm_tors_zpe_2 = harm_zpe - harm_zpe_notors_2
# Check to see which of the above ZPVEs match more closely with tors ZPVE
# calculated directly by treating the torsions in MESS
diff_tors_zpe = harm_tors_zpe - tors_zpe
diff_tors_zpe_2 = harm_tors_zpe_2 - tors_zpe
if diff_tors_zpe <= diff_tors_zpe_2:
freqs = rth_freqs1
imag_freqs = rt_imag1
proj_zpe = harm_zpe_notors_1
else:
freqs = rth_freqs2
imag_freqs = rt_imag2
proj_zpe = harm_zpe_notors_2
# Check imaginary frequencies and set freqs
if zrxn is not None:
if len(imag_freqs) > 1:
ioprinter.warning_message(
'There is more than one imaginary frequency')
imag = max(imag_freqs)
else:
imag = None
# NEW autorun function for the frequencies
# mess_script_str = autorun.SCRIPT_DCT['messpf']
# projrot_script_str = autorun.SCRIPT_DCT['projrot']
# proj_freqs, proj_imags, proj_zpe, harm_freqs, tors_freqs = autorun.projected_frequencies(
# mess_script_str, projrot_script_str, vib_path,
# mess_hr_str, projrot_hr_str,
# tors_geo, harm_geo, hess)
# if saddle:
# proj_imag = proj_imags[0]
# else:
# proj_imag = []
# NEW scale factor functions
# scale_factor = automol.prop.freq.rotor_scale_factor_from_harmonics(
# harm_freqs, tors_freqs)
# Create a scaling factor for the frequencies
# First sort tors frequencies in ascending order
sort_tors_freqs = sorted(tors_freqs)
# keep only freqs whose RRHO freqs are above a threshold
freq_thresh = 50.
log_rt_freq = 0.0
nfreq_remove = 0
for freq in rt_freqs1:
if freq > freq_thresh:
log_rt_freq += numpy.log(freq)
else:
nfreq_remove += 1
log_freq = [numpy.log(freq) for freq in freqs]
log_freq = sum(log_freq)
log_tors_freq = 0.0
idx_remove = []
for idx, freq in enumerate(sort_tors_freqs):
if idx+1 > nfreq_remove:
log_tors_freq += numpy.log(freq)
else:
idx_remove.append(tors_freqs.index(freq))
# log_rt_freq = [numpy.log(freq) for freq in rt_freqs1]
# log_rt_freq = sum(log_rt_freq)
# log_tors_freq = [numpy.log(freq) for freq in tors_freqs]
# log_tors_freq = sum(log_tors_freq)
#unproj_prod = numpy.prod(rt_freqs1)
#proj_prod = numpy.prod(freqs) * numpy.prod(tors_freqs)
#print('proj_prod test:', unproj_prod, proj_prod)
# ioprinter.info_message('log_freq_tests:', log_rt_freq, log_freq, log_tors_freq)
#scale_factor = unproj_prod / proj_prod
# generate the scaling factor
factor = numpy.exp(log_rt_freq - log_freq - log_tors_freq)
ioprinter.info_message('freq test:', freqs, tors_freqs, rt_freqs1)
tau_factor = numpy.exp(log_rt_freq - log_freq)
tau_factor_mode = tau_factor
# generate the set of indices for torsions that are two be scales
scale_factor = (idx_remove, factor)
ioprinter.info_message('scale fact test', scale_factor)
ioprinter.info_message('TAU FACTOR {:4.6f} \t {:g} \t {:3.6f} {} '
.format(tau_factor_mode, len(tors_freqs), factor, '-'.join([str(ridx) for ridx in idx_remove])))
# Check if there are significant differences caused by the rotor projection
diff_tors_zpe *= phycon.EH2KCAL
diff_tors_zpe_2 *= phycon.EH2KCAL
if abs(diff_tors_zpe) > 0.2 and abs(diff_tors_zpe_2) > 0.2:
ioprinter.warning_message(
'There is a difference of ',
'{0:.2f} and {1:.2f}'.format(diff_tors_zpe, diff_tors_zpe_2),
'kcal/mol between harmonic and hindered torsional ZPVEs')
return (proj_freqs, proj_imag, proj_zpe,
scale_factor, tors_freqs, harm_freqs)
def scale_frequencies(freqs, tors_zpe,
spc_mod_dct_i, scale_method='3c'):
""" Scale frequencies according to some method
obtain a corrected zpe
"""
thy_info = spc_mod_dct_i['vib']['geolvl'][1][1]
print('thy info scale test', thy_info)
method, basis = thy_info[1], thy_info[2]
scaled_freqs, scaled_zpe = automol.prop.freq.anharm_by_scaling(
freqs, method, basis, scale_method='c3')
tot_zpe = scaled_zpe + tors_zpe
return scaled_freqs, tot_zpe
|
{"hexsha": "711f2cde72c0a8ad2e2cdd0124f82195b42cfc16", "size": 13518, "ext": "py", "lang": "Python", "max_stars_repo_path": "mechroutines/pf/models/_vib.py", "max_stars_repo_name": "sjklipp/mechdriver", "max_stars_repo_head_hexsha": "17c3d9bc82116954b331955e87a60e9adc5e1de9", "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": "mechroutines/pf/models/_vib.py", "max_issues_repo_name": "sjklipp/mechdriver", "max_issues_repo_head_hexsha": "17c3d9bc82116954b331955e87a60e9adc5e1de9", "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": "mechroutines/pf/models/_vib.py", "max_forks_repo_name": "sjklipp/mechdriver", "max_forks_repo_head_hexsha": "17c3d9bc82116954b331955e87a60e9adc5e1de9", "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": 36.7336956522, "max_line_length": 108, "alphanum_fraction": 0.6641515017, "include": true, "reason": "import numpy", "num_tokens": 3973}
|
import pandas as pd
from rdflib import URIRef, BNode, Literal, Graph
from rdflib.namespace import RDF, RDFS, FOAF, XSD
from rdflib import Namespace
import numpy as np
import math
import sys
import argparse
import json
import requests
collection = requests.get("https://nakamura196.github.io/piranesi/print/iiif/top.json").json()
manifests = collection["manifests"]
df = []
df.append(["URL"])
for manifest in manifests:
no = ""
metadata = manifest["metadata"]
check = {}
for obj in metadata:
label = obj["label"]
value = obj["value"]
if "�" in value and label != "検索フィールド":
check[label] = value
if label == "file_no":
no = value
if len(check.keys()) > 0:
print(no, check)
row = []
row.append("https://piranesi.dl.itc.u-tokyo.ac.jp/item/"+no)
for key in check:
row.append("【"+key+"】"+check[key])
df.append(row)
df = pd.DataFrame(df)
df.to_excel('data/check.xlsx',index=False, header=False)
|
{"hexsha": "d370b63bc7e8a3e80e4a58169d485627a43efd6c", "size": 1033, "ext": "py", "lang": "Python", "max_stars_repo_path": "batch/iizuka/check.py", "max_stars_repo_name": "utda/piranesi", "max_stars_repo_head_hexsha": "28c41334fdc7df44bd1b892542eb0423edd13013", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-15T03:16:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-15T03:16:33.000Z", "max_issues_repo_path": "batch/iizuka/check.py", "max_issues_repo_name": "utda/piranesi", "max_issues_repo_head_hexsha": "28c41334fdc7df44bd1b892542eb0423edd13013", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-08-31T19:36:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T12:12:09.000Z", "max_forks_repo_path": "batch/iizuka/check.py", "max_forks_repo_name": "utda/piranesi", "max_forks_repo_head_hexsha": "28c41334fdc7df44bd1b892542eb0423edd13013", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-15T03:16:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-15T03:16:36.000Z", "avg_line_length": 19.8653846154, "max_line_length": 94, "alphanum_fraction": 0.6156824782, "include": true, "reason": "import numpy", "num_tokens": 272}
|
#This file is used to process images
from whitebox import WhiteboxTools
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import math
import cv2
from shapely.geometry import Point,LineString, MultiPoint
from shapely.ops import split
#Cut out lakes from stream shapefile
def clip_lakes(s_file,wb_file,outfile):
# Initialize whitebox tools
wbt = WhiteboxTools()
# Sets the Whitebox working directory
#wbt.work_dir = ""
# Clip the streams to exclude lakes
wbt.erase(s_file, wb_file, outfile)
#Filter shapefile segments
def filter_segments(clip_file,filter_file,epsg,min_length=500,min_vertices=100, max_vertices=224):
#Load clipped file to perform filtering
s_clipped = gpd.read_file(clip_file)
print("Filtering from {} segments".format(s_clipped.shape[0]))
# Drop un-necessary columns (keep NID and geometry)
s_clipped.drop(s_clipped.columns.difference(['NID', 'geometry']), 1, inplace=True)
# Reproject from EPSG:4269 to EPSG:2958 (NAD83(CSRS) / UTM zone 17N) so units are in metres
s_clipped = s_clipped.to_crs(epsg)
#Calculate the number of vertices per polyline segment
vertices = []
for i in range(0, s_clipped.shape[0]):
vertices.append(len(s_clipped.loc[[i],'geometry'].values[0].xy[0]))
s_clipped = s_clipped.assign(n_vertices=vertices)
# Only keep segments with more than min number of vertices
s_clipped = s_clipped[s_clipped['n_vertices'] > min_vertices].reset_index(drop=True)
#Split long polylines at max_vertices (use floor of max)
# Create a dataframe to hold the new split rows
new_rows = gpd.GeoDataFrame()
drop_rows = []
for i in range(0,s_clipped.shape[0]):
n_vertices = s_clipped.loc[[i],'n_vertices'].values
if n_vertices > max_vertices:
n_divs = math.ceil(n_vertices/max_vertices)
#Get the points to split on
points = [math.floor(n_vertices*j/n_divs) for j in range(n_divs+1)]
#print("Splitting on ", points)
#Split the polyline at the split points
pline = s_clipped.loc[[i], 'geometry'].values[0]
plines = split(pline, MultiPoint([pline.coords[j] for j in points[1:-1]]))
#Create a new geodataframe row for each new line
for line in plines:
new_rows=new_rows.append(s_clipped.iloc[i],ignore_index=True)
new_rows.loc[-1,'geometry'] = line
#List of old rows to drop
drop_rows.append(i)
print("Dropping {} rows".format(len(drop_rows)))
s_clipped.drop(drop_rows)
print("Adding {} new rows".format(new_rows.shape[0]))
s_clipped.append(new_rows,ignore_index=True).reset_index()
# Calculate the length of each line
s_clipped['length'] = s_clipped['geometry'].length
# Only keep segements larger than minimum length
s_clipped = s_clipped[s_clipped['length'] > min_length].reset_index()
# Test plot
#s_clipped.loc[[15], 'geometry'].plot()
#plt.show()
#Save clipped files
s_clipped.to_file(filter_file)
return(s_clipped)
#Function to convert polylines to images
def create_images(filter_file,images):
# Function to rotate points about the origin
def rotate(x, y, theta):
xx = x * math.cos(theta) + y * math.sin(theta)
yy = -x * math.sin(theta) + y * math.cos(theta)
return xx, yy
def convert2img(pline, label, img_size=224):
# Get a list of the X and Y coordinates
x, y = pline[0].xy
x = np.array(x)
y = np.array(y)
# If too few points discard
if len(x) < 15:
"Print discarding image due to too few points"
return None
else:
# Translation to set first point equal to the origin 0,0
x = x - x[0]
y = y - y[0]
angle = math.atan2(y[-1], x[-1])
# Rotate the images to be horizontal
x, y = rotate(x, y, angle)
angle = math.atan2(y[-1], x[-1])
# Remove bias from the image coordinates
x = x - x.min()
y = y - y.min()
# Calculate the aspect ratio
width_to_height = x.max() / y.max()
# If ratio < 1 scale by y.max
if width_to_height <= 1:
x = (x / y.max() + (1 - width_to_height) / 2) * img_size
y = y / y.max() * img_size
# Otherwise scale by x.max
else:
y = (y / x.max() + ((1 - 1 / width_to_height) / 2)) * img_size
x = x / x.max() * img_size
# Create a list of pixel coordiantes
pts = np.int32([x, y]).T
canvas = np.ones((img_size, img_size, 3), np.uint8) * 255
img = cv2.polylines(canvas, [pts], False, (0, 0, 0))
# Return the image
return img
#Load filtered file
s_filtered = gpd.read_file(filter_file)
# Convert all lines to images
count = 0
saveto = images
used = []
print("Saving images to {}".format(saveto))
# Loop through each image
for i in range(0, s_filtered.shape[0]):
line = s_filtered.loc[[i], 'geometry'].values
img = convert2img(line, i)
# If an image is returned
if img is not None:
used.append(i)
# Save the image
cv2.imwrite("{}{}.jpg".format(saveto, i), img)
count = count + 1
print("{} images exported".format(count))
if __name__ == '__main__':
#Set folder and site
folder = "" #local directory
inputs = "{}Inputs/".format(folder)
results = "{}Results/".format(folder)
images = "{}Images/".format(folder)
# List of input stream and watershed files
s_file = "{}NHN_04HA000_2_0_HN_NLFLOW_1.shp".format(inputs)
wb_file = "{}NHN_04HA000_2_0_HD_WATERBODY_2.shp".format(inputs)
#Output files
clip_file = "{}s_clipped.shp".format(results)
filter_file = "{}s_filtered.shp".format(results)
#clip surface waterbodies from the streams if the clipped file doesn't already exist
try:
clipped = gpd.read_file(clip_file)
print("Clipped streams loaded from {}".format(clip_file))
except:
print("Clipping streams for {}".format(s_file))
clip_lakes(s_file,wb_file,clip_file)
clipped = gpd.read_file(clip_file)
clipped.plot()
plt.title("Clipped stream segments")
plt.show()
#Reproject to UTM and filter
#UTM 17N is EPSG:2958
try:
filtered = gpd.read_file(filter_file)
print("Filtered streams loaded from {}".format(filter_file))
except:
print("Filtering streams for {}".format(s_file))
filtered = filter_segments(clip_file,filter_file,"EPSG:2958")
filtered.plot()
plt.title("Filtered stream segments")
plt.show()
#Normalize lines and convert to images
create_images(filter_file,images)
|
{"hexsha": "f98a224f62e4cfe97a911eff327add22e9063b85", "size": 6962, "ext": "py", "lang": "Python", "max_stars_repo_path": "preprocess.py", "max_stars_repo_name": "codykupf/river-cnn", "max_stars_repo_head_hexsha": "d1c297d78cebd57520f05f954283f37c3f6762e2", "max_stars_repo_licenses": ["ECL-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": "preprocess.py", "max_issues_repo_name": "codykupf/river-cnn", "max_issues_repo_head_hexsha": "d1c297d78cebd57520f05f954283f37c3f6762e2", "max_issues_repo_licenses": ["ECL-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": "preprocess.py", "max_forks_repo_name": "codykupf/river-cnn", "max_forks_repo_head_hexsha": "d1c297d78cebd57520f05f954283f37c3f6762e2", "max_forks_repo_licenses": ["ECL-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": 30.6696035242, "max_line_length": 98, "alphanum_fraction": 0.6199367998, "include": true, "reason": "import numpy", "num_tokens": 1817}
|
import numpy as np
import backend as B
import pytest
@pytest.fixture(params=[512])
def input_size(request):
return (request.param)
@pytest.fixture(params=[[128, 128, 1]])
def image_shape(request):
return request.param
@pytest.fixture(params=[1])
def min_scale(request):
return (request.param)
@pytest.fixture
def load_image():
def call(shape, intensity_channel):
image = np.ones(shape)
image[:, :, 0] = intensity_channel
return image.astype(np.uint8)
return call
@pytest.fixture(params=[100])
def intensity_channel(request):
return request.param
@pytest.fixture(params=[529])
def dims(request):
return request.param
@pytest.fixture(params=[[2, 1]])
def point2D_a(request):
return request.param
@pytest.fixture(params=[[1.8, 2.5]])
def point2D_b(request):
return request.param
@pytest.fixture(params=[(1, 17, 176, 128)])
def output_shape(request):
return request.param
@pytest.fixture
def load_output():
def call(shape):
output = np.ones(shape)
return output
return call
@pytest.mark.parametrize("multiple", [64])
def test_get_dims_x64(dims, multiple):
dims = B.get_dims_x64(dims, 64)
assert (dims % multiple == 0)
@pytest.mark.parametrize("transformation_size", [[512, 64]])
def test_get_transformation_size(input_size, image_shape, transformation_size):
size = B.get_transformation_size(
input_size, image_shape[0], image_shape[1])
assert (size[0] == transformation_size[0])
assert (size[1] % transformation_size[1] == 0)
@pytest.mark.parametrize("transformation_scale", [[0.64, 0.64]])
def test_get_transformation_scale(
input_size, image_shape, transformation_scale):
size = B.get_transformation_size(input_size, image_shape[0],
image_shape[1])
scale = B.get_transformation_scale(image_shape[0], size[0], size[1], 200)
assert (list(scale) == transformation_scale)
@pytest.mark.parametrize("image_center", [[64, 64]])
def test_calculate_image_center(load_image, image_shape, intensity_channel,
image_center):
test_image = load_image(image_shape, intensity_channel)
center_W, center_H = B.calculate_image_center(test_image)
assert image_center == [center_W, center_H]
@pytest.mark.parametrize("rotated_point", [np.array([1, -2])])
def test_rotate_point(point2D_a, rotated_point):
point = B.rotate_point(point2D_a, -90)
point = (np.array(point)).astype(np.int8)
assert np.allclose(point, rotated_point)
@pytest.mark.parametrize("third_point", [np.array([3.5, 1.2])])
def test_calculate_third_point(point2D_a, point2D_b, third_point):
point = B.calculate_third_point(np.array(point2D_a), np.array(point2D_b))
assert np.allclose(point, third_point)
@pytest.mark.parametrize("resized_output_shape", [(1, 17, 256, 352)])
def test_resize_output(output_shape, load_output, resized_output_shape):
test_output = load_output(output_shape)
resized_output = B.resize_output(test_output, (352, 256))
assert resized_output_shape == resized_output.shape
|
{"hexsha": "65a07b70e39263fd503b1ec63e2f916bc8be1de9", "size": 3125, "ext": "py", "lang": "Python", "max_stars_repo_path": "examples/human_pose_2d/test/backend/preprocess_test.py", "max_stars_repo_name": "ManuelMeder/paz", "max_stars_repo_head_hexsha": "6de73c0a99e0f9c7233c2797eebba2bb01631e6c", "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": "examples/human_pose_2d/test/backend/preprocess_test.py", "max_issues_repo_name": "ManuelMeder/paz", "max_issues_repo_head_hexsha": "6de73c0a99e0f9c7233c2797eebba2bb01631e6c", "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/human_pose_2d/test/backend/preprocess_test.py", "max_forks_repo_name": "ManuelMeder/paz", "max_forks_repo_head_hexsha": "6de73c0a99e0f9c7233c2797eebba2bb01631e6c", "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.6548672566, "max_line_length": 79, "alphanum_fraction": 0.70752, "include": true, "reason": "import numpy", "num_tokens": 740}
|
# -*- coding: utf-8 -*-
"""
Created on Wed May 11 13:45:00 2016
@author: kbefus
path to the cgw_model needs to be added to the path before importing
cgw_package_tools
e.g.:
import sys
kbpath = 'C:/Research/Coastalgw/Model_develop/'
sys.path.insert(1,kbpath)
"""
from __future__ import print_function
import os
import numpy as np
import geopandas as gpd
from cgw_model.cgw_utils import cgw_general_utils as cgu
from cgw_model.cgw_utils import cgw_raster_utils as cru
from cgw_model.cgw_utils import cgw_feature_utils as cfu
from cgw_model.cgw_utils import cgw_caf_utils as ccu
from cgw_model.cgw_modflow import cgw_mf_utils as cmfu
#from cgw_model.cgw_zonebudget import cgw_zb_utils as zbu
class Model_domain_driver(object):
'''
Create coastal groundwater domain model class
'''
def __init__(self,domain_poly=None,
cell_spacing=None, input_dir='',model_in_dir=None,
domain_shp=None, active_domain=None,
elev_fname=None, rchg_fname=None,
k_fnames=None,sea_level=0.,in_proj=None,use_ll=True):
self.cell_spacing = cell_spacing
self.input_dir = input_dir
self.model_in_dir = model_in_dir
self.domain_shp = domain_shp
self.domain_poly = domain_poly
self.active_domain = active_domain
self.sea_level = sea_level
self.in_proj = in_proj
self.use_ll = use_ll
if (elev_fname is not None):
self.elev_path = os.path.join(self.input_dir,elev_fname)
if (rchg_fname is not None):
self.rchg_path = os.path.join(self.input_dir,rchg_fname)
if (self.domain_shp is not None) and (self.domain_poly is None):
if hasattr(self.domain_shp,'to_file'):
self.domain_poly = self.domain_shp.loc[self.active_domain].geometry
else:
self.domain_poly = cfu.shp_to_polygon(self.domain_shp)[0][self.active_domain]
if (k_fnames is not None):
self.k_fnames = k_fnames
def make_modflow_grid(self):
to_grid_dict = {'shp':self.domain_poly,
'cell_spacing':self.cell_spacing,
'active_feature':self.active_domain,
'in_proj':self.in_proj}
self.XYnodes,self.model_polygon,self.grid_transform = cfu.shp_to_grid(**to_grid_dict)
self.domain_extent = [self.XYnodes[0].min(),self.XYnodes[1].min(),self.XYnodes[0].max(),self.XYnodes[1].max()]
def make_cc(self):
self.cc,self.cc_proj,self.cc_ll = cfu.nodes_to_cc(self.XYnodes,self.grid_transform)
self.nrow,self.ncol = self.cc[0].shape
dlat,dlong = self.cc_ll[1][0,0]-self.cc_ll[1][1,0],self.cc_ll[0][0,0]-self.cc_ll[0][0,1]
self.domain_extent_ll = [self.cc_ll[0].min()-dlong/2.,self.cc_ll[1].min()-dlat/2.,
self.cc_ll[0].max()+dlong/2.,self.cc_ll[1].max()+dlat/2.]
return
def find_active_cells(self,rmv_isolated=True,min_area=1e3):
'''Find active model cells using polygon area.
Inputs
----------
rmv_isolated: bool, remove isolated areas
min_area: float, minimum area/number of cells to be considered not isolated
'''
ir,ic,_ = cfu.gridpts_in_shp(self.model_polygon,self.cc)
self.active_cells = cgu.define_mask(self.cc,[ir,ic])
if rmv_isolated:
self.active_cells = cmfu.clean_ibound(self.active_cells,check_inactive=True,min_area=min_area)
return
def load_nc_grids(self,nc_fname=None):
if os.path.isfile(nc_fname):
f = cru.netCDF4.Dataset(nc_fname)
self.elevation = f.variables['elev'][:]
self.recharge = f.variables['recharge'][:]
self.nrow,self.ncol = self.recharge.shape
if 'hk' in f.variables:
self.hk_in_array = f.variables['hk'][:]
if 'thick' in list(f.variables.keys()):
self.hk_in_botm = f.variables['thick'][:]
# Use hk_in_botm to cull layers
self.hk_in_botm,maxnlay = cmfu.cull_layers(in_array=self.hk_in_botm)
else:
self.hk_in_botm = []
if 'vk' in list(f.variables.keys()):
self.vk_in_array = f.variables['vk'][:]
if 'thick' in list(f.variables.keys()):
if maxnlay.shape[0] < self.hk_in_array.shape[0]:
self.hk_in_array=self.hk_in_array[maxnlay]
self.vk_in_array=self.vk_in_array[maxnlay]
if 'density' in f.variables:
self.density = f.variables['density'][:]
if 'sea_level' in f.variables:
self.sea_level = f.variables['sea_level'][:]
f.close()
if hasattr(self, 'active_cells'):
if self.elevation.shape != self.active_cells.shape:
# Need to account for no data and clipping from previous run
ref_name=os.path.join(self.model_in_dir,'usgs.model.reference')
if os.path.isfile(ref_name):
ref_dict=cgu.read_model_ref(ref_name)
grid_tform = cgu.make_grid_transform(ref_dict,from_ref=True)
mask_array = cgu.match_grid_size(mainXY=self.cc_proj,new_xyul=grid_tform[1],
new_shape = self.elevation.shape)
apply_dict = {'func':cgu.shrink_ndarray,
'func_args':{'mask_in':mask_array,
'shape_out':self.elevation.shape},'skip_vals':['conversion_mask']}
cgu.recursive_applybydtype(self,**apply_dict)
return True
else:
print("Loading grid data...({} not found)".format(os.path.basename(nc_fname)))
return False
def load_griddata(self,use_mask=True, load_vk=False,
save_nc_grids=False,load_nc_grids_bool=False,
max_elev=1e5, landfel=False,n_proc=8):
if use_mask:
mask = ~self.active_cells
else:
mask = None
if load_nc_grids_bool:
out_nc_name = os.path.join(self.model_in_dir,'{}.nc'.format(os.path.basename(self.model_in_dir)))
load_bool = self.load_nc_grids(nc_fname=out_nc_name)
save_nc_grids = not load_bool
if save_nc_grids:
out_nc_name = os.path.join(self.model_in_dir,'{}.nc'.format(os.path.basename(self.model_in_dir)))
save_grid_dict = {'out_desc':'Grid data for cgw model {}'.format(os.path.basename(self.model_in_dir)),
'dims':{'dim_order':['Y','X'],
'X':{'attr':{'var_desc':'X coordinate of cell center in model reference frame',
'long_name':'X','units':'m'},
'data':self.cc[0][0,:]},
'Y':{'attr':{'var_desc':'Y coordinate of cell center in model reference frame',
'long_name':'Y','units':'m'},
'data':self.cc[1][:,0]}},
'vars':[]}
self.gdict = {'crs':self.in_proj}
if self.use_ll:
self.gdict.update({'new_xy':self.cc_ll})#,'in_extent':self.domain_extent_ll})
else:
self.gdict.update({'new_xy':self.cc_proj})#,'in_extent':self.domain_extent})
if hasattr(self,'elev_path') and not hasattr(self,'elevation'):
self.elevation = cru.gdal_loadgrid(self.elev_path,**self.gdict)
if landfel:
# Fill pits in dem in areas above sea level
fel_dict = {'work_dir':self.model_in_dir,
'xy':self.cc_proj,'elev_data':self.elevation,
'proj': self.grid_transform[0],'n_proc':n_proc,
'sea_level':self.sea_level}
self.elevation = cru.landfel_taudem(**fel_dict)
with np.errstate(invalid='ignore'):
self.elevation[np.abs(self.elevation)>1e5] = np.nan
if save_nc_grids:
save_grid_dict.update({'elev':{'attr':{'var_desc':'Land surface elevation in meters above sea level',
'long_name':'elevation','units':'m'},
'dims':('Y','X'),
'data':self.elevation}})
save_grid_dict['vars'].append('elev')
elif hasattr(self,'elevation') and save_nc_grids:
save_grid_dict.update({'elev':{'attr':{'var_desc':'Land surface elevation in meters above sea level',
'long_name':'elevation','units':'m'},
'dims':('Y','X'),
'data':self.elevation}})
save_grid_dict['vars'].append('elev')
if hasattr(self,'rchg_path') and not hasattr(self,'recharge'):
self.recharge = cru.gdal_loadgrid(self.rchg_path,**self.gdict)
if save_nc_grids:
save_grid_dict.update({'recharge':{'attr':{'var_desc':'Groundwater recharge in meters per year',
'long_name':'recharge','units':'m/yr'},
'dims':('Y','X'),
'data':self.recharge}})
save_grid_dict['vars'].append('recharge')
elif hasattr(self,'rchg_path') and save_nc_grids:
save_grid_dict.update({'recharge':{'attr':{'var_desc':'Groundwater recharge in meters per year',
'long_name':'recharge','units':'m/yr'},
'dims':('Y','X'),
'data':self.recharge}})
save_grid_dict['vars'].append('recharge')
if hasattr(self,'density') and save_nc_grids:
save_grid_dict.update({'density':{'attr':{'var_desc':'Seawater density',
'long_name':'Density of seawater','units':'kg/m3'},
'dims':('Y','X'),
'data':self.density}})
save_grid_dict['vars'].append('density')
if hasattr(self,'sea_level') and save_nc_grids:
save_grid_dict.update({'sea_level':{'attr':{'var_desc':'Sea level',
'long_name':'Sea level elevation above NAVD88','units':'m'},
'dims':('Y','X'),
'data':self.sea_level}})
save_grid_dict['vars'].append('sea_level')
if hasattr(self,'k_fnames') and not hasattr(self,'hk_in_array'):
self.hk_in_array,self.vk_in_array,self.hk_in_botm = cru.read_hk(self.k_fnames,griddata_dict=self.gdict,
load_vk=load_vk)
if len(self.hk_in_botm) > 0:
# Remove purely null data layers to save time and space with Modflow files
self.hk_in_botm,maxnlay = cmfu.cull_layers(in_array=self.hk_in_botm)
if maxnlay.shape[0] < self.hk_in_array.shape[0]:
self.hk_in_array=self.hk_in_array[maxnlay]
if len(self.vk_in_array)>0:
self.vk_in_array=self.vk_in_array[maxnlay]
if save_nc_grids:
save_grid_dict['dims']['dim_order'].insert(0,'layers')
save_grid_dict['dims'].update({'layers':{'attr':{'var_desc':'Layers of hydrogeologic framework data',
'long_name':'layers','units':'n/a'},
'data':np.arange(self.hk_in_array.shape[0])}})
save_grid_dict.update({'hk':{'attr':{'var_desc':'Horizontal hydraulic conductivity in meters per day',
'long_name':'Horizontal hydraulic conductivity','units':'m/day'},'dims':('layers','Y','X'),
'data':self.hk_in_array}})
save_grid_dict['vars'].append('hk')
if self.vk_in_array is not None:
save_grid_dict.update({'vk':{'attr':{'var_desc':'Vertical hydraulic conductivity in meters per day',
'long_name':'Vertical hydraulic conductivity','units':'m/day'},
'dims':('layers','Y','X'),
'data':self.hk_in_array}})
save_grid_dict['vars'].append('vk')
if len(self.hk_in_botm)>0:
save_grid_dict.update({'thick':{'attr':{'var_desc':'Thickness of layer in meters','long_name':'layer thickness',
'units':'m'},
'dims':('layers','Y','X'),
'data':self.hk_in_botm}})
save_grid_dict['vars'].append('thick')
elif hasattr(self,'hk_in_array') and save_nc_grids:
save_grid_dict['dims']['dim_order'].insert(0,'layers')
save_grid_dict['dims'].update({'layers':{'attr':{'var_desc':'Layers of hydrogeologic framework data',
'long_name':'layers','units':'n/a'},
'data':np.arange(self.hk_in_array.shape[0])}})
save_grid_dict.update({'hk':{'attr':{'var_desc':'Horizontal hydraulic conductivity in meters per day',
'long_name':'Horizontal hydraulic conductivity','units':'m/day'},'dims':('layers','Y','X'),
'data':self.hk_in_array}})
save_grid_dict['vars'].append('hk')
if self.vk_in_array is not None:
save_grid_dict.update({'vk':{'attr':{'var_desc':'Vertical hydraulic conductivity in meters per day',
'long_name':'Vertical hydraulic conductivity','units':'m/day'},
'dims':('layers','Y','X'),
'data':self.hk_in_array}})
save_grid_dict['vars'].append('vk')
if len(self.hk_in_botm)>0:
save_grid_dict.update({'thick':{'attr':{'var_desc':'Thickness of layer in meters','long_name':'layer thickness',
'units':'m'},
'dims':('layers','Y','X'),
'data':self.hk_in_botm}})
save_grid_dict['vars'].append('thick')
if save_nc_grids:
cru.save_nc(fname=out_nc_name,out_data_dict=save_grid_dict)
return
def run_make_domain(self,use_mask=True, load_vk=False, save_nc_grids=False,load_nc_grids_bool=False):
self.make_modflow_grid()
self.make_cc()
self.find_active_cells()
self.load_griddata(use_mask=use_mask,load_vk=load_vk,
save_nc_grids=save_nc_grids,load_nc_grids_bool=load_nc_grids_bool)
class Assign_cell_types(object):
'''
Use Model_domain_driver object with ws_shp feature of watershed boundaries to
and loaded grids to define model cell types
'''
def __init__(self,domain_obj=None,ws_shp=None,waterbody_shp=None):
self.domain_obj = domain_obj
self.ws_shp = ws_shp
self.waterbody_shp = waterbody_shp
def find_inland_cells(self,find_water=True):
self.caf_land,self.caf_water = ccu.find_land_water(self.ws_shp,self.domain_obj.domain_poly,find_water=find_water)
inland_inds = cfu.gridpts_in_shp(self.caf_land[0],self.domain_obj.cc_ll)
self.land_cells = cgu.define_mask(self.domain_obj.cc_ll,inland_inds[:2])
def find_waterbody_cells(self):
# waterbody_fname = os.path.join(self.domain_obj.input_dir,self.waterbody_shp)
waterbody_inds = cfu.gridpts_in_shp(self.waterbody_shp,self.domain_obj.cc_ll)
self.wb_cells = cgu.define_mask(self.domain_obj.cc_ll,waterbody_inds[:2])
def run_assignment(self,use_elevation=True, use_ws=True,assign_wb = False,elev_uncertainty=0.):
if use_ws:
self.find_inland_cells()
# Initialize cell_types as all zeros (inactive)
self.cell_types = np.zeros(self.domain_obj.cc[0].shape)
if hasattr(self,'land_cells'):
if isinstance(self.domain_obj.active_cells,np.ndarray):
self.cell_types[self.domain_obj.active_cells & self.land_cells] = cgu.grid_type_dict['active']
self.cell_types[self.domain_obj.active_cells & ~self.land_cells] = cgu.grid_type_dict['nearshore']
else:
self.cell_types[self.land_cells] = cgu.grid_type_dict['active']
if assign_wb:
self.find_waterbody_cells()
# Assign non-coastal, active cells to matching waterbodies
self.cell_types[(self.cell_types==cgu.grid_type_dict['active']) & self.wb_cells] = cgu.grid_type_dict['waterbody']
if use_elevation:
if not use_ws and not assign_wb:
# Need to assign active and water cells by elevation only
with np.errstate(invalid='ignore'):
self.cell_types[(self.domain_obj.elevation>self.domain_obj.sea_level) &\
self.domain_obj.active_cells &\
~np.isnan(self.domain_obj.elevation)] = cgu.grid_type_dict['active']
self.cell_types[(self.domain_obj.elevation<=self.domain_obj.sea_level) &\
self.domain_obj.active_cells &\
~np.isnan(self.domain_obj.elevation)]=cgu.grid_type_dict['nearshore']
else:
if isinstance(self.domain_obj.elevation,np.ndarray):
# Use elevation data to assign land areas that the buffer method missed
with np.errstate(invalid='ignore'):
self.cell_types[(self.domain_obj.elevation>self.domain_obj.sea_level) &\
(self.cell_types==cgu.grid_type_dict['nearshore'])] = cgu.grid_type_dict['active'] # convert to land
self.cell_types[(self.domain_obj.elevation<=self.domain_obj.sea_level+elev_uncertainty) &\
(self.cell_types==cgu.grid_type_dict['waterbody'])]=cgu.grid_type_dict['nearshore'] # convert to marine; for East coast, elev_uncertainty=2 m
# Assign submerged areas that the land polygon covered
self.cell_types[(self.domain_obj.elevation <= self.domain_obj.sea_level) &\
(self.cell_types==cgu.grid_type_dict['active'])] = cgu.grid_type_dict['nearshore']
# Assign any missing areas to inactive
self.cell_types[np.isnan(self.domain_obj.elevation)] = cgu.grid_type_dict['inactive']
|
{"hexsha": "0a4c46ca2b526cd91ef3cd2ae6e0bd9316f29778", "size": 20887, "ext": "py", "lang": "Python", "max_stars_repo_path": "cgw_model/cgw_package_tools.py", "max_stars_repo_name": "kbefus/ca_gw_slr", "max_stars_repo_head_hexsha": "7a793351be5c135ea6b39a8f59d95508fcc00c7b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-29T22:09:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T21:20:21.000Z", "max_issues_repo_path": "cgw_model/cgw_package_tools.py", "max_issues_repo_name": "kbefus/ca_gw_slr", "max_issues_repo_head_hexsha": "7a793351be5c135ea6b39a8f59d95508fcc00c7b", "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": "cgw_model/cgw_package_tools.py", "max_forks_repo_name": "kbefus/ca_gw_slr", "max_forks_repo_head_hexsha": "7a793351be5c135ea6b39a8f59d95508fcc00c7b", "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": 55.110817942, "max_line_length": 166, "alphanum_fraction": 0.5132378992, "include": true, "reason": "import numpy", "num_tokens": 4227}
|
#!/usr/bin/env python
# coding: utf-8
# # PVSC Fig. 3
# In[2]:
import PV_ICE
import numpy as np
import pandas as pd
import os,sys
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 22})
plt.rcParams['figure.figsize'] = (12, 8)
# In[3]:
import os
from pathlib import Path
testfolder = str(Path().resolve().parent.parent / 'PV_ICE' / 'TEMP')
print ("Your simulation will be stored in %s" % testfolder)
# In[18]:
years = list(range(2009,2051))
# In[9]:
USyearly = pd.read_csv(os.path.join(testfolder,'PVSC_USYearly_DataforPlot.csv'))
# In[12]:
USyearly.keys()
# In[19]:
USyearly
# In[21]:
# USyearly.to_csv('PVSC_USYearly_DataforPlot.csv')
plt.rcParams.update({'font.size': 8})
plt.rcParams['figure.figsize'] = (12, 8)
keywords=['VirginStock_', 'Waste_']
SFScenarios = ['Reference.Mod', '95-by-35.Adv', '95-by-35_Elec.Adv_DR']
materials = ['glass', 'silicon', 'silver', 'copper', 'aluminum']
fig, axs = plt.subplots(2,1, figsize=(5, 5), facecolor='w', edgecolor='k')
fig.subplots_adjust(hspace = .6, wspace=.001)
fig.subplots_adjust(hspace = .3, wspace=.001)
axs = axs.ravel()
i = 0
### PLOT 1
# Loop over Keywords
ii=0
keyw = keywords[ii]
# Loop over SF Scenarios
kk=0
obj = SFScenarios[kk]
axs[i].yaxis.grid()
axs[i].axvspan(2000, 2018, facecolor='0.9', alpha=0.5)
axs[i].axvspan(2018, 2050.5, facecolor='yellow', alpha=0.1)
axs[i].plot([],[],color='c', label='glass', linewidth=5)
axs[i].plot([],[],color='k', label='silicon', linewidth=5)
axs[i].plot([],[],color='m', label='silver', linewidth=5)
axs[i].plot([],[],color='r', label='copper', linewidth=5)
axs[i].plot([],[],color='g', label='aluminum', linewidth=5)
axs[i].stackplot(years, USyearly[keyw+materials[0]+'_'+SFScenarios[0]],
USyearly[keyw+materials[1]+'_'+SFScenarios[0]],
USyearly[keyw+materials[2]+'_'+SFScenarios[0]],
USyearly[keyw+materials[3]+'_'+SFScenarios[0]],
USyearly[keyw+materials[4]+'_'+SFScenarios[0]],
colors=['c','k','m','r', 'g'])
#axs[i].ylabel('Mass [Tons]')
axs[i].set_xlim([2010, 2050])
#axs[i].set_title(keyw+ ' ' + obj.name)
#axs[i].legend(materials)
i += 1
### PLOT 2
ii=1
keyw = keywords[ii]
# Loop over SF Scenarios
kk=0
obj = SFScenarios[kk]
axs[i].yaxis.grid()
axs[i].axvspan(2000, 2018, facecolor='0.9', alpha=0.5)
axs[i].axvspan(2018, 2050.5, facecolor='yellow', alpha=0.1)
axs[i].plot([],[],color='c', label='glass', linewidth=5)
axs[i].plot([],[],color='k', label='silicon', linewidth=5)
axs[i].plot([],[],color='m', label='silver', linewidth=5)
axs[i].plot([],[],color='r', label='copper', linewidth=5)
axs[i].plot([],[],color='g', label='aluminum', linewidth=5)
axs[i].stackplot(years, USyearly[keyw+materials[0]+'_'+SFScenarios[0]]*907185,
USyearly[keyw+materials[1]+'_'+SFScenarios[0]]*907185,
USyearly[keyw+materials[2]+'_'+SFScenarios[0]]*907185,
USyearly[keyw+materials[3]+'_'+SFScenarios[0]]*907185,
USyearly[keyw+materials[4]+'_'+SFScenarios[0]]*907185,
colors=['c','k','m','r', 'g'])
#axs[i].ylabel('Mass [Tons]')
axs[i].set_xlim([2010, 2050])
#axs[i].set_title(keyw+ ' ' + obj.name)
#axs[i].legend(materials)
i += 1
axs[0].set_ylim([0, 2e7])
axs[1].set_ylim([0, 5e6])
axs[0].set_title("Virgin Stock Needs")
axs[1].set_title("Waste")
axs[0].set_ylabel('Mass [Tons]')
axs[1].set_ylabel('Mass [Tons]')
axs[1].legend(materials)
fig.savefig(os.path.join(testfolder,'testplot.png'), dpi=600)
|
{"hexsha": "3fbfdd8282749b4f023524f33d91d2e8492e408b", "size": 3887, "ext": "py", "lang": "Python", "max_stars_repo_path": "docs/tutorials/PVSC 2021 Fig. 3.py", "max_stars_repo_name": "kanderso-nrel/PV_ICE", "max_stars_repo_head_hexsha": "c37afce01c2e3c9ff22606abd950488806cdbc30", "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": "docs/tutorials/PVSC 2021 Fig. 3.py", "max_issues_repo_name": "kanderso-nrel/PV_ICE", "max_issues_repo_head_hexsha": "c37afce01c2e3c9ff22606abd950488806cdbc30", "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": "docs/tutorials/PVSC 2021 Fig. 3.py", "max_forks_repo_name": "kanderso-nrel/PV_ICE", "max_forks_repo_head_hexsha": "c37afce01c2e3c9ff22606abd950488806cdbc30", "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": 26.2635135135, "max_line_length": 105, "alphanum_fraction": 0.5729354258, "include": true, "reason": "import numpy", "num_tokens": 1230}
|
F(t) = hcat(1.0)
G(t) = hcat(1.0)
Σ(t) = hcat(9.0)
Tau(t) = hcat(1.0)
μ0 = vcat(0.0)
Tau0 = hcat(100.0)
Y = [
5.22896384735402,
2.059848221254017,
11.77696919584194,
5.721925811242492,
2.647894413351219,
8.833040488128724,
10.112474414603064,
6.208953089526956,
7.483218024927158,
1.1450746725213778,
2.3827281539488214,
2.5154588929528154,
7.6938119335857795,
11.267170019825972,
11.203900809640977,
4.641402249798912,
6.393560809006704,
5.434277785253692,
7.754107613915341,
2.8018519282190573,
8.844915959029999,
6.179788030963477,
8.986422350276268,
8.129873884597485,
10.464689898594969,
7.43846896751153,
6.195006607054435,
7.684383628629019,
6.432819127902091,
9.784040586681458,
3.9386281953008275,
1.0524045623884053,
5.2287370014479535,
3.3793567409786296,
9.109449328047496,
2.4107833351064665,
3.1442786924940815,
8.694980615700167,
9.34957815303634,
1.9899759308134595,
1.7676330607869204,
6.164419273710474,
7.378003270378701,
3.730353213883039,
8.15997706282842,
3.912665621137947,
2.8222087161027987,
7.89108559137954,
2.016432756238303,
-0.7283326731242079,
5.34191426139306,
3.7422889485477566,
6.879539434261266,
1.697715484841611,
5.7492808736295835,
3.4683312150848638,
7.897465524526299,
9.358577329317843,
9.01915967340802,
5.098410508423983,
10.161486865442141,
12.905026331072838,
11.193444598591357,
5.284455585283422,
5.403785641006497,
2.984985087125228,
-0.1108114821742765,
3.8443055205297396,
1.1335781598255243,
7.313228382179326,
1.1291030218984508,
0.8188795644543472,
13.044240581728545,
4.551403331575773,
5.182374381380807,
4.064021944452551,
13.385904690258663,
2.7383489638189253,
4.272321073129483,
1.936449829003382,
7.579915913135302,
6.891186573209264,
5.696714256363617,
2.9401339639559136,
4.045792031292042,
-2.69331630340043,
4.253305831682493,
-6.440609695250053,
1.2224659946193035,
3.6232261847393623,
5.212788618742227,
-0.5932923334934714,
6.036279124314067,
6.862343503023183,
-2.9726591794689665,
4.290653945351619,
-2.420184182764869,
0.6612926367123761,
0.6312700637171165,
-0.041609972691161345,
-0.24839219509891972,
]
Y = hcat(Y)
push_tuple = SMC.push_state_forward(vcat(0.0), G(1), Tau(1), μ0, Tau0)
@test push_tuple[1] ≈ vcat(0.0)
@test push_tuple[2] ≈ Tau(1) + Tau0
ll_tuple = SMC.calc_loglik_t(hcat(0.0), F(1), Σ(1), μ0, Tau0, Y[1, :])
@test size(ll_tuple[1]) == (1, 1)
@test size(ll_tuple[2]) == (1, 1)
@test isa(ll_tuple[3], Float64)
update_tuple = SMC.update_state(F(1), μ0, Tau0, ll_tuple[1], ll_tuple[2])
@test size(update_tuple[1]) == (1, 1)
@test size(update_tuple[2]) == (1, 1)
m, V, loglik_t = SMC.iterate_kalman_filter_mv(
vcat(0.0),
F(1),
vcat(0.0),
G(1),
Σ(1),
Tau(1),
μ0,
Tau0,
@view(Y[1, :])
)
loglik, ms, vs =
SMC.kalman_filter_mv((t) -> hcat(0.0), F, (t) -> hcat(0.0), G, Σ, Tau, μ0, Tau0, Y)
@assert size(ms) == (1, 101)
@assert size(vs) == (1, 1, 101)
@test loglik ≈ -275.019326809115
@inferred SMC.kalman_filter_mv(
(t) -> hcat(0.0),
F,
(t) -> hcat(0.0),
G,
Σ,
Tau,
μ0,
Tau0,
Y,
)
model_nomutate = SMC.KalmanModel(
mutate = false,
F0 = (t) -> hcat(0.0),
F1 = F,
G0 = (t) -> hcat(0.0),
G1 = G,
Σ = Σ,
Tau = Tau,
μ0 = μ0,
Tau0 = Tau0,
)
@inferred model_nomutate(Y)
ll_nomutate, state_nomutate = model_nomutate(Y)
@test ll_nomutate ≈ -275.019326809115
@test size(state_nomutate.ms) == (1, 101)
@test size(state_nomutate.Vs) == (1, 1, 101)
@test all(state_nomutate.ms ≈ ms)
@test all(state_nomutate.Vs ≈ vs)
# Test is a 3-dimensional concatenation
# Should be 3x the log-likelihood above
using LinearAlgebra
F0(t) = [0.0, 0.0, 0.0]
G0(t) = [0.0, 0.0, 0.0]
F(t) = diagm([1.0, 1.0, 1.0])
G(t) = diagm(([1.0, 1.0, 1.0]))
Σ(t) = 9.0 * diagm(([1.0, 1.0, 1.0]))
Tau(t) = diagm([1.0, 1.0, 1.0])
μ0 = vcat(0.0, 0.0, 0.0)
Tau0 = 100.0 * diagm([1.0, 1.0, 1.0])
y = [
5.22896384735402,
2.059848221254017,
11.77696919584194,
5.721925811242492,
2.647894413351219,
8.833040488128724,
10.112474414603064,
6.208953089526956,
7.483218024927158,
1.1450746725213778,
2.3827281539488214,
2.5154588929528154,
7.6938119335857795,
11.267170019825972,
11.203900809640977,
4.641402249798912,
6.393560809006704,
5.434277785253692,
7.754107613915341,
2.8018519282190573,
8.844915959029999,
6.179788030963477,
8.986422350276268,
8.129873884597485,
10.464689898594969,
7.43846896751153,
6.195006607054435,
7.684383628629019,
6.432819127902091,
9.784040586681458,
3.9386281953008275,
1.0524045623884053,
5.2287370014479535,
3.3793567409786296,
9.109449328047496,
2.4107833351064665,
3.1442786924940815,
8.694980615700167,
9.34957815303634,
1.9899759308134595,
1.7676330607869204,
6.164419273710474,
7.378003270378701,
3.730353213883039,
8.15997706282842,
3.912665621137947,
2.8222087161027987,
7.89108559137954,
2.016432756238303,
-0.7283326731242079,
5.34191426139306,
3.7422889485477566,
6.879539434261266,
1.697715484841611,
5.7492808736295835,
3.4683312150848638,
7.897465524526299,
9.358577329317843,
9.01915967340802,
5.098410508423983,
10.161486865442141,
12.905026331072838,
11.193444598591357,
5.284455585283422,
5.403785641006497,
2.984985087125228,
-0.1108114821742765,
3.8443055205297396,
1.1335781598255243,
7.313228382179326,
1.1291030218984508,
0.8188795644543472,
13.044240581728545,
4.551403331575773,
5.182374381380807,
4.064021944452551,
13.385904690258663,
2.7383489638189253,
4.272321073129483,
1.936449829003382,
7.579915913135302,
6.891186573209264,
5.696714256363617,
2.9401339639559136,
4.045792031292042,
-2.69331630340043,
4.253305831682493,
-6.440609695250053,
1.2224659946193035,
3.6232261847393623,
5.212788618742227,
-0.5932923334934714,
6.036279124314067,
6.862343503023183,
-2.9726591794689665,
4.290653945351619,
-2.420184182764869,
0.6612926367123761,
0.6312700637171165,
-0.041609972691161345,
-0.24839219509891972,
];
Y = hcat(y, y, y)
push_tuple = SMC.push_state_forward(G0(1), G(1), Tau(1), μ0, Tau0)
@test push_tuple[1] ≈ vcat(0.0, 0.0, 0.0)
@test push_tuple[2] ≈ Tau(1) + Tau0
ll_tuple = SMC.calc_loglik_t(F0(1), F(1), Σ(1), μ0, Tau0, Y[1, :])
@test size(ll_tuple[1]) == (3,)
@test size(ll_tuple[2]) == (3, 3)
@test isa(ll_tuple[3], Float64)
update_tuple = SMC.update_state(F(1), μ0, Tau0, ll_tuple[1], ll_tuple[2])
@test size(update_tuple[1]) == (3,)
@test size(update_tuple[2]) == (3, 3)
loglik, _, _ = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y)
@test loglik ≈ -275.019326809115 * 3
Tau(t) = [
1.0 0.5 0.0
0.5 1.0 0.0
0.0 0.0 1.0
]
# @test kalman_filter_loglik_mv(vcat(0.0, 0.0, 0.0), F, vcat(0.0, 0.0, 0.0), G, Σ, Tau, μ0, Tau0, Y) ≈ -818.388291668541
## Test filtered distribution
loglik, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y)
@test loglik ≈ -818.388291668541
@test size(ms) == (3, 101)
@test size(Vs) == (3, 3, 101)
Y_missing = Matrix{Union{Missing,Float64}}(deepcopy(Y));
breaks = [2, 5, 18];
Y_missing[breaks, :] .= missing;
loglik, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y_missing)
## The missing likelihood should be the same as if we estimated before/after each break
push_forward(m, v, t) = SMC.push_state_forward(G0(t), G(t), Tau(t), m, v)
ll_pt1, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y[1:1, :])
m_next, V_next = push_forward(push_forward(ms[:, end], Vs[:, :, end], 2)..., 3)
ll_pt2, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, m_next, V_next, Y[3:4, :])
m_next, V_next = push_forward(push_forward(ms[:, end], Vs[:, :, end], 5)..., 6)
ll_pt3, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, m_next, V_next, Y[6:17, :])
m_next, V_next = push_forward(push_forward(ms[:, end], Vs[:, :, end], 18)..., 19)
ll_pt4, ms, Vs = SMC.kalman_filter_mv(F0, F, G0, G, Σ, Tau, m_next, V_next, Y[19:end, :])
@test (ll_pt1 + ll_pt2 + ll_pt3 + ll_pt4) ≈ loglik
## Smoother
ms_smoothed, Vs_smoothed = SMC.kalman_smoother_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y_missing)
@test size(ms_smoothed) == (3, 101)
@test size(Vs_smoothed) == (3, 3, 101)
@inferred SMC.kalman_smoother_mv(F0, F, G0, G, Σ, Tau, μ0, Tau0, Y_missing)
model_nomutate = SMC.KalmanModel(
mutate = false,
F0 = F0,
G0 = G0,
F1 = F,
G1 = G,
Σ = Σ,
Tau = Tau,
μ0 = μ0,
Tau0 = Tau0,
)
state_nomutate = SMC.smooth(model_nomutate, Y_missing);
@test all(ms_smoothed ≈ state_nomutate.ms_smoothed)
@test all(Vs_smoothed ≈ state_nomutate.Vs_smoothed)
@inferred SMC.smooth(model_nomutate, Y_missing);
## Draw posterior pass_threshold
using Random: MersenneTwister
Xs_smoothed =
@inferred SMC.draw_posterior_path(MersenneTwister(23), ms, Vs, G0, G, Σ, Tau, μ0, Tau0)
|
{"hexsha": "766b40b9426e2f01b2b9a57869c42ad1f04b0f44", "size": 9400, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/kalman.jl", "max_stars_repo_name": "dereklhansen/SMC.jl", "max_stars_repo_head_hexsha": "1ef99d957b343f7b3ec28989fb580a2a0b920650", "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/kalman.jl", "max_issues_repo_name": "dereklhansen/SMC.jl", "max_issues_repo_head_hexsha": "1ef99d957b343f7b3ec28989fb580a2a0b920650", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-02-11T21:49:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-16T01:47:34.000Z", "max_forks_repo_path": "test/kalman.jl", "max_forks_repo_name": "dereklhansen/SMC.jl", "max_forks_repo_head_hexsha": "1ef99d957b343f7b3ec28989fb580a2a0b920650", "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": 25.3369272237, "max_line_length": 120, "alphanum_fraction": 0.6543617021, "num_tokens": 4121}
|
# Copyright 2020 LMNT, 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.
# ==============================================================================
import time
import numpy as np
import os
import torch
import torchaudio
from argparse import ArgumentParser
from wavegrad.params import AttrDict, params as base_params
from wavegrad.model import WaveGrad
models = {}
def load_model(model_dir, params=None, device=torch.device('cuda')):
# Lazy load model.
if not model_dir in models:
if os.path.exists(f'{model_dir}/weights.pt'):
checkpoint = torch.load(f'{model_dir}/weights.pt')
else:
checkpoint = torch.load(model_dir)
model = WaveGrad(AttrDict(base_params)).to(device)
state_dict = checkpoint['model']
new_state_dict = {}
for key in state_dict:
new_state_dict[key.replace("module.", "")] = state_dict[key]
model.load_state_dict(new_state_dict)
model.eval()
models[model_dir] = model
model = models[model_dir]
model.params.override(params)
return model
def predict(spectrogram, model, device=torch.device('cuda')):
with torch.no_grad():
beta = np.array(model.params.noise_schedule)
alpha = 1 - beta
alpha_cum = np.cumprod(alpha)
# Expand rank 2 tensors by adding a batch dimension.
if len(spectrogram.shape) == 2:
spectrogram = spectrogram.unsqueeze(0)
spectrogram = spectrogram.to(device)
audio = torch.randn(spectrogram.shape[0], model.params.hop_length * spectrogram.shape[-1], device=device)
noise_scale = torch.from_numpy(alpha_cum ** 0.5).float().unsqueeze(1).to(device)
for n in range(len(alpha) - 1, -1, -1):
c1 = 1 / alpha[n] ** 0.5
c2 = (1 - alpha[n]) / (1 - alpha_cum[n]) ** 0.5
audio = c1 * (audio - c2 * model(audio, spectrogram, noise_scale[n]).squeeze(1))
if n > 0:
noise = torch.randn_like(audio)
sigma = ((1.0 - alpha_cum[n - 1]) / (1.0 - alpha_cum[n]) * beta[n]) ** 0.5
audio += sigma * noise
audio = torch.clamp(audio, -1.0, 1.0)
return audio, model.params.sample_rate
def main(args):
# spectrogram = torch.from_numpy(np.load(args.spectrogram_path))
params = {}
if args.noise_schedule:
params['noise_schedule'] = torch.from_numpy(np.load(args.noise_schedule))
start_time = time.time()
model = load_model(model_dir=args.model_dir, params=params)
if not os.path.exists(args.output_path):
os.mkdir(args.output_path)
time_consuming = time.time() - start_time
print(" > Load model, time consuming {}s".format(round(time_consuming, 2)))
mels = os.listdir(args.spectrogram_path)
for mel_file in mels:
if not os.path.isdir(mel_file) and mel_file[-2:] == "pt":
start_time = time.time()
print(" > Start inferencing sentence {} . ".format(mel_file))
spectrogram = torch.tensor(torch.load(os.path.join(args.spectrogram_path, mel_file)))
audio, sr = predict(spectrogram, model)
wav_name = os.path.join(args.output_path, mel_file[:-7] + "_wg.wav")
torchaudio.save(wav_name, audio.cpu(), sample_rate=sr)
time_consuming = time.time() - start_time
print(" > Complete, time consuming {}s".format(round(time_consuming, 2)))
if __name__ == '__main__':
parser = ArgumentParser(description='runs inference on a spectrogram file generated by wavegrad.preprocess')
parser.add_argument('model_dir',
help='directory containing a trained model (or full path to weights.pt file)')
parser.add_argument('spectrogram_path',
help='path to a spectrogram file generated by wavegrad.preprocess')
parser.add_argument('--noise-schedule', '-n', default=None,
help='path to a custom noise schedule file generated by wavegrad.noise_schedule')
parser.add_argument('--output_path', '-o', default='output.wav',
help='output file name')
main(parser.parse_args())
|
{"hexsha": "370fe591192f39e82e7e279bef485f23f1a62b26", "size": 4293, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/wavegrad/inference.py", "max_stars_repo_name": "wjqkkky/wavegrad", "max_stars_repo_head_hexsha": "3fe9959f542f90a66dfdf0cfa769504450f9ec53", "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/wavegrad/inference.py", "max_issues_repo_name": "wjqkkky/wavegrad", "max_issues_repo_head_hexsha": "3fe9959f542f90a66dfdf0cfa769504450f9ec53", "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/wavegrad/inference.py", "max_forks_repo_name": "wjqkkky/wavegrad", "max_forks_repo_head_hexsha": "3fe9959f542f90a66dfdf0cfa769504450f9ec53", "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.3303571429, "max_line_length": 109, "alphanum_fraction": 0.6962497088, "include": true, "reason": "import numpy", "num_tokens": 1069}
|
# coding=utf-8
# Copyleft 2019 project LXRT.
import argparse
import random
import numpy as np
import torch
def get_optimizer(optim):
# Bind the optimizer
if optim == 'rms':
print("Optimizer: Using RMSProp")
optimizer = torch.optim.RMSprop
elif optim == 'adam':
print("Optimizer: Using Adam")
optimizer = torch.optim.Adam
elif optim == 'adamax':
print("Optimizer: Using Adamax")
optimizer = torch.optim.Adamax
elif optim == 'sgd':
print("Optimizer: sgd")
optimizer = torch.optim.SGD
elif 'bert' in optim:
optimizer = 'bert' # The bert optimizer will be bind later.
else:
assert False, "Please add your optimizer %s in the list." % optim
return optimizer
def parse_args():
parser = argparse.ArgumentParser()
# Data Params. These are all required.
parser.add_argument("train_json",
help='comma seperated training jsons '
'e.g., "train1.json,train2.json" or "train.json". '
'For None, use -1.')
parser.add_argument("valid_json",
help='comma seperated validation jsons. For none, use -1.')
parser.add_argument("test_json",
help='comma seperated testing jsons. For none, use -1.')
parser.add_argument("image_feat_tsv", default=None,
help='comma seperated tsv for files containing extracted '
'image features. '
'e.g., "data/feats1.tsv,data/feats2.tsv" or "vg_gqa_obj36.tsv"')
parser.add_argument('output_dir', type=str, default='output')
# classifier arguments
parser.add_argument("--ans2label", default=None,
help='json dictionary mapping from strings to ints. '
'the strings are the names of the classes, and the '
'ints are their indices.')
parser.add_argument("--use_logits", default=0,
type=int,
help='Should we use the logits in the data file?')
# Training Hyper-parameters
parser.add_argument('--optim', default='bert')
parser.add_argument('--optimize_metric', default='acc',
help='which metric to optimize over the validation set?')
# set to gqa defaults
parser.add_argument('--batchSize', dest='batch_size', type=int, default=32)
parser.add_argument('--lr', type=float, default=1e-5)
parser.add_argument('--epochs', type=int, default=5)
parser.add_argument('--dropout', type=float, default=0.1)
parser.add_argument('--seed', type=int, default=9595, help='random seed')
# Debugging
parser.add_argument("--fast", action='store_const', default=False, const=True)
parser.add_argument("--tiny", action='store_const', default=False, const=True)
parser.add_argument("--tqdm", action='store_const', default=True, const=True)
# Model Loading
parser.add_argument('--load_finetune', type=str, default=None,
help='Load the finetuned model for testing.')
parser.add_argument('--loadLXMERT', dest='load_lxmert', type=str, default=None,
help='Load the pre-trained LXMERT model.')
# LXRT Model Config
# Note: LXRT = L, X, R (three encoders), Transformer
parser.add_argument("--llayers", default=9, type=int, help='Number of Language layers')
parser.add_argument("--xlayers", default=5, type=int, help='Number of CROSS-modality layers.')
parser.add_argument("--rlayers", default=5, type=int, help='Number of object Relationship layers.')
parser.add_argument("--model_type", default='full', type=str,
help='What LXMERT model type should be used?')
# Training configuration
parser.add_argument("--multiGPU", action='store_const', default=False, const=True)
parser.add_argument("--numWorkers", dest='num_workers', default=0)
# Parse the arguments.
args = parser.parse_args()
# we need to set these, but we dont want to make them mutable
args.from_scratch = False
if args.load_lxmert and '_LXRT.pth' in args.load_lxmert:
args.load_lxmert = args.load_lxmert.replace('_LXRT.pth', '')
if args.load_finetune and '.pth' in args.load_finetune:
args.load_finetune = args.load_finetune.replace('.pth', '')
# Bind optimizer class.
args.optimizer = get_optimizer(args.optim)
# Set seeds
torch.manual_seed(args.seed)
random.seed(args.seed)
np.random.seed(args.seed)
return args
args = parse_args()
|
{"hexsha": "f8b62f2cceb803ed15026447c8d4acaec58ca8a3", "size": 4654, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/finetune_param.py", "max_stars_repo_name": "jmhessel/lxmert", "max_stars_repo_head_hexsha": "4ee7b1a1ec652eb163572e3ae8189ea8b93c957e", "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/finetune_param.py", "max_issues_repo_name": "jmhessel/lxmert", "max_issues_repo_head_hexsha": "4ee7b1a1ec652eb163572e3ae8189ea8b93c957e", "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/finetune_param.py", "max_forks_repo_name": "jmhessel/lxmert", "max_forks_repo_head_hexsha": "4ee7b1a1ec652eb163572e3ae8189ea8b93c957e", "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.1092436975, "max_line_length": 103, "alphanum_fraction": 0.6254834551, "include": true, "reason": "import numpy", "num_tokens": 1062}
|
import numpy as np
def _get_covered_instances(rule, fuzzy_dataset, threshold=0.001):
first_feat = list(fuzzy_dataset.keys())[0]
first_val = list(fuzzy_dataset[first_feat].keys())[0]
ds_len = len(fuzzy_dataset[first_feat][first_val])
mu = np.ones(ds_len)
for feat, val in rule.antecedent:
mu = np.minimum(mu, fuzzy_dataset[feat][val])
return (mu > threshold, ds_len)
def _get_fuzzy_coverage(rules, fuzzy_dataset, threshold=0.001):
covered_instances, ds_len = _get_covered_instances(rules[0], fuzzy_dataset, threshold)
for rule in rules:
n_covered_instance, _ = _get_covered_instances(rule, fuzzy_dataset, threshold)
covered_instances = covered_instances | n_covered_instance
return covered_instances, ds_len
def coverage(rules, fuzzy_dataset, threshold=0.001):
covered_instances, ds_len = _get_fuzzy_coverage(rules, fuzzy_dataset, threshold)
return np.sum(covered_instances) / ds_len
def precision(rules, fuzzy_dataset, y, threshold=0.001):
covered_instances, ds_len = _get_fuzzy_coverage(rules, fuzzy_dataset, threshold)
# All rules have the same consequent
return np.sum((covered_instances) & (y == rules[0].consequent)) / np.sum(covered_instances)
def fidelity(y, y_local):
return np.sum(y == y_local) / len(y)
def rule_fidelity(y, y_local, fuzzy_dataset, rules, threshold=0.001):
covered_instances, ds_len = _get_fuzzy_coverage(rules, fuzzy_dataset, threshold)
return np.sum(y[covered_instances] == y_local[covered_instances]) / np.sum(covered_instances)
|
{"hexsha": "fc3ede82f820852c47f8a6d94496ebf6960a8f31", "size": 1563, "ext": "py", "lang": "Python", "max_stars_repo_path": "teacher/metrics/rule.py", "max_stars_repo_name": "Kaysera/fuzzy-lore", "max_stars_repo_head_hexsha": "128131e0f41f480d509b63c5e75d0ce58f07bae4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-09T16:54:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T13:28:31.000Z", "max_issues_repo_path": "teacher/metrics/rule.py", "max_issues_repo_name": "Kaysera/fuzzy-lore", "max_issues_repo_head_hexsha": "128131e0f41f480d509b63c5e75d0ce58f07bae4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-17T16:30:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T17:54:08.000Z", "max_forks_repo_path": "teacher/metrics/rule.py", "max_forks_repo_name": "Kaysera/fuzzy-lore", "max_forks_repo_head_hexsha": "128131e0f41f480d509b63c5e75d0ce58f07bae4", "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.1219512195, "max_line_length": 97, "alphanum_fraction": 0.7440818938, "include": true, "reason": "import numpy", "num_tokens": 386}
|
#ifndef BLACKJACK_HPP
#define BLACKJACK_HPP
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <random>
#include <ctime>
#include <chrono>
#include "../src/relearn.hpp"
#if USING_BOOST_SERIALIZATION
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>
#endif
/**
* The basic Blackjack header structures:
* - card
* - hand
* - player
* - house
* - client
*
* All that is minimally needed in order to
* create the Blackjack example
*/
// a simple card structure
struct card
{
std::string name;
std::string label;
std::vector<unsigned int> value;
void print() const
{
std::cout << name << " "
<< label << " ";
}
bool operator==(const card & rhs) const
{
return this->name == rhs.name &&
this->label == rhs.label &&
this->value == rhs.value;
}
#if USING_BOOST_SERIALIZATION
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & name;
ar & label;
ar & value;
}
#endif
};
// a 52 playing card constant vector with unicode symbols :-D
const std::deque<card> cards {
{"Ace", "♠", {1, 11}}, {"Ace", "♥", {1, 11}}, {"Ace", "♦", {1, 11}}, {"Ace", "♣", {1, 11}},
{"Two", "♠", {2}}, {"Two", "♥", {2}}, {"Two", "♦", {2}}, {"Two", "♣", {2}},
{"Three","♠", {3}}, {"Three","♥", {3}}, {"Three","♦", {3}}, {"Three","♣", {3}},
{"Four", "♠", {4}}, {"Four", "♥", {4}}, {"Four", "♦", {4}}, {"Four", "♣", {4}},
{"Five", "♠", {5}}, {"Five", "♥", {5}}, {"Five", "♦", {5}}, {"Five", "♣", {5}},
{"Six", "♠", {6}}, {"Six", "♥", {6}}, {"Six", "♦", {6}}, {"Six", "♣", {6}},
{"Seven","♠", {7}}, {"Seven","♥", {7}}, {"Seven","♦", {7}}, {"Seven","♣", {7}},
{"Eight","♠", {8}}, {"Eight","♥", {8}}, {"Eight","♦", {8}}, {"Eight","♣", {8}},
{"Nine", "♠", {9}}, {"Nine", "♥", {9}}, {"Nine", "♦", {9}}, {"Nine", "♣", {9}},
{"Ten", "♠", {10}}, {"Ten", "♥", {10}}, {"Ten", "♦", {10}}, {"Ten", "♣", {10}},
{"Jack", "♠", {10}}, {"Jack", "♥", {10}}, {"Jack", "♦", {10}}, {"Jack", "♣", {10}},
{"Queen","♠", {10}}, {"Queen","♥", {10}}, {"Queen","♦", {10}}, {"Queen","♣", {10}},
{"King", "♠", {10}}, {"King", "♥", {10}}, {"King", "♦", {10}}, {"King", "♣", {10}}
};
bool card_compare(const card & lhs, const card & rhs)
{
return lhs.name == rhs.name &&
lhs.label == rhs.label &&
lhs.value == rhs.value;
}
// hand is the currently held cards
struct hand
{
hand() = default;
hand(const hand &) = default;
// calculate value of hand - use max value of hand
unsigned int max_value() const
{
unsigned int result = 0;
for (const card & k : cards) {
result += *std::max_element(k.value.begin(), k.value.end());
}
return result;
}
// calculate value of hand - use min value (e.g., when hold an Ace)
unsigned int min_value() const
{
unsigned int result = 0;
for (const card & k : cards) {
result += *std::min_element(k.value.begin(), k.value.end());
}
return result;
}
// print on stdout
void print() const
{
for (card k : cards) {
k.print();
}
std::cout << std::endl;
}
// add new card
void insert(card arg)
{
cards.push_back(arg);
}
// clear hand
void clear()
{
cards.clear();
}
// hand is blackjack
bool blackjack() const
{
std::vector<card> twoblacks = {{"Ace", "♠", {1, 11}},
{"Ace", "♣", {1, 11}}};
return std::is_permutation(twoblacks.begin(), twoblacks.end(),
cards.begin(), card_compare);
}
// hash this hand for relearn
std::size_t hash() const
{
std::size_t seed = 0;
for (auto & k : cards) {
for (auto & v : k.value) {
relearn::hash_combine(seed, v);
}
}
return seed;
}
bool operator==(const hand & rhs) const
{
return this->cards == rhs.cards;
}
private:
std::vector<card> cards;
#if USING_BOOST_SERIALIZATION
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & cards;
}
#endif
};
namespace std
{
template <> struct hash<hand>
{
std::size_t operator()(hand const& arg) const
{
return arg.hash();
}
};
}
/// compare hands (return true for lhs wins)
bool hand_compare(const hand & lhs, const hand & rhs)
{
if (lhs.blackjack()) return true;
else if (rhs.blackjack()) return false;
if (lhs.min_value() > 21) return false;
else if (rhs.min_value() > 21 && lhs.min_value() < 21) return true;
if (lhs.max_value() > rhs.max_value()) return true;
else return false;
}
// Base class for all players
struct player : public hand
{
virtual bool draw()
{
return false;
}
};
// House/dealer only uses simple rules to draw or stay
struct house : public player
{
house(std::deque<card> cards, std::mt19937 & prng)
: cards(cards), gen(prng)
{}
// draw a card based on current hand - house always draws until 17 is reached
bool draw()
{
return (min_value() < 17 || max_value() < 17);
}
// deal a card using current deck - or reset and deal
card deal()
{
if (deck.size() > 0) {
auto obj = deck.front();
deck.pop_front();
return obj;
}
else {
reset_deck();
return deal();
}
}
// shuffle cards randomly
void reset_deck()
{
deck = cards;
std::shuffle(std::begin(deck), std::end(deck), gen);
}
private:
std::deque<card> deck;
const std::deque<card> cards;
std::mt19937 gen;
};
//
// our learning adaptive player
struct client : public player
{
// decide on drawing or staying
bool draw(std::mt19937 & prng,
relearn::state<hand> s_t,
relearn::policy<relearn::state<hand>,
relearn::action<bool>> & map)
{
auto pair = map.best(s_t);
std::uniform_real_distribution<float> dist(0, 1);
// there exists a "best action" and it is positive
if (pair.first && pair.second > 0) {
policy_actions++;
return pair.first->trait();
}
// there does not exist a "best action"
else {
random_actions++;
return (dist(prng) > 0.5 ? true : false);
}
}
// return a state by casting self to base class
relearn::state<hand> state() const
{
return relearn::state<hand>(*this);
}
void reset()
{
random_actions = 0;
policy_actions = 0;
}
float random_actions = 0;
float policy_actions = 0;
};
#endif
|
{"hexsha": "6ed5e92a812440221c51c9f55da324ed3f748563", "size": 7195, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "examples/blackjack_header.hpp", "max_stars_repo_name": "richelbilderbeek/relearn", "max_stars_repo_head_hexsha": "d31a2859d7621eb4796ea0c027765ad9f450a798", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 27.0, "max_stars_repo_stars_event_min_datetime": "2017-06-29T14:31:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T09:50:22.000Z", "max_issues_repo_path": "examples/blackjack_header.hpp", "max_issues_repo_name": "draryan/relearn", "max_issues_repo_head_hexsha": "4bf4c41618a4e5d61bb110d5de856b9140d4f537", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3.0, "max_issues_repo_issues_event_min_datetime": "2017-09-22T15:13:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-24T01:56:24.000Z", "max_forks_repo_path": "examples/blackjack_header.hpp", "max_forks_repo_name": "draryan/relearn", "max_forks_repo_head_hexsha": "4bf4c41618a4e5d61bb110d5de856b9140d4f537", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2017-09-18T23:01:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T10:31:09.000Z", "avg_line_length": 25.6049822064, "max_line_length": 99, "alphanum_fraction": 0.4907574705, "num_tokens": 2037}
|
import argparse
import os
import numpy as np
# DNN Libraries
from torch.utils.data import DataLoader
# Turboflow Libraries
from turboflow.dataloaders import Turb2DDataset
from turboflow.models.phyrff_hard import DivFreeRFFNet
from turboflow.utils.torch_utils import get_device
def get_path_and_prepare_folder():
root_dir = os.path.dirname(os.path.realpath(__file__))
return root_dir
# def get_args():
# # these are project-wide arguments
# parser = argparse.ArgumentParser(prog='main.py', add_help=True)
# # add data specific arguments
# args = parser.parse_args()
# arg_groups={}
# for group in parser._action_groups:
# group_dict={a.dest:getattr(args,a.dest,None) for a in group._group_actions}
# arg_groups[group.title]=argparse.Namespace(**group_dict)
# return arg_groups
if __name__ == '__main__':
# args = get_args()
# PREPARE FOLDER
root_dir = get_path_and_prepare_folder()
# DATA
data_dir = '/home/dicarlo_d/Documents/Code/TurboSuperResultion/.cache/Turb2D.hdf5'
trainset = Turb2DDataset(data_dir, ds=4, time_idx=42)
trainloader = DataLoader(trainset, batch_size=100000, num_workers=16)
# MODEL
model = DivFreeRFFNet('DivFreeRFFNet',
dim_mpl_layers=[2]+3*[256]+[1],
last_activation_fun_name='tanh',
do_rff=True,f_nfeatures=256,f_scale=10,
smallest_increment=0.00784314,n_increments=3,n_centers=30,
lam_reg=0, lam_sfn=0, lam_pde=1,
verbose=True
)
# TRAIN
device = get_device()
model.to(device)
model.fit(trainloader, epochs=1000)
|
{"hexsha": "ff32cfcd663803b1b4457cb653a0f5a0246fa037", "size": 1621, "ext": "py", "lang": "Python", "max_stars_repo_path": "recipes/turbo2D/single_images/main_nopl.py", "max_stars_repo_name": "Chutlhu/TurboSuperResultion", "max_stars_repo_head_hexsha": "6ef6db8669270681a07e028cf3fd17a747b3ba5d", "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": "recipes/turbo2D/single_images/main_nopl.py", "max_issues_repo_name": "Chutlhu/TurboSuperResultion", "max_issues_repo_head_hexsha": "6ef6db8669270681a07e028cf3fd17a747b3ba5d", "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": "recipes/turbo2D/single_images/main_nopl.py", "max_forks_repo_name": "Chutlhu/TurboSuperResultion", "max_forks_repo_head_hexsha": "6ef6db8669270681a07e028cf3fd17a747b3ba5d", "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.9482758621, "max_line_length": 86, "alphanum_fraction": 0.7014188772, "include": true, "reason": "import numpy", "num_tokens": 435}
|
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.4.2
# kernelspec:
# display_name: Python [conda env:PROJ_irox_oer] *
# language: python
# name: conda-env-PROJ_irox_oer-py
# ---
# # Analyse magmoms of converged slabs for the purpose of setting initial magmoms in the future
# ---
# # Import Modules
# +
import os
print(os.getcwd())
import sys
import numpy as np
import pandas as pd
# #########################################################
from methods import get_df_atoms_sorted_ind
from methods import get_df_jobs
from methods import get_df_jobs_anal
# -
# # Read Data
# +
df_atoms_sorted_ind = get_df_atoms_sorted_ind()
df_jobs = get_df_jobs()
df_jobs_anal = get_df_jobs_anal()
# + active=""
#
#
# -
df_jobs_anal_i = df_jobs_anal[df_jobs_anal.job_completely_done == True]
# +
df_index_i = df_jobs_anal_i.index.to_frame()
df_index_i = df_index_i[df_index_i.ads == "oh"]
df_index_i.index
# +
df_atoms_sorted_ind_i = df_atoms_sorted_ind.loc[
df_index_i.index
]
# print(10 * "TEMP | ")
# df_atoms_sorted_ind_i = df_atoms_sorted_ind_i.iloc[[0]]
# #########################################################
data_dict_list = []
# #########################################################
for name_i, row_i in df_atoms_sorted_ind_i.iterrows():
# #####################################################
was_sorted_i = row_i.was_sorted
magmoms_sorted_good_i = row_i.magmoms_sorted_good
atoms_sorted_good_i = row_i.atoms_sorted_good
# #####################################################
if atoms_sorted_good_i is not None:
# print(name_i)
if magmoms_sorted_good_i is None:
magmoms_i = atoms_sorted_good_i.get_magnetic_moments()
else:
magmoms_i = magmoms_sorted_good_i
atoms = atoms_sorted_good_i
# Positions
z_positions = atoms.positions[:, 2]
z_max = z_positions.max()
for atom_j in atoms:
# #################################################
data_dict_j = dict()
# #################################################
atom_index_j = atom_j.index
symbol_j = atom_j.symbol
# #################################################
magmom_j = magmoms_i[atom_index_j]
z_pos_j = atom_j.position[2]
dist_from_top = z_max - z_pos_j
# #################################################
data_dict_j["symbol"] = symbol_j
data_dict_j["magmom"] = magmom_j
data_dict_j["dist_from_top"] = dist_from_top
# data_dict_j[""] =
# #################################################
data_dict_list.append(data_dict_j)
# #################################################
# #########################################################
df = pd.DataFrame(data_dict_list)
df.head()
# -
df["magmom_abs"] = np.abs(df.magmom)
df = df[df.dist_from_top < 4]
# +
# assert False
# -
import plotly.express as px
fig = px.histogram(
df,
x="magmom_abs",
color="symbol",
marginal="rug", # can be `box`, `violin`
nbins=100,
)
fig.show()
|
{"hexsha": "2760d022f732381903a25f15812c5f7b6919ea27", "size": 3323, "ext": "py", "lang": "Python", "max_stars_repo_path": "dft_workflow/job_analysis/compare_magmoms/anal_magmoms.py", "max_stars_repo_name": "raulf2012/PROJ_IrOx_OER", "max_stars_repo_head_hexsha": "56883d6f5b62e67703fe40899e2e68b3f5de143b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-21T04:43:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T04:43:47.000Z", "max_issues_repo_path": "dft_workflow/job_analysis/compare_magmoms/anal_magmoms.py", "max_issues_repo_name": "raulf2012/PROJ_IrOx_OER", "max_issues_repo_head_hexsha": "56883d6f5b62e67703fe40899e2e68b3f5de143b", "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": "dft_workflow/job_analysis/compare_magmoms/anal_magmoms.py", "max_forks_repo_name": "raulf2012/PROJ_IrOx_OER", "max_forks_repo_head_hexsha": "56883d6f5b62e67703fe40899e2e68b3f5de143b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-13T12:55:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-13T12:55:02.000Z", "avg_line_length": 24.0797101449, "max_line_length": 95, "alphanum_fraction": 0.509780319, "include": true, "reason": "import numpy", "num_tokens": 767}
|
[STATEMENT]
lemma length_mtf[simp]: "size (mtf x xs) = size xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. length (mtf x xs) = length xs
[PROOF STEP]
by (auto simp add: mtf_def min_def) (metis index_less_size_conv leD)
|
{"llama_tokens": 95, "file": "List_Update_Move_to_Front", "length": 1}
|
from fb import Viewer
import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
import pycuda.gpuarray as gpuarray
from pycuda.compiler import SourceModule
from PIL import Image
N = 200
display_size = (900, 900)
cell_state = np.zeros((N, N), dtype=np.int32)
cell_state[0, N//2] = 0x80000001
mod = SourceModule('''
__global__ void cell_step(int *A, int rule, int step, int n)
{
const int idx = threadIdx.x + 1;
const int is_active = A[(step-1)*n + idx] & 0x80000000;
if(is_active == 0) {
A[step*n + idx] = A[(step-1)*n + idx];
return;
}
const int a = A[(step-1)*n + idx - 1] & 1;
const int b = A[(step-1)*n + idx] & 1;
const int c = A[(step-1)*n + idx + 1] & 1;
const int current_pattern = (a<<2) | (b<<1) | c;
const int p = ((rule & 0x00ff) & (1 << current_pattern)) >> current_pattern;
const int new_active = (((rule & 0xff00)>>8) & (1 << current_pattern)) >> current_pattern;
if(new_active == 0) {
A[step * n + idx + 1] |= 0x80000000;
} else {
A[step * n + idx - 1] |= 0x80000000;
}
A[step * n + idx] = p;
}
''')
func = mod.get_function('cell_step')
step = 0
rule = 0b1100011000100011
rule = 0b0011100100100011
def update():
global step, rule
step += 1
if step == N:
step = 1
func(cuda.InOut(cell_state), np.int32(rule), np.int32(step), np.int32(N), block=(N-1, 1, 1))
image = cell_state * rule
image = np.array(Image.fromarray(image).resize(display_size, Image.NEAREST))
return image
viewer = Viewer(update, display_size)
viewer.start()
|
{"hexsha": "df6dcaeea4449e5b71fd3dca174a7bee7c8dee1d", "size": 1593, "ext": "py", "lang": "Python", "max_stars_repo_path": "02_mobile_automata.py", "max_stars_repo_name": "medakk/cellular-automata", "max_stars_repo_head_hexsha": "d9f4a43cc73992e143168b0f16498707e4f001f0", "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": "02_mobile_automata.py", "max_issues_repo_name": "medakk/cellular-automata", "max_issues_repo_head_hexsha": "d9f4a43cc73992e143168b0f16498707e4f001f0", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-06-08T21:20:18.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-13T02:34:25.000Z", "max_forks_repo_path": "02_mobile_automata.py", "max_forks_repo_name": "medakk/cellular-automata", "max_forks_repo_head_hexsha": "d9f4a43cc73992e143168b0f16498707e4f001f0", "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.9473684211, "max_line_length": 96, "alphanum_fraction": 0.6095417451, "include": true, "reason": "import numpy,import pycuda,from pycuda", "num_tokens": 541}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.